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 sys
sys.setrecursionlimit(10**9)

mod = 1000000007
INF = 110110110

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
for test in range(int(input())):
'''
inf = 100000000000000000  # 1e17

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(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=list(map(int,input().split()))
print(str(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(int(a+b))

Submission status: Accepted

Solution code:
# solution

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

c = a*(a-1)//2 + b*(b-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:
A = list(map(int, input().strip().split(' ')))
ans = (A[0] * (A[0] - 1)) // 2 + ((A[1] * (A[1] - 1)) // 2)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = input().split(" ")
b = int(x[0])
c = int(x[1])
a = b*(b-1)/2 + c*(c-1)/2
print(int(a))

Submission status: Accepted

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

if N>0 and M>0:
  print(int(M*(M-1)/2+N*(N-1)/2))
elif N==0:
  print(int(M*(M-1)/2))
else:
  print(int(N*(N-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(int(ans))

Submission status: Accepted

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

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

print(number)

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

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
lis = []
for i in range(n):
  lis.append(1)
for i in range(m):
  lis.append(2)
count = 0
for i in range(len(lis)):
  for j in range(i + 1, len(lis)):
    if (lis[i] + lis[j]) % 2 == 0:
      count += 1
print(count)

Submission status: Accepted

Solution code:
def c(i):
    return i*(i-1)//2

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

Submission status: Accepted

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

elif n == 0 and m >= 2:
    ans = 1/2 * m * (m-1)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from scipy.misc import comb
n=[int(i) for i in input().split()]
a=comb(n[0],2,exact=True)
b=comb(n[1],2,exact=True)
print(a+b)

Submission status: Accepted

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

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

print(int(c))

Submission status: Accepted

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

print(cnt)

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


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

Submission status: Accepted

Solution code:
def factorial(n):
    if n == 0 or n == 1 or n < 0:
        return 1
    return n * factorial(n-1)

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

even = int(factorial(N) / (2 * (factorial(N-2))))
odd = int(factorial(M) / (2 * (factorial(M-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:
import math
def combination(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))
N, M = list(map(int, input().split(' ')))
sum_num = 0
if N >= 2:
    sum_num += combination(N, 2)
if M >= 2:
    sum_num += combination(M, 2)
print(int(sum_num))

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

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:
def main():
	# s = int(input())
	# s = str(input())
	a,b = map(int,input().split())
	#1行R列
	# a = list(map(int,input().split()))
	#R行1列
	# l = [str(input()) for i in range(n)]
	#R行C列
	# qu = [list(map(str,input().split())) for x in range(q)]
	# print(' '.join(map(str,)))
	import math
	def combinations_count(n, r):
		return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

	if a <= 1 and b > 1:
		print(combinations_count(b,2))
	elif a <= 1 and b <= 1:
		print(0)
	elif a > 1 and b <= 1:
		print(combinations_count(a,2))
	else:
		print(combinations_count(a,2) + combinations_count(b,2))


if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if N == 1 and M == 1 :
    ans = 0
elif N > 1 and M == 1 :
    ans = nC2
elif N == 1 and M > 0 :
    ans = mC2
else :
    ans = nC2 + mC2

print(ans)

Submission status: Accepted

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

c_o = int((N * (N-1)) / 2)
c_e = int((M * (M-1)) / 2)

print(c_o + c_e)

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 * N - N + M * M - M) // 2)

Submission status: Accepted

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


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


ans = combination(n) + combination(m)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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


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

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

print(int(method))

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

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

Submission status: Accepted

Solution code:
from sys import stdin


def cmb(n,r):
    return n*(n-1)//2



if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = cmb(N,2) + cmb(M,2)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Accepted

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

n=int(temp[0])
m=int(temp[1])
Answer=0
ball_list=list()

for i in range(0,n):
    ball_list.append(2)

for i in range(0,m):
    ball_list.append(1)

for i in range(0,n+m):
    for j in range(0,n+m):
        if i < j:
            if (ball_list[i]+ball_list[j])%2==0:
                Answer=Answer+1

print(Answer)

Submission status: Accepted

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

partn = 0 if n < 2 else math.factorial(n)/(2*math.factorial(n-2))
partm = 0 if m < 2 else math.factorial(m)/(2*math.factorial(m-2))

print(int(partn+partm))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
if((N<=1)&(M<=1)):
  num=0
else:
  num=int(N*(N-1)/2)+int(M*(M-1)/2)
print(num)

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 = (int(x) for x in input().split())
s = ((n+m)*(n+m-1))/2
k = m * n
print(int(s-k))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import math

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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


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

print(c)

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

e = 0
o = 0

if N>=2:
    e = comb(N,2)
if M>=2:
    o = comb(M,2)
print(e+o)

Submission status: Accepted

Solution code:
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


# エントリーポイント
def main():
    N, M = input(int, int)
    print(N * (N - 1) // 2 + M * (M - 1) // 2)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Accepted

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    print((n * (n-1) // 2) + (m * (m-1) // 2))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if m>1:
  n_sum=((m*(m-1))//2)
  total+=n_sum
print(total)

Submission status: Accepted

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	ans = int(N * (N - 1) // 2) + int(M * (M - 1) // 2)
	print(ans)


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:
from operator import mul  # mul:引数を2つ持つ関数。例) mul(4, 5)をすると掛け算をして`20`を返す
from functools import reduce  # reduce：引数を2つ持つ関数。(実行したい関数(引数が2つあるもの), リスト)

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


def p(_n, _r):
    # nPrをreturnする
    return reduce(mul, list(range(_n, _n - _r, -1)))  # _nから(_n - _r)まで-1ずつ。p(5, 4)の場合はmul(mul(mul(5, 4), 3), 2)


def c(_n, _r):
    # nCrをreturnする
    over = p(_n, _r)
    under = p(_r, _r)
    return over / under


print(int((c(n, 2)) + c(m, 2)))

Submission status: Accepted

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

a = []
for i in range(1,n+1):
  a.append(2*i)
for j in range(1, m+1):
  a.append(2*j - 1)

counter = 0
for i in range(len(a)-1):
  for j in range(i+1, len(a)):
    if (a[i] + a[j]) % 2 == 0:
      counter += 1
      
print(counter)

Submission status: Accepted

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


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

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

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc159/tasks/abc159_a"

def main():
    e, v = list(map(int, input().split()))
    lis = []
    for i in range(e):
        lis.append(1)
    for i in range(v):
        lis.append(2)
    count = 0
    for i in range(len(lis)):
        for j in range(i + 1, len(lis)):
            # print(lis[i], lis[j])
            if (lis[i] + lis[j]) % 2 == 0:
                count += 1
    print(count)

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 = list(map(int,input().split()))
x = (n[0]*(n[0]-1))//2
y = (n[1]*(n[1]-1))//2
print(x+y)

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 = 0
#m = 3


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

k = 2
import math
#print(math.factorial(3))

nResult = 0
if (n-k) >= 0:
    nResult = (math.factorial(n))/(2*math.factorial(n-k))
    nResult=int(nResult)
#print("N numbers comination", nResult)

mResult = 0

if (m-k) >= 0:
    mResult = (math.factorial(m))/(2*math.factorial(m-k))
    mResult=int(mResult)
#print("M numbers comination", mResult)

#print("Answer is: ", nResult+mResult)
print(nResult+mResult)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = input().split()
L = [int(x) for x in l]
N = L[0]
M = L[1]

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

print(int(result))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
NM = list(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
    # reduce(mul, 範囲)で範囲までの階乗計算
    # range (n, n-r, -1) -> n から n-rまで，逆順
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():

    kiki = 0
    gugu = 0

    if NM[0] > 1:
        gugu = cmb(NM[0], 2)
    if NM[1] > 1:
        kiki = cmb(NM[1],2)


    print(kiki+gugu)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

def main():
    N, M = map(int, open(0).read().split())
    T = N * (N-1) / 2 + M * (M-1) / 2
    print(int(T))

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:
from heapq import *
import sys
from collections import *

from itertools import *
from decimal import *
import copy
from bisect import *
import time

import math

def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
N,M=map(int,input().split())
print(N*(N-1)//2 + M*(M-1)//2)

Submission status: Accepted

Solution code:
def kai(nn):
    if nn == 0 or nn==1:
        return 1
    else:
        return nn*kai(nn-1)


#print(kai(5))

n,m = map(int,input().split())
#m = int(input())
# e+e or o+o
ans =0
if n>=2:
    ans += kai(n)//(2*kai(n-2))
if m>=2:
    ans += kai(m)//(2*kai(m-2))
print(ans)

Submission status: Accepted

Solution code:
N,M = (int(i) for i in input().split())
comb_n = int(N*(N-1)/2) if N > 1 else 0
comb_m = int(M*(M-1)/2) if M > 1 else 0
print(comb_n + comb_m)

Submission status: Accepted

Solution code:
o, e = input().split()
o = int(o);
e = int(e);

num1 = o * (o-1) / 2;
num2 = e * (e-1) / 2;

print(int(num1+num2))

Submission status: Accepted

Solution code:
from sys import stdin
import itertools
N,M = list(map(int, (stdin.readline().strip().split())))
count=0
count+=len(list(itertools.combinations(range(N), 2)))
count+=len(list(itertools.combinations(range(M), 2)))
print(count)

Submission status: Accepted

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

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

print(x)

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(' '))
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:
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 and m <= 1:
    print(0)
elif n <= 1:
    print(combinations_count(m, 2))
elif m <= 1:
    print(combinations_count(n, 2))
else:
    print(combinations_count(n, 2) + combinations_count(m, 2))

Submission status: Accepted

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

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

class Run:
    def build(gv):
        gv.N, gv.M = map(int, input().split())

    def solve(gv):
        ans = 0
        
        p = [0]*gv.N
        q = [0]*gv.M
        ans += len(list(itertools.combinations(p, 2)))
        ans += len(list(itertools.combinations(q, 2)))
        
        print (ans)
        
if __name__ == '__main__':
    run = Run()
    run.build()
    run.solve()

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


def p(_n, _r):
    # nPrをreturnする
    ret = 1
    for i in range(_r):
        ret = ret * (_n - i)
    return ret


def c(_n, _r):
    over = p(_n, _r)
    under = p(_r, _r)
    return over / under


print(int(c(n, 2) + c(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())

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

print(p)

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


#a = [int(s) for s in input().split(" ")]
n, m = [int(s) for s in input().split(" ")]
print(solve())

Submission status: Accepted

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

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

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

print(int(sum_even+sum_odd))

Submission status: Accepted

Solution code:
def Main(N, M):
    return N*(N-1)//2+M*(M-1)//2

def main():
    N, M = map(int, input().split())
    print(Main(N, M))

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:
def main():
  n,m = (int(x) for x in input().split())
  print(int(n*(n-1)/2) + int(m*(m-1)/2))

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:
import math

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

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

ans = 0
if N >= 2:
    ans += comb(N, 2)
if M >= 2:
    ans += comb(M, 2)

print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = comb(n,2,exact=True) + comb(m,2,exact=True) #exact=Trueで整数値が返される
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())
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)+int(m*(m-1)/2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# even + even
ans += n * (n-1) / 2
# odd + odd
ans += m * (m-1) / 2
print(round(ans))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
print("{:.0f}".format(n * (n - 1) / 2 + m * (m - 1) / 2))

Submission status: Accepted

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

Submission status: Accepted

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

import itertools
ｃ = len(list(itertools.combinations(range(a), 2)))
d = len(list(itertools.combinations(range(b), 2)))

print(c + d)

Submission status: Accepted

Solution code:
import itertools

n,m = map(int,input().split())
comb = lambda x:x*(x-1)/2 if x >= 1 else 0
print(int(comb(n)+comb(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:
import math
N, M = map(int, input().split())
if N>=2:
    n = math.factorial(N)/(math.factorial(2) * math.factorial(N - 2))
else:
    n = 0
if M>=2:
    m = math.factorial(M)/(math.factorial(2) * math.factorial(M - 2))
else:
    m = 0

print(int(n+m))

Submission status: Accepted

Solution code:
import math
def com(a):
    if a == 0 or a == 1:
        return 0
    elif a == 2:
        return 1
    else:
        return math.factorial(a)/2/math.factorial(a-2)
A = list(map(int, input().split()))
result  = int(com(A[0])+com(A[1]))
print (result)