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

Fixed submission:
s=input()
if s =="AAA" or s=="BBB":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
ppy
Problem p02862 (python)

Fixed submission:
X,Y=map(int,input().split())
import math

def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

def f2(r):

    return inv_t
def co(n,r):
    P = 10**9 + 7
    N = r+1
    inv_t = [0]+[1]
    for i in range(2,N+1):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
    ans =1
    for i in range(1,r+1):
        ans = (ans * (n+i-1)) % P
    for i in range(1,r+1):
        ans = (ans * inv_t[i]) % P
    return ans
if (X+Y)%3==0:
    Z=X+Y
    if min(X,Y)-Z//3 >-1:
        #print(1)
        print(combination(Z//3,min(X,Y)-Z//3))
        #print(co(Z//3,min(X,Y)-Z//3))
    else:
        print(0)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
import math
def f2(r):

    return inv_t
def co(n,r):
    P = 10**9 + 7
    N = r+1
    inv_t = [0]+[1]
    for i in range(2,N+1):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
    ans =1
    for i in range(1,r+1):
        ans = (ans * (n+i-1)) % P
    for i in range(1,r+1):
        ans = (ans * inv_t[i]) % P
    return ans
if (X+Y)%3==0:
    Z=X+Y
    if min(X,Y)-Z//3 >-1:
        #print(1)
        comb = Combination(Z)
        print(comb(Z//3,min(X,Y)-Z//3))
        #print(co(Z//3,min(X,Y)-Z//3))
    else:
        print(0)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
X,Y=map(int,input().split())
import math
def f2(r):

    return inv_t
def co(n,r):
    P = 10**9 + 7
    N = r+1
    inv_t = [0]+[1]
    for i in range(2,N+1):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
    ans =1
    for i in range(1,r+1):
        ans = (ans * (n+i-1)) % P
    for i in range(1,r+1):
        ans = (ans * inv_t[i]) % P
    return ans
if (X+Y)%3==0:
    Z=X+Y
    if min(X,Y)-Z//3 >-1:
        #print(1)
        comb = Combination(Z//3)
        print(comb(Z//3,min(X,Y)-Z//3))
        #print(co(Z//3,min(X,Y)-Z//3))
    else:
        print(0)
else:
    print(0)
Problem p02916 (python)

Fixed submission:
N=int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happy=0
for i in range(0,N-1):
  happy+=B[A[i]-1]
  if A[i+1] == A[i] + 1:
    happy+=C[A[i]-1]
happy+=B[A[N-1]-1]
print(happy)

Buggy submission (verdict: Runtime Error):
N=int(input())
A = sorted([int(x) for x in input().split()])
B = sorted([int(x) for x in input().split()])
C = sorted([int(x) for x in input().split()])

happy=0
for i in range(0,N-1):
  happy+=B[A[i]]
  if A[i+1] == A[i] + 1:
    happy+=C[A[i]]
happy+=B[A[N-1]]
print(happy)
Problem p02987 (python)

Fixed submission:
S=input()
if len(set(S)) == 2 and S.count(S[0]) ==2:
    print("Yes")     
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
H=10 ** 9 + 7
ans=N-K+1
print(ans)
for i in range(1,K):
    P=(N-K-i+1)/(i+1)
    Q=(K-i)/i
    if ans< H :
        ans=int(ans*P*Q)
        print(ans)
    else:
        ans=int(ans*P*Q % H)
        print(ans)
Problem p02989 (python)

Fixed submission:
N=int(input())
D=list(map(int,input().split()))
 
D=sorted(D)
K=D[N//2]-D[N//2-1]
print(K)

Buggy submission (verdict: Runtime Error):
N=int(input())
P=list(map(int,input().split()))

D=sorted(D)
K=D[N//2]-D[N//2-1]
print(K)
Problem p03013 (python)

Fixed submission:
#!/home/ryo/.pyenv/versions/anaconda3-2019.03/envs/hoge/bin/python
import sys

lim=10**9+7
N,M = map(int,input().split())
A = set([int(input()) for _ in range(M)])
memo = [0] * (N+1)
memo[0]=1

if not 1 in A:
    memo[1]=1
for i in range(2, N+1):
    if not i in A:
        memo[i] = (memo[i - 1] + memo[i - 2]) % lim
print(memo[-1])

Buggy submission (verdict: Runtime Error):
#!/home/ryo/.pyenv/versions/anaconda3-2019.03/envs/hoge/bin/python
import sys
def fib(n):
    memo = [0] * (n+1)
    memo[0:2] = [0, 1]
    for i in range(2, n+1):
        memo[i] = memo[i - 1] + memo[i - 2]
    return memo

lim=10**9+7

N,M = map(int,input().split())
A=[]
for i in range(0,M):
    A.append(int(input()))
diff=[]
for i in range(0,len(A)-1):
    diff.append(A[i+1]-A[i]-1)
if 0 in diff:
    print(0)
    sys.exit()
else:
    max_n=diff.copy()
    max_n.append(A[0])
    max_n.append(N-A[-1])
    memo_fib=fib(max(max_n))
    #print(memo_fib)
    ans=memo_fib[A[0]]
    #print(ans)
    for i in diff:
        ans= ans * memo_fib[i] % lim
        #print(i, ans)
ans=ans*memo_fib[N-A[-1]] % lim
print(ans)
Problem p03127 (python)

Fixed submission:
import fractions
N=int(input())
A=[int(x) for x in input().split()]
ans=A[0]
for a in A[1:]:
  ans=fractions.gcd(ans,a)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
A=[int(x) for x in input().split()]
ans=A[0]
for a in A[1:]:
  ans=math.gcd(ans,a)
print(ans)
Problem p03209 (python)

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

from functools import lru_cache
import sys

sys.setrecursionlimit(10*20)

@lru_cache(maxsize=None)
def count(N):
    if N == 0:
        return 1
    else:
        return 3 + 2 * count(N-1)
    
@lru_cache(maxsize=None)
def calc(N,X):
    if N == 0:
        return 1
    center = count(N-1) + 1
    if X == 0 :
        return 0
    elif X < center:
        return calc(N-1,X-1)
    elif X == center:
        return calc(N-1,center-2) + 1
    elif X > center:
        return calc(N-1,X-center-1) + calc(N,center)
print(calc(N,X-1))

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

from functools import lru_cache
import sys

sys.setrecursionlimit(10*20)

@lru_cache(maxsize=None)
def count(N):
    if N == 0:
        return 1
    else:
        temp = pan(N-1)
        return 3 + 2 * count(N-1)
    
@lru_cache(maxsize=None)
def calc(N,X):
    if N == 0:
        return 1
    center = count(N-1) + 1
    if X == 0 :
        return 0
    elif X < center:
        return calc(N-1,X-1)
    elif X == center:
        return calc(N-1,center-2) + 1
    elif X > center:
        return calc(N-1,X-center-1) + calc(N,center)
print(calc(N,X-1))

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

from functools import lru_cache
import sys

sys.setrecursionlimit(10*10)

@lru_cache(maxsize=None)
def count(N):
    if N == 0:
        return 1
    else:
        temp = pan(N-1)
        return 3 + 2 * count(N-1)
    
@lru_cache(maxsize=None)
def calc(N,X):
    if N == 0:
        return 1
    center = count(N-1) + 1
    if X == 0 :
        return 0
    elif X < center:
        return calc(N-1,X-1)
    elif X == center:
        return calc(N-1,center-2) + 1
    elif X > center:
        return calc(N-1,X-center-1) + calc(N,center)
print(calc(N,X-1))

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

from functools import lru_cache

@lru_cache(maxsize=None)
def count(N):
    if N == 0:
        return 1
    else:
        temp = pan(N-1)
        return 3 + 2 * count(N-1)
    
@lru_cache(maxsize=None)
def calc(N,X):
    if N == 0:
        return 1
    center = count(N-1) + 1
    if X == 0 :
        return 0
    elif X < center:
        return calc(N-1,X-1)
    elif X == center:
        return calc(N-1,center-2) + 1
    elif X > center:
        return calc(N-1,X-center-1) + calc(N,center)
print(calc(N,X-1))

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

from functools import lru_cache

@lru_cache(maxsize=None)
def count(N):
    if N == 0:
        return 1
    else:
        temp = pan(N-1)
        return 3 + 2 * count(N-1)
    
@lru_cache(maxsize=None)
def calc(N,X):
    if N == 0:
        return 1
    center = count(N-1) + 1
    if X == 0 :
        return 0
    elif X < center:
        return calc(N-1,X-1)
    elif X == center:
        return calc(N-1,center-2) + 1
    elif X > center:
        return calc(N-1,X-center-1) + calc(N,center)
print(calc(N,X-1))
Problem p03252 (python)

Fixed submission:
import sys
s=input()
t=input()
n=len(s)
d=dict()
d2=dict()
for i in range(n):
    if t[i] in d.keys():
        if d[t[i]] != s[i]:
            print("No")
            sys.exit()
    else:
        d[t[i]] = s[i]
    
    if s[i] in d2.keys():
        if d2[s[i]] != t[i]:
            print("No")
            sys.exit()
    else:
        d2[s[i]] = t[i]
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
s=input()
t=input()
n=len(s)-1
d=dict()
for i in range(n):
  if t[i] in d.keys():
  	if d[t[i]] != s[i]:
      print("No")
      sys.exit()
  else:
    d[t[i]] = s[i]
else:
  print("Yes")
Problem p03272 (python)

Fixed submission:
N, i =map(int,input().split())
print(N-i+1)

Buggy submission (verdict: Runtime Error):
N, i =int(input().split())
print(N-i+1)
Problem p03329 (python)

Fixed submission:
import math
N=int(input())
l=[1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]
dp=[100000 for _ in range(N+1)]
dp[0] = 0
for i in l:
    if i > N:
        break
    for j in range(i,N+1):
        dp[j] = min(dp[j],dp[j-i]+1)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
l=[1]
for i in range(1,int(math.log(N,6))+1):
    l.append(6**i)
for i in range(1,int(math.log(N,9))+1):
    l.append(9**i)
l.sort()
dp=[math.inf for _ in range(N+1)]
dp[0] = 0
for i in range(len(l)):
    for j in range(l[i],N+1):
        dp[j] = min(dp[j],dp[j-l[i]]+1)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
l=[1]
for i in range(1,int(math.log(N,6))+1):
    l.append(6**i)
for i in range(1,int(math.log(N,9))+1):
    l.append(9**i)
l.sort()
dp=[math.inf for _ in range(N+1)]
dp[0] = 0
for i in range(len(l)):
    for j in range(l[i],N+1):
        dp[j] = min(dp[j],dp[j-l[i]]+1)
print(dp[-1])
Problem p03426 (python)

Fixed submission:
h,w,d=map(int,input().split())
A=[]
for _ in range(h):
    A.append([int(i) for i in input().split()])
q=int(input())
lr=[]
for _ in range(q):
    l,r = map(int,input().split())
    lr.append((l,r))
D=dict()
for i in range(h):
    for j in range(w):
        D[A[i][j]]=(i,j)

def dist(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])
#ans=[[-1 for _ in range(h*w//d+1)] for _ in range(d)]
res=dict()
for i in range(d):
    j=i+1
    cnt=0
    res[j]=0
    #ans[i][0] = 0
    while j<=h*w-d:
        #ans[i][cnt+1] = ans[i][cnt] + dist(D[j],D[j+d])
        res[j+d] = res[j]+dist(D[j],D[j+d]) #ans[i][cnt]
        j+=d
        cnt+=1
for l,r in lr:
    print(res[r]-res[l])

Buggy submission (verdict: Runtime Error):
h,w,d=map(int,input().split())
A=[]
for _ in range(h):
    A.append([int(i) for i in input().split()])
q=int(input())
lr=[]
for _ in range(q):
    l,r = map(int,input().split())
    lr.append((l,r))
D=dict()
for i in range(h):
    for j in range(w):
        D[A[i][j]]=(i,j)

def dist(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])
#ans=[[-1 for _ in range(h*w//d+1)] for _ in range(d)]
res=dict()
for i in range(d):
    j=i+1
    cnt=0
    #ans[i][0] = 0
    while j<=h*w-d:
        #ans[i][cnt+1] = ans[i][cnt] + dist(D[j],D[j+d])
        res[j] = ans[i][cnt]
        j+=d
        cnt+=1
for l,r in lr:
    print(res[r]-res[l])
Problem p02679 (python)

Fixed submission:
import math
from collections import Counter

N = int(input())
A_B = []
mod = 1000000007
for _ in range(N):
    A, B = map(int, input().split())
    if (A == 0) and (B == 0):
        A_B.append((A, B))
    elif A == 0:
        A_B.append((0, -1))
    elif B == 0:
        A_B.append((1, 0))
    else:
        if A < 0:
            A = -A
            B = -B
        C = math.gcd(abs(A), abs(B))
        A_B.append((A // C, B // C))

A_B_C = Counter(A_B)


ans = 1
Done = set([])
Done.add((0, 0))
for key, value in A_B_C.items():
    if key in Done:
        continue
    keya, keyb = key
    a = 0
    if keya == 0 and keyb == 0:
        a = value + 1
        Done.add((0, 0))
    else:
        if keyb < 0:
            keya = -keya
            keyb = -keyb
        if (keyb, -keya) not in A_B_C:
            a = pow(2, value, mod)
        else:
            a = (pow(2, value, mod) - 1) + (pow(2, A_B_C[(keyb, -keya)], mod) - 1) + 1
            Done.add((keyb, -keya))
    ans *= a
    ans %= mod
    Done.add(key)
ans -= 1
ans += A_B_C[(0, 0)]

print(ans % mod)

Buggy submission (verdict: Runtime Error):
import math
from collections import Counter
N = int(input())
A_B = []
mod = 1000000007
for _ in range(N):
    A, B = map(int, input().split())
    if A < 0:
        A = -A
        B = -B
    C = math.gcd(abs(A), abs(B))
    A_B.append((A//C, B//C))
A_B_C = Counter(A_B)


hate_couple = 0
ans = 1
Done = set([])
for key, value in A_B_C.items():
    if key in Done:
        continue
    keya, keyb = key
    a = 0
    if keyb < 0:
        keya = -keya
        keyb = -keyb
    if (keyb, -keya) not in A_B_C:
        a = pow(2, value, mod)
    else:
        a = (pow(2, value, mod) - 1) + (pow(2, A_B_C[(keyb, -keya)], mod) - 1) + 1
        Done.add((keyb, -keya))
    ans *= a
    ans %= mod
    Done.add(key)

print((ans - 1)%mod)

Buggy submission (verdict: Runtime Error):
import fractions
from collections import Counter
N = int(input())
A_B = []
mod = 1000000007
for _ in range(N):
    A, B = map(int, input().split())
    if A < 0:
        A = -A
        B = -B
    C = fractions.gcd(abs(A), abs(B))
    A_B.append((A//C, B//C))
A_B_C = Counter(A_B)


hate_couple = 0
ans = 1
Done = set([])
for key, value in A_B_C.items():
    if key in Done:
        continue
    keya, keyb = key
    a = 0
    if keyb < 0:
        keya = -keya
        keyb = -keyb
    if (keyb, -keya) not in A_B_C:
        a = pow(2, value, mod)
    else:
        a = (pow(2, value, mod) - 1) + (pow(2, A_B_C[(keyb, -keya)], mod) - 1) + 1
        Done.add((keyb, -keya))
    ans *= a
    Done.add(key)

print(ans - 1)
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
num = N // (A + B) + 1
zan = num * (A + B) - N

if zan <= B:
    print(num * A)
else:
    print(num * A + B - zan)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

Ball = ''

while len(Ball) < N:
    Ball += "B" * A + "R" * B

print(Ball[:N].count("B"))

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
color = ''
while True:
    if len(color) < N:
        color = color + 'b' * A + 'r' * B
    else:
        break
num = color[:N].count('b')
print(num)

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
color = ''
while True:
    if len(color) < N:
        color = color + 'b' * A + 'r' * B
    else:
        break
num = color[:N].count('b')
print(num)
Problem p02831 (python)

Fixed submission:
import fractions
A, B = map(int, input().split())


def lcm(x, y):
    return x * y // fractions.gcd(x, y)


print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())


def lcm(x, y):
    return x * y // math.gcd(x, y)


print(lcm(A, B))
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
Broken = set([])
for _ in range(M):
    broken = int(input())
    Broken.add(broken)

DP = [0] * (N+1)
DP[0] = 1

for i in range(1, N+1):
    if i in Broken:
        continue
    DP[i] = DP[i-1] + DP[i-2]
    DP[i] %= 10**9 + 7
print(DP[N])

Buggy submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
Broken = deque()
for _ in range(M):
    broken = int(input())
    Broken.append(broken)

DP = [0] * (N+1)
DP[0] = 1

nex = Broken.popleft()

for i in range(1, N+1):
    if i == nex:
        if len(Broken) >0:
            nex = Broken.popleft()
        continue
    DP[i] = DP[i-1] + DP[i-2]
    DP[i] %= 10**9 + 7
print(DP[N])

Buggy submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
Broken = deque()
for _ in range(M):
    broken = int(input())
    Broken.append(broken)

DP = [0] * (N+1)
DP[0] = 1

nex = Broken.popleft()

for i in range(1, N+1):
    if i == nex:
        if len(Broken) >0:
            nex = Broken.popleft()
        continue
    DP[i] = DP[i-1] + DP[i-2]
    DP[i] %= 10**9 + 7
print(DP[N])
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
Alist = list(map(int, input().split()))
BClist = []
for i in range(M):
    B, C = map(int, input().split())
    BClist.append([B, C])
Alist.sort()
BClist.sort(reverse=True, key=lambda x: x[1])

num = 0
flag = True
for i in range(M):
    if not flag:
        break
    for j in range(BClist[i][0]):
        if num >= len(Alist):
            flag = False
            break
        elif BClist[i][1] > Alist[num]:
            Alist[num] = BClist[i][1]
            num += 1
        elif BClist[i][1] <= Alist[num]:
            flag = False
            break

print(sum(Alist))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
Alist = list(map(int, input().split()))
BClist = []
for i in range(M):
    B, C = map(int, input().split())
    BClist.append([B, C])
Alist.sort()
BClist.sort(reverse= True, key=lambda x: x[1])

num = 0
flag = True
for i in range(M):
    if not flag:
        break
    for j in range(BClist[i][0]):
        if num > len(Alist):
            flag = False
            break
        elif BClist[i][1] > Alist[num]:
            Alist[num] = BClist[i][1]
            num += 1
        elif BClist[i][1] <= Alist[num]:
            flag = False
            break

print(sum(Alist))
Problem p03053 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
que = deque()
A = [[0 for i in range(W)] for j in range(H)]
white_num = 0
for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == '.':
            A[i][j] = -1
            white_num += 1
        elif S[j] == '#':
            A[i][j] = 0
            que.append([j, i])

ans = 0
while len(que) > 0:
    x, y = que.popleft()
    for k in range(4):
        nx = x + [1, 0, -1, 0][k]
        ny = y + [0, 1, 0, -1][k]
        if nx < 0 or ny < 0 or nx >= W or ny >= H:
            continue
        if A[ny][nx] == -1:
            que.append([nx, ny])
            A[ny][nx] = A[y][x] + 1
            ans = max(ans, A[ny][nx])
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

H, W = map(int, input().split())
que = deque()
A = [[0 for i in range(W)] for j in range(H)]
white_num = 0
for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == '.':
            A[i][j] = -1
            white_num += 1
        elif S[j] == '#':
            A[i][j] = 0
            que.append([j, i])

ans = 0
while len(que) > 0:
    x, y = que.popleft()
    for k in range(4):
        nx = x + [1, 0, -1, 0][k]
        ny = y + [0, 1, 0, -1][k]
        if nx < 0 or ny < 0 or nx >= W or ny >= W:
            continue
        if A[ny][nx] == -1:
            que.append([nx, ny])
            A[ny][nx] = A[y][x] + 1
            ans = max(ans, A[ny][nx])
print(ans)

Buggy submission (verdict: Runtime Error):
import copy

H, W = map(int, input().split())
A = [[]for j in range(H)]
white_num = 0
for i in range(H):
    S = input()
    A[i] = S
    for j in range(W):
        if A[i][j] == '.':
            white_num += 1

ans = 0
while white_num > 0:
    A_ = copy.deepcopy(A)
    ans += 1
    for y in range(H):
        for x in range(W):
            if A[y][x] == "#":
                for k in range(4):
                    nx = x + [1, 0, -1, 0][k]
                    ny = y + [0, 1, 0, -1][k]
                    if nx < 0 or ny < 0 or nx >= W or ny >= W:
                        continue
                    if A[ny][nx] == "." and A_[ny][nx] == ".":
                        A_[ny] = A_[ny][:nx] + "#" + A_[ny][nx+1:]
                        white_num -= 1
    A = A_
print(ans)

Buggy submission (verdict: Runtime Error):
import copy

H, W = map(int, input().split())
A = [[]for j in range(H)]
white_num = 0
for i in range(H):
    S = input()
    A[i] = S
    for j in range(W):
        if A[i][j] == '.':
            white_num += 1

ans = 0
while white_num > 0:
    A_ = copy.deepcopy(A)
    ans += 1
    for y in range(H):
        for x in range(W):
            if A[y][x] == "#":
                for k in range(4):
                    nx = x + [1, 0, -1, 0][k]
                    ny = y + [0, 1, 0, -1][k]
                    if nx < 0 or ny < 0 or nx >= W or ny >= W:
                        continue
                    if A[ny][nx] == "." and A_[ny][nx] == ".":
                        A_[ny] = A_[ny][:nx] + "#" + A_[ny][nx+1:]
                        white_num -= 1
    A = A_
print(ans)
Problem p03209 (python)

Fixed submission:
N, X = map(int, input().split())
Size = [1]
Patty = [1]

for i in range(51):
    Size.append(Size[-1] * 2 + 3)
    Patty.append(Patty[-1] * 2 + 1)


def count_p(n, x):
    if x == 0:
        return 0
    if n == 0:
        return min(x, 1)
    if (Size[n]+1) // 2 > x:
        return count_p(n-1, x-1)
    elif (Size[n]+1) // 2 == x:
        return Patty[n-1] + 1
    else:
        return Patty[n-1] + 1 + count_p(n-1, x - ((Size[n]+1) // 2))


print(count_p(N, X))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N, X = map(int, input().split())
Burger = ['P']
for i in range(1,N+1):
    Burger_ = 'B' + Burger[i-1] + 'P' + Burger[i-1] + 'B'
    Burger.append(Burger_)
print(Burger[N][0:X].count('P'))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
Burger = ['P']
for i in range(1,N+1):
    Burger_ = 'B' + Burger[i-1] + 'P' + Burger[i-1] + 'B'
    Burger.append(Burger_)
print(Burger[N][0:X].count('P'))
Problem p02711 (python)

Fixed submission:
N=input()
if '7' in N:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
ans=0

for i in range(N-2):
    for j in range(i+1,N-1):
        if S[i]!=S[j]:
            for k in range(1,2*j-i):
                if S[j]!=S[k] and S[k]!=S[i]:
                    ans+=1
            for k in range(2*j-i+1,N):
                if S[j]!=S[k] and S[k]!=S[i]:
                    ans+=1
         
                
print(ans)
Problem p02759 (python)

Fixed submission:
x=int(input())
if x%2==0:
    print(int(x/2))
else:
    print(int(x/2)+1)

Buggy submission (verdict: Runtime Error):
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
 
for j in range(int(input())):
    X=int(input())
    for i in range(3):
        if X in a1:
            num=a1.index(X)
            a1[num]=[0]
        
        elif X in a2:
            num=a2.index(X)
            a2[num]=[0]
            
        elif X in a3:
            num=a3.index(X)
            a3[num]=[0]
        
        
        
C=False
for i in range(3):
    if a1.count(0)==3 or a2.count(0)==3 or a3.count(0)==3 or a1[0]==a2[0]==a3[0]==[0] or a1[1]==a2[1]==a3[1]==[0] or a1[2]==a2[2]==a3[2]==[0] or a1[0]==a2[1]==a3[2]==[0] or a1[0]==a2[1]==a3[2]==[0] or a1[2]==a2[1]==a3[0]==[0]:
        C=True
 
if C==True:
    print("Yes")
else:
    print("No")
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
import math

A,B = input().split()
#print(A*B)
ans = math.floor(Decimal(A)*Decimal(B))
print(ans)

Buggy submission (verdict: Runtime Error):
from decimal import Decimal

A,B = input().split()
#print(A*B)
ans = math.floor(Decimal(A)*Decimal(B))
print(ans)
Problem p02699 (python)

Fixed submission:
S,W = map(int,input().split())

if S <= W :
	print("unsafe")
else :
	print("safe")

Buggy submission (verdict: Runtime Error):
S = input()
#S = str(1817181712114)
ans = 0
 
for a in range(len(S) - 3):
	for b in range(a+3, len(S)):
		if int(S[a:b+1]) % 2019 == 0:
			ans += 1        
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
#S = str(1817181712114)
ans = 0

for a in range(len(S) - 3):
	for b in range(a+1, len(S)):
		if int(S[a:b+1]) % 2019 == 0:
			ans += 1        
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
#S = str(1817181712114)
ans = 0

for a in range(len(S)-1):
	for b in range(a+1, len(S)):
		if int(S[a:b+1]) % 2019 == 0:
			ans += 1        
print(ans)