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

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

n,m=map(int,input().split())
print((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)
kai = []
kai2 = []
kai3 = []

for i in range(N):
  kai.append(S[i])

for i in range(0, int((N - 1) / 2)):
  kai2.append(S[i])

for i in range(int((N + 3) / 2) - 1, N):
  kai3.append(S[i])

rev = kai.reverse
rev2 = kai2.reverse
rev3 = kai3.reverse

if kai == rev:
  if kai2 == rev2:
    if kai3 == rev3:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')


N, M = map(int, input().split())
def sta(n):
  one = 1
  for i in range(1, n + 1):
    one *= i
  return one

if N >= 3:
  num = sta(N)/(sta(2)*sta(N-2))
if N = 2:
  num = 1
if N <= 1:
  num = 0

if M >= 3:
  mum = sta(N)/(sta(2)*sta(N-2))
if M = 2:
  mum = 1
if M <= 1:
  mum = 0

print(num + mum)


N, M = map(int, input().split())
def sta(n):
  one = 1
  for i in range(1, n + 1):
    one *= i
  return one

if N >= 3:
  num = sta(N)/(sta(2)*sta(N-2))
if N == 2:
  num = 1
if N <= 1:
  num = 0

if M >= 3:
  mum = sta(M)/(sta(2)*sta(M-2))
if M == 2:
  mum = 1
if M <= 1:
  mum = 0

print(int(num + mum))

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

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

n_comb = comb(N, 2)
m_comb = comb(M, 2)

output = int(n_comb) + int(m_comb)

print(output)

from scipy.misc import comb

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

n_comb = comb(N, 2)
m_comb = comb(M, 2)

output = int(n_comb + m_comb)

print(output)

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

n_comb = (N * (N -1)) / 2
m_comb = (M * (M -1)) / 2

output = int(n_comb) + int(m_comb)

print(output)

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

n = N-1
m = M-1

Even = N*n
Odd = M*m

print((Even+Odd)/2)

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

n = N-1
m = M-1

Even = N*n
Odd = M*m

print((Even+Odd)/2)

N = input()
M = input()

n = N-1
m = M-1

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

N = input()
M = input()

n = N-1
m = M-1

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

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

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

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

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

Submission attempts (in order):
a = input().split(' ')
b = (a[0] * a[0]-1)/2 + (a[1] * a[1]-1)/2
print (b)

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

Verdicts: Runtime Error

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

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


pattern_1 = N*(N-1)/2


pattern_2 = M*(M-1)/2

print(pattern_1 + pattern_2)

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

pattern_1 = N*(N-1)/2
pattern_2 = M*(M-1)/2

print(pattern_1 + pattern_2)

nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
ans = n*(n-1)/2 + m*(m-1)/2
print(int(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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readlines().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, read().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

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


dict = {}
for a in A:
    if a in dict:
        dict[a] += 1
    else:
        dict[a] = 1


memo = {}
for k in range(N):
    ans = 0
    m = A[k]
    if m in memo.keys():
        ans = memo[m]
    else:
        dict_work = dict.copy()
        dict_work[m] -= 1
        for d in dict_work.values():
            if d > 1:
                ans += (d * (d - 1)) // 2
        memo[m] = ans
    print(ans)

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

ans = 0

if N > 1:
    ans += (N * (N - 1)) // 2
if M > 1:
    ans += (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):
import collections

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

c = collections.Counter(a)

ans = 0

for i in c.values():
    ans += i * (i - 1) // 2

for i in range(n):
    print(ans - c[a[i]] + 1)


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

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

print(a)


Verdicts: Runtime Error

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

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

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

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
import functools
from operator import add

def main():
    h,w,k = tuple([int(t)for t in input().split()])

    s = [[int(i) for i in list(input())] for _ in range(h)]
    
    cusum = [accumelist(s_) for s_ in s]

    candidates = []

    for i in range(1<<(h-1)):
        subcu = divide(cusum,i)
        subcusum = []

        for sub_ in subcu:
            subcusum.append(functools.reduce((lambda a,b:list(map(add,a,b))),sub_))

        cutnum = 0
        j=0
        temp = [0]*len(subcusum)

        while j<w:
            for l in range(len(subcusum)):
                pos = 0
                if subcusum[l][j]-temp[l]>k:
                    pos = j
                    j-=1
                    if j-pos==0:
                        cutnum+=10000
                    temp = [x[j-1] for x in subcusum]
                    cutnum+=1
                    break
            j+=1
        
        candidates.append(cutnum+bin(i).count('1'))

    print(min(candidates))
            
def divide(s,i):
    subs = []
    counter = 0
    pos = 0
    while i!= 0:
        counter +=1
        if i%2==1:
            subs.append(s[pos:counter])
            pos = counter
        i >>=1
 
    subs.append(s[pos:])
    return subs

def accumelist(s):
    if s == []:
        return []
    res = [s[0]]
    for i in range(1,len(s)):
        res.append(res[i-1]+s[i])

    return res

def _add_(a,b):
    return map(add,a,b)
    
if __name__ == "__main__":
    main()

def main():
    n,m = tuple([int(t)for t in input().split()])

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

if __name__ == "__main__":
    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):
import sys
from math import factorial

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

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


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

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

print(ans)

import sys
from math import factorial

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

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


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

a = comb(N, 2) if N>=2 else 0
b = comb(M, 2) if M >=2 else 0
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):
import math
N,M = map(int, input().split())
def combinations_count(n,r):
	return math.factorial(n) // (math.factorial(n-r)*math.factorial(r))
print(combinations_count(N,2) + combinations_count(M,2))

import math
N,M = map(int, input().split())
def combinations_count(n,r):
	return math.fractorial(n) / (math.fractorial(n-r)*math.fractorial(r))
print(combinations_count(N,2) + combinations_count(M,2))

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

Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
import math
N,M=map(int,input().split())
def kumiawase(n):
    a=math.factorial(n)
    r=math.factorial(2)
    return a / (r*math.factorial(n-2))
print(int(kumiawase(M)+kumiawase(N)))

import math
N,M=map(int,input().split())
def kumiawase(n):
    if n>2:
        a=math.factorial(n)
        r=math.factorial(2)
        return a / (r*math.factorial(n-2))
    return 0

print(int(kumiawase(M)+kumiawase(N)))

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

Verdicts: Runtime Error

Wrong Answer

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

Submission attempts (in order):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,m=map(int,input().split())
if (n<=1) and (m<=1):
  ans=0
elif (n==0) or (m==0):
  ans=0
else:
  ans=comb(n,2)+comb(m,2)
  
print(ans)

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

n,m=map(int,input().split())
if (n<=1) and (m<=1):
  ans=0
else:
  if n==0:
    ans=comb(m,2)
  elif m==0:
    ans=comb(n,2)
  else:
    ans=comb(n,2)+comb(m,2)
  
print(ans)
  

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

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

list1 = []
list2 = []

count = 0
C = 0
o = 0
b = 0
G = 0

for i in range(1, N + 1):
    list1.append(i * 2)
    if i >= 2:
        C = sum(list1)
        list1.remove(list1[o])
        o += 1
    if C % 2 == 0:
        count += 1
    C = 0

for q in range(1, M + 1):
    list2.append((q * 2) - 1)
    if q >= 2:
        G = sum(list2)
        list2.remove(list2[b])
        b += 1
    if G % 2 == 0:
        count += 1
    G = 0

for w in list1:
    for e in list2:
        total = w + e
        if total % 2 == 0:
            count += 1

print(count)

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

list1 = []
list2 = []


total1 = 0

count = 0

for i in range(1, N + 1):
    list1.append(i * 2)

for q in range(1, M + 1):
    list2.append((q * 2) - 1)

for w in list1:
    for e in list2:
        total = w + e
        if total % 2 == 0:
            count += 1


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

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

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

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

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

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

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

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):
from itertools import combinations
ne, no = map(int,input().split())
even, odd = [i for i in range(1,2*(ne+1)) if i % 2 == 0], [i for i in range(1,2*no) if i % 2 != 0]
lst = even + odd
c = 0
for i in combinations(lst,2):
    print(i)
    if sum(i) % 2 == 0:
        c += 1
print(c)


from itertools import combinations
ne, no = map(int,input().split())
even, odd = [i for i in range(1,2*(ne+1)) if i % 2 == 0], [i for i in range(1,2*no) if i % 2 != 0]
lst = even + odd
c = 0
for i in combinations(lst,2):
    if sum(i) % 2 == 0:
        c += 1
print(c)


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


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


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

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

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

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

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

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

Verdicts: Wrong Answer

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

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

if __name__ == '__main__':
    main()


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 math

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

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


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

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

Verdicts: Wrong Answer

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

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

n,m=map(int,input().split())
print(int((n*(n-1)+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 numpy as np
import itertools

H, W, K = map(int, input().split())
choco = []
for i in range(H):
    choco.append([int(x) for x in list(input())])

arr = np.array(choco)


count = (H-1) + (W-1)

for k in range(H):
    
    
    if count <= k:
        break

    
    for comb in itertools.combinations(range(1,H),k):

        
        t = (None,) + comb + (None,)
        s = [slice(t[j],t[j+1],) for j in range(len(t)-1)]
        
        # print(t)
        
        sum_p = [0] * (k+1)
        
        cut = k
        
        for col in zip(*choco):
                        
            
            sum_a = [sum(col[b]) for b in s]
            # print(sum_a)
            
            if any(map(K.__lt__, sum_a)):
                
                break
            
            sum_b = [x+y for x,y in zip(sum_p, sum_a)]

            if any(map(K.__lt__, sum_b)):
                cut += 1
                sum_p = [0] * (k+1)
            else:
                sum_p = sum_b
                
                
        
        else:
            count = min(count,cut)

print(count)

import math

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


a = 0
if N > 1:
    a = int(math.factorial(N) / (math.factorial(N-2)*2))


b = 0
if M > 1:
    b = int(math.factorial(M) / (math.factorial(M-2)*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):
import itertools
import numpy as np

res = 999999999999999999

H, W, K = [int(i) for i in input().split()]
arr = []
for _ in range(H):
  arr.append([int(v) for v in input()])

arr = np.array(arr)
  
for p in itertools.product([0, 1], repeat = H-1):
  sp = np.zeros((sum(p)+1, W), int)
  row = 0
  sp[0] += arr[0]
  for j in range(H-1):
    if p[j]:
      row += 1
    sp[row] += arr[j+1]
  if np.max(sp) > K:
    continue
  
  sum_arr = np.zeros(len(sp), int)
  cut_cnt = sum(p)
  for c in range(W):
    sum_arr += sp[:, c]
    if max(sum_arr) > K:
      sum_arr = sp[:, c]
      cut_cnt += 1
  if cut_cnt < res:
    res = cut_cnt
print(res)

n, m = [int(i) for i in input().split()]

def calc(s):
  if s < 2:
    return int(0)
  else:
    return int(s * (s-1) / 2)

print(calc(n) + calc(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 sys import stdin
from collections import Counter

def main():

    input = stdin.readline

    N = int(input())

    A = [0] * N

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

    all_case = 0

    num_all = Counter(A) 

    for k in num_all.values():
        all_case += (k * (k-1)) // 2

    for i in A:
        ans = all_case - (num_all[i] - 1)
        print(ans)
    
if __name__ == "__main__":
    main()

from sys import stdin

def main():

    input = stdin.readline

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

    ans = 0

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

    print(ans)


def comb(n,k):
    min_k = min(k,n-k)

    if n < 2:
        return 0

    n_kaijyo = 1
    k_kaijyo = 1
    for i in range(min_k):
        n_kaijyo = n_kaijyo * (n - i)
        k_kaijyo = k_kaijyo * (i + 1)

    result = int(n_kaijyo / k_kaijyo)
    return result
    
if __name__ == "__main__":
    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):
l = int(input())

from decimal import *
n = Decimal(l/3).quantize(Decimal('.001'))

print((l-2*n)*n*n)

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

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


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

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


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

rs = s[::-1]
q1 = 0
if s == rs:
  q1 = 1
# print("q1=",q1)


n = len(s)
h = int((n-1)/2)
# print("n,h=",n,h)
s1 = s[:h:]
# print("s1=",s1)
rs1 = s1[::-1]
q2 = 0
if (s1 == rs1):
  q2 = 1
# print("q2=",q2)


n = len(s)
h = int((n+2)/2)
# print("n,h=",n,h)
s2 = s[h::]
# print("s2=",s2)
rs2 = s2[::-1]
q3 = 0
if (s2 == rs2):
  q3 = 1
# print("q3=",q3)
if q1 == 1 and q2 == 1 and q3 ==1:
  print("Yes")
else:
  print("No")

lin = input().split()
n = int(lin[0])
m = int(lin[1])
np = 0
if n >= 2:
  np = int(n * (n-1) / 2)
op = 0
if m >= 2:
  op = int(m * (m-1) / 2)
print(np+op)

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

num1 = 1
list_M = []

for i in M:
  list_M.append(i)
  num1 += 1

num2 = 1
list_n = []
for j in N:
  list_N.append(j)
  num2 += 1

add_list = []
for k in M:
  for l in N:
    add_list.append(list_m[k] + list[l])

odd = 0

for m in add_list:
  if m % 2 == 0:
    odd += 1
    
print(odd)
    

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

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

Verdicts: Runtime Error

Runtime Error

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

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

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

Verdicts: Wrong Answer

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

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
tmp = input().split(" ")
N = int(tmp[0])
M = int(tmp[1])

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

tmp = input().split(" ")
N = int(tmp[0])
M = int(tmp[1])
 
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):
n,m=map(int,input().split())
count=0
a=[]
for i in range(n):
    a.append(2)
for i in range(m):
    a.append(1)

for i in range(n+m-1):
    for j in range(i,n+m):
        if a[i]+a[j]%2==0:
            count+=1
print(count)

n,m=map(int,input().split())
count=0
a=[]
for i in range(n):
    a.append(2)
for i in range(m):
    a.append(1)
#print(a)

for i in range(n+m-1):
    for j in range(i+1,n+m):
        #print(a[i],a[j])
        if (a[i]+a[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):
S = int(input())
a = S//3
b = a * 0.8
c = a * 1.2
ans = a * b * c
ans = ans * 1.0416666666666666
print("{0:.7f}".format(ans))

N, M = map(int, input().split())
a = []
b = []
if M == 0:
    for i in range(1,(2*N)+1):
        if i%2==0 and i>0:
            a.append(i)
elif N == 0:
    for i in range(1,(2*M)+1):
        if i%2==1:
            b.append(i)
else:
    for i in range(1,501):
        if i%2==0 and i>0:
            a.append(i)
        else:
            b.append(i)
c = a[:N] + b[:M]
l = []
num = 1
for i in range(len(c)-1):
    for j in range(num,len(c)):
        res = c[i] + c[j]
        l.append(res)
    num+=1

k=[i for i in l if i%2==0]
print(len(k))

Verdicts: Runtime Error

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

Submission attempts (in order):
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):
a,b = map(int,input().split())
print(a*(a-1)/2 + b*(b-1)/2)

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

Verdicts: Wrong Answer

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

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

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

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

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

Verdicts: Runtime Error

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

li = list(map(int, input().split()))
n = li[0]
m = li[1]

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


import math


def combinations_count(n, r):
    try:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    except ValueError:
        return 0
    

li = list(map(int, input().split()))
n = li[0]
m = li[1]

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


Verdicts: Runtime Error

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

Submission attempts (in order):
S = input()
N = len(S)
list_a = []
count = 0

for i in range(0, N):
    list_a.append(S[i])

for i in range(0, N):
    if list_a[i] == list_a[N-1-i]:
        count += 1
    else:
        pass

for j in range(0, int(N//2)):
    if list_a[j] == list_a[int((N-3-j)/2)] and list_a[int((N+1+j)/2)] == list_a[N-1-j]:
        count += 1
    else:
        pass

if count > N:
    print("Yes")
else:
    print("No")


N, M = map(int, input().split())
sum_a = 0
sum_b = 0

if N % 2 == 0:
    sum_a = (N/2) * (N-1)
else:
    sum_a = N * ((N-1)/2)

if M % 2 == 0:
    sum_b = (M/2) * (M-1)
else:
    sum_b = M * ((M-1)/2)

sum = sum_a + sum_b

print(int(sum))


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()))
x=a/2*(a-1)+b/2*(b-1)
print(x)

a,b=list(map(int,input().split()))
x=int(a/2*(a-1)+b/2*(b-1))
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():
    input()
    t = list(map(int, input().split()))
    col = collections.Counter(t)
    com = {}
    al = 0
    for key in col:
        com[key] = combinations_count(col[key], 2)
        al += com[key]
    for v in t:
        c = col[v] - 1
        if c <= 1:
            c = 0
        else:
            c = combinations_count(c, 2)
        tmp = (al - com[v]) + c
        print(tmp)


if __name__ == '__main__':
    main()


url = "https://atcoder.jp//contests/abc159/tasks/abc159_a"

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

if __name__ == '__main__':
    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):
import utility

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

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

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

print(int(result))

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

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

if(m >=1):
    result = 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):
from scipy.misc import comb

#from scipy.special import comb

def main():
    n, m = map(int, input().split(" "))
    ans = comb(n, 2) + comb(m, 2)

    print(ans)

if __name__ == '__main__':
    main()

import itertools
import numpy as np

def main():
    n, m = map(int, input().split(" "))
    ans = 0
    for i in [n, m]:
        iterable = np.arange(start=1, stop=i+1, step=1).astype("str")
        ans += len(list(itertools.combinations(iterable, 2)))


    print(ans)

if __name__ == '__main__':
    main()



Verdicts: Wrong Answer

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

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

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

Verdicts: Wrong Answer

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

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

n = 0
m = 0
if N <= 1:
  n = N
else:
  n = (N*(N-1))/2
if M <= 1:
  m = M
else:
  m = (M*(M-1))/2
print(int(n + m))





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

n = 0
m = 0
if N <= 1:
  n = 0
else:
  n = (N*(N-1))/2
if M <= 1:
  m = 0
else:
  m = (M*(M-1))/2
print(int(n + m))





Verdicts: 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())
C1 = N*(N-1)/2
C2 = M*(M-1)/2

print(C1 + C2)


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

print(C1 + C2)

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 = int(input())
a = input().split()
 
for i in range(n):
  b = a[:]
  del b[i]
  k = 0
  c = set(b)
  for t in c:
    num = b.count(t)
    for i in range(num):
      k += i
  print(k)

n, m = input().split()

n = int(n)
m = int(m)
j = 0
for i in range(1, n):
  j += i
  
for i in range(1, m):
  j += i
  
print(j)

Verdicts: Runtime Error

Accepted