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

Fixed submission:
#プログラムの例:
n=int(input())
listsT=list(map(int,input().split()))
from fractions import gcd
lists_left=[]
lists_right=[]
number1=0
number2=0
for i in range(n):
    if i==0:
        lists_left.append(0)
    if i==1:
        lists_left.append(listsT[0])
        number1=listsT[0]
    if i>=2:
        number1=gcd(number1,listsT[i-1])
        lists_left.append(number1)

number2=listsT[-1]
for j in range(n,0,-1):
    if j==n:
        lists_right.append(0)
    if j==n-1:
        lists_right.append(listsT[-1])
    if j<n-1:      
        number2=gcd(number2,listsT[j])  
        lists_right.append(number2)
ans=0
for x in range(n):
    if ans<= gcd(lists_right[x],lists_left[n-1-x]):
        ans=gcd(lists_right[x],lists_left[n-1-x])   
print(ans)

Buggy submission (verdict: Runtime Error):
# セグメント木。区間における要素の取得をO(logN)で行うことが可能である。
class SegTree():
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.func = function
        self.basement = basement
        self.seg = [basement]*2**(self.K+1)

        for i in range(self.n):
            self.seg[i+2**self.K-1] = lists[i]

        for i in range(2**(self.K)-2, -1, -1):
            self.seg[i] = self.func(self.seg[2*i+1], self.seg[2*i+2])

    def update(self, k, value):
        # 0-indexでa[k]の値をvalueに変更
        k += 2**self.K-1
        self.seg[k] = value
        while k:
            k = (k-1)//2
            self.seg[k] = self.func(self.seg[k*2+1], self.seg[k*2+2])

    def query(self, p, q):
        # 0-indexで[p,q)の値を取得する
        if q <= p:
            return self.basement
        num = 2**self.K
        p += num-1
        q += num-2
        res = self.basement
        while q-p > 1:
            if p & 1 == 0:
                res = self.func(res, self.seg[p])
            if q & 1 == 1:
                res = self.func(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.func(res, self.seg[p])
        else:
            res = self.func(self.func(res, self.seg[p]), self.seg[q])
        return res


#gcd on blackboard
#セグ木（区間gcd) verify
from math import gcd
N=int(input())
A=list(map(int,input().split()))
seg=SegTree(A,gcd,0)
ans=1
for i in range(-1,N):
    v=gcd(seg.query(0,i),seg.query(i+1,N))
    ans=max(v,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
#プログラムの例:
n=int(input())
listsT=list(map(int,input().split()))
from math import gcd
lists_left=[]
lists_right=[]
number1=0
number2=0
for i in range(n):
    if i==0:
        lists_left.append(0)
    if i==1:
        lists_left.append(listsT[0])
        number1=listsT[0]
    if i>=2:
        number1=gcd(number1,listsT[i-1])
        lists_left.append(number1)

number2=listsT[-1]
for j in range(n,0,-1):
    if j==n:
        lists_right.append(0)
    if j==n-1:
        lists_right.append(listsT[-1])
    if j<n-1:      
        number2=gcd(number2,listsT[j])  
        lists_right.append(number2)
ans=0
for x in range(n):
    if ans<= gcd(lists_right[x],lists_left[n-1-x]):
        ans=gcd(lists_right[x],lists_left[n-1-x])   
print(ans)
Problem p03078 (python)

Fixed submission:
import sys
input = sys.stdin.readline
x,y,z,K=map(int,input().split())
listsa=list(map(int,input().split()))#長さはｘ
listsb=list(map(int,input().split()))#長さはy
listsc=list(map(int,input().split()))#長さはz
if x*y>3000:
    suballlist=[]
    for i in listsa:
        for j in listsb:
            suballlist.append(i+j)
    suballlist=sorted(suballlist,reverse=True)
    uselist=suballlist[:3000]
    alllist=[]
    
    for i in uselist:
        for j in listsc:
            alllist.append(i+j)
            
    alllist=sorted(alllist,reverse=True)
    for i in range(K):
        print(alllist[i])
    
elif x*y<=3000:
    alllist=[]
    for i in listsa:
        for j in listsb:
            for k in listsc:
                alllist.append(i+j+k)
                
    alllist=sorted(alllist,reverse=True)
    for i in range(K):
        print(alllist[i])

Buggy submission (verdict: Runtime Error):
x,y,z,K=map(int,input().split())
listsa=list(map(int,input().split()))#長さはｘ
listsb=list(map(int,input().split()))#長さはy
listsc=list(map(int,input().split()))#長さはz
if x*y>3000:
    suballlist=[]
    for i in lista:
        for j in listsb:
            suballlist.append(i+j)
    suballlist=sorted(suballlist,reverse=True)
    uselist=suballlist[:3000]
    alllist=[]
    for i in uselist:
        for j in listsc:
            alllist.append(i+j)
    alllist=sorted(alllist,reverse=True)
    for i in range(K):
        print(alllist[i])
    
elif x*y<=3000:
    alllist=[]
    for i in listsa:
        for j in listsb:
            for k in listsc:
                alllist.append(i+j+k)
                
    alllist=sorted(alllist,reverse=True)
    for i in range(K):
        print(alllist[i])
Problem p03095 (python)

Fixed submission:
n=int(input())
s=input()
import collections
s=dict(collections.Counter(s))
ans=1
for i in s.values():
    ans*=(i+1)
    ans=(ans)%(10**9+7)
print(ans-1)

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

s=input()

s=s+str(X)

counter=1

lists=[]

for i in range(n):

  if s[i]==s[i+1]:

    counter+=1

  else:

    lists.append(counter)

    counter=1

ans=1

for i in lists:

  ans=ans*i%(10**9+7)

print(ans)

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

s=input()

s=s+str(X)

counter=1

lists=[]

for i in range(n):

  if s[i]==s[i+1]:

    counter+=1

  else:

    lists.append(counter)

    counter=1

ans=1
13
for i in lists:

  ans=ans*i%(10**9+7)

print(ans)
Problem p03096 (python)

Fixed submission:
#reversi
n=int(input())
lists=[]
for i in range(n):
    a=int(input())
    lists.append(a)
dp=[0 for i in range(n+1)]
dp[0]=1
mod=10**9+7
before=[0 for i in range(2*10**5+1)]

for i in range(n):
    a=lists[i]
    if before[a]==0:
        dp[i+1]=dp[i]
        before[a]=i+1
        continue
        
    elif before[a]!=0:
        if before[a]==i:
            before[a]=i+1
            dp[i+1]=dp[i]
        else:
            dp[i+1]=(dp[i]+dp[before[a]])%mod

            before[a]=i+1
print(dp[n]%mod)

Buggy submission (verdict: Runtime Error):
#reversi
n=int(input())
lists=[]
for i in range(n):
    a=int(input())
    lists.append(a)
dp=[0 for i in range(n+1)]
dp[0]=1

before=[0 for i in range(n+1)]

for i in range(n):
    a=lists[i]
    if before[a]==0:
        dp[i+1]=dp[i]
        before[a]=i+1
    elif before[a]!=0:
        if before[a]==i:
            before[a]=i+1
            dp[i+1]=dp[i]
        else:
            dp[i+1]=dp[i]+dp[before[a]]
            before[a]=i+1
print(dp[n])
Problem p03141 (python)

Fixed submission:
n=int(input())
lists=[]
lists1=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append((a+b,a,b))
listed=sorted(lists,key=lambda x:x[0],reverse=True)

ans=0
for n in range(n):
    if n%2==0:
        ans+=listed[n][1]
    
    elif n%2!=0:
        ans-=listed[n][2]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=[]
lists1=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append((a+b,a,b))
listed=sorted(lists,key=lambda x:x[0],reverse=True)

ans=0
for n in range(n):
if n%2==0:
    ans+=listed[n][1]
    
elif n%2!=0:
    ans-=listed[n][2]
print(ans)
Problem p03157 (python)

Fixed submission:
h,w=map(int,input().split())
lists=[list(input()) for i in range(h)]
visited=[[False for i in range(w)] for j in range(h)]
from collections import deque

ans=0
dif=[(-1,0),(1,0),(0,-1),(0,1)]

def solve(i,j):
    global ans 
    ans=ans
    black=0
    white=0
    if visited[i][j]==False:
        if lists[i][j]=="#":
            black+=1
        else:
            white+=1
        visited[i][j]=True
        
    d=deque()
    e=deque()
    d.append((i,j))
    while d:
        while d:
            p=d.popleft()
            x,y=p
            color=lists[x][y]
            for que in dif:
                dx,dy=que
                if 0<=dx+x<h and 0<=dy+y<w:
                    if visited[dx+x][dy+y]==False and lists[dx+x][dy+y]!=color:
                        visited[dx+x][dy+y]=True
                        e.append((dx+x,dy+y))
                        if color=="#":
                            white+=1
                        else:
                            black+=1
        if e:
            d=e
            e=deque()
    ans+=(white)*(black)
flag=True
while flag:
    sub=False
    for i in range(h):
        for j in range(w):
            if visited[i][j]==False:
                solve(i,j)
                sub=True
    if sub==False:
        flag=False
print(ans)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
lists=[list(input()) for i in range(h)]
visited=[[False for i in range(h)] for j in range(w)]
from collections import deque

ans=0
dif=[(-1,0),(1,0),(0,-1),(0,1)]
def solve(i,j):
    global ans 
    ans=ans
    visited[i][j]=True
    d=deque()
    e=deque()
    d.append((i,j))
    black=0
    white=0
    while d:
        while d:
            p=d.popleft()
            x,y=p
            color=lists[x][y]
            if color=="#":
                black+=1
            else:
                white+=1
            for que in dif:
                dx,dy=que
                if 0<=dx+x<h and 0<=dy+y<w:
                    if visited[dx+x][dy+y]==False and visited[dx+x][dy+y]!=color:
                        visited[dx+x][dy+y]=True
                        e.append((dx+x,dy+y))
                        if color=="#":
                            white+=1
                        else:
                            black+=1
        if e:
            d=e
            e=deque()
    ans+=white*black
flag=True
while flag:
    sub=False
    for i in range(h):
        for j in range(w):
            if visited[i][j]==False:
                solve(i,j)
                sub=True
    if sub==False:
        flag=False
print(ans)
Problem p03197 (python)

Fixed submission:
n=int(input())
lists=[]
for i in range(n):
    s=int(input())
    lists.append(s)
if all(lists[i]%2==0 for i in range(n)):
    print("second")
else:
    
    print("first")

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=[]
for i in range(n):
	s=int(input())
  	lists.append(s)
if all(lists[i]%2==0 for i in range(n)):
  print("second")
else:
  print("first")
Problem p03215 (python)

Fixed submission:
n,k=map(int,input().split())
lists=list(map(int,input().split()))
GG=[]
sumlist=[0]
a=0
for i in range(len(lists)):
    a+=lists[i]
    sumlist.append(a) 
for i in range(len(sumlist)):
    for j in range(i+1,len(sumlist)):
        
        G=sumlist[j]-sumlist[i]
        GG.append(G)
        
GG=sorted(GG,reverse=True)      
maxi=format(GG[0],"b")
from collections import deque
d=deque()
e=deque()
for j in range(len(GG)):
    d.append(format(GG[j],"b").zfill(len(maxi)))
answer=0
index=0
 
while index!=len(maxi):
    counter=0
    for some in d:
        if some[index]=="1":
            counter+=1
            e.append(some)
    if counter>=k:
        answer+=2**(len(maxi)-1-index)
        d=e
        e=deque()
    elif counter<k:
        d=d
        e=deque()
        
    index+=1
    counter=0
print(answer)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
lists=list(map(int,input().split()))
GG=[]
for i in range(len(lists)+1):
    for j in range(i,len(lists)):
        
        G=sum(lists[i:j+1])
        GG.append(G)
        
GG=sorted(GG,reverse=True)      
maxi=format(GH[0],"b")
from collections import deque
d=deque()
e=deque()
for j in range(len(GG)):
    d.append(format(GG[j],"b").zfill(len(maxi)))
answer=0
index=0

while index!=len(maxi):
    counter=0
    for some in d:
        if some[index]=="1":
            counter+=1
            e.append(some)
    if counter>=k:
        answer+=2**(len(maxi)-1-index)
        d=e
        e=deque()
    elif counter<k:
        d=d
        e=deque()
        
    index+=1
    counter=0


print(answer)
Problem p03266 (python)

Fixed submission:
import math

n,k=map(int,input().split())
if k%2!=0:
    nums=math.floor(n/k)
    print(nums**3)
 
else:
    nums1=math.floor(2*n/k)

    if nums1%2==0:
        a=int(nums1/2)
        b=nums1-a
        print(a**3+b**3)
    
    
    if nums1%2!=0:
        a=int((nums1+1)/2)
        b=nums1-a
        print(a**3+b**3)

Buggy submission (verdict: Runtime Error):
import math

n,k=map(int,input().split())
if k%2!=0:
  nums=math.ceil(n/k)
  print(nums*3)
 
else:
  nums1=math.ceil(2*n/k)
  if nums1%2==0:
    a=int(nums1/2)
    b=nums1-a
    print(a**3+b**3)
    
    
  elif nums1%2!=0:
    a=int((num-1)/2)
    b=nums1-a
    print(a**3+b**3)
Problem p03282 (python)

Fixed submission:
s=input()
lists=[int(integer)for integer in s] 
nums=int(input())

numbers=0 
strong=0 
#sに位置が初め何個ついているのかをnumbers変数に代入する
#もしｓが1で始まらなかった場合、その初めの文字を出力して終了する
for j in lists:
    if lists[0]!=1:
        break
    else:
        if j==1:
            numbers+=1
        else:
            break
#startで場合分け            
if lists[0]==1:
    if numbers>=nums:
        print(1)
        
    elif numbers<nums:
        print(lists[numbers])
else:
    print(lists[0])

Buggy submission (verdict: Runtime Error):

a = [int(c) for c in s]
k=int(input())
strong=0
for some in range(k):
  if a[some]==1:
    strong+=1
  if strong==k-1:
    print(some)
  if a[some]!=1:
    print(some)
    break
Problem p03309 (python)

Fixed submission:
n=int(input())
lists=list(map(int,input().split()))
uselists=[]
for _ in range(n):
    uselists.append(lists[_]-_-1)
uselist=sorted(uselists)
if n%2==0:
    num1=int(n/2-1)
    num2=int(n/2)
    numbers=min(uselist[num1],uselist[num2])
    
if n%2!=0:
    num1=int((n-1)/2)
    numbers=uselist[num1] 
ans=0
for x in range(n):
    ans+=abs(uselist[x]-numbers)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input().split())
lists=list(map(int,input().split())
for i in range(n):
    lists[i]-=(i+1)
mini=10**100
for k in range(-10**9,10**9,1):
    sub=0
    for i in range(n):
        sub+=abs(list[i]-k)
    mini=min(mini,sub)
           
print(mini)

Buggy submission (verdict: Runtime Error):
import bisect
n=int(input())
lists=list(map(int,input().split()))
uselists=[]
for _ in range(n):
    uselists.append(lists[_]-_-1)
uselist=sorted(uselists)
if n%2==0:
    num1=int(n/2-1)
    num2=int(n/2)
    numbers=min(uselist[num1],uselist[num2])
if n%2!=0:
    num1=int((n-1)/2)
    numbers=uselist[num1]  
for x in range(n):
    ans+=abs(uselist[x]-numbers)
print(ans)
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split())
data=[[0 for i in range(w+2)] for j in range(h+2)]
for j in range(h):
    s=input()
    for i in range(w):
        if s[i]=="#":
            data[j+1][i+1]=1
flag=True
for i in range(1,h+2):
    for j in range(1,w+2):
        if data[i][j]==1 and data[i-1][j]==data[i+1][j]==data[i][j-1]==data[i][j+1]==0:
            flag=False
            break
if flag:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
data=[[0 for i in range(w+2)] for j in range(h+2)]
for j in range(h):
    s=input()
    for i in range(w):
        if s[i]=="#":
            data[j+1][i+1]=1
flag=True
for i in range(1,h+2):
    for j in range(1,w+2):
        c=0
        for a in range(i-1,i+2):
            for b in range(j-1,j+2):
                c+=data[a][b]
        if c==1:
            flag=False
            break
if flag:
    print("Yes")
else:
    print("No")
Problem p03394 (python)

Fixed submission:
a=0
b=0
lists=[]
n=int(input())
lists2=[2*j for j in range(1,15001)]
lists3 =[3+6*k for k in range(0,5000)]
for q in range(1,2501):
    if (n-2*q)%3==0 and 1<=(n-2*q)<=15000:
        a=(n-2*q)
        b=q
if n>=7and n!=19999:
    lists=lists2[:a]+lists3[:2*b]
    print(*lists)
elif n==3:
    lists=[2,5,63]
    print(*lists)
elif n==4:
    lists=[2 ,5 ,20, 63]
    print(*lists)  
elif n==5:
    lists=[2,4,6,3,9]
    print(*lists)
elif n==6:
    lists=[2,5,20,63,70,140]
    print(*lists)
elif n==19999:
    lists=lists2[:14985]
    addlist2=[]
    count=0
    for i in lists3:
        if i%5!=0:
            addlist2.append(i)
            count+=1
        if count==3040:
            break
    addlist3=[]
    counter=0
    for i in range(5,30001,5):
        if i%2!=0 and i%3!=0:
            addlist3.append(i)
            counter+=1
        if counter==1974:
            break
    lists=lists+addlist2+addlist3
    print(*lists)

Buggy submission (verdict: Runtime Error):
a=0
b=0
lists=[]
n=int(input())
if n>=7and n!=19999:
    lists2=[2*j for j in range(1,15001)]
    lists3 =[3+6*k for k in range(0,5000)]
    for q in range(1,2501):
        if (n-2*q)%3==0 and 1<=(n-2*q)<=15000:
            a=(n-2*q)
            b=q
            print(a,2*b)
    lists=lists2[:a]+lists3[:2*b]
    print(*lists)
elif n==3:
    lists=[2,5,63]
    print(*lists)
elif n==4:
    lists=[2 ,5 ,20, 63]
    print(*lists)  
elif n==5:
    lists=[2,4,6,3,9]
    print(*lists)
elif n==6:
    lists=[2,5,20,63,70,140]
    print(*lists)
elif n==19999:
    lists=lists2[:14999]+lists3[:4988]
    lists.append(229)
    print(*lists)

Buggy submission (verdict: Runtime Error):
a=0
b=0
lists=[]
n=int(input())
if n>=7 and n!=19999:
    lists2=[2*j for j in range(1,15001)]
    lists3 =[3+6*k for k in range(0,5000)]
    for q in range(1,2501):
        if (n-2*q)%3==0 and 1<=(n-2*q)<=15000:
            a=(n-2*q)
            b=q
    lists=lists2[:a]+lists3[:2*b]
    print(*lists)
elif n==3:
    lists=[2,5,63]
    print(*lists)
elif n==4:
    lists=[2 ,5 ,20, 63]
    print(*lists)  
elif n==5:
    lists=[2,4,6,3,9]
    print(*lists)
elif n==6:
    lists=[2,5,20,63,70,140]
    print(*lists)
elif n==19999:
    lists2=[2*j for j in range(1,15001)]
    lists3 =[3+6*k for k in range(0,5000)]
    lists=lists2[:14999]+lists3[:4999]
lists.append(229)
    print(*lists)

Buggy submission (verdict: Runtime Error):
n=int(input())
lists2=[2*j for j in range(1,15001)]
lists3 =[3+6*k for k in range(0,5000)]
for q in range(1,5001):
    if (n-2*q)%3==0 and 1<=n-2*q<=15000:
        p=(n-2*q)
        break
lists=lists2[:p]+lists3[:2*q]
print(*lists)
Problem p03411 (python)

Fixed submission:
#2d plane 2n points
n=int(input())
cnt=0
red=[]
blue=[]
for _ in range(n):
    x,y=map(int,input().split())
    red.append((x,y))
for _ in range(n):
    x,y=map(int,input().split())
    blue.append((x,y))
red=sorted(red,key=lambda x:x[0])
blue=sorted(blue,key=lambda x:x[0])
blue=blue[::-1]
for i in range(n-1,-1,-1):
    x,y=red[i][0],red[i][1]
    d=[]
    for some in blue:
        X,Y=some[0],some[1]
        if X>x:
            d.append((X,Y))
    if d:
        d=sorted(d,key=lambda x:x[1])
        node=0
        for some in d:
            if some[1]>y:
                node=some
                cnt+=1
                break
        if node!=0:
            blue.remove(node)
print(cnt)

Buggy submission (verdict: Runtime Error):
#2d plane 2n points
n=int(input())
cnt=0
red=[]
blue=[]
for _ in range(n):
    x,y=map(int,input().split())
    red.append((x,y))
for _ in range(n):
    x,y=map(int,input().split())
    blue.append((x,y))
red=sorted(red,key=lambda x:x[0])
blue=sorted(blue,key=lambda x:x[0])
blue=blue[::-1]
for i in range(n-1,-1,-1):
    x,y=red[i][0],red[i][1]
    d=[]
    for some in blue:
        X,Y=some[0],some[1]
        if X>x:
            d.append((X,Y))
    if d:
        d=sorted(d,key=lambda x:x[1])
        node=-1
        for some in d:
            if some[1]>y:
                node=some
                cnt+=1
                break
        blue.remove(node)
print(cnt)
Problem p03449 (python)

Fixed submission:
n=int(input())
lists1=list(map(int,input().split()))
lists2=list(map(int,input().split()))
diff=[0]
if n>=2:
    for i in range(n-1):
        diff.append(lists1[i+1]-lists2[i])
    cnt=0
    findlist=[]
    for i in range(n):
        cnt=cnt+diff[i]
        findlist.append((cnt,i))
    anslist=sorted(findlist,key=lambda x: x[0])
    base=lists1[0]+sum(lists2)
    print(base+anslist[-1][0])
elif n==1:
    print(lists1[0]+lists2[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
lists1=list(map(int,input().split()))
lists2=list(map(int,input().split()))
diff=[]
if n>=2:
    for i in range(n-1):
        diff.append(lists1[i+1]-lists2[i])
    cnt=0
    findlist=[]
    for i in range(n-1):
        cnt=cnt+diff[i]
        findlist.append((cnt,i))
    anslist=sorted(findlist,key=lambda x: x[0])
    base=lists1[0]+sum(lists2)
    print(base2+anslist[-1][0])
elif n==1:
    print(lists1[0]+lists2[0])
Problem p03471 (python)

Fixed submission:
#お年玉
n,y=map(int,input().split())
a,b,c=0,0,0
flag=False
for i in range(2001):
    for j in range(2001):
        if i+j<=n and 10000*i+5000*j+1000*(n-i-j)==y:
            a=i
            b=j
            c=n-i-j
            flag=True
            break
if flag:
  print(a,b,c)
if not flag:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
#お年玉
n,y=map(int,input().split())
a,b,c=0,0,0
for i in range(2001):
    for j in range(2001):
        if i+j<=n and 10000*i+5000*j+1000*(n-i-j)==y:
            a=i
            b=j
            c=n-i-j
            flag=True
            break
if flag:
  print(a,b,c)
if not flag:
    print(-1,-1,-1)
Problem p03475 (python)

Fixed submission:
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]  
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    elif nums!=n:
        times=0
        while nums<n:
            if times>lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[nums-1][1])%lists[nums-1][2]  
                    times=times+lists[nums-1][2]-a
                    times+=lists[nums-1][0]
                    nums+=1  
                else:
                    times+=lists[nums-1][0]
                    nums+=1
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]
lists.append(s)   
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    
    else:
        times=0
        while nums<n:
            if times>=lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[num-1][1])%lists[nums-1][2]
                    
                times+=lists[nums-1][0]
                nums+=1      
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)
Problem p03476 (python)

Fixed submission:
q=int(input())
n =10**3
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
lists=[]
for i in prime:
    lists.append(i)  
lists=sorted(lists) 

checklist=[0]*(10**5+1)
checklist[0]=0
checklist[1]=0
count=0
for i in range(2,10**5+1):
    if i%2==0:
        checklist[i]=checklist[i-1]
    elif i%2!=0:
        if (all(i%j!=0 for j in lists) or i in lists) and (all(((i+1)//2)%j!=0 for j in lists) or (i+1)//2 in lists) :
            count+=1
            checklist[i]=checklist[i-1]+1
        else:
            checklist[i]=checklist[i-1]

listss=[0]*q
for i in range(q):
    a,b=map(int,input().split())
    c=checklist[b]-checklist[a-1]
    listss[i]=c
for i in listss:
    print(i)

Buggy submission (verdict: Runtime Error):
q=int(input())
n =10**3
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
lists=[]
for i in prime:
    lists.append(i)  
lists=sorted(lists) 

checklist=[0]*(10**5+1)
checklist[0]=0
checklist[1]=0
for i in range(2,10**5+1):
    if i%2==0:
        checklist[i]=checklist[i-1]
    elif i%2!=0:
        if (all(i%j!=0 for j in lists) or i in lists) and (all(((i+1)//2)%j!=0 for j in lists) or (i+1)//2 in lists) :
            count+=1
            checklist[i]=checklist[i-1]+1
        else:
            checklist[i]=checklist[i-1]

listss=[0]*q
for i in range(q):
    a,b=map(int,input().split())
    c=checklist[b]-checklist[a-1]
    listss[i]=c
for i in listss:
    print(i)