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):
a = [int(i) for i in input().split()]

x= a[0] * (a[0]-1) * (1/2)

x+= a[1] * (a[1]-1) * (1/2)

print(int(x))

Solution (Python):
import itertools


def pattern_sum_is_even_number(input_n, input_m):
    even_num = [i*2 for i in range(1, input_n+1)]
    odd_num = [i*2+1 for i in range(1, input_m+1)]

    even_num.extend(odd_num)
    all_num_combination = itertools.combinations(even_num, 2)
    sum_is_even_combinations = 0
    for n in all_num_combination:
        if (n[0] + n[1]) % 2 == 0:
            sum_is_even_combinations += 1
    return sum_is_even_combinations


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(pattern_sum_is_even_number(n, m))

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

ans = 0
for i in range(N):
    ans += i
if M == 1:
  pass
  
  
    
    
else:
  for _ in range(M):
      ans += _

print(ans)

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

def fact(n): 
	res = 1
	for i in range(2, n+1): 
		res = res * i 		
	return res 

n,m=map(int,input().split())
if(n==1 and m!=1):
  print(nCr(m,2))
elif(n!=1 and m==1):
  print(nCr(n,2))
elif(n==1 and m==1):
  print("0")
else:
  print(int(nCr(n,2)+nCr(m,2)))

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

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


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

Solution (Python):
def comb(x):
    return x*(x-1)/2

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

Solution (Python):

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """
    if n<r:
        return 0
    
    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


N,M=acinput()

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

Solution (Python):
import math
n = input().split(' ')
s = [int(s) for s in n]
def combination(x):
    if x >= 2:
        return math.factorial(x) // (math.factorial(x - 2) * math.factorial(2))
    else:
        return 0
print(combination(s[0]) + combination(s[1]))

Solution (Python):
import math
N, M = map(int, input().split())
if N > 2:
    ans_N = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))
    if M > 2:
        ans_M = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
        print(ans_N + ans_M)
    elif M == 2:
        print(ans_N + 1)
    elif M < 2:
        print(ans_N)
elif N == 2:
    if M > 2:
        ans_M = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
        print(1 + ans_M)
    elif M == 2:
        print(1 + 1)
    elif M < 2:
        print(1 + 0)
elif N < 2:
    if M > 2:
        ans_M = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
        print(0 + ans_M)
    elif M == 2:
        print(0 + 1)
    elif M < 2:
        print(0 + 0)

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

o=1
while o<=m*2:
    if o%2!=0:
        l.append(o)

    o+=2


e=2
while e<=n*2:
    if e%2==0:
        l.append(e)

    e+=2


re=0


for i in range(0,len(l)):
    j=i+1
    while j<len(l):
        s=l[i]+l[j]
        if s%2==0:
            re+=1
            

        j+=1

print(re)

Solution (Python):
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, m = I()
print(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())
N=cmb(n,2)
M=cmb(m,2)
if n == 0:
    print(M)
    exit()
elif m == 0:
    print(N)
    exit()
if n == 1 and m != 1:
    print(M)
elif m == 1 and n != 1:
    print(N)
elif m == 1 and n == 1:
    print(0)
else:
    print(cmb(n,2)+cmb(m,2))

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

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

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

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

Solution (Python):
import math

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

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


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

Solution (Python):

import itertools

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

ansN = len(list(itertools.combinations(range(N), 2)))
ansM = len(list(itertools.combinations(range(M), 2)))

ans = ansN + ansM
print(ans)

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

cnt_even = (N*(N-1))/2
cnt_odd = (M*(M-1))/2
cnt = int(cnt_even + cnt_odd)

print(cnt)

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

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

if n == 1 and m == 1:
    print(0)
    exit()


if n > 2:
    ans1 = factorial(n) / factorial(2) / factorial(n - 2)
elif n == 2:
    ans1 = 1
elif n <= 1:
    ans1 = 0


if m > 2:
    ans2 = factorial(m) / factorial(2) / factorial(m - 2)
elif m == 2:
    ans2 = 1
elif m <= 1:
    ans2 = 0

print(int(ans1 + ans2))

Solution (Python):
import math


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

ans_N=0
ans_M=0
if N != 0:
	ans_N=(N*(N-1))//2
if M != 0:
	ans_M=(M*(M-1))//2

print(ans_N+ans_M)

Solution (Python):
import math

data = input()
data = data.split()
n = data[0]
m = data[1]
v1 = 0
v2 = 0

if int(n) > 1:
	v1 = (math.factorial(int(n)) // (math.factorial(int(n) - 2) * math.factorial(2)))

if int(m) > 1:
    v2 = (math.factorial(int(m)) // (math.factorial(int(m) - 2) * math.factorial(2)))

print(v1+v2)

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

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

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

Solution (Python):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

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

Solution (Python):
from math import factorial

x,y=map(int,input().split())
if x>1:
    a = factorial(x) / factorial(2) / factorial(x - 2)
else: a=0
if y>1:
    b = factorial(y) / factorial(2) / factorial(y - 2)
else: b=0
print(int(a+b))

Solution (Python):
from itertools import combinations

N, M = [int(n) for n in input().split()]
print(len([c for c in combinations(range(N), 2)])+len([c for c in combinations(range(M), 2)]))

Solution (Python):
guusuu, kisuu = map(int, input().split())
guusuuhairetu = [i for i in range(2, guusuu * 2 + 1, 2)]
kisuuhairetu = [i for i in range(1, kisuu * 2, 2)]
count = 0
haiiretu = guusuuhairetu + kisuuhairetu
hairetu2 = guusuuhairetu + kisuuhairetu
for i in hairetu2:
    haiiretu.remove(i)
    for u in haiiretu:
        if (i + u) % 2 == 0:
            count += 1
print(count)

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

Solution (Python):
def cmb(n, r):
    if n < r:
        return 0
    a = 1
    for i in range(n, n - r, -1):
        a *= i
    b = 1
    for i in range(1, r + 1):
        b *= i
    return int(a / b)


N, M = [int(i) for i in input().split()]
ans = cmb(N, 2) + cmb(M, 2)

print(ans)

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

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

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

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

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

if m > 1:
    for i in range(1,m):
        ans += i
    
print(ans)

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

Solution (Python):

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

Solution (Python):
import math
N,M=map(int, input().split())
cnt=0
if math.factorial(N)!=1:
  cnt+=math.factorial(N)//(2*math.factorial((N-2)))

if math.factorial(M)!=1:
  cnt+=math.factorial(M)//(2*math.factorial((M-2)))

print(cnt)

Solution (Python):
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

def re(n):
  if n < 2:
    return 1
  return n*re(n-1)

def c(n,r):
  return re(n)//re(n-r)//2

a,b = miinps()

ans = 0

ans += c(a,2)
ans += c(b,2)

print(ans)

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

Solution (Python):
k=0
import math
def combinations_count(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a,b=map(int,input().split())
if b<2:
    if b==1:
        j=0
    else:
        j=b
else:
    j=combinations_count(b, 2)
for i in range(a):
    k=k+i
h=j+k
print(h)

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

Solution (Python):

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

ans_n = 0
if(N < 2):
  ans_n = 0
else:
  for i in range(N-1):
    ans_n = (i+1) + ans_n
    
  
ans_m = 0
if(M < 2):
  ans_m = 0
else:
  for i in range(M-1):
    ans_m = (i+1) + ans_m
    
  
print(ans_n+ans_m)

Solution (Python):
n, m = [int(w) for w in input().split()]

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

print(odd + even)

Solution (Python):
from itertools import combinations

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

def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    
    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 and not M <= 1:
    print(nCr(M,2))
elif not N <= 1 and M <= 1:
    print(nCr(N,2))
else:
    print(nCr(N, 2) + nCr(M,2))

Solution (Python):
from itertools import combinations
MOD = 10**9+7
nn, m = map(int, input().split())
def nCr(n, r, mod):
	r = min(r, n-r)
	numer = denom = 1
	for i in range(1, r+1):
		numer = numer * (n+1-i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod-2, mod) % mod
ansn = 0
if nn < 2:
	ansn = 0
else:
	ansn = nCr(nn,2,MOD)
if m < 2:
	ansm = 0
else:
	ansm = nCr(m,2,MOD)

print (ansn + ansm)

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

odd = [i for i in range(1, M*2+2, 2)]
even = [i for i in range(2, N*2+2, 2)]

for k in range(M):
  ans = ans + k

for g in range(N):
  ans = ans + g
print(ans)

Solution (Python):

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


if N >= 2:
    N_even = N*(N - 1)/2
else:
    N_even = 0

if M >= 2:
    M_even = M*(M-1)/2
else:
    M_even = 0

print(int(N_even + M_even))

Solution (Python):
import itertools
n,m = map(int,input().split())
o = 0
o += len(list(itertools.permutations([i for i in range(n)], 2)))/2
o += len(list(itertools.permutations([i for i in range(m)], 2)))/2
print(int(o))

Solution (Python):
import math

def resolve():

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

    nc=0
    mc=0
    if n >=2:
        nc=math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
    if m>=2:
        mc=math.factorial(m) // (math.factorial(m - 2) * math.factorial(2))

    print(nc+mc)

resolve()

Solution (Python):
import math


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

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

total = nCr(N,2) + nCr(M,2)

print(total)

Solution (Python):
N,M=[int(x) for x in input().rstrip().split()]
l_n=[]
l_m=[]


if N!=0:
  for i in range(1,N+1):
    l_n.append(i*2)
else:
  l_n.append(0)


if M!=0:
  now=1
  for i in range(M):
    l_m.append(now)
    now+=2
else:
  l_m.append(0)

now_n=0
now_m=0
cnt=0


if N==0 and M==0:
  print(0)
else:
  for i in range(len(l_n)):
    for j in range(len(l_n)):
      if i<j:
        now_n=l_n[i]+l_n[j]
        if now_n%2==0:
          cnt+=1


if N==0 and M==0:
  print(0)
else:
  for i in range(len(l_m)):
    for j in range(len(l_m)):
      if i<j:
        now_m=l_m[i]+l_m[j]
        if now_m%2==0:
          cnt+=1
  print(cnt)

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

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

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

l_n = [i for i in range(1, n+1)]
l_m = [i for i in range(1, m+1)]


print(len([k * j for i, k in enumerate(l_n) for j in l_n[i + 1:]]) 
    + len([k * j for i, k in enumerate(l_m) for j in l_m[i + 1:]]))

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

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

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

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

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

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


if __name__ == '__main__':
    solver()

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

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

Solution (Python):
import math
def cmb(n, r):
    if n<2:
        return 0

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    import sys
    N,M=list(map(int,sys.stdin.readline().split()))
    print(cmb(M,2)+cmb(N,2))


main()

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

Solution (Python):
import itertools
n, m = [int(i) for i in input().split()]
a = []
num = 1
for i in range(1, n+1):
  a.append(i*2)
for i in range(1, m+1):
  a.append(num)
  num = num + 2
c = []
c = list(itertools.combinations(a, 2))
goukei = 0
for i in range(len(c)):
  if sum(c[i]) % 2 == 0:
    goukei += 1
print(goukei)

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

Solution (Python):
import numpy as np

NM=np.array(input().split(" "),dtype=np.int64)

N=NM[0]
M=NM[1]

result=0

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

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

print(int(result))

Solution (Python):
import itertools
n,m  = map(int, input().split())
l = list()
ans = 0

for i in range(n):
  l.append(2)
for i in range(m):
  l.append(1)

for v in itertools.combinations(l, 2):
  if sum(v)%2 == 0:
    ans += 1

print(ans)

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

Solution (Python):
import itertools
N,M=map(int,input().split())
c=0
for (a,b) in itertools.combinations(list(range(2,201,2))[:N]+list(range(1,200,2))[:M],2):
    c += 1 if (a+b)%2==0 else 0
print(c)

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

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

Solution (Python):
from math import factorial
N,M = map(int,input().split())
if N <= 1:
    n_count = 0
else:
    n_count = factorial(N) / factorial(2) / factorial(N-2)
if M <= 1: 
    m_count = 0
else:
    m_count = factorial(M) / factorial(2) / factorial(M-2)



print(int(n_count+m_count))