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



Sample input:
2 1


Sample output:
1

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
N = A[0]
M = A[1]

# 偶数＋偶数
pattern_1 = N*(N-1)/2

# 奇数＋奇数
pattern_2 = M*(M-1)/2

print(int(pattern_1 + pattern_2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()

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


print(main())

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))

N = a[0]
M = a[1]

N_combi = N*(N-1)/2
M_combi = M*(M-1)/2

print(int(N_combi+M_combi))

Submission status: Accepted

Solution code:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = open(0).read().strip('\n').split(' ')
S = [int(s) for s in S]
even = 0 if  S[0]==1 else S[0]*(S[0]-1)/2
odd = 0 if  S[0]==1 else S[1]*(S[1]-1)/2
print(int(even+odd))

Submission status: Accepted

Solution code:
m,n=(int(x) for x in input().split());
even = m*(m-1)/2;
odd = n*(n-1)/2;

result = int(even + odd);
print(result);

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  4 19:20:51 2020

@author: Kanaru Sato
"""

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

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

if m <= 1:
    ans2 = 0
else:
    ans2 = m*(m-1)/2
    
ans = ans1+ans2
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = list(map(int, input().split()))
N = i[0]
M = i[1]

guusuu = (N * (N-1)) // 2
kisuu = (M * (M-1)) // 2

print(guusuu + kisuu)

Submission status: Accepted

Solution code:
"""
A-The Number of Even Pairs
"""

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

Submission status: Accepted

Solution code:
def rC2(r):
    return int(r*(r-1)//2)

N, M = list(map(int, input().split()))
num_N = rC2(N)
num_M = rC2(M)

print(num_N + num_M)

Submission status: Accepted

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

def comb_num(a, b):
    if a - b < b: b = a - b
    if b == 0: return 1
    if b == 1: return a

    numerator = [a - b + k + 1 for k in range(b)]
    denominator = [k + 1 for k in range(b)]

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

    result = 1
    for k in range(b):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if N >= 2:
    num_n = comb_num(N,2)
else:
    num_n = 0

if M >= 2:
    num_m = comb_num(M,2)
else:
    num_m = 0

print(num_n + num_m)

Submission status: Accepted

Solution code:
def comb_2(x):
    if x < 2:
        return 0
    return x * (x - 1) // 2


a, b = map(int, input().split())
print(comb_2(a) + comb_2(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N,M=map(int,input().split())
if N<=1 and M<=1:
    print(0)
elif N<=1 and M>1:
    Mn = math.factorial(M)/(math.factorial(2)*math.factorial(M-2))
    print(int(Mn))
elif M<=1 and N>1:
    Nn = math.factorial(N)/(math.factorial(2)*math.factorial(N-2))
    print(int(Nn))
else:
    Nn = math.factorial(N)/(math.factorial(2)*math.factorial(N-2))
    Mn = math.factorial(M)/(math.factorial(2)*math.factorial(M-2))
    print(int(Nn+Mn))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().split()
N = int(S[0])
M = int(S[1])

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

Submission status: Accepted

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

Submission status: Accepted

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

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

s = n + m
print(combinations_count(s,2) - (combinations_count(n,1)*combinations_count(m,1)))

Submission status: Accepted

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

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

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

print(int(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(int(a+b))

Submission status: Accepted

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

P = 0

if N >= 2:
    for i in range(N - 1):
        for j in range(N - 1 - i):
            P = P + 1

if M >= 2:
    for i in range(M - 1):
        for j in range(M - 1 - i):
            P = P + 1

print(P)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = input().split()
n = int(num[0])
m = int(num[1])

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

Submission status: Accepted

Solution code:
from sys import stdin
N, M = map(int, input().split()) 

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 159: A – The Number of Even Pairs
n, m = map(int, input().split())
print(n * (n - 1) // 2 + m * (m - 1) // 2)

Submission status: Accepted

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

num = 0
for n in range(1, N):
  num += n
for n in range(1, M):
  num += n
print(num)

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

Solution code:
from scipy.misc import comb
 
n,m = map(int, input().split())
 
if n>1:
  even = comb(n,2, exact=True)
else:
  even = 0
 
if m>1:
  odd = comb(m,2, exact=True)
else:
  odd = 0
 
ans = even + odd
print(str(int(ans)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N,M = map(int, input().split())
def combinations_count(n,r):
	if n == 0 or n == 1:
		return 0
	elif n == 2:
		return 1
	else: return math.factorial(n) // (math.factorial(n-r)*math.factorial(r))
print(combinations_count(N,2) + combinations_count(M,2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inp=str(input())
N= int(inp.split()[0])
M=int(inp.split()[1])
n= abs(N)
m=abs(M)
sum_N = (N-1)*N/2
sum_M=(M-1)*M/2
sum_all = sum_N + sum_M
print(int(sum_all))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def even_count(N):
    if N == 0:
        return 0
    elif N == 1:
        return 0
    else:
        return N * (N-1) // 2

def odd_count(M):
    if M == 0:
        return 0
    elif M == 1:
        return 0
    else:
        return M * (M-1) // 2

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

num_even = even_count(N)
num_odd = odd_count(M)
amount = num_even + num_odd
print(amount)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#偶数タス偶数または奇数タス奇数
import math
def combinations_count(a, b):
    return math.factorial(a) // (math.factorial(a - b) * math.factorial(b))

if n >= 2:
    ans1 = combinations_count(n, 2)
else:
    ans1 = 0

if m >= 2: 
    ans2 = combinations_count(m, 2)
else:
    ans2 = 0
    
print(ans1 + ans2)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
def factorial(x):
    f = 1
    for i in range(1, x+1):
        f *= i
    return f
ans = 0
if n < 2 and m < 2:
    ans = 0
    print(ans)
elif n < 2:
    ans = int(factorial(m) / (factorial(2) * factorial(m - 2)))
    print(ans)
elif m < 2:
    ans = int(factorial(n) / (factorial(2) * factorial(n - 2)))
    print(ans)
else:
    ans = int(factorial(m) / (factorial(2) * factorial(m - 2)) + factorial(n) / (factorial(2) * factorial(n - 2)))
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m, n = input("").split()
m = int(m)
n = int(n)
total = 0
if m > 1:
    total += m*(m-1)/2
if n > 1:
    total += n*(n-1)/2
print(int(total))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N, M = list(map(int, input().split()))
if N==M==1:
    print(0)
elif M < 2:
    print(int(math.factorial(N)/math.factorial(2)/math.factorial(N-2)))
elif N==0:
    print(int(math.factorial(M)/math.factorial(2)/math.factorial(M-2)))
else:
    print(int(math.factorial(N)/math.factorial(2)/math.factorial(N-2) +  math.factorial(M)/math.factorial(2)/math.factorial(M-2)))

Submission status: Accepted

Solution code:
from scipy.misc import comb
N, M = map(int, input().split())
print(comb(N, 2, exact=True) + comb(M, 2, exact=True))

Submission status: Accepted

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

nout =n* (n-1)//2
mout =m* (m-1)//2

print(nout+mout)

Submission status: Accepted

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

n = N*(N-1)/2
m = M*(M-1)/2
s = int(m+n)
print(s)

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p, q = 0, 0
for i in range(n):
    p = p + i
for i in range(m):
    q = q + i
print(p + q)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
n = 0
m = 0
for i in range(N-1):
    n += N

for j in range(M-1):
    m += M
    
Nans = n//2
Mans = m//2
print(Nans + Mans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ここにコード書く
n, m = map(int, input().split())
# combination nC2 mC2
ans = n * (n - 1) / 2 + m * (m - 1) / 2
print(int(ans))

Submission status: Accepted

Solution code:
from scipy.misc import comb

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

print(comb(N,2, exact=True) + comb(M,2,exact=True))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math as m

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


def comb(n, r):
    if n <= 1:
        return 0
    else:
        return m.factorial(n) / (m.factorial(n - r) * m.factorial(r))


print(int((comb(n[0], 2)+comb(n[1], 2))))

Submission status: Accepted

Solution code:
o=input().rstrip().split(' ')
a=int(o[0])
b=int(o[1])
c=(a*(a-1))//2;
d=(b*(b-1))//2;


print(c+d)

Submission status: Accepted

Solution code:
from functools import reduce
mod=10**9+7
def f(A,B):
 if B==0:
  den=1
  num=1
 else:
  den=reduce(lambda x,y:x*y%mod,range(A,A-B,-1))
  num=reduce(lambda x,y:x*y%mod,range(1,B+1))

 return den*pow(num,mod-2,mod)%mod
n,m=map(int,input().split())
print(f(n,2)+f(m,2))

Submission status: Accepted

Solution code:
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product

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

#print(t)
N = t[0] #偶数
M = t[1]

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

Submission status: Accepted

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

print(int(ans))

Submission status: Accepted

Solution code:
import sys

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

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

def main():
    res = choose2(n) + choose2(m)
    print(res)

if __name__ ==  '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 30 23:58:42 2020

@author: black
"""


N, M = map(int, input().split())
#偶数と偶数または奇数と奇数
print(round(N*(N-1)/2 + M*(M-1)/2))

Submission status: Accepted

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

pattern = 0

for i in range(n):
    pattern = pattern + n - (i+1)

for i in range(m):
    pattern = pattern + m - (i+1)
    
print(pattern)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def bikkuri(n):
    if n <= 0:
        return 1
    else:
        return n * bikkuri(n - 1)

nm = input().split(" ")
print(bikkuri(int(nm[0])) // (bikkuri(int(nm[0]) - 2) * 2) * (0 if int(nm[0]) < 2 else 1) + bikkuri(int(nm[1])) // (bikkuri(int(nm[1]) - 2) * 2) * (0 if int(nm[1]) < 2 else 1))

Submission status: Accepted

Solution code:
N,M=input().split()
N=int(N)
M=int(M)
a=0
b=0
if N>=2:
    a=N*(N-1)/2
    
if M>=2:
    b=1
    b=M*(M-1)/2
c=a+b
print(int(c))

Submission status: Accepted

Solution code:
str1 =str(input())
s1 = str1.split(' ')
m = int(s1[0])
n = int(s1[1])
x = (m*(m-1))/2
y = (n*(n-1))/2
print(int(x+y))

Submission status: Accepted

Solution code:
def solve(string):
    n, m = map(int, string.split())
    return str((n + m) * (n + m - 1) // 2 - n * m)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
if a<=1 and b<=1:
    print(0)
if a<=1 and 1<b:
    print((b*(b-1))//2)
if 1<a and b<=1:
    print((a*(a-1))//2)
if 1<a and 1<b:
    print(((a*(a-1))//2)+((b*(b-1))//2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力 : N M
N,M = map(int,input().split())

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

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 初期入力
N_gu,M_ki = map(int, input().split())

# 最初に偶数をとると　残りはN_gu -1,M_ki
# 和が偶数とは　偶数＋偶数　OR　奇数＋奇数
from math import factorial

def kumiawase_num(n, r):
    if  n<r:
        return 0
    return factorial(n) // (factorial(n - r) * factorial(r))
def kumiawase_jufuku(n, r):
    if  n<r:
        return 0
    else:
        return kumiawase_num(n + r - 1, r)

gu_gu = kumiawase_num(N_gu , 2) #  
ki_ki = kumiawase_num(M_ki, 2)
print(gu_gu + ki_ki)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
st = input().split()

n = int(st[0])
m = int(st[1])
print(int(n * (n - 1) / 2 + m * (m - 1) / 2))

Submission status: Accepted

Solution code:
import math
m,n=map(int,input().split())
j=0
if m>1:
  j+=math.factorial(m)/math.factorial(m-2)/2
if n>1:
  j+=math.factorial(n)/math.factorial(n-2)/2
print(int(j))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = list(map(int, input().split()))
N = i[0]
M = i[1]

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

Submission status: Accepted

Solution code:
import math

def combi(num):
    return num*(num-1)//2

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



print(combi(n) + combi(m))

Submission status: Accepted

Solution code:
def cmb(a):
  if a<2:
    return 0
  return a*(a-1)//2
m,n=map(int,input().split())
print(cmb(m)+cmb(n))

Submission status: Accepted

Solution code:
import math

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

even,odd = map(int,input().split())
ans = 0
if even>=2:
    ans += comb(even,2)
if odd>=2:
    ans += comb(odd,2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
N, M = map(int, input().split())
even = []
odd = []

for i in range(N):
  even.append(2)

for i in range(M):
  odd.append(1)
  
lst = even + odd

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

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split(" "))
count = 0
for i in range(1,n+m):
    count += i
count -= n * m
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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



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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

Submission status: Accepted

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

answer1 = N * (N - 1) / 2
answer2 = M * (M - 1) / 2

print(int(answer1 + answer2))

Submission status: Accepted

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

#N = 13 #奇数
#M = 3 #偶数

#2個選んで総和が偶数
# 奇数、奇数＝偶数、偶数、偶数＝偶数

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

Submission status: Accepted

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

Submission status: Accepted

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

print(int(A + B))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

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

N_M_list=[2]*N+[1]*M

c = list(itertools.combinations(N_M_list, 2))

cnt=0

for i in c:
    if sum(i)%2==0:
        cnt+=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

# 偶数と偶数の方法の数
eeCount = n * (n - 1) / 2

# 奇数と奇数の方法の数
ooCount = m * (m - 1) / 2

print(int(eeCount + ooCount))