Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=input().split()
if(sorted(set(A), key=A.index)==A):
  print("YES")
else:
  print("NO")


Fixed submission:
N=input()
A=input().split()
def has_duplicates(seq):
    return len(seq) != len(set(seq))
if has_duplicates(A):
  print("NO")
else:
  print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=input().split()
if(sorted(set(A), key=A.index)==A):
  print("YES")
else:
  print("NO")


Fixed submission:
N=input()
A=input().split()
def has_duplicates(seq):
    return len(seq) != len(set(seq))
if has_duplicates(A):
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
A,B,K = input().split()
x=0
while (int(A)>0):
  x=int(x)+1
  A=int(A)-1
  if(x>int(K)):
    break
while (int(B)>0):
  x=int(x)+1
  B=int(B)-1
  if(x>int(K)):
    break
if(A>0):
  A=int(A)+1
if(B>0):
  B=int(B)+1
print(format(A)+' '+format(B))

Fixed submission:
S,T = input().split()
print (T+S)

Buggy python submission (verdict: Runtime Error):
A,B,K = input().split()
x=0
while (int(A)>0):
  x=int(x)+1
  A=int(A)-1
  if(x>int(K)):
    break
while (int(B)>0):
  x=int(x)+1
  B=int(B)-1
  if(x>int(K)):
    break
if(A>0):
  A=int(A)+1
if(B>0):
  B=int(B)+1
print(format(A)+' '+format(B))

Fixed submission:
S,T = input().split()
print (T+S)

Buggy python submission (verdict: Runtime Error):
x=0
A,B,K = input().split()
while (int(A)>0):
  x=int(x)+1
  A=int(A)-1
  if(x>int(K)):
    break
while (int(B)>0):
  x=int(x)+1
  B=int(B)-1
  if(x>int(K)):
    break
if(A>0):
  A=int(A)+1
if(B>0):
  B=int(B)+1
print(format(A)+' '+format(B))

Fixed submission:
S,T = input().split()
print (T+S)
Buggy python submission (verdict: Runtime Error):
S=input()
a=(str(S)[0])
b=(str(S)[1])
c=(str(S)[2])
d=(str(S)[3])
if(int(a)==int(b)):
  print("Bad")
else:
    print("Good")
    if(int(b)==int(c)):
  print("Bad")
else:
    print("Good")
if(int(c)==int(d)):
  print("Bad")
else:
    print("Good")

Fixed submission:
S=input()
a=(str(S)[0])
b=(str(S)[1])
c=(str(S)[2])
d=(str(S)[3])
if(int(a)==int(b)):
  print("Bad")
elif(int(b)==int(c)):
  print("Bad")
elif(int(c)==int(d)):
  print("Bad")
else:
    print("Good")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
for A in range(1, N + 1):
	for B in range(1, N // A + 1):
		C = N - A * B
		if C >= 1 and A * B + C == N:
			cnt += 1
print(cnt)


Fixed submission:
N = int(input())
cnt = 0
for A in range(1, N + 1):
	for B in range(1, N // A + 1):
		C = N - A * B
		if C >= 1 and A * B + C == N:
			cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
for A in range(1, N + 1):
	for B in range(1, N + 1):
		C = N - A * B
		if C >= 1 and A * B + C == N:
			cnt += 1
print(cnt)


Fixed submission:
N = int(input())
cnt = 0
for A in range(1, N + 1):
	for B in range(1, N // A + 1):
		C = N - A * B
		if C >= 1 and A * B + C == N:
			cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
for A in range(1, N + 1):
	for B in range(1, N + 1):
		C = N - A * B
		if C >= 1 and A * B + C == N:
			cnt += 1
print(cnt)


Fixed submission:
N = int(input())
cnt = 0
for A in range(1, N + 1):
	for B in range(1, N // A + 1):
		C = N - A * B
		if C >= 1 and A * B + C == N:
			cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
S = input()
print(S.replace(7, 8, 1))

Fixed submission:
S = input()
print(S.replace('7', '8', 1))

Buggy python submission (verdict: Runtime Error):
S = input()
S[3] = '8'
print(S)

Fixed submission:
S = input()
print(S.replace('7', '8', 1))

Buggy python submission (verdict: Runtime Error):
S = input()
print(S[3] = '8')

Fixed submission:
S = input()
print(S.replace('7', '8', 1))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input())
if a<c and c<b:
  print("Yes")
else:
  print("No")


Fixed submission:
a, b, c = map(int, input().split())
if a<c<b or b<c<a:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input())
if a<c<b:
  print("Yes")
else:
  print("No")

Fixed submission:
a, b, c = map(int, input().split())
if a<c<b or b<c<a:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *	
#from heapq import *
#from math import ceil
#from itertools import permutations ,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=0
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
def represent(n):
	s=""
	while n>0:
		s+=str(n%3)
		n//=3
	s=s[::-1]
	return s			

t=1
while t>0:
	t-=1
	a,b,c,d=mi()
	print(b*d)					





Fixed submission:
import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *	
#from heapq import *
#from math import ceil
#from itertools import permutations ,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
def represent(n):
	s=""
	while n>0:
		s+=str(n%3)
		n//=3
	s=s[::-1]
	return s			

t=1
while t>0:
	t-=1
	a,b,c,d=mi()
	maxi=-10**19
	for i in a,b:
		for j in c,d:
			maxi=max(maxi,i*j)		
	print(maxi)
Buggy python submission (verdict: Runtime Error):
from math import *
x,n=map(int,input().split())
a=[int(x) for x in input().split()]
s=[i for i in range(-100,105)]
s=set(s)-set(a)
s=list(s)
s.sort()
dif=10**18
#a.sort()
ans=s[0]
for i in range(len(s)):
	if abs(s[i]-x)<dif:
		dif=abs(s[i]-x)
		ans=s[i]
print(ans)		


Fixed submission:
a=[int(x) for x in input().split()]
print(a.index(0)+1)
Buggy python submission (verdict: Runtime Error):
from math import 8
x,n=map(int,input().split())
a=[int(x) for x in input().split()]
s=[i for i in range(-100,105)]
s=set(s)-set(a)
s=list(s)
s.sort()
dif=10**18
#a.sort()
ans=s[0]
for i in range(len(s)):
	if abs(s[i]-x)<dif:
		dif=abs(s[i]-x)
		ans=s[i]
print(ans)		


Fixed submission:
from math import *
x,n=map(int,input().split())
a=[int(x) for x in input().split()]
s=[i for i in range(-100,105)]
s=set(s)-set(a)
s=list(s)
s.sort()
dif=10**18
#a.sort()
ans=s[0]
for i in range(len(s)):
	if abs(s[i]-x)<dif:
		dif=abs(s[i]-x)
		ans=s[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import collections

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

d = collections.Counter(A)

for i in range(Q):
    B,C = list(map(int, input().split()))
    if B in d:
        val = d[B]
        if C in d:
            d[C] = d[C] + d[B]
        else:
            d[C] = d[B]
        d.pop(B)

    ans = 0
    for k, v in d.items():
        ans += k * v
    
    print(ans)

Fixed submission:
#!/usr/bin/env python3
import sys
import collections

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

d = collections.Counter(A)
ans = 0
for k, v in d.items():
    ans += k * v

for i in range(Q):
    B,C = list(map(int, input().split()))
    if B in d:
        val = d[B]
        ans -= B * d[B]
        ans += C * d[B]
        if C in d:
            d[C] = d[C] + d[B]
        else:
            d[C] = d[B]
        d.pop(B)

    print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N,M,X = list(map(int, input().split()))

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

ans = 1000000000
found = False

for i in range(2 ** N):
    tmp = [0] * (M + 1)
    books = np.array(tmp)
    for j in range(N): 
        if ((i >> j) & 1):
            books = books + np.array(C[j])

    skill_good = True
    for k in range(1,M+1):
        if books[k] < X:
            skill_good = False

    if books[0] < ans and skill_good:
        ans = books[0]
        found = True

if found:
    print(ans)
else:
    print(-1)
    


Fixed submission:
import numpy as np

N,M,X = list(map(int, input().split()))

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

ans = 1000000000
found = False

for i in range(2 ** N):
    tmp = [0] * (M + 1)
    books = np.array(tmp)
    for j in range(N): 
        if ((i >> j) & 1):
            books = books + np.array(C[j])

    skill_good = True
    for k in range(1,M+1):
        if books[k] < X:
            skill_good = False

    if books[0] < ans and skill_good:
        ans = books[0]
        found = True

if found:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import math
N = int(input())
A = list(map(int,input().split()))

def comb(n, r):
    if n > 1:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0

dict = {}

for i in range(N):
    if A[i] in dict.keys():
        dict[A[i]] = dict[A[i]] + 1
    else:
        dict[A[i]] = 1

combs = {}

for k in dict:
    combs[k] = comb(dict[k],2)


total = sum(combs.values())

for i in range(N):
    diff = combs[A[i]] - comb(dict[A[i]]-1,2)
    print(total - diff)



Fixed submission:
#!/usr/bin/env python3
import sys
N = int(input())
A = list(map(int,input().split()))

def comb(n):
    if n > 1:
        return n * (n-1) // 2
    else:
        return 0

dict = {}

for i in range(N):
    if A[i] in dict.keys():
        dict[A[i]] = dict[A[i]] + 1
    else:
        dict[A[i]] = 1

combs = {}

for k in dict:
    combs[k] = comb(dict[k])


total = sum(combs.values())

for i in range(N):
    diff = combs[A[i]] - comb(dict[A[i]]-1)
    print(total - diff)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

S = input()
Q = int(input())

reverse = False

ans = S

for i in range(Q):
    query = input()
    if query == "1":
        reverse = not reverse

    else:
        a,b,c = list(query.split())
        if (b == "1" and not reverse) or (b == "2" and reverse):
            t = [c,ans]
            ans = ''.join(t)
        else:
            t = [ans,c]
            ans = ''.join(t)

if reverse:
    print(ans[::-1])
else:
    print(ans)
            


Fixed submission:
#!/usr/bin/env python3

S = input()
Q = int(input())

reverse = False

mae = []
ushiro = []

for i in range(Q):
    query = input()
    if query == "1":
        reverse = not reverse

    else:
        a,b,c = list(query.split())
        if (b == "1" and not reverse) or (b == "2" and reverse):
            mae.append(c)
        else:
            ushiro.append(c)

if reverse:
    origin = [S[::-1]]
    ans = ushiro[::-1]
    ans.extend(origin)
    ans.extend(mae)
    print(''.join(ans))
else:
    ans = mae[::-1]
    origin = [S]
    ans.extend(origin)
    ans.extend(ushiro)
    print(''.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

S = input()
Q = int(input())

reverse = False

ans = S

for i in range(Q):
    query = input()
    if query == "1":
        reverse = not reverse

    else:
        a,b,c = list(query.split())
        if (b == "1" and not reverse) or (b == "2" and reverse):
            ans = c + ans
        else:
            ans = ans + c

if reverse:
    print(ans[::-1])
else:
    print(ans)
            


Fixed submission:
#!/usr/bin/env python3

S = input()
Q = int(input())

reverse = False

mae = []
ushiro = []

for i in range(Q):
    query = input()
    if query == "1":
        reverse = not reverse

    else:
        a,b,c = list(query.split())
        if (b == "1" and not reverse) or (b == "2" and reverse):
            mae.append(c)
        else:
            ushiro.append(c)

if reverse:
    origin = [S[::-1]]
    ans = ushiro[::-1]
    ans.extend(origin)
    ans.extend(mae)
    print(''.join(ans))
else:
    ans = mae[::-1]
    origin = [S]
    ans.extend(origin)
    ans.extend(ushiro)
    print(''.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, A: "List[int]"):
    for i in range(0,N):
        if (A[i] in A[i+1:]):
            print(NO)
            return

    print(YES)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, A: "List[int]"):
    p = sorted(A)
    for i in range(0,N-1):
        if (p[i] == p[i+1]):
            print(NO)
            return

    print(YES)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
# INPUT
input = list(map(int, input().split()))

s = input[0]
t = input[1]

ans = t
print(t+s)


Fixed submission:
# -*- coding: utf-8 -*-
import sys
# INPUT
input = list(map(str, input().split()))

s = input[0]
t = input[1]

print(t+s)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

def min(val: int, new: int):
    if new < val:
        return new
    else:
        return val

def solve(N: int, K: int, h: "List[int]"):
    dp = [sys.maxsize] * N
    dp[0] = 0

    for i in range(1,N):
        for j in range(1,K+1):
            if i-j >= 0:
                dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]))

    print(dp[N-1])

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

def min(val: int, new: int):
    if new < val:
        return new
    else:
        return val

def solve(N: int, K: int, h: "List[int]"):
    dp = [sys.maxsize] * N
    dp[0] = 0

    for i in range(1,N):
        for j in range(1,K+1):
            if i-j >= 0:
                dp[i] = min(dp[i],dp[i-j] + abs(h[i]-h[i-j]))

    print(dp[N-1])

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    s = 0
    while N:
        s += N%10
        s %= 9
        N //= 10
    if s%9 == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = input()
    s = 0
    for i in range(len(N)):
        s += int(N[i])
    if s%9 == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    s = 0
    while N:
        s += N%10
        s %= 9
        N //= 10
    if s%9 == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = input()
    s = 0
    for i in range(len(N)):
        s += int(N[i])
    if s%9 == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    s = 0
    while N:
        s += N%10
        N //= 10
    if s%9 == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = input()
    s = 0
    for i in range(len(N)):
        s += int(N[i])
    if s%9 == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    ans = 1
    for i in a:
        ans *= i
    INF = int(1e18)
    if ans > INF: 
        print(-1)
        return
    print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    for i in a:
        if i == 0:
            print(0)
            return
    ans = 1
    INF = int(1e18)
    for i in a:
        ans *= i
        if ans > INF:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

stp = -1 
def main():
    n, k = map(int, readline().split())
    a = [int(i)-1 for i in readline().split()]

    order = []
    ex = set()
    def dfs(node):
        global stp
        order.append(node)
        ex.add(node)
        nx = a[node]
        if nx in ex:
            stp = nx
            return
        dfs(nx)
    dfs(0)
    cnt = order.index(stp)
    m = len(order[cnt:])
    idx = (k-cnt)%m
    print(order[cnt:][idx]+1)
if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(100000000)

stp = -1 
def main():
    n, k = map(int, readline().split())
    a = [int(i)-1 for i in readline().split()]

    order = []
    ex = set()
    def dfs(node):
        global stp
        order.append(node)
        ex.add(node)
        nx = a[node]
        if nx in ex:
            stp = nx
            return
        dfs(nx)
    dfs(0)

    cnt = order.index(stp)
    if k < cnt:
        print(order[k]+1)
    else:    
        m = len(order[cnt:])
        idx = (k-cnt)%m
        print(order[cnt:][idx]+1)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    ans = 0
    for i in range(n):
        if (i%3==0) and (i%5==0):
            continue
        if (i%3==0):
            continue
        if (i%5==0):
            continue
        ans += i
    print(ans)
main(

Fixed submission:
def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        if (i%3==0) and (i%5==0):
            continue
        if (i%3==0):
            continue
        if (i%5==0):
            continue
        ans += i
    print(ans)
main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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


def main():
    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)
main()

Fixed submission:
import math
from functools import reduce

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


def main():
    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)
main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter 
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    d = Counter(A)
    for i in A:
        ans = 0
        for key, val in d.items():
            if i == key:
                val -= 1
            ans += val*(val-1)//2 
        print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
#python3
from collections import Counter
def C2(x):
    return x*(x-1)//2

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    d = Counter(a) 
    pans = 0
    for v in d.values():
        pans += C2(v)

    for k in range(n):
        p = pans
        val = d[a[k]]
        p = p - C2(val) + C2(val-1)
        print(p)
main()