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 = list(map(int, input().split(' ')))

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

Solution (Python):
import itertools
n,m=map(int,input().split())
N=[i for i in range(1,n+1)]
M=[i for i in range(1,m+1)]
n_com=itertools.combinations(N,2)
m_com=itertools.combinations(M,2)
print(len(list(n_com))+len(list(m_com)))

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

Solution (Python):
import itertools

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


n = list(itertools.combinations(list(range(N)),2));
m = list(itertools.combinations(list(range(M)),2));

print(len(n) + len(m))

Solution (Python):
import sys


import math

n,m = map(int, input().split())
def c(n):
    return int(math.factorial(n) / math.factorial(n-2) / math.factorial(2))

if n == 1 and m == 1:
    print(0)
elif n <= 1:
    print(c(m))
elif m <= 1:
    print(c(n))
else:
    print(c(n)+c(m))

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

print(int(ans))

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

if N >= 3:
  num = sta(N)/(sta(2)*sta(N-2))
if N == 2:
  num = 1
if N <= 1:
  num = 0

if M >= 3:
  mum = sta(M)/(sta(2)*sta(M-2))
if M == 2:
  mum = 1
if M <= 1:
  mum = 0

print(int(num + mum))

Solution (Python):

def n(N):
    if N == 0 or N == 1:
        return 0
    else:
        return N * (N - 1) / 2


var = [int(s) for s in input().split()]

N=var[0]
M=var[1]

print(int(n(N) + n(M)))

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

Solution (Python):
n,m = map(int,input().split())
a = [0]*n
b = [1]*m
ans = a+b
count = 0
for i in range(0,n+m):
    for j in range(i+1,n+m):
        if (ans[i]+ans[j])%2==0:
            count += 1
print(count)

Solution (Python):

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

if n[0] <= 1 and n[1] <= 1:
    print(0)
else:
    ans = 0
    for i in range(n[0]):
        ans += i
    for i in range(n[1]):
        ans += i
    print(ans)

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

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

ans = 0

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

print(int(ans))

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

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

Solution (Python):
def tmp(n):
    return n * (n - 1) / 2


def main():
    line = input().strip()
    n, m = [int(v) for v in line.split(' ')]

    ans_n = tmp(n) if n > 1 else 0
    ans_m = tmp(m) if m > 1 else 0
    ans = ans_n + ans_m
    print(int(ans))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
from math import factorial as f
x,y=map(int,input().split())
if(x<2):
    a=0
else:
    a=f(x)//(f(x-2)*2)
if(y<2):
    b=0
else:    
    b=f(y)//(f(y-2)*2)
print(a+b)

Solution (Python):
import math

n,m = map(int, input().split())
n_p = 0
if 2 <= n:
    n_p = math.factorial(n) // (2*(math.factorial(n-2)))

m_p = 0
if 2 <= m:
    m_p = math.factorial(m) // (2*(math.factorial(m-2)))

print(n_p + m_p)

Solution (Python):

def calcPair(ballNum):
    if ballNum -1 <= 0:
        return 0
    else:
        return int(ballNum * (ballNum -1) / 2)

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

Solution (Python):
from math import factorial

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

if n > 2 and m > 2:
    print(
        factorial(n) // (factorial(n - 2) * factorial(2))
        + factorial(m) // (factorial(m - 2) * factorial(2))
    )
elif n < 2 and m < 2:
    print(0)
elif n < 2:
    print(factorial(m) // (factorial(m - 2) * factorial(2)))
elif m < 2:
    print(factorial(n) // (factorial(n - 2) * factorial(2)))

Solution (Python):
import sys
import math

n, m = [int(s) for s in sys.stdin.readline().strip().split()]

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

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

n = int(i[0])
m = int(i[1])

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

print(int(p))

Solution (Python):
def comb(n, r):
    nc = n
    for rc in range(1, r):
        nc -= 1
        n = n*nc
        r = r*rc

    return n/r


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



if __name__ == "__main__":
    solve()

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

a = m *( (m-1) )//2
b = n *( (n-1) )//2

print (a + b)

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

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

print(ans)

Solution (Python):
def fac2(n):
    if n < 2:
        return 0
    ans = n * (n-1) //2
    return ans



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

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

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

n_even2 = N * (N-1) / 2
n_odd2 = M * (M-1) / 2

print(int(n_even2+n_odd2))

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

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

b = M * N

print(int(a - b))

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

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

result = 0
if (N < 2 and M < 2):
  result = 0
else:
  a = N*(N-1)//2
  b = M*(M-1)//2
  result = a + b

print(result)

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

print(len(list(combinations(range(n),2))) + len(list(combinations(range(m),2))))

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):
val = input().split(' ')
n = int(val[0])
m = int(val[1])

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

print(int(result))

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

if m >= 2:
    m = int(m * (m-1) / 2)
else:
    m = 0

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 math import factorial

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

comb_n = 0
comb_m = 0

if n > 1:
    comb_n = (factorial(n) // factorial(n - 2)) // factorial(2)

if m > 1:
    comb_m = factorial(m) // factorial(m - 2) // factorial(2)

print(comb_n + comb_m)

Solution (Python):
import itertools
import math

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

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

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

even,odd = map(int,input().split())
if even != 1 or odd != 1:
    numa = cmb(even,2)
    numb = cmb(odd,2)
    if even == 1 or even == 0:
        numa = 0
    if odd == 1 or odd == 0:
        numb = 0
    print(numa+numb)
else:
    print(0)

Solution (Python):

import sys


def solve(N: int, M: int):
    a = 0 if N == 0 else N * (N - 1) / 2
    b = 0 if M == 0 else M * (M - 1) / 2
    print(int(a + b))
    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):
N, M = map(int, input().split(' '))


def main(n, m):
    cnt = 0

    if m <= 1:
        cnt += n * (n - 1) / 2
    else:
        cnt += n * (n - 1) / 2
        cnt += m * (m - 1) / 2

    return int(cnt)


print(main(N, M))

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

sum = 0
sum2 = 0
for i in range(m):
    sum += i

for i in range(n):
    sum2 += i

print(sum + sum2)

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '
        
        
    return ret


MOD = 10**9 + 7

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  

N, M = read_ints()






tmp = [2] * N + [1] * M
ans = 0
for a, b in combinations(tmp, r=2):
    ans += (a + b) % 2 == 0
print(ans)

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

Solution (Python):
import math

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

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

print(n + m)

Solution (Python):
import math

a = [int(x) for x in input().split(" ")]
n = a[0]
m = a[1]
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(ans)

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

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

print(ans)

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

print(ans)

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

N, M = MI()

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

Solution (Python):
import math

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

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

if nums[0] <= 1 and nums[1] <= 1:
  print(0)
elif nums[1] <= 1:
  print(comb(nums[0], 2))
elif nums[0] <= 1:
  print(comb(nums[1], 2))
else:
  print(comb(nums[0], 2) + comb(nums[1], 2))

Solution (Python):
a = list(map(int,input().split()))
n = a[0]
m = a[1]

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

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

Solution (Python):
import math
def f(n):
    if n == 1 or n == 0:
        return 0
    return math.factorial(n) // (2 * math.factorial(n-2)) 
n, m = map(int, input().split())
print(f(n) + f(m))

Solution (Python):
from math import factorial

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
a, b = list(map(int, input().split()))

if a <= 1 and b <= 1:
    print(0)
    exit()
if a < 2:
    result = combinations_count(b,2)
elif b < 2:
    result = combinations_count(a,2)
elif b > 1:
    result = combinations_count(a,2) + combinations_count(b,2)
else:
    result = combinations_count(a,2)
print(result)

Solution (Python):
import math

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

def combinations_count(n, r):

    if n < r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

Solution (Python):

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())
ans = 0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in (n,m):
    if i >= 2:
        ans += combinations_count(i,2)
print(ans)

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

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

print( odd + even )

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

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


if __name__ == "__main__":
    main()

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

total = 0


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


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

print(int(total))

Solution (Python):
import math
import sys 
n,m = map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
cnt = 0

if n>=2:
    cnt += combinations_count(n,2)

if m>=2:
    cnt += combinations_count(m,2)
print(cnt)

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

Solution (Python):
def combination_2(n):
    if n < 2:
        return 0
    else:
        return int(n * (n - 1) / 2)


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

print(combination_2(n)+combination_2(m))

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

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

Solution (Python):
from math import factorial
N,M=map(int,input().split())
a,b=0,0
if N>=2:
  a = factorial(N) / factorial(2) / factorial(N - 2)

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

print(int(a+b))

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

Solution (Python):


t = input().split()
n = int(t[0])
m = int(t[1])

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

if m < 0:
    a += 0
else:
    a += (m * (m-1)//2)

print(a)

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


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

Solution (Python):
import math
N, M = map(int, input().split())
if N >= 2:
  pn = math.factorial(N) // math.factorial(N - 2)
else:
  pn = 0
if M >= 2:
  pm = math.factorial(M) // math.factorial(M - 2)
else:
  pm = 0
total = pn // 2 + pm // 2
print(total)

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

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

print(int(all - minus))

Solution (Python):
data = input().split(" ")
 
N = int(data[0])
M = int(data[1])
 
ans = N*(N-1)/2
ans += M*(M-1)/2
 
print(int(ans))

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

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

total = int(total)

print(total)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def solve():
    n, m = LI()
    print(n * (n - 1) // 2 + m * (m - 1)//2)
    return



if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)

n,m = map(int,input().split())
a = n - 1
b = m - 1
ans = 0

if m <= 1:
    ans = n*a/2
else:
    ans = n*a/2 + m*b/2

print(str(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))
base1 = 0
base2 = 0
if n >= 2:
    base1 = comb(n,2)
if m >= 2:
    base2 = comb(m,2)
ans = base1 + base2
print(ans)

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

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

    print(ans)

if __name__ == '__main__':
    resolve()

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

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

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

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

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

Solution (Python):
def fac(x):
    a=1
    for i in range(2,x+1):
        a*=i
    return(a)
def npr(x,x1):
    return fac(x)//(fac(x-x1)*fac(x1))
n,m=map(int,input().split())
ans=npr(n,2)+npr(m,2)
print(ans)

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

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

a1 = n * (n-1) // 2
a2 = m * (m-1) // 2

a1 = max(0, a1)
a2 = max(0, a2)

print(a1 + a2)

Solution (Python):
from math import factorial

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


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

answer = 0

if N >= 2:
  answer += comb(N, 2)
else:
  answer += 0

if M >= 2:
  answer += comb(M, 2)
else:
  answer += 0

print(int(answer))

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

Solution (Python):
dat = list(map(int,input().split(' ')))
n=dat[0]
m = dat[1]

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

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

if n == 1 and m == 1:
    ans = 0
elif n <= 1 and m > 1:
    ans = m * (m - 1) / 2
elif n > 1 and m <= 1:
    ans = n * (n - 1) / 2
else:
    ans = n * (n - 1) / 2 + m * (m - 1) / 2

print(int(ans))

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

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

ansn = 0
ansm = 0
if n > 1 :
  ansn = (n * (n-1)) //2
if m > 1 :
  ansm = (m * (m-1)) //2

print(ansn + ansm)

Solution (Python):
import math

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

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

a = combinations_count(n, 2)
b = combinations_count(m, 2)

print(a+b)

Solution (Python):

if True:
    n,m = map(int, input().split())


else:
    
    n=0
    
    m=3

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

print(int(ans))

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

if n == 1 :
  n == 0
if m == 1:
  m == 0
ans_n = n * (n-1) / 2
ans_m = m * (m-1) / 2
ans = int(ans_n + ans_m)
print(ans)

Solution (Python):
import math

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

Solution (Python):
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7


n, m = MAP()

ans = 0

for x in range(0, n ):
    ans += x
for x in range(0, m ):
    ans += x

print(ans)

Solution (Python):

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

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

if n==0:
    print(combinations_count(m, 2))
elif m == 0:
        print(combinations_count(n, 2))
elif n==1 and m ==1:
    print(0)
elif n==1:
    print(combinations_count(m, 2))

elif m==1:
    print(combinations_count(n, 2))

else:
    print(combinations_count(n, 2)+combinations_count(m, 2))

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


if __name__ == "__main__":
    main()

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

total = 0
for ni in range(1, n):
    if n <= 1:
        break
    total += ni

for mi in range(1, m):
    if m <= 1:
        break
    total += mi

print(total)

Solution (Python):
import math

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


a = input().split(" ")
n = int(a[0])
m = int(a[1])

c = combinations_count(n, 2)
c += combinations_count(m, 2)

print(c)

Solution (Python):


from math import factorial
n, m = map(int, input().split())
if n < 2:
    if m < 2:
        print(0)
    else:
        ans = factorial(m) / factorial(2) / factorial(m - 2)
        print(int(ans))
else:
    if m < 2:
        ans = factorial(n) / factorial(2) / factorial(n - 2)
        print(int(ans))
    else:
        ans = factorial(n) / factorial(2) / factorial(n - 2) + factorial(m) / factorial(2) / factorial(m - 2)
        print(int(ans))

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

n_ans = n * (n-1) / 2
m_ans = m * (m-1) / 2

print(int(n_ans + m_ans))

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

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


def count(number):
  if number == 1 or number == 0:
    return 0
  else:
    return number * (number - 1) / 2

print(int(count(N) + count(M)))

Solution (Python):
a = list(map(int,input().split()))
ev = a[0]
od = a[1]
if (ev<=1)and(od<=0):
  n = 0
elif ev<=1:
  n = a[1]*(a[1]-1)/2
elif od<=1:
  n = a[0]*(a[0]-1)/2
else:
  n = a[0]*(a[0]-1)/2+a[1]*(a[1]-1)/2
print(int(n))

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

num = 0
for i in range(N):
    for j in range(N):
        if i != j:
            num += 1
for i in range(H):
    for j in range(H):
        if i != j:
            num += 1
print(int(num/2))

Solution (Python):

import itertools

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

all = [0] *n
temp = [1] *m
all.extend(temp)

count = 0
for v in itertools.combinations(all, 2):
    ans = v[0]+v[1]
    
    if ans%2 == 0:
        count += 1
print(count)

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

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

Solution (Python):
a,b=map(int,input().split())
s=[]
for i in range(1,a):
    s.append(i)
x=sum(s)
t=[]
for i in range(1,b):
    t.append(i)
y=sum(t)
print(x+y)

Solution (Python):
base = input().split()
n = int(base[0])
m = int(base[1])
ansn = n*(n-1)//2
ansm = m*(m-1)//2
if n==0:
    ansn = 0
if m==0:
    ansm = 0
print(ansn+ansm)

Solution (Python):
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



N,M = LI()

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

Solution (Python):
def comb2(n):
    if n < 2:
        return 0
    return int(n * (n - 1) / 2)

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

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

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

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

    ans += factorial(n) // ((2) * factorial(n-2))
if m >= 2:

    ans += factorial(m) // ((2) * factorial(m-2))
print(ans)

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

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




print(int(total - odd))

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int):
    import math
    def combination(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    ans = 0
    if N >= 2:
        ans += combination(N,2)
    if M >= 2:
        ans += combination(M,2)
    print(ans)
    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 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:
    N_ans = 0
else:
    N_ans =combinations_count(N, 2)
if M == 1 or M == 0:
    M_ans = 0
else:
    M_ans = combinations_count(M, 2)

ans = N_ans + M_ans

print(str(ans))

Solution (Python):

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

cnt = 0

if N > 1:
    cnt += N*(N-1)/2
if M > 1:
    cnt += M*(M-1)/2
print(int(cnt))

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

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

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

if N > 0:
  A = N * (N-1) / 2
elif N ==0:
  A = 0

if M > 0:
  B = M * (M-1) / 2
elif M ==0:
  B = 0

out = int(A) + int(B)
print(out)

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

Solution (Python):
def solve():
    a, b = list(map(int, input().split()))
    
    if a == 0 and b == 0:
        print(0)
        return
    
    if a == 0:
        ans = b * (b - 1) // 2
        print(ans)
        return

    if b == 0:
        ans = a * (a - 1) // 2
        print(ans)
        return
    
    ans = a * (a - 1) // 2
    ans += b * (b - 1) // 2
    print(ans)
    return

if __name__ == "__main__":
    solve()

Solution (Python):
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())

n,m=IA()
def f1(n):
    res=1
    for i in range(1,n+1):
        res*=i
    return res
def f(n):
    if n<2:return 0
    return f1(n)//(f1(n-2)*f1(2))

print(f(n)+f(m))