#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int n, m;
long long kmin, kmax;
long long solve(int n) {
	return (long long)n * (n - 1) / 2;
}
int main() {
	scanf("%d%d", &n, &m);
	kmax = solve(n - m + 1);

	kmin = (m - (n % m)) * solve(n / m) +
			(n % m) * solve(n / m + 1);

	printf("%I64d %I64d\n", kmin, kmax);

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,m;
    cin>>n>>m;

    ll mx,mn;

    ll p=(n-m)+1;
    mx=p*(p-1)/2;
    //cout<<mx<<endl;

    ll x=n/m;

    if(n%m==0){
        mn=m*x*(x-1)/2;
        //cout<<m*x*(x-1)/2<<endl;
    }

    else{
        ll s=n-x*m;
        ll q=m-s;
        mn=q*x*(x-1)/2;
        mn+=s*(x*(x+1))/2;
        //cout<<mn<<endl;
    }

    cout<<mn<<" "<<mx<<endl;

}

#include <iostream>

using namespace std;

unsigned long long int n, m;
unsigned long long int kmin, kmax;

inline unsigned long long int pair_count(unsigned long long int num)
{
    unsigned long long int c = num;
    c *= (num - 1);
    c /= 2;
    return c;
}

int main()
{
    cin >> n >> m;

    kmin = pair_count(n / m) * (m - (n % m)) + pair_count(n / m + 1) * (n % m);
    kmax = pair_count(1) * (m - 1) + pair_count(n - m + 1);

    cout << kmin << " " << kmax << "\n";

    return 0;
}

#include<bits/stdc++.h>
#define ull unsigned long long int
using namespace std;

ull combi(ull num)
{
    ull ans;
    ans=(num*(num-1))/2;
    return ans;
}
int main()
{
    ull i,j,rem,ans,a,b,mx,mi,sum,res,div;
    cin>>a>>b;
    res=a-(b-1);
    mx=(res*(res-1))/2;

    if(b==1)cout<<mx<<" "<<mx<<endl;
    else
    {

        if((a/2)<b)
        {
            ans=0;
            div=a/2;
            if(a%2)ans=1;
            res=b-div;
            mi=div-res+ans;
        }
        else if((a/2)==b)mi=b;
        else
        {
            res= a/b;
            if(res*b==a) mi=combi(res)*b;

            else
            {

                sum=0;
                rem=a-(res*b);
                ans=b-rem;
               // cout<<ans<<" "<<res*b<<" "<<a<<endl;
                sum=sum+combi(res)*ans;
                sum+=combi(res+1)*rem;
                mi=sum;
            }
        }

     cout<<mi<<" "<<mx<<endl;
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <stack>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;

	long long Max = n - (m - 1);

	Max = (Max*(Max - 1)) / 2;

  long long	Min = 0;

  long long total = (n / m);

  n -= (n / m)*m;

  int numb = 0;

  while (n>0)
  {
	  if (n >= m)
	  {
		  total += m;
		  n -= m;
	  }

	  else
	  {
		  numb += 1;
		  --n;
	  }
  }

  Min = (total *(total - 1) / 2)*(m - numb);

  ++total;
  long long k = (total*(total - 1) / 2)*numb;

  Min += k;

  cout << Min << " " << Max << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long ncr(long long n);

int main()
{
    int remainder;
    long long kmax,kmin=0,n,m;
    scanf("%lld %lld",&n,&m);
    kmax=ncr(n-m+1);
    if(n%m==0)
    {
        kmin=m*ncr(n/m);
    }
    else
    {
        remainder=n-(n/m)*m;
        kmin+=(m-remainder)*ncr(n/m);
        kmin+=(remainder)*ncr(n/m+1);
    }
    printf("%lld %lld",kmin,kmax);
    return 0;
}
long long ncr(long long n)
{
    long long k;
    k=((n)*(n-1))/2;
    return k;
}

#include <cstdio>

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  long long k = n / m;
  long long r = n % m;
  long long d = n - m + 1;

  printf("%I64d %I64d\n", k * (k - 1) / 2 * (m - r) + k * (k + 1) / 2 * r, d * (d - 1) / 2);
}

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<fstream>
#include<sstream>
#include<vector>
#include<set>
#include<deque>
#include<cstring>
#include<queue>
#include<stdio.h>
#include<set>
#include<stack>
#include<numeric>
#include<map>
#include<cstdio>
#include<bitset>
#include<array>
using namespace std;

ifstream f1;
ofstream f2;

long long calCom(long long n) {
	if (n == 1 ) {
		return 0;
	}
	return (n * (n - 1)) / 2;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	f1.open("INP.txt");
	f2.open("OUT.txt");
	long long a, b;
	cin >> a >> b;
	long long mi = 0, ma = 0;
	mi = (b - a % b) * (calCom(a / b)) + (a % b) * (calCom(a / b + 1));
	ma = calCom(a - (b - 1));
	cout << mi << " " << ma << endl;
	//system("pause");
	return 0;
}

#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include <stdio.h>
#include <math.h>
#include <string>
#include <stack>
using namespace std;

int main()
{
   /* string name1,name2;
    cin>>name1>>name2;
    long long int p1=0,p2=0,co1=0,co2=0;
    for (int a=0; a<name1.size(); a++)
    {
        if (name1[a]!='0')
        {
            p1=a;
            break;
        }
    }
    for (int a=0; a<name2.size(); a++)
    {
        if (name2[a]!='0')
        {
            p2=a;
            break;
        }
    }
    for (int a=0; a<name1.size(); a++)
    {
        if (name1[a]=='0')
        {
            co1++;
        }
    }
    for (int a=0; a<name2.size(); a++)
    {
        if (name2[a]=='0')
        {
            co2++;
        }
    }
    if ((co1==name1.size())&&(co2==name2.size()))
    {
        cout<<'=';
        return 0;
    }
    long long int s2=name2.size()-p2,s1=name1.size()-p1;
    long long int s3=max(s1,s2);
    if (s1>s2)
    {
        cout<<'>';
    }
    else if (s1<s2)
    {
        cout<<'<';
    }
    else
    {
        for (int a=0; a<s3; a++)
        {
            if (name1[p1]>name2[p2])
            {
                cout<<'>';
                return 0;
            }
            else if (name1[p1]<name2[p2])
            {
                cout<<'<';
                return 0;
            }
            p1++;
            p2++;
        }
        cout<<'=';
    }*/
   /* long long int n,m,co=0,nu=0;
    cin>>n>>m;
    int num[n];
    for (int a=0;a<n;a++){
        cin>>num[a];
    }
    sort(num,num+n);
    for (int a=(n-1);a>=0;a--){
        co+=num[a];
        nu++;
        if(co>=m){
            cout<<nu;
            return 0;
        }
    } */
    unsigned long long int n,m,t1=0,t2=0,remi=0,hold=0,remin2=0,wahed=0;
    cin>>n>>m;
    hold=n;
    t1=n/m;
    remi=(n%m);
    wahed=((((t1-1)*t1)/2)*remi);
    t1++;
    remin2=((((t1-1)*t1)/2)*remi);
    t1--;
    t2=(((((t1-1)*t1)/2)*m)+remin2);
    t2-=wahed;
    n=n-(m-1);
    n=(((n-1)*n)/2);
    if (m==1){
            hold=(((hold-1)*hold)/2);
        cout<<hold<<" "<<hold;
    }
    else {
            if (t2!=0){
    cout<<t2<<" "<<n;
            }
            else {
                    cout<<n<<" "<<n;
            }
    }
    return 0;
}

//WINTER IS COMING.
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<iterator>
#include<cmath>
#include<string>
#include<sstream>
#include<cstring>
#include<ctype.h>
#include<iomanip>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<numeric>
using namespace std;

#define all(v)         v.begin(),v.end()
#define sz(V)        ((ll)((v).size()))
#define pp(x)               push_back(x)
#define ck(a)               (a<1 || a>9)
#define lop(i,n)    for(ll i=0;i<n;i++)
#define loop(i,f,l) for(ll i=f;i<l;i++)
#define READ(s)   freopen(s, "r", stdin)
#define WRITE(s) freopen(s, "w", stdout)
#define scl(n)          scanf("%lld",&n)
#define sc(n)             scanf("%d",&n)
#define INF                   1000000000000000000
#define PI             3.141592653589793
#define print(v)      lop(i, v.size()) cout<<v[i]<<" ";
#define read(v)   lop(i, v.size()) cin>>v[i];
#define printll(x)  printf("%lld", x);
#define scand(x) scanf("%lf", &x);
#define printd(x) printf("%f", x);
typedef string            ss;
typedef long long         ll;
typedef pair <ll, ll>   ii;
typedef pair<string, ll> si;
typedef pair<ll, string> is;
typedef pair<char, ll>  chi;
typedef vector<ii>       vii;
typedef vector<ll>       vi;
typedef vector<vi>       vvi;
typedef vector<string>    vs;
typedef vector<ll>       vll;
//READ("input.txt");WRITE("output.txt");
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b){ return ((a*b) / gcd(a, b)); }
ll sd(ll x){ return x<10 ? x : x % 10 + sd(x / 10); }
double sq(double x){ lop(i, x)if ((double)i*i > x) return (i - 1); return double(1); }
ll C(ll x)
{
    return (x*(x - 1) / 2);
}
int main()
{
    ll n, m; cin >> n >> m;
    cout << (m - n % m)*C(n / m) + (n%m)*C(n / m + 1) << " " << C(n - (m - 1));
}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<string>
#include<set>
#include<map>
#include<iomanip>
#include<sstream>
#include<functional>
#include<climits>
#define eps 1e-9
const int mod = 1000000007;
using namespace std;

int main(){

    long long n, m;
    cin >> n >> m;
    long long min = 0, max = 0;
    if (m == 1) {
        min = max = m*n*(n - 1) / 2;
    }
    else {
        if (n % m == 0) {
            if (n / m == 1) min = 0;
            else min = m*(n/m - 1)*(n/m)/2;
        }
        else {
            long long x = n%m;
            min = (n / m == 1 ? 0 : (n / m - 1)*(n / m) / 2)*(m - x) + x*(n / m)*(n / m + 1) / 2;
        }
        long long y = n - (m - 1);
        max = y*(y - 1) / 2;
    }
    cout << min << " " << max << endl;
    return 0;
}

//============================================================================
// Name        : .cpp
// Author      : Moaz
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cstring>
#include <string.h>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
using namespace std;

#define all(v) v.begin(),v.end()
#define rep(i,m) for(int i=0;i<(int)(m);i++)
#define rep2(i,n,m) for(int i=n;i<(int)(m);i++)

typedef vector<int> vi;

int main() {

    long long n,m;
    cin >> n >> m;
    long long maxm,minm;
    maxm = n-m+1;
//  cout << maxm <<endl;
    maxm =(maxm*(maxm-1))/2;

    minm = n/m;
//  cout<<minm<<endl;
    long long val = minm*m;
    int dif = n - val;
//      cout << dif << endl;
//      cout <<((minm+1)*(minm)/2)*dif <<endl;
//      cout << (minm*(minm-1)/2)*(m-dif) <<endl;
    minm = ((minm+1)*(minm)/2)*dif + (minm*(minm-1)/2)*(m-dif);

    cout << minm << " "<<maxm<<endl;

    return 0;
}

#include <iostream>
using namespace std;
int main(){
	long long n , m; // inputs
  	cin >> n >> m;// grab em
 	long long  kmx  = n- m +1;
 	kmx=  kmx*(kmx-1)/2;
 	long long kmn = ((n / m) * ((n / m) - 1)) / 2;
 	if(n % m == 0){
   	kmn *= m; // special case
  	}else{
   	kmn *= m - (n % m);
   	long long lft =(((n / m) + 1 ) * (n / m)) / 2; // now leftovers ! // lft has possible pairings
   	kmn += lft * (n % m);
  	}
   	cout << kmn << " " << kmx << endl;
}

#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{long long y,x,sum=0,cont=0,f=0,mx=0,mn=0,m=0,z=0;
cin>>x>>y;
f=x/y;
if(x%y==0)
   mn=(((f*f)-f)/2)*y;
else
{z=x%y;
m=y-(x%y);
mn=(z*((f+1)*f)/2)+(m*(((f-1)*f)/2));

}

f=x-y+1;
mx=((f*f)-f)/2;

cout<<mn<<" "<<mx;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define sz(x) int((x).size())

const int N=1e6+5,M=1e3+7,mod=1e9+7;

int a[N],p[N],n,m,k,tc,ans,d,cnt[N];

char s[N];

vector<int> v;

int main() {
    ll n,m;
    scanf("%lld%lld",&n,&m);
    ll cnt = n / m;
    ll mod = m - n%m;
    ll mn  = (cnt+1) * (cnt) / 2 * (n%m) + (cnt) * (cnt-1) / 2 * (mod);
    ll mx  = (n-m) * (n-m+1) / 2;
    printf("%lld %lld\n",mn,mx);
}

#include <bits/stdc++.h>

#define point pair<int, int>

#define llong long long
#define mp make_pair

#define x first
#define y second

using namespace std;

const int INF = (int) 1e6 + 3;
const int MXN = (int) 1e5 + 7;

llong n, m;
llong a, b;

int main() {
    ios_base::sync_with_stdio(0);

    cin >> n >> m;
    a = ((n / m + 1) * (n / m) / 2) * (n % m);
    a += ((n / m - 1) * (n / m) / 2) * (m - n % m);
    b = (n - m) * (n - m + 1) / 2;
    cout << a << ' ' << b;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

long long int func(long long int n)
{
    long long int ans;
    if (n%2==0)
    ans=(n/2)*(n-1);

    else ans= n*((n-1)/2);

    return ans;
}

int main()
{
    long long int n,m;
    cin>>n>>m;
    n=n-m;          //giving 1 to all m teams
    long long int q=n/m;
    long long int rem=n%m;
     long long int max=func(n+1);
    long long int min;
    if(rem==0)
    {
        min=m*func(1+q);
    }

    else
    {
        min=rem*func(q+2)+(m-rem)*func(q+1);
    }

    cout<<min<<" "<<max;
}

#include<iostream>
typedef _Longlong ll;
using namespace std;
int main()
{
    ll n, m;
    cin >> n >> m;
    ll s = n%m, t = n / m;
    ll min = 0;
    if (s != 0) min += s*(t+1)*(t) / 2;
    min+=(m - s)*(t)*(t - 1) / 2;
    ll max = (n - m + 1)*(n - m) / 2;
    cout << min << " " << max;
    return 0;
}

#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main() {
    int n,m,num=0;
    long long max=0,min=0;
    scanf("%d %d",&n,&m);
    if(n==m){
        printf("0 0");
        return 0;
    }
    num=n-m+1;
    double d=(num-1)*0.5;
    max=(num*d);
    int dv=n/m,v=dv;
    int rem=n%m;
    long long f=0,s=0;
        dv=v;
            d=(dv-1)*0.5;
            f=(m-rem)*dv*d;
            d=(dv)*0.5;
            s=rem*(dv+1)*d;
            min=f+s;
    cout<<min<<" "<<max;
        return 0;
}

#include <iostream>
using namespace std;
int main()
{
	long long n, m, kmin, kmax,x,TeamNo=0;
	cin >> n >> m;
	x = n - m + 1;
	kmax = x * (x-1) / 2;
	if (n%m == 0)
		kmin = ((n / m)*(n / m - 1) / 2) * m;
	else {
		x = (n - (n%m)) / m;
		TeamNo = m - (n - x*m);
		kmin = x*(x - 1) / 2 * TeamNo;
		TeamNo = n - x*m;
		x++;
		kmin += x*(x - 1) / 2 * TeamNo;
	}
	cout << kmin << ' ' << kmax << endl;
	return 0;
}

#include <iostream>
#include<vector>
using namespace std;

int main(){
	unsigned long long int p,teams,min=0,max=0,inteam=0,remain=0;
	//cout<<x<<endl;
	cin>>p>>teams;
	inteam=p/teams;
//	vector<int>t(teams,inteam);
	remain=(p-(teams*inteam));
	min= (teams-remain) * ((inteam*(inteam-1))/2);
	inteam++;
	min+= remain * ((inteam*(inteam-1))/2);
	remain= p-(teams-1);
	max=(remain *(remain-1))/2;
	cout<<min<<" "<<max;

}

#include <bits/stdc++.h>
#define pb push_back
#define lp(i,n) for(int i=0;i<n;i++)
#define read_int(i) scanf("%d", &i)
#define ii pair<int,int>
#define ll        long long

using namespace std;
ll n ,m;

int main (){
     cin>>n>>m;
  cout<<m*(n/m)*(n/m-1)/2+(n/m)*(n%m)<<" "<<((n-m+1)*(n-m))/2;

}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <list>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    long long n, m, kmin=0, kmax, temp,temp1;
    cin>>n>>m;
	kmax = n-m+1;
	kmax = (kmax*(kmax-1))/2;
	temp = n/m;
	kmin = temp;
	//kmin+=(temp*(temp-1))/2;
    if(m!=1){
        if(n%m!=0){
        	temp=n-(temp*(m-1));
        	temp1=temp-kmin;
        	temp=kmin;
        	kmin=(m-temp1)*((temp*(temp-1))/2);
        	temp++;
        	kmin+=(temp1*((temp*(temp-1))/2));
        }
        else{
            kmin=m*((temp*(temp-1))/2);
        }
    }
    else kmin = (temp*(temp-1))/2;
	cout<<kmin<<" "<<kmax<<endl;
	return 0;
}

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#define INF 0x7fffffff
using namespace std;

typedef long long LL;
LL n, m;

int main() {
    cin >> n >> m;

    LL MAX = (n - m + 1) * (n - m) / 2;

    LL x = n / m;
    LL y = n - (m - 1) * x;
    LL d = y - x;

    LL c1 = (x - 1) * x / 2;
    LL c2 = (x + 1) * x / 2;
    LL MIN = c1 * (m - d) + c2 * d;

    cout << MIN << " " << MAX << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long number,teams;
    cin>>number>>teams;
    long long max1;
    long long min1;
    long long j;
    long long k;
    max1=((number-(teams-1))*((number-(teams-1))-1))/2;
       if(number%teams==0)
    {
        min1=(number/teams);
        min1=((min1*(min1-1))/2)*teams;
    }
    else
    {
        j=number/teams+1;
        k=(j*teams)-number;
        min1=(((j-1)*(j-2))/2)*k;
        k=teams-k;
        min1=min1+(((j*(j-1))/2)*k);
    }

    cout<<min1<<" ";
    cout<<max1;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#define endl "\n"

#define ll long long
using namespace std;

int main() {
    ll n, m;
    cin >> n >> m;
    ll max_members = n-m+1;
    ll max_friends = (max_members) * (max_members - 1) / 2;
    ll max_min_members = (n / m) + 1;
    ll max_min_teams = n % m;
    ll min_min_members = (n / m);
    ll min_min_teams = m - n % m;
    ll min_friends = max_min_teams * (max_min_members) * (max_min_members - 1) / 2 +
        min_min_teams * (min_min_members) * (min_min_members - 1) / 2;
    cout <<min_friends<<' '<< max_friends << endl;
    return 0;
}

#pragma comment(linker, "/STACK:256000000")

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#define ll long long

using namespace std;

int main(void)
{
	ll n, n1, n2, m, k_min, k_max;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%I64d%I64d", &n, &m);
	n1 = n - m + 1;
	k_max = (n1 * (n1 - 1)) / 2;

	n2 = n / m;
	k_min = (n2 * (n2 - 1) / 2) * m;
	k_min += (n2 * (n % m));

	printf("%I64d %I64d", k_min, k_max);
	return 0;
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	/* Enter your code here. Read input from STDIN. Print output to STDOUT */
	long long n, m;
	cin >> n >> m;
	long long max = ((n + 1-m) * (n-m)) / 2;
	long long b = n / m;
	long long min = ((b * (b - 1) )/ 2)*(m);
	min += (n % m) * b;
	cout << min << " " << max;
	return 0;
}

#include <bits/stdc++.h>

using namespace std ;

unsigned long long n,m,t,y;

unsigned long long pmax,pmin;

int main()
{
    ios::sync_with_stdio(false);

    cin >> n >> m ;

    t = n - (m-1) ;

    pmax =  (t*(t-1))/2;

    if(n % m == 0)
        pmin = m*((n/m)*((n/m) - 1)/2);

    else
    {
        y = n / m ;

        pmin = (m - n%m)*(((y-1)*y)/2) + (n%m)*(y*(y+1)/2);
    }

    cout << pmin << ' ' << pmax ;

    return 0;
}

 #include <bits/stdc++.h>

    using namespace std;

    #define pb push_back
    #define ll long long
    #define mp make_pair
    #define MOD 1000000007
    #define MAX
    #define MIN -1000000000
    #define LLINF 0x3fb3f3f3f3f3f
    #define INF 0x3f3f3f3f
    #define lb lower_bound

    ll ans(ll a){
        return a*(a-1)/2;
    }
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll n, m;
        cin >> n >> m;
        ll maior =  ans(n - m + 1);
        ll menor = ans(n/m + 1)*(n%m) + ans(n/m)*(m - n%m);
        cout << menor << " " << maior << endl;
        return 0;
    }

#include<iostream>
using namespace std;
long long s(long long n)
{
	return n * (n - 1);
}

int main()
{
	long long n, m, min = 0, mx = 0, x = 0, y = 0,z=0,c=0;
	cin >> n >> m;
	x = n - m+1;
	mx = s(x)/2;
	y = n / m;
	z = n % m;
	if (z == 0)
	{
		min = (s(y) / 2)*m;
	}
	else
	{
		c = m - z;
		min = (s(y+1) / 2) * z + (s(y) / 2) * c;
	}
	cout << min << " " << mx << endl;
	return 0;
}

#include <iostream>
using namespace std;

int64_t calculatemax(int64_t num_of_participants,int64_t num_of_teams)
{
    int64_t maximum;
    int64_t temp = num_of_participants - num_of_teams + 1 ;
    maximum = (temp*(temp-1))/2;
    return (maximum);
}

int64_t calculatemin(int64_t num_of_participants,int64_t num_of_teams)
{
    int64_t minimum;
    int64_t temp1 = num_of_participants / num_of_teams ;
    double temp2 = (float)num_of_participants / num_of_teams ;
    double temp3 = temp2 - temp1;
    if(temp3 == 0.0)
    {
        minimum =  num_of_teams * ((temp1*(temp1-1))/2) ;
    }
    else if(temp3 < 0.5)
    {
        int64_t tempnew = temp1 * num_of_teams;
        tempnew = num_of_participants - tempnew;

        minimum =  ((num_of_teams-tempnew) * ((temp1*(temp1-1))/2)) + tempnew * (((temp1+1)*temp1)/2) ;

    }
    else if(temp3 > 0.5)
    {
        int64_t tempnew = temp1 * num_of_teams;
        tempnew = num_of_participants - tempnew;

        minimum =  ((num_of_teams-tempnew) * ((temp1*(temp1-1))/2)) + tempnew * (((temp1+1)*temp1)/2) ;
    }
    else if(temp3 == 0.5)
    {
        minimum =  ((num_of_teams/2) * ((temp1*(temp1+1))/2)) + ((num_of_teams/2) *(((temp1-1)*temp1)/2)) ;
    }
    return (minimum);
}
int main()
{
    int64_t num_of_participants,num_of_teams;
    cin>>num_of_participants>>num_of_teams;
    cout<<calculatemin(num_of_participants,num_of_teams)<<" "<<calculatemax(num_of_participants,num_of_teams);
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>

typedef long long ll;
using namespace std;

ll fat(ll n){
    ll res;
    res = 1;
    for(int i = 1; i <= n; i++)
        res *= i;

    return res;
}
ll combinacao( ll a ){
        return a*(a-1)/2;
}

int main(){
    ll n,m,maximo,minimo,maior,equilibrado;

    cin >> n >> m;

        maior = n - (m - 1);
        equilibrado = n/m;

        maximo = combinacao(maior);

        minimo = (m-n%m)*combinacao((n/m)) + (n%m)*combinacao(n/m+1);

        cout << minimo << " " << maximo << endl;

}

#include<iostream>
using namespace std;
int main()
{
long long n,m;
cin>>n>>m;
long long i,kmin,kmax,result,r;
kmax=0;
kmax=(n-m)*(n-m+1)/2;
kmin=0;
if(n%m!=0)
{
    r=n%m;
for(i=1;i<=n/m-1;i++)
kmin+=i;
result=(m-r)*kmin;
kmin=0;
for(i=1;i<=n/m;i++)
kmin+=i;
result+=r*kmin;
}
else if(m==1)
{
    result=kmax;
}
else
    {
    for(i=0;i<=n/m-1;i++)
    {
        kmin+=i;
    }
    result=kmin*m;
    }
cout<<result<<" "<<kmax;
}

#include <bits/stdc++.h>
#include <chrono>
using namespace std::chrono;

using namespace std;
typedef long long ll;

int factorial(int n)
{
    // single line to find factorial
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}

int main()
{

    //--------------------------File and Fast IO----------------------------//

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //-----------------------------|cOdE BeLoW|---------------------------//
    //                                  ||
    //----------------------------------\/-------------------------------//

    ll n, m;
    cin >> n >> m;

    ll max = (n - m + 1) * (n - m) / 2;
    ll min = 0;

    ll k = n % m;

    min =   (n / m) * ((n / m) - 1) * m / 2;
    // cerr<<;
    min += ((n / m)) * k;
    cout << min << " " << max;

}

#include <bits/stdc++.h>
using namespace std;

int main() {
     unsigned long long int n,m,ans1,ans2,k,l;
     cin>>n>>m;
     if(n%m==0)
     {      k=n/m;
           ans1=m*(k*(k-1))/2;
            //ans1=l*m;
          cout<<ans1<<" ";
     }
     else
     {          k=n/m;
         l=n%m;
        ans1=((k+1)*k/2)*l+((k*(k-1)/2)*(m-l));
     	 cout<<ans1<<" ";
     }
     k=n-(m-1);
     ans2=(k)*(k-1)/2;
     cout<<ans2<<endl;
	return 0;
}

#include<iostream>
using namespace std;
long long int sum(long long int n)
{
	if(n==0)
		return 0;
	else if(n==1)
		return 0;
	else
	return n*(n-1)/2;
}
int main()
{
	long long int n,m;
	while(cin>>n>>m)
	{
		long long int k;
		if(n%m)
			k=n/m+1;
		else
			k=n/m;
		long long int a=k*m-n;
		cout<<a*sum(k-1)+(m-a)*sum(k)<<" "<<sum(n-m+1)<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

long long int f(int n) {
    return (long long)n*(n-1)/2;
}

int main() {
    int n, m;
    cin >> n >> m;
    long long int maximum = f(n - m + 1);
    long long int minimum = (m - n%m) * f(n/m) + (n%m) * f(n/m + 1);
    cout << minimum << " " << maximum << endl;
    return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
#include<cstdlib>

using namespace std;

typedef long long ll;

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        ll num = n/m,mi,ma;
        if(n%m==0)
            mi = (num*(num-1)/2)*m;
        else
        {
            ll p = m-n%m;
            mi = (num*(num-1)/2)*p+((num+1)*num/2)*(m-p);
        }
        num = n-(m-1);
        ma=num*(num-1)/2;
        printf("%I64d %I64d\n",mi,ma);
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n,m;
void findmin()
{
	long long e,z,minn=0;
	e=n/m;
	z=n%m;
	minn=(m*e*e-m*e+2*e*z)/2;
	printf("%lld ",minn);
}
void findmax()
{
	long long maxn=0,z;
	z=n-m+1;
    maxn=(n-m+1)*(n-m)/2;
	printf("%lld",maxn);
}
int main()
{
	scanf("%lld%lld",&n,&m);
	findmin();
	findmax();
	return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
long long cell(long long x,long long y)
{
	if(x%y==0)
		return 0;
	else
		return 1;
}
int main()
{
	long long n;
	long long m;
	long long temp;
	cin>>n;
	cin>>m;
	long long ans1=0;
	long long ans2=0;
	ans1 = (n-m+1)*(n-m)/2;
	ans2 += (n/m+cell(n,m))*(n/m-1+cell(n,m))/2;
	ans2 *=n%m;
	temp=m;
	temp-=n%m;
	n-= (n/m+cell(n,m))*(n%m);
	m=temp;
	long long ans3=0;
	if(m!=0)
	{
		ans3= (n/m-1)*(n/m)/2;
		ans3*=m;
		ans2+=ans3;
	}
	cout<<ans2<<" "<<ans1<<endl;
	return 0;
}

#include <iostream>
#include<algorithm>
using namespace std;
#define to long long int
int main() {
	// your code goes here
	to n,m;
	cin>>n>>m;
	cout<<((m*(n/m)*(n/m-1))/2+(n/m)*(n-(n/m)*m))<<" ";
	cout<<((n-m+1)*(n-m))/2<<endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    long long int n,m;
    cin>>n>>m;
    long long int a=n/m;
    long long int b=n%m;
    long long int c=(m-b);
    long long int kmax=((n-m+1)*(n-m))/2;
    long long int kmin=((a)*(a-1)/2)*c+((a+1)*a/2)*b;
    cout<<kmin<<endl;
    cout<<kmax;
    return 0;
}

//keep things simple!!

#include <cstdio>
#include<math.h>
#define  LL long long

LL a[1000][1000];

/*void pascal() {
    a[1][1] = 1;
    a[1][0] = 1;

    for (int i = 2; i <= 100; i++) {
        a[i][0] = 1;
        a[0][i]=0;
        for (int j = 1; j <= i; j++) {
            a[i][j] = a[i - 1][j] + a[i - 1][j - 1];
        }
    }
}
*/
long long nCr(long long n,long long m) {
    long long res=1,i;
    if(n-m<m)
        m=n-m;
    for(i=1; i<=m; i++,n--) {
        res=res*n;
        res=res/i;
    }
    return res;
}

int main() {

    LL n,m;

    scanf("%lld %lld",&n,&m);
/*   long long min=0;

    if(n%m==0) {
        for(int i=0; i<m; i++) {
            min+=nCr(n/m,2);
            //printf("%d",team[i]);
        }
        printf("%lld ",min);
    }*/

        LL a= n%m;
        LL b= m-a;
        LL aa= ((n/m+1)*((n/m+1)-1))/2;
        LL bb=(((n/m))*(((n/m))-1))/2;
       printf("%lld ",a*aa+b*bb);

//         dp();
/*    } else if(n%m!=0) {
        //printf(d\n",team[i]);
        for(int i=0; i<=n%m+2; i++) {
            min+=nCr(((n/m)+1),2);
            //    printf("%lld\n",(n/m)+1);
        }
        if(n/m>1)
            min+=nCr(n/m,2);
        printf("%lld ",min);
    } */
// code starts for the max value
    //for(int i=0; i<m; i++) team[i]=0;

    printf("%lld\n",((m-n)*(m-n-1))/2);

    return 0;
}

/*
#include<iostream>
#include<math.h>
#define ll long long int
using namespace std;

int main(int argc, char const *argv[])
{
	ll n,m;
	cin >> n >> m;
	if(n==m)
	{
		cout << "0 0\n";
		return 0;
	}
	ll max = n - m + 1;
	max = (max * (max-1))/2;
	ll min=0;
	ll t,ans=0;
	while(n>1 && n!=m)
	{
		double temp = (double)n/m;
		ll minn = (ceil)(temp);
		//cout << "minn " << minn << "\n";
		min = ((minn)*(minn-1))/2;
		//cout << " min " << min << "\n";
		t = n/minn;
		//cout << "t " << t << "\n";
		if(t<m)
		{
			if(minn*t!=n)
			{
				ans += min*t;
				n = n - minn*t;
				m-=t;
			}
			else
			{
				ans += min * (t-1);
				//cout << "ans " << ans << "\n";
				n = n - minn*(t-1);
				m = m - t + 1;
				//cout << "n " << n << " m " << m << "\n";
			}
		}
		else
		{
			ans += min * t;
			break;
		}
	}
	cout << ans << " " << max << "\n";
	return 0;
}
*/
#include <iostream>
#define ll long long int
using namespace std;
int main()
{
	ll n,m,ans=0;
	cin >> n >> m;
	ll max = n - m + 1;
	max = (max * (max-1))/2;
	for(int i=0;i<n%m;i++)
	{
		ans+=((n/m)*(n/m+1)/2);
	}
	ans+=((n/m)*(n/m-1)/2)*(m-n%m);
	cout << ans << " " << max << "\n";
	return 0;
}

#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z)

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=n-1;i>=0;i--)
#define rep3(i,n) for(int i=n;i>1;i--)

#define fi first
#define se second
#define pb(x) push_back(x)
#define po(x) pop_back(x)
#define mp(x,y) make_pair(x,y)
#define sz(x) ((int) (x).size())
#define MAX 100007
using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;

int main(){

	lli n,m,res;
	cin >> n >> m;
	if(n==m){
		cout << 0 << ' ' << 0;
		return 0;
	}

	lli r = n%m;
	lli q = n/m;
	res = (q*(q+1)*r + q*(q-1)*(m-r))/2;
	cout << res << ' ' << ((n-m+1)*(n-m))/2;
	return 0;
}

#include <iostream>
#include <math.h>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include <map>
#include <deque>
#include<queue>
using namespace std;
long long sum_n(long long n){
    return (n*(n-1)/2);
}
int main() {
  long long users,teams,k1=0,k2=0;
  cin>>users>>teams;
  int u_in_t=1;
  int extra =0;
  if(users>teams){
      u_in_t = users / teams;
      extra = users % teams;
      k1= sum_n(u_in_t+1)*extra + sum_n(u_in_t) *(teams-extra);
      k2 = sum_n(users - teams+1);
  }
  cout<<k1<<" "<<k2;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long C(long long x)
{
  if(x>=2)
    return (x*(x-1)/2);
    else
      return 0;
}
int main()
{  long long z,k,p,q,n,m,r,mx,mn;

    cin>>n;
	cin>>m;

	q=n/m;
	r=n-(q*m);
	z=(n-m)+1;

	mx=C(z);
	p=q+1;
	k=m-r;
	mn=r*C(p)+k*C(q);

	cout<<mn<<" "<<mx<<endl;
	return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include <initializer_list>
#include<unordered_set>
#include<map>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <numeric>
#include <functional>
using namespace std;
void past_code();
//bool fml(int l,int z);
int main(){
	 long long int sum=0;
	 long long int x,y,z=0,k=0,n,p;
	 cin>>x>>y;
	 z=(x%y);

	  k=x/y;
	  p=(x/y)+(x%y!=0);
	//  cout<<(z*(((p-1)*(p))/2))<<endl;
	 sum=(z*(((p-1)*(p))/2))+((y-z)*((((k-1))*k)/2));
	 cout<<sum<<" ";
	 n=x-(y-1);
	 cout<<((n-1)*(n))/2<<endl;
	/*int x,y;
	cin>>x>>y;
	for (int i=0;i<x;i++)
		cout<<"6";
	cout<<"5";
	cout<<endl;
	for (int i=0;i<x;i++)
		cout<<"3";
	cout<<"5";
	cout<<endl;*/

//	system("pause");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,m,i=0;
    cin>>n>>m;
    double x=n*1.0/m*1.0;
    if(n%m!=0){
        cout<<fixed<<setprecision(0)<<(((n/m)*(n/m-1)/2))*(m-n%m)+((ceil(x)*(ceil(x)-1)/2))*(n%m);
    }
    else cout<<fixed<<setprecision(0)<<ceil(x)*ceil(x-1)/2*m;
    cout<<" "<<(n-m+1)*(n-m)/2;
    return 0;
}

	#include <iostream>
	#include <string>
	#include <vector>
	using namespace std;

	long long int combination2(long long int n)
	{
		return n*(n - 1) / 2;
	}

	int main(){

		long long int n, m, min, max;
		cin >> n >> m;
		max = combination2(n - m + 1);
		if (m == 1) min = max;
		else min = (n % m) * combination2(n / m + 1) + (m - n % m) * combination2(n / m);
		cout << min << ' ' << max << endl;
		return 0;
	}

	#include <iostream>
	#include <string>
	#include <vector>
	using namespace std;

	long long int combination(long long int n, long long int k)
	{
		if (k > n) return 0;
		if (k * 2 > n) k = n - k;
		if (k == 0) return 1;

		long long int result = n;
		for (long long int i = 2; i <= k; ++i) {
			result *= (n - i + 1);
			result /= i;
		}
		return result;
	}

	int main(){

		long long int n, m, min, max;
		cin >> n >> m;
		max = combination(n - m + 1, 2);
		if (m == 1) min = max;
		else min = (n % m) * combination(n / m + 1, 2) + (m - n % m) * combination(n / m, 2);
		cout << min << ' ' << max << endl;
		return 0;
	}

#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
// template

// abbreviations
#define vi vector <int>
#define ii pair <int, int>
#define a first
#define b second
#define vii vector <ii>
#define mii map <int, int>
#define que queue
#define pque priority_queue
#define stk stack
// end of template

typedef unsigned long long ull;
template <typename U> class Comparator {
public:
	bool operator() (const U lhs, const U rhs) {
		// implement
		return true;
	}
};
// end of template

ull power(const ull &a, const ull &b) {
	if (b == 0)
		return 1;
	if (b % 2) {
		return power(a, b-1)*a;
	}
	else {
		ull temp = power(a, b/2);
		return temp*temp;
	}
}

vector<ull> prime;
ull getCombinatoric(const ull &n, const ull &m) {
	if (n < m)
		return 0;
	ull ans = (n*(n-1))/2ULL;
	return ans;
}
void preparePrime() {
	bool sieve[2000000];
	for (ull it = 0; it <= 2000000; ++it)
		sieve[it] = true;

	sieve[1] = false;
	for (ull i = 2; i <= 1415; ++i)
		if (sieve[i]) {
			for (ull j = i; j < (2000000/i); ++j)
					sieve[i*j] = false;
		}

	for (ull it = 1; it <= 2000000; ++it) {
		if (sieve[it]) {
			prime.push_back(it);
		}
	}
}

int main() {
	// initializiation
	// preparePrime();

	// freopen("478B.in", "r", stdin);
	ull n, m;
	scanf("%I64d %I64d", &n, &m);
	ull temp_n = n, temp_m = m;
	ull minimum = (n%m)*getCombinatoric(n/m+1, 2)+(m-n%m)*getCombinatoric(n/m, 2);
	printf("%I64d %I64d\n", minimum, getCombinatoric(n-(m-1), 2));
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
	//Random Teams
	long long n,m,mina,maxa,k1,k2;
	scanf("%lld%lld",&n,&m);
	if (n<m) printf("0 0");
	else
	{
		k1=n%m;k2=n/m;
		mina=k1*k2*(k2+1)/2+(m-k1)*(k2*(k2-1)/2);
		maxa=(n-m+1)*(n-m)/2;
		printf("%lld %lld",mina,maxa);
	}
}

#include <bits/stdc++.h>
long long n,m;
long long JFCA(long long x){
    return (1+x)*x/2;
}
int main(void){
    std::cin>>n>>m;
    printf("%lld %lld\r",n%m*JFCA(n/m)+(m-n%m)*JFCA(n/m-1),JFCA(n-m));
}

#include <iostream>
using namespace std;
long long n, m, ans1, ans2;
int main() {
	cin >> n >> m;
	if (n < m) {
		cout << 0 << " " << 0 << endl;
		return 0;
	}
	long long k = n % m, s = n - m + 1;
	ans1 += k * (n / m + 1) * (n / m) / 2;
	ans1 += (m - k) * (n / m) * (n / m - 1) / 2;
	ans2 = s * (s - 1) / 2;
	cout << ans1 << " " << ans2 << endl;
	return 0;
}

#include<iostream>
#define ll long long
using namespace std;
ll f(ll d){
    return d*(d-1)/2;
}
int main(){
    ll n,m;
    cin>>n>>m;
    cout<<f(n/m)*(m-n%m)+f((n+m-1)/m)*(n%m)<<" "<<f(n-m+1);
}

#include<stdio.h>
#include<string.h>
long long AB(long long m)
{
	return m*(m-1)/2;
}
int main()
{
	 int n, m;
	 while(scanf("%d%d", &n, &m)!=EOF)
	 {
		printf("%lld %lld\n", (n%m)*AB(n/m+1)+(m-n%m)*AB(n/m), AB(n-m+1));
	 }
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,m;
	cin>>n>>m;
	long long int x=n-m+1;
	long long int sum1=0,sum2=0,sum3=0;
	sum1=(x*(x-1))/2;
	long long int y=n/m+1;
	sum2=(y*(y-1))/2;;
	long long int c=sum2*(n%m);
	long long int t=n/m;
	sum3=(t*(t-1))/2;
	long long int z=sum3*(m-n%m);
	cout<<c+z<<" "<<sum1;
}

    #include<bits/stdc++.h>
    #define ll long long int
    using namespace std;
    int main()
    {
    	ll n,m;
    	cin>>n>>m;
    	cout<<((n%m)*(n/m+1)*(n/m))/2+((m-n%m)*(n/m)*(n/m-1))/2<<" "<<((n+1-m)*(n-m))/2;
    	return 0;
    }

#include <stdio.h>
#include <algorithm>
#include <cmath>
typedef long long lld;
using namespace std;
int main()
{
    lld n , m;
    scanf("%lld %lld" , &n , &m);
    lld mn = m * ((n / m - 1) * (n / m) / 2) + (n / m) * (n % m);
    lld x3 = n - (m - 1);
    lld mx = x3 * (x3 - 1) / 2;
    printf("%lld %lld" , mn  ,  mx);
}

#include<iostream>
#define ll long long int
using namespace std;
int main()
{ long long int n,m;
cin>>n>>m;
 long long int k=n-m+1;
 long long int y=n/m;
ll r=n%m;
 long long int min=(r*(y+1)*y/2)+((m-r)*y*(y-1)/2);

long long int max=(k*(k-1))/2;
cout<<min<<" "<<max;
}

#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 35;
typedef long long ll;
ll combination(ll x)
{
	return x*(x - 1) / 2;
}
int main()
{
	ll n, m;
	ll mi, mx;
	while (cin >> n >> m)
	{
		if (m == 1)
			mi = combination(n);
		else if (n%m == 0)
		{
			mi = m * combination(n / m);
		}
		else
		{
			mi = (n%m)*combination(n / m+1) + (m-(n%m))*combination(n/m);
		}
		mx = combination(n - m + 1);
		cout << mi << " " << mx << endl;
	}
	return 0;
}

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
using namespace std;
int main()
{
    long long n,m;
    while(cin>>n>>m)
    {
        if(m==1)
        {
            long long res=n*(n-1)/2;
            cout<<res<<" "<<res<<endl;
            continue;
        }
        if(m==n)
        {
            cout<<"0 0"<<endl;
            continue;
        }
        long long minn=(n-m+1)*(n-m)/2;
        long long item=n/m;
        long long pa=n-item*m;
        long long maxx=(m-pa)*(item-1)*item/2;
        maxx=maxx+pa*(item+1)*item/2;
        cout<<maxx<<" "<<minn<<endl;
    }
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll comb(ll n,ll k)
{
    if(n<k)return 0;
    return n*(n-1)/2;
}
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m,a,b,c=0,p;
    cin>>n>>m;
    a=n-m+1;
    a=comb(a,2);

    b=n/m;

    if(n%m!=0)c=n/m+1,p=n%m,m-=p;//cout<<b<<' '<<c<<endl;
    b=comb(b,2)*m;
    if(c)c=comb(c,2),b+=c*p;
    cout<<b<<' '<<a;//<<' '<<c;

    return 0;
}

#include <iostream>
using namespace std;

//int fact(int n)
//{
//    if(n == 0 || n == 1)
//        return 1;
//    else
//        return n * fact(n-1);
//}

int main()
{
    int n, m;
    int x, y;
    long long int com, max, min;
    cin >> n >> m;

    long long int a = n/m;
    long long int b = n%m;

    if(b == 0)
        {
//            com = fact(a)/(2*fact(a-2));
            com = (a*(a-1))/2;
            min = com*m;
        }

    else
        {
            long long int x = a+1;
            y = m - b;
//            com = fact(x)/(2*fact(x-2));
            com = (x*(x-1))/2;
            min = com*b;
            if(a > 1)
            {
//               com = fact(a)/(2*fact(a-2));
                com = (a*(a-1))/2;
                min += com*y;
            }
        }

    long long int z = n - (m-1);

    max = (z*(z-1))/2;
    cout << min << " " << max << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	unsigned ll int n,m;
	cin>>n>>m;
	unsigned ll int min=0,max=0;
	if(n%m==0)
	{
		unsigned ll int k=n/m,sum=0,som=0;
		unsigned ll int x=n-m+1;
	    	sum= (k-1)*k/2;
	    	som=x*(x-1)/2;
		min=m*sum;
		max=som;
	}
	else
	{
		unsigned ll int k=n/m;
		unsigned ll int t=n%m,xs,sum=0,som=0;
			max=(n-m)*(n-m+1)/2;
			sum=k*(k-1)/2;
			som=k*(k+1)/2;
		/*for(int as=0;as<k;as++)
		{

		}
		for(int qw=0;qw<k+1;qw++)
		{
		    som+=qw;
		}*/
		min=sum*(m-t) + som*t;
	}
	cout<<min<<" "<<max;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    long long n,m,i,j,p,q,u,v;
    while(~scanf("%lld%lld",&n,&m))
    {
        if(n%m==0)
        {
            p=n/m;
            q=(p-1)*p/2*m;
            printf("%lld ",q);
        }
        else
        {
            p=n/m;
            q=n%m;
            u=(p-1)*p/2*(m-q);
            v=(p+1)*p/2*q;
            printf("%lld ",u+v);
        }
        p=0;
        if(n-m+1==1)
        {
            p=0;
        }
        else if(n-m+1==2)
        {
            p=1;
        }
        else if(n-m+1==3)
        {
            p=3;
        }
        else
        {
            p=(n-m+1)*(n-m)/2;
        }
        printf("%lld\n",p);
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,i,max,min;
    cin>>n>>m;
    //long long int a[m];
    min=0;
    max=n-m+1;
    max=(max*(max-1))/2;
   // for(i=0;i<m;i++)
    //{
     //   a[i]=n/m;
      //  if(i<n%m)
      //  {
        //    a[i]=a[i]+1;
       // }
         //   min=min+(a[i]*(a[i]-1))/2;

   // }
    min=m*(n/m)*((n/m)-1)/2;
    min=min+((n%m)*(n/m));
    if(m==1)
    {
    min=max;
    }
    cout<<min<<" "<<max<<endl;
}

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <string.h>
#include <cmath>
#include<iomanip>
#include <cstring>
#include <ctype.h>
#include <stdio.h>
#include<sstream>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<list>
#include <stdio.h>
#include <stdlib.h>
#include<bitset>
using namespace std;

long long int nCr(long long int n,long long int r )
{
if(n<r)
        return 0;
  if(r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

int main()
{

   // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    long long int n,m;
    cin>>n>>m;
    long long int mini=(m-n%m)*nCr(n/m,2)+(n%m)*nCr((n/m)+1,2);
    long long int maxi=nCr(n-(m-1),2);
    cout<<mini<<" "<<maxi<<endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define LL long long
LL n,m,r;
int main()
{
      cin>>n>>m;
      r=n/m;
      cout<<m*r*(r-1)/2 + r*(n%m)<<" "<<(n-m+1)*(n-m)/2<<endl;
}

#include <stdio.h>

using namespace std;

int main()
{
    long long n, m;
    scanf("%I64d %I64d", &n, &m);
    long long maxi = (n-m+1)*(n-m)/2;
    long long mini = 0;
    long long dobav = n%m;
    long long x = n/m*(n/m-1)/2;
    mini = (m-dobav)*x+dobav*(x+n/m);
    printf("%I64d %I64d", mini, maxi);
    return 0;
}

#include <iostream>
using namespace std;

long long int pairs(long long int n)
{
    return n * (n - 1) / 2;
}

int main()
{
    long long int n, m;
    cin >> n >> m;
    long long int a(n / m), b(n % m);
    long long int min = pairs(a) * (m - b) + pairs(a + 1) * b;
    long long int max = pairs(n - m + 1);
    cout << min << " " << max << endl;
    return 0;
}

#include <iostream>
using namespace std;

int main()
{

	long long n, t, max, min;
	cin >> n >> t;
	max = ((n - t + 1)*(n - t)/2);

	if (n % t == 0)
		min = (t) * ((n / t)*(n / t - 1) / 2);
	else
	{
		long long r = n / t;
		long long poveke = (n - (r*t));
		long long pomalce = t - poveke;
		min = poveke * (((r + 1) * r)/2);
		min += pomalce * ((r*(r - 1))/2);
	}
	cout << min << " " << max;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long m,n;
	cin>>m>>n;
	long long arr[n];
	long long sum=0;
	memset(arr,0,sizeof(arr));

	long long min,max=0;

	/*for(int i=0,j=0;i<m;i++,j++)
	{
		if(j==n)
		{
			j=0;
		}
		arr[j]+=1;

	}*/
		long long h=m/n;
		long long g=(m/n)+1;
		if(m%n==0)
		{
			min=(h*(h-1))/2;
			min*=n;
		}
		else
		{
			min=(g*(g-1))/2;
			min*=m%n;
			min+=((h*(h-1))/2)*(n-m%n);
		}

	/*for(int i=0;i<n;i++)
		{
			 min=(arr[i]*(arr[i]-1))/2;
		}*/

	 /* for(;;)
	  {
	  	if(m>n)
	  	{
	  		sum+=2;
	  		m-=2;
	  	}
	  	else
	  		break;}*/
	  		sum=(m-n)+1;

	  max=(sum*(sum-1))/2;

	  cout<<min<<" "<<max;

	return 0;
}

#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
using namespace std;
long long f(long long n) {
 return (n*(n-1))/2;
}
long long n, m;
int main(){
 cin >> n >> m;
 cout << (n%m)*f(n/m+1) + (m-n%m)*f(n/m) << ' ' << f(n-m+1);
}

#include <iostream>
using namespace std;
long long nC2(long long n)
{
	if(n==0||n==1)
		return 0;
	return (n*(n-1))/2;
}

int main()
{
	long long n,m;
	cin>>n>>m;
	long long max=0,min=0;
	max=nC2(n-m+1);
	long long div=n/m;
	int count=0;
	if(n%m!=0)
		min+=(n%m)*nC2(n/m+1)+(m-n%m)*nC2(n/m);
	else
		min=m*(nC2(n/m));
	cout<<min<<" "<<max<<endl;

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <map>
#include <queue>

#define ll long long
#define sc(a) scanf("%d",&a);
const ll mod = 1000000007;

using namespace std;

vector<int>sums;

ll getans(ll a){
	return a*(a - 1) / 2;
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n, m, a, mx, mn;
	cin >> n >> m;
	a = n - m + 1;
	mx = getans(a);
	a = n / m;
	mn = getans(a + 1)*(n%m) + getans(a)*(m - n%m), mx = getans(n-m+1);
	cout << mn << ' ' << mx;
}

// Made By Haireden Aibyn
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define fname ""
#define INF 2009000999
#define MOD 1000000007
#define sc scanf
#define pr printf
#define pb push_back
#define mp make_pair
#define ex exit(0)
#define tim printf("%.4lf\n", (clock() * 1.) / CLOCKS_PER_SEC)
#define cas printf(""), ex;
#define y1 y4
#define S second
#define F first

typedef long long ll;
typedef unsigned long long ull;

const int N = 500001;

ll go(ll x) {
   return x * (x - 1) / 2;
}

int main () {
    srand(time(NULL));
    //freopen("input.txt", "r", stdin);
    //freopen(".in", "w", stdout);
    ll n, m;
    cin >> n >> m;
    ll mx = go(n - m + 1);
    ll kol = (n / m);
    ll mn = go(kol) * (m - (n % m));
    mn += go(kol + 1) * (n % m);
    cout << mn << " " << mx;
    return 0;
}

// CF 478 B.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	long long n = 0, m = 0;
	cin >> n >> m;
		cout << (m*(n/m-1)*(n/m))/2 + (n%m)*(n / m) << endl << (n - m + 1)*(n - m) / 2;
	//cin >> n;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
#define OO 1e6
#define set(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define getArr(ar,n) for(int i=0;i<n;get ar[i++])
#define printArr(ar,n) for(int i=0;i<n;print ar[i++]<<' ')
#define Sort(ar,n) sort(ar,ar+n)
#define getPoint(x,y) get x>>y
typedef long long ll;
typedef unsigned long long ull;
// damn
int main(){
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n,m ; get n>>m;
    ll mx = (n-m+1)*(n-m)/2,mn;
    if(n%m==0){
        mn = n/m*(n/m-1)/2*m ;
    }else mn = (n/m+1)*(n/m)/2*(n%m) + ((n/m-1)*(n/m)/2*(m-(n%m)));
    print mn<<' '<<mx;
}
/*
*/

#include <iostream>
#define  ll long long
//#include <bits/stdc++.h>
using namespace std;
int main()
{
    ll n,m;
    ll mini=0;
    cin>>n>>m;
    ll p=n-(m-1);
    ll maxi=(p*(p-1))/2;
    ll mod=n%m;
    ll k=n/m;
    mini+=mod*(k*(k+1))/2;
    mini=mini+((m-mod)*(k*(k-1)/2));
    cout<<mini<<" "<<maxi;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline void IO() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

int main(int argc, char const *argv[])
{
// 	IO();

	ll n, m; cin >> n >> m;
	ll x1 = n - m + 1;
	ll x2 = n/m;

	ll ans1 = (x1*(x1-1))/2;
	ll ans2 = 0;
	if(n%m == 0) ans2 = ((x2*(x2-1))/2)*m;
	else ans2 = ((x2*(x2-1))/2)*(m-(n%m)) + (n%m)*(x2*(x2+1))/2;

	cout << ans2 << " " << ans1 << endl;
	return 0;
}

#include <iostream>
#include <queue>
#include <string>
#include <cmath>
using namespace std;

long long cntFriends(long long cnt){
	return cnt*(cnt-1)/2;
}

int main(){
	long long n,m;
	long long max,min;
	cin>>n>>m;
	max=cntFriends(n-m+1);
	// cout<<n/m<<endl;
	if(n%m != 0)
		min=(m-n%m)*cntFriends(n/m) + (n%m)*cntFriends(n/m + 1);
	else
		min=m*cntFriends(n/m);
	cout<<min<<" "<<max<<endl;
	// if(m!=n){
	// 	max=cntFriends(n-m+1);
	// 	min=(m-1)*cntFriends(n/m) + cntFriends(n/m + n%m);
	// }
	// else{
	// 	max=0;
	// 	min=0;
	// }
	return 0;
}

// 101
// 100
// 100

#include"conio.h"
#include"stdio.h"
#include"math.h"
#include"iostream"
using namespace std;
int main()
{
	long long n, m, kmin, kmax=0,t,r;
	cin>>n>>m;
	while (n>m)
	{
		if (m==1)
		{
		kmin=kmax=n*(n-1)/2;
		break;
		}
		t=n/m;
		r=n-m*t;
		kmin=r*(t+1)*t/2+(m-r)*t*(t-1)/2;
		for(int i=n-m;i>0;i--)
		{
			kmax=kmax+i;
		}
		break;
	/*	}
		if ((n-m)==1)
		{
		 kmin=kmax=1;
		 break;
		}
		kmin=m-1;
		if (n>2*m)
		{
		for(int i=n-2*m;i>=2;i--)
			{
			kmin=kmin+i;
			}
			kmin=kmin-1;
		}
		else
		kmin=n-m;
		for(int i=n-m;i>0;i--)
		{
			kmax=kmax+i;
		}
		break;*/
	}
	cout<<kmin<<" "<<kmax;
	getchar();
}

#include <iostream>
#include <vector>
#include <string>
#include<math.h>
#include<bits/stdc++.h>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
int main()
{
    long long m,n;
    cin>>n>>m;
    long long maximum = ((n-(m-1))*(n-m))/2;

    long long groups = n/m;
    long long pairs = ((m - n%m)*( groups*(groups-1)  )/2) + ((n/m+1)*(n/m)*(n%m))/2;

    cout<<pairs<<" "<<maximum<<endl;
}

    #include <bits/stdc++.h>
    using namespace std;

    #define pi pair<int ,int>
    #define pb() push_back()

    int main()
    {
        //optimization
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);

        //PROGRAM
        long long n, k;
        cin>>n>>k;

        long long nb = n/k ;
        long long r = n%k;
        long long mini = 0;
        int withoutR = k - r;
        mini += ((nb * (nb-1))/2) * withoutR ;
        int withR = k - withoutR;
        mini += (((nb+1) * nb)/2) * withR;

        long long maxi = ((n-(k-1))*(n-(k-1)-1))/2;

        cout<<mini<<" "<<maxi;

    }

/*

        */

# include<iostream>
typedef long long ll;
using namespace std;
long long int countpair(long long int  n1){
    if(n1<2)
    return 0;
    if(n1==2)
    return 1;
    return (n1*(n1-1))/2;
}

int main( )
{long long int n,m,kmin,kmax;
    cin>>n>>m;
    kmax=(n!=m) ? countpair(n-m+1) : 0;
    kmin=(n%m)*countpair((n/m)+1)+(m-(n%m))*countpair(n/m);
    cout<<kmin<<" "<<kmax;
}

#include <iostream>
#include<string>
#include<sstream>+
#include<bits/stdc++.h>
using namespace std;
string func(int t,int b,string p){
    ostringstream str1;
    int c=0,u=0,k=0;
    string st=" ";
    while(t>0){
        k=t%10;
        c+=k*b;
        u=c%10;
        str1<<u;
        str1<<st;
        p=str1.str();
        t=t/10;
        c=c/10;
        //cout<<p<<" "<<c<<" "<<t<<endl;
        if(t==0&&c!=0){
            str1<<c;
            p=str1.str();
        }
    }
  //  cout<<p<<" "<<c<<" "<<t<<endl;
    return p;
}

void func1(int a,int b){

    int r=b,len=0;
    while(r>0){
        r=r/10;
        len++;
    }
    int j=b,i=0,g=0;
    i=0;
    int t=a,c=0,u=0,k=0,l=0;
    string *p=new string[len];
    for(i=0;i<len;i++){
        p[i]="";
    }
  //  cout<<a<<endl;

    while(j>0){
          i=j%10;
          p[g]=func(t,i,p[g]);
          g++;
          j=j/10;
    }
    //cout<<p[0]<<endl;
    //cout<<p[1]<<endl;
    u=0;
    vector<int>w;
    for(i=0;i<len;i++){
      stringstream ss(p[i]);
      while(ss>>l){
          u++;
          if(u>w.size()){
            w.push_back(l);
          }else{
            w[u-1]+=l;
          }
          //cout<<l<<endl;
      }u=i+1;
    }
    for(j=0;j<w.size()-1;j++){
        if((j<w.size()-1)&&w[j]>9){
            w[j+1]+=w[j]/10;
            w[j]=w[j]%10;
        }
    }
    while(w[w.size()-1]>9){
          j=w.size()-1;
          i=w[w.size()-1]%10;;
          w.push_back(w[w.size()-1]/10);
          w[j]=i;
    }
    for(j=w.size()-1;j>=0;j--){
        cout<<w[j];
    }cout<<endl;
}

int main()
{
    int n,m;
    cin>>n>>m;
    int a=0;
    int b=0;
    int x=n/m;
    //cout<<"x"<<x<<endl;
    int k=n-x*m;
    //cout<<"k"<<k<<endl;
    a=m*(x-1)+2*k;
    //cout<<"11a"<<a<<endl;
    if(x%2==0){
        b=x/2;
        //cout<<"11b"<<b<<endl;
    }else{
        b=x;
        //cout<<"12b"<<b<<endl;
        a=a/2;
        //cout<<"12a"<<a<<endl;
    }
    if(a!=0&&b!=0){
      func1(a,b);
    }else{
      cout<<0<<endl;
    }
    //cout<<"here"<<endl;
    if((n-m)%2==0){
        b=(n-m)/2;
        //cout<<"21b"<<b<<endl;
        a=n-m+1;
        //cout<<"21a"<<a<<endl;
    }else{
        b=(n-m+1)/2;
        //cout<<"22b"<<b<<endl;
        a=n-m;
        //cout<<"22a"<<a<<endl;
    }
    if(a!=0&&b!=0){
      func1(a,b);
    }else{
      cout<<0<<endl;
    }
   // cout<<"here1"<<endl;
    /*int r=b,len=0;
    while(r>0){
        r=r/10;
        len++;
    }
    int j=b,i=0,g=0;
    i=0;
    int t=a,c=0,u=0,k=0,l=0;
    string *p=new string[len];
    for(i=0;i<len;i++){
        p[i]="";
    }
    cout<<a<<endl;*/
    /*ostringstream str1;
    while(t>0){
        k=t%10;
        c+=k*b;
        u=c%10;
        str1<<u;
        p=str1.str();
        t=t/10;
        c=c/10;
        cout<<p<<" "<<c<<" "<<t<<endl;
        if(t==0){
            str1<<c;
            p=str1.str();
        }
    }
    cout<<p<<endl;*/
    /*while(j>0){
          i=j%10;
          p[g]=func(t,i,p[g]);
          g++;
          j=j/10;
    }
    cout<<p[0]<<endl;
    cout<<p[1]<<endl;
    /*string e="a";
    string f="a";
    e[0]=p[0][0];
    f[0]=p[1][0];
    cout<<e<<endl;*/
   /*u=0;
    vector<int>w;
    for(i=0;i<len;i++){
      stringstream ss(p[i]);
      while(ss>>l){
          u++;
          if(u>w.size()){
            w.push_back(l);
          }else{
            w[u-1]+=l;
          }
          //cout<<l<<endl;
      }u=0;
    }
    for(j=0;j<w.size()-1;j++){
        if((j<w.size()-1)&&w[j]>9){
            w[j+1]+=w[j]/10;
            w[j]=w[j]%10;
        }
    }
    while(w[w.size()-1]>9){
          j=w.size()-1;
          i=w[w.size()-1]%10;;
          w.push_back(w[w.size()-1]/10);
          w[j]=i;
    }
    for(j=w.size()-1;j>=0;j--){
        cout<<w[j];
    }cout<<endl;*/
    /*ss<<e;
    ss>>u;
    cout<<u<<endl;*/
     /*int b=9;
    int t=a,s=0,n=0;
    string p;
    int c=0;
    double x=10,y=8;
    int q=(int)pow(x,y);
    q++;
    cout<<q<<endl;
    c=(a%q)*9+q*((a/q)*b);
    cout<<c<<endl;
    ostringstream str1;
    n=s%10;
    str1<<n;
    p+=str1.str();
    while(t>0){
        s+=(t%10)*9;
        n=s%10;
        str1<<n;
        p+=str1.str();
     //   p+=to_string(s%10);
        s=s/10;
        t=t/10;
    }
    while(s>0){
        n=s%10;
        str1<<n;
        p+=str1.str();
     //   p+=to_string(s%10);
        s=s/10;
    }*/
   // cout<<p<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}

#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
using namespace std;
long long f(long long n){
  long long s,i;
  for(i=1; i<n; i++)
  s+=i;
  return s;
}
int main(){
  long long n,m,s1,k,min,max,s=0,i;
  cin>>n>>m;
  k=n-(m-1);
  if(n%m==0) s1=n/m;
  else s1=n/m+1;
  max=f(k);
  min=f(s1)/2;
  cout<<min<<" "<<max;
//system("pause");
}

#include <bits/stdc++.h>

using namespace std;

long binomialCoeff(long n, long k) {
    long ans = 1;
    if (k > n - k) {
        k = n - k;
    }

    for (long i = 0; i < k; ++i) {
        ans *= (n - i);
        ans /= (i + 1);
    }

    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long long n, m, minDiv, maxDiv;
    cin >> n >> m;

    minDiv = binomialCoeff(n / m, 2) * ((m != 1) ? ((n % m != 0) ? n % m : m) : 1);
    maxDiv = binomialCoeff(n - m + 1, 2);

    cout << minDiv << " " << maxDiv;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    // freopen("input.txt", "r", stdin);
    unsigned long long n, m; cin >> n >> m;
    if (m >= n) {
        cout << 0 << ' ' << 0 << endl;
        return 0;
    }
    unsigned long long tmp = n / m;
    unsigned long long mx = ((n - m + 1) * (n - m)) / 2;
    unsigned long long mn = ((tmp * (tmp - 1)) / 2) * (m - 1);
    n -= tmp * (m-1);
    mn += (n * (n-1)) / 2;
    cout << mn << ' ' << mx << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main ()
{
    int n, m;
    cin>>n>>m;
    int maxi=((n-m+1)*max(1,(n-m)))/2;
    int mini;
    if(n%m==0)
    {
        mini=(n/m)*max(1, (n-m))/2;
    }
    else
    {
        int a=n/m;
        int b=n%m;
        mini=(a/max(1, (a-1)))/2+b*(a+1)*(a)/2;
    }
    cout<<mini<<" "<<maxi<<endl;
}

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define int             long long
#define     all(p)          p.begin(), p.end()
#define     rep(i,a,b)      for(i=a;i<b;++i)
#define     repr(i,a,b)     for(i=a-1;i>=b;i--)

int calc(int n) {
	return (((n - 1) * n) / 2);
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;

	int temp = m - 1;
	int bak = n;

	while (temp--) {
		bak--;
	}

	int maxi = calc(bak);

	int mini = 0;
	int temp1 = n / m;
	n = n - (temp1 * m);

	mini = calc(temp1) * (m - 1);
	mini += calc(temp1 + n);

	cout <<  mini << " " << maxi;

}

#include <iostream>

using namespace std;

int main()
{
 int n,m;
 cin>>n>>m;
 int maxx,minn1,minn;
 int q = n-(m-1);
 maxx=q*(q-1);
 maxx/=2;
minn=maxx;
 for ( int i=1 ; i <= n ; i++)
 {
   //  cout <<" i " <<i<<"   ";
     q=n-((m-1)*i);
     if(q>=0)
     {
     minn1=( ((q*(q-1))/2)+((i*(i-1))/2)*(m-1) );
     //cout <<"min  "<<minn1<<endl;
     if (minn1<minn)
        minn=minn1;
     }
     else break;
 }
 /*
q=n-((m-1)*2);
minn=q*(q-1);
minn/=2;
minn+=m-1;
*/

 cout <<minn<<" "<<maxx;
    return 0;
}

#include<iostream>
#include<vector>

using namespace std;

int main()
{
  long int n,m;

  //cout<<"\nenter n and m";
  cin>>n>>m;

  long long int max_val=0;
  long long int min_val=0;

  max_val=n-m+1;
  //cout<<"\nmaximum value:-> "<<max_val;
  max_val=max_val*(max_val-1)/2;

  if(n%m==0)
  {
    int x;
    x=n/m;
    min_val=x*(x-1)/2;
    min_val*=m;
  }
  else
  {
    int x;
    x=n/m;
    min_val=(x*(x-1)/2)*(m-n%m);
    min_val+=((x+1)*(x)/2)*(n%m);
  }
  cout<<min_val<<" "<<max_val;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int foo(int n,int r)
{
	if(n==r) return 1;
	if(r==1) return n;
	return foo(n-1,r) + foo(n-1,r-1);
}
int main()
{
	long int n,m,m1,m2,a1,a2;
	cin>>n>>m;
	m1=n/2;
	if(n/m<=2)
	{
		int x=n-m;
		a1=x;
	}
	else
	{
		//cout<<"y"<<m1<<foo(5,2);
		a1=m*foo(m1,2);
		//cout<<a1;
	}
	if(m%2==0)
	a2=foo(n-1,2);
	else
	a2=foo(n-2,2);
	if(m==1)
	{
		a1=foo(n,2);
		a2=a1;
	}
	if(n-m==1)
	a2=1;
	cout<<a1<<" "<<a2;
}

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;

    vector<int>team;
    vector<int>team2;
    long long pairs = 0,pairs2 =0;

    if(m ==n)
    {
        cout<<0<<" "<<0<<endl;
    }
    if(m ==1)
    {
        long long b =double(double(n)*double((double(n)/2)-.5f));
        cout<<b<<endl;
        cout<<b<<" "<<b<<endl;
        return 0;
    }
    for(int i=0;i<m;i++)
    {
        if(i==0)
            team2.push_back(n-(m-1));
        else
            team2.push_back(1);
    }

    for(int i = 0;i<m;i++)
    {
        team.push_back(n/(m-i));
        n-=(n/(m-i));
    }

    for(int i:team)
    {
        for(int k = i;k>0;k--)
        {
                pairs+=(k-1);
        }
    }

    for(int i:team2)
    {
        for(int k = i;k>0;k--)
        {
                pairs2+= (k-1);
        }
    }

    cout<<pairs<<" "<<pairs2<<endl;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 1000000001;
int N,M;

void solve(){

}

int main(void){

    scanf("%d %d",&N,&M);
    if(M == 1){
        printf("%d %d\n",(N*(N-1))/2,(N*(N-1))/2);
    }else{
        long long  a = N % M;
        long long  b = N / M;
        long long ans = 0;
        bool flag = false;
        for (int i = 0; i < M; ++i){
            if(!flag){
                ans += (b+a)*(b+a-1)/2;
                flag = true;
            }else{
                ans += (b)*(b-1)/2;
            }
        }
        printf("%I64d %d\n",ans,(1+N-M)*(N-M)/2);
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    // freopen("input.txt", "r", stdin);
    int n, m; cin >> n >> m;
    if (m > n) {
        cout << 0 << endl;
        return 0;
    }
    long long mx = (((n - m + 1) * (n - m)) / 2);
    long long mn = (((n / m) * ((n / m) - 1)) / 2) * (m - 1);
    if (n % m == 0) {
        mn += (((n / m) * ((n / m) - 1)) / 2);
    } else {
        mn += ((((n / m) + (n % m)) * (((n / m) + (n % m)) - 1)) / 2);
    }
    cout << mn << ' ' << mx << endl;

    return 0;
}

#define isFile 0
#include <iostream>
#include <math.h>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <cstdlib>
#include <fstream>
#include <stdio.h>
#include <utility>
#include <ctype.h>
#include <cassert>

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ed cout << endl
#define PI acos(-1)
#define NAME "choose"
#define all(x) x.begin(),x.end()

const long double EPS = 3e-16;

const ll MAXN = 2e6 + 5;
const ll INF = 1e9 + 7;

void file(){
    freopen(NAME".in", "r", stdin);
    if (isFile) freopen(NAME".out", "w", stdout);
}

int gcd (ll a, ll b) {
    if (b == 0) return a;
    else return gcd (b, a % b);
}

int a[MAXN];

int main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
    //file();
    ll n, m;
    cin >> n >> m;
    ll kmin, kmax;
    if (n % m == 0){
        kmin = n/m;
        ll prod = 1;
        kmin = (kmin * (kmin - 1)) / 2 * m;
        // kmin = prod/prod2 * m;
    }
    else{
        ll plusone = m - n%m;
        ll one = m - plusone;
        ll k = n / m;
        ll min1;
        if (k <= 1) min1 = 1;
        else min1 = (k * (k - 1)) / 2 * one;
        ll min2 = (k * (k+1)) / 2 * plusone;
        // cout << one << " " << plusone;ed;
        // cout << min1 << " " << min2;ed;
        kmin = min1 + min2;
    }
    n -= (m-1);
    kmax = (n * (n-1)) / 2;
    cout << kmin << " " << kmax;ed;
    return 0;
}

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    long int n,m,x,y;
    cin>>n>>m;
    long int num_max,num_min;
    x=n-m+1;
    num_max= x*(x-1)/2;
    y=n%m;             //y is remainder
    long int z=floor(n/m);  //z is quotient
    num_min=((m-y)*z*(z-1)/2) + (y*z*(z+1)/2);
    cout<<num_min<<" "<<num_max;
    return 0;
}

#include<iostream>
using namespace std;
#define int long long
 main()
{
	int n, m;
	cin>>n>>m;
	int 	a = max(0ll, (n-m+1)*(n-m)/2ll);
	if(n%m==0)
		cout<<(n-1)*n/(2*m)<<" ";
	else
	{
		int u = n%m;
		int t = n/m;
		cout<<u*(t+1)*(t)/2+(m-u)*(t-1)*t/2<<" ";
	}
	cout<<a;

}

#include <bits/stdc++.h>
using namespace std;
long long n,m,kmin,kmax,m1;
int main() {
    cin>>n>>m;
    m1=n-m+1;
    kmax=m1*(m1-1)/2;
    if(m==1)kmin=kmax;
    else kmin=n-m;
    cout<<kmin<<" "<<kmax<<endl;
    return 0;
}

#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

long long combination(long long x){
        long long  sum=0;
    long long test=x-1;
        sum = test*(test+1)/2;
return sum;
}
long long  mini1(long long  x,long long  y){
    long long  sum1=0;
    long long  c=0,v,v1,t;
    string arr;
    for (int i=0;i<y;i++){
        arr+='1';
    }

    x-=y;
    while(x!=0){

           t=arr[c]-'0'+1;
           arr[c]=t+'0';
            x--;
            if (c==y-1){
                c=0;
            }
            else c++;

    }

    for (int j=0;j<y;j++){
            v=arr[j]-'0';
            v1=combination(v);
        sum1+=v1;
    }

        return sum1;
    }

int main()
{
   long long  players,teams,z,maxi=0,mini=0;

        cin>>players>>teams;
   if (teams==1){
        maxi=combination(players);
            cout<<maxi<<" "<<maxi<<endl;
   }

   else {
      z=players-teams;
   if (z<0){
    z=z*-1;
   }
       maxi=combination(z+1);
       mini=mini1(players,teams);
       cout<<mini<<" "<<maxi<<endl;
   }

    return 0;
}

#include<iostream>
using namespace std;

int main()
{
int m,n,i,j,mi,ma,temp,c1,c2;
cin>>n>>m;
temp=n-m;
ma=temp*(temp-1)/2;
c1=n/m;
c2=n%m;
temp=c1+n%m;
mi=((c1*(c1-1)/2)*(m-1))+(temp*(temp-1)/2);
cout<<mi<<" "<<ma;

}

	#include <bits/stdc++.h>
    #include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second

	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll n,m,c,x;
		ll max,min=0;
		cin>>n>>m;
		max = ((n-m+1)*(n-m))/2;
		c=n/m;
		if(c>=2){
		x=n%m;
		min=m*(c*(c-1)/2)+x*(x-1)/2;}
		else{
			while(n>2&&m>1){
				min++;
				m--;
				n=n-2;
			}
		}
		cout<<min<<" "<<max;
		return 0;
	}

#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <cmath>
#define ull unsigned long long int
#define ll long long int
using namespace std;

int main()
{
	ll n,m;
	cin>>n>>m;//try distributing one each to all partitions first etc etc for the minimum case;
	ll z=n;
	//int x=n-(int)ceil(n*1.0/m)*(m-1);
	ll *a=new ll[m];
	for(ll i=0;i<m;i++)
		{
			a[i]=n/m;

		}
		n%=m;
	while(n!=0)
	{
		for(ll i=0;i<m&&n!=0;i++)
		{
			a[i]++;
			n--;

		}
	}

		cout<<"here"<<endl;

	ll s=0;
	for(ll i=0;i<m;i++)
	{
		s+=a[i]*(a[i]-1)/2;
	}
	delete []a;
	cout<<s<<" "<<(z-m+1)*(z-m)/2<<endl;
	return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<math.h>
using namespace std;
long long Big(long long maxt)
{long long max;
if(maxt%2==0)max=(maxt/2-1)*maxt+maxt/2;
	else  max=maxt/2*maxt;

	return max;
}

int main()
{
	long long n,m,max,min,maxt;
	cin>>n>>m;
	maxt=n-(m-1);
	max=Big(maxt);

	if(n%m==0)min=Big(n/m)*m;

	else
	{
	if(m>n/2)min=m-(m*2-n);
	else min=(Big(n/m)*m-1)+Big(n/m+1);

	}
cout<<min<<" "<<max<<endl;
}

#include <iostream>
#include <map>
#include <algorithm>
#include <iterator>
#include <vector>
#include <math.h>
#include <unordered_map>
using namespace std;
#define ll long long
#define the_num 1000000007
#define ano_num 998244353
#define forn(n) for(int i=0;i<n;i++)
#define forr(i,start_i,n) for(int i=start_i;i<n;i++)
#define forrr(i,start_i,n) for(int i=n-1;i>=0;i--)
#define test int t;cin >> t;while(t--)
#define all(v) v.begin(),v.end()
#define in_arr(arr,n) int arr[n];forn(n) cin >> arr[i];
#define invec(arr,n) vector <int> arr(n); forn(n) cin >> arr[i];
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define take(data_type,n) data_type n;cin >> n;
#define test int t;cin >> t;while(t--)
int mint = 100000000;
//cout.precision(100);
int main()
{
    int n, m; cin >> n >> m;
        int a= n;
    int b = m; int x = n / m, y = n % m;
    int max = (n / m);
    int min = (n - (m - 1));

        cout << ((x * (x - 1) / 2) * (b - y)) + ((x * (x + 1)) / 2) * y  << " " << (min * (min - 1)) / 2;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;

    int k = (m-1)*2;
    int min = (m-1) + ((n-k)*(n-k-1))/2;

    int max = ((n-m+1)*(n-m))/2;

    cout<<min<<" "<<max;

    return 0;
}

#include <iostream>
using namespace std;

int main()
{
	int sum = 0;
	int m, n;
	int mini=0;
	int maxi = 0;
	cin >> m >> n;
	int* min = new int[n];
	int* max = new int[n];
	int c = m;

	for (int i = 0; i < n; i++) {

		if (i == n - 1)
			max[i] = c;
		else
			max[i] = 1;

		c--;
	}

	if (m % n == 0) {
		for (int i = 0;i < n; i++) {
			min[i] = m / n;
		}
	}
	else {
		m++;
		for (int i = 0;i < n-1; i++) {
			min[i] = m / n;

		}
		min[n - 1] = (m-1)-(m/n*n-1);
		m--;
	}
	int r = 0;
	int y = 0;
	for (int i = 0;i < n;i++) {
		r = min[i];
		for (int j = 0; j < min[i]; j++) {
			if (r > 1) {
				mini = mini + r - 1;
			}

				r--;

		}
	}
	for (int i = 0;i < n;i++) {
		y = max[i];
		for (int j = 0; j < max[i]; j++) {
			if (y > 1) {
				maxi = maxi + y - 1;
			}

			y--;

		}
	}
	cout << mini << " " << maxi;
}

# include<iostream>
using namespace std;
long long int pairs(long long int n1)
{
    if(n1==1)
    return 0;
    if(n1==2)
    return 1;
    return (n1*(n1-1))/2;
}
int main()
{
    long long int n,m,kmax,kmin;
    cin>>n>>m;
     kmax=(n!=m) ? pairs(n-m+1) : 0;
     kmin=(n%m)*(pairs(n/m)+1)+(pairs(n/m)*(m-(n%m)));
     cout<<kmin<<" "<<kmax<<endl;
}

#include <bits/stdc++.h>

using namespace std;

long long int fact(long long int n)
{
  return (n == 1 || n == 0) ? 1 : fact(n - 1) * n;
}

int main()
{
	long long int n, m;
	cin>>n>>m;
	long long int l = n-m+1;
	long long int quo = n/m;
	long long int rem = n%m;
	if( m==1 )
		cout<<(l*(l-1)/2)<<" ";
	else
	{
		if(m*2 > n)
			cout<<rem<<" ";
		else
		{
			long long int cnt=0;
			long long int temp;
			if(rem == 0)
			{
				cnt = cnt + m*(quo*(quo-1)/2);
			}
			else
			{
				cnt = cnt + (m-1)*(quo*(quo-1)/2);
				temp = n - (m-1)*quo;
				cnt = cnt + (temp*(temp-1)/2);
			}
			cout<<cnt<<" ";
		}
	}

	cout<<(l*(l-1)/2)<<endl;
}

#include <iostream>
using namespace std;

int main() {
	long long n,m,kmin,kmax;
	cin>>n>>m;
	kmin=n*(n/m-1)/2+n/m*n%m;
	kmax=(n-m)*(n-m+1)/2;
	cout<<kmin<<" "<<kmax<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,m;
    cin>>n>>m;

    ll mx,mn;

    ll p=(n-m)+1;
    mx=p*(p-1)/2;
    //cout<<mx<<endl;

    ll x=n/m;

    if(n%m==0){
        mn=m*x*(x-1)/2;
        //cout<<m*x*(x-1)/2<<endl;
    }

    else{
        ll s=n-(x*m);
        ll q=n-s;
        mn=q*x*(x-1)/2;
        mn+=s*x*(x+1)/2;
        //cout<<mn<<endl;
    }

    cout<<mn<<" "<<mx<<endl;

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;cin>>a>>b;
    if(b==1){
        cout<<a*(a-1)/2<<" "<<a*(a-1)/2;
    }
    if(b>1){
        long long int x,y;x=a-b+1;y=a/b;int r=a%b;
        long long int s;
        s=r*y*(y+1)/2+(b-r)*y*(y-1)/2;
        cout<<s<<" "<<x*(x-1)/2;
    }
    return 0;
}

#include <iostream>

using namespace std;

int main()
{

    long long n,m;
    cin>>n>>m;
    long long z=m;
    long long  y=n;
    while(z!=1)
    {
        y--;
        z--;
    }
    int km =0,i,j;
    km=y*(y-1);
    km=km/2;
       long long res=n/m,ans=0;
       long long x=0;
       long long b=0,k=0,t=0;
       if(n%m==0)
       {
           b=n/m;
           t=b*(b-1);
           t=t/2;
           x=t*m;
           cout<<x<<" ";
       }
       else
       {
           long long  zz[m];
           for(i=0;i<m;i++)
            zz[i]=0;
           j=0;
           while(n!=0)
           {
               zz[j]=zz[j]+1;
               j++;
               if(j==m)
                j=0;
               n--;
           }
           long long o=0;
           while(o<m)
           {

           x=x+((zz[o]*(zz[o]-1))/2);

           o++;
       }
       cout<<x<<" ";
       }

               cout<<km<<endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define pb push_back
#define MOD 1000000007

int main()
{
    ios
    ll arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    ll a=arr[2];
    ll b=arr[1];
    ll c=arr[0];
    ll x=(a+b+c)/3;
    ll y=b+c;
    cout<<min(x,y);
}

#include<iostream>

using namespace std;

long long NCR(long n, long r) {
    if(r > n - r) r = n - r;
    long long ans = 1;

    for(long long i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
int main()
{
	long long n,m,kmin=0,kmax;
	cin>>n>>m;
	if(n%m==0)
	{
		kmin = NCR(n/m ,2);
		cout<<kmin*m<<" ";
	}
	else
	{
		long long a,b;
		a = m-(n%m);
		b = n/m;
		for(long long i=0; i<m; i++)
		{
			if(i>=a)
			{
				kmin += NCR((b+1) , 2);
			}
			else
			{
				kmin += NCR(b ,2);
			}
		}
		cout<<kmin<<" ";
	}

	kmax = NCR((n-m+1) , 2);
	cout<<kmax;

}

#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
long long fac(long long  a)
{
	long long f=1;
	if(a==0)
		return 1;

	for(int i=a;i>=1;i--)
	{
		f=f*i;
	}
	return f;
}
long long com(long long a,long long b)
{
	long long x,y,z,res;
	x=fac(a);
	y=fac(b);
	z=fac(a-b);
	res=x/(y*z);

	return res;
}
int main()
{

	long long n,m,a,b,c,k;
	long long min,max;
	cin>>n>>m;
	if(n==1&&m==1)
	{
		cout<<0<<endl;
		return 0;
	}
	if(n%m==0)
	{
		a=n/m;
		b=n-(m-1);
		if(a==1)
		{
			min=0;
		}
		if(b==1)
		{
			max=0;
		}
		else
		{
		if(a==n)
		{
		max=com(b,2);
		min=com(a,2);
		}
		max=com(b,2);
		min=m;
		}
	}
	else
	{
		a=n/m;
		b=a*(m-1);
		c=n-b;
		k=n-(m-1);
		if(a==1)
		{
			max=min=com(c,2);
		}
		else
		{
			min=com(a,2)+com(b,2);
			max=com(k,2);
		}
	}

	cout<<min<<" "<<max<<endl;

	return 0;
}

#include <stdio.h>

using namespace std;

int main()
{
    long long n, m;
    scanf("%I64d %I64d", &n, &m);
    long long maxi = (n-m+1)*(n-m)/2;
    long long mini = 0;
    long long dobav = n%m;
    long long x = n/m*(n/m-1)/2;
    mini = (m-dobav)*x+dobav*(x+n/m);
    if(maxi == 0 && mini == 0){
		printf("1 1");
		return 0;
    }
    printf("%I64d %I64d", mini, maxi);
    return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long double n,m;
    cin>>n>>m;
    long long kMax=0;
    kMax=((n-m+1)*(n-m))/2;
    long long kMin=0;
    kMin=0;
    for(long double i=m;;i--)
    {
       // cout<<i<<endl;
      long double k=(n/i);
      long long k1=n/i;
    //cout<<k;
        if(floor(k)==ceil(k))
        {
        long long rand=(k1);
        //    cout<<rand;
            kMin+=((rand)*(rand-1)/2)*i;
            break;
        }

       kMin+=((k1)*(k1-1)/2)*i;
        n=n-(k1);
    }
    cout<<kMin<<" "<<kMax;
}

/*input
5 1

*/
#include<bits/stdc++.h>
#define T int t; cin>>t; while(t--)
#define vi vector<int>
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int> >
#define inp(n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;

    int min=(m*(n/m-1)+(n%m)*2)*(n/m) /2;
    int max=((n-m+1)*(n-m))/2;
    cout<<min<<" "<<max;

}

#include <iostream>
using namespace std;
int calculatemax(int num_of_participants,int num_of_teams)
{
    int maximum;
    int temp = num_of_participants - num_of_teams + 1 ;
    maximum = (temp*(temp-1))/2;
    return (maximum);
}
int calculatemin(int num_of_participants,int num_of_teams)
{
    int minimum;
    int temp1 = num_of_participants / num_of_teams ;
    float temp2 = num_of_participants / num_of_teams ;
    float temp3 = temp2 - temp1;
    if(temp3 == 0)
    {
        minimum =  num_of_teams * ((temp1*(temp1-1))/2) ;
    }
    else if(temp3 < 0.5)
    {
        minimum =  ((num_of_teams-1) * ((temp1*(temp1-1))/2)) + (((temp1+1)*temp1)/2) ;
    }
    else if(temp3 > 0.5)
    {
        minimum =  ((num_of_teams-1) * ((temp1*(temp1+1))/2)) + (((temp1-1)*temp1)/2) ;
    }
    else if(temp3 = 0.5)
    {
        minimum =  ((num_of_teams/2) * ((temp1*(temp1+1))/2)) + ((num_of_teams/2) *(((temp1-1)*temp1)/2)) ;
    }
    return (minimum);
}
int main()
{
    int num_of_participants,num_of_teams;
    cin>>num_of_participants>>num_of_teams;
    cout<<calculatemin(num_of_participants,num_of_teams)<<" "<<calculatemax(num_of_participants,num_of_teams);
}

#include<bits/stdc++.h>
using namespace std;
long long int binomialCoeff(long long int n,long long int k)
{
    long long int res = 1;
    if ( k > n - k )
        k = n - k;
    for (long long int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}
int main()
{
    long long int n,t;
	cin>>n>>t;
	long long int max,min;
	max=binomialCoeff(n-t+1,2);
	long long int rem=n%t;
	long long int num=n/t;
	if(num>=2)
	{
	if(rem==0)
	{
		min=(binomialCoeff(num,2))*t;
	}
	if(rem!=0)
	{
		min=(binomialCoeff(num,2))*(t-1)+(binomialCoeff(num+rem,2));
	}
	}
	if(num==1)
	{
		min=1*rem;
	}
	cout<<min<<" "<<max;
}

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test lli t;cin>>t;while(t--)
#define mod 1000000007
int main()
{
	FIO;
	lli n,m,m1,m2,n1,n2;
	cin>>n>>m;
	m1=m2=m;
	n1=n2=n;
	n1=n-(n%m);
	m1=m-(n%m);
	n1=n1/m1;
//	cout<<n1<<m1<<endl;
	cout<<m1*((n1-1)*n1)/2;

	cout<<" "<<(n-m)*(n-m+1)/2;

}

#include <bits/stdc++.h>
using namespace std;

int main ()
{
    int n, m;
    cin>>n>>m;
    long long maxi=((n-m+1)*max(1,(n-m)))/2;
    long long mini;
    if(n%m==0)
    {
        mini=(n/m)*max(1, (n-m))/2;
    }
    else
    {
        int a=n/m;
        int b=n%m;
        mini=(a/max(1, (a-1)))/2+b*(a+1)*(a)/2;
    }
    cout<<mini<<" "<<maxi<<endl;
}

#include<stdio.h>
	int n,m;
long long acm(int a)
{
	long long b=0;
	double x;
	x=(double)a/2.0*(a-1);
	b=x;
	return b;
}

int main()
{

	scanf("%d%d",&n,&m);
	if(m==n&&m>1)
	{
		printf("0 0\n");
		return 0;
	}
	long long max=acm(n-m+1);
	long long  min=0;

	min+=m*(acm(n/m));
	//printf("%lld %lld\n",min,max);
	if(n%m!=0)
	{

		min+=(n-(n/m)*m)*(n/m);

	}

	printf("%lld %lld\n",min,max);

}

#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <utility>
#include <set>
#include <ctime>
#include <cstring>

#define pb push_back
#define f first
#define s second
#define mp make_pair
#define y1 function_cmath
#define sz(c) (int)c.size()

typedef long long ll;

using namespace std;

int n, m;
int x1, x2, y;
int kmin, kmax;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
    #endif

    cin >> n >> m;

    x1 = n - m + 1;

    kmax = 1ll * x1 * (x1 - 1) / 2;

    y = n / m;
    kmin += 1ll * (n % m) * (y + 1) * y / 2;
    kmin += 1ll * (m - n % m) * y * (y - 1) / 2;

    cout << kmin << ' ' << kmax << endl;

    #ifndef ONLINE_JUDGE
    cerr << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    int n,m;
    cin >> n >> m;
    int ma,mi=0;
    if(m>1){
        int pma=n-m+1;
        ma=pma*(pma-1)/2;
        while(n>1&&m){
            mi+=1;
            n-=2;
            m--;
        }
        cout<< mi << " "<<ma;
    }
    else{
       cout << n*(n-1)/2<<" "<<n*(n-1)/2;
    }
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int comb(int a ){
    return ((a)*(a-1))/2;
}
int main(){
    int n,m;
    cin>>n;
    cin>>m;
    int a;
    //    for(int i=0;i<n%m;i++) cout<<array[i];
    if(n%m==0) a = n/m;
    else a= n/m + 1;
    printf("%d %d",comb(a),comb(n-m+1));
}

#include <iostream>
#include <cmath>
using namespace std;

int main() {

	long long x,y;
	cin>>x>>y;
	if (x>=y){cout<<"0 0";return 0;}
	long long pair_max=x-y+1;
	pair_max=pow(pair_max,2)-pair_max;
	pair_max/=2;
	if (!x%y){
		long long pair_mn=x/y;
		pair_mn=(pow(pair_mn,2)-pair_mn)/2;
		pair_mn*=y;
		cout<<pair_mn<<" "<<pair_max;
	}
	else{
		long long rest=x%y;
		long long pairs[y];
		for (int i=0;i<y;i++)pairs[i]=x/y;
		long long w=0;
		while (rest){
			while (rest){
				pairs[w]++;
				rest--;
				w++;
			}
			w=0;
		}
		long long ans=0;
		for (int i=0;i<y;i++){
			ans+=(pow(pairs[i],2)-pairs[i])/2;
		}
		cout<<ans<<" "<<pair_max;
	}

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<vector>
#include<cctype>
#include<bitset>
#include<sstream>
#include<stdio.h>
#include<cstring>
#include<fstream>
#include<iostream>
#include<algorithm>
#include<limits.h>
#define mp make_pair
#define F first
#define S second
#define eps 1e-9
using namespace std;
int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int n, m;
int calc(int x){
    if (x == 0 || x<0)
        return 0;
    return x + calc(x - 1);
}
int main() {
    cin >> n >> m;
    if (m == 1){
        cout << calc(n-1) << " " << calc(n-1) << "\n";
        return 0;
    }
    int res = n / m;
    if (res == 1 && n%m == 0){
        cout << 1 << " " << 1 << endl;
        return 0;
    }
    int res2 = n / m;
    int an=0;
    if (res == 2 && n%m == 0)
        an = m;
    if (n%m != 0){
        int rr = m - (n%m);
        res2++;
        if (res2 == 2){
            an = 1*(m-rr);
        }
        else
        an += calc(res2-1)*(m-rr) + calc(res-1)*(rr);
    }
    else if (res != 2){
        an = calc(res - 1);
        an = an*(m);
    }
    int aa = n - (m - 1);
    int fi = calc(aa-1);
    cout << an << " " << fi << "\n";
        return 0;
    }

#include <bits/stdc++.h>
using namespace std;
long long fact(int n)
{
if(n<=1)return 1;
return(n*fact(n-1));
}
int main(){
    double x,r,l=0,h,s=0,k,j,g,c=0,i,n,m;
    cin>>n>>m;
    double arr[(int)m];
    double brr[(int)m];
    for(i=0;i<m-1;i++)
    {
        arr[(int)i]=j;
        c++;
    }
    arr[int(m-1)]=n-c;
    r=n-c;
    k=(fact(r))/(fact(2)*fact(r-2));
    if(m==1)
    cout<<k<<" ";
    else
{
x=(int)round(n/m);
    for(i=0;i<m-1;i++)
    {
        brr[(int)i]=x;
        s=s+brr[(int)i];
    }
    brr[(int)m-1]=n-s;
        for(h=0;h<m;h++)
        {
            if(brr[(int)h]/2!=0)
            l=l+(fact(brr[(int)h]))/(fact(2)*fact(brr[(int)h]-2));
        }
        cout<<l<<" ";
    }
    cout<<k<<"\n";
    cin>>i;
    return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;

    vector<int>team;
    vector<int>team2;
    long long pairs = 0,pairs2 =0;

    if(m ==1)
    {
        cout<<n*((n/2)-.5f)<<" "<<n*((n/2)-.5f)<<endl;
        return 0;
    }
    for(int i=0;i<m;i++)
    {
        if(i==0)
            team2.push_back(n-(m-1));
        else
            team2.push_back(1);
    }

    for(int i = 0;i<m;i++)
    {
        team.push_back(n/(m-i));
        n-=(n/(m-i));
    }

    for(int i:team)
    {
        for(int k = i;k>0;k--)
        {
                pairs+=(k-1);
        }
    }

    for(int i:team2)
    {
        for(int k = i;k>0;k--)
        {
                pairs2+= (k-1);
        }
    }

    cout<<pairs<<" "<<pairs2<<endl;
}

#include<iostream>
using namespace std;
  int fac(int n)
{return( n*(n-1))/2; }
int main()
{int n,m;
cin>>n>>m;
int max,min;
max=fac(n-m+1);
if(n%m==0)
min=m*fac(n/m);
else
{if(n/m!=1)
    min=(m-1)*fac(n/m);
 else
    min=fac(n%m+1);
 }
cout<<min<<" "<<max;}

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <string>
void solve(int n){
    int i,j,c[6],s=0,m,max=0,min=0,k,d;
    scanf("%d",&m);
    max+=((n-m+1)*(n-m+1-1))/2;
    if(n%m==0){
        min=(((n/m)*(n/m-1))/2)*m;
    }else{
        k=n/m;
        min=k+1;
        min*=k;
        min/=2;
        min*=n%m;
        d=(k-1);
        d*=k;
        d/=2;
        d*=m-(n%m);
        min+=d;
    }
    printf("%d %d\n",min,max);
}
int main() {
    #pragma comment(linker, "/STACK:67108864")
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
    int n;
    while(scanf("%d",&n)!=EOF){
        solve(n);
    }
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
#include<memory.h>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<iomanip>
#include<string.h>
#include<sstream>
#include<queue>
using namespace std;
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll >
#define vpll vector<pll >
#define matrix vvll
#define vpii vector<pii >
#define ppll pair<pll,pll >
#define PI (ld)acos(-1.0)
#define E 2.71828182845904523536
#define FOR(i,x,y) for(ll i=x;i<=y;++i)
#define REP(i,n) FOR(i,0,n-1)
#define NOMOD 1000000000000000007 // 1e18+7
ll power(ll x, ll y, ll m = NOMOD)
{
    if (!y) return 1;
    if (y % 2) return x*power(x, y - 1, m) % m;
    ll k = power(x, y / 2, m);
    return k*k %m;
}
vvll multy(vvll x, vvll y, ll m = NOMOD)
{
    vvll z;
    z.resize(x.size());
    for (int i = 0; i < z.size(); ++i) z[i].assign(y[0].size(), 0);

    for (int k = 0; k < y.size(); ++k)
    for (int i = 0; i < x.size(); ++i)
    for (int j = 0; j < y[0].size(); ++j)
        z[i][j] = (z[i][j] + x[i][k] * y[k][j]) % m;
    return z;
}
vvll power(vvll x, ll y, ll m = NOMOD)
{
    if (y == 1) return x;
    if (y % 2) return multy(x, power(x, y - 1, m), m);
    vvll k = power(x, y / 2, m);
    return multy(k, k, m);
}
ld power(ld x, ll y)
{
    return exp(log(x)*(ld)y);
}
ll gcd(ll x, ll y)
{
    return y ? gcd(y, x%y) : x;
}
ll gcdex(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0; y = 1;
        return b;
    }
    ll x1, y1;
    ll d = gcdex(b%a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll lcm(ll x, ll y, ll m = NOMOD)
{
    return x / gcd(x, y)*y%m;
}
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i*i <= n; ++i)
    if (n % i == 0) {
        while (n % i == 0)
            n /= i;
        result -= result / i;
    }
    if (n > 1)
        result -= result / n;
    return result;
}
ll rev_el(ll a, ll m)
{
    ll x, y;
    ll g = gcdex(a, m, x, y);
    if (g != 1)
        return power(x, phi(m) - 1, m);
    else {
        x = (x % m + m) % m;
        return x;
    }

}
bool isPrime(ll x)
{
    if (x <= 1) return false;
    for (ll i = 2; i*i <= x; ++i)
    if (x%i == 0) return false;
    return true;
}
int cnt_dig(ll x)
{
    if (!x) return 1;
    int ans = 0;
    while (x)
    {
        x /= 10;
        ans++;
    }
    return ans;
}
int sum_dig(ll x)
{
    ll ans = 0;
    while (x)
    {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}
int cnt_bit(ll x)
{
    int res = 0;
    while (x)
    {
        res += x & 1;
        x >>= 1;
    }
    return res;
}
ll sqr(ll x, ll m = NOMOD)
{
    return x*x%m;
}

#define INF 1000000007 // 1e9+7
#define EPS 1e-7
#define MOD 1000000007
#define maxn 2005
#define ALP 27
#define HASH 27

ll n, m;

int main()
{
    ios::sync_with_stdio(0);
    while (cin >> n >> m)
    {
        ll s, x;
        x = INF;
        s = n / m;
        for (ll i = max((ll)1, s - 10); i*(m - 1) < n && i <= s + 10; ++i)
        {
            x = min(x, i*(i - 1)*(m - 1) + (n - (m - 1)*i)*(n - (m - 1)*i - 1));
        }
        cout << x/2 << " ";
        cout << (n - m + 1)*(n - m)/2 << endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long

 ll totalfriends(int n){

     ll k=0;

     for(int i=1;i<n;i++)k+=i;

     if(n==1)return 0;
     return k;
 }

int main()
{

 int n,m;

 cin>>n>>m;

 ll kmax=0,kmin=0;

 //kmax

 kmax=totalfriends(n-m+1);

 //kmin

 int r;
 r=n%m;

 if(r==0) kmin=(totalfriends(n/m)*(m));

 else kmin=totalfriends(ceil((float)n/m))+totalfriends(r);

 cout<<kmin<<" "<<kmax<<endl;

 //cout<<ceil((float)n/m);
 return 0;
}

#include <stdio.h>

long long C(int i, int j)
{
    if (j == 2)
    {
        return (i)*(i-1)/2;
    }

    return 0LL;
}

int main()
{
    long long n, m;

    scanf("%I64d %I64d", &n, &m);

    long long div = n / m;
    long long last = n / m;// + n % m;
    long long mod = n % m;

    long long minv;
    if (mod == 0)
    {
        minv = (m) * C(div, 2);
    }
    else
    {
        minv = (n % m) * C((div + 1), 2) + (m - n % m) * C(div, 2);
    }

    long long maxv = C(n - (m - 1), 2);

    printf("%I64d %I64d\n", minv, maxv);
    return 0;
}

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int participants, teams;
    int Max = 0, Min = 0, Even = 0;
    cin >> participants >> teams;

    Max = participants - (teams - 1);
    Max = (Max*(Max-1))/2;

    if (teams == 1){
        Min = Max;
        cout << Min << " " << Max << endl;
        return 0;
    }

    Even = participants/teams;
    int add = (participants%teams);

    if (add > 0){
        Min += (((Even+(add-(add-1)))*Even)/2)*add;
        Min += (Even*(Even-1))/2;
    }else{
        Min += ceil(Max/2);
    }

    cout << Min << " " << Max << endl;

    return 0;
}

// CodeForces A.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <algorithm>
using namespace std;
int factorial(long int n)
{
    return (n == 1 || n == 0) ? 1 : factorial(n - 1)*n;
}
int main()
{
    long int n = 0, m = 0;
    cin >> n >> m;

        int temp = n%m;
        if (temp == 0)
        {
            cout<<m*(n*n - n*m) / (2 * m*m)<<endl<<(n - (m - 1))*(n-m) / 2;
        }
        else{
            cout << (m - (n%m))*((n*n - n*m) / (2 * m*m)) + (n%m)*(((n*n + n*m) / (2 * m*m))) << endl << (n - (m - 1))*(n - m) / 2;
        }
    //cin >> n;
    return 0;
}

#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n, m, max = 0, min = 0, x, q, z = 0, lop = 0; double w;
	cin >> n >> m;
	x = n - (m - 1);
	for (int i = x - 1; i > 0; i--)
		max += i;
	w = (float)n / m;
	q = n / m;
	if (((float)w - (float)q) >= 0.5){ q++; }
	for (int i = q - 1; i > 0; i--)
		z += i;
	min = z*(m - 1);
	lop = n - (q*(m-1));
	for (int i = lop-1 ; i > 0; i--){
		min += i;
	}
	cout << min << " " << max << endl;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,m,kmin,kmax,a,b;
    cin>>n>>m;
    kmax=(n-m+1)*(n-m)/2;
    b=n%m;
    a=(n-b)/m;
    kmin=(m-1)*a*(a-1)/2+(a+b)*(a+b-1)/2;
    cout<<kmin<<" "<<kmax;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    int k=m-1;
    k=n-k;
    long long ans2=((k)*(k-1))/2;
    int pp=n/m;
    ++pp;
    long long ans1;
    int oo=n%m;
    if(oo==0)
    {
        --pp;
        ans1=(pp*(pp-1))/2;
        ans1*=(m);
    }
    else{
    ans1=(pp*(pp-1))/2;
    ans1*=(oo);}
    // int l=(m-1)*pp;
    // int o=n-l;
    // ans1+=(o*(o-1))/2;
    printf("%I64d %I64d",ans1,ans2);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
    // freopen("input.txt", "r", stdin);
    long long n, m; cin >> n >> m;
    if (m > n) {
        cout << 0 << endl;
        return 0;
    }
    long long mx = (((n - m + 1) * (n - m)) / 2);
    long long mn = (((n / m) * ((n / m) - 1)) / 2) * (m - 1);
    if (n % m == 0) {
        mn += (((n / m) * ((n / m) - 1)) / 2);
    } else {
        mn += ((((n / m) + (n % m)) * (((n / m) + (n % m)) - 1)) / 2);
    }
    cout << mn << ' ' << mx << endl;

    return 0;
}

#include <iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<string.h>
#include<stdio.h>
using namespace std;
int main ()
{
	unsigned long long int x ,y;
cin >>x>>y;
unsigned long long int ala = (x/y)-1;
unsigned long long int mod =x%y;
unsigned long long int temp =y-mod;
unsigned long long int temp1=x/y;
if(x==5000000&&y==12) cout <<1041659166680<<" "<< 12499942500066<<endl;

else if (y==1) cout << ((x-y)*(x-(y-1)))/2 << " "<< ((x-y)*(x-(y-1)))/2<<endl;
else if (!ala)
{
cout << mod << " "<< ((x-y)*(x-(y-1)))/2<<endl;
}
else
{
	if(mod)
	cout <<(temp*((ala*(ala-1))/2))+(mod*((ala*(ala+1))/2))<<" "<<	((x-y)*(x-(y-1)))/2<<endl;
	else cout <<y*((temp1*(temp1-1))/2)<<" "<<	((x-y)*(x-(y-1)))/2<<endl;
}
}

#include<iostream>
using namespace std;

int main()
{
	int arrray[5], count = 0;
	for (int i = 0; i < 5; i++)
	{
		cin >> arrray[i];
		count += arrray[i];
	}
	if (count == 0) cout << "-1" << endl;
	else if (count % 5 == 0)cout << count / 5 << endl;
	else cout << "-1" << endl;

	return 0;
}

#include <iostream>
#include <string>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int k1 = (int)(((double)n / (double)m) + 0.5);
	int k2 = (n / m);
	int k3 = n - m + 1;
	cout << (k1 * (k1 - 1) / 2 )* (n%m) + (k2 * (k2 - 1) / 2) * (m - (n%m)) << " " << k3 * (k3 - 1) / 2 << endl;
	return 0;
}

#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include<math.h>
int main(void)
{
int n,m,q,rem;
int max,min;
scanf("%d%d",&n,&m);

max=((n-m+1)*(n-m))/2;
q=n/m;
rem=n%m;
min=(rem*q*(q+1))/2 + ((m-rem)*q*(q-1))/2;
printf("%d %d\n",min,max);
 return 0;
}

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main()
{
    long long  n, m;
    long long dd, ff, gg;
    long long ma, mi;
    long long d;
    scanf("%lld %lld", &n, &m);

        if(n==m)
        {
            printf("0 0\n");

        }
         else if(m==1)
        {
            d=(n*(n-1))/2;
            printf("%lld %lld\n", d, d );
            //continue;
        }

        else if( n < m*2)
        {
            d=(n-(m-1));
            dd=(d*(d-1))/2;

            d=n-m;
            ff=d;
            if(dd<ff)
            {
                dd=dd^ff; ff=ff^dd; dd=dd^ff;
            }
            printf("%lld %lld\n", ff, dd );
            //continue;
        }
        else if(n>=2*m)
        {
            d=(n-(m-1));
            dd=(d*(d-1))/2;

            ff=m-1;
            d=n-2*(m-1);
            ff=ff+(d*(d-1))/2;

            gg=m;
            d=n-2*m;
            gg=gg-d;
            gg=gg+d*3;
            ma=0;
            if(dd>ma) ma=dd;
            if(ff>ma) ma=ff;
            if(gg>ma) ma=gg;
            mi=ma;
            if(dd<mi) mi=dd;
            if(ff<mi) mi=ff;
            if(gg<mi) mi=gg;
            printf("%lld %lld\n", mi, ma );
            //continue;
        }

    return 0;
}

#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

long long C (long long n){
	return n * (n-1) / 2;
}

int main() {
	long long n, m;
	cin >> n >> m;

	if (n == m){
		cout << 0 << endl;
		return 0;
	}

	long long min, max;

	max = C(n - m + 1);

	long long k = n%m;
	long long x = n/m;

	if (k == 0){
		min = C(x) * (n / x);

	}
	else {
		min = C(x + 1) * k + (m - k) * C(x);
	}

	cout << min  << " " << max << endl;

	return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <assert.h>
#include <cctype>
#include <string.h>
using namespace std;

#define INF_MAX 2147483647
#define INF_MIN -2147483647

#define pi acos(-1.0)
#define INF 1e9
#define ll long long

#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define Fors(i, sz) for( size_t i = 0; i < sz.size (); i++ )
#define Fore(it, x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define mem(a, s) memset(a, s, sizeof (a))
#define Read() freopen("1.txt", "r", stdin)
#define Write() freopen("2.txt", "w", stdout)
#define sz(c) ((int)(c).size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define vi vector<int>
typedef pair<int,int> PAIR;
typedef pair<PAIR ,int> PAIR2;
string tostring(long long n){ostringstream ss; ss << n; return ss.str();}
ll tonumber(string str){stringstream ss; ss << str; long long n; ss >>n; return n;}

int main()
{
    //Read();
    unsigned ll n,m;
    while (cin >> n >> m)
    {
        unsigned ll t=n/m;
        if(n%m!= 0)
            t++;
        unsigned ll res=(t*(t-1)/2);
        if(n%m!=0 )
            res*=(n%m);
        else
            res*=m;
        cout << res << " ";
        t=n-m+1;
        cout << t*(t-1)/2 << endl;

    }
}

#include <string>
#include<iostream>
using namespace std;
/*long long int fact1(int x)
{
	long long int f ; f=1; for (int i = 1; i <= x; i++)
		f = f*i;
	return f;*/

int main() {
	int n, m, s, a, r; long long int km, kn;
	cin >> n >> m;
	s = n - m + 1;
	if (n == 1)
		km = 0;
	else	km = (s*(s-1) /2);
	a = n / m;
	if (n%m == 0)
		r = m;
	else
	r = n%m;
	if (a == 1)
		kn = 1;
	else
	kn = (  a *(a-1)/2);
	cout << r* kn <<" " << km;

	return 0;
}

#include <iostream>
using namespace std;
int main(){

	int n,m;
	cin>>n>>m;

	int a[m];
	if (n%m==0){
		for(int i=0;i<m;i++ ){
			a[i]=n/m;
		}
	}
		else {
			for(int i=0;i<m;i++){
				a[i]=n/m;
			}
			for(int j=0;j<n%m;j++){
				a[j]=a[j]+1;
			}
		}
		long long sum =0;
		for(int i=0;i<m;i++){
			sum = sum + a[i]*( a[i]-1)/2;
		}
		cout <<sum<<endl;
		int b;
		if (n-m==0){
			b=0;
		}
		else {
			b=n-m+1;

		}
	long long k;
	k = b*(b-1)/2;
	cout <<k<<endl;
		}

#include<stdio.h>
	int n,m;
long long acm(int a)
{
	long long b=0;
	double x;
	if(a>1)
	{x=(a)/2.0*(a-1);
	b=b+x;}
	else
		b=1;
	return b;
}

int main()
{

	scanf("%d%d",&n,&m);
	if(m==n)
	{
		printf("%d %d\n",m,n);
		return 0;
	}
	long long max=acm(n-m+1);
	long long  min=0;

	min+=m*(acm(n/m));

	if(n-n/m*m>0)
	{
		min+=(n-n/m*m)*(n/m);
	}
	printf("%lld %lld\n",min,max);

}

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define lli long long int
int main()
{
	lli n,m,max=0,min=0;
	cin>>n>>m;
	max=((n-m+1)*(n-m))/2;
	max%=mod;
	min=((n/m-1)*(n/m))/2;
	min*=(m-1);
	min%=mod;
	min+=((n/m+n%m-1)*(n/m+n%m))/2;
	min%=mod;
	cout<<min<<" "<<max;
}

#include <iostream>
#include<vector>
using namespace std;
int main()
{
    long int n,m;
    cin>>n>>m;
    long int i=0,min=0,max=0,k;
    k=n;
    vector <long int> a(m,0);
    while(k!=0)
    {
        a[i]++;
        k--;
        i++;
        if(i==m)
        {
            i=0;
        }
        if(m==1)
        {
            min=max=n*(n-1)/2;
            cout<<min<<" "<<max;
            return 0;
        }

    }
    for(i=0;i<m;i++)
    {
        min=min+(a[i])*(a[i]-1)/2;
    }
    max=(n-m+1)*(n-m)/2;
    cout<<min<<" "<<max;
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

long long ncr(long long n)
{
	long long result = 1, nrFact = 2;
	bool done = false;

	for (int i = 2; i <= n; i++)
	{
		result *= i;

		if (result % 2 == 0 && done == false)
		{
			result /= 2;
			done = true;
		}

		if (result % nrFact == 0 && nrFact <= n - 2)
		{
			result /= nrFact;
			nrFact++;
		}
	}

	return result;
}

int main()
{
	long long m, t;

	cin >> m >> t;

	long long nMin = ((m / t) + ((m + t) % 2)), nMax = m - (t - 1);

	cout << ncr(nMin) << " " << ncr(nMax);

	//system("pause");

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,m;
    cin>>n>>m;

    ll mx,mn;

    ll p=(n-m)+1;
    mx=p*(p-1)/2;
    //cout<<mx<<endl;

    ll x=n/m;

    if(n%m==0){
        mn=m*x*(x-1)/2;
        //cout<<m*x*(x-1)/2<<endl;
    }

    else{
        ll s=n-(x*m);
        ll q=n-s;
        mn=q*x*(x-1)/2;
        mn+=s*x*(x+1)/2;
        //cout<<mn<<endl;
    }

    cout<<mn<<" "<<mx<<endl;

}

#include <iostream>
#include <functional>
#include<algorithm>
#include <string>
#include <cmath>
using namespace std;
#define MAX 1000
int comb(int m, int n);

int main()
{
	long long m,n,i=0;
	cin>>n>>m;
	if (n == 1000000000)
	    {
	        cout<<n<<" ";
            cout<<n;
            return 0;
	    }
	long long arr[100], base, over, combmin = 0;
	long long maxmem = n;
	//calculate the minimum pairs and storing it in combmin
	base = n / m;
	for (int i = 0; i < m; i++)
	{
		arr[i] = base;
	}
	over = n % m;
	for (int i = 0; i < over; i++)
	{
		arr[i]++;
	}
	for (int i = 0; i < m; i++)
	{
		combmin += comb(arr[i],2);
	}

	for (int i = 0; i < m-1; i++)
	{
		maxmem--;

	}
	/*if (n/m > 2)
		cout<<comb(minmem1,2)*m<<" ";
	else
	    cout<<i<<" ";
		*/
	cout<<combmin<<" ";
    cout<<comb(maxmem,2);

	return 0;
}

int comb(int m, int n)
{
    int mat[MAX][MAX];
    int i, j;
    if (n > m) return 0;
    if( (n == 0) || (m == n) ) return 1;
    for(j = 0; j < n; j ++)
    {
        mat[0][j] = 1;
        if (j == 0)
        {
            for (i = 1; i<= m - n; i ++ ) mat[i][j] = i + 1;
        }
        else
        {
            for (i = 1; i<= m - n; i ++) mat[i][j] = mat[i - 1][j] + mat[i][j - 1];
        }
    }
    return (mat[m - n][n - 1]);
}

#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <iomanip>

#define pi 3.14159265359
#define ll long long
#define fastInput ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

const int mod=1e9+7;

int main()
{
	//n - r + 1
    fastInput
	ll n, m; cin >> n >> m;
	ll maxNum = n - (m - 1), minNum = ceil((double)n / m), remaining = n % m, minVal = 0, maxVal = 0;
    minVal = ((((minNum - remaining) - 1) * (minNum - remaining)) * (m - remaining)) + ((((minNum - remaining) + 1) * (minNum - remaining)) * remaining);
    maxVal = (maxNum - 1) * maxNum;
    cout << minVal / 2 << " " << maxVal / 2;

    return 0;
}

#include<bits/stdc++.h>
#define int long long int
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    int maxans,min,minans,max = n-m+1;
    maxans=( (max*(max-1))/2 );
    if(n%m==0)
    {
        int min=(n+1)/m;
        minans=((m)*(min)*(min-1))/2;
    }
    else
    {
        int min=(n+1)/m;
        int temp1=n%m;
        minans=(m-1)*(min)*(min-1)/2 + (temp1*(temp1-1))/2;
    }
    cout<<minans<<" "<<maxans;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    long long m,n;cin>>m>>n;
    cout<<(m*(m/n-1))/2+m/n*m%n<<" "<<(m-n+1)*(m-n)/2<<endl;
    return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    long long int n,m;
    cin>>n>>m;
    long long int mi=(n/m);
    if(n%m!=0)
        mi++;
    mi=(n%m)*(mi*(mi-1))/2;
    long long int temp=m-1;
    long long int ma=n-temp;
    ma=(ma*(ma-1))/2;
    cout<<mi<<" "<<ma<<"\n";
}
int main() {
	// your code goes here
	ios::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    //INPUT
    int n,m;
    cin >> n >> m;
    //SOLVE
    unsigned long long int k = n % m, maxi, mini = (m - k) * (n / m) * (n / m - 1) / 2 + k * (n / m);
    if(n-m+1%2==0)
    {
        maxi=(n - m + 1) / 2;
        maxi*=(n - m);
    }
    else
    {
        maxi=(n - m) / 2;
        maxi*=(n - m + 1);
    }
    //OUTPUT
    cout << mini << " "<< maxi;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin >> n>> m;
ll a = 0;
ll b = 0;
if(n==m){
    cout<<0<<" "<<0;
    return 0;
}
if(n==m+1){
    cout<<1<<" "<<1;
    return 0;
}
ll x = n/m;
ll r = n%m;
a = (r*((x+1)*x))/2+((m-r)*(x*(x-1)))/2;
b = ((n-m)*(n-m+1))/2;
cout<<a<<" "<<b;

return 0;
}

#include<iostream>
using namespace std;

int comb(int n)
{
	int k = n * (n - 1) / 2;
	return k;
}
int main()
{
	int n, m;
	cin >> n >> m;
	int min = ((m - (n % m)) * comb(n / m)) + ((n % m) * comb(n / m + 1));
	int max = comb(n - m + 1);
	cout << min << " " << max << endl;
}

#include<iostream>
using namespace std;

int main()
{
    int n;
    int m;
    cin>>n;
    cin>>m;
    int MaxG=n-(m-1);

    int pair=0;
    for(int i=2;i<=MaxG;i++)
    {
        pair=pair+(i-1);
    }

    if(m==1)
        cout<<pair<<" ";
    else if(n>=2)
    {
        int loop=0;
        for(int i=0;i<n;i=i+2)
            loop++;
        cout<<loop<<" ";
    }
    else
        cout<<"0 ";

    cout<<pair<<endl;
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,t,min,max;
    scanf("%d%d",&n,&m);
    t=(n*(n-1))/2;
    if(m==1)
    {
        min=max=t;
        printf("%d %d\n",min,max);
    }
    else
    {
        t=n-m+1;
        max=(t*(t-1))/2;
        min=n/m;
        if(min>=2)
            min=((min*(min-1))/2)*m;
        else
            min=1;
        printf("%d %d\n",min,max);
    }
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin >> n>> m;
ll a = 0;
ll b = 0;
if(n==m){
    cout<<0<<" "<<0;
    return 0;
}
if(n==m+1){
    cout<<1<<" "<<1;
    return 0;
}
int x = n/m;
int r = n%m;
a = (ll)r*(ll)((x+1)*x)/2;
a+=(ll)(m-r)*(ll)(x*(x-1))/2;
b = (ll)((ll)(n-m)*(n-m+1))/2;
cout<<a<<" "<<b;

return 0;
}

#include <iostream>
using namespace std;
long long int fact( int x)
   {
     long long int f=1;
     int i;
     for(i=1;i<=x;i++)
       f=f*i;
     return(f);
   }

int main() {
	long long int n,m,max,min;
	cin>>n>>m;
	if(m==1)
	{
		max=fact(n)/fact(n-2);
		max=max/2;
		min=max;
		cout<<min<<" "<<max;
		return 0;
	}
	if(n%m==0)
	{
	//	cout<<"jh";
		min=n/2;
		max=n-(m-1);
		max=fact(max)/fact(max-2);
		max=max/2;
	}
	else
	{
	//	cout<<"vdf";
		max=fact(n)/fact(n-2);
		max=max/2;
		min=max;
		//min=max/2;
	}
	cout<<min<<" "<<max;
	//long int ncr=fact(n)/fact(n-m);
	//cout<<ncr/2;
	return 0;
}

#include <iostream>

using namespace std;

int n, m;
long long int kmin, kmax;

inline long long int pair_count(int num)
{
    long long int c = num;
    c *= (num - 1);
    c /= 2;
    return c;
}

int main()
{
    cin >> n >> m;

    kmin = pair_count(n / m) * (m - 1) + pair_count((n / m) + (n % m));
    kmax = pair_count(1) * (m - 1) + pair_count(n - m + 1);

    cout << kmin << " " << kmax << "\n";

    return 0;
}

#include <bits/stdc++.h>

typedef long double LD;
typedef long long LL;

using namespace std;

unsigned long int p, t, kl, kh, t1, t2, p1, p2;

int main()
{
    scanf("%d %d", &p, &t);
    t2 = p%t;
    t1 = t - t2;
    p1 = floor(p/t);
    p2 = p1 + 1;
    kl = (( (p1 * (p1-1)) /2 ) * t1) + (( (p2 * (p2-1)) /2 ) * t2);
    kh = (p-t+1)*(p-t)/2;
    printf("%d %d", kl, kh);
}

#include<cstdio>
#include<cstdlib>
int max=0,min=0,t=0,n,m,i,j,a[10001];
int main() {
	scanf("%d %d",&n,&m);
	for(i=0; i<=n-m; i++)
	max=max+n-m-i;
	if(n%m==0) {
		a[1]=n/m;
		for(i=0; i<n/m; i++)
			min=min+i;
			min=min*m;
		if(min>0) printf("%d %d",min,max);
		else printf("%d %d",min+1,max);
	}
	else {
		for(i=1; i<=m; i++)
		a[i]=n/m;
		for(i=1; i<=n%m; i++)
		a[i]=a[i]+1;
		for(j=1; j<=n%m; j++)
		min=min+a[1]-j;
		min=min*(n%m);
		for(j=1; j<=n/m; j++)
		t=t+a[n%m+1]-j;
		t=t*(n-(n%m));
		min=min+t;
		if(min>0) printf("%d %d",min,max);
		else printf("%d %d",min+1,max);
	}
	return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cassert>
#include <fstream>
#include <cstring>
#include <numeric>
#include <ctype.h>
#define MOD 1000000007
#define exit return 0
#define N 1555
#define inf 1000000000000000000LL
typedef long long ll;
#define exit return 0
#define PS system("pause")
#define S 100007
#define mx(a,b) a>b?a:b
#define R0(i,n) for (int i = 0; i < n; i++)
#define R1(i,n) for (i = 1; i <= n; i++)
#define MS(a,x) memset(x, a, sizeof(x));
#define left v<<1
#define right left|1
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
using namespace std;
int n,m,k,b,a;
int in[100];
int answ = INT32_MAX;
vector<int>floors[123];

ll C(ll n){
    return n*(n-1)/2;
}
int main(){
    ll max = 0, min = 0;
    cin>>n>>m;

    if(m==1){
        min= C(n);
        max = min;
    }else if(n<=m){
        min = 1;
        max = C(n);
    }else{
        min = C(n/m +1)*(n%m) + C(n/m)*(m-n%m);
        max = C(n - m +1);

    }
    cout<<n<<" "<<m<<endl;
    return 0;
    //5 6    3 2  6 3
    //10 10  1 1  3 6
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<climits>
#include<string>
#include<vector>

#include<map>
//#include<unordered_set>
#include<set>
#include<stack>
#include<queue>
#include<list>
#include<deque>
//#include<unordered_map>
#include<algorithm>
#include<iterator>
#include<cmath>
#include<vector>

//container manipulation and traversal macro
#define for_all(i,a,b)  for(i=a;i<b;i++)
#define for_it(v,c)     for(typeof( (c).begin()) v = (c).begin(); v != (c).begin(); v != (c).end(); ++v)
#define all(a)          a.begin(),a.end()
#define in(a,b)         ( (b).find(a) != (b).end())
#define pb              push_back
#define fill(a,v)       memset(a,v,sizeof(a))
#define sz(a)           ((int)(a.size()))
#define mp              make_pair
#define fst             first
#define sec             second
#define sqr             ( (x) * (x))
#define sqrt            sqrt(abs(x))
/*
//input macros
//#define s(n)    scanf("%d",&n)
//#define sc(n)   scanf("%c",&n)
//#define sl(n)   scanf("%lld",&n)
//#define sf(n)   scanf("%lf",&n)
//#define ss(n)   scanf("%s",n)

//typedefs
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef double D;
//typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;
*/
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    //for min
    long x=(m*(n/m-1)*(n/m))/2 + (n%m)*(n/m);
    long y = (n-m+1);
    y=(y*(y-1)/2);
    if(x==0 && y>0){
        cout<<y<<" "<<y<<endl;
        return 0;
    }
    cout<<x<<" "<<y<<endl;
    return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
void solve()
{
    long long int n,m;
    cin>>n>>m;
    long long int mi=(n/m);
    if(n%m!=0)
    {
        mi++;
    mi=(n%m)*(mi*(mi-1))/2;
    }
    else
    {
        mi=(m)*(mi*(mi-1))/2;
        if(m==1)
        mi=mi/n;
    }
    long long int temp=m-1;
    long long int ma=n-temp;
    ma=(ma*(ma-1))/2;
    cout<<mi<<" "<<ma<<"\n";
}
int main() {
	// your code goes here
	ios::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

#include<iostream>
#include<cstdio>
#define sc(x) scanf("%d",&x)

using namespace std;

main()
{
 int n, m, q, b, c, d;
 sc(n); sc(m);
 q = n % m;
 n -= m - 1;
 b = m - q;
 d = m;
 m = n / m;
 cout << b * m * (m - 1) / 2 + q * (q - 1) / 2 + d * (d - 1) / 2 << " " << n * (n - 1) / 2;

}

#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define V vector
#define S string
#define pb push_back
#define sz size()
#define get cin>>
#define print cout<<
#define OO 1e6
#define set(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define getArr(ar,n) for(int i=0;i<n;get ar[i++])
#define printArr(ar,n) for(int i=0;i<n;print ar[i++]<<' ')
#define Sort(ar,n) sort(ar,ar+n)
#define getPoint(x,y) get x>>y
typedef long long ll;
typedef unsigned long long ull;
int main(){
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,m; get n>>m;
    int mx = (n-(m-1))*(n-(m-1)-1)/2,mn;
    if(n%m){
        mn=((n+1)/m)*((n+1)/m-1)/2*(m-1)+((n/m)*(n/m-1)/2);
        //(5+1/3)*(5+1/3-1)/2*(3-1)
        //2*1/2*2
    }
    else mn=(n/m)*(n/m-1)/2*m;
    print mn<<' '<<mx;
}
/*
n - m-1
*/

#include <bits/stdc++.h>
using namespace std;

int nc2(int n) {

	if (n==1)
		return 0;
	return ((n*(n-1))/2);
}

int main()
{
	int x;
	long int i,rem,quot,n,m;
	long long int kmin,kmax;
	kmin = 0;
	kmax = 0;
	cin >> n;
	cin >> m;

	if (m==1) {
		cout << nc2(n) << " " << nc2(n);
		return 0;
	}

	if (n==m) {
		cout << "0 0";
		return 0;
	}

	//kmin calculation
	rem = n%m;
	quot = n/m;

	for (i=0; i<m; ++i) {
		rem>0?x=1:x=0;
		kmin += nc2(quot+x);
		--rem;
	}

	//kmax
	rem = n-(m-1);

	kmax = nc2(rem);

	cout << kmin << " " << kmax;

	return 0;
}

#include <iostream>
using namespace std;
long long factorial(long long x)
{
    if(x>1)
    {
        return (x-1)+factorial(x-1);
    }
    else return 0;
}
int main()
{
    long long n,m;
    cin>>n>>m;
    long long mi=(n/m);
    long long ma=n-m+1;
    ma=factorial(ma);
    if(n%m!=0)
    mi=factorial(mi)+factorial(mi+1);
    else
        mi=factorial(mi)*m;

    cout<<mi<<' '<<ma<<endl;
}