Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
k = int(input())
ans = 0
for a in range(1,k+1):
	for b in range(1,k+1):
		for c in range(1,k+1):
			ans += gcd(gcd(a,b),c)

print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for a in range(1,k+1):
	for b in range(1,k+1):
		for c in range(1,k+1):
			ans += gcd(gcd(a,b),c)

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

count = 0
for i in range(n-2):
	lis = []
	for j in range(i+1,n-1):
		lis = [s[i]]
		if not s[j] in lis :
			for k in range(j+1,n):
				lis = [s[i],s[j]]
				if not s[k] in lis :
					if j-i != k-j:
						count += 1

print(count)

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

r = s.count("R")
g = s.count("G")
b = s.count("B")


count = 0

for i in range(n):
	for j in range(i+1,n):
		k = j*2-i
		if 0 <= k < n:
			if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
				count += 1
print(r*g*b - count)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n,k = map(int,input().split())

def process(a,b):
	flag = True
	while flag:
		a,b = max(a,b),min(a,b)
		a = a%b
		if a == 0:
			flag = False

	for i in range(1000):
		a = min(a,abs(a-b))
	return a
if n == 0:
	print(0)
elif k == 1 or n == 1:
	print(0)
else:
	print(process(n,k))




Fixed submission:
x,y,z = map(int,input().split())

x,y = y,x
x,z = z,x
print(x,y,z)

Buggy python submission (verdict: Runtime Error):
x,y,z = map(int,input().split())

a,b = b,a
a,c = c,a
print(a,b,c)

Fixed submission:
x,y,z = map(int,input().split())

x,y = y,x
x,z = z,x
print(x,y,z)
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
a,b,c = map(int,input().split())

a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
ans = a**0.5+b**0.5-c**0.5

if ans <0:
	print("Yes")
else:
	print("No")



Fixed submission:
from decimal import Decimal
from math import sqrt
a,b,c = map(int,input().split())

a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
ans = a.sqrt()+b.sqrt()-c.sqrt()
if ans <0:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Time Limit Exceeded):

n,a,b = map(int,input().split())

mod = 10**9+7

def comb(n,r):
	u = 1
	d = 1
	for i in range(n-r+1,n+1):
		u *= i%mod

	for i in range(1,r+1):
		d *= i%mod
	D = pow(d,mod-2,mod)

	return u*D%mod

ans = pow(2,n,mod)-1-comb(n,a)-comb(n,b)

print(ans%mod)

Fixed submission:
import itertools
import math
n,a,b = map(int,input().split())

mod = 10**9+7

def comb(n, r):
    ans = 1
    for i in range(r):
        ans = ans * (n-i) * pow(i+1, mod-2, mod) % mod
    return ans

print((pow(2, n, mod)-1-comb(n,a)-comb(n,b)) % mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

b = len(set(a))
if len(a)== len(b):
	print('YES')
else:
	print('NO')

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

b = list(set(a))
if len(a)== len(b):
	print('YES')
else:
	print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
p = list(map(int,input().split()))

ave = [(p[i]+1)/2 for i in range(N)]

ans = 0

for i in range(N-K+1):
	ans = max(ans,sum(ave[i:K+i]))
	#print(ave[i:K+i])
print(ans)


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

ave = [(p[i]+1)/2 for i in range(N)]

ans = 0
cumlative = []
for i in range(N):
	if i == 0:
		cumlative.append(ave[i])
	else:
		cumlative.append(cumlative[i-1]+ave[i])
	#print(ave[i:K+i])
if N == K:
	ans = cumlative[N-1]
else:
	for i in range(N-K):
		ans = max(cumlative[i+K] - cumlative[i],ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
N,M = map(int,input().split())
if M == 0:
	print('0 0')
	sys.exit()


p = [0]*M#問題の番号
s = [0]*M#結果 AC,WA

for i in range(M):
	p[i],s[i] = input().split()

cor_count = 0
pen_count = 0
AC_list = []

for i in range(M):
	if not p[i] in AC_list:
		if s[i] == 'AC':
			AC_list.append(p[i])
		else:
			pen_count += 1

#print(AC_list)
cor_count = len(set(AC_list))
if M != 0:
	print(cor_count,pen_count)




Fixed submission:

C = input()



print(chr(ord(C)+1))
Buggy python submission (verdict: Runtime Error):
from math import gcd

a,b = map(int,input().split())
print(a*b//gcd(a,b))

Fixed submission:
A,B = map(int,input().split())
c = [0 for _ in range(1+max(A,B))]

ans = 1
#AとBで割り切れるような自然数を求める
# 2 <= ans <= A*B
def prime(n):
	res = [0 for _ in range(n+1)]
	for i in range(2,int(n**0.5)+1):
		while n%i == 0:
			res[i] += 1
			n = n//i
	if n != 1:
		res[n] = 1
	return res
a = prime(A)
b = prime(B)
for i in range(1+max(A,B)):
	if len(a)<=i:
		c[i] = b[i]
	elif len(b)<=i:
		c[i] = a[i]
	else:
		c[i] = max(a[i],b[i])


for i in range(1,len(c)):
	ans *= i**c[i]

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd

a,b = map(int,input().split())
print(a*b//gcd(a,b))

Fixed submission:
A,B = map(int,input().split())
c = [0 for _ in range(1+max(A,B))]

ans = 1
#AとBで割り切れるような自然数を求める
# 2 <= ans <= A*B
def prime(n):
	res = [0 for _ in range(n+1)]
	for i in range(2,int(n**0.5)+1):
		while n%i == 0:
			res[i] += 1
			n = n//i
	if n != 1:
		res[n] = 1
	return res
a = prime(A)
b = prime(B)
for i in range(1+max(A,B)):
	if len(a)<=i:
		c[i] = b[i]
	elif len(b)<=i:
		c[i] = a[i]
	else:
		c[i] = max(a[i],b[i])


for i in range(1,len(c)):
	ans *= i**c[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = []
for i in range(N):
	if i**2 > N:
		left = (i-1)
		break

for i in reversed(range(N)):
	if i**2 <N:
		right = (i-1)
		break
print(left,right)
left,right=right,left

for i in range(left**2,right**2+1):
	if N%i==0:
		ans.append(i+N//i-2)

print(min(ans))

Fixed submission:
N = int(input())
a,b = 0,0
t = 10**13
for i in range(1,int(N**0.5)+1):
	if N%i == 0:
		if t >= N//i + i:
			t = N//i + i
			


print(t-2)

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

a = int(math.sqrt(n))
for j in range(a,n):
	if n%j == 0 and n/j >0:
		print(int(n/j+j-2))
		break
	


Fixed submission:
N = int(input())
a,b = 0,0
t = 10**13
for i in range(1,int(N**0.5)+1):
	if N%i == 0:
		if t >= N//i + i:
			t = N//i + i
			


print(t-2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = input().split()

l = list(l)
for i in range(n):
	l[i] = int(l[i])
l.sort()
count = 0
#a<b+c, a>b-c, a>c-b
for a in range(n):
	for b in range(a+1,n):
		for c in range(b+1,n):
			if l[a]<l[b]+l[c]:
				if l[b]<l[c]+l[a]:
					if l[c]<l[a]+l[b]:
						count += 1
					else:
						break

print(count)

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()

ans = 0

#a<b+c, a>b-c, a>c-b
for a in range(n-2):
	for b in range(a+1,n-1):
		index = bisect.bisect_left(l,l[a]+l[b])
		ans += index - (b+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = input().split()

l = list(l)
for i in range(n):
	l[i] = int(l[i])
l.sort()
count = 0
#a<b+c, a>b-c, a>c-b
for a in range(n):
	for b in range(a+1,n):
		for c in range(b+1,n):
			if l[a]<l[b]+l[c] and l[b]<l[c]+l[a] and l[c]<l[a]+l[b]:
				count += 1
			else:
				break

print(count)

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()

ans = 0

#a<b+c, a>b-c, a>c-b
for a in range(n-2):
	for b in range(a+1,n-1):
		index = bisect.bisect_left(l,l[a]+l[b])
		ans += index - (b+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = input().split()

l = list(l)
for i in range(n):
	l[i] = int(l[i])
count = 0
#a<b+c, a>b-c, a>c-b
for a in range(n):
	for b in range(a+1,n):
		for c in range(b+1,n):
			if l[a]<l[b]+l[c] and l[b]<l[c]+l[a] and l[c]<l[a]+l[b]:
				count += 1


print(count)

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()

ans = 0

#a<b+c, a>b-c, a>c-b
for a in range(n-2):
	for b in range(a+1,n-1):
		index = bisect.bisect_left(l,l[a]+l[b])
		ans += index - (b+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = input().split()

l = list(l)
for i in range(n):
	l[i] = int(l[i])

count = 0
memo =[0,0,0]*100
#a<b+c, a>b-c, a>c-b
for a in range(n):
	for b in range(a+1,n):
		for c in range(b+1,n):
			if l[a]<l[b]+l[c] and l[b]<l[c]+l[a] and l[c]<l[a]+l[b]:
				count += 1
				memo += a,b,c


print(count)

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()

ans = 0

#a<b+c, a>b-c, a>c-b
for a in range(n-2):
	for b in range(a+1,n-1):
		index = bisect.bisect_left(l,l[a]+l[b])
		ans += index - (b+1)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
a = input().split()
s = ''

s = np.argsort(a)

for i in range(n):
	s[i] += 1 
s.strip("[")
s.strip("]")


print(s)


Fixed submission:
n = int(input())
ans = []
A = list(map(int,input().split()))
A2 = [[0,i+1] for i in range(n)]

for i in range(n):
	A2[i][0] = A[i]
#print(A2)
A2 = sorted(A2,key = lambda x:x[0])

for i in range(n):
	ans.append(A2[i][1])
print(*ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input().split()
s = ''
iList = [[ 0 for i in range(n)] for i in range(n)]


MIN = 100
#iの時にa[i]人いた
#a[i]が小さい順に並べてその時のiを順番に出力
for i in range(n):
	a[i] = int(a[i])
	iList[i][0] = a[i]
	iList[i][1] = i+1

for i in range(n):
	for j in range(n):
		if iList[i][0] < iList[j][0]:
			t = iList[i]
			iList[i] = iList[j]
			iList[j] = t

s += str(iList[0][1])
for i in range(1,n):
	s += ' '
	s += str(iList[i][1])
	


print(s)


Fixed submission:
n = int(input())
ans = []
A = list(map(int,input().split()))
A2 = [[0,i+1] for i in range(n)]

for i in range(n):
	A2[i][0] = A[i]
#print(A2)
A2 = sorted(A2,key = lambda x:x[0])

for i in range(n):
	ans.append(A2[i][1])
print(*ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input().split()
s = ''
iList = [[ 0 for i in range(n)] for i in range(n)]


MIN = 100
#iの時にa[i]人いた
#a[i]が小さい順に並べてその時のiを順番に出力
for i in range(n):
	a[i] = int(a[i])
	iList[i][0] = a[i]
	iList[i][1] = i+1
for i in range(n):
	for j in range(n):
		if iList[i][0] < iList[j][0]:
			t = iList[i]
			iList[i] = iList[j]
			iList[j] = t
for i in range(n):
	s += str(iList[i][1])
	s += ' '


print(s)


Fixed submission:
n = int(input())
ans = []
A = list(map(int,input().split()))
A2 = [[0,i+1] for i in range(n)]

for i in range(n):
	A2[i][0] = A[i]
#print(A2)
A2 = sorted(A2,key = lambda x:x[0])

for i in range(n):
	ans.append(A2[i][1])
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
correctAnswer = [0 for i in range(q)]
participant = [k for i in range(n)]


for i in range(q): # q = 正解者のかず
	correctAnswer[i] = int(input())

for correct in correctAnswer:
	for i in range(n):# n = 参加者の人数
		participant[i] -= 1 
	participant[correct-1] += 1



for i in range(n):
	if participant[i] <= 0:
		print('No')
	else:
		print('Yes')


Fixed submission:
n,k,q = map(int,input().split())
participant = [k-q for i in range(n)]


for i in range(q):# q = len.correctAnswer
	participant[int(input())-1] += 1

for i in participant :
	if i <= 0:
		print('No')
	else:
		print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
n,m = map(int,input().split())
a = list(map(int,input().split()))
SUM =0 
for i in range(m):#チケットの数
	a[np.argmax(a)] /= 2

for i in range(len(a)):
	a[i] = math.floor(a[i])
	SUM += a[i]
print(SUM)


Fixed submission:
import heapq
n,m = map(int,input().split())
a = [int(i) * (-1) for i in input().split()]

heapq.heapify(a)

for _ in range(m):
	a_min = heapq.heappop(a)
	heapq.heappush(a,(-(-a_min//2)))

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
n,m = map(int,input().split())
a = list(map(int,input().split()))

for i in range(m):#チケットの数
	a[np.argmax(a)] /= 2

for i in range(len(a)):
	a[i] = math.floor(a[i])

print(sum(a))


Fixed submission:
import heapq
n,m = map(int,input().split())
a = [int(i) * (-1) for i in input().split()]

heapq.heapify(a)

for _ in range(m):
	a_min = heapq.heappop(a)
	heapq.heappush(a,(-(-a_min//2)))

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
n,m = map(int,input().split())
a = [0]*n
a = input().split()

for i in range(n):
	a[i] = int(a[i])

for i in range(m):#チケットの数
	a[np.argmax(a)] /= 2

for i in range(len(a)):
	a[i] = math.floor(a[i])

print(sum(a))



Fixed submission:
import heapq
n,m = map(int,input().split())
a = [int(i) * (-1) for i in input().split()]

heapq.heapify(a)

for _ in range(m):
	a_min = heapq.heappop(a)
	heapq.heappush(a,(-(-a_min//2)))

print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
ans = 0


for l in range(1,n):
	for r in range(l+1,n+1):
		ans += sorted(p[l-1:r])[-2]

print(ans)


Fixed submission:

n = int(input())
p = list(map(int,input().split()))

r = list(range(n))
l = list(range(n))
I = [-1] * (n+1)

for i,P in enumerate(p):
	I[P] = i
#I[1~Nまでの数字] = 0,1,...
#index を求めている
ans  = 0

for N,index in enumerate(I[1:],1):#1からスタート
	L = index -1
	if L >= 0:
		L = l[L]

	R = index + 1
	if  R < n:
		R = r[R]

	l[R-1] = L
	r[L+1] = R
#0 <= L , R < n
	if L >= 0:
		L2 = L-1
		if L2 >= 0:
			L2 = l[L2]
		ans += N * (L-L2) * (R - index)

	if R < n:
		R2 = R+1
		if R2 < n:
			R2 = r[R2]
		ans += N * (index - L ) * (R2 - R)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
count = [0] * n
MAX = 0
for j in range(n):
	for i in range(j,n-1):
		if h[i] >= h[i+1]:
			count[j] += 1
		else:
			i = j
			break

for i in range(n):
	if MAX < count[i]:
		MAX = count[i]
	i = count[i] + 2

print(MAX)


Fixed submission:
n = int(input())
h = list(map(int,input().split()))
count = [0] * n
MAX = 0

j = 0
for i in range(j,n-1):
	if h[i] >= h[i+1]:
		count[j] += 1
	else:
		j += 1

for i in range(n):
	if MAX < count[i]:
		MAX = count[i]
	i = count[i] + 2

print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
count = [0] * n

for j in range(n):
	for i in range(j,n-1):
		if h[i] >= h[i+1]:
			count[j] += 1
		else:
			i = j
			break

print(max(count))


Fixed submission:
n = int(input())
h = list(map(int,input().split()))
count = [0] * n
MAX = 0

j = 0
for i in range(j,n-1):
	if h[i] >= h[i+1]:
		count[j] += 1
	else:
		j += 1

for i in range(n):
	if MAX < count[i]:
		MAX = count[i]
	i = count[i] + 2

print(MAX)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
count = [0] * n

for j in range(n):
	for i in range(j,n-1):
		if h[i] >= h[i+1]:
			count[j] += 1
		else:
			break

print(max(count))


Fixed submission:
n = int(input())
h = list(map(int,input().split()))
count = [0] * n
MAX = 0

j = 0
for i in range(j,n-1):
	if h[i] >= h[i+1]:
		count[j] += 1
	else:
		j += 1

for i in range(n):
	if MAX < count[i]:
		MAX = count[i]
	i = count[i] + 2

print(MAX)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []

for i in range(n):
	s.append(sorted(list(input())))

s = sorted(s)
count = 0
for i in range(n-1):
	for j in range(i+1,n):
		if s[i] == s[j]:
			count += 1
		else:
			break


print(count)



Fixed submission:


n = int(input())
s = []

def comb2(x):
	if x==0:
		return 0
	ans = x*(x-1)/2
	return ans

for i in range(n):
	s.append(sorted(list(input())))

s = sorted(s)
count = [0 for _ in range(len(s))]

x = 0

for i in range(n-1):
	if s[i] == s[i+1]:
		count[x] += 1
	else:
		count[x] += 1
		x = x + 1
	if i == n-2:
		count[x] += 1

ans = 0
#print (count)
for i in count:
	ans += comb2(i)


print(int(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))

sort_a = sorted(list(set(a)))

for i in range(n):
	if a[i] == sort_a[-1]:
		print(sort_a[-2])
	else:
		print(sort_a[-1])



Fixed submission:
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))

sort_a = sorted(a)

for i in range(n):
	if a[i] == sort_a[-1]:
		print(sort_a[-2])
	else:
		print(sort_a[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = [i%mod for i in range(l,r+1)]


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

print(ans)



Fixed submission:
import sys
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = [i%mod for i in range(l,r+1)]


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			break
			
print(ans)


Fixed submission:
import sys
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = [i%mod for i in range(l,r+1)]


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)

print(ans)


Fixed submission:
import sys
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())

mod = 2019
ans = 10000
for i in range(l,r):
	for j in range(i+1,r+1):
		ans = min(ans,(i*j)%mod)

print(ans)

Fixed submission:
import sys
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
l = list(map(int,input().split()))
d = 0
cnt = 0
for i in range(n+1):
	cnt += 1
	d += l[i]
	if x < d:
		print(cnt)
		exit()




Fixed submission:
n,x = map(int,input().split())
l = list(map(int,input().split()))
d = [0]

for i in range(n):
	d.append(d[i] + l[i])

ans  = 0
for i in range(n+1):
	if d[i] <= x:
		ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

trans = []
n = int(input())
for i in range(5):
	trans.append(int(input()))

town =[0 for _ in range(6)] 
town[0] = n

t = 0
while town[-1] != n:
	t += 1
	for i in reversed(range(5)):

		temp = min(town[i],trans[i])
		town[i] -= temp
		town[i+1] += temp
print(t)

Fixed submission:

trans = []
n = int(input())
for i in range(5):
	trans.append(int(input()))

m=min(trans)
if n%m==0:
  print(n//m+4)
else:
  print(n//m+5)
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())

s = input()
l = [0 for _ in range(q)]
r = [0 for _ in range(q)]
for i in range(q):
	l[i],r[i] = map(int,input().split())
for i in range(q):

	a = s[l[i]-1:r[i]]
	#print(a)
	count = 0
	for j in range(len(a)-1):
		if a[j:j+2] =="AC": 
			count += 1
	print(count)

Fixed submission:
n,q = map(int,input().split())

s = input()
t = [0] * (n+1)
p = []
for i in range(n):
	t[i+1] = t[i] + (1 if s[i:i+2] =='AC' else 0)

for _ in range(q):
	l,r= map(int,input().split())
	p.append(t[r-1]-t[l-1])

for i in p:
	print(i)
Buggy python submission (verdict: Runtime Error):
limit = input()



def dfs(s):
	if int(s)>limit:
		return 0

	ret = 1 if all(s.count(c)>0 for c in "753") else 0
	for c in "753":
		ret += dfs(s+c)
	return ret
print(dfs("0"))


Fixed submission:
n = int(input())

def dfs(s):
	if int(s) > n:#nより大きいならカウントしない
		#print(int(s))
		return 0

	ret = 1 if all(s.count(c) > 0 for c in '753') else 0
	#753,全てが含まれているなら1
	
	for c in '753':
		ret += dfs(s+c)
		#print(s+c)
	return ret

print(dfs('0'))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

X = sum(a)
x = list(sum(a[:i+1]) for i in range(n))
ans = min(list(abs(X-2*x[i]) for i in range(n-1)))

print(ans)

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

X = sum(a)
x =[a[0]]
for i in range(n-1):
	x.append(x[i]+a[i+1])
ans = min(list(abs(X-2*x[i]) for i in range(n-1)))

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
dist = []
a = []
b = []
c = []

for i in range(m):
	a[i], b[i], c[i] = map(int,input().split())
	dist[a[i]-1][b[i]-1] = c[i]
	dist[b[i]-1][a[i]-1] = c[i]



#nは頂点、mは辺、a、bは頂点、cはaとbの距離


for i in range(n):
	for j in range(n):
		for k in range(n):
			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

res = 0
for i in range(m):
	if c[i] > dist[a[i]-1][b[i]-1]:
		res += 1

print (res)


Fixed submission:
n,m = map(int,input().split())

dist = [[10**10 for i in range(n)]for j in range(n)]
for i in range(n):
	dist[i][i] == 0

a = [0]*m
b = [0]*m
c = [0]*m

for i in range(m):
	a[i], b[i], c[i] = map(int,input().split())
	dist[a[i]-1][b[i]-1] = c[i]
	dist[b[i]-1][a[i]-1] = c[i]


#nは頂点、mは辺、a、bは頂点、cはaとbの距離


for k in range(n):
	for i in range(n):
		for j in range(n):
			dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])


res = 0
for i in range(m):
	if c[i] > dist[a[i]-1][b[i]-1]:
		res += 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
input = sys.stdin.readline


N, M = map(int, input().split())

obvs = list(range(1,N+1,1))

obvs_height = list(map(int, input().split()))
#print(obvs)

def get_height_of_obvs(i):
    return obvs_height[i-1]

def remove_obvs_if_exist(i):
    if i in obvs:
        obvs.remove(i)

while True:
    #print(obvs)
    path = list(map(int, input().strip().split()))
    if path==[]:
        break
    if get_height_of_obvs(path[0]) == get_height_of_obvs(path[1]):
        remove_obvs_if_exist(path[0])
        remove_obvs_if_exist(path[1])

    elif get_height_of_obvs(path[0]) > get_height_of_obvs(path[1]):
        remove_obvs_if_exist(path[1])
    elif get_height_of_obvs(path[0]) < get_height_of_obvs(path[1]):
        remove_obvs_if_exist(path[0])

print(len(obvs))

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


N, M = map(int, input().split())

obvs = list(range(1,N+1,1))
obvs_height = list(map(int, input().split()))
#print(obvs)

obvs = {}
i = 1
for h in obvs_height:
    obvs[i] = h
    i += 1

obvs_remain = obvs.copy()

while True:
    path = list(map(int, input().strip().split()))
    if path==[]:
        break
    if obvs[path[0]] == obvs[path[1]]:
        obvs_remain.pop(path[0], None)
        obvs_remain.pop(path[1], None)
    elif obvs[path[0]] > obvs[path[1]]:
        obvs_remain.pop(path[1], None)
    elif obvs[path[0]] < obvs[path[1]]:
        obvs_remain.pop(path[0], None)

print(len(obvs_remain))