Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    S = input()
    min = N
    mc = 0
    for i in range(0, N):
        m = S[i]
        l = S[:i]
        r = S[i:]
        c = 0
        c = mc
        for h in r:
            if h != 'W': c += 1
        if min > c: min = c
        if m != 'E': mc += 1
    print(min)
        
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    S = input()
    ec = S.count('E')
    tec = ec
    for k in S:
        if k == 'E':
            tec -= 1
        else:
            tec += 1
        ec = min(ec, tec)
    print(ec)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    S = input()
    min = N
    for i in range(0, N):
        m = S[i]
        l = S[:i]
        r = S[i:]
        c = 0
        for h in l:
            if h != 'E': c += 1
        if c > min: continue
        for h in r:
            if h != 'W': c += 1
        if min > c: min = c
    print(min)
        
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    S = input()
    ec = S.count('E')
    tec = ec
    for k in S:
        if k == 'E':
            tec -= 1
        else:
            tec += 1
        ec = min(ec, tec)
    print(ec)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    S = input()
    min = N
    for i in range(0, N):
        m = S[i]
        l = S[:i]
        r = S[i:]
        c = 0
        for h in l:
            if h != 'E': c += 1
        for h in r:
            if h != 'W': c += 1
        if min > c: min = c
    print(min)
        
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    S = input()
    ec = S.count('E')
    tec = ec
    for k in S:
        if k == 'E':
            tec -= 1
        else:
            tec += 1
        ec = min(ec, tec)
    print(ec)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    As = list(map(int, input().split()))
    c = 0
    for i in range(N):
        l = 0
        r = 0
        for ii in range(i, N):
            l ^= As[ii]
            r += As[ii]
            if l == r:
                c += 1
            else:
                break

    print(c)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    s = 0
    r = 0
    res = 0
    for l in range(N):
        while N > r and x ^ A[r] == s + A[r]:
            x ^= A[r]
            s += A[r]
            r += 1

        x ^= A[l]
        s -= A[l]
        res += r - l

    print(res)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    As = list(map(int, input().split()))
    c = 0
    for i in range(N):
        l = 0
        r = 0
        for ii in range(i, N):
            if r & As[ii] != 0: break
            l ^= As[ii]
            r += As[ii]
            if l == r: c += 1

    print(c)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    s = 0
    r = 0
    res = 0
    for l in range(N):
        while N > r and x ^ A[r] == s + A[r]:
            x ^= A[r]
            s += A[r]
            r += 1

        x ^= A[l]
        s -= A[l]
        res += r - l

    print(res)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    As = list(map(int, input().split()))
    c = 0
    for i in range(N):
        l = bin(0)
        r = 0
        for ii in range(i, N):
            if (r & As[ii] != 0): break
            l = bin(int(l, 2) ^ As[ii])
            r += As[ii]
            if (l == bin(r)): c += 1

    print(c)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    s = 0
    r = 0
    res = 0
    for l in range(N):
        while N > r and x ^ A[r] == s + A[r]:
            x ^= A[r]
            s += A[r]
            r += 1

        x ^= A[l]
        s -= A[l]
        res += r - l

    print(res)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    As = list(map(int, input().split()))
    c = 0
    for i in range(N):
        l = bin(0)
        r = 0
        for ii in range(i, N):
            l = bin(int(l, 2) ^ As[ii])
            r += As[ii]
            if (l == bin(r)): c += 1
    print(c)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    s = 0
    r = 0
    res = 0
    for l in range(N):
        while N > r and x ^ A[r] == s + A[r]:
            x ^= A[r]
            s += A[r]
            r += 1

        x ^= A[l]
        s -= A[l]
        res += r - l

    print(res)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int a,b;
  if (n==1) cout<<"Hello World";
  else{
    cin>>a;
    cin>>b;
    cout<<a+b;
  }
}


Fixed submission:
N=int(input())
if N==1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)
Buggy python submission (verdict: Runtime Error):
def half(xs):
  for x in xs:
    if x % 2 == 0:
      return xs
  for i in range(len(xs)):
    xs[i] /= 2
  return half(xs)


ls = [int(num) for num in input().split()]
print(half(ls))
    

Fixed submission:
def half(xs):
    count = 0
    while True:
        for i in range(len(xs)):
            if xs[i] % 2 != 0 or xs[i] == 0:
                return count
            xs[i] /= 2
        else:
            count += 1
    return count


def main():
    _num = input()
    xs = [int(i) for i in input().split()]
    res = half(xs)
    print(res)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n,t = map(int,input().split())

a = []

for i in range(n):
    a.append(list(map(int,input().split())))

min = 9999

for i in a:
    if i[1] <= t and i[0] < min:
        min = i[0]

if min > 1000:
    print("TLE")
else:
    print(min)


Fixed submission:
n = int(input())
if n ==1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy python submission (verdict: Runtime Error):
n = int(input())
if n ==1:
    print(Hello World)
else:
    a = int(input())
    b = int(input())
    print(a+b)


Fixed submission:
n = int(input())
if n ==1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
min=1001
for i in range(N):
    c,t=map(int,input().split())
    if t<(T+1):
        if c<min:
            min=c           
if min==1001:
    print("TLE")
else:
    print(min)


Fixed submission:
a=int(input())
if a==1:
    print("Hello World")
elif a==2 :
    b=int(input())
    c=int(input())
    print(b+c)

Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
min=1001
for i in range(N):
    c,t=map(int,input().split())
    if t<(T+1):
        if c<min:
            min=c           
if min=1001:
    print("TLE")
else:
    print(min)

Fixed submission:
a=int(input())
if a==1:
    print("Hello World")
elif a==2 :
    b=int(input())
    c=int(input())
    print(b+c)
Buggy python submission (verdict: Runtime Error):
s = raw_input()
k = int(raw_input())

ans = '1'

for i in range(0, k):
	if s[i] != '1':
		ans = s[i]
		break

print ans

Fixed submission:
s = raw_input()
k = int(raw_input())

ans = '1'
i = 0
while i < k and i < len(s):
	if s[i] != '1':
		ans = s[i]
		break
	i = i + 1

print ans
Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, raw_input().split())

train = []
for i in range(0, N):
	train.append([])
for i in range(0, M):
	L, R = map(int, raw_input().split())
	train[L-1].append(R)
for i in range(0, N):
	train[i-1].sort()

counter = []
for i in range(0, N):
	lst = []
	for j in range(0, N):
		lst.append(0)
	for j in range(0, len(train[i])):
		lst[train[i][j]-1] = lst[train[i][j]-1] + 1
	for j in range(1, len(lst)):
		lst[j] = lst[j-1] + lst[j]
	counter.append(lst)

for i in range(0, Q):
	p, q = map(int, raw_input().split())
	cnt = 0
	for j in range(p-1, q):
		cnt = cnt + counter[j][q-1]
	print cnt


Fixed submission:
N, M, Q = map(int, raw_input().split())

train = []
for i in range(0, N):
	train.append([])
for i in range(0, M):
	L, R = map(int, raw_input().split())
	train[L-1].append(R)
for i in range(0, N):
	train[i-1].sort()

counter = []
for i in range(0, N):
	lst = []
	for j in range(0, N):
		lst.append(0)
	for j in range(0, len(train[i])):
		lst[train[i][j]-1] = lst[train[i][j]-1] + 1
	for j in range(1, len(lst)):
		lst[j] = lst[j-1] + lst[j]
	counter.append(lst)
for i in range(1, N):
	for j in range(0, N):
		counter[N-1-i][j] = counter[N-1-i][j] + counter[N-i][j]

for i in range(0, Q):
	p, q = map(int, raw_input().split())
	print counter[p-1][q-1]

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, raw_input().split())

train = []
for i in range(0, N):
	train.append([])
for i in range(0, M):
	L, R = map(int, raw_input().split())
	train[L-1].append(R)
for i in range(0, N):
	train[i-1].sort()

counter = []
for i in range(0, N):
	lst = []
	for j in range(0, N):
		lst.append(0)
	for j in range(0, len(train[i])):
		lst[train[i][j]-1] = lst[train[i][j]-1] + 1
	counter.append(lst)

for i in range(0, Q):
	p, q = map(int, raw_input().split())
	cnt = 0
	for j in range(p-1, q):
		for k in range(j, q):
			cnt = cnt + counter[j][k]
	print cnt


Fixed submission:
N, M, Q = map(int, raw_input().split())

train = []
for i in range(0, N):
	train.append([])
for i in range(0, M):
	L, R = map(int, raw_input().split())
	train[L-1].append(R)
for i in range(0, N):
	train[i-1].sort()

counter = []
for i in range(0, N):
	lst = []
	for j in range(0, N):
		lst.append(0)
	for j in range(0, len(train[i])):
		lst[train[i][j]-1] = lst[train[i][j]-1] + 1
	for j in range(1, len(lst)):
		lst[j] = lst[j-1] + lst[j]
	counter.append(lst)
for i in range(1, N):
	for j in range(0, N):
		counter[N-1-i][j] = counter[N-1-i][j] + counter[N-i][j]

for i in range(0, Q):
	p, q = map(int, raw_input().split())
	print counter[p-1][q-1]
Buggy python submission (verdict: Runtime Error):
cake = []
donut = []
for i in range(1, 26):
	cake.append(i*4)
for i in range(1, 15):
	donut.append(i*7)

n = int(raw_input())

flag = false
if n in cake: flag = true
if n in donut: flag = true
if not flag:
	for i in range(0, len(cake)):
		for j in range(0, len(donut)):
			if n == cake[i] + donut[j]:
				flag = true
				break
		if flag: break

if flag: print 'Yes'
else: print 'No'

Fixed submission:
cake = []
donut = []
for i in range(1, 26):
	cake.append(i*4)
for i in range(1, 15):
	donut.append(i*7)

n = int(raw_input())

flag = False
if n in cake: flag = True
if n in donut: flag = True
if not flag:
	for i in range(0, len(cake)):
		for j in range(0, len(donut)):
			if n == cake[i] + donut[j]:
				flag = True
				break
		if flag: break

if flag: print 'Yes'
else: print 'No'
Buggy python submission (verdict: Runtime Error):
s = raw_input()
ans = 0
for i in range(0, 4):
	if s[i] = '+': ans = ans + 1
	else: ans = ans - 1

print ans

Fixed submission:
s = raw_input()
ans = 0
for i in range(0, 4):
	if s[i] == '+': ans = ans + 1
	else: ans = ans - 1

print ans
Buggy python submission (verdict: Runtime Error):
s = raw_input()
sum = 0
for i in range(0, len(s)):
	sum = int(s[i])
if int(s) % sum == 0: print 'Yes'
else: print 'No'

Fixed submission:
s = raw_input()
sum = 0
for i in range(0, len(s)):
	sum = sum + int(s[i])
if int(s) % sum == 0: print 'Yes'
else: print 'No'
Buggy python submission (verdict: Runtime Error):
inpt = map(int, raw_input().split())

for i in range(inpt[0], inpt[1]+1):
	if i < inpt[0] + inpt[2] or inpt[1] - inpt[2] < i:
		print i

Fixed submission:
inpt = map(int, raw_input().split())

for i in range(inpt[0], inpt[0]+inpt[2]):
	if i > inpt[1]: break
	print i
for i in range(inpt[1]-inpt[2]+1, inpt[1]+1):
	if i >= inpt[0]+inpt[2]:
		print i

Buggy python submission (verdict: Runtime Error):
inpt = map(int, raw_input().split())

for i in range(inpt[0], inpt[1]+1):
	if i < inpt[0] + inpt[2] or inpt[1] - inpt[2] < i:
		print i


Fixed submission:
inpt = map(int, raw_input().split())

for i in range(inpt[0], inpt[0]+inpt[2]):
	if i > inpt[1]: break
	print i
for i in range(inpt[1]-inpt[2]+1, inpt[1]+1):
	if i >= inpt[0]+inpt[2]:
		print i
Buggy python submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())
cnt = 0
for i in range(A, B+1):
	s = str[i]
	if s[0] == s[4] and s[1] == s[3]:
		cnt = cnt + 1

print cnt

Fixed submission:
A, B = map(int, raw_input().split())
cnt = 0
for i in range(A, B+1):
	s = str(i)
	if s[0] == s[4] and s[1] == s[3]:
		cnt = cnt + 1

print cnt
Buggy python submission (verdict: Runtime Error):
inpt = map(int, raw_input())

if (inpt[0] * inpt[1]) % 2 == 0: print 'Even'
else: print 'Odd'


Fixed submission:
inpt = map(int, raw_input().split())

if (inpt[0] * inpt[1]) % 2 == 0:
	print "Even"
else:
	print "Odd"
Buggy python submission (verdict: Runtime Error):
def searchyen(n, y):
	for i in range(0, n+1):
		for j in range(0, n+1-i):
			if 10000*i + 5000*j + 1000*(n-i-j) == y:
				return [i, j, k]
	return [-1, -1, -1]

inpt = map(int, raw_input().split())

ans = searchyen(inpt[0], inpt[1])
print str(ans[0]) + ' ' + str(ans[1]) + ' ' + str(ans[2])


Fixed submission:
def searchyen(n, y):
	for i in range(0, n+1):
		for j in range(0, n+1-i):
			if 10000*i + 5000*j + 1000*(n-i-j) == y:
				return [i, j, n-i-j]
	return [-1, -1, -1]

inpt = map(int, raw_input().split())

ans = searchyen(inpt[0], inpt[1])
print str(ans[0]) + ' ' + str(ans[1]) + ' ' + str(ans[2])
Buggy python submission (verdict: Runtime Error):
def smaller(int x, int y):
	if x < y: return x
	else: return y

inpt = map(int, raw_input())
n = inpt[0]
a = inpt[1]
b = inpt[2]

print smaller(n*a, b)

Fixed submission:
def smaller(x, y):
	if x < y: return x
	else: return y

N, A, B = map(int, raw_input().split())
print smaller(A*N, B)
Buggy python submission (verdict: Runtime Error):
def harshad(x):
	sum = 0
	for i in range(0, len(x)):
		sum = sum + x[i]
	if int(x)%sum == 0: return 'Yes'
	else: return 'No'

print harshad(raw_input())

Fixed submission:
def harshad(x):
	sum = 0
	for i in range(0, len(x)):
		sum = sum + int(x[i])
	if int(x)%sum == 0: return 'Yes'
	else: return 'No'

print harshad(raw_input())
Buggy python submission (verdict: Runtime Error):
S = raw_input()
lst = []
for i in range(0, 26):
	lst.append(True)

for i in range(0, len(S)):
	lst[ord(S[i])-141] = False

flag = True
for i in range(0, 26):
	if lst[i]:
		print chr(i+141)
		flag = False
		break

if flag:
	print 'None'

Fixed submission:
S = raw_input()
lst = []
for i in range(0, 26):
	lst.append(True)

for i in range(0, len(S)):
	lst[ord(S[i])-97] = False

flag = True
for i in range(0, 26):
	if lst[i]:
		print chr(i+97)
		flag = False
		break

if flag:
	print 'None'
Buggy python submission (verdict: Time Limit Exceeded):
def fct(x):
	t = long(1)
	for i in range(1, x+1):
		t = t * long(i)
	return t

inpt = map(int, raw_input().split())
n = inpt[0]
m = inpt[1]

ans = long(0)

if abs(n-m) < 2:
	ans = fct(n)*fct(m)
	if n == m:
		ans = 2 * ans

print ans

Fixed submission:
def fct(x):
	t = 1L
	for i in range(1, x+1):
		t = (t * long(i)) % 1000000007L
	return t

inpt = map(int, raw_input().split())
n = inpt[0]
m = inpt[1]

ans = 0L

if abs(n-m) < 2:
	ans = (fct(n)*fct(m)) % 1000000007L
	if n == m:
		ans = (2L * ans) % 1000000007L

print ans

Buggy python submission (verdict: Runtime Error):
inpt = map(int, raw_input().split())
n = inpt[0]
m = inpt[1]

ans = long(0)

if abs(n-m) < 2:
	ans = fct(n)*fct(m)
	if n == m:
		ans = 2 * ans

print ans % 1000000007L

Fixed submission:
def fct(x):
	t = 1L
	for i in range(1, x+1):
		t = (t * long(i)) % 1000000007L
	return t

inpt = map(int, raw_input().split())
n = inpt[0]
m = inpt[1]

ans = 0L

if abs(n-m) < 2:
	ans = (fct(n)*fct(m)) % 1000000007L
	if n == m:
		ans = (2L * ans) % 1000000007L

print ans
Buggy python submission (verdict: Runtime Error):
def judge(a, b, y, x, m):
	for i in range(0, m):
		for j in range(0, m):
			if a[y+i][x+j] != b[y][x]: return False
	return True

N, M = map(int, raw_input().split())
A = []
B = []
for i in range(0, N):
	A.append(raw_input())
for i in range(0, M):
	B.append(raw_input())

ans = 'No'
for i in range(0, N-M+1):
	for j in range(0, N-M+1):
		if judge(A, B, i, j, M):
			ans = 'Yes'
			break

print ans


Fixed submission:
def judge(a, b, y, x, m):
	for i in range(0, m):
		for j in range(0, m):
			if a[y+i][x+j] != b[i][j]: return False
	return True

N, M = map(int, raw_input().split())
A = []
B = []
for i in range(0, N):
	A.append(raw_input())
for i in range(0, M):
	B.append(raw_input())

ans = 'No'
for i in range(0, N-M+1):
	for j in range(0, N-M+1):
		if judge(A, B, i, j, M):
			ans = 'Yes'
			break

print ans

Buggy python submission (verdict: Runtime Error):
def judge(a, b, y, x, m):
	for i in range(0, m):
		for j in range(0, m):
			if a[y+i][x+j] != b[y+i][x+j]: return False
	return True

N, M = map(int, raw_input().split())
A = []
B = []
for i in range(0, N):
	A.append(raw_input())
for i in range(0, M):
	B.append(raw_input())

ans = 'No'
for i in range(0, N-M+1):
	for j in range(0, N-M+1):
		if judge(A, B, i, j, M):
			ans = 'Yes'
			break

print ans


Fixed submission:
def judge(a, b, y, x, m):
	for i in range(0, m):
		for j in range(0, m):
			if a[y+i][x+j] != b[i][j]: return False
	return True

N, M = map(int, raw_input().split())
A = []
B = []
for i in range(0, N):
	A.append(raw_input())
for i in range(0, M):
	B.append(raw_input())

ans = 'No'
for i in range(0, N-M+1):
	for j in range(0, N-M+1):
		if judge(A, B, i, j, M):
			ans = 'Yes'
			break

print ans
Buggy python submission (verdict: Time Limit Exceeded):
def larger(x, y):
	if x > y: return x
	else: return y

N, A = map(int, raw_input().split())
x = map(int, raw_input().split())
x.sort()
max = larger(x[-1], A)
dp = []

for i in range(0, N+1):
	tmp1 = []
	for j in range(0, N+1):
		tmp2 = []
		for k in range(0, N*max+1):
			tmp2.append(0)
		tmp1.append(tmp2)
	dp.append(tmp1)

for i in range(0, N+1):
	for j in range(0, N+1):
		for k in range(0, N*max+1):
			if i == 0:
				if j == 0 and k == 0: dp[i][j][k] = 1
			else:
				if k < x[i-1]: dp[i][j][k] = dp[i-1][j][k]
				elif j >= 1:
					dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]

ans = 0
for i in range(1, N+1):
	ans = ans + dp[N][i][i*A]
print ans

Fixed submission:
def larger(x, y):
	if x > y: return x
	else: return y

N, A = map(int, raw_input().split())
x = map(int, raw_input().split())
x = map(lambda a: a-A, x)
max = larger(x[-1], A)
dp = []

for i in range(0, N+1):
	tmp = []
	for j in range(0, 2*N*max+1):
		tmp.append(0)
	dp.append(tmp)

for i in range(0, N+1):
	for j in range(0, 2*N*max+1):
		if i == 0:
			if j == N*max: dp[i][j] = 1
		else:
			if j-x[i-1] < 0 or j-x[i-1] > 2*N*max:
				dp[i][j] = dp[i-1][j]
			else:
				dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i-1]]

print dp[N][N*max]-1
Buggy python submission (verdict: Runtime Error):
<?php
fscanf(STDIN, "%d %d", $a, $b);
$ans = max($a+$b, max($a-$b, $a*$b));
print("$ans\n");
?>

Fixed submission:
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    a, b = map(int, input().split())
    ans = max(a+b, max(a-b, a*b))
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    x = int(input())
    ans = float('-inf')
    for p in range(1,x+1):
        for b in range(2, x+2):
            if p**b <= x:
                ans = max(ans, p**b)
    else:
        print(ans)

Fixed submission:
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    x = int(input())
    ans = float('-inf')
    for p in range(1,x+1):
        for b in range(2, x+2):
            if p**b <= x:
                ans = max(ans, p**b)
            else:
                break
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    a,b,k = map(int, input().split())
    factors = [ tmp for tmp in range(a, b+1) ]
    ans = list(set(factors[0:k]+factors[-k:]))
    ans.sort()
    for factor in ans:
        print(factor)

Fixed submission:
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    a,b,k = map(int, input().split())
    ans = []
    if b-a+1 >= 2*k:
        for tmp in range(a, a+k):
            ans.append(tmp)
        for tmp in range(b-k+1,b+1):
            ans.append(tmp)
    else:
        for tmp in range(a, b+1):
            ans.append(tmp)
    ans.sort()
    for tmp in ans:
        print(tmp)
Buggy python submission (verdict: Runtime Error):
<?php
$n = intval(trim(fgets(STDIN)));
$ans = floor($n/3);
print "$ans\n";
?>

Fixed submission:
# -*- coding:utf-8 -*-
import math
if __name__ == "__main__":
    n = int(input())
    print(math.floor(n/3))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
import math
n, h = map(int, input().split())
l = []
ans = 0

for tmp in range(n):
    a, b = map(int, input().split())
    l.append((a,b))

factor = sorted(l, key=lambda tmp:tmp[1])

while h > 0:
    max_a = max(l, key=lambda tmp:tmp[0])
    if len(factor) != 0:
        max_b = factor[-1]
    else:
        max_b = (-1,-1)
    if max_a[0] < max_b[1] and max_b != (-1,-1):
        h -= max_b[1]
        factor.pop()
        ans += 1
    else:
        ans += math.ceil(h/max_a[0])
        h -= max_a[0]*math.ceil(h/max_a[0])
print(ans)

Fixed submission:
# -*- coding:utf-8 -*-
import math
n, h = map(int, input().split())
l = []
ans = 0

for tmp in range(n):
    a, b = map(int, input().split())
    l.append((a,b))

factor = sorted(l, key=lambda tmp:tmp[1])
max_a = max(l, key=lambda tmp:tmp[0])
while h > 0:
    if len(factor) != 0:
        max_b = factor[-1]
    else:
        max_b = (-1,-1)
    if max_a[0] < max_b[1]:
        h -= max_b[1]
        factor.pop()
        ans += 1
    else:
        ans += math.ceil(h/max_a[0])
        h -= max_a[0]*math.ceil(h/max_a[0])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
def isPrime(num):
    a = 2
    if num == 1:
        return False

    while num >= a*a:
        if num%a == 0:
            return False
        a += 1

    return True

if __name__ == '__main__':
    q = int(input())
    a = []
    b = {}
    minNum, maxNum = (float('inf'), float('-inf'))
    for tmp in range(q):
        l, r = map(int, input().split())
        minNum = min(minNum, l)
        maxNum = max(maxNum, r)
        a.append((l,r))

    for tmp in range(minNum, maxNum+1):
        factor = (tmp+1)/2
        if isPrime(tmp) and factor == int(factor) and isPrime(factor):
            b[tmp] = 1
        else:
            b[tmp] = 0

    for tmp in a:
        ans = 0
        for tmp2 in range(tmp[0], tmp[1]+1):
            if b[tmp2] == 1:
                ans += 1
        print(ans)

Fixed submission:
# -*- coding:utf-8 -*-
def isPrime(num):
    a = 2
    if num == 1:
        return False

    while num >= a*a:
        if num%a == 0:
            return False
        a += 1

    return True

if __name__ == '__main__':
    q = int(input())
    a = []
    b = {}
    c = []
    for tmp in range(q):
        l, r = map(int, input().split())
        a.append((l,r))

    for tmp in range(1, (10**5)+1):
        factor = (tmp+1)/2
        if isPrime(tmp) and factor == int(factor) and isPrime(factor):
            b[tmp] = 1
        else:
            b[tmp] = 0
    
    c.append(b[1])
    for tmp in range(2,(10**5)+1):
        if b[tmp]:
            c.append(c[len(c)-1]+1)
        else:
            c.append(c[len(c)-1])

    for tmp in a:
        threshold = tmp[0]-2
        if threshold < 0:
            print(c[tmp[1]-1])
        else:
            print(c[tmp[1]-1]-c[threshold])