Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
def yakusuu(n):
  num=0
  for i in range(1,n):
    if n%i==0:
      num=num+1
  return num==8
ans=0
for i in range(n):
  if def(i):
    ans=ans+1
print(ans)
  
      

Fixed submission:
n=int(input())
def yakusuu(n):
  num=0
  if n%2==1:
    for i in range(1,n+1):
      if n%i==0:
        num=num+1
  return num 

ans=0
for i in range(n+1):
  if yakusuu(i)==8:
    ans=ans+1
print(ans)

Buggy python submission (verdict: Runtime Error):
#import math
N=int(input())
def yakusuu(n):
  num=_0
  for i in range(1,n):
    if n%i==0:
      num=num+1
  return num==8
ans=0
for i in range(n):
  if def(i):
    ans=ans+1
print(ans)
  
      

Fixed submission:
n=int(input())
def yakusuu(n):
  num=0
  if n%2==1:
    for i in range(1,n+1):
      if n%i==0:
        num=num+1
  return num 

ans=0
for i in range(n+1):
  if yakusuu(i)==8:
    ans=ans+1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
n=int(input())
A=list(map(int,input().split()))
A=list(accumulate(A))
A=[0]+A
ans=[]
for i in range(n):
  for j in range(i+1,n+1):
    ans.append(A[i]-A[j])
print(ans.count(0))
  

Fixed submission:
from itertools import accumulate
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
A=list(accumulate(A))
A=[0]+A
B=Counter(A)
ans=0
for i in B:
  ans=int(ans+B[i]*(B[i]-1)/2)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from itertools import accumulate
def is_prime(n):
  if n==2:
    return True
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      return False
  return True
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=map(int,input().split())
min_l=min(l)
max_r=max(r)
a=[]
for i in range(min_l,max_r+1):
  if i%2==0:
    a.append(0)
  else:
    if is_prime(i) and is_prime((i+1)/2):
      a.append(1)
check=[0]+a
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]-min_l+1]-check[l[i]-min_l])
  

Fixed submission:
import math
from itertools import accumulate
def is_prime(n):
  if n==1:
    return False
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      return False
  return True
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=list(map(int,input().split()))
min_l=min(l)
max_r=max(r)
a=[]
for i in range(min_l,max_r+1):
  if i%2==0:
    a.append(0)
  else:
    if is_prime(i) and is_prime((i+1)/2):
      a.append(1)
    else:
      a.append(0)
check=[0]+a
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]-min_l+1]-check[l[i]-min_l])

Buggy python submission (verdict: Runtime Error):
import math
from itertools import accumulate
def is_prime(n):
  if n==2:
    return True
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      return False
  return True
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=map(int,input().split(""))
min_l=min(l)
max_r=max(r)
a=[]
for i in range(min_l,max_l+1):
  if i%2==0:
    a.append(0)
  else:
    if is_prime(n) and is_prime((i+1)/2):
      a.append(1)
check=[0]+check
check=list(accumulate(check))
for i in range(q):
  print(check(r[i+1])-check(l[i]))
  
    
  

Fixed submission:
import math
from itertools import accumulate
def is_prime(n):
  if n==1:
    return False
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      return False
  return True
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=list(map(int,input().split()))
min_l=min(l)
max_r=max(r)
a=[]
for i in range(min_l,max_r+1):
  if i%2==0:
    a.append(0)
  else:
    if is_prime(i) and is_prime((i+1)/2):
      a.append(1)
    else:
      a.append(0)
check=[0]+a
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]-min_l+1]-check[l[i]-min_l])
Buggy python submission (verdict: Runtime Error):
=list(input())
#sのi番目の次に＋かーを入れる。それまでの文字列char,合計sum
def dfs(i,char,sum):
  if i==3:
    if sum==7:
      print(char+"=7")
      exit()
  else:
    dfs(i+1,char+"+"+s[i+1],sum+int(s[i+1]))  
    dfs(i+1,char+"-"+s[i+1],sum-int(s[i+1]))
        
    
      
    
      
dfs(0,s[0],int(s[0]))

Fixed submission:
s=list(input())
#sのi番目の次に＋かーを入れる。それまでの文字列char,合計sum
def dfs(i,char,sum):
  if i==3:
    if sum==7:
      print(char+"=7")
      exit()
  else:
    dfs(i+1,char+"+"+s[i+1],sum+int(s[i+1]))  
    dfs(i+1,char+"-"+s[i+1],sum-int(s[i+1]))
        
    
      
    
      
dfs(0,s[0],int(s[0]))

Buggy python submission (verdict: Runtime Error):
s=list(int(input()))
#sのi番目までの合計をsumとする
def dfs(i,sum):
  if i==4:
    return sum==7
  if dfs(i+1,sum+s[i]):
    return True
  if dfs(i+1,sum-s[i]):
    return True
  else:
    return False
if dfs(0,s[0]):
  print("Yes")
else:
  print("No")

    

Fixed submission:
s=list(input())
#sのi番目の次に＋かーを入れる。それまでの文字列char,合計sum
def dfs(i,char,sum):
  if i==3:
    if sum==7:
      print(char+"=7")
      exit()
  else:
    dfs(i+1,char+"+"+s[i+1],sum+int(s[i+1]))  
    dfs(i+1,char+"-"+s[i+1],sum-int(s[i+1]))
        
    
      
    
      
dfs(0,s[0],int(s[0]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()

import bisect
ans=0
for i in b:
    a=bisect.bisect_left(i)
    b=bisect.bisect_right(i)
    ans=ans+a*(n-b)
print(ans)
    

Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect.bisect_left(A, b) # 挿入点はどの同じ値よりも左
    c = bisect.bisect_right(C, b) # 挿入点はどの同じ値よりも右
    ans += a * (len(C)-c)
print (ans)

Buggy python submission (verdict: Runtime Error):
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort
b.sort
c.sort
ans=0
for i in b:
  A=bisect.bisect_left(a,b[i])
  B=bisect.bisect_right(c,b[i])
  ans=ans+A*(n-B)
print(ans)
          
  
  

  


Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect.bisect_left(A, b) # 挿入点はどの同じ値よりも左
    c = bisect.bisect_right(C, b) # 挿入点はどの同じ値よりも右
    ans += a * (len(C)-c)
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,R=map(int,input().split())
r=list(map(int,input().split()))

d=[[float("INF")]*n for i in range(n)]
for i in range(n):
  d[i][i]=0

for i in range(m):
  a,b,c=map(int,input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c
  
#ワーシャルフロイド法
#d[i][j]:iからjへの最短経路
for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])

      
from itertools import permutations
per=list(permutations(r,R))

ans=float("INF")
for l in per:
  cnt=0
  for j in range(R-1):
    cnt+=d[l[j]-1][l[j+1]-1]
  ans=min(cnt,ans)
print(ans)

      
      
  


Fixed submission:
n,m,R=list(map(int,input().split()))
r=list(map(int,input().split()))
dp=[[float("INF")]*n for i in range(n)]
for i in range(m):
  a,b,c=list(map(int,input().split()))
  dp[a-1][b-1]=c
  dp[b-1][a-1]=c
for i in range(n):
  dp[i][i]=0
for k in range(n):
  for i in range(n):
    for j in range(n):
      dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
from itertools import permutations
per=list(permutations(r,R))
ans=float("INF")
for tup in per:
  ans_kouho=0
  for i in range(R-1):
    ans_kouho=ans_kouho+dp[tup[i]-1][tup[i+1]-1]
  ans=min(ans,ans_kouho)
print(ans)
Buggy python submission (verdict: Runtime Error):
#ベルマンフォード法
#正の閉路がない時は普通のベルマンフォード法
n,m=list(map(int,input().split()))
es=[]
for i in range(m):
  a,b,c=list(map(int,input().split()))
  es.append((a-1,b-1,c))
import sys
def Bellmanford(n,m,s,es):
  d=[-float("INF")]*n
  d[s]=0
  cnt=0
  while(1):
    update=False
    for p,q,r in es:
      if d[p]!=-float("INF") and d[q]<d[p]+r:
        d[q]=d[p]+r
        update=True
    cnt+=1
    if not update:
      break
    if cnt==n-1:
      memo=d[n-1]
    if cnt==n:
      #正のループがある
      if d[n-1]>memo:
        print(float("INF"))
        sys.exit()
      else:
        print(d[n])
  print(d[n-1])
  
Bellmanford(n,m,0,es)  
    
    
      
  
  

  

Fixed submission:
#ベルマンフォード法
#正の閉路がない時は普通のベルマンフォード法
n,m=list(map(int,input().split()))
es=[]
for i in range(m):
  a,b,c=list(map(int,input().split()))
  es.append((a-1,b-1,c))
import sys
def Bellmanford(n,m,s,es):
  d=[-float("INF")]*n
  d[s]=0
  cnt=0
  while(1):
    update=False
    for p,q,r in es:
      if d[p]!=-float("INF") and d[q]<d[p]+r:
        d[q]=d[p]+r
        update=True
    cnt+=1
    if not update:
      break
    if cnt==n-1:
      memo=d[n-1]
    if cnt==n:
      #正のループがある
      if d[n-1]>memo:
        print(float("INF"))
        sys.exit()
      else:
        print(d[n-1])
        sys.exit()
  print(d[n-1])
  
Bellmanford(n,m,0,es)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
res = 0
for i in range(len(a)):
	if a[i] == i:
		res = i + 1
        break
print(res)


Fixed submission:
a = list(map(int, input().split()))
res = 0
for i in range(len(a)):
    if a[i] == 0:
        res = i + 1
        break
print(res)

Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
res = 0
for i in range(len(a)):
  	if a[i] == i:
      	res = i + 1
print(res)

Fixed submission:
a = list(map(int, input().split()))
res = 0
for i in range(len(a)):
    if a[i] == 0:
        res = i + 1
        break
print(res)
Buggy python submission (verdict: Runtime Error):
a = int(input())

count = 0
for i in range(len(a)):
  if a[i] == 1:
    count += 1

print(count)

Fixed submission:
s = list(input())
print(s.count("1"))
Buggy python submission (verdict: Runtime Error):
import numpy　as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Buggy python submission (verdict: Runtime Error):
import numpy　as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Buggy python submission (verdict: Runtime Error):
import numpy　as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 1):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Buggy python submission (verdict: Runtime Error):
import numpy　as np
N = int(input())
a = int(list(input()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 1):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Buggy python submission (verdict: Runtime Error):
import numpy　as np
N = int(input())
a = int(list(input())

count = [0] * N
for i in range(N):
  while(a[i] % 2== 1):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Buggy python submission (verdict: Runtime Error):
import numpy　as np
N = int(input())
a = map(int, input().split())

count = [0] * N
for i in range(N):
  while(a[i] % 2== 1):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Buggy python submission (verdict: Runtime Error):
import numpy　as np
N = int(input())
a = map(int, input().split())

count = [0] * N
for i in range(N):
  while(a[i] % == 1):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))

Fixed submission:
import numpy as np
N = int(input())
a = list(map(int, input().split()))

count = [0] * N
for i in range(N):
  while(a[i] % 2== 0):
    a[i] = a[i] // 2
    count[i] += 1
print(np.min(count))
Buggy python submission (verdict: Runtime Error):
s = input()
s = s[0] + len(s[1:-1]) + s[-1]
print(s)

Fixed submission:
s = input()
num = len(s[1:-1])
s = s[0] + str(num) + s[-1]
print(s)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

if a == 5:
  if (b == 5 and c == 7) or (c == 5 and b == 7):
    print(YES)
  else:
    print(NO)
if a == 7:
  if b == 5 and c == 5:
    print(YES)
  else:
    print(NO)

Fixed submission:
a, b, c = map(int, input().split())
 
if a == 5:
  if (b == 5 and c == 7) or (c == 5 and b == 7):
    print("YES")
  else:
    print("NO")
if a == 7:
  if b == 5 and c == 5:
    print("YES")
  else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N, D= map(int,input().split())
arr = [list(map(int,input().split())) for _ in range(N)]
count=0
for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            if i != j:
                tmp += (arr[i][k]-arr[j][k])**2
        tmp = tmp**0.5
        if tmp == int(tmp)
            count = count+1
print(count)

Fixed submission:
N, D= map(int,input().split())
arr = [list(map(int,input().split())) for _ in range(N)]
count=0
for i in range(N):
    for j in range(i+1,N):
        tmp = 0
        for k in range(D):
            if i != j:
                tmp += (arr[i][k]-arr[j][k])**2
        tmp = tmp**0.5
        if tmp.is_integer():
            count = count+1
print(count)
Buggy python submission (verdict: Runtime Error):
L, R= map(int,input().split())
m = 2019
lis = list(range(L,R+1))
lis2 = [i%m for i in lis]
lis2.sort()
print(lis2[0]*lis2[1])

Fixed submission:
L, R= map(int,input().split())
m = 2019
ans = 0
if R-L < m:
    ans = m
    L = L%m
    R = R%m
    lis = list(range(L,R+1))
    lis2 = [i%m for i in lis]
    for i in range(len(lis2)):
        for j in range(i+1,len(lis2)):
            if ans > (lis2[i]*lis[j])%m:
                ans = (lis2[i]*lis[j])%m
print(ans)

Buggy python submission (verdict: Runtime Error):
L, R= map(int,input().split())
m = 2019
L = L % m
R = R % m
lis = list(range(L,R+1))
lis.sort()
print(lis[0]*lis[1])

Fixed submission:
L, R= map(int,input().split())
m = 2019
ans = 0
if R-L < m:
    ans = m
    L = L%m
    R = R%m
    lis = list(range(L,R+1))
    lis2 = [i%m for i in lis]
    for i in range(len(lis2)):
        for j in range(i+1,len(lis2)):
            if ans > (lis2[i]*lis[j])%m:
                ans = (lis2[i]*lis[j])%m
print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
s.sort()
if len(len(s))!=4:
  print("No")
elif s[0]==s[1] and s[2]==s[3]:
  	print("Yes")
else:
  	print("No")

Fixed submission:
s = set(input())
print('Yes' if len(s) == 2 else 'No')
Buggy python submission (verdict: Runtime Error):
info = input().split(" ")
N = int(info[0])
A = int(info[1])
B = int(info[2])

if N*A =< B:
  print(N*A)
else:
  print(B)


Fixed submission:
info = input().split(" ")
N = int(info[0])
A = int(info[1])
B = int(info[2])

if N*A <= B:
  print(N*A)
else:
  print(B)

Buggy python submission (verdict: Runtime Error):
info = input().split(" ")
N = int(info[0])
A = int(info[1])
B = int(info[2])

if N*A =< B:
  print(N*A)
else:
  print(B)

Fixed submission:
info = input().split(" ")
N = int(info[0])
A = int(info[1])
B = int(info[2])

if N*A <= B:
  print(N*A)
else:
  print(B)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
        if mod == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if ans == 0:
                    break
        if ans == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if mod == 0:
                    break
    print(ans)


if __name__ == '__main__':
    main()



Fixed submission:
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if ans == 0:
                    break
        if ans == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if ans == 0:
                    break
        if ans == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import*
n, m, *t = map(int, open(0).read().split())       
*w, s, t = [a-1for a in t]         
e = [[]for _ in range(n)]        
for u, v in zip(w[::2], w[1::2]):      
    e[u].append(v)

INF = 10**10
f = [[INF]*3for _ in range(n)]        
f[s][0] = 0        
q = deque([(s, 0)])           
while q:
    vi, j = q.popleft()         
    if vi == t and j == 0:
        print(f[vi][0]//3)
        break
    for ui in e[vi]:           
        if f[ui][(j+1)%3] < INF: continue           
        f[ui][(j+1)%3] = f[vi][j] + 1
        q.append((ui, (j+1)%3))
else:
    print(-1)

Fixed submission:
def f_f(str):
    for s in str:
        if str.count(s) != 2:
            return False
    return True
 
S = input()
if f_f(S):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s = int(input())
list = [int(n) for n in input().split()]

s_l = sorted(list)
print(s_l[s//2] - s_l[s//2 - 1])


Fixed submission:
def f_f(str):
    for s in str:
        if str.count(s) != 2:
            return False
    return True
 
S = input()
if f_f(S):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
s = int(input())
list = [int(n) for n in input().split()]

sum = 0

for i in range(1, s - 1):
    if (list[i] - list[i - 1]) * (list[i + 1] - list[i]) > 0:
        sum += 1

print(sum)


Fixed submission:
def f_f(str):
    for s in str:
        if str.count(s) != 2:
            return False
    return True
 
S = input()
if f_f(S):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from collections import*
n, m, *t = map(int, open().read().split())       
*w, s, t = [a-1for a in t]         
e = [[]for _ in range(n)]        
for u, v in zip(w[::2], w[1::2]):      
    e[u].append(v)

INF = 10**10
f = [[INF]*3for _ in range(n)]        
f[s][0] = 0        
q = deque([(s, 0)])           
while q:
    vi, j = q.popleft()         
    if vi == t and j == 0:
        print(f[vi][0]//3)
        break
    for ui in e[vi]:           
        if f[ui][(j+1)%3] < INF: continue           
        f[ui][(j+1)%3] = f[vi][j] + 1
        q.append((ui, (j+1)%3))
else:
    print(-1)

Fixed submission:
from collections import*
n, m, *t = map(int, open(0).read().split())       
*w, s, t = [a-1for a in t]         
e = [[]for _ in range(n)]        
for u, v in zip(w[::2], w[1::2]):      
    e[u].append(v)

INF = 10**10
f = [[INF]*3for _ in range(n)]        
f[s][0] = 0        
q = deque([(s, 0)])           
while q:
    vi, j = q.popleft()         
    if vi == t and j == 0:
        print(f[vi][0]//3)
        break
    for ui in e[vi]:           
        if f[ui][(j+1)%3] < INF: continue           
        f[ui][(j+1)%3] = f[vi][j] + 1
        q.append((ui, (j+1)%3))
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
from collections import*
n, m, *t = map(int, open("test").read().split())       
*w, s, t = [a-1for a in t]         
e = [[]for _ in range(n)]        
for u, v in zip(w[::2], w[1::2]):      
    e[u].append(v)

INF = 10**10
f = [[INF]*3for _ in range(n)]        
f[s][0] = 0        
q = deque([(s, 0)])           
while q:
    vi, j = q.popleft()         
    if vi == t and j == 0:
        print(f[vi][0]//3)
        break
    for ui in e[vi]:           
        if f[ui][(j+1)%3] < INF: continue           
        f[ui][(j+1)%3] = f[vi][j] + 1
        q.append((ui, (j+1)%3))
else:
    print(-1)

Fixed submission:
from collections import*
n, m, *t = map(int, open(0).read().split())       
*w, s, t = [a-1for a in t]         
e = [[]for _ in range(n)]        
for u, v in zip(w[::2], w[1::2]):      
    e[u].append(v)

INF = 10**10
f = [[INF]*3for _ in range(n)]        
f[s][0] = 0        
q = deque([(s, 0)])           
while q:
    vi, j = q.popleft()         
    if vi == t and j == 0:
        print(f[vi][0]//3)
        break
    for ui in e[vi]:           
        if f[ui][(j+1)%3] < INF: continue           
        f[ui][(j+1)%3] = f[vi][j] + 1
        q.append((ui, (j+1)%3))
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D=map(int, input().split())
def lcm(a, b):
    if a>b:
        grater = a
    else:
        grater = b
    while(True):
        if((grater%a == 0) and (grater%b == 0)):
            lcm = grater
            break
        else:
            grater += 1
    return lcm

def f(X, a, b):
    return (X - X//a - X//b + X//lcm(a, b))

sum = f(B, C, D) - f(A-1, C, D)
print(sum)

Fixed submission:
A,B,C,D=map(int, input().split())
def gcd(a, b):
    remainder = max(a, b) % min(a, b)
    if remainder == 0:
        return min(a, b)
    return gcd(min(a, b), remainder)

def lcm(a, b):
    return a*b // gcd(a, b)

def f(X, a, b):
    return (X - X//a - X//b + X//lcm(a, b))

sum = f(B, C, D) - f(A-1, C, D)
print(sum)