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):
import math
g,k=map(int,input().split())
def cou(n):
    return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
if g<2:
  a=0
else:
  a=cou(g)
if k<2:
  b=0
else:
  b=cou(k)
print(a+b)

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

N, M = map(int, input().split())
ans = 0
if N > 1 :
  ans += calcConbination(N-1)

if M > 1 :
  ans += calcConbination(M-1)

print(ans)

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

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

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

def ans(N,M):
    if N>=2 and M<2:
        return combinations_count(N,2)
    elif N<2 and M>=2:
        return combinations_count(M,2)
    elif N<2 and M<2:
        return 0
    else:
        return combinations_count(N,2) + combinations_count(M,2) 


print(ans(N,M))

Solution (Python):
from itertools import combinations

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

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

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

Solution (Python):
def ball(x,y):
    if x>1 and y>1:
        print((x*(x-1)+y*(y-1))//2)
    elif x<=1 and y>1:
        print((y*(y-1))//2)
    elif x>1 and y<=1:
        print((x*(x-1))//2)
    else:
        print(0)


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

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

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

print(int(ans))

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    odd = 0
    even = 0
    if N >= 2:
        odd = N*(N-1)//2
    if M >= 2:
        even = M*(M-1)//2
    print(odd+even)
if __name__ == "__main__":
    main()

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

Solution (Python):
n,m=map(int,input().split())
from scipy.misc import comb
print(comb(n,2,exact=True)+comb(m,2,exact=True))

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

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

import math

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

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

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

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

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

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

print(ans)

Solution (Python):
import math as m
N, M = input().split(' ')
N, M = int(N), int(M)

if N > 1:
    a = m.factorial(N)/(2*m.factorial(N-2))
else:
    a = 0
if M > 1:
    b = m.factorial(M)/(2*m.factorial(M-2))
else:
    b = 0

print(int(a+b))

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

Solution (Python):
import math
M,N = list(map(int,input().split()))
def comb(n,r):
    if n >= r:
        return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
    else:
        return 0
   
 
A = comb(M,2)
B = comb(N,2)
print(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())
print((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):
M,N = map(int,input().split())
print(int(M*(M-1)/2 + N*(N-1)/2))

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

Solution (Python):


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

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

print("{}".format(int(ans)))

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

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

Solution (Python):
import sys
N, M = map(int, sys.stdin.readline().split())

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

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, M: int):
    print(N*(N-1)//2+M*(M-1)//2)
    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())

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

Solution (Python):
from scipy.misc import comb
N, M = [int(i) for i in input().split()]
ans = comb(N,2,exact=True) + comb(M,2,exact=True)
print(ans)

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

Solution (Python):
n, m = [int(x) for x in 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)+M*(M-1))/2))

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

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

Solution (Python):
n,m=[int(i)for i in input().split()]
print((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):
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:
    p1=0
else:
    p1 = combinations_count(a, 2)

if b<2:
    p2=0
else:
    p2 = combinations_count(b, 2)


total = p1 + p2
print(total)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    n, m = map(int, rl().split())
    ans = n * (n - 1) // 2 + m * (m - 1) // 2
    print(ans)

    
if __name__ == '__main__':
    solve()

Solution (Python):


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

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

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

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

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

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

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

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

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

Solution (Python):
inp=[int(x) for x in input().split()]
n,m=inp[0],inp[1]
s=0
if n>=2:
  s+=n*(n-1)/2
if m>=2:
  s+=m*(m-1)/2
print(int(s))

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

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


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


  
print(sum)

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

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

Solution (Python):
a,b=map(int,input().split())
an=0
ans=0
for i in range(a):
    an=an+i
for i in range(b):
    ans=ans+i
print(an+ans)

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

Solution (Python):
ab = input().split()
a,b = int(ab[0]), int(ab[1])
result = a*(a-1)//2 + b*(b-1)//2
print(result)

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

mod = 1000000007
INF = 110110110

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

Solution (Python):
import sys
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
for test in range(int(input())):
'''
inf = 100000000000000000  

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

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

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

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

c = a*(a-1)//2 + b*(b-1)//2
print(c)

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

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

Solution (Python):
A = list(map(int, input().strip().split(' ')))
ans = (A[0] * (A[0] - 1)) // 2 + ((A[1] * (A[1] - 1)) // 2)
print(ans)

Solution (Python):
import math
def kumiawase(n):
  a = 1
  b = 1
  for i in range(1, n+1):
    a = i * a
  for i in range(1, n - 2+1):
    b = i * b
  c = math.floor(a /(b * 2))
  return c
if __name__ == "__main__":
  x = input().split()
  n = int(x[0]) 
  m = int(x[1]) 
  a = kumiawase(n)
  b = kumiawase(m)
  print(a + b)

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

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

Solution (Python):
x = input().split(" ")
b = int(x[0])
c = int(x[1])
a = b*(b-1)/2 + c*(c-1)/2
print(int(a))

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

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

Solution (Python):

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

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

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

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

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

print(number)

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

print(int(even+odd))

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

Solution (Python):
n, m = list(map(int, input().split()))
lis = []
for i in range(n):
  lis.append(1)
for i in range(m):
  lis.append(2)
count = 0
for i in range(len(lis)):
  for j in range(i + 1, len(lis)):
    if (lis[i] + lis[j]) % 2 == 0:
      count += 1
print(count)

Solution (Python):
def c(i):
    return i*(i-1)//2

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

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

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

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

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

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

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

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

Solution (Python):
from scipy.misc import comb
n=[int(i) for i in input().split()]
a=comb(n[0],2,exact=True)
b=comb(n[1],2,exact=True)
print(a+b)

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

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

print(int(c))

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

print(cnt)

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


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

Solution (Python):
def factorial(n):
    if n == 0 or n == 1 or n < 0:
        return 1
    return n * factorial(n-1)

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

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

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

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

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

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):
def main():
	
	
	a,b = map(int,input().split())
	
	
	
	
	
	
	
	import math
	def combinations_count(n, r):
		return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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


if __name__ == '__main__':
	main()

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

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

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

if N == 1 and M == 1 :
    ans = 0
elif N > 1 and M == 1 :
    ans = nC2
elif N == 1 and M > 0 :
    ans = mC2
else :
    ans = nC2 + mC2

print(ans)

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

c_o = int((N * (N-1)) / 2)
c_e = int((M * (M-1)) / 2)

print(c_o + c_e)

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

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

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


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


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

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

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

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

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


method = 0
if n >= 2:
    method += n * (n - 1) / 2

if m >= 2:
    method += m * (m-1) / 2

print(int(method))

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

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

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

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

Solution (Python):
from sys import stdin


def cmb(n,r):
    return n*(n-1)//2



if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  
    
    cnt = cmb(N,2) + cmb(M,2)
    
    print(cnt)

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

n=int(temp[0])
m=int(temp[1])
Answer=0
ball_list=list()

for i in range(0,n):
    ball_list.append(2)

for i in range(0,m):
    ball_list.append(1)

for i in range(0,n+m):
    for j in range(0,n+m):
        if i < j:
            if (ball_list[i]+ball_list[j])%2==0:
                Answer=Answer+1

print(Answer)

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

partn = 0 if n < 2 else math.factorial(n)/(2*math.factorial(n-2))
partm = 0 if m < 2 else math.factorial(m)/(2*math.factorial(m-2))

print(int(partn+partm))

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

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

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

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

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

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

Solution (Python):
print(sum(map(lambda x:int(x)*(int(x)-1)//2,input().split())))

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

Solution (Python):



import math

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

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

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

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

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

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(sum([N*(N-1)/2 if N >= 2 else 0, M*(M-1)/2 if M >= 2 else 0])))

Solution (Python):


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

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

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

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



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


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

print(c)

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

e = 0
o = 0

if N>=2:
    e = comb(N,2)
if M>=2:
    o = comb(M,2)
print(e+o)

Solution (Python):
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]



def main():
    N, M = input(int, int)
    print(N * (N - 1) // 2 + M * (M - 1) // 2)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Solution (Python):


import sys



















def main():
    mod = 1000000007                  
    inf = float('inf')
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    print((n * (n-1) // 2) + (m * (m-1) // 2))

if __name__ == "__main__":
    main()

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

if n>1:
  n_sum=((n*(n-1))//2)
  total=n_sum

if m>1:
  n_sum=((m*(m-1))//2)
  total+=n_sum
print(total)

Solution (Python):

import sys
input = sys.stdin.buffer.readline


from collections import defaultdict

con = 10 ** 9 + 7

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


def main():
	N, M = getlist()
	ans = int(N * (N - 1) // 2) + int(M * (M - 1) // 2)
	print(ans)


if __name__ == '__main__':
	main()

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

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

Solution (Python):
from operator import mul  
from functools import reduce  

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


def p(_n, _r):
    
    return reduce(mul, list(range(_n, _n - _r, -1)))  


def c(_n, _r):
    
    over = p(_n, _r)
    under = p(_r, _r)
    return over / under


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

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

a = []
for i in range(1,n+1):
  a.append(2*i)
for j in range(1, m+1):
  a.append(2*j - 1)

counter = 0
for i in range(len(a)-1):
  for j in range(i+1, len(a)):
    if (a[i] + a[j]) % 2 == 0:
      counter += 1
      
print(counter)

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


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

print(choose2(n) + choose2(m))

Solution (Python):

url = "https://atcoder.jp//contests/abc159/tasks/abc159_a"

def main():
    e, v = list(map(int, input().split()))
    lis = []
    for i in range(e):
        lis.append(1)
    for i in range(v):
        lis.append(2)
    count = 0
    for i in range(len(lis)):
        for j in range(i + 1, len(lis)):
            
            if (lis[i] + lis[j]) % 2 == 0:
                count += 1
    print(count)

if __name__ == '__main__':
    main()

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

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

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 = 2
import math


nResult = 0
if (n-k) >= 0:
    nResult = (math.factorial(n))/(2*math.factorial(n-k))
    nResult=int(nResult)


mResult = 0

if (m-k) >= 0:
    mResult = (math.factorial(m))/(2*math.factorial(m-k))
    mResult=int(mResult)



print(nResult+mResult)

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

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

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

Solution (Python):
l = input().split()
L = [int(x) for x in l]
N = L[0]
M = L[1]

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

print(int(result))

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

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

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

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


def main():

    kiki = 0
    gugu = 0

    if NM[0] > 1:
        gugu = cmb(NM[0], 2)
    if NM[1] > 1:
        kiki = cmb(NM[1],2)


    print(kiki+gugu)



if __name__ == '__main__':
    main()

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

Solution (Python):


def main():
    N, M = map(int, open(0).read().split())
    T = N * (N-1) / 2 + M * (M-1) / 2
    print(int(T))

main()

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

Solution (Python):
from heapq import *
import sys
from collections import *

from itertools import *
from decimal import *
import copy
from bisect import *
import time

import math

def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
N,M=map(int,input().split())
print(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):
def kai(nn):
    if nn == 0 or nn==1:
        return 1
    else:
        return nn*kai(nn-1)




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


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

Solution (Python):
N,M = (int(i) for i in input().split())
comb_n = int(N*(N-1)/2) if N > 1 else 0
comb_m = int(M*(M-1)/2) if M > 1 else 0
print(comb_n + comb_m)

Solution (Python):
o, e = input().split()
o = int(o);
e = int(e);

num1 = o * (o-1) / 2;
num2 = e * (e-1) / 2;

print(int(num1+num2))

Solution (Python):
from sys import stdin
import itertools
N,M = list(map(int, (stdin.readline().strip().split())))
count=0
count+=len(list(itertools.combinations(range(N), 2)))
count+=len(list(itertools.combinations(range(M), 2)))
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())

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

print(x)

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

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

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

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

Solution (Python):

import sys
import collections
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
import itertools

class Run:
    def build(gv):
        gv.N, gv.M = map(int, input().split())

    def solve(gv):
        ans = 0
        
        p = [0]*gv.N
        q = [0]*gv.M
        ans += len(list(itertools.combinations(p, 2)))
        ans += len(list(itertools.combinations(q, 2)))
        
        print (ans)
        
if __name__ == '__main__':
    run = Run()
    run.build()
    run.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())

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

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

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


def p(_n, _r):
    
    ret = 1
    for i in range(_r):
        ret = ret * (_n - i)
    return ret


def c(_n, _r):
    over = p(_n, _r)
    under = p(_r, _r)
    return over / under


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

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

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

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

print(p)

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

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

Solution (Python):
def solve():
  return int(n*(n-1)/2+m*(m-1)/2)



n, m = [int(s) for s in input().split(" ")]
print(solve())

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

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

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

print(int(sum_even+sum_odd))

Solution (Python):
def Main(N, M):
    return N*(N-1)//2+M*(M-1)//2

def main():
    N, M = map(int, input().split())
    print(Main(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):
def main():
  n,m = (int(x) for x in input().split())
  print(int(n*(n-1)/2) + int(m*(m-1)/2))

if __name__ == '__main__':
  main()