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):
from math import factorial

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

if N <= 1 and M <= 1:
  print(0)
elif N >= 2 and M <= 1:
  print(factorial(N) // factorial(2) // factorial(N - 2))
elif N <=1 and M >=2:
  print(factorial(M) // factorial(2) // factorial(M - 2))
else:
  print(factorial(N) // factorial(2) // factorial(N - 2) + factorial(M) // factorial(2) // factorial(M - 2))

Solution (Python):
x, y = map(int, input().split())
result_x = 0
result_y = 0
if x > 1:
    result_x = 0
    for i in range(x):
        result_x = result_x + i

if y > 1:
    result_y = 0
    for i in range(y):
        result_y = result_y + i


print(result_x + result_y)

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

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

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

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

Solution (Python):
import math

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

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

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

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

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

Solution (Python):
from itertools import combinations

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

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

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

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

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

Solution (Python):
import math
import itertools
N,M = input().split()
N1=int(N)
M1=int(M)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N1>=2:
    n=combinations_count(N1,2)
else:
    n=0
if M1>=2:
    m=combinations_count(M1,2)
else:
    m=0
print(n+m)

Solution (Python):
if __name__ == '__main__':
    a, b = map(int, input().split())
    ans = 0

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



    print(ans)

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

print(answer)

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

P = n+m

TOTAL = P*(P-1)//2
SUB = n*m

print(TOTAL - SUB)

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

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

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

ans1=comb(n,2)
ans2=comb(m,2)

if n<=1:
    ans1=0
if m<=1:
    ans2=0

print(ans1+ans2)

Solution (Python):
from math import factorial
def ncr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)

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





if m < 2 :
    if n < 2:
        print(0)
    else:
        print(ncr(n,2))
else:
    if n < 2:
        print(ncr(m,2))
    else:
        print(ncr(n,2)+ncr(m,2))

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

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

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

def aPb(a,b):
    x = a
    for i in range(b-1):
        x *= (a-1-i)
    return x

print(int((aPb(n,2) + aPb(m,2))/2))

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

Solution (Python):
s1 = 0
s2 = 0
n,m = map(int,input().split())
for i in range(1,n):
  s1 += i
for i in range(1,m):
  s2 += i
s = s1 + s2
print(s)

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

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

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

Solution (Python):
def nCr(n, r):
    return (fact(n) / (fact(r)* fact(n - r)))

def fact(n):
    res = 1
    if n == 0:
        res == 1
    elif n == 1:
        res == 1
    else:
        for i in range(2, n + 1):
            res = res * i

    return res

inList = list(map(int, input().split()))
N = inList[0]
M = inList[1]
a = nCr(N, 2)
b = nCr(M, 2)
if N == M == 1:
    print(0)
else:
    print(int(a+b))

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

N -= 1
M -= 1

print(((N * (N + 1))//2 if N > 0 else 0) + ((M * (M + 1))//2 if M > 0 else 0))

Solution (Python):
import sys
import math
import collections
from collections import deque

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



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

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

print(a+b)

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

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

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

a = cmb(N+M, 2)
print(a-N*M)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    n = 1
    m = 1
    for i in range(N, N-2, -1):
        n *= i
    for i in range(M, M-2, -1):
        m *= i
    print((n + m) // 2)

if __name__ == '__main__':
    main()

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

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

if n >= 2:
	a = combinations_count(n,2)
else:
    a = 0
    
if m >= 2:
	b = combinations_count(m,2)
else:
    b = 0

print(a+b)

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

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

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

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())
a = 0
b = 0
if n > 1:
  a = cmb(n, 2)  
if m > 1:
  b = cmb(m,2)
print(a+b)

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

nums = map(int,input().split())

ans=0
for n in nums:
    if n<2:
    	continue
    ans+=math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
print(ans)

Solution (Python):
elms = input().split(" ")

N= int(elms[0])
M= int(elms[1])


ev =N * (N-1)
ev= ev/2 

od = M*(M-1)
od = od/2

print(int(ev+od))

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

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

if __name__ == '__main__':
    main()

Solution (Python):
from itertools import combinations

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

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

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

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

Solution (Python):
import math

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

s = 0
if n > 1:
    s = math.factorial(n)/math.factorial(n-2)
if m > 1:
    s += math.factorial(m)/math.factorial(m-2)
print(int(s/2))

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

print(len(list(combinations(range(N),2)))+len(list(combinations(range(M),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))/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())

ansA = 0

if N < 2 and M < 2:
    ansA = 0
if N >=2:
    ansA += ((N * (N-1)) / 2)
if M >= 2:
    ansA += ((M * (M-1)) / 2)

print(int(ansA))

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

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

Solution (Python):
import math

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

gusu = 0
kisu = 0

if N >= 2:
    gusu = math.factorial(N) / ( math.factorial(N - 2) * 2 )

if M >= 2:
    kisu = math.factorial(M) / ( math.factorial(M - 2) * 2 )

print(int(gusu + kisu))

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

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

import itertools
nl=[]
ml=[]
for n in range(1,N+1):
    nl.append(n)
for m in range(1,M+1):
    ml.append(m)
nnum=len(list(itertools.combinations(nl,2)))
mnum=len(list(itertools.combinations(ml,2)))
res=nnum+mnum
print(res)

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

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

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

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

def ncr(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
  
m, n = map(int, input().strip().split())
print((ncr(m, 2) if m >=2 else 0) + (ncr(n, 2) if n >= 2 else 0))

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

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

Solution (Python):
import itertools
import math


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


temp_n = combinations_count(n+m,2)
    
print(temp_n - (n*m))

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

Solution (Python):
from scipy.misc import comb
n, m = [int(x) for x in input().split()]



print(int(comb(n, 2, exact=True) + comb(m, 2, exact=True)))

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

from math import factorial
if N > 1:
    a = factorial(N) // factorial(2) // factorial(N - 2)
else:
    a = 0

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

print(a + b)

Solution (Python):
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    even = (N * (N - 1)) // 2
    odd = 0 if M == 1 else (M * (M - 1)) // 2
    print(even + odd)


if __name__ == '__main__':
    main()

Solution (Python):
import itertools
import numpy as np

def main():
    n, m = map(int, input().split(" "))
    ans = 0
    for i in [n, m]:
        iterable = np.arange(start=1, stop=i+1, step=1).astype("str")
        ans += len(list(itertools.combinations(iterable, 2)))


    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def comb(a, r):
    if a <= 1:
        return 0
    from math import factorial
    return factorial(a) / factorial(r) / factorial(a - r)

n, m = (int(each) for each in input().split(' '))

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

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

a = 0
for i in range(N):
    a += i

b=0
for j in range(M):
    b += j

print(a+b)

Solution (Python):
import itertools
nm = list(map(int, input().split()))
print(len(list(itertools.combinations(range(nm[0]),2))) + len(list(itertools.combinations(range(nm[1]),2))))

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

if n <= 1:
  n_even = 0
else:
  n_even = n * (n-1) / 2
if m <= 1:
  m_even = 0
else:
  m_even = m * (m-1) / 2

even = n_even + m_even
print(int(even))

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

nums = [(i+1) * 2 for i in range(n)] + [(i * 2) + 1 for i in range(m)]

ans = 0
for i in range(len(nums)):
    for j in range(i):
        if (nums[i] + nums[j]) % 2 == 0:
            ans += 1
print(ans)

Solution (Python):
from itertools import combinations

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

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

Solution (Python):
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
  
n,m =map(int, input().split())
if n==m==1:
    print(0)
elif n==1 or n==0:
    print(cmb(m,2))
elif m==1 or m==0:
    print(cmb(n,2))
else:
    print(cmb(n,2)+cmb(m,2))

Solution (Python):
import math
import sys

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

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

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

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

Solution (Python):

import collections
import itertools as it
import math
import numpy as np

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



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





cN = 0
cM = 0
if N == 0:
    cN = 0
elif N == 1:
    cN == 1
else:
    cN = permutations_count(N, 2)

if M == 0:
    cM = 0
elif M == 1:
    cM == 1
else:
    cM = permutations_count(M, 2)

print(cN + cM)

Solution (Python):
from scipy.misc import comb
N,M = map(int,input().split())
even = comb(N,2,exact=True)
odd = comb(M,2,exact=True)
print(even + odd)

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

import math

if n >= 2:
    cn = math.factorial(n) / math.factorial(2) / math.factorial(n - 2)
else:
    cn = 0
if m >= 2:
    cm = math.factorial(m) / math.factorial(2) / math.factorial(m - 2)
else:
    cm = 0

print(int(cn + cm))

Solution (Python):
import math

inp = list(map(int,input().split()))
N,M = inp
r1 = math.factorial(2)
if N > 1:
    N1 = math.factorial(N)
    Nr1 = math.factorial(N-2)
    a = N1/r1/Nr1
else:
    a = 0

if M > 1:
    M1 = math.factorial(M)
    Mr1 = math.factorial(M-2)
    b =M1/r1/Mr1
else:
    b = 0

kai = a + b
print(int(kai))

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

if n < 2 and m < 2:
    print("0")
elif n < 2 and m >= 2:
    ans = 0
    for i in range(m):
        ans = ans + (i)
    print(ans)
elif n >= 2 and m < 2:
    ans = 0
    for i in range(n):
        ans = ans + (i)
    print(ans)
elif n >= 2 and m >= 2:
    ans = 0
    for i in range(n):
        ans = ans + (i)
    for i in range(m):
        ans = ans + (i)
    print(ans)

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

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

Solution (Python):
S = 0
P = 0
N,M = map(int,input().split())
if N == 0:
    S = 0
else:
    for i in range(1,N):
        S += i
if M == 0:
    P = 0
else:
    for i in range(1,M):
        P += i
print(S+P)

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

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

ans = fn(n) + fn(m)
print(ans)

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

def c(x):
  if x <= 1:
    r = 0
  else:
    r = int((x * (x-1))/2)
  return r

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

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

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

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

Solution (Python):
from math import factorial


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

N, M = list(map(int, input().split(' ')))
N_combinations = combinations_count(N, 2)
M_combinations = combinations_count(M, 2)

print(N_combinations +  M_combinations)

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

c = 0

li = []
for i in range(n):
    li.append(2)
for i in range(m):
    li.append(1)


for i in itertools.combinations(li, 2):
    sum = i[0]+i[1]

    if(sum %2 == 0):
        c += 1
    

print(c)

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

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

if nm[0]<=1 and nm[1]<=1:
    print(0)
else:
    print(int((nm[0]*(nm[0]-1))/2*1+(nm[1]*(nm[1]-1))/2*1))

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

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

N, M = map(int, input().split(' '))
if (N >= 2) & (M >=2):
	print(cmb(N, 2) + cmb(M, 2))
elif (N < 2) & (M >=2):
	print(cmb(M, 2))
elif (M < 2) & (N >= 2):
	print(cmb(N, 2))
else:
    print(0)

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

print(count+countt)

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

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

Solution (Python):
import math

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

if (n < 2) and (m < 2):
    tn = tm = 0
elif (n >= 2) and (m < 2):
    tn = math.factorial(n) // (math.factorial(n - 2)*2)
    tm = 0
elif (m >= 2) and (n < 2):
    tn = 0 
    tm = math.factorial(m) // (math.factorial(m - 2)*2)
else:
    tn = math.factorial(n) // (math.factorial(n - 2)*2)
    tm = math.factorial(m) // (math.factorial(m - 2)*2)

print(tn+tm)

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

Solution (Python):
import math

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

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

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

from math import factorial

cn = 0
cm = 0

if n >= 2:
    cn = factorial(n) // (factorial(n - 2) * factorial(2))

if m >= 2:
    cm = factorial(m) // (factorial(m - 2) * factorial(2))

print(int(cn+cm))

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):
a = list(map(int,input().split()))
b = a[0]+a[1]

c = ((a[0]*(a[0]-1))+(a[1]*(a[1]-1)))/2
print(int(c))

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

Solution (Python):

from math import factorial

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

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

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

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

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

else:
    sum_n = 0

print(sum_n)

Solution (Python):
import math

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

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

if(N==0 and M==0):
  print("0")
elif(N==0 and M==1):
  print("0")
elif(N==1 and M==1):
  print("0")
elif(M==0 or M==1):
  print(com(N, 2))
elif(N==0):
  print(com(M, 2))
else:
  print(com(N, 2) + com(M, 2))

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

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

Solution (Python):
from sys import stdin

def main():

    input = stdin.readline

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

    ans = 0

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

    print(ans)


def comb(n,k):
    min_k = min(k,n-k)

    if n < 2:
        return 0

    n_kaijyo = 1
    k_kaijyo = 1
    for i in range(min_k):
        n_kaijyo = n_kaijyo * (n - i)
        k_kaijyo = k_kaijyo * (i + 1)

    result = int(n_kaijyo / k_kaijyo)
    return result
    
if __name__ == "__main__":
    main()

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

nn = [1 for i in range(n)]
mm = [2 for i in range(m)]

nn.extend(mm)

res = 0
for i in range(n+m):
    for j in range(i+1, n+m):
        if (nn[i] + nn[j]) % 2 ==0:
            res = res + 1
        
print(res)

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

if N % 2 == 0:
    sum_a = (N/2) * (N-1)
else:
    sum_a = N * ((N-1)/2)

if M % 2 == 0:
    sum_b = (M/2) * (M-1)
else:
    sum_b = M * ((M-1)/2)

sum = sum_a + sum_b

print(int(sum))

Solution (Python):
import math

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

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

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

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

print(num)

Solution (Python):
import itertools,sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
N, M = I()
x = itertools.combinations
print(len(list(x(range(N), 2))) + len(list(x(range(M), 2))))

Solution (Python):
import math

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


ans_n = 0
if n <= 1:
    ans_n = 0
else:
    ans_n = math.factorial(n)//(math.factorial(n-2)*math.factorial(2))

ans_m = 0
if m <= 1:
    ans_m = 0
else:
    ans_m = math.factorial(m)//(math.factorial(m-2)*math.factorial(2))
print(ans_n+ans_m)

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

def rc2(i):
  if i<2:
    return 0
  return (i*(i-1))//2
print(rc2(n)+rc2(m))

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

Solution (Python):
import math


n, m = map(int, input().split())
c  = 0 if n <= 1 else math.factorial(n)//(2*math.factorial(n-2))
c += 0 if m <= 1 else math.factorial(m)//(2*math.factorial(m-2))
print(c)

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

a=0 
b=0


if n==0 or n==1: a==0
else :a=(n*(n-1))/2

if m==0 or m==1: b==0
else :b=(m*(m-1))/2

print(int(a+b))

Solution (Python):
import itertools as it

if __name__ == "__main__":
    N, M = map(int, input().split())
    n = len(list(it.combinations(["0" for _ in range(N)], 2)))
    m = len(list(it.combinations(["0" for _ in range(M)], 2)))
    print(n+m)

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

Solution (Python):
def n_sum(n):
  x = 1
  ans_sum = 0
  while x <= n:
    ans_sum += x
    x += 1

  return ans_sum


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

new_n = n - 1
new_m = m - 1
print(n_sum(new_n) + n_sum(new_m))

Solution (Python):
import itertools

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

nn = [2 for _ in range(0, n)]
mm = [1 for _ in range(0, m)]
nn.extend(mm)

ans = [True for (a, b) in itertools.combinations(nn, 2) if (a + b) % 2 is 0].__len__()
print(ans)

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:
    if m < 2:
        ans = 0
    else:
        ans = combinations_count(m, 2)
else:
    if m < 2:
        ans = combinations_count(n, 2)
    else:
        ans = combinations_count(n, 2) + combinations_count(m, 2)
print(ans)

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

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

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

    return numerator // denominator

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

Solution (Python):
t = input().split()

N = int(t[0])
M = int(t[1])

A = (N * (N -1)) // 2
B = (M * (M -1)) // 2


ans = A + B
print(ans)

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

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())
al = N + M
souwa = al*(al - 1)/2
ki = N * M
gu = int(souwa - ki)
print(gu)

Solution (Python):


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

def npr(n, r):
    a = 1
    while r != 0:
        a *= n
        n -= 1
        r -= 1
    return a

def ncr(n, r):
    return npr(n, r) // npr(r, r)

print ncr(n, 2) + ncr(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())
counter = 0

counter += N*(N-1)/2

counter += M*(M-1)/2
print(int(counter))

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 N <= 1:
    print(0) if M <= 1 else print(N + comb(M, 2))
elif M <= 1:
    print(comb(N, 2))
else:
    print(comb(N, 2) + comb(M, 2))

Solution (Python):
import itertools

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

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

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

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

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 main():
    n, m = na()
    if n <= 1 and m <= 1:
        print(0)
    elif n <= 1:
        print(cmb(m, 2))
    elif m <= 1:
        print(cmb(n, 2))
    else:
        print(cmb(n, 2) + cmb(m, 2))

if __name__ == '__main__':
    main()

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N == 1 or N == 0:
    a = 0
else:
    a = cmb(N,2)
if M == 1 or M == 0:
    b = 0
else:
    b = cmb(M,2)
print(a+b)

Solution (Python):
import math
def nCr(n,r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n-r) if n>1 else 0
N,M=list(map(int,input().split(' ')))
print(int(nCr(N,2)+nCr(M,2)))

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

ball_numbers = [2 * i for i in range(N)]
ball_numbers.extend([2 * i + 1 for i in range(M)])

count = 0
for i, num1 in enumerate(ball_numbers):
    for j, num2 in enumerate(ball_numbers):
        if i == j:
            continue
        if (num1 + num2) % 2 == 0:
            count += 1
print(count // 2)