Problem:
 Score : 100 points    Problem Statement  We have N+M balls, each of which has an integer written on it. It is known that:   The numbers written on N of the balls are even.  The numbers written on M of the balls are odd.   Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It can be shown that this count does not depend on the actual values written on the balls.      Constraints   0 \leq N,M \leq 100  2 \leq N+M  All values in input are integers.         Input  Input is given from Standard Input in the following format:  N  M       Output  Print the answer.        Sample Input 1 2 1      Sample Output 1 1  For example, let us assume that the numbers written on the three balls are 1,2,4 .   If we choose the two balls with 1 and 2 , the sum is odd;  If we choose the two balls with 1 and 4 , the sum is odd;  If we choose the two balls with 2 and 4 , the sum is even.   Thus, the answer is 1 .       Sample Input 2 4 3      Sample Output 2 9       Sample Input 3 1 1      Sample Output 3 0       Sample Input 4 13 3      Sample Output 4 81       Sample Input 5 0 3      Sample Output 5 3

Solution (Python):



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

def factrial(n):
    a = 0
    for i in range(1, n+1):
        a += i
    return a

nf = 0 if n < 2 else int(factrial(n - 1))
mf = 0 if m < 2 else int(factrial(m - 1))

print(nf + mf)

Solution (Python):

"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""

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

Solution (Python):
import itertools

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

list_num = [1] * M
list_2 = [2] * N

list_num.extend(list_2)

count = 0
for c in list(itertools.combinations(list_num, 2)):
    wa = sum(c)
    if wa == 2 or wa == 4:
        count += 1
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()) 
Count=0
if N>0:
  Count=N*(N-1)//2
if M>0:
  Count=Count+M*(M-1)//2
print(Count)

Solution (Python):
data = input().split(" ")
N = int(data[0])
M = int(data[1])
answer = 0

if N == 0:
  answer = (M*(M-1))/2
elif M == 0:
  answer = (N*(N-1))/2
else:
  mth1 = (N*(N-1))/2
  mth2 = (M*(M-1))/2
  answer = mth1 + mth2
print(int(answer))

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



sum = m + n
gu = [2] * n
ki = [1] * m

num1 = list(itertools.combinations(gu,2))
num2 = list(itertools.combinations(ki,2))
result = int(len(num1)) + int(len(num2))
print(result)

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

ar = [0] * n + [1] * m
for s in range(len(ar)):
    for a in range(s + 1, n + m):
        if (ar[s] + ar[a]) % 2 == 0:
            ans += 1

print(ans)

Solution (Python):
import math

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


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


if N <= 1 and M <= 1:
    print(0)
elif N <= 1:
    print(combinations_count(M))
elif M <= 1:
    print(combinations_count(N))
else:
    print(combinations_count(N) + combinations_count(M))

Solution (Python):
from math import factorial
n, m = map(int, input().split())
x = 0
y = 0
if n >= 2:
    x = factorial(n) / factorial(2) / factorial(n - 2)

if m >= 2:
    y = factorial(m) / factorial(2) / factorial(m - 2)

print(int(x+y))

Solution (Python):
M,N=map(int,input().split())
def fact(n):
	s=1
	for i in range(2,n+1):
		s=s*i
	return s

def conb(n,r):
	return fact(n)//(fact(r)*fact(n-r))

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

Solution (Python):
import math
n,m = map(int, input().split())
e = 0
o = 0
f = math.factorial
if n>=2:
    e = f(n) / f(n-2) / 2
if m>=2:
    o = f(m) / f(m-2) / 2

print(int(e+o))

Solution (Python):
import math
import sys

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

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

if n == 1 and m == 1:
  print('0')
  sys.exit()
  
if n <= 1:
  print(comb(m, 2))
  sys.exit()
  
if m <=1:
  print(comb(n, 2))
  sys.exit()

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

Solution (Python):
e,o=map(int,input().split())
sum1=0
sum2=0

if e>=2:
  sum1=e*(e-1)/2

if o>=2:
  sum2=o*(o-1)/2

print(int(sum1+sum2))

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

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

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

Solution (Python):
from math import factorial


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

    C = factorial(N + M) // (factorial((N + M) - 2) * factorial(2))
    print(C - N * M)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
import math

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

result = 0

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

print(int(result))

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

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

Solution (Python):
import math

NS = [int(_) for _ in input().split()]
N = NS[0] 
M = NS[1] 

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

def solve(N, M):
    
    return combinations_count(N+M, 2) - M * N

print(solve(N, M))

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

def comb(n, r):
    if r == 0 or r == n:
        return 1
    elif r == 1:
        return n
    else:
        return (comb(n - 1, r - 1) + comb(n - 1, r))

if n >= 2:
    count += comb(n, 2)

if m >= 2:
    count += comb(m, 2)

print(count)

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


if __name__ == '__main__':
    main()

Solution (Python):



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




count = 0
for i in range(n + m):
    for j in range(n + m):
        if i == j:
            continue
        
        
        if i < n and j < n:
            count += 1
        if i >= n and j >= n:
            count += 1
        

print(count // 2)

Solution (Python):
from operator import mul
from functools import reduce
def main():
    n, m = map(int, input().split())
    fromN = 0
    fromM = 0
    if n > 1:
        fromN = cmb(n, 2)
    
    if m > 1:
        fromM = cmb(m, 2)
    
    print(fromN + fromM)
    return 


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 __name__ == '__main__':
    main()

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 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):
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 50010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()
ans = ncr(n,2)+ncr(m,2)
print(ans)

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


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

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

Solution (Python):
import math

A = input().split()

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

x = int(A[0])
y = int(A[1])

if x > 1 and y > 1:
  print(combinations_count(x, 2) + combinations_count(y, 2))
else:
  if x > 1 and y <= 1:
    print(combinations_count(x, 2))
  else:
    if x <= 1 and y > 1:
      print(combinations_count(y, 2))
    else:
      print(0)

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

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

if N == int(0):
    print(int(M*(M-1)/2))
elif M == int(0):
    print(int(N*(N-1)/2))
else:
    print(int(N*(N-1)/2 + M*(M-1)/2))

Solution (Python):
def inputs(): return [int(x) for x in input().split()]
from collections import defaultdict

n,m= inputs()
a = (n*(n-1))//2
b = (m*(m-1))//2
print(a+b)

Solution (Python):


import math

def main():
    n, m = map(int, input().split())
    
    if n >= 2 and m >= 2:
        even = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))
        odd = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))
    elif m >= 2:
        even = 0
        odd = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))
    elif n >= 2:
        even = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))
        odd = 0
    else:
        even = 0
        odd = 0

    print(even + odd)

if __name__ == '__main__':
    main()

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

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

if M >= 2:
    ans += math.factorial(M)/(2*math.factorial(M-2))
print(int(ans))

Solution (Python):

import sys
from itertools import combinations
def solve(N: int, M: int):
    n=[]
    m=[]
    for i in range(N):
        n.append(i)
    for i in range(M):
        m.append(i)
    o=len(list(set(list(combinations(n,2)))))
    i=len(list(set(list(combinations(m,2)))))
    print(o+i)
    return



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

if __name__ == '__main__':
    main()

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

n = '2'*N
m = '1'*M
l = list(n + m)

ans = 0

for x in itertools.combinations(l, 2):
  xx = int(x[0]) + int(x[1])
  if xx%2==0:
    ans += 1
print(ans)

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

Solution (Python):
import sys
import collections
import heapq
import math
n,m = map(int,sys.stdin.readline().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(max(n - r,0)) * math.factorial(r))
print(combinations_count(n,2)+combinations_count(m,2))

Solution (Python):



def nC2(x):
    if x == 1 or x == 0:
        return 0
    else:
        return x * (x - 1) // 2

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

result = nC2(N) + nC2(M)
print(result)

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

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

result=sum([i for i in range(0,N)])+sum([i for i in range(0,M)])

print(result)

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 == 0:
    base1 = 0
elif n == 1:
    base1 = 0
else:
    base1 = comb(n,2)

if m == 0:
    base2 = 0
elif m == 1:
    base2 = 0
else:
    base2 = comb(m,2)

print(base1 + base2)

Solution (Python):
import math
import itertools as it


i = input().split()



n = int(i[0])
m = int(i[1])
nc = it.combinations(range(n),2)
mc = it.combinations(range(m),2)

print(len(list(nc) + list(mc)))

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

Solution (Python):


def c(n):
    return n*(n-1)//2

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

ans = c(n) + c(m)

print(ans)

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

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

n = int(n)
m = int(m)
j = 0
for i in range(1, n):
  j += i
  
for i in range(1, m):
  j += i
  
print(j)

Solution (Python):


N, M = map(int, input().split())
A = [0 for _ in range(N)]
B = [1 for _ in range(M)]
X = A + B

ans = 0
for i in range(N + M):
    for j in range(i + 1, N + M):
        if (X[i] + X[j]) % 2 == 0:
            ans += 1


print(ans)

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 <= 1 and M>=2:
  print(combinations_count(M,2))

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

Solution (Python):
import math as m1

def ncr(n1,n2):
  f= m1.factorial
  ans = f(n1)//(f(n1-n2)*f(n2))
  return ans

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

res =0
if n<2:
  res+=0
if m<2:
  res+=0
if n>=2:
  res+=ncr(n,2)
if m>=2:
  res+=ncr(m,2)
  
print(res)

Solution (Python):
import sys

input = sys.stdin.readline


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


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


if __name__ == '__main__':
    main()

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

def combi(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>=2:
    print(int(combi(N,2))+int(combi(M,2)))
elif N>=2 and M<=1:
    print(int(combi(N,2)))
elif N<=1 and M>=2:
    print(int(combi(M,2)))

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 <= 1 and m >= 2:
  print(combinations_count(m,2))
elif n >= 2 and m <= 1:
  print(combinations_count(n,2))
else:
  print(combinations_count(n,2)+combinations_count(m,2))

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

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


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

print(int(m+n))

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

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

Solution (Python):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def main():
  N, M = map(int, input().split())
  if N == 1 and M == 1:
    print(0)
  elif N == 0 or N == 1:
    print(combinations_count(M, 2))
  elif M == 0 or M == 1:
    print(combinations_count(N, 2))
  else:
    print(combinations_count(N, 2) + combinations_count(M, 2))
if __name__ == '__main__':
  	main()

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

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

Solution (Python):
import itertools
n,m = list(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(round((N*(N-1)+M*(M-1))/2))

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

a, b = map(int, input().split())
print(comb(a,2)+comb(b,2))

Solution (Python):
n,m = map(int, input().split(" "))
result = 0
if n > 1:
    for i in range(n):
        result += n-1
        n -= 1
if m > 1:
    for t in range(m):
        result += m-1
        m -= 1
print(result)

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

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())
x, y = 0, 0
for i in range(1, n):
    x += i
for j in range(1, m):
    y += j
print(x + y)

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

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

print(ans)

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

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

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

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

Solution (Python):
a=input().split()
(n,m)=map(int,a)
d=0
d1=0
for i in range(n):
    n-=1
    d=d+n
for j in range(m):
    m-=1
    d1=d1+m
print(d1+d)

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

nsum = 0
for i in range(N-1):
	nsum += i+1
msum = 0
for i in range(M-1):
	msum += i+1
print(nsum + msum)

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

Solution (Python):
import itertools
import math

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

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

ans = 0
if N == 0 or N ==1:
    ans +=0
else:
    ans +=combinations_count(N, 2)

if M == 0 or M ==1:
    ans +=0
else:
    ans +=combinations_count(M, 2)

    
print(ans)

Solution (Python):
def comb(a, r = 2):
    if a < 2:
        return 0
    return a * (a - 1) // 2
def solve():
    n, m = map(int, input().split())
    print(comb(n, 2) + comb(m, 2))
solve()

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

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

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

print(ans)

Solution (Python):

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


Ans = 0
for i in range(n - 1):
  Ans += (i + 1)
for i in range(m - 1):
  Ans += (i + 1)


print(Ans)

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

count = 0

if N >= 2:
    count += len(list(itertools.combinations(range(N), 2)))

if Y >= 2:
    count += len(list(itertools.combinations(range(Y), 2)))

print(count)

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

Solution (Python):
s = input().split()
n = int(s[0])
m = int(s[1])

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

Solution (Python):
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]

even_only = 0
odd_only = 0

if n > 1:
    even_only = n * (n - 1) / 2
if m > 1:
    odd_only = m * (m - 1) / 2

result = int(even_only + odd_only)
print(result)

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

def A159():
    N, M = [int(_) for _ in input().split()]
    if N <= 1:
        cn = 0
    else:
        
        cn = combinations_count(N, 2)
    if M <= 1:
        cm = 0
    else:
        cm = combinations_count(M, 2)
    print(cn+cm)

if __name__ == "__main__":
    A159()

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

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

if N >= 2:
	A=nCr(N,2)
else:
	A=0
if M >= 2:
	B=nCr(M,2)
else:
	B=0
print(A+B)

Solution (Python):
from itertools import combinations

n, m = [int(i) for i in input().split()]
c1, c2 = 0, 0
if n != 1:
    c1 = len(list(combinations(list(range(2, n * 2 + 1, 2)), 2)))
if m != 1:
    c2 = len(list(combinations(list(range(1, m * 2 + 1, 2)), 2)))
print(c1 + c2)

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

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

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

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

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

if __name__ == "__main__":
    N,M = list(map(int,input().split()))
    
    if N <= 1:
        Nc = 0
    else:
        Nc = cmb(N,2)
    
    if M < 2:
        Mc = 0
    else:
        Mc = cmb(M,2)
    print(Nc + Mc)

Solution (Python):
import math


def ABC159A(a):
    if a < 2:
        return 0
    else:
        return math.factorial(a)//(math.factorial(a-2)*2)


a,b = map(int, input().split())
print(ABC159A(a)+ABC159A(b))

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

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

    print(ans)

    return

if __name__ == "__main__":
    main()

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

Solution (Python):
import math

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

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

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

print(sum(range(N)) + sum(range(M)))

Solution (Python):

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

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

Solution (Python):
from math import pow
n,m=(int(i) for i in input().split())
if(n==1):
  n=0
if(m==1):
  m=0
print(int(((pow(n,2))+(pow(m,2))-(m+n))//2))

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

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

Solution (Python):
init = [int(s) for s in input().rstrip().split(' ')]
res = (init[0] * (init[0]-1))/2 + (init[1] * (init[1]-1))/2
print(int(res))

Solution (Python):
n,m=(int(x) for x in input().split())

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = int(n_dot+ m_dot)
print(answer)

Solution (Python):
import itertools

N, M = map(int, input().split())
A = [0] * N + [1] * M

ans = 0
for i, j in itertools.combinations(A, 2):
  B = i + j
  if B % 2 == 0:
    ans += 1

print(ans)

Solution (Python):
import math

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

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

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

Solution (Python):
import math 
def ncr(m,n):
    return((math.factorial(m))/((math.factorial(n))*(math.factorial(m-n))))
nm=list(map(int,input().split()))
if(nm[0]<2 and nm[1]>=2):
    print(int(ncr(nm[1],2)))
elif(nm[0]>=2 and nm[1]<2):
    print(int(ncr(nm[0],2)))
elif(nm[0]<2 and nm[1]<2):
    print(0)
else:
    print(int(ncr(nm[0],2)+ncr(nm[1],2)))

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

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

ans = 0

if n > 1:
  if n % 2 != 0:
    ans += n * (n // 2)
  else:
    ans += n * ((n-1) // 2) + n / 2 

if m > 1:
  if m % 2 != 0:
    ans += m * (m // 2)
  else:
    ans += m * ((m-1) // 2) + m / 2

print(int(ans))

Solution (Python):
import math
N, M = map(int, input().split())
if(N>=2):
    n = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))
else:
    n = 0

if(M>=2):
    m = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
else:
    m = 0
print(n+m)

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

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

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

ans = ans1 + ans2
print(ans)

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

n1 = n - 1
m1 = m - 1

res = int((n * n1) / 2 + (m * m1) / 2)

print(res)

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

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

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

n = 0
m = 0
r = 2

if N>1:
    n = combinations_count(N, r)
if M>1:
    m = combinations_count(M, r)

sum = n+m
print(sum)

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

Solution (Python):
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

if N == 1 and M == 1:
  print(0)
else:
  n = 0
  if N != 0:
    for i in range(N-1):
      n += 1+i
  else:
    n = 0
  if M != 0:
    m = (M * (M-1)) / 2
  else:
    m = 0
  print(int(n + m))

Solution (Python):
from math import factorial
def combinations_count(n, r):
    if n <= 1:
        return 0
    else:   
        return factorial(n) // (factorial(n - r) * factorial(r))
N,W = map(int,input().split())
even = combinations_count(N,2)
odd = combinations_count(W,2)
print(odd+even)

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

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

if M < 2 and N < 2:
    print(0)
elif M < 2:
    print(comb(N,2))
elif N < 2:
    print(comb(M,2))
else:
    print(comb(N,2) + comb(M, 2))