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:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

x,y = map(int,input().split())

print(int((x * (x-1)) / 2  + (y * (y - 1))/2))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
# N 個の偶数 と　M個の奇数

# 2個選ぶ=偶数になる->2個とも偶数か2個とも奇数
print(N * (N - 1) // 2 + 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:
n, m = map(int, input().split())

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

Submission status: Accepted

Solution code:
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

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

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

Submission status: Accepted

Solution code:
inp=input().split()
n=int(inp[0])
m=int(inp[1])
arr=[]
pares=0
impares=0
count=1
nums=0

def binary(arr, menor, mayor, x): 
    if mayor >= menor: 
        med = (mayor + menor) // 2
        if arr[med] == x: 
            return med 

        elif arr[med] > x: 
            return binary(arr, menor, med - 1, x) 
  
        else: 
            return binary(arr, med + 1, mayor, x) 
    else: 
        return -1

while len(arr)<(m+n):
    if count%2==0 and pares<n:
        arr.append(count)
        pares+=1
    elif count%2!=0 and impares<m:
        arr.append(count)
        impares+=1
    count+=1
sums=[]


for x in arr:
   for y in arr:
        if(x+y)%2==0 and binary(sums, 0, len(sums)-1, [y,x])==-1 and x!=y:
            sums.append([x,y])
            nums+=1
print(nums)

Submission status: Accepted

Solution code:
a=input("")
lista=a.split()
lista2=[]
par=0
impar=-1
contador=0
for i in range (int(lista[0])):
  par+=2
  lista2.append(par)
for i in range (int(lista[1])):
  impar+=2
  lista2.append(impar)
longitud=len(lista2)-1

for i in range (0,len(lista2)):
  b=i
  while True:
    if b+1>longitud:
      break 
    else: 
      suma=lista2[i]+lista2[b+1]
      b=b+1
      if suma%2==0:
        contador+=1
      
print(contador)

Submission status: Accepted

Solution code:
a = list(map(int, input().rstrip().split()))
out=0
for i in a:
    if i > 1:
        out += i*(i-1)//2
print(out)

Submission status: Accepted

Solution code:
import numpy as np
#n = int(input())
a = list(map(int, input().rstrip().split()))
out=0
for i in a:
    if i > 1:
        out += i*(i-1)//2
print(out)

Submission status: Accepted

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

n,m=map(int,input().split())
if (n<=1) and (m<=1):
  ans=0
else:
  if n<=1:
    ans=comb(m,2)
  elif m<=1:
    ans=comb(n,2)
  else:
    ans=comb(n,2)+comb(m,2)
  
print(ans)

Submission status: Accepted

Solution code:
import itertools
n,m=map(int,input().split())
i = [2]*n
j = [2]*m
p = list(itertools.combinations(i, 2))
q = list(itertools.combinations(j, 2))
print(len(p)+len(q))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 >= 2 and m >= 2:
    ans = combinations_count(m, 2) + combinations_count(n, 2)
elif n < 2 and m < 2:
    ans = 0
elif n < 2:
    ans = combinations_count(m, 2)
elif m < 2:
    ans = combinations_count(n, 2)


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

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

Submission status: Accepted

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

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

print(int(sum))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from scipy.special import comb
N,M = input().split()
N = int(N)
M = int(M)

A = 0
B = 0
if N >= 2 :
  A = comb(N, 2, exact=True)

if M >= 2 :
  B = comb(M, 2, exact=True)
 
print(A + B)

Submission status: Accepted

Solution code:
import math
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 n > 1:
    an = n*(n-1)/2
else:
    an = 0
if m>1:
    am = m*(m-1)/2
else:
    am = 0
print(int(an+am))

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

Submission status: Accepted

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

resolve()

Submission status: Accepted

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

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

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

print(int(even+odd))

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

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

print(ans)

Submission status: Accepted

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


main()

Submission status: Accepted

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

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

# Think about sets
all = (N+M) * (N+M-1) // 2
odd = N * M
print(all - odd)

Submission status: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    T=N+M
    T=((T*(T-1))/2)
    return print(int(T-M*N))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(int(cnt))

Submission status: Accepted

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

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

print(int(c))

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

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

Submission status: Accepted

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

ki = (N*(N-1))//2
gu = (M*(M-1))//2

print (ki+gu)

Submission status: Accepted

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

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

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())
ans = N*(N-1)//2 + 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:
import math

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

def c(a, b):
    if a >= 2:
        return math.factorial(a) // (math.factorial(b) * math.factorial(a - b))
    else:
        return 0
        

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

Submission status: Accepted

Solution code:
[N, M] = [int(i) for i in input().split()]
print(int(N*max(N-1, 0)/2) + int(M*max(M-1, 0)/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(N * (N - 1) // 2 + M * (M - 1) // 2)

Submission status: Accepted

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

    e = N*(N-1)/2
    o = M*(M-1)/2

    ans = int(e + o)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

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

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

print(int(even+odd))

Submission status: Accepted

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

kotae = int(N * (N - 1) / 2)
kotae2 = int(M  * (M - 1) / 2)

print(kotae + kotae2)

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

Submission status: Accepted

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

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:
import math
n, m = input().split()
n = int(n)
m = int(m)
x = 0
y = 0
if n > 1:
  x = int(math.factorial(n)/(2 * math.factorial(n-2)))
if m > 1:
  y = int(math.factorial(m)/(2 * math.factorial(m-2)))

print(x+y)

Submission status: Accepted

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

ans = 0

n1 = n*(n-1)/2

n2 = m*(m-1)/2

ans = int(n1 + n2)

print(ans)

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:

def main():
    n, m = list(map(int, input().split(" ")))
    ans = 0
    ans += n*(n-1)/2
    ans += m*(m-1)/2
    print(int(ans))
    

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = int(N*(N-1)/2 + 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:
print(sum([i*(i-1)//2 for i in list(map(int, input().split()))]))

Submission status: Accepted

Solution code:
from scipy.special import comb

N, M = map(int, input().split())
ans = comb(N + M, 2, exact=True) - (N * M)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ri = lambda S: [int(v) for v in S.split()]
N, M = ri(input())

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

print(int(c))

Submission status: Accepted

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

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


a = comb(n, 2)
b = comb(m, 2)
print(a+b)

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:
import itertools
n,m = map(int, input().split())
ball = [2*i for i in range(1,n+1)] + [(2*j)-1 for j in range(1,m+1)]

cnt = 0

for c in itertools.combinations(ball,2):
    cnt += sum(c)%2 == 0

print(cnt)

Submission status: Accepted

Solution code:

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

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

if n == 1 or n == 0 :
  n_c = 0
else :
  n_c = n * (n-1) / 2
if m == 1 or m == 0 :
  m_c = 0
else :
  m_c = m * (m-1) / 2

print(int(n_c + m_c))

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,1(M=0,1)の場合も成り立つ
a = N*(N-1) // 2
b = M*(M-1) // 2
  
print(a+b)

Submission status: Accepted

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

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

if M <= 1: b = 0
else: b = M*(M-1) // 2
  
print(a+b)

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:
N, M = [int(n) for n in input().split(" ")]

def comb(n):
    if n <= 1:
        return 0
    return n * (n - 1) // 2

print(comb(N) + comb(M))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#A
N, M = map(int,input().split())
eve=[2*i for i in range(N)]
odd=[2*i+1 for i in range(M)]

from itertools import combinations
comb_eve=len(list(combinations(eve,2)))
comb_odd=len(list(combinations(odd,2)))

print(comb_eve+comb_odd)

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:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    def select(n,k):
        return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    n,m = LI()
    ans = 0
    if n>=2:
        ans += n*(n-1)//2
    if m>=2:
        ans += m*(m-1)//2

    print(ans)
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:
import math


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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=int((n*(n-1)+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:
import math
def count(n, r):
    return math.factorial(n) // math.factorial(n - r)
def main():
  N, M = map(int, input().split())
  if (N == 0 and M == 0) or (N == 1 and M == 1):
    ans = 0
  elif N == 0 or N == 1:
    y = count(M, 2)
    ans = y
  elif M == 0 or M == 1:
    x = count(N, 2)
    ans = x
  else:
    x = count(N, 2)
    y = count(M, 2)
    ans = x + y
  print(int(ans/2))

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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


if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def kai(n):
    a=1
    for i in range(1,n+1):
        a=a*i
    return a

N,M=map(int,input().split())
if N==0 or N==1:
    g=0
else:
    g=kai(N)/(kai(N-2)*2)
if M==0 or M==1:
    k=0
else:
    k=kai(M)/(kai(M-2)*2)
print(int(g+k))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(n+m)

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:
from scipy.special 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())
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())
if (n < 2):
  a = 0
else:
  a = int(n*(n - 1)/2)
if (m < 2):
  b = 0
else:
  b = int(m*(m - 1)/2)
print(a + b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from scipy.special import comb

N,M=map(int,input().split())
base=0
base += comb(N, 2, exact=True)
base += comb(M, 2, exact=True)
print(base) # 10

Submission status: Accepted

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

if '__main__' == __name__:
    resolve()

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

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

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N, M = MI()

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

print(a + b)

Submission status: Accepted

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

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

print(combi(N) + combi(M))

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

Submission status: Accepted

Solution code:
N,M=list(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(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())

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

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

ans1 = (n*(n-1))//2
ans2 = (m*(m-1))//2

print(ans1+ans2)

Submission status: Accepted

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

from operator import mul
from functools import reduce

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


print(cmb(N+M,2)-N*M)

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:
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int(b*(b-1)/2)))
else:
    print(str(int(a*(a-1)/2)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
totalN = 1/2*(N-1)*N
totalM = 1/2*(M-1)*M
import math

print(math.floor(totalN + totalM))

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:
# ABC159
# A The Number of Even Pairs
import math
n, m = map(int, input().split())
if n < 2:
    x = 0
else:
    x = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

if m < 2:
    y = 0
else:
    y = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))

print(x+y)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
n, m = [int(x) for x in input().split()]
def c2(n):
    return n * (n - 1) // 2
print(c2(n) + c2(m))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
n, m = [int(i) for i in input().split()]
t = 0
tt = 0
def com(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if n > 1:
    t = com(n,2)
if m > 1:
    tt = com(m,2)

print(t+tt)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
l = ['e'] * N + ['o'] * M
cnt = 0
for i in range(len(l)-1):
    for j in range(i+1, len(l)):
        if l[i] != l[j]:
            pass
        else:
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
# The Number of Even Pairs
import math
N, M = map(int, input().split())

def combinations_count(N, M):
    return (math.factorial(N + M) // (math.factorial(N + M - 2) * math.factorial(2)))

ans = combinations_count(N, M) - N * M
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    N,M = [int(i) for i in input().split()]
    ans = 0
    if N > 1:
        ans += N * (N-1) // 2
    if M > 1:
        ans += M * (M-1) // 2
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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 = list(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 = [int(i) for i in input().split(' ')]
print((N * (N - 1) + M * (M - 1)) // 2)