n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.

Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could have formed by the end of the competition.


-----Input-----

The only line of input contains two integers n and m, separated by a single space (1 ≤ m ≤ n ≤ 10^9) — the number of participants and the number of teams respectively. 


-----Output-----

The only line of the output should contain two integers k_{min} and k_{max} — the minimum possible number of pairs of friends and the maximum possible number of pairs of friends respectively.


-----Examples-----
Input
5 1

Output
10 10

Input
3 2

Output
1 1

Input
6 3

Output
3 6



-----Note-----

In the first sample all the participants get into one team, so there will be exactly ten pairs of friends.

In the second sample at any possible arrangement one team will always have two participants and the other team will always have one participant. Thus, the number of pairs of friends will always be equal to one.

In the third sample minimum number of newly formed friendships can be achieved if participants were split on teams consisting of 2 people, maximum number can be achieved if participants were split on teams of 1, 1 and 4 people.

Source: codeforces | Difficulty: EASY
Tags: Constructive algorithms

Combinatorics

Mathematics

Greedy algorithms


Solutions:
import sys
(n, m) = [int(i) for i in input().split(' ')]
print(int(int(n / m) * (int(n / m) - 1) / 2) * (m - n % m) + n % m * int((int((n - 1) / m) + 1) * int((n - 1) / m) / 2), int((int((n - m + 1) / 2) if (n - m + 1) % 2 == 0 else n - m + 1) * (int((n - m) / 2) if (n - m) % 2 == 0 else n - m)))


from math import factorial
(n, m) = map(int, input().split())

def ncr(n, r):
	try:
		z = n * (n - 1) // 2
	except:
		z = 0
	return z
max = ncr(n - m + 1, 2)
z = n // m
left = n % m
min = ncr(z + 1, 2) * left + ncr(z, 2) * (m - left)
print(min, max)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, m) = f()
x = (n // m + 1) * (n // m) // 2 * (n % m) + n // m * (n // m - 1) // 2 * (m - n % m)
y = (n - m + 1) * (n - m) // 2
print(x, y)


def fact(a):
	if a <= 1:
		return 1
	result = 1
	for i in range(1, a + 1):
		result = result * i
	return result

def comb(a, b):
	return fact(a) // fact(b) // fact(a - b)

def pairs(a):
	return a * (a - 1) // 2
(n, m) = map(int, input().split())
print(str(n % m * pairs(n // m + 1) + (m - n % m) * pairs(n // m)) + ' ' + str(pairs(n - m + 1)))


from fractions import Fraction

def pairs(n):
	k = n * (n - 1)
	m = Fraction(1, 2)
	return k * m
import math
(a, b) = map(int, input().split())
kmax = pairs(a + 1 - b)
ji = math.floor(a / b)
yu = a - ji * b
kmin = pairs(ji) * (b - yu) + pairs(ji + 1) * yu
print(int(kmin), int(kmax))


(n, m) = list(map(int, input().split()))

def pogatya(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2
a = n // m
b = n % m
kmin = (m - b) * pogatya(a) + b * pogatya(a + 1)
kmax = pogatya(n - m + 1)
print(kmin, kmax)


(n, m) = map(int, input().split())
a = n // m
mini = m * a * (a - 1) // 2 + a * (n % m)
maxi = (n - m) * (n - m + 1) // 2
print(mini, maxi)


(n, m) = map(int, input().split())
N = n - (m - 1)
mx = N * (N - 1) // 2
if n % m == 0:
	d = n // m
	mi = d * (d - 1) // 2 * m
else:
	d = n // m
	e = n % m
	mi = (d + 1) * d // 2 * e + d * (d - 1) // 2 * (m - e)
print(mi, mx)


(n, m) = list(map(int, input().split(' ')))
if m == 1:
	num = int(n * (n - 1) // 2)
	print(num, num)
else:
	p = n - m + 1
	kmax = int(p * (p - 1) // 2)
	div = int(n // m)
	rem = n % m
	kmin = int(rem * ((div + 1) * div // 2) + (m - rem) * (div * (div - 1) // 2))
	print(kmin, kmax)


def comb(n, k):
	if k > n:
		return 0
	ans = 1
	c = 1
	for i in range(1, k + 1):
		ans *= n + 1 - i
		c *= i
	return ans // c
(n, m) = map(int, input().split())
mi = 0
t = n // m
if n % m == 0:
	mi = m * comb(t, 2)
else:
	x = n % m
	t = (n - x) // m
	mi = (m - x) * comb(t, 2) + x * comb(t + 1, 2)
print(mi, comb(n - m + 1, 2))


import sys
(n, m) = map(int, sys.stdin.readline().split())
kmax = (n - m) * (n - m + 1) // 2
a = n // m
b = n % m
kmin = a * (b * (a + 1) + (m - b) * (a - 1)) // 2
print(kmin, kmax)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
(n, m) = L()

def nC2(x):
	return x * (x - 1) // 2
mn = (m - n % m) * nC2(n // m) + n % m * nC2(n // m + 1)
x = n - (m - 1)
mx = x * (x - 1) // 2
print(int(mn), mx)
endtime = time.time()


import sys
import math
input = sys.stdin.readline

def ncr(n):
	return n * (n - 1) // 2
(n, m) = (int(i) for i in input().split())
mi = ncr(n // m) * m + n // m * (n % m)
ma = ncr(n - m + 1)
print(mi, ma)


z = lambda x: x * (x + 1) // 2
(a, b) = map(int, input().split())
c = a // b
d = a % b
print((b - d) * z(c - 1) + d * z(c), z(a - b))


(m, n) = map(int, input().split())
k_min = 0
g = m // n
s = m - m // n * n
k_min = (g + 1) * g // 2 * s + g * (g - 1) // 2 * (n - s)
g = m - (n - 1)
k_max = g * (g - 1) // 2
print(k_min, k_max)


(n, m) = list(map(int, input().split()))
maxvalue = (n - m + 1) * (n - m) // 2
minvalue = n % m * (n // m + 1) * (n // m) // 2 + (m - n % m) * (n // m) * (n // m - 1) // 2
print(minvalue, maxvalue)


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
(n, m) = mi()
if m == 1:
	mini = maxi = n * (n - 1) // 2
else:
	(q, r) = divmod(n, m)
	mini = q * (q - 1) // 2 * (m - r) + (q + 1) * q // 2 * r
	maxi = (n - m + 1) * (n - m) // 2
print(mini, maxi)


(n, m) = map(int, input().split())
k_min = 0
lesser = (n // m - 1) * (n // m) // 2 * (m - n % m)
greater = n // m * (n // m + 1) // 2 * (n % m)
k_min += lesser + greater
k_max = (n - (m - 1) - 1) * (n - (m - 1)) // 2
print(k_min, k_max)


def sumTillN(N):
	return N * (N - 1) >> 1
(N, M) = map(int, input().split())
Max = sumTillN(N - (M - 1))
Number = int(N // M)
Some = N % M
X = Some * sumTillN(Number + 1)
Y = (M - Some) * sumTillN(Number)
Min = X + Y
print(Min, Max)


(n, m) = map(int, input().split())
print(n // m * (n // m - 1) // 2 * (m - n % m) + n % m * ((n // m + 1) * (n // m)) // 2, (n - m + 1) * (n - m) // 2)


(mini, maxi) = (0, 0)
(n, m) = map(int, input().split())
if n <= 2 * m:
	print(n // 2 - (2 * m - n) // 2, (n - m + 1) * (n - m) // 2)
else:
	(a, b) = (n // m, n % m)
	print((m - b) * a * (a - 1) // 2 + b * a * (a + 1) // 2, (n - m + 1) * (n - m) // 2)


def random_teams(n_peoples, n_teams):
	if n_peoples == n_teams:
		return '0 0'
	n_max = n_peoples - n_teams + 1
	max_friends = n_max * (n_max - 1) // 2
	min_teams_1 = n_peoples // n_teams
	min_teams_2 = min_teams_1 + 1
	number_teams_2 = n_peoples % n_teams
	number_teams_1 = n_teams - number_teams_2
	min_friends = number_teams_1 * min_teams_1 * (min_teams_1 - 1) // 2 + number_teams_2 * min_teams_2 * (min_teams_2 - 1) // 2
	return f'{min_friends} {max_friends}'
data = [int(e) for e in input().split()]
print(random_teams(*data))


(n, m) = [int(i) for i in input().strip().split()]
amax = (n - m + 1) * (n - m) // 2
amin = n % m * ((n // m + 1) * (n // m) // 2) + (m - n % m) * (n // m * (n // m - 1) // 2)
print(amin, amax)


(n, m) = map(int, input().split())
max = n - m + 1
max = max * (max - 1) // 2
x = n // m
y = n % m
min = y * (x * (x + 1) // 2) + (m - y) * (x * (x - 1) // 2)
print(min, max)


(m, n) = list(map(int, input().split()))
if n == 1:
	print(m * (m - 1) // 2, m * (m - 1) // 2)
else:
	e = m // n
	if m // n == m / n:
		min = e * (e - 1) // 2 * n
	else:
		r = m - m // n * n
		s1 = r * (e * (e + 1) // 2)
		s2 = (n - r) * (e * (e - 1) // 2)
		min = s1 + s2
	q = m - (n - 1)
	qf = q * (q - 1) // 2
	print(min, qf)


from math import *

def max_pair(n, m):
	a = n - m + 1
	ans = a * (a - 1)
	ans //= 2
	return ans

def min_pair(n, m):
	a = ceil(n / m)
	b = floor(n / m)
	ans1 = a * (a - 1)
	ans1 //= 2
	ans1 *= n % m
	ans2 = b * (b - 1)
	ans2 //= 2
	ans2 *= m - n % m
	return ans1 + ans2
(n, m) = [int(x) for x in input().split()]
print(min_pair(n, m), max_pair(n, m))


(n, m) = map(int, input().split())

def sp(num):
	return num * (num - 1) // 2
print(sp(n // m) * (m - n % m) + sp(n // m + 1) * (n % m), sp(n - m + 1))


import sys

def main():
	fin = sys.stdin
	fout = sys.stdout
	(n, m) = map(int, fin.readline().split())
	a = n - m + 1
	a = a * (a - 1) // 2
	b = n // m
	c = n % m
	b = c * b * (b + 1) // 2 + (m - c) * b * (b - 1) // 2
	print(b, a)
	fin.close()
	fout.close()
main()


(n, m) = map(int, input().split())
rmax = (n - m) * (n + 1 - m) // 2
q = n // m
r = n % m
print(q * (q - 1) // 2 * (m - r) + r * q * (q + 1) // 2, rmax)


def nc2(n):
	return int(n * (n - 1) // 2)
(n, m) = map(int, input().split(' '))
max = nc2(n - m + 1)
if n % m == 0:
	min = int(m) * nc2(int(n / m))
else:
	min = (m - n % m) * nc2(int(n / m)) + n % m * nc2(int(n / m) + 1)
print(min, max)


(x, y) = map(int, input().split())
a = x // y
b = x - a * y
min1 = (y - b) * a * (a - 1) // 2 + b * a * (a + 1) // 2
max1 = (x - y + 1) * (x - y) // 2
print(min1, max1)


import operator as op
from functools import reduce

def ncr(n, r):
	if n < r:
		return 0.0
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
(n, m) = map(int, input().split())
rem = n % m
min_combo = ncr(n // m, 2) * (m - rem) + ncr(n // m + 1, 2) * rem
max_combo = (n - m) * (n - m + 1) // 2
print(int(min_combo), int(max_combo))


from fractions import Fraction
(n, m) = map(Fraction, input().split())
min_num = n // m
min_sum = 0
a = int(min_num * (min_num + 1) / 2)
min_sum += a * (n % m)
a = int(min_num * (min_num - 1) / 2)
min_sum += a * (m - n % m)
print(int(min_sum), end=' ')
print(int((n - m + 1) * (n - m) / 2))


(n, m) = [int(i) for i in input().split()]
max1 = (n - (m - 1)) * (n - (m - 1) - 1) // 2
k = n // m
min1 = k * (k - 1) // 2
min1 = min1 * m
r = n % m
min1 = min1 + k * r
print(min1, max1)


(n, m) = map(int, input().split())

def nck(n):
	return n * (n - 1) // 2
numaxi = n - m + 1
maxi = nck(numaxi)
q = n // m
resto = n % m
mini = resto * nck(q + 1) + (m - resto) * nck(q)
print(mini, maxi)


(n, m) = list(map(int, input().split()))
mmax = (n - m) * (n - m + 1) // 2
mmin = 0
k = n // m
a = n % m
mmin = (k + 1) * k * a // 2 + (m - a) * k * (k - 1) // 2
print('{} {}'.format(mmin, mmax))


def f(num):
	return num * (num - 1) // 2
(n, m) = [int(a) for a in input().split()]
kmax = f(n - m + 1)
x = n // m
y = n % m
kmin = f(x) * (m - y) + f(x + 1) * y
print(kmin, kmax)


(n, m) = map(int, input().split())
kmax = (n - m + 1) * (n - m) // 2
kmin = n % m * (n // m + 1) * (n // m) // 2 + (m - n % m) * (n // m) * (n // m - 1) // 2
print(kmin, kmax)


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
(n, m) = mp()
ma = (n - m + 1) * (n - m) // 2
k = n // m
rem = n % m
mi = rem * ((k + 1) * k // 2) + (m - rem) * (k * (k - 1) // 2)
print(mi, ma)


(n, m) = input().split()
n = int(n)
m = int(m)
mymax = (n - m + 1) * (n - m) // 2
mymin = (m - n % m) * (n // m - 1) * (n // m) / 2 + n % m * (n // m + 1) * (n // m) / 2
print(int(mymin), int(mymax))


import math

def f(n):
	return n * (n - 1) // 2
inp = list(map(int, input().split(' ')))
m = inp[0]
n = inp[1]
last_group = m - n + 1
max = f(last_group)
min = 0
if n == 1:
	min = max
else:
	min = m % n * f(m // n + 1) + (n - m % n) * f(m // n)
print(min)
print(max)


def ans(x):
	return x * (x - 1) // 2
(n, m) = input().split()
n = int(n)
m = int(m)
a = n // m
b = n % m
mi = ans(a) * (m - b) + ans(a + 1) * b
ma = ans(n - m + 1)
print('{} {}'.format(mi, ma))


import math
from decimal import *
getcontext().prec = 18
Decimal(1) / Decimal(3)

def main():
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	floor = math.floor(n / m)
	minimizer = Decimal((n - floor * m) * (floor + 1) * floor + (m * (floor + 1) - n) * floor * (floor - 1)) / Decimal(2)
	maximizer = Decimal((n - m + 1) * (n - m)) / Decimal(2)
	print(minimizer, maximizer)
main()


(n, m) = map(int, input().split())
(a, c) = divmod(n, m)
b = n - m + 1
print((a * (a - 1) >> 1) * (m - c) + ((a + 1) * a >> 1) * c, b * (b - 1) >> 1)


(n, m) = map(int, input().split())

def pa(a):
	return a * (a - 1) // 2
ma = pa(n - m + 1)
t = n % m
mi = pa(n // m) * (m - t) + pa(n // m + 1) * t
print(mi, ma)


linea = input().split(' ')
n = int(linea[0])
m = int(linea[1])
x = n - m + 1
mayor = x * (x - 1) // 2
Pe = n // m
Re = n % m
menor = (m - Re) * (Pe * (Pe - 1) // 2) + Re * (Pe * (Pe + 1) // 2)
print(str(menor) + ' ' + str(mayor))


(n, m) = map(int, input().split())
kmax = (n - m + 1) * (n - m) // 2
q = n // m
r = n % m
a = (q + 1) * q // 2 * r
b = (q - 1) * q // 2 * (m - r)
print(a + b, kmax)


(n, m) = map(int, input().split())
a = n // m
b = n % m
mi = b * ((a + 1) * a // 2) + (m - b) * ((a - 1) * a // 2)
A = n - m + 1
Ma = A * (A - 1) // 2
print(mi, Ma)


(p, t) = map(int, input().split())
M = (p - t + 1) * (p - t) // 2
m = p % t * ((p // t + 1) * (p // t) // 2) + (t - p % t) * (p // t * (p // t - 1) // 2)
print(m, M)


import sys
ip = lambda : int(sys.stdin.readline())
ip1 = lambda : map(int, sys.stdin.readline().split())
arr = lambda : list(map(int, sys.stdin.readline().split(' ')))
arr1 = lambda n: [arr() for _ in range(n)]
(n, m) = ip1()
v = n - m + 1
e = n // m
rem = n % m
v1 = e + (1 if rem != 0 else 0)
if rem != 0:
	mn = v1 * (v1 - 1) // 2 * rem + (m - rem) * (e * (e - 1) // 2)
else:
	mn = e * (e - 1) // 2 * m
print(mn, v * (v - 1) // 2)


(n, m) = map(int, input().split())
temp = n // m
mn = temp * (temp - 1) // 2 * m
mn += temp * (n % m)
temp = n - m + 1
mx = temp * (temp - 1) // 2
print(mn, mx)


n = list(map(int, input().split()))
max1 = (n[0] - n[1] + 1) * (n[0] - n[1]) // 2
each = n[0] // n[1]
rem = n[0] % n[1]
min1 = (each + 1) * each * rem // 2 + each * (each - 1) * (n[1] - rem) // 2
L = [min1, max1]
for x in L:
	print(x, end=' ')


(n, m) = map(int, input().split(' '))
x = n // m
y = n % m
mina = (x + 1) * x // 2 * y + x * (x - 1) // 2 * (m - y)
x = n - (m - 1)
maxa = x * (x - 1) // 2
print(mina, maxa)


(n, m) = map(int, input().split())
u = n % m
v = n // m
print(v * (v - 1) // 2 * (m - u) + v * (v + 1) // 2 * u, (n - m) * (n - m + 1) // 2)


(n, m) = map(int, input().split())
kmax = n - m + 1
kmax = kmax * (kmax - 1) // 2
kmin = n // m * (n // m - 1) // 2
if n % m == 0:
	kmin = kmin * m
else:
	kmin = kmin * (m - n % m)
	lftovers = n // m * (n // m + 1) // 2
	kmin += lftovers * (n % m)
print(int(kmin), int(kmax))


(n, m) = [int(x) for x in input().split()]
if m == 1:
	a = n * (n - 1)
	print(a // 2, a // 2)
else:
	a = n - m + 1
	b = a * (a - 1)
	mx = b // 2
	c = n // m
	d = n % m
	r = c * (c - 1) * (m - d)
	r = r // 2
	s = (c + 1) * c * d
	s = s // 2
	mi = r + s
	print(mi, mx)


q = list(map(int, input().split()))
w = q[0] // q[1] * (q[0] // q[1] - 1) * q[1] // 2
e = (q[0] - q[1] + 1) * (q[0] - q[1]) // 2
if w == 0:
	w = q[0] - q[1]
else:
	w = w - w // q[1] * (q[0] % q[1]) + q[0] % q[1] * (q[0] // q[1] + 1) * (q[0] // q[1]) // 2
print(w, e)


(p, t) = list(map(int, input().split()))
t1 = p // t
t1e = p % t
f1 = (t - t1e) * (t1 * (t1 - 1) // 2)
f2 = t1e * ((t1 + 1) * t1 // 2)
p -= t - 1
print(f1 + f2, p * (p - 1) // 2)


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	(n, m) = ain()
	if m == 1:
		print(n * (n - 1) // 2, n * (n - 1) // 2)
	else:
		if n % m == 0:
			x = n // m
			print(m * (x * (x - 1)) // 2, end=' ')
		else:
			x = math.ceil(n / m)
			p = n % m
			print(p * x * (x - 1) // 2 + (m - p) * (x - 1) * (x - 2) // 2, end=' ')
		n = n - m + 1
		print(n * (n - 1) // 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def sum_1_to_n(n):
	return n * (n + 1) // 2
(num_people, num_groups) = map(int, input().split())
baseline = num_people // num_groups
remainder = num_people % num_groups
mn = 0
if baseline + 1 > 1:
	mn += remainder * sum_1_to_n(baseline)
if baseline > 1:
	mn += (num_groups - remainder) * sum_1_to_n(baseline - 1)
big_group_size_for_max = num_people - (num_groups - 1)
mx = 0
if big_group_size_for_max > 1:
	mx = sum_1_to_n(big_group_size_for_max - 1)
print(str(mn) + ' ' + str(mx))


(n, m) = map(int, input().split())
a = n // m
b = n - a * m
print((b * (a + 1) * a + (m - b) * (a - 1) * a) // 2, (n - m) * (n - m + 1) // 2)


(n, m) = map(int, input().split())
kmax = (n - m + 1) * (n - m) // 2
quo = n // m
rem = n % m
kmin = rem * (quo * (quo + 1) // 2) + (m - rem) * (quo * (quo - 1) // 2)
print(kmin, kmax)


(n, m) = map(int, input().split())
kn = (n - m + 1) * (n - m) // 2
a = n // m
km = m * a * (a - 1) // 2 + a * (n % m)
print(km, kn)


(n, k) = map(int, input().split())
flag = 1
if n == 1:
	print('0', '0')
	flag = 0
elif n <= k:
	print('0', '0')
	flag = 0
if flag == 1:
	maxi = (n - k + 1) * (n - k) // 2
	x = n % k
	mini = 0
	fe = n // k
	mini = (fe + 1) * fe // 2 * x + (k - x) * fe * (fe - 1) // 2
	print(mini, maxi, end=' ')


(n, m) = map(int, input().split())
k = n - 1
a = n // m
mn = m * a * (a - 1) // 2 + a * (n % m)
if m == 1:
	print(mn, k * (k + 1) // 2)
else:
	n = n - (m - 1) - 1
	print(mn, n * (n + 1) // 2)


import math

def nCr(n, r):
	i = n
	num = 1
	f = math.factorial
	if n >= r:
		while i > n - r:
			num = num * i
			i = i - 1
		return num // f(r)
	else:
		return 0
(n, m) = input().split()
n = int(n)
m = int(m)
a = n // m
b = n % m
kmin = nCr(a + 1, 2) * b + nCr(a, 2) * (m - b)
kmax = nCr(n - m + 1, 2)
print(kmin, ' ', kmax, sep='', end='')


(people, groups) = map(int, input().split())
print(people % groups * (people // groups + 1) * (people // groups) // 2 + (groups - people % groups) * (people // groups) * (people // groups - 1) // 2, (people - groups + 1) * (people - groups) // 2)


(n, k) = map(int, input().split())
if n != k:
	x = n // k
	minp0 = x
	minpn = x
	if n - k * x > 0:
		minp0 += 1
	z = minp0 * (n - k * x) * (minp0 - 1) // 2 + minpn * (k - n + k * x) * (minpn - 1) // 2
else:
	z = 0
noma = (n - k + 1) * (n - k) // 2
print(z, noma)


(n, m) = map(int, input().split())
mxc = n % m
mnc = m - mxc
mn = n // m
mx = mn + 1
print(mxc * mx * (mx - 1) // 2 + mnc * mn * (mn - 1) // 2, (n - m) * (n - m + 1) // 2)


import sys
import math
import collections

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	(n, m) = get_ints()
	maxim = n - m + 1
	c_max = maxim * (maxim - 1) // 2
	minim = math.ceil(n / m)
	rem = minim * m - n
	(big_min_count, big_min_value) = (m - rem, minim)
	(small_min_count, smaall_min_value) = (rem, minim - 1)
	c_min_big = big_min_count * (big_min_value * (big_min_value - 1) // 2)
	c_min_small = small_min_count * (smaall_min_value * (smaall_min_value - 1) // 2)
	c_min = c_min_big + c_min_small
	print(c_min, c_max)


(n, k) = map(int, input().split())
ma = (n - k) * (n - k + 1) // 2
j = n // k
h = n % k
mi = h * (j + 1) * j // 2 + (k - h) * j * (j - 1) // 2
print(mi, ma)


from math import *
from collections import *
(n, m) = map(int, input().split())
maxx = (n - m) * (n - m + 1) // 2
x = n // m
y = n % m
min1 = x * (x - 1) // 2
min2 = x * (x + 1) // 2
minn = y * min2 + (m - y) * min1
print(minn, maxx)


(n, m) = map(int, input().split())
if n % m == 0:
	h = n // m
	h = m * (h * (h - 1) // 2)
else:
	h1 = n // m
	h2 = h1 + 1
	h1 = (m - n % m) * (h1 * (h1 - 1) // 2)
	h2 = n % m * (h2 * (h2 - 1) // 2)
	h = h1 + h2
print(h, (n - m + 1) * (n - m) // 2)


(n, m) = map(int, input().split())
r1 = n // m
r2 = n % m
print(r2 * (r1 * (r1 + 1)) // 2 + (m - r2) * (r1 * (r1 - 1)) // 2, end=' ')
count = n - m + 1
print(count * (count - 1) // 2)


def calculate(N):
	N = int(N)
	return int(N * (N - 1) // 2)
(n, m) = map(int, input().split())
minValue = 0
maxValue = 0
minValue = calculate(int(n / m + 1)) * (n % m) + calculate(int(n / m)) * (m - n % m)
maxValue = calculate(n - (m - 1))
print(minValue, maxValue)


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def f(n):
	return n * (n - 1) // 2
(n, m) = rinput()
kmax = f(n - m + 1)
(q, r) = divmod(n, m)
kmin = (m - r) * f(q) + r * f(q + 1)
print(kmin, kmax)


import sys

def fn(n, m):
	kmax = (n - m + 1) * (n - m) // 2
	k = int(kmax)
	kmin = int(int(n / m) * (int(n / m) - 1) / 2 * (m - n % m) + (int(n / m) + 1) * int(n / m) / 2 * (n % m))
	print(kmin, k)
input = sys.stdin.read()
data = list(map(int, input.split()))
n = data[0]
m = data[1]
fn(n, m)


def op(x):
	return x * (x - 1) // 2
(n, m) = map(int, input().split())
l = n // m
k = n % m
print(op(l + 1) * k + op(l) * (m - k), op(n - m + 1))


def ncr(n):
	prod = n * (n - 1)
	return prod // 2
(n, m) = [int(x) for x in input().split()]
mini = ncr(n - m + 1)
maxi = n % m * ncr(n // m + 1) + (m - n % m) * ncr(n // m)
import math
print(math.ceil(maxi), math.ceil(mini))


def ns(n):
	return n * (n - 1) // 2
(a, b) = [int(i) for i in input().split()]
k = a - b + 1
ma = ns(k)
p = a // b
q = a % b
mi = ns(p + 1) * q + ns(p) * (b - q)
print(mi, ma)


from math import ceil
(n, m) = map(int, input().split())
k_max = (n - m + 1) * (n - m) // 2
base = n // m
remain = n - m * base
k_min = remain * (base + 1) * base / 2
k_min += (m - remain) * base * (base - 1) / 2
print(int(k_min), int(k_max))


(n, m) = map(int, input().split())
k_max = (n - m + 1) * (n - m) // 2
if n % m == 0 and m != 1:
	k_min = n * (n / m - 1) // 2
else:
	ost = n % m
	k_min = (n // m * (n // m - 1) * (m - ost) + (n // m + 1) * (n // m) * ost) // 2
print(int(k_min), int(k_max))


(n, m) = map(int, input().split(' '))
t = n - m
max1 = (t + 1) * t // 2
n1 = m - n % m
n2 = n % m
n1 = n1 * (n // m * (n // m - 1) // 2)
n2 = n2 * ((n // m + 1) * (n // m) // 2)
min1 = n1 + n2
print(min1, max1)


(n, m) = [int(x) for x in input().split()]
big = (n - m + 1) * (n - m) // 2
a = n // m
small = m * a * (a - 1) // 2 + a * (n % m)
print(str(small) + ' ' + str(big))


(a, b) = map(int, input().split())
z = a - (b - 1)
w = a // b
q = a % b
maxi = z * (z - 1) // 2
mini = (b - q) * (w * (w - 1)) // 2 + q * (w * (w + 1)) // 2
print(mini, maxi)


def sum2(y):
	x = y - 1
	return x * (x + 1) // 2
(n, m) = map(int, input().split())
temp = n // m
w = n % m
new = w * sum2(temp + 1) + (m - w) * sum2(temp)
temp2 = n - m + 1
print(new, sum2(temp2))


(n, m) = map(int, input().split())
count = 0
if m == 1:
	count = n * (n - 1) / 2
	print(str(int(count)) + ' ' + str(int(count)))
elif n % m == 0:
	a = int(n / m)
	p = a * (a - 1) / 2
	min = int(p * m)
	a = n - m + 1
	max = a * (a - 1) // 2
	print(str(min) + ' ' + str(max))
else:
	a = int(n / m)
	if a > 1:
		count = a * (a - 1) / 2
	a = int((n - int(n / m) * (m - n % m)) / (n % m))
	p = a * (a - 1) / 2
	min = int((m - n % m) * count + n % m * p)
	a = n - m + 1
	max = (a - 1) * a // 2
	print(str(min) + ' ' + str(max))


def nc2(n):
	return n * (n - 1) // 2
(n, m) = [int(x) for x in input().strip().split()]
ratio = n // m
left = n % m
kmaxpop = n - (m - 1)
kmax = kmaxpop * (kmaxpop - 1) // 2
kmin = left * nc2(ratio + 1) + (m - left) * nc2(ratio)
print(kmin, kmax)


(n, m) = map(int, input().split())
div = n // m
mod = n % m
mini = ((div - 1) * (m - mod) + (div + 1) * mod) * div / 2
maxi = (n - (m - 1)) * (n - m) // 2
print(int(mini), int(maxi))


(n, m) = map(int, input().split())
(x, mod) = divmod(n, m)
print(m * x * (x - 1) // 2 + x * mod, (n - m) * (n - m + 1) // 2)


(n, m) = map(int, input().split())
r = n % m
t = n // m
kmin = r * (t + 1) * t // 2 + (m - r) * t * (t - 1) // 2
kmax = (n - m + 1) * (n - m) // 2
print(' '.join(map(str, [kmin, kmax])))


(n, m) = map(int, input().split())

def comb(n):
	if n == 1:
		return 0
	tmp = n - 2
	floor = max(tmp, 2)
	rest = min(tmp, 2)
	upper_fat = 1
	for i in range(n, floor, -1):
		upper_fat *= i
	rest_fat = 1
	for i in range(rest, 1, -1):
		rest_fat *= i
	return upper_fat // rest_fat
tiny_floor_size = n // m
tiny_ceil_size = tiny_floor_size + 1
tcs_number = n % m
mini = comb(tiny_floor_size) * (m - tcs_number) + comb(tiny_ceil_size) * tcs_number
maxi = comb(n - m + 1)
print('%d %d' % (mini, maxi))


from sys import stdin

def main():
	entrada = [int(entrada) for entrada in stdin.readline().strip().split()]
	integrantes = entrada[0]
	equipos = entrada[1]
	if equipos == 1:
		maxi = (integrantes - (equipos - 1)) * (integrantes - (equipos - 1) - 1) // 2
		mini = maxi
	else:
		mini = integrantes // equipos * (integrantes % equipos * (integrantes // equipos + 1) + (equipos - integrantes % equipos) * (integrantes // equipos - 1)) // 2
		maxi = (integrantes - (equipos - 1)) * (integrantes - (equipos - 1) - 1) // 2
	print(mini, maxi)
main()


import math
(players, teams) = list(map(int, input().split()))
maxBPlayers = players - (teams - 1)
maxFriends = maxBPlayers * (maxBPlayers - 1) // 2
bucketSize = players / teams
bigBucketSize = math.ceil(bucketSize)
countBigBuckets = players % teams
if countBigBuckets == 0:
	minFriends = bigBucketSize * (bigBucketSize - 1) // 2 * teams
else:
	minFriends = bigBucketSize * (bigBucketSize - 1) // 2 * countBigBuckets + (bigBucketSize - 1) * (bigBucketSize - 2) // 2 * (teams - countBigBuckets)
print(f'{minFriends} {maxFriends}')


from math import floor

def f(n, m):
	if m == 1:
		return (n * (n - 1) // 2, n * (n - 1) // 2)
	else:
		mxn = n - m + 1
		mx = mxn * (mxn - 1) // 2
		rem = floor(n / m)
		y = n - rem * m
		x = m - y
		mn = x * (rem * (rem - 1) / 2) + y * (rem * (rem + 1) / 2)
		return (int(mn), mx)
(n, m) = [int(x) for x in input().strip().split(' ')]
(mi, mx) = f(n, m)
print('%d %d' % (mi, mx))


def nC2(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
max_team_count = n - m + 1
k_max = nC2(max_team_count)
if m == 1:
	print(k_max, k_max)
	exit(0)
(q, r) = divmod(n, m)
count_1 = q + 1
count_2 = q
k_min = r * nC2(count_1) + (m - r) * nC2(count_2)
print(k_min, k_max)


def f(k):
	return k * (k - 1) // 2
(n, m) = map(int, input().split())
print(f(n // m + 1) * (n % m) + f(n // m) * (m - n % m), f(n - m + 1))


(n, m) = list(map(int, input().split()))
first = n % m * ((n + m - 1) // m * ((n + m - 1) // m - 1) // 2) + (m - n % m) * (n // m * (n // m - 1) // 2)
second = (n - m + 1) * (n - m) // 2
print(first, second)


import math
(n, m) = map(int, input().split())
kmax = (n - m + 1) * (n - m) // 2
kmin = m * (((n - m) // m + 1) * ((n - m) // m)) // 2 + math.ceil((n - m) / m) * ((n - m) % m)
print(int(kmin), end=' ')
print(int(kmax))


(a, b) = map(int, input().split())
if b == 1:
	print(a * (a - 1) // 2, a * (a - 1) // 2)
elif a == b:
	print(0, 0)
else:
	k = int(a // b)
	k1 = a % b
	if a % b == 0:
		print(k * (k - 1) * b // 2, (a - b) * (a - b + 1) // 2)
	else:
		print(b * k * (k - 1) // 2 + k1 * k, (a - b + 1) * (a - b) // 2)


(people, teams) = map(int, input().split())
temp = people - (teams - 1)
maxx = (temp - 1) * temp // 2
temp1 = people % teams
temp2 = people // teams
if temp1 != 0:
	while temp1 != 0:
		if temp1 > teams:
			temp1 = temp1 - teams
			temp2 += 1
		else:
			numTeamsDec = teams - temp1
			numTeamsInc = temp1
			temp1 = 0
			ans = numTeamsInc * (temp2 + 1) * temp2 // 2 + numTeamsDec * temp2 * (temp2 - 1) // 2
else:
	ans = teams * temp2 * (temp2 - 1) // 2
lst = [ans, maxx]
print(*lst)


import sys
TESTING = False

def n(x):
	return x * (x - 1) // 2

def solve():
	(p, t) = read()
	bb = n(p - t + 1)
	if p % t == 0:
		ll = n(p // t) * t
	elif p - t == 1:
		ll = 1
	else:
		up = p // t + 1
		down = p // t
		n1 = 0
		while p // t < up:
			p -= down
			t -= 1
			n1 += 1
		ll = n(down) * n1 + n(up) * t
	return str(int(ll)) + ' ' + str(int(bb))

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='')

def run():
	if TESTING:
		sys.stdin = open('test.txt')
	res = solve()
	write(res)
run()


(n, m) = map(int, input().split())
nsum = lambda x: x * (x - 1) // 2
print(n % m * nsum(n // m + 1) + (m - n % m) * nsum(n // m), nsum(n - m + 1))


def mini(n, m):
	members = n // m
	a = members
	b = 0
	n -= members * m
	g = 0
	if n != 0:
		g = n
		b = members + 1
	ans = 0
	ans += (m - g) * (a * (a - 1) // 2)
	ans += g * (b * (b - 1) // 2)
	return ans

def maxi(n, m):
	x = n - (m - 1)
	return x * (x - 1) // 2
(n, m) = [int(x) for x in input().split()]
a = mini(n, m)
b = maxi(n, m)
print(a, b)


from math import ceil
teams = input().split()
n = int(teams[0])
m = int(teams[1])

def friends(n):
	return (n ** 2 - n) // 2
mint = n // m
rem = n % m
minf = friends(mint) * (m - rem) + friends(mint + 1) * rem
maxt = n - m + 1
maxf = friends(n - m + 1)
print(minf, maxf)


(n, m) = map(int, input().split())
x = n - (m - 1)
x = x * (x - 1) // 2
y = n // m
d = n % m
mm = y * (y - 1) // 2 * (m - d) + (y + 1) * (y + 1 - 1) // 2 * d
print(mm, x)


(n, m) = map(int, input().split())
w = n - (m - 1)
max1 = w * (w - 1) // 2
q = 1 + (n - m) // m
q = q * (q - 1) // 2 * (m - (n - m) % m)
r = 2 + (n - m) // m
r = r * (r - 1) // 2 * ((n - m) % m)
print(q + r, max1)


(m, n) = map(int, input().split())
i = m // n
l = m % n
u = m - n
print(i * (i - 1) * (n - l) // 2 + i * (i + 1) * l // 2, (1 + u) * u // 2)


(n, m) = map(int, input().split())
if m == 1:
	s = n * (n - 1) // 2
	print(s, s)
else:
	last_team = n - m + 1
	s = last_team * (last_team - 1) // 2
	if s == 1:
		print('1 1')
	elif n % m == 0:
		v = n // m
		x = v * (v - 1) // 2
		print(x * m, s)
	else:
		(v1, v2) = (n // m, n // m + 1)
		x = n % m
		y = (n - x * v2) // v1
		(s2, s1) = (v2 * (v2 - 1) // 2, v1 * (v1 - 1) // 2)
		print(x * s2 + y * s1, s)


(n, m) = [int(x) for x in input().split()]
maxno = (n + 1 - m) * (n - m) // 2
k = n // m
yushu = n % m
minno = (m - yushu) * k * (k - 1) // 2 + yushu * k * (k + 1) // 2
print(minno, maxno)


[m, n] = [int(x) for x in input().split()]
k_max = (m - n + 1) * (m - n) // 2
l = m % n
j = m // n
k_min = l * ((j + 1) * j / 2) + (n - l) * (j * (j - 1) / 2)
k_min = int(k_min)
print(k_min, k_max)


(n, m) = [int(x) for x in input().split()]
k = n // m
print(k * (k - 1) // 2 * (m - n % m) + k * (k + 1) // 2 * (n % m), (n - m + 1) * (n - m) // 2)


(n, m) = map(int, input().split())
Max = max(0, (n - m + 1) * (n - m) // 2)
Mi = n % m
Ma = m - Mi
Min = Ma * (n // m) * (n // m - 1) // 2 + Mi * (n // m) * (n // m + 1) // 2
print(Min, Max)


(n, m) = list(map(int, input().split()))
X = m - 1
Max = n - X
Max = Max * (Max - 1) // 2
Test = n // m
mod = n % m
Min = mod * (Test * (Test + 1)) // 2
Min += (m - mod) * (Test * (Test - 1)) // 2
print(Min, Max)


(n, m) = map(int, input().split())
maximum = 0
minimum = 0
nC2 = lambda x: x * (x - 1) // 2
maximum = nC2(n - (m - 1))
if n % m == 0:
	minimum = m * nC2(n // m)
else:
	minimum = n % m * nC2(n // m + 1) + (m - n % m) * nC2(n // m)
print(minimum, maximum)


(n, m) = map(int, input().split())
maxi = n - m + 1
if maxi >= 2:
	ansm = maxi * (maxi - 1) // 2
else:
	ansm = 0
mini = n // m
r = n % m
if r != 0:
	if mini >= 1:
		ansi = (mini + 1) * mini // 2
		ansi = ansi * r
		if mini >= 2:
			e = mini * (mini - 1) // 2 * (m - r)
			ansi = ansi + e
elif mini >= 2:
	ansi = mini * (mini - 1) // 2 * m
else:
	ansi = 0
print(ansi, ansm)


(n, m) = map(int, input().split())
x = n // m
y = n % m
s = (m - y) * (x * (x - 1)) // 2
s += y * (x * (x + 1)) // 2
z = n - m + 1
p = z * (z - 1) // 2
print(min(s, p), max(s, p))


inp = lambda : map(int, input().split(' '))
(p, t) = inp()
x = int(p)
m = (p - t + 1) * (p - t) // 2
s = p % t * ((p // t + 1) * (p // t)) / 2 + (t - p % t) * ((p // t - 1) * (p // t)) / 2
print(int(s), int(m))


from sys import stdin
import functools

def ncr(n, r):
	if n < r:
		return 0
	else:
		r = min(r, n - r)
		a = functools.reduce(lambda x, y: x * y, range(n, n - r, -1), 1)
		b = functools.reduce(lambda x, y: x * y, range(1, r + 1), 1)
		return a // b
(n, m) = map(int, stdin.readline().split())
s = n - m + 1
k_max = ncr(s, 2)
a = n // m
b = n - a * m
k_min = b * ncr(a + 1, 2) + (m - b) * ncr(a, 2)
print(k_min, k_max)


(n, m) = map(int, input().split())
kmax = (n - m + 1) * (n - m) // 2
if n % m == 0:
	kmin = int(m * (n / m * (n / m - 1) / 2))
else:
	temp = int(n / m)
	team1 = n % m
	team2 = m - team1
	kmin1 = team1 * ((temp + 1) * temp / 2)
	kmin2 = team2 * ((temp - 1) * temp / 2)
	kmin = int(kmin1 + kmin2)
print(kmin, kmax)


(n, m) = map(int, input().split())
c = n // m
d = n % m
print((m - d) * c * (c - 1) // 2 + d * (c + 1) * c // 2)
print((n - m + 1) * (n - m) // 2)


def fac(n):
	f = 1
	while n > 0:
		f *= n
		n -= 1
	return f

def ncr(n, m):
	if n < m:
		return 0
	ans = 1
	for i in range(m):
		ans *= n - i
	return ans // fac(m)
(n, m) = input().strip().split(' ')
(n, m) = (int(n), int(m))
r = n - m
mx = ncr(n - m + 1, 2)
mn = n % m * ncr(1 + n // m, 2) + (m - n % m) * ncr(n // m, 2)
print(mn, mx)


def ncr(n1):
	f = n1 * (n1 - 1) // 2
	return f
(n, m) = input().split(' ')
n = int(n)
m = int(m)
c = n - m
Max = ncr(c + 1)
s = n // m
s1 = n % m
d = m * s * (s - 1) // 2
d1 = s1 * s
Sum = d + d1
print(Sum, Max)


def main():
	(n, m) = map(int, input().split())
	max_rem = n - m + 1
	maxi = max_rem * (max_rem - 1) // 2
	if n % m == 0:
		x = n // m
		pmin = int(x * (x - 1) / 2) * m
	else:
		x = n // m
		pmin = x * (x - 1) / 2 * (m - n % m)
		pmin += (x + 1) * x / 2 * (n % m)
	print(int(pmin), maxi)
main()


(n, m) = map(int, input().split())
max_friends = n - m + 1
max_pairs = max_friends * (max_friends - 1) // 2
teams = n // m
rest_part = n % m
min_pairs = rest_part * (teams * (teams + 1)) // 2 + (m - rest_part) * (teams * (teams - 1) // 2)
print(min_pairs, max_pairs)


(n, m) = map(int, input().split())
left = n % m
mn = n // m
mx = n - m + 1
print(left * (mn * (mn + 1)) // 2 + (m - left) * (mn * (mn - 1)) // 2, mx * (mx - 1) // 2)


(n, m) = map(int, input().split())
a = n // m
lo = m * a * (a - 1) // 2 + a * (n % m)
n -= m - 1
print(lo, n * (n - 1) // 2)


(a, b) = map(int, input().split(' '))
if a % b:
	x = a // b
	e = a % b
	t = (b - e) * (x * (x - 1) // 2) + e * (x * (x + 1) // 2)
else:
	x = a // b
	t = b * (x * (x - 1) // 2)
ma = (a - b + 1) * (a - b) // 2
print(t, ma)


def f(x):
	return x * (x - 1) // 2
(n, m) = map(int, input().split())
k_max = f(n - m + 1)
k_min = f(n // m) * (m - n % m) + f(n // m + 1) * (n % m)
print(k_min, k_max)


import datetime
import math

def clock():
	print(datetime.datetime.now())
a = [int(x) for x in input().split()]
k = s = 0
i = 1
b = []
(a1, a2, a3, a33) = (0, 0, 0, 0)
a1 = a[0] // a[1]
a2 = a[0] % a[1]
a3 = a1 + 1
a3 = a3 * (a3 - 1) // 2 * a2
a33 = a1 * (a1 - 1) // 2 * (a[1] - a2)
s = a[0] - (a[1] - 1)
print(a3 + a33, s * (s - 1) // 2)


import math

def nchoosek(n, k):
	return n * (n - 1) // 2
(n, m) = map(int, input().split(' '))
if m == 1:
	if n > 1:
		kmin = nchoosek(n, 2)
		kmax = kmin
		print(kmin, kmax)
	else:
		print(0, 0)
else:
	kmax = nchoosek(n - m + 1, 2)
	div = n // m
	n1 = nchoosek(div + 1, 2)
	n2 = nchoosek(div, 2)
	kmin = n1 * (n % m) + n2 * (m - n % m)
	print(kmin, kmax)


(n, m) = map(int, input().split())
ansmax = (n - m + 1) * (n - m) // 2
var = n // m
bal = n % m
ansmin = bal * ((var + 1) * var) // 2
ansmin += (m - bal) * (var * (var - 1)) // 2
print(ansmin, ansmax)


def P(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
kmax = P(n - m + 1)
r = n % m
d = n // m
kmin = r * P(d + 1) + (m - r) * P(d)
print(kmin, kmax)


def calcularCombinacao(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - k + i) // i
	return int(res)
entrada = input().split()
n = int(entrada[0])
m = int(entrada[1])
distribuicao = n // m
restoDistribuicao = n % m
kmin = 0
kmin += calcularCombinacao(distribuicao + 1, 2) * restoDistribuicao
kmin += calcularCombinacao(distribuicao, 2) * (m - restoDistribuicao)
kmax = calcularCombinacao(n - (m - 1), 2)
print(kmin, kmax)


def pairs(n):
	return n * (n - 1) // 2
(n, m) = [int(i) for i in input().split()]
d = n // m
r = n % m
kmin = (m - r) * pairs(d) + r * pairs(d + 1)
kmax = pairs(n - m + 1)
print(str(kmin) + ' ' + str(kmax))


(n, m) = map(int, input().split())
(kmin, kmax) = (0, 0)
kmax = (n - m + 1) * (n - m) // 2
temp = n // m
temp2 = n % m
kmin += temp * (temp - 1) // 2 * (m - temp2)
kmin += (temp + 1) * temp // 2 * temp2
print(kmin, kmax)


import sys
from collections import *
from heapq import *
import math
import bisect

def input():
	return sys.stdin.readline()
(n, m) = map(int, input().split())
a = n // m
if n % m == 0:
	s1 = max(0, a * (a - 1) // 2) * m
else:
	s = n % m
	s1 = max(0, a * (a - 1) // 2) * (m - s)
	s1 += (a + 1) * a // 2 * s
if m > 1:
	b = n - (m - 1)
	if b <= 0:
		s2 = 0
	else:
		s2 = b * (b - 1) // 2
else:
	s2 = s1
print(min(s1, s2), max(s1, s2))


(n, m) = [int(x) for x in input().split()]
size = n // m
r = n % m
kmin = (m - r) * size * (size - 1) // 2 + r * (size + 1) * size // 2
B_size = n - m + 1
kmax = B_size * (B_size - 1) // 2
print(kmin, kmax)


def nC2(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
kmax = nC2(n - m + 1)
kmin = 0
if n % m == 0:
	kmin = m * nC2(n // m)
else:
	kmin = m * nC2(n // m) + n // m * (n % m)
print(kmin, kmax)


vals = [int(x) for x in input().split()]
n = vals[0]
m = vals[1]
minPairs = 0
maxPairs = (n - m + 1) * (n - m) // 2
if n % m == 0:
	peopleInGroup = n / m
	minPairs = peopleInGroup * (peopleInGroup - 1) / 2 * m
else:
	peopleInGroup = n // m
	plusOneGroups = n % m
	minPairs = peopleInGroup * (peopleInGroup - 1) / 2 * (m - plusOneGroups) + peopleInGroup * (peopleInGroup + 1) / 2 * plusOneGroups
print(str(int(minPairs)) + ' ' + str(maxPairs))


(n, m) = [int(i) for i in input().split()]
if n % m == 0:
	kmin = n // m * (n // m - 1) // 2 * m
	kmax = (n - m + 1) * (n - m) // 2
else:
	t = n // m
	kmin = t * (t + 1) // 2 * (n % m) + t * (t - 1) // 2 * (m - n % m)
	kmax = (n - m + 1) * (n - m) // 2
print(kmin, kmax)


(n, m) = map(int, input().split())
mi = int((n - (m - 1)) * (n - (m - 1) - 1) // 2)
au1 = n // m
au2 = n % m
ma = int((m - au2) * au1 * (au1 - 1) // 2 + au2 * (au1 + 1) * au1 // 2)
print(min(mi, ma), end=' ')
print(max(mi, ma))


import heapq as hp
import collections
import bisect
import math
import re

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def ml_unpack(n):
	return [int(input()) for i in range(n)]

def range_n():
	return range(int(input()))

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def getint():
	return int(input())

def setbits(x):
	count = 0
	while x:
		x = x & x - 1
		count += 1
	return count

def nC2(n):
	return n * (n - 1) // 2

def main():
	(n, m) = unpack()
	(k, x) = (n // m, n % m)
	maxi = nC2(n - m + 1)
	mini = x * nC2(k + 1) + (m - x) * nC2(k)
	print(mini, maxi)
main()


def inp():
	return map(int, stdin.readline().split())

def nCr(n, r):
	(f, m) = (factorial, 1)
	for i in range(n, n - r, -1):
		m *= i
	return int(m // f(r))
from math import *
from sys import *
(n, m) = inp()
if n % m == 0:
	mi = nCr(n // m, 2) * m
else:
	mi = nCr(n // m + 1, 2) * (n % m) + nCr(n // m, 2) * (m - n % m)
ma = nCr(n - (m - 1), 2)
print(mi, ma)


def comb(n):
	return n * (n - 1) // 2

def Main():
	(n, m) = map(int, input().split())
	k = n // m
	p = n % m
	mn = p * comb(k + 1) + (m - p) * comb(k)
	mx = comb(n - m + 1)
	print(mn, mx)
Main()


def randomTeams(n):
	return (n - 1) * n // 2
(n, m) = list(map(int, input().split()))
(a, b) = divmod(n, m)
min = b * randomTeams(a + 1)
if a >= 2:
	min += (m - b) * randomTeams(a)
max = randomTeams(n - (m - 1))
print(min, max)


def maximum(n, m):
	n = n - m + 1
	return n * (n - 1) // 2

def minimum(n, m):
	if n % m == 0:
		k = n // m
		return m * (k * (k - 1) // 2)
	else:
		temp = n % m
		n -= temp
		k = n // m
		a2 = (m - temp) * (k * (k - 1) // 2) + temp * ((k + 1) * k // 2)
		return a2
(n, m) = map(int, input().split())
print(minimum(n, m), maximum(n, m))


(n, m) = map(int, input().split())
div = n // m
rem = n % m
res = div * (div - 1) // 2 * (m - rem)
res += div * (div + 1) // 2 * rem
k = n - m + 1
print(res, k * (k - 1) // 2)


from math import ceil

def somar(n):
	n = n - 1
	return (1 + n) * n // 2
(n, m) = map(int, input().split())
if n % m == 0:
	mini = somar(n // m) * m
else:
	r = n % m
	maior = ceil(n / m)
	mini = somar(ceil(n / m)) * r + somar(n // m) * (m - r)
maxi = somar(n - m + 1)
print(mini, maxi)


def sumupto(z):
	return int(z * (z - 1) / 2)
(n, m) = map(int, input().split())
nm = n // m
print(m * nm * (nm - 1) // 2 + n % m * (n // m), (n - m + 1) * (n - m) // 2)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	params = tuple(invr())
	n = params[0]
	t = params[1]
	max_res = count(n - t + 1)
	team_size = n // t
	rem = n % t
	min_res = count(team_size) * (t - rem) + count(team_size + 1) * rem
	print(*[min_res, max_res])

def count(n):
	return n * (n - 1) // 2
BUFSIZE = 8192

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def pairs(n, m):
	if n == 1 and m == 1:
		return [0, 0]
	if m == 1:
		return [ncr(n, 2), ncr(n, 2)]
	if n == m:
		return [0, 0]
	elif n % m == 0:
		return [ncr(n // m, 2) * m, ncr(int(n - (m - 1)), 2)]
	else:
		newN = n // m
		extra = round((n / m - int(n / m)) * m)
		normal = ncr(newN, 2) * (m - extra) if newN > 1 else 0
		return [ncr(newN + 1, 2) * extra + normal, ncr(int(n - (m - 1)), 2)]
line = input()
line = line.split(' ')
n = int(line[0])
m = int(line[1])
miMa = pairs(n, m)
mi = miMa[0]
ma = miMa[1]
print(mi, ma)


(n, m) = map(int, input().split())
x = n % m
nn = n - x
a = nn / m
xx = x * a * (a + 1) / 2
xy = (m - x) * a * (a - 1) / 2
mn = int(xx + xy)
n = n - m + 1
if n % 2 == 0:
	aa = int(n / 2)
	mx = aa * (n - 1)
else:
	aa = int((n - 1) / 2)
	mx = aa * n
print(int(mn), int(mx))


from decimal import *

def pair(n):
	return Decimal(n / 2) * (n - 1)
nm = [int(i) for i in input().split()]
print(int((nm[1] - nm[0] % nm[1]) * pair(nm[0] // nm[1]) + nm[0] % nm[1] * pair(nm[0] // nm[1] + 1)), int(pair(nm[0] - (nm[1] - 1))))


def con(a, b):
	if a == 0 or a < b:
		return 0
	if a == b or b == 0:
		return 1
	if b == 1:
		return a
	return con(a - 1, b - 1) * a // b
s = [int(i) for i in input().split(' ')]
mini = s[0] // s[1]
mini2 = 0
maxi = con(s[0] - s[1] + 1, 2)
if s[0] % s[1] > 0:
	mini2 = 1
mini = con(mini, 2) * (s[1] - s[0] % s[1])
mini += con(s[0] // s[1] + 1, 2) * (s[0] % s[1])
s = str(int(mini)) + ' ' + str(int(maxi))
print(s)


import math
(persons, teams) = map(int, input().split())

def comb(size_team):
	if size_team < 2:
		return 0
	else:
		return size_team * (size_team - 1) // 2
persons_remaining = persons - teams
add_people_per_team = persons_remaining // teams
remaining = persons_remaining % teams
minimum = (teams - remaining) * comb(1 + add_people_per_team)
minimum += remaining * comb(2 + add_people_per_team)
people_last_team = persons - (teams - 1)
maximum = comb(people_last_team)
print(int(minimum), int(maximum))


string = input()
numbers = string.split(' ')
total = int(numbers[0])
teams = int(numbers[1])
n = int(total / teams)
a = int(n * (n - 1) // 2 * teams + total % teams * n)
n = total - (teams - 1)
b = int(n * (n - 1) // 2)
print('%d %d' % (a, b))


def comb(a):
	res = a * (a - 1)
	return res // 2

def next(n, m):
	k_max = comb(n - m + 1)
	rem = n % m
	k_min = rem * comb(int(n / m) + 1) + (m - rem) * comb(int(n / m))
	print(k_min, k_max)
	return
(a, b) = map(int, input().split())
next(a, b)


w = input().split(' ')
n = int(w[0])
m = int(w[1])
formax = n - m
maxx = int(formax * (formax + 1) // 2)
a = n // m
b = n % m
minn = int(b * (a * (a + 1) / 2) + (m - b) * (a * (a - 1) / 2))
print(str(minn) + ' ' + str(maxx))


alle = input()
alle = list(map(int, alle.split()))
n = alle[0]
m = alle[1]
maximo = n - m + 1
maximo = maximo * (maximo - 1) // 2
if n % m == 0:
	x = n // m
	minimo = x * (x - 1) / 2 * m
else:
	x = n // m
	minimo = x * (x - 1) / 2 * (m - n % m)
	minimo += (x + 1) * x / 2 * (n % m)
maximo = int(maximo)
minimo = int(minimo)
print(minimo, maximo)


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi

def binNumber(n, size=4):
	return bin(n)[2:].zfill(size)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())

def par(a):
	print(' '.join(list(map(str, a))))

def tdl(outerListSize, innerListSize, defaultValue=0):
	return [[defaultValue] * innerListSize for i in range(outerListSize)]

def sts(s):
	s = list(s)
	s.sort()
	return ''.join(s)

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)
(x, y) = isp()
k2 = (x - y + 1) * (x - y)
k2 //= 2
m = x // y
ex = x % y
k1 = m * (m - 1)
k1 *= y - ex
k1 += m * (m + 1) * ex
k1 //= 2
print(k1, k2)


(m, n) = list(map(int, input().split(' ')))

def form(x):
	return x * (x - 1) // 2
a = m - n + 1
largest = form(a)
a = m // n
b = m % n
res = form(a) * n
if b != 0:
	res = form(a) * (n - b) + form(a + 1) * b
print(res, largest)


(n, m) = map(int, input().split())
minval = n // m
minval = minval * (minval - 1) // 2 * m + n % m * minval
maxval = n - m + 1
maxval = maxval * (maxval - 1) // 2
print(minval, maxval)


(n, m) = map(int, input().split())
maxx = n - m + 1
ansmaxx = maxx * (maxx - 1) // 2
minn = n // m
tmp = n % m
ansminn = (minn + 1) * minn // 2 * tmp + minn * (minn - 1) // 2 * (m - tmp)
print(ansminn, ansmaxx)


l1 = [int(x) for x in input().split()]
n = l1[0]
m = l1[1]
min1 = n // m
n_min1 = n - min1 * m
min_half = (min1 + 1) * min1 // 2 * n_min1
min_full = (m - n_min1) * (min1 * (min1 - 1) // 2)
min_out = min_half + min_full
max1 = n - m
max_out = (1 + (n - m)) * (n - m) // 2
print(int(min_out), int(max_out))


(n, m) = map(int, input().split())
d = n // m
ans1 = n % m * (d + 1) * d / 2 + (m - n % m) * d * (d - 1) / 2
ans2 = (n - m + 1) * (n - m) // 2
print(int(ans1), int(ans2))


import math
(parter, group) = [int(x) for x in input().split()]
ans = 0
m2 = parter - (group - 1)
m_min = parter // group
gr_max = parter % group
m_max = m_min + 1
gr_min = group - gr_max
ans = int(m_min * (m_min - 1) * gr_min // 2 + m_max * (m_max - 1) * gr_max // 2)
print(str(ans) + ' ' + str(int(m2 * (m2 - 1) // 2)))


(n, m) = input().split()
n = int(n)
m = int(m)
r = n % m
q = n // m
qn = n // m + 1
c = m - r
s = r * (qn * (qn - 1)) // 2 + c * (q * (q - 1)) // 2
x = n - m + 1
x = x * (x - 1) // 2
print(s, x)


def nC2(n):
	return n * (n - 1) // 2
(n, m) = input().split(' ')
n = int(n)
m = int(m)
kmax = nC2(n - m + 1)
kmin = 0
if n % m == 0:
	t = n // m
	kmin = m * nC2(t)
else:
	t = n // m
	x = t * m
	y = n - x
	kmin = (m - y) * nC2(t) + y * nC2(t + 1)
print(kmin, end=' ')
print(kmax)


(n, m) = map(int, input().split())
k_min = n % m * (n // m + 1) * (n // m) // 2 + (m - n % m) * (n // m - 1) * (n // m) // 2
k_max = (n - m) * (n - m + 1) // 2
print(k_min, k_max)


(n, m) = map(int, input().split())
ma = (n - m + 1) * (n - m) // 2
p = n // m
r = n % m
mi = p * (p - 1) // 2 * (m - r)
p = p + 1
mi = mi + p * (p - 1) // 2 * r
print(mi, ma)


(n, m) = map(int, input().split())
k = n - m + 1
x = 0
u = 0
import math
bache = n - m * (n // m)
new = n // m + 1
x = new * (new - 1) * bache // 2
x += n // m * (n // m - 1) * (m - bache) // 2
print(x, k * (k - 1) // 2)


def sumcalc(n=1):
	return n * (n + 1) // 2
(n, m) = map(int, input().split())
print(sumcalc(n // m - 1) * (m - n % m) + sumcalc(n // m) * (n % m))
print(sumcalc(n - m))


(n, m) = map(int, input().split())
s = n // m
j = n % m
a = s + 1
p = j * a * (a - 1) // 2
q = (m - j) * s * (s - 1) // 2
print(p + q, end=' ')
mx = n - m + 1
print(mx * (mx - 1) // 2)


(n, m) = input().split()
n = int(n)
m = int(m)
ma = (n - m + 1) * (n - m) // 2
mi = n // m * (n // m - 1) * (m - n % m) // 2 + (n // m + 1) * (n // m) * (n % m) // 2
print(mi, ma)


import sys
from bisect import bisect_left, bisect_right
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10
from itertools import permutations
inf = float('inf')
mod = 1000000007
mini = 1000000007

def func(n):
	return n * (n - 1) // 2

def fact(n):
	if n == 0:
		return 1
	p = 1
	d = 10 ** 9 + 7
	for i in range(1, n + 1):
		p = p * i
		p = p % d
	return p

def ncr(n, r):
	d = 10 ** 9 + 7
	num = fact(n)
	den = fact(r) * fact(n - r) % d
	den = pow(den, d - 2, d)
	return num * den % d

def sieve(n):
	prime = [True for i in range(n + 1)]
	lst = []
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p = p + 1
	for i in range(2, n + 1):
		if prime[i]:
			lst.append(i)
	return lst

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def calculate_factors(n):
	hh = [1] * (n + 1)
	p = 2
	while p * p < n:
		if hh[p] == 1:
			for i in range(p * 2, n, p):
				hh[i] = 0
		p += 1
	total = 1
	for p in range(2, n + 1):
		if hh[p] == 1:
			count = 0
			if n % p == 0:
				while n % p == 0:
					n = int(n / p)
					count += 1
				total *= count + 1
	return total

def prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			factors.add(n // i)
			n = n // i
			factors.add(i)
	if n > 1:
		factors.add(n)
	return factors

def isPrime(n):
	if n == 2 or n == 3:
		return True
	if n % 2 == 0 or n < 2:
		return False
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True

def solve(n):
	if n == 1:
		return 1
	p = 2
	while p * p <= n:
		if n % p == 0:
			return n // p
		p = p + 1
	return False

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
if m == 1:
	print(func(n), func(n))
else:
	mini = n % m * func(n // m + 1) + (m - n % m) * func(n // m)
	maxi = func(n - m + 1)
	print(mini, maxi)


from sys import stdin, stdout
import math

def combination(a, b):
	if a >= 2:
		return a * (a - 1) // 2
	else:
		return 0

def calculate_min(n, m):
	temp = n // m
	remain = n % m
	ans = (m - remain) * combination(temp, 2)
	ans += remain * combination(temp + 1, 2)
	return ans

def calculate_max(n, m):
	return combination(n - (m - 1), 2)
(n, m) = list(map(int, stdin.readline().split()))
second = calculate_max(n, m)
first = calculate_min(n, m)
print(first, second)


def ans(n):
	return n * (n - 1) // 2
(a, b) = map(int, input().split())
x = a // b
y = a % b
mi = ans(x) * (b - y) + ans(x + 1) * y
ma = ans(a - b + 1)
print(mi, ma)


import math

def ncr(a):
	if n == 0:
		return 0
	else:
		return a * (a - 1) // 2
(n, m) = map(int, input().split())
kmax = ncr(n - m + 1)
k = n // m
c = n % m
kmin = k * (k - 1) // 2 * (m - c) + c * (k * (k + 1) // 2)
print(kmin, kmax)


(n, m) = map(int, input().split())
maxx = (n - m + 1) * (n - m) // 2
x = n // m
minn = n % m * (x * (x + 1)) // 2
minn += (m - n % m) * (x * (x - 1)) // 2
print(minn, maxx)


a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
n = a[0]
m = a[1]
pmin = n % m * (n // m + 1) * (n // m) // 2 + (m - n % m) * (n // m) * (n // m - 1) // 2
l = n - m + 1
pmax = l * (l - 1) // 2
print(int(pmin), int(pmax))


(m, n) = list(map(int, input().split()))
if m % n == 0:
	print(str(m // n * (m // n - 1) // 2 * n) + ' ' + str((m - n + 1) * (m - n) // 2))
else:
	print(str(m // n * (m // n - 1) // 2 * (n - m % n) + (m // n + 1) * (m // n) // 2 * (m % n)) + ' ' + str((m - n + 1) * (m - n) // 2))


def c(x):
	return x * (x - 1) // 2
(n, m) = map(int, input().split())
print(n % m * c(n // m + 1) + (m - n % m) * c(n // m), end=' ')
tmp = n - m + 1
print(c(tmp))


ins = [int(i) for i in input().split()]
(p, t) = ins
most = (p - t) * (p - t + 1) // 2
if t == 1:
	least = most
else:
	least = (t - p % t) * (p // t - 1) * (p // t) // 2 + p % t * (p // t) * (p // t + 1) // 2
print(least, most)


def suan(a):
	return a * (a - 1) // 2
(n, m) = map(int, input().split())
kmi = n % m * suan(n // m + 1) + (m - n % m) * suan(n // m)
kma = suan(n - m + 1)
print(kmi, kma)


from functools import reduce
import operator as op
(n, m) = map(int, input().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom
maxx = ncr(n - m + 1, 2)
if n == m:
	maxx = 0
q = n // m
r = n % m
minn = ncr(q + 1, 2) * r
if q > 1:
	minn += ncr(q, 2) * (m - r)
print(minn, end='')
print(' ', end='')
print(maxx)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, permutations
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def ceill(n, x):
	return (n + x - 1) // x
f = lambda x: x * (x - 1) // 2
(n, m) = tup()
r = n % m
mi = f(n // m) * (m - r) + f(n // m + 1) * r
ma = f(n - (m - 1))
print(mi, ma)
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


firstLine = [int(x) for x in input().split()]
players = firstLine[0]
teams = firstLine[1]
sparePlayers = players - teams

def summation(a):
	return int(int((a + 1) * a) // 2)
smallTeamSize = int(players / teams)
bigTeamSize = smallTeamSize + 1
bigTeamCount = players % teams
smallTeamCount = teams - bigTeamCount
total = summation(bigTeamSize - 1) * bigTeamCount + summation(smallTeamSize - 1) * smallTeamCount
print(total, '', end='')
print(summation(sparePlayers))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	t = n // m
	u = n % m
	r = t * (t - 1) // 2 * (m - u)
	r += t * (t + 1) // 2 * u
	k = n - m + 1
	return '{} {}'.format(r, k * (k - 1) // 2)
print(main())


def friends_in_team(amount):
	if amount <= 1:
		return 0
	return amount * (amount - 1) // 2
(n, m) = (int(x) for x in input().split())
a = friends_in_team(n // m) * (m - n % m)
a += friends_in_team(n // m + 1) * (n % m)
b = friends_in_team(n - m + 1)
print('{} {}'.format(min(a, b), max(a, b)))


(n, m) = map(int, input().split())
l = n - m
maxi = (l + 1) * l // 2
t = n // m
l1 = n % m
mini1 = (m - l1) * (t * (t - 1) // 2)
mini2 = l1 * ((t + 1) * t // 2)
mini = mini1 + mini2
print(str(mini) + ' ' + str(maxi))


import math
(n, m) = map(int, input().split())
x = n // m
if n % m == 0:
	mi = m * x * (x - 1) // 2
else:
	mi = n % m * (x + 1) * x // 2 + (m - n % m) * x * (x - 1) // 2
ma = (n - m + 1) * (n - m) // 2
print(mi, ma)


(n, g) = map(int, input().split())
print(int(n % g * (n // g) + 0.5 * g * (n // g) * (n // g - 1)), int((n - g + 1) * (n - g) // 2))


(n, m) = [int(x) for x in input().split()]
size = n // m
res = n % m
nummin = (size - 1) * size // 2 * (m - res) + res * (size + 1) * size // 2
nummax = (n - m + 1) * (n - m) // 2
print(nummin, nummax)


(n, m) = list(map(int, input().split()))
rem = n % m
ans = rem * (n // m + 1) * (n // m) // 2 + (m - rem) * (n // m) * (n // m - 1) // 2
print(ans, end=' ')
cnt = n - (m - 1)
print(cnt * (cnt - 1) // 2)


def comb2(n):
	return n * (n - 1) // 2

def main():
	(n, m) = read()
	k = n // m
	p = n % m
	mn = p * comb2(k + 1) + (m - p) * comb2(k)
	mx = comb2(n - m + 1)
	print(mn, mx)

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='')
write(main())


def main():
	(a, b) = [int(i) for i in input().split()]
	m = a // b
	n = b - a % b
	print((m - 1) * n * m // 2 + (b - n) * (m + 1) * m // 2, (a - b + 1) * (a - b) // 2)
main()


def cal(x):
	a = x
	b = x - 1
	if x % 2 == 0:
		a = int(x / 2)
	else:
		b = int(x / 2)
	return a * b
(n, m) = [int(n) for n in input().split()]
tmp = int(n / m)
tmp1 = n % m
sum = int(tmp1 * cal(tmp + 1) + (m - tmp1) * cal(tmp))
sum1 = cal(n - m + 1)
print(sum, sum1)


def maxi(n, m):
	n -= m - 1
	return summ(n - 1)

def mini(n, m):
	if m > n:
		return 0
	x = n // m
	f = n % m
	ans = f * summ(x) + (m - f) * summ(x - 1)
	return ans

def summ(n):
	return n * (n + 1) // 2
(n, m) = map(int, input().rstrip().split())
print(mini(n, m), maxi(n, m))


(n, m) = [int(x) for x in input().split()]
nb_joueurs_max = n - m + 1
nb_max = int(nb_joueurs_max * (nb_joueurs_max - 1) // 2)
nb_joueurs_petite = int(n / m)
nb_joueurs_grande = int(n / m) + 1
nb_equipe_petite = m - n % m
nb_equipe_grande = n % m
nb_min = int(nb_equipe_petite * nb_joueurs_petite * (nb_joueurs_petite - 1) / 2)
nb_min += int(nb_equipe_grande * nb_joueurs_grande * (nb_joueurs_grande - 1) / 2)
print(str(nb_min) + ' ' + str(nb_max))


(n, m) = map(int, input().split())
num = n // m - 1
num2 = n % m
num3 = m - num2
num4 = num * (num + 1) // 2
num5 = (num + 2) * (num + 1) // 2
kmin = num4 * num3 + num5 * num2
num6 = n - m + 1 - 1
kmax = (num6 + 1) * num6 // 2
print(kmin, kmax)


(n, m) = [int(i) for i in input().split()]
kmin = 0
kmax = 0
kmin = (m - n % m) * (n // m) * (n // m - 1) // 2 + n % m * (n // m + 1) * (n // m) // 2
kmax = (n - m + 1) * (n - m) // 2
print(kmin, kmax)


from math import ceil
(a, b) = [int(i) for i in input().split()]
s = a - b + 1
j = s * (s - 1) // 2
z = a % b
c = ceil(a / b)
f = a // b
x = c * (c - 1) // 2
y = f * (f - 1) // 2
t = z * x + (b - z) * y
print(t, j)


(p, g) = map(int, input().split())
n = p * (p - 1) // 2
if g == 1:
	print(n, end=' ')
else:
	print(p % g * ((p // g + 1) * (p // g)) // 2 + (g - p % g) * (p // g * (p // g - 1)) // 2, end=' ')
print((p - g + 1) * (p - g) // 2, end=' ')


(n, m) = map(int, input().split())
if n == m:
	print(0, 0)
elif m == 1:
	print(n * (n - 1) // 2, n * (n - 1) // 2)
else:
	n = n - m
	mx = (n + 1) * n // 2
	c = 1
	while n - m >= 0:
		n = n - m
		c += 1
	if n == 0:
		mn = m * (c * (c - 1) // 2)
	else:
		mn = n * (c * (c + 1) // 2) + (m - n) * (c * (c - 1) // 2)
	print(mn, mx)


(n, m) = map(int, input().split())
max = (n - m + 1) * (n - m) // 2
if m == 1:
	tmp = 0
min = n % m * (n // m * (n // m + 1) // 2) + (m - n % m) * ((n // m - 1) * (n // m) // 2)
print(min, end=' ')
print(max)


import math
import sys
(n, m) = list((int(x) for x in input().split()))
import math
min1 = (n % m, math.ceil(n / m))
min2 = (m - n % m, math.floor(n / m))
resmin = min1[0] * (min1[1] * (min1[1] - 1) // 2) + min2[0] * (min2[1] * (min2[1] - 1) // 2)
max1 = n - m + 1
resmax = max1 * (max1 - 1) // 2
print(resmin, resmax)


(p, t) = (int(i) for i in input().split())
n = p - t
kmax = int((n + 1) * n) // 2
m = p // t - 1
e = p % t
kmin = int((m + 1) / 2 * m) * t + (m + 1) * e
print(kmin, kmax)


(n, m) = map(int, input().split())
a = n - m + 1
b = n // m
kmax = (a - 1) * a // 2
kmin = n % m * b * (b + 1) // 2 + (m - n % m) * b * (b - 1) // 2
print(kmin, kmax)


def f(x):
	return x * (x - 1) // 2
a = list(map(int, input().split()))
print((a[1] - a[0] % a[1]) * f(a[0] // a[1]) + a[0] % a[1] * f(a[0] // a[1] + 1), f(a[0] - a[1] + 1))


def pair(n):
	return n * (n - 1) // 2
(n, m) = [int(x) for x in input().split(' ')]
k1 = n % m * pair(n // m + 1) + (m - n % m) * pair(int(n // m))
k2 = pair(n - m + 1)
print(k1, k2)


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, m):
	maxx = n - m
	maxx = (maxx + 1) * maxx // 2
	rem = n % m
	cnt = n // m
	minn = rem * ((cnt + 1) * cnt // 2)
	minn += (m - rem) * ((cnt - 1) * cnt // 2)
	print(minn, maxx)
(n, m) = list(map(int, input().split()))
solve(n, m)


from sys import stdin

def anfel():
	a = stdin.readline().split()
	num = int(a[0])
	num2 = int(a[1])
	x = num - (num2 - 1)
	numx = x * (x - 1) // 2
	y = num % num2
	z = num // num2
	numm = z * (y * (num // num2 + 1) + (num2 - num % num2) * (num // num2 - 1)) // 2
	print(numm, numx)
anfel()


(n, m) = map(int, input().split())
k = n - (m - 1)
k = k - 1
maxk = k * (k + 1) // 2
q = n // m
r = n % m
mink = (m - r) * (q * (q - 1) // 2) + r * (q * (q + 1) // 2)
print(mink, maxk)


from sys import stdin, stderr

def readInts():
	return map(int, stdin.readline().strip().split())

def print_err(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def pair_count(n):
	return n * (n - 1) // 2

def min_pairs(n, k):
	if k == 1:
		return pair_count(n)
	v = n // k
	d = n % k
	lo = pair_count(v) * (k - d)
	hi = pair_count(v + 1) * d
	return lo + hi

def max_pairs(n, k):
	n2 = n - k + 1
	return pair_count(n2)

def run():
	(n, k) = readInts()
	print(min_pairs(n, k), max_pairs(n, k))
run()


(n, m) = map(int, input().split())
k = n // m
u = n % m
z = n - m
print('%d %d' % (k / 2 * ((k - 1) * (m - u) + (k + 1) * u), (z + 1) * z // 2))


(n, m) = map(int, input().split())
temp = n - (m - 1)
maxm = temp * (temp - 1) // 2
q = n // m
r = n % m
temp2 = q * (q - 1) // 2 * (m - r)
temp3 = q + 1
temp4 = temp3 * (temp3 - 1) // 2 * r
minm = temp2 + temp4
print(minm, maxm)


import sys
from collections import deque
input = sys.stdin.readline
l = list(map(int, input().split()))
n = l[0]
m = l[1]
remain1 = n - m
remain1 += 1
max1 = remain1 * (remain1 - 1) // 2
left = n % m
quot = n // m
no_extra = m - left
extra = left
for_extra = quot + 1
for_no_extra = quot
t1 = extra * for_extra * (for_extra - 1) // 2
t2 = no_extra * for_no_extra * (for_no_extra - 1) // 2
min1 = t1 + t2
print(str(min1) + ' ' + str(max1))


(n, m) = map(int, input().split())
mx = (n - m + 1) * (n - m) // 2
x = n // m
mn = x * (x - 1) // 2
mn *= m
mn += x * (n % m)
print(mn, mx)


(n, m) = map(int, input(' ').split())

def pairs(n):
	return n * (n - 1) // 2
x = n % m
minimum = x * pairs(n // m + 1)
minimum += (m - x) * pairs(n // m)
maximum = pairs(n - m + 1)
print(minimum, maximum)


import math

def count(x):
	return x * (x - 1) // 2
(n, m) = map(int, input().split())
k_min = count(math.ceil(n / m)) * (n % m) + count(math.floor(n / m)) * (m - n % m)
k_max = count(n - m + 1)
print(k_min, k_max)


import math
(n, m) = map(int, input().split())
cal = lambda x: max(0, x * (x - 1) // 2)
print(cal(n // m) * (m - n % m) + cal(math.ceil(n / m)) * (n % m), cal(n - m + 1))


import math
(n, m) = map(int, input().split())
u = n % m
v = n // m
print(v * (v - 1) // 2 * (m - u) + v * (v + 1) // 2 * u, (n - m) * (n - m + 1) // 2)


(a, b) = map(int, input().split())
check = a - b
maxi = check * (check + 1) // 2
check2 = a % b
check3 = a // b
mini = check3 * (check3 - 1) // 2 * (b - check2) + check2 * (check3 * (check3 + 1) // 2)
print(mini, maxi)


(n, m) = [int(a) for a in input().split()]

def pairs(x):
	return x * (x - 1) // 2
minfriends = pairs(n // m) * (m - n % m) + pairs(n // m + 1) * (n % m)
maxfriends = pairs(n - m + 1)
print(minfriends, maxfriends)


(n, m) = map(int, input().split())
if m == 1:
	print(n * (n - 1) // 2, n * (n - 1) // 2)
elif n <= m:
	print(0, 0)
else:
	kmin = 0
	r = n // m
	k = 0
	p = n
	t = 1
	kmin += p % m * (r + 1) * r // 2
	kmin += (m - p % m) * r * (r - 1) // 2
	kmax = (n - m + 1) * (n - m) // 2
	print(kmin, kmax)


(n, k) = map(int, input().split())
(m, d) = (n // k, n % k)
print(m * (2 * d + m * k - k) // 2, (n - k + 1) * (n - k) // 2)


(n, k) = map(int, input().split())
x = n - (k - 1)
kmax = x * (x - 1) // 2
t = n // k
y = n % k
kmin = (k - y) * (t * (t - 1) // 2) + y * ((t + 1) * t // 2)
print(kmin, kmax)


def main():
	(n, m) = map(int, input().strip().split())
	ma = (n - m + 1) * (n - m) // 2
	p = (n + m - 1) // m
	m1 = m * p - n
	m -= m1
	mi = (m * p + m1 * (p - 2)) * (p - 1) // 2
	print(mi, ma)
main()


def C2_N(n):
	return (n - 1) * n // 2

def minPairs(n, m):
	if n % m == 0:
		member_in_team = n // m
		return C2_N(member_in_team) * m
	else:
		member_in_small_team = n // m
		member_in_large_team = n // m + 1
		num_large_team = n % m
		num_small_team = m - num_large_team
		return C2_N(member_in_small_team) * num_small_team + C2_N(member_in_large_team) * num_large_team

def maxPairs(n, m):
	member_in_biggest_team = n - (m - 1)
	return C2_N(member_in_biggest_team)
inp = input().split(' ')
n = int(inp[0])
m = int(inp[1])
print(minPairs(n, m), maxPairs(n, m))


combinations = lambda x: x * (x - 1) // 2
(n, m) = map(int, input().split())
(normal_team, remainder) = divmod(n, m)
mini = (m - remainder) * combinations(normal_team) + remainder * combinations(normal_team + 1)
maxi = combinations(n - m + 1)
print(mini, maxi)


[n, m] = list(map(int, input().split(' ')))

def count_friends(n):
	return n * (n - 1) // 2
minimum = 0
if n % m == 0:
	minimum = count_friends(n // m) * m
else:
	minimum = count_friends(n // m) * (m - n % m) + count_friends(n // m + 1) * (n % m)
maximum = count_friends(n - m + 1)
print(minimum, maximum)


(n, m) = map(int, input().split())
rem = n % m
members = (n - rem) // m
minpairs = 0
if members > 1:
	minpairs += (m - rem) * members * (members - 1) // 2
minpairs += rem * (members + 1) * members // 2
rest = n - m + 1
maxpairs = 0
if rest > 1:
	maxpairs = rest * (rest - 1) // 2
print(minpairs, maxpairs)


def result(n):
	n -= 1
	return n * (n + 1) // 2
(n, m) = map(int, input().split())
max = result(n - (m - 1))
temp1 = n // m
temp2 = n % m
min = result(temp1 + 1) * temp2
min += result(temp1) * (m - temp2)
print(min, max)


(n, m) = map(int, input().split())
if m == 1:
	print(n * (n - 1) // 2, n * (n - 1) // 2)
else:
	l = n - m
	h = l * (l + 1) // 2
	k = n // m
	z = n % m
	f = k + 1
	j = k
	ans = z * f * (f - 1) // 2 + (m - z) * j * (j - 1) // 2
	print(ans, h)


M = lambda : map(int, input().split())
(n, m) = M()
ma = n - m + 1
kma = ma * (ma - 1) // 2
a = 1 + (n - m) // m
if n % m == 0:
	mi = a * (a - 1) // 2 * m
else:
	a = a * (a - 1) // 2 * (m - (n - m) % m)
	b = (n - m) // m + 2
	b = b * (b - 1) // 2 * ((n - m) % m)
	mi = a + b
print(mi, kma)


def solve(n, m):
	count_pair = lambda x: x * (x - 1) // 2
	t = n // m
	kmin = count_pair(t + 1) * (n % m) + count_pair(t) * (m - n % m)
	kmax = count_pair(n - m + 1)
	return (kmin, kmax)

def test():
	assert solve(5, 1) == (10, 10)
	assert solve(3, 2) == (1, 1)
	assert solve(6, 3) == (3, 6)
	assert solve(10, 2) == (20, 36)
	assert solve(1000000000, 1000000) == (499500000000, 499000500499500000)
test()
(n, m) = map(int, input().split())
res = solve(n, m)
print('{} {}'.format(res[0], res[1]))


(n, m) = map(int, input().split())
if m == 1:
	ans = n * (n - 1) // 2
	print(ans, ans)
else:
	if n % m == 0:
		k = n // m
		temp = k * (k - 1) // 2
		ans = temp * m
	else:
		k = n // m
		p = n % m
		temp = k * (k - 1) // 2
		temp2 = k * (k + 1) // 2
		ans = temp * (m - p)
		ans += temp2 * p
	mi = ans
	k = n - (m - 1)
	ans = k * (k - 1) // 2
	if mi == ans:
		print(mi, mi)
	elif mi > ans:
		print(ans, mi)
	elif mi < ans:
		print(mi, ans)


(p, t) = [int(x) for x in input().split()]

def pairsCombinations(p, t):
	if p % t == 0:
		minForTeam = p // t * (p // t - 1) // 2
		minimum = minForTeam * t
	else:
		minForTeam1 = p // t * (p // t - 1) // 2
		minForTeam2 = (p // t + 1) * (p // t) // 2
		minimum = minForTeam1 * (t - p % t) + minForTeam2 * (p % t)
	maximum = (p - (t - 1)) * (p - t) // 2
	return '%s %s' % (minimum, maximum)
print(pairsCombinations(p, t))


(n, m) = map(int, input().split())
tna = n // m
tnb = tna
if n % m > 0:
	tnb = tna + 1
tx = n - m + 1
print(tnb * (tnb - 1) // 2 * (n % m) + tna * (tna - 1) // 2 * (m - n % m), tx * (tx - 1) // 2)


(n, m) = map(int, input().split())
hi = (n - (m - 1)) * (n - (m - 1) - 1) // 2
sz = n // m
extra = n % m
lo = extra * (sz + 1) * sz // 2 + (m - extra) * sz * (sz - 1) // 2
print(lo, hi)


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007

def cal(n):
	return n * (n - 1) // 2
(n, m) = iia()
maxx = cal(n - m + 1)
t = n % m
t1 = n // m
minn = cal(t1) * (m - t) + cal(t1 + 1) * t
print(minn, maxx)


def pair(x):
	return x * (x - 1) // 2
(n, k) = list(map(int, input().split()))
share = n // k
rem = n % k
comb = share + 1
mini = pair(comb) * rem + pair(share) * (k - rem)
maxi = pair(n - k + 1)
print(*(mini, maxi))


import sys
import math
import random
if len(sys.argv) >= 2:
	if sys.argv[1] == 'LOCAL':
		sys.stdin = open('input.in', 'r')
(n, m) = map(int, input().split())
t = n - (m - 1)
maxx = int(t * (t - 1) // 2)
t = n // m
if n % m == 0:
	minn = t * (t - 1) // 2
	minn *= m
else:
	t = n // m
	minn = t * (t - 1) // 2 * (m - n % m)
	t += 1
	minn += t * (t - 1) // 2 * (n % m)
print(minn, maxx)


(n, t) = input().split()
n = int(n)
t = int(t)

def sm(n):
	return int(int(n * (n - 1)) // 2)
mx = sm(n - t + 1)
if n % t == 0:
	mn = t * sm(int(n / t))
else:
	x = n % t
	mn = x * sm(int(n // t + 1)) + (t - x) * sm(int(n // t))
print(int(mn), int(mx))


(n, k) = map(int, input().split())
nk = n // k
print(nk * (nk - 1) // 2 * k + n % k * nk, (n - k + 1) * (n - k) // 2)


(n, m) = map(int, input().split())
w = n - (m - 1)
max1 = w * (w - 1) // 2
if (n - m) % m == 0:
	p = 1 + (n - m) // m
	min1 = p * (p - 1) // 2 * m
	print(min1, max1)
else:
	q = 1 + (n - m) // m
	q = q * (q - 1) // 2 * (m - (n - m) % m)
	r = 2 + (n - m) // m
	r = r * (r - 1) // 2 * ((n - m) % m)
	print(q + r, max1)


(n, m) = (int(x) for x in input().split())
(q, r) = (n // m, n % m)
kmin = r * (q + 1) * q // 2 + (m - r) * q * (q - 1) // 2
kmax = (n - m + 1) * (n - m) // 2
print(kmin, kmax)


def f(a):
	return a * (a - 1) // 2
(n, m) = map(int, input().split())
f_max = f(n - m + 1)
f_min = (n - m * (n // m)) * f(n // m + 1) + (m - n + m * (n // m)) * f(n // m)
print(f_min, f_max)


def f(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
ma = f(n + 1 - m)
q = n // m
r = n % m
mi = r * f(q + 1) + (m - r) * f(q)
print(mi, ma)


def comb(h):
	if h % 2 == 0:
		k = int(h / 2) * (h - 1)
	else:
		k = int((h - 1) / 2) * h
	k = int(k)
	return k
g = input()
(n, m) = [int(x) for x in g.split()]
kmax = comb(n - m + 1)
if n - m < m:
	kmin = n - m
else:
	mini = int(n / m)
	t = n - mini * m
	if t == 0:
		kmin = m * comb(mini)
	else:
		rem = m - t
		kmin = t * comb(mini + 1) + rem * comb(mini)
print(kmin, kmax)


(n, m) = map(int, input().split())
c = n - (m - 1)
kmax = c * (c - 1) // 2
a = n // m
b = n % m
if a != 0:
	kmin = (a + 1) * a // 2 * b + a * (a - 1) // 2 * (m - b)
else:
	kmin = (a + 1) * a // 2 * b
print(kmin, kmax)


inp = list(map(int, input().split()))
n = inp[0]
m = inp[1]
k = n // m
print(k * (k + 1) // 2 * (n % m) + k * (k - 1) // 2 * (m - n % m), end=' ')
print((n - m + 1) * (n - m) // 2)


(n, m) = map(int, input().split())
a = n // m
max = (n - m + 1) * (n - m) // 2
min = m * a * (a - 1) // 2 + a * (n % m)
print(min, max)


(n, m) = map(int, input().split())
min = n // m
rem = n % m
mani = m - rem
ans = min * (min - 1) // 2
ans *= mani
mani = rem
min = min + 1
ans1 = min * (min - 1) // 2
ans1 *= mani
ans = ans + ans1
min = ans
max = n - (m - 1)
ans = max * (max - 1) // 2
print(min, ans)


(n, m) = tuple(map(int, input().split()))
n1 = int(n / m)
mod = n % m
print((n1 + 1) * n1 // 2 * mod + n1 * (n1 - 1) // 2 * (m - mod), (n - m + 1) * (n - m) // 2)


pair_friends = lambda x: (x - 1) * x // 2

def solve(n, m):
	if n == m:
		return (0, 0)
	elif n > m:
		mx = pair_friends(n - m + 1)
		per_team = n // m
		teams_one_more = n - per_team * m
		teams_normal = m - teams_one_more
		mn = pair_friends(per_team) * teams_normal + pair_friends(per_team + 1) * teams_one_more
		return (mn, mx)
(n, m) = map(int, input().split())
print(*solve(n, m))


def comb(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
min_friends = 0
max_friends = comb(n - m + 1)
if n % m == 0:
	min_friends = m * comb(n // m)
else:
	base = n // m
	remaining = n % m
	min_friends = remaining * comb(base + 1) + (m - remaining) * comb(base)
print(min_friends, max_friends)


from sys import stdin, stdout
input = stdin.readline
(n, m) = map(int, input().split())

def pir(n):
	return n * (n - 1) // 2
kmin = pir(n // m) * (m - n % m)
kmin += pir(n // m + 1) * (n % m)
stdout.write(str(kmin) + ' ' + str(pir(n - m + 1)))


def nCr(n):
	return (n - 1) * n // 2
(n, m) = list(map(int, input().split()))
(a, b) = divmod(n, m)
res_min = b * nCr(a + 1)
if a >= 2:
	res_min += (m - b) * nCr(a)
res_max = nCr(n - (m - 1))
print(res_min, res_max)


(n, m) = [int(x) for x in input().split()]
(maxPair, minPair) = [0, 0]
maxMember = n - (m - 1)
if maxMember % 2 == 0:
	maxPair = int(maxMember / 2) * (maxMember - 1)
else:
	maxPair = int((maxMember - 1) / 2) * maxMember
minMembers = int(n / m)
left = n % m
minPair = (m - left) * int(minMembers * (minMembers - 1) / 2) + left * int(minMembers * (minMembers + 1) / 2)
print(minPair, maxPair)


def fact(n):
	if n <= 1:
		return 0
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
q = n // m
r = n % m
d = n - m
kmax = fact(d + 1)
kmin = r * fact(q + 1) + (m - r) * fact(q)
print(kmin, kmax)


(kids, teams) = [int(i) for i in input().split()]
low = int((kids - teams) * (kids - teams + 1) // 2)
small_teams = kids // teams
big_teams = kids // teams + 1
if kids % teams == 0:
	big_teams_amount = 0
	small_teams_amount = teams
else:
	big_teams_amount = kids % teams
	small_teams_amount = teams - big_teams_amount
high = int((big_teams_amount * big_teams * (big_teams - 1) + small_teams_amount * small_teams * (small_teams - 1)) / 2)
print(high, low)


(n, m) = map(int, input().split())
if n == m:
	print('{} {}'.format(0, 0))
	exit()

def nc2(n):
	return n * (n - 1) // 2
ans1 = nc2(n - m + 1)
if n % m == 0:
	if n // m >= 2:
		ans2 = nc2(n // m) * m
	else:
		ans2 = 0
else:
	ans2 = nc2(n // m + 1) * (n % m)
	if n // m >= 2:
		ans2 += nc2(n // m) * (m - n % m)
print(min(ans1, ans2), max(ans1, ans2))


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	(n, m) = map(int, input().split())
	r = n % m
	q = n // m
	if m > 1:
		print(q * (q - 1) // 2 * (m - r) + (q + 1) * q // 2 * r, (n - m + 1) * (n - m) // 2)
	else:
		print(nCr(q, 2), nCr(q, 2))
for _ in range(1):
	solve()


import math
import sys
(n, m) = list((int(x) for x in input().split()))
import math
(min1am, min1si) = (n % m, math.ceil(n / m))
(min2am, min2si) = (m - n % m, math.floor(n / m))
resmin = min1am * (min1si * (min1si - 1) // 2) + min2am * (min2si * (min2si - 1) // 2)
max1 = n - m + 1
resmax = max1 * (max1 - 1) // 2
print(resmin, resmax)


(n, m) = map(int, input().split())
nummin = n // m
nummore = n % m
MIN = nummin * (nummin - 1) / 2 * (m - nummore) + nummin * (nummin + 1) / 2 * nummore
nummax = n + 1 - m
print(int(MIN), nummax * (nummax - 1) // 2)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def f(n):
	return n * (n - 1) // 2

def solve():
	(n, m) = read()
	if n % m == 0:
		a = f(n // m) * m
	else:
		a = f(n // m + 1) * (n % m) + f(n // m) * (m - n % m)
	b = f(n - (m - 1))
	print(a, b)
solve()


import math
(n, m) = map(int, input().split())
div = n // m
rem = n % m
mans = 0
mans += rem * ((div + 1) * div // 2)
mans += (m - rem) * (div * (div - 1) // 2)
maxans = n - m + 1
maxans = maxans * (maxans - 1) // 2
print(mans, maxans)


(n, m) = map(int, input().split())
x = n // m
y = n - x * m
kmin = y * ((x + 1) * x // 2) + (m - y) * (x * (x - 1) // 2)
z = n - (m - 1)
kmax = z * (z - 1) // 2
print(kmin, kmax, sep=' ')


from math import *
(n, m) = map(int, input().split())

def printNcR(n, r):
	if n == 1:
		return 0
	p = 1
	k = 1
	if n - r < r:
		r = n - r
	if r != 0:
		while r:
			p *= n
			k *= r
			m = gcd(p, k)
			p //= m
			k //= m
			n -= 1
			r -= 1
	else:
		p = 1
	return p
if n % m == 0:
	kmin = m * printNcR(int(n / m), 2)
else:
	a = n % m
	b = int(n / m)
	kmin = a * printNcR(b + 1, 2) + (m - a) * printNcR(b, 2)
p = m - 1
q = n - p
kmax = printNcR(q, 2)
print(kmin, kmax)


import sys

def read_from_stdin():
	(n, m) = input().split()
	return (int(n), int(m))

def write_to_stdout(res1, res2):
	sys.stdout.write('%d %d\n' % (res1, res2))

def get_answer(n, m):
	k_max = (n - m) * (n - m + 1) // 2
	k_min_plus = n % m
	k_min = k_min_plus * (n // m) * (n // m + 1) // 2 + (m - k_min_plus) * (n // m) * (n // m - 1) // 2
	return (k_max, k_min)

def main():
	(n, m) = read_from_stdin()
	(k_max, k_min) = get_answer(n, m)
	write_to_stdout(k_min, k_max)
main()


ot = [int(i) for i in filter(None, input().split(' '))]
n = ot[0]
k = ot[1]
k_chel_min = n // k
k_groops_max = n - k_chel_min * k
k_groops_min = k - k_groops_max
k_chel_max = k_chel_min + 1
friends_min = k_chel_min * (k_chel_min - 1) * k_groops_min // 2
friends_max = k_chel_max * (k_chel_max - 1) * k_groops_max // 2
sum_min = friends_max + friends_min
sum_max = (n - k + 1) * (n - k) // 2
print(sum_min, sum_max)


import sys
fin = sys.stdin
fout = sys.stdout
(n, m) = map(int, fin.readline().strip().split())
t1 = n - m + 1
kmax = t1 * (t1 - 1) // 2
t2 = n // m
kmin = t2 * (t2 - 1) // 2 * m + n % m * t2
print(' '.join([str(kmin), str(kmax)]))


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	(n, m) = vars()
	mini = n // m
	mini_ans = 0
	mini_ans += (n // m + 1) * (n // m) // 2 * (n % m)
	mini_ans += n // m * (n // m - 1) // 2 * (m - n % m)
	maxi = n - m + 1
	maxi_ans = (maxi - 1) * maxi // 2
	print(mini_ans, maxi_ans)
t = 1
for _ in range(t):
	main()


o = input().rstrip().split(' ')
a = int(o[0])
b = int(o[1])
A = a // b
H = a - A * b
B = H % b
if B != 0:
	J = b * (A * (A - 1) // 2)
	L = B * A
	print(L + J, end=' ')
else:
	print(b * (A * (A - 1) // 2), end=' ')
C = a - (b - 1)
print(C * (C - 1) // 2)


(n, m) = map(int, input().split())
t1 = n - (m - 1)
y = t1 * (t1 - 1) // 2
t2 = n // m
t3 = n % m
x = t3 * ((t2 + 1) * t2 // 2) + (m - t3) * (t2 * (t2 - 1) // 2)
print(x, y)


def randomteams(n, m):
	if m == n:
		return (0, 0)
	else:
		ma = (n - m + 1) * (n - m) // 2
		mi = (m - n % m) * (n // m) * (n // m - 1) // 2
		mi += n % m * (n // m + 1) * (n // m) // 2
		return (ma, mi)
(n, m) = list(map(int, input().split(' ')))
(a, b) = randomteams(n, m)
print(b, a)


(n, m) = map(int, input().split())

def ft(x):
	return x * (x - 1) // 2
kmax = ft(n - m + 1)
a = n // m
b = n % m
kmin = ft(a) * (m - b) + ft(a + 1) * b
print(kmin, kmax)


(n, m) = map(int, input().split())

def pair(x):
	return x * (x - 1) // 2

def count(n1, p1, n2, p2):
	return n1 * pair(p1) + n2 * pair(p2)
n1 = n % m
n2 = m - n1
p2 = n // m
p1 = p2 + 1
mn = count(n1, p1, n2, p2)
n1 = m - 1
p1 = 1
n2 = 1
p2 = n - n1
mx = count(n1, p1, n2, p2)
print(mn, mx)


import sys
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
sys.setrecursionlimit(10 ** 7)
mod = 1000000007

def IOE():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def pair(n):
	if n == 1:
		return 0
	else:
		return n * (n - 1) // 2

def main():
	(a, b) = map(int, sys.stdin.readline().split())
	if b == 1:
		print(pair(a), pair(a))
	elif a % b == 0:
		print(min(pair(a // b) * b, pair(a - b + 1)), max(pair(a // b) * b, pair(a - b + 1)))
	else:
		print(min(pair(a // b + 1) * (a % b) + pair(a // b) * (b - a % b), pair(a - b + 1)), max(pair(a - b + 1), pair(a // b + 1) * (a % b) + pair(a // b) * (b - a % b)))
try:
	IOE()
except:
	pass
main()


import sys
import math

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))
(n, m) = ninp()
cnt1 = 0
cnt2 = 0
if m == 1:
	print(n * (n - 1) // 2, n * (n - 1) // 2)
elif n % m == 0:
	most = n - m + 1
	ans1 = most * (most - 1) // 2
	a = n // m
	ans = m * a * (a - 1) // 2
	print(ans, ans1)
else:
	most = n - m + 1
	ans1 = most * (most - 1) // 2
	min = n // m
	max = n // m + 1
	cnt1 = m - n % m
	cnt2 = n % m
	ans = cnt1 * min * (min - 1) // 2 + cnt2 * max * (max - 1) // 2
	print(ans, ans1)


import math

def cnt(n):
	return n * (n - 1) // 2
(n, m) = [int(x) for x in input().split()]
print((m - n % m) * cnt(n // m) + n % m * cnt(n // m + 1), cnt(n - m + 1))


(a, b) = map(int, input().split())
x = a - b + 1
res1 = x * (x - 1) // 2
y = a // b
z = a % b
res2 = (b - z) * (y * (y - 1) // 2) + z * ((y + 1) * y // 2)
print(str(res2) + ' ' + str(res1))


def main():
	(n, m) = [int(i) for i in input().split()]
	k = n // m
	n1 = (k + 1) * m - n
	minimal = n1 * k * (k - 1) // 2 + (m - n1) * (k + 1) * k // 2
	maximal = (n - m + 1) * (n - m) // 2
	print(minimal, maximal)
main()


(n, m) = [int(i) for i in input().split()]
minimum_members = n // m
minimum_pairs = minimum_members * (minimum_members - 1) // 2 * m + n % m * minimum_members
maximum_pairs = (n - m + 1) * (n - m) // 2
print(minimum_pairs, maximum_pairs)


from collections import *
from bisect import *
from math import *
from heapq import *
from fractions import *
import sys
input = sys.stdin.readline
t = 1

def r(a):
	return a * (a - 1) // 2
while t:
	t -= 1
	(n, k) = map(int, input().split())
	q = n // k
	n1 = n - k * q
	kmin = r(q + 1) * n1
	kmin += r(q) * (k - n1)
	kmax = r(n - k + 1)
	print(kmin, kmax)


(n, m) = map(int, input().split())
mod = n % m
min_size1 = n // m
min_size2 = min_size1 + 1
min_ans = min_size1 * (min_size1 - 1) // 2 * (m - mod) + min_size2 * (min_size2 - 1) // 2 * mod
max_ans = (n - m + 1) * (n - m) // 2
print(min_ans, max_ans)


(n, m) = map(int, input().split())
if (n - m) % 2:
	kmax = int((n - m + 1) / 2) * (n - m)
else:
	kmax = int((n - m) / 2) * (n - m + 1)
k = int(n / m)
kmin = int(n % m * (k + 1) * k / 2) + int((m - n % m) * k * (k - 1) / 2)
print(kmin, kmax)


(n, m) = (int(x) for x in input().split())
a = n - m + 1
mn = n // m
r = n % m

def mul(a):
	return max(a * (a - 1) // 2, 0)
print((m - r) * mul(mn) + r * mul(mn + 1), mul(a))


(n, m) = map(int, input().split())
k = n - m
maxx = k * (k + 1) // 2
a = n // m
minn = m * a * (a - 1) // 2 + a * (n % m)
print(minn, maxx)


import math
(n, m) = map(int, input().split())
kmax = 0
kmin = 0
if n == 1:
	kmax = 0
	kmin = 0
elif m == 1:
	kmin = kmax = n * (n - 1) / 2
else:
	x = n // m
	y = n - x * m
	kmin = y * x * (x + 1) / 2 + (m - y) * x * (x - 1) / 2
	kmax = (n - m + 1) * (n - m) // 2
print(int(kmin), int(kmax))


import sys
import math

def combination(k, n):
	if k > n:
		return 0
	else:
		return n * (n - 1) // 2

def main():
	(n, m) = map(int, sys.stdin.readline().strip().split()[:2])
	if m == 1:
		print(combination(2, n), end=' ')
		print(combination(2, n))
	else:
		k = n // m
		h = n % m
		print(h * combination(2, k + 1) + (m - h) * combination(2, k), end=' ')
		print(combination(2, n - m + 1))
main()


(n, m) = map(int, input().split())
if n == m:
	print(0, 0)
elif n == m + 1:
	print(1, 1)
else:
	p = n - m + 1
	maxi = p * (p - 1) // 2
	d = n // m
	if d == 1:
		mini = n - m
	elif n % m:
		d += 1
		remain = d * m - n
		mini = (d - 1) * (d - 2) // 2 * remain
		remain = n - remain * (d - 1)
		remain //= d
		mini += d * (d - 1) // 2 * remain
	else:
		mini = d * (d - 1) // 2 * m
	print(mini, maxi)


(n, m) = map(int, input().split())
k = n // m
z = n - m
print(m * k * (k - 1) // 2 + k * (n % m), (z + 1) * z // 2)


from sys import stdin
(n, m) = [int(x) for x in stdin.readline().split()]
k_max = int((n - m + 1) * (n - m) // 2)
a = n // m
b = n % m
k_min = (m - b) * (a * (a - 1) / 2)
k_min += b * (a + 1) * a / 2
k_min = int(k_min)
print(k_min, k_max)


import sys

def calc(n):
	if n == 1:
		return 0
	if n % 2 == 0:
		return (n - 1) * (n >> 1)
	return (n - 1 >> 1) * n
(m, n) = map(int, sys.stdin.readline().split())
mmin = 0
left = m
each = int(m / n)
mmin += calc(each + 1) * (m % n)
if each != 0:
	mmin += calc(each) * (n - m % n)
mmax = 0
mmax = calc(m - n + 1)
print(mmin, mmax)


(n, m) = map(int, input().split())
x = (n - (m - 1)) * (n - (m - 1) - 1) // 2
a = n // m
b = n % m
y = b * ((1 + a) * a // 2) + (m - b) * (a * (a - 1) // 2)
print(y, x)


(n, m) = map(int, input().split())
if n == m:
	print(0, 0)
else:
	max_val = n - (m - 1)
	minimum = 0
	if max_val > 1:
		maximum = max_val * (max_val - 1) // 2
	else:
		maximum = 0
	minimum += (n // m + 1) * (n // m) // 2 * (n % m)
	minimum += n // m * (n // m - 1) // 2 * (m - n % m)
	print(minimum, maximum)


(n, m) = map(int, input().split())
q = n // m
rem = n % m
ans = int((n - m + 1) * (n - m))
kmax = ans // 2
if q > 1:
	kmin = int(rem * ((q + 1) * q / 2) + (m - rem) * (q * (q - 1) / 2))
else:
	kmin = rem
print(kmin, kmax)


(a, b) = map(int, input().split())
z = a - b + 1
z = z * (z - 1) // 2
c = a // b
k = a % b
m = c * (c - 1) // 2 * (b - k)
c += 1
m = m + k * c * (c - 1) // 2
print(m, z)


import math
(n, m) = map(int, input().split())

def comb(num):
	return num * (num - 1) // 2
min_pair = 0
max_pair = 0
per_team = n // m
remainder = n % m
min_pair = comb(per_team + 1) * remainder
min_pair += comb(per_team) * (m - remainder)
n = n - m + 1
max_pair = comb(n)
print('{} {}'.format(min_pair, max_pair))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
T = 1
for _ in range(T):
	(n, m) = list(map(int, stdin.readline().split()))
	if n == m:
		print(0, 0)
		continue
	kx = ncr(n - (m - 1), 2)
	x = n // m
	y = n % m
	if x > 1:
		kn = ncr(x + 1, 2) * y + ncr(x, 2) * (m - y)
	else:
		kn = ncr(x + 1, 2) * y
	print(kn, kx)


def ncr(n, r):
	if n < r:
		return 0
	res = 1
	r = min(r, n - r)
	if r == 0:
		return 1
	for i in range(1, r + 1):
		res = res * (n - i + 1) // i
	return res
(n, k) = map(int, input().split())
r = n % k
s = (k - r) * ncr(n // k, 2) + r * ncr(n // k + 1, 2)
print(s, ncr(n - k + 1, 2))


import math
(x, y) = map(int, input().strip().split())
x = x - y
kmax = (x + 1) * x // 2
w = int((x + y) / y)
k = (x + y) % y
kmin = (y - k) * w * (w - 1) / 2 + k * w * (w + 1) / 2
kmin = int(kmin)
kmax = int(kmax)
print(kmin, kmax)


(x, y) = map(int, input().split())
ma = x - y + 1
mi = x // y
lis = []
l = (mi + 1) * mi // 2 * (x % y) + mi * (mi - 1) // 2 * (y - x % y)
f = ma * (ma - 1) // 2
print(l, f)


import math

def main():
	(n, m) = map(int, input().split())
	Kmin = 0
	Kmax = 0
	if m == n:
		Kmin = 0
		Kmax = 0
	else:
		if m > 1:
			k = n - m + 1
			Kmax = int(k * (k - 1) // 2)
			k = int(n - m + 1)
			b = n / m
			if b > 2:
				b = int(b)
				Kmin = (n - m * b) * int(int(b + 1) * int(b) // 2) + (m - n + m * b) * int(int(b) * int(b - 1) // 2)
			if b == 2 and n % m == 0:
				Kmin = m
			if b >= 1 and n % m > 0 and (b < 2):
				Kmin = n % m
		if m == 1:
			Kmax = int(n * (n - 1) // 2)
			Kmin = Kmax
	print('{} {}'.format(Kmin, Kmax))
main()


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import math
(n, m) = map(int, input().split())
p = n - (m - 1)
a = p * (p - 1) // 2
b = n // m
if n % m == 0:
	x = m * b * (b - 1) // 2
else:
	share = n // m
	rem = n % m
	c = share + 1
	x = rem * c * (c - 1) // 2 + (m - rem) * share * (share - 1) // 2
print(min(a, x), max(a, x))


from math import ceil
(n, m) = [int(x) for x in input().split()]
max_pares = (n - m + 1) * (n - m) // 2
min_pares = 0
mod = n % m
c = ceil(n / m)
aux = mod * (c * (c - 1) // 2)
min_pares += aux
a = (n - c * mod) / (m - mod)
min_pares += (m - mod) * (a * (a - 1)) // 2
print(int(min_pares), max_pares)


def pairs(n):
	if n == 1:
		return 0
	if n % 2 == 0:
		return int(n // 2 * (n - 1))
	else:
		return int((n - 1) // 2 * n)
(n, k) = map(int, input().split())
maxx = int(pairs(n - k + 1))
x = n // k
rem = n % k
if rem == 0:
	minn = pairs(x) * k
else:
	minn = (k - rem) * pairs(x) + rem * pairs(x + 1)
print(int(minn), int(maxx), end=' ')


(n, m) = map(int, input().split())
if n == m:
	print(0, 0)
else:
	count = 0
	count = (n - m) * (n - m + 1) // 2
	fmax = count
	fmin = 0
	if m == 1:
		fmin = fmax
	else:
		a = n // m
		b = n % m
		fmin = a * (a - 1) // 2 * (m - b) + b * ((a + 1) * a // 2)
	print(fmin, fmax)


def c2(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
ma = c2(n - m + 1)
du = n % m
deu = m - du
people = n // m
mi = c2(people) * deu + c2(people + 1) * du
print(mi, ma)


def fac(a):
	return (a * a - a) // 2
(n, m) = map(int, input().split())
a = n // m
print(str(fac(a) * (m - n % m) + fac(a + 1) * (n % m)) + ' ' + str(fac(n - m + 1)))


def sum(x):
	f = x * (x - 1) // 2
	return f
(n, m) = map(int, input().split())
max1 = sum(n - m + 1)
k = n // m
l = n % m
min1 = l * sum(k + 1) + (m - l) * sum(k)
print(min1, max1)


import sys
import math
import collections
inp = lambda : sys.stdin.readline()
(x, y) = map(int, inp().split())
val = (x - y) // y + 1
rem = (x - y) % y
ct = y - rem
print(ct * (val * (val - 1) // 2) + rem * ((val + 1) * val) // 2, (x - y + 1) * (x - y) // 2)


import math

def sum(n):
	return n * (n - 1) // 2

def main():
	(n, m) = map(int, input().split())
	s = m - 1
	mx = sum(n - s)
	if m == 1:
		mn = mx
	else:
		mn = m * (((n - m) // m + 1) * ((n - m) // m)) // 2 + math.ceil((n - m) / m) * ((n - m) % m)
	print(f'{int(mn)} {int(mx)}')
main()


def su(a):
	return a * (a - 1) // 2
(n, m) = map(int, input().split())
a = n // m
b = n - a * m
c = m - b
minsum = 0
minsum += c * su(a)
minsum += b * su(a + 1)
maxsum = 0
alone = m - 1
toge = n - alone
maxsum += su(toge)
print(minsum, maxsum)


import math
(m, n) = map(int, input().split())
maxium = (m - n + 1) * (m - n) // 2
A = math.ceil(m / n)
Bcnt = A * n - m
Acnt = n - Bcnt
B = A - 1
minium = A * (A - 1) / 2 * Acnt + B * (B - 1) / 2 * Bcnt
print(int(minium), int(maxium))


(n, m) = map(int, input().split())
kmax = (n - m + 1) * (n - m) // 2
r = n % m
q = n // m
kmin = r * (q + 1) * q // 2 + (m - r) * (q - 1) * q // 2
print(str(kmin) + ' ' + str(kmax))


def pair(x):
	return x * (x - 1) // 2
(n, k) = list(map(int, input().split()))
(a, b) = (n // k, n % k)
res = a + 1
mini = pair(res) * b + pair(a) * (k - b)
maxi = pair(n - k + 1)
print(mini, maxi, sep=' ')


(a, b) = map(int, input().split())
ai = a // b
l = a - b + 1
print(b * ai * (ai - 1) // 2 + ai * (a % b), (l - 1) * l // 2)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)
(n, m) = map(int, input().split(' '))
v1 = n // m
v2 = m - n % m
v11 = v2 * (v1 * (v1 - 1)) // 2
v12 = n % m * (v1 * (v1 + 1)) // 2
ans1 = v11 + v12
ans2 = n - (m - 1)
ans2 = ans2 * (ans2 - 1) // 2
print(ans1, ans2)


def nc2(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
if m == 1:
	print(n * (n - 1) // 2, n * (n - 1) // 2)
	exit()
if n == m:
	print(0, 0)
	exit()
z = n - m + 1
maxi = nc2(z)
a = n // m
b = n % m
print((m - b) * nc2(a) + b * nc2(a + 1), maxi)


(n, m) = map(int, input().split())
if m >= n:
	print('0 0')
else:
	kmax = (n - m + 1) * (n - m) // 2
	val = n // m
	plus = n - m * val
	nonplus = m - plus
	kmin = nonplus * (val * (val - 1)) // 2 + plus * (val * (val + 1)) // 2
	print(str(kmin) + ' ' + str(kmax))


(n, m) = map(int, input().split())
r1 = 0
r1 += n % m * (n // m + 1) * (n // m) // 2 + (m - n % m) * (n // m - 1) * (n // m) // 2
r2 = (n - m) * (n - m + 1) // 2
print(r1, r2)


(n, m) = map(int, input().split())
b = n - (m - 1)
mayor = b * (b - 1) // 2
k = n % m
q = n // m
menor = k * ((q + 1) * q) // 2 + (m - k) * q * (q - 1) // 2
print(menor, mayor)


(n, m) = list(map(int, input().split()))
x = n // m
kmin = m * x * (x - 1) // 2 + x * (n % m)
kmax = (n - m) * (n - m + 1) // 2
print(str(kmin) + ' ' + str(kmax))


(n, m) = map(int, input().split())
if m == 1:
	s = (n - 1) * n // 2
	print(s, end=' ')
	print(s, end=' ')
else:
	y = n - (m - 1)
	s = (y - 1) * y // 2
	x = n // m
	c = n % m
	if c / m < 1:
		z = c * (x * (x + 1)) // 2 + (m - c) * ((x - 1) * x) // 2
	print(z, end=' ')
	print(s, end=' ')


from sys import stdin, stdout
from math import factorial

def Cnm(m, k=2):
	if m == 1:
		return 1
	return int(m * (m - 1) // factorial(k))

def maxi(n, m):
	return Cnm(n - m + 1)

def mini(n, m):
	if n % m == 0:
		return m * Cnm(n // m)
	if n // m > 1:
		return n % m * Cnm(n // m + 1) + (m - n % m) * Cnm(n // m)
	return n % m * Cnm(n // m + 1)

def solve(n, m):
	if m == n:
		return '0 0'
	if m == 1:
		res = Cnm(n)
		return '{} {}'.format(res, res)
	kmin = mini(n, m)
	kmax = maxi(n, m)
	return '{} {}'.format(kmin, kmax)
(n, m) = list(map(int, stdin.readline().strip().split()))
stdout.write(str(solve(n, m)))


import sys
import time
import os
from math import sqrt, log, log2, ceil, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def permute(nums):

	def fun(arr, nums, cur, v):
		if len(cur) == len(nums):
			arr.append(cur.copy())
		i = 0
		while i < len(nums):
			if v[i]:
				i += 1
				continue
			else:
				cur.append(nums[i])
				v[i] = 1
				fun(arr, nums, cur, v)
				cur.pop()
				v[i] = 0
				i += 1
		return arr
	res = []
	nums.sort()
	v = [0] * len(nums)
	return fun(res, nums, [], v)

def subsets(res, index, arr, cur):
	res.append(cur.copy())
	for i in range(index, len(arr)):
		cur.append(arr[i])
		subsets(res, i + 1, arr, cur)
		cur.pop()
	return res

def sieve(N):
	root = int(sqrt(N))
	primes = [1] * (N + 1)
	(primes[0], primes[1]) = (0, 0)
	for i in range(2, root + 1):
		if primes[i]:
			for j in range(i * i, N + 1, i):
				primes[j] = 0
	return primes

def bs(arr, l, r, x):
	if x < arr[0] or x > arr[len(arr) - 1]:
		return -1
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def nc2(n):
	if n <= 1:
		return 0
	return n * (n - 1) // 2

def solve():
	(n, m) = mint()
	maxx = nc2(n - (m - 1))
	if n % m == 0:
		minn = m * nc2(n // m)
	else:
		minn = 0
		a = n % m * nc2(ceil(n / m))
		b = (m - n % m) * nc2(n // m)
		minn += a + b
	print(minn, maxx)
start_time = time.time()
solve()


(n, m) = map(int, input().split())

def fri(x):
	return x * (x - 1) // 2
size = int(n / m)
large = n - m * size
small = m - large
print(small * fri(size) + large * fri(size + 1), fri(n - m + 1))


(n, m) = map(int, input().split())
tmn = n // m
tmn_p1 = n % m
print(tmn * (m * (tmn - 1) + 2 * tmn_p1) // 2, (n - m + 1) * (n - m) // 2)


(n, m) = map(int, input().split())
r = n - m + 1
d = n // m
s = n % m
mini = s * (d + 1) * d // 2 + (m - s) * d * (d - 1) // 2
print(mini, r * (r - 1) // 2)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))

def f(n):
	return n * (n - 1) // 2
(n, m) = I()
k = n // m
print((m - n % m) * f(n // m) + n % m * f(n // m + 1), f(n - m + 1))


l = list(map(int, input().split()))
(n, m) = (l[0], l[1])
if n % m == 0:
	p = n // m
	q = n - (m - 1)
	print(m * p * (p - 1) // 2, q * (q - 1) // 2)
else:
	q = n - (m - 1)
	p = n // m
	r = n % m
	s = p + 1
	print(r * (s * (s - 1) // 2) + (m - r) * (p * (p - 1) // 2), q * (q - 1) // 2)


(n, m) = input().split(' ')
(n, m) = (int(n), int(m))
if n % m == 0:
	print(f'{m * (n // m * (n // m - 1)) // 2} {(n - m + 1) * (n - m) // 2}')
else:
	c = n // m
	d = n % m
	print(f'{d * (c * (c + 1)) // 2 + (m - d) * (c * (c - 1)) // 2} {(n - m + 1) * (n - m) // 2} ')


from math import factorial
from math import ceil
from functools import lru_cache

def _kmin(n, m):
	if m == 1:
		return comb(n, 2)
	c = ceil(n / m)
	return comb(c, 2) + _kmin(n - c, m - 1)

@lru_cache(maxsize=128)
def semifact(a, b):
	if a == b:
		return 1
	else:
		return a * semifact(a - 1, b)

@lru_cache(maxsize=128)
def comb(a, b):
	if b > a:
		return 0
	return semifact(a, max(b, a - b)) // factorial(min(b, a - b))
(n, m) = tuple(map(int, input().split()))
perfgroups = n % m
impfgroups = m - perfgroups
szimpfgroups = n // m
szperfgroups = ceil(n / m)
kmin = perfgroups * comb(szperfgroups, 2) + impfgroups * comb(szimpfgroups, 2)
kmax = int(comb(n - m + 1, 2))
print(kmin, kmax)


import math

def nC2(n):
	return n * (n - 1) // 2

def main():
	(n, m) = map(int, input().split(' '))
	x = n // m
	y = n % m
	minimumPossibleNumPairs = (m - y) * nC2(x) + y * nC2(x + 1)
	maximumPossibleNumPairs = nC2(n - m + 1)
	print(minimumPossibleNumPairs, maximumPossibleNumPairs)
main()


(n, m) = list(map(int, input().split()))
t = n - (m - 1)
max = t * (t - 1) // 2
min = 0
t = n // m
pendding = n % m
t1 = (int(t) + 1) * (int(t) + 1 - 1) // 2 * pendding
t2 = t * (t - 1) // 2 * (m - pendding)
min = t1 + t2
print(min, max)


(n, m) = map(int, input().split())
f = lambda n: n * (n - 1) // 2
kmax = f(n - m + 1)
a = (n + m - 1) // m
kmin = (a * m - n) * f(a - 1) + (m * (1 - a) + n) * f(a)
print(kmin, kmax)


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
(n, m) = INL()
x = m * (n // m * (n // m - 1)) // 2 + n % m * (n // m)
y = (n - m) * (n - m + 1) // 2
OPL([x, y])


import math
(n, m) = map(int, input().split(' '))
nk = n // m
print(m * (nk * (nk - 1) // 2) + n % m * nk, (n - m + 1) * (n - m) // 2)


def count(c):
	return c * (c - 1) // 2
[n, m] = list(map(int, input().split(' ')))
maxm = count(n - m + 1)
minm = n % m * count(n // m + 1) + (m - n % m) * count(n // m)
print(minm, maxm)


(a, b) = map(int, input().rstrip().split())
c = a // b
print(c * (c - 1) // 2 * b + a % b * c, (a - b + 1) * (a - b) // 2)


import math

def nC2(n):
	if n <= 0:
		return 0
	if n % 2 == 0:
		ans = int(n / 2)
		ans *= n - 1
	else:
		ans = int((n - 1) / 2)
		ans *= n
	return ans

def main():
	(n, m) = map(int, input().split())
	k = int(math.floor(n / m))
	kmin = n % m * nC2(k + 1)
	kmin += (m - n % m) * nC2(k)
	kmax = nC2(n + 1 - m)
	print(kmin, kmax)
main()


import decimal

def fac(n):
	a = 1
	for i in range(1, n + 1):
		a = a * i
	return a

def c(n, m):
	a = 1
	for i in range(n, n - m, -1):
		a = decimal.Decimal(a) * decimal.Decimal(i)
	return decimal.Decimal(a / decimal.Decimal(fac(m)))
(n, m) = map(int, input().split())
if n == m:
	print(0, 0)
elif m == 1:
	print(c(n, 2), c(n, 2))
else:
	kmax = c(n - m + 1, 2)
	kmin = n % m * c(n // m + 1, 2) + (m - n % m) * c(n // m, 2)
	print(kmin, kmax)


def npairs(n):
	return n * (n - 1) // 2

def main():
	(n, m) = map(int, input().split())
	(div, mod) = divmod(n, m)
	res_min = mod * npairs(div + 1) + (m - mod) * npairs(div)
	res_max = npairs(n - m + 1)
	print(res_min, res_max)
main()


(n, k) = [int(x) for x in input().split()]
da = (n - (k - 1)) * (n - (k - 1) - 1) // 2
if n % k == 0:
	meizu = n // k
	xiao = meizu * (meizu - 1) // 2 * k
else:
	junxiao = n // k
	q = n % k
	qzu = q * (junxiao + 1) * junxiao // 2
	haiyou = (k - q) * (junxiao - 1) * junxiao // 2
	xiao = qzu + haiyou
print(xiao, da)


import math

def f(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
kmin = n % m * f(math.ceil(n / m)) + (m - n % m) * f(n // m)
kmax = f(n - m + 1)
print(kmin, kmax)


(n, m) = map(int, input().strip().split())
x = n // m
m_in = (m - n % m) * (x * (x - 1) // 2) + n % m * ((x + 1) * x // 2)
print(m_in, end=' ')
x = n - m + 1
m_ax = x * (x - 1) // 2
print(m_ax)


(n, m) = map(int, input().split())
p = n // m
q = n % m
print(q * p * (p + 1) // 2 + (m - q) * p * (p - 1) // 2, end=' ')
print((n - m) * (n - m + 1) // 2)


(num_de_participantes, num_de_times) = map(int, input().split())
part_por_time = num_de_participantes // num_de_times - 1
aux1 = part_por_time * (part_por_time + 1) // 2
aux2 = (part_por_time + 2) * (part_por_time + 1) // 2
resto_part_por_time = num_de_participantes % num_de_times
times_menos_resto = num_de_times - resto_part_por_time
part_menos_times = num_de_participantes - num_de_times
num_min_de_pares = aux1 * times_menos_resto + aux2 * resto_part_por_time
num_max_de_pares = (part_menos_times + 1) * part_menos_times // 2
print(num_min_de_pares, num_max_de_pares)


a = [int(x) for x in input().split()]
small_team = a[0] // a[1]
big_team = small_team + 1
times_big = a[0] % a[1]
times_small = a[1] - times_big
mini = times_small * (small_team * (small_team - 1) // 2) + times_big * (big_team * (big_team - 1) // 2)
maxi = (a[0] - a[1]) * (a[0] - a[1] + 1) // 2
print(mini, maxi)


(n, m) = map(int, input().split())
max_a = (n - m + 1) * (n - m) // 2
a = n // m
min_a = m * a * (a - 1) // 2 + a * (n % m)
print(min_a, max_a)


(n, m) = input().split()
m = int(m)
n = int(n)
if n % m == 0:
	k = n // m
	a = m * (k * (k - 1)) // 2
else:
	k = n // m
	r = n % m
	a1 = (m - 1) * (k * (k - 1)) // 2 + (k + r) * (k + r - 1) // 2
	a2 = r * (k * (k + 1)) // 2 + (m - r) * (k * (k - 1)) // 2
	a = min(a1, a2)
b = (n - m + 1) * (n - m) // 2
print(a, b)


import math
(n, m) = map(int, input().split())
c_max = n - m + 1
c_min = math.floor(n / m)

def s(i):
	return i * (i - 1) // 2
k_max = s(c_max)
if n % m:
	d = n // m
	o = n - m * d
	k_min = s(d) * (m - o) + s(d + 1) * o
else:
	k_min = s(c_min) * m
print(k_min, k_max)


(n, m) = map(int, input().split())
tmp = n // m
s = tmp + 1
kol_s = n % m
kol_tmp = m - kol_s
imin = tmp * (tmp - 1) // 2 * kol_tmp + s * (s - 1) // 2 * kol_s
imax = (n - m + 1) * (n - m) // 2
print(imin, imax)


def Combi(n):
	return n * (n - 1) // 2
NM = input().split()
n = int(NM[0])
m = int(NM[1])
if m == 1:
	print(str(Combi(n)) + ' ' + str(Combi(n)))
else:
	if n % m == 0:
		minK = m * Combi(n // m)
	else:
		minK = n % m * Combi(n // m + 1) + (m - n % m) * Combi(n // m)
	maxK = Combi(n - m + 1)
	print(str(minK) + ' ' + str(maxK))


(n, m) = map(int, input().split())
yo = n - m + 1
max1 = yo * (yo - 1) // 2
k = n // m
hi = n % m
min1 = 0
x = n - k * m
a = m - x
b = m - a
min1 = 0
res1 = k * (k - 1) // 2 * a
res2 = k * (k + 1) // 2 * b
min1 = min1 + res1 + res2
print(min1, max1)


from decimal import *
getcontext().prec = 28
(n, m) = list(map(int, input().split(' ')))
a = 0

def count_friends(num):
	return int(Decimal(num - 1) / Decimal(2) * Decimal(num))
maxFriends = count_friends(n - (m - 1))
minFriends = 0
if n % m == 0:
	min = int(n / m)
	minFriends += count_friends(min) * m
else:
	roundNum = int(n / m)
	ostatok = n % m
	minFriends += count_friends(roundNum) * (m - ostatok)
	minFriends += count_friends(roundNum + 1) * ostatok
print(str(minFriends) + ' ' + str(maxFriends))


import sys
import math
from collections import Counter
from collections import OrderedDict
from collections import defaultdict
from functools import reduce
sys.setrecursionlimit(10 ** 6)

def inputt():
	return sys.stdin.readline().strip()

def printt(n):
	sys.stdout.write(str(n) + '\n')

def listt():
	return [int(i) for i in inputt().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b // gcd(a, b)

def factors(n):
	step = 2 if n % 2 else 1
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(math.sqrt(n)) + 1, step) if n % i == 0)))

def comb(n, k):
	factn = math.factorial(n)
	factk = math.factorial(k)
	fact = math.factorial(n - k)
	ans = factn // (factk * fact)
	return ans

def is_prime(n):
	if n <= 1:
		return False
	if n == 2:
		return True
	if n > 2 and n % 2 == 0:
		return False
	max_div = math.floor(math.sqrt(n))
	for i in range(3, 1 + max_div, 2):
		if n % i == 0:
			return False
	return True

def maxpower(n, x):
	B_max = int(math.log(n, x)) + 1
	return B_max
t = 1
for _ in range(t):
	(n, m) = map(int, inputt().split())
	z = n // m
	mi = n // m
	if n % m != 0:
		mi += 1
	ma = n - m + 1
	if n % m == 0:
		count = m
	else:
		count = max(1, n % m)
	fokat = (m - count) * (z * (z - 1) // 2)
	print(count * mi * (mi - 1) // 2 + fokat, ma * (ma - 1) // 2)


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
(n, m) = map(int, input().split())
mini = 0
maxi = (n - m + 1) * (n - m) // 2
first = n // m
val = 0
act = 0
if first > 1:
	val = first * (first - 1) // 2
	rem = n % m
	mult = m - rem
	act = (first + 1) * first // 2
	print(val * mult + act * rem, maxi)
else:
	print(n - m, maxi)


(n, m) = tuple(map(int, input().split()))
print(' '.join(map(str, reversed([(n - (m - 1)) * (n - m) // 2, n // m * (m - n % m) * (n // m - 1) // 2 + (n // m + 1) * (n % m) * (n // m) // 2]))))


(n, m) = map(int, input().split())
kmin = 0
kmax = 0
kmin = n - m + 1
kmax = n // m
d = n % m
t = m - d
max = t * (kmax * (kmax - 1)) // 2
max += d * (kmax * (kmax + 1)) // 2
min = kmin * (kmin - 1) // 2
print(max, min)


(aa, b) = map(int, input().split())
m = aa // b
n = b - aa % b
print((m - 1) * n * m // 2 + (b - n) * (m + 1) * m // 2, (aa - b + 1) * (aa - b) // 2)


(n, m) = map(int, input().split())
maxi = (n - (m - 1)) * (n - (m - 1) - 1) // 2
tmp = n // m
if n % m == 0:
	mini = tmp * (tmp - 1) // 2 * m
else:
	r = n % m
	mini = r * ((tmp + 1) * tmp // 2) + (m - r) * (tmp * (tmp - 1)) // 2
print(mini, maxi)


(n, m) = map(int, input().split())
kmin = n // m
kmax = n - m
pairMin = m * kmin * (kmin - 1) // 2 + kmin * (n % m)
pairMax = (kmax + 1) * kmax // 2
print(pairMin, pairMax)


(p, g) = map(int, input().split())
print(p % g * ((p // g + 1) * (p // g)) // 2 + (g - p % g) * (p // g * (p // g - 1)) // 2, end=' ')
print((p - g + 1) * (p - g) // 2)


def find_pairs(x):
	return x * (x - 1) // 2
(n, m) = map(int, input().split())
share = n // m
rem = n % m
left = share + 1
kmin = find_pairs(share) * (m - rem) + find_pairs(left) * rem
kmax = find_pairs(n - m + 1)
print(kmin, kmax)


from math import ceil
(n, m) = map(int, input().split())
l = n - (m - 1)
k = l * (l - 1) // 2
h = n // m
p = n % m * ((h + 1) * h // 2)
p += (m - n % m) * (h * (h - 1) // 2)
print(p, k)


def ii():
	return int(input())

def ss():
	return [x for x in input()]

def si():
	return [int(x) for x in input().split()]

def mi():
	return map(int, input().split())

def f(x):
	return x * (x - 1) // 2
(a, b) = mi()
mn = f((a - 1) // b + 1) * (a % b) + f(a // b) * (b - a % b)
mx = f(a - b + 1)
print(mn, mx)


(x, y) = list(map(int, input().split()))
mink = x // y
extra = x % y
small = extra * ((mink + 1) * mink // 2) + (y - extra) * (mink * (mink - 1) // 2)
large = (x - y + 1) * (x - y) // 2
print(small, large)


import math
(n, m) = map(int, input().split())
l = math.ceil(n / m)
k = m * l - n
a = k * (l - 1) * (l - 1) + (m - k) * l * l
print(int((a - n) / 2), (n - m + 1) * (n - m) // 2)


(n, m) = map(int, input().split())
perteam = n // m
maxi = n - (m - 1)
print(int(perteam * (perteam - 1) * (m - n % m) / 2 + (perteam + 1) * perteam * (n % m) / 2), int(maxi * (maxi - 1) // 2))


import math
(n, m) = map(int, input().split())
t = n - m + 1
c = t * (t - 1) // 2
lc = n % m
clf1 = 0
clf2 = 0
nc = n // m
if m > 1:
	if lc > 0:
		clf1 = lc * ((nc + 1) * nc // 2)
if nc > 1:
	clf2 = (m - lc) * (nc * (nc - 1) // 2)
print(clf1 + clf2, end=' ')
print(c)


(a, b) = map(int, input().split())
r = a % b
c = a // b
d = a - b
print((b - r) * c * (c - 1) // 2 + r * (c + 1) * c // 2, d * (d + 1) // 2)


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
(a, b) = get_int()
(m, M) = (0, 0)
M = (a - (b - 1)) * (a - (b - 1) - 1) // 2
m = (b - a % b) * (a // b * (a // b - 1)) // 2 + a % b * ((a // b + 1) * (a // b)) // 2
print(m, M)


import math

def pares(n):
	return n * (n - 1) // 2

def max_pares(n, m):
	return pares(n - (m - 1))

def min_pares(n, m):
	quociente = n // m
	resto = n % m
	pares1 = pares(quociente)
	pares2 = pares(quociente + 1)
	return resto * pares2 + (m - resto) * pares1
n_m = input().split()
n = int(n_m[0])
m = int(n_m[1])
print(min_pares(n, m), max_pares(n, m))


(n, m) = map(int, input().split())
Nk = n // m
num1 = n % m
minA = Nk * (Nk - 1) / 2 * (m - num1) + (Nk + 1) * Nk / 2 * num1
Nk = n - m + 1
maxA = Nk * (Nk - 1) // 2
print('%d %d' % (minA, maxA))


(n, m) = map(int, input().split())
if m == 1:
	ans = n * (n - 1) // 2
	print(ans, ans)
elif n == m:
	print(0, 0)
else:
	s = n - m
	kmax = (s + 1) * s // 2
	f = n // m
	r = n % m
	total = 0
	total += f * (f - 1) // 2
	total *= m - r
	t2 = (f + 1) * f // 2
	t2 *= r
	total += t2
	print(total, kmax)


import sys
f = sys.stdin
(n, m) = map(int, f.readline().strip().split())
k_max = (n - (m - 1)) * (n - (m - 1) - 1) // 2
n1 = n // m
n2 = n1 + 1
m2 = n % m
m1 = m - m2
k_min = m1 * n1 * (n1 - 1) // 2 + m2 * n2 * (n2 - 1) // 2
print(str(k_min) + ' ' + str(k_max))


(n, m) = map(int, input().split())
(mi, mx) = (0, 0)
base = n // m
extra = n - base * m
exn = base + 1
mi = extra * (exn * (exn - 1) // 2) + (m - extra) * (base * (base - 1) // 2)
mxn = n - m + 1
mx = mxn * (mxn - 1) // 2
print(mi, mx)


def choose(n, r):
	r = max(r, n - r)
	if n == 1:
		return 0
	out = 1
	for i in range(r + 1, n + 1):
		out *= i
	for i in range(1, n - r + 1):
		out = out // i
	return out
l = input().split()
n = int(l[0])
m = int(l[1])
d = n // m
o = n % m
p = m - o
print(o * choose(d + 1, 2) + p * choose(d, 2), choose(n - m + 1, 2))


import sys
import math

def main():
	(n, m) = map(int, input().split())
	t1 = n - m + 1
	kmax = t1 * (t1 - 1) // 2
	t2 = n // m
	kmin = t2 * (t2 - 1) // 2 * m + n % m * t2
	print(kmin, kmax)
main()


(n, m) = map(int, input().split())
x = n - m + 1
r = n % m
a = (m - r) * (n // m * (n // m - 1)) // 2 + r * ((n // m + 1) * (n // m)) // 2
print(a, x * (x - 1) // 2)


(n, m) = input().split()
n = int(n)
m = int(m)
count = n - m
for_maxi = count + 1
maxi = for_maxi * (for_maxi - 1) // 2
equal = count // m
rem = count % m
mini = 0
one = 2 + equal
two = equal + 1
mini += one * (one - 1) // 2 * rem + two * (two - 1) // 2 * (m - rem)
print(mini, maxi)


(n, m) = map(int, input().strip().split(' '))
dv = n // m
md = n % m
k_min = dv * (dv + 1) // 2 * md + dv * (dv - 1) // 2 * (m - md)
k_max = (n - m + 1) * (n - m) // 2
print(k_min, k_max)


(n, m) = (int(x) for x in input().split())
max_ans = (n - m + 1) * (n - m) // 2
min_ans = m * (n // m) * (n // m - 1) // 2 + n % m * (n // m)
print(min_ans, max_ans)


import math
(ppl, teams) = [int(i) for i in input().split()]

def cnt(z):
	return int(z * (z - 1) // 2)
if teams == 1:
	print(cnt(ppl), cnt(ppl))
else:
	equal = math.floor(ppl / teams)
	large_teams = ppl % teams
	mn = cnt(equal + 1) * large_teams + cnt(equal) * (teams - large_teams)
	print(mn, cnt(ppl - teams + 1))


(n, m) = map(int, input().split())
st = n // m
re = n % m
minim = (m - re) * (st * (st - 1) // 2) + re * ((st + 1) * st // 2)
maxim = (n - m + 1) * (n - m) // 2
print(minim, maxim)


(n, m) = map(int, input().split())
if n % m == 0:
	mn = m * (n // m) * (n // m - 1) // 2
	mx = (n - m + 1) * (n - m) // 2
else:
	mx = (n - m + 1) * (n - m) // 2
	mn = n % m * (n // m + 1) * (n // m) // 2 + (m - n % m) * (n // m) * (n // m - 1) // 2
print(mn, mx)


(n, m) = map(int, input().split())
x = n - m + 1
a1 = x * (x - 1) // 2
z = n // m
x = n % m
a2 = x * (z + 1) * z // 2 + (m - x) * (z * (z - 1) // 2)
print(a2, a1)


import math
num = list(map(int, input().split()))
(m, n) = (num[0], num[1])
k_max = (m - n + 1) * (m - n) // 2
num = math.floor(m / n)
rem = m % n
k_min = num * (num - 1) // 2 * (n - rem) + (num + 1) * num // 2 * rem
print(k_min, k_max)


def ap(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
kmax = ap(n - m + 1)
if m == 1:
	kmin = kmax
else:
	kmin = ap(n // m + 1) * (n % m) + ap(n // m) * (m - n % m)
print(kmin, kmax)


(n, m) = map(int, input().split())
q = n - m + 1
w = n // m
print(w * (w - 1) // 2 * (m - n % m) + w * (w + 1) // 2 * (n % m), q * (q - 1) // 2)


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def main():
	(n, m) = map(int, input().split())
	mx = n - m + 1
	mx *= mx - 1
	mx //= 2
	dt = n // m
	rs = n % m
	mn = dt * (dt - 1) // 2 * (m - rs)
	dt += 1
	mn += dt * (dt - 1) // 2 * rs
	print(mn, mx)
main()


(n, m) = map(int, input().split())

def suma(x):
	return int(x * (x - 1)) / 2

def main():
	print(int((m - int(n % m)) * suma(int(n / m)) + int(n % m) * suma(int(n / m) + 1)), end=' ')
	print((n - m + 1) * (n - m) // 2)
main()


def main():
	(n, m) = map(int, input().split())
	r = n % m
	i = n // m
	kmax = (n - m + 1) * (n - m) // 2
	kmin = (m - r) * (i * (i - 1)) // 2 + r * ((i + 1) * i) // 2
	print(kmin, kmax)
main()


import math
(n, m) = map(int, input().split())
x = math.ceil(n / m)
y = math.floor(n / m)
z = n % m
min = z * (x * (x - 1) / 2)
min = min + (m - z) * (y * (y - 1) / 2) if y >= 2 else min
max = (n - m + 1) * (n - m) // 2
print(int(min), int(max))


import math
(n, m) = map(int, input().split())
t = n // m
last = n - t * (m - 1)
g1 = m
g2 = 0
if abs(last - t) > 0:
	g2 = abs(last - t)
	g1 = m - g2
	last = t + 1
tmin = g1 * (t * (t - 1)) // 2 + g2 * (last * (last - 1)) // 2
t = n - m + 1
tmax = t * (t - 1) // 2
print(tmin, tmax)


(n, m) = map(int, input().split())
kmax = (n - m) * (n - m + 1) // 2
each = n // m
adds = n % m
print(adds * (each * (each + 1)) // 2 + (m - adds) * (each * (each - 1)) // 2, kmax)


import math

def s(x):
	return x * (x + 1) // 2
(p, e) = [int(x) for x in input().split()]
tmp = p - e
mx = s(tmp)
persEq = int(p / e)
res = p % e
mn = res * s(persEq) + (e - res) * s(persEq - 1)
print(str(mn) + ' ' + str(mx))


(n, k) = input().split()
(n, k) = (int(n), int(k))
temp = int(n / k)
if n % k == 0:
	mini = 0
	mini = temp * temp - temp >> 1
	mini *= k
	maxi = 0
	kola = n - (k - 1)
	kola = kola * kola - kola
	maxi = kola >> 1
	print(str(int(mini)) + ' ' + str(int(maxi)))
else:
	temp1 = temp + 1
	p = k * temp + k - n
	mini = 0
	mini = (temp * temp - temp >> 1) * p + (temp1 * temp1 - temp1 >> 1) * (k - p)
	maxi = 0
	kola = n - (k - 1)
	maxi = kola * kola - kola >> 1
	print(str(int(mini)) + ' ' + str(int(maxi)))


import math
(n, m) = map(int, input().split())

def C(a):
	if a == 1:
		return 0
	else:
		return a * (a - 1) // 2
(i, j) = divmod(n, m)
print(C(i) * (m - j) + C(i + 1) * j, end=' ')
print(C(n - m + 1))


(n, m) = map(int, input().split())
kmax = 0
kmin = 0
kmax = (n - m + 1) * (n - m) // 2
k = n // m
k1 = n - m * k
kmin = k1 * (k + 1) * k // 2 + (m - k1) * k * (k - 1) // 2
print(kmin, kmax)


def main():
	(n, m) = map(int, input().split())
	rem = n % m
	q = n // m
	min_friend = 0
	if q - 2 >= 0:
		min_friend += (m - rem) * (q * (q - 1) // 2)
	if q - 1 >= 0 and rem > 0:
		min_friend += rem * ((q + 1) * q) // 2
	max_friend = 0
	if m != n:
		max_friend = (n - m + 1) * (n - m) // 2
	print(min_friend, max_friend)
main()


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 100000007
(n, m) = vary(2)
tt = n // m
print(tt * m * (tt - 1) // 2 + tt * (n % m), (n - m + 1) * (n - m) // 2)


import math

def nCm(n, m):
	if n < m:
		return 0
	return n * (n - 1) // 2

def solve():
	(n, m) = [int(x) for x in input().split()]
	M = n - (m - 1)
	M = nCm(M, 2)
	s = nCm(math.ceil(n / m), 2) * (n % m) + nCm(n // m, 2) * (m - n % m)
	print(s, M, sep=' ')
solve()


(n, m) = list(map(int, input().split()))
c = n - (m - 1)
maxx = c * (c - 1) // 2
d = n // m
e = d + 1
(c1, c2) = (n % m, m - n % m)
k = c1 * (e * (e - 1) // 2)
q = c2 * (d * (d - 1) // 2)
print(k + q, maxx)


(n, m) = map(int, input().split())
av = n // m
mi = av * (av - 1) // 2
mi *= m
mi += av * (n % m)
ma = (n - m) * (n - m + 1) // 2
print(mi, ma)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
(n, m) = rinput()
max = n - m + 1
max_team = max * (max - 1) // 2
k = n // m
min_team = m * k * (k - 1) // 2 + k * (n % m)
print(min_team, max_team)


(n, m) = map(int, input().split())
(val1, val2) = divmod(n, m)
resultado1 = val2 * (val1 * (val1 + 1) // 2)
resultado2 = (n - (m - 1) - 1) * (n - (m - 1)) // 2
if val1 >= 2:
	resultado1 += (m - val2) * ((val1 - 1) * val1 // 2)
print(resultado1, resultado2)


(n, m) = map(int, input().split())
kmax = (n - m + 1) * (n - m) // 2
x = n // m
f = x * (x - 1) // 2
kmin = 0
if n % m == 0:
	kmin = m * f
else:
	kmin = (n - x * m) * ((x + 1) * x) // 2 + (m - n + x * m) * f
print(kmin, kmax)


(n, m) = map(int, input().split())
(x, y) = divmod(n, m)
mini = n * (n - 1) // 2 if m == 1 else x * (x - 1) * m // 2 + x * y
maxi = (n - m + 1) * (n - m) // 2
print(mini, maxi)


line = input()
line = line.split()
n = int(line[0])
m = int(line[1])
pof = 0
xfri = n - m
maxi = (xfri + 1) * xfri // 2
maxi = int(maxi)
layers = xfri // m
xfri = xfri % m
rem = m - xfri
mini = rem * (layers + 1) * layers
mini = mini + xfri * (layers + 2) * (layers + 1)
mini = mini // 2
mini = int(mini)
mini = str(mini)
maxi = str(maxi)
print(mini + ' ' + maxi)


(n, m) = list(map(int, input().strip().split(' ')))

def countFrend(r):
	r = int(r)
	return int((r ** 2 - r) // 2)
d = n - m
iMax = countFrend(d + 1)
iMin = iMax
if m > 1:
	k = n % m
	j = n // m
	iMin = int(countFrend(j + 1) * k + countFrend(j) * (m - k))
print(str(iMin) + ' ' + str(iMax))


def c(a):
	return a * (a - 1) // 2

def main():
	(n, m) = map(int, input().split(' '))
	if m == 1:
		mi = c(n)
		ma = c(n)
	else:
		mi = (m - n % m) * c(n // m)
		mi += n % m * c(n // m + 1)
		ma = c(n - m + 1)
	print('{} {}'.format(mi, ma))
main()


(n, m) = map(int, input().split())
c = n // m
print(m * c * (c - 1) // 2 + c * (n % m), end=' ')
print((n + 1 - m) * (n - m) // 2)


(n, m) = map(int, input().split())
r = n % m
q = n // m
a = r * (q + 1) * q // 2
a += (m - r) * q * (q - 1) // 2
print(int(a))
N = n - m + 1
a = N * (N - 1) // 2
print(int(a))


import sys, threading, os.path
import string
import collections, heapq, math, bisect
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)

def main():
	if os.path.exists('in.rtf'):
		input = open('in.rtf', 'r')
	else:
		input = sys.stdin
	(n, m) = list(map(int, input.readline().split()))
	(mina, maxim) = (0, 0)
	reminder = n % m
	(k, l) = (int(n / m), int(n / m) + 1)
	mina = int(l * (l - 1) / 2) * reminder
	mina += int(k * (k - 1) / 2) * (m - reminder)
	r = int(n - m + 1)
	maxim = int(int(r * int(r - 1)) // 2)
	output = ' '.join(map(str, [mina, maxim]))
	if os.path.exists('out.rtf'):
		open('out.rtf', 'w').writelines(str(output))
	else:
		sys.stdout.write(str(output))
main()


(n, m) = map(int, input().split())

def P(x):
	return x * (x - 1) // 2
print(P(n // m) * (m - n % m) + P(n // m + 1) * (n % m), end=' ')
print(P(n - m + 1))


(n, m) = map(int, input().split())
z = n // m - 1
t = n % m
k = z + 1
s = k * (k + 1) // 2 * t
s1 = z * (z + 1) // 2 * (m - t)
k2 = n - m
s2 = k2 * (k2 + 1) // 2
print(s + s1, s2)


(n, m) = map(int, input().split())
r = n // m
mi = m * (r * (r - 1)) // 2 + r * (n % m)
mx = (n - m) * (n - m + 1) // 2
print(mi, mx)


def kmin(n, m):
	ppg = n // m
	rem = n % m
	if ppg % 2 == 0:
		x = ppg * (ppg // 2 - 1) + ppg // 2
	else:
		x = ppg * (ppg // 2)
	ppgp1 = ppg + 1
	if ppgp1 % 2 == 0:
		y = ppgp1 * (ppgp1 // 2 - 1) + ppgp1 // 2
	else:
		y = ppgp1 * (ppgp1 // 2)
	return rem * y + (m - rem) * x

def kmax(n, m):
	ppg = n - m + 1
	if ppg % 2 == 0:
		x = ppg * (ppg // 2 - 1) + ppg // 2
	else:
		x = ppg * (ppg // 2)
	return x

def answer(n, m):
	print(kmin(n, m), kmax(n, m))
	return

def main():
	(n, m) = [int(i) for i in input().split()]
	answer(n, m)
main()


(a, b) = map(int, input().split())
mi = 0
ma = 0
if b == 1:
	ma = (a - 1) * a // 2
	mi = ma
	print(mi, ma)
else:
	ma = a - 1 * (b - 1)
	ma = ma * (ma - 1) // 2
	if a % b == 0:
		mi = a // b * (a // b - 1) // 2 * b
	else:
		mi = (a // b + 1) * (a // b) // 2 * (a % b) + a // b * (a // b - 1) // 2 * (b - a % b)
	print(mi, ma)


(n, m) = (int(_) for _ in input().split(' '))
kmax = (n - m + 1) * (n - m) // 2
num = n // m
rem = n % m
kmin = rem * (num + 1) * num // 2 + (m - rem) * num * (num - 1) // 2
print(kmin, kmax)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2
from math import *
for _ in range(1):
	(n, m) = map(int, input().split())
	kmax = nc2(n - m + 1)
	kmin = n % m * nc2(ceil(n / m)) + (m - n % m) * nc2(floor(n / m))
	print(kmin, kmax)


(n, m) = map(int, input().split(' '))
c = n - m
kmax = c * (c + 1) // 2
c = n // m
d1 = n % m
d2 = m - d1
kmin = d1 * (c * (c + 1)) // 2 + d2 * (c * (c - 1)) // 2
print(kmin, kmax)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
(a, b) = (0, 0)
if n % m == 0:
	p = n // m
	a = m * (p * (p - 1) // 2)
else:
	q = n % m
	p = n // m
	a = q * (p * (p + 1) // 2) + (m - q) * (p * (p - 1) // 2)
n = n - (m - 1)
b += n * (n - 1) // 2
stdout.write(str(a) + ' ' + str(b))


import operator as op
from functools import reduce
from operator import mul
from fractions import Fraction

def ncr(n, k):
	return int(reduce(mul, (Fraction(n - i, i + 1) for i in range(k)), 1))
arr2 = str(input())
arr = arr2.split()
n = int(arr[0])
m = int(arr[1])
if m == 1:
	ans = int(ncr(n, 2))
	print(str(ans) + ' ' + str(ans))
else:
	avg = n // m
	more1 = n % m
	most = avg + 1
	mostgroup = ncr(most, 2) * more1
	rest = ncr(avg, 2) * (m - more1)
	low = int(mostgroup + rest)
	mostppl = n - (m - 1)
	comb_mostppl = int(ncr(mostppl, 2))
	print(str(low) + ' ' + str(comb_mostppl))


(n, m) = map(int, input().split())
a = [0, 0]
if m == 1:
	k = n * (n - 1) // 2
	a[0] = k
	a[1] = k
else:
	k = n - m
	a[1] = (k + 1) * k // 2
	vari = n % m
	each = n // m
	a[0] = vari * (each + 1) * each // 2 + (m - vari) * each * (each - 1) // 2
print(str(a[0]) + ' ' + str(a[1]))


(n, m) = map(int, input().split())
a = n // m
min_ = m * a * (a - 1) // 2 + a * (n % m)
t = n - m + 1
max_ = t * (t - 1) // 2
print(min_, max_)


[n, m] = list(map(int, input().split()))

def nC2(num):
	return num * (num - 1) // 2
max_ppl = n - m + 1
kmax = nC2(max_ppl)
min_ppl = n // m
min_pplr = n % m
kmin = min_pplr * nC2(min_ppl + 1) + (m - min_pplr) * nC2(min_ppl)
s = str(kmin) + ' ' + str(kmax)
print(s)


def num(n):
	c = n * (n - 1) // 2
	return c
(n, m) = map(int, input().split())
min = num(n // m + 1) * (n % m) + (m - n % m) * num(n // m)
max = num(n - m + 1)
print(min, max)
n = 5000000
m = 12
min = num(n // m + 1) * (n % m) + (m - n % m) * num(n // m)
min


(n, t) = list(map(int, input().split()))
max = 0
min = 0
r = n % t
if r == 0:
	part_for_min = n / t
	part_for_max = n - (t - 1)
	max = part_for_max * (part_for_max - 1) // 2
	min = part_for_min * (part_for_min - 1) // 2 * t
	print(int(min), int(max))
else:
	part_for_max = n - (t - 1)
	max = part_for_max * (part_for_max - 1) // 2
	parti_per_team = n // t
	first_vag = t - r
	second_vag = r
	first_vag_sum = parti_per_team * (parti_per_team - 1) // 2 * first_vag
	second_vag_sum = parti_per_team * (parti_per_team + 1) // 2 * second_vag
	min = first_vag_sum + second_vag_sum
	print(int(min), int(max))


(n, m) = input().split()
(n, m) = [int(n), int(m)]
a = n // m
b = a + 1
min = n % m * (b * (b - 1) // 2) + (m - n % m) * (a * (a - 1) // 2)
max = (n - m + 1) * (n - m) // 2
print(min, max)


(n, m) = map(int, input().split())

def cn2(x):
	return x * (x - 1) // 2
maxx = cn2(n - m + 1)
a = n % m
b = n // m
minn = a * cn2(b + 1) + (m - a) * cn2(b)
print(minn, maxx)


def pair(a):
	return a * (a - 1) // 2
(n, m) = [int(i) for i in input().split()]
nmat = n - (m - 1)
nmat = pair(nmat)
if n % m != 0:
	k = n // m
	nmit = pair(k + 1) * (n % m)
	nmit += pair(k) * (m - n % m)
else:
	nmit = pair(n // m) * (n // (n // m))
print(nmit, nmat)


(n, m) = map(int, input().split())
a = n // m
k = n - m + 1
print(m * a * (a - 1) // 2 + a * (n % m), (k - 1) * k // 2)


def nf(n):
	if n < 2:
		return 0
	else:
		return n * (n - 1) // 2

def main():
	(n, m) = map(int, input().split())
	minPairs = (m - n % m) * nf(n // m) + n % m * nf(n // m + 1)
	maxPairs = nf(n - m + 1)
	print(minPairs, maxPairs)
main()


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
(n, m) = mi()
a = math.ceil(n / m)
b = n % m
d = m - b
c = (n - b * a) // d
y = n - m + 1
y = y * (y - 1)
y //= 2
x = b * (a * (a - 1) // 2) + d * (c * (c - 1) // 2)
print(x, y)


(n, m) = map(int, input().split())
print((m * (n // m) ** 2 - m * (n // m)) // 2 if n % m == 0 else (2 * (n % m) * (n // m) + m * (n // m) ** 2 - m * (n // m)) // 2, (m ** 2 + n + n ** 2 - 2 * m * n - m) // 2)


(n, m) = list(map(int, input().split()))
(k1, k2) = (0, 0)
t = n // m
(a, b) = (0, 0)
k = n % m
h = m - n % m
a = t * (t + 1) // 2
a = a * k
b = t * (t - 1) // 2
b = b * h
k1 = a + b
t = n - m + 1
k2 = t * (t - 1) // 2
print(k1, k2)


(n, m) = map(int, input().split())
N = n - (m - 1)
if N % 2 != 0:
	maxi = N * ((N - 1) // 2)
if N % 2 == 0:
	maxi = N * ((N - 2) // 2) + N // 2
if n % m == 0:
	N = n / m
	mini = m * (N - 1) * N / 2
else:
	N = (n - n % m) // m
	if N % 2 != 0:
		mini = N * ((N - 1) // 2) * m
	if N % 2 == 0:
		mini = (N * ((N - 2) // 2) + N // 2) * m
	mini = mini + N * (n % m)
print(int(mini), int(maxi))


def sol(n, m):
	(u, v) = (n // m, n % m)
	f = lambda x: x * (x - 1) // 2
	kmin = f(u) * (m - v) + f(u + 1) * v
	kmax = f(n - m + 1)
	return (kmin, kmax)
(n, m) = map(int, input().split())
print(*sol(n, m))


s = input()
s = [int(x) for x in s.split()]
(n, m) = (s[0], s[1])
(smin, smax) = (0, 0)
x = n - m
smax = (x + 1) * x // 2
x = n // m
smin = (x + 1) * x // 2 * (n % m) + x * (x - 1) // 2 * (m - n % m)
s = str(smin) + ' ' + str(smax)
print(s)


(n, m) = map(int, input().split())
maxi = (n - m + 1) * (n - m) // 2
k = n // m
mini = k * (k - 1) // 2
mini *= m
mini += k * (n % m)
print(mini, maxi)


(n, m) = map(int, input().split())
k_max = (n - m + 1) * (n - m) // 2
c = n // m
mod = n % m
if mod == 0:
	k_min = n // m * (n // m - 1) // 2 * m
else:
	k_min = c * (c - 1) // 2 * m + mod * c
print(k_min, k_max)


def main():
	(n, m) = list(map(int, input().split()))
	formin = n // m
	if n % m != 0:
		formin += 1
		modulo = n % m
		formin = modulo * (formin * (formin - 1) // 2) + (m - modulo) * ((formin - 1) * (formin - 2) // 2)
	else:
		formin = m * int(formin * (formin - 1) / 2)
	formax = n - m + 1
	formax = formax * (formax - 1) // 2
	print(formin, formax)
t = 1
while t != 0:
	main()
	t -= 1


def c2(a):
	return a * (a - 1) // 2
a = list(map(int, input().split()))
if a[0] == a[1]:
	print('0 0')
else:
	max = c2(a[0] + 1 - a[1])
	b = a[0] // a[1]
	c = a[0] % a[1]
	min = c2(b + 1) * c + c2(b) * (a[1] - c)
	print(min, end=' ')
	print(max)


(n, m) = map(int, input().split())
init_size = n // m
rest = n % m
min_pairs = rest * ((init_size + 1) * init_size // 2) + (m - rest) * (init_size * (init_size - 1) // 2)
print(min_pairs, (n - m + 1) * (n - m) // 2)


def choose2(a):
	if a >= 2:
		return a * (a - 1) // 2
	return 0
(n, m) = [int(x) for x in input().split()]
maxima = choose2(n - m + 1)
each = n // m
left = n % m
minima = left * choose2(each + 1) + (m - left) * choose2(each)
print(minima, maxima)


inputs = input().split()
players = int(inputs[0])
teams = int(inputs[1])
players_per_team = players // teams
teams_with_extras = players % teams
max_players_on_team = players - (teams - 1)
min_friends = teams_with_extras * ((players_per_team + 1) * players_per_team) / 2 + (teams - teams_with_extras) * (players_per_team * (players_per_team - 1)) / 2
max_friends = max_players_on_team * (max_players_on_team - 1) // 2
print(str(int(min_friends)) + ' ' + str(int(max_friends)))


(n, m) = map(int, input().split())
(l, h) = (n // m, n - m + 1)
print((m - n % m) * (l * (l - 1) >> 1) + n % m * (l * (l + 1) >> 1), h * (h - 1) >> 1)


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()

def solve(n):
	return n * (n - 1) // 2
(n, m) = get_ints()
maxi = solve(n - m + 1)
mini = n % m * solve(n // m + 1) + (m - n % m) * solve(n // m)
print(mini, maxi)


(n, m) = map(int, input().split())
x = n - m + 1
ans1 = x * (x - 1) // 2
z = n // m
x = n % m
ans2 = x * (z + 1) * z // 2 + (m - x) * (z * (z - 1) // 2)
print(ans2, ans1)


(n, m) = map(int, input().split())

def pairs(x):
	return x * (x - 1) // 2
max_v = pairs(n - m + 1)
min_v = n % m * pairs(n // m + 1)
min_v += (m - n % m) * pairs(n // m)
print('%s %s' % (min_v, max_v))


(n, m) = map(int, input().split())
k = n - m + 1
mx = k * (k - 1) // 2
v = n // m
v2 = v * (v - 1) // 2 * m
v2 += n % m * v
mn = v2
print(mn, mx)


(n, m) = map(int, input().split())
temp = n - m + 1
kmax = (temp - 1) * temp - temp * (temp - 1) // 2
a = n // m
kmin = m * a * (a - 1) // 2 + a * (n % m)
if m == 1:
	print(kmax, kmax)
else:
	print(kmin, kmax)


3
(n, m) = list(map(int, input().split()))
k1 = (n - m + 1) * (n - m) // 2
div = n // m
mod = n % m
k2 = (m - mod) * div * (div - 1) // 2 + mod * (div + 1) * div // 2
print(min(k1, k2), max(k1, k2))


(n, m) = map(int, input().split())
if m == 1:
	x = n * (n - 1) // 2
	print(x, x)
else:
	z = n - m + 1
	y = n // m
	if n % m == 0:
		x = y * (y - 1) // 2
		x *= m
		print(x, z * (z - 1) // 2)
	else:
		x = y * (y - 1) // 2 * (m - n % m) + y * (y + 1) // 2 * (n % m)
		print(x, z * (z - 1) // 2)


def comb(p):
	return int(int(p / 2) * int(p - 1)) if p % 2 == 0 else int(int((p - 1) / 2) * p)

def max_pair(n, m):
	print(int(comb(n - m + 1)), end='')

def min_pair(n, m):
	(val, mod, sm) = (n // m, n % m, 0)
	if mod:
		sm = int(comb(val + 1)) * mod + int(comb(val)) * (m - mod)
	else:
		sm = comb(val) * m
	print(int(sm), end=' ')
(n, m) = input().split(' ')
(n, m) = (int(n), int(m))
if n == m:
	print('0 0')
else:
	min_pair(n, m)
	max_pair(n, m)


import itertools as ittls
from collections import Counter
import re
import math

def sqr(x):
	return x * x

def inputarray(func=int):
	return map(func, input().split())
(n, m) = inputarray()
(x, y) = divmod(n, m)
minv = m * x * (x - 1) // 2 + y * x
maxv = (n - m + 1) * (n - m) // 2
print(minv, maxv)


def cal(m):
	return m * (m - 1) // 2
(n, k) = map(int, input().split())
ans_max = cal(n - k + 1)
nMin = n // k
surlus = n % k
ans_min = cal(nMin) * (k - surlus) + cal(nMin + 1) * surlus
print(ans_min, ans_max)


(n, m) = map(int, input().split())

def team(n):
	return n * (n - 1) // 2
minn = n % m * team(n // m + 1) + (m - n % m) * team(n // m)
maxx = team(n - m + 1)
print(minn, maxx)


(n, m) = map(int, input().split())
ppl = n
ppl -= m
ppl += 1
MAX = ppl * (ppl - 1) // 2
MIN = 0
ppl = n // m
nk = n % m
one_more = nk
one_less = m - nk
MIN = ppl * (ppl + 1) // 2
MIN *= one_more
kt = ppl * (ppl - 1) // 2
kt *= one_less
MIN += kt
print(MIN, MAX)


(n, m) = map(int, input().split())
a = n // m
b = n // m + 1
s = (a * (a - 1) * (m - n % m) + b * (b - 1) * (n % m)) // 2
c = n - m + 1
t = c * (c - 1) // 2
print(s, t)


def solve(A):
	count = A * (A + 1) // 2
	return count
(n, m) = [int(x) for x in input().split(' ')]
k_max = solve(n - m)
if m == 1:
	print(k_max, k_max, sep=' ')
elif n % m == 0:
	k_min = solve(n // m - 1)
	print(m * k_min, k_max, sep=' ')
else:
	x = solve(n // m - 1)
	y = solve(n // m)
	a = n - n // m * m
	print(a * y + (m - a) * x, k_max, sep=' ')


(n, m) = list(map(int, input().split()))
mini = int((m - n % m) * (n // m * (n // m - 1)) // 2 + n % m * ((n // m + 1) * (n // m) // 2))
maxi = int((n - m + 1) * (n - m) // 2)
print(mini)
print(maxi)


(n, m) = [int(p) for p in input().split()]
(low, high) = (0, 0)
if n < m:
	print(low, high)
	exit()
curr = n
perGrp = curr // m
remain = curr % m
low = remain * (perGrp + 1) * perGrp // 2 + (m - remain) * perGrp * (perGrp - 1) // 2
curr = n
curr -= m
if curr > 0:
	high = (curr + 1) * curr // 2
print(low, high)


(x, y) = map(int, input().split())
a = x % y
l = x // y + 1
lol = l * (l - 1) // 2 * a
l -= 1
lol += l * (l - 1) // 2 * (y - a)
k = x - y + 1
print(lol, k * (k - 1) // 2)


import operator as op
from functools import reduce
import math

def ncr(n, r):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
if n == m:
	print(0, 0)
elif n % m == 0:
	x = n // m
	mi = ncr(x, 2) * m
	y = n - (m - 1)
	mx = ncr(y, 2)
	print(mi, mx)
else:
	besi = n // m + 1
	mi = ncr(besi, 2) * (n % m)
	left = n // m
	if left > 1:
		mi += ncr(left, 2) * (m - n % m)
	y = n - (m - 1)
	mx = ncr(y, 2)
	print(mi, mx)


from math import *
(n, m) = map(int, input().split())
if m == 1:
	print(n * (n - 1) // 2, n * (n - 1) // 2)
else:
	(sum1, sum2) = (0, 0)
	sum1 = (n // m + 1) * (n // m) // 2 * (n % m)
	sum1 += n // m * (n // m - 1) // 2 * (m - n % m)
	sum2 = (n - m + 1) * (n - m) // 2
	print(sum1, sum2)


def pairs(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
ma = pairs(n - m + 1)
rem = n % m
mi = rem * pairs(n // m + 1) + (m - rem) * pairs(n // m)
print(mi, ma)


def f(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
d = n % m
kmin = f(n // m) * (m - d) + f(n // m + 1) * d
kmax = f(n - m + 1)
print(kmin, kmax)


(n, m) = [int(i) for i in input().split()]
max = (n - m + 1) * (n - m) // 2
k = n // m
c = n % m
min = k * (k - 1) // 2 * (m - c) + c * (k * (k + 1) // 2)
print(min, max)


(n, m) = list((int(a) for a in input().split()))
fd = n // m
mn = fd * (fd - 1) // 2 * m + n % m * fd
print(mn, (n - m + 1) * (n - m) // 2)


(n, m) = input().split()
(n, m) = (int(n), int(m))
q = n - m + 1
p = n - m
h = q * p
Max = h >> 1
a = int(n / m)
sum1 = a * (a - 1) / 2 * (m - n % m)
sum2 = (a + 1) * a / 2 * (n % m)
Min = int(sum1 + sum2)
print(Min, Max)


(n, m) = [int(x) for x in input().strip().split()]
dv = n // m
md = n % m
mn = md * (dv * (dv + 1) // 2) + (m - md) * ((dv - 1) * dv // 2)
k = n - m + 1
mx = k * (k - 1) // 2
print('{0} {1}'.format(mn, mx))


(n, m) = str(input()).split()
n = int(n)
m = int(m)
k_max = (n - m) * (n - m + 1) // 2
k_min = m * (n // m * (n // m - 1) // 2) + n % m * (n // m)
print(str(k_min) + ' ' + str(k_max))


a = [int(x) for x in input().split()]
n = a[0]
m = a[1]
sum = 0
ma = n % m * (int(n / m) + 1) * int(n / m) / 2 + (m - n % m) * int(n / m) * (int(n / m) - 1) / 2
ans = (n - m + 1) * (n - m) // 2
print(int(ma), ans)


(n, m) = [int(x) for x in input().split()]
f = lambda x: x * (x - 1) // 2
size = n // m
r = n % m
ans1 = f(n // m) * (m - r) + f(n // m + 1) * r
ans2 = f(n - m + 1)
print(ans1, ans2)


(n, m) = [int(i) for i in input().strip().split()]
maxAns = (n - (m - 1)) * (n - (m - 1) - 1) // 2
rest = n % m
players = n // m
minAns = rest * ((players + 1) * players // 2) + (m - rest) * (players * (players - 1) // 2)
print(minAns, maxAns)


(n, m) = map(int, input().split())
ans = 0
x = int(n // m)
ans += x * (x - 1) // 2 * m
ans += n // m * (n % m)
res = (n - m + 1) * (n - m) // 2
print(ans, res)


(n, m) = map(int, input().split())
if m == 1:
	a = n * (n - 1) // 2
	print(a, a)
else:
	maxs = n - m + 1
	maxs = maxs * (maxs - 1) // 2
	a = (n + m - 1) // m
	if a * m == n:
		a = m * a * (a - 1) // 2
	else:
		k = a * m - n
		al = (m - k) * a * (a - 1) // 2
		a = a - 1
		a = al + k * a * (a - 1) // 2
	print(a, maxs)


def form_it(x):
	return x * (x - 1) >> 1
(N, M) = [int(x) for x in input().strip().split(' ')]
Sol1 = form_it(N - M + 1)
k = N % M
K2 = M - k
Sol2 = k * form_it(N // M + 1) + K2 * form_it(N // M)
if Sol1 > Sol2:
	(Sol1, Sol2) = (Sol2, Sol1)
print(Sol1, Sol2)


(n, m) = map(int, input().split())
grupo = n - (m - 1)
max = grupo * (grupo - 1) // 2
min = 0
sala = n // m
resto = n - m * sala
min += (sala + 1) * sala // 2 * resto
min += sala * (sala - 1) // 2 * (m - resto)
print(min, max)


(n, m) = map(int, input().split())
x = n // m
k = m - n % m
print(k * x * (x - 1) // 2 + (m - k) * (x + 1) * x // 2, (n - m + 1) * (n - m) // 2)


from math import factorial
import re
n = list(map(int, input().split()))
(n, m) = (n[0], n[1])
maximum = (n - m + 1) * (n - m) // 2
teams = n // m
if teams >= 2:
	minimum = (m - n % m) * teams * (teams - 1) // 2
else:
	minimum = 0
minimum += n % m * (teams + 1) * teams // 2
print(f'{minimum} {maximum}')


(a, b) = list(map(int, input().split()))
y = a // b
u = b * y
t = a - u
g = b - t
total = g * (y * (y - 1)) // 2
y += 1
total += t * (y * (y - 1)) // 2
total1 = a - (b - 1)
mota = total1 * (total1 - 1) // 2
print(total, mota)


(m, n) = map(int, input().split())
b = m + 1 - n
c = m % n
f = m // n
g = f + 1
print(g * (g - 1) // 2 * c + f * (f - 1) // 2 * (n - c), b * (b - 1) // 2)


(n, m) = map(int, input().split(' '))
kmax = 0
kmin = 0
kmax = (n - m + 1) * (n - m) // 2
if n % m == 0:
	n = n // m
	kmin = m * (n * (n - 1) // 2)
else:
	r = n % m
	n1 = n // m
	kmin = r * (n1 * (n1 + 1) // 2) + (m - r) * n1 * (n1 - 1) // 2
print(kmin, kmax)


import math
(n, m) = map(int, input().strip().split(' '))
f = lambda x: (x - 1) * x >> 1
amax = f(n - m + 1)
amin = f(math.ceil(n / m)) * (n % m) + f(math.trunc(n / m)) * (m - n % m)
print(amin, amax)


(n, m) = map(int, input().split())
a1 = n % m * ((n // m + 1) * (n // m) // 2) + (m - n % m) * ((n // m - 1) * (n // m)) // 2
a2 = (n - m + 1) * (n - m) // 2
print(a1, a2)


(n, m) = (int(s) for s in input().split(' '))
res2 = (n - m + 1) * (n - m) // 2
res1 = (n // m - 1) * (n // m) * (m - n % m) // 2 + n // m * (n // m + 1) * (n % m) // 2
print(res1, res2)


(n, m) = map(int, input().split())
maximum = n - (m - 1)
maximum = maximum * (maximum - 1) // 2
t = n // m
a = n % m
if a == 0:
	minimum = m * (t * (t - 1) // 2)
else:
	minimum = (m - a) * (t * (t - 1) // 2)
	t = t + 1
	minimum += a * (t * (t - 1)) // 2
print(minimum, maximum)


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def array():
	return [int(i) for i in input().split()]
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nc2(n):
	if n == 1:
		return 0
	return n * (n - 1) // 2
(n, k) = map(int, input().split())
kmin = 0
kmax = nc2(n - k + 1)
kmin = nc2(n // k) * (k - n % k) + nc2(n // k + 1) * (n % k)
print(kmin, kmax)


(n, m) = map(int, input().split())

def combination(n):
	return int(n * 0.5 * (n - 1))

def minTeam(n, m):
	if n == 0 and m == 0:
		return 0
	if n % m == 0:
		return m * combination(n // m)
	else:
		return (m - n % m) * combination(n // m) + n % m * combination(n // m + 1)
print(minTeam(n, m), (n - m + 1) * (n - m) // 2)


(n, m) = map(int, input().split())
(minn, maxn) = (n // m, n - m + 1)
print(m * minn * (minn - 1) // 2 + n % m * (n // m), maxn * (maxn - 1) // 2)


(n, m) = [int(x) for x in input().split()]
each = n // m
r = n % m
Min = (each - 1) * each // 2 * (m - r) + (each + 1) * each // 2 * r
n = n - m + 1
Max = (n - 1) * n // 2
print(Min, Max)


def comb(n, r):
	num = 1
	denom = 1
	for i in range(1, r + 1):
		denom *= i
		num *= n - i + 1
	return num // denom
(n, m) = map(int, input().split())
max_ans = comb(n - m + 1, 2)
min_ans = (n - n // m * m) * comb(n // m + 1, 2) + (m - n + n // m * m) * comb(n // m, 2)
print(min_ans, max_ans)


(n, m) = input().split()
n = int(n)
m = int(m)
maxv = (n - m + 1) * (n - m) // 2
if n % m == 0:
	x = n // m
	minv = x * (x - 1) // 2 * m
else:
	x = n // m
	minv = x * (x - 1) // 2 * (m - n % m)
	minv += (x + 1) * x // 2 * (n % m)
print(minv, maxv)


from math import ceil

def MinimumMaximumPairs(n, m):
	max_pairs = (n - m + 1) * (n - m) // 2
	min_pairs = m * (((n - m) // m + 1) * ((n - m) // m)) // 2 + ceil((n - m) / m) * ((n - m) % m)
	return [min_pairs, max_pairs]
(a, b) = map(int, input().split())
(c, d) = MinimumMaximumPairs(a, b)
print(c, d)


import math

def foo(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
if m == 1:
	print(foo(n), foo(n))
	exit()
else:
	x = n // m
	r = n % m
	x1 = m * foo(x) + r * x
	x2 = foo(n - m + 1)
	print(min(x1, x2), max(x1, x2))


def fact(x):
	return (x + 1) * x // 2
(n, m) = map(int, input().split())
kmax = fact(n - m)
if m == 1:
	kmin = kmax
elif n % m != 0:
	kmin = (m - n % m) * fact(n // m - 1) + n % m * fact(n // m)
else:
	kmin = m * fact(n // m - 1)
print(kmin, kmax)


import math

def ncr(n):
	if n == 1:
		return 0
	return n * (n - 1) // 2
(n, k) = input().split()
(n, k) = (int(n), int(k))
(ma, mi) = (0, 0)
if k == 1:
	ma = ncr(n)
	mi = ncr(n)
else:
	c = (k - 1) * 1
	ma = ncr(n - c)
	mi = n % k * ncr(n // k + 1) + (k - n % k) * ncr(n // k)
print(mi, ma)


def combinacoes(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - k + i) // i
	return res
(quantidade_de_pessoas, n_times) = map(int, input().split())
time_maior = quantidade_de_pessoas - n_times + 1
maior = combinacoes(time_maior, 2)
times = []
menor = 0
quantidade_base = int(quantidade_de_pessoas / n_times)
if quantidade_de_pessoas % n_times != 0:
	times.append((quantidade_de_pessoas % n_times, quantidade_base + 1))
	times.append((n_times - times[0][0], quantidade_base))
else:
	times.append((n_times, quantidade_base))
t_maiores = combinacoes(times[0][1], 2)
menor += t_maiores * times[0][0]
if len(times) > 1 and times[1][1] > 1:
	t_menores = combinacoes(times[1][1], 2)
	menor += t_menores * times[1][0]
print('%d %d' % (menor, maior))


def CN2(n):
	return n * (n - 1) // 2
(n, m) = map(int, input().split())
print(n % m * CN2(n // m + 1) + (m - n % m) * CN2(n // m), CN2(n - m + 1))


def calculaMax(n, m):
	aux = m - 1
	num = n - aux
	return num * (num - 1) // 2

def calculaMin(n, m):
	if n % m == 0:
		aux = n // m
		return m * (aux * (aux - 1)) // 2
	else:
		resto = n % m
		n -= resto
		aux = n // m
		m1 = m - resto
		ans1 = m1 * (aux * (aux - 1)) // 2
		m2 = m - m1
		aux += 1
		ans2 = m2 * (aux * (aux - 1)) // 2
		return ans1 + ans2
(n, m) = map(int, input().split())
print(calculaMin(n, m), calculaMax(n, m))


(a, b) = map(int, input().split())
count = 0
mt = 0
d = a - b
import math
count = int((a - math.ceil(d / b) * b) * ((math.ceil(d / b) + 1) * math.ceil(d / b)) / 2 + ((math.ceil(d / b) + 1) * b - a) * math.ceil(d / b) * ((math.ceil(d / b) - 1) / 2))
mt = (a + 1 - b) * (a - b) // 2
print(count, mt)


(n, m) = map(int, input().split())

def count(n):
	if n == 2:
		return 1
	else:
		count = 1
		for i in range(n, n - 2, -1):
			count *= i
		return count // 2
kmax = 0
kmin = 0
if m == 1:
	kmax = count(n)
	kmin = kmax
else:
	a = n // m
	b = n % m
	if b == 0:
		kmin = m * count(a)
	else:
		kmin = b * count(a + 1) + (m - b) * count(a)
	m = n - (m - 1)
	kmax = count(m)
print(int(kmin), int(kmax))


def combinacao(e, comb):
	if e == comb:
		return 1
	if e < comb:
		return 0
	x = e - comb
	result = 1
	if x > comb:
		while e > x:
			result = result * e
			e = e - 1
		while comb > 1:
			result = result // comb
			comb = comb - 1
	else:
		while e > comb:
			result = result * e
			e = e - 1
		while x > 1:
			result = result // x
			x = x - 1
	return result

def maxPares(n, m):
	return combinacao(n - m + 1, 2)

def minPares(n, m):
	if n % m == 0:
		return m * combinacao(n // m, 2)
	else:
		voltasCompletas = n // m
		parcela1 = n % m * combinacao(voltasCompletas + 1, 2)
		parcela2 = (m - n % m) * combinacao(voltasCompletas, 2)
		return parcela1 + parcela2
(n, m) = input().split()
n = int(n)
m = int(m)
maxPares = maxPares(n, m)
minPares = minPares(n, m)
print(minPares, maxPares)


(n, m) = map(int, input().split())
o = n - m + 1
MX = (o ** 2 - o) // 2
p = n // m
mand = n - p * m
MN = (p ** 2 - p) // 2 * (m - mand)
p += 1
MN += (p ** 2 - p) // 2 * mand
print(MN, MX)


from sys import stdin

def main():
	(n, m) = [int(x) for x in stdin.readline().strip().split()]
	(omax, omin) = (None, None)
	if m == 1:
		omax = omin = n * (n - 1) >> 1
	else:
		omax = (1 + n - m) * (n - m) >> 1
		fill = n // m
		omin = (n - fill * m) * (fill * (fill + 1) >> 1) + (m - (n - fill * m)) * (fill * (fill - 1) >> 1)
	print(omin, omax)
main()


def get_int():
	from sys import stdin
	return int(stdin.readline().replace('\n', ''))

def get_int_list():
	from sys import stdin
	return [int(x) for x in stdin.readline().replace('\n', '').split(' ')]

def get_str():
	from sys import stdin
	return stdin.readline().replace('\n', '')

def factorial(n):
	return partial_factorial(n, 0)

def partial_factorial(n, m):
	fac = 1
	for i in range(m + 1, n + 1):
		fac *= i
	return fac

def combination(n, m):
	if n < m:
		return 0
	return partial_factorial(n, m) // factorial(n - m) if n - m < m else partial_factorial(n, n - m) // factorial(m)

def min_team(n, m):
	from math import ceil, floor
	team = int(n / m)
	rest = n % m
	return (m - rest) * combination(team, 2) + rest * combination(team + 1, 2)

def max_team(n, m):
	return combination(n - m + 1, 2)

def random_teams(n, m):
	return (int(min_team(n, m)), int(max_team(n, m)))
(n, m) = get_int_list()
rt = random_teams(n, m)
print(rt[0], rt[1])


(n, m) = map(int, input().split(' '))
m1 = 0
m2 = 0
if n % m == 0:
	temp = n / m
	m1 = int(temp * (temp - 1) / 2) * m
else:
	r = n % m
	t = int(n / m)
	t1 = t + 1
	a1 = int(t1 * (t1 - 1) / 2 * r)
	a2 = int(t * (t - 1) / 2) * (m - r)
	m1 = a1 + a2
k1 = n - m
k2 = k1 + 1
if k1 % 2 == 0:
	k1 = int(k1 / 2)
else:
	k2 = int(k2 / 2)
x = k1 * k2
m2 = int(x)
print(m1, m2)