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):
import math
n, m = map(int, input().split())

if n >= 2:
  a = math.factorial(n)/(math.factorial(2)*math.factorial(n-2))
else:
  a = 0

if m >= 2:
  b = math.factorial(m)/(math.factorial(2)*math.factorial(m-2))
else:
  b = 0

print(int(a + b))

Solution (Python):
from scipy.misc import comb
print(int(sum(comb(list(map(int,input().split())),2, exact = False))+0.5))

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

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

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

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

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

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

print(ans // 2)

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

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

Solution (Python):
def decSum(x):
    sum = 0
    for i in range(x):
        sum += i
    return sum


combined = input().split(" ")
even = int(combined[0])
odd = int(combined[1])

print(decSum(even) + decSum(odd))

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

Even = [ i for i in range(N)] 
Odd = [ j for j in range(M)]

print(sum(Odd) + sum(Even))

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

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

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 = list(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) + 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) + 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())

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

Solution (Python):
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(range(N), 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(range(M), 2)))

c3 = c1 + c2
print(c3)

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

print(m*(m-1)//2 + n*(n-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 math
def kumiawase(n):
  a = 1
  b = 1
  for i in range(1, n+1):
    a = i * a
  for i in range(1, n - 2+1):
    b = i * b
  c = math.floor(a /(b * 2))
  return c
if __name__ == "__main__":
  x = input().split()
  n = int(x[0]) 
  m = int(x[1]) 
  a = kumiawase(n)
  b = kumiawase(m)
  print(a + b)

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

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

total = 0

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

print(total)

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):
from functools import reduce

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

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

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


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

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

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

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

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


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

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

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

even = 0
for ni in range(N):
    for nj in range(ni, N):
        if ni != nj:
            even += 1

odd = 0
for mi in range(M):
    for mj in range(mi, M):
        if mi != mj:
            odd += 1

ans = even + odd

print(ans)

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

Solution (Python):
import math

ARGS=input().split()
N=int(ARGS[0])
M=int(ARGS[1])
R=2

COMB=0
if N >= R:
    COMB=math.factorial(N) // math.factorial(N - R) // math.factorial(R)
if M >= R:
    COMB+=math.factorial(M) // math.factorial(M - R) // math.factorial(R)

print(str(COMB))

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

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

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

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

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

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

def inv(a): return pow(a, MOD-2, MOD)

def comb(n,r):
    ans = 1
    for i in range(r):
        ans *= n-i
        ans *= inv(r-i)
        ans %= MOD
    return ans

n,m = imap()
ans = comb(n,2) + comb(m,2)
print(ans)

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


sys.setrecursionlimit(10**7)






def run():
    N, M = map(int, sysread().split())
    print(N*max(N-1,0)//2 + M*max(M-1, 0)//2)
if __name__ == "__main__":
    run()

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

M2=(M*(M-1))/2 
N2=(N*(N-1))/2
A=M2+N2
A=int(A)
print(A)

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

if n != 0:
    pn = (n**2 - n) // 2
else:
    pn = 0

if m != 0:
    pm = (m**2 - m) // 2
else:
    pm = 0

print(pn + pm)

Solution (Python):

import math
gu, ki = map(int, input().split())

if gu <= 1:
    sum_gu = 0
elif gu == 2:
    sum_gu = 1
else:
    sum_gu = math.factorial(gu) / (math.factorial(gu-2)*2)

if ki <= 1:
    sum_ki = 0
elif ki == 2:
    sum_ki = 1
else:
    sum_ki = math.factorial(ki) / (math.factorial(ki-2)*2)

print(int(sum_gu+sum_ki))

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

Solution (Python):
from itertools import permutations, combinations,combinations_with_replacement,product
A,B=map(int,input().split())

a=[2 for i in range(A)]+[1 for i in range(B)]
b=list(combinations(a,2))
ans=0
for i in b:
    tmp=sum(i)
    if tmp%2==0:
        ans+=1
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())

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

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

print(ans)

Solution (Python):


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

ans=0

if M<=1:
    if N<=1:
        ans = 0
    else:
        ans = N*(N-1)/2
elif N<=1:
    ans = M*(M-1)/2

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

print(int(ans))

Solution (Python):
h, m = map(int, input().split())
h_method = h*(h-1)//2
m_method = m*(m-1)//2

print(h_method + m_method)

Solution (Python):
N,M = [int(x) for x in input().split()] 
    
N = (N * (N - 1)) / 2
M = (M * (M - 1)) / 2

X = N + M 

print(int(X))

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):
def c2(n):
	ret=n*(n-1)
	return ret//2
n,m=map(int,input().split())
print(c2(n)+c2(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())
C = N * (N - 1)/2 + M * (M - 1)/2
print(int(C))

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

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

Solution (Python):
import sys
 
mod = 10**9+7 
 
 
class Factorial:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorials = [1, 1]  
        self.invModulos = [0, 1]  
        self.invFactorial_ = [1, 1]  
 
    def calc(self, n):
        if n <= -1:
            print("Invalid argument to calculate n!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.factorials):
            return self.factorials[n]
        nextArr = [0] * (n + 1 - len(self.factorials))
        initialI = len(self.factorials)
        prev = self.factorials[-1]
        m = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = prev * i % m
        self.factorials += nextArr
        return self.factorials[n]
 
    def inv(self, n):
        if n <= -1:
            print("Invalid argument to calculate n^(-1)")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        p = self.MOD
        pi = n % p
        if pi < len(self.invModulos):
            return self.invModulos[pi]
        nextArr = [0] * (n + 1 - len(self.invModulos))
        initialI = len(self.invModulos)
        for i in range(initialI, min(p, n + 1)):
            next = -self.invModulos[p % i] * (p // i) % p
            self.invModulos.append(next)
        return self.invModulos[pi]
 
    def invFactorial(self, n):
        if n <= -1:
            print("Invalid argument to calculate (n^(-1))!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.invFactorial_):
            return self.invFactorial_[n]
        self.inv(n)  
        nextArr = [0] * (n + 1 - len(self.invFactorial_))
        initialI = len(self.invFactorial_)
        prev = self.invFactorial_[-1]
        p = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
        self.invFactorial_ += nextArr
        return self.invFactorial_[n]
 
 
class Combination:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorial = Factorial(MOD)
 
    def ncr(self, n, k):
        if k < 0 or n < k:
            return 0
        k = min(k, n - k)
        f = self.factorial
        return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
 
 
def powm(a, n, m):
    if a == 1 or n == 0:
        return 1
    if n % 2 == 0:
        s = powm(a, n // 2, m)
        return s * s % m
    else:
        return a * powm(a, n - 1, m) % m
n,k=map(int,input().split())
s=Combination(mod)
ans=s.ncr(n,2)+s.ncr(k,2)
print(ans)

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

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 >= 2) and (M >= 2):
    C_e = combinations_count(N, 2)
    C_o = combinations_count(M, 2)
    print(C_e + C_o)
elif (N < 2) and (M >= 2):
    C_e = 0
    C_o = combinations_count(M, 2)
    print(C_e + C_o)
elif (N >= 2) and (M < 2):
    C_e = combinations_count(N, 2)
    C_o = 0
    print(C_e + C_o)
else:
    print(0)

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

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

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

def main():
    N,M = map(int, input().split())
    ans = combinations_count(M,2) + combinations_count(N,2)
    print(ans)

main()

Solution (Python):
import itertools
def main():
    N,M = map(int, input().split())
    ans = len(list(itertools.combinations([i for i in range(M)],2))) + len(list(itertools.combinations([i for i in range(N)],2)))
    print(ans)

main()

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

n, m = ISI()
cnt =0
for i in range(n):
	if i>0:	cnt += i
for j in range(m):
	if j>0: cnt += j
print(cnt)

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

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())
cnt = 0
if N >= 2:
    cnt += ((N * (N-1)) / 2)
if M >= 2:
    cnt += ((M * (M-1)) / 2)
print(int(cnt))

Solution (Python):
from itertools import combinations
n, m = map(int, input().split())
r = []
i = 0
j = -1
c = 0
for _ in range(n):
    i += 2
    r.append(i)
for _ in range(m):
    j += 2
    r.append(j)
r.sort()
for k in list(combinations(r, 2)):
    if sum(k) % 2 == 0:
        c += 1

print(c)

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

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 or m>=2:
  if 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)
    
else:
  print(0)

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

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


if __name__ == '__main__':
    main()

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

Solution (Python):

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

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

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

if(N >= 2):    
    ans1 = (N*(N-1))//2
if(M >= 2):
    ans2 = (M*(M-1))//2

print(ans1+ans2)

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

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
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())
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = LI()
    even_num = N*(N-1)/2    
    odd_num = M*(M-1)/2     
    print(int(even_num + odd_num))

main()

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

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

if N >= 2:
  N_num = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))
if M >= 2:
  M_num = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))

print(N_num + M_num)

Solution (Python):
import math 
import sys 

t=1
for _ in range(t):
    n,m=map(int,input().split())
    ans=n*(n-1)//2+m*(m-1)//2 
    print(ans)

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

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

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

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

if List[0] >= 2 and List[1] >= 2:
    c = List[0]*(List[0]-1)/2  + List[1]*(List[1]-1)/2
elif List[0] < 2 and List[1] >= 2:
    c = List[1]*(List[1]-1)/2
elif List[0] >= 2 and List[1] < 2:
    c = List[0]*(List[0]-1)/2
else:
    c = 0

print(int(c))

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

N = int(N)
M = int(M)

even = 0
odd = 0
final = int

even = (N*(N-1))/2
odd = (M*(M-1))/2
final = even + odd
print(int(final))

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

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

Solution (Python):
from sys import stdin, setrecursionlimit


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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

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

Solution (Python):
import math
def fac(k):
    return(math.factorial(k)//(math.factorial(k-2)*2))


n,k = input().split()
n = int(n) 
k = int(k)
se = 0

if k > 1:
    if n > 1:
        se = fac(k) + fac(n)
    else:
        se= fac(k)
else:
    if n > 1:
        se =  fac(n)
    else:
        se = 0
print(se)

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

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):
import operator as op
from functools import reduce

def comb(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
n,m = map(int, input(). split())
A = 0
B = 0
if n >= 2:
  A = int(comb(n, 2))
if m >= 2:
  B = int(comb(m, 2))
print(A + B)

Solution (Python):
from math import factorial

def choose(n, k):
    if n < k:
        return 0
    else:
        return factorial(n) // factorial(k) // factorial(n - k)

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

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

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

pattern_o=(N-1)*N/2
pattern_e=(M-1)*M/2

print(int(pattern_o+pattern_e))

Solution (Python):

import sys
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
def comb(n, r):  
    if n <= 0 or r > n: return 0
    return factorial(n) // factorial(n - r) // factorial(r)

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

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

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

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

print(ans)

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

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

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

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

Solution (Python):
from scipy.misc import comb
n,m=map(int,input().split())
print(comb(n,2,exact=True)+comb(m,2,exact=True))

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

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

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

ans = N*(N-1)//2 + M*(M-1)//2
print("{}".format(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())
sum = 0
for i in range(m+n):
    sum += i
print(sum-n*m)

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

Solution (Python):
def minusOneFactorial(num):
    return sum([i-1 for i in range(1,num+1)])

N,M = [int(i) for i in input().split()]
possible_evens = minusOneFactorial(N)
possible_odds = minusOneFactorial(M) if not M==0 else 0
print(possible_evens + possible_odds)

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())
result=0
n1=1
m1=1
for i in range(n-1,n+1):
    n1*=i
for k in range(m-1,m+1):
    m1*=k
print(int((n1+m1)/2))

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

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

Solution (Python):
from math import factorial


def nc2(n):
    return factorial(n) // 2 // factorial(n - 2)


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

patterns = 0

if N > 1:
    patterns += nc2(N)

if M > 1:
    patterns += nc2(M)

print(patterns)

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

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

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

Solution (Python):
import math
M, N = (int(x) for x in input().split())
def combinations_count(n, r):
  if n >= 2:
    ans = math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  else:
    ans = 0
  return ans

print(combinations_count(M, 2) + combinations_count(N, 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())

ki_ki = M*(M-1)/2
guu_guu = N*(N-1)/2
if ki_ki<0:
    ki_ki = 0
if guu_guu < 0:
    guu_guu = 0

print(int(ki_ki +guu_guu))

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

Solution (Python):
N, M = map(int, input().split())
even = [2]*N
odd = [1]*M
a = even+odd
ans = 0
for i in range(N+M):
    for j in range(i+1, N+M):
        if (a[i]+a[j]) % 2 == 0:
            ans += 1
print(ans)

Solution (Python):
import math

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

N, M = list(map(int, input().split()))
N = combinations_count(N, 2) if N >= 2 else 0
M = combinations_count(M, 2) if M >= 2 else 0

print(N + M)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]





N, M = mi()

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

Solution (Python):

import sys


def solve(N: int, M: int):
    return N * (N-1) // 2 + M * (M - 1) // 2


def main():
    N, M = map(int, sys.stdin.readline().split())
    print(solve(N, M))


if __name__ == '__main__':
    main()

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

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

print(ans)

Solution (Python):
def resolve():
    import itertools
    N,M = map(int,input().split())
    N_list = [int(x) for x in range(N)]
    M_list = [int(y) for y in range(M)]

    n = len(list(itertools.combinations(N_list,2)))
    m = len(list(itertools.combinations(M_list,2)))
    print(n+m)

resolve()

Solution (Python):


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


def main() -> None:
    """Entry point
    """
    
    
    result = int(N*(N-1)/2 + M*(M-1)/2)

    
    print(result)


if __name__ == "__main__":
    main()

Solution (Python):


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


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


print(result)

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

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

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

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

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

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

if __name__ == '__main__':

    ABC_159_A()

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

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

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

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

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

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

print(int(ans))

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

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

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

print( int(m*(m-1)/2) + int(n*(n-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):
import math
n, m = map(int, input().split())
if n == 1:
    print(0)
else:
    print(math.floor(n*(n-1)/2 + m*(m-1)/2))

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

cn = 0
cm = 0

if n < 2:
    cn = 0
elif n == 2:
    cn = 1
else:
    cn = n * (n-1) / 2

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

ans = cn + cm
print(int(ans))

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

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