Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque
n,k = map(int,input().split())
a = list(map(int,input().split()))
li = [1,]
ans = [0] * n 
tmp = 1
ind = []
count = 0
for i in range(10**5):
    li.append(a[tmp-1])
    ans[tmp-1] += 1
    tmp = a[tmp-1]
    for j in range(len(ans)):
        if ans[j] == 2:
            count = sum(ans) -1
            ind.append(a[tmp-1])
            ans[j] = 3
    if any(item > 3 for item in ans):
        break
q = deque(ind)
q.rotate(-1)
s = count-2*len(ind)-1
if s >= k:
    print(li[k])
else:
    print(q[k%len(q)-s])

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
 
visited = []
tf_visited = [0] * n
pos = 0
count = 0
 
while tf_visited[pos] == 0:
	visited.append(pos)
	tf_visited[pos] = 1
	pos = a[pos]-1
	count += 1
	if count >= k:
		print(pos+1)
		exit()
 
loop_start = visited.index(pos)
loop_length = len(visited)-loop_start
pos_t = (k-loop_start) % loop_length + loop_start
print(visited[pos_t]+1)

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
li = [1,]
ans = [0] * n 
tmp = 1
ind = []
count = 0
for i in range(10**5):
    li.append(a[tmp-1])
    ans[tmp-1] += 1
    tmp = a[tmp-1]
    for j in range(len(ans)):
        if ans[j] == 2:
            count = sum(ans) -1
            ind.append(j)
            ans[j] = 3
    if any(item > 3 for item in ans):
        break
s = count-2*len(ind)-1

if k <= s:
    print(a[k])
else:
    print(a[ind[(k-s+1) % (s+1) -2]])

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
 
visited = []
tf_visited = [0] * n
pos = 0
count = 0
 
while tf_visited[pos] == 0:
	visited.append(pos)
	tf_visited[pos] = 1
	pos = a[pos]-1
	count += 1
	if count >= k:
		print(pos+1)
		exit()
 
loop_start = visited.index(pos)
loop_length = len(visited)-loop_start
pos_t = (k-loop_start) % loop_length + loop_start
print(visited[pos_t]+1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n = map(int,input().split())
x = 0
max_f = 0
for i in range(n+1):
    f = math.floor(a * x / b) - a * math.floor(x/b)
    if f > max_f:
        max_f = f
    x += 1
print(max_f)

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

f_max = 0
if n >= b-1:
    f_max = b-1
else:
    f_max = n
print(math.floor(a * f_max / b) - a * math.floor(f_max/b))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
counts = [0]*2019
counts[0] += 1
num = 0
d = 1
for c in reversed(s):
    num += int(c)%2019 * d%2019
    counts[num % 2019] += 1
    d *= 10
ans = 0
for count in counts:
    ans += count*(count -1) // 2
print(ans)


Fixed submission:
s = input()
counts = [0]*2019
counts[0] += 1
num = 0
d = 1
for c in reversed(s):
    num += int(c) * d
    counts[num % 2019] += 1
    d *= 10
    d %= 2019
ans = 0
for count in counts:
    ans += count*(count -1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
counts = [0]*2019
counts[0] += 1
num = 0
digit = 0
for c in reversed(s):
    num += int(c) * 10**digit
    counts[num % 2019] += 1
    digit += 1
ans = 0
for count in counts:
    ans += count*(count -1) // 2
print(ans)

Fixed submission:
s = input()
counts = [0]*2019
counts[0] += 1
num = 0
d = 1
for c in reversed(s):
    num += int(c) * d
    counts[num % 2019] += 1
    d *= 10
    d %= 2019
ans = 0
for count in counts:
    ans += count*(count -1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
count = 0
a = ''
for i in range(len(s)-3):
    for j in range(i,len(s)):
        a += s[j]
        ans = int(a)
        if ans % 2019 == 0:
            count += 1
    a = ''
    ans = 0
print(count)

Fixed submission:
s = input()
counts = [0]*2019
counts[0] += 1
num = 0
d = 1
for c in reversed(s):
    num += int(c) * d
    counts[num % 2019] += 1
    d *= 10
    d %= 2019
ans = 0
for count in counts:
    ans += count*(count -1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
count = 0
for i in range(len(s)-3):
    for j in range(i+3,len(s)+1):
        ans = int(s[i:j])
        if ans % 2019 == 0:
            count += 1
print(count)


Fixed submission:
s = input()
counts = [0]*2019
counts[0] += 1
num = 0
d = 1
for c in reversed(s):
    num += int(c) * d
    counts[num % 2019] += 1
    d *= 10
    d %= 2019
ans = 0
for count in counts:
    ans += count*(count -1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
count = 0
for i in range(len(s)):
    for j in range(i+3,len(s)+1):
        ans = int(s[i:j])
        if ans % 2019 == 0:
            count += 1
print(count)

Fixed submission:
s = input()
counts = [0]*2019
counts[0] += 1
num = 0
d = 1
for c in reversed(s):
    num += int(c) * d
    counts[num % 2019] += 1
    d *= 10
    d %= 2019
ans = 0
for count in counts:
    ans += count*(count -1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r = [-1]*n
g = [-1]*n
b = [-1]*n
count = 0
for i in range(len(s)):
    if s[i] == 'R':
        r[count] = i+1
    elif s[i] == 'G':
        g[count] = i+1
    else:
        b[count] = i+1
    count += 1
ans = 0
for i in r:
    if i == -1:
        continue
    for j in g:
        if j == -1:
            continue
        for k in b:
            if k == -1:
                continue
            if j-i != k-j and i-j != k-i and k-i != j-k:
                ans += 1
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = s.count('R')*s.count('G')*s.count('B')
for i in range(n):
    for j in range(i+1,n):
        k = j - i + j
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]:
            ans-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
flg = False
for i in range(len(S)/2-1):
    if S[i] == S[len(S)-i]:
        flg = True
    else:
        flg = False
for i in range(((len(S)-1) /2 -1)/2):
    if S[i] == S[(len(S)-1)/2-i]:
        pass
    else:
        flg = False
for i in range((len(S)-(len(S)+3)/2 -1)/2):
    if S[i] == S[(len(S)+3)/2 -i]:
        pass
    else:
        flg = False
 
if flg:
    print('Yes')
else:
    print('No')

Fixed submission:
N,M = map(int,input().split())
print(int(N*(N-1)/2 + M*(M-1)/2))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
print(math.factorial(N) + math.factorial(M))

Fixed submission:
N,M = map(int,input().split())
print(int(N*(N-1)/2 + M*(M-1)/2))
Buggy python submission (verdict: Runtime Error):
S = input()
flg = False
for i in range(len(S)//2):
    if S[i] == S[len(S)-i]:
        flg = True
    else:
        flg = False
for i in range((len(S)-1) //2//2):
    if S[i] == S[(len(S)-1)//2-i]:
        pass
    else:
        flg = False
for i in range((len(S)-(len(S)+3)//2)//2):
    if S[i] == S[(len(S)+3)//2 -i]:
        pass
    else:
        flg = False

if flg:
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
r1 = s[::-1]
n = len(s)
r2 = s[0:(n-1)//2]
r2r = r2[::-1]
r3 = s[(n+3)//2-1:]
r3r = r3[::-1]
if s == r1 and r2 == r2r and r3 == r3r:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
S = input()
flg = False
for i in range(len(S)):
    if S[i] == S[len(S)-i]:
        flg = True
    else:
        flg = False
for i in range((len(S)-1) /2):
    if S[i] == S[(len(s)-1)/2-i]:
        pass
    else:
        flg = False
for i in range((len(S)+3)/2, N):
    if S[i] == S[(len(S)+3)/2) -i]:
        pass
    else:
        flg = False

if flg:
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
r1 = s[::-1]
n = len(s)
r2 = s[0:(n-1)//2]
r2r = r2[::-1]
r3 = s[(n+3)//2-1:]
r3r = r3[::-1]
if s == r1 and r2 == r2r and r3 == r3r:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from math import factorial
n = int(input())
a = list(map(int,input().split()))
ans = []
for it in itertools.combinations(a,2):
    if it[0] == it[1]:
        ans.append(it[0])
for i in range(n):
    if a[i] in ans:
        print(len(ans)-a.count(a[i])+1)
    else:
        print(len(ans))

Fixed submission:
from collections import Counter
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
    cnt += c * (c-1) // 2
for a in An:
    print(cnt - (counter[a] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
a = list(map(int,input().split()))
tmp = 0
#ans = [0]*n
for i in range(n):
    tmp = a[i]
    a[i] = 0
    count = 0
    for it in itertools.combinations(a,2):
        if it[0] == it[1]:
            count += 1
    print(count)
    a[i] = tmp

Fixed submission:
from collections import Counter
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
    cnt += c * (c-1) // 2
for a in An:
    print(cnt - (counter[a] - 1))
Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b = map(int,input().split())
i = 0
while True:
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        print(i)
        exit()
    i+=1
print(-1)

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

max = math.ceil(a*100/8)*math.ceil(b*10)

for i in range(1, max+1):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        print(i)
        exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
ans = [0] * n
flg = [0] * n
for i in range(m):
    s[i],c[i] = map(int,input().split())
for j in range(m):
    if flg[s[j]-1] == 1 and ans[s[j]-1] != c[j]:
        print(-1)
        exit()
    else:
        ans[s[j]-1] = c[j]
        flg[s[j]-1] = 1
    
if n > 1 and flg[0] == 1 and ans[0] == 0 :
    print(-1)
elif n > 1 and flg[0] == 0:
    ans[0] = 1
    print(''.join(map(str,ans)))
    exit()
else:
    print(''.join(map(str,ans)))

Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N//2)
else:
    print(N//2 + 1)
Buggy python submission (verdict: Runtime Error):
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
listb = [input() for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[1] == A2[2] == A3[3] or A1[3] == A2[2] == A3[1]:
    print('Yes')
    exit()
print('No')

Fixed submission:
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
listb = [int(input()) for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[0] == A2[1] == A3[2] or A1[2] == A2[1] == A3[0]:
    print('Yes')
    exit()
print('No')

Buggy python submission (verdict: Runtime Error):
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
listb = [input() for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
flg = false
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[1] == A2[2] == A3[3] or A1[3] == A2[2] == A3[1]:
    print 'Yes'
    exit()
print('No')

Fixed submission:
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
listb = [int(input()) for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[0] == A2[1] == A3[2] or A1[2] == A2[1] == A3[0]:
    print('Yes')
    exit()
print('No')
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
ans = [0] * n
flg = [0] * n
for i in range(m):
    s[i],c[i] = map(int,input().split())
for j in range(m):
    if: flg[s[j]-1] == 1 and ans[s[j]-1] != c[j]:
        print(-1)
        exit()
    else:
        ans[s[j]-1] = c[j]
        flg[s[j]-1] = 1
    
if n > 1 and ans[0] == 0 :
    print(-1)
else:
    print(''.join(map(str,ans)))


Fixed submission:
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
ans = [0] * n
flg = [0] * n
for i in range(m):
    s[i],c[i] = map(int,input().split())
for j in range(m):
    if flg[s[j]-1] == 1 and ans[s[j]-1] != c[j]:
        print(-1)
        exit()
    else:
        ans[s[j]-1] = c[j]
        flg[s[j]-1] = 1
    
if n > 1 and flg[0] == 1 and ans[0] == 0 :
    print(-1)
elif n > 1 and flg[0] == 0:
    ans[0] = 1
    print(''.join(map(str,ans)))
    exit()
else:
    print(''.join(map(str,ans)))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
a = list(map(int,input().split()))
v = itertools.combinations(a,2)
for item in v:
    if item[0] == item[1]:
        print('NO')
        exit()
print('YES')

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if len(a) == len(set(a)):
    print('YES')
else:
    print('NO')

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

for v in itertools.combinations(a,2):
    if v[0] == v[1]:
        print('NO')
        exit()
print('YES')

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if len(a) == len(set(a)):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
count = [0] * n
for i in range(n):
    for j in range(i+1):
        if p[i] <= p[j]:
            count[i] = 1
        else:
            count[i] = 0
            break
print(sum(count))

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
count = 0
p_min = p[0]
for i in range(n):
    if p_min >= p[i]:
        count+=1
    p_min = min(p[i],p_min)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
p = list(map(int,input().split()))
li = []
count = 0
for i in range(n):
    min_p = 0
    li.append(p[i])
    for j in range(len(li)):
        min_p = min(p[i],li[j])
        if min_p != p[i]:
            break
    if min_p == p[i]:
        count+=1
print(count)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
count = 0
p_min = p[0]
for i in range(n):
    if p_min >= p[i]:
        count+=1
    p_min = min(p[i],p_min)
print(count)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ps = [0] * m
p = [0] * m
s = [0] * m
for i in range(m):
    ps[i] = list(map(str,input().split()))
if m = 0:
    print(0,0)
    exit()
cp=int(ps[0][0])
countA = [0] * n
countW = 0
cn = 0
for item in ps:
    if item[1] == 'AC':
        countA[int(item[0])-1] = 1
        countW += cn
        cp += 1
        cn = 0
    else:
        cn+=1
print(sum(countA),countW)

Fixed submission:
n,m = map(int,input().split())
ps = [0] * m
for i in range(m):
    ps[i] = list(map(str,input().split()))
if m == 0:
    print(0,0)
    exit()
countA = [0] * n
countW = [0] * n
cn = 0
for item in ps:
    if item[1] == 'AC' and countA[int(item[0])-1] == 0:
        countA[int(item[0])-1] = 1
        cn += countW[int(item[0])-1]
    else:
        countW[int(item[0])-1] += 1
print(sum(countA),cn)
Buggy python submission (verdict: Runtime Error):
import math
a,b= map(int,input().split())
print(a*b//math.gcd(a,b))

Fixed submission:
from fractions import gcd
a,b= map(int,input().split())
print(a*b//gcd(a,b))

Buggy python submission (verdict: Runtime Error):
import math
a,b= map(int,input().split())
print(a*b//math.gcd(a,b))

Fixed submission:
from fractions import gcd
a,b= map(int,input().split())
print(a*b//gcd(a,b))
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
a = [0] * n
xy = []
for i in range(n):
    a[i] = int(input())
    x_y = []
    for j in range(a[i]):
        x_y.append(list(map(int,input().split())))
    xy.append(x_y)

ans = 0
for it in itertools.product([0,1],repeat=n):
    li = [0] * n
    for i in range(len(a)):
        for k in range(n):
            for j in range(a[i]):
                if it[k] == 1:
                    if xy[k][j][1]==0:
                        li[xy[k][j][0]-1] = -1
                    else:
                        li[xy[k][j][0]-1] = 1
    flg = True                        
    for l in range(n):
        if li[l] == -1 and it[l] == 1 or li[l] == 1 and it[l] == -1 or li[l] == 1 and it[l] == 0:
            flg = False
    if flg:

        if ans < sum(it):
            ans = sum(it)
print(ans)

Fixed submission:
n = int(input())
shougen=[[-1]*(n+1) for _ in range(n+2)]
for i in range(1,n+1):
  a = int(input())
  for j in range(a):
    x,y = map(int, input().split())
    shougen[i][x]=y
 
ans=0
for i in range(2**n):
  f=True
  for j in range(n):
    if i>>j & 1:
      for k,s in enumerate(shougen[j+1][1:],start=0):
        if s == 1 and not i>>k & 1:
          f=False
        if s == 0 and i>>k & 1:
          f=False
  else:
    if f:
      ans=max(ans, str(bin(i)).count("1"))
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
l = []
for it in itertools.combinations_with_replacement(divisor(n),2):
    if it[0] * it[1] == n:
        l.append(it[0] + it[1] -2)
print(sorted(l)[0])

Fixed submission:
import itertools
n = int(input())
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
d = divisor(n)
l = float('inf')
for i in range(len(d)):
    l = min(n // d[i] + d[i] - 2,l)
print(l)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
l = float("inf")
for it in itertools.combinations_with_replacement(divisor(n),2):
    if it[0] * it[1] == n:
        l = min(it[0] -1 + it[1] -1,l)
print(l)

Fixed submission:
import itertools
n = int(input())
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
d = divisor(n)
l = float('inf')
for i in range(len(d)):
    l = min(n // d[i] + d[i] - 2,l)
print(l)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a = [0] * q
for i in range(q):
    a[i] = int(input())

for i in range(n):
    if(k-q+a.count(i+1)>0):
        print('Yes')
    else:
        print('No')

Fixed submission:
N,K,Q = map(int, input().split())
List = [int(input()) for i in range(Q)]
PList=[K-Q]*N
for i in range(0,Q):
    PList[(List[i])-1]+=1
for j in range(0,N):
    if PList[j]>0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a = [0] * q
for i in range(q):
    a[i] = int(input())

point = [k] * n
for i in range(q):
    for j in range(n):
        if a[i]-1 != j:
            point[j] -= 1
for i in range(n):
    if(point[i] > 0):
        print('Yes')
    else:
        print('No')

Fixed submission:
N,K,Q = map(int, input().split())
List = [int(input()) for i in range(Q)]
PList=[K-Q]*N
for i in range(0,Q):
    PList[(List[i])-1]+=1
for j in range(0,N):
    if PList[j]>0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())
li = list(range(1,n+1))
q = deque(li)
q.rotate(-1)
count = 1
ans = 0
for q_i in q:
    ans += count % q_i
    count += 1
print(ans)

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s = [0] * n
c = [0] * n
count = 0
for i in range(n):
    s[i] = input()
    c[i] = collections.Counter(s[i])
    for j in range(i):
        if c[i] == c[j]:
            count+=1
print(count)

Fixed submission:
import collections
n = int(input())
s = [0] * n
c = [0] * n

count = 0
for i in range(n):
    s[i] = input()
    c[i] = ''.join(sorted(s[i]))
for i in collections.Counter(c).values():
    count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s = [0] * n
c = [0] * n
count = 0
for i in range(n):
    s[i] = input()
    c[i] = collections.Counter(s[i])
for i in range(n):
    for j in range(i+1,n):
        if c[i] == c[j]:
            count += 1
print(count)

Fixed submission:
import collections
n = int(input())
s = [0] * n
c = [0] * n

count = 0
for i in range(n):
    s[i] = input()
    c[i] = ''.join(sorted(s[i]))
for i in collections.Counter(c).values():
    count += i*(i-1)//2
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
for i in range(n):
    if i == 0:
        li_s=0
    else:
        li_s = max(a[:i])
    if i == n-1:
        li_g = 0
    else:
        li_g = max(a[i+1:])
    print(max(li_s,li_g))

Fixed submission:
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
sorted_a = sorted(a, reverse=True)
max_a = sorted_a[0]
for i in range(n):
    if max_a != a[i]:
        print(max_a)
    else:
        print(sorted_a[1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
for i in range(n):
    li_s = max(a[:i])
    li_g = max(a[i+1:])
    print(max(li_s,li_g))

Fixed submission:
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
sorted_a = sorted(a, reverse=True)
max_a = sorted_a[0]
for i in range(n):
    if max_a != a[i]:
        print(max_a)
    else:
        print(sorted_a[1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] * n
li = [0] * (n-1)
for i in range(n):
    a[i] = int(input())
for i in range(n):
    li_s = a[:i]
    li_g = a[i+1:]
    li_max = max(li_s,li_g)
    print(max(li_max))

Fixed submission:
n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
sorted_a = sorted(a, reverse=True)
max_a = sorted_a[0]
for i in range(n):
    if max_a != a[i]:
        print(max_a)
    else:
        print(sorted_a[1])