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

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

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

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

from math import factorial

x,y=map(int,input().split())
if x>1:
    a = factorial(x) / factorial(2) / factorial(x - 2)
else: a=0
if y>1:
    b = factorial(y) / factorial(2) / factorial(y - 2)
else: b=0
print(int(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):
# -*- coding: utf-8 -*-

import collections

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

for k in range(n):
    # print(balls[ : k])
    
    arr = balls[ : k] + balls[ k + 1 : ]

    dic = collections.Counter(arr)
    total = 0
    for v in dic.values():
        total += int(v * (v - 1) / 2)
    print(total)



# -*- coding: utf-8 -*-
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())

if n >= 2:
  even = n * (n-1) /2
else:
  even = 0

if m >= 2:  
  odd = m * (m-1) /2
else:
  odd = 0
print(even + odd)

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

if n >= 2:
    even = n * (n - 1) / 2
else:
    even = 0

if m >= 2:
    odd = m * (m - 1) / 2
else:
    odd = 0
print(int(even + odd))

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

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

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

print(ans)

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

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

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

print(ans)

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

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

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

Verdicts: 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 math
def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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


main()


import math
def cmb(n, r):
    if n<2:
        return 0

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

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


main()


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

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

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):
S=str(input())
N=len(S)
if S[1:int(N-1)//2] == S[int(N+3)//2:N]:
  print('Yes')
else:
  print('No')


S=str(input())
N=len(S)
if S[1:int(N-1)//2]== S[int(N+3)//2:N]:
  print('Yes')
else:
  print('No')

N,M=map(int,input().split())
a=N*N/4+M*M/4
b=N+M
if int(b)>2:
  print(a)
else:
  print(0)

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

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

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

import  math

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

def ans(a):
    if a<2:
        return 0
    else:
        return math.factorial(a) // (math.factorial(a - 2) * math.factorial(2))

print(int(ans(n) + ans(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):
l = int(input())
a = l/3
print(round(a**3,13))

n,m = map(int,input().split())
ans = n*(n-1)//2 + m*(m-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):
def factorial(n):
    if n == 0 or n == 1 or n < 0:
        return 1
    return n * factorial(n-1)

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

combination = int(factorial(N) / (2 * (factorial(N-2)))) + M
print(combination)


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

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

even = int(factorial(N) / (2 * (factorial(N-2))))
odd = int(factorial(M) / (2 * (factorial(M-2))))
print(even+odd)

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):
input_line = input().split()
N = int(input_line[0])
M = int(input_line[1])

import math

print("N="+str(N)+" M="+str(M))

def combination(n, r):
    if(n == 1 or n == 0):
        return 0
    else:
        return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

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


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

import math

def combination(n, r):
    if(n == 1 or n == 0):
        return 0
    else:
        return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

print(combination(N,2) + combination(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())
x = (n*(n-1)) / 2
y = (m*(m-1)) / 2
print(x+y)



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

import numpy as np
result = 0
for x in np.arange(l/3-0.1, l/3+0.1, 0.1):
  for y in np.arange(x, l/3+0.1, 0.1):
    z = l - (x+y)
    if z <= 0:
      break
    v = x*y*z
    result = max(v, result)
print(result)

n,m=map(int,input().split())
print( int((n+m)*(n+m-1)/2 - 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):
n = int(input())
a = list(map(int, input().split()))
import math
import collections
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def get_result(key, c):
    ans = 0
    for d in c.items():
        if d[0] == key:
            value = d[1]-1
        else:
            value = d[1]
        if value > 1:
            ans += combinations_count(value, 2)
    return int(ans)
ans = {}
tmp = a.copy()
tmp.sort()
c = collections.Counter(tmp)
for k in range(n):
    key = a[k]
    if key in ans:
        print(ans[key])
    else:
        ans[key] = get_result(key, c)
        print(ans[key])

n, m = map(int, input().split())
n_l = [i for i in range(0,n*2,2)]
m_l = [i for i in range(1,m*2,2)]
hoge = n_l + m_l
count = 0
for i in hoge:
    for j in hoge:
        if (i!=j)&((i+j)%2==0):
            count+=1
print(int(count/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())
x=n*(n-1)/2+m*(m-1)/2
print(x)

n,m=map(int,input().split())
print(int(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):
n = int(input())
m = int(input())

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = int(n_dot+ m_dot)
print(answer)

n = int(input())
m = int(input())

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = n_dot+ m_dot
print(answer)

n,m=(int(x) for x in input().split())

n_dot = n*(n-1)/2
m_dot = m*(m-1)/2

answer = int(n_dot+ m_dot)
print(answer)


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
m,n=map(int,input().split())
dm,dn=0,0
if m>2:
    dm = math.factorial(m)//math.factorial(m-2)
if n>2:
    dn = math.factorial(n)//math.factorial(n-2)
print((dm+dn)//2)


import math
m,n=map(int,input().split())
dm,dn=0,0
if m>=2:
    dm = math.factorial(m)//math.factorial(m-2)
if n>=2:
    dn = math.factorial(n)//math.factorial(n-2)
print((dm+dn)//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 = input().split()
n = int(n)
m = int(m)

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



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

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

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

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



import math
n, m = input().split()
n = int(n)
m = int(m)
x = 0
y = 0
if n > 1:
  x = int(math.factorial(n)/(2 * math.factorial(n-2)))
if m > 1:
  y = int(math.factorial(m)/(2 * math.factorial(m-2)))

print(x+y)



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

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



N, M = map(int, input().split())
print((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):
from math import factorial

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

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

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

print(res)

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

def factorial(n):
    p = 1
    for i in range(n, 0, -1):
        p *= i
    return p


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


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

print(res)

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


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



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 fact(n):
  for i in range(1,n+1): 
    fact = fact * i 
  return fact


x,y = input().split()
return ((fact(x)/(2*fact(x-2)) + (fact(y)/(2*fact(y-2)))


using namespace std;
int fact(int n)
{
  int facto=1;
  for (int i = 1; i < n+1;i++)
  {
    facto = facto * i;
  }
  return facto;
}


int main()
{
	int x,y, result;
	cin >> x >> y;
	result = (fact(x)/(2*fact(x-2))) + (fact(y)/(2*fact(y-2)));
	cout << result << endl;
	return 0;
}

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


x,y = input().split()
return ((fact(x)/(2*fact(x-2)) + (fact(y)/(2*fact(y-2)))

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


x,y = input().split()
x = int(x)
y = int(y)
print((fact(x)//(2*fact(x-2))) + (fact(y)//(2*fact(y-2))))


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

ans=n*(n-1)/2
ans+=m*(m-1)/2

print(int(ans))

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

ans=n*(n-1)/2
ans+=m*(m-1)/2

print(int(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=input().split()
from math import factorial 
if int(N)>=2 and int(M)>=2:
    print(factorial(int(N))/2/factorial(int(N)-2)+factorial(int(M))/2/factorial(int(M)-2))
elif int(N)<2 and int(M)>=2:
     print(factorial(int(M))/2/factorial(int(M)-2))
elif int(M)<2 and int(N)>=2:
     print(factorial(int(N))/2/factorial(int(N)-2))
else:
    print("0")

S=input()
N=len(S)

a=False

for i in range(N):
    if S[i]!=S[N-1-i]:
        print("No")
        break
    else:
        a=True

if a==True:
    for j in range(int((N-3)/2)):
        if S[j]!=S[int((N-3)/2)-j]:
            a=False
            print("No")
            break
if a==True:
    for k in range(int((N-3)/2)):
        if S[int((N+1)/2)+k]!=S[N-1-k]:
            a=False
            print("No")
            break
if a==True:
    print("Yes")
    

N,M=input().split()
from math import factorial 
if int(N)>=2 and int(M)>=2:
    print('{:.0f}'.format(factorial(int(N))/2/factorial(int(N)-2)+factorial(int(M))/2/factorial(int(M)-2)))
elif int(N)<2 and int(M)>=2:
     print('{:.0f}'.format(factorial(int(M))/2/factorial(int(M)-2)))
elif int(M)<2 and int(N)>=2:
     print('{:.0f}'.format(factorial(int(N))/2/factorial(int(N)-2)))
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 = map(int, input().split())

if n <= 2:
  n_even = 0
else:
  n_even = n * (n-1) / 2
if m <= 2:
  m_even = 0
else:
  m_even = m * (m-1) / 2

even = n_even + m_even
print(int(even))

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

if n <= 1:
  n_even = 0
else:
  n_even = n * (n-1) / 2
if m <= 1:
  m_even = 0
else:
  m_even = m * (m-1) / 2

even = n_even + m_even
print(int(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):
import math

N, M = map(int, input().split())
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

import math

N, M = map(int, input().split())
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N == 0:
  ans = combinations_count(M, 2)
elif M == 0:
  ans = combinations_count(N, 2)
elif N == 1 and M == 1:
  ans = 0
elif N == 1:
  ans = combinations_count(M, 2)
elif M == 1:
  ans = combinations_count(N, 2)
else:
  ans = combinations_count(N, 2) + combinations_count(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):
N,M = map(int, input().split())
ans1 = 0
ans2 = 0

if(N >= 2):    
    ans1 = (N*(N-1))/2
if(M >= 2):
    ans2 = (M*(M-1))/2

print(ans1+ans2)

N,M = map(int, input().split())
ans1 = 0
ans2 = 0

if(N >= 2):    
    ans1 = (N*(N-1))//2
if(M >= 2):
    ans2 = (M*(M-1))//2

print(ans1+ans2)

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

n,m = map(int,input().split())
print((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):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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




import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = na()
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())

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


import math

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

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


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

n, m = map (int, input().split())
ex1 = n*(n-1)//2
ex2 = m*(m-1)//2
ans = ex1 + ex2
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 = input().split()

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

even = int
odd = int
final = int

even = (N*(N-1))/2
odd = (M*(M-1))/2
final = even + odd
print(final)

N,M = input().split()

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

even = 0
odd = 0
final = 0

even = (N*(N-1))/2
odd = (M*(M-1))/2
final = even + odd
print(final)

N,M = input().split()

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

even = 0
odd = 0
final = int

even = (N*(N-1))/2
odd = (M*(M-1))/2
final = even + odd
print(int(final))

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

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

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

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

from math import factorial
n, m = map(int, input().split())
c_n = factorial(n) / (factorial(2) * factorial(n - 2)) if n > 1 else 0
c_m = factorial(m) / (factorial(2) * factorial(m - 2)) if m > 1 else 0
ans = int(c_n) + int(c_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):
while True:
    m, n = list(map(int, input().split()))
    print(m * (m - 1) / 2 + n * (n - 1) / 2)


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

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

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


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


n_cmb = combinations_count(n, 2)
m_cmb = combinations_count(m, 2)

print(n_cmb + m_cmb)

from operator import mul
from functools import reduce

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


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


a = cmb(n, 2)
b = cmb(m, 2)

print(a + b)

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

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


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):
def compute_fact(n):
    global f
    f = [0 for i in range(n+1)]
    f[0] = 1
    f[1] = 1
    for i in range(2,n+1):
        f[i] = f[i-1]*i

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

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



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

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

n,m = [int(s) for s in input().split()]
if n >= 2 and m >= 2:
    print(int(compute_c(n,2) + compute_c(m,2)))
elif n >= 2:
    print(int(compute_c(n,2)))
elif m >= 2:
    print(int(compute_c(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):
a = list(map(int, input().split()))
if a[0]<=1:
  n=0
else:
  n=a[0]*(a[0]-1)/2

if a[1]<=1:
  m=0
else:
  m=a[1]*(a[1]-1)/2
 
print(n+m)

a = list(map(int, input().split()))
if a[0]==1:
  n=0
else:
  n=a[0]*(a[0]-1)/2

if a[1]==1:
  m=0
else:
  m=a[1]*(a[1]-1)/2
 
print(n+m)

a = list(map(int, input().split()))
if a[0]==1:
  n=0
else:
  n=a[0]*(a[0]-1)/2

if a[1]==1:
  m=0
else:
  m=a[1]*(a[1]-1)/2
 
print(int(n+m))

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())
method1 = N*(N-1)/2
method2 = M*(M-1)/2
method=method1+method2
print(str(method))


N, M = map(int, input().split())
method1 = N*(N-1)/2
method2 = M*(M-1)/2
method=method1+method2
print(str(round(method)))


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):
even, odd = map(int, input().split())
s = even * (even -1) / 2
s += odd * (odd - 1) / 2
print(s)


even, odd = map(int, input().split())
s = even * (even -1) // 2
s += odd * (odd - 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):
a, b  = [int(i) for i in input().split()]
x = 0
x = a*(a-1)/2+b*(b-1)/2
print(x)



a, b  = [int(i) for i in input().split()]
x = 0
x = a*(a-1)//2+b*(b-1)//2
print(x)



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():
    from itertools import product

    H,W,K = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    
    i = 0
    while i < len(S):
        if '1' in S[i]:
            i += 1
        else:
            del S[i]
    H = len(S)
 
    S = [[int(s[i]) for s in S] for i in range(W)]

    if sum(sum(s) for s in S)<=K:
        print(0)
    else:
        answer = (H-1) * (W-1)
        for X in product([False,True], repeat=H-1):
            ans = np.sum(X)
            if ans >= answer:
                continue
            M = [[0]]
            for i, x in enumerate(X):
                if x:
                    M.append([])
                M[-1].append(i+1)
            D = [0]*len(M)
            for s in S:
                for k, m in enumerate(M):
                    D[k] += sum(s[i] for i in m)
                if any(d > K  for d in D):
                    ans += 1
                    if ans >= answer:
                        break
                    for k, m in enumerate(M):
                        D[k] = sum(s[i] for i in m)
                    
                    if any(d > K for d in D):
                        ans = answer + 1
                        break

            answer = min(answer,ans)

        print(answer)

main()

S = list(input())
N = len(S)
S_mae = S[:int((N-1)/2)]
S_usi = S[int((N+1)/2):]

if (S_mae[:len(S_mae)] == S_mae[::-1]) and (S == S[::-1]):
    print("Yes")
else:
    print("No")
    
#print(S_mae)
#print(S_usi)



A, B = map(int, input().split())
#A = list(map(int, input().split()))

print(int((A*(A-1))/2+(B*(B-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 = int(input())
m = int(input())

result = 0

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

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

print(result)

n, m = map(int, input().split())
 
result = 0
 
if n != 0: 
  result += n*(n-1)/2
 
if m != 0:
  result += m*(m-1)/2
 
print(int(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):
s = input()
d = len(s)//2
print("Yes" if s[:d] == s[d+1:] "No" else)

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):
import sys
input=sys.stdin.readline
N,M = map(int,input().split())
nCr = {}
def cmb(n, r):
    if r == 0 or r == n:
         return 1
    if r == 1:
         return n
    if (n,r) in nCr:
         return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

a = cmb(N,2)
b = cmb(M,2)
print(a+b)

import sys
input=sys.stdin.readline
N,M = map(int,input().split())
nCr = {}
def cmb(n, r):
    if n == 0:
        return 0
    if r == 0 or r == n:
         return 1
    if r == 1:
         return n
    if (n,r) in nCr:
         return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

a = cmb(N,2)
b = cmb(M,2)
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):
# solution

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

# solution

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

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

import math
N, M = list(map(int, input().split()))
n_pairs = math.factorial(N) // (2*math.factorial(N-2)) if N > 1 else 0
m_pairs = math.factorial(M) // (2*math.factorial(M-2)) if M > 1 else 0
print(n_pairs + m_pairs)

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))
n,m = map(int,input().split())
if n<1 and m<1:
    print(0)
elif n<1:
    print(combinations_count(m,2))
elif m<1:
    print(combinations_count(n,2))
else:
    print(combinations_count(n,2)+combinations_count(m,2))

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,m = map(int,input().split())
if n<2 and m<2:
    print(0)
elif n<2:
    print(combinations_count(m,2))
elif m<2:
    print(combinations_count(n,2))
else:
    print(combinations_count(n,2)+combinations_count(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 == 0:
  print(m*(m-1)/2)
elif n == 1:
  if m == 1:
    print('0')
  else:
    print(m*(m-1)/2)
elif m == 0:
  print(n*(n-1)/2)
elif m == 1 and n>=2:
  print(n*(n-1)/2)
else:
  print(m*(m-1)/2 + n*(n-1)/2)

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

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

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

import math

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

Verdicts: Runtime Error

Accepted