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):
def tmp(n):
    return n * (n - 1) / 2


def main():
    line = input().strip()
    n, m = [int(v) for v in line.split(' ')]

    ans_n = tmp(n) if n > 1 else 0
    ans_m = tmp(m) if m > 1 else 0
    ans = ans_n + ans_m
    print(ans)


if __name__ == '__main__':
    main()


def main():
    line = input().strip()
    n, m = [int(v) for line.split(' ')]

    ans_n = n * (n - 1) if n > 1 else 0
    ans_m = m * (m - 1) if m > 1 else 0
    ans = ans_n + ans_m
    return ans


if __name__ == '__main__':
    main()


def main():
    line = input().strip()
    n, m = [int(v) for v in line.split(' ')]

    ans_n = n * (n - 1) if n > 1 else 0
    ans_m = m * (m - 1) if m > 1 else 0
    ans = ans_n + ans_m
    return ans


if __name__ == '__main__':
    main()


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


def main():
    line = input().strip()
    n, m = [int(v) for v in line.split(' ')]

    ans_n = tmp(n) if n > 1 else 0
    ans_m = tmp(m) if m > 1 else 0
    ans = ans_n + ans_m
    print(int(ans))


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

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())
ans = 0
if(n >= 2):
    ans += n*(n-1)/2
if(m >= 2):
    ans += m*(m-1)/2
print(ans)


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


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


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


Verdicts: Wrong Answer

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())
print(((math.factorial(n) // math.factorial(n - 2))//2)+ ((math.factorial(m) // math.factorial(m - 2))//2))

import itertools
n,m = map(int,input().split())
o = 0
o += len(list(itertools.permutations([i for i in range(n)], 2)))/2
o += len(list(itertools.permutations([i for i in range(m)], 2)))/2
print(int(o))

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

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


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

a = N * (N-1) // 2
b = M * (M-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):
a = list(map(int, input().split()))

b = a[0] * a[0]-1 / 2 + a[1] * a[1] -1 / 2

print(b)

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

b = a[0] * (a[0] - 1) // 2 + a[1] * (a[1] - 1) // 2

print(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):
S = input()
N = len(S)
a = S[1:int((N-1)/2+1)]
b = S[int((N+3)/2):]

def kaibun(l):
    for i in range(len(l)):
        if l[i] != l[-i]:
            return(False)
    return(True)

if kaibun(S) & kaibun(a) & kaibun(b):
    print("Yes")
else:
    print("No")
            

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

S = input()
N = len(S)
a = S[1:(N-1)//2+1]
b = S[(N+3)//2:]

def kaibun(l):
    for i in range(len(l)):
        if l[i] != l[len(l)-1-i]:
            return(False)
    return(True)

print(kaibun("abccba"))

if kaibun(S) & kaibun(a) & kaibun(b):
    print("Yes")
else:
    print("No")
            

S = input()
N = len(S)
a = S[1:(N-1)//2+1]
b = S[(N+3)//2:]

def kaibun(l):
    for i in range(len(l)):
        if l[i] != l[len(l)-1-i]:
            return(False)
    return(True)

if kaibun(S) & kaibun(a) & kaibun(b):
    print("Yes")
else:
    print("No")
            

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

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

S = input()
N = len(S)
a = S[1:(N-1)//2]
b = S[(N+3)//2:]

def kaibun(l):
    for i in range(len(l)):
        if l[i] != l[len(l)-1-i]:
            return(False)
    return(True)

print(kaibun(S))
print(kaibun(a))
print(kaibun(b))
  
if kaibun(S) & kaibun(a) & kaibun(b):
    print("Yes")
else:
    print("No")
            

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

import math

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



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)

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):
integer = int(input().split())
conbi = ((integer[0] * (integer[0] - 1) + integer[1] * (integer[1] -1 )) / 2
print(conbi)

s = input()
n = len(s)
num = int((n-1)/2)-1
for i in range(num):
  if s[i] != s[n-1-i]:
    print("No")
    exit()
    
num = int(num /2 -1)
for i in range(num):
  if s[i] != s[n-1-i]:
    print("No")
    exit()

num = int(len(s) * 0.5 - 1.5)
index = int((n + 3) /2 -1 )
for i in range(num):
  if s[index+i] != s[n-1-i]:
    print("No")
    exit()
   
  
print("Yes")

    

    
    

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

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

Verdicts: Runtime Error

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

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

    e = N*(N-1)/2
    o = M*(M-1)/2

    ans = int(e + o)
    print(e, o, ans)


if __name__ == '__main__':
    main()

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

    e = N*(N-1)/2
    o = M*(M-1)/2

    ans = int(e + o)
    print(ans)


if __name__ == '__main__':
    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(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: 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 combination(n, k):
	return fact(n) / ( fact(n-k) * fact(k) )

def fact(n):
	if n < 0:
		return 0
	if n == 0:
		return 1
	if n == 1:
		return 1
	return fact(n-1)

n, m = [int(x) for x in input().split()]
answer = combination(n, 2) + combination(m, 2)
print(answer)

def fact(n):
    if n < 0:
        return 0
    if n == 0:
        return 1
    if n == 1:
        return 1
    return fact(n-1)

def combination(n, k):
    if n < k:
        return 0
    return fact(n) / ( fact(n-k) * fact(k))

n, m = [int(x) for x in input().split()]
answer = combination(n, 2) + combination(m, 2)
print(answer)

def fact(n):
    if n < 0:
        return 0
    if n == 0:
        return 1
    if n == 1:
        return 1
    return n * fact(n-1)

def combination(n, k):
    if n < k:
        return 0
    return fact(n) / ( fact(n-k) * fact(k))

n, m = [int(x) for x in input().split()]
answer = int(combination(n, 2) + combination(m, 2))
print(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):
import math

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

import math
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)
  
m, n = map(int, input().split())
print(permutations_count(m,2)+permutations_count(n,2))

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

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

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

Verdicts: Wrong Answer

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=list(input())
def kaibun(l):
  flg=False
  for i in range(int((len(l)-1)/2)):
    
    if l[i] != l[len(l)-1-i]:
      flg=True
  return(int(flg))

c=kaibun(n)
m=n[:int((len(n)-1)/2)]
d=kaibun(m)
p=n[int((len(n)+1)/2):]
e=kaibun(p)
if c+d+e == 0:
  print('Yes')
else:
  print('No')
 

n, m = map(int,input().split())
if n==0:
  c=m*(m-1)
elif m==0:
  c=n*(n-1)
else:
  c=n*(n-1)+m*(m-1)

print(c)


n=list(input())
def kaibun(l):
  flg=False
  for i in range(int((len(l)-1)/2)):
    
    if l[i] != l[len(l)-1-i]:
      flg=True
  return(int(flg))

c=kaibun(n)
m=n[:int((len(n)-1)/2)]
d=kaibun(m)
p=n[int((len(n)+1)/2):]
e=kaibun(p)
if c+d+e == 0:
  print('Yes')
else:
  print('No')
 

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

print(int(c))


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):
 nm = [int(i) for i in input().split()]
  2
  3 result = (nm[0] * (nm[0] - 1)) // 2
  4 result += (nm[1] * (nm[1] - 1)) // 2
  5
  6 print(result)

nm = [int(i) for i in input().split()]

result = (nm[0] * (nm[0] - 1)) // 2
result += (nm[1] * (nm[1] - 1)) // 2

print(result)

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

ab = input().split()
a,b = int(ab[0]), int(ab[1])
result = a*(a-1)//2 + b*(b-1)//2
print(result)

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

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

test

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

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



def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

even,odd = map(int,input().split())
if even != 1 or odd != 1:
    numa = cmb(even,2)
    numb = cmb(odd,2)
    if even == 1 or even == 0:
        numa = 0
    if odd == 1 or odd == 0:
        numb = 0
    print(numa+numb)
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 = map(int,input().split())
print(n*(n-1)+m*(m-1))

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

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=list(input())
countA=0
countB=0
for i in range(3):
    if S[i]=="A":
        countA+=1
    else:
        countB+=1
if countA!=0 and countB!=0:
    print("Yes")
else:
    print("No")    

N,M=map(int,(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):
import collections
import math

#****************************************************************
def comb(n):
    if n < 2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
#****************************************************************

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

c = collections.Counter(A)
dict_ans = {i:0 for i in c.keys()}
full_ans = sum(list(map(comb, c.values())))

for i in c.keys():
    target = c.copy()
    target[i] -= 1
    if target[i] == 0:
        dict_ans[i] = full_ans
    else:
        dict_ans[i] = sum(list(map(comb, target.values())))

for i in A:
    print(dict_ans[i])


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

ans = int((N + M) * (N + M - 1) / 2 - N * M)
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):
N, M = map(int, input().split())

g = 0 if N < 2 else (N * N - 1) / 2
k = 0 if M < 2 else (M * M - 1) / 2

print(g + k)

N, M = map(int, input().split())
 
g = 0 if N < 2 else (N * (N - 1)) / 2
k = 0 if M < 2 else (M * (M - 1)) / 2
 
print(int(g + 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())
A = N * (N - 1) / 2
B = M * (M - 1) / 2
print(A+B)

N, M = (int(x) for x in input().split())
A = N * (N-1)/2 + M*(M-1)/2
print(A)

N, M = (int(x) for x in input().split())
A = N * (N - 1) / 2
B = M * (M - 1) / 2
print(int(A+B))


Verdicts: 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())
if m%2:
	print('0')
else	:
	print('1')

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):
a= str(input())
kaibun = list(a)
n = int(len(kaibun))
answer = "No"
strongn1 = int((n-1)/2)
strongn2 = int((n+3)/2)
for i in reversed(range((int((n+1)/2)),n)):
    if kaibun[i] == kaibun[n-i-1]:
        answer = "Yes"
    else:
        answer = "No"
        break;
if answer == "Yes":
    for i in range(int(strongn1/2)):
        if kaibun[i] == kaibun[strongn1-i-1]:
            answer = "Yes"
        else:
            answer="No"
            break;
if answer =="Yes":
    for i in reversed(range(strongn2,(n-strongn2)//2)):
        if kaibun[i] == kaibun[strongn2-2-i+n]:
            answer = "Yes"
        else:
            answer = "No"
print(answer)


m,n = map(int,input().split())
a=(m*(m-1))/2+(n*(n-1))/2
print(int(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):
import math
def combinations(n ,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
n, m = map(int, input().split())
print(combinations(n, 2) + combinations(m , 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):
l = int(input())
print((l / 3) ** 3)

n,m=map(int,input().split())
# print((n*m)-m)
n=n-1
m=m-1
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):
def cmb(n):
	if n<=1:
		return 0
	else:
		return int(n*(n-1)*0.5)
N = int(input())
A = [int(x) for x in input().split()]
ans=[0]*N
lists={}
k=0
for i in range(N):
  if not A[i] in lists:
    l=cmb(A.count(A[i]))
    m=cmb(A.count(A[i])-1)-l
    k+=l
    lists[A[i]]=m
    ans[i]=m
  else:
    ans[i]=lists[A[i]]
    
for i in range(N):
  ans[i]+=k
  print(ans[i])

a,b=map(int,input().split())
ans=0
if a>=2:
  ans+=a*(a-1)*0.5
if b>=2:
  ans+=b*(b-1)*0.5
ans=int(ans)
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):
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())
answer = 0
answer += (N ** 2 - N) / 2
answer += (M ** 2 - M) / 2
print(answer)

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


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):
l=int(input())
n=l/3
print(n*n*n)

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

# tmpN,tmpM = 0,0
# if N != 2:

#         ue *= N-i


# if M != 2:

#         uee *= N-i



# print(tmpN+tmpM)

ans = N*int(N/2) + M*int(M/2)
print(ans)


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

# tmpN,tmpM = 0,0
# if N != 2:

#         ue *= N-i


# if M != 2:

#         uee *= N-i



# print(tmpN+tmpM)

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

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

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

x=0
y=0
if N>=2:
    x=combinations_count(N, 2)
if M>=2:
    y=combinations_count(M, 2)

print(x+y)


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(x) for x in input().split()]
print((n * (n-1) / 2) + (m * (m-1) / 2))

n,m = [int(x) for x in input().split()]
print(n * (n-1) / 2 + m * (m-1) / 2)

n,m = [int(x) for x in input().split()]
print((n * (n-1) // 2) + (m * (m-1) // 2))

Verdicts: 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
def comb(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))
print(comb(n + m, 2) - n * m)


import math
def comb(a, b):
  return math.factorial(a) / (math.factorial(a - b) * math.factorial(b))
print(comb(n + m, 2) - n * m)


  import math
  def comb(n, r):
  	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))
  base = comb(n+m, n * 2) + comb(n+m, m * 2)
  print(base)


 import math
 def comb(n, r):
 	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 base = comb(n+m, n * 2) + comb(n+m, m * 2)
 print(base)


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



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):
sum = int(input())
print((sum/3)*(sum/3)*(sum/3))

import math
def comb(n,r):
    if n<2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

a, b = map(int, input().split())
print(comb(a,2)+comb(b,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):
a = list(map(int,input().split()))
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
x = a[0]
y = a[1]
z = 1
if(x is not z){
    c = (combinations_count(x, 2));
}
else{
    c = 0;
}
if(y is not z){
    d = (combinations_count(y, 2));
}
else{
    d = 0;
}
print(c + d)

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

a = list(map(int,input().split()))
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
x = a[0]
y = a[1]
if(x != 1) and (x != 0):
    c = (combinations_count(x, 2))
else:
    c = 0
if(y != 1) and (y != 0):
    d = (combinations_count(y, 2))
else:
    d = 0
print(c + d)

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

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

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


import math

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

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


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

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

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

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

if N>=2:
    a=combinations_count(N,2)
else:
    a=0
if M>=2:
    b=combinations_count(M,2)
else:
    b=0
print(a+b)

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):
L, R = map(int,input().split())
sum = L+R
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

aaa = cmb(L,2) + cmb(R,2)
print(aaa)

import itertools
L, R = map(int,input().split())
a = len(list(itertools.combinations(range(L), 2))) + len(list(itertools.combinations(range(R), 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)

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

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

print(c)

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

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

print(c)



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

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

print(int(c))

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):
line = input().split()
n = int(line[0])
m = int(line[1])


eeCount = n * (n - 1)


ooCount = m * (m - 1)

print(eeCount + ooCount)

def checkKaibun(str):
    print(str)
    for i in range(int((len(str) - 1) / 2)):
        if str[i] != str[-i - 1]:
            return False
    return True
 
s = input()
n = len(s)
c2e = int((n - 1) / 2)
c3s = int((n + 3) / 2) - 1
if not checkKaibun(s):
    print('No')
elif not checkKaibun(s[0:c2e]):
    print('No')
elif not checkKaibun(s[c3s:n]):
    print('No')
else:
    print('Yes')

def checkKaibun(str):
    for i in range(int((len(str) - 1) / 2)):
        if str[i] != str[-i - 1]:
            return False
    return True
 
s = input()
n = len(s)
c2e = int((n - 1) / 2)
c3s = int((n + 3) / 2) - 1
if not checkKaibun(s):
    print('No')
elif not checkKaibun(s[0:c2e]):
    print('No')
elif not checkKaibun(s[c3s:n]):
    print('No')
else :
    print('Yes')      

def checkKaibun(str):
    for i in range(int((len(str) - 1) / 2)):
        if str[i] != str[-i - 1]:
            return False
    return True
 
s = input()
n = len(s)
c2e = int((n - 1) / 2)
c3s = int((n + 3) / 2)
if not checkKaibun(s):
    print('No')
elif not checkKaibun(s[0:c2e]):
    print('No')
elif not checkKaibun(s[c3s:n]):
    print('No')
else :
    print('Yes')
 
            

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


eeCount = n * (n - 1) / 2


ooCount = m * (m - 1) / 2

print(int(eeCount + ooCount))

Verdicts: Wrong Answer

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())
k=n*(n-1)/2
l=m*(m-1)/2
if n>=2 and m>=2:
    print(k+l)
elif n>=2 and m<2:
    print(k)
elif n<2 and m>=2:
    print(l)
else:
    print(0)

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

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

Verdicts: 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=(int(x) for x in input('Enter N and M:').split())
print(N)
print(M)
if not 0 <= N <= 100:
    print('N is not appropreate')
elif not 0 <= M <= 100:
    print('M is not appropreate')
elif N+M < 2:
    print('num of ball is too small')
else:
    print(int((N*(N-1)+M*(M-1))/2))


N,M=(int(x) for x in input().split())
if not 0 <= N <= 100:
    print('N is not appropreate')
elif not 0 <= M <= 100:
    print('M is not appropreate')
elif N+M < 2:
    print('num of ball is too small')
else:
    print(int((N*(N-1)+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 factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)
a,b=map(int, input().split())
cnt=0
if a>1:
    cnt=(factorial(a)/((factorial(a-2))*2))
if b>1:
    cnt=(factorial(b)/((factorial(b-2))*2))+cnt
print(int(cnt))

def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)
a,b=map(int, input().split())
cnt=0
if a>0:
    cnt=(factorial(a)/((factorial(a-2))*2))
if b>0:
    cnt=(factorial(b)/((factorial(b-2))*2))+cnt
print(int(cnt))

def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)
a,b=map(int, input().split())
cnt=0
if a==2:
    cnt=1
elif a>1:
    cnt=(factorial(a)/((factorial(a-2))*2))
if b==2:
    cnt=cnt+1
elif b>1:
    cnt=(factorial(b)/((factorial(b-2))*2))+cnt
print(int(cnt))

Verdicts: Runtime Error

Runtime Error

Accepted