Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
count = 0
li = [3, 5, 7]

for i in range(300, N+1):
  t = []

  while(True):
    if i % 10 not in li:
      break

    if i % 10 not in t:
      t.append(i % 10)      

    i = math.floor(i / 10)

    if i == 0 and 3 in t and 5 in t and 7 in t:
      count += 1
      break

print(count)

Fixed submission:
N = int(input())
counter = 0

def dfs(cur, use):
  global counter

  if cur > N:
    return

  if use == 0b111:
    counter += 1

  dfs(cur * 10 + 7, use | 0b001)
  dfs(cur * 10 + 5, use | 0b010)
  dfs(cur * 10 + 3, use | 0b100)

dfs(0, 0b000)
print(counter)

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

N = int(input())
count = 0
li = [3, 5, 7]

for i in range(300, N+1):
  t = []

  while(True):
    if i % 10 not in li:
      break

    if i % 10 not in t:
      t.append(i % 10)      

    i = math.floor(i / 10)

    if i == 0 and 3 in t and 5 in t and 7 in t:
      count += 1
      break

print(count)

Fixed submission:
N = int(input())
counter = 0

def dfs(cur, use):
  global counter

  if cur > N:
    return

  if use == 0b111:
    counter += 1

  dfs(cur * 10 + 7, use | 0b001)
  dfs(cur * 10 + 5, use | 0b010)
  dfs(cur * 10 + 3, use | 0b100)

dfs(0, 0b000)
print(counter)
Buggy python submission (verdict: Runtime Error):
N = int(input())
li = [list(map(int, input().split())) for i in range(N)]

for x in range(101):
  for y in range(101):
    h = li[0][2] + abs(x - li[0][0]) + abs(y - li[0][1])
    ok = True

    for i in li:
      if h != i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False

    if ok:
      ans = [x, y, h]

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Fixed submission:
N = int(input())
li = [list(map(int, input().split())) for i in range(N)]

s = 0

for index, i in enumerate(li):
  if i[2] > 0:
    s = index
    break
  
for x in range(101):
  for y in range(101):
    h = li[s][2] + abs(x - li[s][0]) + abs(y - li[s][1])
    ok = True

    for i in li:
      if i[2] > 0 and h != i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False
      if i[2] == 0 and h > i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False

    if ok:
      ans = [x, y, h]

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
li = [list(map(int, input().split())) for i in range(N)]

for x in range(101):
  for y in range(101):
    h = li[0][2] + abs(x - li[0][0]) + abs(y - li[0][1])
    ok = True

    for i in li:
      if h != i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False

    if ok:
      ans = [x, y, h]

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Fixed submission:
N = int(input())
li = [list(map(int, input().split())) for i in range(N)]

s = 0

for index, i in enumerate(li):
  if i[2] > 0:
    s = index
    break
  
for x in range(101):
  for y in range(101):
    h = li[s][2] + abs(x - li[s][0]) + abs(y - li[s][1])
    ok = True

    for i in li:
      if i[2] > 0 and h != i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False
      if i[2] == 0 and h > i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False

    if ok:
      ans = [x, y, h]

print("{} {} {}".format(ans[0], ans[1], ans[2]))
Buggy python submission (verdict: Runtime Error):
N = int(input())

dp = [100000] * (10**5)
dp[0] = 0

for n in range(N):
  count = 1
  while(True):
    if count > N:
      break

    dp[n+count] = min(dp[n+count], dp[n]+1)
    count *= 6

  count = 1
  while(True):
    if count > N:
      break

    dp[n+count] = min(dp[n+count], dp[n]+1)
    count *= 9

print(dp[N])

Fixed submission:
N = int(input())

dp = [10000] * (N+1)

dp[0] = 0

for n in range(N+1):
  count = 1
  while(True):
    if count > N:
      break

    if n - count < 0:
      break

    dp[n] = min(dp[n], dp[n-count]+1)
    count *= 6

  count = 1
  while(True):
    if count > N:
      break

    if n - count < 0:
      break

    dp[n] = min(dp[n], dp[n-count]+1)
    count *= 9

print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
li=list(input())

min = 100000000

w = 0

for index, i in enumerate(li):
  a = 0
  
  s = li[index + 1:].count('E')

  a = w + s
    
  if min > a:
    min = a
    
  if i == 'W':
    w += 1

print(min)

Fixed submission:
from itertools import accumulate
 
n = int(input())
s = [c == 'W' for c in input()]
l = accumulate([0] + s[:-1])
r = accumulate([0] + [not c for c in reversed(s[1:])])
print(min(e + w for e, w in zip(l, reversed(list(r)))))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
li=list(input())

min = 100000000

for index, i in enumerate(li):
  a = 0
  
  w1 = li[0:index].count('W')
  s1 = li[index + 1:].count('E')

  a = w1 + s1
    
  if min > a:
    min = a
    
print(min)

Fixed submission:
from itertools import accumulate
 
n = int(input())
s = [c == 'W' for c in input()]
l = accumulate([0] + s[:-1])
r = accumulate([0] + [not c for c in reversed(s[1:])])
print(min(e + w for e, w in zip(l, reversed(list(r)))))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
li=list(input())

min = 1000000000

for index, i in enumerate(li):
  a = 0
  
  left = li[0:index]
  right = li[index + 1:]
  
  w1 = left.count('W')
  s1 = right.count('E')

  a = w1 + s1
    
  if min > a:
    min = a
    
print(min)

Fixed submission:
from itertools import accumulate
 
n = int(input())
s = [c == 'W' for c in input()]
l = accumulate([0] + s[:-1])
r = accumulate([0] + [not c for c in reversed(s[1:])])
print(min(e + w for e, w in zip(l, reversed(list(r)))))
Buggy python submission (verdict: Runtime Error):
s = input()
K = int(input())

ans = []
now = ""

for index, i in enumerate(s):
  now = i
  ans.append(i)

  for indexs, k in enumerate(s):
    if indexs <= index:
      continue

    if s[indexs] == now[-1]:
      break

    now += k
    ans.append(now)
    
ans = list(set(ans))
ans.sort()

print(ans[K-1])

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

ans = []

for index, i in enumerate(s):
  ans.append(i)

  count = 1
  now = i
  for indexs, k in enumerate(s):
    if indexs <= index:
      continue
      
    if count >= 5:
      break

    now += k
    ans.append(now)
    count += 1

ans = list(set(ans))
ans.sort()
print(ans[K-1])

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

ans = []
now = ""

for index, i in enumerate(s):
  now = i
  ans.append(i)

  for indexs, k in enumerate(s):
    if indexs <= index:
      continue

    if s[indexs] == now[-1]:
      break

    now += k
    ans.append(now)
    
ans = list(set(ans))
ans.sort()

print(ans[K-1])

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

ans = []

for index, i in enumerate(s):
  ans.append(i)

  count = 1
  now = i
  for indexs, k in enumerate(s):
    if indexs <= index:
      continue
      
    if count >= 5:
      break

    now += k
    ans.append(now)
    count += 1

ans = list(set(ans))
ans.sort()
print(ans[K-1])
Buggy python submission (verdict: Runtime Error):
import math

A, B, C, X, Y = map(int,input().split())

ans = 100000000000000000000000000

for x in range(X):
  ab = (X - x) * 2
  
  if Y > (ab / 2):
    continue

  y = Y - (ab / 2)

  a = (A * x) + (B * y) + (C * ab)

  if ans > a:
    ans = a

print(math.floor(a))

Fixed submission:
A, B, C, X, Y = map(int,input().split())

ans = 100000000000000000000000000

AB = C * 2

for ab in range(100000 + 1):
  x = 0
  if X - ab > 0:
    x = X - ab
  
  y = 0
  if Y - ab > 0:
    y = Y - ab
  
  d = (x * A) + (y * B) + (AB * ab)

  if ans > d:
    ans = d

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

N = int(input())
li = list(map(int, input().split()))

m = sum(li) / N

new = sorted(li)

for i in range(N):
  if i <= (N / 2) - 1
    print(new[math.floor(N/2)])
  else:
    print(new[math.floor(N/2) - 1])

Fixed submission:
n = int(input())
s = list(map(int, input().split()))
sx = sorted(s)
a = sx[(n//2)-1]
b = sx[n//2]
for i in s:
  if i <= a:
    print(b)
  else:
    print(a)

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

N = int(input())
li = list(map(int, input().split()))

m = sum(li) / N

new = sorted(li)

for i in range(N):
  if i <= (N / 2) - 1
    print(new[math.floor(N/2)])
  else:
    print(new[math.floor(N/2) - 1])

Fixed submission:
n = int(input())
s = list(map(int, input().split()))
sx = sorted(s)
a = sx[(n//2)-1]
b = sx[n//2]
for i in s:
  if i <= a:
    print(b)
  else:
    print(a)

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

N = int(input())
li = list(map(int, input().split()))

for i in range(N):
  a = copy.copy(li)
  a.pop(i)
  print(statistics.median(a))

Fixed submission:
n = int(input())
s = list(map(int, input().split()))
sx = sorted(s)
a = sx[(n//2)-1]
b = sx[n//2]
for i in s:
  if i <= a:
    print(b)
  else:
    print(a)

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

N = int(input())
li = list(map(int, input().split()))

for i in range(N):
  a = []
  for index, k in enumerate(li):
    if i == index:
      continue
      
    a.append(k)
    
  print(statistics.median(a))

Fixed submission:
n = int(input())
s = list(map(int, input().split()))
sx = sorted(s)
a = sx[(n//2)-1]
b = sx[n//2]
for i in s:
  if i <= a:
    print(b)
  else:
    print(a)

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

N = int(input())
li = list(map(int, input().split()))

for i in range(N):
  a = []
  for index, k in enumerate(li):
    if i == index:
      continue
      
    a.append(k)
    
  print(statistics.median(a))

Fixed submission:
n = int(input())
s = list(map(int, input().split()))
sx = sorted(s)
a = sx[(n//2)-1]
b = sx[n//2]
for i in s:
  if i <= a:
    print(b)
  else:
    print(a)
Buggy python submission (verdict: Runtime Error):
a=int(input())
list = []

for i in a:
  list.append(int(input()))

print(list(set(list)))

Fixed submission:
a=int(input())
lis = []

for i in range(a):
  lis.append(int(input()))

new = list(set(lis))
print(len(new))
Buggy python submission (verdict: Runtime Error):
li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in range(a + 1):
  ans = 0
  tmp = i

  while(i >= 1):
    ans += i % 10
    i = math.floor(i / 10)

  if b <= ans <= c:
    list.append(tmp)

data = 0
for e in list:
  data += e

print(data)

Fixed submission:
import math

li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in range(a + 1):
  ans = 0
  tmp = i

  while(i >= 1):
    ans += i % 10
    i = math.floor(i / 10)

  if b <= ans <= c:
    list.append(tmp)

data = 0
for e in list:
  data += e

print(data)

Buggy python submission (verdict: Runtime Error):
li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in a + 1:
  ans = 0

  while(i != 0):
    ans += i % 10
    i / 10

  if b <= ans <= c:
    list.append(ans)

data = 0
for e in list:
  data += e

print(data)

Fixed submission:
import math

li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in range(a + 1):
  ans = 0
  tmp = i

  while(i >= 1):
    ans += i % 10
    i = math.floor(i / 10)

  if b <= ans <= c:
    list.append(tmp)

data = 0
for e in list:
  data += e

print(data)

Buggy python submission (verdict: Runtime Error):
list = []

for i in range(a + 1):
  if i < 10:
    if b <= i <= c:
      list.append(i)
  else:
    d = [int(i) for c in str(i)]
    e = 0
    for j in d:
      e += j
    if b <= e <= c:
      list.append(i)

k = 0
for t in list:
  k += t
print(k)

Fixed submission:
import math

li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in range(a + 1):
  ans = 0
  tmp = i

  while(i >= 1):
    ans += i % 10
    i = math.floor(i / 10)

  if b <= ans <= c:
    list.append(tmp)

data = 0
for e in list:
  data += e

print(data)

Buggy python submission (verdict: Runtime Error):
li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in range(a + 1)
  if i < 10:
    if b <= i <= c:
      list.append(i)
  else:
    d = [int(i) for c in str(i)]
    e = 0
    for j in d:
      e += j
    if b <= e <= c:
      list.append(i)

k = 0
for t in list:
  k += t
print(k)

Fixed submission:
import math

li = list(map(int,input().split()))
a = li[0]
b = li[1]
c = li[2]

list = []

for i in range(a + 1):
  ans = 0
  tmp = i

  while(i >= 1):
    ans += i % 10
    i = math.floor(i / 10)

  if b <= ans <= c:
    list.append(tmp)

data = 0
for e in list:
  data += e

print(data)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()

ss = sorted(s)
tt = sorted(t)

ans = "No"

for i in range(len(ss)):
  if ss[i] < tt[i]:
    ans = "Yes"
    break

print(ans)

Fixed submission:
s=input()
t=input()

ss = sorted(s)
tt = sorted(t)

sss = "".join(ss)

tt.reverse()
ttt = "".join(tt)

if sss < ttt:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

t = len(T)
ans = "UNRESTORABLE"

answers = []

for index, s in enumerate(S):
  if index + t > len(S):
    break

  if s != '?' and s != T[0]:
    continue

  for a in range(1, t):
    if S[index+a] != '?' and S[index+a] != T[a]:
      break

  else:
    ans = S[0:index] + T + S[index+t:-1]
    answers.append(ans.replace('?', 'a'))

answers.sort()  
print(answers[0])

Fixed submission:
S = input()
T = input()

ans = []

for index, s in enumerate(S):
  if s == '?' or s == T[0]:
    if index+len(T)-1 > len(S)-1:
        break

    for indexs, t in enumerate(T):
      if S[index+indexs] != t and S[index+indexs] != '?':
        break
    else:
      ans.append(S[0:index]+T+S[index+len(T):])


if len(ans) == 0:
  print("UNRESTORABLE")
else:
  ans.sort()
  print(ans[0].replace('?', 'a'))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
li = [0] * 100000000

for n in range(N):
  li[int(input())] += 1

ans = 0

for i in li:
  if i % 2 == 1:
    ans += 1

print(ans)

Fixed submission:
N=int(input())
sets = set()

for n in range(N):
  a = int(input())
  
  if a in sets:
    sets.remove(a)
  else:
    sets.add(a)

print(len(sets))

Buggy python submission (verdict: Runtime Error):
N=int(input())
li = [0] * 1000000000000

for n in range(N):
  li[int(input())] += 1

ans = 0

for i in li:
  if i % 2 == 1:
    ans += 1

print(ans)

Fixed submission:
N=int(input())
sets = set()

for n in range(N):
  a = int(input())
  
  if a in sets:
    sets.remove(a)
  else:
    sets.add(a)

print(len(sets))

Buggy python submission (verdict: Runtime Error):
N=int(input())
li = [0] * 100002

for n in range(N):
  li[int(input())] += 1

ans = 0

for i in li:
  if i % 2 == 1:
    ans += 1

print(ans)

Fixed submission:
N=int(input())
sets = set()

for n in range(N):
  a = int(input())
  
  if a in sets:
    sets.remove(a)
  else:
    sets.add(a)

print(len(sets))

Buggy python submission (verdict: Runtime Error):
N=int(input())
li = [0] * 100002

for n in range(N):
  li[int(input())] += 1

ans = 0

for i in li:
  if i % 2 == 1:
    ans += 1

print(ans)

Fixed submission:
N=int(input())
sets = set()

for n in range(N):
  a = int(input())
  
  if a in sets:
    sets.remove(a)
  else:
    sets.add(a)

print(len(sets))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
li = np.array([])

N=int(input())
li = list(map(int, input().split()))
arr = np.array(li)

max = 0

for i in range(100000 + 1):

  a = np.count_nonzero(arr == i)
  a += np.count_nonzero(arr == (i + 1))
  a += np.count_nonzero(arr == (i - 1))

  if max < a:
    max = a

print(max)

Fixed submission:
n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v-1] += 1
    cnt[v+1] += 1
    
print(max(cnt))

Buggy python submission (verdict: Runtime Error):
import numpy as np
li = np.array([])

N=int(input())
li = list(map(int, input().split()))
arr = np.array(li)

max = 0

for i in range(100000 + 1):

  a = np.count_nonzero(arr == i or arr == (i + 1) or arr == (i - 1))

  if max < a:
    max = a

print(a)

Fixed submission:
n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v-1] += 1
    cnt[v+1] += 1
    
print(max(cnt))

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

max = 0

for i in range(100000 + 1):
  X = i

  new = [l for l in li if l == X or l == (X + 1) or l == (X - 1)]

  if max < len(new):
    max = len(new)

print(max)

Fixed submission:
n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v-1] += 1
    cnt[v+1] += 1
    
print(max(cnt))

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

max = 0

for i in range(100000 + 1):
  X = i

  new = [l for l in li if l == X or l == (X + 1) or l == (X - 1)]

  if max < len(new):
    max = len(new)

print(max)

Fixed submission:
n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v-1] += 1
    cnt[v+1] += 1
    
print(max(cnt))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

a = []
b = []

for i in li:
  if i[1] == N:
    b.append(i[0])

  if i[0] == 1:
    a.append(i[1])
    
if len(a) == 0 or len(b) == 0:
  print("IMPOSSIBLE")
  sys.exit()
    
for i in a:
  if i in b:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

Fixed submission:
import sys
from collections import defaultdict
d = defaultdict(int)

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

for i in li:
  if i[1] == N:
    d[i[0]] += 1

for i in li:
  if i[0] == 1 and d[i[1]] != 0:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

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

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

a = []
b = []

for i in li:
  if i[1] == N:
    b.append(i[0])

  if i[0] == 1:
    a.append(i[1])
    
if len(a) == 0 or len(b) == 0:
  print("IMPOSSIBLE")
  sys.exit()
    
for i in a:
  if i in b:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

Fixed submission:
import sys
from collections import defaultdict
d = defaultdict(int)

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

for i in li:
  if i[1] == N:
    d[i[0]] += 1

for i in li:
  if i[0] == 1 and d[i[1]] != 0:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

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

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

a = []

for i in li:
  if i[0] == N:
    a.append(i[1])

  if i[1] == N:
    a.append(i[0])

for i in li:
  if i[0] == 1 and i[1] in a:
    print("POSSIBLE")
    sys.exit()

print("IMPOSSIBLE")

Fixed submission:
import sys
from collections import defaultdict
d = defaultdict(int)

N, M = map(int, input().split())
li = [list(map(int, input().split())) for n in range(M)]

for i in li:
  if i[1] == N:
    d[i[0]] += 1

for i in li:
  if i[0] == 1 and d[i[1]] != 0:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

B = []

if N % 2 == 0:
  for index, a in enumerate(A):
    if index % 2 == 1:
      B.insert(0, a)
    else:
      B.append(a)
else:
  for index, a in enumerate(A):
    if index % 2 == 0:
      B.insert(0, a)
    else:
      B.append(a)

for b in B:
  print(b, end=" ")

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

B = []
T = []

if N % 2 == 0:
  for index, a in enumerate(A):
    if index % 2 == 1:
      T.append(a)
    else:
      B.append(a)
else:
  for index, a in enumerate(A):
    if index % 2 == 0:
      T.append(a)
    else:
      B.append(a)

T.reverse()
T.extend(B)


for b in T:
  print(b, end=" ")

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

B = []

if N % 2 == 0:
  for index, a in enumerate(A):
    if index % 2 == 1:
      B.insert(0, a)
    else:
      B.append(a)
else:
  for index, a in enumerate(A):
    if index % 2 == 0:
      B.insert(0, a)
    else:
      B.append(a)

for b in B:
  print(b, end=" ")

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

B = []
T = []

if N % 2 == 0:
  for index, a in enumerate(A):
    if index % 2 == 1:
      T.append(a)
    else:
      B.append(a)
else:
  for index, a in enumerate(A):
    if index % 2 == 0:
      T.append(a)
    else:
      B.append(a)

T.reverse()
T.extend(B)


for b in T:
  print(b, end=" ")

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

B = []

for a in A:
  B.append(a)
  B.reverse()

for b in B:
  print(b, end=" ")

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

B = []
T = []

if N % 2 == 0:
  for index, a in enumerate(A):
    if index % 2 == 1:
      T.append(a)
    else:
      B.append(a)
else:
  for index, a in enumerate(A):
    if index % 2 == 0:
      T.append(a)
    else:
      B.append(a)

T.reverse()
T.extend(B)


for b in T:
  print(b, end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
li = [list(map(int, input().split())) for n in range(N)]

a = []

for i in li:
  b = [i[0]] * i[1]
  a.extend(b)

a.sort()

print(a[K-1])

Fixed submission:
from collections import defaultdict
d = defaultdict(int)

N, K = map(int, input().split())
li = [list(map(int, input().split())) for n in range(N)]

for i in li:
  d[i[0]] += i[1]
  
count = 0
new = sorted(d)

for i in new:
  count += d[i]
  
  if count >= K:
    print(i)
    break
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
t = list(map(int,input().split()))

newLi = sorted(t, reverse=True)
li = []
ans = 0

for i in range(N):
  k = [newLi.pop(0), newLi.pop(0), newLi.pop(-1)]
  ans += k[1]

print(ans)

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

newLi = sorted(t, reverse=True)
ans = 0

for i in range(N):
  ans += newLi[i * 2 + 1]

print(ans)

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

newLi = sorted(t, reverse=True)
li = []

for i in range(N):
  k = [newLi.pop(0), newLi.pop(0), newLi.pop(-1)]
  li.append(k)

ans = 0

for s in li:
  ans += s[1]

print(ans)

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

newLi = sorted(t, reverse=True)
ans = 0

for i in range(N):
  ans += newLi[i * 2 + 1]

print(ans)

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

newLi = sorted(t, reverse=True)
li = []

for i in range(N):
  k = []

  k.append(newLi.pop(0))
  k.append(newLi.pop(0))
  k.append(newLi.pop(-1))

  li.append(k)

ans = 0

for s in li:
  ans += s[1]

print(ans)

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

newLi = sorted(t, reverse=True)
ans = 0

for i in range(N):
  ans += newLi[i * 2 + 1]

print(ans)

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

newLi = sorted(t, reverse=True)
li = []

for i in range(N):
  k = []

  k.append(newLi.pop(0))
  k.append(newLi.pop(0))
  k.append(newLi.pop(-1))

  li.append(k)

ans = 0

for s in li:
  ans += s[1]

print(ans)

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

newLi = sorted(t, reverse=True)
ans = 0

for i in range(N):
  ans += newLi[i * 2 + 1]

print(ans)