Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = [input() for i in range(5)]
flag = 1
ans = 0
while flag:
    flag = 0
    for i in range(len(n)-1,0,-1):
        if n[i][-1] < n[i-1][-1]:
            n[i],n[i-1] = n[i-1],n[i]
            flag = 1
for i in range(len(n)):
    if n[i][-1] != '0':
        n[i] = int(n[i])
        l = n.pop(i)
        break
for i in range(len(n)):
    n[i] = int(n[i])
for i in range(len(n)):
    while n[i]%10 != 0:
        n[i] += 1
    ans += n[i]
ans += l
print(ans)

Fixed submission:
n = [input() for i in range(5)]
flag = 1
ans = 0
l = []
while flag:
    flag = 0
    for i in range(len(n)-1,0,-1):
        if n[i][-1] < n[i-1][-1]:
            n[i],n[i-1] = n[i-1],n[i]
            flag = 1
for i in range(len(n)):
    if n[i][-1] != '0':
        n[i] = int(n[i])
        l = n.pop(i)
        break
for i in range(len(n)):
    n[i] = int(n[i])
for i in range(len(n)):
    while n[i]%10 != 0:
        n[i] += 1
    ans += n[i]
if l:
    ans += l
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
ans = [0]*q
for i in range(q):
    l,r = map(int,input().split())
    ss = s[l-1:r]
    for j in range(len(ss)-1):
        if ss[j] == 'A' and ss[j+1] == 'C':
            ans[i] += 1
for i in range(q):
    print(ans[i])

Fixed submission:
import bisect

n,q = map(int,input().split())
s = input()
l=[]
r=[]
a = []
c = []
for i in range(q):
    l1,r1 = map(int,input().split())
    l.append(l1)
    r.append(r1)
for i in range(n-1):
    if s[i] + s[i+1] == 'AC':
        a.append(i+1)
        c.append(i+2)
for i in range(q):
    ans = 0
    ans = bisect.bisect_right(c,r[i]) - bisect.bisect_left(a,l[i])
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
l=[]
r=[]
ans = 0
for i in range(q):
    l1,r1=[int(i) for i in input().split()]
    l.append(l1)
    r.append(r1)
for i in range(q):
    for j in range(l[i]-1,r[i]-1):
        if s[j]=='A' and s[j+1]=='C':
            ans += 1
    print(ans)
    ans = 0

Fixed submission:
import bisect

n,q = map(int,input().split())
s = input()
l=[]
r=[]
a = []
c = []
for i in range(q):
    l1,r1 = map(int,input().split())
    l.append(l1)
    r.append(r1)
for i in range(n-1):
    if s[i] + s[i+1] == 'AC':
        a.append(i+1)
        c.append(i+2)
for i in range(q):
    ans = 0
    ans = bisect.bisect_right(c,r[i]) - bisect.bisect_left(a,l[i])
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = []
b = []
for _ in range(n):
    a1,b1 = map(int,input().split())
    a.append(a1)
    b.append(b1)
ans = 0
cnt = 0
flag = 1
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if a[i] < a[i-1]:
            a[i],a[i-1] = a[i-1],a[i]
            b[i],b[i-1] = b[i-1],b[i]
            flag = 1
for i in range(n):
    flag = 1
    while b[i] > 0 and cnt < m:
        ans += a[i]
        cnt += 1
        b[i] -= 1
        flag = 0
    if flag:
        break
print(ans)

Fixed submission:
n,m = map(int,input().split())
a = []
b = []
for _ in range(n):
    a1,b1 = map(int,input().split())
    a.append(a1)
    b.append(b1)
c = sorted(zip(a,b))
ans = 0
for i in range(n):
    if m > c[i][1]:
        ans += c[i][0]*c[i][1]
        m -= c[i][1]
    else:
        ans += c[i][0]*m
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [0] * n
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    min_cost = 999999999
    for j in range(1,min(i,k)+1):
        tmp = dp[i-j] + abs(h[i] - h[i-j])
        min_cost = min(min_cost, tmp)
    dp[i] = min_cost

print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [0] * n
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    min_cost = 999999999
    for j in range(1,min(i,k)+1):
        tmp = dp[i-j] + abs(h[i] - h[i-j])
        min_cost = min(min_cost, tmp)
    dp[i] = min_cost

print(dp[n-1])

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

dp = [float('inf')] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    min_cost = float('inf')
    for j in range(1,min(i,k)+1):
        tmp = dp[i-j] + abs(h[i] - h[i-j])
        min_cost = min(min_cost, tmp)
    dp[i] = min_cost

print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]

dp = [0] * n
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
    min_cost = 999999999
    for j in range(1,min(i,k)+1):
        tmp = dp[i-j] + abs(h[i] - h[i-j])
        min_cost = min(min_cost, tmp)
    dp[i] = min_cost

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, W = map(int, input().split())
w = []
v = []
for _ in range(n):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)

# dp[i+1][j]=i番目までの品物から重さの総和がj以下となるように選んだ時の価値の総和の最大値
dp = [[0 for j in range(W+1)] for i in range(n+1)]
for i in range(n):
    for j in range(W+1):
    # ナップザックの容量をjと仮定する
        # とi番目の品物を持てないとき
        if j < w[i]:
            # i番目の品物をスルーする
            dp[i + 1][j] = dp[i][j]
        # i番目の品物を持とうと思えば持てるとき
        else:
            # 1.i番目の品物を持たなかった場合
            # 2.i番目の品物を持った場合
            # 以上2通りの内、価値の総和が最大となる品物の選び方をする
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
print(dp[n][W])


# イメージはこんな感じ
# 入力が
# n = 4
# W = 5
# (w, v) = ((2, 3), (1, 2), (3, 4), (2, 2))
# となるとき
# → はナップザックに入ってる品物の重さ(j <= W)の総和
# ↓ はi(i <= n)番目までの品物を順に確認
# (i+1, j)は最初の品物を0番目として数えたときの、
# i番目までの品物から重さの総和がj以下となるように選んだ時の価値の総和の最大値
# i\j  0   1   2   3   4   5
#
#  0   0   0   0   0   0   0
#
#  1   0   0   3   3   3   3
#
#  2   0   2   3   5   5   5
#
#  3   0   2   3   5   6   7
#
#  4   0   2   3   5   6   7

Fixed submission:
n, W = map(int, input().split())
w = []
v = []
for _ in range(n):
    ww, vv = map(int, input().split())
    w.append(ww)
    v.append(vv)

# dp[i+1][j]=i番目までの品物から重さの総和がj以下となるように選んだ時の価値の総和の最大値
dp = [[0 for j in range(W+1)] for i in range(n+1)]
for i in range(n):
    for j in range(W+1):
    # ナップザックの容量をjと仮定する
        # とi番目の品物を持てないとき
        if j < w[i]:
            # i番目の品物をスルーする
            dp[i + 1][j] = dp[i][j]
        # i番目の品物を持とうと思えば持てるとき
        else:
            # 1.i番目の品物を持たなかった場合
            # 2.i番目の品物を持った場合
            # 以上2通りの内、価値の総和が最大となる品物の選び方をする
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
print(dp[n][W])


# イメージはこんな感じ
# 入力が
# n = 4
# W = 5
# (w, v) = ((2, 3), (1, 2), (3, 4), (2, 2))
# となるとき
# → はナップザックに入ってる品物の重さ(j <= W)の総和
# ↓ はi(i <= n)番目までの品物を順に確認
# (i+1, j)は最初の品物を0番目として数えたときの、
# i番目までの品物から重さの総和がj以下となるように選んだ時の価値の総和の最大値
# i\j  0   1   2   3   4   5
#
#  0   0   0   0   0   0   0
#
#  1   0   0   3   3   3   3
#
#  2   0   2   3   5   5   5
#
#  3   0   2   3   5   6   7
#
#  4   0   2   3   5   6   7
Buggy python submission (verdict: Runtime Error):
n = int(input())
t,a = map(int(input().split()))
h = list(map(int,input().split()))
deg = 11451419
for i in range(n):
  if deg > abs(a - h[i]*0.006):
    deg = abs(a - h[i]*0.006)
    ans = i+1
print(ans)

Fixed submission:
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
deg = 11451419
for i in range(n):
  if deg > abs(a - (t - h[i]*0.006)):
    deg = abs(a - (t - h[i]*0.006))
    ans = i+1
print(ans)
Buggy python submission (verdict: Runtime Error):
N,T = map(int,input().split())
c = []
t = []
c1,t1 = [int(i) for i in input().split()]
for i in range(N):
  c.append(n1)
  t.append(t1)
ans = 10000
for i in range(N):
  if t[i] <= T:
    ans = min(ans,c[i])
if ans == 10000:
  print('TLE')
else:
  print(ans)

Fixed submission:
N,T = map(int,input().split())
c = []
t = []
for i in range(N):
    c1,t1 = [int(i) for i in input().split()]
    c.append(c1)
    t.append(t1)
ans = 10000
for i in range(N):
  if t[i] <= T:
    ans = min(ans,c[i])
if ans == 10000:
  print('TLE')
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

Fixed submission:
a,b=map(int,input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
x = int(input())
ans = []
for i in range(1,x):
    for j in range(2,10):
        if i**j > x:
            break
        else:
            ans.append(i**j)
print(max(ans))

Fixed submission:
x = int(input())
ans = 1
if x < 4:
    print(1)
else:
    for i in range(2,int(x**(1/2)+1)):
        j = 2
        a = -1
        while a <= x:
            ans = max(ans,a)
            a = i**j
            j += 1
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
ans = []
for i in range(a,b+1):
    if i < a + k or b - k < i:
        ans.append(i)
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
a,b,k = map(int,input().split())
ans = []
for i in range(a,a+k):
    if i <= b:
        ans.append(i)
for i in range(b-k+1,b+1):
    if a < i and i not in ans:
        ans.append(i)
for i in range(len(ans)):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
s = sorted(input())
t = sorted(input(), reverse=True)

for i in range(len(s)):
    if ord(s[i]) < ord(t[i]):
        print('Yes')
        exit()
    elif ord(s[i]) > ord(t[i]):
        print('No')
        exit()
if len(s) < len(t):
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
t = input()
min_s = sorted(s)
max_t = sorted(t, reverse=True)
if min_s < max_t:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b,c,d=int(open(0));print(max(0,min(b,d)-max(a,c)))

Fixed submission:
a,b,c,d = map(int,input().split());print(max(0, min(b,d) - max(a,c)))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')

Fixed submission:
a,b = map(int,input().split())
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print("Possible")
else:
    print("Impossible")
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
stu = []
check = []
for i in range(n):
    stu.append(list(map(int, input().split())))
for i in range(m):
    check.append(list(map(int, input().split())))
for i in stu:
    min_dis = 2 * 10 ** 8 + 1
    for j, k in enumerate(check):
        dis = abs(i[0] - k[0]) + abs(i[1] - k[1])
        if dis < min_dis:
            ans = j + 1
            min_dis = dis
    print(ans)

Fixed submission:
n, m = map(int, input().split())
stu = []
check = []
for i in range(n):
    stu.append(list(map(int, input().split())))
for i in range(m):
    check.append(list(map(int, input().split())))
for i in stu:
    min_dis = 4 * 10 ** 8 + 1
    for j, k in enumerate(check):
        dis = abs(i[0] - k[0]) + abs(i[1] - k[1])
        if dis < min_dis:
            ans = j + 1
            min_dis = dis
    print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())
'''
if x == 1:
    ans = 1
elif x == 2:
    ans = 2
elif x == 3:
    ans = 2
elif x == 4:
    ans = 3
elif x == 5:
    ans = 3
elif x == 6:
    ans = 3
elif x == 7:
    ans = 4
elif x == 8:
    ans = 4
elif x == 9:
    ans = 4
elif x == 10:
    ans = 4
11から15までは5
122333444455555...の群数列
'''
for i in range(1,x):
    if i*(i-1)/2 < x <= i*(i+1)/2:
        ans = i
        break
print(ans)

Fixed submission:
x = int(input())
'''
if x == 1:
    ans = 1
elif x == 2:
    ans = 2
elif x == 3:
    ans = 2
elif x == 4:
    ans = 3
elif x == 5:
    ans = 3
elif x == 6:
    ans = 3
elif x == 7:
    ans = 4
elif x == 8:
    ans = 4
elif x == 9:
    ans = 4
elif x == 10:
    ans = 4
11から15までは5
122333444455555...の群数列
'''
for i in range(1,x+1):
    if i*(i-1)/2 < x <= i*(i+1)/2:
        ans = i
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a == 1:
  if b == 1:
    print(Draw)
  else:
    print(Alice)
elif b == 1:
  print(Bob)
else:
  if a == b:
    print(Draw)
  elif a < b:
    print(Alice)
  else:
    print(Bob)

Fixed submission:
a,b = map(int,input().split())
if a == 1:
  if b == 1:
    print('Draw')
  else:
    print('Alice')
elif b == 1:
  print('Bob')
else:
  if a == b:
    print('Draw')
  elif a > b:
    print('Alice')
  else:
    print('Bob')
Buggy python submission (verdict: Runtime Error):
c = input()
v = [a,i,u,e,o]
if c in v:
  print('vowel')
else:
  print('consonant')

Fixed submission:
c = input()
v = ['a','i','u','e','o']
if c in v:
  print('vowel')
else:
  print('consonant')
Buggy python submission (verdict: Time Limit Exceeded):
w,h,n = map(int,input().split())
gra = [[1 for i in range(w)] for i in range(h)]
for i in range(n):
    x,y,a = map(int,input().split())
    for j in range(n):
        if a == 1:
            for k in range(h):
                for l in range(x):
                    gra[k][l] = 0
        elif a == 2:
            for k in range(h):
                for l in range(x,w):
                    gra[k][l] = 0
        elif a == 3:
            for k in range(y):
                for l in range(w):
                    gra[k][l] = 0
        else:
            for k in range(y,h):
                for l in range(w):
                    gra[k][l] = 0
print(sum(map(sum, gra)))

Fixed submission:
w,h,n = map(int,input().split())
up = h
down = 0
left = 0
right = w
for i in range(n):
    x, y, a = map(int,input().split())
    if a == 1:
        left = max(left,x)
    elif a == 2:
        right = min(right,x)
    elif a == 3:
        down = max(down,y)
    else:
        up = min(up,y)
print(max(0, right - left) * max(0, up - down))
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
d = {}
for i in range(m):
  a,b = map(int, input().split())
  if a in d:
    l = d[a]
    l.append(b)
    d[a] = l
  else:
    d[a] = [b]
  if b in d:
    l = d[b]
    l.append(a)
    d[b] = l
  else:
n,m = map(int, input().split())
d = {}
for i in range(m):
  a,b = map(int, input().split())
  if a in d:
    l = d[a]
    l.append(b)
    d[a] = l
  else:
    d[a] = [b]
  if b in d:
    l = d[b]
    l.append(a)
    d[b] = l
  else:
    d[b] = [a]
clear = [1]
ans_ = [1]
ans = [0]*(n-1)
while(0 in ans):
  for i in ans_:
    ans__ = []
    for j in d[i]:
      if j in clear:
        continue
      else:
        clear.append(j)
        ans__.append(j)
        ans[j-2] = i
  ans_ = ans__
  if len(ans_) == 0:
    break
if 0 in ans:
  print("No")
else:
  print("Yes")
  for i in ans:
    print(i)

Fixed submission:
n,m = map(int, input().split())
d = {}
for i in range(m):
  a,b = map(int, input().split())
  if a in d:
    l = d[a]
    l.append(b)
    d[a] = l
  else:
    d[a] = [b]
  if b in d:
    l = d[b]
    l.append(a)
    d[b] = l
  else:
    d[b] = [a]
dpth = {}
dpth[1] = 0
l = [1]
ans = [0]*(n-1)
while(len(l)>0):
  l_ = []
  for i in l:
    dpth_ = dpth[i]
    for j in d[i]:
      if j not in dpth:
        ans[j-2] = i
        dpth[j] = dpth_+1
        l_.append(j)
  l = l_
print("Yes")
for i in ans:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int, input().split())
ans = 0
while(k>0):
  if a>0:
    a-=1
    ans += 1
  elif b>0:
    b-=1
  else:
    ans-=1
  k-=1
print(ans)

Fixed submission:
a,b,c,k = map(int, input().split())
ans = 0
if k <= a:
  ans = k
elif k <= a+b:
  ans = a
else:
  ans = a-(k-a-b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for num,i in enumerate(a):
  d[num+1] =  i
t = []
i = 1
j = 1
while(i not in t):
  t.append(i)
  i = d[i]
for num,j in enumerate(t):
  if j == i:
    b = num
    break
a = 1
if k < b+1:
  ans = t[k]
else:
  k = (k-b)%(len(t)-b)
  ans = t[b+k]
print(ans)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for num,i in enumerate(a):
  d[num+1] =  i
t = {}
t_ = {}
i = 1
j = 0
while(i not in t):
  t[i] = j
  t_[j] = i
  i = d[i]
  j += 1
a = 1
b = t[i]
if k < b+1:
  ans = t_[k]
else:
  k = (k-b)%(len(t.keys())-b)
  ans = t_[b+k]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for num,i in enumerate(a):
  d[num+1] =  i
t = []
i = 1
j = 1
while(i not in t):
  t.append(i)
  i = d[i]
t_ = []
b = {}
while(i not in t_):
  t_.append(i)
  i = d[i]
i = 1
while(k>0):
  if i == t_[0]:
    k = k%len(t_)
    ans = t_[k]
    break
  else:
    i = d[i]
    ans = i
    k-=1
print(ans)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for num,i in enumerate(a):
  d[num+1] =  i
t = {}
t_ = {}
i = 1
j = 0
while(i not in t):
  t[i] = j
  t_[j] = i
  i = d[i]
  j += 1
a = 1
b = t[i]
if k < b+1:
  ans = t_[k]
else:
  k = (k-b)%(len(t.keys())-b)
  ans = t_[b+k]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
#ncr
mod = 998244353
class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod 
    def ncr(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod 
cmb = Combination(n)
ans = 0
for i in range(k+1):
  a = m*(m-1)**(n-i-1)%p
  a *= cmb.ncr(n,i)
  ans += a%p
print(ans%p)

Fixed submission:
n,m,k = map(int, input().split())
#ncr
mod = 998244353
class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod 
    def ncr(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod 
cmb = Combination(n)
ans = 0
for i in range(k+1):
  a = m*pow(m-1,n-i-1,mod)%mod
  a *= cmb.ncr(n-1,i)
  ans += a%mod
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k = map(int, input().split())
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 998244353
N = n  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0
for i in range(k+1):
  a = m*(m-1)**(n-i-1)%p
  a *= cmb(n-1, i, p)%p
  ans += a
print(ans%p)

Fixed submission:
n,m,k = map(int, input().split())
#ncr
mod = 998244353
class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod 
    def ncr(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod 
cmb = Combination(n)
ans = 0
for i in range(k+1):
  a = m*pow(m-1,n-i-1,mod)%mod
  a *= cmb.ncr(n-1,i)
  ans += a%mod
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  a.apped(str(input()))
print(len(set(a)))

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(str(input()))
print(len(set(a)))
Buggy python submission (verdict: Runtime Error):
r = int(input())
inport math
print(r*2*math.pi)

Fixed submission:
r = int(input())
import math
print(math.pi*2*r)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  def make_divisors(n):
      divisors = []
      for i in range(1, int(n**0.5)+1):
          if n % i == 0:
              divisors.append(i)
              if i != n // i:
                  divisors.append(n//i)
      divisors.sort()
      return divisors

  n = int(input())
  l = make_divisors(n)
  ans = make_divisors(n-1)
  for i in l:
    m=n
    if i==1:
      continue
    else:
      while(m%i==0):
        m//=i
    if m==1:
      ans.append(i)
    else:
      if i in make_divisors(m-1):
        ans.append(i)
  ans=set(ans)
  print(len(ans)-1)  

if __name__ == "__main__":
  main()

Fixed submission:
def main():
  def make_divisors(n):
      divisors = []
      for i in range(1, int(n**0.5)+1):
          if n % i == 0:
              divisors.append(i)
              if i != n // i:
                  divisors.append(n//i)
      divisors.sort()
      return divisors

  n = int(input())
  l = make_divisors(n)
  ans = make_divisors(n-1)
  for i in l:
    m=n
    if i==1:
      continue
    else:
      while(m%i==0):
        m//=i
    if m==1:
      ans.append(i)
    else:
      if i in make_divisors(m-1):
        ans.append(i)
  ans=set(ans)
  print(len(ans)-1)  

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n = int(input())
l = make_divisors(n)
ans = make_divisors(n-1)
for i in l:
  m=n
  if i==1:
    continue
  else:
    while(m%i==0):
      m//=i
  if m==1:
    ans.append(i)
  else:
    if i in make_divisors(m-1):
      ans.append(i)
ans=set(ans)
print(len(ans)-1)

Fixed submission:
def main():
  def make_divisors(n):
      divisors = []
      for i in range(1, int(n**0.5)+1):
          if n % i == 0:
              divisors.append(i)
              if i != n // i:
                  divisors.append(n//i)
      divisors.sort()
      return divisors

  n = int(input())
  l = make_divisors(n)
  ans = make_divisors(n-1)
  for i in l:
    m=n
    if i==1:
      continue
    else:
      while(m%i==0):
        m//=i
    if m==1:
      ans.append(i)
    else:
      if i in make_divisors(m-1):
        ans.append(i)
  ans=set(ans)
  print(len(ans)-1)  

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

d = {}
for i in range(n):
  if a[i] in d:
    d[a[i]] += 1
  else:
    d[a[i]] = 1

for i in range(n):
  ans = 0
  d[a[i]] -= 1
  for j in d.values():
    ans += j*(j-1)//2
  print(ans)
  d[a[i]] += 1

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

d = {}
for i in range(n):
  if a[i] in d:
    d[a[i]] += 1
  else:
    d[a[i]] = 1
ans = 0
for j in d.values():
  ans += j*(j-1)//2
for i in range(n):
  x = d[a[i]]
  print(ans-(x*(x-1)//2)+((x-1)*(x-2)//2))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0]*n
s = 0
d = {}
for i in range(n):
  x,l = map(int, input().split())
  if i != 0:
    for j in range(i):
      if d[j][0]-d[j][1]<x+l and x-l<d[j][0]+d[j][1]:
        a[j]+=1
        a[i]+=1
        s+=1
  d[i] = (x,l)
a.sort(reverse=True)
ans_=0
while(s>0):
  s -= a[ans_]*2
  ans_ += 1
print(n-ans_)

Fixed submission:
n = int(input())
ans = 1
a = []
d = {}
for i in range(n):
  x,l = map(int, input().split())
  a.append((x+l,x-l))
if n == 1:
  print(ans)
else:
  a.sort(key=lambda x:(x[0],x[1]))
  gl = a[0][0]
  st = a[0][1]
  for i in range(1,n):
    if gl<=a[i][1]:
      ans += 1
      gl = a[i][0]
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(str(input()))

j = len(s)-1
i = 0
ans = 0
while(i < j):
  if s[i] != s[j] :
    ans += 1
  else:
    continue
print(ans)

Fixed submission:
s = list(str(input()))

j = len(s)-1
i = 0
ans = 0
while(i < j):
  if s[i] != s[j] :
    ans += 1
    i += 1
    j -= 1
  else:
    i += 1
    j -= 1
    continue
print(ans)