Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
import numpy as np


def burger(num):
    if num == 1:
        return np.array([1, 3, 1])
    last_burger = burger(num - 1)
    return np.concatenate((last_burger[0] + 1, last_burger[1:], 1, last_burger[:-1], last_burger[-1] + 1), axis=None)


def main(n, x):
    burger_n = burger(n)

    i, p, eaten = 0, 0, 0

    while eaten < x:
        eaten += burger_n[i]
        if i % 2 == 1:
            p += burger_n[i]
        i += 1

    if i % 2 == 0:
        p -= (eaten - x)

    print(p)


main(n, x)

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


def main(n, x):
    if n == 0:
        if x >= 0:
            return 1
        else:
            return 0
    if x == 0:
        return 0
    if x == 2 ** (n + 1) - 2:
        return 2 ** n
    if x < 2 ** (n + 1) - 2:
        return main(n - 1, x - 1)
    return 2 ** n + main(n - 1, x - (2 ** (n + 1) - 1))


print(main(n, x))
Buggy python submission (verdict: Runtime Error):
s = input()

print(s.replace("9", "x").replace("1", "9").replace("x", "1")

Fixed submission:
s = input()

print(s.replace("9", "x").replace("1", "9").replace("x", "1"))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

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

even = a[1::2]
odd = a[::2]

c_even = Counter(even)
c_odd = Counter(odd)

arr_even = c_even.most_common()
arr_odd = c_odd.most_common()

sum_even = sum(x[1] for x in arr_even)
sum_odd = sum(x[1] for x in arr_odd)

min_sum = sum_even - arr_even[0] + n // 2

for i, x in arr_even:
    for j, y in arr_odd:
        if i != j:
            cnt = sum_even - x + sum_odd - y
            min_sum = min(min_sum, cnt)
            break
        else:
            continue

print(min_sum)

Fixed submission:
from collections import Counter

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

even = a[1::2]
odd = a[::2]

c_even = Counter(even)
c_odd = Counter(odd)

arr_even = c_even.most_common()
arr_odd = c_odd.most_common()

sum_even = sum(x[1] for x in arr_even)
sum_odd = sum(x[1] for x in arr_odd)

min_sum = sum_even - arr_even[0][1] + n // 2

for i, x in arr_even:
    for j, y in arr_odd:
        if i != j:
            cnt = sum_even - x + sum_odd - y
            min_sum = min(min_sum, cnt)
            break
        else:
            continue

print(min_sum)
Buggy python submission (verdict: Runtime Error):
n = int(input())
words = [input() for _ in range(n)]
print("Yes" if all([y[0] == x[-1] for x, y in zip(words, words[1:]]) and len(set(words)) == n else "No")

Fixed submission:
n = int(input())

words = [input() for _ in range(n)]

spoken = {words[0]}

for x, y in zip(words, words[1:]):
    if y[0] != x[-1]:
        print("No")
        exit()
    if y in spoken:
        print("No")
        exit()
    spoken.add(y)
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
n = int(input())
words = [input() for _ in range(n)]
print("Yes" if all([y[0] == x[-1] for x, y in zip(words, words[1:])) and len(set(words)) == n else "No")

Fixed submission:
n = int(input())

words = [input() for _ in range(n)]

spoken = {words[0]}

for x, y in zip(words, words[1:]):
    if y[0] != x[-1]:
        print("No")
        exit()
    if y in spoken:
        print("No")
        exit()
    spoken.add(y)
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
n = int(input())
words = [input() for _ in range(n)]
print("Yes" if all([y[0] == x[-1] for x, y in zip(words, words[1:]) and len(set(words)) == n else "No")

Fixed submission:
n = int(input())

words = [input() for _ in range(n)]

spoken = {words[0]}

for x, y in zip(words, words[1:]):
    if y[0] != x[-1]:
        print("No")
        exit()
    if y in spoken:
        print("No")
        exit()
    spoken.add(y)
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):

import numpy as np

x = np.array(list(map(int, input().split())))
x -= X

x = np.abs(x)

M = x[0]
from fractions import gcd

for i in x[1:]:
  M = gcd(M, i)

print(M)


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

import numpy as np

x = np.array(list(map(int, input().split())))
x -= X

x = np.abs(x)

M = x[0]
from fractions import gcd

for i in x[1:]:
  M = gcd(M, i)

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

if k % 2 == 0:
    check = k // 2
else:
    check = k

cnt = 0
for a in range(check, n+1, check):
    for b in range(check, n+1, check):
        for c in range(check, n+1, check):
            if (a + b) % k or (b + c) % k or (c + a) % k:
                continue
            else:
                cnt += 1

print(cnt)

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

if k % 2 == 0:
    even = n // k
    odd = n // (k // 2) - even
    print(odd ** 3 + even ** 3)
else:
    print((n // k) ** 3)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
 
a = [list(input()) for i in range(h)]
 
for i in range(h):
  if "#" not in a[i]:
    del a[i]
 
aT = list(zip(*a))
 
for i in range(len(aT)):
  if "#" not in aT[i]:
    del aT[i]
 
a = list(zip(*aT))

for i in a:
  print(i)


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

a = [list(input()) for i in range(h)]

a = [x for x in a if "#" in x]

aT = list(zip(*a))
aT = [x for x in aT if "#" in x]

a = list(zip(*aT))

for i in a:
    print("".join(i))

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
 
a = [list(input()) for i in range(h)]
 
for i in range(h):
  if "#" not in a[i]:
    del a[i]
 
aT = zip(*a)
 
for i in range(len(aT)):
  if "#" not in aT[i]:
    del aT[i]
 
a = zip(*aT)
 
for i in a:
  print(i)

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

a = [list(input()) for i in range(h)]

a = [x for x in a if "#" in x]

aT = list(zip(*a))
aT = [x for x in aT if "#" in x]

a = list(zip(*aT))

for i in a:
    print("".join(i))

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

a = [input() for i in range(h)]

for i in range(h):
  if "#" not in a[i]:
    del a[i]

aT = zip(*a)

for i in range(len(aT)):
  if "#" not in aT[i]:
    del aT[i]

a = zip(*aT)

for i in a:
  print(i)

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

a = [list(input()) for i in range(h)]

a = [x for x in a if "#" in x]

aT = list(zip(*a))
aT = [x for x in aT if "#" in x]

a = list(zip(*aT))

for i in a:
    print("".join(i))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = list(map(int, input().split()))

min_t = 10 ** 9

import bisect

snuke = bisect.bisect_left(x, 0)
if x[snuke] == 0:
    k -= 1
    n -= 1
    del x[snuke]

for i in range(k+1):
    if i == 0:
        left = 0
    elif snuke - i >= 0:
        left = abs(x[snuke - i])
    else:
        left = 10 ** 9

    if k - i == 0:
        right = 0
    elif snuke + k - i - 1 <= n - 1:
        right = abs(x[snuke + k - i - 1])
    else:
        right = 10 ** 9

    min_t = min(min_t, min(left, right) * 2 + max(left, right))

print(min_t)

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

min_t = 10 ** 9

import bisect

snuke = bisect.bisect_left(x, 0)
if snuke < n and x[snuke] == 0:
    k -= 1
    n -= 1
    del x[snuke]

for i in range(k+1):
    if i == 0:
        left = 0
    elif snuke - i >= 0:
        left = abs(x[snuke - i])
    else:
        left = 10 ** 9

    if k - i == 0:
        right = 0
    elif snuke + k - i - 1 <= n - 1:
        right = abs(x[snuke + k - i - 1])
    else:
        right = 10 ** 9

    min_t = min(min_t, min(left, right) * 2 + max(left, right))

print(min_t)

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

min_t = 10 ** 9

import bisect

snuke = bisect.bisect_left(x, 0)
if x[snuke] == 0:
    k -= 1
    del x[snuke]

for i in range(k+1):
    if i == 0:
        left = 0
    elif snuke - i >= 0:
        left = abs(x[snuke - i])
    else:
        left = 10 ** 9

    if k - i == 0:
        right = 0
    elif snuke + k - i - 1 <= n - 1:
        right = abs(x[snuke + k - i - 1])
    else:
        right = 10 ** 9

    min_t = min(min_t, min(left, right) * 2 + max(left, right))

print(min_t)

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

min_t = 10 ** 9

import bisect

snuke = bisect.bisect_left(x, 0)
if snuke < n and x[snuke] == 0:
    k -= 1
    n -= 1
    del x[snuke]

for i in range(k+1):
    if i == 0:
        left = 0
    elif snuke - i >= 0:
        left = abs(x[snuke - i])
    else:
        left = 10 ** 9

    if k - i == 0:
        right = 0
    elif snuke + k - i - 1 <= n - 1:
        right = abs(x[snuke + k - i - 1])
    else:
        right = 10 ** 9

    min_t = min(min_t, min(left, right) * 2 + max(left, right))

print(min_t)
Buggy python submission (verdict: Runtime Error):
difficulties, goal = map(int, input().split())

pcs = [list(map(int, input().split())) for _ in range(difficulties)]

total_problem = 0
new_dp = [0] * 1001

for d, pc in enumerate(pcs, 1):
    dp = new_dp

    problem, complete = pc
    total_problem += problem

    score = {x: x*100*d for x in range(problem)}
    score[problem] = problem * 100 * d +complete

    for i in range(1, total_problem + 1):
        for j in range(0, i + 1):
            if i - j > problem:
                continue
            else:
                new_dp[i] = max(new_dp[i], dp[d-1][j] + score[i-j])

for i, a in enumerate(new_dp):
    if a >= goal:
        print(i)
        exit()


Fixed submission:
difficulties, goal = map(int, input().split())

pcs = [list(map(int, input().split())) for _ in range(difficulties)]

dp = [[0] * 1102 for _ in range(difficulties + 1)]

total_problem = 0
for d, pc in enumerate(pcs, 1):
    problem, complete = pc
    total_problem += problem

    score = {x: x*100*d for x in range(problem)}
    score[problem] = problem * 100 * d +complete

    for i in range(1, total_problem + 1):
        for j in range(0, i + 1):
            if i - j > problem:
                dp[d][i] = max(dp[d][i], dp[d - 1][j])
            else:
                dp[d][i] = max(dp[d][i], dp[d-1][j] + score[i-j])

for i, a in enumerate(dp[difficulties]):
    if a >= goal:
        print(i)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
difficulties, goal = map(int, input().split())

pcs = [list(map(int, input().split())) for _ in range(difficulties)]

dp = [[0] * 1102 for _ in range(difficulties + 1)]

for d, pc in enumerate(pcs, 1):
    problem, complete = pc

    score = [x*100*d for x in range(problem)] + [problem*100*d+complete] +[0] * 1001

    for i in range(1, 1001):
        for j in range(0, i + 1):
            if i - j > problem:
                dp[d][i] = max(dp[d][i], dp[d - 1][j])
            else:
                dp[d][i] = max(dp[d][i], dp[d-1][j] + score[i-j])

for i, a in enumerate(dp[difficulties]):
    if a >= goal:
        print(i)
        exit()


Fixed submission:
difficulties, goal = map(int, input().split())

pcs = [list(map(int, input().split())) for _ in range(difficulties)]

dp = [[0] * 1102 for _ in range(difficulties + 1)]

total_problem = 0
for d, pc in enumerate(pcs, 1):
    problem, complete = pc
    total_problem += problem

    score = {x: x*100*d for x in range(problem)}
    score[problem] = problem * 100 * d +complete

    for i in range(1, total_problem + 1):
        for j in range(0, i + 1):
            if i - j > problem:
                dp[d][i] = max(dp[d][i], dp[d - 1][j])
            else:
                dp[d][i] = max(dp[d][i], dp[d-1][j] + score[i-j])

for i, a in enumerate(dp[difficulties]):
    if a >= goal:
        print(i)
        exit()
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())

n = b - a
original_b = n * (n + 1) // 2

print(original_b - b)

Fixed submission:
a, b = map(int, input().split())
 
n = b - a
original_b = n * (n + 1) // 2
 
print(original_b - b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]

import bisect

def six_nine(n):
  if n == 0:
    return 0
  else:
    six = six_list[bisect.bisect_right(six_list, n) - 1]
    nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
    return 1 + min(six_nine(n - six), six_nine(n - nine))


print(six_nine(n))

Fixed submission:
n = int(input())

six_list = [6 ** i for i in range(7)]
nine_list = [9 ** i for i in range(6)]

import bisect

def six_nine(n):
  if n == 0:
    return 0
  else:
    six = six_list[bisect.bisect_right(six_list, n) - 1]
    nine = nine_list[bisect.bisect_right(nine_list, n) - 1]
    return min(n // six + six_nine(n % six), 1 + six_nine(n - nine))


print(six_nine(n))
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if j > 0 and a[i][j-1] != "." and a[i][j] = "#":
      a[i][j] = "*"
    elif j < w - 1 and a[i][j+1] != "." and a[i][j] = "#":
      a[i][j] = "*"
    elif i > 0 and a[i-1][j] != "." and a[i][j] = "#":
      a[i][j] = "*"
    elif i < h - 1 and a[i+1][j] != "." and a[i][j] = "#":
      a[i][j] = "*"

print("No" if sum([row.count("#") for row in a]) else "Yes")


Fixed submission:
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

for i in range(h):
  for j in range(w):
    if j > 0 and a[i][j-1] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif j < w - 1 and a[i][j+1] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif i > 0 and a[i-1][j] != "." and a[i][j] == "#":
      a[i][j] = "*"
    elif i < h - 1 and a[i+1][j] != "." and a[i][j] == "#":
      a[i][j] = "*"

print("No" if sum([row.count("#") for row in a]) else "Yes")
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from collections import Counter


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

s = 0
for j in range(n):
    l = list(accumulate(a[j:]))
    c = Counter(l)
    s += c[0]

print(s)

Fixed submission:
from itertools import accumulate
from collections import Counter


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

l = [0] + list(accumulate(a))
c = Counter(l)


s = 0
for key, value in c.items():
    s = s + value * (value - 1) // 2

print(s)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

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

s = 0
for j in range(n):
    s += list(accumulate(a[j:])).count(0)

print(s)

Fixed submission:
from itertools import accumulate
from collections import Counter


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

l = [0] + list(accumulate(a))
c = Counter(l)


s = 0
for key, value in c.items():
    s = s + value * (value - 1) // 2

print(s)
Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())

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

import bisect

l = bisect.bisect_left(a, x)

print(min(l, m-l))


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

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

import bisect

l = bisect.bisect_left(a, x)

print(min(l, m-l))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())


cnt = 0
for i in range(a, b+1):
    ii = str(i)
    if ii[0] == ii[4] and ii[1] == ii[3]:
        cnt += 1

print(cnt)


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

cnt = 0
for i in range(a, b+1):
    ii = str(i)
    if ii[0] == ii[4] and ii[1] == ii[3]:
        cnt += 1

print(cnt)

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


cnt = 0
for i in range(a, b+1):
    ii = str(i)
    if ii[0] == ii[4] and ii[1] == ii[3]:
        cnt += 1

print(cnt)


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

cnt = 0
for i in range(a, b+1):
    ii = str(i)
    if ii[0] == ii[4] and ii[1] == ii[3]:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import combinations

n = int(input())

count = {x:0 for x in "MARCH"}

for _ in range(n):
  s = input()[0]
  if s in count:
    count[s] += 1

sum_count = 0
for a, b, c in combinations("MARCH", 3):
  sum_count += count[a] * count[b] * count[c]

print(sum_count)

Fixed submission:
from itertools import combinations
 
n = int(input())
 
count = {x:0 for x in "MARCH"}
 
for _ in range(n):
  s = input()[0]
  if s in count:
    count[s] += 1
 
sum_count = 0
for a, b, c in combinations("MARCH", 3):
  sum_count += count[a] * count[b] * count[c]
 
print(sum_count)
Buggy python submission (verdict: Runtime Error):
s = input()

if s < 10:
    print(s)
else:
    print(int(s[0]) - 1 + 9 * (len(s) - 1))


Fixed submission:
s = input()

if int(s) < 10:
    print(int(s))
elif all([x == "9" for x in s[1:]]):
    print(int(s[0]) + 9 * (len(s) - 1))
else:
    print(int(s[0]) - 1 + 9 * (len(s) - 1))
Buggy python submission (verdict: Runtime Error):
n = int(input())

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

a.sort(reverse=True)

print(a[::2] - a[1::2])

Fixed submission:
n = int(input())

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

a.sort(reverse=True)

print(sum(a[::2]) - sum(a[1::2]))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

s = input()
n = s[:a]+s[a+1:]

print("Yes" if s[a]="-" and n.isdigit() else "No")

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

s = input()
n = s[:a]+s[a+1:]

print("Yes" if s[a]=="-" and n.isdigit() else "No")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

print(-(-(a + b) // 2)

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

print(-(-(a + b) // 2))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

a.sort()
b.sort(reverse=True)

print("Yes" if a < b else "No")

Fixed submission:
a = input()
b = input()

print("Yes" if sorted(a) < sorted(b)[::-1] else "No")

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

x = a.sort()
y = b.sort(reverse=True)

print("Yes" if x < y else "No")

Fixed submission:
a = input()
b = input()

print("Yes" if sorted(a) < sorted(b)[::-1] else "No")
Buggy python submission (verdict: Runtime Error):
x = input()

print("Yes" if x[0]=x[1]=x[2] or x[1]=x[2]=x[3] else "No")

Fixed submission:
x = input()
 
print("Yes" if x[0]==x[1]==x[2] or x[1]==x[2]==x[3] else "No")
Buggy python submission (verdict: Runtime Error):
x, y = input()

print(">" if x > y else "<" if x < y else "=")

Fixed submission:
x, y = input().split()

print(">" if x > y else "<" if x < y else "=")
Buggy python submission (verdict: Runtime Error):
import sys

n = int(input())

def main():
    for i in range(1, 3500):
        for j in range(1, 3500):
            z = n * i * j / (4 * i * j - n * i - n * j)
            if z >= 1 and z == int(z):
                print(i, j, z)
                sys.exit()


main()


Fixed submission:
import sys

n = int(input())

def main():
    for i in range(1, 3500):
        for j in range(1, 3500):
            z = 4 * i * j - n * i - n * j
            if z > 0:
                x = n * i * j / z
                if x == int(x):
                    print(i, j, int(x))
                    sys.exit()


main()

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

n = int(input())

for i in range(1, 3500):
  for j in range(1, 3500):
    try:
        x = int(1 / (4/n - 1/i - 1/j))
        if x >= 1 and 4/n == 1/i + 1/j + 1/x:
            print(i, j, x)
            sys.exit()
    except:
        pass



Fixed submission:
import sys

n = int(input())

def main():
    for i in range(1, 3500):
        for j in range(1, 3500):
            z = 4 * i * j - n * i - n * j
            if z > 0:
                x = n * i * j / z
                if x == int(x):
                    print(i, j, int(x))
                    sys.exit()


main()
Buggy python submission (verdict: Runtime Error):
input()
print(2 * sum(min(x, int(input())-x) for x in list(map(int, input().split()))))

Fixed submission:
_,k=input(),int(input())
print(2*sum(min(x,k-x) for x in map(int,input().split())))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()

x = 0
li_a = []

while a[x][0]== 1 and x < m:
    li_a.append(a[x][1])
    x += 1

a.sort(reverse=True, key=lambda x: x[1])

x = 0
li_b = []

while a[x][1] == n and x < m:
    li_b.append(a[x][0])
    x += 1

print("POSSIBLE" if set(li_a) & set(li_b) else "IMPOSSIBLE")

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

a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()

x = 0
li_a = []

while x < m and a[x][0]== 1:
    li_a.append(a[x][1])
    x += 1

a.sort(reverse=True, key=lambda x: x[1])

x = 0
li_b = []

while x < m and a[x][1] == n:
    li_b.append(a[x][0])
    x += 1

print("POSSIBLE" if set(li_a) & set(li_b) else "IMPOSSIBLE")

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

a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()

x = 0
li_a = []

while a[x][0]== 1 and x < n:
    li_a.append(a[x][1])
    x += 1

a.sort(reverse=True, key=lambda x: x[1])

x = 0
li_b = []

while a[x][1] == n and x < n:
    li_b.append(a[x][0])
    x += 1

print("POSSIBLE" if set(li_a) & set(li_b) else "IMPOSSIBLE")

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

a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()

x = 0
li_a = []

while x < m and a[x][0]== 1:
    li_a.append(a[x][1])
    x += 1

a.sort(reverse=True, key=lambda x: x[1])

x = 0
li_b = []

while x < m and a[x][1] == n:
    li_b.append(a[x][0])
    x += 1

print("POSSIBLE" if set(li_a) & set(li_b) else "IMPOSSIBLE")

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

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

a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()

x = 0
li_a = []

while a[x][0]== 1:
    li_a.append(a[x][1])
    x += 1

a.sort(reverse=True, key=lambda x: x[1])

x = 0
li_b = []

while a[x][1] == n:
    li_b.append(a[x][0])
    x += 1

print("POSSIBLE" if set(li_a) & set(li_b) else "IMPOSSIBLE")

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

a = [list(sorted(map(int, input().split()))) for i in range(m)]
a.sort()

x = 0
li_a = []

while x < m and a[x][0]== 1:
    li_a.append(a[x][1])
    x += 1

a.sort(reverse=True, key=lambda x: x[1])

x = 0
li_b = []

while x < m and a[x][1] == n:
    li_b.append(a[x][0])
    x += 1

print("POSSIBLE" if set(li_a) & set(li_b) else "IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

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

a.sort(reverse=True)

print(sum(a[:k]))

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

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

a.sort(reverse=True)

print(sum(a[:k]))

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

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

a.sort(reverse=True)

print(sum(a[:k])

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

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

a.sort(reverse=True)

print(sum(a[:k]))
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = list(map(int, input()))

import collections

b = collections.deque()

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

print(*b)



Fixed submission:
n = int(input())

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

import collections

b = collections.deque()

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

print(*b)

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

a = list(map(int, input()))

import collections
b = collections.deque()

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

print(*b)
  

Fixed submission:
n = int(input())

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

import collections

b = collections.deque()

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

print(*b)