Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
sushis = [list(map(int, input().split())) for _ in range(N)]

sushis = sorted(sushis, key=lambda x: (x[1], x[0]), reverse=True)

p = 0


def calcPoint(selected_sushis):
    p = 0
    vari = set()
    for i, v in selected_sushis:
        vari.add(i)
        p += v
    p += len(vari)**2
    return p, vari


selected = sushis[:K]
unSelected = sushis[K:]

p, vari = calcPoint(selected)
cand = [p]

va = len(vari)
v = [0]*(N+1)
for i, _ in selected:
    v[i] += 1

can_del = []
for i, v in reversed(selected):
    if vari[i] > 2:
        vari[i] -= 1
        can_del.append(v)

can_in = []
for i, v in unSelected:
    if not i in vari:
        vari.add(i)
        can_in.append(v)

for od, nd in zip(can_del, can_in):
    nextp = p-od+nd-(vari)**2+(vari+1)**2
    cand.append(nextp)
    vari += 1
print(max(cand))


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
sushis = [list(map(int, input().split())) for _ in range(N)]

sushis = sorted(sushis, key=lambda x: (x[1], x[0]), reverse=True)

p = 0


def calcPoint(selected_sushis):
    p = 0
    vari = set()
    for i, v in selected_sushis:
        vari.add(i)
        p += v
    p += len(vari)**2
    return p, vari


selected = sushis[:K]
unSelected = sushis[K:]

p, vari = calcPoint(selected)
cand = [p]

va = len(vari)
v = [0]*(N+1)
for i, _ in selected:
    v[i] += 1

can_del = []
for i, d in reversed(selected):
    if v[i] >= 2:
        v[i] -= 1
        can_del.append(d)

can_in = []
for i, d in unSelected:
    if not i in vari:
        vari.add(i)
        can_in.append(d)

#print("del->", can_del, can_in)
for od, nd in zip(can_del, can_in):
    nextp = p-od+nd-(va)**2+(va+1)**2
    p = nextp
    cand.append(p)
    va += 1
print(max(cand))
Buggy python submission (verdict: Time Limit Exceeded):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [float('inf')]*N

dp[0] = 0
dp[1] = abs(H[1]-H[0])

for i in range(2, N):
    dp[i] = min([dp[i-v]+abs(H[i]-H[i-v]) for v in range(1, min(i, K)+1)])
print(dp[-1])


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
H = list(map(int, input().split()))

dp = [float('inf')]*N

dp[0] = 0
dp[1] = abs(H[1]-H[0])

for i in range(2, N):
    dp[i] = min([dp[i-v]+abs(H[i]-H[i-v]) for v in range(1, min(i, K)+1)])
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N)]

# init
first_item = items[0]
for i in range(W+1):
    if i >= first_item[0]:
        dp[0][i] = first_item[1]

# update
for i in range(1, N):
    for w in range(W+1):
        if w-items[i][0] >= 0:
            dp[i][w] = max(dp[i-1][w], dp[i-1][w-items[i][0]]+items[i][1])
        else:
            dp[i][w] = dp[i-1][w]

print(max(dp[N-1]))


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N)]

# init
first_item = items[0]
for i in range(W+1):
    if i >= first_item[0]:
        dp[0][i] = first_item[1]

# update
for i in range(1, N):
    for w in range(W+1):
        if w-items[i][0] >= 0:
            dp[i][w] = max(dp[i-1][w], dp[i-1][w-items[i][0]]+items[i][1])
        else:
            dp[i][w] = dp[i-1][w]

print(max(dp[N-1]))
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]


def solve():
    dp = [[0]*(W+1) for _ in range(N+1)]

    # init
    # update
    for i in range(1, N+1):
        for w in range(W+1):
            if w-items[i-1][0] >= 0:
                dp[i][w] = max(dp[i-1][w], dp[i-1]
                               [w-items[i-1][0]]+items[i-1][1])
            else:
                dp[i][w] = dp[i-1][w]

    print(max(dp[N]))


def solve2():
    dp = [0]*(W+1)
    for i in range(N):
        for w in reversed(range(W+1)):  # revにしないと、更新済みの値を使って更新しちゃう
            if w-items[i][0] >= 0:
                dp[w] = max(dp[w], dp[w-items[i][0]]+items[i][1])
    print(dp[-1])


solve2()


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]


def solve():
    MaxV = 10**3*N+1
    dp = [[float('inf')]*MaxV for _ in range(N+1)]
    dp[0][0] = 0

    for i in range(1, N+1):
        for v in range(MaxV):
            if items[i-1][1] <= v:
                dp[i][v] = min(dp[i-1][v], dp[i-1]
                               [v-items[i-1][1]]+items[i-1][0])
            else:
                dp[i][v] = dp[i-1][v]
    ans = 0
    for i, v in enumerate(dp[N]):
        if v <= W:
            ans = i

    print(ans)


solve()
Buggy python submission (verdict: Time Limit Exceeded):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
P = [0]+list(map(float, input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    for j in range(0, i+1):
        if j > 0:
            dp[i][j] = P[i]*dp[i-1][j-1]+(1-P[i])*dp[i-1][j]
        else:
            dp[i][j] = (1-P[i])*dp[i-1][j]

ans = 0
for i in range(N//2+1, N+1):
    ans += dp[-1][i]
print(ans)


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
P = [0]+list(map(float, input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    for j in range(0, i+1):
        if j > 0:
            dp[i][j] = P[i]*dp[i-1][j-1]+(1-P[i])*dp[i-1][j]
        else:
            dp[i][j] = (1-P[i])*dp[i-1][j]

ans = 0
for i in range(N//2+1, N+1):
    ans += dp[-1][i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split()))
if al(l%2==0 for l in L):
  print("second")
else:
  print("first")

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

if all(v % 2 == 0 for v in A):
    print("second")
else:
    print("first")
Buggy python submission (verdict: Time Limit Exceeded):
i = (input())

s = [c for c in i]

n = len(i)

c = 0
f = True
while(f):
    f = False
    for i in range(n-1):
        if s[i] == 'B' and s[i+1] == 'W':
            tmp = s[i]
            s[i] = s[i+1]
            s[i+1] = tmp
            c += 1
            f = True
            break

print(c)


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

s = input()
l = [0]*(len(s))
if s[0] == 'B':
    l[0] = 1
ans = 0
for i, c in enumerate(s[1:]):
    if c == 'B':
        l[i+1] = 1
    elif c == "W":
        ans += l[i]
    l[i+1] += l[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=input()
count=0
for i in range(357,int(n)+1,2):
    c=Counter(str(i))
    if len(c.keys())==3:
        if c['3'] and c['5'] and c['7']:
            count +=1
print(count)


Fixed submission:
n = (int)(input())

def f(s):
    ans = 0
    if (int)(s) > n:
        return 0
    for c in '753':
        num = (str)(s+c)
        if (int)(num) <= n:
            if num.count('3')and num.count('5') and num.count('7'):
                ans += 1
            ans += f(num)
    return ans
print(f('0'))
Buggy python submission (verdict: Runtime Error):
#M num of prefecture
#N num of city
N, M = map(int,input().split())
#P pref
#Y year
P=[]
Y=[]
cities=[]
for i in range(M):
    try:
        s = input()
        p,y = s.split()
        city=(p,y)
        cities.append(city) 
        P.append(p)
        Y.append(y)
    except:
        break

sort_city=sorted(cities,key=lambda x:(x[0],x[1]))
prefs = sorted(set(P))

address=[]
res=[]
for i in range(len(sort_city)): 
    address=str(sort_city[i][0]).rjust(6,'0')+str(i+1).rjust(6,'0')
    res.append((sort_city[i],address))

print(res[1][0])
for i in range(len(cities)):
    for j in range(len(res)):
        if cities[i] == res[j][0]:
            print(res[j][1])



Fixed submission:
x,y = list(map(int,input().split()))
print(int(x+y/2))

Buggy python submission (verdict: Runtime Error):
x,y = list(map(int,input().split())
print(x+y/2)

Fixed submission:
x,y = list(map(int,input().split()))
print(int(x+y/2))
Buggy python submission (verdict: Runtime Error):
h,w,k = list(map(int,input().split()))

mat = [[0 for i in range(w)] for j in range(h)]
mat[0][0]=1

for i in range(1,h):
    for j in range(w):
        if j==0:
            mat[i][j]=mat[i-1][j]+mat[i-1][j+1]
        elif j==w-1:
            mat[i][j]=mat[i-1][j]+mat[i-1][j-1]
        else:
            mat[i][j]=mat[i-1][j]+mat[i-1][j-1]+mat[i-1][j+1]

print(mat[h-1][k-1] % 1000000007)


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

mat = [[0 for _ in range(w)] for __ in range(h+1)]
mat[0][0] = 1


def num(n):
    ret = 0
    if n == 0:
        return 1
    for i in range(2**(n-1)):
        dig = format(i, 'b')
        if not '11' in dig:
            ret += 1

    return ret


if w == 1:
    print('1')
    exit()

for col in range(1, h+1):
    for row in range(w):
        if row == 0:
            mat[col][row] = mat[col-1][row] * \
                num(w-1) + mat[col-1][row+1]*num(w-2)
        elif row == w-1:
            mat[col][row] = mat[col-1][row] * \
                num(w-1) + mat[col-1][row-1]*num(w-2)
        else:
            mat[col][row] = mat[col-1][row] * (num(row)*num(w-row-1)) \
                + mat[col-1][row-1]*(num(row-1)*num(w-row-1))\
                + mat[col-1][row+1]*(num(row)*num(w-row-2))
print(mat[h][k-1] % 1000000007)
Buggy python submission (verdict: Runtime Error):
n,t=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append(tuple(map(int,input().split())))

l=sorted(l,key=lambda x:x[0])
for i in l:
    if i[1]<=t:
        print(i[0])
        exit(1)
print('TLE')


Fixed submission:
n,t=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append(tuple(map(int,input().split())))

l=sorted(l,key=lambda x:x[0])
for i in l:
    if i[1]<=t:
        print(i[0])
        exit()
print('TLE')
Buggy python submission (verdict: Runtime Error):
n = (int)(input())

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        tmp.remove(0)
        if tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, (lambda x: x if x >= 0 else 0)(tmp[0]))
            exit()


Fixed submission:
n = (int)(input())

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

f = False
for i in range(0, 100+1):
    for j in range(0, 100+1):
        for k in range(n):
            if h[k] != 0:
                ch = h[k] + abs(i-x[k]) + abs(j-y[k])
                break
        if all(max(ch-abs(i-x[k]) - abs(j-y[k]), 0) == h[k] for k in range(n)):
            print(i, j, ch)
            exit()

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

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        tmp.rempe(0)
        if tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, (lambda x: x if x >= 0 else 0)(tmp[0]))
            exit()


Fixed submission:
n = (int)(input())

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

f = False
for i in range(0, 100+1):
    for j in range(0, 100+1):
        for k in range(n):
            if h[k] != 0:
                ch = h[k] + abs(i-x[k]) + abs(j-y[k])
                break
        if all(max(ch-abs(i-x[k]) - abs(j-y[k]), 0) == h[k] for k in range(n)):
            print(i, j, ch)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
n, m = (list)(map(int, input().split()))

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


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

upper = m//n
ans = 0
for i in range(1, upper+1):
    if m % i == 0:
        ans = i
        if (m // i) > i and (m // i) <= upper:
            ans = m // i
            break

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n,m=list(map(int,input().split()))
lim=(int)(2*m/((n-1)*(n)))
for i in reversed(range(1,lim+2)):
    a=m%i
    b=m/i
    if a==0 and b>=n:
        x=(int)(n/3+1)
        for j in range(1,x):
            for k in range(1,x):
                for l in range(1,x):
                    if j+k+l==n:
                        print(j*2)
                        exit()



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

upper = m//n
ans = 0
for i in range(1, upper+1):
    if m % i == 0:
        ans = i
        if (m // i) > i and (m // i) <= upper:
            ans = m // i
            break

print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n,m=list(map(int,input().split()))
lim=(int)(2*m/((n-1)*(n)))
for i in reversed(range(1,lim+2)):
    a=m%i
    b=m/i
    print(i,a,b,n)
    if a==0 and b>=n:
        for j in range(1,(int)(n/3+1)):
            if(math.factorial(b-2)
                    /(math.factorial(n-j-1)*math.factorial(b-n+j-1))>0):
                print(j*i)
                exit()


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

upper = m//n
ans = 0
for i in range(1, upper+1):
    if m % i == 0:
        ans = i
        if (m // i) > i and (m // i) <= upper:
            ans = m // i
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
n = (int)(input())
l = list(map(int,input().split()))
a = l[::2]
b=l[1::2]

a_c=collections.Counter(a).most_common()
b_c=collections.Counter(b).most_common()
if a_c[0][0]==b_c[0][0]:
    if a_c[0][1]==b_c[0][1]:
        print(n//2)
    elif a_c[0][1]>b_c[0][1]:
        if len(b_c)>1:
            print(n-a_c[0][1]-b_c[1][1])
        else:
            print(n-a_c[0][1])
    else:
        if len(a_c)>1:
            print(n-a_c[1][1]-b_c[0][1])
        else:
            print(n-b_c[0][1])
else:
    print(n-a_c[0][1]-b_c[0][1])


Fixed submission:
s=str(input())
dst=s.translate({
    ord('1'):'9',
    ord('9'):'1',
    })
print(dst)
Buggy python submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
n, m = map(int, input().split())

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret /= j
    return (int)(ret)


res = 1
for ele in f:
    ret = comb(ele+n-1, n-1)
    res *= ret

print(res % mod)


Fixed submission:
l=list(map(int,input().split()))
l=sorted(l,reverse=True)
print(l[0]*10+l[1]+l[2])
Buggy python submission (verdict: Runtime Error):
n,m,x,y=list(map(int,input().split()))
l_x=list(map(int,input().split()))
l_y=list(map(int,input().split()))
x_max=max(l_x)
y_max=min(l_y)
for i in range(x_max+1,y_min):
    if x<i<=y:
        print('No War')
        exit()
print('War')


Fixed submission:
n,m,x,y=list(map(int,input().split()))
l_x=list(map(int,input().split()))
l_y=list(map(int,input().split()))
x_max=max(l_x)
y_min=min(l_y)
for i in range(x_max+1,y_min+1):
    if x<i<=y:
        print('No War')
        exit()
print('War')
Buggy python submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
n, m = map(int, input().split())

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret //= j
    return (int)(ret)


ans = 1
for i in f:
    c = 1
    for j in range(i):
        c = c * (n+j) // (j+1)
    ans *= c
print(ans % mod)


Fixed submission:
import collections
s=(str)(input())
t=(str)(input())

s_c=collections.Counter(s)
s_t=collections.Counter(t)
for i in range(len(s_c)):
    if s_c.get(s[i]) != s_t.get(t[i]):
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
m, n = (list)(map(int, input().split()))

l_prime = [0]*(n+1)
N = n
ran = range(3, N+1)

while n % 2 == 0:
    l_prime[2] += 1
    n /= 2

for i in ran:
    while n != 1:
        if n % i == 0:
            n /= i
            l_prime[i] += 1
        else:
            i += 2


def fact(n):
    tmp = 1
    while n != 0:
        tmp *= n
        n -= 1

    return tmp


def comb(a, b):
    if a < b:
        print("err")

    return (int)(fact(a)/(fact(a-b)*fact(b)))


res = 1
for i in range(1, N+1):
    ele = l_prime[i]
    if ele != 0:
        ret = comb(ele+m-1, ele)
        res *= ret

print(res % (10**9+1))


Fixed submission:
import math
mod = 10 ** 9 + 7
n, m = map(int, input().split())

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret //= j

    return (int)(ret)


ans = 1
for i in f:
    ans *= comb(i+n-1, i)
print(ans % mod)
Buggy python submission (verdict: Runtime Error):
n = (int)(input())
l_o = [v for v in range(1,n+1,2)]
l_e = [v for v in range(2,n+1,2)]
return (len(l_o)*len(l_e))

Fixed submission:
n=(int)(input())
if n%2==0:
    print((n//2)**2)
else:
    print((n//2)*(n//2+1))
Buggy python submission (verdict: Runtime Error):
import collections
n,k=list(map(int,input().split()))
l_n=[(v+1)%k for v in range(n)]
c = collections.Counter(l_n)
m = len(c)
ret=0
if k%2==0:
    for i in range(0,m,k/2):
        for j in range(0,m,k/2):
            if (i+j)%k==0:
                for r in range(0,r,k/2):
                    if(i+r)%k==0 and(r+j)%k==0:
                        ret+=c[i]*c[j]*c[r]
else:
    for i in range(0,m,k):
        for j in range(0,m,k):
            if (i+j)%k==0:
                for r in range(0,m,k):
                    if (i+r)%k ==0 and (r+j)%k==0:
                        ret+=c[i]*c[j]*c[r]
print(ret)
            
    


Fixed submission:
n, k = map(int, input().split())
print(sum([1 if v % k == 0 else 0 for v in range(1, n+1)])**3 +
      sum([1 if v % k == k/2 else 0 for v in range(1, n+1)])**3)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,k=list(map(int,input().split()))
l_n=[(v+1)%k for v in range(n)]
c = collections.Counter(l_n)
m = len(c)
ret=0
for i in range(0,m):
    for j in range(0,m):
        if (i+j)%k==0:
            for r in range(0,m):
                if (i+r)%k ==0 and (r+j)%k==0:
                    ret+=c[i]*c[j]*c[r]
print(ret)
            
    


Fixed submission:
n, k = map(int, input().split())
print(sum([1 if v % k == 0 else 0 for v in range(1, n+1)])**3 +
      sum([1 if v % k == k/2 else 0 for v in range(1, n+1)])**3)
Buggy python submission (verdict: Runtime Error):
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else S[0]
print(a)


Fixed submission:
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)

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

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(S) else None
a = n if n and c < K else S[0]
print(a)


Fixed submission:
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)

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

c = 0
for c in s:
  if not c == '1':
    break
  c += 1
n = s[c] if c < len(S) else None
a = n if n and c < K else S[0]
print(a)


Fixed submission:
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)

Buggy python submission (verdict: Runtime Error):
s = input()
K = (int)(input())
k = K
for n in s:
  if n != '1':
    print(n)
    exit(1)
print('1')


Fixed submission:
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)

Buggy python submission (verdict: Runtime Error):
s = input()
K = (int)(input())
k = K
for n in s:
  if k == 0:
    break
  elif n == '1':
    k = k-1
  else:
    print(n)
    exit(1)
if k == 0:
  print(s[K-1])


Fixed submission:
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)

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

if k <= 5000000000000000:
  for n in s:
    if k == 0:
      print(n)
    elif n == '1':
      k = k-1
    else:
      print(n)

else:
  for n in s:
    if n == '1':
      k = k-1
    elif n == '2':
      if k >= 2ae0i0:
      else:
        print(n)
    else:
    print(n)


Fixed submission:
s = input()
k = (int)(input())

c = 0
for ch in s:
  if not ch == '1':
    break
  c += 1
n = s[c] if c < len(s) else None
a = n if n and c < k else s[0]
print(a)