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

Fixed submission:
LL = input()


count = 0
maxcount = 0

for ll in LL:
    if ll == "R":
        count+= 1
    else:
        count = 0
    
    if maxcount <= count:
        maxcount = count

print(maxcount)

Buggy submission (verdict: Runtime Error):

#"""
N, K = [int(n) for n in input().split(" ")]
Ps = [int(n) for n in input().split(" ")]
Cs = [int(n) for n in input().split(" ")]
#"""
"""
N = 10
K = 58345
Ps = [9, 1, 6, 7, 8, 4, 3, 2, 10, 5]
Cs = [695279662, 988782657, -119067776, 382975538, -151885171, -177220596, -169777795, 37619092, 389386780, 980092719]
"""
"""
N = 3
K = 3
Ps = [3, 1, 2]
Cs = [-1000,-2000,-3000]
"""

circles = []
already = {}
for p in range(N):
    if p not in already:
        tmp = []
        nowp = p
        while nowp not in tmp:
            tmp.append(nowp)
            already[nowp] = 1
            nowp = Ps[nowp] - 1
        circles.append(tmp)

#print(circles)

finalResult = -100000000000

def getCircleScore(circle, start, kk):
    #print(circle, start, kk)
    s = 0
    for k in range(kk):
        index = start + k
        if index >= len(circle):
            index = index % len(circle)
        s += Cs[circle[index]]
    return s

"""
maxCircle = []
maxCircleScore = -10000000000
maxIndex = 0
for circle in circles:
    CircleSum = sum([Cs[n] for n in circle])
    if maxCircleScore <= CircleSum:
        maxCircleScore = CircleSum
        maxCircle = circle
"""
#for circle in [maxCircle]:
for circle in circles:
    
    CircleSum = sum([Cs[n] for n in circle])
    #print(circle, CircleSum)
    score = 0
    if CircleSum > 0:
        score = K // len(circle) * CircleSum

    K = K % len(circle)
    if K == 0:
        K = len(circle)

    maxScore = -100000000000
    for start in range(len(circle)):
        #print("start", start)
        for kk in range(1, K+1):
            s = getCircleScore(circle, start, kk)
            #print(s)
            if maxScore <= s:
                maxScore = s

    final = score + maxScore

    if final >= finalResult:
        finalResult = final

print(finalResult)
Problem p02584 (python)

Fixed submission:
X, K, D = [int(n) for n in input().split(" ")]

#X = 10
#K = 1
#D = 2


startN = (D * K - X) // (2 * D)

N1 = startN + 1
N2 = startN
N3 = startN - 1

if N1 < 0:
    N1 = 0
if N2 < 0:
    N2 = 0
if N3 < 0:
    N3 = 0
if N1 > K:
    N1 = K
if N2 > K:
    N2 = K
if N3 > K:
    N3 = K

def getScore(n):
    score = X + n * D - D * (K - n)
    if score < 0:
        score = score * -1
    return score

score1 = getScore(N1)
score2 = getScore(N2)
score3 = getScore(N3)

minScore = score1
if minScore > score2:
    minScore = score2
if minScore > score3:
    minScore = score3

print(minScore)

Buggy submission (verdict: Runtime Error):
X, K, D = [int(n) for n in input()]

#X = 10
#K = 1
#D = 2


startN = (D * K - X) // (2 * D)

N1 = startN + 1
N2 = startN
N3 = startN - 1

if N1 < 0:
    N1 = 0
if N2 < 0:
    N2 = 0
if N3 < 0:
    N3 = 0

def getScore(n):
    score = X + n * D - D * (K - n)
    if score < 0:
        score = score * -1
    return score

score1 = getScore(N1)
score2 = getScore(N2)
score3 = getScore(N3)

minScore = score1
if minScore > score2:
    minScore = score2
if minScore > score3:
    minScore = score3

print(minScore)
Problem p02621 (python)

Fixed submission:
a = int(input())

print(a + a ** 2 + a ** 3)

Buggy submission (verdict: Runtime Error):
a = input()
print(a + a * a + a * a * a)
Problem p03455 (python)

Fixed submission:
b, c = map(int, input().split())
if b*c%2==0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a = input()
if a[0]*a[1]%2==0:
  print("Even")
else:
  print("Odd")
Problem p02582 (python)

Fixed submission:
s=input()
if s=="RRR":
	print(3)
elif s=="RRS" or s=="SRR":
	print(2)
elif s=="SSR" or s=="SRS" or s=="RSS" or s=="RSR":
	print(1)
else:
	print(0)

Buggy submission (verdict: Runtime Error):
import sys

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

p=list(map(int,input().split()))
c=list(map(int,input().split()))

check=[0 for i in range(n)]

if max(c)<0:
    print(max(c))
    sys.exit()

ans=0

for i in range(n):
    if check[i]==0:
        cnt=0
        check[i]=1
        li=[i]
        pc=p[i]-1
        while pc!=i:
            check[pc]=1
            li.append(pc)
            pc=p[pc]-1
        sumli=0
        for j in li:
            sumli+=c[j]
        add=0
        ki=k
        if k>len(li):
            if sumli>0:
                ki=(ki-1)%len(li)+1
                add=sumli*((k-ki)//len(li))
            else:
                ki=len(li)
        for w in range(1,ki+1):
            sumwmax=0
            sumw=0
            for j in range(w):
                sumw+=c[li[j]]
            for j in range(len(li)):
                sumw=sumw-c[li[j]]+c[li[(j+w)%len(li)]]
                sumwmax=max(sumw,sumwmax)
            cnt=max(cnt,sumwmax)
        ans=max(ans,cnt+add)

print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
if s=="RRR":
	print(3)
elif s=="RRS" or s=="SRR":
	print(2)
elif s=="SSR" or s=="SRS" or s=="RSS" or s=="RSR”:
	print(1)
else:
	print(0)

Buggy submission (verdict: Runtime Error):
s=input()
if s=="RRR":
	print(3)
elif s=="RRS" or s=="SRR":
	print(2)
elif s=="SSR" or s=="SRS" or s=="RSS" or s=="RSR:
	print(1)
else:
	print(0)
Problem p02585 (python)

Fixed submission:
import sys

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

p=list(map(int,input().split()))
c=list(map(int,input().split()))

check=[0 for i in range(n)]

if max(c)<0:
    print(max(c))
    sys.exit()

ans=0

for i in range(n):
    if check[i]==0:
        cnt=0
        check[i]=1
        li=[i]
        pc=p[i]-1
        while pc!=i:
            check[pc]=1
            li.append(pc)
            pc=p[pc]-1
        sumli=0
        for j in li:
            sumli+=c[j]
        add=0
        ki=k
        if k>len(li):
            if sumli>0:
                ki=(ki-1)%len(li)+1
                add=sumli*((k-ki)//len(li))
            else:
                ki=len(li)
        for w in range(1,ki+1):
            sumwmax=0
            sumw=0
            for j in range(w):
                sumw+=c[li[j]]
            for j in range(len(li)):
                sumw=sumw-c[li[j]]+c[li[(j+w)%len(li)]]
                sumwmax=max(sumw,sumwmax)
            cnt=max(cnt,sumwmax)
        ans=max(ans,cnt+add)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

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

p=list(map(int,input().split()))
c=list(map(int,input().split()))

check=[0 for i in range(n)]

if max(c)<0:
    print(max(c))
    sys.exit()

ans=0

for i in range(n):
    if check[i]==0:
        cnt=0
        check[i]=1
        li=[i]
        pc=p[i]-1
        while pc!=i:
            check[pc]=1
            li.append(pc)
            pc=p[pc]-1
        sumli=0
        for j in li:
            sumli+=c[j]
        add=0
        ki=k
        if sumli>0:
            add=sumli*(k//len(li))
        if ki>len(li):
            ki=ki%len(li)
        for w in range(1,ki+1):
            sumwmax=0
            sumw=0
            for j in range(w):
                sumw+=c[li[j]]
            for j in range(len(li)):
                sumw=sumw-c[li[j]]+c[li[(j+w)%len(li)]]
                print(sumw)
                sumwmax=max(sumw,sumwmax)
            cnt=max(cnt,sumwmax)
    ans=max(ans,cnt+add)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

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

p=list(map(int,input().split()))
c=list(map(int,input().split()))

check=[0 for i in range(n)]

if max(c)<0:
    print(max(c))
    sys.exit()

ans=0

for i in range(n):
    if check[i]==0:
        cnt=0
        check[i]=1
        li=[i]
        pc=p[i]-1
        while pc!=i:
            check[pc]=1
            li.append(pc)
            pc=p[pc]-1
        print(li)
        sumli=0
        for j in li:
            sumli+=c[j]
        add=0
        ki=k
        if sumli>0:
            add=sumli*(k//len(li))
        if ki>len(li):
            ki=ki%len(li)
        for w in range(1,ki+1):
            sumwmax=0
            sumw=0
            for j in range(w):
                sumw+=c[li[j]]
            for j in range(len(li)):
                sumw=sumw-c[li[j]]+c[li[(j+w)%len(li)]]
                print(sumw)
                sumwmax=max(sumw,sumwmax)
            cnt=max(cnt,sumwmax)
    ans=max(ans,cnt+add)

print(ans)
Problem p02609 (python)

Fixed submission:
import sys

n=int(input())
x=input()

if n==1:
    if x=="0":
        print(1)
    else:
        print(0)
    sys.exit()


lis=[0,1]

for i in range(2,n+1):
    ni=i
    cnti=0
    while ni!=0:
        if ni%2==1:
            cnti+=1
        ni=ni//2
    lis.append(lis[i%cnti]+1)

cnt=0
for i in range(len(x)):
    if x[i]=="1":
        cnt+=1

cpls=cnt+1
cmns=cnt-1

cplis=[1]
if cpls!=0:
    for i in range(n):
        cplis.append((cplis[i]*2)%cpls)
cmlis=[1]
if cmns!=0:
    for i in range(n):
        cmlis.append((cmlis[i]*2)%cmns)

cpsum=0
cmsum=0
for i in range(n):
    if x[i]=="1":
        cpsum=(cpsum+cplis[n-1-i])%cpls
        if cmns!=0:
            cmsum=(cmsum+cmlis[n-1-i])%cmns

for i in range(n):
    if x[i]=="0":
        Xi=(cpsum+cplis[n-1-i])%cpls
        print(lis[Xi]+1)
    else:
        if cmns==0:
            print(0)
        else:
            Xi=(cmsum-cmlis[n-1-i])%cmns
            print(lis[Xi]+1)

Buggy submission (verdict: Runtime Error):
import sys

n=int(input())
x=input()

if n==1:
    if x=="0":
        print(1)
    else:
        print(0)
    sys.exit()


lis=[0,1]

for i in range(2,n+1):
    ni=i
    cnti=0
    while ni!=0:
        if ni%2==1:
            cnti+=1
        ni=ni//2
    lis.append(lis[i%cnti]+1)

cnt=0
for i in range(len(x)):
    if x[i]=="1":
        cnt+=1

cpls=cnt+1
cmns=cnt-1

cplis=[1]
if cpls!=0:
    for i in range(n):
        cplis.append((cplis[i]*2)%cpls)
cmlis=[1]
if cmns!=0:
    for i in range(n):
        cmlis.append((cmlis[i]*2)%cmns)

cpsum=0
cmsum=0
for i in range(n):
    if x[i]=="1":
        cpsum=(cpsum+cplis[n-1-i])%cpls
        cmsum=(cmsum+cmlis[n-1-i])%cmns

for i in range(n):
    if x[i]=="0":
        Xi=(cpsum+cplis[n-1-i])%cpls
        print(lis[Xi]+1)
    else:
        if cmns==0:
            print(0)
        else:
            Xi=(cmsum-cmlis[n-1-i])%cmns
            print(lis[Xi]+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=input()
X=0
for i in range(n):
    X+=int(x[n-1-i])*(2**i)

lis=[0,1]

for i in range(2,n+1):
    ni=i
    cnti=0
    while ni!=0:
        if ni%2==1:
            cnti+=1
        ni=ni//2
    lis.append(lis[i%cnti]+1)

cnt=0
for i in range(len(x)):
    if x[i]=="1":
        cnt+=1

for i in range(n):
    Xi=X
    ci=cnt
    if x[i]=="0":
        Xi+=2**(n-1-i)
        ci+=1
    else:
        Xi-=2**(n-1-i)
        ci-=1
    print(lis[Xi%ci]+1)
Problem p02683 (python)

Fixed submission:
import numpy

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

l=[]
for i in range(n):
    l.append(list(map(int,input().split())))

bl=[]
for i in range(2**n):
    bli=list(map(int,format(i,"b").zfill(n)))
    bl.append(bli)


p=-1
for i in range(2**n):
    u=numpy.zeros(m,dtype=int)
    pi=0
    for j in range(n):
        if bl[i][j]==1:
            pi+=l[j][0]
            for k in range(m):
                u[k]+=l[j][k+1]
    if min(u)>=x:
        if p==-1:
            p=pi
        else:
            p=min(p,pi)

print(p)

Buggy submission (verdict: Runtime Error):
import numpy

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

l=[]
for i in range(n):
    l.append(list(map(int,input().split())))

bl=[]
for i in range(2**n):
    bli=list(map(int,format(i,"b").zfill(n)))
    bl.append(bli)


p=-1
for i in range(2**n):
    u=numpy.zeros(m,dtype=int)
    pi=0
    for j in range(n):
        if bl[i][j]==1:
            pi+=l[j][0]
            for k in range(m):
                u[k]+=l[j][k+1]
    if min(u)>=x:
        if p==-1:
            p=pi
        else:
            p=min(p,pi)

print(p)
Problem p02720 (python)

Fixed submission:
import queue

k=int(input())

q=queue.Queue()

for i in range(9):
    q.put(i+1)

c=1

for i in range(k):
    c=q.get()
    b=c%10
    if b!=0:
        q.put(10*c+b-1)
    q.put(10*c+b)
    if b!=9:
        q.put(10*c+b+1)

print(c)

Buggy submission (verdict: Runtime Error):
k=int(input())
A=[[1,1,1,1,1,1,1,1,1,1]]
for i in range(9):
    Ai=[]
    Ai.append(A[i][0]+A[i][1])
    for j in range(8):
        Ai.append(A[i][j]+A[i][j+1]+A[i][j+2])
    Ai.append(A[i][7]+A[i][8])
    A.append(Ai)
c=[]
for i in range(len(A)):
    c.append(sum(A[i][1:10]))
l=1 #length of number
while k>c[l-1]:
    k=k-c[l-1]
    l+=1
seq=[]

n=1 
while k>A[l-1][n]:
    k=k-A[l-1][n]
    n+=1
seq.append(n)#head number

for i in range(l-1):
    if seq[i]==0:
        j=0
        while k>A[l-2-i][j]:
            k=k-A[l-2-i][j]
            j+=1
        seq.append(j)
    else:
        j=seq[i]-1
        while k>A[l-2-i][j]:
            k=k-A[l-2-i][j]
            j+=1        
        seq.append(j)

for i in range(len(seq)):
    print(seq[i],end="")

Buggy submission (verdict: Runtime Error):
k=int(input())
A=[[1,1,1,1,1,1,1,1,1,1]]
for i in range(9):
    Ai=[]
    Ai.append(A[i][0]+A[i][1])
    for j in range(8):
        Ai.append(A[i][j]+A[i][j+1]+A[i][j+2])
    Ai.append(A[i][7]+A[i][8])
    A.append(Ai)
c=[]
for i in range(len(A)):
    c.append(sum(A[i][1:10]))

print(c)
l=1 #length of number
while k>c[l-1]:
    k=k-c[l-1]
    l+=1
seq=[]

n=1 
while k>A[l-1][n]:
    k=k-A[l-1][n]
    n+=1
seq.append(n)#head number

for i in range(l-1):
    if seq[i]==0:
        j=0
        while k>A[l-2-i][j]:
            k=k-A[l-2-i][j]
            j+=1
        seq.append(j)
    else:
        j=seq[i]-1
        while k>A[l-2-i][j]:
            k=k-A[l-2-i][j]
            j+=1        
        seq.append(j)

for i in range(len(seq)):
    print(seq[i],end="")
Problem p02743 (python)

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

if 4*a*b<(c-a-b)*(c-a-b) and c-a-b>=0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if (c-a-b)*(c-a-b)-round4*a*b>=0:
    print("Yes")
else:
    print("No")
Problem p02748 (python)

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

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[list(map(int,input().split())) for i in range(m)]

lis=[min(A)+min(B)]

for i in range(m):
    lis.append(A[C[i][0]-1]+B[C[i][1]-1]-C[i][2])

print(min(lis))

Buggy submission (verdict: Runtime Error):
a,b,m=map(int,input().split())
A=input().split()
B=input().split()
AA=[]
for i in range(len(A)):
	AA.append(int(A[i]))
BB=[]
for i in range(len(B)):
	BB.append(int(B[i]))
C=[]
for i in range(m):
	x,y,c=map(int,input().split())
	C.append(AA[x]+BB[y]-c)
C.append(min(AA)+min(BB))
print(min(C))
Problem p02756 (python)

Fixed submission:
s=input()
q=int(input())
query=[]
for i in range(q):
    query.append(input())
rev=0
bef=""
aft=""
for i in range(q):
    if query[i][0]=="1":
        rev+=1
    else:
        n,f,c=query[i].split()
        if (rev+int(f))%2==0:
            aft=aft+c
        else:
            bef=c+bef
seqfin=bef+s+aft
if rev%2==0:
    print(seqfin)
else:
    print(seqfin[::-1])

Buggy submission (verdict: Runtime Error):
s=input()
q=int(input())
query=[]
for i in range(q):
    query.append(input())
rev=0
bef=""
aft=""
for i in range(q):
    if query[i][0]=="1":
        rev+=1
    else:
        n,f,c=query[i].split()
        if (rev+int(f))%2==0:
            aft=aft+c
        else:
            bef=c+bef
seqfin=bef+s+aft
if rev%2==0:
    print(seqfin)
else:
    for i in range(len(seqfin)):
        print(seqfin[len(seq)-i-1],end="")

Buggy submission (verdict: Runtime Error):
s=input()
q=int(input())
query=[]
for i in range(q):
    query.append(input())
rev=0
before=""
after=""
for i in range(q):
    if query[i][0]=="1":
        rev+=1
    else:
        n,f,c=query[i].split()
        if (rev+int(f))%2==0:
            after=after+c
        else:
            before=c+before
seqfin=before+s+after
if rev%2==0:
    print(seqfin)
else:
    for i in range(len(seqfin)):
        print(seqfin[len(seq)-i-1],end="")
Problem p02803 (python)

Fixed submission:
import queue

h,w=map(int,input().split())

s=[]
for _ in range(h):
    s.append(input())

ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            seen=[[0 for _ in range(w)] for _ in range(h)]
            length=[[0 for _ in range(w)] for _ in range(h)]
            q=queue.Queue()
            q.put([i,j])
            seen[i][j]=1
            while not q.empty():
                ci,cj=q.get()
                for ni,nj in [[ci-1,cj],[ci+1,cj],[ci,cj-1],[ci,cj+1]]:
                    if 0<=ni<h and 0<=nj<w and s[ni][nj]=="." and seen[ni][nj]==0:
                        q.put([ni,nj])
                        length[ni][nj]=length[ci][cj]+1
                        seen[ni][nj]=1
            ans=max(ans,length[ci][cj])

print(ans)

Buggy submission (verdict: Runtime Error):
import queue

h,w=map(int,input().split())

s=[]
for _ in range(h):
    s.append(input())

ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            seen=[[0 for _ in range(w)] for _ in range(h)]
            length=[[0 for _ in range(w)] for _ in range(h)]
            q=queue.Queue()
            q.put([i,j])
            seen[i][j]=1
            while not q.empty():
                ci,cj=q.get()
                for ni,nj in [[ci-1,cj],[ci+1,cj],[ci,cj-1],[ci,cj+1]]:
                    if 0<=ni<h and 0<=nj<w and s[ni][nj]=="." and seen[ni][nj]==0:
                        q.put([ni,nj])
                        length[ni][nj]=length[ci][cj]+1
                        seen[ni][nj]=1
        ans=max(ans,max(max(length)))

print(ans)
Problem p02866 (python)

Fixed submission:
import math
import sys

n=int(input())

d=list(map(int,input().split()))

if d[0]!=0 or 0 in d[1:]:
    print(0)
    sys.exit()

lis=[0 for i in range(n)]

for i in range(n):
    lis[d[i]]+=1

for i in range(1,n-1):
    if lis[i]==0 and lis[i+1]!=0:
        print(0)
        sys.exit()
s=1

i=0
while i+1<=n-1 and lis[i+1]!=0:
    s=(s*pow(lis[i],lis[i+1],998244353))%998244353
    i+=1
print(s)

Buggy submission (verdict: Runtime Error):
import math
import sys

n=int(input())

d=list(map(int,input().split()))

if d[0]!=0 or 0 in d[1:]:
    print(0)
    sys.exit()

lis=[0 for i in range(n)]

for i in range(n):
    lis[d[i]]+=1

s=1

i=0
while lis[i+1]!=0:
    s=(s*pow(lis[i],lis[i+1],998244353))%998244353
    i+=1
print(s)
Problem p03447 (python)

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

print((x-a)%b)

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

l=[]
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            l.append(500*i+100*j+50*k)
n=0
for i in range(len(l)):
    if l[i]==x:
        n+=1
print(n)
Problem p03448 (python)

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

l=[]
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            l.append(500*i+100*j+50*k)
n=0
for i in range(len(l)):
    if l[i]==x:
        n+=1
print(n)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
x=int(input())/50
n=0
for i in range(x//10+1):
    n+=(x-10*i)//2+1
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
c=a*b
if c%2==0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=a*b
if c%2==0:
  print(Even)
else:
  print(Odd)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=a*b
if c%2==0:
  print(Even)
else:
  print(Odd)
Problem p03493 (python)

Fixed submission:
seq=input()
c=0
for i in range(3):
  if int(seq[i])==1:
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
seq=input()
c=0
for i in range(3):
  if seq[i]=1:
    c+=1
print(c)
Problem p03651 (python)

Fixed submission:
import fractions

n,k=map(int,input().split())
A=list(map(int,input().split()))

M=A[0]
g=A[0]
for i in range(n-1):
    M=max(M,A[i+1])
    g=fractions.gcd(g,A[i+1])

if k<=M:
    if g==1:
        print("POSSIBLE")
    elif k%g==0:
            print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import math

n,k=map(int,input().split())
A=list(map(int,input().split()))

M=A[0]
g=A[0]
for i in range(n-1):
    M=max(M,A[i+1])
    g=math.gcd(g,A[i+1])

if k<=M:
    if g==1:
        print("POSSIBLE")
    elif k%g==0:
            print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import math

n,k=map(int,input().split())
A=list(map(int,input().split()))

M=A[0]
g=A[0]
for i in range(n-1):
    M=max(M,A[i+1])
    g=math.gcd(g,A[i+1])

if k<=M:
    if g==1:
        print("POSSIBLE")
    elif k%g==0:
            print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import math

n,k=map(int,input().split())
A=list(map(int,input().split()))

M=A[0]
gcd=A[0]
for i in range(n-1):
    M=max(M,A[i+1])
    gcd=math.gcd(gcd,A[i+1])

if k<=M:
    if gcd==1:
        print("POSSIBLE")
    elif k%gcd==0:
            print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p02576 (python)

Fixed submission:
def resolve():
    import math
    n, x, t = map(int, input().split())
    print(math.ceil(n / x) * t)

resolve()

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

    h, w = map(int, input().split())
    c_h, c_w = map(int, input().split())
    c_h -= 1
    c_w -= 1
    d_h, d_w = map(int, input().split())
    d_h -= 1
    d_w -= 1
    dist = [[10**18 for i in range(w)] for i in range(h)]
    dist[c_h][c_w] = 0

    C = []
    for _ in range(h):
        C.append(list(input()))
    D = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    queue = deque([(c_h, c_w)])

    while queue:
        (x, y) = queue.popleft()
        d = dist[x][y]

        for (dx, dy) in D:
            new_x, new_y = x + dx, y + dy
            if -1 < new_x < h and -1 < new_y < w:
                if C[new_x][new_y] == '.' and dist[new_x][new_y] > d:
                    dist[new_x][new_y] = d
                    queue.appendleft((new_x, new_y))

        for dx in range(-2, 3):
            for dy in range(-2, 3):
                if -1 < x + dx < h and -1 < y + dy < w and (dx != 0 or dy != 0):
                    if C[x + dx][y + dy] == '.' and dist[x + dx][y + dy] > d:
                        dist[x + dx][y + dy] = d + 1
                        queue.append((x + dx, y + dy))

    ans = dist[d_h][d_w]
    if ans == 10**18:
        print(-1)
    else:
        print(ans)

resolve()

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

    h, w = map(int, input().split())
    c_h, c_w = map(int, input().split())
    c_h -= 1
    c_w -= 1
    d_h, d_w = map(int, input().split())
    d_h -= 1
    d_w -= 1
    dist = [[10**18 for i in range(w)] for i in range(h)]
    dist[c_h][c_w] = 0

    C = []
    for _ in range(h):
        C.append(list(input()))
    D = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    queue = deque([(c_h, c_w)])

    while queue:
        (x, y) = queue.popleft()
        d = dist[x][y]

        for (dx, dy) in D:
            new_x, new_y = x + dx, y + dy
            if -1 < new_x < h and -1 < new_y < w:
                if C[new_x][new_y] == '.' and dist[new_x][new_y] > d:
                    dist[new_x][new_y] = d
                    queue.appendleft((new_x, new_y))

        for dx in range(-2, 3):
            for dy in range(-2, 3):
                if -1 < x + dx < h and -1 < y + dy < w and (x + dx == 0 and y + dy == 0):
                    if C[x + dx][y + dy] == '.' and dist[x + dx][y + dy] > d:
                        dist[x + dx][y + dy] = d + 1
                        queue.append((x + dx, y + dy))

    ans = dist[d_h][d_w]
    if ans == 10**18:
        print(-1)
    else:
        print(ans)

resolve()
Problem p02600 (python)

Fixed submission:
def resolve():
    x = int(input())
    print(8 - ((x - 400) // 200))

resolve()

Buggy submission (verdict: Runtime Error):
x = int(input())
def resolve():
    x = int(input())
    print(8 - ((x - 400) // 200))

resolve()