Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ln=[0]*n
i=0
for a  in range(n):
    while a %2 ==0:
        a/=2
        i+=1
    ln[a-1]=i
print(ln.index(max(ln)))

Fixed submission:
n=int(input())
ans=0
for i in range(7):
    if 2**i<=n:
        ans=2**i
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
ln=[0]*n
for a  in range(n):
    if a %2 ==0:
        ln[a-1}=a//2
    else:
        ln[a-1]=0
print(max(ln))

Fixed submission:
n=int(input())
ans=0
for i in range(7):
    if 2**i<=n:
        ans=2**i
print(ans)

Buggy python submission (verdict: Runtime Error):
ln=[n for n in range(int(input()))]
cnt=[0]*n
for n in ln:
    while n%2==0:
        cnt[n-1]+=1
print((max(cnt)).index()+1)

Fixed submission:
n=int(input())
ans=0
for i in range(7):
    if 2**i<=n:
        ans=2**i
print(ans)
Buggy python submission (verdict: Runtime Error):
R,G,B=input().split(" ")
r=R
g=G
b=B
if (100*r+10*g+b)%4==0:
    print("YES")
else:
    print("NO")

Fixed submission:
R,G,B=input().split(" ")
r=int(R)
g=int(G)
b=int(B)
s=100*r+10*g+b
if s%4==0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ln=[int(a) for a in input().split()]
ln.sort(reverse=True)
sum1=0
for i in range(n):
    sum1+=ln[1]
    del ln[0:2]
print(sum1)

Fixed submission:
n=int(input())
ln=[int(a) for a in input().split()]
ln.sort(reverse=True)
print(sum(ln[1:n*2:2]))
Buggy python submission (verdict: Runtime Error):
print(input().rfind("Z")-input().find("A")+1)

Fixed submission:
s=input()
print(s.rfind("Z")-s.find("A")+1)

Buggy python submission (verdict: Runtime Error):
print(input().rfind("Z")-input().find("A")+1)

Fixed submission:
s=input()
print(s.rfind("Z")-s.find("A")+1)

Buggy python submission (verdict: Runtime Error):
s=input()
print(max(s.index("Z"))-min(s.index('A')))

Fixed submission:
s=input()
print(s.rfind("Z")-s.find("A")+1)

Buggy python submission (verdict: Runtime Error):
s=input()
print(abs(min(s.index('A'))-max(s.index("Z"))))

Fixed submission:
s=input()
print(s.rfind("Z")-s.find("A")+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int,input().split()))
ans = 0
while sum(nums)%2 == 0:
    for i in range(n):
        nums[i]=nums[i]/2
    ans +=1
print(ans)

Fixed submission:
print(sum(list(map(int,str(input())))))

Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int,input().split()))
ans = 0
while sum(nums)%2 == 0:
    for i in range(n):
        nums[i]=nums[i]//2
    ans +=1
print(ans)

Fixed submission:
print(sum(list(map(int,str(input())))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
 
l1 = []
for i in range(1, int(n ** 0.5)):
  q, mod = divmod(n , i)
  if mod == 0:
    l1.append(q + i -2)
print(min(l1))

Fixed submission:
n = int(input())
 
l1 = []
for i in range(1, int(n ** 0.5) + 1):
  q, mod = divmod(n , i)
  if mod == 0:
    l1.append(q + i -2)
print(min(l1))

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

l1 = 0
for i in range(n // 2):
  if n % (i +1) == 0 and l1 == 0:
    l1 = (n // (i + 1) + i - 1)
  elif n % (i +1) == 0 and (n // (i + 1) + i - 1) < l1:
    l1 = (n // (i + 1) + i - 1)
print(l1)

Fixed submission:
n = int(input())
 
l1 = []
for i in range(1, int(n ** 0.5) + 1):
  q, mod = divmod(n , i)
  if mod == 0:
    l1.append(q + i -2)
print(min(l1))

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

l1 = []
for i in range(n // 2):
  q, mod = divmod(n , i + 1)
  if mod == 0:
    l1.append(q + i -1)
print(min(l1))

Fixed submission:
n = int(input())
 
l1 = []
for i in range(1, int(n ** 0.5) + 1):
  q, mod = divmod(n , i)
  if mod == 0:
    l1.append(q + i -2)
print(min(l1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = [int(z) for z in input().split()]

l2 = [""] * n

c = 0
for i in li:
  l2[c] = i
  c += 1
print(l2)

Fixed submission:
N = int(input())

odd = 0
even = 0
for i in range(N):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(odd + even))

Buggy python submission (verdict: Runtime Error):
n, h = [int(z) for z in input().split()]
li2 = [int(z) for z in input().split()]

f = 0
for i in li2:
  if i >= h:
    f += 1
print(f)

Fixed submission:
N = int(input())

odd = 0
even = 0
for i in range(N):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(odd + even))

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

odd = 0
even = 0
for i in range(N-1):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

total = odd + even
print(odd/total)

Fixed submission:
N = int(input())

odd = 0
even = 0
for i in range(N):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(odd + even))

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

odd = 0
even = 0
for i in range(N-1):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(even + odd))

Fixed submission:
N = int(input())

odd = 0
even = 0
for i in range(N):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(odd + even))

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

odd = 0
even = 0
for i in range(N-1):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(even + odd))


Fixed submission:
N = int(input())

odd = 0
even = 0
for i in range(N):
	if i % 2 == 0:
		odd += 1
	else:
		even += 1

print(odd/(odd + even))
Buggy python submission (verdict: Time Limit Exceeded):
n1 = int(input())
l1 = [int(x) for x in input().split()]
l2 = [""] * n1

for i, v in enumerate(l1):
  l2[v -1] = i + 1

ans = ""
for i in l2:
  ans = ans + str(i) + " "
print(ans[:-1])

Fixed submission:
n1 = int(input())
l1 = [int(x) for x in input().split()]
l2 = [""] * n1

for i, v in enumerate(l1):
  l2[v -1] = i + 1

l2 = map(str,l2)
ans = " ".join(l2)
print(ans)

Buggy python submission (verdict: Runtime Error):
n1 = int(input())
l1 = [int(x) for x in input().split()]
l2 = [""] * 8

for i, v in enumerate(l1):
  l2[v -1] = i + 1

ans = ""
for i in l2:
  ans = ans + str(i) + " "
print(ans[:-1])

Fixed submission:
n1 = int(input())
l1 = [int(x) for x in input().split()]
l2 = [""] * n1

for i, v in enumerate(l1):
  l2[v -1] = i + 1

l2 = map(str,l2)
ans = " ".join(l2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nu = [int(x) for x in input().split()]
r2 = {}

for i in nu:
  r2[i] = nu.index(i)
#print(r2)

kyt = ""
for ky in r2.values():
  ky = str(ky +1)
  kyt = kyt + ky + " "
print(kyt)

Fixed submission:
n1 = int(input())
l1 = [int(x) for x in input().split()]
l2 = [""] * n1

for i, v in enumerate(l1):
  l2[v -1] = i + 1

l2 = map(str,l2)
ans = " ".join(l2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nu = [int(x) for x in input().split()]
r2 = {}

for i in nu:
  r2[i] = nu.index(i)
#print(r2)

j2 = []
for i in range(len(r2)):
  j2.append(r2[i+1]+1)
#print(j2)

answ = ""
for i in j2:
  answ = answ + str(i) + " "
print(answ)

Fixed submission:
n1 = int(input())
l1 = [int(x) for x in input().split()]
l2 = [""] * n1

for i, v in enumerate(l1):
  l2[v -1] = i + 1

l2 = map(str,l2)
ans = " ".join(l2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nu = [int(x) for x in input().split()]
ans = ["a" for x in range(len(nu))]
                          
for i, v in enumerate(nu):
  #print("i=", i)
  #print("v=", v)
  ans[v-1] = i+1
#print(ans)

answ = ""
for i in ans:
  answ = answ + str(i) + " "
print(answ)

Fixed submission:
n1 = int(input())
l1 = [int(x) for x in input().split()]
l2 = [""] * n1

for i, v in enumerate(l1):
  l2[v -1] = i + 1

l2 = map(str,l2)
ans = " ".join(l2)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
list1 = [int(x) for x in input().split()]
#print(list1)

set1 = set(list1)
#print(set1)

listans = []

for i in set1:
  if list1.count(i) > 1:
    listans.append(i)

#print(listans)

if len(listans) < 2:
  print(0)
else:
  print(sorted(listans)[-1]*sorted(listans)[-2])

Fixed submission:
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x > a:
	x_a = x - a
else:
	x_a = a - x

if x > b:
	x_b = x - b
else:
	x_b = b - x
	


if x_a > x_b:
	print("B")
else:
	print("A")

Buggy python submission (verdict: Runtime Error):
n = int(input())
list1 = [int(x) for x in input().split()]
set1 = set(list1)

listans = []

for i in set1:
  if list1.count(i) > 2:
    listans.append(i)

if len(listans) < 2:
  print(0)
else:
  print(sorted(listans)[-1]*sorted(listans)[-2])

Fixed submission:
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x > a:
	x_a = x - a
else:
	x_a = a - x

if x > b:
	x_b = x - b
else:
	x_b = b - x
	


if x_a > x_b:
	print("B")
else:
	print("A")

Buggy python submission (verdict: Runtime Error):
n = int(input())
list1 = [int(x) for x in input().split()]
#print(list1)

set1 = set(list1)
#print(set1)

listans = []

for i in set1:
  if list1.count(i) > 2:
    listans.append(i)

#print(listans)

if len(listans) < 2:
  print(0)
else:
  print(sorted(listans)[-1]*sorted(listans)[-2])

Fixed submission:
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x > a:
	x_a = x - a
else:
	x_a = a - x

if x > b:
	x_b = x - b
else:
	x_b = b - x
	


if x_a > x_b:
	print("B")
else:
	print("A")

Buggy python submission (verdict: Runtime Error):
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x > a:
	x_a = x - a
else:
x_a = a - x

if x > b:
	x_b = x - b
else:
	x_b = b - x
	

if x_a > x_b:
	print("B")
else:
	print("A")

Fixed submission:
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x > a:
	x_a = x - a
else:
	x_a = a - x

if x > b:
	x_b = x - b
else:
	x_b = b - x
	


if x_a > x_b:
	print("B")
else:
	print("A")
Buggy python submission (verdict: Runtime Error):
n = int(input())
list1 = [int(x) for x in input().split()]
list2 = list(reversed(sorted(list1)))
m = list2[0]

ans = []
for i in range(1, len(list2)):
  if list2[i] == m:
    ans.append(m)
  if len(ans) == 2:
    break
  m = list2[i]

print(ans[0] * ans[1])

Fixed submission:
n = int(input())
list1 = [int(x) for x in input().split()]
list2 = list(reversed(sorted(list1)))

fflag = 0
ans = []
for i in range(len(list2) - 1):
  if fflag ==0:
    if list2[i] == list2[i + 1]:
      ans.append(list2[i])
      fflag = 1
  elif fflag == 1:
    fflag = 0
    continue
  if len(ans) == 2:
    break

if len(ans) == 2:
  print(ans[0] * ans[1])
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
n = int(input())
list1 = [int(x) for x in input().split()]

set1 = set(list1)


listans = []

for i in set1:
  if list1.count(i) > 1 and list1.count(i) < 4:
    listans.append(i)
  elif list1.count(i) >3:
    listans.append(i)
    listans.append(i)




listasn = sorted(listans)
if len(listansn) < 2:
  print(0)
else:
  print(listansn[-1]*listansn[-2])

Fixed submission:
n = int(input())
list1 = [int(x) for x in input().split()]
list2 = list(reversed(sorted(list1)))

fflag = 0
ans = []
for i in range(len(list2) - 1):
  if fflag ==0:
    if list2[i] == list2[i + 1]:
      ans.append(list2[i])
      fflag = 1
  elif fflag == 1:
    fflag = 0
    continue
  if len(ans) == 2:
    break

if len(ans) == 2:
  print(ans[0] * ans[1])
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list1 = [int(x) for x in input().split()]


set1 = set(list1)


listans = []

for i in set1:
  if list1.count(i) > 1 and list1.count(i) < 4:
    listans.append(i)
  elif list1.count(i) >3:
    listans.append(i)
    listans.append(i)


if len(listans) < 2:
  print(0)
else:
  print(sorted(listans)[-1]*sorted(listans)[-2])

Fixed submission:
n = int(input())
list1 = [int(x) for x in input().split()]
list2 = list(reversed(sorted(list1)))

fflag = 0
ans = []
for i in range(len(list2) - 1):
  if fflag ==0:
    if list2[i] == list2[i + 1]:
      ans.append(list2[i])
      fflag = 1
  elif fflag == 1:
    fflag = 0
    continue
  if len(ans) == 2:
    break

if len(ans) == 2:
  print(ans[0] * ans[1])
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
  f = sum([int(x) for x in str(i)])
  if a <= f && f <= b:
    ans+=i
print(ans)   

Fixed submission:
n,a,b = map(int,input().split())
ans = 0
for i in range(n+1):
  f = sum([int(x) for x in str(i)])
  if (a <= f) & (f <= b):
    ans+=i
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

ans = 0
t=0

while True:
    for i in range(n):  # 0 1 2 ... n-1
        if a[i] %2 ==0:
            a[i] = a[i] / 2
        else:
            t = 1
    if t != 1:
        ans += 1
    else:
        break

print(ans)


Fixed submission:
s = input()
factor = [int(x) for x in s]
print(sum(factor))

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

ans = 0
t=0

while True:
    for i in range(n):  # 0 1 2 ... n-1
        if a[i] %2 ==0:
            a[i] = a[i] / 2
        else:
            t = 1
    if t != 1:
        ans += 1
    else:
        break

print(ans)


Fixed submission:
s = input()
factor = [int(x) for x in s]
print(sum(factor))

Buggy python submission (verdict: Runtime Error):
n=int(input())
li = list(map(int,input().split()))
counter = 0
while 1:
  judge = [a%2 for a in li] 
  if sum(judge) != 0:
    break
  else:
    counter+=1
    li = [a/2 for a in li]
print(counter)

Fixed submission:
s = input()
factor = [int(x) for x in s]
print(sum(factor))

Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
print(str(a+b+c))

Fixed submission:
s = input()
factor = [int(x) for x in s]
print(sum(factor))
Buggy python submission (verdict: Runtime Error):
import sys
li = ["dream","dreamer","erase","eraser"]
li = [s[::-1] for s in li]
sen = input()[::-1]
while 1:
  if sen[:5] == "maerd":
    if len(sen) == 5:
      print("YES")
      sys.exit()
    else sen = sen[5:]
  elif sen[:6] == "remaerd":
    if len(sen) == 6:
      print("YES")
      sys.exit()
    else sen = sen[6:]
  elif sen[:5] == "esare":
    if len(sen) == 5:
      print("YES")
      sys.exit()
    else sen = sen[5:]
  elif sen[:6] == "resare":
    if len(sen) == 6:
      print("YES")
      sys.exit()
    else sen = sen[6:]
  else:
    print("NO")
    sys.exit()

Fixed submission:
import sys
li = ["dream","dreamer","erase","eraser"]
li = [s[::-1] for s in li]
sen = input()[::-1]
while 1:
  ju = 0
  for i in range(4):
    le = len(li[i])
    if sen[:le] == li[i]:
      if len(sen) == le:
        print("YES")
        sys.exit()
      else:
        sen = sen[le:]
        ju = 1
  if not ju:
    print("NO")
    sys.exit()
Buggy python submission (verdict: Runtime Error):
import math

input = int(input()
guess = math.floor(input / 1.08)
if math.floor(guess * 1.08) == input:
    print(guess)
elif math.floor((guess + 1) * 1.08) == input:
    print(guess + 1)
else:
    print(':(')

Fixed submission:
import math

input = int(input())
guess = math.floor(input / 1.08)
if math.floor(guess * 1.08) == input:
    print(guess)
elif math.floor((guess + 1) * 1.08) == input:
    print(guess + 1)
else:
    print(':(')

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

input = input()
guess = math.floor(input / 1.08)
if math.floor(guess * 1.08) == input:
    print(guess)
elif math.floor((guess + 1) * 1.08) == input:
    print(guess + 1)
else:
    print(':(')

Fixed submission:
import math

input = int(input())
guess = math.floor(input / 1.08)
if math.floor(guess * 1.08) == input:
    print(guess)
elif math.floor((guess + 1) * 1.08) == input:
    print(guess + 1)
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
input = int(input())
n = input // 100
m = input % 100
if m // n <= 5:
    print(1)
else:
    print(0)

Fixed submission:
input = int(input())
n = input // 100
if n > 0:
    m = input % 100
    if m / n <= 5:
        print(1)
    else:
        print(0)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
l = int(input())
s = input()
r = set()
for x in range(0, l - 2):
    for y in range(x + 1, l - 1):
        for z in range(y + 1, l):
            r.add(s[x] + s[y] + s[z])

print(len(r))

Fixed submission:
l = int(input())
s = input()
r = set()
cx = set(s)
for x in range(0, l - 2):
    if not cx:
        break
    if s[x] not in cx:
        continue
    cx.remove(s[x])
    cy = set(s[x+1:])
    for y in range(x + 1, l - 1):
        if not cy:
            break
        if s[y] not in cy:
            continue
        cy.remove(s[y])
        cz = set(s[y+1:])
        for z in range(y + 1, l):
            if not cz:
                break
            if s[z] not in cz:
                continue
            cz.remove(s[z])
            r.add(s[x] + s[y] + s[z])

print(len(r))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split(' '))
r = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        for z in range(0, k + 1):
            if x + y + z == s:
                r += 1
print(r)

Fixed submission:
k, s = map(int, input().split(' '))
r = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        if s - x - y <= k and s - x - y >= 0:
            r += 1
print(r)

Buggy python submission (verdict: Runtime Error):
k, s = map(input, input().split(' '))
r = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        for z in range(0, k + 1):
            if x + y + z == s:
                r += 1
print(r)

Fixed submission:
k, s = map(int, input().split(' '))
r = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        if s - x - y <= k and s - x - y >= 0:
            r += 1
print(r)
Buggy python submission (verdict: Runtime Error):
l = [SUN, MON, TUE, WED, THU, FRI, SAT]
day = input()
for i in range(len(l)):
  if day = l[i]:
    print(7-i)

Fixed submission:
l = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
day = input()
for i in range(len(l)):
    if day == l[i]:
        print(7-i)
Buggy python submission (verdict: Runtime Error):
import string
A = list(string.ascii_uppercase)
N = int(input()) % 26
S = input()
Output = ''
for i in range(len(S)):
    for j in range(len(A)):
        if A[j] == S[i]:
            Output += A[j+N]
print(Output)

Fixed submission:
import string
A = list(string.ascii_uppercase)
N = int(input())
S = input()
Output = ''
for i in range(len(S)):
    for j in range(len(A)):
        if A[j] == S[i]:
            Output += A[(j+N) % 26]
print(Output)
Buggy python submission (verdict: Runtime Error):
import numpy as np

r = input()
c = 1*(np.pi**2)
c2 = r*(np.pi**2)
print(int(c2/c))

Fixed submission:
import numpy as np
r = int(input())
c = int(np.pi)*(1**2)
c2 = int(np.pi)*(r**2)
print(int(c2/c))

Buggy python submission (verdict: Runtime Error):
import numpy as np
r = raw_input()
c = 1*(np.pi**2)
c2 = r*(np.pi**2)
print(int(c2/c))

Fixed submission:
import numpy as np
r = int(input())
c = int(np.pi)*(1**2)
c2 = int(np.pi)*(r**2)
print(int(c2/c))
Buggy python submission (verdict: Runtime Error):
N3 = int(input())
if N3 < 1200:
    print('ABC')
elif N3 > 1999 and N3 < 2800:
    print('ARC')
elif NR > 2799:
    print('AGC')

Fixed submission:
N3 = int(input())
if N3 < 1200:
    print('ABC')
elif 1200 <= N3 < 2800:
    print('ARC')
else:
    print('AGC')

Buggy python submission (verdict: Runtime Error):
N3 = int(input())
if N3 < 1200:
    print('ABC')
elif N3 > 1999 and NR < 2800:
    print('ARC')
else:
    print('AGC')

Fixed submission:
N3 = int(input())
if N3 < 1200:
    print('ABC')
elif 1200 <= N3 < 2800:
    print('ARC')
else:
    print('AGC')
Buggy python submission (verdict: Time Limit Exceeded):
import copy as cp

N,M = map(int,input().split())
P = []
Y = []
for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)
#print(N,M,P,Y)

C_lst = [[] for _ in range(N)]
for i in range(M):
    C_lst[P[i]-1].append(Y[i])
#print(N,M,P,Y,C_lst)
C_cp = cp.deepcopy(C_lst)
for i in range(N):
    C_cp[i].sort()
for i in range(M):
    ans = "0"*(6-len(str(P[i]))) + str(P[i])
    idx = C_cp[P[i]-1].index(Y[i]) + 1
    ans += "0"*(6-len(str(idx))) + str(idx)
    print(ans)

Fixed submission:
import copy as cp

def bin_search(n,lst):
    l=0
    r=len(lst)
    
    while r-1>=l:
        i=(l+r)//2
        if lst[i]==n: return i
        elif lst[i]<n: l=i+1
        else: r=i

N,M = map(int,input().split())
P = []
Y = []
for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)
#print(N,M,P,Y)

C_lst = [[] for _ in range(N)]
for i in range(M):
    C_lst[P[i]-1].append(Y[i])
#print(N,M,P,Y,C_lst)
C_cp = cp.deepcopy(C_lst)
for i in range(N):
    C_cp[i].sort()
for i in range(M):
    ans = "0"*(6-len(str(P[i]))) + str(P[i])
    idx = bin_search(Y[i],C_cp[P[i]-1]) + 1
    ans += "0"*(6-len(str(idx))) + str(idx)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input());A = [int(input()) for _ in range(n)];A.sort();if n%2==1:print(max(2*sum(A[n-n//2:])-sum(A[n-n//2-2:n-n//2])-2*sum(A[:n-n//2-2]),-2*sum(A[:n//2])+sum(A[n//2:n//2+2])+2*sum(A[n//2+2:])));else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n%2==1:print(max(2*sum(A[n-n//2:])-sum(A[n-n//2-2:n-n//2])-2*sum(A[:n-n//2-2]),-2*sum(A[:n//2])+sum(A[n//2:n//2+2])+2*sum(A[n//2+2:])))
else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n%2==1:print(max(2*sum(x[n-n//2:])-sum(x[n-n//2-2:n-n//2])-2*sum(x[:n-n//2-2]),-2*sum(x[:n//2])+sum(x[n//2:n//2+2])+2*sum(x[n//2+2:])))
else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n%2==1:print(max(2*sum(A[n-n//2:])-sum(A[n-n//2-2:n-n//2])-2*sum(A[:n-n//2-2]),-2*sum(A[:n//2])+sum(A[n//2:n//2+2])+2*sum(A[n//2+2:])))
else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

Buggy python submission (verdict: Runtime Error):
n=int(input());A=[int(input()) for _ in range(n)];A.sort();if n%2==1:print(max(2*sum(x[n-n//2:])-sum(x[n-n//2-2:n-n//2])-2*sum(x[:n-n//2-2]),-2*sum(x[:n//2])+sum(x[n//2:n//2+2])+2*sum(x[n//2+2:])));else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n%2==1:print(max(2*sum(A[n-n//2:])-sum(A[n-n//2-2:n-n//2])-2*sum(A[:n-n//2-2]),-2*sum(A[:n//2])+sum(A[n//2:n//2+2])+2*sum(A[n//2+2:])))
else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

Buggy python submission (verdict: Runtime Error):
# tenkaichi c

n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()

if n%2==1:
    ans1 = 2*sum(A[n//2+2:]) + sum(A[2:n//2+2]) -2*sum(A[:2])
    ans2 = 2*sum(A[n//2+1:]) - sum(A[n//2-1:n//2+1]) -2*sum(A[:n//2-1])
    print(max(ans1,ans2))
else:
    print(-2*sum(A[:(n-2)/2])-A[(n-2)/2]+A[(n-2)/2+1]+2*sum(A[(n-2)/2+2:]))

Fixed submission:
n = int(input())
A = [int(input()) for _ in range(n)]
A.sort()
if n%2==1:print(max(2*sum(A[n-n//2:])-sum(A[n-n//2-2:n-n//2])-2*sum(A[:n-n//2-2]),-2*sum(A[:n//2])+sum(A[n//2:n//2+2])+2*sum(A[n//2+2:])))
else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))