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):
n,m = [int(i) for i in input().split()]
p = ['P']*n
k = ['I']*m
al = p+k
ans = 0
for i in range(len(al)):
    for j in range(i+1,len(al)):
        if al[i] == 'I' and al[j]=='I':ans+=1
        if al[i] == 'P' and al[j] == 'P': ans+=1
print(ans)

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

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

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

Solution (Python):
a = [int(x) for x in input().split()]
print(a[0]*(a[0] - 1) // 2 + a[1]*(a[1] - 1) // 2)

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

if ((A<=1) and (B<=1)):
    print(0)
    exit()
if (B<=1):
    print(combinations_count(A,2))
    exit()
if (A<=1):
    print(combinations_count(B,2))
    exit()
print(combinations_count(A,2)+combinations_count(B,2))

Solution (Python):

def gcd(x, y):
    k, l = x, y
    if y < 0:
        k, l = -k, -l
    while l:
        k, l = l, k % l
    return k
    
def extgcd(a, b, c):
    if b == 0:
        return c // a, 0
    if b < 0:
        a, b, c = -a, -b, -c
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return c * x, c * y


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


def fracsum(f1, f2, sign = 1):
    fs = [f1[0]*f2[1]+sign*f1[1]*f2[0], f1[1]*f2[1]]
    g = gcd(fs[0], fs[1])
    fs[0] //= g
    fs[1] //= g
    return fs
def fracprod(f1, f2):
    fs = [f1[0]*f2[0], f1[1]*f2[1]]
    g = gcd(fs[0], fs[1])
    fs[0] //= g
    fs[1] //= g
    return fs


def factorization(n):
    D = {}
    a = n
    p = 2
    while a != 1:
        cnt = 0
        while a % p == 0:
            cnt += 1
            a //= p
        if cnt != 0:
            D[p] = cnt
        p += 1
        if p * p > n and a != 1:
            D[a] = 1
            break
    return D
def divisors_list(D):
    F = [1]
    for i in D:
        mL = F[:]
        dp = i
        for j in range(D[i]):
            for k in mL:
                F.append(dp*k)
            dp *= i
    F.sort()
    return F

def doubling(n, m, modulo=0):
    y = 1
    base = n
    tmp = m
    while tmp:
        if tmp % 2 == 1:
            y *= base
            if modulo > 0:
                y %= modulo
        base *= base
        if modulo > 0:
            base %= modulo
        tmp //= 2
    return y

def inved(a, modulo):
    x, y, u, v, k, l = 1, 0, 0, 1, a, modulo
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return x % modulo
def bic(n): 
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt
def powlimit(n):
    y = 1
    cnt = 0
    while y < n:
        y *= 2
        cnt += 1
    return y, cnt
def CRT(n, a, b): 
    r = a[0]
    bas = b[0]
    x, y = 0, 0
    for i in range(1, n):
        x, y = extgcd(bas, -b[i], a[i] - r)
        r += bas * x
        bas *= b[i]
    return r % bas


def mod_maker(cnt, num):
    bin_list = [1 for _ in range(cnt+1)]
    for i in range(cnt, 0, -1):
        bin_list[i-1] = 2*bin_list[i]
    L = []
    pm = []
    bas = doubling(2, cnt)
    ccnt = 0
    j = 1
    while ccnt < num:
        if IsPrime(j*bas+1):
            x = j*bas+1
            L.append(j*bas+1)
            ccnt += 1
            st = 1
            flg = 0
            while not flg:
                flg = (doubling(st, bin_list[0], x) == 1)
                for k in range(cnt):
                    flg *= (doubling(st, bin_list[k+1], x) != 1)
                if flg:
                    pm.append(st)
                    break
                st += 1
        j += 2
    return L, pm

def NTT(f, n, cn, num, inverse=False):
    if n == 1:
        return f
    if n == 2:
        return [(f[0]+f[1])%mod[num], (f[0]-f[1])%mod[num]]
    dn = n // 2
    fe = [f[2*i+0] for i in range(dn)]
    fo = [f[2*i+1] for i in range(dn)]
    fe = NTT(fe, dn, cn-1, num, inverse)
    fo = NTT(fo, dn, cn-1, num, inverse)
    seed = inverse * prim[num][cn] + (1 - inverse) * invp[num][cn]
    grow = 1
    xf = [0 for _ in range(n)]
    for i in range(dn):
        right = fo[i] * grow % mod[num]
        xf[i+0*dn] = (fe[i] + right) % mod[num]
        xf[i+1*dn] = (fe[i] - right) % mod[num]
        grow *= seed
        grow %= mod[num]
    return xf


N, M = map(int, input().split())
A = [N, M]
n = 2
pl, bn = powlimit(2*n+2)
A = A[:] + [0]*(pl-n)
convolution_time = 2 
binary_count = 20
mod, primod = mod_maker(binary_count, convolution_time)
prim = [[doubling(primod[j], doubling(2, binary_count-i), mod[j]) for i in range(binary_count)] for j in range(convolution_time)]
invp = [[inved(prim[j][i], mod[j]) for i in range(binary_count)] for j in range(convolution_time)]

X1 = [NTT(A, pl, bn, j) for j in range(convolution_time)]
X2 = [NTT(A, pl, bn, j) for j in range(convolution_time)]
XX = [[X1[j][i]*X2[j][i]%mod[j] for i in range(pl)] for j in range(convolution_time)]
Y = [NTT(XX[j], pl, bn, j, 1) for j in range(convolution_time)]
Z = [0 for _ in range(pl)]
ipl = [inved(pl, mod[j]) for j in range(convolution_time)]
for j in range(convolution_time):
    for i in range(pl):
        Y[j][i] *= ipl[j]
        Y[j][i] %= mod[j]
for i in range(pl):
    Z[i] = CRT(convolution_time, [Y[j][i] for j in range(convolution_time)], mod)
print((Z[0]+Z[2]-N-M)//2)

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

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

a=["A" for i in range(0,N)]
b=["B" for i in range(0,M)]

tmp1=(len(list(combinations(a,2))))
tmp2=(len(list(combinations(b,2))))

print(tmp1+tmp2)

Solution (Python):
even,odd = map(int, input().split())

  
print(int(even * (even-1)/2 + odd * (odd-1)/2))

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

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)+M*(M-1))//2)

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

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

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

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

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

Solution (Python):
import math

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

if (n > 1):
  cn = math.factorial(n) / (2 * math.factorial(n - r))
else:
  cn = 0
  
if (m > 1):
  cm = math.factorial(m)  / (2 * math.factorial(m - r))
else :
  cm = 0
  
print(int(cn+cm))

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)+M*(M-1))//2)

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

if __name__ == '__main__':
    main()

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())
ans = n*(n-1)//2 + m*(m-1)//2
print(ans)

Solution (Python):
N,W = map(int,input().split())
total1 = 0
total2 = 0
if N>1:
  total1 = N*(N-1)//2
else:
  total1 = 0

if W>=2:
  total2 = W*(W-1)//2
else:
  total2 = 0
print(total1+total2)

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())

if n >= 2:
    even = n * (n - 1) / 2
else:
    even = 0

if m >= 2:
    odd = m * (m - 1) / 2
else:
    odd = 0
print(int(even + odd))

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, m = M()
print(n*(n-1)//2 + m*(m-1)//2)

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

def factorial(n):
    p = 1
    for i in range(n, 0, -1):
        p *= i
    return p


def comb(n, k):
    return factorial(n) // (factorial(k) * factorial(n-k))


res = comb(M, 2) + comb(N, 2)

print(res)

Solution (Python):


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

def factorial(a):
    p = 1
    for i in range(a, 0 , -1):
        p *= i
    return p

def combo(b, num):
    ans = factorial(b) // (factorial(num) * factorial(b - num))
    return ans

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

Solution (Python):
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(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
N,M=(map(int,input().split()))
a=0
if N>=2:
    x=math.factorial(N)/(math.factorial(N-2)*2)
    a=a+x
if M>=2:
    y=math.factorial(M)/(math.factorial(M-2)*2)
    a=a+y
if a!=0:
    print(int(a))
else:
    print('0')

Solution (Python):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
M,N=map(int,input().split())
print(N*(N-1)//2+M*(M-1)//2)

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==0 or N==1:
    if M==0 or M==1:
        print(0)
        exit(0)
    else:
        print(combinations_count(M, 2))
        exit(0
        )
if M==0 or M==1:
    if N==0 or N==1:
        print(0)
        exit(0)
    else:
        print(combinations_count(N, 2))
        exit(0)
        

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

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

if n==1 and m==1:
    print(0)
else:
    print(int(n*(n-1)/2 + m*(m-1)/2))

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

print(int(ans))

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

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

Solution (Python):
x,y = [int(x) for x in input().split()]
def c(m):
      if (m>=2):
            return m*(m-1)//2
      else:
            return 0
if (x<2 and y<2):
      print(0)
else:
      print(c(x)+c(y))

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(int(n*(n-1)/2+m*(m-1)/2))

Solution (Python):
import math
N, M = list(map(int, input().split()))
n_pairs = math.factorial(N) // (2*math.factorial(N-2)) if N > 1 else 0
m_pairs = math.factorial(M) // (2*math.factorial(M-2)) if M > 1 else 0
print(n_pairs + m_pairs)

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

def comb(n, r):
    if n<r:
        return 0
    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

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

odd_odd = comb(M,2)

even_even = comb(N,2)

print(odd_odd+even_even)

Solution (Python):
def tri_num(num):
    num -= 1
    return int(num * (num + 1) / 2)


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


if __name__ == "__main__":
    main()

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

Solution (Python):
def keisan(x):
  ret_val=0
  for i in range(1,x):
    ret_val+=i
  return ret_val

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

Solution (Python):
n, m = map(int,input().split())
count = 0
l = []

for i in range(n):
  for i2 in range(i,n):
    if i != i2:
      l.append([i,i2])

for i in range(m):
  for i2 in range(i,m):
    if i != i2:
      l.append([i,i2])
print(len(l))

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

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

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

def factorial(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

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

if n < 2:
    ans_1 = 0
else:
    ans_1 = factorial(n, 2)
if m < 2:
    ans_2 = 0
else:
    ans_2 = factorial(m, 2)
print(ans_1+ans_2)

Solution (Python):
def main():
    N, M = (int(i) for i in input().split())
    ans = N*(N-1)//2 + M*(M-1)//2
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import itertools
N,M=map(int,input().split())
print(len(list(itertools.combinations(range(N),2)))+len(list(itertools.combinations(range(M),2))))

Solution (Python):






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

g = n*(n-1)/2
k = m*(m-1)/2

print(int(g+k))

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

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

print(math.floor(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())
n=N*(N-1)
m=M*(M-1)
print((n+m)//2)

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

Solution (Python):
N,M=map(int,input().split())
n=N*(N-1)
m=M*(M-1)
print((n+m)//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())

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

print(even + odd)

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

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())
 
even = n * (n-1)/2
odd = m * (m-1)/2
 
print(int(even + odd))

Solution (Python):
S = input().split()
M = int(S[0])
N = int(S[1])
a = int((M*(M-1)/2) + (N*(N-1)/2))
print(a)

Solution (Python):
N,M  = (int(x) for x in input().split())
Even = N*(N-1)//2
Odd  = M*(M-1)//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()))
ans = int(N * (N - 1) / 2 + M * (M - 1) / 2)
print(ans)

Solution (Python):
n,m=map(int,input().split())
def num(x):
  if x<2:
    return 0
  else:
    return int(x*(x-1)/2)
print(num(n)+num(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())
print(N*(N-1)//2+M*(M-1)//2)

Solution (Python):
N,M = list(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())
if m == 1 and n == 1:
    print(0)
elif m < 2:
    print(n*(n-1)//2)
elif n < 2:
    print(m*(m-1)//2)
else:
    print(n*(n-1)//2 + m*(m-1)//2)

Solution (Python):

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

Solution (Python):
import sys

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


result = n * (n - 1) // 2

result += m * (m - 1) // 2
print(result)

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

Solution (Python):
import math
n, m = map(int, input().split())
if n <= 1:
    a = 0
else:
    a = math.factorial(n)//(2*math.factorial(n-2))
if m <= 1:
    b = 0
else:
    b = math.factorial(m)//(2*math.factorial(m-2))
print(a + b)

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

Solution (Python):
n,m = input().split()
N = (int(n) * (int(n) - 1)) // 2
M = (int(m) * (int(m) - 1)) // 2
print(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())
ans=0
if N>1:
  ans += N*(N-1)//2
else:
  pass
if M>1:
  ans += M*(M-1)//2
else:
  pass
print(ans)

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(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())
import math 

if n>=2 and m>=2:
  ans = math.factorial(n)/math.factorial(n-2)/math.factorial(2) + math.factorial(m)/math.factorial(m-2)/math.factorial(2)

elif n<2 and m>=2 :
  ans =  math.factorial(m)/math.factorial(m-2)/math.factorial(2)

elif m<2 and n>=2:
  ans = math.factorial(n)/math.factorial(n-2)/math.factorial(2)

else:
  ans = 0

print(int(ans))

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

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

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

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


if __name__ == '__main__':
    solve()

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

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

def combination(n,r):
  if n < 0 or r < 0 or n-r<0:
    return 0
  return step(n) // (step(r) * step(n-r))

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

Solution (Python):
import math
def calc_combi(n,m):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(m)*(math.factorial(n-m)))
n,m=map(int,input().split())
ans=int(calc_combi(n,2)+calc_combi(m,2))
print(ans)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9


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

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


if __name__ == '__main__':
    main()

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

Solution (Python):
N,M = map(int,input().split())
print(sum(range(0,N))+sum(range(0,M)))

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) + 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())
a=n*(n-1)//2+m*(m-1)//2
print(a)

Solution (Python):
import math

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

x,y = map(int,input().split())
if x!=0 and x!=1:
    a = combinations_count(x, 2)
else:
    a=0
if y!=0 and y!=1:
    b = combinations_count(y, 2)
else:
    b=0

print(a+b)

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(int(N*(N-1)/2 + M * (M-1)/2))

Solution (Python):
print(sum(map(lambda x:int(x)*(int(x)-1)//2,input().split())))

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

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

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+M)*(N+M-1)//2 - N*M
print(ans)

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    ans = 0
    if N == 1 and M == 1:
        pass
    else:
        if N != 0:
            ans += N*(N-1)/2
        if M != 0:
            ans += M*(M-1)/2
    print(int(ans))
resolve()

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

Solution (Python):

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


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

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

print(n1 + m1)

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())
ans = 0
if n > 1:
  ans += n*(n-1)//2
if m > 1:
  ans += m*(m-1)//2
print(ans)

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

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

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

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

Solution (Python):
gusu,kisu=map(int,input().split())
count=0
S=[]
for i in range(gusu):
    S.append(2)
for i in range(kisu):
    S.append(1)

for i in range(len(S)):
    for j in range(len(S)):
        if i!=j and i>j:
            if (S[i]+S[j])%2==0:
                count+=1

print(count)

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

print(N+M)

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

def factorial(n):
    v = 1
    for i in range(1, n + 1):
        v *= i
    return v

def comb(a, b):
    return factorial(a) // (factorial(b) * factorial(a - b))

if (n < 2) & (m < 2):
    print('0')
elif n < 2:
    print(comb(m, 2))
elif m < 2:
    print(comb(n, 2))
else:
    print(comb(n, 2) + comb(m, 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(' '))
c = int((N*(N-1))/2 + (M*(M-1))/2)
print(c)

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

Solution (Python):

n,m=map(int,input().split())
if n<=1:
    n_ans=0
else:
    n_ans=n*(n-1)/2

if m<=1:
    m_ans=0
else:
    m_ans=m*(m-1)/2
    

print(int(n_ans+m_ans))

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

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

print(pairs)

Solution (Python):
import sys

input = lambda: sys.stdin.readline().rstrip()


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


if __name__ == '__main__':
    solve()

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

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

Solution (Python):
n,m = map(int,input().split())
a = 0
n = n - 1
m = m - 1

while n > 0:
    a = a + n
    n = n - 1

while m > 0:
    a = a + m
    m = m - 1

print(a)

Solution (Python):
m, n = map(int, input().split())
print((m*(m-1) + n*(n-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())
print(n*(n-1)//2+m*(m-1)//2)

Solution (Python):
import math

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

if (N==0 or N==1) and (M==0 or M==1):
  print(0)
elif (N==0 or N==1) and (M!=0 and M!=1):
  print(int(math.factorial(M)/math.factorial(M-2)/math.factorial(2)))
elif (M==0 or M==1) and (N!=0 and N!=1):
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)))
else:
  print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)+math.factorial(M)/math.factorial(M-2)/math.factorial(2)))

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

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

Solution (Python):
x, y = map(int, input().split())

x_sum = x*(x-1)//2
y_sum = y*(y-1)//2
print(x_sum+y_sum )

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

Solution (Python):
import itertools


n_even, n_odd = map(int, input().split())


count1 = n_even * (n_even - 1) // 2
count2 = n_odd * (n_odd - 1) // 2

print(count1 + count2)


count1 = len(list(itertools.combinations(range(n_even), r=2)))
count2 = len(list(itertools.combinations(range(n_odd), r=2)))

Solution (Python):
import itertools


n_even, n_odd = map(int, input().split())


count1 = len(list(itertools.combinations(range(n_even), r=2)))
count2 = len(list(itertools.combinations(range(n_odd), r=2)))

print(count1 + count2)

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)+m*(m-1))//2)

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

if n==1 and m==1:
    print(0)
else:
    print(int(n*(n-1)/2 + m*(m-1)/2))

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

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

print(int(p))

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

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

Solution (Python):
def combination(n):
    return n * (n-1) // 2

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

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 - 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):
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

n,m=map(int,input().split())
if n>=2 and m>=2:print(cmb(n,2)+cmb(m,2))
elif n>=2:print(cmb(n,2))
elif m>=2:print(cmb(m,2))
else:print(0)

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

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int):
    ret = 0
    if N > 1:
        ret += N * (N - 1) // 2
    if M > 1:
        ret += M * (M - 1) // 2
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
print(sum(map(lambda i: int(i)*(int(i)-1)//2, input().split())))

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

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

Solution (Python):
import math
def comb(x,y):
    return math.factorial(x)//(math.factorial(x-y)*math.factorial(y))
n,m = map(int,input().split())

ans1=0
ans2=0
if n > 1:
    ans1=comb(n,2)
if m > 1:
    ans2=comb(m,2)
print(ans1+ans2)

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

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

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(int(n*(n-1)/2 + m*(m-1)/2))

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

main()

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

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

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

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

Solution (Python):
g, k = map(int, input().split())

a = g * (g - 1) / 2
b = k * (k - 1) /2

print(int(a + b))

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

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 = N * (N-1) // 2
b = M * (M-1) // 2

print(a+b)

Solution (Python):
n,m=map(int, input().split())
ans=int(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):
nm = list(map(int, input().split()))

ans = 0

for n in nm:
    ans += (n * (n - 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):
import math
n, m = map(int, input().split())

def combinations_count(a, b):
    return math.factorial(a+b) // (2 * math.factorial(a+b-2))

print(combinations_count(n, m)-(n*m))

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

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

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

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

print(int(a*(a-1)/2+b*(b-1)/2))

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

print(int(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(int((N * (N - 1) + M * (M - 1)) * 0.5))

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

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

    ans1 = math.factorial(n) // (math.factorial(n-2) * 2) if n > 1 else 0
    ans2 = math.factorial(m) // (math.factorial(m-2) * 2) if m > 1 else 0
    print(ans1 + ans2)
resolve()