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

Fixed submission:
import sys,math,collections,itertools,copy
input = sys.stdin.readline

D,G=list(map(int,input().split()))
score = []
maxScore = []
cos_per = []
maxS = []
for d in range(D):
    p,c=map(int,input().split())
    tmp = [(d+1)*100]*p
    tmp[-1]+=c
    score.append(tmp)
    maxScore.append(sum(tmp))
    maxS.append([p,sum(tmp)])
    #cos_per.append([d+1,sum(tmp)/p])
    cos_per.append([d+1,d+1])
#-最大いくつの問題セットを必要とするか-#
maxScore.sort()
tmp = 0
for idx,mS in enumerate(maxScore):
    tmp += mS
    if tmp >= G:
        max_num = idx+1
        break
#-最小でいくつの問題セットを必要とするか-#
tmp = 0
j=0
for i in range(len(maxScore)-1,-1,-1):
    j+=1
    tmp += maxScore[i]
    if tmp >= G:
        min_num = j
        break
#-最小-2個はスコアが高いものを入れてよし-#
#cos_per.sort(key = lambda x:-x[1])
choice = set(range(1,D+1))
#choiceList = []
#for i in range(0,min_num-3):
 #   choiceList+=score[cos_per[i][0]-1]
 #   choice.discard(cos_per[i][0])
 #   max_num -=1
 
#-足し上げる-#

ans = float('inf')
for ch in itertools.permutations(choice,max_num):
    times = 0
    total = 0
    flag = 0
    for ci in ch:
        if total + maxS[ci-1][1] <G:
            total += maxS[ci-1][1]
            times += maxS[ci-1][0]
        else:
            for sc in score[ci-1]:
                total += sc
                times += 1
                if total >= G:
                    ans = min(ans,times)
                    falg = 1
                    break
    if flag ==1:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools,copy
input = sys.stdin.readline

D,G=list(map(int,input().split()))
score = []
maxScore = []
cos_per = []
for d in range(D):
    p,c=map(int,input().split())
    tmp = [(d+1)*100]*p
    tmp[-1]+=c
    score.append(tmp)
    maxScore.append(sum(tmp))
    #cos_per.append([d+1,sum(tmp)/p])
    cos_per.append([d+1,d+1])
#-最大いくつの問題セットを必要とするか-#
maxScore.sort()
tmp = 0
for idx,mS in enumerate(maxScore):
    tmp += mS
    if tmp >= G:
        max_num = idx+1
        break
#-最小でいくつの問題セットを必要とするか-#
tmp = 0
j=0
for i in range(len(maxScore)-1,-1,-1):
    j+=1
    tmp += maxScore[i]
    if tmp >= G:
        min_num = j
        break
#-最小-2個はスコアが高いものを入れてよし-#
#cos_per.sort(key = lambda x:-x[1])
#choice = set(range(1,D+1))
#choiceList = []
#for i in range(0,min_num-3):
 #   choiceList+=score[cos_per[i][0]-1]
 #   choice.discard(cos_per[i][0])
 #   max_num -=1
 
#-足し上げる-#

ans = float('inf')
for ch in itertools.permutations(choice,max_num):
    times = 0
    total = 0
    flag = 0
    for ci in ch:
        for sc in score[ci-1]:
            total += sc
            times += 1
            if total >= G:
                ans = min(ans,times)
                falg = 1
                break
    if flag ==1:
        break
print(ans)
Problem p03309 (python)

Fixed submission:
import sys
import numpy as np
import math
import copy
input = sys.stdin.readline
 
N = int(input())
A = np.array(list(map(int,input().split())))
if N ==1:
    ans = 0
else:
    r = np.array(list(range(1,N+1)))
    B = np.array(sorted(A-r))
    ans = float('inf')
    for i in range(max(N//2-1,0),min(N//2+2,N)):
        c = list(map(abs,(B - B[i])))
        ans = min(ans,sum(c))
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
import math
import copy
input = sys.stdin.readline
 
N = int(input())
A = np.array(list(map(int,input().split())))
r = np.array(list(range(1,N+1)))
B = np.array(sorted(A-r))
ans = float('inf')
for i in range(max(N//2-1,0),max(N//2+2,N)):
    c = list(map(abs,(B - B[i])))
    ans = min(ans,sum(c))
print(ans)

Buggy submission (verdict: Runtime Error):
mport sys
import numpy as np
import math
import copy
input = sys.stdin.readline
 
N = int(input())
A = np.array(list(map(int,input().split())))
r = np.array(list(range(1,N+1)))
B = np.array(sorted(A-r))
ans = float('inf')
for i in range(max(N//2-1,0),max(N//2+2,N)):
    c = list(map(abs,(B - B[i])))
    ans = min(ans,sum(c))
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
import math
input = sys.stdin.readline
 
N = int(input())
A = np.array(list(map(int,input().split())))
r = np.array(list(range(1,N+1)))
B = A-r
C = list(map(abs,B-(math.ceil(sum(B)/len(B)))))
D = list(map(abs,B-(math.floor(sum(B)/len(B)))))
E = list(map(abs,B-(B[N//2])))
F = list(map(abs,B-(B[N//2+1])))

ans = min(sum(C),sum(D))
ans = min(ans,sum(E))
ans = min(ans,sum(F))

print(ans)
Problem p03455 (python)

Fixed submission:
print('Odd' if eval(input().replace(" ",'*'))%2 else 'Even')

Buggy submission (verdict: Runtime Error):
print('Odd' if eval(input().replace("",'*')%2) else 'Even')

Buggy submission (verdict: Runtime Error):
print('Odd' if eval(input().replace("",*)%2) else 'Even')
Problem p03469 (python)

Fixed submission:
s = input()
print(s[:3]+'8'+s[4:])

Buggy submission (verdict: Runtime Error):
s = input()
pirnt(s[:3]+'7'+s[4:])

Buggy submission (verdict: Runtime Error):
s = input()
pirnt(s[0:3]+'7'+s[4:])

Buggy submission (verdict: Runtime Error):
s = input()
pirnt(s[0:3]='7'+s[4:])
Problem p03470 (python)

Fixed submission:
N = int(input())
d = sorted(list((input()) for _ in range(N)))
count = 0
dum =""
for i in range(N):
    if d[i] != dum:
        dum = d[i]
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = list((int(input()) for _ in range(N)))
import pandas as pd
print(len(pd.DataFrame(d)[0].value_counts()))
Problem p03477 (python)

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

A,B,C,D=list(map(int,input().split()))
if A+B == C+D:
    print('Balanced')
elif A+B > C+D:
    print('Left')
else:
    print('Right')

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

A,B,C,D=list(map(int,input().split()))
if A+B == C+D:
    print('Balanced')
elif A+B ＞ C+D:
    print('Left')
else:
    print('Right')
Problem p03583 (python)

Fixed submission:
N = int(input())
for ai in range(1,3500):
    for bi in range(1,3500):
        try:
            ci = N*ai*bi/(4*ai*bi-N*ai-N*bi)
        except:
            continue
        if ci == int(ci) and ci > 0:
            print(ai,bi,int(ci))
            exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
if N%2==0:
    a=N//2
    b=N
    c=N
    print(a,b,c)
else:
    for ai in range(N//4,3500):
        for bi in range(N//4,3500):
            ci = N*ai*bi/(4*ai*bi-N*ai-N*bi)
            if ci == int(ci) and ci > 0:
                print(ai,bi,int(ci))
                exit()
Problem p03606 (python)

Fixed submission:
N = int(input())
seat = [0]*100000
for i in range(N):
    a,b = map(int,list(input().split()))
    for j in range(a,b+1):
        seat[j-1] = 1
print(sum(seat))

Buggy submission (verdict: Runtime Error):
N = int(input())
seat = [0]*100000
for i in range(N):
    a,b = map(int,list(input().split()))
    for j in range(a,b+1):
        seat[j] = 1
print(sum(seat))

Buggy submission (verdict: Runtime Error):
N = int(input())
seat = [0]*100000
for i in range(N):
    li,ri = map(int,input().split())
    for j in range(li,ri+1):
        seat[j] = 1
print(sum(seat))
Problem p03607 (python)

Fixed submission:
N = int(input())
dic_a = {}
for i in range(N):
    a= int(input())
    if a in dic_a:
        dic_a[a] +=1
        dic_a[a] = dic_a[a]%2
    else:
        dic_a[a] = 1
print(sum(list(dic_a.values())))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [0]*(10**6)
for i in range(N):
    a = int(input())
    s[a-1] += 1
    s[a-1] = s[a-1]%2
print(sum(s))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [0]*10**6
for i in range(N):
    a = int(input())
    s[a-1] += 1
    s[a-1] = s[a-1]%2
print(sum(s))
Problem p03623 (python)

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

x,a,b = list(map(int,input().split()))
print('A' if abs(x-a) < abs(x-b) else 'B')

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

int(input())
list(map(int,input().split()))
input().rstrip()
Problem p03720 (python)

Fixed submission:
N,M = list(map(int,input().split()))
lis = []
for i in range(N):
    lis.append([i+1])
for i in range(M):
    a,b = list(map(int,input().split()))
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(N):
    print(len(lis[i])-1)

Buggy submission (verdict: Runtime Error):
	N,M = list(map(int,input().split()))
lis = []
for i in range(N):
    lis.append([i+1])
for i in range(M):
    a,b = list(map(int,input().split()))
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(N):
    print(len(lis[i])-1)
Problem p03814 (python)

Fixed submission:
s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s)-1,-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)

Buggy submission (verdict: Runtime Error):
s = input()
a=0
b=0
for i in range(len(s)):
  if s[i]=='A':
    a = i
    break
for i in range(len(s),-1,-1):
  if s[i] == 'Z':
    b = i
    break
print(b-a+1)
Problem p03830 (python)

Fixed submission:
N= int(input())

m = 10**9+7
pri_num = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
dic = {}

for i in range(2,N+1):
    for pri in pri_num:
        while i>0:
            if i % pri == 0:
                if pri in dic:
                    dic[pri] +=1
                else:
                    dic[pri]=1
                i = i//pri

            else:
                break

count = 1
for val in dic.values():
    count = (count*(val+1))%m
print(count)

Buggy submission (verdict: Runtime Error):
import sympy
import math
N = int(input())
l = math.factorial(N)
t = sympy.divisors(l)
print(len(t)%(10**9+7))
Problem p03966 (python)

Fixed submission:
import math
N = int(input())
t= 1
a= 1

def t_small(t,a,t1,a1):
    gain = -(-t//t1)
    t = gain*t1
    a_tmp=gain*a1
    if a_tmp<a:
        gain_a = -(-a//a_tmp)
        t *= gain_a
        a = a_tmp*gain_a
    else:
        a = a_tmp
    return t,a,t+a

def a_small(t,a,t1,a1):
    gain = -(-a//a1)
    a = gain*a1
    t_tmp=gain*t1
    if t_tmp<t:
        gain_t = -(-t//t_tmp)
        a *= gain_t
        t = t_tmp*gain_t
    else:
        t = t_tmp
    return t,a,t+a

ans = 0
for _ in range(N):
    t1,a1 = map(int,input().split())
    tt1,aa1,sta1 = t_small(t,a,t1,a1)
    tt2,aa2,sta2 = a_small(t,a,t1,a1)
    if sta1<=sta2:
        t=tt1;a=aa1;ans = sta1
    else:
        t=tt2;a=aa2;ans=sta2
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
t= 1
a= 1

def t_small(t,a,t1,a1):
    gain = -(-t//t1)
    t = gain*t1
    a_tmp=gain*a1
    if a_tmp<a:
        gain_a = -(-a//a_tmp)
        t *= gain_a
        a = a_tmp*gain_a
    else:
        a = a_tmp
    return t,a,t+a

def a_small(t,a,t1,a1):
    gain = -(-a//a1)
    a = gain*a1
    t_tmp=gain*t1
    if t_tmp<t:
        gain_t = -(-t//t_tmp)
        a *= gain_t
        t = t_tmp*gain_t
    else:
        t = t_tmp
    return t,a,t+a

ans = 0
for _ in range(N):
    t1,a1 = map(int,input().split())
    tt1,aa1,sta1 = t_small(t,a,t1,a1)
    tt2,aa2,sta2 = a_small(t,a,t1,a1)
    if sta1<=sta2:
        t=tt1;a=aa1,ans = sta1
    else:
        t=tt2,a=aa2,ans=sta2
print(ans)
Problem p04026 (python)

Fixed submission:
import collections
s = input()
ls = len(s)
if ls ==2 and s[0]!=s[1]:
    print(-1,-1)
    exit()
elif ls ==2 and s[0]==s[1]:
    print(1,2)
    exit()
for i in range(2,ls):
    tmp = collections.Counter(s[i-2:i+1])
    if len(tmp.keys())<=2:
        print(i-1,i+1)
        exit()
print(-1,-1)

Buggy submission (verdict: Runtime Error):
import collections
s = input()
ls = len(s)
if ls ==2 and s[0]=!s[1]:
    print(-1,-1)
elif ls ==2 and s[0]==s[1]:
    print(1,2)
for i in range(2,ls):
    tmp = collections.Counter(s[i-2:i+1])
    if len(tmp.keys())<=2:
        print(i-1,i+1)
        exit()
print(-1,-1)
Problem p04043 (python)

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

a,b,c = sorted(list(map(int,input().split())))
print('YES' if a==b and b==5 and c==7 else 'NO')

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print(*s,sep="")
Problem p04045 (python)

Fixed submission:
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N,K=list(map(int,input().split()))
D = list(map(int,input().split()))
Ds = set([0,1,2,3,4,5,6,7,8,9])-set(D)
if 0 in Ds:
    can = list(itertools.product(Ds,repeat = 5))
    candi = []
    for c in can:
        candi.append(10**4*c[0]+10**3*c[1]+10**2*c[2]+10**1*c[3]+c[4])
    candi = sorted(candi)
else:
    Ds = Ds | set([0])
    can = list(itertools.product(Ds,repeat = 5))
    candi = []
    for c in can:
        cs = (10**4*c[0]+10**3*c[1]+10**2*c[2]+10**1*c[3]+c[4])
        s = list(str(cs))
        if '0' in s:
            continue
        else:
            candi.append(cs)
    candi = sorted(candi)
    
print(candi[bisect.bisect_left(candi,N)])

Buggy submission (verdict: Runtime Error):
import sys,math,collections,itertools,bisect
input = sys.stdin.readline

N,K=list(map(int,input().split()))
D = list(map(int,input().split()))
Ds = set([0,1,2,3,4,5,6,7,8,9])-set(D)
can = list(itertools.product(Ds,repeat = 5))
candi = []
for c in can:
    candi.append(1**4*c[0]+10**3*c[1]+10**2*c[2]+10**1*c[3]+c[4])
candi = sorted(candi)
print(candi[bisect.bisect_left(candi,N)])
Problem p02534 (python)

Fixed submission:
print('ACL'*int(input()))

Buggy submission (verdict: Runtime Error):
import sys

arg = sys.argv
#arg.pop(0)
#print(arg)

for i in range(arg[0]):
  print('ACL')
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3 * (r ** 2))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(N):
	if sum(x % (N - i) for x in ans) != a[N - 1 - i]:
		ans.append(N - i)
print(len(ans))
Ans = [str(x) for x in ans]
print(' '.join(Ans))
Problem p03005 (python)

Fixed submission:
N, K = map(int, input().split())
if K == 1:
	print(0)
else:
	print(N - K)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1:
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[1] >= 0:
	print(sum(A) - 2 * A[0])
	y = A[0]
	for i in range(N - 2):
		print(y, A[i + 1])
		y -= A[i + 1]
	print(A[-1], y)
elif A[-1] < 0:
	print(-sum(A) + 2 * A[-1])
	y = A[-1]
	for i in range(N - 1):
		print(y, A[i])
		y -= A[i]
else:
	for i in range(N - 1):
		if A[i] < 0 and A[i + 1] >= 0:
			n = i
	print(-sum(A[:i]) + sum(A[i:]))
	y = A[0]
	for i in range(N - n - 2):
		print(y, A[-i - 2])
		y -= A[-i - 2]
	print(A[-1], y)
	y = A[-1] - y
	for i in range(n):
		print(y, A[i + 1])
Problem p03006 (python)

Fixed submission:
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1:
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
L = []
for i in range(N):
	a, b = x[i][0], x[i][1]
	for j in range(N):
		if a > x[j][0] or b > x[j][1]:
			L.append((a - x[j][0], b - x[j][1]))
c = collections.Counter(L)
max = c.most_common(1)[0][1]
print(N - max)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
L = []
for i in range(N):
	a, b = x[i][0], x[i][1]
	for j in range(N):
		if a >= x[j][0] and b >= x[j][1] and not(a == x[j][0] and b == x[j][1]):
			L.append((a - x[j][0], b - x[j][1]))
c = collections.Counter(L)
max = c.most_common()[0][1]
print(N - max)
Problem p03023 (python)

Fixed submission:
N = int(input())
print((N - 2) * 180)

Buggy submission (verdict: Runtime Error):
mod = 10 ** 6 + 3

W = [1] * (mod)
for i in range(mod - 1):
	W[i + 1] = ((i + 1) * W[i]) % mod

def rev(a):
	return pow(a, mod - 2, mod)

def f(x, d, n):
	if d == 0:
		return pow(x, n, mod)
	else:
		d_r = rev(d)
		xdr = d_r * x % mod
		if xdr == 0:
			return 0
		elif (xdr + n - 1) >= mod:
			return 0
		else:
			return (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod

ans = []
q = int(input())
for _ in range(q):
    x,d,n = map(int,input().split())
    ans.append(f(x,d,n))
for i in ans:
    print(i)
Problem p03025 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
mod = 10 ** 9 + 7

W = [1] * (2 * N)
for i in range(2 * N - 1):
	W[i + 1] = ((i + 1) * W[i]) % mod

def rev(a):
	return pow(a, mod - 2, mod)

def comb(a, b):
	return (W[a] * rev(W[b]) * rev(W[a - b])) % mod

def f(a, b):
	res = 0
	for i in range(N):
		res += ((i + N) * com[i] * pow(b, i, mod)) % mod
		res %= mod
	return (pow(a, N, mod) * res) % mod

a = A * rev(A + B)
b = B * rev(A + B)
c = C * rev(100)
com = [comb(i + N - 1, i) for i in range(N)]

w_a = f(a, b)
w_b = f(b, a)
ans = ((w_a + w_b) * rev(1 - c)) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
mod = 10 ** 9 + 7

W = [1] * (2 * N)
for i in range(2 * N - 1):
	W[i + 1] = ((w + 1) * W[i]) % mod

def rev(a):
	return pow(a, mod - 2, mod)

def comb(a, b):
	return (W[a] * rev(W[b]) * rev(W[a - b])) % mod

def f(a, b):
	res = 0
	for i in range(N):
		res += ((i + N) * com[i] * pow(b, i, mod)) % mod
		res %= mod
	return (pow(a, N, mod) * res) % mod

a = A * rev(A + B)
b = B * rev(A + B)
c = C * rev(100)
com = [comb(i + N - 1, i) for i in range(N)]

w_a = f(a, b)
w_b = f(b, a)
ans = ((w_a + w_b) * rev(1 - c)) % mod
print(ans)
Problem p03029 (python)

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

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
n_switch = []
switch = []
for i in range(M):
	s = list(map(int, input().split()))
	n_switch.append(s[0])
	switch.append(s[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** N):
	x = 1
	b = bin(i)[2:].rjust(N, '0')
	for j in range(M):
		n_light = 0
		for k in range(n_switch[j]):
			if b[switch[j][k] - 1] == '1':
				n_light += 1
		if n_light % 2 != p[j]:
			x *= 0
			break
	if x == 1:
		ans += 1
print(ans)
Problem p02603 (python)

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

money = 1000
ticket = 0
for i in range(N - 1):
    # buy
    if A[i] < A[i + 1]:
        ticket += money // A[i]
        money -= (money // A[i]) * A[i]
    elif A[i] == A[i + 1]:
        pass
    # sell
    else:
        money += A[i] * ticket
        ticket = 0

money += A[-1] * ticket

print(money)

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

money = 1000
ticket = 0
for i in range(N):
    # buy
    if A[i] < A[i + 1]:
        money -= (money // A[i]) * A[i]
        ticket += money // A[i]
    elif A[i] == A[i + 1]:
        pass
    # sell
    else:
        money += A[i] * ticket
        ticket = 0
Problem p02658 (python)

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

count = 1

if 0 in A:
    print(0)
    exit()

for i in A:
    count *= i
    if count > 10**18:
        print(-1)
        exit()

print(count)

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

count = 1

for i in A:
    if A > 10**18:
        print(-1)
        exit()

for i in A:
    count *= i

if count > 10**18:
    print(-1)
else:
    print(count)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if S == T[:-1]:
	print("Yes")
else:
    print("No")

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

if S == T[:-2]
	print("Yes")
else:
    print("No")
Problem p02761 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    s = [0] * M
    c = [0] * M
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    if M == 0:
        if N == 1:
            print(0)
            exit()
        elif N == 2:
            print(10)
            exit()
        elif N == 3:
            print(100)
            exit()

    for i in range(M):
        if s[i] == 1 and c[i] == 0 and N > 1:
            print(-1)
            exit()

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    for i in range(M - 1):
        if s[i] == s[i + 1]:
            if c[i] != c[i + 1]:
                print(-1)
                exit()

    for i in range(1, N + 1):
        if i not in s:
            s.append(i)
            if i == 1:
                c.append(1)
            else:
                c.append(0)

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    k = 1
    ans = ''
    for i in range(len(s)):
        if s[i] == k:
            ans += str(c[i])
            k += 1
    print(ans)




if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    s = [0] * M
    c = [0] * M
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    for i in range(M):
        if s[i] == 1 and c[i] == 0 and N > 1:
            print(-1)
            exit()

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    for i in range(M - 1):
        if s[i] == s[i + 1]:
            if c[i] != c[i + 1]:
                print(-1)
                exit()

    for i in range(1, N + 1):
        if i not in s:
            s.append(i)
            if i == 1:
                c.append(1)
            else:
                c.append(0)

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    k = 1
    ans = ''
    for i in range(len(s)):
        if s[i] == k:
            ans += str(c[i])
            k += 1
    print(ans)




if __name__ == '__main__':
    main()