Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02880 (python)

Fixed submission:
n = int(input())

for i in range(1,10):
    for j in range(1, 10):
        if i * j == n:
            print("Yes")
            exit()
print("No")

Buggy submission (verdict: Runtime Error):
a = int(input())
f = False
for i in range(1,10):
    if a % i == 0 and a/i < 10:
        f = True
        break
if f:
    print "Yes"
else:
    print "No"

Buggy submission (verdict: Runtime Error):
a = input()
f = False
for i in range(1,10):
    if a % i == 0 and a/i < 10:
        f = True
        break
if f:
    print "Yes"
else:
    print "No"
Problem p03127 (python)

Fixed submission:
# 入力
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
import numpy as np
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

def solution():
    N = input_int()
    As = input_ints()
    ans = gcd(As)
    print(ans)

if __name__ == '__main__':
    solution()

Buggy submission (verdict: Runtime Error):
input_int = lambda:int(input())
input_ints = lambda:map(int,input().split())
input_ints_list = lambda:list(input_ints())
input_str = lambda:input()
input_strs = lambda:input().split()
input_lines = lambda n,f:[f() for _ in range(n)]

import functools,fractions
import numpy as np
gcd = lambda a:functools.reduce(fractions.gcd,a) # 最大公約数（リスト）
lcm_base = lambda a,b:(a*b)//fractions.gcd(a,b) # 最小公倍数(2値)
lcm = lambda a:functools.reduce(lcm_base,a,1) # 最小公倍数(リスト)

init_dp = lambda v,n:[v]*(n)

import math
# 四捨五入はround
ceil = lambda a:math.ceil(a) # 切り上げ
floor = lambda a:math.floor(a) # 切り捨て

def solution():
    N,M = input_ints()
    As = input_ints_list()
    w = [0,2,5,5,4,5,6,3,7,6]

    dp = init_dp(-1,N+1)
    dp[0] = 0
    for i in range(N+1):
        for v in As:
            if i+w[v] < N+1:
                dp[i+w[v]] = max(dp[i+w[v]],dp[i]*10+v)
    print(dp[N])
    
if __name__ == '__main__':
    solution()
Problem p03775 (python)

Fixed submission:
import math
n=int(input())
f=[]
for a in range(1,math.floor(n**(1/2))+1):
    if n%a==0:
        b=n//a
        f.append(len(str(b)))
print(min(f))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
l=[]
for a in range(1,math.ceil(n**(1/2))):
    if n%a==0:
        l.append(len(str(n//a)))
print(min(l))

Buggy submission (verdict: Runtime Error):
n=int(input())
f=[]
for a in range(1,n+1):
    if n%a==0:
        b=n//a
        f.append(max(len(a),len(b)))
print(min(f))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
l=[]
for a in range(1,math.ceil(n**(1/2))):
    if n%a==0:
        l.append(len(str(n//a)))
print(min(l))
Problem p02915 (python)

Fixed submission:
num = int(input())

print(num ** 3)

Buggy submission (verdict: Runtime Error):
num = int(input())
index = list(map(int, input().split()))
point = list(map(int, input().split()))
add = list(map(int, input().split()))

total = 0
for i in range(num):
  total += point[index[i]-1]

for j in range(num-1):
  if index[j+1] == index[j]+ 1:
    total += add[index[i]-1]


print(total)

Buggy submission (verdict: Runtime Error):
num = input()

print(num **3)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = str(input())

if a >= 3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop, heapify

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

heapify(values)

while len(values) > 1:
  a = heappop(values)
  b = heappop(values)
  heappush(values, (a+b) / 2)
  
print(values[0])
Problem p02880 (python)

Fixed submission:
target = int(input())
rest = 0
for i in range(1, int(target/2)+2):
    if target % i == 0:
        rest = target / i
    if i < 10 and rest < 10:
        print("Yes")
        exit(0)
 
print("No")

Buggy submission (verdict: Runtime Error):
target = int(input())
rest = 0
for i in range(1, int(target/2)):
  if target % i == 0:
	rest = target / i
    if rest < 10:
      break

if rest > 0:
  print("Yes")
else:
  print("No")
Problem p03107 (python)

Fixed submission:
s = input()

if s.count('1') > 0 and s.count('0') > 0:
  print(min(s.count('1'), s.count('0')) * 2)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
t = ['01','10']
s = input()

def count_removal(c):
  is_01 = c.count(t[0])
  is_10 = c.count(t[1])
  if is_01 >= is_10 and is_01 > 0:
    return count_removal(c.replace(t[0], '')) + c.count(t[0]) * 2
  elif is_01 < is_10 and is_10 > 0:
    return count_removal(c.replace(t[1], '')) + c.count(t[1]) * 2
  else:
    return 0

print(count_removal(s))

Buggy submission (verdict: Runtime Error):
s = input()

def count_removal(c):
  if '01' in c:
    return count_removal(c.replace('01', '')) + c.count('01')*2
  else:
    return 0

print(count_removal(s))
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
X = sorted(map(int, input().split()))
D = sorted(abs(x - y) for x, y in zip(X, X[1:]))
if N > 1:
    print(sum(D[:-(N-1)]))
else:
    print(sum(D))

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<int> X(M);
    for (auto& xi : X) cin >> xi;
    sort(X.begin(), X.end());
    vector<int> diff(M - 1);
    for (int i = 0; i < M - 1; i++) {
        diff[i] = abs(X[i] - X[i + 1]);
    }
    sort(diff.begin(), diff.end());
    int res = 0;
    for (int i = 0; i < (M - 1) - (N - 1); i++) {
        res += diff[i];
    }
    cout << res << endl;
    return 0;
}
Problem p03286 (python)

Fixed submission:
N = int(input())
if N == 0:
    print('0')
    exit()
res = []
for i in range(32):
    digit = (-2) ** i
    if N % (digit * (-2)) != 0:
        N -= digit
        res.append('1')
    else:
        res.append('0')
while res[-1] == '0':
    res.pop()
print(''.join(res[::-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
res = []
for i in range(32):
    digit = (-2) ** i
    if N % (digit * (-2)) != 0:
        N -= digit
        res.append('1')
    else:
        res.append('0')
while res[-1] == '0':
    res.pop()
print(''.join(res[::-1]))
Problem p03652 (python)

Fixed submission:
from collections import Counter
from operator import itemgetter

def sub(prefers, canceled):
    res = Counter()
    for pref in prefers:
        pt = -1
        while pref[pt] in canceled:
            pt -= 1
        res[pref[pt]] += 1
    return max(res.items(), key=itemgetter(1))

def solve(m, prefers):
    canceled = set()
    ans = float('inf')
    for _ in [0] * m:
        s, c = sub(prefers, canceled)
        canceled.add(s)
        ans = min(ans, c)
    return ans

if __name__ == '__main__':
    N, M = map(int, input().split())
    A = [list(map(int, input().split()))[::-1] for _ in [0] * N]
    print(solve(M, A))

Buggy submission (verdict: Runtime Error):
from collections import Counter
from operator import itemgetter

def sub(prefers, canceled):
    res = Counter()
    for pref in prefers:
       p = pref[-1]
        while p in canceled:
            pref.pop()
            p = pref[-1]
        res[p] += 1
    return max(res.items(), key=itemgetter(1))

def solve(m, prefers):
    canceled = set()
    ans = float('inf')
    for _ in [0] * m:
        s, c = sub(prefers, canceled)
        canceled.add(s)
        ans = min(ans, c)
    return ans

if __name__ == '__main__':
    N, M = map(int, input().split())
    A = [list(map(int, input().split()))[::-1] for _ in [0] * N]
    print(solve(M, A))
Problem p03775 (python)

Fixed submission:
F=lambda*m:max(len(str(x))for x in m)
N=int(input())
print(min(F(x,N//x)for x in range(1,int(N**.5)+1)if N%x==0))

Buggy submission (verdict: Runtime Error):
F=lambda*m:max(len(str(x))for x in m);print(m)
N=int(input())
print(min(F(x,N//x)for x in range(1,int(N**.5)+1)if N%x==0))

Buggy submission (verdict: Runtime Error):
F=lambda*m:max(len(str(x))for x in m)
N=int(input())
print(min(F(x,N//x)for x in range(1,int(N**.5)+1)if N%x))
Problem p03012 (python)

Fixed submission:
def solve(N, W):
    left, right = 0, sum(W)
    ans = [abs(right-left)]
    for w in W:
        left += w
        right -= w
        ans.append(abs(right-left))
    return min(ans)


N = int(input())
W = [int(w) for w in input().split()]
ans = solve(N, W)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(N, W):
    left, right = 0, sum(W)
    ans = [abs(right-left)]
    for w in W:
        left += w
        right -= w
        ans.append(abs(right-left))
    return min(ans)


def main(args):
    N = int(input())
    W = [int(w) for w in input().split()]
    ans = solve(N, W)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
h
Problem p03013 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""



"""
import sys


def solve(N, M, A):
    MOD = 10**9 + 7
    A = set(A)
    dp = [0] * (N+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in A else 0
    for i in range(2, N+1):
        if i in A:
            dp[i] = 0
        else:
            dp[i] = (dp[i-2] + dp[i-1]) % MOD
    return dp[-1]


def main(args):
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    ans = solve(N, M, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy submission (verdict: Runtime Error):
def solve(N, M, A):
    MOD = 10**9 + 7
    A = set(A)
    if N == 1:
        return 1

    dp = [0] * (N+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in A else 0
    for i in range(2, N+1):
        if i in A:
            dp[i] = 0
        else:
            dp[i] = (dp[i-2] + dp[i-1]) % MOD
    return dp[-1]


N, M = map(int, input).split())
A = [int(input()) for _ in range(M)]
ans = solve(N, M, A)
print(ans)
Problem p03307 (python)

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

"""
import sys
from sys import stdin
input = stdin.readline


from fractions import gcd

def main(args):
    N = int(input())
    g = gcd(N, 2)
    print(N * 2 // g)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
A - Multiple of 2 and N
https://beta.atcoder.jp/contests/abc102/tasks/abc102_a

"""
import sys
from sys import stdin
input = stdin.readline


from math import gcd

def main(args):
    N = int(input())
    g = gcd(N, 2)
    print(N * 2 // g)


if __name__ == '__main__':
    main(sys.argv[1:])
Problem p03326 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
D - Patisserie ABC
https://abc100.contest.atcoder.jp/tasks/abc100_d

"""
import sys
from sys import stdin
input = stdin.readline


from heapq import heappop, heappush


def solve(cakes, M):
    result = []
    for xx in [1, -1]:
        for yy in [1, -1]:
            for zz in [1, -1]:
                hq = []
                for x, y, z in cakes:
                    x *= xx
                    y *= yy
                    z *= zz
                    heappush(hq, -(x+y+z))
                ans = 0
                for _ in range(M):
                    ans += heappop(hq)
                result.append(-ans)
    return sorted(result)[-1]


def main(args):
    N, M = map(int, input().split())

    cakes = []
    for _ in range(N):
        x, y, z = map(int, input().split())
        cakes.append((x, y, z))
    ans = solve(cakes, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
D - Patisserie ABC
https://abc100.contest.atcoder.jp/tasks/abc100_d

"""
import sys
from sys import stdin
input = stdin.readline


from heapq import heappop, heappush


def solve(cakes, M):
    result = []
    for xx in [1, -1]:
        for yy in [1, -1]:
            for zz in [1, -1]:
                hq = []
                for x, y, z in cakes:
                    x *= xx
                    y *= yy
                    z *= zz
                    heappush(hq, -(x+y+z))
                ans = 0
                for _ in range(M):
                    ans += heappop(hq)
                result.append(-ans)
    return sorted(result)[-1]


def main(args):
    duplicate = set()
    N, M = map(int, input().split())

    cakes = []
    for _ in range(N):
        x, y, z = map(int, input().split())
        if not (x, y, z) in duplicate:
            cakes.append((x, y, z))
        duplicate.add((x, y, z))
    ans = solve(cakes, M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
Problem p03745 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
A - Sorted Arrays
https://atcoder.jp/contests/agc013/tasks/agc013_a

"""
import sys


def solve(N, array):
    ans = 1
    prev = None
    direction = None

    for a in array:
        if prev == None:
            pass
        elif a > prev:
            if direction == 'd':
                ans += 1
                direction = None
            else:
                if a > prev:
                    direction = 'u'
        elif a < prev:
            if direction == 'u':
                ans += 1
                direction = None
            else:
                if a < prev:
                    direction = 'd'
        prev = a
    return ans


def main(args):
    N = int(input())
    array = [int(a) for a in input().split()]
    ans = solve(N, array)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
A - Sorted Arrays
https://atcoder.jp/contests/agc013/tasks/agc013_a

"""
import sys
from typing import List


def solve(N, array):
    ans = 1
    prev = None
    direction = None

    for a in array:
        if prev == None:
            pass
        elif a > prev:
            if direction == 'd':
                ans += 1
                direction = None
            else:
                if a > prev:
                    direction = 'u'
        elif a < prev:
            if direction == 'u':
                ans += 1
                direction = None
            else:
                if a < prev:
                    direction = 'd'
        prev = a
    return ans


def main(args):
    N = int(input())
    array = [int(a) for a in input().split()]
    ans = solve(N, array)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
Problem p02831 (python)

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

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
c=int(a*b//math.gcd(a,b))
print(c)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
c=a*b//math.gcd(a,b)
print(c)
Problem p02835 (python)

Fixed submission:
l=list(map(int,input().split()))
s=sum(l)
if(s<=21):
  print("win")
else:
  print("bust")

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
s=sum(l)
if(l<=21):
  print("win")
else:
  print("bust")
Problem p02847 (python)

Fixed submission:
d=input()
if(d=="SAT"):
  print(1)
elif(d=="FRI"):
  print(2)
elif(d=="THU"):
  print(3)
elif(d=="WED"):
  print(4)
elif(d=="TUE"):
  print(5)
elif(d=="MON"):
  print(6)
else:
  print(7)

Buggy submission (verdict: Runtime Error):
d=input()
if(d=="SAT"):
  print(1)
elif(d=="FRI")
  print(2)
elif(d=="THU")
  print(3)
elif(d=="WED")
  print(4)
elif(d=="TUE")
  print(5)
elif(d=="MON")
  print(6)
else:
  print(7)

Buggy submission (verdict: Runtime Error):
d=str(input())
if(d="SAT"):
   print(1)
elif(d="FRI"):
  print(2)
elif(d="THU"):
  print(3)
elif(d="WED"):
  print(4)
elif(d="TUE"):
  print(5)
elif(d="MON"):
  print(6)
else:
  print(7)

Buggy submission (verdict: Runtime Error):
d=input()
if(d="SAT"):
   print(1)
elif(d="FRI"):
  print(2)
elif(d="THU"):
  print(3)
elif(d="WED"):
  print(4)
elif(d="TUE"):
  print(5)
elif(d="MON"):
  print(6)
else:
  print(7)

Buggy submission (verdict: Runtime Error):
d=input()
if(d="SAT"):
   print(1)
elif(d="FRI"):
  print(2)
elif(d="THU"):
  print(3)
elif(d="WED"):
  print(4)
elif(d="TUE"):
  print(5)
elif(d="MON"):
  print(6)
else:
  print(7)
Problem p02860 (python)

Fixed submission:
n=int(input())
s=input()
if(n%2!=0):
  print("No")
else:
  v=[s[i: i+n//2] for i in range(0, len(s), n//2)]
  if(len(set(v))==1):
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
if(n%2!=0):
  print("No")
else:
  v=[s[i: i+n/2] for i in range(0, len(s), n/2)]
  if(len(set(v))==1):
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
v=[s[i: i+n/2] for i in range(0, len(s), n/2)]
if(len(set(v))==1):
  print("Yes")
else:
  print("No")
Problem p02879 (python)

Fixed submission:
l=list(map(int,input().split()))
a=l[0]
b=l[1]
if(a<=9 and b<=9):
  print(a*b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
if !(all[i<=9 for i in l]):
  print (-1)
else:
  print(l[0]*l[1])

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
if !all[i<=9 for i in l]:
  print (-1)
else:
  print(l[0]*l[1])
Problem p02970 (python)

Fixed submission:
import math

l=list(map(int,input().split()))
n=l[0]
d=l[1]
print(math.ceil(n/(2*d+1)))

Buggy submission (verdict: Runtime Error):
import math

l=list(map(int,input().split()))
n=l[0]
d=l[1]
print(math.ceil(n/(2d+1)))
Problem p03036 (python)

Fixed submission:
l=list(map(int,input().split()))
r=l[0]
D=l[1]
x=l[2]
t=[x]
for i in t:
  m=i*r-D
  t.append(m)
  if(len(t)==11):
    break
for p in t[1:]:
	print(p)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
r=l[0]
D=l[1]
x=l[2]
t=[x]
for i in t:
  m=i*r-D
  t.append(m)
  if(len(t)=11):
    break
for p in t[1:]:
	print(p)
Problem p02948 (python)

Fixed submission:
from heapq import heappop, heappush
from bisect import bisect
from collections import deque
inf = 10**5


N, M = map(int,input().split())
info = [list(map(int,input().split())) for _ in range(N)]
info = deque(sorted(info))

ans = 0
hq = []

for i in range(M-1,-1,-1):
    index = bisect(info, [M-i,inf])
    for _ in range(index):
        A, B = info.popleft()
        heappush(hq, -B)
    if hq:
        B = -heappop(hq)
        ans += B

print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

N, M = map(int,input().split())

# works[i] : M-i日に報酬が得られるリスト
works = [[] for _ in range(10**5)]

for _ in range(N):
    A, B = map(int,input().split())
    # 報酬が得られる日付に応じて格納
    works[A].append(B)

hq = []
ans = 0

for i in range(1,M+1):
    # M-i日から降順に仕事の候補リストを作る
    for w in works[i]:
        # 大きいものから選びたいのでマイナスをかける
        heappush(hq, -w)
    # M-i日の時点で報酬が最大の仕事を選ぶ
    if hq:
        ans += -heappop(hq)

print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

N, M = map(int,input().split())

# works[i] : M-i日に報酬が得られるリスト
works = [[] for _ in range(10**4)]

for _ in range(N):
    A, B = map(int,input().split())
    A -= 1
    # 報酬が得られる日付に応じて格納
    works[A].append(B)

hq = []
ans = 0

for i in range(M):
    # M-i日から降順に仕事の候補リストを作る
    for w in works[i]:
        # 大きいものから選びたいのでマイナスをかける
        heappush(hq, -w)
    # M-i日の時点で報酬が最大の仕事を選ぶ
    if hq:
        ans += -heappop(hq)

print(ans)
Problem p02990 (python)

Fixed submission:
from math import factorial

mod = 10**9 + 7

# 組み合わせ　n_C_r
def comb(n,r):
    if not n >= r:
        return 0
    return factorial(n) // (factorial(n-r)*factorial(r))

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

def cal(i):
    return comb(K-1,i-1) * comb(N-K+1,i) % mod

for i in range(1,K+1):
    ans = cal(i)
    print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial

mod = 10**9 + 7

# 組み合わせ　n_C_r
def comb(n,r):
    r = min(r,n-r)
    return factorial(n) // (factorial(n-r)*factorial(r))

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

def cal(i):
    return comb(K-1,i-1) * comb(N-K+1,i) % mod

for i in range(1,K+1):
    ans = cal(i)
    print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial

mod = 10**9 + 7

# 組み合わせ　n_C_r
def comb(n,r):
    return factorial(n) // (factorial(n-r)*factorial(r))

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

def cal(i):
    return comb(K-1,i-1) * comb(N-K+1,i) % mod

for i in range(1,K+1):
    ans = cal(i)
    print(ans)
Problem p03104 (python)

Fixed submission:
def xor(data):
    if not data:
        return 0
    res = data[0]
    for i in range(1,len(data)):
        res ^= data[i]
    return res

A,B = map(int,input().split())
if A == B:
    print(A)
    exit()
num = B-A+1
data = []
cut = 0
if A % 2 == 0:
    cut = (num) // 2
    if cut % 2 == 1:
        data.append(1)
    if num % 2 == 1:
        data.append(B)
else:
    data.append(A)
    cut = (num-1) // 2
    if cut % 2 == 1:
        data.append(1)
    if (num-1) % 2 == 1:
        data.append(B)
ans = xor(data)
print(ans)

Buggy submission (verdict: Runtime Error):
def xor(data):
    res = data[0]
    for i in range(1,len(data)):
        res ^= data[i]
    return res

A,B = map(int,input().split())
num = B-A+1
data = []
cut = 0
if A % 2 == 0:
    cut = (num) // 2
    if cut == 1:
        data.append(1)
    if num % 2 == 1:
        data.append(B)
else:
    data.append(A)
    cut = (num-1) // 2
    if cut == 1:
        data.append(1)
    if (num-1) % 2 == 1:
        data.append(B)
ans = xor(data)
print(ans)
Problem p03209 (python)

Fixed submission:
N,X = map(int,input().split())
# a:バンの数  b:パティの数
a,b = [1],[1]
for i in range(N):
    a.append(2*a[i] + 3)
    b.append(2*b[i] + 1)
def f(N,X):
    if N == 0:
        return 1
    if X == 1:
        return 0
    elif 1 < X <= a[N-1] + 1:
        return f(N-1,X-1)
    elif X == a[N-1] + 2:
        return b[N-1] + 1
    elif a[N-1] + 2 < X <= 2*a[N-1] + 2:
        return b[N-1] + 1 + f(N-1,X-(a[N-1]+2))
    elif X == 2*a[N-1] + 3:
        return 2*b[N-1] + 1
ans = f(N,X)
print(ans)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
if N == 0:
    print(1)
    exit()
# a:バンの数  b:パティの数
a,b = [1],[1]
for i in range(N):
    a.append(2*a[i] + 3)
    b.append(2*b[i] + 1)
def f(N,X):
    if X == 1:
        return 0
    elif 1 < X <= a[N-1] + 1:
        return f(N-1,X-1)
    elif X == a[N-1] + 2:
        return b[N-1] + 1
    elif a[N-1] + 2 < X <= 2*a[N-1] + 2:
        return b[N-1] + 1 + f(N-1,X-(a[N-1]+2))
    elif X = 2*a[N-1] + 3:
        return 2*b[N-1] + 1
ans = f(N,X)
print(ans)

Buggy submission (verdict: Runtime Error):
N,X = map(int,input().split())
if N == 0:
    print(1)
    exit()
# a:バンの数  b:パティの数
a,b = [1],[1]
for i in range(N):
    a.append(2*a[i] + 3)
    b.append(2*b[i] + 1)
def f(N,X):
    if X == 1:
        return 0
    elif 1 < X <= a[N-1] + 1:
        return f(N-1,X-1)
    elif X == a[N-1] + 2:
        return b[N-1] + 1
    elif a[N-1] + 2 < X <= 2*a[N-1] + 2:
        return b[N-1] + 1 + f(N-1,X-(a[N-1]+2))
    elif X = 2*a[N-1] + 3:
        return 2*b[N-1] + 1
ans = def(N,X)
print(ans)