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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#A
n, m = [int(_) for _ in input().split()]
print(int(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())
ans1 = 0
ans2 = 0

if(N >= 2):    
    ans1 = (N*(N-1))//2
if(M >= 2):
    ans2 = (M*(M-1))//2

print(ans1+ans2)

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 bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = LI()
    even_num = N*(N-1)/2    #NC2
    odd_num = M*(M-1)/2     #MC2
    print(int(even_num + odd_num))

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N,M = map(int, input().split())
N_num = 0
M_num = 0

if N >= 2:
  N_num = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))
if M >= 2:
  M_num = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))

print(N_num + M_num)

Submission status: Accepted

Solution code:
import math 
import sys 
#t=int(sys.stdin.readline())
t=1
for _ in range(t):
    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(n*(n-1)//2 + m *(m-1)//2)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    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:
List = list(map(int, input().split()))

if List[0] >= 2 and List[1] >= 2:
    c = List[0]*(List[0]-1)/2  + List[1]*(List[1]-1)/2
elif List[0] < 2 and List[1] >= 2:
    c = List[1]*(List[1]-1)/2
elif List[0] >= 2 and List[1] < 2:
    c = List[0]*(List[0]-1)/2
else:
    c = 0

print(int(c))

Submission status: Accepted

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

N = int(N)
M = int(M)

even = 0
odd = 0
final = int

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

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 sys import stdin, setrecursionlimit


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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
from itertools import *

def main():
    N, M = list(map(int, input().split()))
    print(len(list(combinations(range(N), 2))) + len(list(combinations(range(M), 2))))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
def fac(k):
    return(math.factorial(k)//(math.factorial(k-2)*2))


n,k = input().split()
n = int(n) 
k = int(k)
se = 0

if k > 1:
    if n > 1:
        se = fac(k) + fac(n)
    else:
        se= fac(k)
else:
    if n > 1:
        se =  fac(n)
    else:
        se = 0
print(se)

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

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

Submission status: Accepted

Solution code:
import operator as op
from functools import reduce

def comb(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
n,m = map(int, input(). split())
A = 0
B = 0
if n >= 2:
  A = int(comb(n, 2))
if m >= 2:
  B = int(comb(m, 2))
print(A + B)

Submission status: Accepted

Solution code:
from math import factorial

def choose(n, k):
    if n < k:
        return 0
    else:
        return factorial(n) // factorial(k) // factorial(n - k)

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

Submission status: Accepted

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

pattern_o=(N-1)*N/2
pattern_e=(M-1)*M/2

print(int(pattern_o+pattern_e))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
def comb(n, r):  # 組み合わせ
    if n <= 0 or r > n: return 0
    return factorial(n) // factorial(n - r) // factorial(r)

answer = comb(N, 2) + comb(M, 2)
print(answer)

Submission status: Accepted

Solution code:
e,o=map(int,input().split())
r=0
if e>=2:
  r+=e*(e-1)/2
if o>=2:
  r+=o*(o-1)/2
print(int(r))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

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

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
c = 0
c += int(n*(n-1)/2)
c += int(m*(m-1)/2)
print(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())
even = n * (n - 1) // 2
odd = m * (m - 1) // 2
print(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:
if __name__ == "__main__":
    n, m = map(int, input().split())
    part1 = 0
    if n >= 2:
        part1 = n * (n - 1) // 2
    part2 = 0
    if m >= 2:
        part2 = m * (m - 1) // 2
    print(part1 + part2)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
ans = 0
if n >= 2:
    ans += int(n*(n - 1) / 2)
if m >= 2:
    ans += int(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("{}".format(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def minusOneFactorial(num):
    return sum([i-1 for i in range(1,num+1)])

N,M = [int(i) for i in input().split()]
possible_evens = minusOneFactorial(N)
possible_odds = minusOneFactorial(M) if not M==0 else 0
print(possible_evens + possible_odds)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
result=0
n1=1
m1=1
for i in range(n-1,n+1):
    n1*=i
for k in range(m-1,m+1):
    m1*=k
print(int((n1+m1)/2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import factorial


def nc2(n):
    return factorial(n) // 2 // factorial(n - 2)


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

patterns = 0

if N > 1:
    patterns += nc2(N)

if M > 1:
    patterns += nc2(M)

print(patterns)

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

Submission status: Accepted

Solution code:
import math
M, N = (int(x) for x in input().split())
def combinations_count(n, r):
  if n >= 2:
    ans = math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  else:
    ans = 0
  return ans

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

Submission status: Accepted

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

ki_ki = M*(M-1)/2
guu_guu = N*(N-1)/2
if ki_ki<0:
    ki_ki = 0
if guu_guu < 0:
    guu_guu = 0

print(int(ki_ki +guu_guu))

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
even = [2]*N
odd = [1]*M
a = even+odd
ans = 0
for i in range(N+M):
    for j in range(i+1, N+M):
        if (a[i]+a[j]) % 2 == 0:
            ans += 1
print(ans)

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 = list(map(int, input().split()))
N = combinations_count(N, 2) if N >= 2 else 0
M = combinations_count(M, 2) if M >= 2 else 0

print(N + M)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
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()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()

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

Submission status: Accepted

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


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


def main():
    N, M = map(int, sys.stdin.readline().split())
    print(solve(N, M))


if __name__ == '__main__':
    main()

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:
def resolve():
    import itertools
    N,M = map(int,input().split())
    N_list = [int(x) for x in range(N)]
    M_list = [int(y) for y in range(M)]

    n = len(list(itertools.combinations(N_list,2)))
    m = len(list(itertools.combinations(M_list,2)))
    print(n+m)

resolve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
N, M = list(map(int, input().split()))


def main() -> None:
    """Entry point
    """
    # 求解処理
    # N個のボールから2個またはM個のボールから2個選んだ場合の数
    result = int(N*(N-1)/2 + M*(M-1)/2)

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
N, M = list(map(int, input().split()))

# 求解処理
result = int(N*(N-1)/2 + M*(M-1)/2)

# 結果出力
print(result)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=0
import math
def combinations_count(w, r):
    return math.factorial(w) // (math.factorial(w - r) * math.factorial(r))
if n<=1:
    pass
else:
    ans+=combinations_count(n,2)
if m<=1:
    pass
else:
    ans+=combinations_count(m,2)
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':

    ABC_159_A()

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

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())
nC2 = max(0, n*(n-1)/2)
mC2 = max(0, m*(m-1)/2)
print(int(nC2 + mC2))

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

def check_even_number(N, M):
    if N <= 1:
        combination_N = 0
    else:
        combination_N = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))

    if M <= 1:
        combination_M = 0
    else:
        combination_M = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
        
    return combination_N + combination_M


if __name__ == "__main__":
    N, M = map(int, input().split())
    print(check_even_number(N, M))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

cn = 0
cm = 0

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

if m < 2:
    cm = 0
elif m == 2:
    cm = 1
else:
    cm = m * (m-1) / 2

ans = cn + cm
print(int(ans))

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

x = math.factorial(int(N))
y = math.factorial(int(M))

if N > 2 and M > 2:
    Nk = N - 2
    Mk = M - 2
    Nk2 = math.factorial(int(Nk))
    Mk2 = math.factorial(int(Mk))
    CN = x // Nk2 // 2
    CM = y // Mk2 // 2
    print(CN + CM)

elif N > 2 and M <= 2:
    Nk = N - 2
    Nk2 = math.factorial(int(Nk))
    CN = x // Nk2 // 2
    M = M // 2
    print(CN + M)

elif N <= 2 and M > 2:
    Mk = M - 2
    Mk2 = math.factorial(int(Mk))
    CM = y // Mk2 // 2
    N = N // 2
    print(CM + N)

elif N <= 2 and M <= 2:
    N = N // 2
    M = M // 2
    print(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:
import sys
from math import factorial

def comb(n,r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return int(a)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

a = comb(N, 2) if N>=2 else 0
b = comb(M, 2) if M >=2 else 0
ans = N * (N-1) // 2 + M * (M-1) //2
print(ans)

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

su = combinations_count(n+m, 2)
mm = n*m
ans = su-mm

print(str(ans))

Submission status: Accepted

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

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 itertools
a=list(itertools.combinations(range(1,n+1),2))
b=list(itertools.combinations(range(1,m+1),2))
print(len(a)+len(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())
ans = 0

if(n>1):
	ans += (n*(n-1))/2
if(m>1):
	ans += (m*(m-1))/2
print(int(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:
#! env/bin/local python3
# -*- coding: utf-8 -*-

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

pick_up_from_n = n * (n - 1) // 2
pick_up_from_m = m * (m - 1) // 2

print(pick_up_from_m + pick_up_from_n)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

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

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

odd = nC2(m)
even = nC2(n)

print(int(odd + even))

Submission status: Accepted

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

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

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:
# -*- coding: utf-8 -*-
N,M=map(int,input().split())
k = N * (N-1) // 2
g = M * (M-1) // 2
print(k + g)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(n + m)

Submission status: Accepted

Solution code:
N,M=list(map(int,input().split()))
from math import factorial as f
f_1,f_2=0,0
if N>1:
    f_1=f(N)/(f(2)*f(N-2))
if M>1:
    f_2=f(M)/(f(2)*f(M-2))
print(int(f_1+f_2))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed May  6 16:43:05 2020

@author: shinba
"""
N,M = map(int,input().split())

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

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:
# A - The Number of Even Pairs

import math

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

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

print(cnt)

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

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

Submission status: Accepted

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

if a > 0:
  a = a * (a - 1) // 2
  
if b > 0:
  b = b * (b - 1) // 2
print(a + b)

Submission status: Accepted

Solution code:
n, m = list(map(int,input().strip().split()))
print(((n- 1)*(n))//2 + ((m-1)*(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:
#!/usr/bin/env python3
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:
a=input().split()
N=int(a[0])
M=int(a[1])
def sum(i):
    if i==1 or i==0:
        return 0
    else:
        return i*(i-1)/2

print(int(sum(N)+sum(M)))

Submission status: Accepted

Solution code:
e,o = map(int,input().split())
cte = (e*(e-1))//2
cto = (o*(o-1))//2
print(cte+cto)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, m = MI()

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

    print(choose2(n+m) - n * m)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def ncr(n,r):
    if r> n: return 0;
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

def solve(n,m):
    print(ncr(n,2)+ ncr(m,2))

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

Submission status: Accepted

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

# 偶数 = 偶数 + 偶数
# 偶数 = 奇数 + 奇数

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

Submission status: Accepted

Solution code:
N,M=input().split()
from math import factorial 
if int(N)>=2 and int(M)>=2:
    print('{:.0f}'.format(factorial(int(N))/2/factorial(int(N)-2)+factorial(int(M))/2/factorial(int(M)-2)))
elif int(N)<2 and int(M)>=2:
     print('{:.0f}'.format(factorial(int(M))/2/factorial(int(M)-2)))
elif int(M)<2 and int(N)>=2:
     print('{:.0f}'.format(factorial(int(N))/2/factorial(int(N)-2)))
else:
    print("0")

Submission status: Accepted

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

def c2(a):
  return (a*(a-1))/2

print(int(c2(n) + c2(m)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
nm = input().split(" ")

#偶数になるのは偶偶or奇奇

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

#偶偶の場合の数
Even = n * (n-1)/2

#奇数の場合の数
Odd = m * (m-1)/2

#組み合わせの合計
print(int(Even + Odd))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n,m = readInts()

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

Submission status: Accepted

Solution code:
def Even(x):
  return  2 * x

def Odd(x):
  return 2 * x - 1

N, M = map(int, input().split())
G = list(map(Even, range(1, N+1)))#偶数
K = list(map(Odd, range(1, M+1)))#奇数

even=list()

for n in range(0, N):
  for nm in range(n+1, N):
    even.append(G[n]+G[nm])
  
for m in range(0, M):
  for mm in range(m+1, M):
    even.append(K[m]+K[mm])

print(len(even))

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())

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

Submission status: Accepted

Solution code:
import itertools

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(i) for i in input().split()]
print(n * (n-1)//2 + m * (m-1)//2)

Submission status: Accepted

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

Submission status: Accepted

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


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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
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
    print(solve(N, M))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

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

Submission status: Accepted

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