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

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

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

print(ans)

Submission status: Runtime Error

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

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

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

print(ans)

Submission status: Runtime Error

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

import itertools
guusu = itertools.combinations(N,2)
kisuu = itertools.combinations(M,2)

print(guusu + kisuu)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
print(M*(M-1)/2+N*(N-1)/2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
M*(M-1)/2+N*(N-1)/2

Submission status: Runtime Error

Solution code:
M*(M-1)/2+N(N-1)/2

Submission status: Runtime Error

Solution code:
M*(m-1)/2+N(N-1)/2

Submission status: Runtime Error

Solution code:
def palindrome(word):
  if len(word) <= 1:
    return True
  if word[0] != word[-1]:
    return False
  return palindrome(word[1:-1])
 
word = input().lower()
n = len(word) // 2
issuper = palindrome(word[:n]) and palindrome(word[n+1:])
print("Yes" if issuper else "No"))

Submission status: Runtime Error

Solution code:
import math
n_num,m_num=map(int,input().split())
n_comb=math.factorial(n_num)//(math.factorial(n_num-2)*math.factorial(2))
m_comb=math.factorial(m_num)//(math.factorial(m_num-2)*math.factorial(2))
print(int(n_comb+m_comb))

Submission status: Runtime Error

Solution code:
import math
n_num,m_num=map(int,input().split())
n_comb=math.factorial(n_num)/(math.factorial(n_num-2)*math.factorial(2))
m_comb=math.factorial(m_num)/(math.factorial(m_num-2)*math.factorial(2))
print(int(n_comb+m_comb))

Submission status: Runtime Error

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

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

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


if __name__ == '__main__':
	main()

Submission status: Runtime Error

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

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


if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
def main():
	# s = int(input())
	# s = str(input())
	a,b = map(int,input().split())

	from itertools import combinations

	if b == 0 or b == 1:
		print(len(combinations(a,2)))
	else:
		print(len(combinations(a,2)) + len(combinations(b,2)))


if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
def main():
	# s = int(input())
	# s = str(input())
	a,b = map(int,input().split())
	#1行R列
	# a = list(map(int,input().split()))
	#R行1列
	# l = [str(input()) for i in range(n)]
	#R行C列
	# qu = [list(map(str,input().split())) for x in range(q)]
	# print(' '.join(map(str,)))
	from itertools import permutations, combinations,combinations_with_replacement,product

	if b == 0 or b == 1:
		print(combinations(a,2))
	else:
		print(combinations(a,2) + combinations(b,2))


if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
def main():

	a,b = map(int,input().split())

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

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


if __name__ == '__main__':
	main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
L = int(input())

print((L/3)**3)

Submission status: Runtime Error

Solution code:
# C - Maximum Volume
# https://atcoder.jp/contests/abc159/tasks/abc159_c

L = int(input())

center = (L/3)
pre = center - 0.1

follow = center + 0.1
# print(pre)
# print(center)
# print(follow)

print(center*center*center)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int, input().split()))
a = 0
for m in range(n):
    k = l.count(m+1)
    a += int(k*(k-1)/2)
for m in range(n):
    print(a-l.count(l[m])+1)

Submission status: Runtime Error

Solution code:
L=int(input())
L1=(L//3)
L2=L%3
while L2>=10**-16:
    L1+=(L2/3)
    L2=(L2/3)

print(L1**3)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

print(max_vol)

Submission status: Runtime Error

Solution code:
L=int(input())
max_vol=0
for i in range(1,L):
  for j in range(1,L-i):
    k=L-i-j
    vol=i*j*k
    max_vol=max(max_vol,vol)
print(max_vol)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

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

Submission status: Runtime Error

Solution code:
def main():
    input()
    t = list(map(int, input().split()))
    col = collections.Counter(t)
    com = {}
    al = 0
    for key in col:
        com[key] = combinations_count(col[key], 2)
        al += com[key]
    for v in t:
        c = col[v] - 1
        if c <= 1:
            c = 0
        else:
            c = combinations_count(c, 2)
        tmp = (al - com[v]) + c
        print(tmp)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import stdin
from scipy import special
N,M = list(map(int, (stdin.readline().strip().split())))
count=0
count+=special.comb(N,2, True)
count+=special.comb(M,2, True)
print(count)

Submission status: Runtime Error

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

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

print(x)

Submission status: Runtime Error

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

if n = 0:
  pn = 0
  
if m = 0:
  pm = 0

else:
  pn = n*(n-1) // 2
  pm = m*(m-1) // 2

p = pn + pm
print(p)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
import math
if n <= 1:
  pn = 0
  if m <= 1:
    pm = 0
  else:
    pm = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))
elif m >= 2:
  pn = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))
  pm = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))

p = pn + pm
print(p)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
import math
pn = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))
pm = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))
p = pn + pm
print(p)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
import math
pn = math.factorial(n) / (math.factorial(n-2) * math.factorial(2))
pm = math.factorial(m) / (math.factorial(m-2) * math.factorial(2))
print(pn + pm)

Submission status: Runtime Error

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

print(len(list(itertools.combinations(n,2)))+len(list(itertools.combinations(m,2)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
N = len(S)
if S == S[::-1] and S[:(N - 1)//2][::-1] == S[:(N - 1)//2] and S[(N + 3)//2][::-1] == S[(N + 3)//2]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
def main():
    import numpy as np
    inf = 100100100
    ans = inf
    H, W, K = map(int, input().split())
    S = []
    for _ in range(H):
        S.append([int(x) for x in input()])
    S = np.array(S)
    for i in range(2**(H-1)):
        group = [0]
        g = 0
        for j in range(H-1):
            if (i >> j) & 1:
                g += 1
            group.append(g)
        group = np.array(group)
        g += 1
        c = np.array([[0]*W]*g)
        for j in range(H):
            for k in range(W):
                c[group[j],k] += S[j,k]
        num = g-1
        now = np.zeros(g)
        def large(now):
            for n in now:
                if n > K:
                    return True
            else:
                return False
        for k in range(W):
            now += c[:,k]
            if large(now):
                now = c[:,k]
                num += 1
                if large(now):
                    num = inf
                    break
        ans = min(ans, num)
    print(ans)
main()

Submission status: Runtime Error

Solution code:
import collections

n = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)

ans = 0

for i in c.values():
    ans += i * (i - 1) // 2

for i in range(n):
    print(ans - c[a[i]] + 1)

Submission status: Runtime Error

Solution code:
import itertools

n,m = map(int,input().split())
comb = itertools.combinations
print(comb(n,2)+comb(m,2))

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;

int main(){
 
  int N,M;
  
 cin >> N >>M;

 // nc2 + mc2
 cout << N * (N-1) / 2 + M * (M - 1) / 2 << endl;
  
 return 0;
  
}

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:
import math
A = list(map(int, input().split()))
result  = math.factorial(A[0])/2/math.factorial(A[0]-2)+math.factorial(A[1])/2/math.factorial(A[1]-2)
print (result)

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

if (m != 1):
    ans = ans + combinations_count(m, 2)
    
print(ans)

Submission status: Runtime Error

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

from collections import Counter

c = Counter(L)
d = {}
sum = 0

for i in c:
    k = c[i]
    sum += k * (k-1) //2
for i in range(N):
    print(int(sum - c[L[i]] + 1))

Submission status: Runtime Error

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

from collections import Counter

c = Counter(L)
d = {}
sum = 0

for i in c:
    k = c(i)
    sum += k * (k-1) //2
for i in range(N):
    print(int(sum - c[L[i]] + 1))

Submission status: Runtime Error

Solution code:
def compute_fact(n):
    global f
    f = [0 for i in range(n+1)]
    f[0] = 1
    f[1] = 1
    for i in range(2,n+1):
        f[i] = f[i-1]*i

def compute_c(n,r):
    compute_fact(n)
    ans = f[n]/(f[r] * f[n-r])
    return ans

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

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
a = list(map(int, input().split()))

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

"""
for i in range(n):
    count = a.count(i+1)
    count_all += combi(count)
"""
count_all = sum([combi(a.count(i+1)) for i in range(n)])
"""
for k in range(n):
    #aのk番目の要素と同じ要素の数を(k番目の要素も含めて)出し、1を引く
    count = a.count(a[k]) - 1
    ans = count_all - count
    print(ans)
"""
count = [a.count(a[k]) - 1 for k in range(n)]
x = np.array([count_all]*n)
y = np.array(count)
ans = x-y
for s in ans.tolist():
    print(s)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math

n, m = map(int, input().split())
ans = math.factorial(n) / math.factorial(n - 2) / 2
ans += math.factorial(m) / math.factorial(m - 2) / 2
print(int(ans))

Submission status: Runtime Error

Solution code:
import math

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

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

print(int(n + m))

Submission status: Runtime Error

Solution code:
def comb(val):
    if(val > 0):
        return int(val*(val-1) / 2)
    else:
        return 0
    
def make_map(balls):
    balls_map = {}
    for ball in balls:
        if(ball in balls_map):
            balls_map[ball] += 1
        else:
            balls_map[ball] = 1
    return balls_map

def main():
    args = input().rstrip().split(' ')
    N = int(args[0])
    balls = [val for val in input().rstrip().split(' ')]
    balls_map = make_map(balls)
    
    sum_ = 0
    for ball in balls:
        balls_map[ball] -= 1
        sum_ = 0
        for val in balls_map.values():
            sum_ += comb(val)
        print(sum_)
        balls_map[ball] += 1
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
s=input()
s = int(s)
t=input()
t = int(t)
print(s*(s-1) /2 + t*(t-1)/2)

Submission status: Runtime Error

Solution code:
even, odd = map(int,input().split())
print((even*~-even // 2) + (odd*=~-odd // 2))

Submission status: Runtime Error

Solution code:
even, odd = map(int,input().split())
print((even*~-n // 2) + (odd*=~-odd // 2))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readlines().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Submission status: Runtime Error

Solution code:
from collections import Counter
from operator import mul
from functools import reduce

def combinations_count2(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
#
N=int(input())
A=list(map(int,input().split()))
#
hoge=Counter(A)
ans1=0
for i in hoge.values():
    if i==1:
        continue
    else:
        ans1+=combinations_count2(i,2)

ans2=[]
for i in A:
    ans2.append(A.count(i)-1)

for k in range(N):
    print(ans1-ans2[k])

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    from scipy.special import comb
    NM = list(map(int,readline().split()))
    cnt = 0
    for nm in NM:
        if nm <2:
            continue
        else:
            cnt += comb(nm, 2, exact=True)
    print(cnt)
    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def chose(A):
    s = 0
    t = 0
    for i in range(len(A)):
        t = A.count(i+1) 
        for q in range(t):
            s += q
    print(s)

for i in range(N):
    B = C[:]
    B.pop(i)
    chose(B)

Submission status: Runtime Error

Solution code:
from math import factorial

inputted = list(map(int, input().split()))
N = inputted[0]
M = inputted[1]

nPk = lambda n, k: factorial(n) / (factorial(k) * factorial(n - k))

answer = nPk(N, 2) +  nPk(M, 2)
answer = int(answer)

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
MOD = 998244353

N, S = map(int, input().split())
A = list(map(int, input().split()))

DP = [[[0] * 3 for _ in range(S + 1)] for _ in range(N + 1)]
DP[0][0][0] = 1

for i in range(N):
    DP[i + 1][0][0] = DP[i][0][0] 
    a = A[i]
    for j in range(S + 1):
        if j == 0: #左側を決めて合計0になるのは、
            # DP[i + 1][j][0] = DP[i][j][0] 
            DP[i + 1][j][1] = DP[i][j][0] + DP[i][j][1]
        elif j < a: #左側を決めて合計jになるとき、ただしaはjより大きいので使えない
            # DP[i + 1][j][0] = DP[i][j][0] 
            DP[i + 1][j][1] = DP[i][j][0] + DP[i][j][1] #以前から合計jになっている場合のみOK
        else: #左側を決めて合計j > aになるとき, aだけでは足りない = 左側はこれより前で決まっている
            DP[i + 1][j][1] = DP[i][j][0] + DP[i][j][1] + DP[i][j - a][0] + DP[i][j - a][1]
        # DP[i + 1][j][0] %= MOD
        DP[i + 1][j][0] %= MOD
    DP[i + 1][S][2] = DP[i][S][1] + DP[i][S][2]
    if a <= S:
        DP[i + 1][S][2] += DP[i][S - a][0] + DP[i][S - a][1]
    DP[i + 1][S][2] %= MOD

print (DP[N][S][2])

# for i in range(N + 1):
#     print (DP[i])

Submission status: Runtime Error

Solution code:
import math


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

li = list(map(int, input().split()))
n = li[0]
m = li[1]

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

Submission status: Runtime Error

Solution code:
H, W, K = map(int, input().split())
S = list(input() for i in range(H))

sum = [[0] * (W+1) for i in range((H+1))]
for i in range(H):
    for j in range(W):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if S[i][j] == '1' else 0)

ans = H + W - 2

for ptn in range(1<<H-1): # 2^H - 1 通り
    cand = 0

    sep = [0] # 横方向の分割リスト、ここ天才
    for i in range(H-1):
        if((ptn >> i) & 1): # & を取ることで、上の桁を消せる
            sep.append(i+1)
            cand += 1
    sep.append(H)

    left = 0 # left は直前の分割
    for pos in range(W):
    	cur = [] # cur は今見てるホワイトチョコの個数のリスト

    	# 横方向に分割されている各部分について
    	for i in range(len(sep) - 1):
    		cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])

    	if max(cur) > K:
    		if left == pos: # 縦に分割できない場合(一列しかない場合)
    			cand = H * W
    			break
    		else:
    			cand += 1
    			left = pos

    ans = min(ans, cand)

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
a = (len(S) - 1) / 2
b = (len(S) + 1) / 2
if S[:a] == S[b:]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import factorial as f
n,m=map(int,input().split())
print(f(n)//(f(2)*f(n-2))+f(m)//(f(2)*f(m-2)))

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

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

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

Submission status: Runtime Error

Solution code:
x = input().split
n = int(x[0])
m = int(x[1])
if n == 0:
  print(m * (m -1) /2)
elif m == 0:
  print(n * (n - 1) / 2)
else:
  k = m * (m -1) /2 + n * (n - 1) / 2
  print(k)

Submission status: Runtime Error

Solution code:
import sys
nums = sys.stdin.readline().rstrip()
from itertools import combinations
even = combinations(nums[0],2)
odd = combinations(nums[1],2)
print(even + odd)

Submission status: Runtime Error

Solution code:
import math


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


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

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


evenPairs()

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

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


evenPairs()

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

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

Submission status: Runtime Error

Solution code:
# number of balls
N = input()
# ball values
K = list(map(int, input().split()))

# get ball counts
ball_counts = {}
for i in range(len(K)):
    ball_value = K[i]
    if ball_value in ball_counts:
        ball_counts[ball_value] += 1
    else:
        ball_counts[ball_value] = 1

# get sums
total_sum = 0
for value, count in ball_counts.items():
    total_sum += (count * (count - 1)) / 2

# remove extra
for i in range(len(K)):
    ball_value = K[i]
    print(int(total_sum - (ball_counts[ball_value] - 1)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3
import copy

def minOp(h, w, k, yl, s):
    xl = []
    ks = [ 0 for i in range(len(yl) + 1) ]
    sxl = 0
    
    for x in range(w):
        py = 0
        cks = [ 0 for i in range(len(yl) + 1) ]
        for idx, y in enumerate(yl + [h - 1]):
            for yy in range(py, y + 1):
                if s[yy][x] == '1':
                    cks[idx] += 1

            py = y + 1

        over = False
        for idx, kk in enumerate(ks):
            if kk + cks[idx] > k:
                over = True

        if over:
            if sxl == 0:
                return (h - 1) + (w - 1)
            xl.append(x - 1)
            ks = copy.copy(cks)
            sxl = 0
        else:
            sxl += 1
            ks = list(map(lambda a, b: a + b, ks, cks))

    return len(xl) + len(yl)
    

def devideVertical(h, w, k, cy, yl, s):
    m = (h - 1) + (w - 1)
    for y in range(cy, h - 1):
        nyl = copy.copy(yl)
        nyl.append(y)
        m = min(m, devideVertical(h, w, k, y + 1, nyl, s))
    
    m = min(m, minOp(h, w, k, yl, s))
    return m

(h, w, k) = map(int, input().split())
s = []
for i in range(h):
    s.append(input())

print(devideVertical(h, w, k, 0, [], s))

Submission status: Runtime Error

Solution code:
				
def factorial(number):
	if number>2:
		return number*factorial(number-1)
	elif not number==0:
		return number
	else:
		return 1
def choose2(number):
	if number>=2:
		return number*(number-1)/2
	else:
		return 0
N = int(input())
klist = input()
k = []
for x in range(N-1):
	k.append(int(klist[:klist.index(" ")]))
	klist = klist[klist.index(" ")+1:]
k.append(int(klist))
valArr = list(set(k))
occurence = []
for i in range(len(valArr)):
	occurence.append(0)
for j in range(N):
	for x in range(len(valArr)):
		if k[j]==valArr[x]:
			occurence[x]+=1
for ball in range(len(k)):
	ans = 0
	kArray = occurence[:len(occurence)]
	for index in range(len(valArr)):
		if valArr[index]==k[ball]:
			kArray[index]-=1
			break;
	for time in kArray:
		ans+=choose2(time)
	print(int(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

import numpy as np

H, W, K = map(int, input().split())

data = np.array([[None] * W for _ in range(H)])

for i in range(H):
    temp = input()
    for j in range(W):
        data[i, j] = int(temp[j])


current_best = np.inf

# Hに関する全ての場合を試す
for cnt in range(2 ** (H-1)):
    # bitで1の場所が切れ目とする
    option_h = np.array([int(s) for s in list(bin(cnt))[2:][::-1]])
    kireme = np.where(option_h == 1)[0]

    # 各グループについて1の数を集計する
    li = 0
    g = np.array([[None] * W for _ in range(len(kireme) + 1)])
    if len(kireme) == 0:
        g[0] = data[li:, :].sum(axis=0)
    else:
        for cnt, j in enumerate(kireme):
            g[cnt] = data[li:j+1, :].sum(axis=0)
            li = j + 1
        g[-1] = data[li:, :].sum(axis=0)

    # 左から順に足していく
    score = len(kireme)
    if score > current_best:
        # すでにこの時点で回数かかっていれば探索打ち切り
        continue
    cnt = np.zeros(len(kireme) + 1)
    for col in range(W):
        cnt = cnt + g[:, col]
        # どこか1つのグループでもKを超えてしまったらその左で切る
        if (cnt > K).any():
            score += 1
            # 最小を求めたいので、それまでの結果と同じ値になってしまったら終了
            if score >= current_best:
                break
            cnt = g[:, col]
            # 現在の列だけで条件を満たせないのであれば不可能なので終了
            if (cnt > K).any():
                score = np.inf
                break
    # スコアの更新
    if score < current_best:
        current_best = score


print(current_best)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

pattern_1 = N*(N-1)/2
pattern_2 = M*(M-1)/2

print(pattern_1 + pattern_2)

Submission status: Runtime Error

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

# 偶数＋偶数
pattern_1 = N*(N-1)/2

# 奇数＋奇数
pattern_2 = M*(M-1)/2

print(pattern_1 + pattern_2)

Submission status: Runtime Error

Solution code:
S = input()

if  S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
d = len(s)//2
print("Yes" if s[:d] == s[d+1:] "No" else)

Submission status: Runtime Error

Solution code:
import sys

n = int(sys.stdin.readline())
 
li = list(map(int, sys.stdin.readline().split()))
 
ans = [0]*n
for i in range(n):
    li2 = li.copy()
    del li2[i]
    for j in range(n-1):
        for k in range(j+1, n-1):
            if li2[j] == li2[k]:
                ans[i] += 1
for l in range(len(ans)):
    print(ans[l])

Submission status: Runtime Error

Solution code:
import utility

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

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

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

print(int(result))

Submission status: Runtime Error

Solution code:
import math
 
def combination(n):
  c = 0
  if n > 0:
    c = math.factorial(n)/(2*math.factorial(n-2))
	
  return int(c)
 
N, M = map(int, input().split())
 
print(combination(N)+combination(M))

Submission status: Runtime Error

Solution code:
from math import factorial
 
def combination(n):
  c = 0
  if n > 0:
    c = factorial(n)/(2*factorial(n-2))
	
  return int(c)
 
N, M = map(int, input().split())
 
print(combination(N)+combination(M))

Submission status: Runtime Error

Solution code:
from math import factorial
 
def combination(n):
  c = 0
  if n > 0:
    c = factorial(n)/(2*factorial(n-2))
	
  return int(c)
 
N, M = [int(x) for x in input().split()]
 
print(combination(N)+combination(M))

Submission status: Runtime Error

Solution code:
from math import factorial

def combination(n):
  
  c = factorial(n)/(2*factorial(n-2))
  return int(c)

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

print(combination(N)+combination(M))

Submission status: Runtime Error

Solution code:
x = input() 
y = input()
print(x*(x-1)/2+y*(y-1)/2)

Submission status: Runtime Error

Solution code:
x = input() y = input()
print(x*(x-1)/2+y*(y-1)/2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import stdin

N, M = stdin.readline().rstrip().split()

#全ての組み合わせのうち、奇数になるもののみ除く（奇数 + 偶数）

total = ((N+M)*(N+M-1))/2
odd = N*M

print(total - odd)

Submission status: Runtime Error

Solution code:
from sys import stdin

N, M = stdin.readline().rstrip().split()

#全ての組み合わせのうち、奇数になるもののみ除く（奇数 + 偶数）

NM = N*M
total = (NM*(NM-1))/2
odd = NM/2

print(total - odd)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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