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):
from scipy.misc import comb
import numpy as np
A,B=map(int,input().split())
print(int(np.round(comb(A,2))+np.round(comb(B,2))))

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

Solution (Python):
a,b = [int(x) for x in input().split()]
print((a*a+b*b-a-b)//2)

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

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

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

Solution (Python):
import math
from scipy.misc import comb

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

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

answer = 0
if N >= 2:
    answer += combinations_count(N, 2)
if M >= 2:
    answer += combinations_count(M, 2)
print(answer)

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

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

Solution (Python):
from sys import *
from math import *
from collections import deque
input = stdin.readline
lmi = lambda: list(map(float, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

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

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

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

Solution (Python):
N,M=(int(x) for x in input().split())
if not 0 <= N <= 100:
    print('N is not appropreate')
elif not 0 <= M <= 100:
    print('M is not appropreate')
elif N+M < 2:
    print('num of ball is too small')
else:
    print(int((N*(N-1)+M*(M-1))/2))

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

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

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

Solution (Python):
n,m=map(int,input().split())
rs=0
if(n>2):
    for i in range(1,n+1):
        for e in range(i+1,n+1):
            rs+=1
if(n==2):rs+=1
if(m>2):
    for i in range(1,m+1):
        for e in range(i+1,m+1):
            rs+=1
if(m==2):rs+=1
print(rs)

Solution (Python):




import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

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

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

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

Solution (Python):
I = input().split()

N = int(I[0])
M = int(I[1])

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

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

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

print(output)

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

    sum_eve = (a * (a-1))/2
    sum_odd = (b * (b-1))/2

    print(int(sum_eve + sum_odd))


if __name__ == "__main__":
    main()

Solution (Python):

import sys
import itertools
n, m = map(int, sys.stdin.readline().split())

L = [0 for _ in range(n)] + [1 for _ in range(m)]
L = list(itertools.combinations(L, 2))

total = 0
for a, b in L:
    if (a+b)%2 ==0:
        total+=1

print(total)

Solution (Python):

import sys
n, m = map(int, sys.stdin.readline().split())


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

Solution (Python):
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

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

main()

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

def n_c_2(n):
    if n < 2:
        return 0
    else:
        return n * (n - 1) // 2

print(n_c_2(N) + n_c_2(M))

Solution (Python):
def check(a, b):
  return((a+b)%2==0)
n, m = map(int, input().split())
x=sorted(list(range(1, 2*m+1, 2)) + list(range(2, 2*n+1, 2)))
c=0
for i in range(len(x)):
  for j in range(i+1, len(x)):
    if check(x[i], x[j]):
      c+=1
print(c)

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

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

Solution (Python):
import math


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


def C(n, r):
    return P(n, r)//math.factorial(r)


N, M = map(int, input().split())
ans = 0
if N >= 2:
    ans += C(N, 2)
if M >= 2:
    ans += C(M, 2)
print(ans)

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

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

print(C1 + C2)

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

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

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

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

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

import numpy as np

A = np.asarray(range(max(1, N)))
B = np.asarray(range(max(1, M)))
A = A.cumsum()
B = B.cumsum()

print(A[-1] + B[-1])

Solution (Python):
import sys

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

def com(n,r):
    ans1 = 1
    ans2 = 1
    tmp = r
    while r != 0:
        ans1 = ans1 * (n)
        ans2 = ans2 * r
        n -= 1
        r -= 1

    return ans1/ans2

print(int(com(N,2)+com(M,2)))

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    aa=a*(a-1)/2
    bb=b*(b-1)/2
    print(int(aa+bb))
if __name__ == '__main__':
    do()

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

Solution (Python):
N = list(map(int, input().split()))
ans = 0
for i in range(2):
  if N[i] != 0:
    ans += N[i]*(N[i]-1)//2

print(ans)

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


def nCk(N,K):
    c,p = 1,1
    for k in range(1,K+1):
        c *= (N - k + 1)
        p *= k
    return c//p

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

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

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

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

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

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

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

print(int(a+b))

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

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

def main():
    mod=10**9+7
    N,M=MI()
    ans=(N*(N-1))//2+(M*(M-1))//2
    print(ans)
main()

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

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

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

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

Solution (Python):
import itertools

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

for i in itertools.combinations(n*[2] + m*[1], 2):
    if sum(i) % 2 == 0:
        ans += 1
print(ans)

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

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

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

def f(n):
    sum = 0
    for i in range(n):
        sum += i
    return sum

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

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

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

if n==1 and m==1:
  print("0")
if n==1 and not m==1:
  print(m*(m-1)//2)
if m==1 and not n==1:
  print(n*(n-1)//2)
if not m==1 and not n==1:
    print(n*(n-1)//2+m*(m-1)//2)

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

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

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

if n==0:
    n2=0
else:
    n2=n-1

if m==0:
    m2=0
else:
    m2=m-1

print(int(n*n2/2+m*m2/2))

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 = n * (n - 1) // 2 + 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 2 <= b:
    print(combinations_count(b, 2))
elif 2 <= a and b < 2:
    print(combinations_count(a, 2))
elif a < 2 and b < 2:
    print(0)
else:
    print(combinations_count(a, 2)+combinations_count(b, 2))

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

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


main()

Solution (Python):
import itertools

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

print(len(list(itertools.combinations(range(N),2))) + len(list(itertools.combinations(range(M),2))))

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

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

def func(n):
    num = 1
    if n == 0:
        return 0
    else:
        for i in range(1,n+1):
            num = num*i
        return num
def func1(n):
    if n < 1:
        return 0
    elif n == 2:
        return 1
    else:
        return int(func(n)/(2*func(n-2)))

print(func1(n)+func1(m))

Solution (Python):
def n_c_two(i):
  if i <= 1:
    return 0
  return i * (i-1) // 2

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

Solution (Python):
import itertools

odd, even = map(int, input().split(" "))
nums = [1] * odd + [2] * even
counter = 0

for x in itertools.combinations(nums, 2):
    if sum(x) % 2 == 0:
        counter += 1
print(counter)

Solution (Python):
import sys
import os
import collections

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    e = N * (N-1) // 2
    o = 0 if M <= 1 else M * (M-1) // 2
    print(e+o)


if __name__ == '__main__':
    main()

Solution (Python):
import itertools

odd, even = map(int, input().split(" "))
nums = [1] * odd + [2] * even
counter = 0

for x in itertools.combinations(nums, 2):
    if sum(x) % 2 == 0:
        counter += 1
print(counter)

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

Solution (Python):
odd, even = map(int, input().split(" "))
odd_list = [1] * odd
even_list = [2] * even
nums = odd_list + even_list
counter = 0
for x in range(len(nums)):
    if x == len(nums) - 1:
        break
    else:
        for y in nums[x + 1:]:

            if (nums[x] + y) % 2 == 0:
                counter += 1
print(counter)

Solution (Python):
print(sum([(x * (x - 1)) // 2 for x in map(int,input().split())]))

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

for i in range(1,M):
    for j in range(i,M):
        count += 1

print(count)

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

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

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

print(((N+M)*(N+M-1))//2 - (N*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 operator import mul
from functools import reduce
N, M=map(int, input().split())


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

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

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 // 2) + (m* ~-m // 2))

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

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

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

Solution (Python):
n,m = map(int,input().split())
ans = n*(n-1)//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):
import math
import string
import collections
from collections import Counter


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


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):
import math
N,M=map(int, input().split())
def comb(N, r):
    return math.factorial(N) // (math.factorial(N - r) * math.factorial(r))
try :
    base = comb(N,2)
except:
    base=0
def comb2(M, r):
    return math.factorial(M) // (math.factorial(M - r) * math.factorial(r))
try:
    base2 = comb2(M,2)
except:
    base2=0

print(base+base2)

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())
def kaijo(a):
    start=1
    for i in range(1,a+1):
        start*=i
    return start
def comb(a,b):
    if a==0 or a==1:
        ans=0
    elif a==2:
        ans=1
    else:
        ans=kaijo(a)/(kaijo(b)*kaijo(a-b))
        
    return ans
print(int(comb(M,2)+comb(N,2)))

Solution (Python):

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

Solution (Python):
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') 
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(sys.stdin.readline()) 
def ifn(): return float(sys.stdin.readline()) 
def isn(): return sys.stdin.readline().split() 
def imn(): return map(int, sys.stdin.readline().split()) 
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) 
def fmn(): return map(float, sys.stdin.readline().split()) 
def iln(): return list(map(int, sys.stdin.readline().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, sys.stdin.readline().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,M = imn()
ans = 0
if N > 1: ans += comb_count(N,2)
if M > 1: ans += comb_count(M,2)
print(ans)

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

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

Solution (Python):
N,M=list(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):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'

    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase

input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

n,m=LI()

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

Solution (Python):
import math

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

raw = input()
n, m = [int(i) for i in raw.split(" ")]
 
print(comb(n, 2) + comb(m, 2))

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

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

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

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

nC2, mC2 = 0, 0
if N >= 2:
    nC2 = N*(N-1)/2*1

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

print(int(nC2 + mC2))

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 math

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

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


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

Solution (Python):
a = input().split()

m = int(a[0])
o = int(a[1])

t = (m*(m-1))/2
s = (o*(o-1))/2

print(int(t+s))

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

Solution (Python):
a, b  = [int(i) for i in input().split()]
x = 0
x = a*(a-1)//2+b*(b-1)//2
print(x)

Solution (Python):
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().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):
def get_combi(a):
    return (a * (a - 1)) // 2

i = input().split()

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

print(get_combi(m) + get_combi(n), end='')

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 = 0
ans += n*(n-1)//2
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 = map(int, input().split())
count = 0

count += M * (M - 1)
count += N * (N - 1)

print(count // 2)

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

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



if __name__ == "__main__":
    main()

Solution (Python):




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


def ncr(n, r):
    res = 1
    for i in range(1, r + 1):
        res = res * (n - i + 1) // i
    return res


print(ncr(n + m, 2) - n * m)

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

s = 0
for i in range(n):
  s += i
for i in range(m):
  s += i
print(s)

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

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

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

Solution (Python):
import math

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

print(cnt)

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

result = int(total - odd)
print(result)

Solution (Python):
A=input()
L=A.split()

B=(int(L[0]))*(int(int(L[0])-1))/2
      
C=(int(L[1]))*(int(int(L[1])-1))/2
      
print(int(B+C))

Solution (Python):
A=input()
L=A.split()

N=int(L[0])
M=int(L[1])

x=1
for n in range(N-1,N+1):
  x*=n
x /= 2
  
y=1
for m in range(M-1,M+1):
  y*=m
y /= 2

print(int(x+y))

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

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

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

Solution (Python):


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


print(int(n*(n-1)/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 f(x):
    if x > 0:
        return x * (x-1) // 2
    else:
        return 0

def solve(n, m):
    return f(n) + f(m)

assert solve(2, 1) == 1
assert solve(4, 3) == 9
assert solve(1, 1) == 0

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

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

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

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

Solution (Python):
from itertools import combinations

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

    ans = 0

    n_list = [i+1 for i in range(n)]
    m_list = [i+1 for i in range(m)]

    ans += len(list(combinations(n_list, 2)))
    ans += len(list(combinations(m_list, 2)))

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):

N, M = [int(i) for i in input().split()]
ans = (N * (N-1))//2 + (M * (M-1))//2
print(ans)

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

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

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

Solution (Python):
from scipy.misc import comb

a,b = map(int,input().split()) 
x = 0

x = comb(a, 2, exact=True) + comb(b, 2, exact=True)
    

print(x)

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

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

Solution (Python):
n,m = list(map(int,input().split()))
count = 0
for i in range(n):
  for j in range(n):
    if i > j:
      count += 1
for i in range(m):
  for j in range(m):
    if i > j:
      count += 1
print(count)

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

Solution (Python):
inp = input().split(' ')

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

ncount = 0 if n < 2 else n*(n-1)//2
mcount = 0 if m < 2 else m*(m-1)//2

print(str(ncount + mcount))

Solution (Python):
def factorial(n):
    if n > 1:
        return n * factorial(n - 1)
    else:
        return 1
        
m,n=map(int,input().split())



result = (int)(factorial(n)/(factorial(2) * factorial(n - 2)))
result += (int)(factorial(m)/(factorial(2) * factorial(m - 2)))

print(result)

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

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

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

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

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

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

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

def kaijou(n):
  ans = 1
  for i in range(1,n+1):
    ans *= i
  return ans

ans = 1
ans2 = 1

if n == 1 or n == 0:
  ans = 0
elif n>2:
  ans = kaijou(n)//(2*kaijou(n-2))
elif n==2:
  ans = kaijou(n)//2

if m ==1 or m == 0:
  ans2 = 0
elif m>2:
  ans2 = kaijou(m)//(2*kaijou(m-2))
elif m==2:
  ans2 = kaijou(m)//2

print(ans+ans2)

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

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

def main():
    N, M = map(int, input().split())
    ans = 0
    if N >= 2:
        ans += combinations_count(N, 2)
    if M >= 2:
        ans += combinations_count(M, 2)
    print(ans)


if __name__ == '__main__':
    main()

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

n, m = [int(i) for i in input().split(" ")]
r = 0
if n > 1:
  r += comb(n, 2)
if m > 1:
  r += comb(m, 2)
print(r)

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

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

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