TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
using System;
using System;
using System.Collections.Generic;
using System.Linq;


    class Solver5
    {
        /*
         * 
         * https://atcoder.jp/contests/abc115/tasks/abc115_d
         * 
         */
 public void Solve5()
        {
            var nx = u.readLongArrayBySplit();
			var n = nx[0];
            var x = nx[1];
            long ans = 0;

            while (true)
            {
                var thk = new long[5]{ 1, (long)Math.Pow(2,n + 1) - 3, 1, (long)Math.Pow(2, n + 1) - 3, 1 };
                var pc = new long[5] { 0, (long)Math.Pow(2, n ) - 1 , 1, (long)Math.Pow(2, n )- 1, 0 };
                for (int i = 0; i < 5; i++)
                {
                    if (x > thk[i])
                    {
                        x -= thk[i];
                        ans += pc[i];
                    }
                    else if (x < thk[i])
                    {
                        n--;
                        break;
                    }
                    else
                    {
                        ans += pc[i];
                        Console.WriteLine(ans.ToString());
                        return;
                    }
                }

            }

        }
        static void Main()
        {
            var solver = new Solver5();
            solver.Solve5();
        }
    }
    static class u
    {
      public static long[] readLongArrayBySplit() { return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }

n,x = map(int,input().split())
 

 
ans = 0
x2 = x
k=n
while True:
  thk = [1,2**(k+1)-3,1,2**(k+1)-3,1]
  pc = [0,2**k-1,1,2**k-1,0]
  for i in range(5):
    x2-=thk[i]
    if x2<0:
      x2+=thk[i]
      k-=1
      break
    elif x2==0:
      ans+=pc[i]
      print(ans)
      exit()
    else:
      ans+=pc[i]


Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
ri = lambda: map(int, input().split(' '))
L = [1]
C = [1]

def rec(n, x):
	if n == 0:
		return 1

	if x == L[n]:
		return 2*C[n-1] + 1

	ans = 0
	if x >= L[n-1] + 2:
		ans += C[n-1] + 1
		ans += rec(n-1, x-L[n-1]-2)
	else:
		ans += rec(n-1, x-1)

	return ans

if __name__ == '__main__':
	N, X = ri()
	for i in range(1, N+1):
		L.append(2*L[i-1] + 3)
		C.append(2*C[i-1] + 1)
	ans = rec(N, X)
	print(ans)



ri = lambda: map(int, input().split(' '))
L = [1]
C = [1]

def rec(n, x):
	if x == 0:
		return 0

	if n == 0:
		return 1

	if x == L[n]:
		return 2*C[n-1] + 1

	ans = 0
	if x >= L[n-1] + 2:
		ans += C[n-1] + 1
		ans += rec(n-1, x-L[n-1]-2)
	else:
		ans += rec(n-1, x-1)

	return ans

if __name__ == '__main__':
	N, X = ri()
	for i in range(1, N+1):
		L.append(2*L[i-1] + 3)
		C.append(2*C[i-1] + 1)
	ans = rec(N, X)
	print(ans)



Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
#!/usr/env/python3
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
	a.append(a[i] * 2 + 3)
	p.append(p[i] * 2 + 1)

def f(N, X):
	if N == 0:
		return 0 if X == 0 else 1
	elif X <= 1 + a[N-1]:
		return f(N-1, X-1)
	else:
		return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))


#!/usr/env/python3
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
	a.append(a[i] * 2 + 3)
	p.append(p[i] * 2 + 1)

def f(N, X):
	if N == 0:
		#return 0 if X == 0 else 1
		return 0 if X <= 0 else 1
	elif X <= 1 + a[N-1]:
		return f(N-1, X-1)
	else:
		return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))


Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
N, X = map(int, input().split())
pat = [0 for _ in range(N+1)]
mai = [0 for _ in range(N+1)]
pat[1] = 1
mai[1] = 1
for i in range(2, N+1):
  mai[i] = 2 * mai[i-1] + 3
  pat[i] = 2 * pat[i-1] + 1

def cnt_pat(x, n):
  if n == 1:
    return 1
  if x == 1:
    return 0
  if x <= mai[n] // 2:
    return cnt_pat(x-1, n-1)
  if x == mai[n] // 2 + 1:
    return pat[n-1] + 1
  if x < mai[n]:
    return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)
  if x == n:
    return pat[n]
  
print(cnt_pat(X, N))

N, X = map(int, input().split())
pat = [1 for _ in range(N)]
mai = [1 for _ in range(N)]
for i in range(1, N+1):
  mai[i] = 2 * mai[i-1] + 3
  pat[i] = 2 * pat[i-1] + 1

def cnt_pat(x, n):
  if n == 0:
    return 1
  if x == 1:
    return 0
  if x <= mai[n] // 2:
    return cnt_pat(x-1, n-1)
  if x == mai[n] // 2 + 1:
    return pat[n-1] + 1
  if x < mai[n]:
    return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)
  if x == n:
    return pat[n]
  
print(cnt_pat(X, N))

N, X = map(int, input().split())
pat = [1 for _ in range(N+1)]
mai = [1 for _ in range(N+1)]
for i in range(1, N+1):
  mai[i] = 2 * mai[i-1] + 3
  pat[i] = 2 * pat[i-1] + 1

def cnt_pat(x, n):
  if n == 0:
    return 1
  if x == 1:
    return 0
  if x <= mai[n] // 2:
    return cnt_pat(x-1, n-1)
  if x == mai[n] // 2 + 1:
    return pat[n-1] + 1
  if x < mai[n]:
    return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)
  if x == mai[n]:
    return pat[n]
  
print(cnt_pat(X, N))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
from sys import stdin
N,X=[int(x) for x in stdin.readline().rstrip().split()]
burger_set=["P"]
for i in range(N):
    new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"
    burger_set.append(new_burger)
    del burger_set[0]
print(burger_set[0].count('P'))

from sys import stdin
import numpy as np
N,X=[int(x) for x in stdin.readline().rstrip().split()]
burger_set=np.array(["P"])
for i in range(N):
    new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"
    burger_set[0]=(new_burger)
ans=burger_set[0][0][0:X].count('P')
print(ans)

from sys import stdin
import numpy as np
N,X=[int(x) for x in stdin.readline().rstrip().split()]
burger_set=np.array(["P"])
for i in range(N):
    new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"
    burger_set[0]=(new_burger)
ans=burger_set[0][0:X].count('P')
print(ans)

from sys import stdin
N, X = [int(x) for x in stdin.readline().rstrip().split()]

heights = [1]
putties = [1]
for _ in range(N):
    heights.append(heights[-1] * 2 + 3)
    putties.append(putties[-1] * 2 + 1)


def solve(n, x):
    if n == 0 and x == 1:
        return 1
    elif x == 1:
        return 0
    elif 1 < x <= 1+heights[n-1]:
        return solve(n-1, x-1)
    elif x == 2+heights[n-1]:
        return 1+putties[n-1]
    elif 2+heights[n-1] < x <= 2+2*heights[n-1]:
        return putties[n-1]+1+solve(n-1,x-2-heights[n-1]) 
    elif x == 3+2*heights[n-1]:
        return 2*putties[n-1]+1
print(solve(N, X))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
n,x=map(int,input().split())

a=[1]
p=[1]

for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def bur(n,x):
    if n==0:
        if x==0:
            return 0
        else:
            return 1
    elif 1<=x<=(1+a[n-1]):
        return bur(n-1,x-1)
    # elif x==2+a[n-1]:
    #     return p[n-1]+1
    # elif (2+a[n-1])<=x<=2+2*a[n-1]:
    #     return p[n-1]+1+bur(n-1,x-2-a[n-1])
    else:
        return p[n-1]+1+bur(n-1,x-2-a[n-1])
    # else:
    #     return 2*p[n-1]+1

print(bur(n,x))


n,x=map(int,input().split())

a=[1]
p=[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if x==0:
        return 0
    elif x==1:
        if n==0:
            return 1
        else:
            return 0

    elif 1<x<=(1+a[n-1]):
        return f(n-1,x-1)

    elif x==2+a[n-1]:
        return p[n-1]+1

    elif (2+a[n-1])<=x<=2+2*a[n-1]:
        return p[n-1]+1+f(n-1,x-2-a[n-1])

    else:
        return 2*p[n-1]+1

print(f(n,x))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
def cal(N, i):
    if N > 0:
        return 2 * cal(N - 1, i) + i
    elif N == 0:
        return 1
    else:
        return 0

def pCal(N ,X):
    total = cal(N, 3)
    half = total // 2
    pTmp = cal(N - 1, 1)
    if X == 1 and N == 0:
        return 1
    elif X <= N:
        return 0
    elif X < half:
        return pCal(N - 1, X - 1)
    elif X == half:
        return pTmp
    elif X == half + 1:
        return pTmp + 1
    elif total > X > half + 1:
        return (pTmp + 1) + pCal(N - 1, X - (half + 1))
    else x == total
        return cal(N, 1)
N, X = list(map(int, input().split()))
print(pCal(N, X))

def cal(N, i):
    if N > 0:
        return 2 * cal(N - 1, i) + i
    elif N == 0:
        return 1
    else:
        return 0

def pCal(N ,X):
    total = cal(N, 3)
    half = total // 2
    pTmp = cal(N - 1, 1)
    if X == 1 and N == 0:
        return 1
    elif X <= N:
        return 0
    elif X < half:
        return pCal(N - 1, X - 1)
    elif X == half:
        return pTmp
    elif X == half + 1:
        return pTmp + 1
    elif total > X > half + 1:
        return (pTmp + 1) + pCal(N - 1, X - (half + 1))
    elif X == total:
        return cal(N, 1)
N, X = list(map(int, input().split()))
print(pCal(N, X))

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
import sys
sys.setrecursionlimit(1000000)
N,X = map(int,input().split())
def n_barg_hight(n):
	if(n == 0):
		return 1

	L1barg_height = n_barg_hight(n-1)
	Lbarg_height = 1 + L1barg_height + 1 + L1barg_height + 1
	return Lbarg_height

def n_barg_pat(n):
	if(n == 0):
		return 1
	L1barg_pat = n_barg_pat(n-1)
	Lbarg_pat = 1 + L1barg_pat*2
	return Lbarg_pat


def answer(N,X):
	print(N,X)
	if(X == 1):
		return 0
	
	elif(X == n_barg_hight(N)):
		return n_barg_pat(N)

	elif(X == n_barg_hight(N)//2 + 1):
		return n_barg_pat(N-1)+1

	elif(X <= n_barg_hight(N)//2):
		return answer(N-1,X-1)

	elif(X > n_barg_hight(N)//2 + 1):
		Lbarg = n_barg_pat(N-1) + answer(N-1,X-n_barg_hight(N-1)-2) +1
		return Lbarg


print(answer(N,X))

import sys
sys.setrecursionlimit(10000000)
N,X = map(int,input().split())
def n_barg_hight(n):
	if(n == 0):
		return 1

	L1barg_height = n_barg_hight(n-1)
	Lbarg_height = 1 + L1barg_height + 1 + L1barg_height + 1
	return Lbarg_height

def n_barg_pat(n):
	if(n == 0):
		return 1
	L1barg_pat = n_barg_pat(n-1)
	Lbarg_pat = 1 + L1barg_pat*2
	return Lbarg_pat


def answer(N,X):

	if(X == 1):
		if(N == 0):
			return 1
		else:
			return 0
	
	elif(X == n_barg_hight(N)):
		return n_barg_pat(N)

	elif(X == n_barg_hight(N)//2 + 1):
		return n_barg_pat(N-1)+1

	elif(X <= n_barg_hight(N)//2):
		return answer(N-1,X-1)

	elif(X > n_barg_hight(N)//2 + 1):
		Lbarg = n_barg_pat(N-1) + answer(N-1,X-n_barg_hight(N-1)-2) +1
		return Lbarg


print(answer(N,X))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
n, x = map(int, input().split())

sum_p = [0 for i in range(n + 1)]
sum_dim = [0 for i in range(n + 1)]
sum_p[0] = 1
sum_dim[0] = 1

for i in range(1, n + 1):
    sum_p[i] = sum_p[i - 1] * 2 + 1
    sum_dim[i] = sum_dim[i - 1] * 2 + 3


def cal(n, rem):
    if n == 0:
        return 1 if rem == 1 else 0
    elif rem <= 1 + sum_dim[n]:
        return cal(n - 1, rem - 1)
    else:
        return sum_p[n] + 1 + cal(n - 1, rem - 2 - sum_dim[n])


print(cal(n, x))


n, x = map(int, input().split())

sum_p = [1]
sum_dim = [1]

for i in range(n):
    sum_p.append(sum_p[i] * 2 + 1)
    sum_dim.append(sum_dim[i] * 2 + 3)


def cal(n, rem):
    if n == 0:
        return 0 if rem<= 0 else 1
    elif rem <= 1 + sum_dim[n-1]:
        return cal(n - 1, rem - 1)
    else:
        return sum_p[n-1] + 1 + cal(n - 1, rem - 2 - sum_dim[n-1])


print(cal(n, x))


Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
import itertools
from collections import deque
N, X = map(int, input().split())

d = deque()
current = "P"

for _ in range(1, N+1):
  d.appendleft("B")
  d.extend(current)
  d.append("P")
  d.extend(current)
  d.append("B")
  current = d

print(l.count("P"))


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

layer_size = [1]
P_cnt = [1]

for _ in range(50):
  "[-1]は末尾の要素を取得。layer_sizeで、合計"
  layer_size.append(layer_size[-1]*2+3)

  "[-1]は末尾の要素を取得。P_cntはパティの枚数
  P_cnt.append(P_cnt[-1]*2+1)


def solve(level, x):
  if x == 1:
    return 0 if level > 0 else 1
  l = layer_size[level-1]
  p = P_cnt[level-1]
  if x <= 1+l:
    return solve(level-1, x-1)
  elif x == l+2:
    return p+1
  elif x <= 2*l+2:
    return p+1+solve(level-1, x-l-2)
  else:
    return 2*p+1
  
ans = solve(N, X)
print(ans)

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

layer_size = [1]
P_cnt = [1]

for _ in range(50):
  "[-1]は末尾の要素を取得。layer_sizeで、合計"
  layer_size.append(layer_size[-1]*2+3)

  "[-1]は末尾の要素を取得。P_cntはパティの枚数
  P_cnt.append(P_cnt[-1]*2+1)

print(layer_size)
print(P_cnt)

def solve(level, x):
  if x == 1:
    return 0 if level > 0 else 1
  l = layer_size[level-1]
  p = P_cnt[level-1]
  if x <= 1+l:
    return solve(level-1, x-1)
  elif x == l+2:
    return p+1
  elif x <= 2*l+2:
    return p+1+solve(level-1, x-l-2)
  else:
    return 2*p+1
  
ans = solve(N, X)
print(ans)

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

layer_size = [1]
P_cnt = [1]

for _ in range(50):
  
  layer_size.append(layer_size[-1]*2+3)

  
  P_cnt.append(P_cnt[-1]*2+1)


def solve(level, x):
  if x == 1:
    return 0 if level > 0 else 1
  l = layer_size[level-1]
  p = P_cnt[level-1]
  if x <= 1+l:
    return solve(level-1, x-1)
  elif x == l+2:
    return p+1
  elif x <= 2*l+2:
    return p+1+solve(level-1, x-l-2)
  else:
    return 2*p+1
  
ans = solve(N, X)
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
n_x = input()
n_x_list =n_x.split(' ')

N = int(n_x_list[0])
X = int(n_x_list[1])

# g_list = [''] * N

#     if N == 0:
#         return 'p'
#
#     gn_1 = G(N-1)
#
#     return 'b' + gn_1 + 'p' + gn_1 + 'b'

# g_n = G(N)
# print(g_n)
# eaten_burger = g_n[0:X]

# ans = eaten_burger.count('p')
# print(ans)

def L(N):
    return 2 ** (N+2) - 3

def P(N):
    return 2 ** (N+1) - 1

def solve(N, X):
    half_l = int(P(N) / 2)
    if N == 0:
        return 1

    if half_l > X:
        return solve(N - 1, X - 1)
    elif half_l == X:
        return P(N-1)
    elif half_l + 1 == X:
        return P(N-1) + 1
    elif half_l + 1 < X:
        return P(N-1) + 1 + solve(N-1, (X - L(N-1) - 2))
    elif half_l * 2 + 1 == X:
        return 2 * P(N-1) + 1


ans = solve(N, X)
print(ans)


n_x = input()
n_x_list =n_x.split(' ')

N = int(n_x_list[0])
X = int(n_x_list[1])

# g_list = [''] * N

#     if N == 0:
#         return 'p'
#
#     gn_1 = G(N-1)
#
#     return 'b' + gn_1 + 'p' + gn_1 + 'b'

# g_n = G(N)
# print(g_n)
# eaten_burger = g_n[0:X]

# ans = eaten_burger.count('p')
# print(ans)

def L(N):
    return 2 ** (N+2) - 3

def P(N):
    return 2 ** (N+1) - 1

def solve(N, X):
    half_l = int(L(N) / 2)
    if N == 0 and X >= 1:
        return 1
    elif N == 0 and X == 0:
        return 0

    if half_l <= 1:
        return 0
    elif X < half_l:
        return solve(N - 1, X - 1)
    elif X == half_l:
        return P(N-1)
    elif X == half_l + 1:
        return P(N-1) + 1
    elif half_l + 1 < X:
        return P(N-1) + 1 + solve(N-1, (X - L(N-1) - 2))
    elif half_l * 2 + 3 == X:
        return 2 * P(N-1) + 1


ans = solve(N, X)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
n, x = map(int, input().split())

a, p = [1], [1]

for i in range(n):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)

def f(N, X):
  if N == 0:
    if X == 0:
      return 0
    else:
      return 1  
  elif X <= 1 + a[N - 1]:
    return f(N - 1, X - 1)
  else:
    return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

print(f(n, x))

n, x = map(int, input().split())

a, p = [1], [1]

for i in range(n):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)

def f(N, X):
  if N == 0:
    if X <= 0:
      return 0
    else:
      return 1  
  elif X <= 1 + a[N - 1]:
    return f(N - 1, X - 1)
  else:
    return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

print(f(n, x))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
 N, X = map(int, input().split())
2
3 a, p = [1], [1]
4 for i in range(N):
5 a.append(a[i] * 2 + 3)
6 p.append(p[i] * 2 + 1)
7
8 def f(N, X): 
9 if N == 0:
10 return 0 if X <= 0 else 1
11 elif X <= 1 + a[N-1]:
12 return f(N-1, X-1)
13 else:
14 return p[N-1] + 1 + f(N-1, X-2-a[N-1])
15
16 print(f(N, X))


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

a, p = [1], [1]
for i in range(N):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)

def f(N, X): 
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))



Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
N, X = map(int, input().split())

burgersize, pnum = [1], [1]
for i in range(N):
    burgersize.append(burgersize[-1] * 2 + 3)
    pnum.append(pnum[-1] * 2 + 1)

def count_p(level, X):
    if level == 0:
        return 1
    # elif X == burgersize[level]:
    #     return pnum[level]
    elif X == 1:
        return 0
    elif X < (burgersize[level] - 1) // 2:
        return count_p(level - 1, X - 1)
    elif X == (burgersize[level] - 1) // 2:
        return count_p(level - 1, X - 1) + 1
    elif X > (burgersize[level] - 1) // 2:
        return pnum[level - 1] + 1 + count_p(level - 1, X - (burgersize[level] - 1) // 2 - 1)

    return None

ans = count_p(N, X)
print(ans)

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

burgersize, pnum = [1], [1]
for i in range(N):
    burgersize.append(burgersize[-1] * 2 + 3)
    pnum.append(pnum[-1] * 2 + 1)

def count_p(level, X):
    if X == 0:
        return 0
    if X == burgersize[level]:
        return pnum[level]
    if level == 0:
        return 1
    Xmid = (burgersize[level] - 1) // 2 + 1
    if X < Xmid:
        return count_p(level - 1, X - 1)
    else:
        return pnum[level - 1] + 1 + count_p(level - 1, X - Xmid)

print(count_p(N, X))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
level,eat = map(int, input().split())
burger = 'BPPPB'
for i in range(1, level):
  burger = 'B' + burger + 'P' + burger + 'B'
print(burger)
count=0
eat -=1
for i in range(len(burger)):
  if i > eat:
    break
  if burger[i] == 'P':
    count+=1
print(count)

def f(N, X):
  if N == 0:
    if X >= 1:
      return 1
    return 0
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-a[N-1] - 2)

N, X = map(int, input().split(" "))
a = [1]
p = [1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)

print(f(N,X))

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
N, X = map(int,input().split())

a = [1] 
p = [1] 
for i in range(N):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def function(N,X):
    if N == 0 :
        return 1
    else:
        if X <= 0 :
            return 0
        elif 1 < X  and X <= a[N-1] + 2 :
            ret = function(N-1,X-1)
            return ret
        else:
            ret  = 1 + p[N-1]
            ret +=  function(N-1,X-a[N-1]-2)
            return ret
print(function(N,X))

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

a = [1] 
p = [1] 
for i in range(N):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def function(N,X):
    if N == 0 :
        return 1
    else:
        if X <= 0 :
            return 0
        elif 1 < X  and X < a[N-1] + 2 :
            ret = function(N-1,X-1)
            return ret
        elif X == (a[N-1] + 2):
            return 1 + a[N-1]
        else:
            ret  = 1 + p[N-1]
            ret +=  function(N-1,X-a[N-1]-2)
            return ret
print(function(N,X))

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

a = [1] 
p = [1] 
for i in range(N):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def function(N,X):
    if N <= 0 :
        return 0 if X<= 0 else 1
    elif 1 < X  and X <= a[N-1] + 1 :
        ret = function(N-1,X-1)
        return ret
    else:
        ret  = 1 + p[N-1]
        ret +=  function(N-1,X-a[N-1]-2)
        return ret
print(function(N,X))

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

a = [1] 
p = [1] 
for i in range(N):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def function(N,X):
    if N <= 0 :
        return 0 if X<= 0 else 1
    elif X <= a[N-1] + 1 :
        ret = function(N-1,X-1)
        return ret
    else:
        ret  = 1 + p[N-1]
        ret +=  function(N-1,X-a[N-1]-2)
        return ret
print(function(N,X))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
N,X = map(int,input().split())
a = [1]
p = [1]
for i in range(N):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)

def f(N,X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1+a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + f(N-1, X-2-a[N-1])
print(f(N,X))

N,X = map(int,input().split())
a = [1]
p = [1]
for i in range(N):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)

def f(N,X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1+a[N-1]:
        return f(N-1, X-1)
    elif X == 2+a[N-1]:
        return p[N-1]+1
    elif 2+a[N-1] < X <= 2+2*a[N-1]:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])
    elif X == 3+2*a[N-1]:
        return 2*p[N-1] +1

print(f(N,X))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
N,X=map(int,input().split())

a,p=[1],[1]

for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def solve(n,x): #n,x
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<=1+a[N-1]:
        return  solve(N-1,X-1)
    else:
        return p[N-1]+1+solve(N-1,X-2-a[N-1])

print(solve(N,X))




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

a,p=[1],[1]

for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def solve(n,x): #n,x
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<=1+a[n-1]:
        return  solve(n-1,x-1)
    else:
        return p[n-1]+1+solve(n-1,x-2-a[n-1])

print(solve(N,X))


Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
n , k=map(int,input().split())
l="p"
b=0
for o in range(0,n):
 l="b"+l+"p"+l+"b"
p=list(l)
for t in range(0,k):
 if p[t]==b:
  pass
 elif p[t]==p:
  b+=1
print(b)
 


n,m=map(int,input().split())
l=["p"]
i=0
while len(l)<x:
  i+=1
  l=["b"]+l+["p"]+l+["b"]
for j in range(n-i):
  l=["b"]+l
c=0
for i in range(x):
  if l[i]=="p":
    c+=1
print(c)

n,x=map(int,input().split())
plist=[1]
blist=[1]
for i in range(n):
  plist.append(plist[-1]*2+1)
  blist.append(blist[-1]*2+3)
def patty(n,x):
  if n==0:
    return 1
  else:
    if x==1:
      return 0
    elif 1<x and x<=blist[n-1]+1:
      return patty(n-1,x-1)
    elif x==blist[n-1]+2:
      return plist[n-1]+1
    elif 2+blist[n-1]<x and 2*blist[n-1]+2>=x:
      return plist[n-1]+patty(n-1,x-2-blist[n-1])+1
    else:
      return plist[n]
print(patty(n,x))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
n, x = map(int, input().split())

dp = [1]*(n+1)
res = 0

for i in range(1,n+1):
    dp[i] = dp[i-1]*2+3

for j in range(n,1,-1):
    if dp[j-1]+2 <= x :
        res += 1 + (dp[j-1]+1)//2
        x -= dp[j-1]+3
    elif dp[j-1]+1 ==x:
        res += (dp[j-1]+1)//2
        x = 0
    else:
        x -=1
    
    if x ==0:
        break
        
if x ==5:
    res += 3
elif x ==0:
    pass
else:
    res +=x-1

print(res)

n, x = map(int, input().split())

dp = [1]*(n+1)
res = 0

for i in range(1,n+1):
    dp[i] = dp[i-1]*2+3

for j in range(n,1,-1):
    if dp[j] ==x:
        res += (dp[j]+1) //2
        x =0        
    elif dp[j-1]+2 <= x :
        res += 1 + (dp[j-1]+1)//2
        x -= dp[j-1]+2
    elif dp[j-1]+1 ==x:
        res += (dp[j-1]+1)//2
        x = 0
    else:
        x -=1
    
    if x ==0:
        break
        
if x ==5:
    res += 3
elif x ==0:
    pass
else:
    res +=x-1

print(res)


Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
N, X = map(input().split())


a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    
    if N == 0:
        if X <= 0:
            return 0
        else:
            return 1
    elif X <= 1 + a[N - 1]:
        return f(N - 1, X - 1)
    else:
        return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

print(f(N, X))


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


a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    
    if N == 0:
        
        if X <= 0: 
            return 0
        
        else:
            return 1
    
    
    elif X <= 1 + a[N - 1]:
        return f(N - 1, X - 1)
    
    else:
        return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

print(f(N, X))


Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
N, X = map(int, input().split())
a,p=[1],[1] for i in range(N):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)
def f(N,X): 
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))


N, X = map(int, input().split())
a,p=[1],[1] for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
def f(N,X): 
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))

n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  if k == 0:
    return 0
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  else:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))



Verdicts: Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
Tmp = []
Tmp = input().rstrip().split(' ')

nN = int(Tmp[0])
nX = int(Tmp[1])

nA = 1
nP = 1

nAnsA = []
nAnsP = []

for i in range(nN):
  nTmpA = nA * 2 +3
  nTmpP = nP * 2 +1
  nAnsA.append(nTmpA)
  nAnsP.append(nTmpP)
  nA = nTmpA
  nP = nTmpP
  
print(nAnsA)  



Tmp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nX = int(Tmp[1])


nA = 1
nP = 1
 
nAnsA = []
nAnsP = []

nAnsA.append(1)
nAnsP.append(1)
 
for i in range(nN):
  nTmpA = nA * 2 +3
  nTmpP = nP * 2 +1
  nAnsA.append(nTmpA)
  nAnsP.append(nTmpP)
  nA = nTmpA
  nP = nTmpP

nAnsA.sort(reverse=True)  
nAnsP.sort(reverse=True)  
nN += 1

nMaxA = nAnsA[0]
nMaxP = nAnsP[0]
 
nTmpA = nMaxA
nTmpP = nMaxP
 
nAns = 0

# print(nAnsA)
# print(nAnsP)


for i in range(nN):
#  print(nX)
  if i == nN - 1:
    nAns += 1
    break
  else:
    nTmpA = nAnsA[i+1] + 2
    nTmpP = nAnsP[i+1] + 1
#  print(nTmpA)
#  print(nTmpP)

  
  if nTmpA > nX:
    nX -= 1
    if (nX == 0):
      break
  elif nTmpA == nX:
    nAns += nTmpP
    break
  else:
    nAns += nTmpP
    nX -= nTmpA
#  print(nAns)
    
print(nAns)
 

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):

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

def calcl(n):
    l = 2 ** (n+2) - 3 
    return l
def calcp(n):
    p = 2 ** (n+1) - 1
    return p
    
L = [1]
P = [1]

for i in range(1, N+1):
    L.append( L[i-1] * 2 + 3)
    P.append( P[i-1] * 2 + 1)

def judge(n, x):
    # if n == 0:
    #     if x == 1:
    #         return 1
    #     else:
    
    if x == 1:
        if n == 0:
            return "3"
        else:
            return "2"
    else:
        l = L[n]       # layers
        top = l
        bottom = 1
        mid = (l-1)//2 # index of middle

        if x == mid:
            return "3"
        elif top > x > mid:
            return "1"
        elif 0 < x < mid:
            return "0"            
        elif x == top:
            return "4"
        elif x == bottom:
            return "2"
        else:
            raise "No such pattern!"
        
    
def calc_pan(n,x):
    c = judge(n,x)
    # print("calc_panK: n:{}, x:{}, c: {}".format(n,x,c))
    if  c == "2":
        return 0
    elif c == "4":
        return 1 + P[n-1] * 2
    elif c == "3":
        return 1 + P[n-1]
    elif c == "0":
        return calc_pan(n-1, x-1)
    elif c == "1":
        return P[n-1] + 1 + calc_pan(n-1, x-L[n-1]-2)





sum = calc_pan(N, X)
print(sum)






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

    
L = [1]
P = [1]

for i in range(0, N+1):
    L.append( L[i] * 2 + 3)
    P.append( P[i] * 2 + 1)

        
    
def calc_pan(n,x):
    # c = judge(n,x)
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + L[n-1]:
        return calc_pan(n-1, x-1)
    else:
        return P[n-1] + 1  + calc_pan(n-1, x - 2 - L[n-1])

sum = calc_pan(N, X)
print(sum)





Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas.  Mr. Takaha decides to make a multi-dimensional burger in his party. A _level- L burger_ (L is an integer greater than or equal to 0) is the following thing:    * A level-0 burger is a patty.   * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) burger and another bun, stacked vertically in this order from the bottom.  For example, a level-1 burger and a level-2 burger look like `BPPPB` and `BBPPPBPBPPPBB` (rotated 90 degrees), where `B` and `P` stands for a bun and a patty.  The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Submission attempts (in order):
N, X = map(int, input().split())

T = [1]*(N + 1)
P = [1]*(N + 1)
for i in range(1, N+1):
	P[i] = P[i-1]*2 + 1
	T[i] = T[i-1]*2 + 3
print(T)
def pate(n, x):
	if n == 0:
		if x > 0: return 1
		return 0
	mid = T[n]//2
	if x < mid:
		print(n, x, mid, "a")
		return pate(n-1, x-1)
	elif mid == x:
		print(n, x, mid, "b")
		return 1 + pate(n-1, x-2)
	else:
		print(n, x, mid, "c")
		return P[n-1] + 1 + pate(n-1, x-mid-1)

print(pate(N, X))


T = [1]*(N + 1)
P = [1]*(N + 1)
for i in range(1, N+1):
	P[i] = P[i-1]*2 + 1
	T[i] = T[i-1]*2 + 3
def pate(n, x):
	if n == 0:
		if x > 0: return 1
		return 0
	mid = T[n]//2
	if x < mid:
		return pate(n-1, x-1)
	elif mid == x:
		return 1 + pate(n-1, x-2)
	else:
		return P[n-1] + 1 + pate(n-1, x-mid-1)

print(pate(N, X))


N, X = map(int, input().split())
hight, paty = [0]*51, [0]*51
hight[0] = 1
paty[0] = 1

for i in range(1, 51):
	hight[i] = 2*hight[i-1] + 3
	paty[i] = 2*paty[i-1] + 1

def f(n, x):
	if x == 0: return 0
	elif n == 0: return 1

	elif x <= (hight[n-1]+1):
		return f(n-1, x-1)
	else:
		return paty[n-1] + 1 + f(n-1, x-hight[n-1]-2)

print(f(N, X))

Verdicts: Wrong Answer

Runtime Error

Accepted