alexjercan/bugnet huggingface dataset:
Problem p03651 (Python) — buggy submission, verdict: Runtime Error

import functools
import fractions

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

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(fractions.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


Error: 0

Fixed submission:

import functools
import math

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

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(math.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
Problem p03651 (Python) — buggy submission, verdict: Runtime Error

a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

array = list(set(array))

if len(array) == 1:
    if b == array[0]:
        print(possible)
    else:
        print(impossible)
    exit(0)

array.sort()

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)


Error: 0

Fixed submission:

a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

if a == 1:
    if b == array[0]:
        print(possible)
    else:
        print(impossible)
    exit(0)

array = list(set(array))
array.sort()

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)
Problem p03651 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3
import copy

N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

a_list = sorted(a_list)


def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    w_list = sorted(list(set(w_list)))

    if k in w_list:
        return True, w_list
    elif 1 in w_list:
        return True, w_list
    elif abs(w_list[0] - w_list[-1]) < K:
        return False, w_list
    elif k % 2 == 0 and 2 in w_list:
        return True, w_list
    else:
        ww_list = set([w + K for w in w_list])
        if ww_list & set(w_list):
            return True, w_list
        else:
            return False, w_list


w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            break
        if w_list == org_w_list:
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)


Error: TLE

Fixed submission:

#!/usr/bin/env python3
import copy

N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

a_list = sorted(a_list)


def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    w_list = sorted(list(set(w_list)))

    if k in w_list:
        return True, w_list
    elif 1 in w_list:
        return True, w_list
    elif abs(w_list[0] - w_list[-1]) < K:
        return False, w_list
    elif k % 2 == 0 and 2 in w_list:
        return True, w_list
    else:
        for w in w_list:
            if w + K in w_list:
                return True, w_list

        return False, w_list


w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            break
        if w_list == org_w_list:
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)
Problem p03652 (Python) — buggy submission, verdict: Runtime Error

import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, *A = map(int, read().split())
A = list(map(list, map(reversed, zip(*[iter(A)] * M))))

# 各スポーツに参加している人数
p = [0] * (M + 1)
canceled = set()
answer = []


def solve(s, n):
    # nは開催しているスポーツの数
    # sは新たに開催をやめるスポーツ
    if n == 1:
        answer.append(N)
    elif n == M:
        for i in A:
            p[i[-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)
    else:
        canceled.add(s)
        p[s] = 0
        for i in range(N):
            if A[i][-1] in canceled:
                while A[i][-1] in canceled:
                    A[i].pop()
                p[A[i][-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)


solve(0, M)
print(min(answer))


Error: 0

Fixed submission:

import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M, *A = map(int, read().split())
A = list(map(list, map(reversed, zip(*[iter(A)] * M))))

# 各スポーツに参加している人数
p = [0] * (M + 1)
canceled = set()
answer = []


def solve(s, n):
    # nは開催しているスポーツの数
    # sは新たに開催をやめるスポーツ
    p[s] = 0
    canceled.add(s)
    if n == M:
        for i in A:
            p[i[-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)
    elif n == 1:
        answer.append(N)
    else:
        for i in range(N):
            if A[i][-1] in canceled:
                while A[i][-1] in canceled:
                    A[i].pop()
                p[A[i][-1]] += 1
        p_max = max(p)
        answer.append(p_max)
        cancel = p.index(p_max)
        solve(cancel, n - 1)


solve(0, M)
print(min(answer))
Problem p03657 (Python) — buggy submission, verdict: Runtime Error

A, B = map(int, input().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


Error: AttributeError: 'builtin_function_or_method' object has no attribute 'split'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03657/Python/s777334457.py", line 1, in <module>
    print("Impossible" if sum(map(int, input.split())) % 3 else "Possible")
AttributeError: 'builtin_function_or_method' object has no attribute 'split'


Fixed submission:

print("Impossible" if sum(map(int, input.split())) % 3 else "Possible")
Problem p03658 (Python) — buggy submission, verdict: Runtime Error

N, K = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[:K]))


Error: TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03658/Python/s266603109.py", line 3, in <module>
    print(sum(L[:K]))
TypeError: 'NoneType' object is not subscriptable


Fixed submission:

K, N = map(int, input().split())
L = list(map(int, input().split())).sort(reverse=True)
print(sum(L[:K]))
Problem p03658 (Python) — buggy submission, verdict: Time Limit Exceeded

from itertools import combinations

N, K = map(int, input().split())
L = sorted(list(map(int, input().split())), reverse=True)
ans = sum(L[:K])
print(ans)


Error: TLE

Fixed submission:

from itertools import combinations

N, K = map(int, input().split())
L = list(map(int, input().split()))

ans = max([sum(combi) for combi in combinations(L, K)])
print(ans)
Problem p03658 (Python) — buggy submission, verdict: Runtime Error

l1 = input().split()
N, K = map(int, l1)
max = K + 1
l2 = input().split()
l2 = list(map(int, l2))

l3 = sorted(l2)
sum = 0


for i in range(1, max):
    sum += l3[-i]

print(sum)


Error: 0

Fixed submission:

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

l2 = input().split()
l2 = list(map(int, l2))

l3 = sorted(l2)
sum = l3[-1] + l3[-2] + l3[-3]
print(sum)
Problem p03658 (Python) — buggy submission, verdict: Runtime Error

N, K = [int(x) for x in input().split()]
lens = [int(x) for x in input().split()]

lens = sorted(lens)[::-1]

if len(lens) <= K:
    print(sum(lens))
else:
    print(sum(lens[:K]))


Error: TypeError: object of type 'NoneType' has no len()
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03658/Python/s815774463.py", line 6, in <module>
    if len(lens) >= K:
TypeError: object of type 'NoneType' has no len()


Fixed submission:

N, K = [int(x) for x in input().split()]
lens = [int(x) for x in input().split()]

lens = sorted(lens).reverse()

if len(lens) >= K:
    print(sum(lens))
else:
    print(sum(lens[:K]))
Problem p03659 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = list(map(int, input().split()))
tmp = 0
ans = 10**10
Asum = sum(A)
for i in range(N - 1):
    tmp += A[i]
    a = abs((Asum - tmp) - tmp)
    if ans > a:
        ans = a
print(ans)


Error: TLE

Fixed submission:

N = int(input())
A = list(map(int, input().split()))
tmp = 0
diffs = []
for i in range(N - 1):
    tmp += A[i]
    diffs.append(abs(sum(A) - tmp - tmp))
print(min(diffs))
Problem p03659 (Python) — buggy submission, verdict: Time Limit Exceeded

from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
A = list(accumulate(A))
answer = abs((A[-1] - A[0]) - A[0])
for i in range(N - 1):
    L = A[-1] - A[i]
    K = abs(L - A[i])
    if K < answer:
        answer = K


print(answer)


Error: TLE

Fixed submission:

def test(L):
    T = abs(sum(A[:L]) - sum(A[L:]))
    return T < answer


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

left = 0
right = N
answer = float("inf")

for i in range(1, N):
    if test(i):
        answer = abs(sum(A[:i]) - sum(A[i:]))

print(answer)
Problem p03659 (Python) — buggy submission, verdict: Time Limit Exceeded

INF = float("inf")


def main():
    N, *a = map(int, open(0).read().split())
    ans = INF
    tmp = 0
    total = sum(a)
    for i in range(N - 1):
        tmp += a[i]
        ans = min(ans, abs(2 * tmp - total))
    print(ans)
    return


main()


Error: TLE

Fixed submission:

def main():
    N, *a = map(int, open(0).read().split())
    print(min(abs(2 * sum(a[:i]) - sum(a)) for i in range(1, N)))
    return


main()
Problem p03659 (Python) — buggy submission, verdict: Time Limit Exceeded

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

a_sum = sum(a_list)
l_a_sum = a_list[0]
min_diff = abs(a_sum - 2 * l_a_sum)
for i in range(1, N - 1):
    l_a_sum += a_list[i]
    min_diff = min(min_diff, abs(a_sum - 2 * l_a_sum))
print(min_diff)


Error: TLE

Fixed submission:

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

min_diff = abs(sum(a_list[:1]) - sum(a_list[1:]))
for i in range(2, N):
    diff = abs(sum(a_list[:i]) - sum(a_list[i:]))
    min_diff = min(min_diff, diff)
print(min_diff)
Problem p03659 (Python) — buggy submission, verdict: Time Limit Exceeded

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    g1 = a[0]
    g2 = sum(a[1:n])
    ans = abs(g1 - g2)
    if n > 2:
        for i in range(1, n - 1):
            g1 += a[i]
            g2 -= a[i]
            tmp = abs(g1 - g2)
            if tmp < ans:
                ans = tmp

    print(ans)


Error: TLE

Fixed submission:

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ans = 10**10
    for i in range(1, n):
        g1 = a[0:i]
        g2 = a[i:n]
        tmp = abs(sum(g1) - sum(g2))
        if tmp < ans:
            ans = tmp

    print(ans)
Problem p03659 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
a = list(map(int, input().split()))
ans = 10000000000
total = sum(a)
sunuke = 0
for i in range(N - 1):
    sunuke += a[i]
    dif = abs(2 * sunuke - total)
    if dif <= ans:
        ans = dif
print(ans)


Error: TLE

Fixed submission:

N = int(input())
a = list(map(int, input().split()))
ans = 10000000000
total = sum(a)
for i in range(1, N):
    sunuke = a[:i]
    Sum = sum(sunuke)
    if abs(Sum - (total - Sum)) <= ans:
        ans = abs(Sum - (total - Sum))
print(ans)
Problem p03659 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = [int(x) for x in input().split()]

b = sum(a)
c = a[0]
d = a[0]

for i in range(1, n - 1):
    c += a[i]
    if abs(b - 2 * d) > abs(b - 2 * c):
        d = c

print(abs(b - 2 * d))


Error: TLE

Fixed submission:

n = int(input())
a = [int(x) for x in input().split()]

d = []

for i in range(1, n):
    d.append(abs(sum(a[:i]) - sum(a[i:])))

print(min(d))
Problem p03659 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A_sum = sum(A)
    tmp = 0

    result = []

    for a in A:
        tmp += a
        result.append(abs(A_sum - tmp * 2))
    print(min(result[:-1]))


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))

    result = []

    for i in range(1, N):
        result.append(abs(sum(A[:i]) - sum(A[i:])))
    print(min(result))


if __name__ == "__main__":
    main()
Problem p03667 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter

n, m = map(int, input().split())
an = list(map(int, input().split()))
ac_ = Counter(an)
ac = {i: ac_[i] if i in ac_ else 0 for i in range(1, n + 1)}
ad = [0] * n
for a, c in ac.items():
    for i in range(max(0, a - c), a):
        ad[i] += 1
ans = ad.count(0)
anss = []

for x, y in (map(int, input().split()) for _ in range(m)):
    ax = an[x - 1]
    xdi = ax - ac[ax]
    if xdi >= 0:
        ad[xdi] -= 1
        if ad[xdi] == 0:
            ans += 1
    ac[ax] -= 1
    ac[y] += 1
    ydi = y - ac[y]
    if ydi >= 0:
        ad[ydi] += 1
        if ad[ydi] == 1:
            ans -= 1
    an[x - 1] = y
    anss.append(ans)
print("\\n".join(map(str, anss)))


Error: TLE

Fixed submission:

from collections import Counter

n, m = map(int, input().split())
an = list(map(int, input().split()))
ac_ = Counter(an)
ac = {i: ac_[i] if i in ac_ else 0 for i in range(1, n + 1)}
ad = [0] * n
for a, c in ac.items():
    for i in range(max(0, a - c), a):
        ad[i] += 1
ans = ad.count(0)

for _ in range(m):
    x, y = map(int, input().split())
    ax = an[x - 1]
    xdi = ax - ac[ax]
    if xdi >= 0:
        ad[xdi] -= 1
        if ad[xdi] == 0:
            ans += 1
    ac[ax] -= 1
    ac[y] += 1
    ydi = y - ac[y]
    if ydi >= 0:
        ad[ydi] += 1
        if ad[ydi] == 1:
            ans -= 1
    an[x - 1] = y
    print(ans)
Problem p03671 (Python) — buggy submission, verdict: Runtime Error

a = list(map(int, input().split()))
print(sorted(a)[0] + sorted(a)[1])


Error: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03671/Python/s485399330.py", line 1, in <module>
    a = list(int(input().split()))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'


Fixed submission:

a = list(int(input().split()))
print(sorted(a)[-1] + sorted(a)[-2])
Problem p03671 (Python) — buggy submission, verdict: Runtime Error

a, b, c = list(map(int, input().split()))
values = sorted([a, b, c])
ans = values[0] + values[1]
print(ans)


Error: 0

Fixed submission:

a, b, c = list(map(int, input().split()))
values = sorted(list(set([a, b, c])))
ans = values[0] + values[1]
print(ans)
Problem p03671 (Python) — buggy submission, verdict: Runtime Error

abc = list(map(int, input().split()))
print(sum(abc) - max(abc))


Error: TypeError: unsupported operand type(s) for +: 'int' and 'map'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03671/Python/s477518016.py", line 2, in <module>
    print(sum(abc) - max(abc))
TypeError: unsupported operand type(s) for +: 'int' and 'map'


Fixed submission:

abc = [map(int, input().split())]
print(sum(abc) - max(abc))
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = tuple(map(int, input().split()))
reverse_a = a[::-1]


if n % 2 == 0:
    first = first = reverse_a[::2]
    second = a[::2]
else:
    first = reverse_a[::2]
    second = a[1:n:2]

print(*first + second)


Error: TLE

Fixed submission:

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

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

print(*b)
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = [int(i) for i in input().split()]
if n % 2 == 0:
    b = a[1::2][::-1] + a[::2]
    print(*b)
else:
    b = a[::2][::-1] + a[1::2]
    print(*b)


Error: TLE

Fixed submission:

n = int(input())
a = [int(i) for i in input().split()]
b = []
is_even = len(a) % 2 == 0

if is_even:
    for i in range(n):
        if i % 2 == 0:
            b.append(str(a[i]))
        else:
            b.insert(0, str(a[i]))
else:
    for i in range(n):
        if i % 2 == 0:
            b.insert(0, str(a[i]))
        else:
            b.append(str(a[i]))
print(" ".join(b))
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import deque

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

b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 1:
    b.reverse()

print(" ".join(map(str, b)))


Error: TLE

Fixed submission:

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

b = []
for t in a:
    b.append(t)
    b.reverse()

print(" ".join(map(str, b)))
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

# -*- coding: utf-8 -*-

from collections import deque

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

b = deque()
for i, ele in enumerate(a):
    if i % 2:
        b.appendleft(ele)
    else:
        b.append(ele)

if n % 2:
    b.reverse()

print(*b)


Error: TLE

Fixed submission:

# -*- coding: utf-8 -*-

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

b = []
for ele in a:
    b.append(ele)
    b = b[::-1]

print(*b)
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = list(map(int, input().split()))
ret = []

for i in range(N):
    if i % 2 == 0:
        ret.append(A[i])
ret.reverse()
for i in range(N):
    if i % 2 == 1:
        ret.append(A[i])

if N % 2 == 0:
    ret.reverse()

print(*ret)


Error: TLE

Fixed submission:

N = int(input())
A = list(map(int, input().split()))
ret = []

for i in range(N):
    if i % 2 == 0:
        ret.append(A[i])
    else:
        ret.insert(0, A[i])

if N % 2 == 1:
    ret.reverse()

print(*ret)
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import deque

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

if n % 2 == 1:
    for i in range(n):
        if i % 2 == 0:
            b.appendleft(a.popleft())
        else:
            b.append(a.popleft())
else:
    for i in range(n):
        if i % 2 == 0:
            b.append(a.popleft())
        else:
            b.appendleft(a.popleft())

print(*b)


Error: TLE

Fixed submission:

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)
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
alist = list(map(int, input().split()))
b = alist[::-2] + alist[n % 2 :: 2]
print(" ".join(list(map(str, b))))


Error: TLE

Fixed submission:

n = int(input())
alist = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(alist[i])
    b = b[::-1]

for _ in b:
    print(_, end=" ")
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

int_n = int(input())
ar_int_a = list(map(int, input().split()))
ar_int_b = [-1] * int_n


idx = int_n // 2
ar_int_b[idx] = ar_int_a[0]

if int_n % 2 == 0:
    # 偶数
    for i in range(1, int_n):
        if i % 2 == 0:
            idx = idx + i
        else:
            idx = idx + (-1 * i)
        ar_int_b[idx] = ar_int_a[i]
else:
    # 奇数
    for i in range(1, int_n):
        if i % 2 == 0:
            idx = idx + (-1 * i)
        else:
            idx = idx + i
        ar_int_b[idx] = ar_int_a[i]


print(" ".join(map(str, ar_int_b)))


Error: TLE

Fixed submission:

int_n = int(input())
ar_int_a = list(map(int, input().split()))
ar_int_b = list()
for i in ar_int_a:
    ar_int_b.append(i)
    ar_int_b = ar_int_b[::-1]

print(" ".join(map(str, ar_int_b)))
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import collections


def main():
    N = int(input())
    A = list(map(int, input().split()))

    result = collections.deque()

    for i in range(N):
        if i % 2 == N % 2:
            result.append(A[i])
        else:
            result.appendleft(A[i])
    print(*result)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    result = []

    for i in range(N):
        if i % 2:
            result.append(A[i])
        else:
            result.insert(0, A[i])

    if N % 2:
        print(*result)
    else:
        print(*result[::-1])


if __name__ == "__main__":
    main()
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import deque


def main():
    N = int(input())
    A = list(map(int, input().split()))
    q = deque()
    for i in range(N):
        if (N - i) % 2 == 1:
            q.appendleft(A[i])
        else:
            q.append(A[i])
    print(" ".join(map(str, q)))


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

def main():
    N = int(input())
    A = input().split()
    ans = A[0]
    for i in range(1, N):
        ans = (ans + " " + A[i])[::-1]
    print(ans)


if __name__ == "__main__":
    main()
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

import math

num = int(input())
array = [int(x) for x in input().split()]

zero_array = array[0::2]
one_array = array[1::2]

if num % 2 == 0:
    one_array = one_array[: int(num / 2)]
    pick = one_array[::-1] + zero_array[: int(num / 2)]
else:
    one_array = one_array[: int(num / 2)]
    pick = one_array[::-1] + zero_array[: math.ceil(num / 2)]

if num % 2 == 0:
    print(" ".join(map(str, pick)))
else:
    print(" ".join(map(str, pick[::-1])))


Error: TLE

Fixed submission:

num = int(input())
array = [int(x) for x in input().split()]

res = []
for i in range(0, num):
    if i % 2 == 0:
        res.append(array[i])
    else:
        res.insert(0, array[i])

if num % 2 == 0:
    res = map(str, res)
    print(" ".join(res))
else:
    res = map(str, res[::-1])
    print(" ".join(res))
Problem p03673 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import deque

n = int(input())
A = list(map(int, input().split()))
X = deque([str(A[0])])
append_ = True if n % 2 != 0 else False
for a in A[1:]:
    if append_:
        X.append(str(a))
    else:
        X.appendleft(str(a))
    append_ = not append_
print(" ".join(X))


Error: TLE

Fixed submission:

n = int(input())
A = list(map(int, input().split()))
X = [str(A[0])]
append_ = True if n % 2 != 0 else False
for a in A[1:]:
    if append_:
        X.append(str(a))
    else:
        X.insert(0, str(a))
    append_ = not append_
print(" ".join(X))