Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m//gcd(n, m)

a = [i*(l//n) for i in range(n)]
b = [i*(l//m) for i in range(m)]

x = set(a) & set(b)

for i in x:
    if s[a.index(i)] != t[b.index(i)]:
        print(-1)
        exit()

print(l)

Fixed submission:
def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m//gcd(n, m)

a = [i*(l//n) for i in range(n)]
b = [i*(l//m) for i in range(m)]

x = set(a) & set(b)

for i in x:
    if s[a.index(i)] != t[b.index(i)]:
        print(-1)
        exit()

print(l)

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m // gcd(n, m)

x = [0] * l
a, b = [], []

for i in range(n):
    x[i*(l//n)] = s[i]
    a.append(i*(l//n))

for j in range(m):
    x[j*(l//m)] = t[j]
    b.append(j*(l//m))

if "".join([x[i] for i in a]) == s and ("".join([x[j] for j in b])) == t:
    print(l)
else:
    print(-1)

Fixed submission:
def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m//gcd(n, m)

a = [i*(l//n) for i in range(n)]
b = [i*(l//m) for i in range(m)]

x = set(a) & set(b)

for i in x:
    if s[a.index(i)] != t[b.index(i)]:
        print(-1)
        exit()

print(l)

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m // gcd(n, m)

x = [" "] * l
a, b = [], []
for i in range(n):
    x[i*(l//n)] = s[i]
    a.append(i*(l//n))
for j in range(m):
    x[j*(l//m)] = t[j]
    b.append(j*(l//m))

if "".join([x[i] for i in a]) == s and ("".join([x[j] for j in b])) == t:
    print(l)
else:
    print(-1)

Fixed submission:
def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m//gcd(n, m)

a = [i*(l//n) for i in range(n)]
b = [i*(l//m) for i in range(m)]

x = set(a) & set(b)

for i in x:
    if s[a.index(i)] != t[b.index(i)]:
        print(-1)
        exit()

print(l)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
x = list(map(int, input().split()))

ans = 10 ** 9

for i in range(n-k+1):
    temp = x[i:i+k]
    dif = temp[-1] - temp[0]
    from_s = min(abs(temp[-1]), abs(temp[0]))

    ans = min(dif + from_s, ans)

print(ans)

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

ans = 10 ** 9

for i in range(n-k+1):

    l = abs(x[i]) + abs(x[i+k-1] - x[i])
    r = abs(x[i+k-1]) + abs(x[i+k-1] - x[i])

    if l < r:
        ans = min(ans, l)
    else:
        ans = min(ans, r)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

ans = 0
for x in a:
    ans += (reduce(lcm, a) - 1) % x

print(ans)

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

m = 1
for i in a:
  m *= i

ans = 0
for i in a:
  ans += (m-1) % i

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

n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

  else:
    end += 1


print(ans)

Fixed submission:
import math

n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

Fixed submission:
import math

n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


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

a = a[k:]
c = 1

while True:
    if len(a) == 0:
      break
    a = a[k-1:]
    c += 1
print(c)

Fixed submission:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

a = a[k:]
c = 1

c += math.ceil(len(a) / (k-1))
print(c)
Buggy python submission (verdict: Runtime Error):
def height(n):
    return sum([i for i in range(n+1)])

tower = []

for i in range(1, 1000):
    tower.append(height(i))

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

for i in tower:
    if tower[i] > a:
        ind = i-1
        break

print(abs(tower[ind] - a))

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

print(int(((((1+ (b - a)) * (b - a)) / 2 - b))))

Buggy python submission (verdict: Runtime Error):
def height(n):
    return sum([i for i in range(n+1)])

tower = []

for i in range(1, 1000):
    tower.append(height(i))

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

for i in tower:
    if tower[i] > a:
        ind = i-1
        break

print(abs(tower[ind] - a))

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

print(int(((((1+ (b - a)) * (b - a)) / 2 - b))))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = 10 ** 6
for i in range(1, n+1):
    ans = min(ans, s[:i-1].count("W") + s[i:].count("E"))

print(ans)

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

l = [0]
r = [0]

for i in s:
    if i == "W":
        l.append(l[-1] + 1)
    else:
        l.append(l[-1])

for i in s[::-1]:
    if i == "E":
        r.append(r[-1] + 1)
    else:
        r.append(r[-1])

l = l[1:]
r = r[1:][::-1]

ans = 10 ** 9

for i in zip(l, r):
    ans = min(sum(i), ans)

print(ans-1)

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

ans = 10 ** 6

for i in range(n-1):
    left = s[:i].count("W")
    right = s[i+1:].count("E")

    ans = min(ans, left+right)

print(ans)

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

l = [0]
r = [0]

for i in s:
    if i == "W":
        l.append(l[-1] + 1)
    else:
        l.append(l[-1])

for i in s[::-1]:
    if i == "E":
        r.append(r[-1] + 1)
    else:
        r.append(r[-1])

l = l[1:]
r = r[1:][::-1]

ans = 10 ** 9

for i in zip(l, r):
    ans = min(sum(i), ans)

print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [i for i in input()]

ans = 10 ** 6

for i in range(n-1):
    left = s[:i].count("W")
    right = s[i+1:].count("E")

    ans = min(ans, left+right)

print(ans)

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

l = [0]
r = [0]

for i in s:
    if i == "W":
        l.append(l[-1] + 1)
    else:
        l.append(l[-1])

for i in s[::-1]:
    if i == "E":
        r.append(r[-1] + 1)
    else:
        r.append(r[-1])

l = l[1:]
r = r[1:][::-1]

ans = 10 ** 9

for i in zip(l, r):
    ans = min(sum(i), ans)

print(ans-1)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())

temp = "0" * (h+2)

s = [temp]

for i in range(h):
    s.append("0" + input() + "0")

s.append(temp)

# print(s)

for i in range(h+2):
    for j in range(w+2):
        flag = False
        if s[i][j] == "#":
            if s[i-1][j] == "#" or s[i+1][j] == "#" or s[i][j+1] == "#" or s[i][j-1] == "#":
                flag = True
            if not flag:
                print("No")
                exit()

print("Yes")

Fixed submission:
h, w = map(int, input().split())

temp = "0" * (w+2)

s = [temp]

for i in range(h):
    s.append("0" + input() + "0")

s.append(temp)

for i in range(h+2):
    for j in range(w+2):
        flag = False
        if s[i][j] == "#":
            if s[i-1][j] == "#" or s[i+1][j] == "#" or s[i][j+1] == "#" or s[i][j-1] == "#":
                flag = True
            if not flag:
                print("No")
                exit()

print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

m = (n-1) // 2
 
x_sorted = sorted(x)

ans = []

for i in range(n):
    ind = bisect.bisect_left(x_sorted, x[i])
    ans.append(x_sorted[0:ind] + x_sorted[ind+1:])

for i in range(n):
    print(ans[i][m])

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

sorted_x = sorted(x)
l = sorted_x[n//2]
s = sorted_x[n//2-1]

for i in x:
    if i <= s:
        print(l)
    else:
        print(s)

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

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

m = (n-1) // 2
 
x_sorted = sorted(x)

for i in range(n):
    ind = bisect.bisect_left(x_sorted, x[i])
    print((x_sorted[0:ind] + x_sorted[ind+1:])[m])

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

sorted_x = sorted(x)
l = sorted_x[n//2]
s = sorted_x[n//2-1]

for i in x:
    if i <= s:
        print(l)
    else:
        print(s)

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

m = (n-1) // 2
 
x_sorted = sorted(x)

for i in range(n):
    ind = x_sorted.index(x[i])
    print((x_sorted[0:ind] + x_sorted[ind+1:])[m])

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

sorted_x = sorted(x)
l = sorted_x[n//2]
s = sorted_x[n//2-1]

for i in x:
    if i <= s:
        print(l)
    else:
        print(s)

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

for i in range(n):
    print(sorted(x[0:i] + x[i+1:])[(n-1)//2])

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

sorted_x = sorted(x)
l = sorted_x[n//2]
s = sorted_x[n//2-1]

for i in x:
    if i <= s:
        print(l)
    else:
        print(s)
Buggy python submission (verdict: Runtime Error):
a, b, k =  map(int, input().split())

x = list(range(a, b+1))

i = x[:k]
j = x[-k:]

l = []

for k in i:
    l.append(k)

for k in j:
    l.append(k)

for i in sorted(list(set(l))):
    print(i)


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

if (abs(a-b) + 1) / 2 <= k:
  for i in range(a, b+1):
    print(i)
  exit()

for i in range(k):
  print(a+i)

for i in sorted([b - i for i in range(k)]):
  print(i)

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

x = list(range(a, b+1))

i = x[:k]
j = x[-k:]

l = []

for k in i:
    l.append(k)

for k in j:
    l.append(k)

for i in sorted(list(set(l))):
    print(i)


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

if (abs(a-b) + 1) / 2 <= k:
  for i in range(a, b+1):
    print(i)
  exit()

for i in range(k):
  print(a+i)

for i in sorted([b - i for i in range(k)]):
  print(i)

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

x = list(range(a, b+1))

i = x[:k]
j = x[-k:]

l = []

for k in i:
    l.append(k)

for k in j:
    l.append(k)

for i in sorted(list(set(l))):
    print(i)


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

if (abs(a-b) + 1) / 2 <= k:
  for i in range(a, b+1):
    print(i)
  exit()

for i in range(k):
  print(a+i)

for i in sorted([b - i for i in range(k)]):
  print(i)

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

x = list(range(a, b+1))

i = x[:k]
j = x[-k:]

for k in i:
    print(k)

for k in j:
    print(k)


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

if (abs(a-b) + 1) / 2 <= k:
  for i in range(a, b+1):
    print(i)
  exit()

for i in range(k):
  print(a+i)

for i in sorted([b - i for i in range(k)]):
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    temp = [0] + a[:i] + a[i+1:] + [0]
    ans = 0
    for i in range(len(temp)-1):
        ans += abs(temp[i+1] - temp[i])
    print(ans)

Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

b = [0]

for i in range(len(a)-1):
    b.append(abs(a[i+1]-a[i]) + b[-1])

s = b[-1]

for i in range(1, len(a)-1):
    ans = s - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1])
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def cs(x):
    ans = 0
    for i in range(len(x)-1):
        ans += abs(x[i+1]-x[i])
    return ans


n = int(input())
a = [0] + list(map(int, input().split())) + [0]

for i in range(1, len(a)-1):
    print(cs(a[:i] + a[i+1:]))

Fixed submission:
def cs(x):
    ans = 0
    for i in range(len(x)-1):
        ans += abs(x[i+1]-x[i])
    return ans


n = int(input())
a = [0] + list(map(int, input().split())) + [0]

s = cs(a)

for i in range(1, len(a)-1):
    dif = abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]) - abs(a[i+1]-a[i-1])
    print(s-dif)

Buggy python submission (verdict: Time Limit Exceeded):
def cs(x):
    ans = 0
    for i in range(len(x)-1):
        ans += abs(x[i+1]-x[i])
    return ans


n = int(input())
a = [0] + list(map(int, input().split())) + [0]

for i in range(1, len(a)-1):
    print(cs(a[:i] + a[i+1:]))

Fixed submission:
def cs(x):
    ans = 0
    for i in range(len(x)-1):
        ans += abs(x[i+1]-x[i])
    return ans


n = int(input())
a = [0] + list(map(int, input().split())) + [0]

s = cs(a)

for i in range(1, len(a)-1):
    dif = abs(a[i]-a[i-1]) + abs(a[i+1]-a[i]) - abs(a[i+1]-a[i-1])
    print(s-dif)
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if 10000 * a + 5000 + b + 1000 * (n-(a+b)) == y:
            print(a, b, n-(a+b))
            exit()

print(-1, -1, -1)

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

for a in range(0, n+1):
    for b in range(0, n-a+1):
        if 10000 * a + 5000 * b + 1000 * (n-(a+b)) == y:
            print(a, b, n-(a+b))
            exit()

print("-1 -1 -1")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

aset = set(a)

ans = 0

for i in aset:
    if a.count(i) < i:
        ans += a.count(i)
    else:
        ans += a.count(i) - i

print(ans)

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

d = dict()
for i in a:
    d[i] = d.get(i, 0) + 1


ans = 0
for i in d.items():
    if i[0] > i[1]:
        ans += i[1]
    elif i[0] < i[1]:
        ans += i[1] - i[0]

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

d = dict()
for i in range(n):
    d[a[i]] = d.get(a[i], 0) + 1

d = sorted(d.values())
ans = 0
while k < len(d):
    ans += d.pop(0)

print(ans)

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

d = dict()
for i in range(n):
    d[a[i]] = d.get(a[i], 0) + 1

d = sorted(d.values())
print(sum(d[:len(d)-k]))
Buggy python submission (verdict: Runtime Error):
s = input()

if re.match('A?KIHA?BA?RA?$', s):
    print("YES")
else:
    print("NO")

Fixed submission:
import re

s = input()

if re.match('A?KIHA?BA?RA?$', s):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
s = input()

d = dict()
for a in s:
    d[a] = d.get(a, 0) + 1

if len(d) == 2 and sum(d.values()) > 2:
    print("NO")
    exit()

t = sorted([i - (min(d.values())) for i in d.values()])

if t[-1] - t[-2] > 1:
    print("NO")
else:
    print("YES")

Fixed submission:
s = input()

a = s.count("a")
b = s.count("b")
c = s.count("c")

if max(a, b, c) - min(a, b, c) <= 1:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
for i in input().split():
    if int(i) % 2 == 0:
        cnt *= 2

print(3**n - cnt)

Fixed submission:
n = int(input())
cnt = 1
for i in input().split():
    if int(i) % 2 == 0:
        cnt *= 2

print(3**n - cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())

x = dict()
for i in input().split():
    x[i] = x.get(i, 0) + 1

m = int(input())

for i in input().split():
    if x[i] == 0 or i not in x:
        print("NO")
        exit()
    else:
        x[i] -= 1
print("YES")

Fixed submission:
n = int(input())

ht = {}

for i in input().split():
  ht[i] = ht.get(i, 0) + 1

m = int(input())

for i in input().split():
  if i not in ht or ht[i] == 0:
    print("NO")
    exit()
  else:
    ht[i] -= 1

print("YES")

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

x = dict()
for i in input().split():
    x[i] = x.get(i, 0) + 1

m = int(input())

for i in input().split():
    if x[i] == 0 or i not in x:
        print("NO")
        exit()
    else:
        x[i] -= 1
print("YES")

Fixed submission:
n = int(input())

ht = {}

for i in input().split():
  ht[i] = ht.get(i, 0) + 1

m = int(input())

for i in input().split():
  if i not in ht or ht[i] == 0:
    print("NO")
    exit()
  else:
    ht[i] -= 1

print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = sorted(list(map(int, input().split())))
m = int(input())
t = sorted(list(map(int, input().split())))

for i in t:
  if i in d:
    d.remove(i)
  else:
    print("NO")
    exit()

print("YES")

Fixed submission:
n = int(input())

ht = {}

for i in input().split():
  ht[i] = ht.get(i, 0) + 1

m = int(input())

for i in input().split():
  if i not in ht or ht[i] == 0:
    print("NO")
    exit()
  else:
    ht[i] -= 1

print("YES")

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

for i in t:
  if i in d:
    d.remove(i)
  else:
    print("NO")
    exit()

print("YES")

Fixed submission:
n = int(input())

ht = {}

for i in input().split():
  ht[i] = ht.get(i, 0) + 1

m = int(input())

for i in input().split():
  if i not in ht or ht[i] == 0:
    print("NO")
    exit()
  else:
    ht[i] -= 1

print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []

for i in range(n):
    temp = int(input())
    if temp not in a:
        a.append(temp)
    else:
        a.pop(a.index(temp))

print(len(a))

Fixed submission:
n = int(input())
a = set()

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

print(len(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = [int(i)-1 for i in input().split()]
ans = 0
for i in range(n):
    if p[i] == i:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1

print(ans)

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

x = []

for i in range(n):
    if p[i] - 1 == i:
        x.append('x')
    else:
        x.append('o')

cnt = 0
for i in range(n-1):
    if x[i] == "x" and x[i+1] == 'o':
        cnt += 1
    elif x[i] == "x" and x[i+1] == 'x':
        cnt += 1
        x[i+1] = 'o'

if x[n-1] == "x":
    cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
n -= 1

ab = []

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

for i in ab:
    if i[0] == 0:
        next_p = i[1]
        for j in ab:
            if j[0] == next_p:
                if j[1] == n:
                    print("POSSIBLE")
                    exit()

print("IMPOSSIBLE")

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

ab = [[] for i in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)

for i in ab[0]:
    for j in ab[i]:
        if j == n:
            print("POSSIBLE")
            exit()

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

sum_a = sum(a)

lis = [sum_a]

for i in range(n-1):
    lis.append(abs(sum_a - 2 * sum(a[:i+1])))

print(min(lis[1:]))

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

if n == 2:
    print(abs(a[1] - a[0]))
    exit()

s = [0]

for i in range(n):
    s.append(s[-1]+a[i])

s = s[1:]

ma = s[-1]

ans = 10 ** 18


for i in s[:-1]:
    ans = min(ans, abs(ma-2*i))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

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

for _ in range(n):
    b.append(a.popleft())
    b.reverse()

print(*b)


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

a_odd = a[0::2]
a_even = a[1::2]

if n % 2 == 1:
    print(" ".join(a_odd[::-1] + a_even))
else:
    print(" ".join(a_even[::-1] + a_odd))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()
b = []
for i in range(n):
    n = a[i]
    b.append(n)
    b = b[::-1]

print(*b)

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

a_odd = a[0::2]
a_even = a[1::2]

if n % 2 == 1:
    print(" ".join(a_odd[::-1] + a_even))
else:
    print(" ".join(a_even[::-1] + a_odd))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()[::-1]
b = []
for i in range(n):
    n = a.pop()
    b.append(n)
    b = b[::-1]

print(*b)

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

a_odd = a[0::2]
a_even = a[1::2]

if n % 2 == 1:
    print(" ".join(a_odd[::-1] + a_even))
else:
    print(" ".join(a_even[::-1] + a_odd))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = input().split()
b = []
for i in range(n):
    b.append(a[i])
    b.reverse()

print(" ".join(b))

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

a_odd = a[0::2]
a_even = a[1::2]

if n % 2 == 1:
    print(" ".join(a_odd[::-1] + a_even))
else:
    print(" ".join(a_even[::-1] + a_odd))