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 factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)
a,b=map(int, input().split())
cnt=0
if a==2:
    cnt=1
elif a>1:
    cnt=(factorial(a)/((factorial(a-2))*2))
if b==2:
    cnt=cnt+1
elif b>1:
    cnt=(factorial(b)/((factorial(b-2))*2))+cnt
print(int(cnt))

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

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

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

Solution (Python):
import math
n,m = map(int,input().split())
n2 = n*(n-1)/2
m2 = m*(m-1)/2

print(round(n2+m2))

Solution (Python):



from sys import stdin
import itertools


def main():
    N, M = list( map(int, stdin.readline().split()) )

    O = ['遇' for i in range(N)]
    O.extend(['奇' for i in range(M)])

    A = list(itertools.combinations(O, 2))

    cnt = 0
    for i in A:
        if i.count("遇") in [0, 2]:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
def combination(n, x, mod=10**9+7):
    
    
    
    factorial = [1] * (n+1)
    t = 1
    for i in range(1, n+1):
        t = (t * i) % mod
        factorial[i] = t
    tmp = factorial[n]
    tmp = (tmp * pow(factorial[x], mod-2, mod)) % mod
    tmp = (tmp * pow(factorial[n-x], mod-2, mod)) % mod
    return tmp

N,M=map(int,input().split())
ans=0
if N>1:
  ans+=combination(N,2)
if M>1:
  ans+=combination(M,2)
print(int(ans))

Solution (Python):
N, M = map(int, input().split())  
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N < 2:
    a = 0
else:
    a = comb(N, 2)

if M < 2:
    b = 0
else:
    b = comb(M, 2)
print(a+b)

Solution (Python):
import itertools

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

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

for m in range(M):
    Mlist[m] = (m+m+1) * 1
count = 0
for x in itertools.combinations(Nlist, 2):
    if (x[0] + x[1]) % 2 == 0:
        count = count + 1
for x in itertools.combinations(Mlist, 2):
    if (x[0] + x[1]) % 2 == 0:
        count = count + 1
print(count)

Solution (Python):
import itertools

n,m = map(int, input().split())
print(len(list(itertools.combinations(range(m),2))) + len(list(itertools.combinations(range(n),2))))

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


def comb(x):
    if x == 0:
        return 0
    if x == 1:
        return 0
    return x * (x - 1) // 2


print(comb(N) + comb(M))

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 M == 0 and N == 0:
    print(0)
elif M == 1 and N == 1:
    print(0)
elif M <= 1:
    print(cmb(N, 2))
elif N <= 1:
    print(cmb(M, 2))
else:
    a = cmb(M, 2)
    b = cmb(N, 2)
    print(a + b)

Solution (Python):
even,odd = map(int,input().split())
counter = 0
if even >= 2:
    for i in range(even):
        if i == 0:
            continue
        counter += i
if odd >= 2:
    for i in range(odd):
        if i == 0:
            continue
        counter += i
print(counter)

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

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

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

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

Solution (Python):
import math

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

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

if n >= 2:
    x = permutations_count(n, 2)
else:
    x = 0
if m >= 2:
    y = permutations_count(m, 2)
else:
    y = 0
print((x + y)//2)

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

a = M*(M-1)/2
b = N*(N-1)/2

print(a+b)

Solution (Python):
import math

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


if M > 1 and N > 1:
    print(int(math.factorial(N) / (2 * math.factorial(N - 2))) + int(math.factorial(M) / (2 * math.factorial(M - 2))))
elif M <= 1 and N <= 1:
    print(0)
elif M <= 1:
    print(int(math.factorial(N) / (2 * math.factorial(N - 2))))
elif N <= 1:
    print(int(math.factorial(M) / (2 * math.factorial(M - 2))))

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

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())
ans=0
if N>=2:
    ans+=cmb(N,2)
if M>=2:
    ans+=cmb(M,2)
print(ans)

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

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

x = n + m


x = n + m
z = math.factorial(x) / (2 * math.factorial(x-2))
q = n*m
print(int(z-q))

Solution (Python):
import math
H, W = map(int, input().split())

a = (H * (H-1))/2
b = (W * (W-1))/2

print(int(a+b))

Solution (Python):
from math import factorial
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 >= 0:
    a = cmb(N,2)
else:
    a = 0


if M - 2 >= 0:
    b = cmb(M,2)
else:
    b = 0

print(int(a)+int(b))

Solution (Python):
import itertools

n,m = map(int, input().split())
print(len(list(itertools.combinations(range(m),2))) + len(list(itertools.combinations(range(n),2))))

Solution (Python):
import math


def ncr(n, k):
    return math.factorial(n) / (math.factorial(k) * math.factorial(n - k))


n, m = map(int, input().split())
c1, c2 = 0, 0
if n > 1:
    c1 = ncr(n, 2)
if m > 1:
    c2 = ncr(m, 2)
print(int(c1 + c2))

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

Solution (Python):
from math import factorial
N,M=map(int,list(input().split(" ")))
s=0
if N>=2:
    s+=factorial(N)//(factorial(N-2)*2)
if M>=2:
    s+=factorial(M)//(factorial(M-2)*2)
print(s)

Solution (Python):
import math
n, m = input().split()
m = int(m)
n = int(n)
if n == 1 or n == 0:
	nNum = 0
else:
	nNum = math.factorial(n) / (math.factorial(n-2) * math.factorial(2))
if m == 1 or m == 0:
	mNum = 0
else:
	mNum = math.factorial(m) / (math.factorial(m-2) * math.factorial(2))
print(int(mNum + nNum))

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

L=0
    
for n in range(N):
    L+=n
    
    
for m in range(M):
    L+=m
    
print(L)

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

print(int(Nmath+Mmath))

Solution (Python):


n, m = map(int, input().split())
even = 0
if n >= 2:
    for i in range(1, n):
        even += i
if m >= 2:
    for i in range(1, m):
        even += i

print(even)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

from decimal import *

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007




def main():
	N,M = inputMap()

	if N < 2 and M < 2:
		print(0)
		sys.exit()

	ans = 0
	if N > 1:
		ans += cmb(N, 2)
	if M > 1:
		ans += cmb(M, 2)

	print(ans)







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

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m

    return f(int(math.sqrt(n) * (1 + 1e-10)))



def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

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

Solution (Python):
from scipy.misc import comb
gusu, kisu = input().split()
gusu = int(gusu) 
kisu = int(kisu) 
gusu_num = comb(gusu, 2, exact=True)
kisu_num = comb(kisu, 2, exact=True)
print(gusu_num + kisu_num)

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

Solution (Python):
import math

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

Solution (Python):

import math


b, c = map(int, input().split())

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

print(int(combinations_count(b+c, 2)-b*c))

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

if M > 1:
    ans_ki = (math.factorial(M) / (2 * math.factorial(M - 2)))
else:
    pass

if N > 1:
    ans_gu = (math.factorial(N) / (2 * math.factorial(N - 2)))
else:
    pass
ans = round(ans_ki + ans_gu)
print(ans)

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

Solution (Python):
import math

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

    result = 0
    if N >= 2:
        c = math.factorial(N) // (math.factorial(2) * math.factorial(N - 2))
        result += c
    if M >= 2:
        c = math.factorial(M) // (math.factorial(2) * math.factorial(M - 2))
        result += c
    print(result)
    
if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
a = []
b = []
if M == 0:
    for i in range(1,(2*N)+1):
        if i%2==0 and i>0:
            a.append(i)
elif N == 0:
    for i in range(1,(2*M)+1):
        if i%2==1:
            b.append(i)
else:
    for i in range(1,501):
        if i%2==0 and i>0:
            a.append(i)
        else:
            b.append(i)
c = a[:N] + b[:M]
l = []
num = 1
for i in range(len(c)-1):
    for j in range(num,len(c)):
        res = c[i] + c[j]
        l.append(res)
    num+=1

k=[i for i in l if i%2==0]
print(len(k))

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 m >= 2:
    odd = combinations_count(m, 2)
elif m == 0 or m == 1:
    odd = 0

if n >= 2:
    even = combinations_count(n, 2)
elif n == 1:
    even = 1
elif n == 0:
    even = 0

answer = odd + even
if m == 1 and n == 1:
    answer = 0

print(answer)

Solution (Python):
from itertools import combinations

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

a = len(list(combinations(range(n+m),2)))

if (n == 2 and m == 0) or (n == 0 and m == 2):
    print(2)
    exit()

else:
    print(a-(n*m))

Solution (Python):

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

resn=n*(n-1)/2
resm=m*(m-1)/2

print(int(resn+resm))

Solution (Python):
N, M = list(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 comb(n, r):
    res = 1
    for i in range(n-r+1, n+1):
        res *= i
    for i in range(2, r+1):
        res /= i
    return res

nn = comb(N, 2)
mm = comb(M, 2)

ans = int(nn + mm)

print(ans)

Solution (Python):
def combinations_count(n, r):
    if n >= r:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0
        
import math

a,b = map(int,input().split())

print(combinations_count(a,2) + combinations_count(b,2))

Solution (Python):
import math


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


N, M = map(int, input().split())
if M < 2 and N < 2:
    Count = 0
elif M < 2:
    Count = comb(N, 2)
elif N < 2:
    Count = comb(M, 2)
else:
    Count = comb(N, 2) + comb(M, 2)
print(Count)

Solution (Python):
from math import factorial

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

def comb2(n):
    if n > 1:
        return factorial(n) // factorial(2) // factorial(n - 2)
    else:
        return 0
    
s = 0    
for i in [N, M]:
    s += comb2(i)

print(s)

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

if n - 2 < 0:
    a = 0
else:
    a = math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
if m - 2 < 0:
    b = 0
else:
    b = math.factorial(m) // (math.factorial(m - 2) * math.factorial(2))
print(a + b)

Solution (Python):
n, m = map(int, input().split())
s, o, ans = 0, 1, 0
se = []
if 0 <= n <= 100 and 0<= m <= 100 and 2 <= n+m:
    for i in range(1, n+1):
        se.append(s)
        s += 2
    for i in range(1, m+1):
        se.append(o)
        o += 2
    for x in se:
        for y in range(len(se)):
            if (x + se[y]) % 2 == 0 and x!=se[y]:
                ans += 1 
    print(int(ans/2))

Solution (Python):
import copy
import math
import collections
def comb(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


N, M = list(map(int, input().split()))
a, b = 0, 0
if N >= 2:
    a = comb(N, 2)
if M >= 2:
    b = comb(M, 2)
ans = a + b
print(ans)

Solution (Python):
import sys
import itertools

NM = input()
N = NM.split()[0]
M = NM.split()[1]
N = int(N)
M = int(M)

if (N<0 or 100<N ):
    sys.exit()
if ( M<0 or 100<M ):
    sys.exit() 
if ( N+M<2 ):
    sys.exit()

even = list(itertools.combinations(range(N),2))
odd  = list(itertools.combinations(range(M),2))

print (len(even) + len(odd))

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

if a >= 2 and b >=2 :
    ans = ((a * (a + 1))//2 - a) + ((b * (b +1))//2 - b)
    print(ans)

if a < 2 and b < 2:
    print(0)

if a < 2 and b >= 2:
    print((b * (b + 1))//2 -b)

if a >= 2 and b < 2:
    print((a * (a + 1))//2 -a)

Solution (Python):
import sys
X,Y = map(int,input().split())
if(X == 1 and Y == 1):
    print(0)
    sys.exit()
elif(Y == 1):
    print(int(X/2))
    sys.exit()
elif(X == 0 and Y ==2):
    print(1)
    sys.exit()
print(int((X * (X-1))/2 + int((Y * (Y-1))/2 )))

Solution (Python):

import math

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

if(N==2) :
  n = 1
elif(N<=1) :
  n = 0
else :
  n = math.factorial(N) // ( math.factorial(2) * math.factorial(N - 2) )
  
if(M==2) :
  m = 1
elif(M<=1) :
  m = 0
else :
  m = math.factorial(M) // ( math.factorial(2) * math.factorial(M - 2) )

print(n + m)

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

Solution (Python):
import math

N, M = [int(i) for i in input().rstrip().split(' ')]
_r = math.factorial(2)
patternN = 0
patternM = 0

if N > 1:
    
    _N = math.factorial(N)
    even = math.factorial(N-2)
    patternN = int(_N / even / _r)

if M > 1:
    
    _M = math.factorial(M)
    odd = math.factorial(M-2)
    patternM = int(_M / odd / _r)

print(patternN + patternM)

Solution (Python):
import itertools

n,m = map(int, input().split())
print(len(list(itertools.combinations(range(m),2))) + len(list(itertools.combinations(range(n),2))))

Solution (Python):
nm = [int(i) for i in input().split()]

result = (nm[0] * (nm[0] - 1)) // 2
result += (nm[1] * (nm[1] - 1)) // 2

print(result)

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

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

Solution (Python):


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

cnt = 0
l = list(range(0, N*2, 2)) + list(range(1, M*2, 2))
for i, n in enumerate(l):
  for m in l[i+1::]:
    if (n + m) % 2 == 0:
      cnt += 1

print(cnt)

Solution (Python):
from math import *


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

Solution (Python):
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  
factinv = [1, 1]  
inv = [0, 1]  

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
'''




a,b =  list(map(int, input().split()))

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

Solution (Python):
import math
e,o = map(int,input().split())
if e < 2:
    e_cases = 0
else:
    e_cases = math.factorial(e)/math.factorial(e-2)/2
if o < 2:
    o_cases = 0
else:
    o_cases = math.factorial(o)/math.factorial(o-2)/2
print(int(e_cases+o_cases))

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

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

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

if n == 0:
   N = 0
elif n == 1:
    N = 0
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
elif m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))

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

def fact(num):
    result = 1
    while num > 1:
        result *= num
        num -= 1
    return result

if M!=0 or M!=1:
    result += fact(M) // (fact(2) * fact(M-2))

if N!=0 or N!=1:
    result += fact(N) // (fact(2) * fact(N-2))

print(result)

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

Solution (Python):
def binom(n,r):
    if n<r or n<0:
        return 0

    result=1
    for i in range(r):
        result*=(n-i)
        result//=(i+1)
    return result

inputs=[int(c) for c in input().split()]
n=inputs[0]
m=inputs[1]
print(binom(n,2)+binom(m,2))

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

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


if N <= 1 and M >= 2:
  result = M*(M - 1)/2
  print(int(result))
  
elif M <= 1 and N >= 2:
  result = N*(N - 1)/2
  print(int(result))
  
elif N == 1 and N == 1:
  print('0')
  
else :
  result = M*(M - 1)/2 + N*(N - 1)/2
  print(int(result))

Solution (Python):
def main():
    n, m = map(int, input().split())
    n -= 1
    m -= 1
    e = 0
    while n > 0:
        e += n
        n -= 1
    while m > 0:
        e += m
        m -= 1
    print(e)
 
main()

Solution (Python):
def total(x):
	if x == 1:
		return 0
	else:
		x = x - 1
		return (x * (x + 1))/2
ln = list(map(int, input().split(" ")))
print(int(total(ln[0]) + total(ln[1])))

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

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

Solution (Python):
n, m = list(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 calculation(number):
    factorial = math.factorial(number)
    combination = factorial/math.factorial(number-2)
    result = math.floor(combination/2)
    return result

if m == 1 or m == 0:
    if n == 1 or n == 0:
        print("0")
    else:
        print("{}".format(calculation(n)))
else:
    if n == 1 or n == 0:
        print("{}".format(calculation(m)))
    else:
        print("{}".format(calculation(n)+calculation(m)))

Solution (Python):
if __name__ == '__main__':
    arr = list(map(int,input().rstrip().split()))
    cou = 0
    cou_n = 0
    cou_m = 0
    i =1
    j    =1
    N = arr[0]
    M = arr[1]
    n =[]
    m = []
    while cou_n  != N:
        if i % 2 == 0:
            n.append(i)
            cou_n += 1
        i += 1

    while cou_m != M:
        if j % 2 != 0 :
            m.append(j)
            cou_m +=1
        j += 1
    f = n + m


    f.sort()


    for i in range(len(f)):
        for j in range(i+1,len(f)):
            if ((f[i] + f [j]) % 2) == 0:
                cou +=1
    print(cou)

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

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

Solution (Python):

M,N = map(int, input().split())
A = 0
B = 0
C = M
D = 0
E = 0
F = N
while A < C:
    B += M -1
    M -= 1
    A += 1

while D < F:
    E += N -1
    N -= 1
    D += 1
print(B + E)

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

from operator import mul
from functools import reduce

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

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

Solution (Python):
import itertools
e, o = map(int, input().split())
new = []
for x in range(1, e+1):
    new.append(2*x)
for x in range(1, o*2):
    if x%2==1:
        new.append(x)
counter = 0
for x in itertools.combinations(new, 2):
    if int(x[0]+x[1]) %2 == 0:
        counter +=1
print(counter)

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

Solution (Python):
A,B = list(map(int,input().split()))
import math
if A == 0 and B != 0:
  D = math.factorial(B-2)
  F = math.factorial(B) // 2// D
  print(F)
  exit()
if A != 0 and B == 0:
  C = math.factorial(A-2)
  E = math.factorial(A) // 2// C
  print(E)
  exit()
if A == 0 and B == 0:
  print(0)
  exit()
elif A == 1 and B != 1:
  D = math.factorial(B-2)
  F = math.factorial(B) // 2// D
  print(F)
  exit()
elif A != 1 and B == 1:
  C = math.factorial(A-2)
  E = math.factorial(A) // 2// C
  print(E)
  exit()
elif A == 1 and B == 1:
  print(0)
  exit()
C = math.factorial(A-2)
D = math.factorial(B-2)
E = math.factorial(A) // 2// C
F = math.factorial(B) // 2// D
print(E+F)

Solution (Python):

n, m = map(int, input().split())
n_total_perm = 1
m_total_perm = 1
for j in range(n,n-2,-1):
    n_total_perm *= j

for k in range(m,m-2,-1):
    m_total_perm *= k

total_even = int((n_total_perm/2) + (m_total_perm/2))



print(total_even)

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

a = len(list(itertools.combinations(range(N), 2)))
b = len(list(itertools.combinations(range(M), 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())
s=0
if(n>=2):
  for i in range(n):
    s+=i
    
if(m>=2):
  for i in range(m):
    s+=i
print(s)

Solution (Python):
N,M = map(int,input().split())
 
def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    return cmb(n-1,r) + cmb(n-1,r-1)
 
ret = cmb(N,2) + cmb(M,2)
print(ret)

Solution (Python):
import math
a,b=map(int, input().split())
answer = 0

if a > 1 :
    answer += math.factorial(a) / (math.factorial(a - 2)*2)

if b > 1:
    answer += math.factorial(b) / (math.factorial(b - 2)*2)

print(int(answer))

Solution (Python):
from operator import mul
from functools import reduce
def combinations(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())
result = 0
if N >= 2:
    result += combinations(N, 2)
if M >= 2:
    result += combinations(M, 2)
print(int(result))

Solution (Python):
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


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


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


def inpl_str(): return list(sys.stdin.readline().split())


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

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):
import math
N,M =map(int,input().split())
if N==1 :
    N1=0
elif N==0:
    N1=0
else:
    N1=(math.factorial(N))//(math.factorial(N-2)*2)
    
if M==1:    
    M1=0
    
elif M ==0:
    M1=0
else:
    M1=(math.factorial(M))//(math.factorial(M-2)*2)
    
print(str(N1+M1))

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):
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(0)
    
elif N>=2 and M<=1:
    N_number=combinations_count(N, 2)
    

    print(N_number)
    
elif N<=1 and M>=2:
    
    M_number=combinations_count(M, 2)

    print(M_number)

else:
    N_number=combinations_count(N, 2)
    M_number=combinations_count(M, 2)

    print(N_number+M_number)

Solution (Python):


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

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

print(comb2(n)+comb2(m))

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

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

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

print(con)

Solution (Python):
from operator import mul
from functools import reduce
N, M=map(int, input().split())


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

if N>=2 and M>=2:
    print(combinations_count(N, 2)+combinations_count(M, 2))
elif N>=2 or M>=2:
    print(combinations_count(N, 2)+combinations_count(M, 2)-1)
else:
    print(0)

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

Solution (Python):
N,M=[int(s) for s in input().split(" ")]
Ans1=M*(M-1)/2
Ans2=N*(N-1)/2
print(int(Ans1+Ans2))

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

Solution (Python):
def comb(a):
    if a < 2:
        return 0
    else:
        return a * (a-1) // 2


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

Solution (Python):
import math


def comb(n, r):
    try:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    except ValueError:
        return 0



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

Solution (Python):
a = list(map(int, input().split()))
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if a[0] <=1:
	b = 0
else:
	b = combinations_count(a[0], 2)
if a[1] <=1:
	c = 0
else:
	c = combinations_count(a[1], 2)
print(b + c)

Solution (Python):
n,m = map(int, input().split())
cnt_n = 0
cnt_m = 0
for i in range(n):
    cnt_n += i
for j in range(m):
    cnt_m += j
print(cnt_n+cnt_m)