problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p03209
u047023156
2,000
1,048,576
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?
['import sys\ninput = sys.stdin.readline\n\nN, X = map(int, input().split())\nl, p = [1], [1]\n\ndef f(N, X)\n for i in range(N):\n if N == 0:\n return 0 if X == 0 else 1\n elif X <= 1 + l[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n \nprint(f(N, X))\n', 'import sys\ninput = sys.stdin.readline\n\nN, X = map(int, input().split())\nl, p = [1], [1]\n\ndef f(N, X):\n for i in range(N):\n if N == 0:\n return 0 if X == 0 else 1\n elif X <= 1 + l[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n \nprint(f(N, X))\n', 'import sys\ninput = sys.stdin.readline\n\nN, X = map(int, input().split())\nl, p = [1], [1]\n\nfor i in range(N):\n l.append(l[i]*2 + 3)\n p.append(p[i]*2 + 1)\n\ndef f(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + l[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-l[N-1])\n \nprint(f(N, X))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s039686333', 's130266257', 's401531590']
[2940.0, 3060.0, 3064.0]
[17.0, 18.0, 18.0]
[327, 328, 351]
p03209
u050698451
2,000
1,048,576
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?
['N, X = map(int, input().split())\na = [1]\np = [1]\nfor i in range(N):\n\ta.append(a[i]*2+3)\n\tp.append(p[i]*2+1)\n\ndef f(N, X):\n\tif N == 0:\n\t\treturn 0 if X <= 0 else 1\n\telif 1 <= X <= a[N-1]+1:\n\t\treturn f(N-1, X-1)\n\t# elif X == a[N-1]+2:\n\t# \treturn p[N-1] + 1\n\t# elif a[N-1]+3 <= X <= 2*a[N-1]+2:\n\t# \treturn f(N-1, X-2-a[N-1]) + p[N-1] + 1\n\t# else:\n\t# \treturn 2*p[N-1] + 1\n\telse:\n\t\treturn f(N-1, X-2-a[N-1]) + p[N-1] + 1\n\nprint(f(N, X))\n', 'N, X = map(int, input().split())\na = [1]\np = [1]\nfor i in range(N):\n\ta.append(a[i]*2+3)\n\tp.append(p[i]*2+1)\n\ndef f(N, X):\n\tif N == 0:\n\t\treturn 0 if X <= 0 else 1\n\telif X <= a[N-1]+1:\n\t\treturn f(N-1, X-1)\n\telif X == a[N-1]+2:\n\t\treturn p[N-1] + 1\n\telif a[N-1]+3 <= X <= 2*a[N-1]+2:\n\t\treturn f(N-1, X-2-a[N-1]) + p[N-1] + 1\n\telse:\n\t\treturn p[N]\n\nprint(f(N, X))\n']
['Wrong Answer', 'Accepted']
['s537362667', 's124004542']
[3064.0, 3064.0]
[17.0, 19.0]
[431, 358]
p03209
u059262067
2,000
1,048,576
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?
['a = list(map(int, input().split()))\n\nc = a[1]\nres = 0\n\nb = [[5,3,1]]\nfor i in range(1,a[0]+1):\n tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]\n b.append(tmp)\n\nfor i in range(a[0]-1,-1,-1):\n print(b[i],c)\n if b[i][0] <= c:\n c = c - b[i][0]\n res = res + b[i][1]\n if c > 0:\n c = c -1\n res = res + 1\n c = c - 1\n\nif c > 0:\n res = res + c\n\n\nprint(res)\n\n', 'a = list(map(int, input().split()))\n\nc = a[1]\nres = 0\n\nb = [[5,3,1]]\nfor i in range(1,a[0]+1):\n tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]\n b.append(tmp)\n\nfor i in range(50-1,0,-1):\n c = c - 1\n if b[i][0] < c:\n c = c - b[i][0] - 1\n res = res + b[i][1] + 1\nif c == 1:\n res = res + 1\n\nprint(res)\n', 'a = list(map(int, input().split()))\nc = a[1]\nres = 0\n\nb = [[5,3,1]]\nfor i in range(1,a[0]):\n tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]\n b.append(tmp)\n\nfor i in range(a[0]-1,-1,-1):\n if b[i][0] * 2 + 1 <= c:\n c = c - b[i][0]*2 - 1\n res = res + b[i][1] * 2 + 1\n elif b[i][0] <= c: \n c = c - b[i][0]\n res = res + b[i][1]\n if c > 0:\n c = c - 1\n res = res + 1\n c = c - 1\n\nif c > 0:\n res = res + c\n\nprint(res)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s162102040', 's868991959', 's123282308']
[3064.0, 3064.0, 3064.0]
[17.0, 19.0, 17.0]
[401, 320, 476]
p03209
u060938295
2,000
1,048,576
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?
['# -*- coding: utf-8 -*-\n"""\nCreated on Sun May 19 16:57:17 2019\n\n@author: Yamazaki Kenichi\n"""\n\nN, X = map(int,input().split())\n\ndp = [[1,1] for i in range(N)]\nfor i in range(1,N):\n dp[i][0] = dp[i-1][0]*2 + 1\n dp[i][1] = dp[i-1][1]*2 + 3\n\nans = 0\nfor i in range(2,N+1):\n if X - (dp[-i][1] + 2) >= 0:\n ans += dp[-i][0] + 1\n X -= (dp[-i][1] + 2)\n print(ans,X,dp[-i])\n else:\n X -= 1\n print(ans,X,dp[-i])\nif X >= 1:\n ans += 1\nprint(ans)', '# -*- coding: utf-8 -*-\n"""\nCreated on Sun May 19 16:57:17 2019\n\n@author: Yamazaki Kenichi\n"""\n\nN, X = map(int,input().split())\n\ndp = [[1,1] for i in range(N)]\nfor i in range(1,N):\n dp[i][0] = dp[i-1][0]*2 + 1\n dp[i][1] = dp[i-1][1]*2 + 3\n\nans = 0\nfor i in range(2,N+1):\n if X - (dp[-i][1] + 2) >= 0:\n ans += dp[-i][0] + 1\n X -= (dp[-i][1] + 2)\n# print(ans,X,dp[-i])\n else:\n X -= 1\n# print(ans,X,dp[-i])\nif X >= 1:\n ans += 1\nprint(ans)', '# -*- coding: utf-8 -*-\n"""\nCreated on Mon Apr 27 21:30:42 2020\n"""\n\nimport sys\n#import numpy as np\n\nsys.setrecursionlimit(10 ** 9)\n#def input():\n# return sys.stdin.readline()[:-1]\nmod = 10**9+7\n\n#N = int(input())\nN, X = map(int,input().split())\n#A = list(map(int,input().split()))\n\nn = N\neat = X\n\ndef dfs(x):\n x\n\nans = 0\n#print(ans,eat,n)\nwhile eat > 0 and n >= 0:\n if eat == (pow(2,n+2) - 3 + 1) //2:\n ans += pow(2,n) - 1 + 1\n eat = 0\n n -= 1\n elif eat > (pow(2,n+2) - 3 + 1) //2:\n ans += pow(2,n) - 1 + 1\n eat -= (pow(2,n+2) - 2) //2\n n -= 1\n else:\n eat -= 1\n n -= 1\n# print(ans,eat,n)\n\nprint(ans)\n \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s467596966', 's950469534', 's430952067']
[3064.0, 3064.0, 3064.0]
[18.0, 17.0, 17.0]
[483, 485, 680]
p03209
u062459048
2,000
1,048,576
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?
['n, x = map(int, input().split())\n\nl = [0]*(n+1)\nl[0] = 1\nfor i in range(1,n+1):\n l[i] = l[i-1]*2+3\n\np = [0]*(n+1)\np[0] = 1\nfor i in range(1,n+1):\n p[i] = p[i-1]*2+1\n \nans = 0 \ndef bts(a,b):\n global ans\n if b = 1:\n ans += 0\n elif 1 < b < l[a-1]+1:\n bts(a-1,b-1)\n elif b == l[a-1]+1:\n ans += p[a-1]\n elif b == l[a-1]+2:\n ans += p[a-1]+1\n elif l[a-1]+2 < b < l[a-1]*2+2:\n ans += p[a-1]+1\n bts(a-1,b-2-l[a-1])\n else:\n ans += p[a-1]+2\n\nbts(n,x)\n \nprint(ans)\n', "n, x = map(int, input().split())\n\na = 'P'\nfor i in range(1,n):\n a = 'B'+a+'P'+a+'B'\n \nprint(a[:x].count('P'))\n \n \n ", 'n, x = map(int, input().split())\n\nl = [0]*(n+1)\nl[0] = 1\nfor i in range(1,n+1):\n l[i] = l[i-1]*2+3\n\np = [0]*(n+1)\np[0] = 1\nfor i in range(1,n+1):\n p[i] = p[i-1]*2+1\n \nans = 0 \ndef bts(a,b):\n global ans\n if b == 1:\n ans += 0\n elif 1 < b < l[a-1]+1:\n bts(a-1,b-1)\n elif b == l[a-1]+1:\n ans += p[a-1]\n elif b == l[a-1]+2:\n ans += p[a-1]+1\n elif l[a-1]+2 < b < l[a-1]*2+2:\n ans += p[a-1]+1\n bts(a-1,b-2-l[a-1])\n else:\n ans += p[a]\n\nbts(n,x)\n \nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s335694714', 's430961053', 's243680127']
[2940.0, 2940.0, 3064.0]
[17.0, 2060.0, 17.0]
[486, 120, 483]
p03209
u070561949
2,000
1,048,576
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?
["ef dfs (i,depth):\n\n if i >= depth-1:\n return 'bpppb'\n else:\n s = dfs(i+1,depth)\n return 'b' + s + 'p' + s + 'b'\n\nn,x = map(int,input().split())\n\np = 2**(n+1)-1\nb = 2**(n+1)-2\na = p + b\n#print(p,a,b)\npos = a / x\n#print(pos)\n#print(p / pos)\n\nr = dfs(0,n)\nprint(r.count('p',0,x))\n", 'a = []\np = []\n\ndef dfs (x,i,depth):\n\n if i <= 1:\n #print(x)\n if x == 0:\n return 0\n elif x == 1:\n return 1\n elif x == 2:\n return 2\n elif x >= 3:\n return 3\n else:\n #print(a[i],a[i]//2,x)\n if a[i]//2 < x :\n x = x - a[i]//2 - 1\n #print("right>>>",p[i-1] + 1,x)\n return (p[i-1] + 1) + dfs(x,i-1,depth)\n elif a[i]//2 == x :\n #print("<<<mid>>>",1,x)\n return (1 + dfs(x-1,i-1,depth))\n else:\n #print("left<<<",0,x)\n if x - 1 <= 0:\n return 0\n else:\n return dfs(x-1,i-1,depth)\n\ndef ddff (i,depth):\n if i >= depth-1:\n return \'bpppb\'\n else:\n return \'b\' + ddff(i+1,depth) + \'p\' + ddff(i+1,depth) + \'b\'\n \nn,x = map(int,input().split())\n\nfor i in range(n+1):\n p.append(2**(i+1)-1)\n b = 2**(i+1)-2\n a.append(p[i] + b)\n#print(a,p)\n\nr = dfs(x-1,n,n)\nprint(r)']
['Runtime Error', 'Accepted']
['s994341033', 's629777713']
[2940.0, 3064.0]
[18.0, 18.0]
[304, 1000]
p03209
u075012704
2,000
1,048,576
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?
['N, X = map(int, input().split())\n\n\nthick, patti = [1], [1]\nfor i in range(N):\n thick.append(2 * thick[-1] + 3)\n patti.append(2 * patti[-1] + 1)\n\n\ndef solve(n, x):\n if x == 1: \n return 0\n\n + レベルL-1バーガーの途中まで\n elif 1 < x <= 1 + thick[n - 1]:\n return solve(n - 1, x - 1)\n\n + レベルL-1バーガー + 真ん中のパティ\n elif x == 2 + thick[n - 1]:\n return patti[n - 1] + 1\n\n + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガーの途中まで\n elif 2 + thick[n - 1] < x <= 2 * thick[n - 1] + 2:\n return patti[n - 1] + 1 + solve(n - 1, x - 1 - thick[n - 1] - 1)\n\n + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガー + 最後のバン\n elif x == 2 * thick[n - 1] + 3:\n return 2 * patti[n - 1] + 1\n\n\nprint(solve(N, X))\n', 'N, X = map(int, input().split())\n\n\nthick, patti = [1], [1]\nfor i in range(N):\n thick.append(2 * thick[-1] + 3)\n patti.append(2 * patti[-1] + 1)\n\n\ndef solve(n, x):\n if x == 1: \n return 0\n\n + レベルL-1バーガーの途中まで\n elif 1 < x < 1 + thick[n - 1] + 1:\n return solve(n - 1, x - 1)\n\n + レベルL-1バーガー + 真ん中のパティ\n elif x == 2 + thick[n - 1]:\n return patti[n - 1] + 1\n\n + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガーの途中まで\n elif 2 + thick[n - 1] < x < 2 * thick[n - 1] + 3:\n return patti[n - 1] + 1 + solve(n - 1, x - 1 - thick[n - 1] - 1)\n\n + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガー + 最後のバン\n else:\n return 2 * patti[n - 1] + 1\n\n\nprint(solve(N, X))\n', 'N, X = map(int, input().split())\n\n\nthick, patti = [1], [1]\nfor i in range(N):\n thick.append(2 * thick[-1] + 3)\n patti.append(2 * patti[-1] + 1)\n\n\nans = 0\n\n\ndef solve(n, x):\n global ans\n if x == 1: \n return\n\n + レベルL-1バーガーの途中まで\n elif 1 < x < 1 + thick[n - 1]:\n solve(n - 1, x - 1)\n\n + レベルL-1バーガー + 真ん中のパティ\n elif x == 2 + thick[n - 1]:\n ans += patti[n - 1] + 1\n return\n\n + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガーの途中まで\n elif 2 + thick[n - 1] < x < 2 * thick[n - 1] + 3:\n ans += patti[n - 1] + 1\n solve(n - 1, x - 1 - thick[n - 1] - 1)\n\n + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガー + 最後のバン\n else:\n ans += 2 * patti[n - 1] + 1\n return\n\n\nsolve(N, X)\nprint(ans)\n', 'N, X = map(int, input().split())\n\n\nthick, patti = [1], [1]\nfor i in range(N):\n thick.append(2 * thick[-1] + 3)\n patti.append(2 * patti[-1] + 1)\n\n\ndef solve(n, x):\n if x == 1: \n return 0\n\n + レベルL-1バーガーの途中まで\n elif 1 < x < 1 + thick[n - 1]:\n return solve(n - 1, x - 1)\n\n + レベルL-1バーガー + 真ん中のパティ\n elif x == 2 + thick[n - 1]:\n return patti[n - 1] + 1\n\n + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガーの途中まで\n elif 2 + thick[n - 1] < x < 2 * thick[n - 1] + 3:\n return patti[n - 1] + 1 + solve(n - 1, x - 1 - thick[n - 1] - 1)\n\n + レベルL-1バーガー + 真ん中のパティ + レベルL-1バーガー + 最後のバン\n else:\n return 2 * patti[n - 1] + 1\n\n\nprint(solve(N, X))\n', 'N, X = map(int, input().split())\n\n\nthick, patti = [1], [1]\nfor i in range(N):\n thick.append(2 * thick[-1] + 3)\n patti.append(2 * patti[-1] + 1)\n\n\ndef solve(n, x):\n if x == 1: \n return 0 + (n == 0)\n\n \n elif 1 < x <= 1 + thick[n - 1]:\n return solve(n - 1, x - 1)\n\n \n else:\n return patti[n - 1] + 1 + solve(n - 1, x - 1 - thick[n - 1] - 1)\n\n\nprint(solve(N, X))\n', 'N, X = map(int, input().split())\n\nburger_size = [1]\npatty_num = [1]\nfor i in range(50):\n burger_size.append(2 * burger_size[-1] + 3)\n patty_num.append(2 * patty_num[-1] + 1)\n\n\n\ndef dfs(n, x):\n if burger_size[n] == x:\n return patty_num[n]\n\n if x == 1:\n return 0\n\n elif 1 < x <= 1 + burger_size[n - 1]:\n return dfs(n - 1, x - 1)\n\n elif x == 1 + burger_size[n - 1] + 1:\n return patty_num[n - 1] + 1\n\n elif 1 + burger_size[n - 1] + 1 < x < burger_size[n]:\n return patty_num[n - 1] + 1 + dfs(n - 1, x - burger_size[n - 1] - 2)\n\n\nprint(dfs(N, X))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s060448424', 's175639993', 's307756782', 's353242695', 's806626646', 's084198605']
[3064.0, 3064.0, 3064.0, 3064.0, 3136.0, 9084.0]
[18.0, 18.0, 18.0, 17.0, 25.0, 30.0]
[1052, 1028, 1103, 1024, 771, 685]
p03209
u077337864
2,000
1,048,576
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?
['N, X = map(int, input().strip().split())\n\ntotalp = [1]\ntotalb = [1]\nfor _ in range(1, N+1):\n totalp.append(totalp[-1]*2 + 1)\n totalb.append(totalp[-1]*2 + 3)\n\ndef burger(N, X):\n if N == 0:\n return 0 if X == 0 else 1\n elif X < totalb[N-1] + 1:\n return burger(N-1, X-1)\n else:\n return totalp[N-1] + burger(N-1, X-2-totalp[N-1])\n\nprint(burger(N, X))\n', 'N, X = map(int, input().split())\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))\n']
['Wrong Answer', 'Accepted']
['s100530891', 's550835425']
[3064.0, 3064.0]
[17.0, 18.0]
[361, 289]
p03209
u091051505
2,000
1,048,576
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?
['n, x = map(int, input().split())\na = putty(n)\na = a[:x]\nprint(a.count("P"))', 'def f(n, x):\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= (a[n-1] + 1):\n return f(n - 1, x - 1)\n else:\n return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1])\n\n\nn, x = map(int, input().split())\n\na, p=[1],[1]\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n \nprint(f(n, x))']
['Runtime Error', 'Accepted']
['s425558486', 's088620319']
[2940.0, 3064.0]
[18.0, 18.0]
[75, 329]
p03209
u098968285
2,000
1,048,576
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?
['\n\nN, X = map(int, input().split())\n\nlayer = 1\nfor _ in range(N):\n layer = layer * 2 + 3\n\ndef calc(n, i, layer):\n if n == 1:\n return "BPPPB"[i-1]\n else:\n if i == layer // 2 + 1:\n return "P"\n \n if i > layer // 2:\n i = layer - i + 1\n \n return calc(n-1, i, (layer-3) // 2)\n\nans = calc(N, X, layer)\nprint(ans)\n', 'N, X = map(int, input().split())\n\ncntP = [0]*(N+1)\ncntP[0] = 1\nfor i in range(1, N+1):\n cntP[i] = cntP[i-1] * 2 + 1\n\nlayer = 1\nfor _ in range(N):\n layer = layer * 2 + 3\n\ndef calc(n, i, layer):\n if i == 0:\n return 0\n \n if n == 1:\n return "BPPPB"[:i].count("P")\n else:\n if i == layer // 2 + 1:\n return cntP[n-1] + 1\n elif i > layer // 2 + 1:\n return cntP[n-1] + 1 + calc(n-1, i - (layer // 2 + 1), (layer-3) // 2)\n elif i < layer // 2 + 1:\n return calc(n-1, i-1, (layer-3) // 2)\n\nans = calc(N, X, layer)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s550955633', 's647497783']
[3068.0, 3064.0]
[20.0, 18.0]
[386, 599]
p03209
u102960641
2,000
1,048,576
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?
['def patty(n,x):\n if n == 0:\n if x == 0:\n return 0\n else: \n return 1\n elif x <= 1 + a[n-1]:\n return patty(n-1, x-1)\n else:\n return p[n-1] + 1 + patty(n-1, x-2-a[n-1])\n\nn,x = map(int, input().split())\na = [1]\np = [1]\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\nans = patty(n,x)\nprint(ans)', 'def patty(n,x):\n if n == 0:\n if x <= 0:\n return 0\n else: \n return 1\n elif x <= 1 + a[n-1]:\n return patty(n-1, x-1)\n else:\n return p[n-1] + 1 + patty(n-1, x-2-a[n-1])\n\nn,x = map(int, input().split())\na = [1]\np = [1]\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\nans = patty(n,x)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s793504064', 's152038927']
[3064.0, 3064.0]
[17.0, 17.0]
[336, 336]
p03209
u129836004
2,000
1,048,576
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?
["import sys\nsys.setrecursionlimit(10000000000)\ndef burger(l):\n memo = [0] * (l+1)\n def l_burger(l):\n if l == 0:\n return 'P'\n if memo[l] != 0:\n return memo[l]\n \n memo[l] = 'B' + l_burger(l-1) + 'P' + l_burger(l-1) + 'B'\n return memo[l]\n return l_burger(l)\nn, x = map(int, input().split())\ncnt = 0\nfor i in burger(n)[:x]:\n if i == 'P':\n cnt += 1\n \nprint(cnt)\n ", "import sys\nsys.setrecursionlimit(100000000000000000)\ndef burger(l):\n memo = [0] * (l+1)\n def l_burger(l):\n if l == 0:\n return 'P'\n if memo[l] != 0:\n return memo[l]\n \n memo[l] = 'B' + l_burger(l-1) + 'P' + l_burger(l-1) + 'B'\n return memo[l]\n return l_burger(l)\nn, x = map(int, input().split())\ncnt = 0\nfor i in burger(n)[:x]:\n if i == 'P':\n cnt += 1\n \nprint(cnt)\n \n ", 'N, X = map(int, input().split())\na = [1] * (N+1)\np = [1] * (N+1)\nfor i in range(1,N+1):\n a[i] = a[i-1]*2 + 3\n p[i] = p[i-1]*2 + 1\ndef f(n, x):\n if n == 0:\n return 1\n elif x == 1:\n return 0\n elif 2<= x <= a[n-1] + 1:\n return f(n-1, x-1)\n elif x == a[n-1] + 2:\n return p[n-1] + 1\n elif a[n-1]+3 <= x <= 2*a[n-1]+2:\n return p[n-1]+1+ f(n-1, x-(a[n-1]+2))\n elif x == 2*a[n-1]+3:\n return p[n]\nprint(f(N,X))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s012270423', 's168729946', 's539509481']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 18.0]
[443, 455, 467]
p03209
u151625340
2,000
1,048,576
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?
['def rep(N,X):\n if N == 1:\n if X == 1 or X == 5:\n return(0)\n else:\n return(X-1)\n elif X == 1:\n return(0)\n else:\n n = 2**(N+2)-3\n a = n//2-(X-1)\n p = 2**N-1\n if a < -1:\n return(rep(N-1, abs(a)) + p + 1)\n elif a == -1 or a == 0 or a == 1:\n return(p + 1)\n else:\n return(rep(N-1, X-1))\nprint(rep(N,X))', 'N, X = map(int, input().split())\n\ndef rep(N,X):\n if N == 1:\n if X == 1:\n return(0)\n elif X == 5:\n return(3)\n else:\n return(X-1)\n elif X == 1:\n return(0)\n else:\n n = 2**(N+2)-3\n p = 2**N-1 \n if X <= n//2:\n return(rep(N-1, X-1))\n elif X == n//2+1:\n return(p + 1)\n else:\n if n-1 == X-1:\n return(rep(N-1, X-1-n//2-1) + p + 1)\n else:\n return(rep(N-1, X-1-n//2) + p + 1)\nprint(rep(N,X))\n']
['Runtime Error', 'Accepted']
['s434524531', 's952883891']
[3064.0, 3316.0]
[17.0, 18.0]
[423, 578]
p03209
u160244242
2,000
1,048,576
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?
['nk_list = list(map(int, input().split()))\nn,k = nk_list[0], nk_list[1]\n\nketa_lst = list()\nfor i in range(50):\n if i == 0:\n keta = 1\n keta_lst.append(keta)\n else:\n keta = 2*keta + 3\n keta_lst.append(keta)\n\npaty_lst = list()\nfor i in range(50):\n if i == 0:\n paty = 1\n paty_lst.append(paty)\n else:\n paty = 2*paty+1\n paty_lst.append(paty)\n\ndef eat_paty(n,k):\n \n if n == 0 and k == 1:\n return 1\n \n keta_before = keta_lst[n-1]\n \n if k == 1:\n return 0\n elif k <= keta_before + 1:\n return eat_paty(n-1, k-1)\n elif k == keta_before + 2:\n return paty_lst[n-1]\n elif k <= 2*keta_before + 1:\n return paty_lst[n-1] + eat_paty(n-1, k-keta_before-2)\n elif k == 2*keta_before + 2:\n return 2 * paty_lst[n-1]\n\nprint(eat_paty(n,k))', 'nk_list = list(map(int, input().split()))\nn,k = nk_list[0], nk_list[1]\n\nketa_lst = list()\nfor i in range(50):\n if i == 0:\n keta = 1\n keta_lst.append(keta)\n else:\n keta = 2*keta + 3\n keta_lst.append(keta)\n\npaty_lst = list()\nfor i in range(50):\n if i == 0:\n paty = 1\n paty_lst.append(paty)\n else:\n paty = 2*paty+1\n paty_lst.append(paty)\n\ndef eat_paty(n,k):\n \n if n == 0 and k == 1:\n return 1\n \n keta_before = keta_lst[n-1]\n \n if k == 1:\n return 0\n elif k <= keta_before + 1:\n return eat_paty(n-1, k-1)\n elif k == keta_before + 2:\n return paty_lst[n-1]+1\n elif k <= 2*keta_before + 1:\n return paty_lst[n-1] + 1 + eat_paty(n-1, k-keta_before-2)\n elif k > 2*keta_before + 1:\n return 2 * paty_lst[n-1] + 1\n\nprint(eat_paty(n,k))']
['Runtime Error', 'Accepted']
['s201942194', 's160958366']
[3120.0, 3064.0]
[21.0, 18.0]
[852, 861]
p03209
u167523937
2,000
1,048,576
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?
['def L(N):\n if N==0:\n return 1\n else:\n prev_L = L(N-1)\n return 1+prev_L+1+prev_L+1\ndef numP(N):\n if N==0:\n return 1\n else:\n prev_P = numP(N-1)\n return 2*prev_P+1\ndef eated_P(N,X):\n ans = 0\n fh=int(L(2)/2)\n if X==0:\n return 0\n elif N==0:\n return 1\n elif fh<X:\n ans = numP(N-1)+1+eated_P(N-1,X-fh-1)\n return ans\n else:\n ans = eated_P(N-1,X-N-1)\n return ans\nN,X = map(int(), input().split())\nprint(eated_P(N,X))', 'def L(N):\n if N==0:\n return 1\n else:\n prev_L = L(N-1)\n return 1+prev_L+1+prev_L+1\ndef numP(N):\n if N==0:\n return 1\n else:\n prev_P = numP(N-1)\n return 2*prev_P+1\ndef eated_P(N,X):\n ans = 0\n fh=int(L(N)/2)\n if X<=0:\n return 0\n elif N==0:\n return 1\n elif fh<X:\n ans = numP(N-1)+1+eated_P(N-1,X-fh-1)\n return ans\n else:\n rem = X-1\n ans = eated_P(N-1,rem)\n return ans\nN,X = map(int,input().split())\nprint(eated_P(N,X))']
['Runtime Error', 'Accepted']
['s370761473', 's967049557']
[3064.0, 3188.0]
[18.0, 19.0]
[521, 534]
p03209
u167681750
2,000
1,048,576
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?
['n, x = map(int, input().split())\n\npatties, layers = [1], [1]\nfor i in range(n):\n patties += [patties[-1] * 2 + 1]\n layers += [layers[-1] * 2 + 3]\nprint(patties, layers)\n\ndef solve(N, cur):\n if N == 0:\n return 1 if cur > 0 else 0\n \n return solve(N-1, cur-1) if cur <= (layers[N] // 2) else solve(N-1, (cur-layers[N-1])-2) + patties[N-1] + 1\n\nprint(solve(n,x))', 'n, x = map(int, input().split())\n\nlayers, patties = [1],[1]\nfor i in range(n):\n layers.append(layers[-1] * 2 + 3)\n patties.append(patties[-1] * 2 + 1)\n\ndef solve(cur, level):\n if level == 0:\n return 1 if cur == 1 else 0\n elif (layers[level] // 2) + 1 >= cur:\n return solve(cur - 1, level - 1)\n else:\n return solve(cur - layers[level-1] - 2, level - 1) + patties[level-1] + 1\n\nprint(solve(x,n))', 'n, x = map(int, input().split())\n\npatties, layers = [1], [1]\nfor i in range(n):\n patties += [patties[-1] * 2 + 1]\n layers += [layers[-1] * 2 + 3]\n\ndef solve(N, cur):\n if N == 0:\n return 1 if cur > 0 else 0\n \n return solve(N-1, cur-1) if cur <= (layers[N] // 2) else solve(N-1, (cur-layers[N-1])-2) + patties[N-1] + 1\n\nprint(solve(n,x))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s028797108', 's200443639', 's575542019']
[3064.0, 3064.0, 3064.0]
[18.0, 17.0, 17.0]
[384, 429, 361]
p03209
u169027725
2,000
1,048,576
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?
['N, X = map(int, input().split())\n\na, p = [1], [1]\nfor i in range(N):\n\u3000a.append(a[i] * 2 + 3)\n\u3000p.append(p[i] * 2 + 1)\n\ndef f(N, X): \n\u3000if N == 0:\n\u3000\u3000return 0 if X <= 0 else 1\n\u3000elif X <= 1 + a[N-1]:\n\u3000\u3000return f(N-1, X-1)\n\u3000else:\n\u3000\u3000return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))', 'N, X = map(int, input().split())\n\na, p = [1], [1]\nfor i in range(N):\na.append(a[i] * 2 + 3)\np.append(p[i] * 2 + 1)\n\ndef f(N, X): \n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n elif X == 2 + a[N-1]:\n return p[N-1] + 1\n elif X == 3 + 2 * a[N-1]:\n return 2 * p[N-1] + 1\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\nprint(f(N, X))', 'N, X = map(int, input().split())\n \na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X): \n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n elif X == 2 + a[N-1]:\n return p[N-1] + 1\n elif X == 3 + 2 * a[N-1]:\n return 2 * p[N-1] + 1\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\nprint(f(N, X))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s720061463', 's811002823', 's819678158']
[2940.0, 2940.0, 3064.0]
[18.0, 18.0, 18.0]
[361, 445, 450]
p03209
u172035535
2,000
1,048,576
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?
['n,x = map(int,input().split())\n\nA = [1]\nP = [1]\nfor i in range(n):\n\tA.append(A[i]*2+3)\n\tP.append(P[i]*2+1)\nprint(A,P)\n\ndef func(n,x):\n\telif x == 1:\n\t\treturn 0 if n != 0 else 1\n\telif x <= 1+A[n-1]:\n\t\treturn func(n-1,x-1)\n\telif x == 2+A[n-1]:\n\t\treturn P[n-1]+1\n\telif x <= 2+2*A[n-1]:\n\t\treturn P[n-1]+1+func(n-1,x-2-A[n-1])\n\telse:\n\t\treturn 2*P[n-1]+1\n\nprint(func(n,x))', 'n,x = map(int,input().split())\n\nA = [1]\nP = [1]\nfor i in range(n):\n\tA.append(A[i]*2+3)\n\tP.append(P[i]*2+1)\nprint(A,P)\n\ndef func(n,x):\n\tif x <= 0:\n\t\treturn 1\n\telif x == 1:\n\t\treturn 0\n\telif x <= 1+A[n-1]:\n\t\treturn func(n-1,x-1)\n\telif x == 2+A[n-1]:\n\t\treturn P[n-1]+1\n\telif x <= 2+2*A[n-1]:\n\t\treturn P[n-1]+1+func(n-1,x-2-A[n-1])\n\telse:\n\t\treturn 2*P[n-1]+1\n\nprint(func(n,x))', 'n,x = map(int,input().split())\n\nA = [1]\nP = [1]\nfor i in range(n):\n\tA.append(A[i]*2+3)\n\tP.append(P[i]*2+1)\n# print(A,P)\n\ndef func(n,x):\n\tif x == 1:\n\t\treturn 0 if n != 0 else 1\n\telif x <= 1+A[n-1]:\n\t\treturn func(n-1,x-1)\n\telif x == 2+A[n-1]:\n\t\treturn P[n-1]+1\n\telif x <= 2+2*A[n-1]:\n\t\treturn P[n-1]+1+func(n-1,x-2-A[n-1])\n\telse:\n\t\treturn 2*P[n-1]+1\n\nprint(func(n,x))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s830663544', 's978096749', 's775722487']
[2940.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0]
[365, 371, 365]
p03209
u177411511
2,000
1,048,576
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?
['import sys\nfrom collections import deque\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nn, x = na()\nbg = "P"\nan = 2 ** (n+2) - 3\nbn = 2 ** (n+1) - 1\nif an > x:\n print(bn)\nelse:\n for i in range(n):\n bg = "B" + bg + "P" + bg + "B"\n if len(bg) > x:\n bg = bg[:x]\n print(bg[:x].count("P"))', 'import sys\nfrom collections import deque\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nn, x = na()\nbg = "P"\nan = 2 ** (n+2) - 3\nbn = 2 ** (n+1) - 1\nif an > x:\n print(bn)\nelse:\n for i in range(n - 1):\n bg = "B" + bg + "P" + bg + "B"\n if len(bg) > x:\n bg = bg[:x]\n print(bg[:x].count("P"))', 'import sys\nfrom collections import deque\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nn, x = na()\na = [1]\np = [1]\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(n, x):\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= 1 + a[n-1]:\n return f(n-1, x-1)\n else:\n return p[n-1] + 1 + f(n-1, x-2-a[n-1])\n\nprint(f(n,x))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s104366065', 's764564131', 's265262338']
[3316.0, 3316.0, 3316.0]
[2033.0, 1989.0, 21.0]
[433, 437, 491]
p03209
u185354171
2,000
1,048,576
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?
['N,K = map(int,input().split())\nimport sys\nsys.setrecursionlimit(10000000)\n\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\ndef dfs(N,X):\n if N == 0:\n return 0 \n elif X <= 1 + a[N-1]:\n return dfs(N-1, X-1)\n elif X == 2 + a[N-1]:\n return p[N-1]\n elif X <= 2 + 2*a[N-1]:\n return p[N-1] + 1 + dfs(N-1, X-2-a[N-1])\n else:\n 2*p[N-1]+1\n \nprint(dfs(N,K))', 'N,K = map(int,input().split())\nimport sys\nsys.setrecursionlimit(10000000)\n\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\ndef dfs(N,X):\n #print(N,X)\n if N == 0:\n return 0 if X != 1 else 1\n elif X <= 1 + a[N-1]:\n return dfs(N-1, X-1)\n elif X == 2 + a[N-1]:\n return p[N-1] + 1\n elif X <= 2 + 2*a[N-1]:\n return p[N-1] + 1 + dfs(N-1, X-2-a[N-1])\n else:\n return 2*p[N-1]+1\n \nprint(dfs(N,K))']
['Runtime Error', 'Accepted']
['s992570162', 's730151470']
[3100.0, 3188.0]
[20.0, 19.0]
[440, 483]
p03209
u190406011
2,000
1,048,576
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?
['import sys\nn, x = [int(i) for i in sys.stdin.readline().split()]\ncur = 1\nls = [cur]\nfor i in range(50):\n cur = cur * 2 + 3\n ls.append(cur)\n\ndef f(n, x):\n if x == 1:\n return 0\n elif x <= ls[n-1]:\n return f(n-1, x-1)\n elif x == ls[n-1] + 1:\n return 1 + ls[n-1] // 2 + 1\n elif x < ls[n]:\n return 1 + ls[n-1] // 2 + 1 + f(n-1, x - ls[n-1] - 2)\n else:\n return ls[n] // 2 + 1\n\nres = f(n, x)\nprint(res)', 'import sys\nn, x = [int(i) for i in sys.stdin.readline().split()]\ncur = 1\nls = [cur]\nfor i in range(50):\n cur = cur * 2 + 3\n ls.append(cur)\n\ndef f(n, x):\n if x == 1:\n return 0\n elif x <= 1 + ls[n-1]:\n return f(n-1, x-1)\n elif x == ls[n-1] + 2:\n return ls[n-1] // 2 + 1\n elif x < ls[n]:\n return ls[n-1] // 2 + 1 + f(n-1, x - ls[n-1] - 2)\n else:\n return ls[n] // 2 + 1\nres = f(n, x)\nprint(res)', 'import sys\nn, x = [int(i) for i in sys.stdin.readline().split()]\ncur = 1\np = 1\nls = [cur]\np_ls = [p]\nfor i in range(50):\n cur = cur * 2 + 3\n p = p * 2 + 1\n ls.append(cur)\n p_ls.append(p)\n\ndef f(n, x):\n if n == 0:\n return 0 if x <= 0 else 1\n if x == 1:\n return 0\n elif x <= 1 + ls[n-1]:\n return f(n-1, x-1)\n elif x == ls[n-1] + 2:\n return 1 + p_ls[n-1]\n elif x < ls[n]:\n return 1 + p_ls[n-1] + f(n-1, x - ls[n-1] - 2)\n else:\n return p_ls[n]\nres = f(n, x)\nprint(res)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s379767763', 's987341160', 's048668716']
[3136.0, 3064.0, 3064.0]
[23.0, 17.0, 17.0]
[451, 446, 536]
p03209
u196697332
2,000
1,048,576
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?
['import math\nN, X = map(int, input().split())\n\ndp = [0] * (N + 1)\np_dp = [0] * (N + 1)\ndp[0] = 1\np_dp[0] = 1\nfor i in range(1, N + 1):\n dp[i] = dp[i - 1] * 2 + 3\n p_dp[i] = p_dp[i - 1] * 2 + 1\npatties = p_dp[N]\nburger_len = dp[N]\n\ntmp = X\nmiddle = -(-dp[N]//2)\nn = N - 1\nans = 0\nwhile True:\n print("middle:", middle)\n print("tmp:", tmp)\n if tmp == 1:\n if middle == 1:\n ans += 1\n break\n if tmp == middle:\n ans += p_dp[n] + 1\n break\n if tmp == dp[n + 1]:\n ans += p_dp[n] * 2 + 1\n break\n if 1 < tmp < middle:\n middle = -(-dp[n]//2)\n tmp -= 1\n n -= 1\n if middle < tmp < dp[n + 1]:\n tmp -= middle\n middle = -(-dp[n]//2)\n ans += p_dp[n] + 1\n n -= 1\nprint(ans)\n', 'import math\nN, X = map(int, input().split())\n\ndp = [0] * (N + 1)\np_dp = [0] * (N + 1)\ndp[0] = 1\np_dp[0] = 1\nfor i in range(1, N + 1):\n dp[i] = dp[i - 1] * 2 + 3\n p_dp[i] = p_dp[i - 1] * 2 + 1\npatties = p_dp[N]\nburger_len = dp[N]\n\ntmp = X\nmiddle = -(-dp[N]//2)\nn = N - 1\nans = 0\nwhile True:\n \n #print("tmp:", tmp)\n if tmp == 1:\n if middle == 1:\n ans += 1\n break\n if tmp == middle:\n ans += p_dp[n] + 1\n break\n if tmp == dp[n + 1]:\n ans += p_dp[n] * 2 + 1\n break\n if 1 < tmp < middle:\n middle = -(-dp[n]//2)\n tmp -= 1\n n -= 1\n if middle < tmp < dp[n + 1]:\n tmp -= middle\n middle = -(-dp[n]//2)\n ans += p_dp[n] + 1\n n -= 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s851089323', 's413134662']
[3064.0, 3064.0]
[18.0, 18.0]
[782, 784]
p03209
u197300773
2,000
1,048,576
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?
['def f(level,x):\n if level==0: return x\n \n if x in [1,0]:\n return 0\n elif x==b[level][0]:\n return b[level][1]\n elif 2<=x<b[level-1][0]+2:\n return f(level-1,x-1)\n elif x==b[level-1][0]+2:\n return b[level-1][1]+1\n elif b[level-1][0]+2<x<b[level][0]:\n return b[level-1][1]+1+f( level-1, x-(b[level-1][0]+2))\n\nN,X=map(int,input().split())\nb=[[1,1] for i in range(N+1)]\nfor i in range(1,N+1):\n b[i][0]=b[i-1][0]*2+3\n b[i][1]=b[i-1][1]*2+1\nprint(b)\n\nprint(f(N,X))', 'def f(level,x):\n if level==0: return x\n\n if x in [1,0]:\n return 0\n elif x==b[level][0]:\n return b[level][1]\n elif 2<=x<b[level-1][0]+2:\n return f(level-1,x-1)\n elif x==b[level-1][0]+2:\n return b[level-1][1]+1\n elif b[level-1][0]+2<x<b[level][0]:\n return b[level-1][1]+1+f( level-1, x-(b[level-1][0]+2))\n\nN,X=map(int,input().split())\nb=[[1,1] for i in range(N+1)]\nfor i in range(1,N+1):\n b[i][0]=b[i-1][0]*2+3\n b[i][1]=b[i-1][1]*2+1\n\nprint(f(N,X))']
['Wrong Answer', 'Accepted']
['s404026057', 's078087277']
[3064.0, 3064.0]
[18.0, 19.0]
[522, 505]
p03209
u205580583
2,000
1,048,576
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?
['N, X = map(int, input().split())\n\na, p = [1], [1]\n\nfor i in range(N):\n\ta.append(a[i] * 2 + 3)\n\tp.append(p[i] * 2 + 1)\ndef f(N, X): \n\tif N == 0:\n\t\treturn 0 if X <= 0 else 1\n\telif X <= 1 + a[N-1]:\n\t\treturn f(N-1, X-1)\n\telse:\n\t\treturn p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\n print(f(N, X))\n', 'n,x = map(int,input().split())\n\na,p = [1],[1]\n\n\n\nfor i in range(n):\n a.append(2 * a[i] + 3)\n p.append(2 * p[i] + 1)\n\ndef f(N,X):\n if N == 0:\n if X <= 0:\n return 0\n\n else:\n return 1\n\n elif X <= 1 + a[N-1]:\n return f(N -1,X-1)\n\n else:#if X <= 2 + 2 * a[N-1]:\n return p[N-1] + 1 + f(N -1, X-2-a[N-1])\n\nprint(f(n,x))\n']
['Runtime Error', 'Accepted']
['s646813294', 's955185955']
[2940.0, 3064.0]
[17.0, 18.0]
[341, 433]
p03209
u231261695
2,000
1,048,576
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?
['n, x = map(int, (input().split()))\na, p = [1], [1]\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\nprint("a = {}".format(a))\nprint("p = {}".format(p))\n\ndef f(n, x):\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= 1+a[n-1]:\n return f(n-1, x-1)\n elif x == a[n-1]+2:\n return p[n-1]+1\n elif x <= 2*a[n-1]+3\n return p[n-1]+1 + f(n-1, x-2-a[n-1])\nprint(f(n, x))', 'n, x = map(int, (input().split()))\na, p = [1], [1]\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(n, x):\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= 1+a[n-1]:\n return f(n-1, x-1)\n else:\n return p[n-1]+1 + f(n-1, x-2-a[n-1])\nprint(f(n, x))']
['Runtime Error', 'Accepted']
['s398295575', 's251654863']
[3064.0, 3064.0]
[18.0, 18.0]
[422, 307]
p03209
u254871849
2,000
1,048,576
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?
["import sys\n\ndef make_burger(n):\n patty = [None] * (n + 1)\n bun = [None] * (n + 1)\n patty[0] = 1\n bun[0] = 0\n burger = [None] * (n + 1)\n burger[0] = 1\n for i in range(n):\n patty[i+1] = patty[i] * 2 + 1\n bun[i+1] = bun[i] * 2 + 2\n burger[i+1] = patty[i+1] + bun[i+1]\n \n return patty, bun, burger\n\nn, x = map(int, sys.stdin.readline().split())\n\ndef main():\n r = x\n patty, bun, burger = make_burger(n)\n\n res = 0\n for l in range(n, 0, -1):\n half_burger = burger[l] // 2 + 1\n half_patty = patty[l] // 2 + 1\n if r == 1:\n break\n elif r < half_burger:\n r -= 1\n elif r == half_burger:\n res += half_patty\n break\n elif r < burger[l]:\n res += half_patty\n r -= half_burger\n elif r == burger[l]:\n res += patty[l]\n break\n if r:\n res += 1\n return res\n \nif __name__ == '__main__':\n ans = main()\n print(ans)", "import sys\n\ndef make_burger(n):\n patty = [None] * (n + 1)\n bun = [None] * (n + 1)\n patty[0] = 1\n bun[0] = 0\n burger = [None] * (n + 1)\n burger[0] = 1\n for i in range(n):\n patty[i+1] = patty[i] * 2 + 1\n bun[i+1] = bun[i] * 2 + 2\n burger[i+1] = patty[i+1] + bun[i+1]\n return burger, patty\n\nburger, patty = make_burger(50)\n\ndef patty_cnt(l, r, res):\n if l == 0:\n return res + 1\n half_burger = burger[l] // 2 + 1\n half_patty = patty[l] // 2 + 1\n if r == 1:\n return res\n elif r < half_burger:\n return patty_cnt(l-1, r-1, res)\n elif r == half_burger:\n return res + half_patty\n elif r < burger[l]:\n return patty_cnt(l-1, r-half_burger, res+half_patty)\n elif r == burger[l]:\n return res + patty[l]\n \nn, x = map(int, sys.stdin.readline().split())\n\ndef main():\n return patty_cnt(n, x, 0)\n \nif __name__ == '__main__':\n ans = main()\n print(ans)"]
['Wrong Answer', 'Accepted']
['s887143027', 's084470852']
[3188.0, 3064.0]
[19.0, 18.0]
[1007, 958]
p03209
u262084284
2,000
1,048,576
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?
['# coding: utf-8\n\nn,x = map(int, input().split())\n\nl,p = [1],[1]\nfor i in range(n):\n l.append(a[i]*2+3)\n p.append(a[i]*2+1)\n\ndef f(n,x):\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= 1 + l[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1]+1+f(n-1,x-2-l[n-1])\n\nprint(f(n,x))\n', '# coding: utf-8\n\nn,x = map(int, input().split())\n\nl,p = [1],[1]\nfor i in range(n):\n l.append(a[i]*2+3)\n p.append(a[i]*2+1)\n\ndef f(n,x):\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= 1 + a[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1]+1+f(n-1,x-2-a[n-1])\n\nprint(f(n,x))\n', '# coding: utf-8\n\nn,x = map(int, input().split())\n\nl,p = [1],[1]\nfor i in range(n):\n l.append(l[i]*2+3)\n p.append(p[i]*2+1)\n\ndef f(n,x):\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= 1 + l[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1]+1+f(n-1,x-2-l[n-1])\n\nprint(f(n,x))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s412876786', 's677341711', 's273550609']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0]
[310, 310, 310]
p03209
u263830634
2,000
1,048,576
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?
["N, X = map(int, input().split())\n\na = [1]\np = [1]\nfor i in range(1, N+1):\n a.append(2 * a[i-1] + 3)\n p.append(2 * a[i-1] + 1)\n\nprint (len(a))\ndef calc(N, X): \n if N == 0: \n if X == 0:\n return 0\n else:\n return 1\n if X == 1:\n return 0\n # print (N - 1)\n if 1 <= X <= a[N - 1]:\n # print ('A')\n return calc(N - 1, X - 1)\n if X == 2 + a[N - 1]:\n # print ('B')\n return p[N - 1] + 1\n if 2 +a[N - 1] < X <= 2 + 2 * a[N - 1]:\n # print ('C')\n return p[N - 1] + 1 + calc(N - 1, X - 2 - a[N - 1])\n if X == 3 + 2 * 2 * a[N - 1]:\n # print ('D')\n return 2 * p[N - 1] + 1\n\nprint (calc(N, X))", "N, X = map(int, input().split())\n\na = [1]\np = [1]\nfor i in range(1, N+2):\n a.append(2 * a[i-1] + 3)\n p.append(2 * p[i-1] + 1)\n\ndef calc(N, X): \n if N == 0: \n if X == 0:\n return 0\n else:\n return 1\n if X == 1:\n return 0\n # print (N - 1)\n if 1 < X <= 1 + a[N - 1]:\n # print ('A')\n return calc(N - 1, X - 1)\n if X == 2 + a[N - 1]:\n # print ('B')\n return p[N - 1] + 1\n if 2 + a[N - 1] < X <= 2 + 2 * a[N - 1]:\n # print ('C')\n return p[N - 1] + 1 + calc(N - 1, max(X - 2 - a[N - 1], 0))\n if X == 3 + 2 * a[N - 1]:\n # print ('D')\n return p[N]\n\nprint (calc(N, X))"]
['Runtime Error', 'Accepted']
['s931457106', 's813158634']
[3316.0, 3064.0]
[21.0, 18.0]
[788, 769]
p03209
u282228874
2,000
1,048,576
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?
["import sys\nsys.setrecursionlimit(10**7)\ninput = sys.stdin.readline\nINF = float('inf')\nMOD = 10**9+7\ndy = [0,1,0,-1]\ndx = [1,0,-1,0]\nddy = [0,1,1,1,0,-1,-1,-1]\nddx = [1,1,0,-1,-1,-1,0,1]\n\nn,x = map(int,input().split())\nP = [1]\nL = [1]\nfor i in range(n):\n P.append(P[-1]*2+1)\n L.append(L[-1]*2+3)\n\ndef f(N,X):\n if N == 0:\n return 1\n elif X <= 1 + L[N-1]:\n return f(N-1,X-1)\n else:\n return P[N-1]+1+f(N-1,X-2-L[N-1])\n\nprint(f(n,x))", "import sys\nsys.setrecursionlimit(10**7)\ninput = sys.stdin.readline\nINF = float('inf')\nMOD = 10**9+7\ndy = [0,1,0,-1]\ndx = [1,0,-1,0]\nddy = [0,1,1,1,0,-1,-1,-1]\nddx = [1,1,0,-1,-1,-1,0,1]\n\nn,x = map(int,input().split())\nP = [1]\nL = [1]\nfor i in range(n):\n P.append(P[-1]*2+1)\n L.append(L[-1]*2+3)\n\ndef f(N,X):\n if N == 0:\n if X <= 0:\n return 0\n else:\n return 1\n elif X <= 1 + L[N-1]:\n return f(N-1,X-1)\n else:\n return P[N-1]+1+f(N-1,X-2-L[N-1])\n\nprint(f(n,x))"]
['Wrong Answer', 'Accepted']
['s741964601', 's581675410']
[3064.0, 3064.0]
[18.0, 17.0]
[464, 522]
p03209
u284854859
2,000
1,048,576
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?
['import bisect\nn,x = map(int,input().split())\n\n\na = [1, 5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069, 262141, 524285, 1048573, 2097149, 4194301, 8388605, 16777213, 33554429, 67108861, 134217725, 268435453, 536870909, 1073741821, 2147483645, 4294967293, 8589934589, 17179869181, 34359738365, 68719476733, 137438953469, 274877906941, 549755813885, 1099511627773, 2199023255549, 4398046511101, 8796093022205, 17592186044413, 35184372088829, 70368744177661, 140737488355325, 281474976710653, 562949953421309, 1125899906842621, 2251799813685245, 4503599627370493]\n\nb = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207, 17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247]\n\n\n\ndef f(k,x,a,b):\n if x == 0:\n return 0\n elif k == 0:\n return 1\n elif k== 2:\n if x <= 4:\n return x-1\n else:\n return 3\n else:\n if x == (a[k]-1)//2+1:\n return b[k-1] + 1\n elif x < (a[k]-1)//2+1:\n if x <= k:\n return 0\n else:\n return f(k-1,x-1,a,b)\n elif x >= a[k]-k:\n return b[k]\n else:\n return b[k-1] + f(k-1,x-(a[k]-1)//2-1,a,b) + 1\n\nprint(f(n,x,a,b))\n \n', 'import bisect\nn,x = map(int,input().split())\n\n\na = [1, 5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069, 262141, 524285, 1048573, 2097149, 4194301, 8388605, 16777213, 33554429, 67108861, 134217725, 268435453, 536870909, 1073741821, 2147483645, 4294967293, 8589934589, 17179869181, 34359738365, 68719476733, 137438953469, 274877906941, 549755813885, 1099511627773, 2199023255549, 4398046511101, 8796093022205, 17592186044413, 35184372088829, 70368744177661, 140737488355325, 281474976710653, 562949953421309, 1125899906842621, 2251799813685245, 4503599627370493]\n\nb = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295, 8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943, 549755813887, 1099511627775, 2199023255551, 4398046511103, 8796093022207, 17592186044415, 35184372088831, 70368744177663, 140737488355327, 281474976710655, 562949953421311, 1125899906842623, 2251799813685247]\n\n\n\ndef f(k,x,a,b):\n if x == 0:\n return 0\n elif k == 0:\n return 1\n elif k== 1:\n if x <= 4:\n return x-1\n else:\n return 3\n else:\n if x == (a[k]-1)//2+1:\n return b[k-1] + 1\n elif x < (a[k]-1)//2+1:\n if x <= k:\n return 0\n else:\n return f(k-1,x-1,a,b)\n elif x >= a[k]-k:\n return b[k]\n else:\n return b[k-1] + f(k-1,x-(a[k]-1)//2-1,a,b) + 1\n\nprint(f(n,x,a,b))\n \n']
['Wrong Answer', 'Accepted']
['s006715574', 's753625678']
[3188.0, 3188.0]
[18.0, 18.0]
[1784, 1784]
p03209
u325956328
2,000
1,048,576
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?
["N, X = map(int, input().split())\n\ndef rec(n):\n if n == 0:\n return 'P'\n \n return 'B' + rec(n-1) + 'P' + rec(n-1) + 'B'\n\nprint(rec(N))\nans = rec(N)[-X:].count('P')\nprint(ans)", 'N, X = map(int, input().split())\n\na = [1]\np = [1]\nfor i in range(1, N + 1):\n a.append(a[i - 1] * 2 + 3)\n p.append(p[i - 1] * 2 + 1)\n\n\ndef F(n, x):\n if n == 0:\n return 1\n if x == 1:\n return 0\n elif x <= 1 + a[n - 1]:\n return F(n - 1, x - 1)\n elif x == 2 + a[n - 1]:\n return p[n - 1] + 1\n elif x <= 2 + 2 * a[n - 1]:\n return p[n - 1] + 1 + F(n - 1, x - 2 - a[n - 1])\n else:\n return 2 * p[n - 1] + 1\n\nprint(F(N, X))\n\n']
['Wrong Answer', 'Accepted']
['s285789722', 's552261280']
[37604.0, 3064.0]
[2105.0, 18.0]
[188, 480]
p03209
u341087021
2,000
1,048,576
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?
['n, x = map(int, input().split())\n\na, p = [1], [1]\nfor i in range(n):\n a.append(a[i]*2+3)\n p.append(a[i]*2+1)\n\ndef f(n, x):\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= 1 + a[n-1]:\n return f(n-1, x-1)\n else:\n return p[n-1] + 1 + f(n-1, x-2-a[n-1])\n\nprint(n,x)', 'n,x = map(int, input().split())\n\np, a = [1], [1]\n\nfor i in range(n):\n p.append(p[i]*2+1)\n a.append(a[i]*2+3)\n\ndef f(n,x):\n if x <= 0:\n return 0\n else:\n if n <= 0:\n return min(x, 3)\n else:\n if x > a[n]:\n return p[n] + 1 + f(n-1, x-2-a[n])\n elif x == a[n]:\n return p[n]\n else:\n return f(n-1,x-1)\n\nprint(f(n,x))']
['Wrong Answer', 'Accepted']
['s099264456', 's631213318']
[3064.0, 3064.0]
[18.0, 17.0]
[299, 430]
p03209
u349091349
2,000
1,048,576
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?
['N,X=map(int,input().split())\n\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef count(N):\n if N == 0:\n return 1\n else:\n temp = pan(N-1)\n return 3 + 2 * count(N-1)\n \n@lru_cache(maxsize=None)\ndef calc(N,X):\n if N == 0:\n return 1\n center = count(N-1) + 1\n if X == 0 :\n return 0\n elif X < center:\n return calc(N-1,X-1)\n elif X == center:\n return calc(N-1,center-2) + 1\n elif X > center:\n return calc(N-1,X-center-1) + calc(N,center)\nprint(calc(N,X-1))', 'N,X=map(int,input().split())\n\nfrom functools import lru_cache\nimport sys\n\nsys.setrecursionlimit(10*20)\n\n@lru_cache(maxsize=None)\ndef count(N):\n if N == 0:\n return 1\n else:\n return 3 + 2 * count(N-1)\n \n@lru_cache(maxsize=None)\ndef calc(N,X):\n if N == 0:\n return 1\n center = count(N-1) + 1\n if X == 0 :\n return 0\n elif X < center:\n return calc(N-1,X-1)\n elif X == center:\n return calc(N-1,center-2) + 1\n elif X > center:\n return calc(N-1,X-center-1) + calc(N,center)\nprint(calc(N,X-1))']
['Runtime Error', 'Accepted']
['s931039344', 's896922915']
[3700.0, 4068.0]
[24.0, 30.0]
[542, 559]
p03209
u349222099
2,000
1,048,576
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?
['import math\n\ndef burger_size(n):\n return 2**(n + 2) - 3\n\ndef num_of_patty(n):\n return 2**(n + 1) - 1\n\ndef calc(n, x):\n if n == 0:\n return 1\n if x <= n:\n return 0\n if x == burger_size(n):\n return num_of_patty(n)\n \n center = math.floor((burger_size(n) + 1) / 2)\n if x < center:\n return calc(n - 1, x - 1)\n elif x > center:\n return num_of_patty(n - 1) + 1 + calc(n - 1, x - burger_size(n - 1) - 2)\n else:\n return num_of_patty(n - 1) + 1\n', 'import math\n\ndef burger_size(n):\n return 2**(n + 2) - 3\n\ndef num_of_patty(n):\n return 2**(n + 1) - 1\n\ndef calc(n, x):\n if n == 0:\n return 1\n if x <= n:\n return 0\n if x == burger_size(n):\n return num_of_patty(n)\n \n center = math.floor((burger_size(n) + 1) / 2)\n if x < center:\n return calc(n - 1, x - 1)\n elif x > center:\n return num_of_patty(n - 1) + 1 + calc(n - 1, x - burger_size(n - 1) - 2)\n else:\n return num_of_patty(n - 1) + 1\n\nn, x = [int(i) for i in input().split()]\nprint(calc(n, x))']
['Wrong Answer', 'Accepted']
['s293398069', 's783961888']
[3060.0, 3064.0]
[18.0, 19.0]
[506, 565]
p03209
u354126779
2,000
1,048,576
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?
['n,x=map(int,input().split())\n\nbp=[]\nh=[]\nfor i in range(n+1):\n bp.append([2**(i+1)-2,2**(i+1)-1])\n h.append(2**(i+2)-3)\n\n\np=0\nwhile x!=0:\n if n==0:\n p+=1\n x=0\n elif x<=h[n-1]+2:\n x=x-1\n elif x<=2*h[n-1]+2:\n p+=bp[n-1][1]+1\n x=x-h[n-1]-2\n else:\n p+=2*bp[n-1][1]+1\n x=0\n n=n-1\n\nprint(p)', 'n,x=map(int,input().split())\n\nbp=[]\nh=[]\nfor i in range(n+1):\n bp.append([2**(i+1)-2,2**(i+1)-1])\n h.append(2**(i+2)-3)\n\n\np=0\nwhile x!=0:\n if n==0:\n p+=1\n x=0\n elif x<=h[n-1]+1:\n x=x-1\n elif x==h[n-1]+2:\n p+=1\n x=x-2\n elif x<=2*h[n-1]+2:\n p+=bp[n-1][1]+1\n x=x-h[n-1]-2\n else:\n p+=2*bp[n-1][1]+1\n x=0\n n=n-1\n\nprint(p)']
['Wrong Answer', 'Accepted']
['s647319046', 's768854126']
[3064.0, 3064.0]
[17.0, 17.0]
[354, 403]
p03209
u371763408
2,000
1,048,576
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?
['n,x=map(int,input().split())\nX=[0,1,2,3,3]\na=0\nprint\nif n==1:\n print(0)\nif n >1:\n if x %2 ==0:\n tmp=int(x/2**(n-1))\n if tmp>=len(X):\n print((X[tmp-1]+1)*(2**(n-1))-1)\n else:\n print(X[tmp]*(2**(n-1))-1)\n else:\n tmp=int(x/2**(n-1))\n print(X[tmp]*(2**(n-1))+1)', 'n,x=map(int,input().split())\na,p=[1],[1]\nfor i in range(n):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\n\ndef f(n,x):\n if n==0:\n return 0 if x<=0 else 1\n elif x<= 1 + a[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1]+1+f(n-1,x-2-a[n-1])\n\n\nprint(f(n,x))\n']
['Runtime Error', 'Accepted']
['s188679089', 's940571643']
[3064.0, 3064.0]
[17.0, 22.0]
[285, 261]
p03209
u379959788
2,000
1,048,576
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?
['N, X = map(int, input().split())\n\na, p = [1], [0]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))', "N, X = map(int, input().split())\n\ndef burger(n):\n if n == 0:\n return 'P'\n ans = 'B' + burger(n-1) + 'P' + burger(n-1) + 'B'\n return ans\n\nprint(burger(N))\neat = burger(N)[ : X]\nprint(eat)\nprint(eat.count('P'))", 'N, X = map(int, input().split())\n\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s074430270', 's261752962', 's791934938']
[3064.0, 37820.0, 3188.0]
[18.0, 2105.0, 17.0]
[311, 224, 311]
p03209
u382907940
2,000
1,048,576
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?
["using System;\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\n\n class Solver5\n {\n /*\n * \n * https://atcoder.jp/contests/abc115/tasks/abc115_d\n * \n */\n public void Solve5()\n {\n var nx = u.readLongArrayBySplit();\n\t\t\tvar n = nx[0];\n var x = nx[1];\n long ans = 0;\n\n while (true)\n {\n var thk = new long[5]{ 1, (long)Math.Pow(2,n + 1) - 3, 1, (long)Math.Pow(2, n + 1) - 3, 1 };\n var pc = new long[5] { 0, (long)Math.Pow(2, n ) - 1 , 1, (long)Math.Pow(2, n )- 1, 0 };\n for (int i = 0; i < 5; i++)\n {\n if (x > thk[i])\n {\n x -= thk[i];\n ans += pc[i];\n }\n else if (x < thk[i])\n {\n n--;\n break;\n }\n else\n {\n ans += pc[i];\n Console.WriteLine(ans.ToString());\n return;\n }\n }\n\n }\n\n }\n static void Main()\n {\n var solver = new Solver5();\n solver.Solve5();\n }\n }\n static class u\n {\n public static long[] readLongArrayBySplit() { return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); }\n }", 'n,x = map(int,input().split())\n \n\n \nans = 0\nx2 = x\nk=n\nwhile True:\n thk = [1,2**(k+1)-3,1,2**(k+1)-3,1]\n pc = [0,2**k-1,1,2**k-1,0]\n for i in range(5):\n x2-=thk[i]\n if x2<0:\n x2+=thk[i]\n k-=1\n break\n elif x2==0:\n ans+=pc[i]\n print(ans)\n exit()\n else:\n ans+=pc[i]\n']
['Runtime Error', 'Accepted']
['s401389547', 's375051880']
[2940.0, 3064.0]
[17.0, 18.0]
[1503, 376]
p03209
u385825353
2,000
1,048,576
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?
["ri = lambda: map(int, input().split(' '))\nL = [1]\nC = [1]\n\ndef rec(n, x):\n\tif n == 0:\n\t\treturn 1\n\n\tif x == L[n]:\n\t\treturn 2*C[n-1] + 1\n\n\tans = 0\n\tif x >= L[n-1] + 2:\n\t\tans += C[n-1] + 1\n\t\tans += rec(n-1, x-L[n-1]-2)\n\telse:\n\t\tans += rec(n-1, x-1)\n\n\treturn ans\n\nif __name__ == '__main__':\n\tN, X = ri()\n\tfor i in range(1, N+1):\n\t\tL.append(2*L[i-1] + 3)\n\t\tC.append(2*C[i-1] + 1)\n\tans = rec(N, X)\n\tprint(ans)\n\n", "ri = lambda: map(int, input().split(' '))\nL = [1]\nC = [1]\n\ndef rec(n, x):\n\tif x == 0:\n\t\treturn 0\n\n\tif n == 0:\n\t\treturn 1\n\n\tif x == L[n]:\n\t\treturn 2*C[n-1] + 1\n\n\tans = 0\n\tif x >= L[n-1] + 2:\n\t\tans += C[n-1] + 1\n\t\tans += rec(n-1, x-L[n-1]-2)\n\telse:\n\t\tans += rec(n-1, x-1)\n\n\treturn ans\n\nif __name__ == '__main__':\n\tN, X = ri()\n\tfor i in range(1, N+1):\n\t\tL.append(2*L[i-1] + 3)\n\t\tC.append(2*C[i-1] + 1)\n\tans = rec(N, X)\n\tprint(ans)\n\n"]
['Wrong Answer', 'Accepted']
['s831258212', 's014114920']
[3064.0, 3064.0]
[17.0, 19.0]
[405, 429]
p03209
u398000383
2,000
1,048,576
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?
['#!/usr/env/python3\nN, X = map(int, input().split())\n\na, p = [1], [1]\nfor i in range(N):\n\ta.append(a[i] * 2 + 3)\n\tp.append(p[i] * 2 + 1)\n\ndef f(N, X):\n\tif N == 0:\n\t\treturn 0 if X == 0 else 1\n\telif X <= 1 + a[N-1]:\n\t\treturn f(N-1, X-1)\n\telse:\n\t\treturn p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))\n', '#!/usr/env/python3\nN, X = map(int, input().split())\n\na, p = [1], [1]\nfor i in range(N):\n\ta.append(a[i] * 2 + 3)\n\tp.append(p[i] * 2 + 1)\n\ndef f(N, X):\n\tif N == 0:\n\t\t#return 0 if X == 0 else 1\n\t\treturn 0 if X <= 0 else 1\n\telif X <= 1 + a[N-1]:\n\t\treturn f(N-1, X-1)\n\telse:\n\t\treturn p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))\n']
['Wrong Answer', 'Accepted']
['s446428850', 's147988315']
[3064.0, 3064.0]
[18.0, 18.0]
[298, 327]
p03209
u398846051
2,000
1,048,576
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?
['N, X = map(int, input().split())\npat = [0 for _ in range(N+1)]\nmai = [0 for _ in range(N+1)]\npat[1] = 1\nmai[1] = 1\nfor i in range(2, N+1):\n mai[i] = 2 * mai[i-1] + 3\n pat[i] = 2 * pat[i-1] + 1\n\ndef cnt_pat(x, n):\n if n == 1:\n return 1\n if x == 1:\n return 0\n if x <= mai[n] // 2:\n return cnt_pat(x-1, n-1)\n if x == mai[n] // 2 + 1:\n return pat[n-1] + 1\n if x < mai[n]:\n return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)\n if x == n:\n return pat[n]\n \nprint(cnt_pat(X, N))', 'N, X = map(int, input().split())\npat = [1 for _ in range(N)]\nmai = [1 for _ in range(N)]\nfor i in range(1, N+1):\n mai[i] = 2 * mai[i-1] + 3\n pat[i] = 2 * pat[i-1] + 1\n\ndef cnt_pat(x, n):\n if n == 0:\n return 1\n if x == 1:\n return 0\n if x <= mai[n] // 2:\n return cnt_pat(x-1, n-1)\n if x == mai[n] // 2 + 1:\n return pat[n-1] + 1\n if x < mai[n]:\n return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)\n if x == n:\n return pat[n]\n \nprint(cnt_pat(X, N))', 'N, X = map(int, input().split())\npat = [1 for _ in range(N+1)]\nmai = [1 for _ in range(N+1)]\nfor i in range(1, N+1):\n mai[i] = 2 * mai[i-1] + 3\n pat[i] = 2 * pat[i-1] + 1\n\ndef cnt_pat(x, n):\n if n == 0:\n return 1\n if x == 1:\n return 0\n if x <= mai[n] // 2:\n return cnt_pat(x-1, n-1)\n if x == mai[n] // 2 + 1:\n return pat[n-1] + 1\n if x < mai[n]:\n return pat[n-1] + 1 + cnt_pat(x-mai[n]//2-1, n-1)\n if x == mai[n]:\n return pat[n]\n \nprint(cnt_pat(X, N))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s791840885', 's800415103', 's765527190']
[3112.0, 3064.0, 3064.0]
[20.0, 18.0, 19.0]
[495, 469, 478]
p03209
u405256066
2,000
1,048,576
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?
['from sys import stdin\nN,X=[int(x) for x in stdin.readline().rstrip().split()]\nburger_set=["P"]\nfor i in range(N):\n new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"\n burger_set.append(new_burger)\n del burger_set[0]\nprint(burger_set[0].count(\'P\'))', 'from sys import stdin\nimport numpy as np\nN,X=[int(x) for x in stdin.readline().rstrip().split()]\nburger_set=np.array(["P"])\nfor i in range(N):\n new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"\n burger_set[0]=(new_burger)\nans=burger_set[0][0][0:X].count(\'P\')\nprint(ans)', 'from sys import stdin\nimport numpy as np\nN,X=[int(x) for x in stdin.readline().rstrip().split()]\nburger_set=np.array(["P"])\nfor i in range(N):\n new_burger="B"+burger_set[0]+"P"+burger_set[0]+"B"\n burger_set[0]=(new_burger)\nans=burger_set[0][0:X].count(\'P\')\nprint(ans)', 'from sys import stdin\nN, X = [int(x) for x in stdin.readline().rstrip().split()]\n\nheights = [1]\nputties = [1]\nfor _ in range(N):\n heights.append(heights[-1] * 2 + 3)\n putties.append(putties[-1] * 2 + 1)\n\n\ndef solve(n, x):\n if n == 0 and x == 1:\n return 1\n elif x == 1:\n return 0\n elif 1 < x <= 1+heights[n-1]:\n return solve(n-1, x-1)\n elif x == 2+heights[n-1]:\n return 1+putties[n-1]\n elif 2+heights[n-1] < x <= 2+2*heights[n-1]:\n return putties[n-1]+1+solve(n-1,x-2-heights[n-1]) \n elif x == 3+2*heights[n-1]:\n return 2*putties[n-1]+1\nprint(solve(N, X))']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s291266930', 's628166541', 's779487773', 's160308475']
[2940.0, 13732.0, 21556.0, 3064.0]
[1773.0, 150.0, 379.0, 17.0]
[256, 276, 273, 620]
p03209
u405660020
2,000
1,048,576
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?
['n,x=map(int,input().split())\n\na=[1]\np=[1]\n\nfor i in range(n):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\n\ndef bur(n,x):\n if n==0:\n if x==0:\n return 0\n else:\n return 1\n elif 1<=x<=(1+a[n-1]):\n return bur(n-1,x-1)\n # elif x==2+a[n-1]:\n # return p[n-1]+1\n # elif (2+a[n-1])<=x<=2+2*a[n-1]:\n # return p[n-1]+1+bur(n-1,x-2-a[n-1])\n else:\n return p[n-1]+1+bur(n-1,x-2-a[n-1])\n # else:\n # return 2*p[n-1]+1\n\nprint(bur(n,x))\n', 'n,x=map(int,input().split())\n\na=[1]\np=[1]\nfor i in range(n):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\n\ndef f(n,x):\n if x==0:\n return 0\n elif x==1:\n if n==0:\n return 1\n else:\n return 0\n\n elif 1<x<=(1+a[n-1]):\n return f(n-1,x-1)\n\n elif x==2+a[n-1]:\n return p[n-1]+1\n\n elif (2+a[n-1])<=x<=2+2*a[n-1]:\n return p[n-1]+1+f(n-1,x-2-a[n-1])\n\n else:\n return 2*p[n-1]+1\n\nprint(f(n,x))']
['Wrong Answer', 'Accepted']
['s124967697', 's303997467']
[3064.0, 3064.0]
[17.0, 17.0]
[509, 468]
p03209
u412151982
2,000
1,048,576
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?
['def cal(N, i):\n if N > 0:\n return 2 * cal(N - 1, i) + i\n elif N == 0:\n return 1\n else:\n return 0\n\ndef pCal(N ,X):\n total = cal(N, 3)\n half = total // 2\n pTmp = cal(N - 1, 1)\n if X == 1 and N == 0:\n return 1\n elif X <= N:\n return 0\n elif X < half:\n return pCal(N - 1, X - 1)\n elif X == half:\n return pTmp\n elif X == half + 1:\n return pTmp + 1\n elif total > X > half + 1:\n return (pTmp + 1) + pCal(N - 1, X - (half + 1))\n else x == total\n return cal(N, 1)\nN, X = list(map(int, input().split()))\nprint(pCal(N, X))', 'def cal(N, i):\n if N > 0:\n return 2 * cal(N - 1, i) + i\n elif N == 0:\n return 1\n else:\n return 0\n\ndef pCal(N ,X):\n total = cal(N, 3)\n half = total // 2\n pTmp = cal(N - 1, 1)\n if X == 1 and N == 0:\n return 1\n elif X <= N:\n return 0\n elif X < half:\n return pCal(N - 1, X - 1)\n elif X == half:\n return pTmp\n elif X == half + 1:\n return pTmp + 1\n elif total > X > half + 1:\n return (pTmp + 1) + pCal(N - 1, X - (half + 1))\n elif X == total:\n return cal(N, 1)\nN, X = list(map(int, input().split()))\nprint(pCal(N, X))']
['Runtime Error', 'Accepted']
['s899593989', 's639905526']
[3064.0, 3064.0]
[18.0, 18.0]
[619, 620]
p03209
u426501657
2,000
1,048,576
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?
['import sys\nsys.setrecursionlimit(1000000)\nN,X = map(int,input().split())\ndef n_barg_hight(n):\n\tif(n == 0):\n\t\treturn 1\n\n\tL1barg_height = n_barg_hight(n-1)\n\tLbarg_height = 1 + L1barg_height + 1 + L1barg_height + 1\n\treturn Lbarg_height\n\ndef n_barg_pat(n):\n\tif(n == 0):\n\t\treturn 1\n\tL1barg_pat = n_barg_pat(n-1)\n\tLbarg_pat = 1 + L1barg_pat*2\n\treturn Lbarg_pat\n\n\ndef answer(N,X):\n\tprint(N,X)\n\tif(X == 1):\n\t\treturn 0\n\t\n\telif(X == n_barg_hight(N)):\n\t\treturn n_barg_pat(N)\n\n\telif(X == n_barg_hight(N)//2 + 1):\n\t\treturn n_barg_pat(N-1)+1\n\n\telif(X <= n_barg_hight(N)//2):\n\t\treturn answer(N-1,X-1)\n\n\telif(X > n_barg_hight(N)//2 + 1):\n\t\tLbarg = n_barg_pat(N-1) + answer(N-1,X-n_barg_hight(N-1)-2) +1\n\t\treturn Lbarg\n\n\nprint(answer(N,X))', 'import sys\nsys.setrecursionlimit(10000000)\nN,X = map(int,input().split())\ndef n_barg_hight(n):\n\tif(n == 0):\n\t\treturn 1\n\n\tL1barg_height = n_barg_hight(n-1)\n\tLbarg_height = 1 + L1barg_height + 1 + L1barg_height + 1\n\treturn Lbarg_height\n\ndef n_barg_pat(n):\n\tif(n == 0):\n\t\treturn 1\n\tL1barg_pat = n_barg_pat(n-1)\n\tLbarg_pat = 1 + L1barg_pat*2\n\treturn Lbarg_pat\n\n\ndef answer(N,X):\n\n\tif(X == 1):\n\t\tif(N == 0):\n\t\t\treturn 1\n\t\telse:\n\t\t\treturn 0\n\t\n\telif(X == n_barg_hight(N)):\n\t\treturn n_barg_pat(N)\n\n\telif(X == n_barg_hight(N)//2 + 1):\n\t\treturn n_barg_pat(N-1)+1\n\n\telif(X <= n_barg_hight(N)//2):\n\t\treturn answer(N-1,X-1)\n\n\telif(X > n_barg_hight(N)//2 + 1):\n\t\tLbarg = n_barg_pat(N-1) + answer(N-1,X-n_barg_hight(N-1)-2) +1\n\t\treturn Lbarg\n\n\nprint(answer(N,X))']
['Wrong Answer', 'Accepted']
['s482957337', 's948439525']
[3064.0, 3064.0]
[19.0, 18.0]
[722, 747]
p03209
u426572476
2,000
1,048,576
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?
["import sys\nimport heapq\nimport re\nfrom itertools import permutations\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, deque\nfrom fractions import gcd\nfrom math import factorial, sqrt, ceil\nfrom functools import lru_cache, reduce\nINF = 1 << 60\nMOD = 1000000007\nsys.setrecursionlimit(10 ** 7)\n\n# UnionFind\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\ndef is_prime(n):\n if n == 1:\n return False\n for i in range(2,int(n**0.5)+1):\n if n % i == 0:\n return False\n return True\n\n\n\n\ndef warshall_floyd(d, n):\n \n for k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\n\n\ndef dijkstra_heap(s, edge, n):\n \n d = [10**20] * n\n used = [True] * n \n d[s] = 0\n used[s] = False\n edgelist = []\n for a,b in edge[s]:\n heapq.heappush(edgelist,a*(10**6)+b)\n while len(edgelist):\n minedge = heapq.heappop(edgelist)\n \n if not used[minedge%(10**6)]:\n continue\n v = minedge%(10**6)\n d[v] = minedge//(10**6)\n used[v] = False\n for e in edge[v]:\n if used[e[1]]:\n heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])\n return d\n\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\ndef lcm_list(numbers):\n return reduce(lcm, numbers, 1)\n\n\ndef gcd_list(numbers):\n return reduce(gcd, numbers)\n\n\n\n\n\n\ndef eratosthenes(limit):\n A = [i for i in range(2, limit+1)]\n P = []\n\n while True:\n prime = min(A)\n \n if prime > sqrt(limit):\n break\n \n P.append(prime)\n \n i = 0\n while i < len(A):\n if A[i] % prime == 0:\n A.pop(i)\n continue\n i += 1\n \n for a in A:\n P.append(a)\n \n return P\n\n\ndef permutation_with_duplicates(L):\n\n if L == []:\n return [[]]\n\n else:\n ret = []\n\n \n S = sorted(set(L))\n\n for i in S:\n\n data = L[:]\n data.remove(i)\n\n for j in permutation_with_duplicates(data):\n ret.append([i] + j)\n\n return ret\n\n\n\nn, x = map(int, input().split())\na = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n a[i] = 1\n else:\n a[i] = a[i - 1] * 2 + 3\np = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n p[i] = 1\n else:\n p[i] = p[i - 1] * 2 + 1\n\ndef func(n, x):\n if x == 0:\n return 0\n if n == 0:\n return 1 \n if x < a[n - 1] + 1:\n return func(n - 1, x - 1)\n if x == a[n - 1] + 1:\n return 1 + func(n - 1, x - 1)\n return p[n - 1] + 1 + func(n - 1, x - a[n - 1] - 2) \nprint(func(n, x))", 'N, X = map(int, input().split())\n2\n3 a, p = [1], [1]\n4 for i in range(N):\n5 a.append(a[i] * 2 + 3)\n6 p.append(p[i] * 2 + 1)\n7\n8 def f(N, X): \n9 if N == 0:\n10 return 0 if X <= 0 else 1\n11 elif X <= 1 + a[N-1]:\n12 return f(N-1, X-1)\n13 else:\n14 return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n15\n16 print(f(N, X))\n', 'N, X = map(int, input().split())\n\na, p = [1], [1]\nfor i in range(N):\na.append(a[i] * 2 + 3)\np.append(p[i] * 2 + 1)\n\ndef f(N, X): \n\tif N == 0:\n \t\treturn 0 if X <= 0 else 1\n\telif X <= 1 + a[N-1]:\n \treturn f(N-1, X-1)\n\telse:\n \t\treturn p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))\n', "import sys\nimport heapq\nimport re\nfrom itertools import permutations\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, deque\nfrom fractions import gcd\nfrom math import factorial, sqrt, ceil\nfrom functools import lru_cache, reduce\nINF = 1 << 60\nMOD = 1000000007\nsys.setrecursionlimit(10 ** 7)\n\n# UnionFind\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\ndef is_prime(n):\n if n == 1:\n return False\n for i in range(2,int(n**0.5)+1):\n if n % i == 0:\n return False\n return True\n\n\n\n\ndef warshall_floyd(d, n):\n \n for k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\n\n\ndef dijkstra_heap(s, edge, n):\n \n d = [10**20] * n\n used = [True] * n \n d[s] = 0\n used[s] = False\n edgelist = []\n for a,b in edge[s]:\n heapq.heappush(edgelist,a*(10**6)+b)\n while len(edgelist):\n minedge = heapq.heappop(edgelist)\n \n if not used[minedge%(10**6)]:\n continue\n v = minedge%(10**6)\n d[v] = minedge//(10**6)\n used[v] = False\n for e in edge[v]:\n if used[e[1]]:\n heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])\n return d\n\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\ndef lcm_list(numbers):\n return reduce(lcm, numbers, 1)\n\n\ndef gcd_list(numbers):\n return reduce(gcd, numbers)\n\n\n\n\n\n\ndef eratosthenes(limit):\n A = [i for i in range(2, limit+1)]\n P = []\n\n while True:\n prime = min(A)\n \n if prime > sqrt(limit):\n break\n \n P.append(prime)\n \n i = 0\n while i < len(A):\n if A[i] % prime == 0:\n A.pop(i)\n continue\n i += 1\n \n for a in A:\n P.append(a)\n \n return P\n\n\ndef permutation_with_duplicates(L):\n\n if L == []:\n return [[]]\n\n else:\n ret = []\n\n \n S = sorted(set(L))\n\n for i in S:\n\n data = L[:]\n data.remove(i)\n\n for j in permutation_with_duplicates(data):\n ret.append([i] + j)\n\n return ret\n\n\n\nn, x = map(int, input().split())\na = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n a[i] = 1\n else:\n a[i] = a[i - 1] * 2 + 3\np = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n p[i] = 1\n else:\n p[i] = p[i - 1] * 2 + 1\n\ndef func(n, x):\n if x == 0:\n return 0\n if n == 0:\n return 1 \n if x < a[n - 1] + 1:\n return func(n - 1, x - 1)\n if x == a[n - 1] + 1:\n return 1 + p[n - 1]\n return p[n - 1] + 1 + func(n - 1, x - a[n - 1] - 2) \nprint(func(n, x))", "import sys\nimport heapq\nimport re\nfrom itertools import permutations\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, deque\nfrom fractions import gcd\nfrom math import factorial, sqrt, ceil\nfrom functools import lru_cache, reduce\nINF = 1 << 60\nMOD = 1000000007\nsys.setrecursionlimit(10 ** 7)\n\n# UnionFind\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\ndef is_prime(n):\n if n == 1:\n return False\n for i in range(2,int(n**0.5)+1):\n if n % i == 0:\n return False\n return True\n\n\n\n\ndef warshall_floyd(d, n):\n \n for k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\n\n\ndef dijkstra_heap(s, edge, n):\n \n d = [10**20] * n\n used = [True] * n \n d[s] = 0\n used[s] = False\n edgelist = []\n for a,b in edge[s]:\n heapq.heappush(edgelist,a*(10**6)+b)\n while len(edgelist):\n minedge = heapq.heappop(edgelist)\n \n if not used[minedge%(10**6)]:\n continue\n v = minedge%(10**6)\n d[v] = minedge//(10**6)\n used[v] = False\n for e in edge[v]:\n if used[e[1]]:\n heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])\n return d\n\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\ndef lcm_list(numbers):\n return reduce(lcm, numbers, 1)\n\n\ndef gcd_list(numbers):\n return reduce(gcd, numbers)\n\n\n\n\n\n\ndef eratosthenes(limit):\n A = [i for i in range(2, limit+1)]\n P = []\n\n while True:\n prime = min(A)\n \n if prime > sqrt(limit):\n break\n \n P.append(prime)\n \n i = 0\n while i < len(A):\n if A[i] % prime == 0:\n A.pop(i)\n continue\n i += 1\n \n for a in A:\n P.append(a)\n \n return P\n\n\ndef permutation_with_duplicates(L):\n\n if L == []:\n return [[]]\n\n else:\n ret = []\n\n \n S = sorted(set(L))\n\n for i in S:\n\n data = L[:]\n data.remove(i)\n\n for j in permutation_with_duplicates(data):\n ret.append([i] + j)\n\n return ret\n\n\n\nn, x = map(int, input().split())\na = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n a[i] = 1\n else:\n a[i] = a[i - 1] * 2 + 3\np = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n p[i] = 1\n else:\n p[i] = p[i - 1] * 2 + 1\n\ndef func(n, x):\n if n == 0:\n return 1 \n if x == 0:\n return 0\n if x < a[n - 1]:\n return func(n - 1, x - 1)\n if x == a[n - 1]:\n return p[n - 1]\n if x == a[n - 1] + 1:\n return 1 + p[n - 1]\n return p[n - 1] + 1 + func(n - 1, x - a[n - 1] - 2) \nprint(func(n, x))", "import sys\nimport heapq\nimport re\nfrom itertools import permutations\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, deque\nfrom fractions import gcd\nfrom math import factorial, sqrt, ceil\nfrom functools import lru_cache, reduce\nINF = 1 << 60\nMOD = 1000000007\nsys.setrecursionlimit(10 ** 7)\n\n# UnionFind\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\ndef is_prime(n):\n if n == 1:\n return False\n for i in range(2,int(n**0.5)+1):\n if n % i == 0:\n return False\n return True\n\n\n\n\ndef warshall_floyd(d, n):\n \n for k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\n\n\ndef dijkstra_heap(s, edge, n):\n \n d = [10**20] * n\n used = [True] * n \n d[s] = 0\n used[s] = False\n edgelist = []\n for a,b in edge[s]:\n heapq.heappush(edgelist,a*(10**6)+b)\n while len(edgelist):\n minedge = heapq.heappop(edgelist)\n \n if not used[minedge%(10**6)]:\n continue\n v = minedge%(10**6)\n d[v] = minedge//(10**6)\n used[v] = False\n for e in edge[v]:\n if used[e[1]]:\n heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])\n return d\n\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\ndef lcm_list(numbers):\n return reduce(lcm, numbers, 1)\n\n\ndef gcd_list(numbers):\n return reduce(gcd, numbers)\n\n\n\n\n\n\ndef eratosthenes(limit):\n A = [i for i in range(2, limit+1)]\n P = []\n\n while True:\n prime = min(A)\n \n if prime > sqrt(limit):\n break\n \n P.append(prime)\n \n i = 0\n while i < len(A):\n if A[i] % prime == 0:\n A.pop(i)\n continue\n i += 1\n \n for a in A:\n P.append(a)\n \n return P\n\n\ndef permutation_with_duplicates(L):\n\n if L == []:\n return [[]]\n\n else:\n ret = []\n\n \n S = sorted(set(L))\n\n for i in S:\n\n data = L[:]\n data.remove(i)\n\n for j in permutation_with_duplicates(data):\n ret.append([i] + j)\n\n return ret\n\n\n\nn, x = map(int, input().split())\na = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n a[i] = 1\n else:\n a[i] = a[i - 1] * 2 + 3\np = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n p[i] = 1\n else:\n p[i] = p[i - 1] * 2 + 1\n\ndef func(n, x):\n if x == 0:\n return 0\n if n == 0:\n return 1 \n if x < a[n - 1]:\n return func(n - 1, x - 1)\n if x == a[n - 1]:\n return p[n - 1]\n if x == a[n - 1] + 1:\n return 1 + p[n - 1]\n return p[n - 1] + 1 + func(n - 1, x - a[n - 1] - 2) \nprint(func(n, x))", "import sys\nimport heapq\nimport re\nfrom itertools import permutations\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, deque\nfrom fractions import gcd\nfrom math import factorial, sqrt, ceil\nfrom functools import lru_cache, reduce\nINF = 1 << 60\nMOD = 1000000007\nsys.setrecursionlimit(10 ** 7)\n\n# UnionFind\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\ndef is_prime(n):\n if n == 1:\n return False\n for i in range(2,int(n**0.5)+1):\n if n % i == 0:\n return False\n return True\n\n\n\n\ndef warshall_floyd(d, n):\n \n for k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\n\n\ndef dijkstra_heap(s, edge, n):\n \n d = [10**20] * n\n used = [True] * n \n d[s] = 0\n used[s] = False\n edgelist = []\n for a,b in edge[s]:\n heapq.heappush(edgelist,a*(10**6)+b)\n while len(edgelist):\n minedge = heapq.heappop(edgelist)\n \n if not used[minedge%(10**6)]:\n continue\n v = minedge%(10**6)\n d[v] = minedge//(10**6)\n used[v] = False\n for e in edge[v]:\n if used[e[1]]:\n heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])\n return d\n\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\ndef lcm_list(numbers):\n return reduce(lcm, numbers, 1)\n\n\ndef gcd_list(numbers):\n return reduce(gcd, numbers)\n\n\n\n\n\n\ndef eratosthenes(limit):\n A = [i for i in range(2, limit+1)]\n P = []\n\n while True:\n prime = min(A)\n \n if prime > sqrt(limit):\n break\n \n P.append(prime)\n \n i = 0\n while i < len(A):\n if A[i] % prime == 0:\n A.pop(i)\n continue\n i += 1\n \n for a in A:\n P.append(a)\n \n return P\n\n\ndef permutation_with_duplicates(L):\n\n if L == []:\n return [[]]\n\n else:\n ret = []\n\n \n S = sorted(set(L))\n\n for i in S:\n\n data = L[:]\n data.remove(i)\n\n for j in permutation_with_duplicates(data):\n ret.append([i] + j)\n\n return ret\n\n\n\nn, x = map(int, input().split())\na = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n a[i] = 1\n else:\n a[i] = a[i - 1] * 2 + 3\np = [0 for i in range(n + 1)]\nfor i in range(n + 1):\n if i == 0:\n p[i] = 1\n else:\n p[i] = p[i - 1] * 2 + 1\n\ndef func(n, x):\n if x == 0:\n return 0\n if n == 0:\n return 1\n if x < a[n - 1] + 1:\n return func(n - 1, x - 1)\n x -= a[n - 1] + 2\n return 1 + p[n - 1] + func(n - 1, x) \n\nprint(func(n, x))", 'n, x = map(int, input().split())\nans = 0\n \nhambargers = [1]\npatties = [1]\n \nfor i in range(1, n+1):\n num = hambargers[i-1] * 2 + 3\n patty_num = patties[i-1] * 2 + 1\n hambargers.append(num)\n patties.append(patty_num)\n \ndef cal(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + hambargers[N-1]:\n return cal(N-1, X-1)\n else:\n return patties[N-1] + 1 + cal(N-1, X-2-hambargers[N-1])\n \nprint(cal(n, x))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s167543795', 's253460917', 's426245636', 's465180496', 's718923758', 's755669473', 's827434812', 's996841411']
[5160.0, 2940.0, 2940.0, 5160.0, 5308.0, 5180.0, 5544.0, 3064.0]
[39.0, 17.0, 17.0, 37.0, 41.0, 39.0, 50.0, 17.0]
[4821, 363, 344, 4811, 4853, 4853, 4761, 450]
p03209
u427344224
2,000
1,048,576
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?
['n, x = map(int, input().split())\n\nsum_p = [0 for i in range(n + 1)]\nsum_dim = [0 for i in range(n + 1)]\nsum_p[0] = 1\nsum_dim[0] = 1\n\nfor i in range(1, n + 1):\n sum_p[i] = sum_p[i - 1] * 2 + 1\n sum_dim[i] = sum_dim[i - 1] * 2 + 3\n\n\ndef cal(n, rem):\n if n == 0:\n return 1 if rem == 1 else 0\n elif rem <= 1 + sum_dim[n]:\n return cal(n - 1, rem - 1)\n else:\n return sum_p[n] + 1 + cal(n - 1, rem - 2 - sum_dim[n])\n\n\nprint(cal(n, x))\n', 'n, x = map(int, input().split())\n\nsum_p = [1]\nsum_dim = [1]\n\nfor i in range(n):\n sum_p.append(sum_p[i] * 2 + 1)\n sum_dim.append(sum_dim[i] * 2 + 3)\n\n\ndef cal(n, rem):\n if n == 0:\n return 0 if rem<= 0 else 1\n elif rem <= 1 + sum_dim[n-1]:\n return cal(n - 1, rem - 1)\n else:\n return sum_p[n-1] + 1 + cal(n - 1, rem - 2 - sum_dim[n-1])\n\n\nprint(cal(n, x))\n']
['Wrong Answer', 'Accepted']
['s234083303', 's454764377']
[3064.0, 3064.0]
[19.0, 18.0]
[464, 388]
p03209
u449863068
2,000
1,048,576
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?
['import itertools\nfrom collections import deque\nN, X = map(int, input().split())\n\nd = deque()\ncurrent = "P"\n\nfor _ in range(1, N+1):\n d.appendleft("B")\n d.extend(current)\n d.append("P")\n d.extend(current)\n d.append("B")\n current = d\n\nprint(l.count("P"))\n', 'N, X = map(int, input().split())\n\nlayer_size = [1]\nP_cnt = [1]\n\nfor _ in range(50):\n "[-1]は末尾の要素を取得。layer_sizeで、合計"\n layer_size.append(layer_size[-1]*2+3)\n\n "[-1]は末尾の要素を取得。P_cntはパティの枚数\n P_cnt.append(P_cnt[-1]*2+1)\n\n\ndef solve(level, x):\n if x == 1:\n return 0 if level > 0 else 1\n l = layer_size[level-1]\n p = P_cnt[level-1]\n if x <= 1+l:\n return solve(level-1, x-1)\n elif x == l+2:\n return p+1\n elif x <= 2*l+2:\n return p+1+solve(level-1, x-l-2)\n else:\n return 2*p+1\n \nans = solve(N, X)\nprint(ans)', 'N, X = map(int, input().split())\n\nlayer_size = [1]\nP_cnt = [1]\n\nfor _ in range(50):\n "[-1]は末尾の要素を取得。layer_sizeで、合計"\n layer_size.append(layer_size[-1]*2+3)\n\n "[-1]は末尾の要素を取得。P_cntはパティの枚数\n P_cnt.append(P_cnt[-1]*2+1)\n\nprint(layer_size)\nprint(P_cnt)\n\ndef solve(level, x):\n if x == 1:\n return 0 if level > 0 else 1\n l = layer_size[level-1]\n p = P_cnt[level-1]\n if x <= 1+l:\n return solve(level-1, x-1)\n elif x == l+2:\n return p+1\n elif x <= 2*l+2:\n return p+1+solve(level-1, x-l-2)\n else:\n return 2*p+1\n \nans = solve(N, X)\nprint(ans)', 'N, X = map(int, input().split())\n\nlayer_size = [1]\nP_cnt = [1]\n\nfor _ in range(50):\n \n layer_size.append(layer_size[-1]*2+3)\n\n \n P_cnt.append(P_cnt[-1]*2+1)\n\n\ndef solve(level, x):\n if x == 1:\n return 0 if level > 0 else 1\n l = layer_size[level-1]\n p = P_cnt[level-1]\n if x <= 1+l:\n return solve(level-1, x-1)\n elif x == l+2:\n return p+1\n elif x <= 2*l+2:\n return p+1+solve(level-1, x-l-2)\n else:\n return 2*p+1\n \nans = solve(N, X)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s092870525', 's425934350', 's995224403', 's600182353']
[1509000.0, 3064.0, 2940.0, 3064.0]
[2175.0, 17.0, 17.0, 17.0]
[259, 586, 617, 585]
p03209
u470101103
2,000
1,048,576
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?
["n_x = input()\nn_x_list =n_x.split(' ')\n\nN = int(n_x_list[0])\nX = int(n_x_list[1])\n\n# g_list = [''] * N\n\n# if N == 0:\n# return 'p'\n#\n# gn_1 = G(N-1)\n#\n# return 'b' + gn_1 + 'p' + gn_1 + 'b'\n\n# g_n = G(N)\n# print(g_n)\n# eaten_burger = g_n[0:X]\n\n# ans = eaten_burger.count('p')\n# print(ans)\n\ndef L(N):\n return 2 ** (N+2) - 3\n\ndef P(N):\n return 2 ** (N+1) - 1\n\ndef solve(N, X):\n half_l = int(P(N) / 2)\n if N == 0:\n return 1\n\n if half_l > X:\n return solve(N - 1, X - 1)\n elif half_l == X:\n return P(N-1)\n elif half_l + 1 == X:\n return P(N-1) + 1\n elif half_l + 1 < X:\n return P(N-1) + 1 + solve(N-1, (X - L(N-1) - 2))\n elif half_l * 2 + 1 == X:\n return 2 * P(N-1) + 1\n\n\nans = solve(N, X)\nprint(ans)\n", "n_x = input()\nn_x_list =n_x.split(' ')\n\nN = int(n_x_list[0])\nX = int(n_x_list[1])\n\n# g_list = [''] * N\n\n# if N == 0:\n# return 'p'\n#\n# gn_1 = G(N-1)\n#\n# return 'b' + gn_1 + 'p' + gn_1 + 'b'\n\n# g_n = G(N)\n# print(g_n)\n# eaten_burger = g_n[0:X]\n\n# ans = eaten_burger.count('p')\n# print(ans)\n\ndef L(N):\n return 2 ** (N+2) - 3\n\ndef P(N):\n return 2 ** (N+1) - 1\n\ndef solve(N, X):\n half_l = int(L(N) / 2)\n if N == 0 and X >= 1:\n return 1\n elif N == 0 and X == 0:\n return 0\n\n if half_l <= 1:\n return 0\n elif X < half_l:\n return solve(N - 1, X - 1)\n elif X == half_l:\n return P(N-1)\n elif X == half_l + 1:\n return P(N-1) + 1\n elif half_l + 1 < X:\n return P(N-1) + 1 + solve(N-1, (X - L(N-1) - 2))\n elif half_l * 2 + 3 == X:\n return 2 * P(N-1) + 1\n\n\nans = solve(N, X)\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s978480016', 's051649626']
[3188.0, 3064.0]
[18.0, 17.0]
[815, 909]
p03209
u472065247
2,000
1,048,576
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?
['n, x = map(int, input().split())\n\na, p = [1], [1]\n\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X):\n if N == 0:\n if X == 0:\n return 0\n else:\n return 1 \n elif X <= 1 + a[N - 1]:\n return f(N - 1, X - 1)\n else:\n return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])\n\nprint(f(n, x))', 'n, x = map(int, input().split())\n\na, p = [1], [1]\n\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X):\n if N == 0:\n if X <= 0:\n return 0\n else:\n return 1 \n elif X <= 1 + a[N - 1]:\n return f(N - 1, X - 1)\n else:\n return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])\n\nprint(f(n, x))']
['Wrong Answer', 'Accepted']
['s574470504', 's631339813']
[3064.0, 3064.0]
[18.0, 17.0]
[333, 333]
p03209
u476604182
2,000
1,048,576
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?
[' N, X = map(int, input().split())\n2\n3 a, p = [1], [1]\n4 for i in range(N):\n5 a.append(a[i] * 2 + 3)\n6 p.append(p[i] * 2 + 1)\n7\n8 def f(N, X): \n9 if N == 0:\n10 return 0 if X <= 0 else 1\n11 elif X <= 1 + a[N-1]:\n12 return f(N-1, X-1)\n13 else:\n14 return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n15\n16 print(f(N, X))\n', 'N, X = map(int, input().split())\n\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X): \n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))\n\n']
['Runtime Error', 'Accepted']
['s078548527', 's847745041']
[2940.0, 3064.0]
[17.0, 17.0]
[364, 352]
p03209
u480472958
2,000
1,048,576
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?
['N, X = map(int, input().split())\n\nburgersize, pnum = [1], [1]\nfor i in range(N):\n burgersize.append(burgersize[-1] * 2 + 3)\n pnum.append(pnum[-1] * 2 + 1)\n\ndef count_p(level, X):\n if level == 0:\n return 1\n # elif X == burgersize[level]:\n # return pnum[level]\n elif X == 1:\n return 0\n elif X < (burgersize[level] - 1) // 2:\n return count_p(level - 1, X - 1)\n elif X == (burgersize[level] - 1) // 2:\n return count_p(level - 1, X - 1) + 1\n elif X > (burgersize[level] - 1) // 2:\n return pnum[level - 1] + 1 + count_p(level - 1, X - (burgersize[level] - 1) // 2 - 1)\n\n return None\n\nans = count_p(N, X)\nprint(ans)', 'N, X = map(int, input().split())\n\nburgersize, pnum = [1], [1]\nfor i in range(N):\n burgersize.append(burgersize[-1] * 2 + 3)\n pnum.append(pnum[-1] * 2 + 1)\n\ndef count_p(level, X):\n if X == 0:\n return 0\n if X == burgersize[level]:\n return pnum[level]\n if level == 0:\n return 1\n Xmid = (burgersize[level] - 1) // 2 + 1\n if X < Xmid:\n return count_p(level - 1, X - 1)\n else:\n return pnum[level - 1] + 1 + count_p(level - 1, X - Xmid)\n\nprint(count_p(N, X))']
['Wrong Answer', 'Accepted']
['s693234904', 's348628600']
[3064.0, 3064.0]
[17.0, 17.0]
[677, 510]
p03209
u492605584
2,000
1,048,576
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?
["level,eat = map(int, input().split())\nburger = 'BPPPB'\nfor i in range(1, level):\n burger = 'B' + burger + 'P' + burger + 'B'\nprint(burger)\ncount=0\neat -=1\nfor i in range(len(burger)):\n if i > eat:\n break\n if burger[i] == 'P':\n count+=1\nprint(count)", 'def f(N, X):\n if N == 0:\n if X >= 1:\n return 1\n return 0\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-a[N-1] - 2)\n\nN, X = map(int, input().split(" "))\na = [1]\np = [1]\nfor i in range(N):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\n\nprint(f(N,X))']
['Runtime Error', 'Accepted']
['s884224367', 's763614664']
[3060.0, 3064.0]
[1787.0, 18.0]
[257, 297]
p03209
u498620941
2,000
1,048,576
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?
['N, X = map(int,input().split())\n\na = [1] \np = [1] \nfor i in range(N):\n a.append(2*a[i]+3)\n p.append(2*p[i]+1)\ndef function(N,X):\n if N == 0 :\n return 1\n else:\n if X <= 0 :\n return 0\n elif 1 < X and X <= a[N-1] + 2 :\n ret = function(N-1,X-1)\n return ret\n else:\n ret = 1 + p[N-1]\n ret += function(N-1,X-a[N-1]-2)\n return ret\nprint(function(N,X))', 'N, X = map(int,input().split())\n\na = [1] \np = [1] \nfor i in range(N):\n a.append(2*a[i]+3)\n p.append(2*p[i]+1)\ndef function(N,X):\n if N == 0 :\n return 1\n else:\n if X <= 0 :\n return 0\n elif 1 < X and X < a[N-1] + 2 :\n ret = function(N-1,X-1)\n return ret\n elif X == (a[N-1] + 2):\n return 1 + a[N-1]\n else:\n ret = 1 + p[N-1]\n ret += function(N-1,X-a[N-1]-2)\n return ret\nprint(function(N,X))', 'N, X = map(int,input().split())\n\na = [1] \np = [1] \nfor i in range(N):\n a.append(2*a[i]+3)\n p.append(2*p[i]+1)\ndef function(N,X):\n if N <= 0 :\n return 0 if X<= 0 else 1\n elif 1 < X and X <= a[N-1] + 1 :\n ret = function(N-1,X-1)\n return ret\n else:\n ret = 1 + p[N-1]\n ret += function(N-1,X-a[N-1]-2)\n return ret\nprint(function(N,X))', 'N, X = map(int,input().split())\n\na = [1] \np = [1] \nfor i in range(N):\n a.append(2*a[i]+3)\n p.append(2*p[i]+1)\ndef function(N,X):\n if N <= 0 :\n return 0 if X<= 0 else 1\n elif X <= a[N-1] + 1 :\n ret = function(N-1,X-1)\n return ret\n else:\n ret = 1 + p[N-1]\n ret += function(N-1,X-a[N-1]-2)\n return ret\nprint(function(N,X))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s434490392', 's609944289', 's701273759', 's595387079']
[3064.0, 3064.0, 3064.0, 3064.0]
[18.0, 17.0, 18.0, 18.0]
[661, 722, 598, 588]
p03209
u503228842
2,000
1,048,576
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?
['N,X = map(int,input().split())\na = [1]\np = [1]\nfor i in range(N):\n a.append(2*a[i]+3)\n p.append(2*p[i]+1)\n\ndef f(N,X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1+a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + f(N-1, X-2-a[N-1])\nprint(f(N,X))', 'N,X = map(int,input().split())\na = [1]\np = [1]\nfor i in range(N):\n a.append(2*a[i]+3)\n p.append(2*p[i]+1)\n\ndef f(N,X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1+a[N-1]:\n return f(N-1, X-1)\n elif X == 2+a[N-1]:\n return p[N-1]+1\n elif 2+a[N-1] < X <= 2+2*a[N-1]:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n elif X == 3+2*a[N-1]:\n return 2*p[N-1] +1\n\nprint(f(N,X))']
['Wrong Answer', 'Accepted']
['s275163652', 's910512726']
[3064.0, 3064.0]
[17.0, 17.0]
[291, 424]
p03209
u511379665
2,000
1,048,576
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?
['N,X=map(int,input().split())\n\na,p=[1],[1]\n\nfor i in range(N):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\n\ndef solve(n,x): #n,x\n if n==0:\n if x<=0:\n return 0\n else:\n return 1\n elif x<=1+a[N-1]:\n return solve(N-1,X-1)\n else:\n return p[N-1]+1+solve(N-1,X-2-a[N-1])\n\nprint(solve(N,X))\n\n\n', 'N,X=map(int,input().split())\n\na,p=[1],[1]\n\nfor i in range(N):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\n\ndef solve(n,x): #n,x\n if n==0:\n if x<=0:\n return 0\n else:\n return 1\n elif x<=1+a[n-1]:\n return solve(n-1,x-1)\n else:\n return p[n-1]+1+solve(n-1,x-2-a[n-1])\n\nprint(solve(N,X))\n']
['Runtime Error', 'Accepted']
['s386463756', 's715960964']
[3952.0, 3064.0]
[76.0, 19.0]
[346, 344]
p03209
u518042385
2,000
1,048,576
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?
['n , k=map(int,input().split())\nl="p"\nb=0\nfor o in range(0,n):\n l="b"+l+"p"+l+"b"\np=list(l)\nfor t in range(0,k):\n if p[t]==b:\n pass\n elif p[t]==p:\n b+=1\nprint(b)\n \n', 'n,m=map(int,input().split())\nl=["p"]\ni=0\nwhile len(l)<x:\n i+=1\n l=["b"]+l+["p"]+l+["b"]\nfor j in range(n-i):\n l=["b"]+l\nc=0\nfor i in range(x):\n if l[i]=="p":\n c+=1\nprint(c)', 'n,x=map(int,input().split())\nplist=[1]\nblist=[1]\nfor i in range(n):\n plist.append(plist[-1]*2+1)\n blist.append(blist[-1]*2+3)\ndef patty(n,x):\n if n==0:\n return 1\n else:\n if x==1:\n return 0\n elif 1<x and x<=blist[n-1]+1:\n return patty(n-1,x-1)\n elif x==blist[n-1]+2:\n return plist[n-1]+1\n elif 2+blist[n-1]<x and 2*blist[n-1]+2>=x:\n return plist[n-1]+patty(n-1,x-2-blist[n-1])+1\n else:\n return plist[n]\nprint(patty(n,x))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s733357124', 's831582626', 's430740327']
[2940.0, 3060.0, 3064.0]
[1826.0, 17.0, 19.0]
[165, 179, 467]
p03209
u519923151
2,000
1,048,576
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?
['n, x = map(int, input().split())\n\ndp = [1]*(n+1)\nres = 0\n\nfor i in range(1,n+1):\n dp[i] = dp[i-1]*2+3\n\nfor j in range(n,1,-1):\n if dp[j-1]+2 <= x :\n res += 1 + (dp[j-1]+1)//2\n x -= dp[j-1]+3\n elif dp[j-1]+1 ==x:\n res += (dp[j-1]+1)//2\n x = 0\n else:\n x -=1\n \n if x ==0:\n break\n \nif x ==5:\n res += 3\nelif x ==0:\n pass\nelse:\n res +=x-1\n\nprint(res)', 'n, x = map(int, input().split())\n\ndp = [1]*(n+1)\nres = 0\n\nfor i in range(1,n+1):\n dp[i] = dp[i-1]*2+3\n\nfor j in range(n,1,-1):\n if dp[j] ==x:\n res += (dp[j]+1) //2\n x =0 \n elif dp[j-1]+2 <= x :\n res += 1 + (dp[j-1]+1)//2\n x -= dp[j-1]+2\n elif dp[j-1]+1 ==x:\n res += (dp[j-1]+1)//2\n x = 0\n else:\n x -=1\n \n if x ==0:\n break\n \nif x ==5:\n res += 3\nelif x ==0:\n pass\nelse:\n res +=x-1\n\nprint(res)\n']
['Wrong Answer', 'Accepted']
['s132108489', 's106956808']
[9168.0, 9056.0]
[32.0, 28.0]
[420, 491]
p03209
u534308356
2,000
1,048,576
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?
['N, X = map(input().split())\n\n\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X):\n \n if N == 0:\n if X <= 0:\n return 0\n else:\n return 1\n elif X <= 1 + a[N - 1]:\n return f(N - 1, X - 1)\n else:\n return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])\n\nprint(f(N, X))\n', 'N, X = map(int, input().split())\n\n\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\ndef f(N, X):\n \n if N == 0:\n \n if X <= 0: \n return 0\n \n else:\n return 1\n \n \n elif X <= 1 + a[N - 1]:\n return f(N - 1, X - 1)\n \n else:\n return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])\n\nprint(f(N, X))\n']
['Runtime Error', 'Accepted']
['s245236498', 's239208950']
[3064.0, 3064.0]
[17.0, 17.0]
[465, 623]
p03209
u561339958
2,000
1,048,576
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?
['N, X = map(int, input().split())\na,p=[1],[1] for i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\ndef f(N,X): \n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\nprint(f(N, X))\n', 'N, X = map(int, input().split())\na,p=[1],[1] for i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\ndef f(N,X): \n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\nprint(f(N, X))', 'n,k = map(int,input().split())\na,p = [1],[1]\nfor i in range(n):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\ndef f(n,k):\n if n == 0:\n if k == 0:\n return 0\n else:\n return 1\n if k == 0:\n return 0\n elif k <= a[n-1]+1:\n return f(n-1,k-1)\n else:\n return p[n-1]+1+f(n-1,k-2-a[n-1])\nprint(f(n,k))\n\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s538261850', 's549536290', 's923036759']
[2940.0, 2940.0, 3064.0]
[18.0, 20.0, 17.0]
[335, 338, 317]
p03209
u571445182
2,000
1,048,576
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?
["Tmp = []\nTmp = input().rstrip().split(' ')\n\nnN = int(Tmp[0])\nnX = int(Tmp[1])\n\nnA = 1\nnP = 1\n\nnAnsA = []\nnAnsP = []\n\nfor i in range(nN):\n nTmpA = nA * 2 +3\n nTmpP = nP * 2 +1\n nAnsA.append(nTmpA)\n nAnsP.append(nTmpP)\n nA = nTmpA\n nP = nTmpP\n \nprint(nAnsA) \n\n", "Tmp = []\nTmp = input().rstrip().split(' ')\n \nnN = int(Tmp[0])\nnX = int(Tmp[1])\n\n\nnA = 1\nnP = 1\n \nnAnsA = []\nnAnsP = []\n\nnAnsA.append(1)\nnAnsP.append(1)\n \nfor i in range(nN):\n nTmpA = nA * 2 +3\n nTmpP = nP * 2 +1\n nAnsA.append(nTmpA)\n nAnsP.append(nTmpP)\n nA = nTmpA\n nP = nTmpP\n\nnAnsA.sort(reverse=True) \nnAnsP.sort(reverse=True) \nnN += 1\n\nnMaxA = nAnsA[0]\nnMaxP = nAnsP[0]\n \nnTmpA = nMaxA\nnTmpP = nMaxP\n \nnAns = 0\n\n# print(nAnsA)\n# print(nAnsP)\n\n\nfor i in range(nN):\n# print(nX)\n if i == nN - 1:\n nAns += 1\n break\n else:\n nTmpA = nAnsA[i+1] + 2\n nTmpP = nAnsP[i+1] + 1\n# print(nTmpA)\n# print(nTmpP)\n\n \n if nTmpA > nX:\n nX -= 1\n if (nX == 0):\n break\n elif nTmpA == nX:\n nAns += nTmpP\n break\n else:\n nAns += nTmpP\n nX -= nTmpA\n# print(nAns)\n \nprint(nAns)\n "]
['Wrong Answer', 'Accepted']
['s535985667', 's080806824']
[3060.0, 3064.0]
[17.0, 18.0]
[266, 811]
p03209
u572144347
2,000
1,048,576
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?
['\nN, X = map(int, input().split())\n\ndef calcl(n):\n l = 2 ** (n+2) - 3 \n return l\ndef calcp(n):\n p = 2 ** (n+1) - 1\n return p\n \nL = [1]\nP = [1]\n\nfor i in range(1, N+1):\n L.append( L[i-1] * 2 + 3)\n P.append( P[i-1] * 2 + 1)\n\ndef judge(n, x):\n # if n == 0:\n # if x == 1:\n # return 1\n # else:\n \n if x == 1:\n if n == 0:\n return "3"\n else:\n return "2"\n else:\n l = L[n] # layers\n top = l\n bottom = 1\n mid = (l-1)//2 # index of middle\n\n if x == mid:\n return "3"\n elif top > x > mid:\n return "1"\n elif 0 < x < mid:\n return "0" \n elif x == top:\n return "4"\n elif x == bottom:\n return "2"\n else:\n raise "No such pattern!"\n \n \ndef calc_pan(n,x):\n c = judge(n,x)\n # print("calc_panK: n:{}, x:{}, c: {}".format(n,x,c))\n if c == "2":\n return 0\n elif c == "4":\n return 1 + P[n-1] * 2\n elif c == "3":\n return 1 + P[n-1]\n elif c == "0":\n return calc_pan(n-1, x-1)\n elif c == "1":\n return P[n-1] + 1 + calc_pan(n-1, x-L[n-1]-2)\n\n\n\n\n\nsum = calc_pan(N, X)\nprint(sum)\n\n\n\n', '\nN, X = map(int, input().split())\n\n \nL = [1]\nP = [1]\n\nfor i in range(0, N+1):\n L.append( L[i] * 2 + 3)\n P.append( P[i] * 2 + 1)\n\n \n \ndef calc_pan(n,x):\n # c = judge(n,x)\n if n == 0:\n return 0 if x <= 0 else 1\n elif x <= 1 + L[n-1]:\n return calc_pan(n-1, x-1)\n else:\n return P[n-1] + 1 + calc_pan(n-1, x - 2 - L[n-1])\n\nsum = calc_pan(N, X)\nprint(sum)\n\n\n\n']
['Runtime Error', 'Accepted']
['s978935814', 's141059067']
[3064.0, 3060.0]
[18.0, 18.0]
[1325, 446]
p03209
u573272932
2,000
1,048,576
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?
['N, X = map(int, input().split())\n\nT = [1]*(N + 1)\nP = [1]*(N + 1)\nfor i in range(1, N+1):\n\tP[i] = P[i-1]*2 + 1\n\tT[i] = T[i-1]*2 + 3\nprint(T)\ndef pate(n, x):\n\tif n == 0:\n\t\tif x > 0: return 1\n\t\treturn 0\n\tmid = T[n]//2\n\tif x < mid:\n\t\tprint(n, x, mid, "a")\n\t\treturn pate(n-1, x-1)\n\telif mid == x:\n\t\tprint(n, x, mid, "b")\n\t\treturn 1 + pate(n-1, x-2)\n\telse:\n\t\tprint(n, x, mid, "c")\n\t\treturn P[n-1] + 1 + pate(n-1, x-mid-1)\n\nprint(pate(N, X))\n', 'T = [1]*(N + 1)\nP = [1]*(N + 1)\nfor i in range(1, N+1):\n\tP[i] = P[i-1]*2 + 1\n\tT[i] = T[i-1]*2 + 3\ndef pate(n, x):\n\tif n == 0:\n\t\tif x > 0: return 1\n\t\treturn 0\n\tmid = T[n]//2\n\tif x < mid:\n\t\treturn pate(n-1, x-1)\n\telif mid == x:\n\t\treturn 1 + pate(n-1, x-2)\n\telse:\n\t\treturn P[n-1] + 1 + pate(n-1, x-mid-1)\n\nprint(pate(N, X))\n', 'N, X = map(int, input().split())\nhight, paty = [0]*51, [0]*51\nhight[0] = 1\npaty[0] = 1\n\nfor i in range(1, 51):\n\thight[i] = 2*hight[i-1] + 3\n\tpaty[i] = 2*paty[i-1] + 1\n\ndef f(n, x):\n\tif x == 0: return 0\n\telif n == 0: return 1\n\n\telif x <= (hight[n-1]+1):\n\t\treturn f(n-1, x-1)\n\telse:\n\t\treturn paty[n-1] + 1 + f(n-1, x-hight[n-1]-2)\n\nprint(f(N, X))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s007075275', 's126397649', 's107690649']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 18.0]
[436, 321, 344]
p03209
u574226814
2,000
1,048,576
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?
['def getItems(layerCount):\n\tif layerCount == 0:\n\t\treturn 1\n\treturn 2*getItems(layerCount-1) + 3\n\ndef getPats(layerCount):\n\treturn 2**(layerCount + 1) - 1\n\ndef patEaten(layer, toEat):\n\tpattyCount = 0\n\n\tif layer == 1:\n\t\tburger = "BPPPB"\n\n\t\tfor x in range(toEat):\n\t\t\tif burger[x] == "P":\n\t\t\t\tpattyCount += 1\n\t\treturn pattyCount\n\t\t\n\telif layer == 0:\n\t\tif toEat == 1:\n\t\t\treturn 1\n\t\telse:\n\t\t\treturn 0\n\t\n\telse:\n\t\titems = getItems(layer)\n\t\tif toEat == items:\n\t\t\tpattyCount += getPats(layer)\n\t\t\treturn pattyCount\n\t\telif toEat < 2+getItems(layer-1):\n\t\t\tif items + 1 == 2* toEat:\n\t\t\t\ttoEat-=2\n\t\t\t\treturn 1 + patEaten(layer - 1, toEat)\n\t\t\ttoEat -= 1\n\t\t\treturn patEaten(layer - 1, toEat)\n\t\telse:\n\t\t\ttoEat -= (1+1+getItems(layer-1))\n\t\t\tpattyCount += 1 + getPats(layer-1)\n\t\t\t\n\t\t\treturn pattyCount + patEaten(layer-1, toEat)\n\n#i, j = [int(x) for x in input().split()]\nprint(patEaten(2,13))\n#print(getItems(2))', 'def getItems(layerCount):\n\tif layerCount == 0:\n\t\treturn 1\n\treturn 2*getItems(layerCount-1) + 3\n\ndef getPats(layerCount):\n\treturn 2**(layerCount + 1) - 1\n\ndef patEaten(layer, toEat):\n\tpattyCount = 0\n\n\tif layer == 1:\n\t\tburger = "BPPPB"\n\n\t\tfor x in range(toEat):\n\t\t\tif burger[x] == "P":\n\t\t\t\tpattyCount += 1\n\t\treturn pattyCount\n\t\t\n\telif layer == 0:\n\t\tif toEat == 1:\n\t\t\treturn 1\n\t\telse:\n\t\t\treturn 0\n\t\n\telse:\n\t\titems = getItems(layer)\n\t\tif toEat == items:\n\t\t\tpattyCount += patEaten(layer, toEat)\n toEat = 0\n\t\t\treturn pattyCount\n\t\telif toEat < 2+getItems(layer-1):\n\t\t\tif items + 1 == 2* toEat:\n\t\t\t\ttoEat-=2\n\t\t\t\treturn 1 + patEaten(layer - 1, toEat)\n\t\t\ttoEat -= 1\n\t\t\treturn patEaten(layer - 1, toEat)\n\t\telse:\n\t\t\ttoEat -= (1+1+getItems(layer-1))\n\t\t\tpattyCount += 1 + getPats(layer-1)\n\t\t\t\n\t\t\treturn pattyCount + patEaten(layer-1, toEat)\n\n#i, j = [int(x) for x in input().split()]\nprint(patEaten(2,13))\n#print(getItems(2))', 'def getItemCount(L):\n if L == 0:\n return 1\n return 2*getItemCount(L-1) + 3\n \ndef getPatsCount(L, eaten):\n if eaten * 2 - 1 == getItemCount(L):\n return 2**(1+layer) + 1\n return 2**(1+layer)\n\ndef getAns(layer, eaten):\n items = getItemCount(layer)\n patsInLayer = getPatsCount(layer, eaten)\n if layer == 0 and eaten == 1:\n return 1\n if eaten == items:\n return patsInLayer\n elif eaten < items:\n return getAns(layer-1, eaten - 1)\n else:\n return patsInLayer + getAns(layer-1, eaten - 1)\n\n\nlayer, eaten = [int(x) for x in input().split()]\nprint(getAns(layer, eaten))\n\n"""\ntPats = 0\nif layer != 0:\n while 1:\n items = getItemCount(layer)\n patsInLayer = getPatsCount(layer)\n\n if eaten == items:\n if layer != 0:\n tPats += patsInLayer\n eaten -= items\n break\n elif eaten < items:\n eaten -= 1\n elif eaten > items:\n tPats += patsInLayer + 1\n eaten -= items\n layer -= 1\n if layer < 0:\n break\nelse:\n if eaten == 1:\n print(1)\n else:\n print(0)\nprint(tPats)\n"""', 'def getItems(layerCount):\n\tif layerCount == 0:\n\t\treturn 1\n\treturn 2*getItems(layerCount-1) + 3\n\ndef getPats(layerCount):\n\treturn 2**(layerCount + 1) - 1\n\ndef patEaten(layer, toEat):\n\tpattyCount = 0\n\n\tif layer == 1:\n\t\tburger = "BPPPB"\n\n\t\tfor x in range(toEat):\n\t\t\tif burger[x] == "P":\n\t\t\t\tpattyCount += 1\n\t\treturn pattyCount\n\t\t\n\telif layer == 0:\n\t\tif toEat == 1:\n\t\t\treturn 1\n\t\telse:\n\t\t\treturn 0\n\t\n\telse:\n\t\titems = getItems(layer)\n\t\tif toEat == items:\n\t\t\tpattyCount += getPats(layer)\n\t\t\treturn pattyCount\n\t\telif toEat < 2+getItems(layer-1):\n\t\t\tif items + 1 == 2* toEat:\n\t\t\t\ttoEat-=2\n\t\t\t\treturn 1 + patEaten(layer - 1, toEat)\n\t\t\ttoEat -= 1\n\t\t\treturn patEaten(layer - 1, toEat)\n\t\telse:\n\t\t\ttoEat -= (1+1+getItems(layer-1))\n\t\t\tpattyCount += 1 + getPats(layer-1)\n\t\t\t\n\t\t\treturn pattyCount + patEaten(layer-1, toEat)\n\ni, j = [int(x) for x in input().split()]\n\nprint(patEaten(i,j))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s417601677', 's540328678', 's882387482', 's376711211']
[3064.0, 2940.0, 3904.0, 3064.0]
[17.0, 18.0, 75.0, 19.0]
[892, 916, 1043, 893]
p03209
u575653048
2,000
1,048,576
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?
['def b(n): \n if n == 0:\n return("P")\n else:\n return("B",b(n-1),"P",b(n-1),"B")\nn, x= map(int, input().split())\nprint(b(n).split("", x).count("P"))\n', 'n, x = map(int, input().split())\ndef patty(L):\n\n p = 1\n for i in range(L):\n p = 2 * p + 1\n return (p)\ndef vol(L):\n\n m = 1\n for i in range(L):\n m = m * 2 + 3\n return (m)\ndef eated(L, X):\n\n if L == 0:\n return 1\n m = vol(L)\n if X == 1 or X == 0:\n \n return 0\n elif X == (m + 1) / 2:\n \n \n return patty(L-1) + 1\n elif X < (m + 1) / 2:\n \n \n return eated(L-1, X-1)\n else:\n \n \n return patty(L) - eated(L, m - X)\nprint(eated(n, x))']
['Runtime Error', 'Accepted']
['s616638553', 's023817100']
[377716.0, 3064.0]
[2133.0, 18.0]
[187, 1005]
p03209
u576917603
2,000
1,048,576
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?
['def make(n,x):\n if n==0:\n return 1\n elif x==1:\n return 0\n elif x>=b_memo[n-1]+1:\n return p_memo[n-1]+1+make(n-1,x-b_memo[n-1]-2)\n elif x<b_memo[n-1]+1:\n return make(n-1,x-1)\n \nn,k=map(int,input().split())\nb_memo=[0]*51\np_memo=[0]*51\nb_memo[0]=1\np_memo[0]=1\nfor i in range(50):\n b_memo[i+1]=2*b_memo[i]+3\nfor i in range(50):\n p_memo[i+1]=2*p_memo[i]+1\n\nprint(make(n,k))', 'def f(n,x):\n if n==0:\n return 1\n elif x==1:\n return 0\n elif x==b_memo[n]//2+1:\n return p_memo[n-1]+1\n elif x<=b_memo[n]//2:\n return f(n-1,x-1)\n else:\n return 1+p_memo[n-1]+f(n-1,x-b_memo[n-1]-2)\n\nn,x=map(int,input().split())\n\nb_memo=[0]*51\np_memo=[0]*51\nb_memo[0]=1\np_memo[0]=1\n\nfor i in range(50):\n b_memo[i+1]=b_memo[i]*2+3\n p_memo[i+1]=p_memo[i]*2+1\n \nprint(f(n,x))']
['Wrong Answer', 'Accepted']
['s251599043', 's370026840']
[3064.0, 3064.0]
[17.0, 19.0]
[415, 427]
p03209
u581040514
2,000
1,048,576
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?
['N, X = map(int, input().split())\n\na, p = [1], [1]\n\nfor i in range(N):\n\ta.append(a[i] * 2 + 3)\n\tp.append(p[i] * 2 + 1)\n\ndef f(N, X):\n\tif N == 0:\n\t\treturn 0 if X <= 0 else 1\n\telif X <= 1 + a[N+1]:\n\t\treturn f(N-1, X-1)\n\telse:\n\t\treturn p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))', 'N, X = map(int, input().split())\n\na, p = [1], [1]\n\nfor i in range(N):\n\ta.append(a[i] * 2 + 3)\n\tp.append(p[i] * 2 + 1)\n\ndef f(N, X):\n\tif N == 0:\n\t\treturn 0 if X <= 0 else 1\n\telif X <= 1 + a[N-1]:\n\t\treturn f(N-1, X-1)\n\telse:\n\t\treturn p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))']
['Runtime Error', 'Accepted']
['s799855060', 's716184384']
[3064.0, 3064.0]
[17.0, 18.0]
[279, 279]
p03209
u584174687
2,000
1,048,576
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?
["\nans = 0\ndef count_ans(level, index, len_dic, p_dic):\n global ans\n\n if level == 0:\n if index == 0:\n ans += 1\n elif index == 0:\n pass\n else:\n if index == len_dic[level - 1] // 2 + 1:\n ans += 1\n ans += p_dic[level - 1]\n elif index > len_dic[level] // 2 + 1:\n ans += p_dic[level - 1] + 1\n index_next = index - len_dic[level - 1] - 2\n count_ans(level - 1, index_next, len_dic, p_dic)\n else:\n index_next = index - 1\n count_ans(level - 1, index_next, len_dic, p_dic)\n\n\ndef get_len_dic(level):\n len_dic = [1]\n for i in range(level):\n len_dic.append(len_dic[-1] * 2 + 3)\n return len_dic\n\ndef get_p_dic(level):\n p_dic = [1]\n for i in range(level - 1):\n p_dic.append(p_dic[-1] * 2 + 1)\n return p_dic\n\ndef main():\n global ans\n level, eat_num = map(int, input().split())\n len_dic = get_len_dic(level)\n p_dic = get_p_dic(level)\n count_ans(level, eat_num, len_dic, p_dic)\n print(ans)\n\n\n\n\n\nif __name__ == '__main__':\n main()", "\nans = 0\ndef count_ans(level, index, len_dic, p_dic):\n global ans\n if level == 0:\n ans += 1\n else:\n if index == 0:\n pass\n elif index == len_dic[level] // 2:\n ans += 1\n ans += p_dic[level - 1]\n elif index == len_dic[level] - 1:\n ans += p_dic[level]\n elif index > len_dic[level] // 2:\n ans += p_dic[level - 1] + 1\n index_next = index - len_dic[level - 1] - 2\n count_ans(level - 1, index_next, len_dic, p_dic)\n else:\n index_next = index - 1\n count_ans(level - 1, index_next, len_dic, p_dic)\n\n\ndef get_len_dic(level):\n len_dic = [1]\n for i in range(level):\n len_dic.append(len_dic[-1] * 2 + 3)\n return len_dic\n\ndef get_p_dic(level):\n p_dic = [1]\n for i in range(level):\n p_dic.append(p_dic[-1] * 2 + 1)\n return p_dic\n\ndef main():\n global ans\n level, eat_num = map(int, input().split())\n len_dic = get_len_dic(level)\n p_dic = get_p_dic(level)\n count_ans(level, eat_num - 1, len_dic, p_dic)\n print(ans)\n\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s766469370', 's420158711']
[3064.0, 3064.0]
[17.0, 18.0]
[1097, 1136]
p03209
u594244257
2,000
1,048,576
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?
['def eat(L,X):\n if L == 0: return 1\n if X == 1: return 0\n elif X <= len_burger(L-1)+1: return eat(L-1,X-1)\n elif X == len_burger(L-1)+2: return num_ban(L-1)+1\n elif X < 2*len_burger(L-1)+3: return num_ban(L-1)+1+eat(L-1,X-len_burger(L-1)-2)\n elif X == len_burger(L): return num_ban(L)\n\ndef solve():\n N,X = [int(s) for s in input().split() if s]\n \n print(eat(N,X))\n\nsolve()', 'def len_burger(L):\n return 2**(L+2)-3\ndef num_ban(L):\n return 2**(L+1)-1\n\ndef eat(L,X):\n if L == 0: return 1\n if X == 1: return 0\n elif X <= len_burger(L-1)+1: return eat(L-1,X-1)\n elif X == len_burger(L-1)+2: return num_ban(L-1)+1\n elif X < 2*len_burger(L-1)+3: return num_ban(L-1)+1+eat(L-1,X-len_burger(L-1)-2)\n elif X == len_burger(L): return num_ban(L)\n\ndef solve():\n N,X = [int(s) for s in input().split() if s]\n \n print(eat(N,X))\n \nsolve()']
['Runtime Error', 'Accepted']
['s918077063', 's607032045']
[3064.0, 3064.0]
[17.0, 17.0]
[398, 482]
p03209
u612721349
2,000
1,048,576
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?
['#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nal = [0, 5] + [0] * 49\nbl = [0, 3] + [0] * 49\n\n\ndef solve2(ans, x, idx, cnt):\n print(ans, x, idx)\n if idx == 1:\n return ans + (0, 0, 1, 2, 3, 3, 3)[x] + [0, 1][cnt >= 1]\n if x == (al[idx] // 2) + 1:\n return ans + bl[idx - 1] + 1 + [0, 1][cnt >= 1]\n elif x > (al[idx] // 2) + 1:\n ans += bl[idx - 1]\n x -= (al[idx] // 2)\n cnt += 1\n return solve2(ans, x, idx - 1, cnt)\n\n\ndef solve():\n n, x = map(int, input().split())\n for i in range(2, n + 1):\n al[i] = al[i - 1] * 2 + 3\n bl[i] = bl[i - 1] * 2 + 1\n ans = solve2(0, x, n, 0)\n print(ans)\n\n\nif __name__ == "__main__":\n solve()\n', '#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nal = [0, 5] + [0] * 49\nbl = [0, 3] + [0] * 49\n\n\ndef solve2(ans, x, idx):\n if idx == 1:\n if x >= 5:\n return ans + 3\n if x <= 0:\n return ans\n return ans + (0, 0, 1, 2, 3, 3)[x]\n if x >= al[idx - 1] + 1:\n ans += bl[idx - 1]\n x -= al[idx - 1] + 1\n if x >= 1:\n ans += 1\n x -= 1\n else:\n x -= 1\n return solve2(ans, x, idx - 1)\n\n\ndef solve():\n n, x = map(int, input().split())\n for i in range(2, n + 1):\n al[i] = al[i - 1] * 2 + 3\n bl[i] = bl[i - 1] * 2 + 1\n print(solve2(0, x, n))\n\n\nif __name__ == "__main__":\n solve()\n']
['Runtime Error', 'Accepted']
['s353000351', 's078287301']
[3128.0, 3064.0]
[21.0, 18.0]
[698, 690]
p03209
u617515020
2,000
1,048,576
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?
['N, K = map(int, input().split())\nS = [tuple(map(int, input().split())) for _ in range(N)]\n\nS.sort(key=lambda x: -x[1])\nst = set()\nfirst_acc, other_acc = [0], [0]\nfor t, d in S:\n if t in st:\n other_acc.append(other_acc[-1] + d)\n else:\n st.add(t)\n first_acc.append(first_acc[-1] + d)\n\nans = 0\nfor i in range(K + 1):\n if len(first_acc) <= i or len(other_acc) <= K - i:\n continue\n ans = max(ans, first_acc[i] + other_acc[K - i] + i * i)\n\nprint(ans)', 'N, X = map(int, input().split())\na,p=[1],[1]\nfor i in range(N):\n a.append(a[i] * 2 + 3) \n p.append(p[i] * 2 + 1)\n\ndef f(N,X):\n if N == 0:\n return 0 if X <= 0 else 1 \n elif X <= 1 + a[N-1]:\n return f(N-1, X-1) \n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\n\nprint(f(N, X))']
['Runtime Error', 'Accepted']
['s332176072', 's903720037']
[9220.0, 9128.0]
[24.0, 29.0]
[460, 286]
p03209
u623687794
2,000
1,048,576
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?
['n,k=map(int,input().split())\nburger=[None]*n\nburger[0]="P"\nfor i in range(1,n):\n burger[i]="B"+burger[i-1]+"P"+burger[i-1]+"B"\nprint(sum(1 for i in burger[-1][:k] if i=="P"))', 'n,x=map(int,input().split())\nlength=[0]*n;p=[0]*n\nlength[0]=1\np[0]=1\nfor i in range(1,n):\n length[i]=length[i-1]*2+3\n p[i]=p[i-1]*2+1\ndef meat(n,x):\n if n==0:\n return 0 if x<=0 else 1\n elif x<=1+length[n-1]:\n return meat(n-1,x-1)\n elif x==2+length[n-1]:\n return p[n-1]+1\n else:\n return p[n-1]+1+meat(n-1,x-length[n-1]-2)\nprint(meat(n,x))\n']
['Runtime Error', 'Accepted']
['s154939911', 's547077659']
[3064.0, 3064.0]
[1123.0, 17.0]
[175, 356]
p03209
u626881915
2,000
1,048,576
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?
['n, x = map(int, input().split())\nl = ["P"]\ndef lvup(n):\n if n == 0:\n pass\n else:\n lvup(n-1)\n l.append("B"+l[n-1]+"P"+l[n-1]+"B")\nprint(l[n][0:x].count("P"))', 'n, x = map(int, input().split())\n \ndef count_p(n, x):\n if n == 0:\n return x\n elif x > 2**(n+1)-2:\n return 2**(n)-1 + 1 + count_p(n-1, min(x-(2**(n+1)-1), 2**(n+1)-3))\n else:\n return count_p(n-1, x-1)\n \nprint(count_p(n,x))', 'n, x = map(int, input().split())\n\ndef count_p(n, x):\n if x == 0:\n return 0\n elif n == 0:\n return 1\n elif x > 2**(n+1)-2:\n return 2**(n)-1 + 1 + count_p(n-1, min(x-(2**(n+1)-1), 2**(n+1)-3))\n else:\n return count_p(n-1, x-1)\n \nprint(count_p(n,x))\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s060273765', 's799809769', 's910196539']
[3060.0, 3060.0, 3060.0]
[17.0, 23.0, 17.0]
[167, 234, 262]
p03209
u629350026
2,000
1,048,576
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?
['n,x=map(int,input().split())\np=[1]\na=[1]\nfor i in range(0,n-1):\n p.append(p[i]*2+1)\n a.append(a[i]*2+3)\ndef f(n,x):\n if x==1:\n return 0\n elif x<=1+a[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1]+f(n-1,x-a[n-1]-2)+1\nprint(f(n,x))', 'n,x=map(int,input().split())\np=[1]\na=[1]\nfor i in range(0,n):\n p.append(p[i]*2+1)\n a.append(a[i]*2+3)\ndef f(n,x):\n if n==0 and x<=0:\n return 0\n elif n==0:\n return 1\n elif x<=1+a[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1]+f(n-1,x-a[n-1]-2)+1\nprint(f(n,x))']
['Runtime Error', 'Accepted']
['s048034894', 's310036398']
[3128.0, 3064.0]
[23.0, 17.0]
[243, 276]
p03209
u631277801
2,000
1,048,576
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?
['import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nn,x = li()\nln = [1]\nfor i in range(n):\n ln.append(3+2*ln[-1])\n\nst = 0\ned = ln[n]-1\n\nans = 0\nwhile True:\n half = st + (ed-st)//2\n \n if x == half:\n ans += ((half-st)//2 + 1)\n break\n \n elif x < half:\n st += 1\n ed = half-1\n \n else:\n ans += ((half-st)//2 + 1)\n st = half+1\n ed -= 1\n \nprint(ans)', 'import sys\nstdin = sys.stdin\n\nsys.setrecursionlimit(10 ** 7)\n\ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x) - 1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\n\ndef rec(n: int, x: int, a: list, p: list) -> int:\n if x <= 0:\n raise ValueError\n\n elif n == 0:\n return 1\n\n elif x == 1:\n return 0\n\n elif 1 < x < a[n-1] + 2:\n return rec(n-1, x-1, a, p)\n\n elif x == a[n-1] + 2:\n return p[n-1] + 1\n\n elif a[n-1] + 2 < x < 2*a[n-1] + 3:\n return p[n-1] + 1 + rec(n-1, x - a[n-1] - 2, a, p)\n\n elif x == 2*a[n-1] + 3:\n return 2 * p[n-1] + 1\n\nn,x = li()\na = [1]\np = [1]\n\nfor i in range(n):\n a.append(2*a[-1]+3)\n p.append(2*p[-1]+1)\n\nprint(rec(n, x, a, p))']
['Wrong Answer', 'Accepted']
['s036878696', 's399220633']
[3064.0, 3064.0]
[2104.0, 17.0]
[808, 989]
p03209
u634208461
2,000
1,048,576
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?
["def PAndB(n):\n return (2 ** (n + 2)) - 3\n\n\ndef allPatty(n):\n return (2 ** (n + 1)) - 1\n\n\ndef count(N, X):\n if N == 0:\n return 1\n elif X <= N:\n return 0\n elif X >= PAndB(N) - (N - 1):\n return allPatty(N)\n elif X == PAndB(N - 1) + 2:\n print('center')\n return allPatty(N - 1) + 1\n elif X <= PAndB(N - 1) + 1:\n return count(N - 1, X - 1)\n else:\n return allPatty(N - 1) + 1 + count(N - 1, X - (PAndB(N - 1) + 2))\n\n\ndef main():\n N, X = map(int, input().split())\n print(count(N, X))\n\n\nif __name__ == '__main__':\n main()", "def PAndB(n):\n return (2 ** (n + 2)) - 3\n\n\ndef allPatty(n):\n return (2 ** (n + 1)) - 1\n\n\ndef count(N, X):\n if N == 0:\n return 1\n elif X <= N:\n return 0\n elif X >= PAndB(N) - (N - 1):\n return allPatty(N)\n elif X == PAndB(N - 1) + 2:\n return allPatty(N - 1) + 1\n elif X <= PAndB(N - 1) + 1:\n return count(N - 1, X - 1)\n else:\n return allPatty(N - 1) + 1 + count(N - 1, X - (PAndB(N - 1) + 2))\n\n\ndef main():\n N, X = map(int, input().split())\n print(count(N, X))\n\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s397869083', 's702751728']
[3064.0, 3064.0]
[17.0, 17.0]
[594, 570]
p03209
u644516473
2,000
1,048,576
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?
['N, X = map(int, input().split())\nburger = [1] * (N+1)\npatty = [1] * (N+1)\nfor i in range(1, N+1):\n burger[i] = burger[i-1] * 2 + 3\n patty[i] = patty[i-1] * 2 + 1\n\n\ndef func(level, x):\n if level == 0:\n return 0 if x <= 0 else 1\n if burger[level] + 1 < x:\n return func(level-1, x-burger[level]-2) + patty[level] + 1\n else:\n return func(level-1, x-1)\n\n\nprint(func(N, X))\n', 'N, X = map(int, input().split())\nburger = [1] * (N+1)\npatty = [1] * (N+1)\nfor i in range(1, N+1):\n burger[i] = burger[i-1] * 2 + 3\n patty[i] = patty[i-1] * 2 + 1\n\n\ndef func(level, x):\n if burger[level-1] + 1 <= x:\n return func(level-1, x-burger[level-1]-2) + patty[level-1] + 1\n else:\n return func(level-1, x-1)\n if level == 0:\n return 0\n\n\nprint(func(N, X))\n', 'N, X = map(int, input().split())\nburger = [1] * N\npatty = [1] * N\nfor i in range(1, N):\n burger[i] = burger[i-1] * 2 + 3\n patty[i] = patty[i-1] * 2 + 1\n\n\ndef func(level, x):\n if level == 0:\n return 0 if x <= 0 else 1\n if burger[level-1] + 1 < x:\n return func(level-1, x-burger[level-1]-2) + patty[level-1] + 1\n else:\n return func(level-1, x-1)\n\n\nprint(func(N, X))\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s163457943', 's205857636', 's247596143']
[3064.0, 3120.0, 3060.0]
[18.0, 23.0, 18.0]
[405, 395, 401]
p03209
u648901783
2,000
1,048,576
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?
['N,X = map(int,input().split())\n\nn_sum= X\nanswer = [0]\ndef saiki(layer,n_sum,sum_p):\n # print(layer,n_sum,sum_p)\n # if layer == 0:\n # answer[0] = sum_p\n # return\n if layer == 1:\n if n_sum == 1:\n answer[0] = sum_p\n elif n_sum == 2:\n answer[0] = sum_p+1\n elif n_sum ==3:\n answer[0] = sum_p+2\n else:\n answer[0] = sum_p+3\n return\n\n \n layer_sum = 2**(layer+2)-3\n \n pre_layer_sum = 2**(layer+1)-3\n pre_p_sum = 2**(layer)-1\n \n if n_sum < layer_sum //2 +1 :\n # print("left")\n n_sum -= 1\n saiki(layer-1,n_sum,sum_p)\n \n else:\n # print("right")\n n_sum -= (pre_layer_sum+2)\n sum_p += (1+pre_p_sum)\n saiki(layer-1,n_sum,sum_p)\n\nsaiki(N,X,0)\n\nprint(answer[0])\n\n\n\n\n\n\n', 'N,X = map(int,input().split())\n\nn_sum= X\nanswer = [0]\ndef saiki(layer,n_sum,sum_p):\n # print(layer,n_sum,sum_p)\n # if layer == 0:\n # answer[0] = sum_p\n # return\n if n_sum == 0:\n answer[0] = sum_p\n return \n if layer == 1:\n if n_sum == 1:\n answer[0] = sum_p\n elif n_sum == 2:\n answer[0] = sum_p+1\n elif n_sum ==3:\n answer[0] = sum_p+2\n else:\n answer[0] = sum_p+3\n return\n\n \n layer_sum = 2**(layer+2)-3\n \n pre_layer_sum = 2**(layer+1)-3\n pre_p_sum = 2**(layer)-1\n \n if n_sum < layer_sum //2 +1 :\n # print("left")\n n_sum -= 1\n saiki(layer-1,n_sum,sum_p)\n \n else:\n # print("right")\n n_sum -= (pre_layer_sum+2)\n sum_p += (1+pre_p_sum)\n saiki(layer-1,n_sum,sum_p)\n\nsaiki(N,X,0)\n\nprint(answer[0])\n\n\n\n\n\n\n']
['Wrong Answer', 'Accepted']
['s953683371', 's823592637']
[3064.0, 3064.0]
[18.0, 18.0]
[902, 963]
p03209
u652150585
2,000
1,048,576
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?
['def f(n, x):\n\tif n==0:\n\t\treturn 0 if x<= 0 else 1\n\telif x<=1+a[n-1]:\n\t\treturn f(n-1,x-1)\n\telse:\n\t\treturn p[n-1]+1+f(n-1,x-2-a[n-1])\n\n\nn,x=map(int, input().split())\na,p=[1],[1]\nfor i in range(N):\n\ta.append(a[i] * 2 + 3)\n\tp.append(p[i] * 2 + 1)\n \nprint(f(n, x))', 'def f(n, x):\n\tif n==0:\n\t\treturn 0 if x<= 0 else 1\n\telif x<=1+a[n-1]:\n\t\treturn f(n-1,x-1)\n\telse:\n\t\treturn p[n-1]+1+f(n-1,x-2-a[n-1])\n\n\nn,x=map(int, input().split())\na,p=[1],[1]\nfor i in range(n):\n\ta.append(a[i] * 2 + 3)\n\tp.append(p[i] * 2 + 1)\n \nprint(f(n, x))']
['Runtime Error', 'Accepted']
['s316494373', 's672845907']
[3064.0, 3064.0]
[19.0, 18.0]
[262, 262]
p03209
u657901243
2,000
1,048,576
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?
['n, x = map(int, input().split())\nflg = False \nL = None\nfor i in range(n+1):\n if i+1 <= x <= i+2**(n-i+3)-3:\n flg = True\n L = i\n break\n if i+1 <= 2**(n+2)-3-x <= i+2**(n-i+3)-3:\n L = i\n break\nprint(L)\nans = None\nif flg==True:\n if x-L==1:\n ans = 0\n elif x==L+2**(n-L+3)-3:\n ans = 2**(n-L+2)-1\n else:\n ans = 2**(n-L+1)-1\nelse:\n if 2**(n+2)-3-x==L:\n ans = 2**(n+1)-1\n elif 2**(n+2)-3-x==L+2**(n-L+3)-3:\n ans = 2**(n+1)-2**(n-L+2)\n else:\n ans = 2**(n+1)-2**(n-L+1)\nprint(ans)\n', 'n, x = map(int, input().split())\nflg = False \nL = None\nfor i in range(n, -1, -1):\n if i+1 <= x <= i+2**(n-i+3)-3:\n flg = True\n L = i\n break\n if i+1 <= 2**(n+2)-3-x <= i+2**(n-i+3)-3:\n L = i\n break\nans = None\nif flg==True:\n if x-L==1:\n ans = 0\n elif x==L+2**(n-L+3)-3:\n ans = 2**(n-L+2)-1\n else:\n ans = 2**(n-L+1)-1\nelse:\n if 2**(n+2)-3-x==L:\n ans = 2**(n+1)-1\n elif 2**(n+2)-3-x==L+2**(n-L+3)-3:\n ans = 2**(n+1)-2**(n-L+2)\n else:\n ans = 2**(n+1)-2**(n-L+1)\nprint(ans)\n', 'n, x = map(int, input().split())\n\ndef p(n):\n return 2**(n+1)-1\n\ndef a(n):\n return 2**(n+2)-3\n\ndef f(n, x):\n if n==0:\n return 0 if x<=0 else 1\n elif x<=1+a(n-1):\n return f(n-1, x-1)\n else:\n return p(n-1)+1+f(n-1, x-2-a(n-1))\n\nprint(f(n, x))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s597909930', 's907330092', 's702111662']
[3064.0, 3064.0, 3060.0]
[17.0, 17.0, 18.0]
[595, 592, 276]
p03209
u665038048
2,000
1,048,576
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?
['n, x = map(int, input().split())\na, p = [1], [1]\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\n\ndef f(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X - 2 - a[N-1])\n\n\nprint(f(N, X))\n', 'n, x = map(int, input().split())\na, p = [1], [1]\nfor i in range(n):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\n\ndef f(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X - 2 - a[N-1])\n\n\nprint(f(N=n, X=x))\n']
['Runtime Error', 'Accepted']
['s080241745', 's372682433']
[3188.0, 3064.0]
[19.0, 17.0]
[317, 321]
p03209
u672475305
2,000
1,048,576
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?
['n,x = map(int,input().split())\n\na,p = [1],[1]\n\nfor i in range(n):\n a.append(a[i]*2+3)\n p.append(p[i]+2+1)\n\ndef f(n,x):\n if n==0:\n return 0 if x <= 0 else 1\n elif x <= 1 + a[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1] + 1 + f(n-1,x-2-a[n-1])\n\nprint(f(n,x))', 'n,x = map(int,input().split())\n\na,p = [1],[1]\nfor i in range(n):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\n\ndef f(n,x):\n if n==0:\n return 0 if x <= 0 else 1\n elif x <= 1 + a[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1] + 1 + f(n-1,x-2-a[n-1])\n\nprint(f(n,x))']
['Wrong Answer', 'Accepted']
['s686259732', 's413292864']
[3064.0, 3064.0]
[17.0, 17.0]
[294, 293]
p03209
u674951726
2,000
1,048,576
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?
["[N,X] = list(map(int,input().split(' ')))\n\ndef paty(n,x):\n if n == 0:\n if x == 1:\n return 1\n else:\n return 0\n elif int((2**(n+2)-3 + 1) / 2) >= x:\n return paty(n-1,x-1)\n else:\n return 2**n + paty(n-1, x-(2**(n+1)-3) -2)\n \nans = paty(N,X)\nprint(ans)", "[N,X] = list(map(int,input().split(' ')))\n\ndef paty(n,x):\n if n == 0:\n if x == 1:\n return 1\n else:\n return 0\n elif int((2**(n+2)-3 - 1) / 2) >= x:\n return paty(n-1,x-1)\n elif int((2**(n+2)-3 + 1) / 2) == x:\n return paty(n-1,x-1) + 1\n else:\n return 2**n + paty(n-1, x-(2**(n+1)-3) -2)\n \nans = paty(N,X)\nprint(ans)", "[N,X] = list(map(int,input().split(' ')))\n\ndef paty(n,x):\n #print('n:{}'.format(n))\n #print('x:{}'.format(x))\n if n == 0:\n if x == 1:\n return 1\n else:\n return 0\n elif int((2**(n+2)-3 - 1) / 2) >= x:\n return paty(n-1,x-1)\n elif int((2**(n+2)-3 + 1) / 2) == x:\n return paty(n-1,x-2) + 1\n elif (2**(n+2)-3) - 1 <= x:\n return 2*paty(n-1, x-(2**(n+1)-3) -2) + 1\n else:\n return 2**n + paty(n-1, x-(2**(n+1)-3) -2)\n \nans = paty(N,X)\nprint(ans)", "[N,X] = list(map(int,input().split(' ')))\n\ndef paty(n,x):\n if n == 0:\n if x == 1:\n return 1\n else:\n return 0\n elif int((2**(n+2)-3 + 1) / 2) >= x:\n return paty(n-1,x-1) + 1\n else:\n return 2**n + paty(n-1, x-(2**(n+1)-3) -2)\n \nans = paty(N,X)\nprint(ans)", "[N,X] = list(map(int,input().split(' ')))\n\ndef paty(n,x):\n #print('n:{}'.format(n))\n #print('x:{}'.format(x))\n if x == 0:\n return 0\n if n == 0:\n return x\n elif ((2**(n+2))-3 - 1) / 2 >= x:\n return paty(n-1,x-1)\n elif ((2**(n+2))-3 + 1) / 2 == x:\n return 2**n\n elif ((2**(n+2))-3) - 1 <= x:\n return 2**(n+1) - 1\n else:\n return 2**n + paty(n-1, x-((2**(n+1))-3) -2)\n \nans = paty(N,X)\nprint(ans)"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s170847283', 's274461690', 's526991835', 's556138006', 's697613701']
[3064.0, 3064.0, 3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0, 18.0, 18.0]
[274, 342, 472, 278, 419]
p03209
u678167152
2,000
1,048,576
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?
['N, X = map(int, input().split())\n\ndef burger(N,X):\n print(N,X)\n if N == 0 and X == 1:\n return 1\n if X == 0:\n return 0\n twopow = pow(2,N)\n if X > 2*twopow-2:\n return twopow + burger(N-1,X-2*twopow+1)\n elif X <= 2*twopow-3:\n return burger(N-1,X-1)\n\nprint(burger(N,X))', 'N, X = map(int, input().split())\n\ndef burger(N,X):\n print(N,X)\n if N == 0 and X == 1:\n return 1\n if X == 0:\n return 0\n twopow = pow(2,N)\n if X == 4*twopow-3:\n return 2*twopow-1\n if X > 2*twopow-2:\n return twopow + burger(N-1,X-2*twopow+1)\n elif X <= 2*twopow-2:\n return burger(N-1,X-1)\n\nprint(burger(N,X))\n', 'N, X = map(int, input().split())\n\ndef burger(N,X):\n #print(N,X)\n if N == 0 and X == 1:\n return 1\n if X == 0:\n return 0\n twopow = pow(2,N)\n if X == 4*twopow-3:\n return 2*twopow-1\n if X > 2*twopow-2:\n return twopow + burger(N-1,X-2*twopow+1)\n elif X <= 2*twopow-2:\n return burger(N-1,X-1)\n\nprint(burger(N,X))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s288513638', 's947716139', 's523061969']
[4064.0, 3064.0, 3060.0]
[77.0, 18.0, 18.0]
[283, 328, 328]
p03209
u681917640
2,000
1,048,576
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?
['def feed_runrun(answer, burger_dimension, appetite):\n if appetite >= 0:\n return answer\n\n burger_size = 2 ** (burger_dimension + 2) - 3\n \n if appetite < burger_size:\n return feed_runrun(answer, burger_dimension - 1, appetite - 1)\n \n amount_of_p = 2 ** (burger_dimension + 1) - 1\n return feed_runrun(answer + amount_of_p + 1, burger_dimension, appetite - burger_size - 1)\n\n\nn, x = map(int, input().split())\nprint(feed_runrun(0, n, x))', 'n, x = map(int, input().split())\n\nanswer = 0\nred = x\n\nsearching_index = n\nwhile red > 0:\n for i in reversed(range(searching_index + 1)):\n length = 2**(i + 2) - 3\n if red >= length:\n print("length", length, red)\n if red >= length + 1:\n print("contain p")\n answer += 1\n red -= 1\n searching_index = i\n answer += 2**(i+1) - 1\n red -= length\n print(answer, length)\n break\n red -= 1\n\nprint(answer)', 'def feed_runrun(burger_dimension, appetite):\n if appetite == 0:\n return 0\n\n burger_size = 2 ** (burger_dimension + 2) - 3\n amount_of_p = 2 ** (burger_dimension + 1) - 1\n\n if appetite == burger_size:\n return amount_of_p\n if appetite < burger_size:\n return feed_runrun(burger_dimension - 1, appetite - 1)\n if appetite > burger_size:\n return amount_of_p + 1 \\\n + feed_runrun(burger_dimension, appetite - burger_size - 1)\n\n\nn, x = map(int, input().split())\nprint(feed_runrun(n, x))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s174695616', 's414953301', 's739949429']
[3060.0, 3064.0, 3060.0]
[18.0, 17.0, 20.0]
[521, 537, 537]
p03209
u686036872
2,000
1,048,576
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?
['N, X = map(int, input().split())\ndef f(n, x):\n if x ==0:\n return 0\n elif n == 0:\n return 1\n elif x <= 2**(n+1) - 1:\n return f(n-1, x-1)\n else:\n return 2**n+f(n-1, x-2**(n+1)+1)\nprint(f(N, X))', 'N, X = map(int, input().split())\ndef f(n, x):\n if x ==0:\n return 0\n if n == 0:\n return 1\n if x <= 2**(n+1) - 1:\n return f(n-1, x-1)\n else:\n return 2**n+f(n-1, x-2**(n+1)+1)\nprint(f(N, X))', 'N, X = map(int, input().split())\ndef f(n, x):\n if x ==0:\n return 0\n if n == 0:\n return 1\n if x <= 2**(n+1) - 2:\n return f(n-1, x-1)\n else:\n return 2**n+f(n-1, x-2**(n+1)+1)\nprint(f(N, X))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s122831910', 's919826837', 's465151037']
[3060.0, 3060.0, 3060.0]
[18.0, 17.0, 18.0]
[231, 227, 227]
p03209
u690536347
2,000
1,048,576
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?
['from functools import lru_cache\n\n@lru_cache()\ndef f(n):\n if n==0:\n return 1\n return 2*f(n-1)+1\n\n@lru_cache()\ndef g(n):\n if n==0:\n return 1\n return 2*g(n-1)+3\n\nN, X = map(int, input().split())\ntotal = [g(i) for i in range(N+1)]\np = [f(i) for i in range(N+1)]\nans = 0\n\ndef search(x, n):\n global ans\n print(n, x)\n if n==0:\n if x:\n ans += 1\n return\n if x==0:\n return\n if x > total[n-1] + 2:\n ans += p[n-1] + 1\n search(x-(2 + total[n-1]), n-1)\n elif x == total[n-1] + 2:\n ans += p[n-1] + 1\n else:\n search(x-1, n-1)\n\nsearch(X, N)\nprint(ans)', 'def f(n):\n if n==0:\n return 1\n return 2*f(n-1)+1\n\nN, X = map(int, input().split())\nl, r = 0, g(N)\nans = 0\n\nwhile N:\n m = (l+r)//2\n if m<=X:\n l = m\n ans += f(N-1) + 1\n else:\n r = m\n N -= 1\n\nprint(ans)', 'N, X = map(int, input().split())\nq = [1]*(N+1)\np = [1]*(N+1)\nfor i in range(1, N+1):\n q[i] = 2*q[i-1]+3\n p[i] = 2*p[i-1]+1\n\nans = 0\ns = [(X, N)]\nwhile s:\n x, n = s.pop()\n if n==0:\n ans += x!=0\n if x:\n a = q[n-1] + 2\n b = p[n-1] + 1\n\n if x >= a:\n ans += b\n s += [(x-a, n-1)]\n else:\n s += [(x-1, n-1)]\n\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s124084416', 's203017039', 's552307254']
[3828.0, 3188.0, 3064.0]
[29.0, 19.0, 18.0]
[641, 245, 394]
p03209
u707498674
2,000
1,048,576
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?
['import numpy as np\nimport sys\nbuf = sys.stdin.buffer\n\ndef main():\n N = int(buf.readline())\n A = np.frombuffer(buf.read(), dtype="int64")\n A = np.mod(A, 2)\n print("first") if np.count_nonzero(A) else print("second")\nif __name__ == "__main__":\n main()', 'def main():\n\n burgur = [0] * 51\n burgur[0] = 1\n pate = [0] * 51\n pate[0] = 1\n for i in range(50):\n burgur[i+1] = burgur[i] * 2 + 3\n pate[i+1] = pate[i] * 2 + 1\n \n N, X = map(int, input().split())\n\n X -= 1\n ans = 0\n for i in reversed(range(1, N+1)):\n if X == burgur[i] - 1:\n ans += pate[i]\n break\n elif X >= burgur[i-1] + 1:\n ans += pate[i-1] + 1\n X -= (burgur[i-1] + 2)\n else: \n X -= 1\n if X == 0:\n ans += 1\n print(ans)\n \n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s424936566', 's448136792']
[12424.0, 3064.0]
[151.0, 17.0]
[264, 596]
p03209
u763741681
2,000
1,048,576
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?
['N, X = map(int, input().split())\na,p=[1],[1] for i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\ndeff(N,X): \n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\nprint(f(N, X))', 'N, X = map(int, input().split())\na,p=[1],[1] \nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\ndeff(N,X): \n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\nprint(f(N, X))', 'N,X=map(int,input().split())\ndef humberger(N):\n if N==0:\n return [1]\n else:\n return [0]+humberger(N-1)+[1]+humberger(N-1)+[0]\nlist1=humberger(N)\ndel list1[X:]\nsum(list1)', 'N, X = map(int, input().split())\na,p=[1],[1] \nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\ndef f(N,X): \n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= 1 + a[N-1]:\n return f(N-1, X-1)\n else:\n return p[N-1] + 1 + f(N-1, X-2-a[N-1])\nprint(f(N, X))']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s074675707', 's176338332', 's568973271', 's318239474']
[2940.0, 2940.0, 85036.0, 3064.0]
[17.0, 18.0, 2105.0, 18.0]
[351, 357, 189, 357]
p03209
u782098901
2,000
1,048,576
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?
['import re\n\nN, X = map(int, input().split())\n\nburger = [None] * 51\nburger[0] = "P"\n\nfor i in range(1, N + 1):\n burger[i] = "B" + burger[i - 1] + "P" + burger[i - 1] + "B"\n print(burger[i])\n\nburger_x = burger[N][:X]\nans = len(re.findall("P", burger_x))\nprint(ans)', 'N, X = map(int, input().split())\n\na, p = [None] * (N + 1), [None] * (N + 1)\na[0], p[0] = 1, 1\nfor i in range(1, N + 1):\n a[i], p[i] = 2 * a[i - 1] + 3, 2 * p[i - 1] + 1\n\n\ndef f(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= a[N - 1] + 1:\n return f(N - 1, X - 1)\n else:\n return p[N - 1] + 1 + f(N - 1, X - a[N - 1] - 2)\n\nprint(f(N, X))\n']
['Runtime Error', 'Accepted']
['s148384174', 's460630520']
[675108.0, 3064.0]
[537.0, 17.0]
[267, 378]
p03209
u798316285
2,000
1,048,576
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?
['n,x=map(int,input().split())\na=[1]\np=[1]\nfor i in range(n-1):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\ndef f(n,x):\n if n==0 and x==1:\n return 1\n elif n==0:\n return 0\n elif x<=1:\n return 0\n elif x<=1+a[n-]:\n return f(n-1,x-1)\n else:\n return p[n-1]+1+f(n-1,x-2-a[n-1])\nprint(f(n,x))', 'n,x=map(int,input().split())\na=[1]\np=[1]\nfor i in range(n-1):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\ndef f(n,x):\n if n==0 and x=1:\n return 1\n elif n==0:\n return 0\n elif x<=1+a[n-1]:\n return f(n-1,x-1)\n else:\n return p[n-1]+1+f(n-1,x-2-a[n-1])\nprint(f(n,x))', 'N,X=map(int,input().split())\na,p=[1],[1]\nfor i in range(N):\n a.append(a[i]*2+3)\n p.append(p[i]*2+1)\ndef f(n,x):\n if n==0:return 0 if x<=0 else 1\n elif x<=1+a[n-1]:return f(n-1,x-1)\n else:return p[n-1]+1+f(n-1,x-2-a[n-1])\nprint(f(N,X))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s273708992', 's816790298', 's645815556']
[2940.0, 2940.0, 3064.0]
[17.0, 17.0, 18.0]
[305, 279, 249]
p03209
u798818115
2,000
1,048,576
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?
['# coding: utf-8\n# Your code here!\nN,X=map(int,input().split())\n\ndef dfs(count,object):\n count+=1\n object="B"+object+"P"+object+"B"\n if count<N:\n dfs(count,object)\n else:\n print(object)\n exit()\n\nn=0\nburger="P"\n\n(dfs(n,burger))\n', '# coding: utf-8\n# Your code here!\nN,X=map(int,input().split())\n\nX-=1\ndef saiki(i,x,count):\n if i==-1:\n print(int(count)+1)\n exit()\n all=2**(i+2)-3\n paty=2**(i+1)-1\n if x==all-1:\n print(count+paty)\n exit()\n elif x==0:\n print(count)\n elif x==(all-1)//2:\n print(int(count+(paty-1)//2+1))\n exit()\n elif x>(all-1)//2:\n count+=((paty-1)//2+1)\n x-=(all//2)\n saiki(i-1,x-1,count)\n elif x<(all-1)//2:\n saiki(i-1,x-1,count)\n \n\nans=0\nsaiki(N,X,ans)\n\n']
['Runtime Error', 'Accepted']
['s256565094', 's686097046']
[3688.0, 3064.0]
[1553.0, 18.0]
[259, 543]
p03209
u803481017
2,000
1,048,576
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?
['N,X = map(int,input().split())\na = ["P"]\ndef b(L):\n if L != 0:\n c = ["B"]\n return c+b(L-1)+a+b(L-1)+c\n else :\n return a\nj = b(N)\nq = j[:X]\nq.count("P")', 'N,X = map(int,input().split())\ndef lb(N):\n if N != 0:\n return 2*lb(N-1)+3\n else:\n return 1\ndef pn(N):\n if N != 0:\n return 2*pn(N-1)+1\n else:\n return 1\ndef B(N,X):\n if X == 0:\n return 0\n elif N == 0:\n \treturn 1\n elif lb(N-1)+1 >= X:\n return B(N-1,X-1)\n else:\n return pn(N-1)+1+B(N-1,X-lb(N-1)-2)\nprint(B(N,X))\n']
['Wrong Answer', 'Accepted']
['s150701254', 's893814899']
[84956.0, 3060.0]
[2105.0, 18.0]
[178, 387]
p03209
u820839927
2,000
1,048,576
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?
["import os, sys, re, math\n\nN,X = list(map(int,input().split(' ')))\n\nmemo_length = [0 for i in range(51)]\nmemo_patties = [0 for i in range(51)]\nmemo_length[0] = 1\nmemo_patties[0] = 1\n\nfor i in range(1,51):\n memo_length[i] = memo_length[i-1] * 2 + 3\n memo_patties[i] = memo_patties[i-1] * 2 + 1\n\ndef doit(level,x):\n if x == 0:\n return 0\n if x >= memo_length[level]:\n return memo_patties[level]\n\n tmp = memo_length[level-1]\n ret = 0\n\n if x >= 1:\n ret += doit(level-1, x-1)\n if x >= tmp + 2:\n ret += 1\n ret += doit(level-1, x-tmp-2)\n\n return ret\n\nprint(doit(N,X-1))", "import os, sys, re, math\n\nN,X = list(map(int,input().split(' ')))\n\nmemo_length = [0 for i in range(51)]\nmemo_patties = [0 for i in range(51)]\nmemo_length[0] = 1\nmemo_patties[0] = 1\n\nfor i in range(1,51):\n memo_length[i] = memo_length[i-1] * 2 + 3\n memo_patties[i] = memo_patties[i-1] * 2 + 1\n\ndef doit(level,x):\n if x == 0:\n return 0\n if x >= memo_length[level]:\n return memo_patties[level]\n\n tmp = memo_length[level-1]\n ret = 0\n\n if x >= 1:\n ret += doit(level-1, x-1)\n if x >= tmp + 2:\n ret += 1\n ret += doit(level-1, x-tmp-2)\n\n return ret\n\nprint(doit(N,X))\n"]
['Wrong Answer', 'Accepted']
['s311466236', 's275175568']
[3188.0, 3188.0]
[19.0, 19.0]
[622, 621]
p03209
u830054172
2,000
1,048,576
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?
['N, X = map(int, input().split())\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\n# print(a, p)\n\ndef f(N, X):\n if N == 0:\n return 1\n elif X <= a[N-1]:\n \n return f(N-1, X-1)\n else:\n \n return p[N-1]+1+f(N-1, X-2-a[i])\nprint(f(N, X))\n', 'N, X = map(int, input().split())\na, p = [1], [1]\nfor i in range(N):\n a.append(a[i] * 2 + 3)\n p.append(p[i] * 2 + 1)\n\n# print(a, p)\n\ndef f(N, X):\n if N == 0:\n return 0 if X <= 0 else 1\n elif X <= a[N-1]+1:\n \n return f(N-1, X-1)\n else:\n \n return p[N-1]+1+f(N-1, X-2-a[N-1])\nprint(f(N, X))\n']
['Wrong Answer', 'Accepted']
['s906756663', 's706037768']
[9188.0, 9168.0]
[26.0, 29.0]
[472, 493]
p03209
u837286475
2,000
1,048,576
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?
['\nn, x = map(int,input().split())\n\ndef rec(lv,ls):\n if lv == 0:\n return [1]\n else:\n ret = rec(lv-1,ls)\n for i in range(0,len(ret) -1):\n if ret[i]>0 and ret[i+1]>0:\n ret[i+1] += ret[i]\n ret[i] = 0 #deleted tag\n\n while 0 != ret.count(0):\n ret.remove(0)\n return [-1,*ret,1,*ret,-1]\n\n \ncount = 0\nfor e in rec(n, list() ):\n abs_e = abs(e)\n if x>=abs_e:\n x -= abs_e\n count += e if e>0 else 0\n else:\n count += e if e>0 else 0\n\n\nprint(count)\n', '\n# This src was written after reading editional.pdf .\n\nn, x = map(int, input().split())\n\n\nan, pn = [1], [1]\n\nfor i in range(n):\n an.append(2*an[i]+3)\n pn.append(2*pn[i]+1)\n\n#print(an)\n\ndef f(n,x):\n\n #print(n,x)\n\n if n == 0:\n return 1 if 0<x else 0\n \n if x <= an[ n-1 ] + 1:\n return f( n-1, x-1 )\n\n else:# x <= 2*an[n-1] + 3:\n return f(n-1, x-an[n-1]-2) + pn[n-1] + 1\n\n\nprint(f(n,x))\n\n \n# else if: \n']
['Runtime Error', 'Accepted']
['s871620094', 's521007756']
[3064.0, 3064.0]
[17.0, 17.0]
[557, 459]
p03209
u844005364
2,000
1,048,576
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?
['n, x = map(int, input().split())\nimport numpy as np\n\n\ndef burger(num):\n if num == 1:\n return np.array([1, 3, 1])\n last_burger = burger(num - 1)\n return np.concatenate((last_burger[0] + 1, last_burger[1:], 1, last_burger[:-1], last_burger[-1] + 1), axis=None)\n\n\ndef main(n, x):\n burger_n = burger(n)\n print(burger_n)\n\n i, p, eaten = 0, 0, 0\n\n while eaten < x:\n eaten += burger_n[i]\n if i % 2 == 1:\n p += burger_n[i]\n i += 1\n\n if i % 2 == 0:\n p -= (eaten - x)\n\n print(p)\n\n\nmain(n, x)', 'n, x = map(int, input().split())\nx -= 1\n\n\ndef main(n, x):\n if n == 0:\n if x >= 0:\n return 1\n else:\n return 0\n if x == 0:\n return 0\n if x == 2 ** (n + 1) - 2:\n return 2 ** n\n if x < 2 ** (n + 1) - 2:\n return main(n - 1, x - 1)\n return 2 ** n + main(n - 1, x - (2 ** (n + 1) - 1))\n\n\nprint(main(n, x))']
['Wrong Answer', 'Accepted']
['s440914091', 's077932702']
[12508.0, 3064.0]
[2158.0, 17.0]
[554, 370]
p03209
u846150137
2,000
1,048,576
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?
['n,x=map(int,input().split())\na=[(1,1)]\nfor _ in range(n):\n a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]\n\nif a[-1][0]==x:\n print(a[-1][1])\n exit()\n\ns=0\nfor i,j in a[::-1]:\n x-=1\n if i<=x:\n x-=i\n s+=j\n if x>=1:\n x-=1\n s+=1\nprint(s)', 'n,x=map(int,input().split())\na=[(1,1)]\nfor _ in range(n):\n a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]\n\ns=0\nfor i,j in a[::-1]:\n x-=1\n if i<=x:\n x-=i;s+=j\n if x>=1:\n x-=1;s+=1\n\nprint(s)\n', 'n,x=map(int,input().split())\na=[(1,1)]\nfor _ in range(n):\n a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]\n\nif a[-1][0] in (x,x-1):\n print(a[-1][1])\n exit()\na=a[:-1]\nx-=1\n\ns=0\nfor i,j in a[::-1]:\n x-=1\n if i<=x:\n x-=i;s+=j\n if x>=1:\n x-=1;s+=1\nprint(s)', 'n,x=map(int,input().split())\na=[(1,1)]\nfor _ in range(n):\n a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]\n\ns=0\nfor k in range(1,len(a)*2+1):\n i,j = a[-k // 2]\n x -= k % 2\n if i <= x:\n x-=i;s+=j\n if x>=1:\n x-=1;s+=1\n\nprint(s)\n', 'n,x=map(int,input().split())\na=[(1,1)]\nfor _ in range(n):\n a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]\n\nif a[-1][0] in (x,x-1):\n print(a[-1][1]);exit()\n\ns=0\nfor k in range(3,len(a)*2+1):\n i,j = a[-k // 2]\n x -= k % 2\n if i <= x:\n x-=i;s+=j\n if x>=1:x-=1;s+=1\n\nprint(s)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s266149357', 's329700362', 's560436460', 's724312167', 's773972453']
[3064.0, 3060.0, 3188.0, 3188.0, 3064.0]
[20.0, 17.0, 18.0, 19.0, 18.0]
[241, 189, 253, 226, 268]
p03209
u846522771
2,000
1,048,576
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?
['#coding:utf-8\nn,x=map(int, input().split())\n\na,p=[1],[1]\nfor i in range(n):\n\ta.append(a[i]*2+3)\n\tp.append(p[i]*2+1)\n\ndef f(n,x):\n\tif n==0:\n\t\treturn0 if x<=0 else 1\n\telif x<=1+a[n-1]:\n\t\treturn f(n-1,x-1)\n\telse:\n\t\treturn p[n-1]+1+f(n-1,x-2-a[n-1])\n\nprint(f(n,x))', '#coding:utf-8\nn,x=map(int, input().split())\n\na,p=[1],[1]\nfor i in range(n):\n\ta.append(a[i]*2+3)\n\tp.append(p[i]*2+1)\n\ndef f(n,x):\n\tif n==0:\n\t\treturn 0 if x<=0 else 1\n\telif x<=1+a[n-1]:\n\t\treturn f(n-1,x-1)\n\telse:\n\t\treturn p[n-1]+1+f(n-1,x-2-a[n-1])\n\nprint(f(n,x))']
['Runtime Error', 'Accepted']
['s567647895', 's709000648']
[3088.0, 3064.0]
[21.0, 18.0]
[260, 261]
p03209
u853185302
2,000
1,048,576
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?
["from functools import lru_cache\n#@lru_cache(maxsize=3000)\n@memoize\ndef burger(str_b,level):\n if(level == 0):\n return str_b + 'p'\n str_b += 'B'\n str_b = burger(str_b,level-1)\n str_b += 'p'\n str_b = burger(str_b,level-1)\n str_b += 'B'\n return str_b\n\n\nstr_b = ''\nN,X = map(int,input().split())\nstr_b = burger(str_b,N)\nb_list = list(str_b)\neat_list = b_list[::-1]\neat_list = b_list[0:X]\nprint(eat_list.count('p'))", 'n,x = map(int,input().split())\na,p = [1],[1]\nfor i in range(n):\n a.append(2*a[i]+3)\n p.append(2*p[i]+1)\n\ndef f(N,X):\n if N==0:\n return 0 if X<=0 else 1\n elif X <= 1+a[N-1]:\n return f(N-1,X-1)\n else:\n return p[N-1]+1+f(N-1,X-2-a[N-1])\nprint(f(n,x))\n\n ']
['Runtime Error', 'Accepted']
['s561442860', 's454830762']
[3700.0, 3064.0]
[31.0, 17.0]
[419, 265]