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

print(math.factrial(N)//2 + math.factrial(M)//2)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(combinations_count(N, 2)+combinations_count(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:
even,odd = map(int, input().split())

def f(n):
  if n == 1 or n == 0:
    return 1
  else:
    return n*f(n-1)
  
print(int(f(even)/(f(even-2)*2) + f(odd)/(f(odd-2)*2)))

Submission status: Runtime Error

Solution code:
even,odd = map(int, input().split())

def f(n):
if n == 1 or n ==0:
   return 1
else:
   return n*f(n-1)
  
print(f(even) + f(odd))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(floor(N*(N-1)*0.5 + M))

Submission status: Runtime Error

Solution code:
from math import floor

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

print(floor(N*(N-1)*0.5 + M))

Submission status: Runtime Error

Solution code:
i = input()

N, M = i.split()

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

Submission status: Runtime Error

Solution code:
from math import factorial

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

def comb(n, k):
    return int(factorial(n) / factorial(k) / factorial(n-k))

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

print(res)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n>> m;
    if(n>=2&&m>=2){
        cout << n*(n-1)/2 + m*(m-1)/2;
    }
    else if(n==1 && m==1){
        cout << 0;
    }
    else{
        cout << max(n,m)*(max(n,m)-1)/2;
    }
}

Submission status: Runtime Error

Solution code:
x,y = [int(x) for x in input().split()]
def c(m):
      if (m>=2):
            return m*(m-1)//2
      else:
            return 0
if (x<2 and y<2):
      print(s)
else:
      print(c(x)+c(y))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
N=int(sys.stdin.readline())
L=list(map(int,sys.stdin.readline().split()))
count=[0]*N
C=list(set(L))
x=0
d=[0]*len(C)
e=[0]*N
for i in range(len(C)):
  d[i] = int((L.count(C[i]))*(L.count(C[i])-1)/2)
  x += d[i]  
for K in range(N):
  e[K] = L.count(L[K])-1
  print(x-e[K])

Submission status: Runtime Error

Solution code:
function Main(input) {
	var str = input;
	var ans = 0;
	var str = str.split("\n")[0];
	var num = str.split(" ");
	var n = Number(num[0]);	
	var m = Number(num[1]);	
	
	if(n >1){
		n = n*(n-1)/2;
	}
	if(m>1){
		m = m*(m-1)/2;
	}
	ans = n+m;
		console.log(ans);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Submission status: Runtime Error

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

Submission status: Runtime Error

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


def main():
    # input
    n = int(readline().rstrip())
    A = list(map(int, readline().rstrip().split()))
    B = [0] * n

    for a in A:
        B[a - 1] += 1

    total = 0
    for b in B:
        if b > 1:
            total += b * (b - 1) // 2

    C = [0] * n
    for i, b in enumerate(B):
        C[i] = total - b + 1

    for a in A:
        print(C[a-1])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s=input()

s1=str.reverse(s)

if s==s1:
  print("YES")
else:
  print("NO")

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=int(input())
m=int(input())

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

Submission status: Runtime Error

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

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

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

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

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

Submission status: Runtime Error

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

def factorial(n):
    v = 1
    for i in range(1, n + 1):
        v *= i
    return v

def comb(a, b):
    return factorial(a) // (factorial(b) * factorial(a - b))

from collections import Counter
acnt = dict(Counter(a))
value = list(acnt.values())
sv = 0
for i in range(len(value)):
    if value[i] > 1:
        sv += (value[i]*value[i-1])//2
for i in range(n):
    cur = a[i]
    cursv = sv
    if acnt[cur] > 2:
        cursv = cursv - acnt[cur] + 1
    elif acnt[cur] == 2:
        cursv -= 1
    print(cursv)

Submission status: Runtime Error

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

while n > 0:
    a = a + n
    n = n - 1

while m > 0:
    a = a + m
    m = m - 1

print(a)

Submission status: Runtime Error

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

while n > 0:
    a = a + n

while m > 0:
    a = a + m

print(a)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import math

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

print(int(math.factorial(N)/math.factorial(N-2)/math.factorial(2)+math.factorial(M)/math.factorial(M-2)/math.factorial(2)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb
n,m = map(int,input().split())
ans1=0
ans2=0
if n > 1:
    ans1=comb(n,2,exact=True)
if m > 1:
    ans2=comb(m,2,exact=True)
print(ans1+ans2)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input())
if n >= 2:
	for i in range(n):
		i *= i
if m >= 2:
	for j in range(m):
    	j *= j
print(i+j//4)

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 itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(N, 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(M, 2)))

c3 = c1 + c2
print(c3)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

if N == 1:
    c1 = 0
else:
    c1 = comb(N, 2, exact = False)

if M == 1:
    c2 = 0
else:
    c2 = comb(M, 2, exact = False)

c3 = c1 + c2
print(c3)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

if N == 1:
    c1 = 0
else:
    c1 = comb(N, 2, exact=True)

if M == 1:
    c2 = 0
else:
    c2 = comb(M, 2, exact=True)

c3 = c1 + c2
print(c3)

Submission status: Runtime Error

Solution code:
from scipy import special

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

if N == 1:
    c1 = 0
else:
    c1 = special.comb(N, 2)

if M == 1:
    c2 = 0
else:
    c2 = special.comb(M, 2)

c3 = c1 + c2
print(c3)

Submission status: Runtime Error

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

if N == 1:
    c1 = 0
else:
    c1 = N! / (2! * (N - 2)!)

if M == 1:
    c2 = 0
else:
    c2 = M! / (2! * (M - 2)!)

print(c1 + c2)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb

ARGS=input().split()
N=int(ARGS[0])
M=int(ARGS[1])

COMB=int(comb(N, 2) + comb(M, 2))

print(str(COMB))

Submission status: Runtime Error

Solution code:
import math
def f(x):
    return math.factorial(x)
arr=list(map(int,input().split()))
n=arr[0]
m=arr[1]
cnt=0
cnt+=int(f(n)/(2*f(n-2)))
if m>1:cnt+=int(f(m)/(2*f(m-2)))
print(int(cnt))

Submission status: Runtime Error

Solution code:
import math


def f(x):
    return math.factorial(x)


arr = list(map(int, input().split()))
n = arr[0]
m = arr[1]
cnt = 0
cnt += int(f(n) / (2 * f(n - 2)))
if m > 1:
    cnt += int(f(m) / (2 * f(m - 2)))
print(int(cnt))

Submission status: Runtime Error

Solution code:
import math

def f(xx):
    return math.factorial(xx)


arr = list(map(int, input().split()))
n = arr[0]
m = arr[1]
cnt = 0
cnt += int(f(n) / (2 * f(n - 2)))
if m > 1:
    cnt += int(f(m) / (2 * f(m - 2)))
print(int(cnt))

Submission status: Runtime Error

Solution code:
import math


def f(xxx):
    return math.factorial(xxx)


arr = list(map(int, input().split()))
n = arr[0]
m = arr[1]
cnt = 0
cnt += int(f(n) / (2 * f(n - 2)))
if m > 1:
    cnt += int(f(m) / (2 * f(m - 2)))
print(int(cnt))

Submission status: Runtime Error

Solution code:
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
  n = int(input())
  a = list(map(int, input().split()))
  c = collections.Counter(a)
  s = 0
  for i in list(c.values()):
    s += i*(i-1)//2
  print(c)
  for i in a:
    print(c[i])
    print(s-(c[i]-1))
  return 0
 
if __name__ == "__main__":
  solve()

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from math import factorial

def choose(n, k):
    if n <= 0:
        return 0
    else:
        return factorial(n) // factorial(k) // factorial(n - k)

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

Submission status: Runtime Error

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

a = comb(N, 2, exact=True)
b = comb(M, 2, exact=True)

print(a+b)

Submission status: Runtime Error

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

pattern_even=(N-1)*N/2
pattern_odd=(M-1)*M/2

return (pattern_even+pattern_odd)

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    lim = max(a)
    amount = [0]*lim
    for i in range(lim):
        amount[i] = a.count(i+1)
        ans += amount[i]*(amount[i]-1)//2
    #print(ans)
    for j in range(n):
        ansout = ans
        #print(amount[a[j]-1])
        ansout -= amount[a[j]-1] -1
        print(ansout)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def resolve():
    import itertools
    N,M = map(int,input().split())
    N_list = [int(x) for x in range(N)]
    M_list = [int(y) for y in range(M)]

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
from scipy.special import comb

# 標準入力の取得
N, M = list(map(int, input().split()))

# 求解処理
result = comb(N, 2, exact=True) + comb(M, 2, exact=True)

# 結果出力
print(result)

Submission status: Runtime Error

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

result = 0

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

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

print(result)

Submission status: Runtime Error

Solution code:
import sys
from math import factorial

def comb(n,r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return int(a)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

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

print(ans)

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

  su = combinations_count(n+m, 2)
  mm = n*m
  ans = su-mm

  print(str(ans))

Submission status: Runtime Error

Solution code:
from math import factorial as f
f_1,f_2=0,0
if N>1:
    f_1=f(N)/(f(2)*f(N-2))
if M>1:
    f_2=f(M)/(f(2)*f(M-2))
print(int(f_1+f_2))

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

Submission status: Runtime Error

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

from collections import Counter

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

#
C=Counter()
for i in range(n):
    C[a[i]] += 1
xsum=0
for key, value in C.items():
    xsum += value*(value-1)//2

#
for k in range(n):
    print( xsum - (C[a[k]] - 1) )

Submission status: Runtime Error

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

base1 = comb(e, 2, exact=True)
base2 = comb(o, 2, exact=True)

print(base1+base2)

Submission status: Runtime Error

Solution code:
def Even(x):
  return  2 * x

def Odd(x):
  return 2 * x - 1

N, M = map(int, input().split())
G = list(map(Even, range(1, N+1)))#偶数
K = list(map(Odd, range(1, M+1)))#奇数

even=list()

for n in range(0, N):
  for nm in range(n+1, N):
    even.append(G[n]+G[nm])
  
for m in range(0, M):
  for mm in range(m+1, M):
    if int(G[n])+int(K[m]) %2 ==0:
      even.append(K[m]+K[mm])
print(len(even))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B=input()
A=int(A)
B=int(B)

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

Submission status: Runtime Error

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

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

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) + combinations_count(M, 2))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import factorial

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

if N<2 and M>=2:
    Ans=factorial(M)/(factorial(M-2)*factorial(2))
    
elif N>=2 and M<2:
    Ans=factorial(N)/(factorial(N-2)*factorial(2))
    
else:
    Ans=factorial(M)/(factorial(M-2)*factorial(2))+factorial(N)/(factorial(N-2)*factorial(2))

print(int(Ans))

Submission status: Runtime Error

Solution code:
from math import factorial

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

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

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

print(a)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

a=int(comb(N,2)+comb(M,2))

print(a)

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

Submission status: Runtime Error

Solution code:
import copy
from scipy.misc import comb
n = int(input())
#x, y, a, b, c = map(int, input().split())
#s= list(input())
a = list(map(int, input().split()))
an = [0] * n
for i in range(n):
    an[a[i]-1] += 1

ac2 = []
ac2_diff = []
for i in range(n):
    ac2.append(comb(an[i], 2, exact=True))
    ac2_diff.append(ac2[i]-comb(an[i]-1, 2, exact=True))
sum = sum(ac2)
for i in range(n):
    print(sum - ac2_diff[a[i]-1])

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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=int(input("Enter the no. of even numbered balls: "))
m=int(input("Enter the no. of odd numbered balls: "))
print((n*(n-1) // 2 ) + (m*(m-1) //2))

Submission status: Runtime Error

Solution code:
n=int(input("Enter the no. of even numbered balls: "))
m=int(input("Enter the no. of odd numbered balls: "))
print((n*(n-1) // 2 ) + (m*(m-1) //2))

Submission status: Runtime Error

Solution code:
import math
n=int(input("Enter the no. of even numbered balls: "))
m=int(input("Enter the no. of odd numbered balls: "))
if(m>1):
    odd=((math.factorial(m))/(math.factorial(m-2)*math.factorial(2)))
elif(m<=1):
    odd=0
if(n>=1):
    even=((math.factorial(n))/(math.factorial(n-2)*math.factorial(2)))
elif(n<1):
    even=0
final=odd+even
print("The total no. of ways is: ",final)


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

Submission status: Runtime Error

Solution code:
import math
n=int(input("Enter the no. of even numbered balls: "))
m=int(input("Enter the no. of odd numbered balls: "))
if(m>1):
    odd=((math.factorial(m))/(math.factorial(m-2)*math.factorial(2)))
if(n>0):
    even=((math.factorial(n))/(math.factorial(n-2)*math.factorial(2)))
final=odd+even
print("The total no. of ways is: ",final)

Submission status: Runtime Error

Solution code:
import math

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


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

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

print(n+m)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb
N=[int(x) for x in input().split()]
if N[1]==1:
  sum1=0
else:
  sum1 = comb(N[1], 2, exact=True)
if N[0]==1:
  sum2=0
else:
    sum2 = comb(N[0], 2, exact=True)
print(sum1+sum2)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
import math
import sys
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 m <= 2:
    print(combinations_count(m, 2))
    sys.exit()
elif n <= 2 and m == 0:
    print(combinations_count(n, 2))
    sys.exit()
elif n == m == 1:
    print(1)
    sys.exit()
else:
    print(combinations_count(n, 2) + combinations_count(m, 2))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
import math

h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
ans = h * w

if h == 1:
    onecnt = 0
    for i in range(w):
        if s[0][i] == "1":
            onecnt += 1
    print(math.ceil(onecnt/k))
    exit()

for i in range(2 ** (h-1)):
    ss = str(format(i,"b").zfill(h-1))
    cnt = 0
    zerocnt = 0
    for j in range(len(ss)):
        if ss[j] == "0":
            zerocnt += 1
    now = [0 for i in range(zerocnt+1)]
    for j in range(w):
        next = []
        num = 0
        for n in range(h):
            if s[n][j] == "1":
                num += 1
            if num > k:
                break
            if n < h-1 and ss[n] == "0":
                next.append(num)
                num = 0
        next.append(num)
  #        print(next,now)
        for n in range(zerocnt+1):
            if now[n] + next[n] > k:
                now = next
                cnt += 1
                break
            else:
                now[n] += next[n]
  #    print(now)
  #    print(ans,cnt,zerocnt)
    ans = min(ans,cnt+zerocnt)
print(ans)

Submission status: Runtime Error

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

n = N-1
m = M-1

Even = N*n
Odd = M*m

print((Even+Odd)/2)

Submission status: Runtime Error

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

n = N-1
m = M-1

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

Submission status: Runtime Error

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

n = N-1
m = M-1

if N == 1 and M == 1:
    print("0")
else:
    print(N*n+M*m)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math

N, M = map(int, imput().split())
count = 0

def nCr(n):
  if n >= 2:
    return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
  else:
    return 0

print(nCr(N)+nCr(M))

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

Submission status: Runtime Error

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

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

print(c)

Submission status: Runtime Error

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

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

print(c)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

print(int(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
n,m = map(int,input().split())
if n is 0 or n is 1:
  print(math.factorial(m)/math.factorial(m-2)/2)
if m is 0 or m is 1:
  print(math.factorial(n)/math.factorial(n-2)/2)
else:
  print(math.factorial(n+m)/math.factorial(n+m-2)/2)

Submission status: Runtime Error

Solution code:
n = input()
m = input()
print(math.factorial(n+m))

Submission status: Runtime Error

Solution code:
n = input()
m = input()
if n=0 or n=1:
  print(math.factorial(m))
if m=0 or m=1:
  print(math.factorial(n))
else:
  print(math.factorial(n+m))

Submission status: Runtime Error

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


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

Submission status: Runtime Error

Solution code:
import collections

N = int(input())
A = input().split()
for i in range(N):
    A[i] = int(A[i])
#print(A)
for i in range(N):
    B = A.copy()
    del B[i]
    #print(B)
    C = collections.Counter(B)
    #print(C)
    D = list(C.values())
    #print(D)
    E=0
    for j in range(len(D)):
        E+=int(D[j]*(D[j]-1)/2)
    print(E)

Submission status: Runtime Error

Solution code:
def uhe(x):
    return x%2

a,b=map(int,input().split())
c=list(range(2,a*2+1,2))
d=list(range(1,b*2+1,2))

e=[(x+y) for x in c for y in d]
f=list(map(uhe,e))

while a!=1:
    g=(a-1)*a
    a=a-1
while b!=1:
    h=(b-1)*b
    b=a-1
print(g,h)
print(f.count(0)+g//a+h//b)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

A = comb(M,2,exact = True)
B = comb(N,2,exact = True)
print(A+B)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
def combinations_count(n, r):
  	if n==1 or n==0:
      return 0
    else:
      return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

Submission status: Runtime Error

Solution code:
N = int(input())
a = (input().split())
a_str = ''.join(a)
a_str2 = a_str
sum = 0
l_dict = {}
while len(a_str)>0:
    n = a.count(a_str[0])
    sum += int(n*(n-1)/2)
    l_dict[a_str[0]] = n
    a_str = a_str.replace(a_str[0],'')
for k in range(N):
    print(sum-l_dict[a_str2[k]]+1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
flg = False
for i in range(len(S)/2-1):
    if S[i] == S[len(S)-i]:
        flg = True
    else:
        flg = False
for i in range(((len(S)-1) /2 -1)/2):
    if S[i] == S[(len(S)-1)/2-i]:
        pass
    else:
        flg = False
for i in range((len(S)-(len(S)+3)/2 -1)/2):
    if S[i] == S[(len(S)+3)/2 -i]:
        pass
    else:
        flg = False
 
if flg:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
 
S = str(input())
N = len(S)-1
 
 
N1 = (N-1)/2
N2 = (N+3)/2
 
s1 = S[:N]
s2 = S[:N1]
s3 = S[N2-1:N]

Submission status: Runtime Error

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