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

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

cnt = 0
ans = []

for i in range(h):
    for j in range(w-1):
        if lst[i][j] %2 == 1:
            lst[i][j] -= 1
            lst[i][j+1] += 1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h-1):
    if lst[i][-1] %2 == 1:
        lst[i][-1] -= 1
        lst[i+1][-1] += 1
        ans.append([i+1,w,i+2,w])

print(len(ans))
for a in ans:
    print(*a)

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

flg = [[False]*w for _ in range(h)]

cnt = 0
ans = []

for i in range(h):
    for j in range(w-1):
        if lst[i][j] %2 == 1:
            lst[i][j] -= 1
            lst[i][j+1] += 1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h-1):
    if lst[i][-1] %2 == 1:
        lst[i][-1] -= 1
        lst[i+1][-1] += 1
        ans.append([i+1,j+1,i+2,j+1])
        
print(len(ans))
for l in ans:
    print(*l)
Problem p03330 (python)

Fixed submission:
import itertools
n,c = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(c)]
C = [list(map(int,input().split())) for _ in range(n)]
mod0 = []
mod1 = []
mod2 = []
for i in range(n):
    for j in range(n):
        # indexのずれを考慮 ((i+1)+(j+1))%3が本来のmod値
        if (i+j)%3 == 1:
            mod0.append(C[i][j]-1)
        elif (i+j)%3 == 2:
            mod1.append(C[i][j]-1)
        else:
            mod2.append(C[i][j]-1)

conv_0, conv_1, conv_2 = [],[],[]
for i in range(c):
    tmp0, tmp1, tmp2 = 0,0,0
    for j in range(len(mod0)):
        tmp0 += D[mod0[j]][i]
    for j in range(len(mod1)):
        tmp1 += D[mod1[j]][i]
    for j in range(len(mod2)):
        tmp2 += D[mod2[j]][i]
    conv_0.append(tmp0)
    conv_1.append(tmp1)
    conv_2.append(tmp2)
res = float('inf')
color_range = list(range(c))
for x,y,z in itertools.permutations(color_range, 3):
    cnt = 0
    cnt = conv_0[x] + conv_1[y] + conv_2[z]
    res = min(cnt, res)
print(res)

Buggy submission (verdict: Runtime Error):
import itertools

n,c = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(c)]
C = [list(map(int,input().split())) for _ in range(n)]
mod0 = []
mod1 = []
mod2 = []
for i in range(n):
    for j in range(n):
        # indexのずれを考慮 ((i+1)+(j+1))%3が本来のmod値
        if (i+j)%3 == 1:
            mod0.append(C[i][j]-1)
        elif (i+j)%3 == 2:
            mod1.append(C[i][j]-1)
        else:
            mod2.append(C[i][j]-1)

color_range = list(range(c))
res = float('inf')
for x,y,z in itertools.permutations(color_range):
    cnt = 0
    for i in range(len(mod0)):
        cnt += D[mod0[i]][x]
    for i in range(len(mod1)):
        cnt += D[mod1[i]][y]
    for i in range(len(mod2)):
        cnt += D[mod2[i]][z]
    res = min(cnt, res)
print(res)
Problem p03337 (python)

Fixed submission:
a,b = map(int,input().split())
x = a+b
y = a-b
z = a*b
print(max(x,y,z))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
X = [0]
C = [0] + np.cumsum(A).tolist()
for i in range(n):
    X.append(X[i-1] ^ A[i])
cnt = 0
for l in range(n):
    for r in range(l+1, n):
        if C[r]-C[l] == X[r]^X[l]:
            cnt += 1
print(cnt+n)
Problem p03340 (python)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
s = 0
x = 0
r = 0
for l in range(n):
    while r<n and s+a[r]==x^a[r]:
        s += a[r]
        x ^= a[r]
        r += 1
    ans += (r-l)
    if l==r:
        r += 1
    else:
        s -= a[l]
        x ^= a[l]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
X = [0]
C = [0] + np.cumsum(A).tolist()
for i in range(n):
    X.append(X[i-1] ^ A[i])
cnt = 0
for l in range(n):
    for r in range(l+1, n):
        if C[r]-C[l] == X[r]^X[l]:
            cnt += 1
print(cnt+n)
Problem p03363 (python)

Fixed submission:
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum([0] + lst)

n = int(input())
lst = list(map(int,input().split()))
d = dict(Counter(f(lst)))

res = 0
for k,v in d.items():
    if v >= 2:
        res += (v*(v-1))//2
print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum(lst)

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

res = 0
for i in range(n):
    tmp_lst = lst[i:]
    c = dict(Counter(f(tmp_lst)))
    if 0 in c:
       res += c[0]
print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum(lst)

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

res = 0
for i in range(n):
    tmp_lst = lst[i:]
    c = dict(Counter(f(tmp_lst)))
    if 0 in c:
       res += c[0]
print(res)
Problem p03380 (python)

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

m = lst[-1]
line = m / 2
r = 10**10

for i in range(n):
    if abs(r-line) > abs(lst[i]-line):
        r = lst[i]
print(m,r)

Buggy submission (verdict: Runtime Error):
from math import factorial
import bisect

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

lst = sorted(lst)

ans = (-1,-1)
val = -1

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

if n == 2:
    print(max(lst), min(lst))
else:
    for i in range(1, n):
        num = lst[i]
        pos = bisect.bisect_left(lst, num//2)
        r = lst[pos]
        
        tmp_val = nCr(num, r)
        if tmp_val > val:
            val = tmp_val
            ans = (num, r)
    
    print(max(ans), min(ans))

Buggy submission (verdict: Runtime Error):
from math import factorial
import bisect

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

lst = sorted(lst)

ans = (-1,-1)
val = -1

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

if n == 2:
    print(max(lst), min(lst))
else:
    for i in range(1, n):
        num = lst[i]
        pos = bisect.bisect_left(lst, num//2)
        r = lst[pos]
        
        tmp_val = nCr(num, r)
        if tmp_val > val:
            val = tmp_val
            ans = (num, r)
    
    print(max(ans), min(ans)

Buggy submission (verdict: Runtime Error):

from math import factorial
import bisect

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

lst = sorted(lst)

ans = (-1,-1)
val = -1

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

if n==2:
    print(*lst)
    exit()

for i in range(1, n):
    n = lst[i]
    r1 = bisect.bisect_left(lst, n//2)
    r2 = bisect.bisect_right(lst, n//2)
    
    v1 = nCr(n, lst[r1])
    v2 = nCr(n, lst[r2])
    
    if v1 > val and n!=lst[r1]:
        val = v1
        ans = (n, lst[r1])
    if v2 > val and n!=lst[r2]:
        val = v2
        ans = (n, lst[r2])
    
print(*ans)
Problem p03402 (python)

Fixed submission:
a,b=map(int,input().split())
ans=[['#' for i in range(100)] for j in range(50)]
ans+=[['.' for i in range(100)] for j in range(50)]
for i in range(a-1):
    ans[(i//50)*2][(i%50)*2]='.'
for i in range(b-1):
    ans[(i//50)*2+52][(i%50)*2]='#'
print(100,100)
for i in range(100):
    print(''.join(ans[i]))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
grid_b = [list('#'*100) for _ in range(50)]
grid_w = [list('.'*100) for _ in range(50)]
for i in range(1, a):
    grid_b[2*(i//10)-1][2*(i%10)-1] = '.'
for i in range(1, b):
    grid_w[2*(i//10)-1][2*(i%10)-1] = '#'
print(100, 100)
grid = grid_b + grid_w
for g in grid:
    print(*g)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
a,b = a-1,b-1
grid_b = [list('#'*100) for _ in range(50)]
grid_w = [list('.'*100) for _ in range(50)]
for i in range(a):
    grid_b[2*(i//10)+1][2*(i%10)+1] = '.'
for i in range(b):
    grid_w[2*(i//10)+1][2*(i%10)+1] = '#'

grid = grid_b + grid_w

print(100, 100)
for g in grid:
    print(*g)
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1
print(cnt)
Problem p03463 (python)

Fixed submission:
def is_fin(x,y):
    if abs(x-y)==1:
        return False
    return True
n,a,b = map(int,input().split())
turn = 0
while is_fin(a,b):
    if turn%2==0:
        a += 1
    else:
        b -= 1
    turn += 1
print('Alice' if turn%2==1 else 'Borys')

Buggy submission (verdict: Runtime Error):
from math import ceil
k = int(input())
A = list(map(int,input().split()))[::-1]
if A[0]!=2:
    print(-1)
    exit()

flg = True
ans = [2,3]
for i in range(1, k):
    m = A[i]*(ceil(ans[0]/A[i]))
    n = A[i]*(ceil(ans[1]/A[i]))
    
    if not m<=ans[1]<=n:
        flg = False
        break
    else:
        ans = [m,n-1]

if flg:
    print(*ans)
else:
    print(-1)
Problem p03504 (python)

Fixed submission:
import numpy as np
n,C = map(int,input().split())
ch = [[] for _ in range(30)]
for _ in range(n):
    s,t,c = map(int,input().split())
    if s>t:
        s,t = t,s
    ch[c-1].append((s,t))

lst = []
for i in range(30):
    if len(ch[i])!=0:    
        for i, (ns,nt) in enumerate(ch[i]):
            if i==0:
                s,t = ns, nt
            else:
                if ns == t:
                    t = nt
                else:
                    lst.append((s,t))
                    s,t = ns, nt
        else:
            lst.append((s,t))
    
d = [0]*(10**6)
for s,t in lst:
    d[s-1] += 1
    d[t] -= 1
d = np.cumsum(d)
print(min(max(d), C))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,c = map(int,input().split())
d = [0]*(10**5)
for _ in range(n):
    s,t,c = map(int,input().split())
    d[s-1] += 1
    d[t] -= 1
d = np.cumsum(d)
print(max(d))
Problem p03565 (python)

Fixed submission:
s_dash = input()
t = input()
len_s = len(s_dash)
len_t = len(t)
candidates = set()

for i in range(len_s - len_t + 1):
    part_s = s_dash[i:i+len_t+1]
    flag = True
    for j,k in zip(part_s,t):
        if j=='?' or j==k:
            continue
        else:
            flag = False
            break
    if flag:
        candidates.add(s_dash[0:i].replace("?","a")+t+s_dash[i+len_t::].replace("?","a"))

ret = 'UNRESTORABLE'
if len(candidates)>0:
    ret = min(candidates)
print(ret)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

sl = len(s)
tl = len(t)

lst = []
for i in range(sl):
    if s[i] == t[0]:
        lst.append(i)
        
k = []

for i in lst:
    cnt = 0
    for j in range(tl):
        if s[i+j]==t[j] or s[i+j]=='?':
            cnt += 1
    if cnt == tl:
        ans = s[:i] + t + s[i+tl:]
        ans = ans.replace('?','a')
        k.append(ans)

if len(k)==0:
    print('UNRESTORABLE')
else:
    
    kk = sorted(k)
    print(kk[0])
Problem p03576 (python)

Fixed submission:
n,K = map(int,input().split())
X, Y = [], []
dots = []
for _ in range(n):
    x,y = map(int,input().split())
    dots.append((x,y))
    X.append(x)
    Y.append(y)
X.sort()
Y.sort()
ans = float('inf')
for i in range(n):
    for j in range(i+1, n):
        for k in range(n):
            for l in range(k+1, n):
                x1,x2 = X[i], X[j]
                y1,y2 = Y[k], Y[l]
                cnt = 0
                for dot in dots:
                    if x1<=dot[0]<=x2 and y1<=dot[1]<=y2:
                        cnt += 1
                if cnt >= K:
                    ans = min(ans, (x2-x1)*(y2-y1))
print(ans)

Buggy submission (verdict: Runtime Error):
n,K = map(int,input().split())
X, Y = [], []
dots = []
for _ in range(n):
    x,y = map(int,input().split())
    dots.append((x,y))
    X.append(x)
    Y.append(y)
X.sort()
Y.sort()
ans = float('inf')
for i in range(n):
    for j in range(i+1, n):
        for k in range(n):
            for l in range(k+1, l):
                x1,x2 = X[i], X[j]
                y1,y2 = Y[k], Y[l]
                cnt = 0
                for dot in dots:
                    if x1<=dot[0]<=x2 and y1<=dot[1]<=y2:
                        cnt += 1
                if cnt >= K:
                    ans = min(ans, (x2-x1)*(y2-y1))
print(ans)
Problem p03583 (python)

Fixed submission:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        div = 4*h*n - N*(h+n)
        if div!=0 and N*h*n%div==0:
            w = N*h*n // div
            if w > 0:
                print(h,n,w)
                exit()

Buggy submission (verdict: Runtime Error):
def f(N,h,n):
    return 4/N - 1/h - 1/n

N = int(input())
for h in range(1, 3500):
    for n in range(1, 3500):
        inv_w = f(N, h, n)
        if inv_w > 0:
            w = 1/inv_w
            if w.is_integer() and 1<=w<=3500:
                ans = [h,n,int(w)]
                break
print(*ans)

Buggy submission (verdict: Runtime Error):
def f(N,h,n):
    return 4/N - 1/h - 1/n

N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        tmp = f(N, h, n)
        if tmp > 0:
            w = 1/tmp
            if w.is_integer():
                ans = [h,n,int(w)]
                break
print(*ans)

Buggy submission (verdict: Runtime Error):
def f(N,h,n):
    return 4/N - 1/h - 1/n

N = int(input())
for h in range(1, 5):
    for n in range(1, 5):
        tmp = f(N, h, n)
        if tmp != 0:
            w = 1/tmp
            if w.is_integer():
                ans = [h,n,int(w)]
                break
print(*ans)
Problem p03665 (python)

Fixed submission:
n,k = map(int,input().split())
lst = list(map(int,input().split()))
e,o = 0,0
for i in range(n):
    if lst[i]%2==0:
        e += 1
    else:
        o += 1

if o==0:
    if k==0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
lst = list(map(int,input().split()))
e,o = 0,0
for i in range(n):
    if lst[i]%2==0:
        e += 1
    else:
        o += 1

if o==0:
    if p==0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))
Problem p03732 (python)

Fixed submission:
N,W = map(int,input().split())
tmpv = [[] for _ in range(4)]
w1 = None
for i in range(N):
    tw, tv = map(int,input().split())
    if i==0:
        w1 = tw
        tmpv[0].append(tv)
    else:
        tmpv[tw-w1].append(tv)

v = []
for tv in tmpv:
    v.append(sorted(tv, reverse=True)+[0])
    
ans = 0
for i in range(len(v[0])):
  for j in range(len(v[1])):
    for k in range(len(v[2])):
      for l in range(len(v[3])):
        tw = w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l
        tv = sum(v[0][:i]) + sum(v[1][:j]) + sum(v[2][:k]) + sum(v[3][:l])
        if tw<=W:
          ans = max(ans, tv)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 9)

N,W = map(int,input().split())
w = []
v = []
for _ in range(N):
    w_, v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)

# dp[i][j]:iまでを用いて、重みjの時の最大値
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if w[i]<=j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        dp[i+1][j] = max(dp[i][j], dp[i+1][j])
        
print(dp[N][W])

Buggy submission (verdict: Runtime Error):
N,W = map(int,input().split())
w = []
v = []
for _ in range(N):
    w_, v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)

# dp[i][j]:iまでを用いて、重みjの時の最大値
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if w[i]<=j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        dp[i+1][j] = max(dp[i][j], dp[i+1][j])
        
print(dp[N][W])
Problem p03846 (python)

Fixed submission:
from collections import Counter
n = int(input())
lst = [int(i) for i in input().split()]
mod = 10**9 + 7
lst_c = Counter(lst)
lst_c = sorted(lst_c.items(),key = lambda x:x[0])

ideal = []

if n%2!=0:
    ideal.append((0,1))
    for i in range(1,n//2+1):
        ideal.append((2*i,2))
else:
    for i in range(n//2):
        ideal.append((2*i+1,2))

if lst_c != ideal:
    print(0)
else:
    l = len(ideal)
    if n%2!=0:
        l -= 1
    print(2**l % mod)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
lst = [int(i) for i in input().split()]
mod = 10**9 + 7
lst_c = Counter(lst)
lst_c = sorted(lst_c.items(),key = lambda x:x[0])

ideal = []

if n%2!=0:
    ideal.append((0,1))
    for i in range(1,n//2+1):
        ideal.append((2*i,2))
else:
    for i in range(n//2):
        ideal.append((2*i+1,2))

if lst_c != ideal:
    print(0)
else:
    l = len(ideal)
    if n%2!=0:
        l -= 1
    print(2**l　% mod)
Problem p03994 (python)

Fixed submission:
s = input()
x = int(input())
tank = []
for c in list(s):
    if c=='a':
        tank.append(0)
    else:
        tank.append(ord('z') + 1 - ord(c))
res = ''
for i in range(len(tank)):
    if tank[i] == 0:
        res += s[i]
    elif tank[i] <= x:
        x -= tank[i]
        tank[i] = 0
        res += 'a'
    else:
        res += s[i]

c = res[-1]
x %= 26
if ord(c)+x <= ord('z'):
    res = res[:-1] + chr(ord(c)+x)
else:
    res = res[:-1] + chr(ord(c)+x-ord('z')+ord('a')-1)
print(res)

Buggy submission (verdict: Runtime Error):
s = input()
x = int(input())
tank = []
for c in list(s):
    if c=='a':
        tank.append(0)
    else:
        tank.append(ord('z') + 1 - ord(c))
res = ''
for i in range(len(tank)):
    if tank[i] == 0:
        res += s[i]
    elif tank[i] <= x:
        x -= tank[i]
        tank[i] = 0
        res += 'a'
    else:
        res += s[i]

c = res[-1]
if ord(c)+x <= ord('z'):
    res = res[:-1] + chr(ord(c)+x)
else:
    res = res[:-1] + chr(ord(c)+x-ord('z')+ord('a')-1)
print(res)

Buggy submission (verdict: Runtime Error):
s = input()
x = int(input())
tank = []
for c in list(s):
    if c=='a':
        tank.append(0)
    else:
        tank.append(ord('z') + 1 - ord(c))
res = ''
for i in range(len(tank)):
    if tank[i] == 0:
        res += s[i]
    elif tank[i] <= x:
        x -= tank[i]
        tank[i] = 0
        res += 'a'
    else:
        res += s[i]
else:
    if x != 0:
        n = ord(s[-1])+x
        res = res[:-1] + chr(n)
print(res)
Problem p04013 (python)

Fixed submission:
num,ave = map(int,input().split())
numx = list(map(int,input().split()))

L = len(numx)
numy = [0] * L
for i in range(L):
    numy[i] = numx[i] - ave

if abs(min(numy)) < abs(max(numy)):
    maxX = max(numy)
else:
    maxX = abs(min(numy))

dp = [[0]*(2*maxX*L+1) for _ in range(L+1)]
dp[0][maxX*L] = 1
for i in range(L):
    for j in range(2*maxX*L+1):
        if (j-numy[i]) < 0 or (j - numy[i]) > 2*maxX*L:
          dp[i+1][j] = dp[i][j]
        else:
          dp[i+1][j] = dp[i][j] + dp[i][j-numy[i]]
print(dp[L][maxX*L]-1)

Buggy submission (verdict: Runtime Error):
num,ave = map(int,input().split())
numx = list(map(int,input().split()))

L = len(numx)
numy = [0] * L
for i in range(L):
    numy[i] = numx[i] - ave

if abs(min(numy)) < abs(max(numy)):
    maxX = max(numy)
else:
    maxX = abs(min(numy))

dp = [[0]*(2*maxX*L+1) for _ in range(L+1)]
dp[0][maxX*L] = 1
for i in range(L):
    for j in range(2*maxX*L+1):
        if (j-numy[i]) < 0 or (j - numy[i]) > 2*maxX*L:
            dp[i+1][j] = dp[i][j]
        else
        dp[i+1][j] = dp[i][j] + dp[i][j-numy[i]]
print(dp[L][maxX*L]-1)
Problem p02612 (python)

Fixed submission:
N=int(input())
a=N%1000
if a==0:
  print(0)
else:
  print(1000-N%1000)

Buggy submission (verdict: Runtime Error):
N=(input())
if int(N[1:])==0:
  print(0)
else:
  print(1000-int(N[1:]))
Problem p02677 (python)

Fixed submission:
import math
A,B,H,M=map(int,input().split())
s=abs(0.5*(H*60+M)-6*M)

a=math.radians(s)
h=A**2+B**2
minus=2*A*B*math.cos(a)
ans=(h-minus)**(1/2)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M=map(int,input().split())
s=abs(30*H-6*M)
if s>=180:
  s=360-s
  a=math.radians(s)
ans=(A**2+B**2-2*A*B*math.cos(a))**(1/2)
print(ans)
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
if s==t[:-1]:
    print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c,k= map(int,input().split())
if k>a:
    if k>a+b:
        print(a-k+a+b)
    else:
        print(a)
else:
    print(k)
Problem p02678 (python)

Fixed submission:
from collections import deque
n,m = map(int, input().split())


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

#print(graph)

dist = [-1]*2 + [0 for i in range (n-1)]

d = deque([1])
#print(d)

while d:
    v = d.popleft()
    for i in graph[v]:
        if dist[i] == 0:
            dist[i] = v
            d.append(i)

print("Yes")
ans = dist[2:]
print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m = map(int, input().split())


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

print(graph)

dist = [-1]*2 + [0 for i in range (n-1)]
dist[1] = 0
d = deque([1])
print(d)

while d:
    v = d.popleft()
    graph.remove(v)
    for i in graph[v]:
        if dist[i] == 0:
            dist[i] = v
            d.append(i)
            print(i ," " ,dist[i], d)
            

print("Yes")
ans = dist[2:]
print(*ans, sep="\n")
Problem p02612 (python)

Fixed submission:
n=int(input())
print((1000-n%1000)%1000)

Buggy submission (verdict: Runtime Error):
n=int(input())
print((1000-n%1000)%1000))
Problem p02606 (python)

Fixed submission:
l,r,d = map(int,input().split())
c=0
for i in range(l,r+1):
  if i%d==0:
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
l,r,d = map(int,input(.split()))
c=0
for i in range(l,r+1):
  if i%d==0:
    c+=1
print(c)
Problem p02658 (python)

Fixed submission:
import sys
n = input()
list_num =list(map(int,input().split()))
output = 1
if 0 in list_num:
    print(0)
    sys.exit()
for i in list_num:
    output = output * i
    if output > 10 ** 18:
        print(-1)
        sys.exit()
print(output)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
  b = 0
else:
  for i in range(N):
    b = b * a[i]
    if b > 10 ** 18:
      b = 'out'

if b == 'out':
  print(-1)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
  b = 0
else:
  for i in range(N):
    b *= a[i]
    if b > 10 ** 18:
      b = 'out'

if b == 'out':
  print(-1)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
from numba import njit
N = int(input())
a = list(map(int, input().split()))
@njit()
def main():
  b = 1
  for i in range(N):
    b *= a[i]
    if 0 in a:
      b = 0
      break
    elif b > 10 ** 18:
      b = 'out'
      break
  if b == 'out':
    print(-1)
  else:
    print(b)
main()
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
print(int(input())*int(input()))
Problem p02658 (python)

Fixed submission:
n = int(input());
list = list(map(int,input().split()))
zero = False
for i in list:
    if i==0:
        zero = True
        break
if zero:
    print(0)
else:
    ans = 1
    for i in list:
        ans *= i
        if ans>10**18:
            ans = -1
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input());
ans = 1;
zero = false
for i in map(int, input().split()):
    ans *= i
    if i==0:
        zero = true
print(ans if ans>=0 else -1);

Buggy submission (verdict: Runtime Error):
n = int(input());
list = map(int, input());
ans = 1
for i in range(n):
    ans *= list[i]
    if ans>10**18 :
        ans = -1
        break
print(ans)