Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)

N = int(input())
T = [defaultdict(int) for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    T[u-1][v-1] = w
    T[v-1][u-1] = w
visited = [0]*N
ans = [0]*N
def dfs(now,col):
    visited[now] = 1
    for i in T[now].keys():
        if visited[i] == 1:
            continue
        if T[now][i]%2==1:
            ans[i] = col^1
            next =  = col^1
        else:
            ans[i] = col
        dfs(i,next)
dfs(0,0)
for i in range(N):
    print(ans[i])



Fixed submission:
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)

N = int(input())
T = [defaultdict(int) for i in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    T[u-1][v-1] = w
    T[v-1][u-1] = w
visited = [0]*N
ans = [0]*N
def dfs(now,col):
    visited[now] = 1
    for i in T[now].keys():
        if visited[i] == 1:
            continue
        if T[now][i]%2==1:
            ans[i] = col^1
            next = col^1
        else:
            ans[i] = col
            next = col
        dfs(i,next)
dfs(0,0)
for i in range(N):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
K = int(input())
s = S[K-1]

for i in range(N):
    if S[i] == s:
        pass
    else:
        S[i] = '*'

print(''.join(S))


N = int(input())
S = input()
for i in range(N):



Fixed submission:
N = int(input())
S = list(input())
K = int(input())
s = S[K-1]

for i in range(N):
    if S[i] == s:
        pass
    else:
        S[i] = '*'

print(''.join(S))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(int(input()))
K = int(input())
s = S[K-1]

for i in range(N):
    if S[i] == s:
        pass
    else:
        S[i] = '*'

print(''.join(S))



Fixed submission:
N = int(input())
S = list(input())
K = int(input())
s = S[K-1]

for i in range(N):
    if S[i] == s:
        pass
    else:
        S[i] = '*'

print(''.join(S))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

l = [a,b,c,d,e]
m = min([i for i in l if i != 0])
n = l.count(0)
ans = (A//10 + B//10 + C//10 + D//10 + E//10)*10 + m + (5-n)*10-10
print(ans)



Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

l = [a,b,c,d,e]
if len([i for i in l if i != 0]) == 0:
    m = 10
    
else:
    m = min([i for i in l if i != 0])
n = l.count(0)
ans = (A//10 + B//10 + C//10 + D//10 + E//10)*10 + m + (5-n)*10 -10
print(ans)

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

l = [a,b,c,d,e]
m = min([i for i in l if i != 0])
n = l.count(0)
ans = (A//10 + B//10 + C//10 + D//10 + E//10)*10 + m + (5-n)*10
print(ans)


Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

l = [a,b,c,d,e]
if len([i for i in l if i != 0]) == 0:
    m = 10
    
else:
    m = min([i for i in l if i != 0])
n = l.count(0)
ans = (A//10 + B//10 + C//10 + D//10 + E//10)*10 + m + (5-n)*10 -10
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
m = 10**9 + 7
nl = [0 for i in range(26)]
for s in S:
    nl[ord(s)-97] += 1
ans = 1
for i in range(N):
    if nl[i] == 0:
        continue
    else:
        ans *= nl[i] + 1
        ans = ans % m
print(ans-1)


Fixed submission:
N = int(input())
S = input()
m = 10**9 + 7
nl = [0 for i in range(26)]
for s in S:
    nl[ord(s)-97] += 1
ans = 1
for i in range(26):
    if nl[i] == 0:
        continue
    else:
        ans *= nl[i] + 1
        ans = ans % m
print(ans-1)
Buggy python submission (verdict: Runtime Error):
N, M = input().split()
X = list(map(int, input().split()))

if N >= M:
  print(0)
else:
  X.sort()
  L = []
  for i in range(M-1):
    L.append(X[i+1]-X[i])
  L.sort(reverse=True)
  print(X[M-1]-X[0]-sum(L[:N-1]))


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

if N >= M:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort(reverse=True)
    print(X[M-1]-X[0]-sum(L[:N-1]))

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

if N >= M:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort(reverse=True)
    print(X[M-1]-X[0]-sum(L[:N-1]))


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

if N >= M:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort(reverse=True)
    print(X[M-1]-X[0]-sum(L[:N-1]))

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

if N >= M:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort(reverse=True)
    print(X[M]-X[0]-sum(L[:N-1]))


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

if N >= M:
    print(0)
else:
    X.sort()
    L = []
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort(reverse=True)
    print(X[M-1]-X[0]-sum(L[:N-1]))
Buggy python submission (verdict: Runtime Error):
L = list(map(int, input().split()))

L.pop(L[L.index(max(L))])
S = 1
for i in range(2):
  S *= L[i]
  
print(S//2)


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

L.remove(L[L.index(max(L))])
S = 1
for i in range(2):
  S *= L[i]
  
print(S//2)

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

L.pop(L[L.index(max(L))])
S = 1
for i in range(2):
  S *= L[i]
  
print(S)


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

L.remove(L[L.index(max(L))])
S = 1
for i in range(2):
  S *= L[i]
  
print(S//2)
Buggy python submission (verdict: Runtime Error):
s = int(input())

a = [s]
def f(n):
    if n % 2 == 0:
        return(n//2)
    else:
        return(3*n+1)

for i in range(1000001):
    if f(a[i]) in a:
        print(i+1)
        break
    a.append(f(a[i])

Fixed submission:
s = int(input())

a = [s]
def f(n):
    if n % 2 == 0:
        return(n//2)
    else:
        return(3*n+1)

for i in range(1000001):
    if f(a[i]) in a:
        print(i+2)
        break
    a.append(f(a[i]))

Buggy python submission (verdict: Runtime Error):
s = int(input())

a = [s]
def f(n):
    if n % 2 == 0:
        return(n//2)
    else:
        return(3*n+1)

for i in range(1000001):
    if f(a[i]) in a:
        print(i+1)
        break
    a.append(f(a[i])
    


Fixed submission:
s = int(input())

a = [s]
def f(n):
    if n % 2 == 0:
        return(n//2)
    else:
        return(3*n+1)

for i in range(1000001):
    if f(a[i]) in a:
        print(i+2)
        break
    a.append(f(a[i]))

Buggy python submission (verdict: Runtime Error):
s = input()
a = [s]
def f(n):
    if n % 2 == 0:
        return(n//2)
    else:
        return(3*n+1)
i = 0
while True:
    if f(a[i]) in a:
        print(i+1)
        break
    a.append(f(a[i])
    i += 1


Fixed submission:
s = int(input())

a = [s]
def f(n):
    if n % 2 == 0:
        return(n//2)
    else:
        return(3*n+1)

for i in range(1000001):
    if f(a[i]) in a:
        print(i+2)
        break
    a.append(f(a[i]))
Buggy python submission (verdict: Time Limit Exceeded):

N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [0]*N
for i in range(1,N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    for j in range(max(0,i-K),i):
        dp[i] = min(dp[j]+abs(h[i]-h[j]),dp[i])
print(dp[N-1])


Fixed submission:

N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [0]*N
for i in range(1,N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    for j in range(max(0,i-K),i):
        dp[i] = min(dp[j]+abs(h[i]-h[j]),dp[i])
print(dp[N-1])

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

dp = [0]*N
for i in range(1,N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    for j in range(max(0,i-K),i):
        dp[i] = min(dp[j]+abs(h[i]-h[j]),dp[i])
print(dp[N-1])



Fixed submission:

N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [0]*N
for i in range(1,N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    for j in range(max(0,i-K),i):
        dp[i] = min(dp[j]+abs(h[i]-h[j]),dp[i])
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())

def rep(N,X):
    if N == 1:
        if X == 1 or X == 5:
            return(0)
        else:
            return(X-1)
    else:
        n = 2**(N+2)-3
        a = n//2-(X-1)
        p = 2**N-1
        if a < -1:
            return(rep(N-1, abs(a)) + p + 1)
        elif a == -1 or a == 0 or a == 1:
            return(p + 1)
        else:
            return(rep(N-1, X-1))
print(rep(N,X))



Fixed submission:
D = int(input())
if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')
Buggy python submission (verdict: Runtime Error):
def rep(N,X):
    if N == 1:
        if X == 1 or X == 5:
            return(0)
        else:
            return(X-1)
    elif X == 1:
        return(0)
    else:
        n = 2**(N+2)-3
        a = n//2-(X-1)
        p = 2**N-1
        if a < -1:
            return(rep(N-1, abs(a)) + p + 1)
        elif a == -1 or a == 0 or a == 1:
            return(p + 1)
        else:
            return(rep(N-1, X-1))
print(rep(N,X))

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

def rep(N,X):
    if N == 1:
        if X == 1:
            return(0)
        elif X == 5:
            return(3)
        else:
            return(X-1)
    elif X == 1:
        return(0)
    else:
        n = 2**(N+2)-3
        p = 2**N-1 # N-1のPの個数
        if X <= n//2:
            return(rep(N-1, X-1))
        elif X == n//2+1:
            return(p + 1)
        else:
            if n-1 == X-1:
                return(rep(N-1, X-1-n//2-1) + p + 1)
            else:
                return(rep(N-1, X-1-n//2) + p + 1)
print(rep(N,X))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = input()
T = input()
flag = True
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        while b:
            a, b = b, a % b
        return a
    return a * b // gcd(a, b)
L = lcm(N,M)
"""
l = [-1 for i in range(L)]
for i in range(N):
    l[L//N*i] = ord(S[i])-97
for i in range(M):
    if l[L//M*i] == -1:
        l[L//M*i] = ord(T[i])-97
    elif l[L//M*i] == ord(T[i])-97:
        pass
    else:
        flag = False
"""
if S[0] == T[0 and S[N-1] == T[M-1]:
    flag = True
else:
    flag = False
if flag:
    print(L)
else:
    print(-1)


Fixed submission:
N,M = map(int,input().split())
S = input()
T = input()
flag = True
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        while b:
            a, b = b, a % b
        return a
    return a * b // gcd(a, b)
L = lcm(N,M)
def gcd(a, b): # 最大公約数
    while b:
        a, b = b, a % b
    return a

flag = True
for i in range(gcd(N,M)):
    if S[i*N//gcd(N,M)] == T[i*M//gcd(N,M)] and flag:
        pass
    else:
        flag = False
if flag:
    print(L)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
S = input()
T = input()
flag = True
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        while b:
            a, b = b, a % b
        return a
    return a * b // gcd(a, b)
L = lcm(N,M)
l = [-1 for i in range(L)]
for i in range(N):
    l[L//N*i] = ord(S[i])-97
for i in range(M):
    if l[L//M*i] == -1:
        l[L//M*i] = ord(T[i])-97
    elif l[L//M*i] == ord(T[i])-97:
        pass
    else:
        flag = False
if flag:
    print(L)
else:
    print(-1)


Fixed submission:
N,M = map(int,input().split())
S = input()
T = input()
flag = True
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        while b:
            a, b = b, a % b
        return a
    return a * b // gcd(a, b)
L = lcm(N,M)
def gcd(a, b): # 最大公約数
    while b:
        a, b = b, a % b
    return a

flag = True
for i in range(gcd(N,M)):
    if S[i*N//gcd(N,M)] == T[i*M//gcd(N,M)] and flag:
        pass
    else:
        flag = False
if flag:
    print(L)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()
sl = {}
tl = {}
for i in range(len(S)):
    if S[i] in sl:
        sl[S[i]] = sl[S[i]] + str(i)
    else:
        sl[S[i]] = str(i)
    if T[i] in tl:
        tl[T[i]] = tl[T[i]] + str(i)
    else:
        tl[T[i]] = str(i)
sv = [i for i in list(sl.values()) if len(i)>=2]
tv = [i for i in list(tl.values()) if len(i)>=2]
flag = True
if len(sv) != len(tv):
    flag = False
elif len(sv) == 0 and len(tv) == 0:
    pass
else:
    for v in sv:
        if not v in tv:
            flag = False
            break
    if flag:
        for v in tv:
            if not v in sv:
                flag = False
                break
if flag:
    print('Yes')
else:
    print('No')

Fixed submission:
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)

S = input()
T = input()
N = len(S)
ds = {}
dt = {}
ss = 0
tt = 0
SS = []
TT = []
for i in range(N):
    if S[i] in ds:
        SS.append(ds[S[i]])
    else:
        ds[S[i]] = ss
        SS.append(ss)
        ss += 1
    if T[i] in dt:
        TT.append(dt[T[i]])
    else:
        dt[T[i]] = tt
        TT.append(tt)
        tt += 1
flag = True
for i in range(N):
    if SS[i]==TT[i]:
        continue
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int,input().split())
import numpy as np

x1 = np.array([x1,y1])
x2 = np.array([x2,y2])
rot = np.array([[0,-1],[1,0]])
x3 = np.dot(rot,(x2-x1))+x2
x4 = np.dot(rot,(x3-x2))+x3
print(x3[0],x3[1],x4[0],x4[1])

Fixed submission:
x1,y1,x2,y2 = map(int,input().split())
import numpy as np

x1 = np.array([x1,y1])
x2 = np.array([x2,y2])
rot = np.array([[0,-1],[1,0]])
x3 = np.dot(rot,(x2-x1))+x2
x4 = np.dot(rot,(x3-x2))+x3
print(x3[0],x3[1],x4[0],x4[1])
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
D, G = map(int, input().split())
p = []
c = []
score = 0
ans = 0
for i in range(D):
    pi, ci = map(int, input().split())
    p.append(pi)
    c.append(ci)
a = [i for i in range(D)]
comp = [[i, 100*(i+1)*p[i]+c[i], (100*(i+1)*p[i]+c[i])//p[i], p[i]] for i in range(D)]
comp.sort(key=itemgetter(2),reverse=True)
for d in range(D):
    if score + comp[d][1] < G:
        #print(comp[d][0])
        score += comp[d][1]
        a.pop(comp[d][0])
        ans += comp[d][3]
    else:
        can = d
        for dd in range(d,D):
            if score + comp[dd][1] >= G and comp[can][3] > comp[dd][3]:
                can = dd

        if 100*(max(a)+1)*p[max(a)] + score >= G and comp[can][3] >= (G-score-1)//(100*(max(a)+1)) + 1:
            #print(ans)
            ans += (G-score-1)//(100*(max(a)+1)) + 1
            #print(ans)
            break
        else:
            ans += comp[can][3]
            break
print(ans)


Fixed submission:
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]
ans = 10**9
from math import ceil
for i in range(2**D):
    now = 0
    score = 0
    for j in range(D):
        if i>>j & 1:
            now += pc[j][0]
            score += pc[j][0]*100*(j+1) + pc[j][1]

    if score >= G:
        ans = min(ans,now)
    else:
        for j in reversed(range(D)):
            if i>>j & 1 == 0:
                if ceil((G-score)/(100*(j+1))) < pc[j][0]:
                    now += ceil((G-score)/(100*(j+1)))
                    break
        else:
            continue

        if now==0:
            continue
        ans = min(ans,now)

print(ans)
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
s = sum(a)
ans = 1000
for i in range(3):
    for j in range(3):
        if i == j:
            continue
        b = abs(A[i]-A[j])+abs(A[j]-(a-(A[i]+A[j])))
        ans = min(ans,b)
print(ans)

Fixed submission:
A = list(map(int,input().split()))
s = sum(A)
ans = 1000
for i in range(3):
    for j in range(3):
        if i == j:
            continue
        b = abs(A[i]-A[j])+abs(A[j]-(s-(A[i]+A[j])))
        ans = min(ans,b)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
now = a[0]
i = 1
while i < N:
    if now == a[i]:
        ans += 1
        now = a[i+1]
        i += 2
        if i > N-1:
            break
    else:
        now = a[i]
        i += 1
print(ans)


Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 0
now = a[0]
i = 1
while i < N:
    if now == a[i]:
        ans += 1
        if i == N-1:
            break
        now = a[i+1]
        i += 2
        
    else:
        now = a[i]
        i += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
now = a[0]
i = 1
while i < N:
    if now == a[i]:
        ans += 1
        i += 2
        if i == N-1:
            break
        now = a[i+1]
    else:
        now = a[i]
        i += 1
print(ans)


Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 0
now = a[0]
i = 1
while i < N:
    if now == a[i]:
        ans += 1
        if i == N-1:
            break
        now = a[i+1]
        i += 2
        
    else:
        now = a[i]
        i += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
print(S.count('+')-S.count'-')


Fixed submission:
S = input()
print(S.count('+')-S.count('-'))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
ab = 'abcdefghijklmnopqrstuvwxyz'
N = len(s)
substrings = set()
for i in ab:
    for l in range(N):
        if s[l] != i:
            continue
        for r in range(l,N):
            substrings.add(s[l:r+1])
    if len(substrings) >= K:
        break

substrings = list(substrings)
substrings.sort()
print(substrings[K-1])

Fixed submission:
s = input()
K = int(input())
ab = 'abcdefghijklmnopqrstuvwxyz'
N = len(s)
substrings = set()
for i in ab:
    for l in range(N):
        if s[l] != i:
            continue
        for r in range(l,N):
            if r-l+1 > K:
                break
            substrings.add(s[l:r+1])
    if len(substrings) >= K:
        break
substrings = list(substrings)
substrings.sort()
print(substrings[K-1])
Buggy python submission (verdict: Runtime Error):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))

print(min(sum(A[:X],sum(A[X:]))))

Fixed submission:
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
import bisect
id = bisect.bisect_left(A,X)
print(min(len(A[:id]),len(A[id:])))
Buggy python submission (verdict: Runtime Error):
N = input()
if len(N) == 1:
    print(int(N))
else:
    print(max(sum(list(N)),(len(N)-1)*9+int(N[0])-1))


Fixed submission:
N = input()
if len(N) == 1:
    print(int(N))
else:
    print(max(sum([int(i) for i in N]),(len(N)-1)*9+int(N[0])-1))
Buggy python submission (verdict: Runtime Error):
S = list(input())
print('2017/01/'+S[8:])


Fixed submission:
S = list(input())
print('2018/01/'+''.join(S[8:]))
Buggy python submission (verdict: Runtime Error):
def sieve(n): # エラトステネスの篩
    num = [1]*n
    num[0]=num[1]= 0
    for i in range(int(n**0.5)+1):
        if num[i]:
            for j in range(i**2,n,i):
                num[j] = 0
    return num # list ### 1なら素数0なら合成数

primes = sieve(10**5)
like_2017 = [0]
for i in range(1,len(primes)):
    if i <= 2:
        like_2017.append(like_2017[i-1])
    elif primes[i] == 1 and primes[(i+1)//2] == 1:
        like_2017.append(like_2017[i-1]+1)
    else:
        like_2017.append(like_2017[i-1])
Q = int(input())
for q in range(Q):
    l,r = map(int,input().split())
    print(like_2017[r+1]-like_2017[l-1])


Fixed submission:
def sieve(n): # エラトステネスの篩
    num = [1]*n
    num[0]=num[1]= 0
    for i in range(int(n**0.5)+1):
        if num[i]:
            for j in range(i**2,n,i):
                num[j] = 0
    return num # list ### 1なら素数0なら合成数

primes = sieve(10**5)
like_2017 = [0]
for i in range(1,len(primes)):
    if i <= 2:
        like_2017.append(like_2017[i-1])
    elif primes[i] == 1 and primes[(i+1)//2] == 1:
        like_2017.append(like_2017[i-1]+1)
    else:
        like_2017.append(like_2017[i-1])
Q = int(input())
for q in range(Q):
    l,r = map(int,input().split())
    print(like_2017[r]-like_2017[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
def sieve(n): # エラトステネスの篩
    num = [1]*n
    num[0]=num[1]= 0
    for i in range(int(n**0.5)+1):
        if num[i]:
            for j in range(i**2,n,i):
                num[j] = 0
    return num # list ### 1なら素数0なら合成数

primes = sieve(10**5)
like_2017 = []
for i in range(len(primes)):
    if i <= 2:
        like_2017.append(0)
    elif primes[i] == 1 and primes[(i+1)//2] == 1:
        like_2017.append(1)
    else:
        like_2017.append(0)
Q = int(input())
for q in range(Q):
    l,r = map(int,input().split())
    print(sum(like_2017[l:r+1]))


Fixed submission:
def sieve(n): # エラトステネスの篩
    num = [1]*n
    num[0]=num[1]= 0
    for i in range(int(n**0.5)+1):
        if num[i]:
            for j in range(i**2,n,i):
                num[j] = 0
    return num # list ### 1なら素数0なら合成数

primes = sieve(10**5)
like_2017 = [0]
for i in range(1,len(primes)):
    if i <= 2:
        like_2017.append(like_2017[i-1])
    elif primes[i] == 1 and primes[(i+1)//2] == 1:
        like_2017.append(like_2017[i-1]+1)
    else:
        like_2017.append(like_2017[i-1])
Q = int(input())
for q in range(Q):
    l,r = map(int,input().split())
    print(like_2017[r]-like_2017[l-1])
Buggy python submission (verdict: Runtime Error):
def ceil(n): # ceiling関数
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))
a,b = map(int,input().split())
print(ceil(a+B/2))


Fixed submission:
def ceil(n): # ceiling関数
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))
a,b = map(int,input().split())
print(ceil((a+b)/2))

Buggy python submission (verdict: Runtime Error):
def ceil(n): # ceiling関数
    if n > int(n):
        return(int(n)+1)
    else:
a,b = map(int,input().split())
print(ceil(a+B/2))


Fixed submission:
def ceil(n): # ceiling関数
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))
a,b = map(int,input().split())
print(ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [0]*(N+2)
L[0] = 2
L[1] = 1
if N<=2:
    print(L[i-1])
else:
    for i in range(2,N+1):
        L[i] = L[i-1]+L[i-2]
    print(L[N])


Fixed submission:
N = int(input())
L = [0]*(N+2)
L[0] = 2
L[1] = 1
if N<=1:
    print(L[N])
else:
    for i in range(2,N+1):
        L[i] = L[i-1]+L[i-2]
    print(L[N])

Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [0]*(N+1)
L[0] = 2
L[1] = 1
if N<=2:
    print(L[i-1])
    exit()
for i in range(2,N+1):
    L[i] = L[i-1]+L[i-2]
print(L[N])


Fixed submission:
N = int(input())
L = [0]*(N+2)
L[0] = 2
L[1] = 1
if N<=1:
    print(L[N])
else:
    for i in range(2,N+1):
        L[i] = L[i-1]+L[i-2]
    print(L[N])