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

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 = 0

for i in range(N):
        ans = i + ans 

for j in range(M):
        ans = j + ans 

print(ans)

Solution (Python):

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

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

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

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

Solution (Python):









import sys



readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()

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

ans = n * (n - 1) / 2

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

print(int(ans))

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

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

Solution (Python):

import sys
import math
def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n)/math.factorial(n-r)/math.factorial(r)
def solve(N: int, M: int):
    print(int(comb(N, 2) + comb(M, 2)))



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):
from math import factorial

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

if n > 1:
    kazu = (factorial(n) // factorial(2) // factorial(n - 2))
if m > 1:
    kazu += (factorial(m) // factorial(2) // factorial(m - 2))

print(kazu)

Solution (Python):
a = list(map(int, input().split()))
if a[0]==1:
  n=0
else:
  n=a[0]*(a[0]-1)/2

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

Solution (Python):
import itertools
N,M=list(map(int,input().split()))
l=[]
t=1
for i in range(N):
   l.append(t)
   t+=2
t=2
for i in range(M):
   l.append(t)
   t+=2
count=0
for v in itertools.combinations(l,2):
    
    if (v[0]+v[1])%2==0:
        count+=1
print(count)

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

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

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

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

ans = 0

if n >= 2:
    ans = ans + cmb(n, 2)

if m >= 2:
    ans = ans + cmb(m, 2)
    
print(ans)

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

x=l[0]*(l[0]-1)/2+l[1]*(l[1]-1)/2
print(round(x))

Solution (Python):
from sys import stdin
import math
import fractions

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

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

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

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

g = n * (n - 1) / 2
k = m * (m - 1) / 2

print(int(g + k))

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

    Nlist = [0] * N
    Mlist = [1] * M

    Nlist.extend(Mlist)

    count = 0
    for i in range(0, len(Nlist)):
        for j in range(i+1, len(Nlist)):
            if (Nlist[i] + Nlist[j]) % 2 == 0:
                count += 1

    print(count)

if __name__ == "__main__":
    main()

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

ans = 0
ans_n = 0
ans_m = 0

if 1 < n :
    ans_n = combinations_count(n, 2)

if 1 < m :
    ans_m = combinations_count(m, 2)

ans = ans_n + ans_m

print(ans)

Solution (Python):
import itertools

N,M = [int(i) for i in input().split(" ")]

even = [i for i in range(10**3) if i % 2 == 0]
odd =  [i for i in range(10**3) if i % 2 != 0]
lst = even[:N]+odd[:M]
count=0
for i in itertools.combinations(lst,2):
    if sum(list(i)) % 2 == 0:
        count+=1
print(count)

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))
ll = 0
if n > 1:
  ll = comb(n, 2)
rr = 0
if m > 1:
  rr = comb(m, 2)
print(ll + rr)

Solution (Python):

import sys
import itertools


from operator import itemgetter
from sys import stdin

from math import factorial
N=3
M=3
i=0
j=0
k=0

number_list=list(map(int, input().split(" ")))
N=number_list[0]
M=number_list[1]

if N >=2:
    i=factorial(N) / factorial(2) /factorial(N-2)
else:
    i=0

if M>=2:
    j=factorial(M) / factorial(2) /factorial(M-2)
else:
    j=0
print(int(i+j))




"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

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

n_ = n * (n - 1) // 2
m_ = m * (m - 1) // 2

print(n_ + m_)

Solution (Python):

"""
Created on Sun Mar 22 20:55:28 2020

@author: naoki
"""

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

option = 0
if N>1:
    
    option += len(list(itertools.combinations(range(N), 2)))
if M>1:
    option += len(list(itertools.combinations(range(M), 2)))
print(option)

Solution (Python):
import math
def comp(n, r):

    return math.factorial(n) // (math.factorial(abs(n-r))*math.factorial(r))
n, m = map(int, input().split())
print(comp(n, 2) + comp(m, 2))

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

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

Solution (Python):
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())

N,M = LI()
if N <= 1:
    n = 0
else:
    n = math.factorial(N)//((math.factorial(N-2))*(math.factorial(2)))
if M <= 1:
    m = 0
else:
    m = math.factorial(M)//((math.factorial(M-2))*(math.factorial(2)))
print(n+m)

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

Solution (Python):
import math
from sys import stdin


def get_result(data):
    N, M = data
    ans = N * (N-1) / 2 + M * (M-1) / 2 
    return int(ans)


if __name__ == '__main__':
    data = list(map(int, stdin.readline().split(' ')))
    result = get_result(data)
    print(result)

Solution (Python):

N,M = map(int,input().split())
a = 0
b = 0
for i in range(N):
    a += i

for i in range(M):
    b += i

print(a+b)

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

Solution (Python):
import itertools


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

if n >= 2:
    ans1 = len(list(itertools.combinations(range(n), 2)))
else:
    ans1 = 0

if m >= 2:
    ans2 = len(list(itertools.combinations(range(m), 2)))
else:
    ans2 = 0
print(int(ans1 + ans2))

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

Solution (Python):
n,k=map(int,input().split())
def cmb(n, r):
    if n<2:
        return 0
    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
print(cmb(n,2)+cmb(k,2))

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

Solution (Python):
def main():
  n, m = input_list()
  if n < 2:
    nk = 0
  else:
    nk = combinations_count(n, 2)
  if m < 2:
    mk = 0
  else:
    mk = combinations_count(m, 2)
  print(nk+mk)
  
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

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

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import math
import fractions
import collections
from functools import reduce
main()

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

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

nc2 = n*(n-1)/2 
mc2 = m*(m-1)/2

if n == 1 or n == 0:
    nc2 = 0
if m == 1 or m == 0:
    mc2 = 0
print(int(nc2+mc2))

Solution (Python):

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
base = comb(5,3)
m, n = map(int, input().split())
if m > 1 and n > 1:
    ans = comb(n, 2) + comb(m, 2)
elif n > 1:
    ans = comb(n, 2) 
elif m > 1:
    ans = comb(m, 2)
else:
    ans = 0
print(ans)

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

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

print (a + b)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b = MAP()

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

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

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

Solution (Python):

def combination(n, m):
    perm = 1
    dup = 1
    for i in range(m):
        perm *= (n-i)
        dup *= (m-i)
    return perm // dup
    

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

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

Solution (Python):
N, M = map(int, input().split())
a = 0
b = 0
if N > 0:
    a = N * (N - 1) // 2
if M > 0:
    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):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect




from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
input = sys.stdin.readline

sys.setrecursionlimit(2147483647)

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

if __name__ == '__main__':
  main()

Solution (Python):
def fact(n):
  if n < 2: return 1
  return n*fact(n-1)

def nc2(n):
  if n < 2: return 0
  return fact(n)//(fact(n-2)*2)

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

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) 
    
    return result
if n >= 2 and m >= 2:
     print(cmb(n,2) + cmb(m,2))
if n < 2 and m < 2:
    print(0)
if n < 2 and m >= 2:
    print(cmb(m, 2))
if n >= 2 and m < 2:
    print(cmb(n, 2))

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

mysum = 0

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

print(mysum)

Solution (Python):
import sys
from math import ceil, floor, factorial
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def comb(n, r):
    if n-r < 0:
        return 0
    return factorial(n) // (factorial(n - r) * factorial(r))


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

if __name__ == '__main__':
    main()

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

Solution (Python):
def nCr(n, r):
    return (fact(n) / (fact(r)
                       * fact(n - r)))



def fact(n):
    res = 1
    if n == 0:
        res == 1
    elif n == 1:
        res == 1
    else:
        for i in range(2, n + 1):
            res = res * i

    return res

inList = list(map(int, input().split()))
N = inList[0]
M = inList[1]
a = nCr(N, 2)
b = nCr(M, 2)
if N == M == 1:
    print(0)
else:
    print(int(a+b))

Solution (Python):
import math
import sys


scan = sys.stdin.readline


def comb(n, k):
    return math.factorial(n) // (math.factorial(k) * math.factorial(n - k)) if n >= k else 0


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

    comb_even = comb(n, 2)
    comb_odd = comb(m, 2)

    print(comb_even + comb_odd)


if __name__ == '__main__':
    main()

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

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

a = 0
if n >= 2:
    a = cmb(n,2)

b = 0
if m >= 2:
    b = cmb(m,2)

print(a+b)

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

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

Solution (Python):
import math

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

def calc(x):
    if x >= 2:
        return math.factorial(x) / (math.factorial(x - 2) * 2)
    else:
        return 0

even = (calc(n)) + (calc(m))

print(int(even))

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


for i in range(n):
    count += i
for j in range(m):
    arrrr += j
count += arrrr
print(count)

Solution (Python):

from math import factorial

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

if N >= 2:
  N1 = factorial(N) / factorial(2) / factorial(N - 2)
else:
  N1 = 0
if M >= 2:
  M1 = factorial(M) / factorial(2) / factorial(M - 2)
else:
  M1 = 0
print(int(N1+M1))

Solution (Python):
M, N = [int(k) for k in input().split(' ')]
import math 
res = 0

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

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

print(res)

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

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

print(solve())

Solution (Python):
import math


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

def c_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if n > 1 and m > 1:
    print(c_count(n, 2) + c_count(m, 2))
else:
    if n <= 1 and m > 1:
        print(c_count(m, 2))
    elif n > 1 and m <= 1:
        print(c_count(n, 2))
    else:
        print(0)

Solution (Python):
from itertools import permutations, combinations,combinations_with_replacement,product

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

s = [1 for _ in range(n)]
t = [1 for _ in range(m)]

a = list(combinations(s, 2))
b = list(combinations(t, 2))

print(int(len(a)) + int(len(b)))

Solution (Python):
import math
N,M = list(map(int,input().split()))
m = 0
n = 0
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if M>1:
    m =comb(M,2)
if N>1:
    n = comb(N,2)
ans = m +n
print(ans)

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


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


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

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

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

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

Solution (Python):
import math

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

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

odd = 1
if (NM[1] > 1):
    odd = permutations_count(NM[1], 2)

even = 1
if (NM[0] > 1):
    even = permutations_count(NM[0], 2)

sum = 0
if (odd > 1):
    sum += int(odd / 2)
if (even > 1):
    sum += int(even / 2)

print(sum)

Solution (Python):
from itertools import combinations
from math import factorial


def combinations_count(n):
    if n < 2:
        return 0
    return factorial(n) // (factorial(n - 2) * factorial(2))


if __name__ == "__main__":
    n, m = map(int, input().split())
    print(combinations_count(n) + combinations_count(m))

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

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

cnt = 0

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

print(int(cnt))

Solution (Python):

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

def permutations_count(n, r):
  if n == 2:
    return 1
  elif n <= 1:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))



total = permutations_count(N, 2)


total += permutations_count(M, 2)
print(total)

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

nC2 = N * (N - 1) // 2
mC2 = M * (M - 1) // 2

print(nC2 + mC2)

Solution (Python):
A,B=map(int, input().split())
import math
def comb(n, r):
  if n < 2:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
print(comb(A,2)+comb(B,2))

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

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

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

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

res = 0

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

print(res)

Solution (Python):
import math
def per_count(n, r):
    result = 0
    if n >= r:
        result = math.factorial(n) // math.factorial(n - r)
    return result

N, M = map(int, input().split())
result = (per_count(N, 2) + per_count(M, 2)) // 2
print(result)

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

oo = m*(m-1)
ee = n*(n-1)

ans = oo + ee
print(ans//2)

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

Solution (Python):
import math

def permutations_count(n, r):
    return math.factorial(n) // ( math.factorial(n - r) * math.factorial(r) )
n , m = map(int,input().split())

x ,y = 0,0
if n > 1 :
    x = permutations_count(n,2)

if m > 1:
    y = permutations_count(m,2)

print(x+y)

Solution (Python):
import math
def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
N, M = (int(i) for i in input().split())  

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

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

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N < 2:
    base = 0
else:
    base = comb(N,2)
    
if M < 2:
    base2 = 0
else:
    
    base2 = comb(M,2)

print(base+base2)

Solution (Python):

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

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

print(ans)

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

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

    all = int(((n + m)*(n+m-1))/2)
    ki = n*m
    gu = int(all - ki)
    print(gu)


if __name__ == "__main__":
    a_159()

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

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


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

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

print(int(ans))

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

if n == 1 and m ==1:
    print(0)
    exit()

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

Solution (Python):
a, b = map(int,input().split())
count = 0
for i in range(1,a+1):
    count += a - i

for x in range(1,b+1):
    count += b - x


print(count)

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


c = math.factorial(n+m)//(math.factorial(2)*math.factorial((n+m) - 2))
print(c - n*m)

Solution (Python):
Even, Odd = map(int, input().split())

if Odd > 1:
    ans1 = Even * (Even-1) / 2
    ans2 = Odd * (Odd-1) / 2
else:
    ans1 = Even * (Even-1) / 2
    ans2 = 0
print(int(ans1+ans2))

Solution (Python):

import itertools

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

n_cnt = 0
m_cnt = 0

if n >= 2:
    n_cnt = len(list(itertools.combinations(range(n), 2)))

if m >= 2:
    m_cnt = len(list(itertools.combinations(range(m), 2)))

print(n_cnt + m_cnt)

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

Solution (Python):
num=list(map(int,input().split()))
com_1=0
com_2=0

if num[0]<=1:
    com_1=0
else:
    com_1=(num[0]*(num[0]-1))/2

if num[1]<=1:
    com_2=0
else:
    com_2=(num[1]*(num[1]-1))/2

print(int(com_1 + com_2))

Solution (Python):
import math

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

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

c = combinations_count(N+M, 2)

print(c-(N*M))

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

Solution (Python):
from math import factorial

def fact(n):
    r = 2
    if n - r < 0:
        return 0
    return factorial(n) // factorial(r) // factorial(n - r)

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

print(fact(N)  + fact(M))

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

res = 0

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

print(int(res))

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())
def com(n, r):
    if n<r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
print(com(n,2)+com(m,2))

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

Solution (Python):
from scipy.misc import comb
n, m = map(int,input().split())

ans = comb(n,2,exact=True) + comb(m,2,exact=True)
print(ans)

Solution (Python):
from sys import stdin

N, M = [int(x) for x in stdin.readline().rstrip().split()]

sum_ = 0

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

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

print(int(sum_))

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

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

count=0

if a>=2:
    count+=combinations_count(a,2)

if b>2:
    count+=combinations_count(b,2)

print(count)

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

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


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
num = [int(n) for n in input().split()]

def comb(x):
    if x >= 2:
        return (x * (x-1)) / 2
    else:
        return 0

r = 0

for i in num:
    r += comb(i)

print(int(r))

Solution (Python):

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

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

Solution (Python):
from math import factorial

number = input().split(" ")
N = int(number[0])
M = int(number[1])

if N > 1:
    a = factorial(N) / factorial(2) / factorial(N - 2)
else:
    a = 0
if M > 1:
    b = factorial(M) / factorial(2) / 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

def combinations_count(count, r):
    if count <= 1:
        return 0

    return math.factorial(count) // (math.factorial(count - r) * math.factorial(r))

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

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