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:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
N,M = map(int,input().split())

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc159/tasks/abc159_a

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

# 奇数同士の数
odd_odd = M * (M - 1) / 2

# 偶数同士の数
even_even = N * (N - 1) / 2

print(int(even_even + odd_odd))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
N, M = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
class abc_159:
    
    def __init__(self):
        pass
    
    def A(self):
        NM=list(map(int,input().split()))
        print(int((NM[0]*(NM[0]-1))/2 + (NM[1]*(NM[1]-1))/2))
    
    def B(self):
       pass
    
    def C(self):
        pass
        
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_159()
    obj.A()

Submission status: Accepted

Solution code:
A,B=input().split(' ')
A=int(A)
B=int(B)

num=0
num+=A*(A-1)//2
num+=B*(B-1)//2
print(num)

Submission status: Accepted

Solution code:
import math

N, M = map(int, input().split())
     
summa=0
if N>1:
   summa+=math.factorial(N)/(math.factorial(2)*math.factorial(N-2))
if M>1:
   summa+=math.factorial(M)/(math.factorial(2)*math.factorial(M-2))
      
print(int(summa))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
N,M = map(int, input().split())
#A = list(map(int, input().split()))
#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
ansN = 0
ansM = 0
if N <= 1:
    ansN = 0
for i in range(1,N):
    ansN += i
if M <= 1:
    ansM = 0
for i in range(1,M):    
    ansM += i
print(ansN+ansM)

Submission status: Accepted

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

import math


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

ans = 0

if N >= 2:
    ans += combinations_count(N, 2)

if M >= 2:
    ans += combinations_count(M, 2)

print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().strip().split())
a = max(N*(N-1)//2, 0)
b = max(M*(M-1)//2, 0)

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

e_e = N * (N - 1) / 2
o_o = M * (M - 1) / 2

print(int(e_e + o_o))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


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


if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

ans = ans_n + ans_m
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) + M*(M-1))/2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

#result = math.factorial(N + M) - (N * M)

sum = math.factorial(N + M) // (math.factorial(N + M - 2) * math.factorial(2))


print(sum - N * M)

Submission status: Accepted

Solution code:
m, n = 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())

from math import factorial
def comb2(n):
    return factorial(n)//(2*factorial(n-2))
if n>=2 and m>=2:
    print(comb2(n)+comb2(m))
elif n>=2 and m<2:
    print(comb2(n))
elif n<2 and m>=2:
    print(comb2(m))
else:
    print(0)

Submission status: Accepted

Solution code:
#-*- coding: utf-8 -*-
n,m = map(int,input().split())
c = 1
d = 1
for i in range(1,n):
    c += i

for i in range(1,m):
    d += i

print("0" if n==1 and m==1 else c+d-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 sys

n,m = (int(i) for i in input().split())

sum = 0

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

print(int(sum))

Submission status: Accepted

Solution code:
import math

N, M = map(int, input().split())
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N == 0:
  ans = combinations_count(M, 2)
elif M == 0:
  ans = combinations_count(N, 2)
elif N == 1 and M == 1:
  ans = 0
elif N == 1:
  ans = combinations_count(M, 2)
elif M == 1:
  ans = combinations_count(N, 2)
else:
  ans = combinations_count(N, 2) + combinations_count(M, 2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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
for i in range(1,N):
    ans += i

for i in range(1,M):
    ans += i

print(ans)

Submission status: Accepted

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

ans_n = 0
ans_m = 0
if(n == 0):
    ans_n = 0
else:
    ans_n = n*(n-1)//2
if(m == 0):
    ans_m = 0
else:
    ans_m = m*(m-1)//2

print(ans_n + ans_m)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(int(a + b))

Submission status: Accepted

Solution code:
num_list = [int(i) for i in input().split()]
sum = 0
for i in num_list:
  if i > 1:
    sum += i*(i-1)/2

print(int(sum))

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())
def comb(x):
    return int(x*(x-1)/2)
print(comb(N)+comb(M))

Submission status: Accepted

Solution code:
import math

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



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

n = combinations_count(N, 2)
m = combinations_count(M, 2)

print(n+m)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
def nck(x,y):
	res=1
	for i in range(0,y):
		res*=(x-i)/(i+1)
	return int(res)
a=nck(n,2)
b=nck(m,2)
print(a+b)

Submission status: Accepted

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

print(((N+M)*(N+M-1)-2*N*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:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Submission status: Accepted

Solution code:
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N=[int(x) for x in input().split()]
if N[1]==1 or N[1]==0:
  sum1=0
else:
  sum1 = comb(N[1], 2)
if N[0]==1 or N[0]==0:
  sum2=0
else:
    sum2 = comb(N[0], 2)
print(sum1+sum2)

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

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

if n <= 1 and m >= 2:
    print(combinations_count(m, 2))
    sys.exit()
elif n >= 2 and m <= 1:
    print(combinations_count(n, 2))
    sys.exit()
elif n == m == 1:
    print(0)
    sys.exit()
elif n == m == 0:
    print(0)
    sys.exit()
else:
    print(combinations_count(n, 2) + combinations_count(m, 2))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
def fact(x):
  return math.factorial(x)
n, m = map(int, input().split())
ans_n = (fact(n) // (fact(n - 2) * 2)) if n > 1 else 0
ans_m = (fact(m) // (fact(m - 2) * 2)) if m > 1 else 0
print(ans_n + ans_m)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ki = n[0]*(n[0]-1) / 2
gu = n[1]*(n[1]-1) / 2

print(int(ki + gu))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M = map( int,input().split() )
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:
from math import factorial

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans=0

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

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

print(ans)

Submission status: Accepted

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

# 偶数になるのは，両方Nまたは両方M
def comb(a):
    return int(a*(a-1)/2)

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False
s = lambda x: int(0.5*x*(x-1))

def main():
  n,m=ints()
  print(s(n)+s(m))

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import  math
def C(n,r):
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
n,m=input().split()

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

Submission status: Accepted

Solution code:
from math import factorial
n, m = map(int, input().split())
c_n = factorial(n) / (factorial(2) * factorial(n - 2)) if n > 1 else 0
c_m = factorial(m) / (factorial(2) * factorial(m - 2)) if m > 1 else 0
ans = int(c_n) + int(c_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:
N, M = map(int, input().split())

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

print(int(c))

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
result = 0
if m > 1:
    for i in range(1,int(m)):
        result += i
if n > 1:
    for i in range(1,int(n)):
        result += i

# 出力
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() )

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

inputnum = input().split()
N = int(inputnum[0])
M = int(inputnum[1])
ans = 0
if N >= 2:
  ans+= factorial(N) / factorial(2) / factorial(N - 2)
  
if M >= 2:
  ans += factorial(M) / factorial(2) / factorial(M - 2)
  
print(int(ans))

Submission status: Accepted

Solution code:
import math

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

num1 = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2)) if N >= 2 else 0
num2 = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2)) if M >= 2 else 0

print(num1 + num2)

Submission status: Accepted

Solution code:
import math
g,k=map(int,input().split())
def cou(n):
    return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
if g<2:
  a=0
else:
  a=cou(g)
if k<2:
  b=0
else:
  b=cou(k)
print(a+b)

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

Submission status: Accepted

Solution code:
import math

def calcConbination(n):
  if n == 0:
    return 0
  if n == 1:
    return 1
  else:
    return n + calcConbination(n-1)

N, M = map(int, input().split())
ans = 0
if N > 1 :
  ans += calcConbination(N-1)

if M > 1 :
  ans += calcConbination(M-1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

def ans(N,M):
    if N>=2 and M<2:
        return combinations_count(N,2)
    elif N<2 and M>=2:
        return combinations_count(M,2)
    elif N<2 and M<2:
        return 0
    else:
        return combinations_count(N,2) + combinations_count(M,2) 


print(ans(N,M))

Submission status: Accepted

Solution code:
from itertools import combinations

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

n = list(combinations(range(N), 2))
m = list(combinations(range(M), 2))

print(len(n) + len(m))

Submission status: Accepted

Solution code:
def ball(x,y):
    if x>1 and y>1:
        print((x*(x-1)+y*(y-1))//2)
    elif x<=1 and y>1:
        print((y*(y-1))//2)
    elif x>1 and y<=1:
        print((x*(x-1))//2)
    else:
        print(0)


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

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    odd = 0
    even = 0
    if N >= 2:
        odd = N*(N-1)//2
    if M >= 2:
        even = M*(M-1)//2
    print(odd+even)
if __name__ == "__main__":
    main()

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())
from scipy.misc import comb
print(comb(n,2,exact=True)+comb(m,2,exact=True))

Submission status: Accepted

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

Submission status: Accepted

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

import math

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

print(combination(N,2) + combination(M,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())

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

print(ans)

Submission status: Accepted

Solution code:
import math as m
N, M = input().split(' ')
N, M = int(N), int(M)

if N > 1:
    a = m.factorial(N)/(2*m.factorial(N-2))
else:
    a = 0
if M > 1:
    b = m.factorial(M)/(2*m.factorial(M-2))
else:
    b = 0

print(int(a+b))

Submission status: Accepted

Solution code:
import math
M,N = list(map(int,input().split()))
def comb(n,r):
    if n >= r:
        return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
    else:
        return 0
   
 
A = comb(M,2)
B = comb(N,2)
print(A+B)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

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

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

print("{}".format(int(ans)))

Submission status: Accepted

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

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 sys
N, M = map(int, sys.stdin.readline().split())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


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


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

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

Submission status: Accepted

Solution code:
from scipy.misc import comb
N, M = [int(i) for i in input().split()]
ans = comb(N,2,exact=True) + comb(M,2,exact=True)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if a<2:
    p1=0
else:
    p1 = combinations_count(a, 2)

if b<2:
    p2=0
else:
    p2 = combinations_count(b, 2)


total = p1 + p2
print(total)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    n, m = map(int, rl().split())
    ans = n * (n - 1) // 2 + m * (m - 1) // 2
    print(ans)

    
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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


  
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
an=0
ans=0
for i in range(a):
    an=an+i
for i in range(b):
    ans=ans+i
print(an+ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
def cmb(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(cmb(N,2)+cmb(M,2))

Submission status: Accepted

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

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

Submission status: Accepted

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