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

Fixed submission:
n, k = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0
coma = 1
comb = 1
for i in range(min(k+1, n)):
    ans += coma * comb
    ans %= mod
    coma *= (n-i) * pow(i+1, mod-2, mod)
    coma %= mod
    comb *= (n-i-1) * pow(i+1, mod-2, mod)
    comb %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

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

def co(n, r):
    x = comb(n, r, exact=True) % (10 ** 9 + 7)
    return x

if k >= n:
    ans = (2 ** (n-1)) % (10 ** 9 + 7)
else:
    ans = 0

    for i in range(k+1):
        y = (co(n-1, i) * co(n, i)) % (10 ** 9 + 7)
        ans += y

    ans % (10 ** 9 + 7)

print(ans)
Problem p03041 (python)

Fixed submission:
N, K = map(int,input().split())
S = list(input())
if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'
T = ''.join(S)
print(T)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000)
N = int(input())
JU = [-1] * N

LI = [[] for _ in range(N)]
for _ in range(N-1):
    u,v,w = map(int,input().split())
    W = w%2
    LI[u-1].append([v-1,W])
    LI[v-1].append([u-1,W])
def dfs(x):
    for i in range(len(LI[x])):
        j = LI[x][i][0]
        k = LI[x][i][1]
        if JU[j] == -1:
            if JU[i] == 0:
                if k == 0:
                    JU[j] = 0
                    dfs(j)
                else:
                    JU[j] = 1
                    dfs(j)
            else:
                if k == 0:
                    JU[j] = 1
                    dfs(j)
                else:
                    JU[j] = 0
                    dfs(j)

for i in range(N):
    if JU[i] == -1:
        JU[i] = 0
        dfs(i)
for i in range(N):
    print(JU[i])
Problem p02759 (python)

Fixed submission:
print((int(input())+1)//2)

Buggy submission (verdict: Runtime Error):
print((int(input()+1)//2))
Problem p02659 (python)

Fixed submission:
a = input().split()
p = int(a[0])
q = round(float(a[1])*100)
print(p*q//100)

Buggy submission (verdict: Runtime Error):
import math
a = input().split()
p = int(a[0])
q = int(a[1]*100)
print(p*q//100)
Problem p03315 (python)

Fixed submission:
# ABC 101: A – Eating Symbols Easy
s = input()
print(s.count('+') - s.count('-'))

Buggy submission (verdict: Runtime Error):
----
Problem p03705 (python)

Fixed submission:
# AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement

n, a, b = [int(s) for s in input().split()]


if a == b:
    print(1)
elif a > b or n <= 2:
    print(0)
else:
    print((b - a) * (n - 2) + 1)

Buggy submission (verdict: Runtime Error):
# AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement

n, a, b = [int(s) for s in input().split()]


if a == b:
    print(1)
elif a > b or n <= 2:
    print(0)
else:
    candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
    sum_variations = []

    for candidate in candidates:
        if sum(candidate) not in sum_variations:
            sum_variations.append(sum(candidate))
    
    print(len(sum_variations))

Buggy submission (verdict: Runtime Error):
# AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement

n, a, b = [int(s) for s in input().split()]


if a == b:
    print(1)
elif a > b or n == 1:
    print(0)
else:
    candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
    sum_variations = []

    for candidate in candidates:
        if sum(candidate) not in sum_variations:
            sum_variations.append(sum(candidate))
    
    print(len(sum_variations))

Buggy submission (verdict: Runtime Error):
# AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement

n, a, b = [int(s) for s in input().split()]

if a > b or n == 1:
    print(0)
elif a == b:
    print(1)
else:
    candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
    sum_variations = []

    for candidate in candidates:
        if sum(candidate) not in sum_variations:
            sum_variations.append(sum(candidate))
    
    print(len(sum_variations))

Buggy submission (verdict: Runtime Error):
# AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement

n, a, b = [int(s) for s in input().split()]

if a > b:
    print(0)
elif a == b:
    print(1)
else:
    candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
    sum_variations = []

    for candidate in candidates:
        if sum(candidate) not in sum_variations:
            sum_variations.append(sum(candidate))
    
    print(len(sum_variations))
Problem p03774 (python)

Fixed submission:
# ABC 057: B – Checkpoints
n, m = [int(s) for s in input().split()]

a = []
b = []

for i in range(n):
    tmp = [int(s) for s in input().split()]
    a.append(tmp[0])
    b.append(tmp[1])

c = []
d = []

for j in range(m):
    tmp = [int(s) for s in input().split()]
    c.append(tmp[0])
    d.append(tmp[1])

for i in range(n):
    checkpoint = 0
    distance = abs(c[0] - a[i]) + abs(d[0] - b[i])
    
    for j in range(m):
        if distance > abs(c[j] - a[i]) + abs(d[j] - b[i]):
            distance = abs(c[j] - a[i]) + abs(d[j] - b[i])
            checkpoint = j
    
    print(checkpoint + 1)

Buggy submission (verdict: Runtime Error):
# ABC 057: B – Checkpoints
studentPoints = []
checkPoints = []
n, m = map(int, input().split())
for _ in range(n):
    studentPoints.append([int(s) for s in input().split()])
for _ in range(m):
    checkPoints.append([int(s) for s in input().split()])

for i in range(n):
    distances = [abs(studentPoints[i][0] - checkPoints[k][0]) + abs(studentPoints[i][1] - checkPoints[k][1]) for k in range(m)]
    target = distances.index(min(distances))
    print(target + 1)
    m -= 1

Buggy submission (verdict: Runtime Error):
# ABC 057: B – Checkpoints
studentPoints = []
checkPoints = []
n, m = map(int, input().split())
for _ in range(n):
    studentPoints.append([int(s) for s in input().split()])
for _ in range(m):
    checkPoints.append([int(s) for s in input().split()])

for i in range(n):
    distances = [abs(studentPoints[i][0] - checkPoints[k][0]) + abs(studentPoints[i][1] - checkPoints[k][1]) for k in range(m)]
    target = distances.index(min(distances))
    print(target + 1)
    m -= 1

Buggy submission (verdict: Runtime Error):
# ABC 057: B – Checkpoints
n, m = [int(s) for s in input().split()]

a = []
b = []

for i in range(n):
    tmp = [int(s) for s in input().split()]
    a.append(tmp[0])
    b.append(tmp[1])

c = []
d = []

for j in range(m):
    tmp = [int(s) for s in input().split()]
    c.append(tmp[0])
    d.append(tmp[1])

for i in range(n):
    checkpoint = 0
    distance = abs(c[i] - a[0]) + abs(d[i] - b[0])
    
    for j in range(m):
        if distance > abs(c[j] - a[i]) + abs(d[j] - b[i]):
            distance = abs(c[j] - a[i]) + abs(d[j] - b[i])
            checkpoint = j
    
    print(checkpoint + 1)
Problem p02623 (python)

Fixed submission:
n,m,k=input().split()
a=input().split()
b=input().split()
ta=0
cnta=0
while int(cnta)<int(n) and ta+int(a[cnta])<=int(k) :
    ta= ta+ int(a[cnta])
    cnta=cnta+1
tb=0
cntb=0
while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
    tb = tb+ int(b[cntb])
    cntb=cntb+1 
ans=cnta+cntb

while cnta-1>=0:
    ta=ta-int(a[cnta-1])
    cnta=cnta-1
    while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
        tb= tb+ int(b[cntb])
        cntb=cntb+1
    ans=max(ans,cnta+cntb)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=input().split()
a=input().split()
b=input().split()
ta=0
cnta=0
while int(cnta)<int(n) and ta+int(a[cnta])<=int(k) :
    ta= ta+ int(a[cnta])
    cnta=cnta+1
tb=0
cntb=0
while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
    tb = tb+ int(b[cntb])
    cntb=cntb+1 
ans=cnta+cntb

while cnta<=0:
    ta=ta-int(a[cnta])
    cnta=cnta-1
    while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
        tb= tb+ int(b[cntb])
        cntb=cntb+1
    ans=max(ans,cnta+cntb)
print(ans)

Buggy submission (verdict: Runtime Error):
m,n,k=input().split()
a=input().split()
b=input().split()
ta=0
cnta=0
while ta+int(a[cnta])<=int(k) and int(cnta)<int(n):
    ta= ta+ int(a[cnta])
    cnta=cnta+1
tb=0
cntb=0
while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
    tb = tb+ int(b[cntb])
    cntb=cntb+1 
ans=cnta+cntb

while cnta<=0:
    ta=ta-int(a[cnta])
    cnta=cnta-1
    while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
        tb= tb+ int(b[cntb])
        cntb=cntb+1
    ans=max(ans,cnta+cntb)
print(ans)

Buggy submission (verdict: Runtime Error):
m,n,k=input().split()
a=input().split()
b=input().split()
ta=0
cnta=0
while ta+int(a[cnta])<=int(k) and int(cnta)<int(n):
    ta= ta+ int(a[cnta])
    cnta=cnta+1
tb=0
cntb=0
while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
    tb = tb+ int(b[cntb])
    cntb=cntb+1 
ans=cnta+cntb

while cnta<=0:
    ta=ta-a[cnta]
    cnta=cnta-1
    while cntb<int(m) and ta+tb+int(b[cntb])<=int(k):
        tb= tb+ int(b[cntb])
        cntb=cntb+1
    ans=max(ans,cnta+cntb)
print(ans)
Problem p02629 (python)

Fixed submission:
n=int(input())
ans = " "
while n>0:
    re=n%26
    if re!=0:
        ans= chr(ord('a')+re-1)+ans
        n=n//26
    else:
        ans='z'+ans
        n=(n//26)-1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans = " "
while n>0:
    re=n%26
    if re!=0:
        ans= chr(ord('a')+re-1)+ans
        n=n//26
    else:
        ans='z'+ans
        n=(n/26)-1
print(ans)
Problem p02711 (python)

Fixed submission:
#Lucky 7
num=int(input(""))
num3=num//100
num2=num//10%10
num1=num%10
if(num3==7 or num2==7 or num1==7):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#Lucky 7
input(nm)
num=int(nm)
num3=num/100
num2=num/10%10
num1=num%10
if(num3==7 or num2==7 or num1==7):
    print("Yes")
else:
    print("No")
Problem p02831 (python)

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

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
A,B = list(map(int,input().split()))
print(lcm(A, B))
Problem p02847 (python)

Fixed submission:
S = input()
week = ['SUN','MON','TUE','WED','THU','FRI','SAT']
ans = 7 - week.index(S)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A,B,X = input().split()
A = int(A)
B = int(B)
X = math.floor(int(X))
N = 0
tmp = 0
while tmp < X:
    tmp = A * N
    tmp += B * len(str(N))
    N += 1
if A == B:
    N += 1
print(N-2)
Problem p02689 (python)

Fixed submission:
import numpy as np
argList = list(map(int, input().split())) 
heights = list(map(int, input().split())) 

#いい展望台フラグ
check = np.array([1]*argList[0])

for n in range(argList[1]):
    #どことどこをつないでいるか
    con = list(map(int, input().split())) 
    #低かったらいい展望台ではない
    if heights[con[0]-1] <= heights[con[1]-1]:
        check[con[0]-1] = 0
    if heights[con[0]-1] >= heights[con[1]-1]:
        check[con[1]-1] = 0
print(np.sum(check))

Buggy submission (verdict: Runtime Error):
import numpy as np
argList = list(map(int, input().split())) 
heights = list(map(int, input().split())) 

#いい展望台フラグ
check = np.array([1]*argList[0])

for n in range(argList[0]-1):
    #どことどこをつないでいるか
    con = list(map(int, input().split())) 
    #print(con)
    #低かったらいい展望台ではない
    if heights[con[0]-1] < heights[con[1]-1]:
        check[con[0]-1] = 0
    else:
        check[con[1]-1] = 0
print(np.sum(check))

Buggy submission (verdict: Runtime Error):
import numpy as np
argList = list(map(int, input().split())) 
heights = list(map(int, input().split())) 

#いい展望台フラグ
check = np.array([1]*argList[0])

for n in range(argList[0]-1):
    #どことどこをつないでいるか
    con = list(map(int, input().split())) 
    #print(con)
    #低かったらいい展望台ではない
    if heights[con[0]-1] < heights[con[1]-1]:
        check[con[0]] = 0
    else:
        check[con[1]] = 0
print(np.sum(check))
Problem p02862 (python)

Fixed submission:
X,Y = [int(zz) for zz in input().split()]

mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

a = (2*Y-X)/3
b = (2*X-Y)/3

if a != int(a):
    print(0)
    exit()

a = int(a)
b = int(b)
N = a+b

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = cmb(N,a,mod)%(10**9+7)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
from numpy import linalg as LA

N = int(input())
li = [[1,N]]

for i in range(2,int(np.sqrt(N))+1):
    if N%i == 0:
        li.append([i,N//i])

ans = 10**12
for i in li:
    x,y = i
    tmp = LA.norm([x-1,y-1],1)
    if ans > tmp:
        ans = tmp

print(ans)
Problem p02891 (python)

Fixed submission:
S = input()
K = int(input())

N = len(S)
p = S[0]
c = 0

if N == 1:
    print(K//2)
    exit()

if len(set(S)) == 1:
    print(N*K//2)
    exit()

for i in range(1,N):
    if S[i] == p:
        c += 1
        p = ''
    else:
        p = S[i]

ans = c*K
if S[0] == S[-1]:
    p = S[0]
    c = 1
    for i in range(1,N):
        if p == S[i]:
            c += 1
        else:
            break

    d = 1
    for i in range(2,N+1):
        if p == S[-i]:
            d += 1
        else:
            break

    if (c%2)*(d%2) == 1:
        ans += K-1

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

N = len(S)
p = S[0]
c = 0
for i in range(1,N):
    if S[i] == p:
        c += 1
        p = ''
    else:
        p = S[i]

ans = c*K
if S[0] == S[-1] and S[-2] != S[-1]:
    ans += K-1

print(ans)
Problem p03013 (python)

Fixed submission:
N,M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)]

m = 10**9+7

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

memo[0] = 0

A.append(N+1)
p = A[0]
ans = memo[p]
for i in range(1,M+1):
    ans *= memo[A[i]-p-1]
    p = A[i]

print(ans%m)

Buggy submission (verdict: Runtime Error):
import math

N,M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)]

m = 10**9+7

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

A.append(N+1)
p = A[0]
ans = memo[p]
for i in range(1,M+1):
    print(ans)
    if p+1 == A[i]:
        print(0)
        exit()
    else:
        ans *= memo[A[i]-p-1]
        ans %= m
    p = A[i]

print(ans)
Problem p03018 (python)

Fixed submission:
S = list(input())
N = len(S)

ans = 0
flag = 0
ABCflag = 0

i = 0
while i < N-2:

    if S[i]+S[i+1]+S[i+2] == 'ABC':
        if flag:
            ans += flag
        ans += 1
        S[i+2] = 'A'
        i += 1

    elif S[i] == 'A':
        flag += 1

    else:
        flag = 0

    i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
	S = list(input())
N = len(S)

ans = 0
flag = 0
ABCflag = 0

i = 0
while i < N-2:

    if S[i]+S[i+1]+S[i+2] == 'ABC':
        ans += 1
        if flag:
            ans += flag
        if ABCflag:
            ans += ABCflag
            ABCflag = 0
        i += 2
        ABCflag += 1

    elif S[i] == 'A':
        flag += 1

    else:
        flag = 0
        if S[i]+S[i+1] == 'BC':
            if ABCflag:
                ans += ABCflag
                ABCflag = 0
            i += 1
        else:
            ABCflag = 0
    i += 1

print(ans)
Problem p03038 (python)

Fixed submission:
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
bc = [tuple(int(i) for i in input().split()) for _ in range(M)]

A.sort()
bc.sort(key=lambda t: t[1], reverse=True)

index = 0
count = 0
for i in range(N):
    if index >= M or A[i] >= bc[index][1]:
        break
    A[i] = bc[index][1]
    count += 1
    if bc[index][0] <= count:
        index += 1
        count = 0

print(sum(A))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

l = [[] for _ in range(M)]
for j in range(M):
    b,c = [int(i) for i in input().split()]
    l[j] = [c,b]

l.sort(reverse=True)
A.sort()
ans = 0

for i,j in l:
    for k in range(N):
        if i <= A[k]:
            break
    k = min(k,j)
    ans += k*i
    A = A[k:]
if A:
    print(ans+sum(A))
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

l = [[] for _ in range(M)]
for j in range(M):
    b,c = [int(i) for i in input().split()]
    l[j] = [c,b]

l.sort(reverse=True)
A.sort()
ans = 0

for i,j in l:
    for k in range(N):
        if i <= A[k]:
            break
    k = min(k,j)
    ans += k*i
    A = A[k:]
print(ans+sum(A))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

l = [[] for _ in range(M)]
for j in range(M):
    b,c = [int(i) for i in input().split()]
    l[j] = [c,b]

l.sort(reverse=True)
A.sort()
ans = 0

for i,j in l:
    for k in range(N):
        if i <= A[k]:
            break
    k = min(k,j)
    ans += k*i
    A = A[k:]
    print(ans)

print(ans+sum(A))
Problem p03042 (python)

Fixed submission:
S = list(input())

p = S[0]+S[1]
q = S[2]+S[3]

p_flag = 0
q_flag = 0

if int(p) == 0 and int(q) == 0:
    print('NA')
elif int(p) == 0:
    if int(q) < 13:
        print('YYMM')
    else:
        print('NA')
elif int(q) == 0:
    if int(p) < 13:
        print('MMYY')
    else:
        print('NA')
else:
    if int(p) > 12:
        p_flag = 1
    if int(q) > 12:
        q_flag = 1

    if p_flag and q_flag:
        print('NA')
    elif p_flag:
        print('YYMM')
    elif q_flag:
        print('MMYY')
    else:
        print('AMBIGUOUS')

Buggy submission (verdict: Runtime Error):
S = list(input())

p = S[0]+S[1]
q = S[2]+S[3]

p_flag = 0
q_flag = 0

if int(q) = 0 and int(p) == 0:
    print('NA')
elif int(p) == 0:
    print('YYMM')
elif int(q) == 0:
    print('MMYY')
else:
    if int(p) > 12:
        p_flag = 1
    if int(q) > 12:
        q_flag = 1

    if p_flag and q_flag:
        print('NA')
    elif p_flag:
        print('YYMM')
    elif q_flag:
        print('MMYY')
    else:
        print('AMBIGUOUS')
Problem p03724 (python)

Fixed submission:
N,M = [int(i) for i in input().split()]

q = [0] * N
for _ in range(M):
    a,b = [int(i) for i in input().split()]
    q[a-1] += 1
    q[b-1] += 1

for i in range(M):
    if q[i]%2 != 0:
        print('NO')
        exit()

print('YES')

Buggy submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]

q = [0] * N
for _ in range(N):
    a,b = [int(i) for i in input().split()]
    q[a-1] += 1
    q[b-1] += 1

for i in range(M):
    if q[i]%2 != 0:
        print('NO')
        exit()

print('YES')
Problem p04005 (python)

Fixed submission:
li = [int(i) for i in input().split()]

for i in li:
    if i%2 == 0:
        print(0)
        exit()

li.remove(max(li))
ans = 1
for i in li:
    ans *= i

print(ans)

Buggy submission (verdict: Runtime Error):
li = [int(i) for i in input().split()]

for i in li:
    if i%2 == 0:
        print(0)
        exit()

li.pop(max(li))
ans = 1
for i in li:
    ans *= i

print(ans)
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split(" "))
S = input()

alp = S[K-1]
if alp == "A":
  print(S[:K-1] + "a" + S[K:])
elif alp == "B":
  print(S[:K-1] + "b" + S[K:])
else:
  print(S[:K-1] + "c" + S[K:])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
S = input()

alp = S[K-1]
if alp == "A":
  S[K-1] = "a"
elif alp == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
  
print(S)
Problem p03075 (python)

Fixed submission:
a = []
for i in range(5):
  a.append(int(input()))
k = int(input())

if a[4] - a[0] <= k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = []
for i in range(5):
  a.append(int(input()))
k = int(input())

ans = "Yay!"
for i in range(4):
  for j in range(i+1, 5):
  	if a[i] - a[j] > k:
    	ans = ":("
    
print(ans)
Problem p03077 (python)

Fixed submission:
N = int(input())
norimono = []
for _ in range(5):
  norimono.append(int(input()))
  
print((N-1) // min(norimono) + 5)

Buggy submission (verdict: Runtime Error):
N = int(input())
norimono = []
for _ in range(5):
  norimono.append(int(input()))
  
if 
print((N-1) // min(norimono) + 5)
Problem p03209 (python)

Fixed submission:
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])


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)
    
print(f(n, x))

Buggy submission (verdict: Runtime Error):
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])


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)
    
print(f(n, x))
Problem p03221 (python)

Fixed submission:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
s=[]
for i in enumerate(l):
    s.append(i)
s=sorted(s,key=lambda x:(x[1][0],x[1][1]))
#print(s)
a=1
for i in range(m):
    if i==0:
        s[0][1][1]=1
    elif s[i][1][0]==s[i-1][1][0]:
        a+=1
        s[i][1][1]=a
    elif s[i][1][0]!=s[i-1][1][0]:
        a=1
        s[i][1][1]=a
#print(s)
s=sorted(s,key=lambda x:x[0])
#print(s)
for i in s:
    print('%06d'%i[1][0]+'%06d'%i[1][1])

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
#print(l)
li=[[]*n for _ in range(n)]
lis=sorted(l)
for i in lis:
    li[i[0]-1].append(i[1])
    print(li)
for i in l:
    a=li[i[0]-1].index(i[1])
    print(str('%06d'%i[0])+str('%06d'%(a+1)))
Problem p02781 (python)

Fixed submission:
from itertools import combinations, product
from math import factorial

def nCr(n, r):
  return int(factorial(n) / factorial(n - r) / factorial(r))

n = int(input())
k = int(input())
size = len(str(n))
count = 0 if k > size - 1 else nCr(size - 1, k) * (9 ** k)
if k == 1:
  count += sum(i * (10 ** (size - 1)) <= n for i in range(1, 10))
else:
  first = int(str(n)[0])
  count += 0 if k > size else (first - 1) * nCr(size - 1, k - 1) * (9 ** (k - 1))
  for digits in combinations(range(size - 1), k - 1):
    count += sum(
      sum(num * (10 ** digit) for num, digit in zip(nums, digits)) <= n % (10 ** (size - 1))
      for nums in product(range(1, 10), repeat = k - 1)
    )
print(count)

Buggy submission (verdict: Runtime Error):
from itertools import combinations, product
from math import factorial

def nCr(n, r):
  return int(factorial(n) / factorial(n - r) / factorial(r))

n = int(input())
k = int(input())
size = len(str(n))
count = 0 if k > size - 1 else (nCr(size - 1, k) * (9 ** k))
if k == 1:
  count += sum(i * (10 ** (size - 1)) <= n for i in range(1, 10))
else:
  first = int(str(n)[0])
  count += (first - 1) * nCr(size - 1, (k - 1)) * (9 ** (k - 1))
  for digits in combinations(range(size - 1), k - 1):
    count += sum(
      sum(num * (10 ** digit) for num, digit in zip(nums, digits)) <= n % (10 ** (size - 1))
      for nums in product(range(1, 10), repeat = k - 1)
    )
print(count)
Problem p02847 (python)

Fixed submission:
print(7 - ['SUN','MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'].index(input()))

Buggy submission (verdict: Runtime Error):
index(['SUN','MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT])print(7 - ['SUN','MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'].index(input()))