Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())

p1 = int(a // 0.08 + 1)
p2 = int(b // 0.1 + 1)

p1_list = [i for i in range(p1,p1+13)]
p2_list = [i for i in range(p2,p2+10)]

p_list = set(p1_list) & set(p2_list)

p_list = list(p_list)
p_list = sorted(p_list)

print(p_list[0])

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

for i in range(1,10001):
    if (i*0.08)//1==a and (i*0.1)//1==b:
        print(i)
        exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=int(input())
cnt=0
for _ in range(n):
    tmp=input()
    if tmp[0]=="1":
        cnt+=1
    else:
        num,side,st=tmp.split()
        if side=="1":
            if cnt%2==0:
                s=st+s
            else:
                s=s+st
        else:
            if cnt%2==0:
                s=s+st
            else:
                s=st+s
if cnt%2==1:
    s=s[::-1]
print(s)

Fixed submission:
s=input()
n=int(input())
cnt=0
left=[]
right=[]
for _ in range(n):
    tmp=input()
    if tmp[0]=="1":
        cnt+=1
    else:
        num,side,st=tmp.split()
        if side=="1":
            if cnt%2==0:
                left.append(st)
            else:
                right.append(st)
        else:
            if cnt%2==0:
                right.append(st)
            else:
                left.append(st)
left="".join(left)
left=left[::-1]
right="".join(right)
s=left+s+right
if cnt%2==1:
    s=s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=int(input())
cnt=0
for _ in range(n):
    tmp=input()
    if tmp[0]=="1":
        cnt+=1
    else:
        num,side,st=tmp.split()
        if side=="1":
            if cnt%2==0:
                s=st+s
            else:
                s=s+st
        else:
            if cnt%2==0:
                s=s+st
            else:
                s=st+s
if cnt%2==1:
    s=s[::-1]
print(s)

Fixed submission:
s=input()
n=int(input())
cnt=0
left=[]
right=[]
for _ in range(n):
    tmp=input()
    if tmp[0]=="1":
        cnt+=1
    else:
        num,side,st=tmp.split()
        if side=="1":
            if cnt%2==0:
                left.append(st)
            else:
                right.append(st)
        else:
            if cnt%2==0:
                right.append(st)
            else:
                left.append(st)
left="".join(left)
left=left[::-1]
right="".join(right)
s=left+s+right
if cnt%2==1:
    s=s[::-1]
print(s)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a + b = 3:
    print(3)
elif a + b = 4:
    print(2)
else:
    print(1)


Fixed submission:
a = int(input())
b = int(input())

if a + b == 3:
    print(3)
elif a + b == 4:
    print(2)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    memory = a[0]
    a.remove(a[0])
    print(max(a))
    a.append(memory)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)
count = a.count(m)

if count != 1:
    for i in range(n):
        print(m)

else:
    switch = 0
    for i in range(n-1):
        if a[i] == m:
            a.remove(m)
            m2max = max(a)
            print(m2max)
            a.append(m)
            switch = 1
        else:
            print(m)
    
    if switch == 1:
        print(m)
    else:
        a.remove(m)
        m2max = max(a)
        print(m2max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    memory = a[0]
    a.remove(a[0])
    print(max(a))
    a.append(memory)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)
count = a.count(m)

if count != 1:
    for i in range(n):
        print(m)

else:
    switch = 0
    for i in range(n-1):
        if a[i] == m:
            a.remove(m)
            m2max = max(a)
            print(m2max)
            a.append(m)
            switch = 1
        else:
            print(m)
    
    if switch == 1:
        print(m)
    else:
        a.remove(m)
        m2max = max(a)
        print(m2max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    memory = a[0]
    a.remove(a[0])
    print(max(a))
    a.append(memory)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)
count = a.count(m)

if count != 1:
    for i in range(n):
        print(m)

else:
    switch = 0
    for i in range(n-1):
        if a[i] == m:
            a.remove(m)
            m2max = max(a)
            print(m2max)
            a.append(m)
            switch = 1
        else:
            print(m)
    
    if switch == 1:
        print(m)
    else:
        a.remove(m)
        m2max = max(a)
        print(m2max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    memory = a[0]
    a.remove(a[0])
    print(max(a))
    a.append(memory)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)
count = a.count(m)

if count != 1:
    for i in range(n):
        print(m)

else:
    switch = 0
    for i in range(n-1):
        if a[i] == m:
            a.remove(m)
            m2max = max(a)
            print(m2max)
            a.append(m)
            switch = 1
        else:
            print(m)
    
    if switch == 1:
        print(m)
    else:
        a.remove(m)
        m2max = max(a)
        print(m2max)
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b, c, d = map(int, input().split())

#c,d,lcm(c,d)の倍数がa~bの区間にいくつあるか調べる関数
def check(p):
    if a%p==0:
        e = a//p
    else:
        e = (a//p) +1

    if b%p==0:
        f = b//p
    else:
        f = (b//p)
        
    return(f-e+1)
        

lcm = (c*d)//gcd(c,d)
    
ans = b-a+1 -(check(c)+check(d)) +check(lcm)
print(ans)

Fixed submission:
from fractions import gcd
a, b, c, d = map(int, input().split())

#c,d,lcm(c,d)の倍数がa~bの区間にいくつあるか調べる関数
def check(p):
    if a%p==0:
        e = a//p
    else:
        e = (a//p) +1

    if b%p==0:
        f = b//p
    else:
        f = (b//p)
        
    return(f-e+1)
        

lcm = (c*d)//gcd(c,d)
    
ans = b-a+1 -(check(c)+check(d)) +check(lcm)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
if m>0:
    a=[int(input()) for i in range(m)]

dp=[0]*(n+1)
dp[0]=1
if m>0:
    if a[0]==1:
        dp[1]=0
    else:
        dp[1]=1
else:
    dp[1]=1

for i in range(2,n+1):
    if m>0:
        if i in a:
            dp[i]=0
        else:
            dp[i]=(dp[i-2]+dp[i-1])%1000000007
    
    else:
        dp[i]=(dp[i-2]+dp[i-1])%1000000007

print(dp[-1])

Fixed submission:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
if m>0:
    a=[int(input()) for i in range(m)]

dp=[None]*(n+1)
dp[0]=1
for i in range(m):
    dp[a[i]]=0
if dp[1]==None:
    dp[1]=1

for i in range(2,n+1):
    if dp[i]==None:
        dp[i]=(dp[i-2]+dp[i-1])%1000000007

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
n = set([i for i in range(1,n+1)])

for i in range(m):
    a, b = map(int, input().split())
    ab = set([j for j in range(a,b+1)])
    n = n & ab
    if len(n) == 0:
        print(0)
        exit()

print(len(n))

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

left = 1
right = n

for i in range(m):
    a, b = map(int, input().split())
    if a > left:
        left = a
    if b < right:
        right = b
    
    if left > right:
        print(0)
        exit()

print(right-left+1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
n = set([i for i in range(1,n+1)])

for i in range(m):
    a, b = map(int, input().split())
    ab = set([j for j in range(a,b+1)])
    n = n & ab

print(len(n))

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

left = 1
right = n

for i in range(m):
    a, b = map(int, input().split())
    if a > left:
        left = a
    if b < right:
        right = b
    
    if left > right:
        print(0)
        exit()

print(right-left+1)
Buggy python submission (verdict: Runtime Error):
from sympy import divisors

n=int(input())
lst=sorted(map(int,input().split()))

p=divisors(lst[0])
q=divisors(lst[1])
pq=set(p+q)
pq=sorted(pq)
for i in range(len(pq)-1,-1,-1):
    out=0
    for j in lst:
        if j%pq[i]!=0:
            out+=1
    if out<=1:
        print(pq[i])
        exit()

Fixed submission:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n=int(input())
lst=sorted(map(int,input().split()))

p=make_divisors(lst[0])
q=make_divisors(lst[1])
pq=set(p+q)
pq=sorted(pq)
for i in range(len(pq)-1,-1,-1):
    out=0
    for j in lst:
        if j%pq[i]!=0:
            out+=1
    if out<=1:
        print(pq[i])
        exit()
Buggy python submission (verdict: Runtime Error):
a=[]
for i in range(5):
    a.append(int(input()))

zako=9
switch=0
for i in range(5):
    b=a[i]%10
    if b<=zako and b!=0:
        zako=b
        memory=i
        switch=1

if switch=0:
    memory=1
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

print(x+sum(lst))

Fixed submission:
a=[]
for i in range(5):
    a.append(int(input()))

zako=9
switch=0
for i in range(5):
    b=a[i]%10
    if b<=zako and b!=0:
        zako=b
        memory=i
        switch=1

if switch==0:
    memory=1
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

print(x+sum(lst))

Buggy python submission (verdict: Runtime Error):
a=[]
for i in range(5):
    a.append(int(input()))

zako=9
for i in range(5):
    b=a[i]%10
    if b<=zako and b!=0:
        zako=b
        memory=i
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

print(x+sum(lst))

Fixed submission:
a=[]
for i in range(5):
    a.append(int(input()))

zako=9
switch=0
for i in range(5):
    b=a[i]%10
    if b<=zako and b!=0:
        zako=b
        memory=i
        switch=1

if switch==0:
    memory=1
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

print(x+sum(lst))

Buggy python submission (verdict: Runtime Error):
a=[]
for i in range(5):
    a.append(int(input()))

zako=9
for i in range(5):
    b=a[i]%10
    if b<zako and b!=0:
        zako=b
        memory=i
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

print(x+sum(lst))

Fixed submission:
a=[]
for i in range(5):
    a.append(int(input()))

zako=9
switch=0
for i in range(5):
    b=a[i]%10
    if b<=zako and b!=0:
        zako=b
        memory=i
        switch=1

if switch==0:
    memory=1
x=a.pop(memory)

lst=[]

for i in range(4):
    c=a[i]//10
    c=c*10
    if a[i]%10!=0:
        c+=10
    lst.append(c)

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

for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        lst[i]=1

for i in range(q):
    c=lst[a[i]-1:b[i]-1]
    print(c.count(1))

Fixed submission:
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input().rstrip()

lst=[0]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        lst.append(lst[i-1]+1)
    else:
        lst.append(lst[i-1])

for i in range(q):
    l,r=map(int,input().split())
    print(lst[r-1]-lst[l-1])

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

for i in range(n-1):
    if s[i]=="A" and s[i+1]=="C":
        lst[i]=1

for i in range(q):
    c=lst[a[i]-1:b[i]-1]
    print(c.count(1))

Fixed submission:
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input().rstrip()

lst=[0]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        lst.append(lst[i-1]+1)
    else:
        lst.append(lst[i-1])

for i in range(q):
    l,r=map(int,input().split())
    print(lst[r-1]-lst[l-1])

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

for i in range(q):
    print(s.count("AC",a[i]-1,b[i]))

Fixed submission:
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input().rstrip()

lst=[0]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        lst.append(lst[i-1]+1)
    else:
        lst.append(lst[i-1])

for i in range(q):
    l,r=map(int,input().split())
    print(lst[r-1]-lst[l-1])

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

for i in range(q):
    print(s.count("AC",a[i]-1,b[i]))

Fixed submission:
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input().rstrip()

lst=[0]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        lst.append(lst[i-1]+1)
    else:
        lst.append(lst[i-1])

for i in range(q):
    l,r=map(int,input().split())
    print(lst[r-1]-lst[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
input=sys.stdin.readline
s=input().rstrip()
d=deque([])
for i in range(len(s)):
    d.append(int(s[i]))
d.append(2)
ans=0
while 0 in d and 1 in d:
    if d[0]+d[1]==1:
        d.popleft()
        d.popleft()
        ans+=2
    else:
        d.rotate(-1)
 
print(ans)

Fixed submission:
s=input()
print(2*min(s.count("0"), s.count("1")))

Buggy python submission (verdict: Runtime Error):
s=input()
ans=0
num=0
while num<len(s)-1:
    if s[num]!=s[num+1]:
        s=s[:num]+s[num+2:]
        num-=1
        ans+=2
    else:
        num+=1
print(ans)

Fixed submission:
s=input()
print(2*min(s.count("0"), s.count("1")))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ans=0
num=0
while num<len(s)-1:
    if s[num]!=s[num+1]:
        s=s[:num]+s[num+2:]
        num-=1
        ans+=2
    else:
        num+=1
print(ans)

Fixed submission:
s=input()
print(2*min(s.count("0"), s.count("1")))
Buggy python submission (verdict: Time Limit Exceeded):
from decimal import Decimal
n=int(input())
p=list(map(Decimal,input().split()))

dp=[[0]*(n+1) for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(n):
        dp[j][i+1]+=dp[j][i]*(1-p[i])
        dp[j+1][i+1]+=dp[j][i]*p[i]

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

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

dp=[[0]*(n+1) for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(n):
        dp[j][i+1]+=dp[j][i]*(1-p[i])
        dp[j+1][i+1]+=dp[j][i]*p[i]

ans=0
for j in range((n+1)//2,n+1):
    ans+=dp[j][-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h=sorted(h)
s=[]
for i in range(n-1):
    s.append(h[i+1]-h[i])
t=[]
for i in range(n-k+1):
    t.append(sum(s[i:i+k-1]))

print(min(t))

Fixed submission:
n,k=map(int,input().split())
h=sorted(int(input()) for i in range(n))
ans=10**10
for i in range(n-k+1):
    ans=min(h[i+k-1]-h[i],ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h=sorted(h)
s=[]
for i in range(n-1):
    s.append(h[i+1]-h[i])
t=[]
for i in range(n-k+1):
    t.append(sum(s[i:i+k-1]))

print(min(t))

Fixed submission:
n,k=map(int,input().split())
h=sorted(int(input()) for i in range(n))
ans=10**10
for i in range(n-k+1):
    ans=min(h[i+k-1]-h[i],ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h=sorted(h)
s=[]
for i in range(n-1):
    s.append(h[i+1]-h[i])

ans=10**10
for i in range(n-k+1):
    p=sum(s[i:i+k-1])
    ans=min(ans,p)

print(ans)

Fixed submission:
n,k=map(int,input().split())
h=sorted(int(input()) for i in range(n))
ans=10**10
for i in range(n-k+1):
    ans=min(h[i+k-1]-h[i],ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

n,m=map(int,input().split())
lst=[]
print_lst=[]
for i in range(n):
    lst.append([])
for i in range(m):
    p,y=map(int,input().split())
    lst[p-1].append(y)
    print_lst.append([p-1,y])

for i in range(n):
    lst[i]=sorted(lst[i])

for i in range(m):
    left=str(print_lst[i][0]+1)
    right=str(lst[print_lst[i][0]].index(print_lst[i][1])+1)
    prnt=["0"*(6-len(left)),left,"0"*(6-len(right)),right]
    print("".join(prnt))

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

n,m=map(int,input().split())
lst=[]
for i in range(n):
    lst.append([])

for i in range(m):
    p,y=map(int,input().split())
    lst[p-1].append([i,p,y])

for i in range(n):
    lst[i]=sorted(lst[i],key=lambda x:x[2])

for i in range(n):
    for j in range(len(lst[i])):
        lst[i][j].append(j+1)

lst=[i for j in lst for i in j]
lst=sorted(lst,key=lambda x:x[0])

for i in range(m):
    left=str(lst[i][1])
    right=str(lst[i][3])
    prnt=["0"*(6-len(left)),left,"0"*(6-len(right)),right]
    print("".join(prnt))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lst=[]
print_lst=[]
for i in range(n):
    lst.append([])
for i in range(m):
    p,y=map(int,input().split())
    lst[p-1].append(y)
    print_lst.append([p-1,y])

for i in range(n):
    lst[i]=sorted(lst[i])

for i in range(m):
    left=str(print_lst[i][0]+1)
    right=str(lst[print_lst[i][0]].index(print_lst[i][1])+1)
    prnt=["0"*(6-len(left)),left,"0"*(6-len(right)),right]
    print("".join(prnt))

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

n,m=map(int,input().split())
lst=[]
for i in range(n):
    lst.append([])

for i in range(m):
    p,y=map(int,input().split())
    lst[p-1].append([i,p,y])

for i in range(n):
    lst[i]=sorted(lst[i],key=lambda x:x[2])

for i in range(n):
    for j in range(len(lst[i])):
        lst[i][j].append(j+1)

lst=[i for j in lst for i in j]
lst=sorted(lst,key=lambda x:x[0])

for i in range(m):
    left=str(lst[i][1])
    right=str(lst[i][3])
    prnt=["0"*(6-len(left)),left,"0"*(6-len(right)),right]
    print("".join(prnt))
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n==2:
  a=3/0
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)

Fixed submission:
n=int(input())
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
lst=sorted(lst,key=lambda x:x[2],reverse=True)
for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if z==0:
                if abs(i-x)+abs(j-y)<height:
                    switch=1
                    break
            elif abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
lst=list(map(int,input().split()))
ans=float("inf")
for i in range(n-k+1):
    tmp=lst[i:i+k]
    left=tmp[0]
    right=tmp[-1]
    if left==0 and right==0:
        print(0)
        exit()
    if left<0 and right<=0:
        ans=min(ans,abs(left))
    elif left<0 and right>0:
        if abs(left)>abs(right):
            ans=min(ans,abs(left)+right*2)
        else:
            ans=min(ans,abs(left)*2+right)
    else:
        ans=min(ans,right)
print(ans)

Fixed submission:
n,k=map(int,input().split())
lst=list(map(int,input().split()))
ans=float("inf")
for i in range(n-k+1):
    left=lst[i]
    right=lst[i+k-1]
    if left==0 and right==0:
        print(0)
        exit()
    if left<0 and right<=0:
        ans=min(ans,abs(left))
    elif left<0 and right>0:
        if abs(left)>abs(right):
            ans=min(ans,abs(left)+right*2)
        else:
            ans=min(ans,abs(left)*2+right)
    else:
        ans=min(ans,right)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=list(input())
k=int(input())
for i in range(100):
    if s[i]!="1":
        p=i+1
        pnum=int(s[i])
        break

if k<p:
    print(1)
else:
    print(pnum)

Fixed submission:
s=list(input())
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        p=i+1
        pnum=int(s[i])
        break
    p=101

if k<p:
    print(1)
else:
    print(pnum)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
from bisect import bisect
n=int(input())
lst=sorted(map(int,input().split()))
ans_max=0
m=lst[-1]
index=bisect(lst,m/2)
if 0<=index-1:
    tmp=factorial(m)//factorial(m-lst[index-1])//factorial(lst[index-1])
    if tmp>ans_max:
        ans_max=tmp
        ans=[m,lst[index-1]]
if m!=lst[index]:
    tmp=factorial(m)//factorial(m-lst[index])//factorial(lst[index])
    if tmp>ans_max:
        ans_max=tmp
        ans=[m,lst[index]]
print(" ".join(map(str,ans)))

Fixed submission:
from bisect import bisect
n=int(input())
lst=sorted(map(int,input().split()))
m=lst[-1]
index=bisect(lst,m/2)
if m!=lst[index]:
    q=lst[index]
    if 0<=index-1:
        p=lst[index-1]
        if abs(m/2-p)>=abs(m/2-q):
            print(m,q)
        else:
            print(m,p)
    else:
        print(m,q)
else:
    print(m,lst[index-1])

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
from bisect import bisect
n=int(input())
lst=sorted(map(int,input().split()))
ans_max=0
for i in range(-1,-n,-1):
    index=bisect(lst,lst[i]/2)
    if 0<=index-1:
        tmp=factorial(lst[i])//factorial(lst[i]-lst[index-1])//factorial(lst[index-1])
        if tmp>ans_max:
            ans_max=tmp
            ans=[lst[i],lst[index-1]]
    if lst[i]!=lst[index]:
        tmp=factorial(lst[i])//factorial(lst[i]-lst[index])//factorial(lst[index])
        if tmp>ans_max:
            ans_max=tmp
            ans=[lst[i],lst[index]]
print(" ".join(map(str,ans)))

Fixed submission:
from bisect import bisect
n=int(input())
lst=sorted(map(int,input().split()))
m=lst[-1]
index=bisect(lst,m/2)
if m!=lst[index]:
    q=lst[index]
    if 0<=index-1:
        p=lst[index-1]
        if abs(m/2-p)>=abs(m/2-q):
            print(m,q)
        else:
            print(m,p)
    else:
        print(m,q)
else:
    print(m,lst[index-1])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())

for i in range(a,b+1):
    if i<a+k or i>b-k:
        print(i)

Fixed submission:
a,b,k=map(int,input().split())
lst=[]
for i in range(a,a+k):
    if i>b:
        break
    lst.append(i)
    print(i)
for i in range(b-k+1,b+1):
    if i<a:
        continue
    if not i in lst:
        print(i)