Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a != 1 and b != 1:
	print(1)
elif a != 2 and b != 2:
	print(2)
elif a != 3 and b != :
	print(3)


Fixed submission:
a = int(input())
b = int(input())
list = [1, 2, 3]

list.remove(a)
list.remove(b)
print(list[0])

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

if a != 1 and b != 1:
	print(1)
elif a != 2 and b != 2:
	print(2)
elif a != 3 and b != :
	print(3)


Fixed submission:
a = int(input())
b = int(input())
list = [1, 2, 3]

list.remove(a)
list.remove(b)
print(list[0])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

cnt = 0
for i in range(1000):
	sec = str('%03d' % i)
	if sec[0] in s and sec[1] in s and sec[2] in s:
		nex = 0
		for j in range(n):
			if nex == 0 and s[j] == sec[0]:
				nex += 1
			elif nex == 1 and s[j] == sec[1]:
				nex += 1
			elif nex == 2 and s[j] == sec[2]:
				cnt += 1
				break
print(cnt)



Fixed submission:
n = int(input())
s = input()

cnt = 0
for i in range(1000):
	sec = str('%03d' % i)
	if sec[0] in s and sec[1] in s and sec[2] in s:
		nex = 0
		for j in range(n):
			if nex == 0 and s[j] == sec[0]:
				nex += 1
			elif nex == 1 and s[j] == sec[1]:
				nex += 1
			elif nex == 2 and s[j] == sec[2]:
				cnt += 1
				break
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

cnt = 0
for i in range(1000):
	sec = str(i).zfill(3)
	nex = 0
	for j in range(n):
		if nex == 0 and s[j] == sec[0]:
			nex += 1
		elif nex == 1 and s[j] == sec[1]:
			nex += 1
		elif nex == 2 and s[j] == sec[2]:
			cnt += 1
			break
print(cnt)


Fixed submission:
n = int(input())
s = input()

cnt = 0
for i in range(1000):
	sec = str('%03d' % i)
	if sec[0] in s and sec[1] in s and sec[2] in s:
		nex = 0
		for j in range(n):
			if nex == 0 and s[j] == sec[0]:
				nex += 1
			elif nex == 1 and s[j] == sec[1]:
				nex += 1
			elif nex == 2 and s[j] == sec[2]:
				cnt += 1
				break
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

cnt = 0
for i in range(1000):
	sec = str('%03d' % i)
	nex = 0
	for j in range(n):
		if nex == 0 and s[j] == sec[0]:
			nex += 1
		elif nex == 1 and s[j] == sec[1]:
			nex += 1
		elif nex == 2 and s[j] == sec[2]:
			cnt += 1
			break
print(cnt)


Fixed submission:
n = int(input())
s = input()

cnt = 0
for i in range(1000):
	sec = str('%03d' % i)
	if sec[0] in s and sec[1] in s and sec[2] in s:
		nex = 0
		for j in range(n):
			if nex == 0 and s[j] == sec[0]:
				nex += 1
			elif nex == 1 and s[j] == sec[1]:
				nex += 1
			elif nex == 2 and s[j] == sec[2]:
				cnt += 1
				break
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
xy = []
for i in range(n):
	xy.append(list(map(int, input().split())))

a = []
num = [i for i in range(n)]
num2 = num.reverse()
m = "".join(map(str, num))
for i in range(int(m)+1):
	s = []
	for l in range(len(str(i))):
		s.append(str(i)[l])
	ii = ['0' for j in range(n-len(str(i)))] + s
	for l in range(len(ii)):
		ii[l] = int(ii[l])
	if set(ii) == set(num):
		a.append(ii)

dt = []
for i in range(len(a)):
	d = []
	for j in range(n-1):
		d.append(((xy[int(a[i][j])][0]-xy[int(a[i][j+1])][0])**2+(xy[int(a[i][j])][1]-xy[int(a[i][j+1])][1])**2)**(1/2))
	dt.append(sum(d))
print(sum(dt)/len(dt))

Fixed submission:
import math
n = int(input())
xy = []
for i in range(n):
	xy.append(list(map(int, input().split())))
d = []
for i in range(n-1):
	for j in range(i, n):
		d.append(((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**(1/2))
print(2*sum(d)/n)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

cntm = 0
for j in range(N-1):
	cnt = 0
	for i in range(j, N-1):
		if H[i] >= H[i+1]:
			cnt += 1
		else:
			break
	if cntm < cnt:
		cntm = cnt

print(cntm)


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

cntm = 0
cnt = 0
for i in range(N-1):
	if H[i] >= H[i+1]:
		cnt += 1
	else:
		if cntm < cnt:
			cntm = cnt
		cnt = 0

if cntm < cnt:
	cntm = cnt
print(cntm)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []

to = 0
for i in range(N):
	str = input()
	s.append(sorted(str))
	cnt = s.count(s[i])
	if cnt > 1:
		to += cnt-1

print(to)


Fixed submission:
N = int(input())
s = {}

to = 0
for i in range(N):
	st = input()
	st = str(sorted(st))
	if i == 0 or not st in s:
		s[st] = 1
	elif st in s:
		cnt = s[st]
		to += cnt
		s[st] = cnt + 1

print(to)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

for i in range(1, N):
	if H[N-i-1] > H[N-i]:
		H[N-i-1] -= 1
	
for i in range(N-1):
	if H[i] > H[i+1]:
		print("No")
		exit(1)

print("Yes")


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

for i in range(1, N):
	if H[N-i-1] > H[N-i]:
		H[N-i-1] -= 1
	
for i in range(N-1):
	if H[i] > H[i+1]:
		print("No")
		exit(0)

print("Yes")

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

for i in range(N-1):
	if H[i] > H[i+1]:
		H[i] -= 1
	
for i in range(N-1):
	if H[i] > H[i+1]:
		print("No")
		exit(1)

print("Yes")


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

for i in range(1, N):
	if H[N-i-1] > H[N-i]:
		H[N-i-1] -= 1
	
for i in range(N-1):
	if H[i] > H[i+1]:
		print("No")
		exit(0)

print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))

for i in range(N):
	t = A[i]
	A[i] = 0
	print(max(A))
	A[i] = t



Fixed submission:
N = int(input())
A = []
M = 0
p = 0
for i in range(N):
	t = int(input())
	A.append(t)
	if M < t:
		M = t
		p = i

A[p] = 0
sec = max(A)

for i in range(N):
	if i == p:
		print(sec)
	else:
		print(M)
Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())
CD = int((C*D)/math.gcd(C, D))

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))


Fixed submission:
import fractions
A, B, C, D = map(int, input().split())
CD = int((C*D)/fractions.gcd(C, D))

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))

Buggy python submission (verdict: Runtime Error):
import fanctions
A, B, C, D = map(int, input().split())
CD = C*D/fanctions.gcd(C, D)

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))


Fixed submission:
import fractions
A, B, C, D = map(int, input().split())
CD = int((C*D)/fractions.gcd(C, D))

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))

Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())
CD = C*D/math.gcd(C, D)

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))


Fixed submission:
import fractions
A, B, C, D = map(int, input().split())
CD = int((C*D)/fractions.gcd(C, D))

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))
Buggy python submission (verdict: Time Limit Exceeded):
import math

def move(n):
	twonum = n // 2
	com = 0
	for i in range(twonum + 1):
		up = n - i
		com += math.factorial(up) // (math.factorial(up - i) * math.factorial(i))
	return com

N, M = map(int, input().split())
a = []
a.append(0)
for i in range(M):
	a.append(int(input()))
a.append(N+1)

s = 1
for i in range(M+1):
	step = a[i+1] - a[i] - 1
	if step > 1000000007:
		step = step % 1000000007
	m = move(step)
	s = s * m
	a[i+1] += 1

print(s % 1000000007)


Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(M):
	a.append(int(input()))
a.append(-1)

m = []
for i in range(N):
	if i == a[0] - 1:
		del a[0]
		m.append(0)
	elif i == 0:
		m.append(1)
	elif i == 1:
		m.append(m[0]+1)
	else:
		m.append(m[i-1]+m[i-2])

print(m[N-1] % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
import math

def move(n):
	twonum = n // 2
	com = 0
	for i in range(twonum + 1):
		up = n - i
		com += math.factorial(up) // (math.factorial(up - i) * math.factorial(i))
	return com

N, M = map(int, input().split())
a = []
a.append(0)
for i in range(M):
	a.append(int(input()))
a.append(N+1)

s = 1
for i in range(M+1):
	step = a[i+1] - a[i] - 1
	m = move(step)
	s = s * m
	a[i+1] += 1

print(s % 1000000007)


Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(M):
	a.append(int(input()))
a.append(-1)

m = []
for i in range(N):
	if i == a[0] - 1:
		del a[0]
		m.append(0)
	elif i == 0:
		m.append(1)
	elif i == 1:
		m.append(m[0]+1)
	else:
		m.append(m[i-1]+m[i-2])

print(m[N-1] % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ma = 0
for i in range(2**n):
	a = bin(i)
	if len(a) < n+2:
		b = "0" * (n+2-len(a))
		a = a[:2] + b + a[2:]
	get = 0
	pay = 0
	for j in range(n):
		if a[j+2] == '1':
			get += v[j]
			pay += c[j]
	if ma < (get - pay):
		ma = (get - pay)

print(ma)


Fixed submission:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ma = 0
for i in range(2**n):
	a = bin(i)
	if len(a) < n+2:
		b = "0" * (n+2-len(a))
		a = a[:2] + b + a[2:]
	get = 0
	pay = 0
	for j in range(n):
		if a[j+2] == '1':
			get += v[j]
			pay += c[j]
	if ma < (get - pay):
		ma = (get - pay)

print(ma)
Buggy python submission (verdict: Runtime Error):
xyh = []
n = int(input())
for i in range(n):
	x, y, h = map(int, input().split())
	if h != 0:
		xyh.append([x, y, h])

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		h = []
		for k in range(n):
			h.append(xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy))
		if len(h) == 1:
			lst = [cx, cy, h[k]]
			lst = [str(i) for i in lst]
			print(" ".join(lst))
			exit(0)
		for k in range(len(h)-1):
			if h[k] != h[k+1]:
				break
			if k == len(h)-2:
				lst = [cx, cy, h[k]]
				lst = [str(i) for i in lst]
				print(" ".join(lst))
				exit(0)


Fixed submission:
xyh = []
n = int(input())
for i in range(n):
	x, y, h = map(int, input().split())
	xyh.append([x, y, h])

for cx in range(101):
	for cy in range(101):
		h = 0
		judge = 1
		for k in range(n):
			if xyh[k][2] > 0:
				h = xyh[k][2] + abs(cx-xyh[k][0]) + abs(cy-xyh[k][1])
				break
		for k in range(n):
			if max(h - abs(cx-xyh[k][0]) - abs(cy-xyh[k][1]), 0) != xyh[k][2]:
				judge = 0
				break
		if judge:
			print(cx, cy, h)
			exit(0)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=N
a=a*(N-1)/2
b=M*(M-1)/2



print(int(a+b))


Fixed submission:
S=input()
N=len(S)

a=S[0:(int((N-1)/2))]
b=S[(int((N+3)/2)-1):(N)]

if a==b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,M = map(int, input().split())



a=input().split()
b=input().split()
m=[]
for i in range(M):
    m.append(input().split())

counta=0
countb=0
nummin=int(a[0])+int(b[0])
for i in m:

    x=int(i[0])-1
    y=int(i[1])-1
    c=int(i[2])
    num=int(a[x])+int(b[y])-c

    if num<nummin:
        nummin=num

for i in a:
    i=int(i)
    for j in b:
        j=int(j)
        if (i+j)<nummin:
            nummin=i+j
print(nummin)


Fixed submission:
A,B,M = map(int, input().split())



a=list(map(int,input().split()))
b=list(map(int,input().split()))
m=[]
for i in range(M):
    m.append(input().split())

counta=0
countb=0
nummin=int(a[0])+int(b[0])
for i in m:
    
    x=int(i[0])-1
    y=int(i[1])-1
    c=int(i[2])
    num=a[x]+b[y]-c

    if num<nummin:
        nummin=num
if min(a)+min(b)<nummin:
    nummin=min(a)+min(b)

print(nummin)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,M = map(int, input().split())



a=input().split()
b=input().split()
m=[]
for i in range(M):
    m.append(input().split())

counta=0
countb=0
nummin=int(a[0])+int(b[0])
for i in m:

    x=int(i[0])-1
    y=int(i[1])-1
    c=int(i[2])
    num=int(a[x])+int(b[y])-c

    if num<nummin:
        nummin=num

for i in a:
    i=int(i)
    for j in b:
        j=int(j)
        if (i+j)<nummin:
            nummin=i+j
print(nummin)


Fixed submission:
A,B,M = map(int, input().split())



a=list(map(int,input().split()))
b=list(map(int,input().split()))
m=[]
for i in range(M):
    m.append(input().split())

counta=0
countb=0
nummin=int(a[0])+int(b[0])
for i in m:
    
    x=int(i[0])-1
    y=int(i[1])-1
    c=int(i[2])
    num=a[x]+b[y]-c

    if num<nummin:
        nummin=num
if min(a)+min(b)<nummin:
    nummin=min(a)+min(b)

print(nummin)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())


A = list(map(int, input().split()))


count=0
if N>=M:
    for i in range(N-M):
        x1=np.argmin(A)
        x1=A.pop(x1)
        count+=x1
    print(count)



else:
    print(0)


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


A = list(map(int, input().split()))
A.sort()

count=0
if N>=M:
    for i in range(N-M):
        count+=A[i]
    print(count)



else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
count=0
flag=True

A = list(map(int, input().split()))



if N>=M:
    for i in range(M):
        x1=np.argmax(A)
        x1=A.pop(x1)


    print(sum(A))
else:
    print(0)


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


A = list(map(int, input().split()))
A.sort()

count=0
if N>=M:
    for i in range(N-M):
        count+=A[i]
    print(count)



else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
x=list(map(int,input().split()))

counter=0
flag=True

for i in range(N):
    a=x[i]
    for j in range(i+1):
        if flag==False:
            continue
        if a>x[j] and flag:
            counter+=1
            flag=False


    flag=True
print(N-counter)


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

counter=0
flag=True
#最小値
a=x[0]
for i in range(N):

    if a>x[i] :
        a=x[i]
    if a<x[i]:
        counter+=1

print(N-counter)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
x=list(map(int,input().split()))

counter=0
flag=True

for i in range(N):
    a=x[i]
    for j in range(i+1):
        if flag==False:
            continue
        if a>x[j] and flag:
            counter+=1
            flag=False


    flag=True
print(N-counter)


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

counter=0
flag=True
#最小値
a=x[0]
for i in range(N):

    if a>x[i] :
        a=x[i]
    if a<x[i]:
        counter+=1

print(N-counter)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
x=list(map(int,input().split()))

counter=0
flag=True

for i in range(N):
    for j in range(i+1):

        if x[i]>x[j] and flag:
            counter+=1
            flag=False


    flag=True
print(N-counter)


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

counter=0
flag=True
#最小値
a=x[0]
for i in range(N):

    if a>x[i] :
        a=x[i]
    if a<x[i]:
        counter+=1

print(N-counter)
Buggy python submission (verdict: Runtime Error):
P,Q,R=map(int,input().split())
result=0
min1=100
min2=100

if min1>P:
    min1=P
    flag="P"
if min1>Q:
    min1=Q
    flag="Q"
if min1>R:
    min1=R
    flag="R"
if(flag!="P"):
    if min2>P:
        min2=P
if(flag!="Q"):
    if min2>Q:
        min2=Q
if(flag!="R"):
    if min1>R:
        min2=R
print(min1+min2)


Fixed submission:
P,Q,R=map(int,input().split())

min1=P
min2=Q

min1=101
min2=101





Z1=P+Q
Z2=Q+R
Z3=P+R
Z4=Q+R
Z5=R+P
Z6=Q+R

min1=Z1
if(min1>Z2):
    min1=Z2
if(min1>Z3):
    min1=Z3
print(min1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
K=int(input())
s=S[K]

X=[]*N

for i in S:

    if i==s:
        X.append(i)
    else:
        X.append("*")

Y="".join(X)
print(Y)


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

X=[]*N

for i in S:

    if i==s:
        X.append(i)
    else:
        X.append("*")

Y="".join(X)
print(Y)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from itertools import product

N, M = map(int, input().split())
S = np.zeros((M, N))  # (M, N), switch

for i in range(M):
    k, *s = map(int, input().split())
    s = [x - 1 for x in s]
    S[i, s] = 1
p = np.array(list(map(int, input().split())), dtype=np.int)

cnt = 0
for i in product([0, 1], repeat=N):
    a = np.array(i, dtype=np.int)  # N,
    b = (np.dot(S, a) % 2).astype(np.int)
    if np.all(b == p):
        cnt += 1
print(cnt)

Fixed submission:
import numpy as np
from itertools import product

N, M = map(int, input().split())
S = np.zeros((M, N))  # (M, N), switch

for i in range(M):
    k, *s = map(int, input().split())
    s = [x - 1 for x in s]
    S[i, s] = 1
p = np.array(list(map(int, input().split())), dtype=np.int)

cnt = 0
for i in product([0, 1], repeat=N):
    a = np.array(i, dtype=np.int)  # N,
    b = (np.dot(S, a) % 2).astype(np.int)
    if np.all(b == p):
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ans = set(range(1, N+1))

for i in range(M):
    l, r = map(int, input().split())
    ans &= set(range(l, r+1))

print(len(ans))

Fixed submission:
N, M = map(int, input().split())
ans = set(range(1, N+1))
l_max = 1
r_min = N

for i in range(M):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)

print(max(0, r_min - l_max + 1))
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

count = 0
for i in range(N // R + 1):
    tmp = N - i * R
    for j in range(N // G + 1):
        tmp2 = tmp - j * G
        if tmp2 < 0:
            continue
        if tmp2 % B == 0:
            count += 1

print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

count = 0
tmp1 = N + R
for i in range(N // R + 1):
    tmp1 -= R
    tmp2 = tmp1 + G
    for j in range(N // G + 1):
        tmp2 -= G
        if tmp2 < 0:
            continue
        if tmp2 % B == 0:
            count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

count = 0
for i in range(N // R + 1):
    for j in range(N // G + 1):
        tmp = N - i * R - j * G
        if tmp < 0:
            continue
        if tmp % B == 0:
            count += 1

print(count)

Fixed submission:
R, G, B, N = map(int, input().split())

count = 0
tmp1 = N + R
for i in range(N // R + 1):
    tmp1 -= R
    tmp2 = tmp1 + G
    for j in range(N // G + 1):
        tmp2 -= G
        if tmp2 < 0:
            continue
        if tmp2 % B == 0:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

l = [a, b, c, d, e]
d = list()

for i, x in enumerate(l[:-1]):
    l2 = l[i+1:]
    for y in l2:
        d.append(y-x)

if max(d) <= k:
    print('Yay!')
else:
    print(':(')

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


l = [A, B, C, D, E]
l2 = list()

# check min 1 keta

m = -1

for x in l:
    t = int(x) % 10
    if t == 0:
        l2.append(int(x))
    else:
        l2.append((int(x) + 10) // 10 * 10)

l3 = [int(x) % 10 for x in l]
l3 = [x for x in l3 if x != 0]

if len(l3) == 0:
    print(sum(l2))
else:
    print(sum(l2) - 10 + min(l3))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

t = 0
a, b, c, d, e = 0, 0, 0, 0, 0
n = N

while(True):
    t += 1
    # calc minus
    x1 = A if n > A else n
    x2 = B if a > B else a
    x3 = C if b > C else b
    x4 = D if c > D else c
    x5 = E if d > E else d

    n -= x1
    a -= x2
    b -= x3
    c -= x4
    d -= x5

    # calc add
    a += x1
    b += x2
    c += x3
    d += x4
    e += x5

    if e >= N:
        break

print(t)


Fixed submission:
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

t = 0
a, b, c, d, e = 0, 0, 0, 0, 0
n = N

#while(True):
#    t += 1
#    # calc minus
#    x1 = A if n > A else n
#    x2 = B if a > B else a
#    x3 = C if b > C else b
#    x4 = D if c > D else c
#    x5 = E if d > E else d
#
#    n -= x1
#    a -= x2
#    b -= x3
#    c -= x4
#    d -= x5
#
#    # calc add
#    a += x1
#    b += x2
#    c += x3
#    d += x4
#    e += x5
#
#    if e >= N:
#        break
# print(t)

print(math.ceil(N / min([A, B, C, D, E])) + 4)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

t = 0
a, b, c, d, e = 0, 0, 0, 0, 0
n = N

while(True):
    t += 1
    # calc minus
    x1 = A if n > A else n
    x2 = B if a > B else a
    x3 = C if b > C else b
    x4 = D if c > D else c
    x5 = E if d > E else d

    n -= x1
    a -= x2
    b -= x3
    c -= x4
    d -= x5

    # calc add
    a += x1
    b += x2
    c += x3
    d += x4
    e += x5

    if e >= N:
        break

print(t)

Fixed submission:
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

t = 0
a, b, c, d, e = 0, 0, 0, 0, 0
n = N

#while(True):
#    t += 1
#    # calc minus
#    x1 = A if n > A else n
#    x2 = B if a > B else a
#    x3 = C if b > C else b
#    x4 = D if c > D else c
#    x5 = E if d > E else d
#
#    n -= x1
#    a -= x2
#    b -= x3
#    c -= x4
#    d -= x5
#
#    # calc add
#    a += x1
#    b += x2
#    c += x3
#    d += x4
#    e += x5
#
#    if e >= N:
#        break
# print(t)

print(math.ceil(N / min([A, B, C, D, E])) + 4)
Buggy python submission (verdict: Runtime Error):
S = input()

ans = list()
ans_tmp = list()

x = {'A', 'G', 'C', 'T'}

for s in S:
  if s in x:
    ans_tmp.append(s)
  else:
    if len(ans_tmp) > len(ans):
      ans = ans_tmp.copy()
      ans_tmp = list()

print(len(ans))

Fixed submission:
S = input()

ans = 0
ans_tmp = 0

x = {'A', 'G', 'C', 'T'}

for s in S:
  if s in x:
      ans_tmp += 1
  else:
    ans = max(ans_tmp, ans)
    ans_tmp = 0
ans = max(ans_tmp, ans)

print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()

ans = list()
ans_tmp = list()

x = {'A', 'G', 'C', 'T'}

for s in S:
  if s in x:
    ans_tmp.append(s)
  else:
    if len(ane_tmp) > len(ans):
      ans = ans_tmp
      ans_tmp = list()

print(len(ans))

Fixed submission:
S = input()

ans = 0
ans_tmp = 0

x = {'A', 'G', 'C', 'T'}

for s in S:
  if s in x:
      ans_tmp += 1
  else:
    ans = max(ans_tmp, ans)
    ans_tmp = 0
ans = max(ans_tmp, ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
L, R = [None] * N, [None] * N

S = input()

for i in range(Q):
    L[i], R[i] = map(int, input().split())


counts = [0] * N
count_tmp = 0

for i in range(1, N):
    if S[i-1] == 'A' and S[i] == 'C':
        count_tmp += 1
    counts[i] = count_tmp

# print(counts)

for i in range(Q):
    print(counts[R[i] - 1] - counts[L[i] - 1])

Fixed submission:
N, Q = map(int, input().split())
L, R = [None] * Q, [None] * Q

S = input()

for i in range(Q):
    L[i], R[i] = map(int, input().split())

counts = [0] * N
count_tmp = 0

for i in range(1, N):
    if S[i-1] == 'A' and S[i] == 'C':
        count_tmp += 1
    counts[i] = count_tmp

# print(counts)

for i in range(Q):
    print(counts[R[i] - 1] - counts[L[i] - 1])