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:
NM=input().split()
N=int(NM[0])
M=int(NM[1])
print(int((N*(N-1)+M*(M-1))/2))

Submission status: Accepted

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

ans = len(list(itertools.combinations(range(N + M), 2))) - N * M
print(ans)

Submission status: Accepted

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

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

if n <= 1:
    ans1 = 0
else:
    ans1 = combinations_count(n, 2)
if m <= 1:
    ans2 = 0
else:
    ans2 = combinations_count(m, 2)
print(ans1 + ans2)

Submission status: Accepted

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter

n = stdin.readline().rstrip().split()
N = int(n[0])
M = int(n[1])

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

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:
import sys
import numpy as np

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

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

print(int(num))

Submission status: Accepted

Solution code:
S = input().split(" ")
N = int(S[0])
M = int(S[1])
def calculate(n,m):

    s1 = (n * (n - 1)) // 2
    s2 = (m * (m - 1)) // 2

    print(s1 + s2)

calculate(N,M)

Submission status: Accepted

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

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

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

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 math

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

if N>=2:
	ans += math.factorial(N)/(math.factorial(N-2)*math.factorial(2))
    
if M>=2:
	ans += math.factorial(M)/(math.factorial(M-2)*math.factorial(2))  

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
e,o=map(int,input().split())
ean=0
oan=0

if e>1:
    ean+=e*(e-1)//2
if o>1:
    oan+=o*(o-1)//2
    
print(ean+oan)

Submission status: Accepted

Solution code:
from itertools import combinations
def solve():
    N, M = map(int, input().split())
    print(len(list(combinations(range(N),2)) + list(combinations(range(M),2))))
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

from math import factorial
if n >1:
    a = factorial(n) / factorial(2) / factorial(n - 2)
else: a= 0

if m > 1:
    b = factorial(m) / factorial(2) / factorial(m - 2)
else: b= 0

print(int(a+b))

Submission status: Accepted

Solution code:
# list(map(int,input().split()))
from math import factorial as f


def c(n, r=2):
	if n <= 1:
		return 0
	else:
		return f(n) // (f(n - r) * f(r))


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

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

Submission status: Accepted

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


x = n + m
zentai = int(x*(x-1)/2)

result = zentai - n*m
print(int(result))

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

result=a+b

print(int(result))

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
#A = list(map(int, input().split()))

print(int((A*(A-1))/2+(B*(B-1))/2))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

even_cost = 0
odd_cost = 0

if n>=2:
    even_cost = n * (n-1) / 2

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

print("%d"%(even_cost + odd_cost))

Submission status: Accepted

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n,m=map(int,input().split())

a=0

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

print(a)

Submission status: Accepted

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

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

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

print(result)

Submission status: Accepted

Solution code:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
x = 0
a,b = map(int, input().split())

if a == 0 or a == 1:
    pass
else:
    x += combinations_count(a,2)
if b == 0 or b == 1:
    pass
else:
    x += combinations_count(b,2)
print(x)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

import sys
import math
sys.setrecursionlimit(10 ** 6)


def main():
	n, m = map(int, sys.stdin.readline().split())
	score = 0
	if n >= 2:
		score += math.factorial(n) // math.factorial(n-2) // math.factorial(2)
	if m >= 2:
		score += math.factorial(m) // math.factorial(m-2) // math.factorial(2)
	print(score)

main()

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] = [int(s) for s in input().rstrip().split(' ')]
def f(a:int):
  if a < 2:
    return 0
  else:
    return a*(a-1)//2
print(f(N) + f(M))

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

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

print(ans)

Submission status: Accepted

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
n,m = map(int,input().split())
ans = ((m+n) * (m+n-1))//2
kisu = (n *(n-1))//2
gusu = (m*(m-1))//2
kigu = ans - kisu - gusu

print(kisu+gusu)

Submission status: Accepted

Solution code:
N, M = list(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())
if M>=2:
    print(N*(N-1)//2+M*(M-1)//2)
else:
    print(N*(N-1)//2)

Submission status: Accepted

Solution code:
import math

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

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



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

Submission status: Accepted

Solution code:
import math

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

nCount = 0
mCount = 0

def comb(a):
  return math.factorial(a) // (math.factorial(a - 2) * math.factorial(2))

if n >=2:
  nCount = comb(n)

if m >=2:
  mCount = comb(m)
  
print(nCount + mCount)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
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:
e, o = map(int, input().split())
print(e*(e-1)//2 + o*(o-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=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
if M >= 2:
    ans += M * (M - 1) // 2
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# A - The Number of Even Pairs
N,M = list(map(int, input().split()))
ans = int(N*(N-1)/2 + M*(M-1)/2)
print(ans)

Submission status: Accepted

Solution code:
n, m = (int(x) for x in input().split())
ans = ((n*(n-1)) >> 1) + ((m*(m-1)) >> 1)
print(ans)

Submission status: Accepted

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


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


# Generated by 1.1.6 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 = list(map(int, input().split()))

res = 0

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

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

print(res)

Submission status: Accepted

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

ret = 0
if N >= 2:
  ret += N * (N-1) // 2
if M >= 2:
  ret += M * (M-1) // 2
print(ret)

Submission status: Accepted

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

ans = 0
#nC2+mC2
if n >=2:
  ans += n*(n-1)/2

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

print(int(ans))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

ans1 = 0
ans2 = 0

if N<2:
    ans1 = 0
else:
    ans1 = cmb(N,2)

if M<2:
    ans2 = 0
else:
    ans2 = cmb(M,2)

ans = ans1 + ans2
print(ans)

Submission status: Accepted

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

def f(p):
    if p<2:
        return 0
    else:
        return p*(p-1)//2

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

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:
from math import factorial
n,m = map(int, input().split())

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += 1

for i in range(m - 1):
    for j in range(i + 1, m):
        ans += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

A = int(0)

if N != 1:
    A = A + N*(N-1)/2

if M != 1:
    A = A + M*(M-1)/2
    
print(int(A))

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

Submission status: Accepted

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

# NC2 + MC2
print(N * (N - 1) // 2 + M * (M - 1) // 2)

Submission status: Accepted

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

ans_n = int(N*(N-1) / 2)
ans_m = int(M*(M-1) / 2)
print(ans_n + ans_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 itertools as it

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

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

Submission status: Accepted

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

ans = 0
if(N<2 and M<2):
    ans = 0
elif(N<2 and M>=2):
    ans = M*(M-1)/2
elif(N>=2 and M<2):
    ans = N*(N-1)/2
else:
    ans = M*(M-1)/2 + N*(N-1)/2

print(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 sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n,m = i2()
if n == 1:
    a = 0
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)//2 + M*(M-1)//2)

Submission status: Accepted

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

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:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
import math

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


result = 0
if n > 1:
    result += combinations_count(n, 2)
if m > 1:
    result += combinations_count(m, 2)

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

if N == 0 or N == 1:
  ans += 0
else:
  ans += N*(N-1)/2
  
if M == 0 or M == 1:
  ans += 0
else:
  ans += M*(M-1)/2  

print(math.floor(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, M = input_nums()
    o = (N*N)//2 - (N//2)
    e = (M*M)//2 - (M//2)
    print(o + e)

if __name__ == '__main__':
    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())
a=(n*(n-1))/2+(m*(m-1))/2
a=int(a)
print(a)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N, M = map(int, sys.stdin.readline().strip().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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-03-22 20:59:14 +0900
# LastModified: 2020-03-22 21:04:09 +0900
#


import os
import sys


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


if __name__ == "__main__":
    main()

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

n_sum = 0
if n >=2:
    n_sum = n * (n-1) / 2 
    
m_sum = 0
if m >=2:
    m_sum = m * (m-1) / 2 

print(int(n_sum + m_sum))

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
from scipy.misc import comb
# a = comb(n, r)
a = comb(N, 2, exact=True)
b = comb(M,2,exact=True)
print(a+b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys,math,copy,queue,itertools
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
def LI(): return [int(x) for x in input().split()]
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
N,M = LI()
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())

ans = 0
if m >= 2:
    ans += combinations_count(m,2)
if n >= 2:
    ans += combinations_count(n,2)

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,m = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

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

Submission status: Accepted

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

x=0

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

print(int(x))

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 159: A (2020/03/22)
N, M= map(int, input().split())
print(int(N*(N-1)/2 + M*(M-1)/2))

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
odd = N * M
a = N + M
print(a * (a - 1) // 2 - odd)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

import math

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

tmp = 0 if n < 2 else combinations_count(n, 2)
tmp2 = 0 if m < 2 else combinations_count(m, 2)
print(tmp + tmp2)

Submission status: Accepted

Solution code:
n,m=[int(x) for x in 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())
if n * m == 0:
  if n == 0:
    print(m * (m-1) // 2)
  else:
    print(n * (n-1) // 2)
else:
  print((n * (n-1) + 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.0

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

print(int(ans))

Submission status: Accepted

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

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

print(int(s1+s2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=list(map(int, input().split()))  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#　

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


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


ans = 0
if m >= 2:
    ans += combinations_count(m, 2)
if n >= 2:
    ans += combinations_count(n, 2)
print(ans)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
import itertools
a1 = len(list(itertools.combinations(range(a), 2)))
b1 = len(list(itertools.combinations(range(b), 2)))
print(a1+b1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


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


# 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
    solve(N, M)

if __name__ == '__main__':
    main()

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:
#!/usr/bin/env python3
N, M = [int(str) for str in input().strip().split()]

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

Submission status: Accepted

Solution code:
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

import itertools as it

N,M=input_int()

N=len(list(it.combinations([N]*N,2)))

M=len(list(it.combinations([M]*M,2)))

print(N+M)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

result = 0

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

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

print(int(result))

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

def ncr(n, r, p=MOD):
    a = 1
    b = 1
    for i in range(r):
        a = (a * (n - i) % p)
        b = (b * (r - i) % p)

    return a * pow(b, p - 2, p) % p

N, M = LI()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

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

    return result

ans = 0

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

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

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