Problem:
 Score : 100 points    Problem Statement  We have N+M balls, each of which has an integer written on it. It is known that:   The numbers written on N of the balls are even.  The numbers written on M of the balls are odd.   Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.      Constraints   0 \leq N,M \leq 100  2 \leq N+M  All values in input are integers.         Input  Input is given from Standard Input in the following format:  N  M       Output  Print the answer.        Sample Input 1 2 1      Sample Output 1 1  For example, let us assume that the numbers written on the three balls are 1,2,4 .   If we choose the two balls with 1 and 2 , the sum is odd;  If we choose the two balls with 1 and 4 , the sum is odd;  If we choose the two balls with 2 and 4 , the sum is even.   Thus, the answer is 1 .       Sample Input 2 4 3      Sample Output 2 9       Sample Input 3 1 1      Sample Output 3 0       Sample Input 4 13 3      Sample Output 4 81       Sample Input 5 0 3      Sample Output 5 3

Solution (Python):
def main(n,m):
    eveeve = (n*(n-1))/2 if n>=2 else 0
    oddodd = (m*(m-1))/2 if m>=2 else 0
    return int(eveeve+oddodd)

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

Solution (Python):
n, m = map(int, input().split())
ans = n*(n-1)//2 + m*(m-1)//2
print(ans)

Solution (Python):
import math

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

n,m = map(int, input().split())
balls = 2
ans = combinations_count(n,balls) + combinations_count(m,balls)
print(ans)

Solution (Python):
from itertools import combinations
n, m = map(int, input().split())
even = len(list(combinations(range(n), 2)))
odd = len(list(combinations(range(m), 2)))
print(even+odd)

Solution (Python):
n, m = map(int, input().split())
ans = n*(n-1)//2 + m*(m-1)//2
print(ans)

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

Solution (Python):
n,m = [int(i) for i in input().split()]
print(int(n * (n - 1) / 2 + m * (m - 1) / 2))

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

Solution (Python):
import sys
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

N, M = MI()
ans = 0
if N >= 2:
    ans += N*(N-1) / 2
if M >= 2:
    ans += M*(M-1) / 2
print(int(ans))

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

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

Solution (Python):
import math
def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,m=map(int,input().split())
if n>=2 and m>=2:

    ans=c(n,2)+c(m,2)
elif n<=1 and m>=2:
    ans=c(m,2)
elif m<=1 and n>=2:
    ans=c(n,2)
elif n<=1 and m<=1:
    ans=0
print(ans)

Solution (Python):

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

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

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, combinations
import sys
import math
import bisect


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


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, m = LI()

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

    def C(n, r):
        return P(n, r)//math.factorial(r)
    if n > 2 and m > 2:
        print(C(n, 2) + C(m, 2))
    elif n < 2 and m < 2:
        print(0)
    elif n < 2:
        print(C(m, 2))
    elif m < 2:
        print(C(n, 2))
    return



if __name__ == "__main__":
    solve()

Solution (Python):
import math
def combinations_count(n,r):
    if n<r:
        return 0
    
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
N,M=list(map(int,input().split()))
print(combinations_count(N,2)+combinations_count(M,2))

Solution (Python):
import math
def combinations_count(n,r):
    if n<r:
        return 0
    
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
N,M=list(map(int,input().split()))
print(combinations_count(N,2)+combinations_count(M,2))

Solution (Python):

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


import math
def combinations_count(n,k):
    if k==0 or k==n:
        return 1
    elif n<k or k<0:
        return 0
    else:
        return math.factorial(n)//(math.factorial(n-k)*math.factorial(k))
print(combinations_count(n,2)+combinations_count(m,2))

Solution (Python):
n, m = map(int, input().split())

def down_stream_summer(number):
    initial_adder=number-1
    summer=0
    while initial_adder>0:
        summer+=initial_adder
        initial_adder-=1
    return summer

end=down_stream_summer(n)+down_stream_summer(m)
print(end)

Solution (Python):
n, m = map(int, input().split())
ans = 0
ans += n*(n-1)//2
ans += m*(m-1)//2
print(ans)

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

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

Solution (Python):
import sys
input = sys.stdin.readline().rstrip()
input = map(int, input.split(' '))
m, n = tuple(input)

print(sum(i for i in range(m)) + sum(i for i in range(n)))

Solution (Python):
n,m=map(int,input().split())
count=n*(n-1)//2
countt=m*(m-1)//2
print(count+countt)

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

Solution (Python):
def diff_sum(n:int):
    if n>0 :
        return n + diff_sum(n-1)
    else:
        return 0
import math
n,m = list(map(int, input().split()))
print(diff_sum(n-1)+diff_sum(m-1))

Solution (Python):
import math 

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

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

print(nCr(N,2) + nCr(M,2))

Solution (Python):
m,n = map(int,input().split(" "))
res = m * (m-1)//2 + n * (n-1)//2
print(res)

Solution (Python):
n, m = map(int, input().split())
ans = int(n * (n-1)/2 + m*(m-1)/2)
print(ans)

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


s= n*(n-1)//2
t= m* (m-1)//2

print(s+t)

Solution (Python):
import math
n, m = map(int, input().split(' '))


from_n = math.factorial(n)/math.factorial(2)/math.factorial(n - 2) if n >= 2 else 0
from_m = math.factorial(m)/math.factorial(2)/math.factorial(m - 2) if m >= 2 else 0
print(int(from_n + from_m))

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

Solution (Python):
from itertools import combinations
N,M=map(int,input().split())
even=0
odd=0

if N>1:
  even=len(list(combinations(range(N), 2)))
if M>1:
  odd=len(list(combinations(range(M), 2)))
print(even+odd)

Solution (Python):
n,m=map(int,input().split())

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

print(int(a+b))

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

Solution (Python):
n,m = map(int,input().split())
print((n*~-n+m*~-m)>>1)

Solution (Python):
import math
n,m=map(int,input().split())
print( math.factorial(n+m) // (math.factorial(n+m-2) * math.factorial(2))-n*m)

Solution (Python):
n,m =map(int,input().split())

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

print(int(ans))

Solution (Python):
from sys import stdin


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    print(N * (N - 1) // 2 + M * (M - 1) // 2)


if __name__ == "__main__":
    main()

Solution (Python):
import itertools

a,b = [int(i) for i in input().split()]

even = len(list(itertools.combinations(range(a),2)))
odd = len(list(itertools.combinations(range(b),2)))

print(even + odd)

Solution (Python):

def cc(i):
    return i * (i-1) // 2

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

s = cc(n) + cc(m)
print(s)

Solution (Python):
n, m = map(int, input().split())
s = (n*(n - 1)) // 2
t = (m*(m - 1)) // 2
print(s + t)

Solution (Python):
import itertools

a,b = [int(i) for i in input().split()]

even = len(list(itertools.combinations(range(a),2)))
odd = len(list(itertools.combinations(range(b),2)))

print(even + odd)

Solution (Python):

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

Solution (Python):
n,m = map(int,input().split())

ans = 0

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

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


print(int(ans))

Solution (Python):
N,M = map(int,input().split())
sum1 = 1
if N > 1:
    for i in range(2):
        sum1 = sum1 * N
        N -= 1
    sum1 /= 2
else:
    sum1=0
sum2 = 1
if M > 1:
    for i in range(2):
        sum2 *= M
        M -= 1
    sum2 /= 2
else:
    sum2 = 0
print(int(sum1+sum2))

Solution (Python):
from operator import mul
from functools import reduce


def cmb(_n, _r):
    _r = min(_n - _r, _r)
    if _r == 0:
        return 1
    return reduce(mul, range(_n, _n - _r, -1)) // reduce(mul, range(1, _r + 1))


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

count = 0
if n >= 2:
    count += cmb(n, 2)
if m > 2:
    count += cmb(m, 2)
print(count)

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):
N,M = map(int,input().split())

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

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

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

Solution (Python):
n,m = map(int,input().split())
ans = n*(n-1)/2 + m*(m-1)/2
print(int(ans))

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):

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

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

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

print(int(ans))

Solution (Python):
import math

def main():
    N, M = (int(x) for x in input().split())
    a = math.factorial(N+M) // (math.factorial(N+M - 2) * math.factorial(2))
    print(a - (N*M))
if __name__ == '__main__':
    main()

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

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

Solution (Python):
a,b=map(int, input().split(' '))
 
ans = 0
if a>=2:
    ans += a*(a-1)//2
if b>=2:
    ans += b*(b-1)//2
print(ans)

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

Solution (Python):
n,m = map(int,input().split(" "))
a = 0
a += (n*(n-1))//2;
a += (m*(m-1))//2;
print(a)

Solution (Python):


from sys import stdin, stderr

def Choose2(N):
   return N*(N-1)/2

def main():
   N, M = map(int, stdin.readline().split())
   res = Choose2(N) + Choose2(M)
   print(res)

   return 0

if __name__ == '__main__': main()

Solution (Python):

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


if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
if n < 2:
    an = 0
else:
    an = n * (n-1) // 2
if m < 2:
    am = 0
else:
    am = m * (m-1) // 2
print(an + am)

Solution (Python):
N, M = map(int,input().split())
total = 0
if(N > 1):
    total = total + N*(N-1)/2
if(M > 1):
    total = total + M*(M-1)/2
print(int(total))

Solution (Python):
N,M = (int(i) for i in input().split())

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

print(int(ans))

Solution (Python):
import math

n, m = map(int, input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if n > 1 and m > 1:
  print(combinations_count(n, 2) + combinations_count(m, 2))
elif n > 1:
  print(combinations_count(n, 2))
elif m > 1:
  print(combinations_count(m, 2))
else:
  print(0)

Solution (Python):
import math
n,m = map(int, input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a = 0
b = 0
if n >=2:
    a = combinations_count(n, 2)
if m >= 2:
    b = combinations_count(m, 2)
print(a+b)

Solution (Python):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,m = map(int,input().split())
if n<2 and m<2:
    print(0)
elif n<2:
    print(combinations_count(m,2))
elif m<2:
    print(combinations_count(n,2))
else:
    print(combinations_count(n,2)+combinations_count(m,2))

Solution (Python):
n,m=map(int,input().split());print(n*~-n+m*~-m>>1)

Solution (Python):
n,m=map(int,input().split());print(n*~-n+m*~-m>>1)

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

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

Solution (Python):

import collections


def solve(n, m):
    evens = n*(n-1)//2
    odds = m*(m-1)//2

    return evens + odds


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

Solution (Python):



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


def main():
    ans = 0
    if N >= 2:
        ans += N * (N - 1) // 2
    if M >= 2:
        ans += M * (M - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Solution (Python):
N,M = map(int,input().split())
ans1 = N*(N-1)//2
ans2 = M*(M-1)//2
A = ans1+ans2
print(A)

Solution (Python):
n,m = map(int,input().split())
ans = n*(n-1)//2 + m*(m-1)//2
print(ans)

Solution (Python):
from itertools import combinations

def resolve():
    N, M = map(int, input().split())
    balls = [2]*N + [1]*M
    ans = 0
    for x, y in combinations(balls, 2):
        if (x+y)%2 == 0:
            ans += 1
    return print(ans)

if __name__ == "__main__":
    resolve()

Solution (Python):
N,M = map(int, input().strip().split())

c = 0
if N > 1:
  c += N*(N-1)//2
if M > 1:
  c += M*(M-1)//2

print(c)

Solution (Python):
import math

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


a = input().split(" ")
n = int(a[0])
m = int(a[1])

c = combinations_count(n, 2)
c += combinations_count(m, 2)

print(c)

Solution (Python):

import math

def combination(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) / (math.factorial(r) * math.factorial(n-r))

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

ans = combination(N, 2)
ans += combination(M, 2)

print(int(ans))

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    n = N*(N-1)//2
    m = M * (M - 1) // 2
    return print(n+m)

if __name__ == "__main__":
    resolve()

Solution (Python):
n,m = input().split()
n = int(n)
m = int(m)
k = (n*(n-1) + m*(m-1))//2
print(k)

Solution (Python):

from sys import stdin
from operator import itemgetter



n, m = [int(x) for x in stdin.readline().rstrip().split()]

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

Solution (Python):
N,M=map(int,input().split())
f=lambda x:x*(x-1)//2
print(f(N)+f(M))

Solution (Python):
a,b=map(int,input().split())
print (a*(a-1)//2+b*(b-1)//2)

Solution (Python):
n, m = map(int, input().split())

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

Solution (Python):
M,N=(int(x) for x in input().split())

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

print(ans)

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

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

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):
n,m = map(int,input().split())
from operator import mul
from functools import reduce
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 <= 1 and m <= 1:
  print(0)
elif n <= 1:
  print(cmb(m,2))
elif m<= 2:
  print((cmb(n,2)))
else:
  print(cmb(n,2)+cmb(m,2))

Solution (Python):
from math import factorial

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

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

print(comb(N, 2) + comb(M, 2))

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

Solution (Python):
import math
N, M = map(int, input().split())
print(int((1/2)*(N*(N-1)+M*(M-1))))

Solution (Python):
from itertools import combinations
ne, no = map(int,input().split())
even, odd = [i for i in range(1,2*(ne+1)) if i % 2 == 0], [i for i in range(1,2*no) if i % 2 != 0]
lst = even + odd
c = 0
for i in combinations(lst,2):
    if sum(i) % 2 == 0:
        c += 1
print(c)

Solution (Python):
N, M = list(map(int, input().split()))

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

Solution (Python):
a,b = map(int, input().split())
if a == 0 and b == 0:
    print(0)
elif a == 0:
    print(b*(b-1)//2)
elif b == 0:
    print(a*(a-1)//2)
else:
    print(a*(a-1)//2+b*(b-1)//2)

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,m = nm()
print(n*(n-1)//2 + m*(m-1)//2)

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

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

Solution (Python):
n,m=(int(x) for x in input().split())
sum=int((n*(n-1)/2)+(m*(m-1)/2))
print(sum)

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,m = nm()
print(n*(n-1)//2 + m*(m-1)//2)

Solution (Python):
n,m = map(int, input().split())
ans = n * (n-1)//2 + m * (m-1)//2
print(ans)

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

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

Solution (Python):
import itertools
import math

N,M=map(int,input().split())
ans = 0
even = 0
odd = 0
if N > 1:
    even += math.factorial(N) / (math.factorial(2)*math.factorial(N - 2))
if M > 1:
    odd += math.factorial(M) / (math.factorial(2)*math.factorial(M - 2))
ans=even+odd
print(int(ans))

Solution (Python):
N, M = map(int, input().split())
ans=0
for i in range(1,N):
    ans += i
for j in range(1, M):
    ans += j
print(ans)

Solution (Python):
n,m = map(int,input().split())
ans = n*(n-1)//2 + m*(m-1)//2
print(ans)

Solution (Python):
import math

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

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

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

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

Solution (Python):
N,M = map(int, input().split())

all = (N+M)*(N+M-1)/2
minus = N*M

print(int(all - minus))

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

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

n_comb = (N * (N -1)) / 2
m_comb = (M * (M -1)) / 2

output = int(n_comb) + int(m_comb)

print(output)

Solution (Python):
n,m=map(int,input().split())
ans=n*(n-1)//2+m*(m-1)//2
print(ans)

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    ans = 0

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

    print(ans)


resolve()

Solution (Python):
e,o = map(int,input().split())
print(e*(e-1)//2+o*(o-1)//2)

Solution (Python):


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

Solution (Python):
if __name__ == '__main__':
    n , m = map(int, input().split())
    print( ((n * (n - 1)) // 2 ) + ((m * (m - 1))//2))

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

Solution (Python):
import sys
from io import StringIO
import unittest

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

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 1"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 3"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """13 3"""
        output = """81"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """0 3"""
        output = """3"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

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

Solution (Python):
from sys import stdin,setrecursionlimit
n,m = map(int,stdin.readline().rstrip().split())
print(n*(n-1)//2+m*(m-1)//2)

Solution (Python):
import math


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

count = N * (N - 1) / 2 + M * (M - 1) / 2
print(math.floor(count))

Solution (Python):
a, b = map(int,input().split())
ans = 0
if a >= 2:
    ans += a*(a-1)//2
if b >= 2:
    ans += b*(b-1)//2
print(ans)

Solution (Python):
sel='A'

if sel=='A':
    N,M=map(int,input().split())
    ans=0
    ans+=M*(M-1)//2
    ans+=N*(N-1)//2
    print(ans)


if sel=='B':
    def ispal(s):
        for i in range(len(s)//2+1):
            if s[i]!=s[-(i+1)]:
                return False
        return True

    S=input()
    if ispal(S) and ispal(S[:(N-1)//2]) and ispal(S[(N+3)//2-1:]):
        print('Yes')
    else:
        print('No')


if sel=='C':
    L=int(input())
    print((L**3)/27)


if sel=='D':    
    N=int(input())
    A=[int(i) for i in input().split()]
    kin=list(set(A))
    cnt={}
    for k in kin:
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    SUM=0
    for k in kin:
        SUM+=cnt[k]*(cnt[k]-1)//2
    for a in A:
        if cnt[a]>=2:
            print(SUM-cnt[a]+1)
        else:
            print(SUM)
        

if sel=='E':
    a=0


if sel=='F':
    N,S=map(int,input().split())
    A=[int(i) for i in input().split()]

    for l in range(N):
        for r in range(l,N):
            print(tab[l][r])

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):
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)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    print((n*(n-1)>>1)+(m*(m-1)>>1))
    return


if __name__ == "__main__":
    solve()

Solution (Python):
import itertools
import math

def combinations(N, R):
    return math.factorial(N) // (math.factorial(N- R) * math.factorial(R))

N,M = map(int, input().split())
res= combinations(N+M,2)
print(res - (N*M))

Solution (Python):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
input_line = input().split()

N = int(input_line[0])
M = int(input_line[1])
counter = 0 
if N > 1:
    counter += combinations_count(N,2) 
if M > 1:
    counter += combinations_count(M,2)
        
print(counter)

Solution (Python):
import math
def j(n):
    return 0 if n == 0 or n == 1 else math.factorial(n) // (2*math.factorial(n-2))
n,m = map(int,raw_input().split())
print j(n)+j(m)

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

Solution (Python):
import itertools
import math 
def C(n,r):
    if n-r < 0:
        return 0
    return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

n, m = map(int, input().split())
n = C(n,2)
m = C(m,2)
print(n+m)

Solution (Python):
import sys
input = sys.stdin.readline

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

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

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

Solution (Python):
n,m=[int(i) for i in input().split()]
nC2=[0 for i in range(2*10**5)]
for i in range(2,2*10**5):
    nC2[i]=i*(i-1)//2
print(nC2[n]+nC2[m])

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

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

odd = n * (n-1) // 2
even = m * (m-1) // 2
print( odd + even )

Solution (Python):
import math
def P(n,r):
    return math.factorial(n) // math.factorial(n-r)
def C(n,r):
    return P(n,r) // math.factorial(r)
n,m = map(int,input().split())
if n < 2:
    n_len = 0
else:
    n_len = C(n,2)
if m < 2:
    m_len = 0
else:
    m_len = C(m,2)
ans = n_len + m_len
print(ans)

Solution (Python):
inputText1 = input()
numberTextList = inputText1.split()
gNumber = numberTextList[0]
kNumber = numberTextList[1]
gNumbers = []
for gNum in range(int(gNumber)):
    gNumbers.append(2)

kNumbers = []
for kNum in range(int(kNumber)):
    kNumbers.append(1)


gNumbers.extend(kNumbers)
allNumbers = gNumbers
allNumbersCount = len(allNumbers)
successCount = 0
for num1 in range(len(allNumbers)):
    for num2 in range(len(allNumbers)):
        if num1 + num2 + 1 == allNumbersCount:
                break
        

        if (allNumbers[num1] + allNumbers[num1 + num2 + 1]) % 2 == 0:
            successCount += 1








print(successCount)

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

Solution (Python):
import math
def j(n):
    return math.factorial(n) // (2*math.factorial(n-2))
n,m = map(int,raw_input().split())
if (n == 1 and m == 1)or(n == 0 and m == 0): 
    print 0
elif n == 1 or n == 0:
    print j(m)
elif m == 1 or m == 0:
    print j(n)
else:
    print j(n)+j(m)

Solution (Python):
N,M=map(int,input().split())

s=N*M
m=N+M

d=(m*(m-1))/2

print(int(d-s))

Solution (Python):
def select(a):
    d=1
    if a==1:
        return 0
    for i in range(a,a-2,-1):
        d=i*d
    return d//2
n,m=map(int,input().split())
print((select(n)+select(m)))

Solution (Python):
import math
N, M = map(int, input().split())

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

if N >= 2 and M >= 2:
    ans = combinations_count(N, 2) + combinations_count(M, 2)
elif N >= 2:
    ans = combinations_count(N, 2)
elif M >=2:
    ans = combinations_count(M, 2)
else:
    ans = 0

print(ans)

Solution (Python):
import math


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


numbers = input().split()

evens, odds = int(numbers[0]), int(numbers[1])


combs = 0
for i in [evens, odds]:
    if i >= 2:
        combs += combinations_count(i, 2)
print(combs)

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

Solution (Python):
from scipy.misc import comb
N,M = (int(x) for x in input().split())
a = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(a)

Solution (Python):
import itertools

N, M = map(int, input().split())
balls = [0] * N + [1] * M
answer = sum((x + y) % 2 == 0 for x, y in itertools.combinations(balls, 2))
print(answer)

Solution (Python):
a,b = input().split()
a = int(a)
b = int(b)
ans = a * (a-1) / 2 + b * (b-1) / 2
print(int(ans))

Solution (Python):
from itertools import combinations

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

a = list(combinations(range(N), 2))
b = list(combinations(range(M), 2))
print(len(a)+len(b))

Solution (Python):
from itertools import combinations

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

a = list(combinations(range(N), 2))
b = list(combinations(range(M), 2))
print(len(a)+len(b))

Solution (Python):
N,M=map(int,input().split())
res=(N*(N-1)+M*(M-1))/2
print(int(res))

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

    ans = 0
    for i in range(1, N):
        ans += i

    for i in range(1, M):
        ans += i

    print('{}'.format(ans))

if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())

def cmb(n,r):
    if n < 0 or r < 0 or n < r:
        return 0
    elif n == 0 or r == 0:
        return 1
    return cmb(n-1,r-1)+cmb(n-1,r)

print(cmb(n,2) + cmb(m,2))

Solution (Python):
N, M = map(int, input().split())

if N == 0:
  print(int(M*(M-1)/2))
elif M == 0:
  print(int(N*(N-1)/2))
else:
  print(int(M*(M-1)/2+N*(N-1)/2))

Solution (Python):
import math
def combination(n, r):
    if n <= 0 or n is 1:
        return 0
    return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

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

print(combination(n, 2) + combination(m,2))

Solution (Python):
a = list(map(int,input().split()))

count = 0
for i in range(a[0]):
  count += i
 
for i in range(a[1]):
  count += i
  
print(count)

Solution (Python):
n, m = map(int, input().split())

if n == 0:
    n = 1

if m == 0:
    m = 1

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

print(int(ans))

Solution (Python):
import math

def inputlist(): return [int(i) for i in input().split()]

def kumiawase(num):
    r = 2
    if num != 1 and num != 0:
        return math.factorial(num) // (math.factorial(num - r) * math.factorial(r))
    else:
        return 0

def main():
    N, M = inputlist()
    print(kumiawase(N) + kumiawase(M))

if __name__ == '__main__':
    main()