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):
a,b = input().split()
a = int(a)
b = int(b)
A = (a*a-1)/2
B = (b*b-1)/2
if a == 1 and b == 1:
  print(0)
elif a ==1 and b >= 1:
  print(B)
elif a >= 1 and b == 1:
  print(A)
elif a>= 1 and b >=1:
  print(A+B)

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


S = a*a-1/2
F = b*b-1/2
if a<1.9 and b<1.9:
  print(0)
elif a<1.9 and b>1.9:
  print(int(F))
elif a>1.9 and b<1.9:
  print(int(S))
elif a>1.9 and b>1.9:
  print(int(S+F))
        


a,b = input().split()
a = int(a)
b = int(b)
A = (a*a-1)/2
B = (b*b-1)/2
if a <= 2 and b <= 2:
  print(0)
elif a <=2 and b >= 1:
  print(B)
elif a >= 1 and b <= 2:
  print(A)
elif a>= 1 and b >=1:
  print(A+B)

a = input().split()
b = int(a[0])
c = int(a[1])
if b == 1 and c == 1:
    print(0)
elif b>=2 and c>=2:
    d = b-1
    e = c-1
    f = b*d/2
    g = c*e/2
    print(int(f+g))
elif b<=1 and c>=2:
    d = c-1
    f = c*d/2
    print(int(f))
elif b>=2 and c<=1:
    d = b-1
    f = b*d/2
    print(int(f))

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

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

print(int(n + m))

import math

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

def f(a):
    if a > 1:
        return int(math.factorial(a) / math.factorial(a-2) / 2)
    else:
        return 0

print(f(N) + f(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):
from math import *


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

L= int(input())
A = (L/3)*(L/3)*(L/3)
print (A)


N = input()
M = input()
A = (factorial(N)*factorial(N-1))+(factorial(M)*factorial(M-1))/2
print A

from math import *


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



Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
count = 0
L = len(a)
for el in a:
    count += a.count(el)-1
count //= 2
for el in a:
    print(count - a.count(el)+1)

n = int(input())
a = list(map(int, input().split()))
d = [0]*(n+1)
count = 0
for el in set(a):
    temp = d[el] = a.count(el)
    count += temp*(temp-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

n = int(input())
a = list(map(int, input().split()))
count = 0
for el in a:
    count += a.count(el)-1
count //= 2
for el in a:
    print(count - a.count(el)+1)

n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(len(a)):
    count += a.count(a[i])
count /= 2
for i in range(len(a)):
    print(count - a.count(a[i])+1)

n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(len(a)):
    count += a.count(a[i])
count /= 2
for i in range(len(a)):
    print(count - a.count(a[i])+1)

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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

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

Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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


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


print(int((input()))**3/27)


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


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

flag = 0
for i in range(0, len(S), 1):
	if S[i] != S[len(S)-1-i]:
		flag = 1

for i in range(0, (len(S) + 1) //2, 1):
	if S[i] != S[len(S)//2-1-i]:
		flag = 1

if flag == 0:
	print("Yes")
else:
	print("No")

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())
def col(x):
    if x == 0:
        return(0)
    else:
        return((x * (x - 1)) / 2)
print(col(n) + col(m))


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


Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

Submission attempts (in order):
import math 

N2,M1 = map(int, input().split())

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


count = combinations_count(N2,2)

count += combinations_count(M1,2)

print(count)

import math 

N2,M1 = map(int, input().split())

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

print(combinations_count(4, 2))

count = combinations_count(N2,2)

count += combinations_count(M1,2)

print(count)

import math 

N2,M1 = map(int, input().split())
count=0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N2!=0:
    count += combinations_count(N2,2)
if M1!=0:
    count += combinations_count(M1,2)

print(count)

import math 

N2,M1 = map(int, input().split())
count=0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N2!=0 and N2!=1:
    count += combinations_count(N2,2)
if M1!=0 and M1!=1:
    count += combinations_count(M1,2)

print(count)

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):
S = str(input())
N = len(S)

S1 = S[0:N//2]
S1_1=S1[0:len(S)//4]
S1_2=S1[len(S)//4+1:]

S2= S[N//2+1:]
S2_1=S2[0:len(S)//4]
S2_2=S2[len(S)//4+1:]


if S1_1 == S1_2 and S2_1 == S2_2:
    print("Yes")
else:
    print("No")


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

if N > 2:
    N_even = N*(N - 1)/2
else:
    N_even = 0

if M > 2:
    M_even = M*(M-1)/2
else:
    M_even = 0

print(int(N_even + M_even))


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


if N >= 2:
    N_even = N*(N - 1)/2
else:
    N_even = 0

if M >= 2:
    M_even = M*(M-1)/2
else:
    M_even = 0

print(int(N_even + M_even))

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

from itertools import combinations
n, m = map(int, input().split())
r = []
i = 0
j = -1
c = 0
for _ in range(n):
    i += 2
    r.append(i)
for _ in range(m):
    j += 2
    r.append(j)
r.sort()
for k in list(combinations(r, 2)):
    if sum(k) % 2 == 0:
        c += 1

print(c)

Verdicts: Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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


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

if N>=2:
  gyu = N*(N-1)//2
else:
  gyu = 0
  
if M>=2:
  ki = M*(M-1)//2
else:
  ki = 0

print(gyu+ki)

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

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

input_1 = input()
input_2 = input_1.split()

A = map(int, input_2)

def equal(num):
    return num
A = [equal(x) for x in A]

ans = 0

for l in range(N):
    ans += A.count(A[l]) - 1

ans = ans / 2
re = ans

for k in range(N):
    ans -= A.count(A[k]) - 1

    print(int(ans))

    ans = re

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

ans = (N * (N - 1) + 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()
n=int(N)
m=int(M)
a=n*(n-1)
b=m*(m-1)
print(a+b)

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

e_e = N * (N - 1) / 2
o_o = M * (M - 1) / 2

print(e_e + o_o)

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

e_e = N * (N - 1) / 2
o_o = M * (M - 1) / 2

print(int(e_e + o_o))

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):
#include<stdio.h>

long int multiplyNumbers(int n) {
    if (n>=1)
        return n*multiplyNumbers(n-1);
    else
        return 1;
}

int main(){
	long int N, M;
	scanf("%ld %ld", &N, &M);
	long int c1 = multiplyNumbers(N)/((multiplyNumbers(N-2))*multiplyNumbers(2));
	long int c2 = multiplyNumbers(M)/((multiplyNumbers(M-2))*multiplyNumbers(2));
	printf("%d", c1+c2);
	return 0;
}

from itertools import combinations

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

a = list(combinations(range(N), 2))
b = list(combinations(range(M), 2))
print(len(a)+len(b))

Verdicts: Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

Submission attempts (in order):
import functools
import math
import collections
import scipy
import fractions
import itertools

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


import itertools

def solve():
  n, m = map(int, input().split())
  a = len(list(itertools.combinations(range(n), 2)))
  b = len(list(itertools.combinations(range(m), 2)))
  print(a + b)
  return 0

if __name__ == "__main__":
  solve()


Verdicts: Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

Submission attempts (in order):
n,m = [int(i) for i in input().split()]
if n <= 1:
  a = 0
else:
  a = n*(n-1)/2
if m <= 1:
  b = 0
else:
  b = m*(m-1)/2
print(ab)

n,m = [int(i) for i in input().split()]
if n <= 1:
  a = 0
else:
  a = n*(n-1)/2
if m <= 1:
  b = 0
else:
  b = m*(m-1)/2
print(a+b)

n,m = [int(i) for i in input().split()]
if n <= 1:
  a = 0
else:
  a = n*(n-1)/2
if m <= 1:
  b = 0
else:
  b = m*(m-1)/2
print(int(a+b))

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):
def kaibun(str):
    return True if str == str[::-1] else False

s = input()
if not kaibun(s) :
    print('No')
    exit()
n = len(s)
n1 = (n - 1) // 2
if not kaibun(s[:n1]) :
    print('No')
    exit()
n2 = (n + 3) // 2 - 1
if not kaibun(s[n2:]) :
    print('No')
    exit()
print('Yes')


import math
 
def resolve():
    n = int(input())
    a = [int(x) for x in input().split()]
 
    for k in range(n):
        
        ak = [x for x in a] 
        del ak[k]
        kumi = 0
        ended = []
 
        # loop
        for i in range(n - 1):
            a0 = ak[i] 
            if a0 in ended:
                continue
            cnt = ak.count(a0)
            if cnt >= 2:
                kumi += kumiawase(cnt ,2)
            ended.append(a0)
        print(kumi)
 
def kumiawase(n, r):
    return math.factorial(n) // (r * math.factorial(n - r))
 
resolve()

import math

a = [int(x) for x in input().split(" ")]
n = a[0]
m = a[1]
ans = 0
if n >= 2 :
    ans += math.factorial(n) // (2 * math.factorial(n - 2))
if m >= 2 :
    ans += math.factorial(m) // (2 * math.factorial(m - 2))
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

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

Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

     
    


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

     
    


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

     
    

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

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

     
    


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

values = {}
for i in nums:
  if i in values: values[i] += 1
  else: values[i] = 1

sums={} 
subsums={} （ボールがないとき版
allsum = 0
for k,v in values.items():
  sums[k] = v * (v - 1) / 2
  undersum = (v - 2) * (v - 1) / 2 if v > 1 else 0
  subsums[k] = sums[k] - undersum
  allsum += sums[k]


# for k,v in sums.items():

for i in nums:
  print(int(allsum - subsums[i]))


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

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

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


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

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


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

a = (H * (H-1))/2
b = (W * (W-1))/2

print(a+b)


import math
H, W = map(int, input().split())

a = (H * H-1)/2
b = (W * W-1)/2
print(a+b)

import math
H, W = map(int, input().split())
 
a = (H * (H-1))/2
b = (W * (W-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 = list(map(int, input().split()))
lis = []
for i in range(n):
  lis.append(1)
  for i in range(m):
    lis.append(2)
    count = 0
    for i in range(len(lis)):
      for j in range(i + 1, len(lis)):
        if (lis[i] + lis[j]) % 2 == 0:
          count += 1
          print(count)

n, m = list(map(int, input().split()))
lis = []
for i in range(n):
  lis.append(1)
for i in range(m):
  lis.append(2)
count = 0
for i in range(len(lis)):
  for j in range(i + 1, len(lis)):
    if (lis[i] + lis[j]) % 2 == 0:
      count += 1
print(count)

Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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


Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

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

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

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

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

Verdicts: Wrong Answer

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):
s= input()
l = list(s)
ans= "Yes"
for i in range(0,(len(s)//2)):
  if(l[i]!=l[-1-i]):
    ans = "No"
print(ans)


s= input()
l = list(s)
ans= "Yes"
for i in range(0,(len(s)//2)+1):
  if(l[i]!=l[-1-i]):
    ans = "No"
print(ans)


s= input()
l = list(s)
ans= "Yes"
for i in range(0,len(s)//2):
  if(l[i]!=l[-1-i]):
    ans = "No"
print(ans)


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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

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

Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

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

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

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


N,M = map(int , input().split())
result = N+M
if result % 2 == 1:
    print(result)


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

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


Verdicts: Wrong Answer

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

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

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

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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

Submission attempts (in order):
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 and N != 1:
    a = combinations_count(N, 2)
else:
    a = 0

if M !=0 and M != 0:
    b = combinations_count(M, 2)
else:
    b = 0

print(a+b)

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 and N != 1:
    a = combinations_count(N, 2)
else:
    a = 0

if M !=0 and M != 1:
    b = combinations_count(M, 2)
else:
    b = 0

print(a+b)

Verdicts: Runtime Error

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

Submission attempts (in order):
s=input()
s = int(s)
t=input()
t = int(t)
print(s*(s-1) /2 + t*(t-1)/2)

s,t=(int(x) for x in input().split())
print(s*(s-1) /2 + t*(t-1)/2)

s,t=(int(x) for x in input().split())
print(int(s*(s-1) /2 + t*(t-1)/2))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

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

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

Submission attempts (in order):
s = input()
n = len(s)
t = s[:(n-1)//2]
u = s[(n+3)//2-1:]
if s==s[::-1] and t==t[::-1] and u==u[::-1]:
    print("Yes")
else:
    print("No")


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

def inputlist(): return [int(i) for i in input().split()]

def kumiawase(num):
    r = 2
    if num != 1 or num != 0:
        return math.factorial(num) // (math.factorial(num - r) * math.factorial(r))
    else:
        return 0

def main():
    N, M = inputlist()
    print(kumiawase(N) + kumiawase(M))

if __name__ == '__main__':
    main()

import math

def inputlist(): return [int(i) for i in input().split()]

def kumiawase(num):
    r = 2
    return math.factorial(num) // (math.factorial(num - r) * math.factorial(r))

def main():
    N, M = inputlist()
    print(kumiawase(N) + kumiawase(M))

if __name__ == '__main__':
    main()

import math

def inputlist(): return [int(i) for i in input().split()]

def kumiawase(num):
    r = 2
    if num != 1 and num != 0:
        return math.factorial(num) // (math.factorial(num - r) * math.factorial(r))
    else:
        return 0

def main():
    N, M = inputlist()
    print(kumiawase(N) + kumiawase(M))

if __name__ == '__main__':
    main()

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

n = int(input())
a = list(map(int,input().split()))
b = a.copy()
b = set(b)
b = list(b)
c = []
ans = []

for i in range(len(b)):
    c.append(a.count(b[i]))
print(b)
print(c)
d = []
for i in range(len(b)):
    num = 0
    for j in range(len(b)):
        if i == j:
            num += int(((c[j]-1)*(c[j]-2))/2)
        else:
            num += int(((c[j])*(c[j]-1))/2)
    d.append(num)
print(d)

for i in range(n):
    for j in range(len(b)):
        if a[i] == b[j]:
            print(d[j])



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

a = int(n*(n-1)/2)
b = int(m*(m-1)/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):
guu, ki = map(int, input().split())

print(guu*(guu-1)/2 + ki*(ki-1)/2)

guu, ki = map(int, input().split())

print(int(guu*(guu-1)/2 + ki*(ki-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):
val = input().split(' ')
n = int(val[0])
m = int(val[1])

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

print(result)


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

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

print(int(result))


Verdicts: Wrong Answer

Accepted
Problem: We have N+M balls, each of which has an integer written on it.   It is known that:    * The numbers written on N of the balls are even.   * The numbers written on M of the balls are odd.  Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.   It can be shown that this count does not depend on the actual values written on the balls.

Submission attempts (in order):
s1 = str(input())
s2 = ''
for i in range(len(s1)):
    s2 += s1[- i - 1]
if s1 != s2:
    print('No')
    exit()

t1 = s1[0 : ((len(s1)) - 1) // 2]
t2 = ''
for i in range(len(t1)):
    t2 += t1[- i - 1]
if t1 != t2:
    print('No')
    exit() 

u1 = s1[(len(s1) + 3) // 2 - 1:]
u2 = ''
for i in range(len(u1)):
    u2 += u1[- i - 1]
if u1 != u2:
    print('No')
    exit() 
print('Yes')

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()) 
if M == 1:
    answer = N * N-1
elif N == 1:
    answer = M * M-1
else:
    answer = (N * (N-1))//2 + (M * (M-1))//2
print(answer)

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

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

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

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

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(input().split())
if n<=1:
    n=0
if m<=1:
    m=0
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())

N1=(N*(N-1))/2
M1=(M*(M-1))/2

if N==0:
    print(M1)
elif M==0:
    print(N1)
else:
    print(M1+N1)

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

N1=(N*(N-1))/2
M1=(M*(M-1))/2

if N==0:
    print(int(M1))
elif M==0:
    print(int(N1))
else:
    print(int(M1+N1))

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

n, m = list(map(int,input().strip().split()))
print(((n- 1)*(n))//2 + ((m-1)*(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):
a=0
b=0
def ball(x,y):
    a=x*(x-1)//2
    b=y*(y-1)//2
    if a!=0 and b!=0:
        print(a+b)
    elif a=0:
        print(b)
    else:
        print(a)


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

n=int(input())
a=(input().split())
for i in range(n):
    x=0
    for j in range(n):
        for k in range(n):
            if j>k:
                if a[j]==a[k] and j!=i and k!=i:
                    x=x+1
    print(x)


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

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

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

def ball(x,y):
    if x>1 and y>1:
        print((x*(x-1)+y*(y-1))//2)
    elif x<=1 and y>1:
        print((y*(y-1))//2)
    elif x>1 and y<=1:
        print((x*(x-1))//2)
    else:
        print(0)


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

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

  

def uhe(x):
    return x%2

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

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

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

def uhe(x):
    return x%2

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

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

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

  

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted