Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')

Fixed submission:
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input().split()))
print(s[0].upper()+s[1].upper()+s[2].upper())

Fixed submission:
s = list(input().split())
print(s[0][0].upper()+s[1][0].upper()+s[2][0].upper())
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a == 'D':
    if b == 'H':
        print('D')
    else:
        print('H')
else:
    if b == 'D':
        print('D')
    else:
        print('H')

Fixed submission:
a, b = input().split()
if a == 'D':
    if b == 'H':
        print('D')
    else:
        print('H')
else:
    if b == 'D':
        print('D')
    else:
        print('H')
Buggy python submission (verdict: Time Limit Exceeded):
inf = 10**9 + 7
n = int(input())
ans = 1
for i in range(1, n+1):
    ans *= i
print(ans%inf)

Fixed submission:
from math import factorial
inf = 10**9 + 7
n = int(input())
print(factorial(n)%inf)
Buggy python submission (verdict: Runtime Error):
print(int(input) ** 2 * 3)

Fixed submission:
r = int(input())
print(3 * r ** 2)
Buggy python submission (verdict: Runtime Error):
s = input()

if s[0] == s[1] or s[1] == s[2] or s[2] = s[3] :
  print("Bad")
else:
  print("Good")

Fixed submission:
s = input()

if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] :
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

print(min([a + b, a + c, b + c])

Fixed submission:
a, b, c = map(int, input().split())

print(min([a + b, a + c, b + c]))
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter

n, m = map(int, input().split())
arr_a = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for i in range(m)] 

# aをソート
al = sorted(arr_a)

# Ciでソート
l = sorted(e, key=itemgetter(1), reverse=True)

c_arr = []

for i in range(len(l)):
    c_arr.extend( [ l[i][1] ] * l[i][0] )
    
    if len(c_arr) >= n:
        c_arr = c_arr[0:n+1]
        break

for i in range(len(c_arr)):
    if c_arr[i] > al[i]:
        al[i] = c_arr[i]
    else:
        break

print(sum(al))


    



Fixed submission:
from operator import itemgetter

n, m = map(int, input().split())
arr_a = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for i in range(m)] 

# aをソート
al = sorted(arr_a)

# Ciでソート
l = sorted(e, key=itemgetter(1), reverse=True)

c_arr = []

for i in range(len(l)):
    c_arr.extend( [ l[i][1] ] * l[i][0] )
    
    if len(c_arr) >= n:
        c_arr = c_arr[0:n]
        break

for i in range(len(c_arr)):
    if c_arr[i] > al[i]:
        al[i] = c_arr[i]
    else:
        break

print(sum(al))
Buggy python submission (verdict: Runtime Error):
a, b, c, d, e = map(int, input().split())

if e - a <= k:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())


if e - a <= k:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
b = input()

if b == "A":
  print("T")
elif b == "T":
  print("A")
elif b == "C":
  print("G")
else b == "G":
  print("C")

Fixed submission:
b = input()

if b == "A":
  print("T")
elif b == "T":
  print("A")
elif b == "C":
  print("G")
elif b == "G":
  print("C")
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

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


answer = 5000000000000000000000000000000000

e.sort(reverse=True)
for i in range(0,n-2):
    for j in e[i+1:n-1]:
        if gcd(e[i],j) < answer:
            answer = gcd(e[i],j)
            
print(answer)

Fixed submission:
a, b = map(int, input().split())

if b % a == 0:
    print(a + b)
else :
    print(b - a)
Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())

print(gcd_list([int(i) for i in input().split()]))



Fixed submission:
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())
print(gcd_list([int(i) for i in input().split()]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
e = [int(i) for i in input().split()] 

e.sort()
amari = e[0]
while e[n-2]:
    for i,v in enumerate(e):
        if v != 0:
            e[i] = v % e[0]
            e.sort()
    
print(e[n-2])

Fixed submission:
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

n = int(input())
print(gcd_list([int(i) for i in input().split()]))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h1, h2 = map(int, input().split())
l = []
l.append(h1)
l.append(h2)
for i in range(N-2):
    h = int(input())
    global l
    if len(l) < K:
        l.append(h)
    elif len(l) >= K:
        if h > min(l):
            l[l.index(min(l))] = h
        if h < max(l):
            l[l.index(max(l))] = h
print(max(l) - min(l))

Fixed submission:
D = int(input())
if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
elif D == 22:
    print('Christmas Eve Eve Eve')
Buggy python submission (verdict: Runtime Error):
n = int(input())
t, a = map(int, input().split())
e = [int(i) for i in input().split()]

temp = []
for i in e:
    temp.append(abs(t - i * 0.006 - a))
    
print(e)
print(temp)
print(temp.index(min(temp)) + 1)




Fixed submission:
X, Y = map(int, input().split())
print(X + Y // 2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
diff =50000000
num = 0
for i in range(N):
    H = int(input())
    if abs(T - H*0.006) < diff:
        num = i + 1

Fixed submission:
X, Y = map(int, input().split())
print(X + Y // 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
diff =50000000
num = 0
for i in range(1,N+1):
    H = int(input())
    if abs(T - H*0.006 - A) < diff:
        num = i

Fixed submission:
n = int(input())
t, a = map(int, input().split())
e = [int(i) for i in input().split()]

temp = []
for i in e:
    temp.append(abs(t - i * 0.006 - a))
    
print(temp.index(min(temp)) + 1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
diff =50000000
num = 0
for i in range(N):
    H = int(input())
    if abs(T - H*0.006 - A) < diff:
        num = i + 1

Fixed submission:
n = int(input())
t, a = map(int, input().split())
e = [int(i) for i in input().split()]

temp = []
for i in e:
    temp.append(abs(t - i * 0.006 - a))
    
print(temp.index(min(temp)) + 1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
H = [int(input()) for i in range(N)]
print(H.index(min(abs(int(T - H[i] * 0.006 - A)) for i in range(N))))

Fixed submission:
n = int(input())
t, a = map(int, input().split())
e = [int(i) for i in input().split()]

temp = []
for i in e:
    temp.append(abs(t - i * 0.006 - a))
    
print(temp.index(min(temp)) + 1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
H = [int(input()) for i in range(N)]
print(H.index(min(abs(int(T - H[i] * 0.006) - A)) for i in range(N)))

Fixed submission:
n = int(input())
t, a = map(int, input().split())
e = [int(i) for i in input().split()]

temp = []
for i in e:
    temp.append(abs(t - i * 0.006 - a))
    
print(temp.index(min(temp)) + 1)
Buggy python submission (verdict: Runtime Error):
n, m, X, Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

x.append(X)
y.append(Y)

if max(x) < min(y):
    print("No War")
else :
    print("War")

Fixed submission:
a, b, c = map(int, input().split())
array = [a, b, c]
array.sort()
print(array[-1] * 10 + array[0] + array[1])
Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
for s in S:
    if s == o:
        count += 1
print(700 + count*100)

Fixed submission:
S = input()
count = 0
for s in S:
    if s == 'o':
        count += 1
print(700 + count*100)
Buggy python submission (verdict: Runtime Error):
x, a, b = int(input().split())

if abs(x - a) < abs(x- b):
    print("A")
else :
    print("B")

Fixed submission:
x, a, b = map(int,input().split())

if abs(x - a) < abs(x- b):
    print("A")
else :
    print("B")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a % 3 == 0 or b % 3 == 0 or (a*b) % == 0 :
  print("Possible")
else:
  print("Impossible")

Fixed submission:
a, b = map(int, input().split())

if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0 :
  print("Possible")
else:
  print("Impossible")
Buggy python submission (verdict: Runtime Error):
s = input()
count = 0
for i in s:
    if int(i) == 1:
        count += 1
print(count)

Fixed submission:
a, b, c = map(int, input().split())
if (10*b + c) % 4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a == "H" and b == "H":
  print("H")
elif a == "H" and b == "D":
  print("D")
elif a == "D" and b == "H":
  print("D")
elif a == "D" and b == "D":
  print("H")

Fixed submission:
a, b = map(str, input().split())

if a == "H" and b == "H":
  print("H")
elif a == "H" and b == "D":
  print("D")
elif a == "D" and b == "H":
  print("D")
elif a == "D" and b == "D":
  print("H")
Buggy python submission (verdict: Runtime Error):
n = int(input())

print(N * 800 - N // 15 * 200)

Fixed submission:
n = int(input())

print(n * 800 - (n // 15) * 200)
Buggy python submission (verdict: Runtime Error):
a, op, b = map(str, input().split())

a = int(a)
b = int(b)

if op == "+":
  print(a + b)
eles: 
  print(a - b)

Fixed submission:
a, op, b = map(str, input().split())

a = int(a)
b = int(b)

if op == "+":
  print(a + b)
else: 
  print(a - b)
Buggy python submission (verdict: Runtime Error):
c = input()

if c == "a" or c == "i" or c == "u" ro c == "e" or c == "o":
  print("vowel")
else:
  print("consonant")

Fixed submission:
c = input()

if c == "a" or c == "i" or c == "u" or c == "e" or c == "o":
  print("vowel")
else:
  print("consonant")
Buggy python submission (verdict: Runtime Error):
x, k, d = map(int, input().split())

x = abs(x)
k = k - int(x/d)
if k <= 0:
    print(x - k * d)
    exit()
    
a = x - int(x/d)*d
if k % 2 == 0:
    ans = a
else:
    ans = abs(a - d)

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

s = input()
if s[1] == 'R':
    print(s.count('R'))
else:
    if s[0] == 'S' and s[2] == 'S':
        print(0)
    else:
        print(1)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

x, k, d = map(int, input().split())
p_lst = list(range(0, k*d + 1, d))
n_lst = list(map(lambda x: -x, p_lst[1:]))
potential_pos = n_lst + p_lst
potential = [x + y for y in potential_pos]
potential.sort()
print(min(map(lambda x: max(x, -x), potential[0::2])))

Fixed submission:
x, k, d = map(int, input().split())

x = abs(x)
kk = k - int(x/d)
if kk <= 0:
    print(x - k * d)
    exit()

a = x - int(x/d)*d
if kk % 2 == 0:
    ans = a
else:
    ans = abs(a - d)

print(ans)
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
xy = 0
for i in range(n):
  a, b = map(int, input().split())
  xy += xi**2 + yi**2 <= d**2 for xi, yi in xy

print(xy)

Fixed submission:
n, d = map(int, input().split())
x, y = [], []
for i in range(n):
  a, b = map(int, input().split())
  x.append(a)
  y.append(b)

count = 0
for xi, yi in zip(x, y):
  if xi**2 + yi**2 <= d**2:
    count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
xy = []
for i in range(n):
  a, b = map(int, input().split())
  x.append([a, b])
 
count = 0
for xy in xy:
  count += xy[0]**2 + xy[1]**2 <= d**2
 
print(count)

Fixed submission:
n, d = map(int, input().split())
x, y = [], []
for i in range(n):
  a, b = map(int, input().split())
  x.append(a)
  y.append(b)

count = 0
for xi, yi in zip(x, y):
  if xi**2 + yi**2 <= d**2:
    count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
xy = []
for i in range(n):
  a, b = map(int, input().split())
  x.append([a, b])
 
count = 0
for xi, yi in xy:
  count += xi**2 + yi**2 <= d**2
 
print(count)

Fixed submission:
n, d = map(int, input().split())
x, y = [], []
for i in range(n):
  a, b = map(int, input().split())
  x.append(a)
  y.append(b)

count = 0
for xi, yi in zip(x, y):
  if xi**2 + yi**2 <= d**2:
    count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n, *s = map(int, open(0).read().split())

c0 = s.count('AC')
c1 = s.count('WA')
c2 = s.count('TLE')
c3 = n - (c0 + c1 + c2)

print('AC x ' + str(c0), 'WA x ' + str(c1), sep='\n')
print('TLE x ' + str(c2), 'RE x ' + str(c3), sep='\n')

Fixed submission:
n, *s = open(0).read().split()
n = int(n)

c0 = s.count('AC')
c1 = s.count('WA')
c2 = s.count('TLE')
c3 = n - (c0 + c1 + c2)

print('AC x ' + str(c0), 'WA x ' + str(c1), sep='\n')
print('TLE x ' + str(c2), 'RE x ' + str(c3), sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

try:
    idx =a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]

    if ans <= 10**18:
        print(ans)
    else:
        print('-1')

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

try:
    idx = a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]
        if ans > 10**18:
            print('-1')
            exit()

    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

def multi_lst(lst):
    ans = lst[0]
    for i in range(1, len(lst)):
        ans *= lst[i]
    
    return ans
try:
    idx =a.index(0)
    print(0)

except ValueError:
    
    ans = multi_lst(a)

    if ans <= 10**18:
        print(ans)
    else:
        print('-1')

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

try:
    idx = a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]
        if ans > 10**18:
            print('-1')
            exit()

    print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

def multi_lst(lst):
    ans = lst[0]
    for i in range(1, len(lst)):
        ans *= lst[i]
    
    return ans
if a.index(0):
    print(0)
    exit()
else:
    ans = multi_lst(a)

if ans <= 10**18:
    print(ans)
else:
    print('-1')

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

try:
    idx = a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]
        if ans > 10**18:
            print('-1')
            exit()

    print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

def multi_lst(lst):
    ans = lst[0]
    for i in range(1, len(lst)):
        ans *= lst[i]
    
    return ans
if a.index(0):
    print(0)
else:
    ans = multi_lst(a)
    
if ans <= 10**18:
    print(ans)
else:
    print('-1')

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

try:
    idx = a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]
        if ans > 10**18:
            print('-1')
            exit()

    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

def multi_lst(lst):
    ans = lst[0]
    for i in range(1, len(lst)):
        ans *= lst[i]
    
    return ans

ans = multi_lst(a)
if ans <= 10**18:
    print(ans)
else:
    print('-1')

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

try:
    idx = a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]
        if ans > 10**18:
            print('-1')
            exit()

    print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())

def f(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
u = f(k)

def yakusu(n):
    u = [n]
    i = 2
    while i <= n/2:
        if n%i == 0:
            u.append(i)
        i += 1
    return sorted(list(u))

v = yakusu(k-1)
del v[-1]

if k==1:
    print(1)
elif k%2==0 or len(u)>1:
    print(-1)
else:
    for i in v:
        if int('7'*i)%k==0:
            print(i)
            break
    else:
        print(k-1)

Fixed submission:
x = int(input())

if x >= 30:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
q = int(input())
u = []
for i in range(q):
    u.append(tuple(map(int,input().split())))

from collections import Counter
z = Counter(a)

sum = sum(a)
for i in range(q):
    try:
        rev = z.pop(u[i][0])
        sum+=(u[i][1]-u[i][0])*rev
        print(sum)
    except KeyError:
        print(sum)
    if u[i][1] in z:
        z[u[i][1]]+=rev
    else:
        z[u[i][1]]=rev

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
q = int(input())
u = []
for i in range(q):
    u.append(tuple(map(int,input().split())))

from collections import Counter
z = Counter(a)

sum = sum(a)
for i in range(q):
    try:
        rev = z.pop(u[i][0])
        sum+=(u[i][1]-u[i][0])*rev
        print(sum)
        if u[i][1] in z:
            z[u[i][1]]+=rev
        else:
            z[u[i][1]]=rev
    except KeyError:
        print(sum)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
q = int(input())
u = []
for i in range(q):
    u.append(tuple(map(int,input().split())))

from collections import Counter
z = Counter(a)

sum = sum(a)
for i in range(q):
    try:
        rev = z.pop(u[i][0])
        sum+=(u[i][1]-u[i][0])*rev
        print(sum)
    except KeyError:
        print(sum)
    if u[i][1] in z.keys():
        z[u[i][1]]+=rev
    else:
        z[u[i][1]]=rev

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
q = int(input())
u = []
for i in range(q):
    u.append(tuple(map(int,input().split())))

from collections import Counter
z = Counter(a)

sum = sum(a)
for i in range(q):
    try:
        rev = z.pop(u[i][0])
        sum+=(u[i][1]-u[i][0])*rev
        print(sum)
        if u[i][1] in z:
            z[u[i][1]]+=rev
        else:
            z[u[i][1]]=rev
    except KeyError:
        print(sum)
Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
p = list(map(int,input().split()))
p.sort()
b = []
for i in range(1,101):
    if not (i in p):
        b.append((i,abs(i-x)))

b.sort(key=lambda x:x[1])
print(b[0][0])

Fixed submission:
x,n=map(int,input().split())
p = list(map(int,input().split()))
p.sort()
b = []
for i in range(0,102):
    if not (i in p):
        b.append((i,abs(i-x)))

b.sort(key=lambda x:x[1])
print(b[0][0])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
import math
b = [math.log10(i) for i in a]    
if sum(b)>18:
    print(-1)
else:
    z = 1
    for i in a:
        z*=i
    if z>10**18:
        print(-1)
    else:
        print(z)

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

if sorted(a)[0]==0:
    print(0)
else:
    import math
    b = [math.log10(i) for i in a if i!=0]    
    if sum(b)>18:
        print(-1)
    else:
        z = 1
        for i in a:
            z*=i
        if z>10**18:
            print(-1)
        else:
            print(z)
Buggy python submission (verdict: Runtime Error):
2 1 1 3

Fixed submission:
a,b,c,k = map(int,input().split())

if k<=a:
    print(k)
elif a<k<=a+b:
    print(a)
else:
    print(a-(k-(a+b)))
Buggy python submission (verdict: Runtime Error):
s = input()

if s = 'ABC':
    print('ARC')
else:
    print('ABC')

Fixed submission:
s = input()

if s == 'ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
x = int(input())

z = []
u = []
for a in range(1,100):
    for b in range(-100,100):
        z.append(a**5-b**5)
        u.append((a,b))

for i in range(10**9+1):
    if z[i] == x:
        print(u[i][0],u[i][1])
        break

Fixed submission:
x = int(input())

from collections import deque
z = []
u = deque([])
for a in range(0,1000):
    for b in range(-1000,1000):
        z.append(a**5-b**5)
        u.append((a,b))

for i in range(10**6+1):
    if z[i] == x:
        print(u[i][0],u[i][1])
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a3 = list(set(a))

z = []
for i in range(len(a3)):
     z.append(a.count(a3[i]))

q = 1
for i in z:
    q += i*(i-1)/2

for j in range(n):
    count = q
    count -= z[a3.index(a[j])]
    print(int(count))

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))

u = collections.Counter(a)

sume = 0
for i in u.values():
    sume += int(i*(i-1)/2)

for k in range(n):
    s = u[a[k]]
    print(sume-s+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a3 = list(set(a))

z = []
for i in range(len(a3)):
     z.append(a.count(a3[i]))

q = 1
for i in z:
    q += i*(i-1)/2

for j in range(n):
    count = q
    count -= z[a3.index(a[j])]
    print(int(count))

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))

u = collections.Counter(a)

sume = 0
for i in u.values():
    sume += int(i*(i-1)/2)

for k in range(n):
    s = u[a[k]]
    print(sume-s+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a3 = list(set(a))

z = []
for i in range(len(a3)):
     z.append(a.count(a3[i]))

for j in range(n):
    count = 1
    count += sum(list(map(lambda x:int(x*(x-1)/2) ,z)))
    count -= z[a3.index(a[j])]
    print(int(count))

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))

u = collections.Counter(a)

sume = 0
for i in u.values():
    sume += int(i*(i-1)/2)

for k in range(n):
    s = u[a[k]]
    print(sume-s+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a3 = list(set(a))

z = []
for i in range(len(a3)):
     u = a.count(a3[i])
     z.append(u)

for j in range(n):
    count = 1
    for i in z:
        count += i*(i-1)/2
    count -= z[a3.index(a[j])]
    print(int(count))

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))

u = collections.Counter(a)

sume = 0
for i in u.values():
    sume += int(i*(i-1)/2)

for k in range(n):
    s = u[a[k]]
    print(sume-s+1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a2 = sorted(a) 
a3 = list(set(a2))

z = []
for i in range(len(a3)):
     u = a.count(a3[i])
     z.append(u)


for j in range(n):
    count = 1
    for i in z:
        count += i*(i-1)/2
    count -= z[a3.index(a[j])]
    print(int(count))

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))

u = collections.Counter(a)

sume = 0
for i in u.values():
    sume += int(i*(i-1)/2)

for k in range(n):
    s = u[a[k]]
    print(sume-s+1)