Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
import time

def gcd(*numbers):
    return reduce(math.gcd, numbers)

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 += gcd(i, j, k)
print(ans)


Fixed submission:
import math
from functools import reduce
import time

def gcd(*numbers):
    return reduce(math.gcd, numbers)

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 += gcd(i, j, k)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
K = int(input())
table = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
c = 9
result = []
for i in table:
  runrun = i
  if runrun[-1] == '0':
    table.extend([runrun + str(int(runrun[-1])), 
                   runrun + str(int(runrun[-1])+1)])
    c += 2
  elif runrun[-1] == '9':
    table.extend([runrun + str(int(runrun[-1])-1), 
                   runrun + str(int(runrun[-1]))])
    c += 2
  else:
    table.extend([runrun + str(int(runrun[-1])-1), 
                   runrun + str(int(runrun[-1])), 
                   runrun + str(int(runrun[-1])+1)])
    c += 3
  if c>=K:
    print(table[K-1])
    exit()

Fixed submission:
K = int(input())
table = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in table:
  if len(table) > K:
    break
  x = i % 10
  for j in range(max(0, x - 1), min(x + 2, 10)):
    table.append(i * 10 + j)
print(table[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import Counter
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = np.zeros([N, N])
for i in range(N):
  for j in range(i, N):
    ans[i][j] = min(abs(j-i), abs(j-X)+1+abs(Y-i), abs(i-X)+1+abs(j-Y))
c = Counter(ans.reshape(-1))
for k in range(1, N):
  print(c[k])

Fixed submission:
x = input().split()
N = int(x[0])
X = int(x[1])
Y = int(x[2])

L = [0 for _ in range(N+1)]

for i in range(1,N):
    for j in range(i+1,N+1):
        L[min(j-i,abs(X-i)+abs(Y-j)+1)] +=1
            
for k in range(1,N):
    print(L[k])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for k in range(len(A)):
  ans = 0
  search = A.copy()
  search.pop(k)
  unique = set(search)
  for u in unique:
    c = search.count(u)
    ans += c * (c-1) / 2
  print(int(ans))

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

c = collections.Counter(l)
ans=0
for v in c.values():
  ans+=v*(v-1)//2

for x in l:
  print(ans-c[x]+1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
  ai, bi = map(int, input().split())
  A.append(ai)
  B.append(bi)

# process
dp = np.zeros(H+1, dtype=np.int64)
dp[0] = 0

for i in range(1, H + 1):
    dp[i] = np.amin(dp[np.maximum(i - A, 0)] + B)

# output
print(dp[H])


Fixed submission:
import numpy as np
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
  ai, bi = map(int, input().split())
  A.append(ai)
  B.append(bi)

A = np.array(A)
B = np.array(B)
# process
dp = np.zeros(H+1, dtype=np.int64)
dp[0] = 0

for i in range(1, H + 1):
    dp[i] = np.amin(dp[np.maximum(i - A, 0)] + B)

# output
print(dp[H])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
P = list(map(int, input().split()))
c = 0
for i in range(n):
  if i ==0: 
    c+=1
  elif P[i] < min(P[0:i]): 
    c +=1
print(c)

Fixed submission:
n = int(input())
P = list(map(int, input().split()))
c = 0
for i in range(n):
  if i ==0: 
    c+=1
    current_min = P[i]
  elif P[i] < current_min: 
    c +=1
    current_min = P[i]
print(c)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = 0
b = 0
sp = dict()
correct = []
wrong = dict()
for _ in range(M):
    s, p = input().split()
    if not s in sp.keys():
        if p == "AC":
            a +=1
            correct.append(s)
        else:
            wrong[s] = 1
        sp[s] = p
    else:
        if sp[s] == "AC":
            continue
        else:
            if p == "AC":
                a += 1
                correct.append(s)
            else:
                wrong[s] = 1
            sp[s] = p
for c in set(correct):
    b += wrong[c]
print(a, b)

Fixed submission:
N, M = map(int, input().split())
a = 0
b = 0
sp = dict()
for _ in range(M):
    s, p = input().split()
    if int(s) not in sp.keys():
        sp[int(s)] = [p]
    else:
        sp[int(s)].append(p)
        
a = 0
b = 0
for i, result in sp.items():
    if "AC" in result:
        a += 1
        b += result.index("AC")
    else:
        continue
print(a, b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def bfs(maze, visited, sy, sx, gy, gx):
  queue = deque([[sy, sx]])
  visited[sy][sx] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [gy, gx]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if new_y >= H or new_y < 0 or new_x >= W or new_x < 0:
        continue
      elif maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        visited[new_y][new_x] = visited[y][x] + 1
        queue.append([new_y, new_x])

H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]
ans = 0
for sy in range(H):
  for sx in range(W):
    for gy in range(H):
      for gx in range(W):
        visited = [[-1]*W for j in range(H)]
        res = bfs(maze, visited, sy, sx, gy, gx)
        if res != None:
          ans = max(ans, res)
print(ans)

Fixed submission:
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
import numpy as np

H, W = map(int, input().split())
S = [input() for _ in range(H)]

v_id_dict = {}
dista = np.ones((400, 400)) * np.inf

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            v_id_dict[i, j] = len(v_id_dict)

            if (i > 0) and (S[i - 1][j] == "."):
                dista[v_id_dict[(i, j)], v_id_dict[(i - 1, j)]] = 1

            if (j > 0) and (S[i][j - 1] == "."):
                dista[v_id_dict[(i, j)], v_id_dict[(i, j - 1)]] = 1

dist_mat = dijkstra(
    csgraph_from_dense(dista[: len(v_id_dict), : len(v_id_dict)]),
    directed=False,
    unweighted=False,
)

print(int(dist_mat.max()))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c = 6 - a- b
print(c)

Fixed submission:
A = int(input())
B = int(input())
 
print(6-A-B)
Buggy python submission (verdict: Runtime Error):
S = input()
l = len(S)
c = 0
for i in range(l // 2):
  if S[i] == S[l-i]:
    pass
  else:
    c +=1
print(c)


Fixed submission:
S = input()
l = len(S)
c = 0
for i in range(l // 2):
  if S[i] == S[l-i-1]:
    pass
  else:
    c +=1
print(c)

Buggy python submission (verdict: Runtime Error):
S = input()
l = len(S)
c = 0
for i in range(l // 2):
  if S[i] == S[l-i]:
    c +=1
print(c)

Fixed submission:
S = input()
l = len(S)
c = 0
for i in range(l // 2):
  if S[i] == S[l-i-1]:
    pass
  else:
    c +=1
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
a = []
s_list = list(s)
for i in range(len(s)):
    if i + 1 < len(s) - n: 
        w = s_list[i + n]
    else:
        w = s_list[i + n - len(s)]
    a.append(w)
print("".join(a))

Fixed submission:
a = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
N = int(input())
S = input()
l = [] 
for i in S:
    b = a.index(i) + N
    if b <= 25:
        w = a[b]
    else:
        w = a[b-26]
    l.append(w)
print("".join(l))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
index = np.arange(1, N+1)
ans = np.array([0] * N)
for i in index[::-1]:
  if sum(ans[index%i==0]) % 2 == A[i-1]:
    continue
  else:
    ans[i-1] += 1
print(sum(ans))
print(' '.join((np.where(ans > 0)[0] +1).astype(str)))

Fixed submission:
n,*a=map(int,open(0).read().split())
b=[0]*n
for i in range(1,n+1)[::-1]:
  if not sum(b[i-1::i])%2==a[i-1]:
    b[i-1]=1
print(sum(b))
print(*[i+1 for i,b_i in enumerate(b) if b_i==1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
  b, c = map(int, input().split())
  A.extend([c] * b)
A = sorted(A, reverse=True)
print(sum(A[:N]))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
  BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x:x[1],reverse=True)  
for b, c in BC:
  A.extend([c] * b)
  if len(A)>=2*N:
    break
A = sorted(A, reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
  bc = list(map(int, input().split()))
  A.extend([bc[1]] * bc[0])
A = sorted(A, reverse=True)
print(sum(A[:N]))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
  BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x:x[1],reverse=True)  
for b, c in BC:
  A.extend([c] * b)
  if len(A)>=2*N:
    break
A = sorted(A, reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
BC = []
for _ in range(M):
  bc = list(map(int, input().split()))
  A = np.append(A, [bc[1]] * bc[0])
A = sorted(A, reverse=True)
print(sum(A[:N]))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
  BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x:x[1],reverse=True)  
for b, c in BC:
  A.extend([c] * b)
  if len(A)>=2*N:
    break
A = sorted(A, reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
BC = []
for _ in range(M):
  bc = list(map(int, input().split()))
  A[:bc[0]][A[:bc[0]]<bc[1]] = bc[1]
  A = np.sort(A)
print(sum(A))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
  BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x:x[1],reverse=True)  
for b, c in BC:
  A.extend([c] * b)
  if len(A)>=2*N:
    break
A = sorted(A, reverse=True)
print(sum(A[:N]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
A = np.array(sorted(list(map(int, input().split()))))
BC = []
for _ in range(M):
  bc = list(map(int, input().split()))
  BC.append(bc)
BC = sorted(BC, key=lambda x:x[1])
for bc in BC:
  A[:bc[0]][A[:bc[0]]<bc[1]] = bc[1]
  A = np.sort(A)
print(sum(A))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
  BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x:x[1],reverse=True)  
for b, c in BC:
  A.extend([c] * b)
  if len(A)>=2*N:
    break
A = sorted(A, reverse=True)
print(sum(A[:N]))
Buggy python submission (verdict: Runtime Error):
N, Q= input().split(" ")
S = input()
index_list_all = []
for i in range(int(Q)):
    lQ, rQ = input().split(" ")
    index_list_all.append([int(lQ), int(rQ)])

for index_list in index_list_all:
    print(len(S[index_list[0] - 1: index_list[1]].split("AC")) - 1)

Fixed submission:
char = input()
if char == "A":
    char2 = "T"
elif char == "T":
    char2 = "A"
elif char == "G":
    char2 = "C"
elif char == "C":
    char2 = "G"
print(char2)

Buggy python submission (verdict: Runtime Error):
seq = input()
seq_list = []
for char in seq :
    if char == "A":
        char2 = "T"
    elif char == "T":
        char2 = "A"
    elif char == "G":
        char2 = "C"
    elif char == "C":
        char2 = "G"
    seq_list.append(char2)
return("".join(seq_list))

Fixed submission:
char = input()
if char == "A":
    char2 = "T"
elif char == "T":
    char2 = "A"
elif char == "G":
    char2 = "C"
elif char == "C":
    char2 = "G"
print(char2)

Buggy python submission (verdict: Runtime Error):
seq = input()
seq_list = []
for char in seq :
    if char == "A":
        char2 = "T"
    elif char == "T":
        char2 = "A"
    elif char == "G":
        char2 = "C"
    elif char == "C":
        char2 = "G"
    seq_list.append(char2)
return("".join(seq_list))

Fixed submission:
char = input()
if char == "A":
    char2 = "T"
elif char == "T":
    char2 = "A"
elif char == "G":
    char2 = "C"
elif char == "C":
    char2 = "G"
print(char2)
Buggy python submission (verdict: Runtime Error):
input_value = Input()
a, b = input_value.split()
if a * b // 2:
  print("Even")
else:
  print("Odd")

Fixed submission:
input_value = input()
a, b = input_value.split()
if int(a) * int(b) % 2 == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
done = False
for i in range(N+1):
  a = i
  for j in (N+1-a):
    b = j
    c = N -i -j
    sum = 10000*a + 5000 * b + 1000 *c
    if sum == Y:
      done = True
      print(a, b, c)
if not done:
  print(-1, -1, -1)

Fixed submission:
N, Y = map(int, input().split())
done = False
for i in range(N+1):
  a = i
  for j in range(N+1-a):
    b = j
    c = N -i -j
    sum = 10000*a + 5000 * b + 1000 *c
    if sum == Y:
      done = True
      print(a, b, c)
  if done:
    break
        
if not done:
  print(-1, -1, -1)
Buggy python submission (verdict: Runtime Error):
k, s = input().split()
c = 0
for i range(k+1):
  x = i
  for j range(k+1):
  	y = j
    for h range(k+1):
      z = h
      sum = x + y + z
      if sum == k:
        c += 1
        
print(c)


Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
k, s = input()
c = 0
for i range(k+1):
  x = i
  for j range(k+1):
  	y = j
    for h range(k+1):
      z = h
      sum = x + y + z
      if sum == k:
        c += 1
        
print(c)

Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N =int(input())
A_n =list(map(int,input().split()))
Q =int(input())
B_n ,C_n=[],[]
for i in range(Q):
    B,C =map(int,input().split())
    B_n.append(B)
    C_n.append(C)

sum0 =sum(A_n)
for i in range(Q):
    count =Counter(A_n)[B_n[i]]
    sum0 += (C_n[i]-B_n[i])*count
    A_n  =list(filter(lambda x: x != B_n[i] ,A_n))
    A_n.extend([C_n[i] for j in range(count)])
    print(sum0)
    

Fixed submission:
from collections import Counter

N =int(input())
A_n =list(map(int,input().split()))
Q =int(input())
B_n ,C_n=[],[]
for i in range(Q):
    B,C =map(int,input().split())
    B_n.append(B)
    C_n.append(C)

dic =Counter(A_n)

sum0 =sum(A_n)
for i in range(Q):
    count = dic[B_n[i]]
    sum0 += (C_n[i]-B_n[i])*count
    dic[B_n[i]] = 0
    dic[C_n[i]] += count
    print(sum0)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
A_n =list(map(int,input().split()))
Q =int(input())
B_n ,C_n=[],[]
for i in range(Q):
    B,C =map(int,input().split())
    B_n.append(B)
    C_n.append(C)

sum0 =sum(A_n)
for i in range(Q):
    count =A_n.count(B_n[i])
    sum0 += (C_n[i]-B_n[i])*count
    A_n  =list(filter(lambda x: x != B_n[i] ,A_n))
    A_n.extend([C_n[i] for j in range(count)])
    print(sum0)

Fixed submission:
from collections import Counter

N =int(input())
A_n =list(map(int,input().split()))
Q =int(input())
B_n ,C_n=[],[]
for i in range(Q):
    B,C =map(int,input().split())
    B_n.append(B)
    C_n.append(C)

dic =Counter(A_n)

sum0 =sum(A_n)
for i in range(Q):
    count = dic[B_n[i]]
    sum0 += (C_n[i]-B_n[i])*count
    dic[B_n[i]] = 0
    dic[C_n[i]] += count
    print(sum0)
Buggy python submission (verdict: Runtime Error):
A, B =map(int,input())
print(A*B)

Fixed submission:
A,B =map(int,input().split())
print(A*B)
Buggy python submission (verdict: Runtime Error):
N =int(input())
A_n =list(map(int,input().split()))
ans =1
i = 0

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  elif 0 in A_n is False:
    print(-1)
  else:
    print(0)
else:
  print(ans)

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

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  if 0 in A_n:
    print(0)
  else:
    print(-1)
else:
  print(ans)

Buggy python submission (verdict: Runtime Error):
N =int(input())
A_n =list(map(int,input().split()))
ans =1
i = 0

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  elif "0" in A_n is False:
    print(-1)
  else:
    print(0)
else:
  print(ans)

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

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  if 0 in A_n:
    print(0)
  else:
    print(-1)
else:
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
A_n =list(map(int,input().split()))
ans =1
for i in range(N):
  ans *= A_n[i]
if ans > 10**18:
  print(-1)
else:
  print(ans)

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

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  if 0 in A_n:
    print(0)
  else:
    print(-1)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
N , M =map(int,input().split())
A_n =list(map(int,input().split()))

B_n=sorted(A_n,reverse=True)
i =0
count = M
while B_n[i] >= sum(B_n)/(4*M) and count>0:
    i +=1
    count -=1
if count == 0:
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n,reverse=True)

if B_n[M-1] >= sum(B_n)/(4*M) :
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n)
i =0
count =N
while B_n[i] < sum(B_n)/(4*M) and i<=N-1:
    i +=1
    count -=1
if count >= M:
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n,reverse=True)

if B_n[M-1] >= sum(B_n)/(4*M) :
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n)
i =0
count =len(B_n)
while B_n[i] < sum(B_n)/(4*M) and i-1<=len(B_n):
    i +=1
    count -=1
if count >= M:
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n,reverse=True)

if B_n[M-1] >= sum(B_n)/(4*M) :
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n)
i =0
count =len(B_n)
while B_n[i] < sum(B_n)/(4*M) and i<=len(B_n):
    i +=1
    count -=1
if count >= M:
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n,reverse=True)

if B_n[M-1] >= sum(B_n)/(4*M) :
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n)
i =0
count =len(B_n)
while B_n[i] < sum(B_n)/(4*M):
    i +=1
    count -=1
if count >= M:
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n,reverse=True)

if B_n[M-1] >= sum(B_n)/(4*M) :
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n,reverse =True)
i =0
count =0
while B_n[i] >= sum(B_n)/(4*M):
    i +=1
    count +=1
if count >= M:
    print('Yes')
else:
    print('No')

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

B_n=sorted(A_n,reverse=True)

if B_n[M-1] >= sum(B_n)/(4*M) :
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_n = list(map(int,input().split()))

count =[0 for i in range(N)]
for i in range(N):
    count[A_n[i]-1] +=1
ans =[count[i]*(count[i]-1)//2 for i in range(N)]

for i in range(N):
    print(sum(ans)-count[A_n[i]-1]+1)

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

count =[0 for i in range(N)]
for i in range(N):
    count[A_n[i]-1] +=1
ans =[count[i]*(count[i]-1)//2 for i in range(N)]
a1=sum(ans)
for i in range(N):
    print(a1-count[A_n[i]-1]+1)

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

count =[0 for i in range(N)]
for i in range(N):
    count[A_n[i]-1] +=1
ans =[count[i]*(count[i]-1)//2 for i in range(N)]

for i in range(N):
    old = count[A_n[i]-1]*(count[A_n[i]-1]-1)//2
    count[A_n[i]-1] -= 1
    new = count[A_n[i]-1]*(count[A_n[i]-1]-1)//2
    print(sum(ans)-old+new)
    count[A_n[i]-1] += 1

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

count =[0 for i in range(N)]
for i in range(N):
    count[A_n[i]-1] +=1
ans =[count[i]*(count[i]-1)//2 for i in range(N)]
a1=sum(ans)
for i in range(N):
    print(a1-count[A_n[i]-1]+1)

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

count =[0 for i in range(N)]
for i in range(N):
    count[A_n[i]] +=1
ans =[count[i]*(count[i]-1)//2 for i in range(N)]

for i in range(N):
    count[A_n[i]] -= 1
    ans =[count[i]*(count[i]-1)//2 for i in range(N)]
    print(sum(ans))
    count[A_n[i]] += 1

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

count =[0 for i in range(N)]
for i in range(N):
    count[A_n[i]-1] +=1
ans =[count[i]*(count[i]-1)//2 for i in range(N)]
a1=sum(ans)
for i in range(N):
    print(a1-count[A_n[i]-1]+1)

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

ans =0
for i in range(N-1):
    for j in range(i +1,N):
        if A_n[i] == A_n[j]:
            ans += 1
            
for i in range(N):
    minus = 0
    for j in range(N):
        if A_n[i] == A_n[j] and i != j:
            minus +=1
    print(ans-minus)

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

count =[0 for i in range(N)]
for i in range(N):
    count[A_n[i]-1] +=1
ans =[count[i]*(count[i]-1)//2 for i in range(N)]
a1=sum(ans)
for i in range(N):
    print(a1-count[A_n[i]-1]+1)
Buggy python submission (verdict: Time Limit Exceeded):
N, A ,B =map(int,input().split())
blue =0
while N >0:
    blue += min(A,N)
    N -= min(A,N)
    N = max(N-B,0)
print(blue)

Fixed submission:
N, A ,B =map(int,input().split())

print(N//(A+B)*A+min(N%(A+B),A))