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

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())

#############

mod = 10**9 + 7
max = 3 * 10**6
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

#############
ans = (com(r2+c2+2,r2+1) - com(r2+c1+1, c1) - com(r1+c2+1, r1) + com(r1+c1, r1)) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
r1, c1, r2, c2 = map(int, input().split())

#############

mod = 10**9 + 7
max = 2 * 10**6 + 2
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

#############
ans = (com(r2+c2+2,r2+1) - com(r2+c1+1, c1) - com(r1+c2+1, r1) + com(r1+c1, r1)) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
r1, c1, r2, c2 = map(int, input().split())

#############

mod = 10**9 + 7
max = 2 * 10**6
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( n<0 | k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

#############
ans = (com(r2+c2+2,r2+1) - com(r2+c1+1, c1) - com(r1+c2+1, r1) + com(r1+c1, r1)) % mod

print(ans)
Problem p02811 (python)

Fixed submission:
k , x = map(int, input().split())

if(k* 500 >= x):
    print('Yes')
else:
    print('No')

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

a_30 = [0]*30
b_30 = [0]*30
n_1 = 0
for i in range(n):
    n_i += 1 << i
    for j in range(30):
        a_30[j] +=  (a[i] & 2**j) >> j << i
        b_30[j] +=  (b[i] & 2**j) >> j << i



for k in range(n):
    x = 0
    check=True
    for j in range(30):
        a_temp  = a_30[j]
        a_30[j] = (a_temp >> 1) + ((a_temp & 1) << (n-1))
        if( (a_temp ^ b_30[j]) == n_1 ):
            x += (1 << j)
        elif( a_temp ^ b_30[j] != 0 ):
            check=False
    if(check):
        print('{} {}'.format(k, x))
Problem p02839 (python)

Fixed submission:
h,w = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
b = [list(map(int,input().split())) for _ in range(h)]

for i in range(h):
    for j in range(w):
        a[i][j] = abs(a[i][j] - b[i][j])

base = 2**12800 - 1
dp = [[0] * (w+1) for _ in range(h+1)]
dp[1][1] = (2**6400 >> a[0][0])|(2**6400 << a[0][0])&base
for i in range(1,h+1):
    for j in range(1,w+1):
        if(i==1)&(j==1):
            dp[1][1] = (2**6400 >> a[0][0])|(2**6400 << a[0][0])&base
            continue

        dp[i][j] = ((dp[i-1][j] >> a[i-1][j-1])|(dp[i-1][j] << a[i-1][j-1])|
                    (dp[i][j-1] >> a[i-1][j-1])|(dp[i][j-1] << a[i-1][j-1]))&base

ans = 6400
ans_bit = dp[-1][-1]
for i in range(6300,6500):
    if((ans_bit >> i)&1 == 1):
        ans = min(ans, abs(6400-i))

print(ans)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
b = [list(map(int,input().split())) for _ in range(h)]

for i in range(h):
    for j in range(w):
        a[i][j] = abs(a[i][j] - b[i][j])

dp = [[0] * 12800 for _ in range(w)]
for i in range(h):
    for j in range(w):
        min_ = max(0, 6400 - min(i+j, 160-i-j)*80)
        max_ = min(12799, 6400 + min(i+j, 160-i-j)*80)
        if(i==0)&(j==0):
            dp[j][6400+a[i][j]] += 1
            dp[j][6400-a[i][j]] += 1
        elif(i==0):
            for k in range(min_, max_+1):
                dp[j][k+a[i][j]] += dp[j-1][k]
                dp[j][k-a[i][j]] += dp[j-1][k]
        elif(j==0):
            tmp = [0] * 12800
            for k in range(min_, max_+1):
                tmp[k+a[i][j]] += dp[j][k]
                tmp[k-a[i][j]] += dp[j][k]
            dp[j] = tmp[::]
        else:
            tmp = [0] * 12800
            for k in range(min_, max_+1):
                tmp[k+a[i][j]] += dp[j-1][k]
                tmp[k-a[i][j]] += dp[j-1][k]
                tmp[k+a[i][j]] += dp[j][k]
                tmp[k-a[i][j]] += dp[j][k]
            dp[j] = tmp[::]

ans = 6400
for i in range(6300, 6500):
    if(dp[-1][i] > 0):
        ans = min(ans, abs(i-6400))

print(ans)
Problem p02841 (python)

Fixed submission:
print(1*(input()[:2]!=input()[:2]))

Buggy submission (verdict: Runtime Error):
print(1-input()[:2]in input())
Problem p02852 (python)

Fixed submission:
n,m = map(int,input().split())
s = input()

s_0 = []
for i in range(n+1):
    if(s[i] == '0'):
        s_0.append(i)

# 二分木
import bisect

now = n
ans_rev = []
while(now != 0):
    next_i = bisect.bisect_left(s_0, now-m)
    next = s_0[next_i]
    if(now == next):
        print(-1)
        exit()
    ans_rev.append(now-next)
    now = next

print(' '.join(map(str, ans_rev[::-1])))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = input()

now = n
ans_rev = []
while(now != 0):
    for i in range( now-m,now+1):
        if(i == now):
            print(-1)
            exit()
        if(s[i] == '1'):
            continue

        ans_rev.append(now - i)
        now = i
        break

print(' '.join(map(str, ans_rev[::-1])))
Problem p02889 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n,m,l = map(int,input().split())

# ワーシャルフロイド
def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# m行の入力から距離を値に持つ隣接行列を作成 0-indexed
# directed:無向グラフならFalse、有向グラフならTrue
def make_d_matrix(n,m,directed=False):
    inf = 10**13
    d = [[inf] * n for _ in range(n)]
    if(directed):
        for _ in range(m):
            a,b,c = map(int, input().split())
            d[a-1][b-1] = c
    else:
        for _ in range(m):
            a,b,c = map(int, input().split())
            d[a-1][b-1] = c
            d[b-1][a-1] = c
    return d

d = make_d_matrix(n,m)
d = warshall_floyd(d,n)

inf = 10**3
for i in range(n):
    for j in range(n):
        d[i][j] = 1 if (d[i][j] <= l) else inf

d = warshall_floyd(d,n)

q = int(input())

for _ in range(q):
    s,t = map(int, input().split())
    tmp = d[s-1][t-1]
    if(tmp >= inf):
        print(-1)
    else:
        print(tmp-1)

Buggy submission (verdict: Runtime Error):
# scipy使う場合
import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

n,m,l = map(int,input().split())

# m行の入力から距離を値に持つ隣接行列を作成 0-indexed
# directed:無向グラフならFalse、有向グラフならTrue
def make_d_matrix(n,m,directed=False):
    inf = 10**13
    d = [[inf] * n for _ in range(n)]
    if(directed):
        for _ in range(m):
            a,b,c = map(int, input().split())
            d[a-1][b-1] = c
    else:
        for _ in range(m):
            a,b,c = map(int, input().split())
            d[a-1][b-1] = c
            d[b-1][a-1] = c
    return d

d = make_d_matrix(n,m)
csr_graph = csr_matrix(d)
d1 = floyd_warshall(csr_graph,directed=False)

inf = 10**3
for i in range(n):
    for j in range(n):
        d1[i][j] = 1 if (d1[i][j] <= l) else inf

csr_graph = csr_matrix(d1)
d2 = floyd_warshall(csr_graph,directed=False)

q = int(input())

for _ in range(q):
    s,t = map(int, input().split())
    tmp = d2[s-1][t-1]
    if(tmp >= inf):
        print(-1)
    else:
        print(int(tmp-1))
Problem p02913 (python)

Fixed submission:
# import numpy as np

n = int(input())
s = input()

# dp = np.zeros([n+1, n+1])
dp = [0] * (n+1)

for dif in range(1,n):
    count = 0
    t_max = 0
    for l1_r in range(0, n-dif):
        if(s[l1_r] == s[l1_r + dif]):
            count += 1
            t_max = max(count, t_max)
            if( count == dif):
                dp[dif] = count
                break
        else:
            count = 0
    dp[dif] = t_max

print(max(dp))

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

# n, m = 4,4
# a_list = np.array([1,9,3,5])
n = int(input())
s = input()

ct = 0
ct_max = 0
for i in range(1,n):
    if(ct_max >= n-i)
    
    forward = s[:n-i]
    back = s[i:]
    for j in range(n-i):
        f = forward[j]
        b = back[j]
        if(f==b):
            ct += 1
            if(ct_max < ct):
                ct_max = ct*1
            if(ct_max >= i):
                break()
        else:
            ct = 0

print(ct_max)
Problem p02919 (python)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
p_ind = [ (p[i], i+1) for i in range(n) ]
p_ind.sort(reverse=True)

# 平方分割します。
max_n = 10**5
div_n = int(max_n**(1/2))+1
a = [[] for _ in range(div_n)]
a[0] = [0,0]
a[(n+1)//div_n].append(n+1)
a[(n+1)//div_n].append(n+1)
a_count = [0] * (div_n)
a_count[0] += 2
a_count[(n+1)//div_n] += 2

import bisect
ans = 0
for tmp in p_ind:
    val, i = tmp
    group = i//div_n
    j = bisect.bisect(a[group],i)
    #left
    if(j>1):
        left1 = a[group][j-1]
        left2 = a[group][j-2]
    elif(j==1):
        left1 = a[group][j-1]
        lg = group-1
        while(True):
            if(a_count[lg]>0):
                break
            lg -=1
        left2 = a[lg][-1]
    else:
        lg = group-1
        while(True):
            if(a_count[lg]>0):
                break
            lg -=1
        if(a_count[lg]>=2):
            left1 = a[lg][-1]
            left2 = a[lg][-2]
        else:
            left1 = a[lg][-1]
            while(True):
                lg -=1
                if(a_count[lg]>0):
                    break
            left2 = a[lg][-1]
    #right
    if(a_count[group]>=j+2):
        right1 = a[group][j]
        right2 = a[group][j+1]
    elif(a_count[group]>=j+1):
        right1 = a[group][j]
        rg = group
        while(True):
            rg += 1
            if(a_count[rg]>0):
                break
        right2 = a[rg][0]
    else:
        rg = group
        while(True):
            rg += 1
            if(a_count[rg]>0):
                break
        if(a_count[rg]>=2):
            right1 = a[rg][0]
            right2 = a[rg][1]
        else:
            right1 = a[rg][0]
            while(True):
                rg += 1
                if(a_count[rg]>0):
                    break
            right2 = a[rg][0]

    ans += ((right2 - right1)* (i - left1) + (right1 - i)* (left1 - left2)) * val
    a[group].insert(j,i)
    a_count[group] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))
p_ind = [ (p[i], i+1) for i in range(n) ]
p_ind.sort(reverse=True)

import bisect
a = [0,0,n+1,n+1]
ans = 0
for tmp in p_ind:
    val, i = tmp
    j = bisect.bisect(a,i)
    ans += ((a[j+1] - a[j])* (i - a[j-1]) + (a[j] - i)* (a[j-1] - a[j-2])) * val
    a.insort(j,i)

print(ans)
Problem p02922 (python)

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

ans = (b-1 + (a-2)) // (a-1)

print(ans)

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

ans = (b-1 + (a-2)) // (a-1)

print(ans)
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline

from collections import deque

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

edge = {}
for i in range(1,n+1):
    edge[i] = []

for i in range(n-1):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)

ans = [0] * (n+1)
for i in range(q):
    p,x = map(int,input().split())
    ans[p] += x

d = deque()
remains = set(range(1,n+1))
d.append(1)
remains.remove(1)

while(len(d) > 0):
    tmp = d.pop()
    for i in edge[tmp]:
        if(i in remains):
            ans[i] += ans[tmp]
            d.append(i)
            remains.remove(i)

print(' '.join(map(str, ans[1:])))

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())

boss = {}
point = {}
point[n] = 0
for i in range(1,n):
    a,b = map(int, input().split())
    boss[b] = a
    point[i] = 0

for i in range(q):
    p,x = map(int, input().split())
    point[p] += x

ans = str(point[1])
for i in range(2,n+1):
    point[i] += point[boss[i]]
    ans = ans + " " + str(point[i])

print(ans)
Problem p02947 (python)

Fixed submission:
n = int(input())

ans = 0
ans_dict = {}

for i in range(n):
    s = input()
    s = ''.join(sorted(s))
    if(s in ans_dict):
        ans += ans_dict[s]
        ans_dict[s] += 1
    else:
        ans_dict[s] = 1
        
print(int(ans))

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

# alp = ["a","b","c","d","e",
# "f","g","h","i","j",
# "k","l","m","n","o",
# "p","q","r","s","t",
# "u","v","w","x","y","z"]
#
ans = 0
# array1 = np.zeros().reshape( n,10)


# list1 = []
list_s = []

for i in range(n):
    s = input()
    s.sort()
    ans += list_s.count(s)

    list_s.append(s)

print(int(ans))
Problem p02949 (python)

Fixed submission:
n,m,p = map(int,input().split())
# キュー
from collections import deque

# bellman_ford
# 負の経路がある場合は、(-1,-1)を返却する
def bellman_ford(links, start, end, n):
    inf = 10**10
    d = [inf] * (n+1)
    d[start] = 0
    parent = [-1] * (n+1)

    for _ in range(n):
        update = False
        for i in range(1,n+1):
            for j in links[i]:
                cost,neigh = j
                if(d[neigh] > d[i] + cost):
                    d[neigh] = d[i] + cost
                    parent[neigh] = i
                    update = True

        if(not update):
            # 経路の算出
            route = [end]
            now = end
            while(now != start):
                now = parent[now]
                route.append(now)

            return d,route[::-1]

    # 負の経路がある場合（n-1回の更新で終わらない場合）
    return -1,-1

abc = []
graph = [[] for _ in range(n+1)]
graph_rev = [[] for _ in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    abc.append((a,b,p-c))
    graph[a].append(b)
    graph_rev[b].append(a)

can_go_1 = set()
can_go_n = set()

d = deque()
d.append(1)
while(d):
    tmp = d.pop()
    can_go_1.add(tmp)
    for i in graph[tmp]:
        if(not i in can_go_1):
            d.append(i)

d = deque()
d.append(n)
while(d):
    tmp = d.pop()
    can_go_n.add(tmp)
    for i in graph_rev[tmp]:
        if(not i in can_go_n):
            d.append(i)

can_go = can_go_1 & can_go_n

graph2 = [[] for _ in range(n+1)]
for tmp in abc:
    a,b,c = tmp
    if(a in can_go)&(b in can_go):
        graph2[a].append((c,b))

d , _ = bellman_ford(graph2, 1, n, n)
if(d == -1):
    print(-1)
else:
    ans = d[n] * -1
    print(max(0,ans))

Buggy submission (verdict: Runtime Error):
n,m,p = map(int,input().split())
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford, NegativeCycleError
# キュー
from collections import deque

abc = []
graph = [[] for _ in range(n+1)]
graph_rev = [[] for _ in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    abc.append((a,b,p-c))
    graph[a].append(b)
    graph_rev[b].append(a)

can_go_1 = set()
can_go_n = set()

d = deque()
d.append(1)
while(d):
    tmp = d.pop()
    can_go_1.add(tmp)
    for i in graph[tmp]:
        if(not i in can_go_1):
            d.append(i)

d = deque()
d.append(n)
while(d):
    tmp = d.pop()
    can_go_n.add(tmp)
    for i in graph_rev[tmp]:
        if(not i in can_go_n):
            d.append(i)

can_go = can_go_1 & can_go_n

data = []
row = []
col = []
for tmp in abc:
    a,b,c = tmp
    if(a in can_go)&(b in can_go):
        data.append(c)
        row.append(a)
        col.append(b)

csr_graph = csr_matrix((data, (row,col)), shape=(n+1,n+1))
try:
    bf = bellman_ford(csr_graph, indices=1)
except NegativeCycleError:
    print(-1)
    exit()

ans = int(bf[-1]) * -1
print(max(0,ans))
Problem p02953 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1,1,-1):
    dif = h[i] - h[i-1]
    if(dif == -1):
        h[i-1] -= 1
    elif(dif < -1):
        print('No')
        exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
for i in range(n-1,1,-1):
    dif = h[i] - h[i-1]
    if(dif == -1):
        h[i-1] -= 1
    elif(dif < -1):
        print('No')
        exit()

print('Yes')
Problem p02971 (python)

Fixed submission:
n=int(input())
a=[int(input()) for _ in range(n)]
a1=sorted(a)
m=a1[-1]
for i in range(n):
    print(m if m!=a[i] else a1[-2])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for _ in range(n)]
as=sorted(a)
m=as[-1]
for i in range(n):
    print(m if m!=a[i] else a[-2])
Problem p02972 (python)

Fixed submission:
#import numpy as np

n = int(input())
a_s = list(map(int, input().split()))

m = 0
ans = [0]*(n+1)
#ans = np.zeros(n+1).astype(int)


i=1
for i in range(n,0,-1):
    sum_num = 0
    for j in range(i,n+1,i):
        sum_num += ans[j]

    if((sum_num & 1) != a_s[i-1]):
        m += 1
        ans[i] = 1

ans2 = []
for i in range(1,n+1):
    if ans[i]==1:
        ans2.append(i)

print(m)
print(' '.join(map(str,ans2)))

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

n = int(input())
a_s = list(map(int, input().split()))

n = 3
a_s =[1,0,0]

m = 0
ans = [0]*(n+1)
#ans = np.zeros(n+1).astype(int)


i=1
for i in range(n,0,-1):
    sum_num = 0
    for j in range(i,n+1,i):
        sum_num += ans[j]

    if((sum_num & 1) != a_s[i-1]):
        m += 1
        ans[i] = 1

ans2 = []
for i in range(1,n+1):
    if ans[i]==1:
        ans2.append(i)

print(m)
print(' '.join(map(str,ans2[])))
Problem p02985 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import deque

mod = 10**9 + 7

n,k = map(int,input().split())
if(n == 1):
    print(k)
    exit()


edges = {}
d = [0] * (n+1)
for i in range(1,n+1):
    edges[i] = []

for i in range(n-1):
    a,b = map(int,input().split())
    edges[a].append(b)
    edges[b].append(a)
    d[a] += 1
    d[b] += 1

for i in range(1,n+1):
    if(d[i] == 1):
        first = i
        break

d = [0] * (n+1)
d[0] = -1
d[first] = -1
dq = deque()
dq.appendleft([0,first])

ans = 1
while(len(dq) > 0):
    parent, child = dq.pop()
    d[parent] += 1
    d[child] += 1
    ans = ans * (k - d[parent]) % mod

    for i in edges[child]:
        if(i != parent):
            dq.appendleft([child, i])

print(ans)

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

mod = 10**9 + 7

n,k = map(int,input().split())
edges = {}
d = [0] * (n+1)
for i in range(1,n+1):
    edges[i] = []

for i in range(n-1):
    a,b = map(int,input().split())
    edges[a].append(b)
    edges[b].append(a)
    d[a] += 1
    d[b] += 1

for i in range(1,n+1):
    if(d[i] == 1):
        first = i
        break

d = [0] * (n+1)
d[0] = -1
d[first] = -1
dq = deque()
dq.appendleft([0,first])

ans = 1
while(len(dq) > 0):
    parent, child = dq.pop()
    d[parent] += 1
    d[child] += 1
    ans = ans * (k - d[parent]) % mod

    for i in edges[child]:
        if(i != parent):
            dq.appendleft([child, i])

print(ans)
Problem p02988 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
a = 0
for i in range(n-2):
  a += 1-((p[i] < p[i+1])^(p[i+1] < p[i+2]))
print(a)

Buggy submission (verdict: Runtime Error):
n=input()
p=list(map(int,input().split()))
a = 0
for i in range(n-2):
    a += 1*(0<((p[i] < p[i+1])*(p[i+1] < p[i+2])))
print(a)

Buggy submission (verdict: Runtime Error):
n=input()
p=list(map(int,input().split()))
a = 0
for i in range(n-2):
    a += (0<((p[i] < p[i+1])*(p[i+1] < p[i+2])))
print(a)
Problem p02991 (python)

Fixed submission:
n, m = map(int, input().split())
uv = [list(map(int, input().split())) for _ in range(m)]
s, t = map(int, input().split())

next_dict = {}

for i in range(1,n*3 + 1):
    next_dict[i] = []

for i in range(m):
    u,v = uv[i]
    for j in range(3):
        next_dict[u + (j * n)].append((v + ((j+1)%3 * n )))

from collections import deque
d = deque()
d.append(s)

length = [-1] * (3*n + 1)
length[s] = 0

while(True):
    if(len(d) == 0):
        break

    num = d.popleft()
    for i in next_dict[num]:
        if( length[i] == -1 ):
            d.append(i)
            length[i] = length[num] + 1

    if(length[t] != -1):
        break

print(length[t] // 3)

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open('../../input.txt', 'r')
sys.stdin = f

n, m = map(int, input().split())
uv = [list(map(int, input().split())) for _ in range(m)]
s,t = map(int, input().split())

before_dict = {}
after_dict = {}
after_3 = {}

for i in range(1,n+1):
    before_dict[i] =[]
    after_dict[i] = []
    after_3[i] = []

for i in range(m):
    u, v = uv[i]
    before_dict[v].append(u)
    after_dict[u].append(v)

for i in range(m):
    u, v = uv[i]
    for j in before_dict[u]:
        for k in after_dict[v]:
            if( j != k):
                after_3[j].append(k)

from collections import deque
d = deque()
d.append(s)

length = [-1] * (n+1)
length[s] = 0

check = True

while(check):
    if(len(d) == 0):
        break
    num = d.popleft()
    for i in after_3[num]:
        if(length[i] == -1):
            length[i] = length[num] + 1
            d.append(i)

    if(length[t] > -1):
        break

print(length[t])
Problem p03029 (python)

Fixed submission:
a,p = map(int,input().split())
print((3*a+p)//2)

Buggy submission (verdict: Runtime Error):
a,p = map(int,input().split())
print((3*a+b)//2)
Problem p03046 (python)

Fixed submission:
m,k = map(int, input().split())

if( k >= 2**m):
    print(-1)
    exit()

if( (m==1) & (k==1) ):
    print(-1)
    exit()


n = 2**(m+1)
ans = [0] * n
if( k==0):
    for i in range(n):
        ans[i] = i//2
    print(' '.join([str(i) for i in ans ]))
    exit()

ans[0] = k
ind = 1
for i in range(n//2):
    if(i != k):
        ans[ind] = i
        ind += 1

ans[ind] = k
ind += 1

for i in range(n//2 -1, -1, -1):
    if(i != k):
        ans[ind] = i
        ind += 1


print(' '.join([str(i) for i in ans ]))

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

if( k > 2**m):
    print(-1)
    exit()

if( (m==1) & (k==1) ):
    print(-1)
    exit()


n = 2**(m+1)
ans = [0] * n
if( k==0):
    for i in range(n):
        ans[i] = i//2
    print(' '.join([str(i) for i in ans ]))
    exit()

ans[0] = k
ind = 1
for i in range(n//2):
    if(i != k):
        ans[ind] = i
        ind += 1

ans[ind] = k
ind += 1

for i in range(n//2 -1, -1, -1):
    if(i != k):
        ans[ind] = i
        ind += 1


print(' '.join([str(i) for i in ans ]))
Problem p03059 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,t＝map(int,input().split())
print(t//a*b)

Buggy submission (verdict: Runtime Error):
a,b,t＝map(int,input().split)
print(t//a*b)
Problem p03060 (python)

Fixed submission:
input()
v=list(map(int,input().split()))
c=list(map(int,input().split()))
a=[max(0,i-j) for i,j in zip(v,c)]
print(sum(a))

Buggy submission (verdict: Runtime Error):
input()
v=list(map(int,input().split())
c=list(map(int,input().split())
a=[max(0,i-j) for i,j in zip(v,c)]
print(sum(a))