peterverebics/CodeNet_Python_118 huggingface dataset:
#!/usr/bin/env python3
from math import factorial
def com(n,r):
    if n<r:
        return 0
    return int(factorial(n) // factorial(r) // factorial(n-r))
N, M = map(int, input().split())
print(com(N, 2) + com(M, 2))
import sys

input = sys.stdin.readline


def get_ans(n):
    if n <= 1:
        return 0
    return get_ans(n - 1) + n - 1


def main():
    n, m = map(int, input().split())
    print(get_ans(n) + get_ans(m))


if __name__ == '__main__':
    main()
n,m = map(int,input().split())
print(n*(n-1)//2 + m*(m-1)//2)
from math import factorial
N, M = map(int, input().split())
if N > 1:
  a = factorial(N) / (factorial(2) * factorial(N-2))
else:
  a = 0
if M > 1:
  b = factorial(M) / (factorial(2) * factorial(M-2))
else:
  b = 0
print(int(a+b))
a,b=map(int,input().split())
if a==1 and b==1:
    print(0)
else:
    print(a*(a-1)//2+b*(b-1)//2)
N, M = map(int, input().split())

ans = int(N*(N-1) /2+ M*(M-1)/2)

print(ans)
n, m = map(int, input().split())
print((n*(n-1)+m*(m-1))//2)
import math
def comb(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,M = map(int,input().split())
count = 0
if N <= 1:
    a = 0
else:
    a = comb(N,2)

if M <= 1:
    b = 0
else:
    b = comb(M,2)
print(a+b)
N, M = map(int, input().split())
if N == 1:
    print(int((M*(M-1))/2))
elif M == 1:
    print(int((N*(N-1))/2))
else:
    print(int((N*(N-1))/2)+int((M*(M-1))/2))
from operator import mul
from functools import reduce

N, M = map(int, input().split())

Nans = 0
Mans = 0

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

if N == 0 or N == 1:
    Nans = 0
else:
    Nans = cmb(N, 2)

if M == 0 or M == 1:
    Mans = 0
else:
    Mans = cmb(M, 2)

print(Nans + Mans)
n,m=map(int,input().split())
k=n*(n-1)/2
l=m*(m-1)/2
k=int(k)
l=int(l)
if n>=2 and m>=2:
    print(k+l)
elif n>=2 and m<2:
    print(k)
elif n<2 and m>=2:
    print(l)
else:
    print(0)
n,m= map(int,input().split())
print(int(n*(n-1)/2+m*(m-1)/2))
N,M = map(int,input().split())
if N != 0 and M != 0:
  A = N*(N-1)+M*(M-1)
elif N == 0:
  A = M*(M-1)
elif M == 0:
  A = N*(N-1)
print(int(A/2))
N, M = map(int, input().split())

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

x=a*(a-1)/2
y=b*(b-1)/2

ans=x+y

print(int(ans))
import math

N,M = map(int,input().split())
#Nは偶数
#Mは奇数

#偶数偶数
if N >= 2:
  Nf = math.factorial(N)//(math.factorial(N-2)*2)
else:
  Nf = 0
#奇数奇数
if M >= 2:
  Mf = math.factorial(M)//(math.factorial(M-2)*2)
else:
  Mf = 0
ans = int(Nf + Mf)
print(ans)
n, m = map(int, input().split())

total = ((n + m) * (n + m -1)) / 2
odd = m * n
#print(n, m)
#print(total)
#print(odd)

print(int(total - odd))
N, M = [int(i) for i in input().split(' ')]
print((N * (N - 1) + M * (M - 1)) // 2)
def odd_even():
    N,M = map(int, input().split())
    return N*(N-1)//2 + M*(M-1)//2 

print(odd_even())
N,M=list(map(int, input().split()))
print(N*(N-1)//2+M*(M-1)//2)
n,m = map(int, input().split())
ans = (n*(n-1))//2 + (m*(m-1))//2
print(ans)
n,m = map(int, input().split())

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

print(s)
n,m = map(int,input().split())
a = (n*(n-1))//2
b = (m*(m-1))//2
print(a+b)
n,m=map(int,input().split())
print(int(n*(n-1)/2+m*(m-1)/2))
n, m = map(int, input().split())
ans1 = n * (n - 1) // 2
ans2 = m * (m - 1) // 2
print(ans1 + ans2)
def main():
    n, m = list(map(int, input().split(" ")))
    ans = 0
    ans += n*(n-1)/2
    ans += m*(m-1)/2
    print(int(ans))
    

if __name__ == "__main__":
    main()
line = input().split()
n = int(line[0])
m = int(line[1])

# 偶数と偶数の方法の数
eeCount = n * (n - 1) / 2

# 奇数と奇数の方法の数
ooCount = m * (m - 1) / 2

print(int(eeCount + ooCount))
N, M = [int(i) for i in input().split()]
print(N*(N-1)//2 + M*(M-1)//2)
n,m = map(int,input().split())

from operator import mul
from functools import reduce

def bb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
if m==1 and n==1:
    print(0)
    exit()

if m>1 and n>1:
    print(bb(n,2)+bb(m,2))
elif m>1:
    print(bb(m,2))
else:
    print(bb(n,2))
N,M = map(int,input().split())




print(int(N*(N-1)/2 + M*(M-1)/2))
N,M = map(int,input().split())
# 偶数 = 偶数＋偶数 or 奇数＋奇数
print(N*(N-1)//2 + M*(M-1)//2)
n, m = map(int, input().split())

print(n*(n-1)//2 + m*(m-1)//2)
import math

num_of_even, num_of_odd = map(int, input().split())

def combinations_count(n, r):
    if n < 2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if num_of_even == 1 and num_of_odd == 1:
    print('0')
else:
    print(combinations_count(num_of_odd, 2) + combinations_count(num_of_even, 2))
n, m = map(int, input().split())

ans = (n * (n-1))/2 + (m * (m-1)) / 2
print(int(ans))
n,m=map(int,input().split())
print((n*(n-1))//2 + (m*(m-1))//2)
# must have sum even. This only happens for x,y both even or both odd.
# N even, so N*(N-1)/2 pairs of them (not counting order). Same for M.
N, M = map(int, input().split())
num_N = N*(N-1)//2
num_M = M*(M-1)//2
print(num_N+num_M)
from itertools import *

def main():
    N, M = list(map(int, input().split()))
    print(len(list(combinations(range(N), 2))) + len(list(combinations(range(M), 2))))

if __name__ == '__main__':
    main()
n,m = map(int,input().split())

x = (n*(n-1))/2
y = (m*(m-1))/2

print(int(x+y))
a,b = map(int, input().split())
print(int((a*(a-1))/2  + (b*(b-1))/2))
a = list(map(int,input().split()))
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
x = a[0]
y = a[1]
if(x != 1) and (x != 0):
    c = (combinations_count(x, 2))
else:
    c = 0
if(y != 1) and (y != 0):
    d = (combinations_count(y, 2))
else:
    d = 0
print(c + d)
N,M = map(int,input().split())
print(N*(N-1)//2 + M*(M-1)//2)
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())

    res = N * (N-1) // 2 + M * (M-1) // 2
    print(res)


if __name__ == '__main__':
    main()
n, m = map(int, input().split())
if n*m == 1:
  print(0)
else:
  print(int(n*(n-1)/2+m*(m-1)/2))
n,m = map(int,input().split())
'''
和が偶数:
奇数＋奇数
偶数＋偶数
'''
ans = n*(n-1)//2 + m*(m-1)//2
print(ans)
a,b=map(int,input().split())
c=(a*(a-1)+b*(b-1))//2
print(c)
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

sum = n * (n - 1) // 2
if 1 < m:
    sum += m * (m - 1) // 2
print(sum)
n, m = map(int, input().split())

a = (n * (n - 1)) // 2 + (m * (m - 1)) // 2

print(a)
import itertools
n,m=map(int,input().split())
i = [2]*n
j = [2]*m
p = list(itertools.combinations(i, 2))
q = list(itertools.combinations(j, 2))
print(len(p)+len(q))
n,m=map(int, input().split())
r = 0
if n>=2:
	r += n*(n-1)//2
if m>=2:
	r += m*(m-1)//2
print(r)
import math


N,M = map(int,input().split())

ans_N=0
ans_M=0
if N != 0:
	ans_N=(N*(N-1))//2
if M != 0:
	ans_M=(M*(M-1))//2

print(ans_N+ans_M)
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)
n,m = map(int,input().split())
ans = n*(n-1)//2 + m*(m-1)//2
print(ans)
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(abs(n - r)) * math.factorial(r))

N, M = map(int, input().split())

print(combinations_count(N, 2) + combinations_count(M, 2))
x, y = map(int, input().split())
print(x * (x - 1) //2 + y*(y-1)//2)
a,b = input().split()
a = int(a)
b = int(b)
ans = a * (a-1) / 2 + b * (b-1) / 2
print(int(ans))
N = list(map(int, input().split()))
print(int((N[0] * (N[0] - 1) / 2) + (N[1] * (N[1] - 1) / 2)))
N, M = [int(i) for i in input().split(" ")]
con = 0

for i in range(N):
    con += i

for j in range(M):
    con += j

print(con)
n, m = map(int, input().split(' '))
print((n * (n - 1) + m * (m - 1)) // 2)
nm_list = input().split(" ")

n = int(nm_list[0])
m = int(nm_list[1])

print(int(n*(n-1)/2+m*(m-1)/2))
#-*- coding: utf-8 -*-
n,m = map(int,input().split())
c = 1
d = 1
for i in range(1,n):
    c += i

for i in range(1,m):
    d += i

print("0" if n==1 and m==1 else c+d-2)
N,M=map(int,input().split())
print(int(N*(N-1)/2+M*(M-1)/2))
N,M=map(int, input().split()) 
if M == 1 or M==0:
    answer = N * (N-1)//2
elif N == 1 or N==0:
    answer = M * (M-1)//2    
else:
    answer = (N * (N-1))//2 + (M * (M-1))//2
print(answer)
n, m = map(int, input().split())

#nC2
#mC2

ans = 0
if n >= 2:
    ans += n*(n-1)//2
if m >= 2:
    ans += m*(m-1)//2

print(ans)
N, M = [int(_) for _ in input().split()]

ans = N * (N - 1) // 2
ans += M * (M - 1) // 2
print(ans)
import math

def ncr(n,r):
    if r> n: return 0;
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

def solve(n,m):
    print(ncr(n,2)+ ncr(m,2))

N,M = map(int,input().split())
solve(N,M)
N,M=[int(s) for s in input().split(" ")]
Ans1=M*(M-1)/2
Ans2=N*(N-1)/2
print(int(Ans1+Ans2))
import itertools
r = 2
N, M = map(int, input().split())
Nmath = len(list(itertools.combinations(range(N), r)))
Mmath = len(list(itertools.combinations(range(M), r)))

print(int(Nmath+Mmath))
n, m =map(int, input().split())
s = (n*(n-1)/2 + m*(m-1)/2)
s= int(s)
print(s)
def f(N,M):
    return N*(N-1)//2+M*(M-1)//2
N,M=map(int,input().split())
print(f(N,M))
a,b=map(int,input().split())
n=(a*(a-1))//2
m=(b*(b-1))//2
if b<2 and a<2:
  print(0)
elif b<2:
  print(n)
else:
  print(n+m)
from math import factorial

N,M = map(int, input().split())

if N <= 1:
  a = 0
else:
  a = factorial(N) / 2 / factorial(N - 2)
  
if M <= 1:
  b = 0
else:
  b = factorial(M) / 2 / factorial(M - 2)
  
print(int(a+b))
n,m=map(int,input().split())
ans=0
if n>=2:
    ans+=n*(n-1)//2
if m>=2:
    ans+=m*(m-1)//2
print(ans)
N,M=map(int,input().split())
ans=0
if N>1:
  ans += N*(N-1)//2
else:
  pass
if M>1:
  ans += M*(M-1)//2
else:
  pass
print(ans)
n, m=map(int, input().split())
print(int(n*(n-1)/2 + m*(m-1)/2))
from math import factorial
n, m = map(int, input().split())
c_n = factorial(n) / (factorial(2) * factorial(n - 2)) if n > 1 else 0
c_m = factorial(m) / (factorial(2) * factorial(m - 2)) if m > 1 else 0
ans = int(c_n) + int(c_m)
print(ans)
a,b = map(int,input().split())
ans = int((a*(a-1))/2+(b*(b-1)/2))
print(ans)
N,M=map(int, input().split())


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

print(n * (n-1) // 2 + m * (m-1) // 2)
import math
s = input().split()
n=int(s[0])
k=int(s[1])
result=0
if n>1:
    result+=math.factorial(n)/math.factorial(2)/math.factorial(n-2)
if k>1:
    result+=math.factorial(k)/math.factorial(2)/math.factorial(k-2)
print(int(result))
N,M = map(int,input().split(sep=" "))
print(N*(N-1)//2 + M*(M-1)//2)
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

ret = 0
if N >= 2:
  ret += N * (N-1) // 2
if M >= 2:
  ret += M * (M-1) // 2
print(ret)
#!/usr/bin/env python

def main():
    n, m = map(int, input().split())

    ret = n * (n - 1) // 2
    ret += m * (m - 1) // 2

    print(ret)

if __name__ == '__main__':
    main()
n, m = map(int, input().split())
a = n * (n - 1) // 2
b = m*(m-1)// 2
print(a + b)
N,M = map(int,input().split())

answer1 = N * (N - 1) / 2
answer2 = M * (M - 1) / 2

print(int(answer1 + answer2))
n,m=map(int,input().split())
if n>0 and m>0:print((n*(n-1))//2+(m*(m-1))//2)
else:
    k=max(n,m)
    print((k*(k-1))//2)
def bikkuri(n):
    if n <= 0:
        return 1
    else:
        return n * bikkuri(n - 1)

nm = input().split(" ")
print(bikkuri(int(nm[0])) // (bikkuri(int(nm[0]) - 2) * 2) * (0 if int(nm[0]) < 2 else 1) + bikkuri(int(nm[1])) // (bikkuri(int(nm[1]) - 2) * 2) * (0 if int(nm[1]) < 2 else 1))
a,b = map(int,input().split())
print(a * (a-1) // 2 + b * (b-1) //2)
N,M =map(int,input().split())
print(N*(N-1)//2+M*(M-1)//2)
n, m = map(int,input().split())
if n==0:
  c=m*(m-1)/2
elif m==0:
  c=n*(n-1)/2
else:
  c=n*(n-1)/2+m*(m-1)/2

print(int(c))
N,M=(int(x) for x in input().split())
#N=int(input())
#A=list(map(int, input().split()))

if N>=2:
    a=int(N*(N-1)/2)
else:
    a=0

if M>=2:
    b=int(M*(M-1)/2)
else:
    b=0

print(a+b)
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


M, N = map(int, input().split())
if M <= 1 and N <= 1:
    print(0)
elif M <= 1:
    print(combinations_count(N, 2))
elif N <= 1:
    print(combinations_count(M, 2))
else:
    print(combinations_count(M, 2) + combinations_count(N, 2))
n,m=map(int,input().split())

def fac(n):
  if n == 0:
    return 1
  else:
    return n * fac(n-1)

def binom(n,k):
  if n==0 or n==1:
    return 0
  else:
    return fac(n) // (fac(n-k) * fac(k))

print(binom(n,2) + binom(m,2))
N, M = map(int, input().split())
cnt = 0
if N >= 2:
  cnt += N * (N-1) * 0.5
if M >= 2:
  cnt += M * (M-1) * 0.5
print(int(cnt))
n, m = map(int, input().split())

ans = 0

if (n >= 2):
    ans += (n * (n-1)) // 2

if (m >= 2):
    ans += (m * (m-1)) // 2

print(ans)
def main():
    import sys
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    print(int(n*(n-1)/2 + m*(m-1)/2))


if __name__ == '__main__':
    main()
import math
n,m=map(int,input().split())

count=0
if n>1:
    count+=math.factorial(n)//(math.factorial(n - 2) * math.factorial(2))
if m>1:
    count+=math.factorial(m)//(math.factorial(m - 2) * math.factorial(2))
print(count)
n,m =map(int,input().split())
print(int(n*(n-1)/2+m*(m-1)/2))
g,k=map(int,input().split())
ans=g*(g-1)//2+k*(k-1)//2
print(ans)
N, M = map(int, input().split())

print(M * (M-1) //2+ N * (N-1) // 2)
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
print(n*(n-1)//2+m*(m-1)//2)
N, M = map(int, input().split())
print((N*(N-1)+M*(M-1))//2)
N,M=map(int,input().split())
f=lambda x:x*(x-1)//2
print(f(N)+f(M))
from math import factorial

M, N = map(int, input().split())

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

if M > 1 and N > 1:
    sum_n = combinations_count(M, 2) + combinations_count(N, 2)

elif M > 1:
    sum_n = combinations_count(M, 2)

elif N > 1:
    sum_n = combinations_count(N, 2)

else:
    sum_n = 0

print(sum_n)
N, M = map(int, input().split())

total  = M*(M-1)/2
total += N*(N-1)/2

total = int(total)

print(total)
import itertools

N, M = [int(x) for x in input().split()]

Nlist = [0]*N
Mlist = [0]*M
for n in range(N):
    Nlist[n] = (n+1) * 2

for m in range(M):
    Mlist[m] = (m+m+1) * 1
count = 0
for x in itertools.combinations(Nlist, 2):
    if (x[0] + x[1]) % 2 == 0:
        count = count + 1
for x in itertools.combinations(Mlist, 2):
    if (x[0] + x[1]) % 2 == 0:
        count = count + 1
print(count)
import math
n,m=map(int, input().split())
def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
if n == 1 and m == 1:
    print(0)
elif n < 2 or m < 2:
    if n < 2:
        print(comb(m,2))
    else:
        print(comb(n,2))
else:
    n_comb = comb(n,2)
    m_comb = comb(m,2)
    print(n_comb+m_comb)
n, m = map(int, input().split())



import math
def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(comb(n,2) + comb(m,2))
n,m=input().strip().split(" ")
n,m=[int(n),int(m)]
k=n*(n-1)//2
p=m*(m-1)//2

print(k+p)
line = input().strip().split(" ")
even = int(line[0])
odd = int(line[1])

if even > 1 and odd <= 1:
    result = (even * (even - 1)) / 2
    print(int(result))
elif even <= 1 and odd > 1:
    result = (odd * (odd -1)) / 2
    print(int(result))
elif even >1 and odd > 1:
    result = (even * (even -1)) / 2 + (odd * (odd - 1)) / 2
    print(int(result))
else:
    print(0)
n,m = map(int,input().split())

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

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

ans=n*(n-1)//2+m*(m-1)//2
print(ans)
n,m=map(int,input().split())
# print((n*m)-m)
n=n-1
m=m-1
print((n*(n+1))//2+(m*(m+1))//2)
if __name__ == '__main__':
	N,M = map(int, input().split())
	ans = N * (N-1) / 2 + M * (M-1) / 2

	print(int(ans))
N, M = map(int, input().split())
ans = ((N * (N - 1)) // 2) + ((M * (M - 1)) // 2)
print(ans)
def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs



def main(inputs):
	n,m=getIntList(inputs[0])
	
	ans=n*(n-1)//2+m*(m-1)//2
	print(ans)
	
	

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)
n, m = map(int, input().split())
if n < 2 and m < 2:
  print(0)
else:
  print(n*(n-1)//2 + m*(m-1)//2)
n, m = map(int, input().split(' '))
ans = int(n * (n-1) / 2 + m * (m-1) / 2)
print(ans)
a, b = map(int, input().split())

import itertools
ｃ = len(list(itertools.combinations(range(a), 2)))
d = len(list(itertools.combinations(range(b), 2)))

print(c + d)
def main():
    N, M = tuple([int(_x) for _x in input().split()])
    print(N*(N-1)//2 + M*(M-1)//2)


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

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

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

ans = 0
if (n == 0):
  ans += 0
else:
  ans += n*(n-1)/2

if (m == 0):
  ans += 0
else:
  ans += m*(m-1)/2

print(int(ans))
from scipy.misc import comb
n, m = map(int, input().split())
# nC2+mC2を求めればよい
print(comb(n, 2, exact=True) + comb(m, 2, exact=True))
# coding: utf-8
# Your code here!

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

# print(n)
# print(m)

count = 0
for i in range(n + m):
    for j in range(n + m):
        if i == j:
            continue
        # print("{} {}".format(i, j))
        
        if i < n and j < n:
            count += 1
        if i >= n and j >= n:
            count += 1
        
# print(count)
print(count // 2)
n, m = [int(i) for i in input().split()]

print(int(n*(n-1)/2 + m*(m-1)/2))
import sys

n, m = map(int, sys.stdin.readline().split())
print ((n-1)*n //2+ (m-1)*m//2)
N,M = map(int,input().split())
print(N*(N-1)//2+(M*(M-1))//2)
n,m=map(int,input().split())
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b
print(combination(n+m, 2)-n*m)
n, m = map(int, input().split(' '))


print(int(n*(n-1)/2+ m*(m-1)/2))
import sys
n,m=map(int,sys.stdin.readline().split())
ans=n*(n-1)//2+m*(m-1)//2
print(ans)
import math

N,M = map(int,input().split(' '))
count = 0

if N > 1:
    count += N*(N-1)//2
if M > 1:
    count += M*(M-1)//2
print(int(count))
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def main():
  N, M = map(int, input().split())
  if N == 1 and M == 1:
    print(0)
  elif N == 0 or N == 1:
    print(combinations_count(M, 2))
  elif M == 0 or M == 1:
    print(combinations_count(N, 2))
  else:
    print(combinations_count(N, 2) + combinations_count(M, 2))
if __name__ == '__main__':
  	main()
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
a = N*(N-1)/2
b = M*(M-1)/2
# 出力
print(int(a+b))
import math

def combination_count(n,r):
    return math.factorial(n) // (math.factorial(n-r)*math.factorial(r))

N,M =map(int,input().split())

if N <= 1:
    L = 0
else:
    L = combination_count(N,2)

if M <= 1:
    O = 0
else:
    O = combination_count(M,2) 
    
num = L + O 

print(num)
a,b=map(int,input().split())
print(a*(a-1)//2+b*(b-1)//2)
import math

def check_even_number(N, M):
    if N <= 1:
        combination_N = 0
    else:
        combination_N = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))

    if M <= 1:
        combination_M = 0
    else:
        combination_M = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
        
    return combination_N + combination_M


if __name__ == "__main__":
    N, M = map(int, input().split())
    print(check_even_number(N, M))
from scipy.misc import comb

N, M = [int(i) for i in input().split()]


ans = comb(N,2,exact=True) + comb(M,2,exact=True) #exact=Trueで整数値が返される
print(ans)
N,M = (int(i) for i in input().split())

ans = 0
ans += N * (N-1)/2
ans += M * (M-1)/2

print(int(ans))
N, M = map(int, input().split())
print(N*(N-1)//2+M*(M-1)//2)
# 2020/03/22
# AtCoder Beginner Contest 159 - A

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

# Calc
ans = (n * (n - 1)) // 2 + (m * (m - 1)) // 2

# Output
print(ans)
N, M = map(int, input().split())

ans = N * (N-1) // 2
ans += M * (M-1) // 2

print(ans)
import math

N, M = map(int, input().split(' '))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
cnt = 0

if N > 1:
    cnt += combinations_count(N, 2)
if M > 1:
    cnt += combinations_count(M, 2)

print(cnt)
N, M = map(int, input().split())

def nCr(n, r):
    r = min(r, n-r)
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

if N<=1 and M<=1:
    print(0)
elif N<=1:
    print(nCr(M, 2))
elif M<=1:
    print(nCr(N, 2))
else:
    print(nCr(N, 2) + nCr(M, 2))
#author : dokueki

import sys


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


def main():
    n, m = map(int, sys.stdin.readline().split())
    print(n*(n-1)//2+m*(m-1)//2)


if __name__ == "__main__":
    #IOE()
    main()
N, M = map(int, input().split())
x = N * (N-1) / 2
y = M * (M-1) / 2
z = x + y
z = int(z)
print(z)
n,m=map(int,input().split())
a=n*(n-1)//2
b=m*(m-1)//2
print(a+b)
def solve(string):
    n, m = map(int, string.split())
    return str((n + m) * (n + m - 1) // 2 - n * m)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
n, m = map(int, input().split(' '))

def nCr(n, r):
    if n < r:
        return 0
    ans = 1
    for i in range (r):
        ans *= (n-r+i+1)
        ans = ans // (i+1)

    return ans

print(nCr(n, 2) + nCr(m, 2))
import math
n, m = map(int, input().split())
def comp2(num):
    return math.factorial(num) // (math.factorial(max(num-2, 1)) * 2)
print(comp2(n) + comp2(m))
N,M = map(int, input().split())
print((N*(N-1) + M*(M-1))//2)
n, m = map(int, input().split())
print(n*(n-1)//2 + m*(m-1)//2)
N,M = map(int,input().split())

print(int(N*(N-1)/2+M*(M-1)/2))
n,m=map(int,input().split())
if n>=2:
  ans=n*(n-1)//2
else:
  ans=0
if m>=2:
  ans+=m*(m-1)//2




print(ans)
N, M = map(int, input().split())
print((N * (N - 1) + M * (M - 1)) // 2)
N,M = map(int, input().split())

print(N*(N-1)//2+M*(M-1)//2)
N, M = list(map(int, input().split(' ')))

print(int(N*(N-1)/2 + M*(M-1)/2))
n,w = map(int,input().split())
print(int(n*(n-1)/2) + int(w*(w-1)/2))
n, m = map(int, input().split())
ans = (n*(n-1)/2)+(m*(m-1)/2)
print(int(ans))
n,m=map(int,input().split())

ans=0
ans+=n*(n-1)//2
ans+=m*(m-1)//2
print(ans)
a = input().split()
b = int(a[0])
c = int(a[1])
if b == 1 and c == 1:
    print(0)
elif b>=2 and c>=2:
    d = b-1
    e = c-1
    f = b*d/2
    g = c*e/2
    print(int(f+g))
elif b<=1 and c>=2:
    d = c-1
    f = c*d/2
    print(int(f))
elif b>=2 and c<=1:
    d = b-1
    f = b*d/2
    print(int(f))
N, M = map(int, raw_input().split())
ans = 0

ans = ans + N*(N-1)/2
ans = ans + M*(M-1)/2

print ans
N,M=map(int,input().split())

c = (N+M)*(N+M-1)/2 - N*M

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

def rc2(i):
  if i<2:
    return 0
  return (i*(i-1))//2
print(rc2(n)+rc2(m))
n,m=map(int, input().split())
if n<=1:
    a=0
else:
    a=n*(n-1)//2
if m<=1:
    b=0
else:
    b=m*(m-1)//2

print(a+b)