Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    l = list(map(int,input().split()))
    dp = [0]+ [100000000000]*(n-1)

    for i in range(1,n):
        
        for j in range(1,m+1):
            if i-j >= 0:
                dp[i] = min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
        
    print(dp[n-1])

if __name__ == "__main__":
    main()    

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    l = list(map(int,input().split()))
    dp = [0]+ [100000000000]*(n-1)

    for i in range(1,n):
        
        for j in range(1,m+1):
            if i-j >= 0:
                dp[i] = min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
        
    print(dp[n-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
l = list(map(int,input().split()))
dp = [0]+ [100000000000]*(n-1)

for i in range(1,n):
    
    for j in range(1,m+1):
        if i-j >= 0:
            dp[i] = min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
    
print(dp[n-1])

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    l = list(map(int,input().split()))
    dp = [0]+ [100000000000]*(n-1)

    for i in range(1,n):
        
        for j in range(1,m+1):
            if i-j >= 0:
                dp[i] = min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
        
    print(dp[n-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
l = list(map(int,input().split()))
dp = [0]+ [100000000000]*(n-1)

for i in range(1,n):
    ans = dp[i]
    for j in range(1,m+1):
        if i-j >= 0:
            ans = min(ans,dp[i-j]+abs(l[i]-l[i-j]))
    dp[i] = ans
print(dp[n-1])

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    l = list(map(int,input().split()))
    dp = [0]+ [100000000000]*(n-1)

    for i in range(1,n):
        
        for j in range(1,m+1):
            if i-j >= 0:
                dp[i] = min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
        
    print(dp[n-1])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dp = [[0,-1] for i in range(n+1)]

for i in range(n):
    a = l[i].index(max(l[i]))
    if dp[i][1] == a:
        b = l[i].index(min(l[i]))
        dp[i+1][0],dp[i+1][1] = dp[i][0]+l[i][3-a-b],3-a-b
    else:
        dp[i+1][0],dp[i+1][1] = dp[i][0]+l[i][a],a
    
print(dp[n][0])
        
    


Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dp = [[0]*3 for i in range(n+1)]

for i in range(n):
    dp[i+1][0] = max(dp[i][1],dp[i][2])+l[i][0]
    dp[i+1][1] = max(dp[i][0],dp[i][2])+l[i][1]
    dp[i+1][2] = max(dp[i][1],dp[i][0])+l[i][2]
    
print(max(dp[n]))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dp = [[0,-1] for i in range(n+1)]

for i in range(n):
    a = l[i].index(max(l[i]))
    if dp[i][1] == a:
        b = l[i].index(min(l[i]))
        dp[i+1][0],dp[i+1][1] = dp[i][0]+l[i][3-a-b],3-a-b
    else:
        dp[i+1][0],dp[i+1][1] = dp[i][0]+l[i][a],a
    
print(dp[n][0])
        
    

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dp = [[0]*3 for i in range(n+1)]

for i in range(n):
    dp[i+1][0] = max(dp[i][1],dp[i][2])+l[i][0]
    dp[i+1][1] = max(dp[i][0],dp[i][2])+l[i][1]
    dp[i+1][2] = max(dp[i][1],dp[i][0])+l[i][2]
    
print(max(dp[n]))
Buggy python submission (verdict: Runtime Error):
def main():
    import numpy as np
    import sys
    input = sys.stdin.readline

    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = np.zeros(n+1,w+1)
    for i in range(n):
        dp[i+1,l[i][0]:] = np.maximum(dp[i,l[i][0]:],dp[i,-l[i][0]]+l[i][1])
    print(dp[n][w])

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = [[0]*(w+1) for i in range(n+1)]
    for i in range(1,n+1):
        for j in range(w+1):
            if j-l[i-1][0] >= 0:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-l[i-1][0]]+l[i-1][1])
            else:
                dp[i][j] = dp[i-1][j]
    print(dp[n][w])
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main()
    import numpy as np
    import sys
    input = sys.stdin.readline

    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = np.zeros(n+1,w+1)
    for i in range(n):
        dp[i+1,l[i][0]:] = np.maximum(dp[i,l[i][0]:],dp[i,-l[i][0]]+l[i][1])
    print(dp[n][w])

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = [[0]*(w+1) for i in range(n+1)]
    for i in range(1,n+1):
        for j in range(w+1):
            if j-l[i-1][0] >= 0:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-l[i-1][0]]+l[i-1][1])
            else:
                dp[i][j] = dp[i-1][j]
    print(dp[n][w])
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = [[0]*(w+1) for i in range(n+1)]
    for i in range(1,n+1):
        for j in range(w+1):
            if j-l[i-1][0] >= 0:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-l[i-1][0]]+l[i-1][1])
            else:
                dp[i][j] = dp[i-1][j]
    print(dp[n][w])
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    n,w = map(int,input().split())
    l = [list(map(int,input().split())) for i in range(n)]

    dp = [[0]*(w+1) for i in range(n+1)]
    for i in range(1,n+1):
        for j in range(w+1):
            if j-l[i-1][0] >= 0:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-l[i-1][0]]+l[i-1][1])
            else:
                dp[i][j] = dp[i-1][j]
    print(dp[n][w])
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    t = input()

    dp = [[0]*(len(t)+1) for i in range(len(s)+1)]


    check = 0
    for i in range(len(s)):
        
        for j in range(len(t)):
            if s[i]==t[j]:
                dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j],dp[i][j+1])
            else:
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
        
    i = len(s)
    j = len(t)
    ans = ""
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            ans = s[i-1] + ans
            i -= 1
            j -= 1
    print(ans)        
if __name__ == "__main__":
    main()


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

    dp = [[0]*(len(t)+1) for i in range(len(s)+1)]


    check = 0
    for i in range(len(s)):
        
        for j in range(len(t)):
            if s[i]==t[j]:
                dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j],dp[i][j+1])
            else:
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
        
    i = len(s)
    j = len(t)
    ans = ""
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            ans = s[i-1] + ans
            i -= 1
            j -= 1
    print(ans)        
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(float,input().split()))
dp = [[0]*(n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
    for j in range(n+1):
        dp[i][j] = dp[i-1][j]*(1-l[i-1])+dp[i-1][j-1]*l[i-1]
print(sum(dp[-1][n//2+1:]))

Fixed submission:
n = int(input())
l = list(map(float,input().split()))
dp = [[0]*(n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
    for j in range(n+1):
        dp[i][j] = dp[i-1][j]*(1-l[i-1])+dp[i-1][j-1]*l[i-1]
print(sum(dp[-1][n//2+1:]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
d = defaultdict(list)
n = int(input())
l = sorted(list(map(int,input().split())))
for i,j in enumerate(l):
    d[j].append(i)

used = [0]*n
ans = 0
for i in range(n-1,-1,-1):
    if used[i]:
        continue
    x = 2**(l[i].bit_length())
    y = x-l[i]
    if y in d:
        for j in d[y]:
            if used[j] == 0 and j != i:
                used[j] = 1
                ans += 1
                used[i] = 1
                break
print(ans)

Fixed submission:
from collections import defaultdict
d = defaultdict(int)
n = int(input())
l = sorted(list(map(int,input().split())))
for i in l:
    d[i] += 1

ans = 0
for i in range(n-1,-1,-1):
    if d[l[i]] == 0:
        continue
    x = 2**(l[i].bit_length())
    y = x-l[i]
    if y == l[i]:
        if d[y] >= 2:
            d[y] -= 2
            ans += 1
    else:
        if d[y] > 0:
            d[y] -= 1
            d[l[i]] -= 1
            ans += 1
            
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
l = [int(input()) for i in range(n)]
l.sort()
ans = l[-1]
for i in range(n-k):
  ans = min(ans,l[i+k]-l[i])
  if ans = 0
  print(0)
  exit()
  
print(ans)
  

Fixed submission:
n,k = map(int,input().split())
l = [int(input()) for i in range(n)]
l.sort()
ans = l[-1]
for i in range(n-k+1):
  ans = min(ans,l[i+k-1]-l[i])
  if ans == 0:
    print(0)
    exit()
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

for i in range(m//n,0,-1):
    if (m-n*i)%i == 0:
        print(i)
        exit()

Fixed submission:
import bisect
n,m = map(int,input().split())
l = []
for i in range(1,int(m**0.5)+1):
    if m%i == 0:
        l.append(i)
        l.append(m//i)

l.sort()
for i in range(len(l)-1,-1,-1):
    if l[i] <= m//n:
        print(l[i])
        exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
dic1={}
dic2={}
for i in range(n):
  if i%2==0:
    if l[i] in dic1:
      dic1[l[i]] += 1
    else:
      dic1[l[i]].append(1)
  else:
    if l[i] in dic2:
      dic2[l[i]] += 1
    else:
      dic2[l[i]].append(1)
      
count = 0
ma = 0
check=0
for i in dic1.values():
  ma = max(ma,i)
  check += i
count += check-ma
ma = 0
check=0
for i in dic2.values():
  ma = max(ma,i)
  check += i
count += check-ma

print(count)



Fixed submission:
n = int(input())
l = list(map(int,input().split()))
dic1={}
dic2={}
for i in range(n):
  if i%2==0:
    if l[i] in dic1:
      dic1[l[i]] += 1
    else:
      dic1[l[i]]=1
  else:
    if l[i] in dic2:
      dic2[l[i]] += 1
    else:
      dic2[l[i]]=1
dic1a = sorted(dic1.items(),key = lambda x:x[1])
dic2a = sorted(dic2.items(),key = lambda x:x[1]) 
 
if dic1a[-1][0] == dic2a[-1][0]:
    if len(dic1a) == len(dic2a) == 1:
        print(n//2)
    else:
        if dic1a[-2][1] >= dic2a[-2][1]:
            print(sum(dic2.values())-dic2a[-1][1]+sum(dic1.values())-dic1a[-2][1])
        else:
            print(sum(dic1.values())-dic1a[-1][1]+sum(dic2.values())-dic2a[-2][1])
else:
    print(sum(dic1.values())-dic1a[-1][1]+sum(dic2.values())-dic2a[-1][1])
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = []
i = 2
while m != 1:
    if m%i == 0:
        l.append(0)
        while m%i == 0:
            l[-1] += 1
            m //= i
    i += 1

mod = 10**9+7 
fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+max(l)+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

ans = 1

for i in l:
    ans *= nCr(n+i-1,n-1,mod)
    ans %= mod
print(ans)

Fixed submission:
n,m = map(int,input().split())
l = []
i = 2
if m == 1 or n == 1:
    print(1)
    exit()
while m != 1:
    if m%i == 0:
        l.append(0)
        while m%i == 0:
            l[-1] += 1
            m //= i
    i += 1

mod = 10**9+7 
fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,n+max(l)+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

ans = 1

for i in l:
    ans *= nCr(n+i-1,n-1,mod)
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
l = [list(map(int,input().split())) for i in range(h)]
count = 0
ans =[]
for i in range(h):
    for j in range(w-1):
        if l[i][j] %2 == 1:
            l[i][j+1] += 1
            ans.append([i+1,j+1,i+1,j+2])
            count += 1
for i in range(h-1):
    if l[i][w-1] %2 == 1:
        count += 1
        l[i+1][w-1] += 1
        ans.append([i+1,w,i+2,w])
print(count)
for i in ans:
    print(*i,)

Fixed submission:
h,w = map(int,input().split())
l = [list(map(int,input().split())) for i in range(h)]
count = 0
ans =[]
for i in range(h):
    for j in range(w-1):
        if l[i][j] %2 == 1:
            l[i][j+1] += 1
            ans.append([i+1,j+1,i+1,j+2])
            count += 1
for i in range(h-1):
    if l[i][w-1] %2 == 1:
        count += 1
        l[i+1][w-1] += 1
        ans.append([i+1,w,i+2,w])
print(count)
for i in ans:
    print(*i)
Buggy python submission (verdict: Runtime Error):
n = list(input())
k = int(input())
if len(n) == 1:
    print(int(n[0]))
    exit()
for i in range(len(n)):
    if n[i] != "1":
        x = i
        break
if i+1 > k:
    print(1)
    exit()
else:
    print(n[x])


Fixed submission:
n = list(input())
k = int(input())
if len(n) == 1:
    print(int(n[0]))
    exit()
x = 0
for i in range(len(n)):
    if n[i] != "1":
        x = i
        break
if x+1 > k:
    print(1)
    exit()
else:
    print(n[x])
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    n,m,q = map(int,input().split())
    l = [[0]*(n) for i in range(n)]
    for i in range(m):
        a,b = map(int,input().split())
        l[a-1][b-1] += 1

    for i in range(q):
        a,b = map(int,input().split())
        count = 0
        for i in range(a-1,b):
            for j in range(a-1,b):
                count += l[i][j]
        print(count)
if __name__ == "__main__":
    main()

Fixed submission:
n,m,q = map(int,input().split())
l = [[0]*(n) for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    l[a-1][b-1] += 1


for i in range(n):
    for j in range(n):
        if i != 0:
            l[i][j] += l[i-1][j]
        if j != 0:
            l[i][j] += l[i][j-1]
        if i!= 0 and j != 0:
            l[i][j] -= l[i-1][j-1]
    

for i in range(q):
    a,b = map(int,input().split())
    ans = l[b-1][b-1]
    if a >= 2:
        ans -= l[a-2][b-1]
    print(ans)

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

for i in range(q):
    a,b = map(int,input().split())
    count = 0
    for i in range(a-1,b):
        for j in range(a-1,b):
            count += l[i][j]
    print(count)

Fixed submission:
n,m,q = map(int,input().split())
l = [[0]*(n) for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    l[a-1][b-1] += 1


for i in range(n):
    for j in range(n):
        if i != 0:
            l[i][j] += l[i-1][j]
        if j != 0:
            l[i][j] += l[i][j-1]
        if i!= 0 and j != 0:
            l[i][j] -= l[i-1][j-1]
    

for i in range(q):
    a,b = map(int,input().split())
    ans = l[b-1][b-1]
    if a >= 2:
        ans -= l[a-2][b-1]
    print(ans)

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

for i in range(q):
    a,b = map(int,input().split())
    count = 0
    for i in range(a-1,b):
        for j in range(a-1,b):
            count += l[i][j]
    print(count)

Fixed submission:
n,m,q = map(int,input().split())
l = [[0]*(n) for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    l[a-1][b-1] += 1


for i in range(n):
    for j in range(n):
        if i != 0:
            l[i][j] += l[i-1][j]
        if j != 0:
            l[i][j] += l[i][j-1]
        if i!= 0 and j != 0:
            l[i][j] -= l[i-1][j-1]
    

for i in range(q):
    a,b = map(int,input().split())
    ans = l[b-1][b-1]
    if a >= 2:
        ans -= l[a-2][b-1]
    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b  map(int,input().split())
if a % b == 0:
  print(0)
else:
  print(1)

Fixed submission:
a,b = map(int,input().split())
if a % b == 0:
  print(0)
else:
  print(1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n < 1199:
  print("ABC")
elif n < 2800:
  print("ARC")
else:
  print("AGC)

Fixed submission:
n = int(input())
if n < 1200:
  print("ABC")
elif 1200 <= n < 2800:
  print("ARC")
else:
  print("AGC")
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())
for i in range(len(s)):
  check = True:
    for j in range(len(s)):
      if t[j] != s[(i+j)%len(s)]:
        check = False
    if check:
      print("Yes")
      exit()
      
print("No")

Fixed submission:
s = list(input())
t = list(input())
for i in range(len(s)):
  check = True
  for j in range(len(s)):
    if t[j] != s[(i+j)%len(s)]:
      check = False
  if check:
    print("Yes")
    exit()
      
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())

l = [list(map(int,input().split())) for i in range(m)]


count = 0
while True:
    check = [0]* n

    for i in l:
        a,b = i

        for j in range(a,b):
            check[j] += 1
            


    index = check.index(max(check))
    count += 1
    dellist = []
    for i in range(len(l)):
        a,b = l[i][0],l[i][1]
        if index in range(a,b):
            dellist.append(i)
    num = 0
    for i in dellist:
        del l[i-num]
        num += 1

    if l == []:
        break

print(count)
            






Fixed submission:
from operator import itemgetter

n,m = map(int,input().split())

l = sorted([list(map(int,input().split())) for i in range(m)],key=itemgetter(1))



check = -1
count = 0
for a,b in l:
  if a > check:
    count += 1
    check = b-1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop

n,m,s,t = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    e[u].append((v,a,b))
    e[v].append((u,a,b))

S = [float("INF")]*(n+1)
S[s] = 0
h = []
heappush(h,[s,0])
while h:
    now,d = heappop(h)
    for nex,a,b in e[now]:
        if d+a < S[nex]:
            S[nex] = d+a
            heappush(h,[nex,d+a])
T = [float("INF")]*(n+1)
T[t] = 0
h = []
heappush(h,[t,0])
while h:
    now,d = heappop(h)
    for nex,a,b in e[now]:
        if d+b < T[nex]:
            T[nex] = d+b
            heappush(h,[nex,d+b])

ans = [0]*(n+1)
cost = 10**15
now = 0
for i in range(n,0,-1):
    now = max(now,cost-S[i]-T[i])
    ans[i] = now
for i in ans[1:]:
    print(i)

Fixed submission:
from collections import deque

n,m,s,t = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    e[u].append((v,a,b))
    e[v].append((u,a,b))
S = [float("INF")]*(n+1)
S[s] = 0
q = deque([])
q.append([s,-1])
while q:
    now,bef = q.popleft()
    for nex,a,b in e[now]:
        if nex == bef:
            continue
        if S[now]+a < S[nex]:
            S[nex] = S[now]+a
            q.append([nex,now])
T = [float("INF")]*(n+1)
T[t] = 0
q = deque([])
q.append([t,-1])
while q:
    now,bef = q.popleft()
    for nex,a,b in e[now]:
        if nex == bef:
            continue
        if T[now]+b < T[nex]:
            T[nex] = T[now]+b
            q.append([nex,now])

ans = [0]*(n+1)
cost = 10**15
now = 0
for i in range(n,0,-1):
    now = max(now,cost-S[i]-T[i])
    ans[i] = now
for i in ans[1:]:
    print(i)
Buggy python submission (verdict: Runtime Error):
k = int(input())

l = []
for i in range(5):
    ten = 10**i
    for j in range(1,100):
        a = ten
        b = j
        n = a*b-1
        if n == 0:
            continue
        s = sum(map(int,str(n)))
        l.append([n/s,n])
l.sort()
now = 0
count = 0
i = 0
while count < k:
    if l[i][1] > now:
        now = l[i][1]
        count += 1
        print(l[i][1])
    i += 1


Fixed submission:
k = int(input())

l = []
for i in range(17):
    ten = 10**i
    for j in range(1,1000):
        a = ten
        b = j
        n = a*b-1
        if n == 0:
            continue
        s = sum(map(int,str(n)))
        l.append([n/s,n])
l.sort()
now = 0
count = 0
i = 0
while count < k:
    if l[i][1] > now:
        now = l[i][1]
        count += 1
        print(l[i][1])
    i += 1

Buggy python submission (verdict: Runtime Error):
k = int(input())

l = []
for i in range(17):
    ten = 10**i
    for j in range(2,11):
        a = ten
        b = j
        n = a*b-1
        s = sum(map(int,str(n)))
        l.append([s,n])
l.sort()

for i in range(k):
    print(l[i][1])


Fixed submission:
k = int(input())

l = []
for i in range(17):
    ten = 10**i
    for j in range(1,1000):
        a = ten
        b = j
        n = a*b-1
        if n == 0:
            continue
        s = sum(map(int,str(n)))
        l.append([n/s,n])
l.sort()
now = 0
count = 0
i = 0
while count < k:
    if l[i][1] > now:
        now = l[i][1]
        count += 1
        print(l[i][1])
    i += 1
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a > 9 or b > 9:
  print(":(")
else:
  print(""Yay!")

Fixed submission:
a,b = map(int,input().split())
if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in l:
  while i % 2 == 0:
    count += 1
    i // 2
print(count)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in l:
  while i % 2 == 0:
    count += 1
    i //= 2
print(count)