Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
        print(a, b)
        pair += 1
        a += 1
        b -= 1

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

a = 1
b = n

if n%2==1:
    for i in range(m):
        print(a, b)
        a += 1
        b -= 1
else:
    pair = 0
    while b-a > n//2 and pair < m:
        print(a, b)
        pair += 1
        a += 1
        b -= 1
    a += 1
    while pair < m:
        print(a, b)
        pair += 1
        a += 1
        b -= 1
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

res = [0 for i in range(2019)]
res[0] += 1
for i in range(len(s)):
    res[int(s[i:])%2019] += 1

ans = 0
for i in range(2019):
    ans += res[i]*(res[i]-1)//2
print(ans)

Fixed submission:
s = input()

res = [0 for i in range(2019)]
res[0] += 1

resten = 1
ressum = int(s[-1])
res[ressum] += 1

for i in range(2, len(s)+1):
    resten = (resten*10)%2019
    ressum = (int(s[-i])*resten + ressum)%2019
    res[ressum] += 1

ans = 0
for i in range(2019):
    ans += res[i]*(res[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

sum = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        if int(s[i:j+1])%2019 == 0:
            sum += 1

print(sum)

Fixed submission:
s = input()

res = [0 for i in range(2019)]
res[0] += 1

resten = 1
ressum = int(s[-1])
res[ressum] += 1

for i in range(2, len(s)+1):
    resten = (resten*10)%2019
    ressum = (int(s[-i])*resten + ressum)%2019
    res[ressum] += 1

ans = 0
for i in range(2019):
    ans += res[i]*(res[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

sum = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        if int(s[i:j+1])%2019 == 0:
            sum += 1

print(sum)

Fixed submission:
s = input()

res = [0 for i in range(2019)]
res[0] += 1

resten = 1
ressum = int(s[-1])
res[ressum] += 1

for i in range(2, len(s)+1):
    resten = (resten*10)%2019
    ressum = (int(s[-i])*resten + ressum)%2019
    res[ressum] += 1

ans = 0
for i in range(2019):
    ans += res[i]*(res[i]-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, c = list(map(int, input().split()))
s = input()

a = []
b = []

d = -1
for i in range(k):
    while s[d] == 'x':
        d -= 1
    b.insert(0, n+d)
    d -= c+1

d = 0
for i in range(k):
    while s[d] == 'x':
        d += 1
    if d == b[i]:
        print(d+1)
    d += c+1

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

b = []

d = -1
for i in range(k):
    while s[d] == 'x':
        d -= 1
    b.append(n+d)
    d -= c+1

d = 0
for i in range(k):
    while s[d] == 'x':
        d += 1
    if d == b[-i-1]:
        print(d+1)
    d += c+1

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

a = []
b = []

d = 0
for i in range(k):
    while s[d] == 'x':
        d += 1
    a.append(d)
    d += c+1

d = -1
for i in range(k):
    while s[d] == 'x':
        d -= 1
    b.insert(0, n+d)
    d -= c+1

for i in range(k):
    if a[i] == b[i]:
        print(a[i]+1)

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

b = []

d = -1
for i in range(k):
    while s[d] == 'x':
        d -= 1
    b.append(n+d)
    d -= c+1

d = 0
for i in range(k):
    while s[d] == 'x':
        d += 1
    if d == b[-i-1]:
        print(d+1)
    d += c+1
Buggy python submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))

if sqrt(a) + sqrt(b) < sqrt(c):
    print('Yes')
else:
    print('No')

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

if c-a-b > 0 and 4*a*b< (c-a-b)**2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import pprint

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

day = 0

while True:
    end = 1
    game = list()
    for i in range(n):
        if a[i] != []:
            end = 0
            if a[a[i][0]-1] != []:
                if a[a[i][0]-1][0]-1 == i:
                    game.append(i)
    if end == 0:
        if game == []:
            print(-1)
            exit()
        else:
            for i in game:
                a[i].pop(0)
    else:
        print(day)
        exit()
    day += 1

Fixed submission:
import pprint

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

day = 0
check = set(range(n))

while True:
    end = 1
    game = set()
    for i in check:
        if a[i] != []:
            end = 0
            if a[a[i][0]-1] != []:
                if a[a[i][0]-1][0]-1 == i:
                    game.add(i)
                    game.add(a[i][0]-1)
    if end == 0:
        if game == set():
            print(-1)
            exit()
        else:
            for i in game:
                a[i].pop(0)
    else:
        print(day)
        exit()
    day += 1
    check = game
Buggy python submission (verdict: Runtime Error):
def comb(n,r):
    return math.factorial(n)/(math.factorial(r)*math.factorial(n-r))

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

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1)*comb(n-k+1, i)%(10**9+7))

Fixed submission:
import math

def comb(n,r):
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

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

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1)*comb(n-k+1, i)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
def comb(n,r):
    return math.factorial(n)/(math.factorial(r)*math.factorial(n-r))

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

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1, exact=True)*comb(n-k+1, i, exact=True)%(10**9+7))

Fixed submission:
import math

def comb(n,r):
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

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

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1)*comb(n-k+1, i)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
from scipy.special import perm, comb

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


for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1, exact=True)*comb(n-k+1, i, exact=True)%(10**9+7))

Fixed submission:
import math

def comb(n,r):
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))

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

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1)*comb(n-k+1, i)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))

l = [0 for j in range(0, m)]
l[0] = 1
s = 0
ans = 0

for i in range(0, n):
    s += a[i]
    ans += l[s%m]
    l[s%m] += 1

print(ans)

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

d = {0: 1}
s = 0
ans = 0

for i in range(0, n):
    s += a[i]
    if s%m in d:
        d[s%m] += 1
    else:
        d[s%m] = 1
    ans += d[s%m]-1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)

for i in range(n):
    z = y.copy()
    z.remove(x[i])
    print(z[n//2 -1])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n//2 - 1]
b = y[n//2]

for i in range(n):
    if x[i] >= b:
        print(a)
    else:
        print(b)

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

for i in range(n):
    y = x.copy()
    del y[i]
    print(sorted(y)[n//2 -1])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n//2 - 1]
b = y[n//2]

for i in range(n):
    if x[i] >= b:
        print(a)
    else:
        print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))

graph = [[] for i in range(n)]

for i in range(m):
    l, r, d = list(map(int, input().split()))
    graph[l-1].append([r-1, d])
    graph[r-1].append([l-1, -d])



def func():
    visited = [False for i in range(n)]
    x = [None for i in range(n)]
    for i in range(n):
        if visited[i] == False:
            q = [i]
        while q:
            j = q.pop()
            visited[j] = True
            if x[j] == None:
                x[j] = 0
            for k, d in graph[j]:
                if visited[k] == False:
                    q.append(k)
                if x[k] == None:
                    x[k] = x[j] + d
                elif x[k] != x[j] + d:
                    return False
    return True

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

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

graph = [[] for i in range(n)]

for i in range(m):
    l, r, d = list(map(int, input().split()))
    graph[l-1].append([r-1, d])
    graph[r-1].append([l-1, -d])



def func():
    x = [None for i in range(n)]
    for i in range(n):
        if x[i] == None:
            x[i] = 0
            q = [i]
        while q:
            j = q.pop()
            for k, d in graph[j]:
                if x[k] == None:
                    q.append(k)
                    x[k] = x[j] + d
                elif x[k] != x[j] + d:
                    return False
    return True

if func():
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
s = [int(x) for x in input()]

for k in range(len(s)//2 + 1, len(s)+1):
    if (not all(s[len(s)-k:k])) and any(s[len(s)-k:k]):
        print(k - 1)
        break
else:
    print(len(s))

Fixed submission:
s = [int(x) for x in input()]

for k in range((len(s)+1)//2 + 1, len(s)+1):
    if s[k-1] != s[k-2] or s[-k] != s[-k+1]:
        print(k - 1)
        break
else:
    print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
dp = [[0]*3001 for _ in range(3001)]
n,s = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
MOD = 998244353
dp[0][0] = 1
for i in range(1,n+1):
    for j in range(s+1):
        dp[i][j] = (dp[i-1][j] * 2) % MOD
        if j >= a[i-1]:
            dp[i][j] = (dp[i][j] + dp[i-1][j-a[i-1]])%MOD
            
print(dp[n][s])

Fixed submission:
dp = [[0]*3001 for _ in range(3001)]
n,s = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
MOD = 998244353
dp[0][0] = 1
for i in range(1,n+1):
    for j in range(s+1):
        dp[i][j] = (dp[i-1][j] * 2) % MOD
        if j >= a[i-1]:
            dp[i][j] = (dp[i][j] + dp[i-1][j-a[i-1]])%MOD
            
print(dp[n][s])
Buggy python submission (verdict: Runtime Error):
n = int(input())
q = ["0"]
cnt = 0
while cnt < n - 1:
    qt = []
    for num in q:
        lastnum = num[-1]
        for i in range(int(lastnum) + 2):
            qt += [num + str(i)]
    q = qt.copy()
    cnt += 1
    
alp = "abcdefghijkl"
    
def show(num):
    ret = ""
    l = len(num)
    for i in range(l):
        ret += alp[int(num[i])]
    return ret

for num in q:
    print(show(num))

Fixed submission:
n = int(input())
q = [("0",0)]
cnt = 0
while cnt < n - 1:
    qt = []
    for numset in q:
        num = numset[0]
        maxnum = numset[1]
        for i in range(int(maxnum) + 2):
            mx = max(maxnum,i)
            qt += [(num + str(i), mx)]
    q = qt.copy()
    cnt += 1
    
alp = "abcdefghijkl"
    
def show(num):
    ret = ""
    l = len(num)
    for i in range(l):
        ret += alp[int(num[i])]
    return ret

q.sort()

for num in q:
    print(show(num[0]))
Buggy python submission (verdict: Runtime Error):
s = input()
q = int(input())
add_head = ""
add_tail = ""

for _ in range(q):
    query = input().split()
    if query[0] == "1":
        add_head, add_tail = add_tail,add_head
    else:
        if query[1] == "1":
            add_head = query[2] + add_head
        else:
            add_tail = add_tail + query[2]
                
print(add_head[::-1] + s + add_tail)

Fixed submission:
s = input()
if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = (int(num) for num in input().split())
ans = "APPROVED"
for i in range(n):
  if a[i] % 2 == 0 and a[i] % 3 != 0 and a[i] % 5 != 0:
    ans = "DENIED"
print(ans)

Fixed submission:
n = int(input())
a = [int(num) for num in input().split()]
ans = "APPROVED"
for i in range(n):
  if a[i] % 2 == 0 and a[i] % 3 != 0 and a[i] % 5 != 0:
    ans = "DENIED"
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import factorial
iMOD = 10**9 + 7

n = int(input())
s = input()
a = [0] * (n * 2)
for i in range(n*2):
    if s[i] == "B":
        a[i] = 1
        
prevbit = 0
prevlr = 0
lr = [0] * (n*2)
for i in range(n*2):
    if a[i] != prevbit:
        lr[i] = prevlr
    else:
        lr[i] = (prevlr + 1) % 2
    prevlr = lr[i]
    prevbit = a[i]
    
#print(lr)
    
ans = 1
if sum(lr) != n:
    ans = 0
else:
    suml = 0
    for i in range(n*2):
        if lr[i] == 1:
            ans = (ans * suml) % MOD
            suml -= 1
            if suml < 0:
                ans = 0
                break
        else:
            suml += 1
            
print((ans*factorial(n))%MOD)

Fixed submission:
from math import factorial
MOD = 10**9 + 7

n = int(input())
s = input()
a = [0] * (n * 2)
for i in range(n*2):
    if s[i] == "B":
        a[i] = 1
        
prevbit = 0
prevlr = 0
lr = [0] * (n*2)
for i in range(n*2):
    if a[i] != prevbit:
        lr[i] = prevlr
    else:
        lr[i] = (prevlr + 1) % 2
    prevlr = lr[i]
    prevbit = a[i]
    
#print(lr)
    
ans = 1
if sum(lr) != n:
    ans = 0
else:
    suml = 0
    for i in range(n*2):
        if lr[i] == 1:
            ans = (ans * suml) % MOD
            suml -= 1
            if suml < 0:
                ans = 0
                break
        else:
            suml += 1
            
print((ans*factorial(n))%MOD)
Buggy python submission (verdict: Runtime Error):
h,w,x,y = (int(num) for num in input().split())
if h==w:
    if(x==y and x!=h/2):
        print(h*w/2,0)
    else:
        print(h*w/2,1)
else:
    if(x==h/2 or y==w/2):
        print(h*w/2,0)
    else:
        prtin(h*w/2,1)

Fixed submission:
h,w,x,y = (int(num) for num in input().split())
if h!=0 and w!=0 and x==h/2 and y==w/2:
    print(h*w/2,1)
else:
    print(h*w/2,0)

Buggy python submission (verdict: Runtime Error):
h,w,x,y =(int num for num in input().split())
if h!=w and (x==h//2 or y==w//2):
  print(h*w/2,0)
else:
  print(h*w/2,1)

Fixed submission:
h,w,x,y = (int(num) for num in input().split())
if h!=0 and w!=0 and x==h/2 and y==w/2:
    print(h*w/2,1)
else:
    print(h*w/2,0)
Buggy python submission (verdict: Runtime Error):
from math import log2

n,k = (int(num) for num in input().split())
p = 1/n
ans = 0.0

if n >= k:
    ans += p * (n-k+1)
    for i in range(1,k):
        ans += p*(1/2)**(int(log2(k/i))+1)
        
else:
    for i in range(1,n+1):
        ans += p*(1/2)**(int(log2(k/i))+1)
        
print(ans)

Fixed submission:
from math import log

n,k = (int(num) for num in input().split())
p = 1/n
ans = 0.0

for i in range(1,n+1):
    j = i
    t = p
    while j < k:
        t *= 1/2
        j *= 2
    ans += t
    
print(ans)
Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
b = [int(num) for num in input().split()]
c = [int(num) for num in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

l = []
for i in range(X):
    if i+1 > K:
        break
    
    for j in range(Y):
        if (i+1) + (j+1) > K:
            break
        
        for k in range(Z):
            if (i+1) + (j+1) + (k+1) > K:
                break
            
            l.append(a[i]+b[j]+c[k])
            
            
l.sort(reverse=True)
for i in range(K):
    print(l[i])

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a > k:
    print(":(")
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if max(e-a) > k:
    print(":(")
else:
    print("Yay!")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a > k:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
b = [int(num) for num in input().split()]
queue = [[b,[]]]

def bfs(queue):
    c,prev = queue.pop(0)
    ret = 0
    l = len(c)
    for i in range(l):
        if c[i] == i+1:
            app = []
            if i==0:
                app = c[1:]
            elif i==l:
                app = c[:-1]
            else:
                app = c[:i] + c[i+1:]
            pr = [i+1] + prev
            if app == []:
                ret = 1
            queue.append([app,pr])
    return queue

ans = -1
while queue != []:
    if queue[-1][0] == []:
        ans = queue[-1]
        break
    queue = bfs(queue)
        
if ans == -1:
    print(ans)
else:
    for num in ans[1]:
        print(num)
        




Fixed submission:
N = int(input())
b = [int(num) for num in input().split()]
queue = [[b,[]]]

def bfs(queue):
    c,prev = queue.pop(0)
    cnt = len(c)-1
    while cnt >= 0:
        if c[cnt] == cnt+1:
            del c[cnt]
            prev = [cnt+1] + prev
            queue.append([c,prev])
            break
        cnt -= 1
    return queue

ans = -1
while queue != []:
    if queue[-1][0] == []:
        ans = queue[-1]
        break
    queue = bfs(queue)
        
if ans == -1:
    print(ans)
else:
    for num in ans[1]:
        print(num)
Buggy python submission (verdict: Runtime Error):
from math import gcd

nm = input().split()
n = int(nm[0])
m = int(nm[1])
s = input()
t = input()
g = gcd(n,m)

ans = int(n*m / g)
for i in range(g):
    if s[(n//g)*i] != t[(m//g)*i]:
        ans = -1
            
print(ans)

Fixed submission:
def gcd(a,b):
    while a%b != 0:
        a = a%b
        (a,b) = (b,a)
    return min(a,b)

nm = input().split()
n = int(nm[0])
m = int(nm[1])
s = input()
t = input()
g = gcd(m,n)

ans = int(n*m / g)
for i in range(g):
    if s[(n//g)*i] != t[(m//g)*i]:
        ans = -1
            
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

nm = input().split()
n = int(nm[0])
m = int(nm[1])
s = input()
t = input()

ans = int(n*m / gcd(n,m))
for i in range(n):
    if (m*i)%n==0:
        if s[i] != t[(m*i)//n]:
            ans = -1
            
print(ans)

Fixed submission:
def gcd(a,b):
    while a%b != 0:
        a = a%b
        (a,b) = (b,a)
    return min(a,b)

nm = input().split()
n = int(nm[0])
m = int(nm[1])
s = input()
t = input()
g = gcd(m,n)

ans = int(n*m / g)
for i in range(g):
    if s[(n//g)*i] != t[(m//g)*i]:
        ans = -1
            
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

nm = input().split()
n = int(nm[0])
m = int(nm[1])
s = input()
t = input()

ans = int(n*m / gcd(n,m))
for i in range(n):
    if (m*i)%n==0:
        if s[i] != t[(m*i)//n]:
            ans = -1
            
print(ans)


Fixed submission:
def gcd(a,b):
    while a%b != 0:
        a = a%b
        (a,b) = (b,a)
    return min(a,b)

nm = input().split()
n = int(nm[0])
m = int(nm[1])
s = input()
t = input()
g = gcd(m,n)

ans = int(n*m / g)
for i in range(g):
    if s[(n//g)*i] != t[(m//g)*i]:
        ans = -1
            
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

nm = input().split()
n = int(nm[0])
m = int(nm[1])

f = []

i = 2
j = 0
while (m > 1) and i<=m:
    while m%i == 0:
        m /= i
        j += 1
    if j >= 1:
        f.append(j)
    i += 1
    j = 0

        
ans = 1

for k in f:
    if k > 0:
        ans *= factorial(n+k-1) // (factorial(k) * factorial(n-1))
    
print(int(ans) % (10**9+7))


Fixed submission:
from math import factorial

nm = input().split()
n = int(nm[0])
m = int(nm[1])

f = []

i = 2
j = 0
while (m > 1) and i<=m:
    while m%i == 0:
        m /= i
        j += 1
    if j >= 1:
        f.append(j)
    i += 1
    j = 0

        
ans = 1

for k in f:
    if k > 0:
        ans *= factorial(n+k-1) // (factorial(k) * factorial(n-1))
    
print(int(ans) % (10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = input().split()
for i in range(n):
    x[i] = int(x[i])

for i in range(n):
    xm = x[:i] + x[i+1:]
    xm = sorted(xm)
    print(xm[int(n/2)-1])

Fixed submission:
n = int(input())
x = input().split()
for i in range(n):
    x[i] = int(x[i])
xs = sorted(x)
ml = xs[n//2-1]
mr = xs[n//2]

for i in range(n):
    if x[i] <= ml:
        print(mr)
    elif x[i] >= mr:
        print(ml)
Buggy python submission (verdict: Runtime Error):
N = int(input())


def kakuinowa(n):
    a = str(n)
    s = 0
    for i in range(len(a)):
        s = s + int(a[i])
    return s

import math
m = kakuinowa(N)
for i in range(int(math.log10(N)) + 1):
    n = kakuinowa((N // 10**i) * 10**i - 1)
    if n > m:
        m = n


print(m)


Fixed submission:
a = input()
a = list(a)
l = len(a)
for i in range(l):
    a[i] = int(a[i])
m = sum(a)
for i in range(l):
    n = a[i]-1 + 9*(l-i-1)
    if n > m:
        m = n
print(m)

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


def kakuinowa(n):
    a = str(n)
    s = 0
    for i in range(len(a)):
        s += int(a[i])
    return s

import math
m = kakuinowa(N)
for i in range(int(math.log10(N)) + 1):
    n = kakuinowa((N // 10**i) * 10**i - 1)
    if n > m:
        m = n


print(m)

Fixed submission:
a = input()
a = list(a)
l = len(a)
for i in range(l):
    a[i] = int(a[i])
m = sum(a)
for i in range(l):
    n = a[i]-1 + 9*(l-i-1)
    if n > m:
        m = n
print(m)

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

def sum(n):
    s = 0
    if n == 0:
        return 0
    else:
        return n % 10 + sum(n//10)

        
import math
m = sum(N)
for i in range(int(math.log10(N)) + 1):
    n = sum((N // 10**i) * 10**i - 1)
    if n > m:
        m = n


print(m)

Fixed submission:
a = input()
a = list(a)
l = len(a)
for i in range(l):
    a[i] = int(a[i])
m = sum(a)
for i in range(l):
    n = a[i]-1 + 9*(l-i-1)
    if n > m:
        m = n
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def sum(n):
    s = 0
    if n == 0:
        return 0
    else:
        while n != 0:
            s += n % 10
            n = n // 10
        return int(s)

        
import math
m = sum(N)
if N != 0:
    for i in range(int(math.log10(N)) + 1):
        n = sum((N // 10**i) * 10**i - 1)
        if n > m:
            m = n
else:
    m = 0


print(m)

Fixed submission:
a = input()
a = list(a)
l = len(a)
for i in range(l):
    a[i] = int(a[i])
m = sum(a)
for i in range(l):
    n = a[i]-1 + 9*(l-i-1)
    if n > m:
        m = n
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def sum(n):
    s = 0
    while n != 0:
        s += n % 10
        n = n // 10
    return int(s)
        
import math
m = sum(N)
for i in range(int(math.log10(N)) + 1):
    n = sum((N // 10**i) * 10**i - 1)
    if n > m:
        m = n

print(m)

Fixed submission:
a = input()
a = list(a)
l = len(a)
for i in range(l):
    a[i] = int(a[i])
m = sum(a)
for i in range(l):
    n = a[i]-1 + 9*(l-i-1)
    if n > m:
        m = n
print(m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = input().split()
for i in range(N):
    a[i] = int(a[i])

a.sort(reverse = True)
alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print(alice-bob)

Fixed submission:
N = int(input())
A = int(input())

if N % 500 <= A:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
list_mochi = []
for i in range(N):
    r = int(input())
    if not(r in list_mochi):
        list_mochi += [r]

print(len(list_mochi))

Fixed submission:
S = input()
print('2018/01/' + S[8:])