Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M = map(int,input().split())
l = [[] for _ in range(N+1)]
 
for _ in range(M):
  a,b = map(int,input().split())
  l[a].append(b)
  l[b].append(a)
ans = 0
check = [0]*(N+1)
for i in range(1,N+1):
  st = deque([i])
  check[i] = 1
  while st:
    s = st.popleft()
    for t in l[s]:
      if check[t] == 0:
        check[t] = 1
        st.append(t)
  ans = max(ans,N-sum(check))
print(ans)

Fixed submission:
from collections import deque
N,M = map(int,input().split())
l = [[] for _ in range(N+1)]
 
for _ in range(M):
  a,b = map(int,input().split())
  l[a].append(b)
  l[b].append(a)

check = [0]*(N+1)
cnt = 0
for i in range(1,N+1):
  if check[i] == 1:
    continue
  st = deque([i])
  check[i] = 1
  while st:
    s = st.popleft()
    for t in l[s]:
      if check[t] == 0:
        check[t] = 1
        st.append(t)
      continue
  cnt += 1

print(cnt-1)
Buggy python submission (verdict: Runtime Error):
N,X,M = map(int,input().split())
er = [0]*N
er[0] = X
MOD = 10**9+7
for i in range(1,N):
  er[i] = (er[i-1]**2%M)%MOD
  if er[i] == 0:
    break
print(sum(er)%MOD)

Fixed submission:
N,X,M = map(int,input().split())
L = [X]
S = set([X])
idx = N
MOD = 10**9+7
for i in range(1,N):
  X = (X**2%M)
  if len(S) != len(L):
    idx = L.index(X)
    break
  L.append(X)
  S.add(X)

if idx == N:
  print(sum(L[:idx]))
else:
  k = (N-idx)%len(L[idx:])
  print(sum(L[:idx])+((N-idx)//len(L[idx:]))*sum(L[idx:])+sum(L[idx:idx+k]))
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
N = int(input())
A = list(map(int,input().split()))
A.sort()
c = 0
flg = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    c = gcd(A[i],A[j])
    if c != 1:
      flg = 1
a = gcd(A[0],A[1])
for i in range(2,N):
  a = gcd(a,A[i])
if a == 1 and flg == 0:
  print("pairwise coprime")
elif a == 1 and flg == 1:
  print("setwise coprime")
else:
  print("not coprime")

Fixed submission:
from math import gcd

N = int(input())
A = list(map(int,input().split()))
 
flg = 0
l = [0]*(max(A)+1)
for i in A:
  l[i] += 1
a = gcd(A[0],A[1])
for i in range(2,N):
  a = gcd(a,A[i])
for i in range(2,max(A)+1):
  if sum(l[i::i]) > 1:
    flg = 1
    break



if a == 1 and flg == 0:
  print("pairwise coprime ")
elif a == 1 and flg == 1:
  print("setwise coprime")
else:
  print("not coprime")

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
N = int(input())
A = list(map(int,input().split()))
A.sort()
c = 0
flg = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    c = gcd(A[i],A[j])
    if c != 1:
      flg = 1
a = gcd(A[0],A[1])
for i in range(2,N):
  a = gcd(a,A[i])
if a == 1 and flg == 0:
  print("pairwise coprime")
elif a == 1 and flg == 1:
  print("setwise coprime")
else:
  print("not coprime")

Fixed submission:
from math import gcd

N = int(input())
A = list(map(int,input().split()))
 
flg = 0
l = [0]*(max(A)+1)
for i in A:
  l[i] += 1
a = gcd(A[0],A[1])
for i in range(2,N):
  a = gcd(a,A[i])
for i in range(2,max(A)+1):
  if sum(l[i::i]) > 1:
    flg = 1
    break



if a == 1 and flg == 0:
  print("pairwise coprime ")
elif a == 1 and flg == 1:
  print("setwise coprime")
else:
  print("not coprime")
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
C = str(input())
D = copy.copy(C)
while D.count("WR") > 0:
  D = D.replace("WR","RW")

ans = 0

for i in range(N):
  if D[i] == "W":
    break
  if D[i] != C[i]:
    ans += 1

print(ans)

Fixed submission:
N = int(input())
C = str(input())
count = C.count("R")
ans = 0

for i in range(count):
  if C[i] == "W":
    ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [0]*(10**5+1)
A = list(map(int,input().split()))
Q = int(input())
for a in A:
  l[a] += a

for _ in range(Q):
  b,c = map(int,input().split())
  l[c] += (l[b]//b)*c
  l[b] = 0
  print(sum(l))

Fixed submission:
N = int(input())
l = [0]*(10**5+1)
A = list(map(int,input().split()))
Q = int(input())
for a in A:
  l[a] += a
suml = sum(l)
for _ in range(Q):
  b,c = map(int,input().split())
  suml += ((l[b]//b)*c - l[b])
  l[c] += (l[b]//b)*c
  l[b] = 0
  print(suml)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

l = [0]*(2**max(A))
ll = []
for a in A:
  pattern = bin(a)[2:].zfill(N)
  for i in range(len(pattern)):
    if pattern[i] == '1':
      l[i] += 1

for a in A:
  ans = ''
  pattern = bin(a)[2:].zfill(N)
  for i in range(len(pattern)):
    if pattern[i] == '1' and int(l[i])%2 == 0:
      ans += '1'
    elif pattern[i] == '0' and int(l[i])%2 != 0:
      ans += '1'
    else:
      ans += '0'
  ll.append(int(ans,2))
print(*ll)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
num = 0
for a in A:
  num ^= a

l = []

for a in A:
  ans = a^num
  l.append(ans)
print(*l)
Buggy python submission (verdict: Runtime Error):
from decimal import *
A,B = map(float,input().split())
num = str(Decimal(A)*Decimal(B))
ans = ''

for i in range(len(num)):
  if num[i] == '.':
    break
  ans += num[i]
print(int(ans))

Fixed submission:
from decimal import *
A,B = map(str,input().split())
num = str(Decimal(A)*Decimal(B))
ans = ''
 
for i in range(len(num)):
  if num[i] == '.':
    break
  ans += num[i]
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M = map(int,input().split())
l = [[] for _ in range(N+1)]
for _ in range(M):
  a,b = map(int,input().split())
  l[a].append(b)
  l[b].append(a)

ans = 'No'
st = deque([1])
check = [0]*(N+1)
check[1] = 1
mark = [0]*(N+1)

while st:
  s = st.popleft()
  for t in l[s]:
    if check[t] == 0:
      mark[t] = s
      check[t] = 1
      st.append(t)
  if sum(check) == N:
    ans = 'Yes'
    break

print(ans)
if ans == 'Yes':
  for i in range(2,N+1):
    print(mark[i])

Fixed submission:
N,M = map(int,input().split())
AB = [[] for _ in range(N)]
ans = [0]*N
for _ in range(M):
  a,b = map(int,input().split())
  AB[a-1].append(b-1)
  AB[b-1].append(a-1)

from collections import deque

node = 0
q = deque([0])

check = [0]*N
check[0] = 1
while len(q) > 0:
  node = q.popleft()
  for i in AB[node]:
    if check[i] == 0:
      q.append(i)
      check[i] = 1
      ans[i] = node
print("Yes")
for i in range(1,N):
  print(ans[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M = map(int,input().split())
l = [[] for _ in range(N+1)]
for _ in range(M):
  a,b = map(int,input().split())
  l[a].append(b)
  l[b].append(a)

ans = 'No'
st = deque([1])
check = [0]*(N+1)
check[1] = 1
mark = [0]*(N+1)

while st:
  s = st.popleft()
  for t in l[s]:
    if check[t] == 0:
      mark[t] = s
      check[t] = 1
      st.append(t)
  if sum(check) == N:
    ans = 'Yes'
    break

print(ans)
if ans == 'Yes':
  for i in range(2,N+1):
    print(mark[i])

Fixed submission:
N,M = map(int,input().split())
AB = [[] for _ in range(N)]
ans = [0]*N
for _ in range(M):
  a,b = map(int,input().split())
  AB[a-1].append(b-1)
  AB[b-1].append(a-1)

from collections import deque

node = 0
q = deque([0])

check = [0]*N
check[0] = 1
while len(q) > 0:
  node = q.popleft()
  for i in AB[node]:
    if check[i] == 0:
      q.append(i)
      check[i] = 1
      ans[i] = node
print("Yes")
for i in range(1,N):
  print(ans[i]+1)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
AB = [[] for _ in range(M)]
ans = [0]*N
for _ in range(M):
  a,b = map(int,input().split())
  AB[a-1].append(b-1)
  AB[b-1].append(a-1)

from collections import deque

node = 0
q = deque([0])

check = [0]*N
check[0] = 1
while len(q) > 0:
  node = q.popleft()
  for i in AB[node]:
    if check[i] == 0:
      q.append(i)
      check[i] = 1
      ans[i] = node
print("Yes")
for i in range(1,N):
  print(ans[i]+1)


Fixed submission:
N,M = map(int,input().split())
AB = [[] for _ in range(N)]
ans = [0]*N
for _ in range(M):
  a,b = map(int,input().split())
  AB[a-1].append(b-1)
  AB[b-1].append(a-1)

from collections import deque

node = 0
q = deque([0])

check = [0]*N
check[0] = 1
while len(q) > 0:
  node = q.popleft()
  for i in AB[node]:
    if check[i] == 0:
      q.append(i)
      check[i] = 1
      ans[i] = node
print("Yes")
for i in range(1,N):
  print(ans[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
List = [(A,B) for A in range(X//2+1) for B in range(-X//2,X//2) if A**5 - B**5 == X]

print(*List[0])

Fixed submission:
X = int(input())
List = [(A,B) for A in range(-120,120) for B in range(-120,120) if A**5 - B**5 == X]

print(*List[0])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

count = 0
I = [0]*N
J = [0]*N
for i in range(N):
  I[i] = i+A[i]
  J[i] = i-A[i]
for j in range(N):
  count += J.count(I[j])

print(count)

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

ans = 0
B = [0]*N
C = [0]*N

for i in range(N):
  b = i+A[i]
  c = i-A[i]
  if 0 < b < N:
    B[b] += 1
  if 0 < c < N:
    C[c] += 1

for i in range(N):
  ans += B[i]*C[i]

print(ans)

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

count = 0
I = [0]*N
J = [0]*N

for i in range(N):
  I[i] = i+A[i]
  J[i] = i-A[i]
for j in range(N):
  count += J.count(I[j])

print(count)

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

ans = 0
B = [0]*N
C = [0]*N

for i in range(N):
  b = i+A[i]
  c = i-A[i]
  if 0 < b < N:
    B[b] += 1
  if 0 < c < N:
    C[c] += 1

for i in range(N):
  ans += B[i]*C[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
mA = max(A)
max_long = min(N,max(A)*2)
count = 0
for i in range(N-1):
  m = min(N,i+max_long+1)
  for j in range(i+1,m):
    if j-i == A[i]+A[j]:
      count += 1
print(count)

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

ans = 0
B = [0]*N
C = [0]*N

for i in range(N):
  b = i+A[i]
  c = i-A[i]
  if 0 < b < N:
    B[b] += 1
  if 0 < c < N:
    C[c] += 1

for i in range(N):
  ans += B[i]*C[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import floor
A,B,N = map(int,input().split())
ans = 0
if B <=  N:
  for x in range(B-1,N+1,B):
    ans = max(ans, floor(A*x/B) - A*floor(x/B))
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)

Fixed submission:
from math import floor
A,B,N = map(int,input().split())
ans = 0
if B <=  N:
  ans = floor(A*(B-1)/B) - A*floor((B-1)/B)
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)

Buggy python submission (verdict: Runtime Error):
A,B,N = map(int,input().split())
ans = 0
if B <=  N:
  for x in range(B-1,N+1,B):
    ans = max(ans, (A*x)//B - A*(x//B))
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)

Fixed submission:
from math import floor
A,B,N = map(int,input().split())
ans = 0
if B <=  N:
  ans = floor(A*(B-1)/B) - A*floor((B-1)/B)
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import floor
A,B,N = map(int,input().split())
ans = 0
if B-1 <=  N:
  for x in range(B-1,N+1,B):
    ans = max(ans, floor(A*x/B) - A*floor(x/B))
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)

Fixed submission:
from math import floor
A,B,N = map(int,input().split())
ans = 0
if B <=  N:
  ans = floor(A*(B-1)/B) - A*floor((B-1)/B)
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import floor
A,B,N = map(int,input().split())
ans = 0
if B-1 <=  N:
  for x in range(B-1,N+1,B):
    ans = max(ans, floor(A*x/B) - A*floor(x/B))
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)

Fixed submission:
from math import floor
A,B,N = map(int,input().split())
ans = 0
if B <=  N:
  ans = floor(A*(B-1)/B) - A*floor((B-1)/B)
else:
  ans = floor((A*N)/B) - A*floor(N/B)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
from itertools import *
def gcd(*numbers):
    return reduce(math.gcd, numbers)

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

K = int(input())
ans = 0
for i in product([i for i in range(1,K+1)], repeat = 3):
  ans += gcd(i[0],i[1],i[2])
print(ans)

Fixed submission:
import math
from functools import reduce
from itertools import *
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
 
K = int(input())
ans = 0
for i in product([i for i in range(1,K+1)], repeat = 3):
  ans += gcd(i[0],i[1],i[2])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
count = S.count('R')*S.count('G')*S.count('B')
for i in range(1,N+1):
  for j in range(i+1,N-1):
    k = 2*j-1
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      count -= 1
print(count)

Fixed submission:
N = int(input())
S = str(input())
count = S.count('R')*S.count('G')*S.count('B')
for i in range(N):
  for l in range(N):
    j = i + l
    k = j + l
    if k >= N:
      break
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      count -= 1

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
count = S.count('R')*S.count('G')*S.count('B')
for i in range(1,N+1):
  for j in range(i+1,N-1):
    k = 2*j-1
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      count -= 1
print(count)

Fixed submission:
N = int(input())
S = str(input())
count = S.count('R')*S.count('G')*S.count('B')
for i in range(N):
  for l in range(N):
    j = i + l
    k = j + l
    if k >= N:
      break
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      count -= 1

print(count)

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

Fixed submission:
N = int(input())
S = str(input())
count = S.count('R')*S.count('G')*S.count('B')
for i in range(N):
  for l in range(N):
    j = i + l
    k = j + l
    if k >= N:
      break
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      count -= 1

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
count = 0
for i in range(N):
  for i in range(i,N):
    for i in range(j,N):
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k] and j-i != k-j:
        count += 1

Fixed submission:
N = int(input())
S = str(input())
count = S.count('R')*S.count('G')*S.count('B')
for i in range(N):
  for l in range(N):
    j = i + l
    k = j + l
    if k >= N:
      break
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      count -= 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
x = 0
count = 0
if K == 100000:
  print(3234566667)
  exit()
if K <= 12:
  print(K)
  exit()
if K > 100000:
  count = 100000
  x = 3234566667
while count < K:
  x = int(x)
  x += 1
  x = str(x)
  for i in range(1,len(x)):
    if abs(int(x[i])-int(x[i-1])) > 1:
      count -= 1
      break
  count += 1
print(x)



Fixed submission:
from collections import deque
K = int(input())
Q = deque([i for i in range(1,10)])

for _ in range(K-1):
    q = Q.popleft()
    if q%10 != 0:
        Q.append(10*q+(q%10)-1)
    Q.append(10*q+(q%10))
    if q%10 != 9:
        Q.append(10*q+(q%10)+1)
print(Q.popleft())

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
x = 0
count = 0
if K <= 12:
  print(K)
  exit()
while count < K:
  x = int(x)
  x += 1
  x = str(x)
  for i in range(1,len(x)):
    if abs(int(x[i])-int(x[i-1])) > 1:
      count -= 1
      break
  count += 1
print(x)

Fixed submission:
from collections import deque
K = int(input())
Q = deque([i for i in range(1,10)])

for _ in range(K-1):
    q = Q.popleft()
    if q%10 != 0:
        Q.append(10*q+(q%10)-1)
    Q.append(10*q+(q%10))
    if q%10 != 9:
        Q.append(10*q+(q%10)+1)
print(Q.popleft())
Buggy python submission (verdict: Time Limit Exceeded):
N,K,C = map(int,input().split())
S = str(input())
works1 = 0
works2 = 0
l1 = []
l2 = []
i = 0
while i < N and works1 < K:
  if S[i] == "o":
    l1.append(i+1)
    i = i+C+1
    works1 += 1
  else:
    i = i+1
i = N-1
while i > -1 and works2 < K:
    if S[i] == "o":
      l2.append(i+1)
      i = i-C-1
      works2 = works2+1
    else:
      i = i-1

for i in range(len(l1)):
  if l1[i] in l2 :
    print(l1[i])

Fixed submission:
N,K,C = map(int,input().split())
S = str(input())
works1 = 0
works2 = 0
l1 = []
l2 = []
i = 0
while i < N and works1 < K:
  if S[i] == "o":
    l1.append(i+1)
    i = i+C+1
    works1 += 1
  else:
    i = i+1
i = N-1
while i > -1 and works2 < K:
    if S[i] == "o":
      l2.append(i+1)
      i = i-C-1
      works2 = works2+1
    else:
      i = i-1

for i in range(len(l1)):
  if l1[i] == l2[-i-1] :
    print(l1[i])

Buggy python submission (verdict: Time Limit Exceeded):
N,K,C = map(int,input().split())
S = str(input())
works1 = 0
works2 = 0
l1 = []
l2 = []
i = 0
while i < N and works1 < K:
  if S[i] == "o":
    l2.append(i+1)
    i = i+C+1
    works1 += 1
  else:
    i = i+1
i = N-1
while i > -1 and works2 < K:
    if S[i] == "o":
      l2.append(i+1)
      i = i-C-1
      works2 = works2+1
    else:
      i = i-1

l1.extend(l2)
l = [x for x in set(l1) if l1.count(x) > 1]
for i in range(len(l)):
  print(l[i])

Fixed submission:
N,K,C = map(int,input().split())
S = str(input())
works1 = 0
works2 = 0
l1 = []
l2 = []
i = 0
while i < N and works1 < K:
  if S[i] == "o":
    l1.append(i+1)
    i = i+C+1
    works1 += 1
  else:
    i = i+1
i = N-1
while i > -1 and works2 < K:
    if S[i] == "o":
      l2.append(i+1)
      i = i-C-1
      works2 = works2+1
    else:
      i = i-1

for i in range(len(l1)):
  if l1[i] == l2[-i-1] :
    print(l1[i])
Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
P,Q = p[:X],q[:Y]

for i in range(C):
  if min(P[-i-1],Q[-i-1]) > r[i]:
    break
  elif min(P[-i-1],Q[-i-1]) <= r[i]:
    if P[-i-1] < Q[-i-1]:
      P[-i-1] = r[i]
    else:
      Q[-i-1] = r[i]
print(sum(P)+sum(Q))

Fixed submission:
from heapq import heappush, heappop, heapify
X,Y,A,B,C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
P,Q = p[:X],q[:Y]

heapify(P)
heapify(Q)

for i in range(C):
  if min(P[0],Q[0]) > r[i]:
    break
  if P[0] < Q[0]:
    heappop(P)
    heappush(P,r[i])

  else:
    heappop(Q)
    heappush(Q,r[i])
print(sum(P)+sum(Q))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
CA = Counter(A)
all_count = 0
for ca in CA.values():
  all_count += ca*(ca-1)//2

for a in A:
  print(all_count - (A.count(a)-1))

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)
ans = 0

for i in B.values():
  ans += i*(i-1)//2
for a in A:
  k = B[a]
  print(ans - (k*(k-1)//2)+((k-1)*(k-2)//2))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
from operator import mul
from functools import reduce
mod = 10**9 + 7
def cmb(n,r,mod):
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod

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

for k in range(N):
  A[k] -= (10**6)
  C = collections.Counter(A)
  A[k] += (10**6)
  values, counts = zip(*C.most_common())
  ans = 0
  for i in range(len(counts)):
    if counts[i] == 1:
      pass
    else:
      ans += cmb(counts[i],2,mod)
  print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)
ans = 0

for i in B.values():
  ans += i*(i-1)//2
for a in A:
  k = B[a]
  print(ans - (k*(k-1)//2)+((k-1)*(k-2)//2))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
from operator import mul
from functools import reduce
mod = 10**9 + 7
def cmb(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod

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

for k in range(N):
  A[k] -= (10**6)
  C = collections.Counter(A)
  A[k] += (10**6)
  values, counts = zip(*C.most_common())
  ans = 0
  for i in range(len(counts)):
    if counts[i] == 1:
      pass
    else:
      ans += cmb(counts[i],2)
  print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)
ans = 0

for i in B.values():
  ans += i*(i-1)//2
for a in A:
  k = B[a]
  print(ans - (k*(k-1)//2)+((k-1)*(k-2)//2))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

for k in range(N):
  A[k] -= (10**6)
  C = collections.Counter(A)
  A[k] += (10**6)
  values, counts = zip(*C.most_common())
  ans = 0
  for i in range(len(counts)):
    if counts[i] == 1:
      pass
    else:
      ans += cmb(counts[i],2)
  print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)
ans = 0

for i in B.values():
  ans += i*(i-1)//2
for a in A:
  k = B[a]
  print(ans - (k*(k-1)//2)+((k-1)*(k-2)//2))
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
l = [[0]*H]*W
ans = 0
if H%2 == 0 and W%2 == 0:
  ans = (W//2)*H
else:
  ans = (W//2)*(H//2) +(H-(H//2))*(W-(W//2))
print(ans)

Fixed submission:
H,W = map(int,input().split())
ans = 0
if H%2 == 0 and W%2 == 0:
  ans = (W//2)*H
elif H == 1 or W == 1:
  print(1)
  exit()
elif H%2 != 0 and W%2 != 0:
  ans = (W//2)*(H//2) + (H-(H//2))*(W-(W//2))
elif H%2 == 0 and W%2 != 0:
  ans = (W//2)*(H//2) + (H//2)*(W-(W//2))
elif H%2 != 0 and W%2 == 0:
  ans = (W//2)*(H//2) + (H-(H//2))*(W//2)
print(ans)