Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[0])==0:
        print('A')
        break
    elif len(s[1])==0:
        print('B')
        break
    elif len(s[1])==0:
        print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after
    

Fixed submission:
s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[now]) == 0:
        if now == 0:
            print('A')
        if now == 1:
            print('B')   
        if now == 2:
            print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

k = int(input())

cnt = 1
mod = 7

for i in range(k):
    if mod%k == 0:
        break
    cnt+=1
    mod = mod*10 + 7

if mod%k == 0:
    print(cnt)
else:
    print(-1)

Fixed submission:
k = int(input())

cnt = 1
mod = 7

for i in range(k):
    if mod%k == 0:
        break
    cnt+=1
    mod = (mod*10 + 7)%k

if mod%k == 0:
    print(cnt)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
number = 1

while number <= N:
    
    for i in range(1,N+1):
        for j in range(1,N+1):
            for k in range(1,N+1):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == number:
                    cnt += 1
                else:
                    continue
    print(cnt)
    cnt = 0
    number += 1


Fixed submission:
N = int(input())
ans_list = [0 for _ in range(1,10100)]

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            value = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if value <= 10000:
                ans_list[value] += 1

for i in range(1, N+1):
    print(ans_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
number = 1

while number <= N:
    
    for i in range(1,N+1):
        for j in range(1,N+1):
            for k in range(1,N+1):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == number:
                    cnt += 1
                else:
                    continue
    print(cnt)
    cnt = 0
    number += 1

Fixed submission:
N = int(input())
ans_list = [0 for _ in range(1,10100)]

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            value = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if value <= 10000:
                ans_list[value] += 1

for i in range(1, N+1):
    print(ans_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
number = 1

while number <= N:
    
    for i in range(1,N+1):
        for j in range(1,N+1):
            for k in range(1,N+1):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == number:
                    cnt += 1
                else:
                    continue
    print(cnt)
    cnt = 0
    number += 1
            
    

Fixed submission:
N = int(input())
ans_list = [0 for _ in range(1,10100)]

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            value = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if value <= 10000:
                ans_list[value] += 1

for i in range(1, N+1):
    print(ans_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
number = 1

while number <= N:
    
    for i in range(1,N+1):
        for j in range(1,N+1):
            for k in range(1,N+1):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == number:
                    cnt += 1
                else:
                    continue
    print(cnt)
    cnt = 0
    number += 1

Fixed submission:
N = int(input())
ans_list = [0 for _ in range(1,10100)]

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            value = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if value <= 10000:
                ans_list[value] += 1

for i in range(1, N+1):
    print(ans_list[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    test = input()
    if test == "AC":
        c0 += 1
    elif test == "WA":
        c1 += 1
    elif test == "TLE":
        c2 +=1
    elif test == "RE":
        c3 += 1
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
ptint("RE x", c3)

Fixed submission:
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    test = input()
    if test == "AC":
        c0 += 1
    elif test == "WA":
        c1 += 1
    elif test == "TLE":
        c2 +=1
    elif test == "RE":
        c3 += 1
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
print("RE x", c3)

Buggy python submission (verdict: Runtime Error):
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    test = input()
    if test == "AC":
        c0 += 1
    elif test == "WA":
        c1 += 1
    elif test == "TLE":
        c2 +=1
    elif test == "RE":
        c3 += 1
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
ptinr("RE x", c3)

Fixed submission:
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0

for i in range(n):
    test = input()
    if test == "AC":
        c0 += 1
    elif test == "WA":
        c1 += 1
    elif test == "TLE":
        c2 +=1
    elif test == "RE":
        c3 += 1
print("AC x", c0)
print("WA x", c1)
print("TLE x", c2)
print("RE x", c3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
q = int(input())

for i in range(q):
    b, c = map(int, input().split())
    newlist = a_list
    for j in range(n):
        if newlist[j] == b:
          newlist[j] = c
          ans = sum(newlist)
    print(ans)


Fixed submission:
a = str(input())

if ord(a) < ord ("a"):
    print("A")
else:
    print("a")

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

for i in range(q):
    b, c = map(int, input().split())
    newlist = a_list
    for j in range(n):
        if newlist[j] == b:
          newlist[j] = c
          ans = sum(newlist)
    print(ans)


Fixed submission:
a = str(input())

if ord(a) < ord ("a"):
    print("A")
else:
    print("a")

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

for i in range(q):
    b, c = map(int, input().split())
    newlist = a_list
    for j in range(n):
        if newlist[j] == b:
          newlist[j] = c
          ans = sum(newlist)
    print(ans)

Fixed submission:
a = str(input())

if ord(a) < ord ("a"):
    print("A")
else:
    print("a")
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
a = y - 2*x
if a < 0:
    print("No")
elif a > x:
    print("No")
elif a % 2 == 0:
    print("Yes")
elif a == 0:
    print("Yes")

Fixed submission:
a, b, c, d, e = map(int, input().split())
if a == 0:
    print(1)
elif b == 0:
    print(2)
elif c == 0:
    print(3)
elif d == 0:
    print(4)
else:
    print(5)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            break
print(ans)

Fixed submission:
a,b = map(int, input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

x = min(a, k)
a -= x
k -= x
y = min(b, k)
b -= y

print(str(a),str(b))

Fixed submission:
n = int(input())
S, T = input().split()

ans = ""

for i in range(n):
    ans += S[i]+T[i]
    
print(ans)
Buggy python submission (verdict: Runtime Error):
x, a = map(int, input().split())
if s < a:
    print(0)
else:
    print(10)

Fixed submission:
x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
n = int(input())
restaurant = [input().split() for i in range(n)]
restaurant_sorted = sorted(restaurant)

for i in range(n):
    print(restaurant.index((restaurant_sorted[i]))

Fixed submission:
N = int(input())

L = []

for i in range(N):
    s,p = input().split()
    L.append([s, 100-int(p), i+1])
L.sort()
for j in L:
    print(j[2])
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        cnt[survey[j-1]] += 1
    
ans = survey.count(n)
print(ans)

Fixed submission:
n,m = map(int, input().split())

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        favorite = survey[j]
        cnt[favorite - 1] += 1

print(cnt.count(n))

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

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        cnt[survey[j-1]] += 1
    
ans = survey.count(n)
print(ans)

Fixed submission:
n,m = map(int, input().split())

cnt = [0]*m

for i in range(n):
    survey = list(map(int, input().split()))
    k = survey[0]
    for j in range(1,k+1):
        favorite = survey[j]
        cnt[favorite - 1] += 1

print(cnt.count(n))
Buggy python submission (verdict: Runtime Error):
H,W = map(int, input().split())

C = [input() for i in range(W)]

for i in range(W):
    print(C[i])
    print(C[i])

Fixed submission:
H,W = map(int, input().split())

for i in range(H):
    x = input()
    print(x)
    print(x)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())

if len(a) == 7:
    if len(b) == 5 and len(c) == 5:
        print("Yes")
    else:
        print("No")
        
if len(b) == 7:
    if len(a) == 5 and len(c) == 5:
        print("Yes")
    else:
        print("No")

if len(c) == 7:
    if len(a) == 5 and len(b) == 5:
        print("Yes")
    else:
        print("No")


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

A_sort = sorted(A)

if A_sort[0]==5 and A_sort[1]==5 and A_sort[2]==7:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]

par = [i for i in range(n + 1)]
rank = [1 for _ in range(n + 1)]

def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

for a, b in edges:
    unite(a, b)
memo = []
ans = 0
for i in range(1, n + 1):
    if root(i) not in memo:
        memo.append(root(i))
        ans += 1
print(ans - 1)

Fixed submission:
n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]

par = [i for i in range(n + 1)]
rank = [1 for _ in range(n + 1)]

def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

for a, b in edges:
    unite(a, b)
memo = [False for _ in range(n + 1)]
ans = 0
for i in range(1, n + 1):
    r = root(i)
    if memo[r] == False:
        memo[r] = True
        ans += 1

print(ans - 1)
Buggy python submission (verdict: Runtime Error):
s = input()

ans = 0
if s == 'RRR':
    print(3)
    exit()
elif s[0] == 'R' and s[1] == 'R':
    print(2)
    exit()
elif s[1] == 'R' and s[2] == 'R':
    print(2)
    eixt()
elif 'R' in s:
    print(1)
    exit()
else:
    print(0)

Fixed submission:
s = input()

if s == 'RRR':
    print(3)
    exit()
elif s == 'SSS':
    print(0)
    exit()
elif s[:2] == 'RR' or s[1:] == 'RR':
    print(2)
    exit()
elif 'R' in s:
    print(1)
    exit()
else:
    print(0)
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_A = [0 for _ in range(n+1)] # sum_A[i]:=上からi冊の本を読むときにかかる時間
for i in range(1, n+1):
    sum_A[i] = sum_A[i-1] + A[i-1]
sum_B = [0 for _ in range(m+1)] # sum_B[i]:=上からj冊の本を読むときにかかる時間
for j in range(1, m+1):
    sum_B[j] = sum_B[j-1] + B[j-1]

ans = 0
i = 0
while i <= n and sum_A[i] <= k:
    j = 0
    while j <= m and sum_A[i] + sum_B[j] <= k:
        j += 1
    ans = max(ans, i + j-1)
    i += 1
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_A = [0 for _ in range(n+1)] # sum_A[i]:=上からi冊の本を読むときにかかる時間
for i in range(1, n+1):
    sum_A[i] = sum_A[i-1] + A[i-1]
sum_B = [0 for _ in range(m+1)] # sum_B[i]:=上からj冊の本を読むときにかかる時間
for j in range(1, m+1):
    sum_B[j] = sum_B[j-1] + B[j-1]

ans = 0
i = 0
j = m
while i <= n and sum_A[i] <= k:
    while sum_A[i] + sum_B[j] > k:
        j -= 1
    ans = max(ans, i + j)
    i += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
for a in range(x + 1):
    b = x - a
    if (2 * a + 4 * b) == y:
        print('Yes')
        exit()
print('No')

Fixed submission:
x, y = map(int, input().split())

for a in range(x + 1):
    b = x - a
    if (2 * a + 4 * b) == y:
        print('Yes')
        exit()
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

ans = 1
for a in A:
    ans = ans * a

if ans > pow(10, 18):
    print(-1)
else:
    print(ans)

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

if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans = ans * a
    if ans > pow(10, 18):
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans = ans * a
    if ans > pow(10, 18):
        print(-1)
        exit()
print(ans)

Fixed submission:
a, b = input().split()
a, b = int(a), int(b.replace('.', ''))
print((a * b) // 100)
Buggy python submission (verdict: Runtime Error):
import sys
sys.stdin = open('input.txt', 'r', encoding='utf-8')

s = input()
t = input()

if t == s + t[-1]:
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
t = input()

if t == s + t[-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

from operator import mul
from functools import reduce
from collections import Counter

def cmb(n,r):
    if r > n:
        return 0
    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

dict = Counter(A)

dict_cmb = {}
for k, v in dict.items():
    dict_cmb[k] = (cmb(v, 2), cmb(v-1, 2))

for a in A:
    ans = 0
    for k, v in dict_cmb.items():
        if a != k:
            ans += v[0]
        else:
            ans += v[1]
    print(ans)

Fixed submission:
from collections import Counter

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

A_cnt = Counter(A)

x = 0
for i in A_cnt.values():
    x += i * (i-1) // 2

for a in A:
    ans = x - (A_cnt[a] * (A_cnt[a]-1) // 2)
    ans += (A_cnt[a]-1) * (A_cnt[a]-2) // 2
    print(ans)

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

from operator import mul
from functools import reduce
from collections import Counter

def cmb(n,r):
    if r > n:
        return 0
    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

dict = Counter(A)

dict_cmb = {}
for k, v in dict.items():
    dict_cmb[k] = (cmb(v, 2), cmb(v-1, 2))

for a in A:
    ans = 0
    for k, v in dict_cmb.items():
        if a != k:
            ans += v[0]
        else:
            ans += v[1]
    print(ans)

Fixed submission:
from collections import Counter

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

A_cnt = Counter(A)

x = 0
for i in A_cnt.values():
    x += i * (i-1) // 2

for a in A:
    ans = x - (A_cnt[a] * (A_cnt[a]-1) // 2)
    ans += (A_cnt[a]-1) * (A_cnt[a]-2) // 2
    print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for _ in range(M)]

minP = min(a) + min(b)
for x, y, c in xyc:
    minP = min(a[x-1]+b[x-1]-c, minP)
print(minP)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for _ in range(M)]

minP = min(a) + min(b)
for x, y, c in xyc:
    minP = min(a[x-1]+b[y-1]-c, minP)
print(minP)
Buggy python submission (verdict: Runtime Error):
n, r = map(int, input().split())

if n >= 10:
    print(r)
else:
    print(r + 100*(10-n)))

Fixed submission:
n, r = map(int, input().split())

if n >= 10:
    print(r)
else:
    print(r + 100*(10-n))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for x in range(N)]

S_L = list(set(S))

# for i in S:
    # if i not in S_L:
        # S_L.append(i)
# print(S_L)

S_N = [0] * len(S_L)

for j in S:
    ind = S_L.index(j)
    S_N[ind] += 1
# print(S_N)

S_max = [] # 最大の数を持つ文字列を入れるリスト
S_N_max = max(S_N) # 最大の数を追加

for k in range(len(S_N)):
    if S_N[k] == S_N_max:
        S_max.append(S_L[k])

ans_L = sorted(S_max)

print(*ans_L, sep='\n')

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]

S_cnt = Counter(S)
max_cnt = max(S_cnt.values())
# print(max_cnt)

names = [name for name, v in S_cnt.items() if v == max_cnt]
names.sort()

print(*names, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for x in range(N)]

S_L = list(set(S))

# for i in S:
    # if i not in S_L:
        # S_L.append(i)
# print(S_L)

S_N = [0] * len(S_L)

for j in S:
    ind = S_L.index(j)
    S_N[ind] += 1
# print(S_N)

S_max = [] # 最大の数を持つ文字列を入れるリスト
S_N_max = max(S_N) # 最大の数を追加

for k in range(len(S_N)):
    if S_N[k] == S_N_max:
        S_max.append(S_L[k])

ans_L = sorted(S_max)

ans = ''
cnt = 0
rng = len(ans_L)
while cnt < rng:
    ans += ans_L[cnt]
    cnt += 1
    if cnt != rng:
        ans += ' '
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]

S_cnt = Counter(S)
max_cnt = max(S_cnt.values())
# print(max_cnt)

names = [name for name, v in S_cnt.items() if v == max_cnt]
names.sort()

print(*names, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for x in range(N)]

S_L = []

for i in S:
    if i not in S_L:
        S_L.append(i)
# print(S_L)

S_N = [0] * len(S_L)

for j in S:
    ind = S_L.index(j)
    S_N[ind] += 1
# print(S_N)

S_max = [] # 最大の数を持つ文字列を入れるリスト
S_N_max = max(S_N) # 最大の数を追加

for k in range(len(S_N)):
    if S_N[k] == S_N_max:
        S_max.append(S_L[k])

ans_L = sorted(S_max)
ans = ''
cnt = 0
while cnt < len(ans_L):
    ans += ans_L[cnt]
    cnt += 1
    if cnt != len(ans_L):
        ans += ' '
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]

S_cnt = Counter(S)
max_cnt = max(S_cnt.values())
# print(max_cnt)

names = [name for name, v in S_cnt.items() if v == max_cnt]
names.sort()

print(*names, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))

E = []
for i in P:
    E.append((i+1)/2)
# print(E)

sum_E = [0, ]
for i in range(N):
    sum_E.append(sum(E[0:i+1]))
# print(sum_E)

sum_K = []
ans = 0
for i in range(N-K+1):
    if sum_E[i+K] - sum_E[i] > ans:
        ans = sum_E[i+K] - sum_E[i]
print(ans)


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

E = []
for i in P:
    E.append((i+1)/2)
# print(E)

sum_E = [0, ]
for i in range(N):
    sum_E.append(sum_E[i] + E[i])
# print(sum_E)

sum_K = []
ans = 0
for i in range(N-K+1):
    if sum_E[i+K] - sum_E[i] > ans:
        ans = sum_E[i+K] - sum_E[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

if n <= k:
    print(0)
    exit()

for i in range(k):
    h.remove(max(h))
print(sum(h))


Fixed submission:
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())), reverse=True)

if n <= k:
    print(0)
    exit()
del h[0:k]
print(sum(h))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n):
    if p[i] <= min(p[0:i+1]):
        ans += 1
print(ans)


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

ans = 0
p_min = p[0]
for i in range(n):
    if p[i] <= p_min:
        ans += 1
        p_min = p[i]
print(ans)

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

ans = 0
for i in range(n):
    if all(p[i] <= p[j] for j in range(i)):
        ans += 1
print(ans)


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

ans = 0
p_min = p[0]
for i in range(n):
    if p[i] <= p_min:
        ans += 1
        p_min = p[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
prime_table = []

def judge(n):
    for i in prime_table:
        if n%i == 0:
            return False
    prime_table.append(n)
    return True

num = 1
p = True
while p == True:
    num += 1
    if judge(num) == True:
        if num >= x:
            p = False

print(num)

Fixed submission:
x = int(input())

def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, x):
        if x%i == 0:
            return False
    return True

while is_prime(x) == False:
    x += 1

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


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

cnt = 1
while True:
    if max * cnt % min == 0:
        print(max * cnt)
        exit()
    cnt += 1

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

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

cnt = 1
while True:
    if max * cnt % min == 0:
        print(max * cnt)
        exit()
    cnt += 1
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
IN = [input() for _ in range(n)]
S = []
for i in IN:
    S.append(''.join(sorted(i)))

ans = 0
for i in range(1, n):
    for j in range(i):
        if S[i] == S[j]:
            ans += 1

print(ans)

Fixed submission:
n = int(input())
S = [input() for _ in range(n)]

table = {}
ans = 0
for i in S:
    s = ''.join(sorted(i))
    if s not in table:
        table[s] = 0
    else:
        table[s] += 1
        ans += table[s]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
IN = [input() for _ in range(n)]
S = []
for i in IN:
    S.append(''.join(sorted([s for s in i])))

ans = 0
for i in range(1, n):
    for j in range(i):
        if S[i] == S[j]:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
S = [input() for _ in range(n)]

table = {}
ans = 0
for i in S:
    s = ''.join(sorted(i))
    if s not in table:
        table[s] = 0
    else:
        table[s] += 1
        ans += table[s]
print(ans)