ZhenlongDai/ACPR huggingface dataset:
Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
ans = 0
for i in range(n):
    if x > 2 ** (n + 1 - i) - 1:
        x -= 2 ** (n + 1 - i) - 1
        ans += 2 ** (n - i)
    elif x == 2 ** (n + 1 - i) - 1:
        ans += 2 ** (n - i)
        break
    elif x == 2 ** (n + 1 - i) - 2:
        ans += 2 ** (n - i) - 1
        break
    else:
        x -= 1
print(ans)

Failing test case input:
6 30

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())
ans = 0
for i in range(n+1):
    if x > 2 ** (n + 1 - i) - 1:
        x -= 2 ** (n + 1 - i) - 1
        ans += 2 ** (n - i)
    elif x == 2 ** (n + 1 - i) - 1:
        ans += 2 ** (n - i)
        break
    elif x == 2 ** (n + 1 - i) - 2:
        ans += 2 ** (n - i) - 1
        break
    else:
        x -= 1
print(ans)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n+1):
    a.append(3+2*a[-1])
    p.append(1+2*p[-1])
def f(l,x):
    if l==0:return int(x==1)
    if x<=1+a[l-1]:
        return  f(l-1,x-1)
    else:return p[l-1]+1+f(l-1,x-2-a[l-1])
print(f(n,x))

Failing test case input:
10 65

Expected output:
31


Actual output:
30


Fixed submission (verdict: Accepted):
n,x=map(int,input().split())
a,p=[1],[1]
for i in range(n+1):
    a.append(3+2*a[-1])
    p.append(1+2*p[-1])
def f(l,x):
    if l==0:return int(x>=1)
    if x<=1+a[l-1]:
        return  f(l-1,x-1)
    else:return p[l-1]+1+f(l-1,x-2-a[l-1])
print(f(n,x))

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())

l = [1]
p = [1]

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

def result(n, x):
    if n == 0:
        if x == 1:
            return 1
        else:
            return 0
    if x == 1:
        return 0
    
    if l[n] == x:
        return p[n]
    
    if l[n]/2 + 1 <= x:
        return p[n-1] + 1
    else:
        return p[n-1]

print(result(n, x))

Failing test case input:
50 4321098765432109

Expected output:
2160549382716056

Actual output:
67108864


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())

l = [1]
p = [1]

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

def result(n, x):
    if n == 0:
        if x == 1:
            return 1
        else:
            return 0
    elif x == 1:
        return 0
    
    elif l[n] == x:
        return p[n]
    
    elif l[n]
        return p[n-1] + 1 + result(n-1, x - l[n]
    else:
        return result(n-1, x-1)

print(result(n, x))
Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x=map(int,input().split())
a=[1]
p=[1]
for i in range(n-1):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
  if n==0 and x==1:
    return 1
  elif n==0 or x<=1:
    return 0
  elif x<=1+a[n-1]:
    return f(n-1,x-1)
  else:
    return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(n,x))

Failing test case input:
50 1069850374224873

Expected output:
534925187112439


Actual output:
534925187112438


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

Problem: p03209
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, X = map(int, input().split())
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)



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


Failing test case input:
3 -8

Expected output:
0


Actual output:
1


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



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

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,X = map(int, input().split())
t = [0]*(N+1)
h = [0]*(N+1)
h[0]=1
t[0]=1
for i in range(1, N+1):
    h[i]=2*(h[i-1])+3
    t[i]=2*(t[i-1])+1
def find(n, x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=1+h[n-1]:
        return find(n-1, x-1)
    else:
        return t[n-1]+find(n-1, x-h[n-1])
print(find(N,X))


Failing test case input:
6 28

Expected output:
14


Actual output:
12


Fixed submission (verdict: Accepted):
N,X = map(int, input().split())
t = [0]*(N+1)
h = [0]*(N+1)
h[0]=1
t[0]=1
for i in range(1, N+1):
    h[i]=2*(h[i-1])+3
    t[i]=2*(t[i-1])+1
def find(n, x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=1+h[n-1]:
        return find(n-1, x-1)
    else:
        return t[n-1]+1+find(n-1, x-2-h[n-1])
print(find(N,X))
Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
pty = [[] for i in range(n + 1)]
lay = [[] for i in range(n + 1)]
pty[0] = 1
lay[0] = 1
for L in range(1, n + 1):
    pty[L] = 2 * pty[L - 1] + 1
    lay[L] = 2 * lay[L - 1 ] + 3
ans = 0
x -= 1
while x > 0 and L >= 0 :
    if x >= lay[L] + 1:
        x -= lay[L] + 1
        ans += pty[L] + 1
    else:
        L -= 1
        x -= 1
print(ans)

Failing test case input:
6 28

Expected output:
14


Actual output:
12


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())
pty = [[] for i in range(n + 1)]
lay = [[] for i in range(n + 1)]
pty[0] = 1
lay[0] = 1
for L in range(1, n + 1):
    pty[L] = 2 * pty[L - 1] + 1
    lay[L] = 2 * lay[L - 1 ] + 3
ans = 0
while x > 0:
    if x >= lay[L] + 1:
        x -= lay[L] + 1
        ans += pty[L] + 1
    elif x == lay[L]:
        x -= lay[L]
        ans += pty[L]
    else:
        L -= 1
        x -= 1
print(ans)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x=map(int,input().split())
a=[(1,1)]
for _ in range(n):
  a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]

if a[-1][0] in (x,x-1):
  print(a[-1][1])
  exit()
a=a[:-1]
x-=1

s=0
for i,j in a[::-1]:
  x-=1
  if i<=x:
    x-=i;s+=j
    if x>=1:
      x-=1;s+=1
print(s)

Failing test case input:
61 1240793510486497

Expected output:
620396755243242


Actual output:
620396755243241


Fixed submission (verdict: Accepted):
n,x=map(int,input().split())
a=[(1,1)]
for _ in range(n):
  a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]

if a[-1][0] in (x,x-1):
  print(a[-1][1])
  exit()
a=a[:-1]
s=0
for k in range(1,len(a)*2+1):
  i,j = a[-k 
  x -= k % 2
  if i <= x:
    x-=i;s+=j
    if x>=1:
      x-=1;s+=1

print(s)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
nx = list(map(int, input().split()))
n = nx[0]
x = nx[1]
p = 0
for i in range(n):
    l_thick = 2 ** (n - i + 1) - 3
    if x <= l_thick + 1:
        x = x - 1
    else:
        x = x - l_thick - 2
        p += 2 ** (n - i)
    if x == 0:
        break
print(p)

Failing test case input:
50 3396494817772502

Expected output:
1698247408886243


Actual output:
1698247408886242


Fixed submission (verdict: Accepted):
nx = list(map(int, input().split()))
n = nx[0]
x = nx[1]
p = 0
for i in range(n):
    l_thick = 2 ** (n - i + 1) - 3
    if x == 1:
        break
    elif x <= l_thick:
        x = x - 1
    elif x == l_thick + 1 :
        p += 2 ** (n - i) - 1
        break
    elif x <= l_thick * 2 + 1:
        x = x - l_thick - 2
        p += 2 ** (n - i)
    else:
        p += 2 * (2 ** (n - i) - 1) + 1
        break
print(p)
Problem: p03209
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,x = map(int, input().split())

b = [[1,1]]

for i in range(n):
    b.append([b[-1][0]*2+3, b[-1][1]*2+1])

ans = 0
for i in range(n):
    if x >= b[-1-i][0]:
        x -= b[-1-i][0]
        ans += b[-1-i][1]
        if x > 0:
            x-=1
            ans += 1
    x-=1
    if x<=0:
        break

print(ans)

Failing test case input:
4 20

Expected output:
10


Actual output:
8


Fixed submission (verdict: Accepted):
n,x = map(int, input().split())

b = [[1,1]]

for i in range(n):
    b.append([b[-1][0]*2+3, b[-1][1]*2+1])

ans = 0
for i in range(len(b)):
    if x >= b[-1-i][0]:
        x -= b[-1-i][0]
        ans += b[-1-i][1]
        if x > 0:
            x-=1
            ans += 1
        if x>=b[-1-i][0]:
            x -= b[-1 - i][0]
            ans += b[-1 - i][1]
            break
    x-=1
    if x<=0:
        break

print(ans)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



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

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

ans = 0
for i in range(2,N+2):
    if X - (dp[-i][1] + 2) >= 0:
        ans += dp[-i][0] + 1
        X -= (dp[-i][1] + 2)

    else:
        X -= 1

    if i == N+1 and X == 1:
        ans += 1

print(ans)

Failing test case input:
6 30

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):



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

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

ans = 0
for i in range(2,N+2):
    if X - (dp[-i][1] + 2) >= 0:
        ans += dp[-i][0] + 1
        X -= (dp[-i][1] + 2)

    else:
        X -= 1

    if i == N+1 and X >= 1:
        ans += 1

print(ans)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



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

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

ans = 0
for i in range(1,N+1):
    if X - (dp[-i][1] + 2) >= 0:
        ans += dp[-i][0] + 1
        X -= (dp[-i][1] + 2)
print(ans)

Failing test case input:
10 60

Expected output:
28


Actual output:
30


Fixed submission (verdict: Accepted):



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

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

ans = 0
for i in range(2,N+2):
    if X - (dp[-i][1] + 2) >= 0:
        ans += dp[-i][0] + 1
        X -= (dp[-i][1] + 2)

    else:
        X -= 1

    if i == N+1 and X >= 1:
        ans += 1

print(ans)
Problem: p03209
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,X = map(int,input().split())

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

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

Failing test case input:
8 19

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
N,X = map(int,input().split())

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

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

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, X = map(int, input(). split())
a, p = [1], [1]

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

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

print(xmas(N, X))

Failing test case input:
6 33

Expected output:
16


Actual output:
22


Fixed submission (verdict: Accepted):
N, X = map(int, input(). split())
a, p = [1], [1]

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

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

print(xmas(N, X))

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]+1):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] <= c:
        c = c - b[i][0] - 1
        res = res + b[i][1] + 1
    c = c - 1

if c == 1:
    res = res + 1


print(res)



Failing test case input:
7 32

Expected output:
15


Actual output:
12


Fixed submission (verdict: Accepted):
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] * 2 + 1 <= c:
        c = c - b[i][0]*2 - 1
        res = res + b[i][1] * 2 + 1
    elif b[i][0] <= c: 
        c = c - b[i][0]
        res = res + b[i][1]
        if c > 0:
            c = c - 1
            res = res + 1
    c = c - 1

if c > 0:
    res = res + c

print(res)
Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]+1):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] < c:
        c = c - b[i][0] - 1
        res = res + b[i][1] + 1
    c = c - 1

if c == 1:
    res = res + 1


print(res)



Failing test case input:
4 20

Expected output:
10


Actual output:
8


Fixed submission (verdict: Accepted):
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] * 2 + 1 <= c:
        c = c - b[i][0]*2 - 1
        res = res + b[i][1] * 2 + 1
    elif b[i][0] <= c: 
        c = c - b[i][0]
        res = res + b[i][1]
        if c > 0:
            c = c - 1
            res = res + 1
    c = c - 1

if c > 0:
    res = res + c

print(res)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

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

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

print(calc(N,X))

Failing test case input:
6 32

Expected output:
15


Actual output:
16


Fixed submission (verdict: Accepted):

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

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

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

print(calc(N,X))

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
x -= 1


def main(n, x):
    if n == 0:
        if x == 0:
            return 1
        else:
            return 0
    if x == 0:
        return 0
    if x == 2 ** (n + 1) - 2:
        return 2 ** n
    if x < 2 ** (n + 1) - 2:
        return main(n - 1, x - 1)
    return 2 ** n + main(n - 1, x - (2 ** (n + 1) - 1))


print(main(n, x))

Failing test case input:
10 65

Expected output:
31


Actual output:
30


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())
x -= 1


def main(n, x):
    if n == 0:
        if x >= 0:
            return 1
        else:
            return 0
    if x == 0:
        return 0
    if x == 2 ** (n + 1) - 2:
        return 2 ** n
    if x < 2 ** (n + 1) - 2:
        return main(n - 1, x - 1)
    return 2 ** n + main(n - 1, x - (2 ** (n + 1) - 1))


print(main(n, x))
Problem: p03209
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n,x = map(int,input().split())
a,p = [1],[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def calc(n,x):
    if n==0:
        return 1 if x>0 else 0
    else:
        if x>a[n-1]:
            return p[n-1]+1+calc(n-1,x-2-a[n-1])
        else:
            return calc(n-1,x-1)
print(calc(n,x))

Failing test case input:
50 3396494817772502

Expected output:
1698247408886243


Actual output:
1698247408886244


Fixed submission (verdict: Accepted):
n,x = map(int,input().split())
a,p = [1],[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def calc(n,x):
    if n==0:
        return 1 if x>0 else 0
    else:
        if x>a[n-1]+1:
            return p[n-1]+1+calc(n-1,x-2-a[n-1])
        else:
            return calc(n-1,x-1)
print(calc(n,x))

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]+1):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] <= c:
        c = c - b[i][0] - 1
        res = res + b[i][1] + 1
    c = c - 1

if c > 0:
    res = res + c
print(res)

Failing test case input:
50 3396494817772502

Expected output:
1698247408886243


Actual output:
1698247408886244


Fixed submission (verdict: Accepted):
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] * 2 + 1 <= c:
        c = c - b[i][0]*2 - 1
        res = res + b[i][1] * 2 + 1
    elif b[i][0] <= c: 
        c = c - b[i][0]
        res = res + b[i][1]
        if c > 0:
            c = c - 1
            res = res + 1
    c = c - 1

if c > 0:
    res = res + c

print(res)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, X = map(int, input().strip().split())

totalp = [1]
totalb = [1]
for _ in range(1, N+1):
  totalp.append(totalp[-1]*2 + 1)
  totalb.append(totalp[-1]*2 + 3)

def burger(N, X):
  if N == 0:
    return 0 if X == 0 else 1
  elif X < totalb[N-1] + 1:
    return burger(N-1, X-1)
  else:
    return totalp[N-1] + burger(N-1, X-2-totalp[N-1])

print(burger(N, X))


Failing test case input:
10 60

Expected output:
28


Actual output:
27


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

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

print(f(N, X))
Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, X = map(int,input().split())

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

Failing test case input:
50 4321098765432109

Expected output:
2160549382716056

Actual output:
2160549382716062


Fixed submission (verdict: Accepted):
N, X = map(int,input().split())

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

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, X = map(int,input().split())

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

Failing test case input:
50 4321098765432109

Expected output:
2160549382716056

Actual output:
2160549382716060


Fixed submission (verdict: Accepted):
N, X = map(int,input().split())

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

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
nx = list(map(int, input().split()))
n = nx[0]
x = nx[1]
p = 0
for i in range(n):
    l_thick = 2 ** (n - i + 1) - 3
    if x <= l_thick:
        x = x - 1
    elif x == l_thick + 1 :
        p += 2 ** (n - i) - 1
        break
    else:
        x = x - l_thick - 2
        p += 2 ** (n - i)
print(p)

Failing test case input:
10 65

Expected output:
31


Actual output:
30


Fixed submission (verdict: Accepted):
nx = list(map(int, input().split()))
n = nx[0]
x = nx[1]
p = 0
for i in range(n):
    l_thick = 2 ** (n - i + 1) - 3
    if x == 1:
        break
    elif x <= l_thick:
        x = x - 1
    elif x == l_thick + 1 :
        p += 2 ** (n - i) - 1
        break
    elif x <= l_thick * 2 + 1:
        x = x - l_thick - 2
        p += 2 ** (n - i)
    else:
        p += 2 * (2 ** (n - i) - 1) + 1
        break
print(p)
Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]+1):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] < c:
        c = c - b[i][0] - 1
        res = res + b[i][1] + 1
    c = c - 1

if c > 0:
    res = res + c
print(res)

Failing test case input:
50 1069850374224873

Expected output:
534925187112439


Actual output:
534925187112441


Fixed submission (verdict: Accepted):
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] * 2 + 1 <= c:
        c = c - b[i][0]*2 - 1
        res = res + b[i][1] * 2 + 1
    elif b[i][0] <= c: 
        c = c - b[i][0]
        res = res + b[i][1]
        if c > 0:
            c = c - 1
            res = res + 1
    c = c - 1

if c > 0:
    res = res + c

print(res)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x=map(int,input().split())
def b(j):
    return 2**(j+2)-3
def p(j):
    return 2**(j+1)-1
def f(n,x):
    if n==0:
        return 1
    elif x<=b(n-1)+1:
        return f(n-1,x-1)
    elif x==b(n-1)+2:
        return p(n-1)+1
    elif 2+b(n-1)<x<=2*b(n-1)+2:
        return p(n-1)+1+f(n-1,x-b(n-1)-2)
    else:
        return 2*p(n-1)+1
print(f(n,x))

Failing test case input:
61 787102107885139

Expected output:
393551053942568


Actual output:
393551053942569


Fixed submission (verdict: Accepted):
n,x=map(int,input().split())
def b(j):
    return 2**(j+2)-3
def p(j):
    return 2**(j+1)-1
def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    elif x<=b(n-1)+1:
        return f(n-1,x-1)
    elif x==b(n-1)+2:
        return p(n-1)+1
    elif 2+b(n-1)<x<=2*b(n-1)+2:
        return p(n-1)+1+f(n-1,x-b(n-1)-2)
    else:
        return 2*p(n-1)+1
print(f(n,x))

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x = map(int,input().split())

def f(N,X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X < 4*(2**(N-1))-2:
        return f(N-1,X-1)
    elif X == 4*(2**(N-1))-1:
        return 2**N
    elif X <= 4*(2**N) - 4:
        return 2**N + f(N-1,X -4*(2**(N-1)) + 1)
    else:
        return 2**N-1
print(f(n,x))
        

Failing test case input:
10 65

Expected output:
31


Actual output:
27


Fixed submission (verdict: Accepted):
n,x = map(int,input().split())

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

print(f(n,x))
Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())

a, p = [1], [1]

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

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

print(f(n, x))

Failing test case input:
3 -8

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())

a, p = [1], [1]

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

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

print(f(n, x))

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())

answer = 0
red = x

searching_index = n
while red > 0:
    for i in reversed(range(searching_index + 1)):
        length = 2**(i + 2) - 3
        if red >= length:
            print("length", length, red)
            if red >= length + 1:
                print("contain p")
                answer += 1
                red -= 1
            searching_index = i
            answer += 2**(i+1) - 1
            red -= length
            print(answer, length)
            break
        red -= 1

print(answer)

Failing test case input:
11 30

Expected output:
12


Actual output:
length 13 21
contain p
8 13
length 5 6
contain p
12 5
12


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())

answer = 0
red = x

searching_index = n
while red > 0:
    for i in reversed(range(searching_index + 1)):
        length = 2**(i + 2) - 3
        if red >= length:
            if red >= length + 1:
                answer += 1
                red -= 1
            searching_index = i
            answer += 2**(i+1) - 1
            red -= length
            break
        red -= 1

print(answer)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
nx = list(map(int, input().split()))
n = nx[0]
x = nx[1]
p = 0
for i in range(n):
    l_thick = 2 ** (n - i + 1) - 3
    if x == 1:
        break
    elif x <= l_thick:
        x = x - 1
    elif x == l_thick + 1 :
        p += 2 ** (n - i) - 1
        break
    elif x <= l_thick * 2 + 1:
        x = x - l_thick - 2
        p += 2 ** (n - i)
    else:
        p += 2 * (2 ** (n - i) - 1) + 1
print(p)

Failing test case input:
7 32

Expected output:
15


Actual output:
25


Fixed submission (verdict: Accepted):
nx = list(map(int, input().split()))
n = nx[0]
x = nx[1]
p = 0
for i in range(n):
    l_thick = 2 ** (n - i + 1) - 3
    if x == 1:
        break
    elif x <= l_thick:
        x = x - 1
    elif x == l_thick + 1 :
        p += 2 ** (n - i) - 1
        break
    elif x <= l_thick * 2 + 1:
        x = x - l_thick - 2
        p += 2 ** (n - i)
    else:
        p += 2 * (2 ** (n - i) - 1) + 1
        break
print(p)
Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x=map(int,input().split())
a=[(1,1)]
for _ in range(n):
  a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]

if a[-1][0] in (x,x-1):
  print(a[-1][1])
  exit()
a=a[:-1]
 
s=0
for i,j in a[::-1]:
  x-=1
  if i<=x:
    x-=i;s+=j
    if x>=1:
      x-=1;s+=1
print(s)

Failing test case input:
6 30

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
n,x=map(int,input().split())
a=[(1,1)]
for _ in range(n):
  a+=[(a[-1][0]*2+3,a[-1][1]*2+1)]

if a[-1][0] in (x,x-1):
  print(a[-1][1])
  exit()
a=a[:-1]
s=0
for k in range(1,len(a)*2+1):
  i,j = a[-k 
  x -= k % 2
  if i <= x:
    x-=i;s+=j
    if x>=1:
      x-=1;s+=1

print(s)

Problem: p03209
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



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

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

ans = 0
for i in range(2,N+1):
    if X - (dp[-i][1] + 2) >= 0:
        ans += dp[-i][0] + 1
        X -= (dp[-i][1] + 2)

    else:
        X -= 1

if X >= 1:
    ans += 1
print(ans)

Failing test case input:
6 30

Expected output:
15


Actual output:
13


Fixed submission (verdict: Accepted):



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

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

ans = 0
for i in range(2,N+2):
    if X - (dp[-i][1] + 2) >= 0:
        ans += dp[-i][0] + 1
        X -= (dp[-i][1] + 2)

    else:
        X -= 1

    if i == N+1 and X >= 1:
        ans += 1

print(ans)

Problem: p03209
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, X = map(int, input().split())
a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)



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


Failing test case input:
8 19

Expected output:
7


Actual output:
8


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



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



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


Failing test case input:
50 4321098765432109

Expected output:
2160549382716056

Actual output:
1688849860263936


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



def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= a[N-1]+1:
        
        return f(N-1, X-1)
    else:
        
        return p[N-1]+1+f(N-1, X-2-a[N-1])
print(f(N, X))
Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):


while True:
    num = int(input())

    if num == 0: 
        break
    
    list = []
    for i in range(num):
        list.append(int(input()))

    for i in range(1, num):
        list[i] = max(list[i - 1] + list[i], list[i])

    print((list))

Failing test case input:
7
-4
-4
6
14
15
-8
-14
13
1
0
3
2
-3
-1
1
1
5
3
0
-6
2
3
1100
-200
145
0

Expected output:
35
12
1100


Actual output:
[-4, -4, 6, 20, 35, 27, 13]
[1, 1, 4, 6, 3, 2, 3, 4, 9, 12, 12, 6, 8]
[1100, 900, 1045]


Fixed submission (verdict: Accepted):


while True:
    num = int(input())

    if num == 0: 
        break
    
    list = []
    for i in range(num):
        list.append(int(input()))

    for i in range(1, num):
        list[i] = max(list[i - 1] + list[i], list[i])

    print(max(list))

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    n = int(input())
    if n == 0:
        break
    a = [int(input()) for _ in range(n)]
    a[:0] = [0]
    for i in range(1, len(a)):
        a[i] += a[i - 1]
    print(max(a) - min(a))

Failing test case input:
7
-5
-2
6
4
8
-6
-13
13
1
2
3
0
-4
-1
1
0
3
2
1
-2
1
3
1000
-358
325
0

Expected output:
18
8
1000


Actual output:
19
8
1000


Fixed submission (verdict: Accepted):
import itertools
while True:
    n = int(input())
    if n == 0:
        break
    a = [int(input()) for _ in range(n)]
    a[:0] = [0]
    for i in range(1, len(a)):
        a[i] += a[i - 1]
    print(max(map(lambda x:x[1] - x[0], itertools.combinations(a, 2))))

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    num = int(input())
    if not num: break
    result = 0
    for _ in range(num):
        new = int(input())
        result = max(new, result, result+new)
    print(result)

Failing test case input:
7
-5
-4
6
8
15
-6
-12
13
1
2
3
2
-2
-1
1
1
3
2
0
-4
2
3
1100
-200
145
0

Expected output:
29
12
1100


Actual output:
29
17
1245


Fixed submission (verdict: Accepted):
while True:
    num = int(input())
    if not num: break
    result, tmp = -1e6, 0
    for _ in range(num):
        new = int(input())
        tmp = max(new, new+tmp)
        result = max(tmp, result)
    print(result)

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
while(1):
    a=[]
    result=0
    n = int(input())
    if n==0:
        break
    a=[int(input()) for i in range(n)]
    for i in range(n):
        if a[i]>=0:
            result=result+a[i]
    print(result)

Failing test case input:
7
-5
-2
6
8
9
-6
-7
13
1
2
6
2
-2
-1
1
1
3
2
1
-2
1
3
1000
-200
201
0

Expected output:
23
16
1001


Actual output:
23
20
1201


Fixed submission (verdict: Accepted):
while(1):
    a=[]
    n = int(input())
    if n==0:
        break
    a=[int(input()) for i in range(n)]
    result=[]
    for i in range(n):
        result1=a[i]
        result.append(result1)
        for j in range(i+1,n):
            result1=result1+a[j]
            result.append(result1)
    print(max(result))
Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    N=int(input())
    if N==0:
        break
    num=0
    res=-11111111
    for i in range(N):
        a=int(input())
        num=max(num+a,a)
        res=max(num,res)

    print(num)



Failing test case input:
7
-5
-1
6
4
6
-6
0
13
2
2
0
2
-2
-1
1
1
6
2
0
-3
4
3
0000
-200
397
0

Expected output:
16
14
397


Actual output:
10
14
397


Fixed submission (verdict: Accepted):
while True:
    N=int(input())
    
    if N==0:
        break
    
    num=0
    res=-11111111
    for i in range(N):
        a=int(input())
        num=max(num+a, a)
        
        res=max(num, res)
        

    print(res)

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
import itertools

while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = [int(input()) for i in range(n)]
        a = list(itertools.accumulate(a))
        a.insert(0, 0)
        ans = -1000000
        for j in range(n + 1):
            for k in range(n + 1):
                ans = max(ans, a[k] - a[j])
        print(ans)

Failing test case input:
7
-5
-2
6
4
8
-6
-13
13
1
2
3
0
-4
-1
1
0
3
2
1
-2
1
3
1000
-358
325
0

Expected output:
18
8
1000


Actual output:
19
8
1000


Fixed submission (verdict: Accepted):
import itertools

while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = [int(input()) for i in range(n)]
        a = list(itertools.accumulate(a))
        a.insert(0, 0)
        ans = -100000
        for j in range(n):
            for k in range(j + 1, n + 1):
                ans = max(ans, a[k] - a[j])
        print(ans)

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
while 1:
    n=int(input())
    if n==0:break
    nlist=[]
    nans=-100001
    for i in range(n):
        nlist.append(int(input()))
    nkeep=0
    for i in nlist:
        if i>0 and nkeep>=0:
            nkeep+=i
        elif nkeep<0:
            nkeep=i
        if nans<nkeep:nans=nkeep
    if max(nlist)<0:nans=max(nlist)
    print(nans)


Failing test case input:
7
-5
-2
6
3
10
-6
-7
13
1
2
3
2
-2
-3
1
1
3
2
1
-2
1
3
1000
-200
201
0

Expected output:
19
11
1001


Actual output:
19
17
1201


Fixed submission (verdict: Accepted):
while 1:
    n=int(input())
    if n==0:break
    nlist=[]
    nans=-100001
    for i in range(n):
        nlist.append(int(input()))
    nkeep=0
    for i in nlist:
        if nkeep<0:
            nkeep=i
        else:
            nkeep+=i
        if nans<nkeep:nans=nkeep
    if max(nlist)<0:nans=max(nlist)
    print(nans)
Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
from sys import stdin

def getMax(array):
    mx = mx2 = array[0]
    for i in array[1:]:
        mx2 = max(i, mx2 + i)
        print(mx2,mx)
        mx = max(mx, mx2)
    return mx

for line in stdin:
    n = int(line)
    if n == 0:
        break
    array = []
    for line in stdin:
        line = int(line)
        array.append(line)
        if len(array) == n:
            break
    print(getMax(array))

Failing test case input:
7
-5
-2
6
8
9
-6
-7
13
1
0
3
2
-2
-1
0
1
3
2
0
-3
2
3
1000
-200
150
0

Expected output:
23
9
1000


Actual output:
-2 -5
6 -2
14 6
23 14
17 23
10 23
23
1 1
4 1
6 4
4 6
3 6
3 6
4 6
7 6
9 7
9 9
6 9
8 9
9
800 1000
950 1000
1000


Fixed submission (verdict: Accepted):
from sys import stdin

def getMax(array):
    mx = mx2 = array[0]
    for i in array[1:]:
        mx2 = max(i, mx2 + i)
        mx = max(mx, mx2)
    return mx

for line in stdin:
    n = int(line)
    if n == 0:
        break
    array = []
    for line in stdin:
        line = int(line)
        array.append(line)
        if len(array) == n:
            break
    print(getMax(array))

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    num = int(input())
    if not num: break
    result, tmp = 0, 0
    for _ in range(num):
        new = int(input())
        tmp = max(new, new+tmp)
        result = max(tmp, result)
        print(new, tmp, result)
    if tmp < 0:
        result = tmp
    print(result)

Failing test case input:
7
-5
-2
6
4
8
-6
-13
13
1
2
4
0
-4
-1
1
0
3
2
1
-2
1
3
1000
-358
325
0

Expected output:
18
9
1000


Actual output:
-5 -5 0
-2 -2 0
6 6 6
4 10 10
8 18 18
-6 12 18
-13 -1 18
-1
1 1 1
2 3 3
4 7 7
0 7 7
-4 3 7
-1 2 7
1 3 7
0 3 7
3 6 7
2 8 8
1 9 9
-2 7 9
1 8 9
9
1000 1000 1000
-358 642 1000
325 967 1000
1000


Fixed submission (verdict: Accepted):
while True:
    num = int(input())
    if not num: break
    result, tmp = -1e6, 0
    for _ in range(num):
        new = int(input())
        tmp = max(new, new+tmp)
        result = max(tmp, result)
    print(result)

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
import itertools

while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = [int(input()) for i in range(n)]
        a = list(itertools.accumulate(a))
        a.insert(0, 0)
        ans = a[1]
        for j in range(n + 1):
            for k in range(n + 1):
                ans = max(ans, a[k] - a[j])
        print(ans)

Failing test case input:
7
-5
-1
6
4
0
-6
-7
13
1
2
1
2
-2
-1
1
2
6
1
1
-3
1
3
1000
-200
201
0

Expected output:
10
14
1001


Actual output:
13
14
1001


Fixed submission (verdict: Accepted):
import itertools

while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = [int(input()) for i in range(n)]
        a = list(itertools.accumulate(a))
        a.insert(0, 0)
        ans = -100000
        for j in range(n):
            for k in range(j + 1, n + 1):
                ans = max(ans, a[k] - a[j])
        print(ans)
Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):



n = []
a = []

i = 0
while True:
    n.append(int(input()))
    if n[i] == 0:
        break
    for j in range(0,n[i]):
        a.append(int(input()))
    i += 1

count = 0
for i in range(0,len(n)):
    sumMax = 0
    for j in range(count,count + n[i]):
        tmp = 0
        for k in range(j,count + n[i]):
            tmp += a[k]
            sumMax = max(sumMax,tmp)
    count += n[i]
    print(sumMax)

Failing test case input:
7
-4
-4
6
14
15
-8
-14
13
1
0
3
2
-3
-1
1
1
5
3
0
-6
2
3
1100
-200
145
0

Expected output:
35
12
1100


Actual output:
35
12
1100
0


Fixed submission (verdict: Accepted):



while True:
    n = int(input())
    if n == 0:
        break
    a = []
    for i in range(0,n):
        a.append(int(input()))
    sumMax = -100000
    for i in range(0,n):
        tmp = 0
        for j in range(i,n):
            tmp += a[j]
            sumMax = max(sumMax,tmp)
    print(sumMax)

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    n=int(input())
    if n == 0: break

    ans=0
    l=[]

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

Failing test case input:
7
-5
-2
6
8
9
-6
-7
13
1
2
3
1
-2
-1
2
1
3
2
0
-4
2
3
1000
-72
145
0

Expected output:
23
12
1073


Actual output:
0
0
0


Fixed submission (verdict: Accepted):
while True:
    n=int(input())
    if n == 0: break

    ans=-1e100
    l=[]

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

Problem: p00022
Buggy submission (Python3, verdict: Wrong Answer):
while 1:
 n=int(input())
 if n==0:break
 a=[int(input())for _ in[0]*n]
 for i in range(n-1):a[i]=max(a[i],a[i]+a[i-1])
 print(max(a))


Failing test case input:
7
-5
0
6
4
6
-6
0
13
2
2
0
2
-2
-1
1
2
6
2
1
-3
4
3
0000
-200
201
0

Expected output:
16
16
201


Actual output:
16
19
201


Fixed submission (verdict: Accepted):
while 1:
 n=int(input())
 if n==0:break
 a=[int(input())for _ in[0]*n]
 for i in range(1,n):a[i]=max(a[i],a[i]+a[i-1])
 print(max(a))
Problem: p02765
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(100*(10-N))

Failing test case input:
0 1051

Expected output:
2051


Actual output:
1000


Fixed submission (verdict: Accepted):
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R+(100*(10-N)))

Problem: p02765
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, R = map(int, input().split())
print(R + 100 * (10 - N))

Failing test case input:
15 206

Expected output:
206


Actual output:
-294


Fixed submission (verdict: Accepted):
N, R = map(int, input().split())
print(R + 100 * (10 - N) if N <= 10 else R)

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, R = map(int, input().split())

A = int(0)


if N>=10:
  A = N
else:
  A = 100*(10-N)+R

print(A)

Failing test case input:
76 1018

Expected output:
1018


Actual output:
76


Fixed submission (verdict: Accepted):
N, R = map(int, input().split())

A = int(0)


if N>=10:
  A = R
else:
  A = 100*(10-N)+R

print(A)

Problem: p02765
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,R=map(int,input().split())
if N>=10:
    print(R)
else:
    print(R-(100*(10-N)))

Failing test case input:
1 1051

Expected output:
1951


Actual output:
151


Fixed submission (verdict: Accepted):
N,R=map(int,input().split())
if N>=10:
    print(R)
else:
    print(R+(100*(10-N)))

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,R=map(int,input().split())
if N>=10:
    print(R)
else:
    R-=100*(10-N)
    print(R)


Failing test case input:
0 -28

Expected output:
972


Actual output:
-1028


Fixed submission (verdict: Accepted):
N,R=map(int,input().split())
if N>=10:
    print(R)
else:
    print(R+100*(10-N))

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, r = map(int, input().split())
if n < 10:
  print(r)
else:
  print(r + 100*(10 - n))

Failing test case input:
9 319

Expected output:
419


Actual output:
319


Fixed submission (verdict: Accepted):
n, r = map(int, input().split())
if n >= 10:
  print(r)
else:
  print(r + 100*(10 - n))

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,r=map(int,input().split())
if n>=10:
    print(r)
else:
    print(r-1000+100*n)

Failing test case input:
1 139

Expected output:
1039


Actual output:
-761


Fixed submission (verdict: Accepted):
n,r=map(int,input().split())
if n>=10:
    print(r)
else:
    print(r+1000-100*n)

Problem: p02765
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,R=map(int,input().split())
if N>=10:
    print(R)
else:
    print(R-100*(10-N))

Failing test case input:
0 503

Expected output:
1503


Actual output:
-497


Fixed submission (verdict: Accepted):
N,R=map(int,input().split())
if N>=10:
    print(R)
else:
    print(R+100*(10-N))
Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print(b if a>=10 else b+100*(10-b))

Failing test case input:
1 503

Expected output:
1403


Actual output:
-48797


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
print(b if a>=10 else b+100*(10-a))

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, r = map(int, input().split())
print(r-100*(10-n))

Failing test case input:
0 -28

Expected output:
972


Actual output:
-1028


Fixed submission (verdict: Accepted):
n, r = map(int, input().split())
print( r if n >= 10 else r+100*(10-n))

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
if a>=10:
  print(b)
else:
  print(b+100*(10-b))

Failing test case input:
1 2265

Expected output:
3165


Actual output:
-223235


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
if a>=10:
  print(b)
else:
  print(b+100*(10-a))

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
[N, R] = [int(i) for i in input().split()]
ans = R + (100*(10-N))
print(ans)

Failing test case input:
17 3619

Expected output:
3619


Actual output:
2919


Fixed submission (verdict: Accepted):
[N, R] = [int(i) for i in input().split()]
ans = R
if N < 10:
    ans = R + (100*(10-N))
print(ans)

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N  , R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(N + 100*(10 - R))

Failing test case input:
9 206

Expected output:
306


Actual output:
-19591


Fixed submission (verdict: Accepted):
N  , R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R + 100*(10 - N))

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, r=map(int, input().split())
if n>9:
    print(r)
else:
    print(r-100*(10-n))
    

Failing test case input:
0 1615

Expected output:
2615


Actual output:
615


Fixed submission (verdict: Accepted):
n, r=map(int, input().split())
if n>9:
    print(r)
else:
    print(r+100*(10-n))

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
if n >= 10:
  print(k)
else:
  print(n + 100 * (10-k))

Failing test case input:
9 319

Expected output:
419


Actual output:
-30891


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
if n >= 10:
  print(k)
else:
  print(k + 100 * (10-n))

Problem: p02765
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,R = map(int,input().split())
if N < 10:
  R = 100 * (10 - N)
  print(R)
else:
  print(R)

Failing test case input:
0 -16

Expected output:
984


Actual output:
1000


Fixed submission (verdict: Accepted):
N,R = map(int,input().split())
if N < 10:
  R = R + 100 * (10 - N)
  print(R)
else:
  print(R)

Problem: p02765
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,R = map(int,input().split())
print(R if N <= 10 else R+N*100)

Failing test case input:
-1 -22

Expected output:
1078


Actual output:
-22


Fixed submission (verdict: Accepted):
N,R = map(int,input().split())
print(R if N >= 10 else R+(10-N)*100)