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

Fixed submission:
import sys
from collections import deque

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

H, W = rl()
A = [list(rs()) for _ in range(H)]
answer = 0
que = deque()
data = [[-1] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            data[i][j] = 0
            que.append((j, i))
while que:
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    p = que.popleft()
    for i in range(4):
        nx = p[0] + dx[i]
        ny = p[1] + dy[i]
        if 0 <= ny <= H-1 and 0 <= nx <= W-1:
            if data[ny][nx] == -1:
                data[ny][nx] = data[p[1]][p[0]] + 1
                que.append((nx, ny))
answer = max([max(z) for z in data])
print(answer)
# 54

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

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

H, W = rl()
A = [list(rs()) for _ in range(H)]
answer = 0
que = deque()
data = [[-1] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            data[i][j] = 0
            que.append((i, j))
while que:
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    p = que.popleft()
    for i in range(4):
        nx = p[0] + dx[i]
        ny = p[1] + dy[i]
        if 0 <= ny <= H-1 and 0 <= nx <= W-1:
            if data[ny][nx] == -1:
                data[ny][nx] = data[p[1]][p[0]] + 1
                que.append((nx, ny))
answer = max([max(z) for z in data])
print(answer)
# 54

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

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

H, W = rl()
A = [list(rs()) for _ in range(H)]
answer = 0
que = deque()
data = [[-1] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            data[i][j] = 0
            que.append((i, j))
while que:
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    p = que.popleft()
    for i in range(4):
        nx = p[0] + dx[i]
        ny = p[1] + dy[i]
        if 0 <= ny <= H-1 and 0 <= nx <= W-1:
            if data[ny][nx] == -1:
                data[ny][nx] = data[p[1][0]] + 1
                que.append((nx, ny))
answer = max([max(z) for z in data])
print(answer)
# 54
Problem p03127 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

answer = reduce(gcd, A)
print(answer)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = lr()
A = np.array(lr())
g = np.gcd.reduce(A)
print(g)
Problem p03135 (python)

Fixed submission:
t,x=map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
print(eval(int(input()).replace(' ','/')))
Problem p03209 (python)

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

count_p = [1] * (N+1) # パティの数
for i in range(1, N+1):
    count_p[i] += count_p[i-1] * 2

length = [1] * (N+1) # バーガーの長さ
for i in range(1, N+1) :
    length[i] += (length[i-1] + 1) * 2

def F(n, x): # レベルnバーガーの下x層のあるパティの数
    if n == 0:
        return 0 if x <= 0 else 1
    if x == length[n] // 2 + 1:
        return count_p[n-1] + 1
    elif x > length[n] // 2 + 1:
        return count_p[n-1] + 1 + F(n-1, x-(length[n]//2+1))
    else:
        return F(n-1, max(0, x-1))
print(F(N, X))

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

S = 'P'
while N > 0:
    S = 'B' + S + 'P' + S + 'B'
    N -= 1
print(S[:X].count('P'))
Problem p03265 (python)

Fixed submission:
X1, Y1, X2, Y2 = map(int, input().split())
X3, Y3 = X2-(Y2-Y1), Y2+(X2-X1)
X4, Y4 = X3-(Y3-Y2), Y3+(X3-X2)
print(X3, Y3, X4, Y4)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

x1, y1, x2, y2 = lr()
P2 = np.array([x2, y2])  # 2つ目の点
A = np.array([[0, -1], [1, 0]])
vec = np.array([x2-x1, y2-y1])
vec2 = np.dot(A, vec)
vec3 = np.dot(A, vec2)
P3 = np.array(P2) + vec2
P4 = np.array(P3) + vec3
print(*P3, *P4)
Problem p03329 (python)

Fixed submission:
N=int(input())
ans=N
for i in range(N+1):
    cnt=0
    t = i
    while t>0:
        cnt+=t%6
        t//=6
    t=N-i
    while t>0:
        cnt+=t%9
        t//=9
    ans=min(ans,cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# dp
N = ir()
INF = 10 ** 8
dp = np.array([INF] * 100001)
dp[0] = 0
for i in range(5, 0, -1):
    num = 9 ** i
    for j in range(100000):
        if j+num <= N:
            dp[j+num] = min(dp[j+num], dp[j]+1)

for i in range(6, 0, -1):
    num = 6 ** i
    for j in range(100000):
        if j+num <= N:
            dp[j+num] = min(dp[j+num], dp[j]+1)

num = 1
for j in range(100000):
    dp[j+num] = min(dp[j+num], dp[j]+1)

answer = dp[N]
print(answer)
Problem p03634 (python)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def measure(x):
    dist = [INF] * (N)
    dist[x] = 0
    que = deque()
    que.append(x)
    while que:
        cur = que.popleft()
        cur_dist = dist[cur]
        for next, c in edges[cur]:
            if dist[next] == INF:
                dist[next] = cur_dist + c
                que.append(next)
    
    return dist

N = ir()
INF = 10 ** 15
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = lr()
    edges[a-1].append((b-1, c))
    edges[b-1].append((a-1, c))

Q, K = lr()
dist = measure(K-1)
for _ in range(Q):
    x, y = lr()
    print(dist[x-1] + dist[y-1])


# 20

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import shortest_path
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
graph = np.zeros((N, N)) #0-indexed
for _ in range(N-1):
    a, b, c = lr()
    graph[a-1, b-1] = c

dist = shortest_path(graph, directed=False).astype(int)
Q, K = lr()
K_dist = dist[K-1].tolist()
for _ in range(Q):
    x, y = lr()
    print(K_dist[x-1] + K_dist[y-1])

# 20

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import shortest_path
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
graph = np.zeros((N, N)) #0-indexed
for _ in range(N-1):
    a, b, c = lr()
    graph[a-1, b-1] = c

dist = shortest_path(graph, directed=False).astype(int)
Q, K = lr()
K_dist = dist[K-1]
for _ in range(Q):
    x, y = lr()
    print(K_dist[x-1] + K_dist[y-1])

# 20

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import shortest_path
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
graph = np.zeros((N, N)) #0-indexed
for _ in range(N-1):
    a, b, c = lr()
    graph[a-1, b-1] = c

dist = shortest_path(graph, directed=False).astype(int)
Q, K = lr()
for _ in range(Q):
    x, y = lr()
    print(dist[x-1, K-1] + dist[K-1, y-1])

# 20

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from scipy.sparse.csgraph import shortest_path

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
graph = np.zeros((N, N)) #0-indexed
for _ in range(N-1):
    a, b, c = lr()
    graph[a-1, b-1] = c

dist = shortest_path(graph, directed=False).astype(int)
Q, K = lr()
for _ in range(Q):
    x, y = lr()
    print(dist[x-1, K-1] + dist[K-1, y-1])

# 20
Problem p03776 (python)

Fixed submission:
import sys
import numpy as np
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
V = np.array(lr())
V.sort()
if A == 1:
    ave = V[-A]
else:
    ave = V[-A:].sum() / A
print(ave)
left_i = np.searchsorted(V, V[-A], side='left')
right_i = np.searchsorted(V, V[-A], side='right')
num = right_i - left_i
done = N - right_i

bottom = A-done
top = B-done

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

answer = combinations_count(num, bottom)
if ave == V[-A] and num > 1:
    for i in range(bottom+1, min(num, top)+1):
        answer += combinations_count(num, i)

print(answer)
# 15

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
V = np.array(lr(), np.float64)
V.sort()
V = V[::-1]
Vcum = V.cumsum()
ave = Vcum / np.arange(1, N+1)
ma = ave[A-1:B].max()
print(ma)
cases = 0
Vrev = V[::-1]
for i, x in enumerate(ave[A-1:B], A-1):
    if x != ma:
        continue
    j = np.searchsorted(Vrev, V[i])
    k = np.searchsorted(Vrev, V[i], side='right')
    if j+1 == k:
        cases += 1
        continue
    r = i+1-j
    n = k-j
    a = factorial(n) / factorial(r) / factorial(n - r)
    cases += a

print(int(cases))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import numpy as np
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
V = np.array(lr(), np.float64)
V.sort()
V = np.flip(V)
Vcum = V.cumsum()
ave = Vcum / np.arange(1, N+1)
ma = ave[A-1:B].max()
print(ma)
cases = 0
Vrev = np.flip(V)
for i, x in enumerate(ave[A-1:B], A-1):
    if x != ma:
        continue
    j = np.searchsorted(Vrev, V[i])
    k = np.searchsorted(Vrev, V[i], side='right')
    if j+1 == k:
        cases += 1
        continue
    r = i+1-j
    n = k-j
    a = factorial(n) / factorial(r) / factorial(n - r)
    cases += a

print(int(cases))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from math import factorial

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
V = np.array(lr())
V.sort()
if A == 1:
    ave = V[-A]
else:
    ave = V[-A:].sum() / A
print(ave)
left_i = np.searchsorted(V, V[-A], side='left')
right_i = np.searchsorted(V, V[-A], side='right')
num = right_i - left_i
done = N - right_i

bottom = A-done
top = B-done

def combinations_count(n, r):
    ''' 組み合わせ '''
    return factorial(n) // (factorial(n - r) * factorial(r))

answer = combinations_count(num, bottom)
if ave == V[-A] and num > 1:
    for i in range(bottom+1, top+1):
        answer += combinations_count(num, i)

print(answer)
# 15
Problem p03804 (python)

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

flag = 'No'
for i in range(N-M+1):
    for j in range(N-M+1):
        check = []
        for k in range(M):
            if A[i+k][j:j+M] == B[k]:
                check.append(1)
            else:
                check.append(-1)
        if sum(check) == M:
            flag = 'Yes'
print(flag)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

flag = 'No'
for i in range(N-M):
    for j in range(N-M):
        check = []
        for k in range(M):
            if A[i+k][j:j+M] == B[i+k]:
                check.append(1)
            else:
                check.append(-1)
        if sum(check) == M:
            flag = 'Yes'
print(flag)
Problem p04021 (python)

Fixed submission:
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
B = sorted(A)
B = set(B[1::2])
C = [i%2==1 and a not in B for i, a in enumerate(A)]
print(sum(C))

Buggy submission (verdict: Runtime Error):
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
x_to_i = {x:i for i, x in enumerate(sorted(A))}
rank = [x_to_i[x] for x in A]
answer = sum((i^x)&1 for i,x in enumerate(rank)) // 2
print(B)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
B = sorted(np.array(A))
C = [np.where(B == a)[0][0] for a in A]
answer = sum([i%2==1 and x%2!=1 for i, x in enumerate(C)])
print(answer)
# 41
Problem p03767 (python)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
v.sort(reverse = True)
s = 0
for i in range(0, n):
  s += v[1+2*i]
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = map(int, input().split())
v.sort(reverse = True)
s = 0
for i in range(0, n):
  s += v[1+2*i]
print(s)
Problem p02597 (python)

Fixed submission:
n = int(input())
c = list(input())

r = c.count('R')  
wr = c[:r].count('W')  

print(wr)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = list(input())

w = c.index("W")
r = n-1 - c[::-1].index("R")

cnt = 0
while w < r:
  c[w],c[r] = c[r],c[w]
  w = c.index("W")
  r = n-1 - c[::-1].index("R")
  cnt += 1
else:
  print(cnt)
Problem p02790 (python)

Fixed submission:

a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


# print('a_List : ' + a_List)
# print('b_List : ' + b_List)

a_List = int(a_List)
b_List = int(b_List)

if a_List >= b_List:
    print(a_List)

else:
    print(b_List)

Buggy submission (verdict: Runtime Error):

a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


# print('a_List : ' + a_List)
# print('b_List : ' + b_List)

a_List = int(a_List)
b_List = int(b_List)

if a_List => b_List:
    print(a_List)

else:
    print(b_List)

Buggy submission (verdict: Runtime Error):


a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


print('a_List : ' + a_List)
print('b_List : ' + b_List)

# a_List = int(a_List)
# b_List = int(b_List)


if a_List => b_List:
    print(a_List)

else:
    print(b_List)

Buggy submission (verdict: Runtime Error):


a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


print('a_List : ' + a_List)
print('b_List : ' + b_List)

# a_List = int(a_List)
# b_List = int(b_List)


if a_List => b_List:
    print(a_List)

else:
    print(b_List)
Problem p02659 (python)

Fixed submission:
import decimal
a,b = input().split()

a = int(a)
b = decimal.Decimal(b) * 100

print(a * b // 100)

Buggy submission (verdict: Runtime Error):
import math
x = input()
a = int(x[0])
b = float(x[1]) 

a *= 100
b *= 100
print(int(a * b // 10000))
Problem p02777 (python)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()

if s == u:
    print(a - 1, b)
else:
    print(a, b-1)

Buggy submission (verdict: Runtime Error):
s, t = map(input().split())
a, b = map(int, input().split())
u = input()

if s == u:
    print(a - 1, b)
else:
    print(a, b-1)
Problem p02831 (python)

Fixed submission:
a, b = map(int, input().split())


def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


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


print(lcm(a, b))

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

a, b = map(int, input().split())

print(np.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))

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 p02879 (python)

Fixed submission:
a, b = map(int, input().split())

if a >= 10 or b >= 10:
    print(-1)
    exit()
print(a * b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())

if 1 <= a <= 9 or 1 <= b <= 9:
    print(a * b)
else:
    print(-1)
Problem p02623 (python)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

from itertools import accumulate
A = [0] + list(accumulate(a))
B = [0] + list(accumulate(b))

ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

from itertools import accumulate
A = [0] + list(accumulate(a))
B = [0] + list(accumulate(b))

ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while B[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)
Problem p02625 (python)

Fixed submission:
def makefac(n):
    global faclist
    faclist = [1, 1]
    for i in range(2, n + 1):
        faclist.append(faclist[-1] * i % MOD)
    return None
def mcomb(n, r):#nCr % MOD
    return faclist[n] * pow(faclist[r],MOD - 2, MOD) * pow(faclist[n-r], MOD - 2, MOD)
def mperm(n, r):#nPr % MOD
    return faclist[n] * pow(faclist[n-r],MOD - 2, MOD)

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
makefac(M)
ans = mperm(M, N)
for k in range(1, N + 1):
    ans += ((-1)**k * mcomb(N, k) * mperm(M - k, N - k)) % MOD
ans = ans * mperm(M, N) % MOD
print(ans)

Buggy submission (verdict: Runtime Error):
def makefac(n):
    global faclist
    faclist = [1, 1]
    for i in range(2, n + 1):
        faclist.append(faclist[-1] * i % MOD)
    return None
def mcomb(n, r):#nCr % MOD
    return faclist[n] * pow(faclist[r], -1, MOD) * pow(faclist[n-r], -1) % MOD
def mperm(n, r):#nPr % MOD
    return faclist[n] * pow(faclist[n-r], -1, MOD)

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
makefac(M)
ans = mperm(M, N)
for k in range(1, N + 1):
    ans += ((-1)**k * mcomb(N, k) * mperm(M - k, N - k)) % MOD
ans = ans * mperm(M, N) % MOD
print(ans)
Problem p02790 (python)

Fixed submission:
a, b=map(str, input().split())
if int(a)<int(b):
	c=a
	a=b
	b=c
print(b*int(a))

Buggy submission (verdict: Runtime Error):
a, b=map(str, input().split())
if int(a)<int(b):
	c=a
    a=b
    b=c
print(b*int(a))
Problem p02880 (python)

Fixed submission:
N=int(input())
a=[]
for i in range(10):
	for j in range(10):
		a.append(i*j)
if N in a:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
N=input()
if N<11 or N==12 or 11<N<17 or N==18 or 19<N<22 or 23<N<26 or N==27 or N==30
or N==32 or 34<N<37 or N==40 or N==42 or N==45 or N==48 or N==49 or N==54 or N==63 or N==72 or N==81 or N==64 or N==56:
	print('Yes')
else:
	print('No')
Problem p02897 (python)

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

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int, input().split()))
b=a
c=1
if c<=N:
	d=a[c-1]
	b[d-1]='c'
	c+=1
''.join(b)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int, input()))
b=a
c=1
if c<=N:
	d=a[c-1]
	b[d-1]='c'
	c+=1
''.join(b)
Problem p02915 (python)

Fixed submission:
print(int(input())**3)

Buggy submission (verdict: Runtime Error):
N=input()
N*N*N

Buggy submission (verdict: Runtime Error):
N=input()
N**3

Buggy submission (verdict: Runtime Error):
2**N

Buggy submission (verdict: Runtime Error):
S=input()
S*S*S
Problem p03038 (python)

Fixed submission:
N, M = map(int,input().split())
a = list(map(int,input().split()))
check = []
for i in range(M):
    check.append(list(map(int,input().split())))
check.sort(key=lambda x : x[1],reverse = True)
a.sort()
ans = []
for b, c in check:
    ans += [c for i in range(b)]
    if len(ans) > N:
        break
else:
    ans+=[0 for i in range(N-len(ans))]
A=0
for i in range(N):
    A+=max(ans[i],a[i])
print(A)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
a = list(map(int,input().split()))
check = []
for i in range(M):
    check.append(list(map(int,input().split())))
check.sort(key=lambda x : x[1],reverse = True)
a.sort()
ans = 0
for b, c in check:
    change = a[:b]
    a = a[b:]
    if max(change) < c:
        ans += b*c
    else:
        for i in range(len(change)):
            ans+=max(c, change[i])
        print(ans+sum(a))
        break
else:
    print(ans+sum(a))
Problem p03806 (python)

Fixed submission:
# coding: utf-8

import re
from scipy import integrate
import math
from operator import itemgetter
from collections import defaultdict as dd
from collections import Counter
from collections import deque

import numpy as np
import itertools

import heapq

from copy import deepcopy as dcopy
import fractions
def main():
    global N, ma, mb
    N, ma, mb = map(int, input().split())
    shop = [list(map(int, input().split())) for n in range(N)]

    status = dd(int)
    status[(0,0)] = 0
    minimum = 100000
    for product in shop:
        # buy
        old_status = dcopy(status)
        for s, v in old_status.items():
            key = (s[0]+product[0], s[1]+product[1])
            value = v + product[2]
            if not key in status:
                status[key] = value
                if check(key) and value < minimum:
                    minimum = value
            elif status[key] > value:
                status[key] = value
                if check(key) and value < minimum:
                    minimum = value

    if minimum == 100000:
        print(-1)
    else:
        print(minimum)

def check(key):
    c = fractions.gcd(key[0], key[1])
    if key[0]/c == ma and key[1]/c == mb:
        return True
    else:
        return False

if __name__ == "__main__":# {{{
    try:
        import test
        test.test()
    except:
        main()# }}}

Buggy submission (verdict: Runtime Error):
from copy import deepcopy as dcopy
import fractions
def main():
    global N, ma, mb
    N, ma, mb = map(int, input().split())
    shop = [list(map(int, input().split())) for n in range(N)]

    status = dd(int)
    status[(0,0)] = 0
    minimum = 100000
    for product in shop:
        # buy
        old_status = dcopy(status)
        for s, v in old_status.items():
            key = (s[0]+product[0], s[1]+product[1])
            value = v + product[2]
            if not key in status:
                status[key] = value
                if check(key) and value < minimum:
                    minimum = value
            elif status[key] > value:
                status[key] = value
                if check(key) and value < minimum:
                    minimum = value

    if minimum == 100000:
        print(-1)
    else:
        print(minimum)

def check(key):
    c = fractions.gcd(key[0], key[1])
    if key[0]/c == ma and key[1]/c == mb:
        return True
    else:
        return False

if __name__ == "__main__":# {{{
    try:
        import test
        test.test()
    except:
        main()# }}}