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

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

def comb(n, r):
    if n == 0:
        return 0
    if r == 0:
        return 0

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

from scipy.special import comb
n = int(comb(N, 2))
m = int(comb(M, 2))

result_way = n + m

print(result_way)

Submission status: Runtime Error

Solution code:
import math
a = int(input())
b = int(input())

f = ((math.factorial(a))/(math.factorial(a-2)))/2
s = ((math.factorial(b))/(math.factorial(b-2)))/2

c = f+s
print(c)

Submission status: Runtime Error

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L = int(sys.stdin.buffer.readline().rstrip())
    print(L ** 3 / 27)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
 nm = [int(i) for i in input().split()]
  2
  3 result = (nm[0] * (nm[0] - 1)) // 2
  4 result += (nm[1] * (nm[1] - 1)) // 2
  5
  6 print(result)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

a = cmb(N+M, 2)
b = cmb(N, 1)
c = cmb(M, 1)
if N==0:
    print(a)
elif M==0:
    print(a)
else:
    print(int(a-(b*c)))

Submission status: Runtime Error

Solution code:
def is_kaibunn(str): return 1 if str == str[::-1] else 0
word_front = input()
flag = 0
num = len(word)
word_back = word_front
while num > 1:
    if is_kaibunn(word_front) and is_kaibunn(word_back):
        flag = 1
    else:
        flag = 0
        break;
    
    if num%2 == 1:
        num_flag = 1
    else:
        num_flag = 0
    num = int(num/2)
    if num_flag == 1:
        word_front = word_front[0:num]
        word_back = word_back[num+1:]
    else:
        word_front = word_front[0:num]
        word_back = word_back[num:]       
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]
T = []

for i in range(N):
    flag = 0
    for j in range(len(T)):
        if A[i] == T[j][0]:
            T[j][1] += 1
            flag = 1
            break
    if flag == 0:
        T.append([A[i],1])
T2 = []
for i in range(len(T)):
    T2.append(T[i][1])

def hoge(List):
    ans = 0
    for i in range(len(List)):
        ans += (List[i]-1)*List[i]//2
    return ans

for i in range(N):
    for j in range(len(T)):
        if T[j][0] == A[i]:
            T2[j] -= 1
            print(hoge(T2))
            T2[j] += 1
            break

Submission status: Runtime Error

Solution code:
N, M = 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
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

a = cmb(N+M, 2)
b = cmb(N, 1)
c = cmb(M, 1)
if N==0:
    print(a)
elif M==0:
    print(a)
else:
    print(int(a-(b*c)))

Submission status: Runtime Error

Solution code:
print((int(input())/3)**3)

Submission status: Runtime Error

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

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

if a < 2 and b < 2:
    print(0)

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = 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
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

Submission status: Runtime Error

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

if n == 0:
   N = 0
if n == 1:
    N = 0
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
if m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split()):
c=0
d=d*(d-1)//2
e=e*(e-1)//2
while d>0:
  d=d-1
  c=c+1
while e>0:
  e=e-1
  c=c+1
print(c)

Submission status: Runtime Error

Solution code:
if A != 0 and B == 0:
  C = math.factorial(A-2)
  E = math.factorial(A) // 2// C
  print(E)
  exit()
if A == 0 and B == 0:
  print(0)
  exit()
elif A == 1 and B != 1:
  D = math.factorial(B-2)
  F = math.factorial(B) // 2// D
  print(F)
  exit()
elif A != 1 and B == 1:
  C = math.factorial(A-2)
  E = math.factorial(A) // 2// C
  print(E)
  exit()
elif A == 1 and B == 1:
  print(0)
  exit()
C = math.factorial(A-2)
D = math.factorial(B-2)
E = math.factorial(A) // 2// C
F = math.factorial(B) // 2// D
print(E+F)

Submission status: Runtime Error

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

if n == 0:
   N = 0
if n == 1:
    N = 1
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
if m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))

Submission status: Runtime Error

Solution code:
n = int(input())
n = n/3
print(n*n*n)

Submission status: Runtime Error

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

if n == 0:
   M = 0
if n == 1:
    M = 1
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
if m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))

Submission status: Runtime Error

Solution code:
L = input()
ans = (L//3)**3
print(ans)

Submission status: Runtime Error

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

import math
if m <= 2:
  m_side = math.factorial(m)/math.factorial(m-2)/2
else:
  m_side = 0
if n <= 2:
  n_side = math.factorial(n)/math.factorial(n-2)/2
else:
  n_side = 0
print(int(m_side + n_side))

Submission status: Runtime Error

Solution code:
L = int(input())
x = float(L/3)
print(x**3)

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

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

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)
if N==0:
    print(a)
elif M==0:
    print(a)
else:
    print(int(a-(b*c)))

Submission status: Runtime Error

Solution code:
l=int(input())
x=l/3
x=x*x*x
print(x)

Submission status: Runtime Error

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

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

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

print(int(answer))

Submission status: Runtime Error

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

N = factorial(n)/factorial(2)/factorial(n-2)
M = factorial(m)/factorial(2)/factorial(m-2)

print(N+M)

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
x = a[0]
y = a[1]
z = 1
if (x != z)
    c = (combinations_count(x, 2)) 
else 
    c = 0
if (y != z)
    d = (combinations_count(y, 2))
else 
    d = 0
print(c + d)

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 M < 2:
    Count = comb(N, 2)
elif N < 2:
    Count = comb(M, 2)
else:
    Count = comb(N, 2) + comb(M, 2)
print(Count)

Submission status: Runtime Error

Solution code:
l=int(input())
l=l/3
l=l*l*l
print(l)

Submission status: Runtime Error

Solution code:
A,B = list(map(int,input().split()))
import math
if A == 0 and B != 0:
  D = math.factorial(B-2)
  F = math.factorial(B) // 2// D
  print(F)
  exit()
if A != 0 and B == 0:
  C = math.factorial(A-2)
  E = math.factorial(A) // 2// C
  print(E)
  exit()
if A == 0 and B == 0:
  print(0)
  exit()
C = math.factorial(A-2)
D = math.factorial(B-2)
E = math.factorial(A) // 2// C
F = math.factorial(B) // 2// D
print(E+F)

Submission status: Runtime Error

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

for inN in N:
	inN=N*2
    
    for inM in M:
      inM=M*2-1
      sum=inN+inM
      
      if sum%2==0:
        count.append(sum)
      
      else:
        break
        
 print(len(count))

Submission status: Runtime Error

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

N = factorial(n)/factorial(2)/factorial(n-2)
M = factorial(M)/factorial(2)/factorial(m-2)

print(N+M)

Submission status: Runtime Error

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

def comb(n, r):
    if n == 0:
        return 0
    if r == 0:
        return 0
    if n < r: 
        return 0

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = comb(N, 2) + comb(M, 2)

print(ans)

Submission status: Runtime Error

Solution code:
l=int(input());
l=l/3;
l=l*l*l;
print(l);

Submission status: Runtime Error

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

else:
    N1=0
    
if M !=1:
    M1=(math.factorial(M))//(math.factorial(M-2)*2)
else:
    M1=0
    
print(str(N1+M1))

Submission status: Runtime Error

Solution code:
N, M = input()
n = int(N)
m = int(M)

if m == 0:
    way = int((n * (n - 1)) / 2)
    print(str(way))
elif n == 0:
    way = int((m * (m - 1)) / 2)
    print(str(way))
else:
    way = int(((n * (n - 1)) / 2)+((m * (m - 1)) / 2))
    print(str(way))

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

ans = comb(n,2,exact=True) + comb(m,2,exact=True)

Submission status: Runtime Error

Solution code:
import math

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

def calculation(number):
    factorial = math.factorial(number)
    combination = factorial/math.factorial(number-2)
    result = math.floor(combination/2)
    return result

if m == 1 or 0:
    if n == 1 or 0:
        print("0")
    else:
        print("{}".format(calculation(n)))
else:
    if n == 1 or 0:
        print("{}".format(calculation(m)))
    else:
        print("{}".format(calculation(n)+calculation(m)))

Submission status: Runtime Error

Solution code:
from scipy.special import import comb

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

ans = comb(n,2,exact=True) + comb(m,2,exact=True)

Submission status: Runtime Error

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

N1=(math.factorial(N))//(math.factorial(N-2)*2)
M1=(math.factorial(M))//(math.factorial(M-2)*2)

print(str(N1+M1))

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if m == 0:
    way = int((n * (n - 1)) / 2)
    print(str(way))
elif n == 0:
    way = int((m * (m - 1)) / 2)
    print(str(way))
else:
    way = int(((n * (n - 1)) / 2)+((m * (m - 1)) / 2))
    print(str(way))

Submission status: Runtime Error

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

all = comb(n+m,2,exact=True)

print(all-m*n)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

if m == 0:
    way = int((n * (n - 1)) / 2)
    print(str(way))
elif n == 0:
    way = int((m * (m - 1)) / 2)
    print(str(way))
else:
    way = int(((n * (n - 1)) / 2)+((m * (m - 1)) / 2))
    print(str(way))

Submission status: Runtime Error

Solution code:
from math import factorial

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

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

if (n == 0 and m == 0) or (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))
# a = cmb(n, r)

Submission status: Runtime Error

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

N1=math.factorial(N)//(math.factorial(N-2)*2)
M1=math.factorial(M)//(math.factorial(M-2)*2)

print(N1+M1)

Submission status: Runtime Error

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

if m == 0:
    print(str((n * (n - 1)) / 2))
elif n == 0:
    way = str((m * (m - 1)) / 2)
    print(way)
else:
    way = str(((n * (n - 1)) / 2)+((m * (m - 1)) / 2))
    print(way)

Submission status: Runtime Error

Solution code:
import math

data = input()
data = data.split()
n = data[0]
m = data[1]

v = (math.factorial(int(n)) // (math.factorial(int(n) - 2) * math.factorial(2)))+(math.factorial(int(m)) // (math.factorial(int(m) - 2) * math.factorial(2)))

print(v)

Submission status: Runtime Error

Solution code:
#coding:utf-8
from scipy.special import comb

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

ans = comb(N,2,exact = True) + comb(M,2,exact = True)

print(ans)

Submission status: Runtime Error

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


import math
if m <=1:
  m_side = math.factorial(m)/math.factorial(m-2)/2
else:
  m_side = 0
if n <=1:
  n_side = math.factorial(n)/math.factorial(n-2)/2
else:
  n_side = 0
print(int(m_side + n_side))

Submission status: Runtime Error

Solution code:
from math import factorial

x,y=map(int,input().split())

a = factorial(x) / factorial(2) / factorial(x - 2)
b = factorial(y) / factorial(2) / factorial(y - 2)
print(int(a+b))

Submission status: Runtime Error

Solution code:
l=int(input())
n=l/3
print(n*n*n)

Submission status: Runtime Error

Solution code:
import math
from scipy.special import comb

N, M = map(int, input().split())
print(math.floor(comb(N, 2)+comb(M, 2)))

Submission status: Runtime Error

Solution code:
n = int(input())
print(pow(n / 3, 3))

Submission status: Runtime Error

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

def main():
    import sys
    N,M=list(map(int,sys.stdin.readline().split()))
    print(cmb(M,2)+cmb(N,2))


main()

Submission status: Runtime Error

Solution code:
import math


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

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

total = nCr(N,2) + nCr(M,2)

print(total)

Submission status: Runtime Error

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

n,m=(input("")).split()
print(int(C(int(n),2)+C(int(m),2)))

Submission status: Runtime Error

Solution code:
from scipy.special import comb 

def cmb(n,r):
    return comb(n, r, exact=True)

def main():
    import sys
    N,M=list(map(int,sys.stdin.readline().split()))
    print(cmb(M,2)+cmb(N,2))


main()

Submission status: Runtime Error

Solution code:
import math
import string


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


n, m = map(int, input().split())
#print(n, m)
if n == 1:
    print(0)
    exit()
a = nCr(n, 2)
print(a+m)

Submission status: Runtime Error

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

d1, d2 = data[0], data[1]

def fact(n):
  if n == 1:
    return 1
  else:
    return n * fact(n-1)
  
a = fact(d1) / fact(d1-2) / fact(2)

b = fact(d2) / fact(d2-2) / fact(2)

if d1 == 0:
  print(b)
elif d2 == 0:
  print(a)
else:
  print(int(a + b))

Submission status: Runtime Error

Solution code:
import math

N, M = map(int, input().split())
if M <= 1 and N <= 1:
    print(0)
elif N == 0:
    print(int((math.factorial(M)/(2*math.factorial(M-2)))))
elif M == 0:
    print(int((math.factorial(N)/(2*math.factorial(N-2)))))
else:
    print(int((math.factorial(N)/(2*math.factorial(N-2))) + (math.factorial(M)/(2*math.factorial(M-2)))))

Submission status: Runtime Error

Solution code:
import math

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

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

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

ans = comb(N,2) + comb(M,2)


print(int(ans))

Submission status: Runtime Error

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

a = special.comb(x, 2, True)
b = special.comb(y, 2, True)

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


#
if a != 0:
    cnt = cnt + cmb(a, 2)
cnt = cnt + cmb(b, 2)
print(cnt)

Submission status: Runtime Error

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

d1, d2 = data[0], data[1]

def fact(n):
  if n == 1:
    return 1
  else:
    return n * fact(n-1)
  
a = fact(d1) / fact(d1-2) / fact(2)

b = fact(d2) / fact(d2-2) / fact(2)

print(int(a + b))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

num1 = 1
list_M = []

for i in M:
  list_M.append(i)
  num1 += 1

num2 = 1
list_n = []
for j in N:
  list_N.append(j)
  num2 += 1

add_list = []
for k in M:
  for l in N:
    add_list.append(list_m[k] + list[l])

odd = 0

for m in add_list:
  if m % 2 == 0:
    odd += 1
    
print(odd)

Submission status: Runtime Error

Solution code:
A,B = list(map(int,input().split()))
import math
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if A == 0:
  D = combinations_count(B, 2)
  print(D)
  exit()
elif B == 0:
  C = combinations_count(A, 2)
  exit()
C = combinations_count(A, 2)
D = combinations_count(B, 2)
print(C+D)

Submission status: Runtime Error

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

even = comb(n,2,exact=True) + comb(m,2,exact=True)

print(even)

Submission status: Runtime Error

Solution code:
import math
import itertools

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

if __name__ == "__main__":
    N, M = map(int, input().split())
    ret = 0
    if M != 0:
        ret += combinations_count(M, 2)
    else:
        pass
    if N != 0:
        ret += combinations_count(N, 2)
    else:
        pass
    print(ret)

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 < 2:
  a = cmb(M,2)
elif M < 2:
  a = cmb(N,2)
elif N > 1 and M > 1:
  a = cmb(N,2) + cmb(M,2)
else:
  a = 0

print(int(a))

Submission status: Runtime Error

Solution code:
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if A == 0:
  D = combinations_count(B, 2)
  print(D)
  exit()
elif B == 0:
  C = combinations_count(A, 2)
  exit()
C = combinations_count(A, 2)
D = combinations_count(B, 2)
print(C+D)

Submission status: Runtime Error

Solution code:
from math import factorial
def nc2(n):
	if n<r:
		return 0
	else:
		return (n*(n-1))//2

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

done = {}
for i in range(n):
	try:
		if done[arr[i]] > -1:
			continue
	except KeyError:
		ans = 0
		for j in d.keys():
			if j == arr[i]:
				ans+= ncr(len(d[j])-1,2)
			else:
				ans+= ncr(len(d[j]),2)
		done[arr[i]] = int(ans)

for i in arr:
	print(done[i])

Submission status: Runtime Error

Solution code:
from math import factorial

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

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

if n == 1:
    if m == 1:
        print(0)
    else:
        print(combinations_count(m, 2))
elif m == 1:
    print(combinations_count(n, 2))
else:
    print(combinations_count(n, 2) + combinations_count(m, 2))
# a = cmb(n, r)

Submission status: Runtime Error

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


import math
m_side = math.factorial(m)/math.factorial(m-2)/2
n_side = math.factorial(n)/math.factorial(n-2)/2
print(m_side + n_side)

Submission status: Runtime Error

Solution code:
"""
"""

from math import factorial


def int_as_array(num): return list(map(int, [y for y in str(num)]))


def array_as_int(arr): return int(''.join(map(str, arr)))


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


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


def array_to_string(arr, sep=' '): return sep.join(map(str, arr))


def matrix_to_string(arr, sep=' '): return '[\n' + '\n'.join(
    [sep.join(map(str, row)) for row in arr]) + '\n]'


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


def solve(N, M):
    choose_evens = combine(N, 2)
    choose_odds = combine(M, 2)
    return choose_evens + choose_odds


print('input()', input())
N, M = read_array()
print('N, M', N, M)
solve(N, M)

Submission status: Runtime Error

Solution code:
#スペース区切りの整数入力
N, M  = map(int, input().split())

if N > 2:
    N_even = N*(N - 1)/2
else:
    N_even = 0

if M > 2:
    M_even = M*(M-1)/2
else:
    M_even = 0

print(int(N_even + M_even))

Submission status: Runtime Error

Solution code:

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

print(N*M)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#coding:utf-8
from scipy.special import perm, comb

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

ansN = comb(N,2,exact = True)
ansM = comb(M,2,exact = True)

ans = ansN + ansM

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 == 1:
    if m == 1:
        print(0)
    else:
        print(cmb(m, 2))
elif m == 1:
    print(cmb(n, 2))
else:
    print(cmb(n, 2) + cmb(m, 2))
# a = cmb(n, r)

Submission status: Runtime Error

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

if N=<1:
  print(math.floor(M*(M-1)/2))
elif M=<1:
  print(math.floor(N*(N-1)/2))
else: 
  print(math.floor((N*(N-1)/2)+(M*(M-1)/2)))

Submission status: Runtime Error

Solution code:
L = int(input())
ans = L**3
ans = ans / 27
print(ans)

Submission status: Runtime Error

Solution code:
A,B = list(map(int,input().split()))
import math
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
C = combinations_count(A, 2)
D = combinations_count(B, 2)
print(C+D)

Submission status: Runtime Error

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

print(int(a))

Submission status: Runtime Error

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

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

print(num1+num2)

Submission status: Runtime Error

Solution code:
import  math

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

ans = (math.factorial(n) // (math.factorial(n - 2) * math.factorial(2)))  + (math.factorial(m) // ((math.factorial(m - 2) * math.factorial(2))))
print(ans)

Submission status: Runtime Error

Solution code:
import math
N, M= list(map(int, input().split()))
'''
# 組み合わせ計算
print(math.factorial(N)//math.factorial(N-2)//2)
print(math.factorial(M)//math.factorial(max(M-2, 1))//2)
'''
num = math.factorial(N)//math.factorial(N-2)//2 + math.factorial(M)//math.factorial(max(M-2, 1))//2
print(num)

Submission status: Runtime Error

Solution code:
#coding:utf-8
from scipy.special import perm, comb

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

ansN = comb(N,2,exact = True)
ansM = comb(M,2,exact = True)

ans = ansN + ansM

print(ans)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

n, m = map(int, input().split())
print(comb(n, 2, exact=True)+comb(m,2, exact=True))

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)
  else:
    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:
S = input()
N = len(str(S))
temp = S[0:(N-1)/2]
temp2 = S[(N+2)/2:N]
print("Yes") if temp == temp[::-1] and temp2 == temp2[::-1] else "No"

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:

N=int(input())
M=int(input())
num=0

for i in range(M):
  num=num+(N-i)

print(num)

Submission status: Runtime Error

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 and N != 1:
    a = combinations_count(N, 2)
else:
    a = 0

if M !=0 and M != 0:
    b = combinations_count(M, 2)
else:
    b = 0

print(a+b)

Submission status: Runtime Error

Solution code:
L=float(input())
print((L/3)**3)

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 scipy.special import comb

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

ans = comb(N,2) + comb(M,2)


print(int(ans))

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


#
if a != 0:
    cnt = cnt + cmb(a, 2)
cnt = cnt + cmb(b, 2)
print(cnt)

Submission status: Runtime Error

Solution code:
N = input()
M = input()
A = (factorial(N)*factorial(N-1))+(factorial(M)*factorial(M-1))/2
print A

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==0 or n==1:
    print(cmb(m,2))
    quit()
elif m==0 or m==1:
    print(cmb(n,2))
    quit()
print(cmb(n,2)+cmb(m,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))