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: Runtime Error

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

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

Submission status: Runtime Error

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

if N==1 and M ==1:
    print(0)

elif N >= 2 and M == 1:
    ans = factorial(N) / factorial(2) / factorial(N - 2)
    print(int(ans))
        
elif N == 1 and M >= 2:
    ans =factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))    

else:
    ans = (factorial(N) / factorial(2) / factorial(N - 2))+factorial(M) / factorial(2) / factorial(M - 2)
    print(int(ans))

Submission status: Runtime Error

Solution code:
from itertools import combninations

n,m = map(int, input().split())
a = list(combinations(range(n),2))
b = list(combinations(range(m),2))

print(len(a)+len(b))

Submission status: Runtime Error

Solution code:
from math import factorial
 
N, M = map(int, input().split())
if N != 0 and M != 0:
  if N==1 and M==1:
    print(0)
  Ncon = factorial(N) // factorial(2) // factorial(N - 2)
  Mcon = factorial(M) // factorial(2) // factorial(M - 2)
  print(Ncon+Mcon)
if N ==0:
  print(factorial(M) // factorial(2) // factorial(M - 2))
if M == 0:
  print(factorial(N) // factorial(2) // factorial(N - 2))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
frac = [1]
for i in range(max(n, m)):
    frac.append(frac[i]*(i+1)%p)
mod = 10***9 + 7
#フェルマーの小定理を用いてcombの計算を行う
def comb(n, k, mod):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
print(comb(n, 2, mod) + comb(m, 2, mod))

Submission status: Runtime Error

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

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

ans = even + add

print(ans)

Submission status: Runtime Error

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


def a1():
    if a[0] == 1 or a[0] == 0:
        a[0] = 1
        return a[0]
    else:
        return a[0] * (a[0] - 1) / 2


def b1():
    if a[1] == 1 or a[1] == 0:
        a[1] = 1
        return a[1]
    else:
        return a[1] * (a[1] - 1) / 2


print(a() * b())

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0

# 偶数
if a != 0:
    if a % 2 != 0:
        a = a - 1

# 奇数


# 組み合わせ
nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
cnt = cnt + cmb(a, 2) + cmb(b, 2)
print(cnt)

Submission status: Runtime Error

Solution code:
N=input()
M=input()

num1=M*(M-1)*0.5
num2=N*(N-1)*0.5

print(num1+num2)

Submission status: Runtime Error

Solution code:
M=int(input())
N=int(input())

count=0

if M >= 2:
    x=M*(M-1)
    print("M",x)
    count=x/2

if N >= 2:
    x=N*(N-1)
    print("N",x)
    count=x/2 + count

print(int(count))

Submission status: Runtime Error

Solution code:
from math import factorial as fact
n,m=map(int,input().split())
i,k=0,0
if n<2 and m<2:
  print(0)
else:
  if n!=0:
  	i=fact(n)/fact(2)/fact(n-2)
  if m!=0:
    k=fact(m)/fact(2)/fact(m-2)
  print(int(i+k))

Submission status: Runtime Error

Solution code:
from math import factorial

n, m = map(int, input().split())
if n == 1 and m == 1:
    ans = 0
elif n == 1:
    ans = factorial(m) // (factorial(m - 2) * factorial(2))
elif m == 1:
    ans = factorial(n) // (factorial(n - 2) * factorial(2))
else:
    ans = factorial(n) // (factorial(n - 2) * factorial(2))
    ans += factorial(m) // (factorial(m - 2) * factorial(2))
print(ans)

Submission status: Runtime Error

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=map(int,input().split())
if n<2 and m<2:
    print(0)
    quit()
if n==0:
    print(cmb(m,2))
    quit()
elif m==0:
    print(cmb(n,2))
    quit()
print(cmb(n,2)+cmb(m,2))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math 

N2,M1 = map(int, input().split())
count=0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N2!=0:
    count += combinations_count(N2,2)
if M1!=0:
    count += combinations_count(M1,2)

print(count)

Submission status: Runtime Error

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

id N == 0:
  a = cmb(M,2)
elif M == 0:
  a = cmb(N,2)
else:
  a = cmb(N,2) + cmb(M,2)

print(int(a))

Submission status: Runtime Error

Solution code:
import math
import itertools as it


i = input().split()



n = i[0]
m = i[1]
nc = it.combinations(range(n),2)
mc = it.combinations(range(m),2)

print(len(list(nc) + list(mc)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
cnt = 0

# 偶数
if a % 2 != 0:
    a = a - 1

# 奇数


# 組み合わせ
nCr = {}

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


#
cnt = cnt + cmb(a, 2) + cmb(b, 2)
print(cnt)

Submission status: Runtime Error

Solution code:
import sys
X,Y = map(int,input().spliut())
if(X == 1 or Y == 1):
    print(0)
    sys.exit()
print(int((X * (X-1))/2 + Y))

Submission status: Runtime Error

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

Nmath = special.comb(N, 2)
Mmath = special.comb(M, 2)

print(int(Nmath+Mmath))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
from scipy.special import comb
a = comb(N+M, 2, exact=True)
b = comb(N, 1, exact=True)
c = comb(M, 1, exact=True)
print(int(a-(b*c)))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c=0
for i in range(a+b)
  if (a-2)>0 or (b-2)>0:
    a=a-2
    b=b-2
    c=c+1
print(c)

Submission status: Runtime Error

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

print(scipy.misc.comb(a[0], 2, exact=True) + scipy.misc.comb(a[1], 2, exact=True))

Submission status: Runtime Error

Solution code:
import math 

N2,M1 = map(int, input().split())

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


count = combinations_count(N2,2)

count += combinations_count(M1,2)

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

a = cmb(N,2) + cmb(M,2)

print(int(a))

Submission status: Runtime Error

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

print(combinations_count(N, 2)+M)

Submission status: Runtime Error

Solution code:
import math
N,M = map(int, input().split())
a = 0
b = 0
if N != 1:
    a = math.factorial(N)/(2*math.factorial(N-2))
if M != 1:
    b = math.factorial(M)/(2*math.factorial(M-2))
print(int(a+b))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,M = inputMap()

	if N < 2 and M < 2:
		print(0)
		sys.exit()

	ans = 0
	if N > 1:
		ans += cmb(N, 2)
	if M > 1:
		ans += -(-M // 2) + 1

	print(ans)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# special thanks :
#  https://nagiss.hateblo.jp/entry/2019/07/01/185421
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def int_sqrt2(n):
    def f(prev):
        while True:
            m = (prev + n / prev) / 2
            if m >= prev:
                return prev
            prev = m

    return f(int(math.sqrt(n) * (1 + 1e-10)))

# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

Submission status: Runtime Error

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 or N == 0:
    guu = 0
else:
    guu = combinations_count(N, 2)
if M == 1 or N == 0:
    kisu = 0
else:
    kisu = combinations_count(M, 2)
print(guu + kisu)

Submission status: Runtime Error

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

if N == 1 and m == 1:
  print(0)
else:
  n = 0
  if N != 0:
    for i in range(N-1):
      n += 1+i
  else:
    n = 0
  if M != 0:
    m = (M * (M-1)) / 2
  else:
    m = 0
  print(int(n + m))

Submission status: Runtime Error

Solution code:
import math
import sys

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

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

if n <= 1:
  print(comb(m, 2))
  sys.exit()
  
if m <=1:
  print(comb(n, 2))
  sys.exit()

if n == 1 and m == 1:
  print('0')
  sys.exit()

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
N, M= map(int, input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N != 0:
  N_sum = combinations_count(N, 2)
else:
  N_sum = 0
if M != 0:
  M_sum = combinations_count(M, 2)
else:
  M_sum = 0
print(N_sum + M_sum)

Submission status: Runtime Error

Solution code:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def main():
  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))
if __name__ == '__main__':
  	main()

Submission status: Runtime Error

Solution code:
from scipy.special import comb
n, m = [int(x) for x in input().split()]



print(int(comb(n, 2, exact=True) + comb(m, 2, exact=True)))

Submission status: Runtime Error

Solution code:
n = int(input())
m = int(input())

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = int(n_dot+ m_dot)
print(answer)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
from scipy.special import comb
a = comb(N+M, 2, exact=True)
b = comb(N, 1, exact=True)
c = comb(M, 1, exact=True)
print(a-(b*c))

Submission status: Runtime Error

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

Nmath = special.comb(N, 2,True)
Mmath = special.comb(M, 2,True)

print(Nmath+Mmath)

Submission status: Runtime Error

Solution code:
import math

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


def C(n, r):
    return P(n, r)//math.factorial(r)

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

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

Submission status: Runtime Error

Solution code:
import math 

N2,M1 = map(int, input().split())

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

print(combinations_count(4, 2))

count = combinations_count(N2,2)

count += combinations_count(M1,2)

print(count)

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
if a[0] == 1 or a[0] == 0:
  a[0] = 1
  return a[0]
else: 
  return a[0]*(a[0] - 1)/2
if a[1] == 1 or a[1] == 0:
  a[1] = 1
  return a[1] 
else: 
  return a[1]*(a[1] - 1)/2
print(a[0]*a[1])

Submission status: Runtime Error

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):
	ans = 0
elif(N != 0 and M != 0): 
	ans = combinations_count(N, 2)
	ans += combinations_count(M, 2)
elif(N == 1 and M != 1):
  ans = combinations_count(M, 2)
elif(N != 1 and M == 1):
  ans = combinations_count(N, 2)
elif(N == 1 and M ==1 ):
  ans = 0
elif(N == 0 and M != 0):
  ans = combinations_count(M, 2)
elif(N != 0 and M == 0):
  ans = combinations_count(N, 2)
  
print(ans)

Submission status: Runtime Error

Solution code:
n,m =map(int, input().split())
if n==m==1:
    print(0)
elif n==1 or n==0:
    print(cmb(m,2))
elif m==1 or m==0:
    print(cmb(n,2))
else:
    print(cmb(n,2)+cmb(m,2))

Submission status: Runtime Error

Solution code:
import math
import sys

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

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

if n <= 1
  print(comb(m, 2))
  sys.exit()
  
if m <=1
  print(comb(n, 2))
  sys.exit()

if n == 1 and m == 1:
  print('0')
  sys.exit()

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb
N, M = map(int, input().split())
goukei = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(goukei)

Submission status: Runtime Error

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

if N<=1 and M<=1:
    print(0)
else:
    print(int(comb(N,2))+int(comb(M,2)))

Submission status: Runtime Error

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

if N == 1 and m == 1:
  print(0)
else:
  n = 0
  for i in range(N-1):
    n += 1+i
  m = (M * (M-1)) / 2
  print(int(n + m))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
from scipy.special import comb
n = N + M
a = comb(n, 2, exact=True)
b = comb(N, 1, exact=True)
c = comb(M, 1, exact=True)
print(a-(b*c))

Submission status: Runtime Error

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

answer = 0

#偶数2
answer += math.factorial(a) / (math.factorial(a - 2)*2)

#奇数2
answer += math.factorial(b) / (math.factorial(b - 2)*2)

print(int(answer))

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
if a[0] == 1:
  a[0] = 1
  return a[1]
else: 
  return a[0]*(a[0] - 1)
if a[1] == 1:
  a[1] = 1
  return a[1] 
else: 
  return a[1]*(a[1] - 1)
print(a[0]*a[1])

Submission status: Runtime Error

Solution code:
from scipy.special import comb
n,m=map(int,input().split())
print(int(comb(n+m,2)-n*m))

Submission status: Runtime Error

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=map(int, input().split())
a = 0
b = 0
if n != 1:
  a = cmb(n, 2)  
if m != 1:
  b = cmb(m,2)
print(a+b)

Submission status: Runtime Error

Solution code:
import math

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


def C(n, r):
    if n == 1:
        return 0
    return P(n, r)//math.factorial(r)

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

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

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

print(int(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
if n <= 1 and m <= 1:
    print(0)
elif n == 1 and m <= 1:
    print(comb(m,2))
elif n <= 1 and m == 1:
    print(comb(n,2))
else:
    print(comb(n,2) + comb(m,2))

Submission status: Runtime Error

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N == 1:
    a = 0
else:
    a = cmb(N,2)
if M == 1:
    b = 0
else:
    b = cmb(M,2)
print(a+b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
def nCr(n,r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n-r)
N,M=list(map(int,input().split(' ')))
print(int(nCr(N,2)+nCr(M,2)))

Submission status: Runtime Error

Solution code:
n = int(input())
m = int(input())

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = n_dot+ m_dot
print(answer)

Submission status: Runtime Error

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

nc=0
mc=0
if n >=2:
    nc=math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
if m>=2:
    mc=math.factorial(m) // (math.factorial(m - 2) * math.factorial(2))

print(nc+mc)

Submission status: Runtime Error

Solution code:
inputs = input().split(' ')

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

pattern_N = 0
paattern_M = 0

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

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
answer = (N*(N-1) / 2) + (M*(M-1) / 2)

print(int(answer))

Submission status: Runtime Error

Solution code:
integer = int(input().split())
conbi = (integer[0] * (integer[0] - 1) + integer[1] * (integer[1] -1 )) / 2
print(conbi)

Submission status: Runtime Error

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=map(int, input().split())
a = cmb(n, 2)
b = 0
if m != 1:
  b = cmb(m,2)
print(a+b)

Submission status: Runtime Error

Solution code:
n,m = [int(i) for i in input().split()]
if n <= 1:
  a = 0
else:
  a = n*(n-1)/2
if m <= 1:
  b = 0
else:
  b = m*(m-1)/2
print(ab)

Submission status: Runtime Error

Solution code:
n, m = MAP()

ans = 0

for x in range(0, n ):
    ans += x
for x in range(0, m ):
    ans += x

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
def sta(n):
  one = 1
  for i in range(1, n + 1):
    one *= i
  return one

if N >= 3:
  num = sta(N)/(sta(2)*sta(N-2))
if N = 2:
  num = 1
if N <= 1:
  num = 0

if M >= 3:
  mum = sta(N)/(sta(2)*sta(N-2))
if M = 2:
  mum = 1
if M <= 1:
  mum = 0

print(num + mum)

Submission status: Runtime Error

Solution code:
import sys
# sys.stdin = open('input.txt')

import math

n,m = map(int, input().split())
def c(n):
    return int(math.factorial(n) / math.factorial(n-2) / math.factorial(2))

if n == 1 and m == 1:
    print(0)
else:
    print(c(n)+c(m))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
from scipy.special import comb
n = N + M
m = N
l = M
a = comb(n, 2, exact=True)
b = comb(m, 1, exact=True)
c = comb(l, 1, exact=True)
print(a-(b*c))

Submission status: Runtime Error

Solution code:
from math import *
def printNcR(n, r): 
    p = 1
    k = 1
    if (n - r < r): 
        r = n - r 
  
    if (r != 0):  
        while (r): 
            p *= n 
            k *= r  
            m = gcd(p, k)
            p //= m 
            k //= m 
            n -= 1
            r -= 1 
  
    else: 
        p = 1
    return p



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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

if n==1:
  if m==1:
    print(0)
  else:
    print(comb(m, 2))
elif m==1:
  print(comb(n, 2))
else:
  print(comb(n, 2)+comb(m, 2))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2147483647)

n,m = map(int,input().split())
a = n - 1
b = m - 1
ans = 0

if m <= 1:
    ans = n*a/2
else:
    ans = n*a/2 + m*b/2

print(str(int(ans))

Submission status: Runtime Error

Solution code:
from math import factorial
print(factorial(n) // factorial(r) // factorial(n - r))

N, M = map(int, input().split())
if N != 0 and M != 0:
  if N==1 and M==1:
    print(0)
  Ncon = factorial(N) // factorial(2) // factorial(N - 2)
  Mcon = factorial(M) // factorial(2) // factorial(M - 2)
  print(Ncon+Mcon)
if N ==0:
  print(factorial(M) // factorial(2) // factorial(M - 2))
if M == 0:
  print(factorial(N) // factorial(2) // factorial(N - 2))

Submission status: Runtime Error

Solution code:
# 200322 A
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
    
if __name__ == "__main__":
    N,M = list(map(int,input().split()))
    print(cmb(N,2)+cmb(M,2))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 21:08:11 2020

@author: azikausy
"""


from scipy.special import comb
n, m = map(int, input().split())
print(int(comb(n,2)+comb(m,2)))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
 
import math
 
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
if n == 1 and m == 1:
    print(0)
elif n == 1 and m != 1:
    print(comb(m,2))
elif n != 1 and m == 1:
    print(comb(n,2))
else:
    print(comb(n,2) + comb(m,2))

Submission status: Runtime Error

Solution code:
import math

nums = map(int,input().split())

ans=0
for n in nums:
    ans+=math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:

from math import factorial

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

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

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb


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

Submission status: Runtime Error

Solution code:
from math import *
def printNcR(n, r): 
    p = 1
    k = 1
    if (n - r < r): 
        r = n - r 
  
    if (r != 0):  
        while (r): 
            p *= n 
            k *= r  
            m = gcd(p, k)
            p //= m 
            k //= m 
            n -= 1
            r -= 1 
  
    else: 
        p = 1
    return p



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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
integer = int(input().split())
conbi = ((integer[0] * (integer[0] - 1) + integer[1] * (integer[1] -1 )) / 2
print(conbi)

Submission status: Runtime Error

Solution code:
combination::Int->Int
combination count | count < 2 = 0
                  | otherwise = div (count*(count-1)) 2

main = do
  [n,m] <- map read . words <$> getLine
  print $ combination n + combination m

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
base = comb(N,2)
base2 = comb(M,2)
print(base+base2)

Submission status: Runtime Error

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

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

if n < 1:
  print(comb(m, 2))
elif m < 1:
  print(comb(n, 2))
else:
  print(comb(n, 2) + comb(m, 2))

Submission status: Runtime Error

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

import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
if n == 1 and m == 1:
    print(0)
elif n == 1 and m != 1:
    print(comb(m,2))
elif n != 1 and m == 1:
    print(comb(n,2))
else:
    print(comb(n,2) + comb(m,2))

Submission status: Runtime Error

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

from scipy.special import comb
# a = comb(n, r)
a = comb(N+M, 2, exact=True)-N*M
print(a)

Submission status: Runtime Error

Solution code:
# 200322 A

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
    
if __name__ == "__main__":
    N,M = list(map(int,input().split()))
    print(cmb(N,2)+cmb(M,2))

Submission status: Runtime Error

Solution code:
import math

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


n, m = [int(i) for i in input().split()]
print(combinations_count(n,2)+combinations_count(m,2))

Submission status: Runtime Error

Solution code:
import math
def nCr(n, r): 
  
    return (math.fact(n) // (math.fact(r)  
                * math.fact(n - r))) 
n,m=list(map(int,input().split()))
total=0
if n>1:
  total+=nCr(n,2)
if m>1:
  total+=nCr(m,2)
print(total)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
def comb(k, r):
  if n<2:
    return 0
  else:
    return math.factorial(k) // (math.factorial(k - r) * math.factorial(r))

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

Submission status: Runtime Error

Solution code:
import numpy as np
import fractions
import decimal
from collections import deque
from scipy.special import comb

a,b=map(int, input().split())
print(comb(a,2)+comb(b,2))

Submission status: Runtime Error

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

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

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