Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [None] * n
B = [None] * n
for i in range(n):
    A[i], B[i] = list(map(int, input().split()))

print(A[B.index(min_point)] + min(B))

Fixed submission:
n = int(input())
A = [None] * n
B = [None] * n
for i in range(n):
    A[i], B[i] = list(map(int, input().split()))

print(A[B.index(min(B))] + min(B))
Buggy python submission (verdict: Runtime Error):
r, g, b = map(int, input().split())
if (100 * a + 10 * b + c % 4 == 0):
  print('YES')
else:
  print('NO')


Fixed submission:
r, g, b = map(int, input().split())
if ((100 * r + 10 * g + b) % 4 == 0):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if (b − a == c − b):
  print('YES')
else:
  print('NO')


Fixed submission:
a, b, c = map(int, input().split())
d = b - a
e = c - b
if (d == e):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
n = input()
print(800 * n - 200 * (n//15))


Fixed submission:
n = int(input())
print(800 * n - 200 * (n//15))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    for z in range(k + 1):
      if (x + y + z == s):
        ans += 1

print(ans)


Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    if (x + y <= s and s - (x + y) <= k):
      ans += 1


print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

l = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
]

print(l[l.index(s)+1])

Fixed submission:
s = input()

l = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z"
]

print(l[l.index(s)+1])
Buggy python submission (verdict: Runtime Error):
s = input()

flg = 0
for i, c in enumrate(range(s)):
  if i%2!=0:
    if c in ["R", "U", "D"]:
      continue
    else:
      flg = 1
      break
  else:
    if c in ["R", "U", "D"]:
      continue
    else:
      flg = 1
      break
    
ans = "Yes" if flg else "No"
print(ans)

Fixed submission:
s = input()

flg = 0
for i, c in enumerate(s):
  if i%2!=0:
    if c in ["L", "U", "D"]:
      continue
    else:
      flg = 1
      break
  else:
    if c in ["R", "U", "D"]:
      continue
    else:
      flg = 1
      break

ans = "Yes" if not flg else "No"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def gcm(a,b):
    g = max(a,b)
    s = min(a,b)
    while g % s != 0:
        g = max(a,b)
        s = min(a,b)
        g = g % s
    return s

def main():
    n, x = map(int, input().split())
    X = list(map(int, input().split()))

    for i in range(n):
        X[i] -= x
        if X[i] < 0:
            X[i] *= -1

    m = X[0]
    for c in X[1:]:
        m = gcm(c,m)

    print(m)

if __name__ == "__main__":
    main()

Fixed submission:
def gcd(g, s):
    while g % s != 0:
        s, g = sorted([g,s])
        g = g % s
    return s

def main():
    n, x = map(int, input().split())
    X = list(map(int, input().split()))

    for i in range(n):
        X[i] -= x
        if X[i] < 0:
            X[i] *= -1

    m = X[0]
    for c in X[1:]:
        m = gcd(c,m)

    print(m)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def gcm(a,b):
    g = max(a,b)
    s = min(a,b)
    while g % s != 0:
        g = g % s
    return s

def main():
    n, x = map(int, input().split())
    X = list(map(int, input().split()))

    for i in range(n):
        X[i] -= x
        if X[i] < 0:
            X[i] *= -1

    m = X[0]
    for c in X[1:]:
        m = gcm(c,m)

    print(m)

if __name__ == "__main__":
    main()

Fixed submission:
def gcd(g, s):
    while g % s != 0:
        s, g = sorted([g,s])
        g = g % s
    return s

def main():
    n, x = map(int, input().split())
    X = list(map(int, input().split()))

    for i in range(n):
        X[i] -= x
        if X[i] < 0:
            X[i] *= -1

    m = X[0]
    for c in X[1:]:
        m = gcd(c,m)

    print(m)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

# 中央値を取るのがみそ


Fixed submission:
# A - Multiple of 2 and N
# https://beta.atcoder.jp/contests/abc102/tasks/abc102_a

# A_Multiple_of_2_and_N.py

N = int(input())

if N == 1:
    print(2)
elif N%2 == 0:
    print(N)
else:
    print(N*2)

Buggy python submission (verdict: Runtime Error):
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)


Fixed submission:
# A - Multiple of 2 and N
# https://beta.atcoder.jp/contests/abc102/tasks/abc102_a

# A_Multiple_of_2_and_N.py

N = int(input())

if N == 1:
    print(2)
elif N%2 == 0:
    print(N)
else:
    print(N*2)
Buggy python submission (verdict: Runtime Error):
# https://beta.atcoder.jp/contests/abc101/tasks/abc101_b
# B - Digit Sums

# B_Digit_Sums.py

N = int(input())
str_N = str(N)

S_N = 0
for i in range(str_N):
    S_N += ( N % (10 ** (i+1)) ) // ( N // (10 ** i) )
print(S_N)


Fixed submission:
# https://beta.atcoder.jp/contests/abc101/tasks/abc101_b
# B - Digit Sums

# B_Digit_Sums.py

N = int(input())
str_N = str(N)

S_N = 0
for i in range(len(str_N)):
    S_N += ( N % (10 ** (i+1)) ) // (10 ** i)

if N % S_N == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
# https://abc100.contest.atcoder.jp/tasks/abc100_b
# B - Ringos Favorite Numbers

# B_Ringos_Favorite_Numbers.py

D, N = map(int, input().strip().split(" "))

if D == 0:
    print(N)
else:
    if D == 1:
        n = [i*100 for i in range(1, 100)]
    else:
        n = [i*10000 for i in range(1, 100)]
    print(n[N-1])


Fixed submission:
# https://abc100.contest.atcoder.jp/tasks/abc100_b
# B - Ringos Favorite Numbers

# B_Ringos_Favorite_Numbers.py

D, N = map(int, input().strip().split(" "))

if D == 0:
    #n = N
    #order_100 = -1
    #while n >= 1:
    #    n = n / 100
    #    order_100 += 1

    #if order_100 == 0:
    if N <= 99:
        print(N)
    else:
        print(101)

elif D == 1:
    if N <= 99:
        print(N*100)
    else:
        print(10100)
elif D == 2:
    if N <= 99:
        print(N*10000)
    else:
        print(1010000)

Buggy python submission (verdict: Runtime Error):
#
# B - Ringo's Favorite Numbers

# B_Ringos_Favorite_Numbers.py

m = 100

D, N = map(int, input().strip().split(" "))


if D == 0:
    print(N)
else:
    if D == 1:
        n = [i*100 for i in range(1, 100)]
    else:
        n = [i*10000 for i in range(1, 100)]
    print(n[N-1])


Fixed submission:
# https://abc100.contest.atcoder.jp/tasks/abc100_b
# B - Ringos Favorite Numbers

# B_Ringos_Favorite_Numbers.py

D, N = map(int, input().strip().split(" "))

if D == 0:
    #n = N
    #order_100 = -1
    #while n >= 1:
    #    n = n / 100
    #    order_100 += 1

    #if order_100 == 0:
    if N <= 99:
        print(N)
    else:
        print(101)

elif D == 1:
    if N <= 99:
        print(N*100)
    else:
        print(10100)
elif D == 2:
    if N <= 99:
        print(N*10000)
    else:
        print(1010000)
Buggy python submission (verdict: Runtime Error):
# https://beta.atcoder.jp/contests/abc099/tasks/abc099_a
# A - ABD

# A_ABD.py

N = int(input())

C_or_D = (N-1) // 999


name = ""

if C_or_D == 0:
    name += "ABC"
    #n = N
elif C_or_D == 1:
    name += "ABD"
    #n = '{0:03d}'.format(N - 999)

name += str(n)

print(name)


Fixed submission:
# https://beta.atcoder.jp/contests/abc099/tasks/abc099_a
# A - ABD

# A_ABD.py

N = int(input())

C_or_D = (N-1) // 999


name = ""

if C_or_D == 0:
    name += "ABC"
    #n = N
elif C_or_D == 1:
    name += "ABD"
    #n = '{0:03d}'.format(N - 999)

#ame += str(n)

print(name)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    a,b,k = map(int, input().split())

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

if __name__ == "__main__":
    main()

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

    i = a
    while True:
        if i > b:
            return
        if i-a + 1 > k:
            i = max(i, b-k+1)
            break
        print(i)
        i += 1
    while True:
        if i > b:
            break
        print(i)
        i += 1

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
if len(set(input().split()))1:
    print("Yes")
else:
    print("No")

Fixed submission:
if len(set(input().split()))==1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
lcm=1
from fractions import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
print(ans%mod)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
lcm=1
from fractions import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
lcm=1
from fractions import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
    ans%=mod
print(ans)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
lcm=1
from fractions import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
b=[]
lcm=1
from math import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
    ans%=mod
print(ans)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
lcm=1
from fractions import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
b=[]
lcm=1
from math import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
    ans%=mod
print(ans)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
lcm=1
from fractions import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import string
print(string.ascii_lowercase[string.ascii_lowercase.index(input()+1])

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import string
print(string.ascii_lowercase[string.ascii_lowercase.index(input())+1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
set_n_3=set()
for i0 in range(n):
    for i1 in range(i0+1,n):
        for i2 in range(i1+1,n):
            set_n_3.add(s[i0]+s[i1]+s[i2])
print(len(set_n_3))

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            flag=[0,0,0]
            for index in range(n):
                if flag[0]==0 and flag[1]==0 and  s[index]==str(i):
                    flag[0]=1
                elif flag[0]==1 and flag[1]==0 and s[index]==str(j):
                    flag[1]=1
                elif flag[0]==1 and flag[1]==1 and s[index]==str(k):
                    ans+=1
#                     print(i,j,k)
                    break
                else:
                    continue
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
s=[]
dp=[False]*n
ans=0
for _ in range(n):
    s.append(input())
for i in range(n):
    for j in range(i):
        if not dp[i]:
            dp[i]=Counter(s[i])
        if not dp[j]:
            dp[j]=Counter(s[j])
        if dp[i]==dp[j]:
            ans+=1
print(ans)

Fixed submission:
from collections import defaultdict
n=int(input())
d=defaultdict(int)
ans=0
for _ in range(n):
    d["".join(sorted(input()))]+=1
# print(d)
for key,i in d.items():
    ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
def is_anagram(s1,s2):
    if Counter(s1)==Counter(s2):
        return True
    else:
        return False

n=int(input())
s=[]
ans=0
for _ in range(n):
    s.append(input())
for i in range(n):
    for j in range(i):
        if is_anagram(s[i],s[j]):
            ans+=1
print(ans)

Fixed submission:
from collections import defaultdict
n=int(input())
d=defaultdict(int)
ans=0
for _ in range(n):
    d["".join(sorted(input()))]+=1
# print(d)
for key,i in d.items():
    ans+=i*(i-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
u,v=[],[]
path=[[] for i in range(n)]
for i in range(m):
    ui,vi=[int(x)-1 for x in input().split()]
    path[ui].append(vi)
    # path[vi].append(ui)
s,t=[int(x)-1 for x in input().split()]
from collections import deque
q=deque()
q.append((s,0))
# print(path)
check=[False]*n
while q:
    # print(q)
    p,num=q.popleft()
    if num%3!=0:
        for i in path[p]:
            q.append((i,num+1))
        continue
    elif p==t:
        print(num//3)
        import sys
        sys.exit()
    elif check[p]==True:
        continue
    else:
        for i in path[p]:
            q.append((i,num+1))
        check[p]=True
print(-1)

Fixed submission:
n,m=map(int,input().split())
u,v=[],[]
path=[[] for i in range(n)]
for i in range(m):
    ui,vi=[int(x)-1 for x in input().split()]
    path[ui].append(vi)
    # path[vi].append(ui)
s,t=[int(x)-1 for x in input().split()]
from collections import deque
q=deque()
q.append((s,0))
# print(path)
check=[[False]*n for x in [0,1,2]]
while q:
    # print(q)
    p,num=q.popleft()
    if check[num%3][p]==True:
        continue
    if num%3!=0:
        for i in path[p]:
            q.append((i,num+1))
        check[num%3][p]=True
        continue
    elif p==t:
        print(num//3)
        import sys
        sys.exit()
    else:
        for i in path[p]:
            q.append((i,num+1))
        check[0][p]=True
print(-1)
Buggy python submission (verdict: Runtime Error):
def divide(num):
    return b//num - (a-1)//num
import math
a,b,c,d=map(int,input().split())
lcm=c*d//math.gcd(c,d)
print(b - (a - 1) - (divide(c) + divide(d) - divide(lcm)))

Fixed submission:
def divide(num):
    return b//num - (a-1)//num
import fractions
a,b,c,d=map(int,input().split())
lcm=c*d//fractions.gcd(c,d)
print(b - (a - 1) - (divide(c) + divide(d) - divide(lcm)))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
a=sorted(a)
diff=[]
for i in range(m):
    b,c=[int(x) for x in input().split()]
    diff+=[c]*b
diff=sorted(diff,reverse=True)
diff+=[0]*n
# print(a)
# print(diff)
ans=[]
for i in range(n):
    ans.append(max(a[i],diff[i]))
print(sum(ans))

Fixed submission:
n,m=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
a=sorted(a)
diff=[]
bc=[]
for i in range(m):
    b,c=[int(x) for x in input().split()]
    bc.append((b,c))
bc=sorted(bc,key=lambda x : x[1],reverse=True)
# print(bc)
for b,c in bc:
    if len(diff)<=n:
        diff+=[c]*b
diff+=[0]*(n-len(diff))
# print(a)
# print(diff)
ans=[]
for i in range(n):
    ans.append(max(a[i],diff[i]))
print(sum(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(x) for x in input().split()]
from collections import defaultdict
d=defaultdict(int)
for ai in a:
    for i in range(1, int(ai**0.5)+1):
        if ai % i == 0:
            d[i]+=1
            if i != ai // i:
                d[ai//i]+=1
print(max([x for x in d.keys() if d[x]==n or d[x]==n-1]))

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
anses=set()
for i in [0,1]:
    for j in range(1, int(a[i]**0.5)+1):
        if a[i] % j == 0:
            anses.add(j)
            if j != a[i] // j:
                anses.add(a[i] // j)
anses=sorted(anses,reverse=True)
for ans in anses:
    solvenum=0
    for j in a:
        if j%ans==0:
            solvenum+=1
    if solvenum==n or solvenum==n-1:
        print(ans)
        break

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n=int(input())
a=[int(x) for x in input().split()]
from collections import defaultdict
import math
d=defaultdict(int)
num_n=[]
num_n_1=[]
for ai in a:
    for i in range(1,int(math.sqrt(ai))+1):
        if ai%i==0:
            d[i]+=1
            d[ai//i]+=1
for key in d.keys():
    if d[key]==n:
        num_n.append(key)
    elif d[key]==n-1:
        num_n_1.append(key)
anses=[]
if num_n_1:
    anses.append(max(num_n_1))
if num_n:
    anses.append(max(num_n))
print(max(anses))

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
anses=set()
for i in [0,1]:
    for j in range(1, int(a[i]**0.5)+1):
        if a[i] % j == 0:
            anses.add(j)
            if j != a[i] // j:
                anses.add(a[i] // j)
anses=sorted(anses,reverse=True)
for ans in anses:
    solvenum=0
    for j in a:
        if j%ans==0:
            solvenum+=1
    if solvenum==n or solvenum==n-1:
        print(ans)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
from collections import Counter
c= Counter(s)
ans=0
vals=list(c.values())
for i in range(1,1<<len(c)):
    tmpans=1
    for j in range(len(c)):
        if ((i>>j) &1) == 1:
            tmpans*=vals[j]
    ans+=tmpans
print(ans%(10**9+7))

Fixed submission:
n=int(input())
s=input()
from collections import Counter
c= Counter(s)
ans=1
vals=list(c.values())
for i in range(len(c)):
    ans=ans*(1+vals[i])
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
from collections import Counter
c= Counter(s)
ans=0
vals=list(c.values())
for i in range(1,1<<len(c)):
    tmpans=1
    for j in range(len(c)):
        if ((i>>j) &1) == 1:
            tmpans*=vals[j]
    ans+=tmpans
print(ans%(10**9+7))

Fixed submission:
n=int(input())
s=input()
from collections import Counter
c= Counter(s)
ans=1
vals=list(c.values())
for i in range(len(c)):
    ans=ans*(1+vals[i])
print((ans-1)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
a,b,c=[int(x) for x input().split()]
print(b//a,c)

Fixed submission:
a,b,c=[int(x) for x in input().split()]
print(min(b//a,c))
Buggy python submission (verdict: Time Limit Exceeded):
burgerList=[""]*51
def burger(level):
    if burgerList[level]=="":
        if level==0:
            burgerList[level]="P"
        else:
            burgerList[level]="B"+burger(level-1)+"P"+burger(level-1)+"B"
    return burgerList[level]
 
n,x=[int(x) for x in input().split()]
print(burger(n)[:x].count("P"))

Fixed submission:
# coding: utf-8
# Your code here!
n,x=[int(x) for x in input().split()]
burgurnum=["" for _ in [0]*51]
burgurnumP=["" for _ in [0]*51]
def burgurNumFunc(level):
    if burgurnum[level]=="":
        if level==0:
            burgurnum[level]=1
        else:
            burgurnum[level]=burgurNumFunc(level-1)*2+3
    return burgurnum[level]
def burgurnumPFunc(level):
    if burgurnumP[level]=="":
        if level==0:
            burgurnumP[level]=1
        else:
            burgurnumP[level]=burgurnumPFunc(level-1)*2+1
    return burgurnumP[level]
    
    
def burger(num,level):
    if level==0:
        return 1
    elif num==1:
        return 0
    elif 1<num<=1+burgurNumFunc(level-1):
        return burger(num-1,level-1)
    elif num==burgurNumFunc(level-1)+2:
        return burgurnumPFunc(level-1)+1
    elif burgurNumFunc(level-1)+2<num<=burgurNumFunc(level-1)*2+2-1:
        return burgurnumPFunc(level-1)+1+burger(num - burgurNumFunc(level-1)-2,level-1)
    else:
        return burgurnumPFunc(level-1)*2+1
    

print(burger(x,n))

Buggy python submission (verdict: Time Limit Exceeded):
def burger(level):
    if level==0:
        return "P"
    else:
        return "B"+burger(level-1)+"P"+burger(level-1)+"B"

n,x=[int(x) for x in input().split()]
print(burger(n)[:x].count("P"))

Fixed submission:
# coding: utf-8
# Your code here!
n,x=[int(x) for x in input().split()]
burgurnum=["" for _ in [0]*51]
burgurnumP=["" for _ in [0]*51]
def burgurNumFunc(level):
    if burgurnum[level]=="":
        if level==0:
            burgurnum[level]=1
        else:
            burgurnum[level]=burgurNumFunc(level-1)*2+3
    return burgurnum[level]
def burgurnumPFunc(level):
    if burgurnumP[level]=="":
        if level==0:
            burgurnumP[level]=1
        else:
            burgurnumP[level]=burgurnumPFunc(level-1)*2+1
    return burgurnumP[level]
    
    
def burger(num,level):
    if level==0:
        return 1
    elif num==1:
        return 0
    elif 1<num<=1+burgurNumFunc(level-1):
        return burger(num-1,level-1)
    elif num==burgurNumFunc(level-1)+2:
        return burgurnumPFunc(level-1)+1
    elif burgurNumFunc(level-1)+2<num<=burgurNumFunc(level-1)*2+2-1:
        return burgurnumPFunc(level-1)+1+burger(num - burgurNumFunc(level-1)-2,level-1)
    else:
        return burgurnumPFunc(level-1)*2+1
    

print(burger(x,n))
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
def ncm(n,m):
    return factorial(n)//factorial(m)//factorial(n-m)
from itertools import permutations
ans=0
n=int(input())
for num3 in range(1,11):
    for num5 in range(1,11):
        for num7 in range(1,11):
            if int("3"*num3+"5"*num5+"7"*num7)>n:
                continue
            elif int("7"*num7+"5"*num5+"3"*num3)<n:
                ans+=ncm(num7+num5+num3,num7)*ncm(num5+num3,num5)
            else:
                tmp=set()
                for i in permutations(list("7"*num7+"5"*num5+"3"*num3)):
                    tmp.add(int("".join(i)))
                for i in tmp:
                    if i<=n:
                        ans+=1
print(ans)

Fixed submission:
from itertools import product
ans=0
n=int(input())
for i in range(3,11):
    for m in product(["3","5","7"],repeat=i):
        if "3"not in m or "5"not in m or "7"not in m:
            continue
        if int("".join(m))<=n:
            ans+=1
        else:
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
3
99 1 191
100 1 192
99 0 192

Fixed submission:
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff = 0
if min(h)>=10:
    diff=min(h)-5
h=[i-diff for i in h]
# print(h)
def pattern(cx,cy,H):
    for i in range(n):
        # print(cx,x[i],cy,y[i],H,h[i],max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()