Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
s = []
for i in range(n):
    m = list(input())
    m.sort()
    s.append(m)
# print(s)
count = 0
for i in range(n):
    for j in range(n):
        # if i != j:
        if i < j:
        #     print(s[i])
        # print(s[j])
            if s[i] == s[j]:
                count += 1
# for i in range(n):
    
print(count)

Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
s = []
for i in range(n):
    m = list(input())
    m.sort()
    s.append(m)
s.sort()
# print(s)
# print(s)
count = 0
ren = 1
r = []
rsum = [0] * n
for i in range(n-1):
    if s[i] == s[i+1]:
        count += 1
        ren += 1
        # print(ren)
        rsum[i+1] +=rsum[i]+1
    else:
        r.append(ren)
        ren = 1
        # print(ren)
r.append(ren)
        
for i in range(n):
    rsum[i] = rsum[i] + 1
    

def P(n, r):
    return factorial(n)//factorial(n-r)

def C(n, r):
    return P(n, r)//factorial(r)
# print(r)

# print(count)
# print("rsum:", rsum)
b = []
rsum.append(1)

for i in range(n):
    if rsum[i]>rsum[i+1]:
        b.append(rsum[i])
    #     continue
    # else:
    #     print(rsum[i+1])
    #     b.append(rsum[i+1])
# print("b", b)
count2 = 0
for i in b:
    # print(i)
    # print(C(i,2))
    count2 += C(i, 2)
print(count2)
    # if b[i]>=3:


# for i in range(n):
#     for j in range(n):
#         # if i != j:
#         if i < j:
#         #     print(s[i])
#         # print(s[j])
#             if s[i] == s[j]:
#                 count += 1
# # for i in range(n):
    
# print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
n = INT()

ans = 0
# a = [INT() for i in range(n)]
a = []
for i in range(n):
    a.append(INT())
l = []
# print(a)

for i in range(n):
    l = []
    for j in range(n):
        if i != j:
            l.append(a[j])
    print(max(l))
        # print(l)
        # print(max(l))

    # print(a[0:i], a[i:n])
    # print(ans)
# 


Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
n = INT()

ans = 0
# a = [INT() for i in range(n)]
a = []
for i in range(n):
    a.append(INT())
l = []
# print(a)

b = sorted(a, reverse=True)
# print(a)
m1 = b[0]
m2 = b[1]
for i in range(n):
    if a[i] != m1:
        print(m1)
    else:
        print(m2)
     




# # for i in range(n):
#     l = []
#     for j in range(n):
#         if i != j:
#             l.append(a[j])
#     print(max(l))
#         # print(l)
#         # print(max(l))

#     # print(a[0:i], a[i:n])
#     # print(ans)
#
Buggy python submission (verdict: Runtime Error):
l, r = map(int, input().split())
ans = 2020
a = l // 2019
b = r // 2019
ans = []
# print(a)
# print(b) # 2019 num
if a != b:
    print(0)
else:
    for i in range(l, r+1):
        ans.append(i % 2019)
    
ans.sort()
print(ans[0] * ans[1])
    #l.append()
# print(a, b)


# if l // 2019 != r // 2019:
#     #print(0)
# else:
#     a = l % 2019
#     b = l % 2019 + 1
#     print(a * b)
#     # b = r % 2019
    

# if r - l >= 2019:
#     print(0)
# # else:
#     for i in range(l,r + 1):
#         for j in range(i+1,r + 1):
#             if (i * j) % 2019 <= ans:
#                 ans = min(ans, (i * j) % 2019)
#     print(ans)




    #print(i)

Fixed submission:
l, r = map(int, input().split())
# 2019
if r - l >= 2019:
	print(0)

# この数の中に2019が含まれている．
# 2019 * 2019 - 2019 

else:
	ans = 10000
	for i in range(l, r + 1):
		for j in range(i + 1, r + 1):
			ans = min(ans, (i * j) % 2019)
	print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
ans = 2020
for i in range(l,r + 1):
    for j in range(i+1,r + 1):
        if (i * j) % 2019 <= ans:
            ans = min(ans, (i * j) % 2019)
print(ans)



    #print(i)

Fixed submission:
l, r = map(int, input().split())
# 2019
if r - l >= 2019:
	print(0)

# この数の中に2019が含まれている．
# 2019 * 2019 - 2019 

else:
	ans = 10000
	for i in range(l, r + 1):
		for j in range(i + 1, r + 1):
			ans = min(ans, (i * j) % 2019)
	print(ans)
Buggy python submission (verdict: Runtime Error):

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = [INT() for _ in range(M)]

b = [0] * (N + 2)
# 壊れているところが1
for i in A:
    b[i] = 1

dp = [0] * (N + 2)
# for i in range():

dp[0] = 1

if b[1] == 1:
    # あなあいてるのでそのルートは考えられない
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, N + 1):
    if b[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]

ans = dp[i] % mod
print(ans)


Fixed submission:

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = [INT() for _ in range(M)]

b = [0] * (N + 2)
# 壊れているところが1
for i in A:
    b[i] = 1

dp = [0] * (N + 2)
# for i in range():

dp[0] = 1

if b[1] == 1:
    # あなあいてるのでそのルートは考えられない
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, N + 1):
    if b[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]

ans = dp[N] % mod
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,T=map(int,input().split())
t=T+0.5
count=0

for i in range(1,t):
    if A*i<=t:
        count+=B    
    
print(count)

Fixed submission:
A,B,T=map(int,input().split())
t=T+0.5
t=int(t)
a=int(t/A)
print(a*B)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
s=list(input())
l=[]
def times(l,s):
    first=l[0]-1
    last=l[1]
    ss=[]
    count=0
    #5,4
    for i in range(first,last):
        ss.append(s[i])
    #print(ss)
    for i in range(len(ss)-1):
        if ss[i]=='A':
            if ss[i+1]=='C':
                count+=1
        #print(ss)
    return count

for i in range(Q):
    a=list(map(int,input().split()))
    l.append(a)
#print(l)

    
for c in l:
    ans=times(c,s)
    print(ans)






Fixed submission:
N,Q=map(int,input().split())
s=input()
#a=[]

l=[0]*(N)
for i in range(N-1):
    if s[i:i+2]=='AC':
        l[i+1]=l[i]+1
    else:
        l[i+1]=l[i]
#print(l)
ans=[]
for i in range(Q):
    first,last=map(int,input().split())
    ans.append(l[last-1]-l[first-1])

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
s=list(input())
l=[]
def times(l,s):
    first=l[0]-1
    last=l[1]
    ss=[]
    count=0
    #5,4
    for i in range(first,last):
        ss.append(s[i])
    #print(ss)
    for i in range(len(ss)-1):
        if ss[i]=='A' and ss[i+1]=='C':
            count+=1
    return count

for i in range(Q):
    a=list(map(int,input().split()))
    l.append(a)
#print(l)

    
for c in l:
    ans=times(c,s)
    print(ans)






Fixed submission:
N,Q=map(int,input().split())
s=input()
#a=[]

l=[0]*(N)
for i in range(N-1):
    if s[i:i+2]=='AC':
        l[i+1]=l[i]+1
    else:
        l[i+1]=l[i]
#print(l)
ans=[]
for i in range(Q):
    first,last=map(int,input().split())
    ans.append(l[last-1]-l[first-1])

for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=list(map(int,input().split()))
s=[]
flag=1
while len(l)!=0 or flag!=0:
    flag=0
    for i in range(len(l),0,-1):
        if i==l[i-1]:
            p=l[i-1]
            s.append(p)
            l.pop(i-1)
            flag=1
            break
ans=reversed(s)
ans=list(ans)
for i in ans:
    print(i)

Fixed submission:
N=int(input())
l=list(map(int,input().split()))
s=[]
flag=1
while len(l)!=0:
    flag=0
    for i in range(len(l),0,-1):
        if i==l[i-1]:
            p=l[i-1]
            s.append(p)
            l.pop(i-1)
            flag=1
            break
    if flag==0:
        ans=-1
        break

if flag==1:
    ans=reversed(s)
    ans=list(ans)
    for i in ans:
        print(i)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(1,c):
	if a%i==0 and b%i==0:
		l.append(i)
l.sort(reverse=True)
print(l[k-1])

Fixed submission:
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(1,c+1):
	if a%i==0 and b%i==0:
		l.append(i)
l.sort(reverse=True)
print(l[k-1])

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(c):
	if a%i==0 and b%i==0:
		l.append(i)
print(l[k-1])

Fixed submission:
a,b,k=map(int,input().split())
c=max(a,b)
l=[]
for i in range(1,c+1):
	if a%i==0 and b%i==0:
		l.append(i)
l.sort(reverse=True)
print(l[k-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
c=set(list(range(1,m+1)))#from 1 to m+1 set {}
#print(c)
for i in range(n):
    l=list(map(int,input().split()))
    a=l[1:]
    #l[0] no mean
    c=c & se t(a) # and > & 
    #print(c)
print(len(c))

Fixed submission:
n,m=map(int,input().split())
c=set(list(range(1,m+1)))#from 1 to m+1 set {}
#print(c)
for i in range(n):
    l=list(map(int,input().split()))
    a=l[1:]
    #l[0] no mean
    c=c & set(a) # and > & 
    #print(c)
print(len(c))
Buggy python submission (verdict: Runtime Error):
import pdb
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
d=[]
if len(x)!=1:
    for i in range(0,len(x)-1):
        d.append(x[i+1]-x[i])
    d.sort(reverse=True)
    for i in range(n-1):
        d.pop(0)
    ans=sum(d)
    print(ans)
else:
    print(0)
#pdb.set_trace()



Fixed submission:
import pdb
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
d=[]
if n<m:
    for i in range(0,len(x)-1):
        d.append(x[i+1]-x[i])
    d.sort(reverse=True)
    for i in range(n-1):
        d.pop(0)
    ans=sum(d)
    print(ans)
else:#koma are assigned
    print(0)
#pdb.set_trace()
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
cost=0
for i in range(n-1):
    if h[i]>h[i+1]:
        cost+=(h[i]-h[i+1])
    cost+=h[n-1]
print(cost)

Fixed submission:
l=list(map(int,input().split()))
l.remove(max(l))
print(int(l[0]*l[1]/2))
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
h = LIST()

dp = [INF] * N
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        if i + j < N:
            dp[i+j] = min(dp[i] + abs(h[i] - h[i+j]), dp[i+j])
        # if dp[i] >= dp[i-j] + abs(h[i]-h[i-j]):
        #     dp[i] = dp[i-j] + abs(h[i]-h[i-j])
print(dp[-1])



Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
h = LIST()

dp = [INF] * N
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        if i + j < N:
            dp[i+j] = min(dp[i] + abs(h[i] - h[i+j]), dp[i+j])
        # if dp[i] >= dp[i-j] + abs(h[i]-h[i-j]):
        #     dp[i] = dp[i-j] + abs(h[i]-h[i-j])
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, W = MAP()
L = [LIST() for _ in range(N)]

dp = [[0] * (W+1) for i in range(N+1)]
# for w, v in L:
for i in range(1, W+1):
    for j in range(1, N+1):
        w = L[j-1][0]
        v = L[j-1][1]
        if i - w >= 0: 
            dp[j][i] = max(dp[j-1][i-w] + v, dp[j][i])
        dp[j][i] = max(dp[j][i], dp[j-1][i])

print(dp[N][W])




Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, W = MAP()
L = [LIST() for _ in range(N)]

dp = [[0] * (W+1) for i in range(N+1)]
# for w, v in L:
for i in range(1, W+1):
    for j in range(1, N+1):
        w = L[j-1][0]
        v = L[j-1][1]
        if i - w >= 0: 
            dp[j][i] = max(dp[j-1][i-w] + v, dp[j][i])
        dp[j][i] = max(dp[j][i], dp[j-1][i])

print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = [INT() for i in range(N)]
H.sort()
ans = INF
for i in range(N-K+1):
    mi = H[i:i+K][0]
    ma = H[i:i+K][-1]
    tmp = ma - mi
    ans = min(tmp, ans)
print(ans)


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

Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = [INT() for i in range(N)]
H.sort()
ans = INF
for i in range(N-K+1):
    mi = H[i:i+K][0]
    ma = H[i:i+K][2]
    tmp = ma - mi
    ans = min(tmp, ans)
print(ans)


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

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
com=list(itertools.combinations(h,k))
#a=10**9
gap=[]
for i in range(len(com)):
    b=abs(max(com[i])-min(com[i]))
    gap.append(b)

a=min(gap)    
print(a)

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

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
com=list(itertools.combinations(h,k))
a=10**9
for i in range(len(com)):
    gap=abs(max(com[i])-min(com[i]))
    if gap<a:
        a=gap
print(a)

Fixed submission:
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
#for i in range(n-k+1):
print(min(h[i+k-1]-h[i] for i in range(n-k+1)))
Buggy python submission (verdict: Runtime Error):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X = MAP()

# a_0 = 1, p_0 = 1
a, p = [1], [1]
for i in range(N):
    # 漸化式
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

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

print(f(N, X))


Fixed submission:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X = MAP()

# a_0 = 1, p_0 = 1
a, p = [1], [1]
for i in range(N):
    # 漸化式
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

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

print(f(N, X))
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
x=[]
y=[]
h=[]
for l in L:
    x.append(l[0])
    y.append(l[1])
    h.append(l[2])
Cx=0
Cy=0
H=0

for i in range(101):#Cx
    for j in range(101):#Cy
        flag=True
        for k in range(N):
            if h[k]!=0:
                H=h[k]+abs(i-x[k])+abs(j-y[k])
                break

        for k in range(N):
            if h[k]!=max(H-abs(i-x[k])-abs(j-y[k]),0):
                flag=False
                break
        
        if flag==True:
            Cx,Cy=i,j
            break
    if flag==True:
        break
print("{} {} {}".format(Cx,Cy,H))
       

Fixed submission:
n=int(input())
if n==1:
    print('Hello World')
else:
    p=[int(input()) for i in range(n)]
    print(sum(p))