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

ans1 = 0
ans2 = 0

if n > 1:
  ans1 = n*(n-1)//2
  
if m > 1:
  ans2 = m*(m-1)//2
  
print(ans1+ans2)

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

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

def comb2(x):
    return x * (x - 1) / 2

print(int(comb2(N) + comb2(M)))

Solution (Python):
def x(i):
	r = 0
	while i != 0:
		i-=1
		r+= i
	return r

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

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

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


print(int(a+b))

Solution (Python):
import math
n,m = map(int,input().split())
if n < 2 and m <2:
    print(0)
elif n < 2 and m >= 2:
    print((math.factorial(m) // ((math.factorial(2))*(math.factorial(m-2)))))
elif m <2 and n >=2:
    print((math.factorial(n) // ((math.factorial(2))*(math.factorial(n-2)))))
else:
    print((math.factorial(m) // ((math.factorial(2))*(math.factorial(m-2))))+((math.factorial(n) // ((math.factorial(2))*(math.factorial(n-2))))))

Solution (Python):

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

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

print(ans)

Solution (Python):
f=[1]
for i in range(1,101):
    f.append(i*f[i-1])

n,m=map(int,input().split())
sum=0
if m>=2:
    sum+=(f[m]//(f[2]*f[m-2]))
if n>=2:
    sum+=(f[n]//(f[n-2]*f[2]))
print(sum)

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

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

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

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

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

Solution (Python):
import sys

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

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

Solution (Python):
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m = MI()
    print(int(n * (n - 1) / 2 + m * (m - 1) / 2))
    pass


if __name__ == "__main__":
    main()

Solution (Python):
a,b=map(int,input().split())
c=0
d=0
for i in range(a):
    for j in range(i+1,a):
        c+=1
for i in range(b):
    for j in range(i+1,b):
        c+=1
    
print(c)

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

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

Solution (Python):
from sys import stdin
import math


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


A, B = [int(x) for x in stdin.readline().rstrip().split()]



if A < 2:
    c = 0
else:
    c = combinations_count(A, 2)
if B<2:
    d=0
else:
    d = combinations_count(B, 2)
print(c+d)

Solution (Python):
def main():
    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(int(ans))

if __name__ == '__main__':
    main()

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

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

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

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

x = 0
for i in range(n + m):
    for j in range(n + m):
        if i == j:
            continue
        x1 = i < n
        x2 = j < n
        if (x1 and x2) or (not x1 and not x2):
            x += 1
print(x // 2)

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

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

Solution (Python):
import math
a, b = map(int, input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if a>=2 and b>=2:
  print(combinations_count(a,2)+combinations_count(b,2))  
elif a>=2:
  print(combinations_count(a,2))
elif b>=2:
  print(combinations_count(b,2))
else:
  print("0")

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

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

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

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

Solution (Python):
import math
n,m=[int(i) for i in input().split()]
r=math.factorial(n) // (math.factorial(n - 2) * math.factorial(2)) if n >= 2 else 0
r+=math.factorial(m) // (math.factorial(m - 2) * math.factorial(2)) if m >= 2 else 0
print(r)

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


    
    M, N = map(int, input().split())
    
    
    
    
    
    
    
        
    
    a = cmb(M+N, 2)-M*N
    print(a)
    
main()

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

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

x = combinations_count(M + N, 2)

print(x - M * N)

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(round((n*(n-1)+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(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))

a = combinations_count(N, 2) if N > 1 else 0
b = combinations_count(M, 2) if M > 1 else 0

print(a + b)

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

nc2 = comb(n, 2, exact=True)
mc2 = comb(m, 2, exact=True)

print(nc2 + mc2)

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


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

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

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

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

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

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

Ans = conbination_2(N) + conbination_2(M)

print(Ans)

Solution (Python):





def main():
    inp = lambda: [int(x) for x in input().split()]
    n, m = inp()
    ans = n * (n-1) // 2 + m * (m-1) // 2
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):


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

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

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

ans = n+m

print(ans)

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

Solution (Python):
import math

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

N, M = map(int, input().split())
res = 0
if 2 <= N:
  res += comb(N, 2)
if 2 <= M:
  res += comb(M, 2)
print(res)

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>=2 and m>=2):
    ans+=(n*(n-1))//2
    ans+=(m*(m-1))//2
elif(n>=2 and m<2):
    ans += (n*(n-1))//2
elif(m>=2 and n<2):
    ans+=(m*(m-1))//2
else:
    pass
print(ans)

Solution (Python):
import itertools

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

N = [2 for x in range(n)]
M = [1 for x in range(m)]

count = []
for v in itertools.combinations(N + M, 2):
    count.append(sum(v) % 2 == 0)
print(sum(count))

Solution (Python):
import numpy as np
a = [int(i) for i in list(input().split())]
b = int((a[0]*(a[0]-1) +a[1]*(a[1]-1))/2)

print(b)

Solution (Python):



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

    ee = N * (N-1) / 2
    oo = M * (M-1) / 2

    print(int(ee + oo))



if __name__ == '__main__':
    main()

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

def cal(x):
    return x*(x-1)//2

print(cal(N)+cal(M))

Solution (Python):


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

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



print(int(a+b))

Solution (Python):
from itertools import combinations as comb


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

    n_list = list(range(n))
    m_list = list(range(m))
    n_pair = list(comb(n_list, 2))
    m_pair = list(comb(m_list, 2))
    ans = len(n_pair) + len(m_pair)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input=sys.stdin.readline
N,M = map(int,input().split())
nCr = {}
def cmb(n, r):
    if n == 0:
        return 0
    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)]

a = cmb(N,2)
b = cmb(M,2)
print(a+b)

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

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

print(ans)

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

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

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

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

print(round(answer))

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

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

import itertools
a = len(list(itertools.combinations(range(n), 2)))
b = len(list(itertools.combinations(range(m), 2)))
print(a+b)

Solution (Python):
import math


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

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

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

Solution (Python):
def main():

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



if __name__=='__main__':
    main()

Solution (Python):

from scipy.misc import comb
n, m = (int(x) for x in input().split())
ans = 0
if n >= 2:
    ans += comb(n, 2, exact=True)
if m >= 2:
    ans += comb(m, 2, exact=True)
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())

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

print(a)

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

Solution (Python):
from math import factorial

N, M = map(int, input().split())
a = 0
b = 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(b + a))

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

print(odd_even())

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

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

print(answer)

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

ansn = N*(N-1)//2
ansm = M*(M-1)//2

print(ansn+ansm)

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

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

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







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

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

c_N = 0
c_M = 0

if N >= 2:
    c_N = comb(N, 2)
if M >= 2:
    c_M = comb(M, 2)
print(c_N + c_M)

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

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

N, M = map(int, input().split())
even = N*(N-1)//2 if N>1 else 0
odd = M*(M-1)//2 if M>1 else 0
print(even+odd)

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



n_number = 0
if n >=2:
    n_number = (n*(n-1))/2
else:
    n_number = 0

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

print(int(n_number + m_number))

Solution (Python):
import math


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


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

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

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

ans = ans1+ans2
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):
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):
def f(n):
	return (n*(n-1))/2
n,m = map(int,raw_input().split())
print f(n)+f(m)

Solution (Python):



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

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

print(int(even + odd))

Solution (Python):
import sys
import re
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
from functools import reduce
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


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


N, M = MAP()

ans = 0

if N >= 2:
    ans += combinations_count(N, 2)
if M >= 2:
    ans += combinations_count(M, 2)

print(ans)

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


case_1 = N * (N-1)/2


case_2 = M*(M-1)/2

print(int(case_1 + case_2))

Solution (Python):
def cycle(x):
    result = 0
    for y in range(int(x), 0, -1):
        result += y - 1
    return result


def main():
    N, M = map(cycle, input().split(' '))
    print(N + M)


if __name__ == '__main__':
    main()

Solution (Python):

import math


import sys
input = sys.stdin.readline



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

    res = 0

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

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

    print(res)



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

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

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

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

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

Solution (Python):
import math


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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    print(combinations_count(n + m, 2) - (n * m))

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

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

tmp1 = 0
tmp2 = 0

if n != 0:
    tmp1 = n * (n - 1) / 2

if m != 0:
    tmp2 = m * (m - 1) / 2

r = int(tmp1 + tmp2)
print(r)

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

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

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

Solution (Python):
from math import factorial

def main():
    n, m = map(int, input().split())
    r = 0
    if n >= 2:
        r += factorial(n) / (2 * factorial(n - 2))
    if m>= 2:
        r += factorial(m) / (2 * factorial(m - 2))

    print(int(r))

if __name__ == '__main__':
    main()

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

m1 = [0]*m
n1 = [0]*n
print(len(list(combinations(m1,2)))+len(list(combinations(n1,2))))

Solution (Python):


N, M = map(int, input().split())
num_N = N*(N-1)//2
num_M = M*(M-1)//2
print(num_N+num_M)

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

A()

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

Solution (Python):
a=input().split()
Even = int(a[0])
Odd = int(a[1])
if Even < 2 :
    Evenresult = 0
else:
    Evenresult = Even * (Even -1) / 2
if Odd < 2 :
    Oddresult = 0
else:
    Oddresult = Odd * (Odd -1) / 2
print(int(Evenresult + Oddresult))

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




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

print(ans)

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

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

print(ans)

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
from re import split
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy
import re

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


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

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

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

Solution (Python):
import itertools
n, h = map(int, input().split())
lst = [2]*n
lst2 = [1]*h
ev = list(itertools.combinations(lst,2))
ki = list(itertools.combinations(lst2,2))
print(len(ev) + len(ki))

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

if m < 2:
  ans += 0
else:
  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))
n,m = map(int,input().split())
n_num = 0
m_num = 0
if n >= 2:
    n_num = comb(n ,2)
    
if m >= 2:
    m_num = comb(m,2)
print(n_num+m_num)

Solution (Python):
import itertools
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())
ans = 0
if n != 1 and n != 0:
    ans += cmb(n,2)
if m != 1 and m != 0:
    ans += cmb(m,2)
print(ans)

Solution (Python):


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

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

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

n=(N*(N-1))//2
m=(M*(M-1))//2

print(n+m)

Solution (Python):
if __name__ == "__main__":
    n, m = map(int, input().split())

    l = [2] * n + [1] * m

    ans = 0
    for i in range(len(l)):
        for j in range(len(l)):
            if i != j and i < j and (l[i] + l[j]) % 2 == 0:
                ans += 1

    print(ans)

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

    if n < 2 and m < 2:
        print(0)
        exit()

    if n < 2:
        print(m*(m - 1)//2)
        exit()

    if m < 2:
        print(n*(n - 1)//2)
        exit()

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

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

if N > 2:
    a = combinations_count(N, 2)
elif N == 2:
    a = 1
else:
    a = 0

if M > 2:
    b = combinations_count(M, 2)
elif M == 2:
    b = 1
else:
    b = 0

print(a+b)

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

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

if m < 2:
    two = 0
else:
    two = m * (m-1) // 2
print(one + two)

Solution (Python):
import math

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

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

ans = 0
if (n > 1):
    ans += permutations_count(n, 2)
if (m > 1):
    ans += permutations_count(m, 2)

print(ans)

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

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

Solution (Python):


import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n, m = read_list(int)
    print((n + m) * (n + m - 1) // 2 - n * m) 


if __name__ == "__main__":
    main()

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

ans1 = 0
ans2 = 0
if n > 1:
    ans1 = cmb(n, 2)
if m > 1:
    ans2 = cmb(m, 2)

print(ans1+ans2)

Solution (Python):
a,b = input().split()
a = int(a)
b = int(b)
if a >= 2 and b >= 2:
  print(int(a * (a-1) / 2 + b * (b-1) / 2))
elif a < 2 and b < 2:
  print(0)
elif a>=2 and b < 2:
  print(int(a * (a-1)/2))
elif a<2 and b>=2:
  print(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 main():
    N, M = list(map(int, input().split()))
    print(int(N * (N - 1) / 2 + M * (M - 1) / 2))

if __name__ == '__main__':
    main()

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

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

if N > 1:
  count += nCr(N, 2)
if M > 1:
  count += nCr(M, 2)

print(count)

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

for i in range(a):
  for j in range(a-1):
    count1 = count1 + 1
for l in range(b):
  for m in range(b-1):
    count2 = count2 + 1
print((count1+count2)//2)

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

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

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



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

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

print(a+b)

Solution (Python):
x,y = map(int,input().split())


ans = x*(x-1) / 2


ans += y*(y-1) / 2

print(int(ans))

Solution (Python):
h, w = map(int,input().split())

out = 0

for i in range(h):
  out += i
for i in range(w):
  out += i
  
print(out)

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

Solution (Python):
from  itertools import combinations
N, M = map(int, input().split())
N = range(N)
M = range(M)
count_n = len(list(combinations(N,2))) if len(N) >=2 else 0
count_m = len(list(combinations(M,2))) if len(M) >=2 else 0

print(count_n+count_m)

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 


e, o = map(int, input().split())

ans = nCr(e, 2) + nCr(o, 2)
print(ans)

Solution (Python):
data = input()

g, k = [int(i) for i in data.split()]

result = (g * (g-1) /2 + k * (k-1)/2)

print(int(result))

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):
n, m = [int(i) for i in input().split()]
result = (n*(n-1))//2 + (m*(m-1))//2
print(result)

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

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

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

print(n + m)

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

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

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

print(int(ans))

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

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

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

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

Solution (Python):
import math

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

if N > 1:
	cN = math.factorial(N) // (2 * math.factorial(N - 2))
else:
	cN = 0

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

print(cN + cM)