Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
tmp = input().split()

A = [int(tmp[i]) for i in range(N)]


score = [None]*(N*N)
for i in range(N):
    for j in range(N):
        score[i*N+j] = A[i] + A[j]
score.sort()
sum = 0
for i in range(M):
    sum += score[N*N-1-i]
print(sum)

Fixed submission:
# 二分探索を利用した
N, M = map(int, input().split())
tmp = input().split()

A = [int(tmp[i]) for i in range(N)]
A.sort()
cum_A = [None]*N
cum_A[N-1] = A[N-1]
for i in range(1,N):
    cum_A[N-1-i] = cum_A[N-i] + A[N-1-i]
cum_A.append(0)


def geq(A, cum_A, X, N):  # ある定数X以上になる握手の方法が何通りあるか,Aは昇順sort済み
    sum = 0
    val = 0
    index = 0
    for i in range(N):
        while True:
            if index != N and A[i] + A[N - 1 - index] >= X:
                index += 1
            else:
                sum += index
                val += A[i] * index + cum_A[N-index]
                break
    return sum, val

# 2<=X<=2*Nで二分探索をする
low = 2
high = 2*A[N-1]
while low <= high:
    X = (low + high)//2
    sum, val = geq(A, cum_A, X, N)
    if sum == M:
        break
    elif sum > M:
        low = X+1
    else:
        high = X-1
if sum < M:
    X -= 1
sum, val = geq(A, cum_A, X, N)
ans = val - X*(sum-M)
print(ans)
Buggy python submission (verdict: Runtime Error):
def comb(n, r):
	from math import factorial
	return factorial(n) // (factorial(n - r) * factorial(r))

def main():
	import sys
	input = sys.stdin.readline
	N, K = map(int, input().split())
	num = 10 ** 9 + 7
	a = N - K + 1
	print(a)
	if K > 1:
		for j in range(2, K+1):
			b1 = comb(a, j) % num
			b2 = comb(K-1, j-1) % num
			ans = b1 * b2 % num
			print(ans)
			if ans == 0:
				sys.exit()

if __name__ == '__main__':
    main()

Fixed submission:
def comb(n, r):
	from math import factorial
	return factorial(n) // (factorial(n - r) * factorial(r))

def main():
	import sys
	input = sys.stdin.readline
	N, K = map(int, input().split())
	num = 10 ** 9 + 7
	a = N - K + 1
	print(a)
	if K > 1:
		if 2 * K <= N + 1:
			for j in range(2, K+1):
				b1 = comb(a, j) % num
				b2 = comb(K-1, j-1) % num
				ans = (b1 * b2) % num
				print(ans)
		else:
			for j in range(2, N-K+2):
				b1 = comb(a, j) % num
				b2 = comb(K-1, j-1) % num
				ans = (b1 * b2) % num
				print(ans)
			for j in range(N-K+2, K+1):
				print(0)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(raw_input())
a = []
count = 0
for i in range(5):
	a.append(int(raw_input()))
b = np.array(a)
num = np.array((n, 0, 0, 0, 0, 0))
move = np.empty(5, dtype=np.int)
while num[5] < n:
	for i in range(5):
		move[i] = min(num[i], b[i])
	num = num - np.hstack((move,0)) + np.hstack((0,move))
	count += 1

print count

Fixed submission:
import numpy as np
import math

n = int(raw_input())
a = []
for i in range(5):
	a.append(int(raw_input()))
b = np.array(a)
print int(math.ceil(n *1. / np.min(b))) + 4
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, raw_input().split())
s = str(raw_input())
ans = []
arr = []
for i in range(n-1):
	if s[i:i+2] == 'AC':
		arr.append(1)
	else:
		arr.append(0)
for i in range(q):
	l, r = map(int, raw_input().split())
	print sum(arr[l-1:r-1])

Fixed submission:
n, q = map(int, raw_input().split())
s = str(raw_input())
t = [0] * (n + 1)
for i in range(n):
	t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
for i in range(q):
	l, r = map(int, raw_input().split())
	print t[r-1] - t[l-1]

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, raw_input().split())
s = str(raw_input())
ans = []
arr = []
for i in range(n-1):
	if s[i:i+2] == 'AC':
		arr.append(1)
	else:
		arr.append(0)
for i in range(q):
	l, r = map(int, raw_input().split())
	count = sum(arr[l-1:r-1])
	ans.append(count)
for i in range(q):
	print ans[i]

Fixed submission:
n, q = map(int, raw_input().split())
s = str(raw_input())
t = [0] * (n + 1)
for i in range(n):
	t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
for i in range(q):
	l, r = map(int, raw_input().split())
	print t[r-1] - t[l-1]

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, raw_input().split())
s = str(raw_input())
ans = []
for i in range(q):
	l, r = map(int, raw_input().split())
	st = s[l-1:r]
	count = 0
	for j in range(len(st)):
		if st[j:j+2] == 'AC':
			count += 1
	ans.append(count)
for i in range(q):
	print ans[i]

Fixed submission:
n, q = map(int, raw_input().split())
s = str(raw_input())
t = [0] * (n + 1)
for i in range(n):
	t[i + 1] = t[i] + (1 if s[i : i + 2] == 'AC' else 0)
for i in range(q):
	l, r = map(int, raw_input().split())
	print t[r-1] - t[l-1]
Buggy python submission (verdict: Runtime Error):
N = int(input())
xyh = []
xyh1 = []
for _ in range(N):
	x0, y0, h0 = map(int, input().split())
	xyh.append([x0,y0,h0])
	if h0 > 0:
		xyh1.append([x0,y0,h0])

def absum(x, y, h, Cx, Cy):
	return abs(x - Cx) + abs(y - Cy) + h

if len(xyh1) > 1:
	for Cx in range(101):
		for Cy in range(101):
			for i in range(len(xyh1)-1):
				if absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy) != absum(xyh1[i+1][0], xyh1[i+1][1], xyh1[i+1][2], Cx, Cy):
					break
			else:
				H = absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy)
				print(Cx, Cy, H)
else:
	print(xyh1[i][0], xyh1[i][1], xyh1[i][2])

Fixed submission:
N = int(input())
xyh = []
xyh1 = []
for _ in range(N):
	x0, y0, h0 = map(int, input().split())
	xyh.append([x0,y0,h0])
	if h0 > 0:
		xyh1.append([x0,y0,h0])

def absum(x, y, h, Cx, Cy):
	return abs(x - Cx) + abs(y - Cy) + h

if len(xyh1) > 1:
	for Cx in range(101):
		for Cy in range(101):
			for i in range(len(xyh1)-1):
				if absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy) != absum(xyh1[i+1][0], xyh1[i+1][1], xyh1[i+1][2], Cx, Cy):
					break
			else:
				H = absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy)
				print(Cx, Cy, H)
else:
	print(xyh1[0][0], xyh1[0][1], xyh1[0][2])

Buggy python submission (verdict: Runtime Error):
N = int(input())
xyh = []
xyh1 = []
for _ in range(N):
	x0, y0, h0 = map(int, input().split())
	xyh.append([x0,y0,h0])
	if h0 > 0:
		xyh1.append([x0,y0,h0])

def absum(x, y, h, Cx, Cy):
	return abs(x - Cx) + abs(y - Cy) + h


for Cx in range(101):
	for Cy in range(101):
		for i in range(len(xyh1)-1):
			if absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy) != absum(xyh1[i+1][0], xyh1[i+1][1], xyh1[i+1][2], Cx, Cy):
				break
		else:
			H = absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy)
			print(Cx, Cy, H)

Fixed submission:
N = int(input())
xyh = []
xyh1 = []
for _ in range(N):
	x0, y0, h0 = map(int, input().split())
	xyh.append([x0,y0,h0])
	if h0 > 0:
		xyh1.append([x0,y0,h0])

def absum(x, y, h, Cx, Cy):
	return abs(x - Cx) + abs(y - Cy) + h

if len(xyh1) > 1:
	for Cx in range(101):
		for Cy in range(101):
			for i in range(len(xyh1)-1):
				if absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy) != absum(xyh1[i+1][0], xyh1[i+1][1], xyh1[i+1][2], Cx, Cy):
					break
			else:
				H = absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy)
				print(Cx, Cy, H)
else:
	print(xyh1[0][0], xyh1[0][1], xyh1[0][2])
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(int, input().split()))
c_odd  = collections.Counter(v[::2])
c_even = collections.Counter(v[1::2])
odd    = c_odd.most_common()[:2]
even   = c_even.most_common()[:2]
if (len(odd) == 1) & (len(even) == 1):
	if odd[0][0] == even[0][0]:
		ans = odd[0][1]
	else:
		ans = 0
elif len(odd) == 1:
	if odd[0][0] == even[0][0]:
		ans = n - odd[0][1] - even[1][1]
	else:
		ans = n - odd[0][1] - even[0][1]
elif len(even) == 1:
	if odd[0][0] == even[0][0]:
		ans = n - odd[1][1] - even[0][1]
	else:
		ans = n - odd[0][1] - even[0][1]
print(ans)

Fixed submission:
import collections
n = int(input())
v = list(map(int, input().split()))
c_odd  = collections.Counter(v[::2])
c_even = collections.Counter(v[1::2])
odd    = c_odd.most_common()[:2]
even   = c_even.most_common()[:2]
if (len(odd) == 1) & (len(even) == 1):
	if odd[0][0] == even[0][0]:
		ans = odd[0][1]
	else:
		ans = 0
elif len(odd) == 1:
	if odd[0][0] == even[0][0]:
		ans = n - odd[0][1] - even[1][1]
	else:
		ans = n - odd[0][1] - even[0][1]
elif len(even) == 1:
	if odd[0][0] == even[0][0]:
		ans = n - odd[1][1] - even[0][1]
	else:
		ans = n - odd[0][1] - even[0][1]
else:
	if odd[0][0] == even[0][0]:
		ans = min(n - odd[0][1] - even[1][1], n - odd[1][1] - even[0][1])
	else:
		ans = n - odd[0][1] - even[0][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
s = str(input())
K = int(input())

def find(str):
	lt = []
	for start in range(len(str)):
		for end in range(start + 1, len(str) + 1):
			lt.append(str[start:end])
	lt = list(set(lt))
	lt.sort()

	return lt

s_pt = list(set(list(s)))
s_pt.sort()
ans = []

for i in range(min(5, len(s_pt))):
	ind = [ix for ix, x in enumerate(s) if x == s_pt[i]]
	for j in ind:
		ans += find(s[j:min(j+5, len(s))])
	if len(ans) >= 5:
		break
ans = list(set(ans))
ans.sort()
print(ans[K-1])


Fixed submission:
s = str(input())
K = int(input())

def find(str):
	lt = []
	for start in range(len(str)):
		for end in range(start + 1, len(str) + 1):
			lt.append(str[start:end])
	lt = list(set(lt))
	lt.sort()

	return lt

s_pt = list(set(list(s)))
s_pt.sort()
ans = []
for i in range(min(5, len(s_pt))):
	ind = [ix for ix, x in enumerate(s) if x == s_pt[i]]
	for j in ind:
		ans += find(s[j:min(j+5, len(s))])
	ans = list(set(ans))
	if len(ans) >= 5:
		break
ans = list(set(ans))
ans.sort()
print(ans[K-1])

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

def find(str):
	lt = []
	for start in range(len(str)):
		for end in range(start + 1, len(str) + 1):
			lt.append(str[start:end])
	lt = list(set(lt))
	lt.sort()

	return lt

s_pt = list(set(list(s)))
s_pt.sort()
ans = []

for i in range(5):
	ind = [ix for ix, x in enumerate(s) if x == s_pt[i]]
	for j in ind:
		ans += find(s[j:min(j+5, len(s))])
	if len(ans) >= 5:
		break
ans = list(set(ans))
ans.sort()
print(ans[K-1])

Fixed submission:
s = str(input())
K = int(input())

def find(str):
	lt = []
	for start in range(len(str)):
		for end in range(start + 1, len(str) + 1):
			lt.append(str[start:end])
	lt = list(set(lt))
	lt.sort()

	return lt

s_pt = list(set(list(s)))
s_pt.sort()
ans = []
for i in range(min(5, len(s_pt))):
	ind = [ix for ix, x in enumerate(s) if x == s_pt[i]]
	for j in ind:
		ans += find(s[j:min(j+5, len(s))])
	ans = list(set(ans))
	if len(ans) >= 5:
		break
ans = list(set(ans))
ans.sort()
print(ans[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
K = int(input())
lt = []
for start in range(len(s)):
	for end in range(start + 1, len(s) + 1):
		lt.append(s[start:end])
lt = list(set(lt))
lt.sort()
print(lt[K-1])

Fixed submission:
s = str(input())
K = int(input())

def find(str):
	lt = []
	for start in range(len(str)):
		for end in range(start + 1, len(str) + 1):
			lt.append(str[start:end])
	lt = list(set(lt))
	lt.sort()

	return lt

s_pt = list(set(list(s)))
s_pt.sort()
ans = []
for i in range(min(5, len(s_pt))):
	ind = [ix for ix, x in enumerate(s) if x == s_pt[i]]
	for j in ind:
		ans += find(s[j:min(j+5, len(s))])
	ans = list(set(ans))
	if len(ans) >= 5:
		break
ans = list(set(ans))
ans.sort()
print(ans[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int, input().split()))

for nn in range(n - 1, 0, -1):
  t = li.pop(nn)
  if li.count(t) != 0:
    print('NO')
    exit()
print('YES')

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

if len(li) == len(set(li)):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n = int(input())
li = [-1 * int(i) for i in input().split()]
ans = 0

for a in range(len(li)):
  li2 = li[a:]
  for b in range(len(li2)):
    li3 = li2[:b+1]
    li4 = heapq.heapify(li3)
    if len(li3) >= 2:
      heapq.heappop(li3)
      ans += ((-1)*heapq.heappop(li3))

print(ans)

Fixed submission:
n = int(input())
aa = list(map(int, input().split()))
ans = 0
pos = [0] * (n + 1)

for i, a in enumerate(aa):
    pos[a] = i + 2
Lnext = [1, 1] + list(range(1, n + 1)) + [n, n]
Rnext = [3, 3] + list(range(3, n + 3)) + [n + 2, n + 2]
for a in range(1,n + 1):
    i = pos[a]
    l0 = Lnext[i]
    l1 = Lnext[l0]
    r0 = Rnext[i]
    r1 = Rnext[r0]
    ans += a * ((l0 - l1) * (r0 - i) + (i - l0) * (r1 - r0))
    Lnext[r0] = l0
    Rnext[l0] = r0
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())

if b = 1:
  ans = 0
else:
  ans = math.ceil((b - 1) / (a - 1))

print(ans)


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

if b == 1:
  ans = 0
else:
  ans = math.ceil((b - 1) / (a - 1))

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))

ans_list = []
a = 0
b = 0
for c, l in enumerate(li):
  if l <= a:
    b += 1
    if c == n - 1:
      ans_list.append(b)
  else:
    if c != 0:
      ans_list.append(b)
    b = 0
  a = l

ans = max(ans_list)
print(ans)

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

ans_list = []
a = 0
b = 0
for c, l in enumerate(li):
  if l <= a:
    b += 1
    if c == n - 1:
      ans_list.append(b)
  else:
    if c != 0:
      ans_list.append(b)
    b = 0
  a = l

if len(ans_list) != 0:
  ans = max(ans_list)
else:
  ans = 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
if n == 1:
  print(0)
  exit()
li = [i for i in range(n)]
ans = sum(li)
print(ans)

Fixed submission:
n = int(input())
ans = n * (n - 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = int(input())

if a >= 3200:
  print(s)
else:
  print('red')

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

if a >= 3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = [''.join(sorted(input())) for _ in range(n)]

ans = 0
le = len(li)
while le > 1:
  t = li[0]
  cnt = 0
  for n, w in reversed(list(enumerate(li[1:]))):
    if t == w:
      cnt += 1
      li.pop(n + 1)
  ans += cnt * (cnt + 1) / 2
  li.pop(0)
  le = len(li)

print(int(ans))


Fixed submission:
n = int(input())
li = [''.join(sorted(input())) for _ in range(n)]

ans = 0
w_dic = {}
for l in li:
  if not w_dic.get(l):
    w_dic[l] = 1
  else:
    ans += w_dic[l]
    w_dic[l] = w_dic[l] + 1

print(int(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
li = [sorted(list(input())) for a in range(n)]
ans = 0
le = len(li)
while le != 1:
  t = li[0]
  cnt = 0
  for n, w in reversed(list(enumerate(li[1:]))):
    if t == w:
      cnt += 1
      li.pop(n + 1)
  ans += cnt * (cnt + 1) / 2
  li.pop(0)
  le = len(li)

print(ans)

Fixed submission:
n = int(input())
li = [''.join(sorted(input())) for _ in range(n)]

ans = 0
w_dic = {}
for l in li:
  if not w_dic.get(l):
    w_dic[l] = 1
  else:
    ans += w_dic[l]
    w_dic[l] = w_dic[l] + 1

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = [sorted(list(input())) for a in range(n)]

ans = 0
for n, wx in enumerate(li):
  for wy in li[n+1:]:
    if wx == wy:
      ans += 1

print(ans)

Fixed submission:
n = int(input())
li = [''.join(sorted(input())) for _ in range(n)]

ans = 0
w_dic = {}
for l in li:
  if not w_dic.get(l):
    w_dic[l] = 1
  else:
    ans += w_dic[l]
    w_dic[l] = w_dic[l] + 1

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = [input() for a in range(n)]
li2 = []
for w in li:
  di = {}
  for x in w:
    if x in di:
      di[x] += 1
    else:
      di[x] = 1
  li2.append(di)
  
li3 = []
for l in li2:
  wl = ''
  for k in sorted(l):
    wl += k + str(l[k])
  li3.append(wl)

ans = 0
for n, wx in enumerate(li3):
  for wy in li3[n+1:]:
    if wx == wy:
      ans += 1

print(ans)

Fixed submission:
n = int(input())
li = [''.join(sorted(input())) for _ in range(n)]

ans = 0
w_dic = {}
for l in li:
  if not w_dic.get(l):
    w_dic[l] = 1
  else:
    ans += w_dic[l]
    w_dic[l] = w_dic[l] + 1

print(int(ans))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
i = input()
n = len(i)
ans = 0
for j in range(n + 1):
  if j == n and j % 2:
    ans += int(i) - int(str(9) * (j - 1))
  elif j % 2 == 1:
    ans += 10 ** j - int(str(9) * (j - 1)) - 1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
i = input()
n = len(i)
ans = 0
for j in range(n + 1):
  if j == n and j % 2 == 1 and j == 1:
    ans += int(i)
  elif j == n and j % 2 == 1:
    ans += int(i) - int(str(9) * (j - 1))
  elif j == 1:
    ans += 9
  elif j % 2 == 1:
    ans += 10 ** j - int(str(9) * (j - 1)) - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
li = [map(int, input().split())]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
li = [int(a) for a in input().split()]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
l = [int(i) for i in input().split()]
if n > 1:
  for j in range(n):
    if j != n - 1 and max(l[: j + 1]) - min(l[j + 1 :]) >= 2:
      print('No')
      exit()
print('Yes')

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
li = [int(a) for a in input().split()]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
l = [int(i) for i in input().split()]
if n > 1:
  for j in range(n):
    if max(l[:j]) - min(l[j:]) >= 2:
      print('No')
      exit()
print('Yes')

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
li = [int(a) for a in input().split()]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
l = [int(input()) for i in range(n)]
if n > 1:
  for j in range(n):
    if max(l[:j]) - min(l[j:]) >= 2:
      print('No')
      exit()
print('Yes')

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
li = [int(a) for a in input().split()]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = [int(input()) for _ in range(n)]

mi = li.index(max(li))
m = max(li)

for a, b in enumerate(li):
  if a != mi:
    print(m)
  else:
    print(max(l[a+1:]+l[:a]))

Fixed submission:
n = int(input())
li = [int(input()) for _ in range(n)]

mi = li.index(max(li))
m = max(li)

for a, b in enumerate(li):
  if a != mi:
    print(m)
  else:
    print(max(li[a+1:]+li[:a]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = [int(input()) for _ in range(n)]

for a, b in enumerate(li):
  li2 = li[a+1:] + li[:a]
  print(max(li2))

Fixed submission:
n = int(input())
li = [int(input()) for _ in range(n)]

mi = li.index(max(li))
m = max(li)

for a, b in enumerate(li):
  if a != mi:
    print(m)
  else:
    print(max(li[a+1:]+li[:a]))
Buggy python submission (verdict: Runtime Error):
    n=int(input())
    a=list(map(int,input().split()))
    t=[0]*n
    p=[]
    g=0
    for i in range(n-1,-1,-1):
        if sum(t[i::i+1])%2!=a[i]:
            t[i]=1
            p.append(i+1)
            g+=1
    print(g)
    print(*p[::-1])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
t=[0]*n
p=[]
g=0
for i in range(n-1,-1,-1):
    if sum(t[i::i+1])%2!=a[i]:
        t[i]=1
        p.append(i+1)
        g+=1
print(g)
print(*p[::-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = [list(map(input().split())) for _ in range(n)]
print(li)

Fixed submission:
n = int(input())
li = [[a+1, input().split()] for a in range(n)]
li = sorted(li, key=lambda x:(x[1][0],-1 * int(x[1][1])))
for l in li:
  print(l[0])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(0,n-1):
    for j in range(i+1,n):
        if a[i] == a[j]:
            c += 1
if c == 0:
    print('YES')
else :
    print('NO')

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)

if len(c) == len(a):
    print('YES')
else :
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
p = list(map(int, input().split()))
l = []
for i in range(0,n-k+1):
    l.append((sum(p[i:i+k])+k)/2)
print(max(l))

Fixed submission:
n, k = map(int,input().split())
p = list(map(int, input().split()))
a = sum(p[0:k])
l = [a]
for i in range(1,n-k+1):
    a = a - p[i-1] + p[k-1+i]
    l.append(a)
print((max(l)+k)/2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(0,len(s)):
  for j in range (0,26):
    if s[i] == l[j]:
      s[i] = l[(j+n)%26]
      break
print(s)

Fixed submission:
n = int(input())
s = input()
s = list(s)
l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(0,len(s)):
  for j in range (0,26):
    if s[i] == l[j]:
      s[i] = l[(j+n)%26]
      break
s = ''.join(s)
print(s)