Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

ans = []
for i in range(N):
	a = np.argmin(A)
	ans.append(str(a+1))
	A[a] = float('INF')

print(' '.join(ans))

Fixed submission:
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

AS = [[a,idx+1] for idx,a in enumerate(A)]
AS.sort()

for a in AS:
	print(a[1], end=" ")

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

ans = []
for i in range(N):
	a = np.argmin(A)
	ans.append(str(a+1))
	A[a] = float('INF')

print(' '.join(ans))

Fixed submission:
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N = int(input())
A = [int(x) for x in input().split()]

AS = [[a,idx+1] for idx,a in enumerate(A)]
AS.sort()

for a in AS:
	print(a[1], end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
sys.setrecursionlimit(10**6)
def MAP(): return [int(s) for s in input().split()]

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = MAP()
A = MAP()

while M > 0:
	A[np.argmax(A)] = A[np.argmax(A)] // 2
	M -= 1

print(sum(A))

Fixed submission:
import sys
import heapq
sys.setrecursionlimit(10**6)
def MAP(): return [int(s) for s in input().split()]

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = MAP()
# heapq.heappop（優先度『最小』の品物をO(logN)で取得）のため入力値をマイナスに変換
A = [int(s)*-1 for s in input().split()]

# 品物のリストをheapqのオブジェクトに変換
heapq.heapify(A)

while M > 0:
	# 以下、heapq　の計算誤差を防ぐため、(1) も (2) もそれぞれ -1 をかける
	# (1) 最小値を取り出す
	discount = heapq.heappop(A)*-1
	# (2) 最小値を2で切り捨て割ったものをAに戻す
	heapq.heappush(A, discount//2*-1)
	M -= 1

print(sum(A)*-1)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10**6)
def MAP(): return [int(s) for s in input().split()]

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = MAP()
A = MAP()

while M > 0:
	A[np.argmax(A)] = A[np.argmax(A)] // 2
	M -= 1

print(sum(A))

Fixed submission:
import sys
import heapq
sys.setrecursionlimit(10**6)
def MAP(): return [int(s) for s in input().split()]

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = MAP()
# heapq.heappop（優先度『最小』の品物をO(logN)で取得）のため入力値をマイナスに変換
A = [int(s)*-1 for s in input().split()]

# 品物のリストをheapqのオブジェクトに変換
heapq.heapify(A)

while M > 0:
	# 以下、heapq　の計算誤差を防ぐため、(1) も (2) もそれぞれ -1 をかける
	# (1) 最小値を取り出す
	discount = heapq.heappop(A)*-1
	# (2) 最小値を2で切り捨て割ったものをAに戻す
	heapq.heappush(A, discount//2*-1)
	M -= 1

print(sum(A)*-1)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

n = int(input())
if n==1:
	print(0)
	sys.exit()

N = list(range(1,n))
print(np.cumsum(N)[-1])

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	M = N-1
	ans = (1+M)*M//2
	print(ans)

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
from collections import Counter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = INT()
S = [[s for s in input().strip()] for _ in range(N)]

words = []
for s in S:
	s.sort()
	words.append(s)

words.sort()

ans = []
tmp = ''
num = -1
for w in words:
	#print(tmp , w, num)
	if tmp == w:
		#print('same')
		ans[num] += 1
		#print(ans)
	else:
		#print('different')
		tmp = w
		num+=1
		ans.append(1)
		#print(ans)
		
#print(ans)

count = 0
for a in ans:
	if a != 1: count += cmb(a, 2)

print(count)

Fixed submission:
import sys
import numpy as np
from collections import Counter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = INT()
S = [[s for s in input().strip()] for _ in range(N)]

words = []
for s in S:
	s.sort()
	words.append(s)

words.sort()

ans = []
tmp = ''
num = -1
for w in words:
	#print(tmp , w, num)
	if tmp == w:
		#print('same')
		ans[num] += 1
		#print(ans)
	else:
		#print('different')
		tmp = w
		num+=1
		ans.append(1)
		#print(ans)
		
#print(ans)

count = 0
for a in ans:
	if a != 1: count += cmb(a, 2)

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()

dp = [[0] * 13 for _ in range(len(S)+1)]
dp[0][0] = 1

#print(dp)

for i in range(len(S)):
	for j in range(13):
		if S[i]=='?':
			for d in range(10):
				nj = (j*10+d)%13
				dp[i+1][nj] += dp[i][j]
		else:
			nj = (j*10+int(S[i]))%13
			dp[i+1][nj] += dp[i][j]

#print(dp)
print((dp[len(S)][5])%(10**9+7))

Fixed submission:
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()

dp = [[0] * 13 for _ in range(len(S)+1)]
dp[0][0] = 1

#print(dp)

for i in range(len(S)):
	for j in range(13):
		if S[i]=='?':
			for d in range(10):
				nj = (j*10+d)%13
				dp[i+1][nj] += dp[i][j]
		else:
			nj = (j*10+int(S[i]))%13
			dp[i+1][nj] += dp[i][j]
	for j in range(13):
		dp[i+1][j] %= (10**9+7)

#print(dp)
print(dp[len(S)][5])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in ['ios', 'win32', 'darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(x) for x in input().split()]

N = INT()
A = MAP()

R = sum(A)
# print(R)

M = [-1] * N

def solve(i):
	if i<N-1:
		if M[i] != -1:
			mi = M[i]
		else:
			mi = 2*A[i]-solve(i+1)
	else:
		mi = 2*A[i]-solve(0)
	return mi

# print(M)
M[0] = 0
s = 0
for i in range(N):
	s += solve(i)
# print(s)
M[0] += (R-s)

ans = [solve(i) for i in range(N)]
print(' '.join(map(str, ans)))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in ['ios', 'win32', 'darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(x) for x in input().split()]

def main():
	N = INT()
	A = MAP()

	R = sum(A)
	# print(R)

	def solve(i):
		if i<N-1:
			if M[i] != -1:
				mi = M[i]
			else:
				mi = 2*A[i]-solve(i+1)
				M[i] = mi
		else:
			mi = 2*A[i]-solve(0)
			M[i] = mi
		return mi

	# print(M)
	M = [-1] * N
	M[0] = 0
	s = 0
	for i in range(1, N):
		s += solve(i)
	# print(s)

	M = [-1] * N
	M[0] = (R-s)

	ans = [solve(i) for i in range(N)]
	print(' '.join(map(str, ans)))

if __name__ == "__main__":
	main()
Buggy python submission (verdict: Runtime Error):
import sys
import math
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

A, B, C, D = MAP()
# Cで割り切れる数 = B/C - A/C
c_b = B//C
c_a = A//C if A%C else A//C-1
c = c_b-c_a

d_b = B//D
d_a = A//D if A%D else A//D-1
d = d_b-d_a

E = (C*D) // (math.gcd(C,D))
#print(E)
e_b = B//E
e_a = A//E if A%E else A//E-1
e = e_b - e_a

#print(c, d, e)

print((B-A+1)-(c+d-e))

Fixed submission:
import sys
import fractions
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

A, B, C, D = MAP()
# Cで割り切れる数 = B/C - A/C
c_b = B//C
c_a = A//C if A%C else A//C-1
c = c_b-c_a

d_b = B//D
d_a = A//D if A%D else A//D-1
d = d_b-d_a

E = (C*D) // (fractions.gcd(C,D))
#print(E)
e_b = B//E
e_a = A//E if A%E else A//E-1
e = e_b - e_a

#print(c, d, e)

print((B-A+1)-(c+d-e))
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = map(int, input().split())
a = np.array([int(input()) for _ in range(M)])

dp = np.array([0 for _ in range(N+1)])
dp[0] = 1

for i in range(N+1):
	if np.any(a == i):
		continue
	for j in [1, 2]:
		if i - j >= 0 and not np.any(a == i-j):
			dp[i] += dp[i-j]
print(dp[-1]%1000000007)

Fixed submission:
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = map(int, input().split())
n = [True for _ in range(N+1)]
for _ in range(M):
	n[int(input())] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1

for i in range(N+1):
	if not n[i]:
		continue
	for j in [1, 2]:
		if i - j >= 0:
			dp[i] += dp[i-j]
print(dp[-1]%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

dp = [0 for _ in range(N+1)]
dp[0] = 1

for i in range(N+1):
	if a.count(i):
		continue
	for j in [1, 2]:
		if i - j >= 0 and not a.count(i-j):
			dp[i] += dp[i-j]
print(dp[-1]%1000000007)

Fixed submission:
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = map(int, input().split())
n = [True for _ in range(N+1)]
for _ in range(M):
	n[int(input())] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1

for i in range(N+1):
	if not n[i]:
		continue
	for j in [1, 2]:
		if i - j >= 0:
			dp[i] += dp[i-j]
print(dp[-1]%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
if sys.platform =='win32':
  sys.stdin=open('./input.txt')
input = sys.stdin.readline
def MAP(): return [int(x) for x in input().split()]

dy = [-1,0,1,0]
dx = [0,-1,0,1]

H, W = [int(s) for s in input().split()]

M = []

for i in range(H):
	M.append([s for s in input().rstrip()]) 

syx = []
for i in range(H):
	for j in range(W):
		if M[i][j] == '#': syx.append([i,j])
# print(syx)

dist = [[-1 for _ in range(W)] for _ in range(H)]
queue = deque()

for s in syx:
	dist[s[0]][s[1]] = 0

queue.append(syx)

while queue:
	nodelist = queue.popleft()
	# print(nodelist)
	nextnode = []

	for node in nodelist:
		y, x = node
		# print(y,x)
		
		for i in range(4):
			ny = y+dy[i]
			nx = x+dx[i]
			# print(ny, nx)
			
			if ny>=H or ny<0 or nx>=W or nx<0:
				continue
			if dist[ny][nx] != -1:
				continue
			
			if M[ny][nx] == '.':
				dist[ny][nx] = dist[y][x]+1
				nextnode.append([ny,nx])

	# print(nextnode)
	if nextnode:
		queue.append(nextnode)

ans = 0
for d in dist:
  ans = max(ans, max(d))
print(ans)

Fixed submission:
import sys
from collections import deque
if sys.platform =='win32':
  sys.stdin=open('./input.txt')
input = sys.stdin.readline
def MAP(): return [int(x) for x in input().split()]

dy = [-1,0,1,0]
dx = [0,-1,0,1]

H, W = [int(s) for s in input().split()]

M = []

for i in range(H):
	M.append([s for s in input().rstrip()]) 

syx = []
for i in range(H):
	for j in range(W):
		if M[i][j] == '#': syx.append([i,j])
# print(syx)

dist = [[-1 for _ in range(W)] for _ in range(H)]
queue = deque()

for s in syx:
	dist[s[0]][s[1]] = 0

queue.append(syx)

while queue:
	nodelist = queue.popleft()
	# print(nodelist)
	nextnode = []

	for node in nodelist:
		y, x = node
		# print(y,x)
		
		for i in range(4):
			ny = y+dy[i]
			nx = x+dx[i]
			# print(ny, nx)
			
			if ny>=H or ny<0 or nx>=W or nx<0:
				continue
			if dist[ny][nx] != -1:
				continue
			
			if M[ny][nx] == '.':
				dist[ny][nx] = dist[y][x]+1
				nextnode.append([ny,nx])

	# print(nextnode)
	if len(nextnode)!=0:
		queue.append(nextnode)

ans = 0
for d in dist:
  ans = max(ans, max(d))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from heapq import heapify, heappushpop
from bisect import bisect_left as bisect

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

X, Y, Z, K = MAP()
x = MAP()
y = MAP()
z = MAP()

if X > Z:
	x, z = z, x
	X, Z = Z, X
if Y > Z:
	y, z = z, y
	Y, Z = Z, Y

x.sort()
y.sort()
z.sort()

nums = [0] * K
heapify(nums)

for i in range(X):
	for j in range(Y):
		xy = x[i]+y[j]
		z_idx = bisect(z, nums[0]-xy)
		# print(nums)
		# print(xy, z, z_idx)
		for k in range(z_idx, Z):
			heappushpop(nums, xy+z[k])

nums.sort(reverse=True)
for n in nums:
	print(n)

Fixed submission:
import sys
from heapq import heapify, heappushpop
from bisect import bisect_left as bisect

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

X, Y, Z, K = MAP()
x = MAP()
y = MAP()
z = MAP()

if X > Z:
	x, z = z, x
	X, Z = Z, X
if Y > Z:
	y, z = z, y
	Y, Z = Z, Y

x.sort()
y.sort()
z.sort()

nums = [0] * K
heapify(nums)

for i in range(X-1, -1, -1):
	for j in range(Y-1, -1, -1):
		xy = x[i]+y[j]
		z_idx = bisect(z, nums[0]-xy)
		# print(nums)
		# print(xy, z, z_idx)
		for k in range(z_idx, Z):
			heappushpop(nums, xy+z[k])

nums.sort(reverse=True)
for n in nums:
	print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

INF = int(pow(10, 10))

a = [INF] * n
a[0] = 0

for i in range(1, n):
	for j in range(1, k+1):
		if i-j >= 0:
			b = a[i-j] + abs(h[i-j]-h[i])
			if b < a[i]:
				a[i] = b

print(a[n-1])

Fixed submission:
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

INF = int(pow(10, 10))

a = [INF] * n
a[0] = 0

for i in range(1, n):
	for j in range(1, k+1):
		if i-j >= 0:
			b = a[i-j] + abs(h[i-j]-h[i])
			if b < a[i]:
				a[i] = b

print(a[n-1])

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

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')

n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

a = [0]

for i in range(1, n):
	a.append(pow(10, 10))
	for j in range(1, k+1):
		if i-j >= 0:
			b = a[i-j] + abs(h[i-j]-h[i])
			if b < a[i]:
				a[i] = b

print(a[n-1])

Fixed submission:
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

INF = int(pow(10, 10))

a = [INF] * n
a[0] = 0

for i in range(1, n):
	for j in range(1, k+1):
		if i-j >= 0:
			b = a[i-j] + abs(h[i-j]-h[i])
			if b < a[i]:
				a[i] = b

print(a[n-1])
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

def main():
	N, M = MAP()
	S = input().rstrip()
	T = input().rstrip()

	L = lcm(N, M)
	n = int(L//N)
	m = int(L//M)
	X = ['0']*L
	for i in range(0, L, n):
		X[i] = S[i//n]
	for i in range(0, L, m):
		if X[i] != '0' and X[i] != T[i//m]:
			print(-1)
			sys.exit()
	print(L)

if __name__ == '__main__':
	main()

Fixed submission:
import sys
import fractions
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	S = input().rstrip()
	T = input().rstrip()

	L = (N*M)//fractions.gcd(N, M)
	# print(L)
	n = L//N
	m = L//M
	for i in range(0, L, n):
		if i % m == 0:
			if S[i//n] != T[i//m]:
				print(-1)
				sys.exit()
	print(L)


if __name__ == '__main__':
	main()

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

def main():
	N, M = MAP()
	S = input().rstrip()
	T = input().rstrip()

	L = lcm(N, M)
	n = int(L//N)
	m = int(L//M)
	X = ['0']*L
	for i in range(N):
		X[i*n] = S[i]
	for i in range(M):
		if X[i*m] != '0' and X[i*m] != T[i]:
			print(-1)
			sys.exit()
	print(L)

if __name__ == '__main__':
	main()

Fixed submission:
import sys
import fractions
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	S = input().rstrip()
	T = input().rstrip()

	L = (N*M)//fractions.gcd(N, M)
	# print(L)
	n = L//N
	m = L//M
	for i in range(0, L, n):
		if i % m == 0:
			if S[i//n] != T[i//m]:
				print(-1)
				sys.exit()
	print(L)


if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [MAP() for _ in range(N)]

fin = False
for cx in range(101):
	for cy in range(101):
		tmp = 10**9+7
		for a in A:
			x, y, h = a
			if h != 0:
				H = abs(cx-x)+abs(cy-y)+h
				if tmp == 10**9+7:
					tmp = H
				else:
					if tmp != H:
						break
			else:
				if tmp > abs(cx-x)+abs(cy-y):
					break
		else:
			X ,Y ,CH = cx, cy, H
			fin = True
print(X, Y, CH)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [MAP() for _ in range(N)]

fin = False
for cx in range(101):
	for cy in range(101):
		tmp = 10**9+7
		for a in A:
			x, y, h = a
			if h != 0:
				H = abs(cx-x)+abs(cy-y)+h
				if tmp == 10**9+7:
					tmp = H
				else:
					if tmp != H:
						break
			else:
				if tmp == 10**9+7: continue
				if tmp > abs(cx-x)+abs(cy-y):
					break
		else:
			X ,Y ,CH = cx, cy, H
			fin = True
print(X, Y, CH)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, M = MAP()

if N==M:
	print(1)
	sys.exit()

X = M//N+1
for i in range(X, -1, -1):
	if M % i == 0:
		print(i)
		sys.exit()
print(0)

Fixed submission:
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, M = MAP()

if N==M:
	print(1)
	sys.exit()

X = M//N+1
for i in range(X, -1, -1):
	if M % i == 0:
		print(i)
		sys.exit()
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
members = input()

opposite = [(members[:i].count("W")) + (members[i:].count("E")) for i in range(n)]
print(min(opposite))

Fixed submission:
n = int(input())
members = input()
m_e = members.count("E")
cost = m_e
costs = []
for i in range(n):
    if members[i]=="E":
        cost-=1
    if (i!=0 and members[i-1]=="W"):
        cost+=1
    costs.append(cost)
print(min(costs))

Buggy python submission (verdict: Time Limit Exceeded):
_ = int(input())
members = input()

counts = []
for i in range(len(members)):
    count=0
    for j in range(len(members)):
        if i == j:
            continue
        else:
            if (members[j] == 'W' and i<j) or (members[j] == 'E' and i>j):
                continue
            else:
                count+=1
        if counts:
            if count > min(counts):
                break
    counts.append(count)
print(min(counts))

Fixed submission:
n = int(input())
members = input()
m_e = members.count("E")
cost = m_e
costs = []
for i in range(n):
    if members[i]=="E":
        cost-=1
    if (i!=0 and members[i-1]=="W"):
        cost+=1
    costs.append(cost)
print(min(costs))

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

counts = []
for i in range(len(members)):
    count=0
    for j in range(len(members)):
        if i == j:
            continue
        else:
            if (members[j] == 'W' and i<j) or (members[j] == 'E' and i>j):
                continue
            else:
                count+=1
        if count > min(counts):
            break
    counts.append(count)
print(min(counts))

Fixed submission:
n = int(input())
members = input()
m_e = members.count("E")
cost = m_e
costs = []
for i in range(n):
    if members[i]=="E":
        cost-=1
    if (i!=0 and members[i-1]=="W"):
        cost+=1
    costs.append(cost)
print(min(costs))

Buggy python submission (verdict: Time Limit Exceeded):
_ = int(input())
members = input()

counts = []
for i in range(len(members)):
    count = sum([1 for j in range(len(members)) if (members[j] == 'W' and i>j) or (members[j] == 'E' and i<j)])
    counts.append(count)
print(min(counts))

Fixed submission:
n = int(input())
members = input()
m_e = members.count("E")
cost = m_e
costs = []
for i in range(n):
    if members[i]=="E":
        cost-=1
    if (i!=0 and members[i-1]=="W"):
        cost+=1
    costs.append(cost)
print(min(costs))

Buggy python submission (verdict: Time Limit Exceeded):
_ = int(input())
members = input()

counts = []
for i in range(len(members)):
    count=0
    for j in range(len(members)):
        if i == j:
            continue
        else:
            if (members[j] == 'W' and i<j) or (members[j] == 'E' and i>j):
                continue
            else:
                count+=1
    counts.append(count)
print(min(counts))

Fixed submission:
n = int(input())
members = input()
m_e = members.count("E")
cost = m_e
costs = []
for i in range(n):
    if members[i]=="E":
        cost-=1
    if (i!=0 and members[i-1]=="W"):
        cost+=1
    costs.append(cost)
print(min(costs))