Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
sl = list(input())
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
if len(sl) != 26:
    for s in ascii_lowercase:
        if s not in sl:
            sl.append(s)
            break
    print("".join(sl))
elif "".join(sl) == "zyxwvutsrqponmlkjihgfedcba":
    print("-1")
else:
    ansl = []
    for s, t in zip(sl, ascii_lowercase):
        if s != t:
            ansl[-1] = t
            print("".join(ansl))
            break
        ansl.append(t)

Fixed submission:
S=input()
if S=='zyxwvutsrqponmlkjihgfedcba':
  print(-1)
  exit()
alp='abcdefghijklmnopqrstuvwxyz'
N=len(S)
if N<26:
  T=S+alp
  i=0
  while T.index(alp[i])<N:
    i+=1
  print(S+alp[i])
  exit()
  
i=-1
nums=[alp.index(S[i])]
while max(nums)==nums[-1]:
  i-=1
  nums.append(alp.index(S[i]))

out=S[:-len(nums)]
tmp=26
for i in nums[:-1]:
  if i>nums[-1] and tmp>i:
    tmp=i
    
print(out+alp[tmp])

Buggy python submission (verdict: Runtime Error):
sl = list(input())
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
if len(sl) != 26:
    for s in ascii_lowercase:
        if s not in sl:
            sl.append(s)
            break
    print("".join(sl))
elif "".join(sl) == "zyxwvutsrqponmlkjihgfedcba":
    print("zyxwvutsrqponmlkjihgfedcba")
else:
    ansl = []
    for s, t in zip(sl, ascii_lowercase):
        if s != t:
            ansl[-1] = t
            print("".join(ansl))
            break
        ansl.append(t)

Fixed submission:
S=input()
if S=='zyxwvutsrqponmlkjihgfedcba':
  print(-1)
  exit()
alp='abcdefghijklmnopqrstuvwxyz'
N=len(S)
if N<26:
  T=S+alp
  i=0
  while T.index(alp[i])<N:
    i+=1
  print(S+alp[i])
  exit()
  
i=-1
nums=[alp.index(S[i])]
while max(nums)==nums[-1]:
  i-=1
  nums.append(alp.index(S[i]))

out=S[:-len(nums)]
tmp=26
for i in nums[:-1]:
  if i>nums[-1] and tmp>i:
    tmp=i
    
print(out+alp[tmp])
Buggy python submission (verdict: Runtime Error):
n = int(input())
dl = []
for _ in range(n):
    dl.append(d)

print(len(set(dl)))

Fixed submission:
n = int(input())
dl = []
for _ in range(n):
    d = int(input())
    dl.append(d)

print(len(set(dl)))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
al = list(map(int,input().split()))

from collections import defaultdict
dic = defaultdict(int)
for a in al:
    dic[a] += 1

l = [i for i in dic.values()]
l = sorted(l)

loop = 0
ans = 0
while True:
    if len(l) > k:
        ans += l[0]
    else:
        break
    l.pop(0)

print(ans)
    

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

from collections import defaultdict
dic = defaultdict(int)
for a in al:
    dic[a] += 1

l = [i for i in dic.values()]
l = sorted(l)

a = len(l) - k

ans = 0
for i in range(max(a,0)):
    ans += l[i]

print(ans)

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

from collections import defaultdict
dic = defaultdict(int)
for a in al:
    dic[a] += 1

l = [i for i in dic.values()]
l = sorted(l)

loop = 0
ans = 0
while True:
    loop += 1
    if loop > 200000:
        print("yabe")
        import sys
        sys.exit()
    if len(l) > k:
        ans += l[0]
    else:
        break
    l.pop(0)

print(ans)
    

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

from collections import defaultdict
dic = defaultdict(int)
for a in al:
    dic[a] += 1

l = [i for i in dic.values()]
l = sorted(l)

a = len(l) - k

ans = 0
for i in range(max(a,0)):
    ans += l[i]

print(ans)

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

from collections import defaultdict
dic = defaultdict(int)
for a in al:
    dic[a] += 1

l = [i for i in dic.values()]
l = sorted(l)

ans = 0
while True:
    if len(l) > k:
        ans += l[0]
    else:
        break
    l.pop(0)

print(ans)
    

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

from collections import defaultdict
dic = defaultdict(int)
for a in al:
    dic[a] += 1

l = [i for i in dic.values()]
l = sorted(l)

a = len(l) - k

ans = 0
for i in range(max(a,0)):
    ans += l[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
n,z,w = map(int,input().split())

al = list(map(int,input().split()))
if len(al) == 1:
    print(abs(al[-1] - w))
ans1 = abs(al[-1] - al[-2])
ans2 = abs(al[-1] - w)

print(max(ans1, ans2))


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

al = list(map(int,input().split()))
if len(al) == 1:
    print(abs(al[-1] - w))
    exit()
ans1 = abs(al[-1] - al[-2])
ans2 = abs(al[-1] - w)

print(max(ans1, ans2))

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

al = list(map(int,input().split()))

ans1 = abs(al[-1] - al[-2])
ans2 = abs(al[-1] - w)

print(max(ans1, ans2))


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

al = list(map(int,input().split()))
if len(al) == 1:
    print(abs(al[-1] - w))
    exit()
ans1 = abs(al[-1] - al[-2])
ans2 = abs(al[-1] - w)

print(max(ans1, ans2))
Buggy python submission (verdict: Runtime Error):
s = list(input())

ans = 0

for ss in s:
    ans += int(s)
print(ans)

Fixed submission:
s = list(input())

ans = 0

for ss in s:
    ans += int(ss)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
al = []
for _ in range(n):
    a = int(input())
    if a in al:
        al.remove(a)
    else:
        al.append(a)
    
print(len(al))

Fixed submission:
n = int(input())
al = []
for _ in range(n):
    a = int(input())
    al.append(a)

al = sorted(al)
ans = 0

before = 0
for a in al:
    if before == a:
        ans -= 1
        before = 0
    else:
        ans += 1
        before = a
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,r = map(int,input().split())
rl = list(map(int,input().split()))

d = [[float("inf") for i in range(n)] for j in range(n)]
for _ in range(m):
    a,b,c = map(int,input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c


#d[i][j]は2頂点間i, j間の移動コストを格納, Vは頂点数
def warshall_floyd(d, V): 
    for k in range(V):
        for i in range(V):
            for j in range(V):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    return d #d[i][j]に頂点i, j間の最短距離を格納

d = warshall_floyd(d, n)
import itertools
ans = float("inf")
for balls in itertools.permutations(rl):
    a = 0
    for i in range(r-1):
        a += d[balls[i]-1][balls[i+1]-1]
    ans = min(ans, a)

print(ans)

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

d = [[float("inf") for i in range(n)] for j in range(n)]
for _ in range(m):
    a,b,c = map(int,input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c


#d[i][j]は2頂点間i, j間の移動コストを格納, Vは頂点数
def warshall_floyd(d, V): 
    for k in range(V):
        for i in range(V):
            for j in range(V):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    return d #d[i][j]に頂点i, j間の最短距離を格納

d = warshall_floyd(d, n)
import itertools
ans = float("inf")
for balls in itertools.permutations(rl):
    a = 0
    for i in range(r-1):
        a += d[balls[i]-1][balls[i+1]-1]
    ans = min(ans, a)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)

n = int(input())

from collections import defaultdict
d = defaultdict(list)

for _ in range(n-1):
    a,b,c = map(int,input().split())
    d[a-1].append((b-1, c))
    d[b-1].append((a-1, c))

q,k = map(int,input().split())

global dist
dist = [-1 for _ in range(n)]
def dfs(l, pos):
    dist[pos] = l
    for to, c in d[pos]:
        if dist[to] == -1:
            dfs(l+c,to)

dfs(0, k-1)

for _ in range(q):
    x,y = map(int,input().split())
    print(dist[x-1] + dist[y-1])

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

n = int(input())

from collections import defaultdict
d = defaultdict(list)

for _ in range(n-1):
    a,b,c = map(int,input().split())
    d[a-1].append((b-1, c))
    d[b-1].append((a-1, c))

q,k = map(int,input().split())

global dist
dist = [-1 for _ in range(n)]
def dfs(l, pos):
    dist[pos] = l
    for to, c in d[pos]:
        if dist[to] == -1:
            dfs(l+c,to)

dfs(0, k-1)

for _ in range(q):
    x,y = map(int,input().split())
    print(dist[x-1] + dist[y-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
al = list(map(int,input().split()))

ansl = [0] * 9

for a in al:
    ansl[a//400] += 1

min_ans = 0
for a in ansl[:8]:
    if a > 0:
        min_ans += 1

max_ans = min_ans
if ansl[-1] > 0:
    if min_ans == 0:
        min_ans += 1
        max_ans += ansl[-1]
    else:
        max_ans = min_ans + ansl[-1]

print(min_ans, max_ans)

Fixed submission:
color = [0 for i in range(8)]

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

p = 0
for a in al:
    if a < 3200:
        color[a//400] = 1
    else:
        p += 1
print(max(sum(color), 1))
print(sum(color) + p)

Buggy python submission (verdict: Runtime Error):
color = [0 for i in range(8)]

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

p = 0
for a in al:
    if a < 3200:
        color[a//400] = 1
    else:
        p += 1
print(max(sum(color), 1))
print(min(sum(color) + p))

Fixed submission:
color = [0 for i in range(8)]

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

p = 0
for a in al:
    if a < 3200:
        color[a//400] = 1
    else:
        p += 1
print(max(sum(color), 1))
print(sum(color) + p)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
abl = []
for _ in range(n):
    a,b = map(int,input().split())
    abl.append((a,b))

cdl = []
for _ in range(n):
    c,d = map(int,input().split())
    cdl.append((c,d))

for a,b in abl:
    ans = float("inf")
    log = -1
    for idx, (c,d) in enumerate(cdl):
        tmp = abs(a-c) + abs(b-d)
        if ans > tmp:
            ans = tmp
            log = idx+1
    print(log)








Fixed submission:
n,m = map(int,input().split())
cdl = []
for _ in range(n):
    a,b = map(int,input().split())
    cdl.append((a,b))
abl = []
for _ in range(m):
    c,d = map(int,input().split())
    abl.append((c,d))

for c,d in cdl:
    ans = -1
    l = float("inf")
    for idx, (a,b) in enumerate(abl):
        dist = abs(a-c) + abs(b-d)
        if dist < l:
            ans = idx + 1
            l = dist
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,c,k = map(int,input().split())
#cは乗客kは時間
T = []
for i in range(n):
    t = int(input())
    T.append(t)
T.sort()
bus = 0
while(True):
    if len(T) == 0:
        break
    start = T[0]
    for i in range(c):
        if len(T)!=0: 
            if start+k >= T[0]:
                T.remove(T[0])
    bus += 1
print(bus)

Fixed submission:
n,c,k = map(int,input().split())
#cは乗客kは時間
T = []
for i in range(n):
    t = int(input())
    T.append(t)
T.sort()
bus = 0
while(True):
    if len(T) == 0:
        break
    start = T[0]
    for i in range(c):
        if len(T)!=0: 
            if start+k >= T[0]:
                T.remove(T[0])
            else:
                break
    bus += 1
print(bus)
Buggy python submission (verdict: Time Limit Exceeded):
m = int(input())
n = list(map(int,input().split()))
ans = 0
for i in range(len(n)):
    ncopy = list(n)
    child = ncopy[i]
    ncopy.remove(ncopy[i])
    while(True):
        if len(ncopy) == 0:
            ans += 1    
        start = list(ncopy)
        for k in ncopy:
            if k <= child*2:
                ncopy.remove(k)
                child += k
        end = list(ncopy)
        if start == end:
            break
print(ans)
        

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

n.sort()
SUM = 0
count = 0
for i in range(len(n)-1):
    SUM += n[i]
    if n[i+1] > SUM*2:
        count = i+1
print(len(n)-count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input()) 
s = 1
for i in range(n):
    s = s*(i+1)
print(s%((10**9)+7))

Fixed submission:
n = int(input()) 
s = 1
for i in range(n):
    s = (s*(i+1))%((10**9)+7)
print(s%((10**9)+7))
Buggy python submission (verdict: Time Limit Exceeded):
global N
global Nlist
global Ma
global Mb
global minicost
minicost = 10000000
N, Ma, Mb = map(int,input().split()) 
Nlist = []
for i in range(N):
    a,b,c = map(int,input().split())
    Nlist.append([a,b,c])

def dvector(vector):
    global Ma
    global Mb
    global Nlist
    global minicost
    if len(vector) == len(Nlist):
        return 0
    vector.append(1)
    Masum = 0
    Mbsum = 0
    cost = 0
    for i in range(len(vector)):
        Masum+= vector[i] * Nlist[i][0]
        Mbsum+= vector[i] * Nlist[i][1]
        cost += vector[i] * Nlist[i][2]
        if Mbsum > 0:
            if Masum/Mbsum == Ma/Mb:
                if minicost > cost:
                    minicost = cost
        if cost < minicost:
            dvector(vector)
    vector.pop()
    vector.append(0)
    dvector(vector)
    vector.pop()
    return 0
    
dvector([])
if minicost == 10000000:
    print("-1")
else:
    print(minicost)

Fixed submission:
global N
global Nlist
global Ma
global Mb
global minicost
minicost = 10000000
N, Ma, Mb = map(int,input().split()) 
Nlist = []
for i in range(N):
    a,b,c = map(int,input().split())
    Nlist.append([a,b,c])

def dvector(Masum,Mbsum,cost,vector):
    global Ma
    global Mb
    global Nlist
    global minicost
    if len(vector) == len(Nlist):
        return 0
    dvector(Masum,Mbsum,cost,vector+[0])
    Masum+= Nlist[len(vector)-1][0]
    Mbsum+= Nlist[len(vector)-1][1]
    cost += Nlist[len(vector)-1][2]
    if Mbsum > 0:
        if Masum/Mbsum == Ma/Mb:
            if minicost > cost:
                minicost = cost
    if cost < minicost:
        dvector(Masum,Mbsum,cost,vector+[1])
    return 0
    
dvector(0,0,0,[])
if minicost == 10000000:
    print("-1")
else:
    print(minicost)
Buggy python submission (verdict: Time Limit Exceeded):
K,s = map(int,input().split())

ans = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == s:
                ans += 1
print(ans)

Fixed submission:
k,s = map(int,input().split())
 
ans = 0
for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

import numpy as np
from scipy.sparse.csgraph import shortest_path

l = np.array([[float("inf") for i in range(n)] for j in range(n)])
ans = []
for _ in range(m):
   a,b,c = map(int,input().split())
   l[a-1][b-1] = c
   l[b-1][a-1] = c
   if a > b:
      ans.append((b,a))
   else:
      ans.append((a,b))

d, p = shortest_path(l, return_predecessors=True)


for pp in p:
   for idx, ppp in enumerate(pp):
      if idx < ppp:
         if (idx+1, ppp+1) in ans:
            ans.remove((idx+1, ppp+1))
      else:
         if (ppp+1, idx+1) in ans:
            ans.remove((ppp+1, idx+1))
print(len(ans))

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

import numpy as np
from scipy.sparse.csgraph import shortest_path

l = np.array([[float("inf") for i in range(n)] for j in range(n)])
from collections import defaultdict
ans = defaultdict(int)
for _ in range(m):
   a,b,c = map(int,input().split())
   l[a-1][b-1] = c
   l[b-1][a-1] = c
   if a > b:
      ans[(b,a)] = 1
   else:
      ans[(a,b)] = 1

d, p = shortest_path(l, return_predecessors=True)


for pp in p:
   for idx, ppp in enumerate(pp):
      if idx < ppp:
         ans[(idx+1,ppp+1)] = 0
      else:
         ans[(ppp+1,idx+1)] = 0
print(sum(ans.values()))
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())

al = []

for _ in range(h):
   a = list(input())
   al.append(a)

i,j = 0,0
while True:
    al[i][j] = "."
    if j + 1 < w and al[i][j+1] == "#":
        al[i][j+1] = "."
        j += 1
    elif i + 1 < h and al[i+1][j] == "#":
        al[i+1][j] = "."
        i += 1
    else:
        print("Impossible")
        exit()
    if j == w-1 and i == h-1:
        break

for i in range(h):
    for j in range(h):
        if al[i][j] == '#':
            print("Impossible")
            exit()
print("Possible")

        

Fixed submission:
h,w = map(int,input().split())

al = []

for _ in range(h):
   a = list(input())
   al.append(a)

i,j = 0,0
while True:
    al[i][j] = "."
    if j + 1 < w and al[i][j+1] == "#":
        al[i][j+1] = "."
        j += 1
    elif i + 1 < h and al[i+1][j] == "#":
        al[i+1][j] = "."
        i += 1
    else:
        print("Impossible")
        exit()
    if j == w-1 and i == h-1:
        break

for i in range(h):
    for j in range(w):
        if al[i][j] == '#':
            print("Impossible")
            exit()
print("Possible")
Buggy python submission (verdict: Runtime Error):
sl = list(input())
k = int(input())

for i in range(len(sl)):
    ord_s = ord(sl[i])
    use = 123 - ord_s
    if k - use >= 0:
        sl[i] = "a"
        k -= use

if k > 0:
    sl[-1] = chr(ord(sl[-1]) + k)

print("".join(sl))



Fixed submission:
sl = list(input())
k = int(input())

for i in range(len(sl)):
    ord_s = ord(sl[i])
    use = 123 - ord_s
    if k - use >= 0 and sl[i] != "a":
        sl[i] = "a"
        k -= use

if k > 0:
    sl[-1] = chr((ord(sl[-1]) + k - 97) % 26 + 97)

print("".join(sl))
Buggy python submission (verdict: Time Limit Exceeded):
h,w,n = map(int,input().split())

l = [[0 for i in range(w)] for j in range(h)]
for _ in range(n):
   a,b = map(int,input().split())
   l[a-1][b-1] += 1


#da[i][j]:(0,0)~(i,j)の長方形の和
def da_generate(h,w,a):
    da = [[0]*w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1,w):
        da[0][i] = da[0][i-1]+a[0][i]
    for i in range(1,h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i-1][j]+cnt_w
    return da

#da_calc(p,q,x,y):(p,q)~(x,y)の長方形の和
def da_calc(p,q,x,y,da):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y]-da[x][q-1]
    if q == 0:
        return da[x][y]-da[p-1][y]
    return da[x][y]-da[p-1][y]-da[x][q-1]+da[p-1][q-1]

da = da_generate(h,w,l)
from collections import defaultdict
dic = defaultdict(int)
for i in range(h-2):
   for j in range(w-2):
      dic[da_calc(i, j, i+2, j+2, da)] += 1
   
for i in range(10):
   print(dic[i])

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

from collections import defaultdict
dic = defaultdict(int)
for _ in range(n):
   a,b = map(int,input().split())
   a -= 1
   b -= 1
   for aa in range(a-1, a+2):
      for bb in range(b-1, b+2):
         if 1 <= aa <= h-2 and 1 <= bb <= w-2:
            dic[(aa,bb)] += 1
ans = [0 for i in range(10)]
for i in dic.values():
   ans[i] += 1

ans[0] = (h-2)*(w-2) - sum([ans[i] for i in range(1,10)])

for anss in ans:
   print(anss)

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

l = [[0 for i in range(w)] for j in range(h)]
for _ in range(n):
   a,b = map(int,input().split())
   l[a-1][b-1] += 1


#da[i][j]:(0,0)~(i,j)の長方形の和
def da_generate(h,w,a):
    da = [[0]*w for j in range(h)]
    da[0][0] = a[0][0]
    for i in range(1,w):
        da[0][i] = da[0][i-1]+a[0][i]
    for i in range(1,h):
        cnt_w = 0
        for j in range(w):
            cnt_w += a[i][j]
            da[i][j] = da[i-1][j]+cnt_w
    return da

#da_calc(p,q,x,y):(p,q)~(x,y)の長方形の和
def da_calc(p,q,x,y,da):
    if p > x or q > y:
        return 0
    if p == 0 and q == 0:
        return da[x][y]
    if p == 0:
        return da[x][y]-da[x][q-1]
    if q == 0:
        return da[x][y]-da[p-1][y]
    return da[x][y]-da[p-1][y]-da[x][q-1]+da[p-1][q-1]

da = da_generate(h,w,l)
from collections import defaultdict
dic = defaultdict(int)
for i in range(h-2):
   for j in range(w-2):
      dic[da_calc(i, j, i+2, j+2, da)] += 1
   
for i in range(10):
   print(dic[i])

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

from collections import defaultdict
dic = defaultdict(int)
for _ in range(n):
   a,b = map(int,input().split())
   a -= 1
   b -= 1
   for aa in range(a-1, a+2):
      for bb in range(b-1, b+2):
         if 1 <= aa <= h-2 and 1 <= bb <= w-2:
            dic[(aa,bb)] += 1
ans = [0 for i in range(10)]
for i in dic.values():
   ans[i] += 1

ans[0] = (h-2)*(w-2) - sum([ans[i] for i in range(1,10)])

for anss in ans:
   print(anss)
Buggy python submission (verdict: Runtime Error):
n,a = map(int,input().split())
xl = list(map(int,input().split()))

# i個のカードまで使って和がjの組み合わせ
dp = [[0 for i in range(50*50+1)] for j in range(51)]
dp[0][0] = 1

for i in range(n):
    for j in range(n, -1, -1):
        for k in range(50*50+1):
            if k+xl[i] < 50*50+1:
                dp[j+1][k+xl[i]] += dp[j][k]
ans = 0
for i in range(1,n+1):
    ans += dp[i][i*a]

print(ans)


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

# i個のカードまで使って和がjの組み合わせ
dp = [[0 for i in range(50*50+1)] for j in range(51)]
dp[0][0] = 1

for i in range(n):
    for j in range(n-1, -1, -1):
        for k in range(50*50+1):
            if k+xl[i] < 50*50+1:
                dp[j+1][k+xl[i]] += dp[j][k]
ans = 0
for i in range(1,n+1):
    ans += dp[i][i*a]

print(ans)
Buggy python submission (verdict: Runtime Error):
if a.isupper()==True:
    print("A")
else:
    print("a")

Fixed submission:
a = input()
if a.isupper()==True:
    print("A")
else:
    print("a")
Buggy python submission (verdict: Runtime Error):
N= int(input())
N = str(N)
n = N[-1]
f n == "3":
    print("bon")
elif n == "0" or n == "1" or n =="6" or n == "8":
    print("pon")
else:
    print("hon")

Fixed submission:
N= int(input())
N = str(N)
n = N[-1]
if n == "3":
    print("bon")
elif n == "0" or n == "1" or n =="6" or n == "8":
    print("pon")
else:
    print("hon")
Buggy python submission (verdict: Runtime Error):
X=int(input())
count = 0
a = 100

while True:
    if a > X:
        print(count)
        break
    else:
        a  = math.floor(a*1.01)
        count= count+1

Fixed submission:
import math
X=int(input())
count = 0
a = 100
while True:
    if a >= X:
        print(count)
        break
    else:
        a  = math.floor(a*1.01)
        count= count+1
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
a = list(range(1,K+1))
b = list(range(1,K+1))
c = list(range(1,K+1))
Sum = 0
for i in a :
    for j in b:
        for k in c:
            S = gcd(i,j,k)
            Sum = Sum + S
print(Sum)

Fixed submission:
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
a = list(range(1,K+1))
b = list(range(1,K+1))
c = list(range(1,K+1))
Sum = 0
for i in a :
    for j in b:
        for k in c:
            S = gcd(i,j,k)
            Sum = Sum + S
print(Sum)
Buggy python submission (verdict: Time Limit Exceeded):
N, K= (map(int, input().split()))
number_list = [N]
while True:
    a = abs(N-K)
    if a in number_list:
        break
    else:    
        number_list.append(a)
        N = a
print(min(number_list))

Fixed submission:
N, K= (map(int, input().split()))
a = N % K
b = abs(a-K)
if a > b:
    print(b)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
N,K,M = input().split()
i = input().split() 
i2 = [int(s) for s in i]
score = sum(i2)
aim = int(N) * int(M)
d = aim - score
K = int(K)
if d > K:
    d = -1
elif 0 >=  d:
    d = 0
print(d)

Fixed submission:
c = input()
list=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
l = list.index(c) + 1
c = list[l]
print(c)
Buggy python submission (verdict: Runtime Error):
N = int(input()) 
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
A = list(range(1,N+1))
Alist=[]
import itertools
for v in itertools.permutations(A):
        Alist.append(v)
a_num = Alist.index(P)+1
b_num = Alist.index(Q)+1
print(abs(b_num - a_num))

Fixed submission:
K,X = list(map(int, input().split()))
A = 500*K 
if A >= X:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
A, B, K  = list(map(int, input().split()))
for i in range(K):
    if A >= 1:
        A = A-1
    elif B >= 1:
        B = B-1
    elif A == 0 and B == 0:
        break
print(A,B)

Fixed submission:
s = input().split()
S = s[0]
T = s[1]
W1=T+S
print(W1)