Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

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

n,k = na()
mod = 10**9 + 7
ans = 1
for i in range(k, n+1):
  ans += (2*n-i+1)*i//2-i*(i-1)//2+1
  ans %= mod

print(ans)

Fixed submission:
R = int(input())
import math
print(2*R*math.pi)
Buggy python submission (verdict: Runtime Error):
a = input()


if  a  == "TUE":
  print(5)
elif a  == "WED":
  print(4)
elif a  == "THU":
  print(3)
elif a  == "FRI":
  print(2)
elif a  == "SAT":
  print(1)
elif a  == "SUN":
  print(0)
else a  == "MON":
  print(6)

Fixed submission:
a = input()


if  a  == "TUE":
  print(5)
elif a  == "WED":
  print(4)
elif a  == "THU":
  print(3)
elif a  == "FRI":
  print(2)
elif a  == "SAT":
  print(1)
elif a  == "SUN":
  print(7)
else:
  print(6)

Buggy python submission (verdict: Runtime Error):
a = input()

if a == "SUN":
  print(0)
elif a  == "MON":
  print(6)
elif a  == "TUE":
  print(5)
elif a  == "WED":
  print(4)
elif a  == "THU":
  print(3)
elif a  == "FRI":
  print(2)
else a  == "sat":
  print(1)

Fixed submission:
a = input()


if  a  == "TUE":
  print(5)
elif a  == "WED":
  print(4)
elif a  == "THU":
  print(3)
elif a  == "FRI":
  print(2)
elif a  == "SAT":
  print(1)
elif a  == "SUN":
  print(7)
else:
  print(6)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

result = ''
for i in range(0,N):
  num = ord(S[i])
  new = chr(num+2)
  result += new

print(result)

Fixed submission:
N = int(input())
S = list(input())

result = ''
for i in range(0,len(S)):
  num = ord(S[i])
  if num + N > 90:
    p = num + N - 90 + 64
  else:
    p = num + N
  new = chr(p)
  result += new

print(result)
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() 

r = list(input())
print(r*r)

Fixed submission:
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() 

r = ni()
print(r*r)
Buggy python submission (verdict: Runtime Error):
N = int(input())

f = 0
for i in range(1,10):
  for j in range(1,10):
    if i*j == N:
      f = 1
      break
  if f == 1:
    break
if f == 0:
  print("NO")
else:
  print("YES")

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

print(a[0]*a[1] if a[0] <= 9 and a[1] <= 9 else -1)

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

print(a[0]*a[1] if a[0],a[1]<=9 else -1)

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

print(a[0]*a[1] if a[0] <= 9 and a[1] <= 9 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

stdin = sys.stdin

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

n,k = na()
h = na()

A = [0]+[float("inf")]*(n-1)

for i in range(1,n):
  for j in range(max(0, i-k), i):
    A[i] = min(A[i],A[j]+abs(h[i]-h[j]))

print(A[-1])

Fixed submission:
import sys

stdin = sys.stdin

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

n,k = na()
h = na()

A = [0]+[float("inf")]*(n-1)

for i in range(1,n):
  for j in range(max(0, i-k), i):
    A[i] = min(A[i],A[j]+abs(h[i]-h[j]))

print(A[-1])
Buggy python submission (verdict: Runtime Error):
A B C = list(map(int, input().split()))
a = A B C
print("Yes" if a[0]== a[2] == 5 and a[1] == 7 else "No")

Fixed submission:
a = list(map(int, input().split()))
print("YES" if a.count(5) == 2 and a.count(7) == 1 else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
a, b, n = map(int, input().split())
ans = -float('inf')
for i in range(n, 0, -1):
    f1 = (a*i)//b
    f2 = i//b
    tmp = f1-(a*f2)
    if ans < tmp:
        ans = tmp
print(ans)

Fixed submission:
import math
a, b, n = map(int, input().split())
ans = -float('inf')
n = min(b-1, n)
f1 = math.floor(a*n/b)
f2 = math.floor(n/b)
ans = f1-(a*f2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = [input() for i in range(n)]
ans = []
cnt = 0
for i in range(n):
    if S[i] not in ans:
        ans.append(S[i])
        cnt += 1

print(cnt)

Fixed submission:
import collections
n = int(input())
S = [input() for i in range(n)]
ans = collections.Counter(S)
print(len(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
ans = [0 for i in range(n)]
for i in range(n-1):
    ans[A[i]-1] += 1

print(ans)


Fixed submission:
import math
r = int(input())
s = 2 * r * math.pi
print(s)

Buggy python submission (verdict: Runtime Error):
import.math
x= int(input())
y = 2*math.pi*x
print(y)

Fixed submission:
import math
r = int(input())
s = 2 * r * math.pi
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for k in range(1, k+1):
            ans += math.gcd(math.gcd(i, j), k)

print(ans)

Fixed submission:
import math
n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        t = math.gcd(i, j)
        for k in range(1, n+1):
            ans += math.gcd(t, k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
cnt = 0
while True:
    cnt += 1
    if k**cnt <= n and n < k**(cnt+1):
        print(cnt+1)
        break

Fixed submission:
n, k = map(int, input().split())
for i in range(n):
    if k**i <= n and n < k**(i+1):
        print(i+1)
        break
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
d = list(map(int, input().split()))
a = 0
for x in itertools.combinations(d, 2):
    a += x[0]*x[1]
print(a)

Fixed submission:
a, b = map(int, input().split())
if a - 2*b < 0:
    print("0")
else:
    print(a-2*b)
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np 
n = int(input())
A = list(map(int, input().split()))
gcd = 0
if n == 1:
    print(A[0])

else:
    #最大公約数を求める
    for i in range(n-1):
        if i == 0:
            gcd = math.gcd(A[i], A[i+1])
        else:
            gcd = math.gcd(gcd, A[i+1])

    prod = np.prod(A)

    #最小公倍数
    lcm = prod / gcd

    #逆数
    ans = 0
    #分子の総和を求める
    for i in range(n):
        ans += lcm/A[i]
    ans /= lcm
    ans = 1 / ans

    print(ans)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 0
for x in A:
    ans += 1/x
print(1/ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
tmp = ord(s[k])
tmp1 = (chr(tmp+32))
ans = []

for i in range(len(s)):
    if i == k:
        ans.append(tmp1)
    else:
        ans.append(s[i])

print("".join(map(str, ans)))

Fixed submission:
n, k = map(int, input().split())
s = input()
tmp = ord(s[k-1])
tmp1 = (chr(tmp+32))
ans = []

for i in range(len(s)):
    if i == k-1:
        ans.append(tmp1)
    else:
        ans.append(s[i])

print("".join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
S = input()
s01 = int(S[0]+S[1])
s23 = int(S[2]+S[3])
if (0 < s01 and s01 <= 12) and (0 < s23 and s23 <= 12):
    print('AMBIGUOUS')

elif (0 < s01 and s01 <= 12) and (s23 > 12 or s23 == 0):
    print('MMYY')

elif (s01 > 12 or s12 == 0) and (0 < s23 and s23 <= 12):
    print('YYMM')
else:
    print('NA')


Fixed submission:
S = input()
s01 = int(S[0]+S[1])
s23 = int(S[2]+S[3])
if (0 < s01 and s01 <= 12) and (0 < s23 and s23 <= 12):
    print('AMBIGUOUS')

elif (0 < s01 and s01 <= 12) and (s23 > 12 or s23 == 0):
    print('MMYY')

elif (s01 > 12 or s01 == 0) and (0 < s23 and s23 <= 12):
    print('YYMM')
else:
    print('NA')
Buggy python submission (verdict: Runtime Error):
x1, y1, x2, y2, = map(int, input().split())
abs_x = abs(x2-x1)
abs_y = abs(y2-y1)


if x1 >= x2 and y2 > y1:
    x3 = x2-abs_x-1
    x4 = x1-abs_x-1
    y3 = y2+abs_y-1
    y4 = y1+abs_y-1

elif x1 >= x2 and y1 > y2:
    x3 = x2-abs_x+1
    x4 = x1-abs_x+1
    y3 = y2+abs_y-1
    y4 = y1+abs_y-1

elif x2 >= x1 and y2 > y1:
    x3 = x2-abs_x+1
    x4 = x1-abs_x+1
    y3 = y2+abs_y+1
    y4 = y1+abs_y+1

elif x2 >= x1 and y1 > y2:
    x3 = x2-abs_x-1
    x4 = x1-abs_x-1
    y3 = y2+abs_y+1
    y4 = y1+abs_y+1
print(x3, y3, x4, y4)

Fixed submission:
x1, y1, x2, y2, = map(int, input().split())
x = x2-x1
y = y2-y1

x3 = x2-y
y3 = y2+x
x4 = x1-y
y4 = y1+x

print(x3, y3, x4, y4)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())

ans = []
for i in range(a, b+1):
    if i < a+k :
        if i not in ans:
            ans.append(i)
        
    elif b-k < i:
        if i not in ans:
            ans.append(i)
    
for i in range(len(ans)):
    print(ans[i])

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

ans = []
for i in range(a, a+k):
    if i not in ans and (a <= i and i <= b):
        ans.append(i)

for i in range(b-k+1, b+1):
    if i not in ans and (a <= i and i <= b):
        ans.append(i)
    
for i in range(len(ans)):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = [0] * n

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

sum = 1

for i in a:
    sum *= i

if (sum > 1000000000000000000):
    print(-1)
else:
    print(sum)


Fixed submission:
n = int(input())

a = [0] * n

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

sum = 1
cnt = 0
if 0 in a:
    print(0)
else:
    for i in a:
        sum *= i
        if sum > 1000000000000000000:
            print(-1)
            cnt = 1
            break
    if cnt == 0:
        print(sum)
Buggy python submission (verdict: Runtime Error):
b = [0] * 9


def hantei():
    for i in range(3):
        if b[i * 3] == 1 and b[i * 3 + 1] == 1 and b[i * 3 + 2] == 1:
            return True
    for i in range(3):
        if b[i * 3] == 1 and b[(i+1) * 3 ] == 1 and b[(i+2) * 3 ] == 1:
            return True
    if b[0] == 1 and b[4] == 1 and b[8] == 1:
        return True
    if b[2] == 1 and b[5] == 1 and b[6] == 1:
        return True
    return False


a = [0] * 9
[a[0], a[1], a[2]] = input().split()
[a[3], a[4], a[5]] = input().split()
[a[6], a[7], a[8]] = input().split()
a = [int(i) for i in a]

n = int(input())

for i in range(n):
    c = int(input())
    for j in range(len(a)):
        if a[j] == c:
            b[j] = 1

if (hantei()):
    print("Yes")
else:
    print("No")


Fixed submission:
b = [0] * 9


def hantei():
    for i in range(3):
        if b[i * 3] == 1 and b[i * 3 + 1] == 1 and b[i * 3 + 2] == 1:
            return True
    for i in range(3):
        if b[i] == 1 and b[i + 3] == 1 and b[i + 6] == 1:
            return True
    if b[0] == 1 and b[4] == 1 and b[8] == 1:
        return True
    if b[2] == 1 and b[4] == 1 and b[6] == 1:
        return True
    return False


a = [0] * 9
[a[0], a[1], a[2]] = input().split()
[a[3], a[4], a[5]] = input().split()
[a[6], a[7], a[8]] = input().split()
a = [int(i) for i in a]

n = int(input())

for i in range(n):
    c = int(input())
    for j in range(len(a)):
        if a[j] == c:
            b[j] = 1

if (hantei()):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
def all_sum(val):
    sum = 0
    for i in range(val):
        sum = sum + i + 1
    return sum / val


[n, k] = input().split()

p = input().split()

k = int(k)
n = int(n)
p = [int(i) for i in p]

total = 0
max_total = 0
for i in range(k):
    total = total + p[i]
max_total = total
max_ind = 0

for i in range(n - k):
    total = total - p[i] + p[i + k]
    if(max_total < total):
        max_total = total
        max_ind = i + 1
ans = 0
for i in range(k):
    ans = ans + all_sum(p[i + max_ind])

print("{:.8f}".format(ans))


Fixed submission:
def all_sum(val):
    sum = 0
    for i in range(val):
        sum = sum + i + 1
    return sum / val


[n, k] = input().split()

p = input().split()

k = int(k)
n = int(n)
p = [int(i) for i in p]

total = 0
max_total = 0
for i in range(k):
    total = total + p[i]
max_total = total
max_ind = 0

for i in range(n - k):
    total = total - p[i] + p[i + k]
    if(max_total < total):
        max_total = total
        max_ind = i + 1
ans = 0
for i in range(k):
    ans = ans + all_sum(p[i + max_ind])

print("{:.8f}".format(ans))
Buggy python submission (verdict: Runtime Error):
w, h, x, y = map(int, input().split())
print(float(w) * float(h) / 2, 1 if w/2 == x & h / 2 == y else 0)


Fixed submission:
w, h, x, y = map(int, input().split())
print(float(w) * float(h) / 2, 1 if (w/2 == x) & (h / 2 == y) else 0)
Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce


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


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

x_arr = [0] * n

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

for i in range(len(x_arr)):
    x_arr[i] = abs(x_arr[i] - x)
print(gcd_list(x_arr))


Fixed submission:
from fractions import gcd
from functools import reduce


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


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

x_arr = [0] * n

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

for i in range(len(x_arr)):
    x_arr[i] = abs(x_arr[i] - x)
print(gcd_list(x_arr))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

K = int(input())

gcd_sum = 0
target_range = range(1, K + 1)

for a in target_range:
  for b in target_range:
    for c in target_range:
      gcd_sum += reduce(math.gcd, (a, b, c))

print(gcd_sum)

Fixed submission:
import math
from functools import reduce
import itertools

K = int(input())

gcd_sum = 0
target_range = range(1, K + 1)
for comb in itertools.combinations_with_replacement(target_range, 3):
  a, b, c = comb[0], comb[1], comb[2]
  gcd = reduce(math.gcd, comb)
  
  if a == b == c:
    gcd_sum += gcd
  elif a != b != c:
    gcd_sum += gcd * 6
  else:
    gcd_sum += gcd * 3


print(gcd_sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

cnt = 0
for i in range(1, N + 1):
  target = P[:i]
  if target[-1] == min(target):
    cnt += 1
  
print(cnt)

Fixed submission:
N = int(input())

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

cnt = 0
min_num = P[0]
for num in P:
  if num == min_num:
    cnt += 1
  elif num < min_num:
    cnt += 1
    min_num = num
  
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())
print((A * B) // math.gcd(A, B))

Fixed submission:
import fractions

A, B = map(int, input().split())
print((A * B) // fractions.gcd(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 1

for i in range(N):
    ans = ans * A[i]
'''
for i in range(N):
    if ans > 10**18+1:
        break
    else:
        ans = ans * A[i]
'''
if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 1

for i in range(N):
    if ans > 10**18+1:
        break
    else:
        ans = ans * A[i]

if 0 in A:
    print(0)
elif ans > 10**18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from fractions import Fraction

A, B = map(str,input().split())
#print(A,B)

A = float(A)
B = float(B)

#B = format(B,"f")
#print(A,B)

X = Fraction(A,B)
Y = Fraction(B,A)

Z = X * Y

print(math.floor(Z))


Fixed submission:
from decimal import Decimal
A,B = map(Decimal,input().split())
print(int(A*B))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
A = list(map(int,input().split()))
position = 0
for i in range(K):
    position = A[position]
    position -= 1

actual_position = position + 1
print(actual_position)

Fixed submission:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    loop = {i: -1 for i in range(N)}
    loop[0] = 0
    position = 0

    for i in range(N + 1):
        position = A[position] - 1
        if loop[position] != -1:
            ini = loop[position]
            cycle = i + 1 - ini
            break
        else:
            loop[position] = i + 1

    M = (K - ini) % cycle

    answer = 0
    root = min(K, M + ini)
    for j in range(root):
        answer = A[answer] - 1

    answer += 1
    print(answer)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
A,B,N = map(int,input().split())
ans = []
if N < 15:
    for x in range(N+1):
        tmp = (A * x // B) - A * (x//B)
        ans.append(tmp)
        #print(tmp)
else:
    for x in range(N-1000,N+1):
        tmp = (A * x // B) - A * (x//B)
        ans.append(tmp)
        #print(tmp)
print(max(ans))

Fixed submission:
K = int(input())
A,B = map(int,input().split())
ans = 'NG'
for i in range(A,B+1):
    if i % K == 0:
        ans = 'OK'
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
ans = []
if N < 15:
    for x in range(N+1):
        tmp = (A * x // B) - A * (x//B)
        ans.append(tmp)
        #print(tmp)
else:
    for x in range(N-10000000,N+1):
        tmp = (A * x // B) - A * (x//B)
        ans.append(tmp)
        #print(tmp)
print(max(ans))

Fixed submission:
A,B,N = map(int,input().split())
if N >= (B-1):
        x = B -1
else:
        x = N
print((A * x // B) - A * (x//B))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
ans = []
for x in range(N//2,N+1):
    tmp = (A * x // B) - A * (x//B)
    ans.append(tmp)
print(max(ans))

Fixed submission:
A,B,N = map(int,input().split())
if N >= (B-1):
        x = B -1
else:
        x = N
print((A * x // B) - A * (x//B))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
ans = []
for x in range(N+1):
    tmp = (A * x // B) - A * (x//B)
    ans.append(tmp)
print(max(ans))

Fixed submission:
A,B,N = map(int,input().split())
if N >= (B-1):
        x = B -1
else:
        x = N
print((A * x // B) - A * (x//B))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
ans = [0]*N

for i in A:
    ans[i-1] += 1

for j in ans:
    print(j)


Fixed submission:
import math
R = int(input())
print(R * 2 * math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

for i in range(1,N+1):
    print(A.count(i))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = [0]*N

for i in A:
    ans[i-1] += 1

for j in ans:
    print(j)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N[0] == '7' or N[1] == '7' or N[2] == '7':
    print('Yes')
else:
    print('No')

Fixed submission:
N = str(input())
if N[0] == '7' or N[1] == '7' or N[2] == '7':
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
from math import math

K = int(input())
cnt = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += gcd(gcd(i,j),k)
print(cnt)

Fixed submission:
from math import gcd

K = int(input())
cnt = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += gcd(gcd(i,j),k)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
cnt = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += math.gcd(math.gcd(i,j),k)
print(cnt)

Fixed submission:
from math import gcd

K = int(input())
cnt = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += gcd(gcd(i,j),k)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
cnt = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += math.gcd(i, math.gcd(j,k))
print(cnt)

Fixed submission:
from math import gcd

K = int(input())
cnt = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            cnt += gcd(gcd(i,j),k)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                if (j - i) != (k - j):
                    cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = str(input())
ans = S.count('R') * S.count('G') * S.count('B')
for i in range(N-1):
    for j in range(i+1,N):
        k = j + (j - i)
        if k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)

ans = {}
key = list(C.keys())
val = list(C.values())

for i in range(len(key)):
    ans[key[i]] = val[i] * (val[i]-1) //2

ans_val = [int(_) for _ in list(ans.values())]

for j in range(N):
    print(sum(ans_val) - (C[A[j]] - 1) )

Fixed submission:
import collections
N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)

ans = 0
for i in C.values():
    ans += int(0.5* i * (i-1))
for j in A:
    print(ans-C[j]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)

ans = {}
key = list(C.keys())
val = list(C.values())

for i in range(len(key)):
    ans[key[i]] = val[i] * (val[i]-1) //2

ans_val = [int(_) for _ in list(ans.values())]

for j in range(N):
    print(sum(ans_val) - (C[A[j]] - 1) )


Fixed submission:
import collections
N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)

ans = 0
for i in C.values():
    ans += int(0.5* i * (i-1))
for j in A:
    print(ans-C[j]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)

ans = {}
key = C.keys()
val = C.values()
key = list(key)
val = list(val)

for i in range(len(key)):
    ans[key[i]] = val[i] * (val[i]-1) //2

ans_key = [ans.keys()]
ans_val = list(ans.values())
ans_val = [int(_) for _ in ans_val]

for j in range(N):
    print(sum(ans_val) - (C[A[j]] - 1) )


Fixed submission:
import collections
N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)

ans = 0
for i in C.values():
    ans += int(0.5* i * (i-1))
for j in A:
    print(ans-C[j]+1)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
ans = -1

for i in range(1,10**4+1):
    if int(i * 0.08) == A and int(i * 0.10) == B:
        ans = i
        break
print(ans)



Fixed submission:
S = str(input())
if S == 'AAA' or S == 'BBB':
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
li=[0]*N
for i in range(M):
    si,ci=map(int,input().split())
    if li[si-1] != 0 and li[si-1] !=ci:
        print(-1)
        exit(0)
    if si==1 and ci==0:
        if N>1:
            print(-1)
            exit(0)
    li[si-1]=ci
if N>1 and li[0]==0:
    li[0]=1
for i in range(N):
    print(li[i],end="")


Fixed submission:
N = int(input())
print( -(-N // 2))
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
li=[0]*n
for i in range(M):
    si,ci=map(int,input().split())
    if li[si-1] != 0 and li[si-1] !=ci:
        print(-1)
        exit(0)
    if si==1 and ci==0:
        if N>1:
            print(-1)
            exit(0)
    li[si-1]=ci
if N>1 and li[0]==0:
    li[0]=1
for i in range(N):
    print(li[i],end="")


Fixed submission:
N,M=map(int,input().split())
li=[0]*N
for i in range(M):
    si,ci=map(int,input().split())
    if li[si-1] != 0 and li[si-1] !=ci:
        print(-1)
        exit(0)
    if si==1 and ci==0:
        if N>1:
            print(-1)
            exit(0)
    li[si-1]=ci
if N>1 and li[0]==0:
    li[0]=1
for i in range(N):
    print(li[i],end="")