TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
n,m=map(int, input().split())
print(n*(n-1)//2+m(m-1)//2)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())
ans = ((N * (N - 1)) / 2) + ((M * (M - 1)) / 2)
print(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N=input()
M=input()

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

print(num1+num2)

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

num1=n*(n-1)*0.5
num2=m*(m-1)*0.5

print(num1+num2)

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

num1=n*(n-1)*0.5
num2=m*(m-1)*0.5

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

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

print(num1+num2)

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,m=map(int,input().split())

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

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

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


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

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


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

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
N,M=map(int,input().split())

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

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

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

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

if N >= 2:
	A=nCr(N,2)
else:
	A=0
if M >= 2:
	B=nCr(M,2)
else:
	B=0
print(A+B)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
s = input()
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")

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

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


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)))

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

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

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())

if N != 0 and M != 0:
  answer = N(N-1)/2 + M(M-1)/2
  print(answer)
elif N == 0:
  answer = M(M-1)/2
  print(answer)
else:
  answer = N(N-1)/2
  print(answer)

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

if N != 0 and M != 0:
  answer = N*(N-1)/2 + M*(M-1)/2
  print(answer)
elif N == 0:
  answer = M*(M-1)/2
  print(answer)
else:
  answer = N*(N-1)/2
  print(answer)

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

if N != 0 and M != 0:
  answer = N*(N-1)/2 + M*(M-1)/2
  print(int(answer))
elif N == 0:
  answer = M*(M-1)/2
  print(int(answer))
else:
  answer = N*(N-1)/2
  print(int(answer))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,M = map(int,input().split())
print(N*(N-1)/2+M*(M-1)/2)


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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from sys import stdin
from collections import Counter

lines = stdin.readlines()

n = int(lines[0].rstrip())
a = [int(x) for x in lines[1].rstrip().split()]

count = Counter(a)
c = {k:v for k,v in filter(lambda kv: kv[1]>1, count.items())}
res = []
for k in range(n):
    part_res = 0
    for i in c.keys():
        if not i == a[k]:
            quant = c[i]
        else:
            quant = c[i] - 1
        if quant > 1:
            part_res += int((quant * (quant - 1)) / 2)
    res.extend([part_res])

for j in range(len(res)):
    print(res[j])

from sys import stdin
from collections import Counter

lines = stdin.readlines()

n = int(lines[0].rstrip())
a = [int(x) for x in lines[1].rstrip().split()]

c = Counter(a)

res = []
for k in range(n):
    part_res = 0
    for i in c.keys():
        if not i == a[k]:
            quant = c[i]
        else:
            quant = c[i] - 1
        if quant > 1:
            part_res += int((quant * (quant - 1)) / 2)
    res.extend([part_res])

for j in range(len(res)):
    print(res[j])

from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]

even_only = 0
odd_only = 0

if n > 1:
    even_only = n * (n - 1) / 2
if m > 1:
    odd_only = m * (m - 1) / 2

result = int(even_only + odd_only)
print(result)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys

N = int(sys.argv[1]) 
M = int(sys.argv[2]) 

def combination(n,r):
    if n == 1:
        ans = 0

    if r != 1:
        ans = n/r * combination(n-1,r-1)
    elif r == 1:
        ans = n/r

    return ans

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

import sys

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

def combination(n,r):
    if n == 1:
        ans = 0

    if r != 1:
        ans = n/r * combination(n-1,r-1)
    elif r == 1:
        ans = n/r

    return ans

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


import sys

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

def com(n,r):
    ans1 = 1
    ans2 = 1
    tmp = r
    while r != 0:
        ans1 = ans1 * (n)
        ans2 = ans2 * r
        n -= 1
        r -= 1

    return ans1/ans2

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


import sys

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

def combination(n,r):
    if n == 1:
        ans = 0

    if r != 1:
        ans = n/r * combination(n-1,r-1)
    elif r == 1:
        ans = n/r

    return ans

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


import sys

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

def com(n,r):
    ans1 = 1
    ans2 = 1
    tmp = r
    while r != 0:
        ans1 = ans1 * (n)
        ans2 = ans2 * r
        n -= 1
        r -= 1

    return ans1/ans2

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



def kaibuncheck(S):
    N=len(S)
    N_val=N-1
    center=int((N-1)/2)
    checkpoint=0
    for i in range(center-1):
        if S[i] == S[N_val]:
            checkpoint+=1
        N_val -= 1

    if checkpoint == center-1:
        return 1
    else:
        return 0

S = list(input())
N = len(S)
N2 = int((N-1)/2)

S_start=list()
S_end=list()
for i in range(N2):
    S_start.append(S[i])
    S_end.append(S[N-1-i])

if kaibuncheck(S) == 1 and kaibuncheck(S_start) == 1 and kaibuncheck(S_end) == 1:
    print('Yes')
else:
    print('No')


import sys

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

def com(n,r):
    ans1 = 1
    ans2 = 1
    tmp = r
    while r != 0:
        ans1 = ans1 * (n)
        ans2 = ans2 * r
        n -= 1
        r -= 1

    return ans1/ans2

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


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-

import copy

a = input()
a=int(a)
ball=[]
mydict={}
DPdict={}
temp=input().split(" ")
for i in range(a):
    if not (temp[i] in mydict):
        mydict[temp[i]]=1
    else:
        mydict[temp[i]]+=1
    ball.append(temp[i])

for i in range(len(ball)):
    rettemp=0
    if i in DPdict:
        print(int(DPdict[i]))
        continue
    for j in mydict.keys():

        if ball[i]==j:
            rettemp+=(mydict[j]-1)*(mydict[j]-2)/2
        else :
            rettemp+=(mydict[j]-1)*(mydict[j])/2
    DPdict[i]=rettemp
    print(int(rettemp))


# -*- coding: utf-8 -*-


a = input()

H,W=a.split(" ")
N=int(H)
M=int(W)
retnum=0
for i in range(N):
    retnum+=i
retnum+=M*(M-1)/2
print(int(retnum))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, m = map(int, input().split())
all_pattern = (n+m) / (n+m-1) / 2
print(all_pattern - n*m)

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, m = map(int, input().split())

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


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

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
 
N, M = map(int, input().split())

ans1 = 0
if N > 1:
  ans1 = math.factorial(N)/math.factorial(N-2)/2
ans2 = 0
if N > 1:
  ans2 = math.factorial(M)/math.factorial(M-2)/2
print(int(ans1 + ans2))

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

ans1 = 0
if N != 0:
  ans1 = math.factorial(N)/math.factorial(N-2)/2
ans2 = 0
if N != 0:
  ans2 = math.factorial(M)/math.factorial(M-2)/2
print(int(ans1 + ans2))

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

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

def is_kaibun(st):
  f = True
  for x,y in zip(st, st[::-1]):
    if x != y:
      f = False
      break
  return f
 
S = input()
ans = False
if is_kaibun(S):
  if is_kaibun(S[:(len(S)-1)//2]):
    ans = is_kaibun(S[(len(S)+3)//2-1:])
if ans:
  print('Yes')
else:
  print('No')

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

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

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import time
time.sleep(3)

from itertools import combinations

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

def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    # 10C7 = 10C3
    r = min(r, n-r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

if N <= 1 and M <= 1:
    print(0)
elif N <= 1 and not M <= 1:
    print(nCr(M,2))
elif not N <= 1 and M <= 1:
    print(nCr(N,2))
else:
    print(nCr(N, 2) + nCr(M,2))

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
from scipy.misc import comb


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

from operator import mul
from functools import reduce
def combinations(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, M = map(int, input().split())
result = 0
if N >= 2:
    result += combinations(N, 2)
if M >= 2:
    result += combinations(M, 2)
print(int(result))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())

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

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

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

print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b=map(int,input().split())
print(a*(a-1)/2+b*(b-1)/2)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math as m
N, M = input().split(' ')
N, M = int(N), int(M)

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

print(a+b)


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

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

print(int(a+b))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b=int(input().split(' '))

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


a,b=map(int, input().split(' '))
 
ans = 0
if a>=2:
    ans += a*(a-1)//2
if b>=2:
    ans += b*(b-1)//2
print(ans)  

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import collections
N=int(input())
a=0
list1 = list(map(int, input().split()))
c = collections.Counter(list1)
for i in range(N):
    a+=int(c[i+1]*(c[i+1]-1)/2)
for i in range(N):
    if c[list1[i]]!=0:
        print(a-c[list1[i]]+1)
    else:
        print(a)

i = list(map(int, input().split()))
a=i[0]*(i[0]-1)/2+i[1]*(i[1]-1)/2
print(int(a))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
m = int(input())

sum = 0

if n > 1:
    sum += 2 ** (n // 2)
else:
    sum += 1

if m > 1:
    sum += 2 ** (m // 2)
else:
    sum += 1

print(sum)


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

count = 0
if n > 1:
  count += n * (n - 1) // 2
if m > 1:
  count += m * (m - 1) // 2
print(count)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
def combinations_count(n, r):
 return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
A=0
N,M=map(int,input().split())
if N<=2:
 A+=0
else:
 A+=combinations_count(N, 2)
if M<=2:
 A+=0
else:
 A+=combinations_count(M, 2)
print(A)


import math
def combinations_count(n, r):
 return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
A=0
N,M=map(int,input().split())
if N<2:
 A+=0
else:
 A+=combinations_count(N, 2)
if M<2:
 A+=0
else:
 A+=combinations_count(M, 2)
print(A)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,M = map(int,input().split())
print((N*(N-1))/2+(M*(M-1))/2)

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

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())
count = N*(N-1) // 2
count += N*M
print(count)

N, M = map(int, input().split())
count = 0
count += N*(N-1) // 2
count += M*(M-1) // 2
print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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()


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


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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
ans=0

n,m=map(input().split())
if n > 1:
	for i in range(1,n):
		ans += i

if m > 1:
	for i in range(1,m):
		ans += i

print(ans)

ans=0

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

if m > 1:
	for i in range(1,m):
		ans += i

print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

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

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
s = str(input())

def check(text):
    n = len(text)
    if n == 1:
        return True

    left = int((n-1)/2)
    right = int((n+3)/2 - 1)
    if text[0:left] == text[right:n] and check(text[0:left]):
        return True
    return False

if check(s):
    print("Yes")
else:
    print("No")


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

gu = 0
ki = 0
if n >= 2:
    gu = n * (n -1) / 2
if m >= 2:
    ki = m * (m-1) / 2
print(int(gu+ki))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M=map(int,input().split())
print(N*(N-1)/2 + M*(M-1)/2)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())
if N >=2:
    odd = (N*(N-1))/2
else:
    odd = 0
if M >= 2:
    even = (M*(M-1))/2
else:
    even = 0
print(odd+even)

N, M = map(int, input().split())
if N >=2:
    odd = (N*(N-1))/2
else:
    odd = 0
if M >= 2:
    even = (M*(M-1))/2
else:
    even = 0
print(int(odd+even))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#ABC159A
import sys
import itertools
n, m = map(int, sys.stdin.readline().split())
#print(n, m)
L = [0 for _ in range(n)] + [1 for _ in range(m)]
L = list(itertools.combinations(L, 2))
#print(L)
total = 0
for a, b in L:
    if (a+b)%2 ==0:
        total+=1


#ABC159A
import sys
import itertools
n, m = map(int, sys.stdin.readline().split())
#print(n, m)
L = [0 for _ in range(n)] + [1 for _ in range(m)]
L = list(itertools.combinations(L, 2))
#print(L)
total = 0
for a, b in L:
    if (a+b)%2 ==0:
        total+=1

print(total)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
A=list(map(int,input().split()))
ans=0
B=set(A)
L=[0]*N
for i in range(N):
    L[A[i]-1]+=1
for i in B:
    ans+=Comb(L[i-1],2)
for i in range(N):
    pri=ans
    pri=ans-L[A[i]-1]+1
    print(pri)

n,m=map(int,input().split())
def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans
ans=Comb(n,2)+Comb(m,2)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a, b = map(int, input().split())

if a > 0:
  a = a * (a - 1)
  
if b > 0:
  b = b * (b - 1)
print(a + b)


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

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,M = map(int,input().split())

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

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

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


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

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


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

return(int(N(N-1)//2 + M(M-1)//2))

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

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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, m = map(int, input().split(' '))

def nCr(n, r):
    if n < r or r == 0:
        return 1
    ans = 1
    for i in range (r):
        ans *= (n-r+i+1)
        ans = ans // (i+1)

    return ans

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

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

def nCr(n, r):
    if n < r:
        return 0
    ans = 1
    for i in range (r):
        ans *= (n-r+i+1)
        ans = ans // (i+1)

    return ans

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,m = map(int, input().split())
print(int((n+m)*(n+m-1)-n*m))


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


n,m = map(int, input().split())
print(int((n+m)*(n+m-1))-n*m)

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = map(int, input().split())
print(N*(N-1)/2 + M*(M-1)/2)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
    main()
import math
n,m=map(int,input().split())
def cc(n,r):
    return int(math.factorial(n)/(math.factorial(n-r)*math.factorial(r)))
if n>=2:
    if m>=2:
        print(cc(n,2)+cc(m,2))
    else:
        print(cc(n,2))
else:
    if m>=2:
        print(cc(m,2))
    else:
        print(0)

import math
n,m=map(int,input().split())
def cc(n,r):
    return int(math.factorial(n)/(math.factorial(n-r)*math.factorial(r)))
if n>=2:
    if m>=2:
        print(cc(n,2)+cc(m,2))
    else:
        print(cc(n,2))
else:
    if m>=2:
        print(cc(m,2))
    else:
        print(0)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,m = input().split()
n = int(n)
m = int(m)
k = (n*(n-1) + m*(m-1))/2
print(k)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N, M = (int(x) for x in input().split())
ans=0
if N>=2:
  ans+=N*(N-1)/2
if M>=2:
  ans+=M*(M-1)/2
print(ans)

N, M = (int(x) for x in input().split())
ans=0
if N>=2:
  ans+=N*(N-1)/2
if M>=2:
  ans+=M*(M-1)/2
print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,m= map(int, input().split())

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


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

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

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,M=map(int,input().split())
print(N*(N-1)/2+M*(M-1)/2)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def c(i):
    return i*(i-1)/2

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


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


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


def c(i):
    return i*(i-1)//2

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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from operator import mul
from functools import reduce

def combinations_count(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

def main():
    N,M = map(int, input().split())
    ans = combinations_count(M,2) + combinations_count(N,2)
    print(ans)

main()


from operator import mul
from functools import reduce

def combinations_count(n, r):
    if n<r: return 0
    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

def main():
    N,M = map(int, input().split())
    ans = combinations_count(M,2) + combinations_count(N,2)
    print(ans)

main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b=map(input().split())
ans=a*(a-1)/2+b*(b-1)/2
print (ans)

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

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

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


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
mport itertools

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

import itertools

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import combninations

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

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

from itertools import combinations

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

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,M = [int(i) for i in input().split()]

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

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







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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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))


from math import factorial

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

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,M=map(int,input().split())
if N>1 and M>1:
  print((N*(N-1)/2)+(M*(M-1)/2))
elif N<=1:
    if M<=1:
      print(0)
    print(M*(M-1)/2)
else:
  print(N*(N-1)/2)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N,M = input().split()
print( 'N + N' )
print( 'M + M' )


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

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


Verdicts: Wrong Answer

Runtime Error

Accepted