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

Fixed submission:
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

Buggy submission (verdict: Runtime Error):
N = int(input())
testimony = [[] for _ in range(N)]
for i in range(N):
    num = int(input())
    person, state = map(int,input().split())
    testimony[i].append([person-1,state])
#print(testimony)
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)
Problem p03160 (python)

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

dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i<n-2:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,W = map(int,input().split())
w,v = [0]*n, [0]*n
for i in range(n):
    w[i], v[i] = map(int,input().split())

dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j-w[i]>=0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(dp[n][W])

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b,c = [0]*n, [0]*n, [0]*n
for i in range(n):
    a[i], b[i],c[i] = map(int,input().split())
dp = [[0]*3 for _ in range(n)]
dp[0] = [a[0],b[0],c[0]]
for i in range(n-1):
    dp[i+1][0] = max(dp[i+1][0], dp[i][1]+a[i+1], dp[i][2]+a[i+1])
    dp[i+1][1] = max(dp[i+1][1], dp[i][0]+b[i+1], dp[i][2]+b[i+1])
    dp[i+1][2] = max(dp[i+1][2], dp[i][0]+c[i+1], dp[i][1]+c[i+1])
print(max(dp[n-1]))
Problem p02582 (python)

Fixed submission:
main=input().rstrip()
count=0
flag=0
for i in range(3):
    if main[i]=='R' and flag==0:
        count+=1
    elif main[i]=='R' and flag==1:
        count=0
        count+=1
        flag=0
    else:
        flag=1
print(count)

Buggy submission (verdict: Runtime Error):
import sys
import resource
sys.setrecursionlimit(10000)
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
    if start==now:
        flag+=1
    if start==now and flag==2:
        return [max,sum,count]
    elif count==up:
        return [max,sum,count]
    else:
        count+=1
        sum+=c[p[now-1]-1]
        if max<sum:
            max=sum
        return find(start,p[now-1],up,max,sum,count,flag)
kara=[-10000000000]
for i in range(1,n+1):
    m=find(i,i,n,c[p[i-1]-1],0,0,0)
    if m[2]>=k:
        m=find(i,i,k,c[p[i-1]-1],0,0,0)
        if m[0]>kara[0]:
            kara[0]=m[0]
    elif m[1]<=0:
        if m[0]>kara[0]:
            kara[0]=m[0]
    else:
        w=k%m[2]
        if w==0:
            w=m[2]
        spe=find(i,i,w,c[p[i-1]-1],0,0,0)[0]
        if m[1]+spe>m[0] and m[1]*(k-w)//m[2]+spe>kara[0]:
            kara[0]=m[1]*(k-w)//m[2]+spe
        elif m[1]+spe<=m[0] and m[1]*((k-w)//m[2]-1)+m[0]>kara[0]:
            kara[0]=m[1]*((k-w)//m[2]-1)+m[0]
print(kara[0])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
    if start==now:
        flag+=1
    if start==now and flag==2:
        return [max,sum,count]
    elif count==up:
        return [max,sum,count]
    else:
        count+=1
        sum+=c[p[now-1]-1]
        if max<=sum:
            max=sum
        return find(start,p[now-1],up,max,sum,count,flag)
kara=[]
if n>k:
    for i in range(1,n+1):
        kara.append(find(i,i,k,c[p[i-1]-1],0,0,0)[0])
    result=max(kara)
else:
    for i in range(1,n+1):
        m=find(i,i,n,c[p[i-1]-1],0,0,0)
        if m[1]<=0:
            kara.append(m[0])
        else:
            w=k%m[2]
            spe=find(i,i,w,c[p[i-1]-1],0,0,0)[0]
            if w==0:
                spe=0
            if m[0]>int(m[1]*(k-w)//m[2]+spe):
                kara.append(m[0])
            else:
                kara.append(int(m[1]*(k-w)//m[2]+spe))
    result=max(kara)
print(result)
Problem p02615 (python)

Fixed submission:
num=int(input().rstrip())
m=input().rstrip().split()
main=[]
for i in m:
    main.append(int(i))
sample=sorted(main,reverse=True)
result=0
for i in range(2,num+1):
    if i%2==0:
        y=i/2-1
        result+=sample[int(y)]
    else:
        y=(i+1)/2-1
        result+=sample[int(y)]
print(result)

Buggy submission (verdict: Runtime Error):
num=int(input().rstrip())
m=input().rstrip().split()
main=[]
for i in m:
    main.append(int(i))
sample=sorted(main,reverse=True)
new=[]
pluss=[]
result=0
for i in range(num):
    if len(new)==0:
        new.append(sample[i])
    elif len(new)<=2:
        new.append(sample[i])
        result+=sample[i-1]
    else:
        plus=new[len(new)-1]
        point=len(new)
        for j in range(len(new)-1):
            if plus<new[j] and plus<new[j+1]:
                plus=min([new[j],new[j+1]])
                point=j+1
                if plus==pluss[len(pluss)-1]:
                    break
        result+=plus
        pluss.append(plus)
        if point==len(new):
            new.append(sample[i])
        else:
            new.insert(point,sample[i])
print(result)
Problem p02585 (python)

Fixed submission:
N, K = map(int, input().split())
P = list(map(lambda x:int(x) - 1,input().split()))
C = list(map(int, input().split()))
ans = -10**9

for i in range(N):
    tmp_max = [-10**9]*(N+1)
    total = 0
    current_block = P[i]
    for j in range(1, N + 1):
        total += C[current_block]
        tmp_max[j] = max(tmp_max[j-1], total)
        if current_block == i:
            break
        current_block = P[current_block]
    if total <= 0:
        ans = max(ans, tmp_max[j])
    else:
        n = K // j
        r = K % j
        if r == 0:
            ans = max(ans, total*(n-1) + tmp_max[j])
        else:
            ans = max(ans, total*n + tmp_max[r])

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = list(map(lambda x:int(x) - 1, input().split()))
C = list(map(int, input().split()))

L = [[] for _ in range(N)]
for i in range(N):
    cnt = C[i]
    blk = P[i]
    L[i].append([cnt, blk])
    for j in range(N):
        li = L[i][j][1]
        if li == i:
            break
        else:
            cnt += C[li]
            blk = P[li]
            L[i].append([cnt, blk])

ans = []
for l in L:
    maxl = 0
    lenl = len(l)
    modK = K % lenl
    numK = K // lenl
    if l[lenl - 1][0] > 0:
        maxl += numK * l[lenl - 1][0]
        maxl += max(l[:modK], key = lambda x:x[0])[0]
    else:
        maxl += max(l[:min(K, lenl)], key = lambda x:x[0])[0]
    ans.append(maxl)

print(max(ans))
Problem p02767 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
min_sum = 10**9
for i in range(min(l),max(l)+1):
    min_sum = min(min_sum,sum([(j-i)**2 for j in l]))

print(min_sum)

Buggy submission (verdict: Runtime Error):
import numpy
n = int(input())
l = numpy.array(list(map(int,input().split())))
av = round(numpy.average(l))
square_list = numpy.square(l - av)

print(numpy.sum(square_list))

Buggy submission (verdict: Runtime Error):
import numpy
n = int(input())
l = list(map(int,input().split()))
av = round(numpy.average(l))
sumsquare = 0
for i in l:
    sumsquare += (i - av)**2
print(sumsquare)
Problem p02924 (python)

Fixed submission:
N = int(input())
print(sum(range(N)))

Buggy submission (verdict: Runtime Error):
N = int(input())
print(sum(range(N))
Problem p02993 (python)

Fixed submission:
S=input()
n=len(S)
ans="Good"
for i in range(1,n):
  if S[i]==S[i-1]:
    ans="Bad"
    break
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
n=len(S)
ans="Good"
for i in (1,n):
  if S[i]==S[i-1]:
    ans="Bad"
    break
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
n=len(S)
ans="Good"
comp=S[0]
for i in (1,n):
  if S[i]==comp:
    ans="Bad"
    break
  comp=S[i]
print(ans)
Problem p02584 (python)

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

X = abs(X)

if X == D :
  if K == 0:
    print (X)
  elif K % 2 == 0:
    print(X)
  else:
    print(0)
elif X < D :
  if K == 0 :
    print(X)
  elif K % 2 ==0:
    print(X)
  else:
    print( abs(D - X))
elif X > K * D:
  print (X - K * D)

elif X // D < K:
  K = K - X // D
  if K % 2 == 0:
    print (X % D)
  else:
    print (abs(D - X % D))
else:
  print(X)

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

X = abs(X)

if X == D :
  print (X)
elif X < D :
  pirnt( D- X)
elif X > K * D:
  print (X - K * D)
elif X // D < K:
  print (X % D)
else:
  print(X)

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

X = abs(X)

if X == D :
  print (X)
elif X < D :
  pirnt( X - D)
elif X > K * D:
  print (X - K * D)
elif X // D < K:
  print (X % D)
else:
  print(X)

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

X = abs(X)

if X == D :
  print (X)
elif X <D :
  pirnt(X-D)
elif X > K * D:
  print (X - K * D)
elif X // D < K:
  print (X % D)
Problem p02621 (python)

Fixed submission:
a = int(input())

print(a + a*a + a*a*a)

Buggy submission (verdict: Runtime Error):
a = int(intput())

print(a + a*a + a*a*a)
Problem p02628 (python)

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

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

p.sort()

print(sum(p[:k]))

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

p = lilst(map(int, input().split()))

p.sort()

print(sum(p[:k]))
Problem p02639 (python)

Fixed submission:
X = list(map(int, input().split()))
sum = X[0] + X[1] + X[2] + X[3] + X[4]
print(15 - sum)

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

print(A.index(0)+1)
Problem p02641 (python)

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

if len(P) == 0:
  print(X)
else:
  for i in range(0,10000):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue

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

if P.len == 0:
  print(X)
else:
  for i in range(1,100):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+1) == 0:
      print(X+1)
      break
    else:
      continue

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

if P.len == 0:
  print(X)
else:
  for i in range(X,1):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+1) == 0:
      print(X+1)
      break
    else:
      continue

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

if P.len == 0:
  print(X)
else:
  for i in range(X,1):
    if P.index(X-i) == 0:
      print(X-i)
      break
    elif P.index(X+1) == 0:
      print(X+1)
      break
    else:
      continue
Problem p02608 (python)

Fixed submission:
def main():
    N = int(input())

    ans = [0] * 10001
    for i in range(1, 101):
        for j in range(1, 101):
            if i**2 + j**2 < 10001:
                for k in range(1, 101):
                    tmp = i**2 + j**2 + k**2 + i*j + j*k + i*k
                    if tmp < 10001:
                        ans[tmp] += 1

    for i in range(1, N+1):
        print(ans[i])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())

    ans = [0] * 4001
    for i in range(1, 201):
        for j in range(1, 201):
            if i**2 + j**2 < 4001:
                for k in range(1, 201):
                    tmp = i**2 + j**2 + k**2 + i*j + j*k + i*k
                    if tmp < 4001:
                        ans[tmp] += 1

    for i in range(1, N+1):
        print(ans[i])


if __name__ == '__main__':
    main()
Problem p02601 (python)

Fixed submission:
import sys
input = sys.stdin.readline
a, b, c = map(int, input().split())
k = int(input())
def two(num):
  for i in range(1,8):
    if (2**(i-1)<=num) & (num<2**(i)):
      return i
  return 0
ab = two(a/b)
b_ = b*2**ab
b_c = two(b_/c)

if k>=(ab+b_c):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
a, b, c = map(int, input().split())
k = int(input())
def two(num):
  for i in range(1,8):
    if (2**(i-1)<=num) & (num<2**(i)):
      return i
ab = two(a/b)
b_ = b*2**ab
b_c = two(b_/c)

if k>=(ab+b_c):
  print("Yes")
else:
  print("No")
Problem p02639 (python)

Fixed submission:
import sys
input = sys.stdin.readline
a = [int(s) for s in input().split()]
print(a.index(0)+1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
a = [int(s) for s in input().split()]
# a = list(range(1, 2*10**5))
ans = 0
for i,j in enumerate(a):
  a_i = sum(a[i]%s==0 for s in a)
  ans += min([2, a_i])
  # print(min([2, a_i]))
# print('###')
print(n - (ans-n))
Problem p02922 (python)

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

print(-((-int(b)+1)//(int(a)-1)))

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

print(-((-b+1)//(a-1)))
Problem p02924 (python)

Fixed submission:
n=int(input())

print(n*(n-1)//2)

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

print(n*(n-1)/2)
Problem p02947 (python)

Fixed submission:
n=int(input())
ss=[input() for i in range(n)]
d={}
ans=0
for i in ss:
    a=[c for c in i]
    a.sort()
    a="".join(a)

    if a in d:
        ans+=d[a]
        d[a]+=1
    
    else:
        d[a]=1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ss=[input() for i in range(n)]
d={}
for i in ss:
    a=[c for c in ss]
    a.sort()
    a="".join(a)

    if a in d:
        ans+=d[a]
        d[a]+=1
    
    else:
        d[a]=1

print(ans)
Problem p02995 (python)

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

def gcd(a,b):
    if a==0:
        return b
    else:
        return gcd(b%a,a)

cdlcm=c*d//gcd(c,d)

cd=b//c-(a-1)//c
dd=b//d-(a-1)//d
cdd=b//(cdlcm)-(a-1)//(cdlcm)

print(round(b-a+1-(cd+dd-cdd)))

Buggy submission (verdict: Runtime Error):
import math

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

cdlcm=c*d/math.gcd(c,d)

cd=b//c-(a-1)//c
dd=b//d-(a-1)//d
cdd=b//(cdlcm)-(a-1)//(cdlcm)

print(round(b-a+1-(cd+dd-cdd)))
Problem p03035 (python)

Fixed submission:
a,b=map(int,input().split())
if a>=13:
    print(b)
elif 6<=a<13:
    print(b//2)
else:
    print(0)

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

for i in range(m):
    b,c=map(int,input().split())
    a+=([c]*b)

a.sort()
a.reverse()
ans=0

for i in range(n):
    ans+=a[i]

print(ans)

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

for i in range(m):
    b,c=map(int,input().split())
    a+=([c]*b)

a.sort()
a.reverse()
ans=0

for i in range(n):
    ans+=a[i]

print(ans)
Problem p03043 (python)

Fixed submission:
import math

n,k = list(map(int,input().split()))
ans=0
if n<=k:
    for i in range(1,n+1):
        ans+=1/2**(math.ceil(math.log(k/i,2)))
else:
    ans+=n-k+1
    for i in range(1,k):
        ans+=1/2**(math.ceil(math.log(k/i,2)))

ans/=n

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n,k = list(map(int,input().split()))
ans=0
for i in range(1,n+1):
    ans+=1/2**(math.ceil(math.log(k//i,2)))

ans/=n

print(ans)
Problem p03102 (python)

Fixed submission:
N,M,C=map(int,input().split())
b=list(map(int,input().split()))
a=list(range(N))
for i in range(N):
    a[i]=list(map(int,input().split()))
ab=list(range(N))
count=0

for i in range(N):
    ab[i]=0
    for j in range(M):
        ab[i]+=a[i][j]*b[j]
    if ab[i]+C>0:
        count+=1

print(count)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split())
b=list(map(int,input().split()))
a=list(map(int,input().split()) for _ in range(N))
ab=list(range(N))
count=0

for i in range(N):
    for j in range(M):
        ab[i]+=a[i][j]*b[j]
    if ab[i]+C>0:
        count+=1

print(count)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split())
b=list(map(int,input().split()))
a=list(map(int,input().split() for _ in range(N))
ab=list(range(N))
count=0

for i in range(N):
    for j in range(M):
        ab[i]+=a[i][j]*b[j]
    if ab[i]+C>0:
        count+=1
print(count)
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
nump = list(map(int,input().split()))
nump.sort()
x_ind = -1
nump_io = [0]*103
for i in range(n):
    nump_io[nump[i]-1] = 1
    if(nump[i]==x):
        x_ind = i
if(x_ind == -1):
    print(x)
else:            
    for i in range(1,51):
        if(nump_io[(x-1)-i] == 0):
            print(x-i)
            break
        if(nump_io[(x-1)+i] == 0):
            print(x+i)
            break
# print(nump_io)

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
nump = list(map(int,input().split()))
nump.sort()
x_ind = -1
nump_io = [0]*100
for i in range(n):
    nump_io[nump[i]-1] = 1
    if(nump[i]==x):
        x_ind = i
if(x_ind == -1):
    print(x)
else:            
    for i in range(1,50):
        if(nump_io[(x-1)-i] == 0):
            print(x-i)
            break
        if(nump_io[(x-1)+i] == 0):
            print(x+i)
            break

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
nump = list(map(int,input().split()))
nump.sort()
x_ind = -1
nump_io = [0]*100
for i in range(n):
    nump_io[nump[i]-1] = 1
    if(nump[i]==x):
        x_ind = i
if(x_ind == -1):
    print(x)
else:            
    for i in range(1,50):
        if(list_io[(x-1)-i] == 0):
            print(x-i)
            break
        if(list_io[(x-1)+i] == 0):
            print(x+i)
            break

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
nump = list(map(int,input().split()))
if(n ==0):
    print(x)
else:
    list_io = [0]*100
    for i in range(n):
        list_io[nump[i]-1] = 1
    # print(list_io)
    for i in range(1,50):
        if(list_io[(x-1)-i] == 0):
            print(x-i)
            break
        if(list_io[(x-1)+i] == 0):
            print(x+i)
            break
    # print("?")
Problem p02642 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
A.sort()
# print(A)
multiple = [0]*(A[-1]+1)
for i in range(n):
    now = A[i]
    while(now <= A[-1]):
        multiple[now] += 1
        now += A[i]
ans = 0
for i in range(n):
    if(multiple[A[i]] == 1):
        ans += 1
# print(multiple)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A.sort()
# print(A)
multiple = [0]*(A[-1]+1)
for i in range(n):
    now = A[i]
    while(now <= A[-1]):
        multiple[now] += 1
        now += now
ans = 0
for i in range(N):
    if(multiple[A[i]] == 1):
        ans += 1
# print(multiple)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()
# print(A)
ans = 0
for i in range(max(len(A)-1,1)):
    f = 1
    for j in range(i+1,len(A)):
        # print(A[i],A[j])
        if(A[i]%A[j] == 0):
            # print("__")
            f = 0
            break
    if(f == 0):
        ans += 1
if(A[-2] == A[-1]):
    ans += 1
print(n-ans)
Problem p02647 (python)

Fixed submission:
from numba import jit
@jit
def main():
    n,k = map(int,input().split())
    lamps = list(map(int,input().split()))
    for ki in range(k):
        lamplog = [0]*(n+1)
        for i in range(n):
            lamplog[max(0,i-lamps[i])  ] += 1   #先端を出す
            lamplog[min(i+lamps[i]+1,n)] -= 1   #末尾を出す
        # print(lamplog)
        for i in range(n):                      #累積和を計算
            lamplog[i+1] += lamplog[i]
        # print(lamplog)
        lamplog.pop()
        if(lamplog == lamps):                   #１つ前の結果と今回の結果が同じだったら。
            break
        lamps = lamplog                         #今回の結果を記録
    return lamplog

lamplog = main()
ans = ""
for i in range(len(lamplog)):
    ans += str(lamplog[i]) +" "
print(ans.rstrip())

Buggy submission (verdict: Runtime Error):
import copy as cp
n,k = map(int,input().split())
lamps = list(map(int,input().split()))
for j in range(k):
    lamplog = [0]*n
    lamp_io = [0]*n
    for i in range(len(lamps)):
        if(i == 0):
            lamplog[i]=[0,lamps[i]]
        elif(i == n-1):
            lamplog[i]=[n-(lamps[i]+1) ,n-1]
        else:
            lamplog[i]= [max(i-lamps[i],0),min(i+lamps[i],n-1)]
    for i in range(len(lamplog)):
        for l in range(lamplog[i][1]-lamplog[i][0]+1):
            lamp_io[lamplog[i][0]+l]+=1
    # print(lamplog)
    lamps = cp.copy(lamp_io)
ans = ""
for i in range(len(lamp_io)):
    ans += str(lamps[i]) +" "
print(ans.rstrip())

Buggy submission (verdict: Runtime Error):
import copy as cp
n,k = map(int,input().split())
lamps = list(map(int,input().split()))
for j in range(k):
    lamplog = [0]*n
    lamp_io = [0]*n
    for i in range(len(lamps)):
        if(i == 0):
            lamplog[i]=[0,lamps[i]]
        elif(i == n-1):
            lamplog[i]=[n-(lamps[i]+1) ,n-1]
        else:
            lamplog[i]= [max(i-lamps[i],0),min(i+lamps[i],n-1)]
    for i in range(len(lamplog)):
        for l in range(lamplog[i][1]-lamplog[i][0]+1):
            lamp_io[lamplog[i][0]+l]+=1
    # print(lamplog)
    lamps = cp.copy(lamp_io)
ans = ""
for i in range(len(lamp_io)):
    ans += str(lamp_io[i]) +" "
print(ans.rstrip())
Problem p02658 (python)

Fixed submission:
n = int(input())
num = list(map(int,input().split()))
num.sort()
if(num[0] == 0):
    print(0)
else:
    ans = 1
    f = 0
    for i in range(len(num)):
        ans *= num[i]
        if(ans >1000000000000000000):
            print(-1)
            f = 1
            break
    if(f == 0):
        print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
num = list(map(int,input().split()))
num.sort()
if(num[0] == 0):
    print(0)
else:
    ans = 1
    for i in range(len(num)):
        ans *= num[i]
        if(ans >1000000000000000000):
            print(-1)
            return
    print(ans)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    long long k;
    long long ans = 1;
    for (int i = 0; i<N; i++ ){
        cin >>k;
        // cout << i << endl;
        ans *= k;
    } 
    if(ans > pow(10,18)){
        cout << -1;
    }else{
        cout << ans;
    }

    return 0;
}
Problem p02702 (python)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial
S=list(map(int,input()))
S.reverse()
# print(S)
count2019 = [0]*2019
count2019[0]=1

for i in range(len(S)):
    mod2019 =(mod2019+S[i]*10**i)%2019
    count2019[mod2019] +=1

ans =0
for i in count2019:
    if(i>=2):
        ans += factorial(i) // factorial(i) // factorial(i - 2)
print(ans)
# print(count2019)