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

Fixed submission:
import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())
A=nl()
A.sort()
A_MAX=10**6+5
p_l=[0]*(A_MAX)
c=0
if(len(A)==1):
    print(1)
    sys.exit(0)

for i in range(len(A)):
    if(p_l[A[i]]!=0):
        continue
    for k in range(A[i],A_MAX,A[i]):
        if(p_l[k]):
            continue
        p_l[k]=1
    if(i<(len(A)-1) and A[i]==A[i+1]):
        continue
    c+=1
    

print(c)

Buggy submission (verdict: Runtime Error):
import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())
A=nl()
A.sort()
A_MAX=10**6+5
p_l=[0]*(A_MAX)
c=0

for i in range(len(A)):
    if(i==0):
        if(A[i]==A[i+1]):
            continue
    elif(i==(len(A)-1)):
        if(A[i]==A[i-1]):
            continue
    else:
        if(A[i]==A[i-1] or A[i]==A[i+1]):
            continue 
    if(p_l[A[i]]==0):
        c+=1
        for k in range(A[i]*2,A_MAX,A[i]):
            if(p_l[k]):
                continue
            p_l[k]=1

print(c)
Problem p02646 (python)

Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


A,V=nm()
B,W=nm()
T=int(input())

d=abs(A-B)
move_s=(V-W)
if(move_s<=0):
    print("NO")
    sys.exit(0)
if(((d//move_s))<=(T-1) or ((d//move_s)==T and (d%move_s==0)) ):
    print("YES")
    sys.exit(0)
print("NO")

Buggy submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


A,V=nm()
B,W=nm()
T=int(input())

d=abs(A-B)
move_s=(V-W)
if(move_s<=0):
    print("NO")
    sys.exit(0)
if(T<=((d//move_s)+1)):
    print("NO")
    sys.exit(0)
print("YES")



T1=d//move_b
T2=(d%move_b)//move_b
if((d%move_b)%move_b!=0):
    print('No')
    sys.exit(0)
if(T2+T1<=T):
    print('yes')
    sys.exit(0)
else:
    print('No')
    sys.exit(0)
Problem p02647 (python)

Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()

imos_l=[0]*(N+1)

for i in range(K):    
    imos_l=[0]*(N+1)
    for j in range(len(A)): 
        imos_l[max(j-A[j],0)]+=1
        imos_l[min(j+A[j]+1,N)]-=1
    for j in range(len(imos_l)-1):
        imos_l[j+1]=imos_l[j]+imos_l[j+1]
    for j in range(len(A)):
        A[j]=imos_l[j]
    flag=True
    for j in range(len(A)):
        if(A[j]<N):
            flag=False
    if(flag):
        print(*A)
        sys.exit(0)

print(*A)

Buggy submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
import numpy as np
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K=nm()
A=nl()

imos_l=[0]*(N+1)

for i in range(K):    
    imos_l=[0]*(N+1)
    for j in range(len(A)): 
        imos_l[max(j-A[j],0)]+=1
        imos_l[min(j+A[j]+1,N)]-=1
    for j in range(len(imos_l)-1):
        imos_l[j+1]=imos_l[j]+imos_l[j+1]
    for j in range(len(A)):
        A[j]=imos_l[j]
    flag=True
    for j in range(len(A)):
        if(A[j]<N):
            flag=False
    if(flag):
        print(*A)
        sys.exit(0)

print(*A)
Problem p02675 (python)

Fixed submission:
import sys
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


N=int(input())
if(N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9):
    print('hon')

if(N%10==0 or N%10==1 or N%10==6 or N%10==8 ): 
    print('pon')

if(N%10==3): 
    print('bon')

Buggy submission (verdict: Runtime Error):
import sys
import  math
from heapq import *
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

mod=10**9+7
zero=0
counter0=defaultdict(int)
counter1=defaultdict(int)
N=int(input())
for i in range(N):
    x,y=nm()
    if(x==0 and y==0):
        zero+=1
        continue
    g=fractions.gcd(x,y)
    x/=g
    y/=g
    if(y<0):
        x=-x
        y=-y
    if(y==0 and x<0):
        x=-x
        y=-y
    rot90=False
    if(x<0):
        rot90=True
    if(rot90):
        tmp = x
        x=y
        y=-tmp
    if(rot90):
        counter0[(x,y)]+=1
    else:
        counter1[(x,y)]+=1
        counter0[(x,y)]+=0

ans=1
for key,cnt0 in counter0.items():
    cnt1=counter1[key]
    now=1
    now+=2**cnt0-1
    now+=2**cnt1-1
    now%=mod
    ans*=now
    ans%=mod
        
ans+=zero
ans-=1

print(ans%mod)
Problem p02678 (python)

Fixed submission:
import sys
import  math
from heapq import *
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

    
N,M=nm()
INF=10**18
def bfs(start,edge):
    d=[INF]*(N+1)
    ans=[0]*(N+1)
    d[start]=0
    q=[(0,start)]
    while(len(q)!=0):
        ci,i=heappop(q)
        for j in edge[i]:
            if(d[j]>d[i]+1):
                d[j]=d[i]+1
                heappush(q,(d[j],j))
                ans[j]=i

    return ans




edge=[[]for _ in range(N+1)]
for i in range(M):
    A,B=nm()
    edge[A].append(B)
    edge[B].append(A)

ans=bfs(1,edge)


for i in range(2,N+1):
    if(ans[i]==0):
        print('No')
        sys.exit(0)

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

Buggy submission (verdict: Runtime Error):
import sys
import  math
from heapq import *
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

    
N,M=nm()
INF=10**18
def bfs(start,edge):
    d=[INF]*(M+1)
    ans=[0]*(M+1)
    d[start]=0
    q=[(0,start)]
    while(len(q)!=0):
        ci,i=heappop(q)
        for j in edge[i]:
            if(d[j]>d[i]+1):
                d[j]=d[i]+1
                heappush(q,(d[j],j))
                ans[j]=i

    return ans




edge=[[]for _ in range(M+1)]
for i in range(M):
    A,B=nm()
    edge[A].append(B)
    edge[B].append(A)

ans=bfs(1,edge)

for i in range(2,M+1):
    if(ans[i]==0):
        print('No')
        sys.exit(0)

print('Yes')
for i in range(2,M+1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import sys
import  math
from heapq import *
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

    
N,M=nm()
INF=10**18
def bfs(start,edge):
    d=[INF]*(M+1)
    ans=[0]*(M+1)
    d[start]=0
    q=[(0,start)]
    while(len(q)!=0):
        ci,i=heappop(q)
        for j in edge[i]:
            if(d[j]>d[i]+1):
                d[j]=d[i]+1
                heappush(q,(d[j],j))
                ans[j]=i

    return ans




edge=[[]for _ in range(M+1)]
for i in range(M):
    A,B=nm()
    edge[A].append(B)
    edge[B].append(A)

ans=bfs(1,edge)

for i in range(2,M+1):
    if(ans[i]==0):
        print('No')
        sys.exit(0)

print('Yes')
for i in range(2,M+1):
    print(ans[i])
Problem p02681 (python)

Fixed submission:
import sys
stdin=sys.stdin

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

S=list(ns())
T=list(ns())
T2=T[0:len(T)-1]
print('Yes' if S==T2 else 'No')

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

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

N,K=nm()
A=nl()

D=60
MAX_N=20005
to=[[0]*MAX_N for i in range(D)]

to[0][1:N+1]=A

for i in range(D-1):
    for j in range(1,N+1):
        to[i+1][j]=to[i][to[i][j]]

v=1
for i in range(D-1,-1,-1):
    l = 1<<i
    if(l<=K):
        v=to[i][v]
        K-=l

print(v)

Buggy submission (verdict: Runtime Error):
    import sys
    stdin=sys.stdin
     
    ns = lambda:stdin.readline().rstrip()
    ni = lambda:int(stdin.readline().rstrip())
    nm = lambda:map(int,stdin.readline().split())
    nl = lambda:list(map(int,stdin.readline().split()))
     
    N,K=nm()
    A=nl()
     
    city_l=[]
    city_l.append(1)
    city_c=[0]*(N+1)
    city_c[1]+=1
    n_city=A[0]
    flag=True
    r_start=-1
    r_end=-1
    while(flag):
        city_c[n_city]+=1
        city_l.append(n_city)
        if(city_c[n_city]>1):
            r_start=city_l.index(n_city)+1
            r_end=len(city_l)-1
            flag=False
        n_city=A[n_city-1]
     
    if(K<r_end):
        print(city_l[K-1])
     
     
    else:
        K2=K-r_end
        K2=K2%(r_end-r_start+1)
        if(K2==0):
           print(A[city_l[r_end-1]-1])
        else:
           print(A[city_l[r_start+K2-2]-1])
Problem p02789 (python)

Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,M=nm()
print('Yes' if N==M else 'No')

Buggy submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
from functools import reduce
stdin = sys.stdin
         
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
     
INF=10**18
mod=10**9+7
N=int(input())
A=nl()
ans=0
min_bai=1
for i in range(N):#最大公倍数
    min_bai=min_bai*A[i]//fractions.gcd(min_bai,A[i])

#lcm = reduce(lambda x,y: x//fractions.gcd(x,y)*y, A)
 
for i in range(N):
    ans+=lcm//A[i]

#ans = sum(lcm//x for x in A)
print(ans%mod)

Buggy submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
from functools import reduce
stdin = sys.stdin
         
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
     
INF=10**18
mod=10**9+7
N=int(input())
A=nl()
ans=0
min_bai=1
#for i in range(N):#最大公倍数
#    min_bai=min_bai*A[i]//fractions.gcd(min_bai,A[i])

lcm = reduce(lambda x,y: x//fractions.gcd(x,y)*y, A)
 
#for i in range(N):
#    ans+=lcm//A[i]

ans = sum(lcm//x for x in A)
print(ans%mod)
Problem p02801 (python)

Fixed submission:
import sys
stdin=sys.stdin

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

S=input()
A=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if(S=='z'):
    print('a')
else:
    inds=A.index(S)
    print(A[inds+1])

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

ns = lambda:stdin.readline().rstrip()
ni = lambda:int(stdin.readline().rstrip())
nm = lambda:map(int,stdin.readline().split())
nl = lambda:list(map(int,stdin.readline().split()))

S=input()
A=['a','b','c','b','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if(S=='z'):
    print('a')
else:
    inds=A.index(S)
    print(A[inds+1])
Problem p02811 (python)

Fixed submission:
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

K,X=nm()
print('Yes' if X<=500*K else 'No')

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

ns=lambda:stdin.readline().rstrip()
ni=lambda:int(stdin.readline().rstrip())
nm=lambda:map(int,stdin.readline().rstrip())
nl=lambda:list(map(int,stdin,readline().rstrip()))

K,X=nm()
print('Yes' if X<=500*K else 'No')
Problem p02817 (python)

Fixed submission:
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S=ns().split()
print(S[1]+S[0])

Buggy submission (verdict: Runtime Error):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))



X=int(input())

prime_l=[0]*(2*X)
for  i in range(2,X):
    if(prime_l[i]==0):
        for j in range(1,(2*X)//i):
            prime_l[i*j]+=1
        
while(1):
    X+=1
    if(prime_l[X]==0):
        print(X)
        sys.exit(0)
Problem p02910 (python)

Fixed submission:
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S=list(ns())
S_o=''.join(S[0::2])
S_e=''.join(S[1::2])
print('Yes' if ((not ('L' in S_o)) and (not ('R' in S_e))) else 'No')

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

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K,Q=nm()
Al=[0]*N
for i in range(Q):
    Al[i]=ni()



for i in range(N):
    #print(Al.count(i+1))
    print('No' if (K-Q+Al.count(i+1)<1) else 'Yes')
Problem p02911 (python)

Fixed submission:
import sys
import collections
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K,Q=nm()
Al=[0]*Q
ans_l=[K-Q]*N
for i in range(Q):
    #Al[i]=int(input())
    ans_l[int(input())-1]+=1
    


for i in range(N):
    #print(Al.count(i+1))
    #print('No' if (K-Q+Al.count(i+1)<1) else 'Yes')
    print('No' if (ans_l[i]<1) else 'Yes')

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

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K,Q=nm()
Al=[0]*N
for i in range(Q):
    Al[i]=ni()



for i in range(N):
    print('No' if (K-Q+Al.count(i+1)<1) else 'Yes')
Problem p02936 (python)

Fixed submission:
import sys
from collections import deque
stdin=sys.stdin

ns=lambda:input().rstrip()
ni=lambda:int(input().rstrip())
nm=lambda:map(int,input().split())
nl=lambda:list(map(int,input().split()))

N,Q=nm()
AB=[nl() for i in range(N-1)]
PQ=[nl() for i in range(Q)]
root=[[] for i in range(N)]
N_val=[0]*N
ans_val=[0]*N
d=[0]*N

def bfs():
  que=deque([])
  que.append(0)
  while que:
    p=que.popleft()
    for i in root[p]:
       if(d[i]==0):
         ans_val[i]=ans_val[p]+N_val[i]
         que.append(i)
         d[i]=1
      
def dfs(x,d,s):
  for i in root[x]:
    if(d[i]==0):
      s+=N_val[i]
      ans_val[i]=s
      d[i]=1
      dfs(i,d,s)
      s-=N_val[i]
      

for i in range(N-1):
  root[AB[i][0]-1]+=[AB[i][1]-1]
  root[AB[i][1]-1]+=[AB[i][0]-1]
  
for i in range(Q):
  N_val[PQ[i][0]-1]+=PQ[i][1]

  
ans_val[0]=N_val[0]
d[0]=1
#dfs(0,d,N_val[0])
bfs()
print(*ans_val)

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]

n,q = LI()

v = [[] for i in range(n)]
for i in range(n-1):
  a,b = LI()
  a -= 1 
  b -= 1 
  v[a].append(b)
  v[b].append(a)

f = [0]*n
for i in range(q):
  p,x = LI()
  p -= 1 
  f[p] += x

def dfs(x,d,s): 
  for y in v[x]:
    if d[y]: 
      s += f[y]
      ans[y] = s 
      d[y] = 0 
      dfs(y,d,s) 
      s -= f[y] 

ans = [0]*n
d = [1]*n
d[0] = 0
ans[0] = f[0]
s = f[0]
dfs(0,d,s)
print(*ans)

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

ns=lambda:input().rstrip()
ni=lambda:int(input().rstrip())
nm=lambda:map(int,input().split())
nl=lambda:list(map(int,input().split()))

N,Q=nm()
AB=[nl() for i in range(N-1)]
PQ=[nl() for i in range(Q)]
root=[[] for i in range(N)]
N_val=[0]*N
ans_val=[0]*N
d=[0]*N

def dfs(x,d,s):
  for i in root[x]:
    if(d[i]==0):
      s+=N_val[i]
      ans_val[i]=s
      d[i]=1
      dfs(i,d,s)
      s-=N_val[i]
      

for i in range(N-1):
  root[AB[i][0]-1]+=[AB[i][1]-1]
  root[AB[i][1]-1]+=[AB[i][0]-1]
  
for i in range(Q):
  N_val[PQ[i][0]-1]+=PQ[i][1]

  
ans_val[0]=N_val[0]
d[0]=1
dfs(0,d,N_val[0])
print(*ans_val)
Problem p02937 (python)

Fixed submission:
import sys
import heapq
import bisect
from collections import deque
stdin=sys.stdin

ns=lambda:input().rstrip()
ni=lambda:int(input().rstrip())
nm=lambda:map(int,input().split())
nl=lambda:list(map(int,input().split()))

s=list(ns())
t=list(ns())
d={'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25}

order=[[] for _ in range(26)]

for i in range(len(s)):
  order[d[s[i]]].append(i)
  
now=0
ans=0
rep=0
for i in range(len(t)):
  inds=d[t[i]]
  if(order[inds]==[]):
    print(-1)
    sys.exit(0)
  index=bisect.bisect_left(order[inds],now)
  if(index==len(order[inds])):
    now=order[inds][0]+1
    rep+=1
  else:
    now=order[inds][index]+1


print(rep*len(s)+now)

Buggy submission (verdict: Runtime Error):
import heapq
import bisect
from collections import deque
stdin=sys.stdin

ns=lambda:input().rstrip()
ni=lambda:int(input().rstrip())
nm=lambda:map(int,input().split())
nl=lambda:list(map(int,input().split()))

s=list(ns())
t=list(ns())
d={'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25}

order=[[] for _ in range(26)]

for i in range(len(s)):
  order[d[s[i]]].append(i)
  
now=0
ans=0
rep=0
for i in range(len(t)):
  inds=d[t[i]]
  if(order[inds]==[]):
    print(-1)
    sys.exit(0)
  index=bisect.bisect_left(order[inds],now)
  if(index==len(order[inds])):
    now=order[inds][0]
    rep+=1
  else:
    now=order[inds][index]


print(rep*len(s)+now+1)

Buggy submission (verdict: Runtime Error):
import sys
import heapq
import bisect
from collections import deque
stdin=sys.stdin

ns=lambda:input().rstrip()
ni=lambda:int(input().rstrip())
nm=lambda:map(int,input().split())
nl=lambda:list(map(int,input().split()))

s=list(ns())
t=list(ns())
d={'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25}

order=[[] for _ in range(26)]

for i in range(len(s)):
  order[d[s[i]]].append(i)
  
now=0
ans=0
rep=0
for i in range(len(t)):
  inds=d[t[i]]
  if(order[inds]==0):
    print(-1)
    sys.exit(0)
  index=bisect.bisect_left(order[inds],now)
  if(index==len(order[inds])):
    now=order[inds][0]
    rep+=1
  else:
    now=order[inds][index]


print(rep*len(s)+now+1)
Problem p02957 (python)

Fixed submission:
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A,B=nm()

print((A+B)//2 if (A+B)%2==0 else 'IMPOSSIBLE')

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

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S=list(ns())
S.reverse()

modmap=[[0]*10 for i in range(10**5)]
for i in range(10):
    modmap[0][i]=i

for i in range(1,10**5):
    for j in range(10):
        modmap[i][j]=(modmap[i-1][j]*10)%13


q_list=[]
moda=0
for i in range(len(S)):
    if(S[i]=='?'):
        q_list.append(i)
    else:
        moda=(moda+modmap[i][int(S[i])])%13


modlist=[[0]*13 for i in range(len(q_list))]
mlist=[i for i in range(13)]

for i in range(10):
    modlist[0][modmap[q_list[0]][i]]=1

for i in range(1,len(q_list)):
    for j in range(10):
        tmpmod=modmap[q_list[i]][j]
        for k in range(13):
            modlist[i][(tmpmod+k)%13]+=(modlist[i-1][k]%(10**9+7))

print(modlist[len(q_list)-1][mlist[5-moda]]%(10**9+7))

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

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

S=list(ns())
S.reverse()

modmap=[[0]*10 for i in range(10**5)]
for i in range(10):
    modmap[0][i]=i

for i in range(1,10**5):
    for j in range(10):
        modmap[i][j]=(modmap[i-1][j]*10)%13


q_list=[]
moda=0
for i in range(len(S)):
    if(S[i]=='?'):
        q_list.append(i)
    else:
        moda=(moda+modmap[i][int(S[i])])%13


modlist=[[0]*13 for i in range(len(q_list))]
mlist=[i for i in range(13)]

for i in range(10):
    modlist[0][modmap[q_list[0]][i]]=1

for i in range(1,len(q_list)):
    for j in range(10):
        tmpmod=modmap[q_list[i]][j]
        for k in range(13):
            modlist[i][(tmpmod+k)%13]+=modlist[i-1][k]

print(modlist[len(q_list)-1][mlist[5-moda]]%(10**9+7))
Problem p03998 (python)

Fixed submission:
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

p=[0]*3
p[0]=list(ns())
p[1]=list(ns())
p[2]=list(ns())
turn='a'
d={'a':0,'b':1,'c':2}

hand=p[d[turn]]
ch=len(hand)
while(ch!=0):
  turn=p[d[turn]].pop(0)
  hand=p[d[turn]]
  ch=len(hand)


print(turn.upper())

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

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

p=[0]*3
p[0]=ns()
p[1]=ns()
p[2]=ns()
turn='A'
d={'A':0,'B':1,'C':2}

while(len[p[d[turn]]]==0):
	tmp=p[d[turn]][0]
	p[d[turn]][0]=[]	
	turn=tmp


print(d[turn])