Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int(b*(b-1)/2)))
else:
    print(str(inr(a*(a-1)/2)))

Fixed submission:
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int(b*(b-1)/2)))
else:
    print(str(int(a*(a-1)/2)))

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int((b*(b-1)/2)))
else:
    print(str(int((a*(a-1)/2)))

Fixed submission:
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int(b*(b-1)/2)))
else:
    print(str(int(a*(a-1)/2)))

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a >= 1) and (b >= 1):
    print(str(a*(a-1)/2 + b*(b-1)/2))
elif (a == 0) and (b == 0):
    print(str("0")
elif (a == 0):
    print(str(b*(b-1)/2))
else:
    print(str(a*(a-1)/2))


Fixed submission:
a,b = map(int,input().split())
if (a != 0) and (b != 0):
    print(str(int(a*(a-1)/2 + b*(b-1)/2)))
elif (a == 0) and (b == 0):
    print("0")      
elif (a == 0) and (b != 0):
    print(str(int(b*(b-1)/2)))
else:
    print(str(int(a*(a-1)/2)))
Buggy python submission (verdict: Runtime Error):
k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
pritn(a[k])


Fixed submission:
k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])
Buggy python submission (verdict: Runtime Error):
a = int(input())
if a % 2 = 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1.0))

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1))

Buggy python submission (verdict: Runtime Error):
a = int(input())
if a % 2 = 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1))

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1))

Buggy python submission (verdict: Runtime Error):
a = int(input())
if a % 2 = 0:
  print(str(a//2))
else:
  print(str((a//2)+1))

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1))

Buggy python submission (verdict: Runtime Error):
a = int(input())
if a % 2 = 0:
  print(str(a/2))
else:
  print(str((a/2)+1))

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1))
Buggy python submission (verdict: Runtime Error):
i = map(int,input().split())
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")

Fixed submission:
i = list(map(int,input().split()))
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
i = map(int,input(),split())
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")

Fixed submission:
i = list(map(int,input().split()))
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()

for i in range(n):
  if h[i] >= k:
    ans = n-i
    break

print(ans)

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
ans = 0

for i in range(n):
  if h[i] >= k:
    ans = n-i
    break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0

if n == 1:
  ans = 0
else:
  for i in range(1,n):
    ans += i
  
print(ans)

Fixed submission:
n = int(input())
 
ans = (n*(n-1)//2)
 
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [sorted(input()) for i in range(n)]
cnt = 0
 
for j in range(n-1):
  for k in range(j+1,n):
    if s[j] == s[k]:
      cnt += 1
      
print(cnt)

Fixed submission:
from collections import Counter
n = int(input())
cnt_s = Counter([" ".join(sorted(input())) for i in range(n)])
print(sum(v*(v - 1)//2 for v in cnt_s.values()))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
cnt = 0

for j in range(n-1):
  for k in range(j+1,n):
    if sorted(s[j]) == sorted(s[k]):
      cnt += 1
      
print(cnt)

Fixed submission:
from collections import Counter
n = int(input())
cnt_s = Counter([" ".join(sorted(input())) for i in range(n)])
print(sum(v*(v - 1)//2 for v in cnt_s.values()))
Buggy python submission (verdict: Runtime Error):
a,b,c = int(input().split())

if (a-b) <= c:
  print(str(c - (a - b)))
else:
  print("0")

Fixed submission:
a,b,c = map(int,input().split())
 
if (a-b) <= c:
  print(str(c - (a - b)))
else:
  print("0")
Buggy python submission (verdict: Runtime Error):
for i in range(N-1):
    tmp+=A[i]
    ans+=tmp*A[i+1]
print(ans%((10**9)+7))

Fixed submission:
import math

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

for i in range(N-1):
    tmp+=A[i]
    ans+=tmp*A[i+1]
print(ans%((10**9)+7))

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

for i in range(N-1):
    ans+=A[i]*sum(A[i+1:])
print(ans%((10**9)+7))

Fixed submission:
import math

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

for i in range(N-1):
    tmp+=A[i]
    ans+=tmp*A[i+1]
print(ans%((10**9)+7))

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

for i in range(N-1):
    for j in range(i+1,N):
        #print("i="+str(i)+"\tj="+str(j)+"\t[i]="+str(A[i])+"\t[j]="+str(A[j]))
        ans+=A[i]*A[j]
print(ans%((10**9)+7))

Fixed submission:
import math

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

for i in range(N-1):
    tmp+=A[i]
    ans+=tmp*A[i+1]
print(ans%((10**9)+7))
Buggy python submission (verdict: Time Limit Exceeded):
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
before=0
now=1


for i in range(N):
    now*=A[i]
    if i+1>K:
        now=now/A[i-K]
        if now>before:
            print("Yes")
        else:
            print("No")
    if i+1>=K:
        before=now

Fixed submission:
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
before=0
now=1


for i in range(K,N):
    if A[i]>A[i-K]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
before=0
now=1


for i in A:
    now*=i
    count+=1
    if count>K:
        now=now/A[count-K-1]
        if now>before:
            print("Yes")
        else:
            print("No")
    if count>=K:
        before=now


Fixed submission:
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
count=0
before=0
now=1


for i in range(K,N):
    if A[i]>A[i-K]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import math
 
A,B,H,M=map(int,input().split())
x=abs(((60*H+M)*0.5)-(6*M))
if x>=180:
    x=x-180
y=(A**2)+(B**2)-2*A*B*math.cos(math.radians(x))
print((math.sqrt(y))

Fixed submission:
import math
 
A,B,H,M=map(int,input().split())
x=abs(((60*H+M)*0.5)-(6*M))
y=A**2+B**2-2*A*B*math.cos(math.radians(x))
print(math.sqrt(y))

Buggy python submission (verdict: Runtime Error):
import math
import decimal

a,b,h,m=map(float,input().split())
A=decimal.Decimal(a)
B=decimal.Decimal(b)
H=decimal.Decimal(h)
M=decimal.Decimal(m)
x=abs(((60*H+M)*0.5)-(6*M))
if x>=180:
    x=x-180
print(format((math.sqrt((A*A)+(B*B)-2*A*B*math.cos(math.radians(x)))),'.50f'))


Fixed submission:
import math
 
A,B,H,M=map(int,input().split())
x=abs(((60*H+M)*0.5)-(6*M))
y=A**2+B**2-2*A*B*math.cos(math.radians(x))
print(math.sqrt(y))
Buggy python submission (verdict: Time Limit Exceeded):
Ns,Ms=input().split()
N=int(Ns)
M=int(Ms)
LR=input().split()
ans=set(range(int(LR[0]),int(LR[1])+1))
for i in range(M-1):
	LR=[]
	LR=input().split()
#	print("ssssssssss")
#	print(ans)
	ansy=set(range(int(LR[0]),(int(LR[1])+1)))
	ans=ans&ansy
print(len(ans))


Fixed submission:
Ns,Ms=input().split()
N=int(Ns)
M=int(Ms)
lists=[]
ansmins,ansmaxs=input().split()
ansmin=int(ansmins)
ansmax=int(ansmaxs)
for i in range(M-1):
	tmpmin,tmpmax=input().split()
	if int(tmpmin)>ansmin:
		ansmin=int(tmpmin)
	if int(tmpmax)<ansmax:
		ansmax=int(tmpmax)

if (ansmax-ansmin+1)<0:
	ans=0
else:
	ans=ansmax-ansmin+1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
Ns,Ms=input().split()
N=int(Ns)
M=int(Ms)
LR=input().split()
ans=set(list(range(int(LR[0]),int(LR[1])+1)))
for i in range(M-1):
	LR=[]
	LR=input().split()
#	print("ssssssssss")
#	print(ans)
	ansy=set(list(range(int(LR[0]),(int(LR[1])+1))))
	ans=ans&ansy
ansx=list(ans)
print(len(ansx))


Fixed submission:
Ns,Ms=input().split()
N=int(Ns)
M=int(Ms)
lists=[]
ansmins,ansmaxs=input().split()
ansmin=int(ansmins)
ansmax=int(ansmaxs)
for i in range(M-1):
	tmpmin,tmpmax=input().split()
	if int(tmpmin)>ansmin:
		ansmin=int(tmpmin)
	if int(tmpmax)<ansmax:
		ansmax=int(tmpmax)

if (ansmax-ansmin+1)<0:
	ans=0
else:
	ans=ansmax-ansmin+1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
Ns,Ms=input().split()
N=int(Ns)
M=int(Ms)
LR=input().split()
ans=set(list(range(int(LR[0]),int(LR[1])+1)))
for i in range(M-1):
	LR=[]
	LR=input().split()
#	print("ssssssssss")
#	print(ans)
	ansy=set(list(range(int(LR[0]),(int(LR[1])+1))))
	ans=ans&ansy
ansx=list(ans)
print(len(ans))


Fixed submission:
Ns,Ms=input().split()
N=int(Ns)
M=int(Ms)
lists=[]
ansmins,ansmaxs=input().split()
ansmin=int(ansmins)
ansmax=int(ansmaxs)
for i in range(M-1):
	tmpmin,tmpmax=input().split()
	if int(tmpmin)>ansmin:
		ansmin=int(tmpmin)
	if int(tmpmax)<ansmax:
		ansmax=int(tmpmax)

if (ansmax-ansmin+1)<0:
	ans=0
else:
	ans=ansmax-ansmin+1
print(ans)
Buggy python submission (verdict: Runtime Error):
ans=0
f_a=0
b_b=0
a_b=0
str_list=[]
N= int(input())
for i in range(N):
    str=input()
    ans=ans+str.count("AB")
    if(str[-1]=="A"):
        f_a=f_a+1
    if(str[0]=="B"):
        b_b=b_b+1
    if(str[-1]=="A"and str[0]=="B"):
        a_b=a_b+1


if(f_a==N and b_b==N):
    ans=ans+n-1
elif((f_a==a_b)and(b_b==a_b)):
    ans=ans+n-1
elif(f_a< b_b):
    ans=ans+f_a
else:
    ans=ans+b_b

#print(f_a)
#print(b_b)
print(ans)


Fixed submission:
#Rs,Gs,Bs,Ns= input().split()
#R=int(Rs)
#G=int(Gs)
#B=int(Bs)
#N=int(Ns)
#ans=0
#sub_ans=0
#while(sub_ans>=N):

ans=0
f_a=0
b_b=0
a_b=0
str_list=[]
N= int(input())
for i in range(N):
    str=input()
    ans=ans+str.count("AB")
    if(str[-1]=="A"):
        f_a=f_a+1
    if(str[0]=="B"):
        b_b=b_b+1
    if(str[-1]=="A"and str[0]=="B"):
        a_b=a_b+1

if(f_a==N and b_b==N):
    ans=ans+N-1
elif((f_a==a_b)and(b_b==a_b)and(f_a!=0)):
    ans=ans+f_a-1
elif(f_a< b_b):
    ans=ans+f_a
else:
    ans=ans+b_b

#print(f_a)
#print(b_b)
print(ans)

Buggy python submission (verdict: Runtime Error):
ans=0
f_a=0
b_b=0
str_list=[]
N= int(input())
for i in range(N):
    str=input()
    ans=ans+str.count("AB")
    if(str[-1]=="A"):
        f_a=f_a+1
    if(str[0]=="B"):
        b_b=b_b+1

if(f_a==N and b_b==N):
    ans=ans+n-1
elif(f_a<= b_b):
    ans=ans+f_a
else:
    ans=ans+b_b

print(ans)


Fixed submission:
#Rs,Gs,Bs,Ns= input().split()
#R=int(Rs)
#G=int(Gs)
#B=int(Bs)
#N=int(Ns)
#ans=0
#sub_ans=0
#while(sub_ans>=N):

ans=0
f_a=0
b_b=0
a_b=0
str_list=[]
N= int(input())
for i in range(N):
    str=input()
    ans=ans+str.count("AB")
    if(str[-1]=="A"):
        f_a=f_a+1
    if(str[0]=="B"):
        b_b=b_b+1
    if(str[-1]=="A"and str[0]=="B"):
        a_b=a_b+1

if(f_a==N and b_b==N):
    ans=ans+N-1
elif((f_a==a_b)and(b_b==a_b)and(f_a!=0)):
    ans=ans+f_a-1
elif(f_a< b_b):
    ans=ans+f_a
else:
    ans=ans+b_b

#print(f_a)
#print(b_b)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
flag=0
ans=0
anslist=[]
se=0
for i in range(N):
    A.append(int(input()))
A.sort()
if N%2==0:
    anslist.append(A[-1])
    del A[-1]
else:
    anslist.append(A[0])
    del A[0]
    se=1
try:
    if se==0:
        while True:
            if flag==0:
                for i in range(2):
                    anslist.append(A[0])
                    anslist.reverse()
                    del A[0]
                flag=1
            else:
                for i in range(2):
                    anslist.append(A[-1])
                    anslist.reverse()
                    del A[-1]
                flag=0
    else:
        while True:
            if flag!=0:
                for i in range(2):
                    anslist.append(A[0])
                    anslist.reverse()
                    del A[0]
                flag=1
            else:
                for i in range(2):
                    anslist.append(A[-1])
                    anslist.reverse()
                    del A[-1]
                flag=0
 
 
except Exception as e:
    #print (anslist)
    flag=0
    while N-1>flag:
        ans=abs(anslist[flag]-anslist[flag+1])+ans
        flag=flag+1
    
    print(ans)

Fixed submission:
N= input()
nlen=len(N)
if nlen==3:
    CN=N[2]+N[1]+N[0]
    print (CN)
else:
    print (N)
Buggy python submission (verdict: Runtime Error):
import fractions
l = map(int, raw_input().split())
toshisuu= l[0]
starttoshi= l[1]
mathlist=[0]
toshilist = map(int, raw_input().split())
ans=100000000000000000000
das=0
for i in toshilist:
    counts=abs(i-starttoshi)
    if das==0:
        mathlist[0]=counts
        das=1
    else:
        mathlist.append(counts)
mathlist.sort(reverse = True)
# print mathlist
print fractions.gcd(mathlist[0], mathlist[1])


Fixed submission:
ls = raw_input().split()
l=[0,0]
l[0]=int(ls[0])
l[1]=int(ls[1])

if (l[0]%2==0)or(l[1]%2==0):
    print "No"
else:
    print "Yes"

Buggy python submission (verdict: Runtime Error):
from fractions import Fraction
l = map(int, raw_input().split())
toshisuu= l[0]
starttoshi= l[1]
mathlist=[0]
toshilist = map(int, raw_input().split())
ans=100000000000000000000
das=0
for i in toshilist:
    counts=abs(i-starttoshi)
    if das==0:
        mathlist[0]=counts
        das=1
    else:
        mathlist.append(counts)
mathlist.sort(reverse = True)
# print mathlist
print gcd(mathlist[0], mathlist[1])


Fixed submission:
ls = raw_input().split()
l=[0,0]
l[0]=int(ls[0])
l[1]=int(ls[1])

if (l[0]%2==0)or(l[1]%2==0):
    print "No"
else:
    print "Yes"
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n=raw_input().split()
ina=int(n[0])
ika=int(k[1])
ans=ina%ika
if ans==0:
    print"0"
else:
    print"1"


Fixed submission:
# -*- coding: utf-8 -*-
n=raw_input().split()
ina=int(n[0])
ika=int(n[1])
ans=ina%ika
if ans==0:
    print"0"
else:
    print"1"

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n=raw_input()
k=raw_input()
ans=n%k
if ans==0:
    print"0"
else:
    print"1"


Fixed submission:
# -*- coding: utf-8 -*-
n=raw_input().split()
ina=int(n[0])
ika=int(n[1])
ans=ina%ika
if ans==0:
    print"0"
else:
    print"1"

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n=raw_input()
k=raw_input()
inans=int(n)
ikans=int(k)
ans=inans%ikans
if ans==0:
    print"0"
else:
    print"1"


Fixed submission:
# -*- coding: utf-8 -*-
n=raw_input().split()
ina=int(n[0])
ika=int(n[1])
ans=ina%ika
if ans==0:
    print"0"
else:
    print"1"

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n=raw_input()
k=raw_input()
inans=int(n)
ikans=int(k)
ans=inans%ikans
if ans==0:
    print"0"
else:
    print"1"


Fixed submission:
# -*- coding: utf-8 -*-
n=raw_input().split()
ina=int(n[0])
ika=int(n[1])
ans=ina%ika
if ans==0:
    print"0"
else:
    print"1"
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n=raw_input().
ina=int(n)
des=0
for x in range(26):
    for y in range(16):
        ans=4*x+7*y
        if ans==ina:
            des=des+1
if des>0:
    print "Yes"
else:
    print"No"


Fixed submission:
# -*- coding: utf-8 -*-
n=raw_input()
ina=int(n)
des=0
for x in range(26):
    for y in range(16):
        ans=4*x+7*y
        if ans==ina:
            des=des+1
if des>0:
    print "Yes"
else:
    print"No"
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

r = raw_input()
r=r-0x30
if r<=1199:
    print'ABC'
elif r<=2799:
    print'ARC'
else:
    print'AGC'


Fixed submission:
# -*- coding: utf-8 -*-

a = raw_input()
r=int(a)
if r<=1199:
    print'ABC'
elif r<=2799:
    print'ARC'
else:
    print'AGC'

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a = raw_input()
if a<1200:
    print"ABC"
else:
    if a<2800:
    print"ARC"
    else:
        print"AGC"


Fixed submission:
# -*- coding: utf-8 -*-

a = raw_input()
r=int(a)
if r<=1199:
    print'ABC'
elif r<=2799:
    print'ARC'
else:
    print'AGC'
Buggy python submission (verdict: Runtime Error):
# py abc163b.py
n,m = map(int,input().split())
val = sum(list(map(int,input().split())))
if val>m:
	print(-1)
else
	print(m-val)

Fixed submission:
# py abc163b.py
n,m = map(int,input().split())
val = sum(list(map(int,input().split())))
if val>n:
	print(-1)
else:
	print(n-val)
Buggy python submission (verdict: Runtime Error):
from math import factorial
def nc2(n):
	if n<r:
		return 0
	else:
		return (n*(n-1))//2

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

done = {}
for i in range(n):
	try:
		if done[arr[i]] > -1:
			continue
	except KeyError:
		ans = 0
		for j in d.keys():
			if j == arr[i]:
				ans+= ncr(len(d[j])-1,2)
			else:
				ans+= ncr(len(d[j]),2)
		done[arr[i]] = int(ans)

for i in arr:
	print(done[i])
	



Fixed submission:
from math import factorial
def ncr(n,r):
	if n<r:
		return 0
	else:
		return factorial(n)/(factorial(n-r)*factorial(r))
n,m = map(int,input().split())
print(int(ncr(n,2)+ncr(m,2)))
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
def nc2(n):
	if n<2:
		return 0
	else:
		return (n*(n-1))//2

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

done = {}
for i in range(n):
	try:
		if done[arr[i]] > -1:
			continue
	except KeyError:
		ans = 0
		for j in d.keys():
			if j == arr[i]:
				ans+= nc2(len(d[j])-1)
			else:
				ans+= nc2(len(d[j]))
		done[arr[i]] = int(ans)

for i in arr:
	print(done[i])
	



Fixed submission:
from math import factorial
def nc2(n):
	if n<2:
		return 0
	else:
		return (n*(n-1))//2

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

pick2 = {}
pick1 = {}
for i in d.keys():
	pick2[i] = nc2(len(d[i]))
	pick1[i] = nc2(len(d[i])-1)

sum_pick2 = sum(pick2.values())

done = {}

for i in d.keys():
	done[i] = (sum_pick2 - pick2[i] + pick1[i])

for i in arr:
	print(done[i])

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
def ncr(n,r):
	if n<r:
		return 0
	else:
		return factorial(n)/(factorial(n-r)*factorial(r))

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

done = {}
for i in range(n):
	try:
		if done[arr[i]] > -1:
			continue
	except KeyError:
		ans = 0
		for j in d.keys():
			if j == arr[i]:
				ans+= ncr(len(d[j])-1,2)
			else:
				ans+= ncr(len(d[j]),2)
		done[arr[i]] = int(ans)

for i in arr:
	print(done[i])
	



Fixed submission:
from math import factorial
def nc2(n):
	if n<2:
		return 0
	else:
		return (n*(n-1))//2

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

pick2 = {}
pick1 = {}
for i in d.keys():
	pick2[i] = nc2(len(d[i]))
	pick1[i] = nc2(len(d[i])-1)

sum_pick2 = sum(pick2.values())

done = {}

for i in d.keys():
	done[i] = (sum_pick2 - pick2[i] + pick1[i])

for i in arr:
	print(done[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ARR = list(map(int, input().split()))

def calculate(n, arr):
    mod = 1000000000 + 7
    result = 0

    for i in range(n):
        for j in range(i + 1, n):
            result += (arr[i] * arr[j]) % mod

    print(result % mod)


calculate(N, ARR)


Fixed submission:
N = int(input())
ARR = list(map(int, input().split()))

def calculate(n, arr):
    mod = 1000000000 + 7
    result = 0

    rightTotal = sum(arr)
    for i in range(n-1):
        rightTotal -= arr[i]
        result += (arr[i] * rightTotal) % mod

    print(result % mod)




calculate(N, ARR)
Buggy python submission (verdict: Runtime Error):
K = int(input())

def calculate(k):

    res = 1

    n = 7

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    while n % k > 0:
        n = n % k
        n = n * 10 + 7
        res += 1

    print(res)

calculate(K)


K = int(input())

Fixed submission:
K = int(input())

def calculate(k):

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    res = 1

    m = (((10 ** res) - 1) // 9) * 7


    while m % k > 0:
        res += 1
        m = m % k
        m = m * 10 + 7

    print(res)


calculate(K)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

def calculate(k):

    res = 1

    n = 7

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == -1:
        print(-1)
        return

    while n % k > 0:
        n = n % k
        n = n * 10 + 7
        res += 1

    print(res)

calculate(K)

Fixed submission:
K = int(input())

def calculate(k):

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    res = 1

    m = (((10 ** res) - 1) // 9) * 7


    while m % k > 0:
        res += 1
        m = m % k
        m = m * 10 + 7

    print(res)


calculate(K)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

def calculate(k):

    res = 1

    n = 7

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == -1:
        print(-1)
        return

    while n % k > 0:
        n = (n % k) * 10 + 7
        res += 1

    print(res)

calculate(K)

Fixed submission:
K = int(input())

def calculate(k):

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    res = 1

    m = (((10 ** res) - 1) // 9) * 7


    while m % k > 0:
        res += 1
        m = m % k
        m = m * 10 + 7

    print(res)


calculate(K)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

def calculate(k):

    res = 1

    n = 7

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == -1:
        print(-1)
        return

    while True:
        if n % k == 0:
            break
        n = (n % k) * 10 + 7
        res += 1

    print(res)

calculate(K)

Fixed submission:
K = int(input())

def calculate(k):

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    res = 1

    m = (((10 ** res) - 1) // 9) * 7


    while m % k > 0:
        res += 1
        m = m % k
        m = m * 10 + 7

    print(res)


calculate(K)