Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]

possible = 1
for i in range(N):
  if i == 0:
    parity_0 = sum(points[i]) % 2
  else:
    if sum(points[i]) % 2 != parity_0:
      print(-1)
      possible = 0
      break

if possible:
  farthest = max([abs(point[0]) + abs(point[1]) for point in points])
  print(farthest)
  d = ""
  for i in range(farthest):
    if i < farthest - 1:
      d = d + "1" + " "
    else:
      d = d + "1"
  print(d)
  for i in range(N):
    w = ""
    X, Y = points[i][0], points[i][1]
    if X > 0:
      w += "R" * X
    else:
      w += "L" * abs(X)
    if Y > 0:
      w += "U" * Y
    else:
      w += "D" * abs(Y)
    w += "UD" * int((farthest - abs(X) - abs(Y)) / 2)
    print(w)

Fixed submission:
import math

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

possible = 1
for i in range(N):
  if i == 0:
    parity_0 = sum(points[i]) % 2
  else:
    if sum(points[i]) % 2 != parity_0:
      print(-1)
      possible = 0
      break

if possible:
  farthest = max([abs(point[0]) + abs(point[1]) for point in points])
  m = math.ceil(math.log2(farthest + 1))
  d_list = [2**(m-i-1) for i in range(m)]
  if parity_0 == 0:
    m = m + 1
    d_list.append(1)
  print(m)
  print(" ".join(map(str,d_list)))
  uv = [[point[0] + point[1], point[0] - point[1]] for point in points]
  for i in range(N):
    u = uv[i][0]
    v = uv[i][1]
    w = ""
    for d in d_list:
      if u > 0:
        if v > 0:
          w += "R"
          u -= d
          v -= d
        else:
          w += "U"
          u -= d
          v += d
      else:
        if v > 0:
          w += "D"
          u += d
          v -= d
        else:
          w += "L"
          u += d
          v += d
    print(w)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

N, M = map(int, input().split())
mod = 10 ** 9 + 7


def comb(n,r):
  if n >= r:
    numer = factorial(n) % mod
    denom_inv = pow(((factorial(r) % mod)* (factorial(n-r) % mod)), mod-2, mod)
    return (numer * denom_inv) % mod
  else:
    return 0


pp = [0]
div = 2
while M > 1:
    if pp[-1] != 0:
        pp.append(0)
    while M % div == 0:
        pp[-1] += 1
        M = M / div
    div += 1

ans = 1
for p in pp:
    ans = (ans * comb(N+p-1, p)) % mod

print(ans)

Fixed submission:
from math import factorial

N, M = map(int, input().split())
mod = 10 ** 9 + 7


def comb(n,r):
  if n >= r:
    numer = factorial(n) % mod
    denom_inv = pow(((factorial(r) % mod)* (factorial(n-r) % mod)), mod-2, mod)
    return (numer * denom_inv) % mod
  else:
    return 0


pp = [0]
div = 2
while M > 1:
    if pp[-1] != 0:
        pp.append(0)
    while M % div == 0:
        pp[-1] += 1
        M = M / div
    div += 1

ans = 1
for p in pp:
    ans = (ans * comb(N+p-1, p)) % mod

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

L = int(input())

N = math.floor(math.log2(L)) + 1
ans = []
for i in range(1, N):
    ans.append((i, i+1, 0))
    ans.append((i, i+1, 2**(N-i-1)))

tmp = 2 ** (N-1)
for j in range(N-1):
    if L >> j & 1:
        ans.append((1, N-j, (L >> (j+1)) << (j+1)))

print(N, len(ans))
for ans_i in ans:
    print(*ans_i)


Fixed submission:
import math

L = int(input())

N = math.floor(math.log(L, 2)) + 1
ans = []
for i in range(1, N):
    ans.append((i, i+1, 0))
    ans.append((i, i+1, 2**(N-i-1)))

tmp = 2 ** (N-1)
for j in range(N-1):
    if L >> j & 1:
        ans.append((1, N-j, (L >> (j+1)) << (j+1)))

print(N, len(ans))
for ans_i in ans:
    print(*ans_i)
Buggy python submission (verdict: Runtime Error):
import bisect
import collections

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

index = bisect.bisect_left(x, 0)
if x[index] != 0:
  x.insert(index, 0)
  N += 1
  K += 1

start_min = max(index-K+1, 0)
start_max = min(index, N-K)
min_time = 10**9
for i in range(start_min, start_max+1):
  min_time = min(min_time, x[i+K-1]-x[i]+min(abs(x[i+K-1]), abs(x[i])))
print(min_time)

Fixed submission:
import bisect

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

index = bisect.bisect_left(x, 0)
if index < len(x):
  if x[index] != 0:
    x.insert(index, 0)
    N += 1
    K += 1
else:
  x.insert(index, 0)
  N += 1
  K += 1
  index -= 1

start_min = max(index-K+1, 0)
start_max = min(index, N-K)
min_time = 10**9
for i in range(start_min, start_max+1):
  min_time = min(min_time, x[i+K-1]-x[i]+min(abs(x[i+K-1]), abs(x[i])))
print(min_time)
Buggy python submission (verdict: Time Limit Exceeded):
T = int(input())
for i in range(T):
    A, B, C, D = map(int, input().split())
    if A < B:
        print('No')
        continue
    if B > D:
        print('No')
        continue
    if C >= B - 1:
        print('Yes')
        continue
    A = A % B
    D = D % B
    first_A = A
    while True:
        if A > C:
            print('No')
            break
        A = (A + D) % B
        if A == first_A:
            print('Yes')
            break


Fixed submission:
import fractions

T = int(input())
for i in range(T):
    A, B, C, D = map(int, input().split())
    if A < B:
        print('No')
        continue
    if B > D:
        print('No')
        continue
    if C >= B - 1:
        print('Yes')
        continue
    A = A % B
    D = D % B
    BD = fractions.gcd(B, D)
    A_max = A + BD * ((B - 1 - A) // BD)
    if A_max > C:
        print('No')
    else:
        print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

S1 = S[:N]
S2 = S[N:]
S2 = S2[::-1]
rb1 = {}
rb2 = {}
for i in range(2 ** N):
    flag = bin(i)[2:].zfill(N)
    r = ''
    b = ''
    for j in range(N):
        if flag[j] == '0':
            r += S1[j]
        else:
            b = S1[j] + b
    key = r + '&' + b
    if key in rb1.keys():
        rb1[key] += 1
    else:
        rb1[key] = 1

for i in range(2 ** N):
    flag = bin(i)[2:].zfill(N)
    r = ''
    b = ''
    for j in range(N):
        if flag[j] == '0':
            r += S2[j]
        else:
            b = S2[j] + b
    key = r + '&' + b
    if key in rb2.keys():
        rb2[key] += 1
    else:
        rb2[key] = 1

ans = 0
for key in rb1.keys():
    if key in rb2.keys():
       ans += rb1[key] * rb2[key]

print(ans)


Fixed submission:
from collections import Counter

N = int(input())
S = input()

S1 = S[:N]
S2 = S[N:]
S2 = S2[::-1]
rb1 = Counter()
rb2 = Counter()
for i in range(2 ** N):
    flag = bin(i)[2:].zfill(N)
    r1 = ''
    b1 = ''
    r2 = ''
    b2 = ''
    for j in range(N):
        if flag[j] == '0':
            r1 += S1[j]
            r2 += S2[j]
        else:
            b1 = S1[j] + b1
            b2 = S2[j] + b2
    key1 = r1 + '&' + b1
    key2  =r2 + '&' + b2
    rb1[key1] += 1
    rb2[key2] += 1

ans = 0
for key in rb1.keys():
    ans += rb1[key] * rb2[key]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq


def dijkstra(adj, start):
    # adj: [[to, cost] * vertices], 0th index must be empty
    dist = [float('inf')] * len(adj)
    dist[start] = 0
    q = []
    heapq.heappush(q, [0, start])
    while q:
        min_dist, v_from = heapq.heappop(q)
        if min_dist > dist[v_from]:
            continue
        v_tos = adj[v_from]
        for v_to in v_tos:
            if min_dist + v_to[1] < dist[v_to[0]]:
                dist[v_to[0]] = min_dist + v_to[1]
                heapq.heappush(q, [dist[v_to[0]], v_to[0]])
    return dist


n, m, start, goal = map(int, input().split())
adj_yen = [[] for _ in range(n+1)]
adj_snuuk = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    adj_yen[u].append([v, a])
    adj_yen[v].append([u, a])
    adj_snuuk[u].append([v, b])
    adj_snuuk[v].append([u, b])

min_dist_yen = dijkstra(adj_yen, start)
min_dist_snuuk = dijkstra(adj_snuuk, goal)
lose = [float('inf')] * n
for i in range(1, n+1):
    lose[-i] = min(lose[-i+1], min_dist_yen[n-i+1] + min_dist_snuuk[n-i+1])

for i in range(n):
    print(10 ** 15 - lose[i])


Fixed submission:
import heapq
import sys
input = sys.stdin.readline


def dijkstra(adj, start):
    # adj: [[to, cost] * vertices], 0th index must be empty
    dist = [float('inf')] * len(adj)
    dist[start] = 0
    q = []
    heapq.heappush(q, [0, start])
    while q:
        min_dist, v_from = heapq.heappop(q)
        if min_dist > dist[v_from]:
            continue
        v_tos = adj[v_from]
        for v_to in v_tos:
            if min_dist + v_to[1] < dist[v_to[0]]:
                dist[v_to[0]] = min_dist + v_to[1]
                heapq.heappush(q, [dist[v_to[0]], v_to[0]])
    return dist


n, m, start, goal = map(int, input().split())
adj_yen = [[] for _ in range(n+1)]
adj_snuuk = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    adj_yen[u].append([v, a])
    adj_yen[v].append([u, a])
    adj_snuuk[u].append([v, b])
    adj_snuuk[v].append([u, b])

min_dist_yen = dijkstra(adj_yen, start)
min_dist_snuuk = dijkstra(adj_snuuk, goal)
lose = [float('inf')] * n
for i in range(1, n+1):
    lose[-i] = min(lose[-i+1], min_dist_yen[n-i+1] + min_dist_snuuk[n-i+1])

for i in range(n):
    print(10 ** 15 - lose[i])
Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int, input().split())
D = [0] * C
for i in range(C):
    D[i] = list(map(int, input().split()))
grid = [0] * N
for i in range(N):
    grid[i] = list(map(int, input().split()))

ans_min = float('inf')
for i in range(C):
    j_list = list(range(C))
    j_list.remove(i)
    for j in j_list:
        k_list = list(range(C))
        k_list.remove(i)
        k_list.remove(j)
        for k in k_list:
            ans = 0
            for h in range(N):
                for w in range(N):
                    new_color = [i,j,k][(h+w) % 3]
                    ans += D[grid[h][w] - 1][new_color]
            if ans < ans_min:
                ans_min = ans
print(ans_min)

Fixed submission:
N, C = map(int, input().split())
D = [0] * C
for i in range(C):
    D[i] = list(map(int, input().split()))
grid = [0] * N
for i in range(N):
    grid[i] = list(map(int, input().split()))

cost0 = [0] * C
cost1 = [0] * C
cost2 = [0] * C
for color in range(C):
    for h in range(N):
        for w in range(N):
            mod = (h + w) % 3
            if mod == 0:
                cost0[color] += D[grid[h][w] - 1][color]
            elif mod == 1:
                cost1[color] += D[grid[h][w] - 1][color]
            else:
                cost2[color] += D[grid[h][w] - 1][color]

ans = float('inf')
for i in range(C):
    j_list = list(range(C))
    j_list.remove(i)
    for j in j_list:
        k_list = list(range(C))
        k_list.remove(i)
        k_list.remove(j)
        for k in k_list:
            ans = min(ans, cost0[i] + cost1[j] + cost2[k])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
import copy
input = sys.stdin.buffer.readline

N = int(input())
pq_L = []
pq_R = []
for i in range(N):
    L, R = map(int, input().split())
    heapq.heappush(pq_L, (-L, i))
    heapq.heappush(pq_R, (R, i))
pq_L2 = copy.deepcopy(pq_L)
pq_R2 = copy.deepcopy(pq_R)

ans1 = 0
prev = 0
used = [0] * N
for i in range(N):
    if i % 2 == 0:
        while True:
            _x, j = heapq.heappop(pq_L)
            x = -_x
            if not used[j]:
                used[j] = 1
                break
        if prev < x:
            ans1 += x - prev
            prev = x
    else:
        while True:
            x, j = heapq.heappop(pq_R)
            if not used[j]:
                used[j] = 1
                break
        if prev > x:
            ans1 += prev - x
            prev = x

ans1 += abs(prev)

ans2 = 0
prev = 0
used = [0] * N
for i in range(N):
    if i % 2 == 1:
        while True:
            _x, j = heapq.heappop(pq_L2)
            x = -_x
            if not used[j]:
                used[j] = 1
                break
        if prev < x:
            ans2 += x - prev
            prev = x
    else:
        while True:
            x, j = heapq.heappop(pq_R2)
            if not used[j]:
                used[j] = 1
                break
        if prev > x:
            ans2 += prev - x
            prev = x

ans2 += abs(prev)

print(max(ans1, ans2))


Fixed submission:
import sys
import heapq
import copy
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    pq_L = []
    pq_R = []
    for i in range(N):
        L, R = map(int, input().split())
        heapq.heappush(pq_L, (-L, i))
        heapq.heappush(pq_R, (R, i))
    pq_L2 = copy.deepcopy(pq_L)
    pq_R2 = copy.deepcopy(pq_R)

    ans1 = 0
    prev = 0
    used = [0] * N
    for i in range(N):
        if i % 2 == 0:
            while True:
                _x, j = heapq.heappop(pq_L)
                x = -_x
                if not used[j]:
                    used[j] = 1
                    break
            if prev < x:
                ans1 += x - prev
                prev = x
        else:
            while True:
                x, j = heapq.heappop(pq_R)
                if not used[j]:
                    used[j] = 1
                    break
            if prev > x:
                ans1 += prev - x
                prev = x

    ans1 += abs(prev)

    ans2 = 0
    prev = 0
    used = [0] * N
    for i in range(N):
        if i % 2 == 1:
            while True:
                _x, j = heapq.heappop(pq_L2)
                x = -_x
                if not used[j]:
                    used[j] = 1
                    break
            if prev < x:
                ans2 += x - prev
                prev = x
        else:
            while True:
                x, j = heapq.heappop(pq_R2)
                if not used[j]:
                    used[j] = 1
                    break
            if prev > x:
                ans2 += prev - x
                prev = x

    ans2 += abs(prev)

    print(max(ans1, ans2))


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

A_sum = [0] * (N + 1)
for i in range(1, N+1):
    A_sum[i] = A_sum[i-1] + A[i-1]
dict = {}
for a in A_sum:
    if a in dict.keys():
        dict[a] = dict[a] + 1
    else:
        dict[a] = 1
ans = 0
for num in dict.values():
    ans += num * (num-1) / 2
print(int(ans))


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

A_sum = [0] * (N + 1)
for i in range(1, N+1):
    A_sum[i] = A_sum[i-1] + A[i-1]
A_sum.sort()

ans = 0
add = 0
a_cur = float('inf')
for a in A_sum:
    if a != a_cur:
        add = 0
        a_cur = a
    else:
        add += 1
        ans += add
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

ans = [['#'] * 100 for _ in range(50)]
ans_ = [['.'] * 100 for _ in range(50)]
ans.extend(ans_)

h = 0
w = 0
for i in range(A-1):
    ans[h][w] = '.'
    w += 2
    if w >= 10:
        h += 2
        w = 0

h = 51
w = 0
for i in range(B-1):
    ans[h][w] = '#'
    w += 2
    if w >= 10:
        h += 2
        w = 0

for i in range(100):
    print(''.join(ans[i]))


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

ans = [['#'] * 100 for _ in range(50)]
ans_ = [['.'] * 100 for _ in range(50)]
ans.extend(ans_)

h = 0
w = 0
for i in range(A-1):
    ans[h][w] = '.'
    w += 2
    if w >= 100:
        h += 2
        w = 0

h = 51
w = 0
for i in range(B-1):
    ans[h][w] = '#'
    w += 2
    if w >= 100:
        h += 2
        w = 0

print(100, 100)
for i in range(100):
    print(''.join(ans[i]))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    win = 0
    for _ in range(N):
        a, k = map(int, input().split())
        while True:
            if a < k:
                g = 0
                break
            elif a % k == 0:
                g = a // k
                break
            else:
                a -= (a//k) + 1
        win ^= g
    if win:
        print('Takahashi')
    else:
        print('Aoki')


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline

    N = int(input())
    win = 0
    for _ in range(N):
        a, k = map(int, input().split())
        while True:
            if a < k:
                g = 0
                break
            elif a % k == 0:
                g = a // k
                break
            else:
                d = (a//k) + 1
                a -= d * ((a - k * (a//k))//d)
                if a < k:
                    g = 0
                    break
                elif a % k == 0:
                    g = a // k
                    break
                else:
                    a -= d

        win ^= g
    if win:
        print('Takahashi')
    else:
        print('Aoki')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import deque


def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        y, x = queue.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])


H, W = map(int, input().split())
white = 0
s = ['#' * (W + 2)]
for i in range(H):
    s_i = '#' + input() + '#'
    white += s_i.count('.')
    s.append(s_i)
s.append('#' * (W + 2))

visited = [[-1] * (W+2) for i in range(H+2)]
shortest = bfs(s, visited, 1, 1, H, W)
print(white - shortest - 1)


Fixed submission:
from collections import deque


def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while True:
        if len(queue) > 0:
            y, x = queue.popleft()
            if [y, x] == [gy, gx]:
                return visited[y][x]
            for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
                new_y, new_x = y+j, x+k
                if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])
        else:
            return -1


H, W = map(int, input().split())
white = 0
s = ['#' * (W + 2)]
for i in range(H):
    s_i = '#' + input() + '#'
    white += s_i.count('.')
    s.append(s_i)
s.append('#' * (W + 2))

visited = [[-1] * (W+2) for i in range(H+2)]
shortest = bfs(s, visited, 1, 1, H, W)
if shortest > 0:
    print(white - shortest - 1)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
s = input()
x, y = map(int, input().split())

flg = 1
x_list = []
y_list = []
tmp = 0
for i, si in enumerate(s):
    if si == 'F':
        tmp += 1
    else:
        if flg == 1:
            x_list.append(tmp)
        else:
            y_list.append(tmp)
        flg *= -1
        tmp = 0
if flg == 1:
    x_list.append(tmp)
else:
    y_list.append(tmp)

x = sum(x_list) - x
y = sum(y_list) - y
if x % 2 != 0 or y % 2 != 0:
    print('No')
    exit()
x //= 2
y //= 2

if s[0] == 'F':
    x_list.reverse()
    x_list.pop()

dpx = [[0] * (x+1) for _ in range(len(x_list)+1)]
dpx[0][0] = 1
dpy = [[0] * (y+1) for _ in range(len(y_list)+1)]
dpy[0][0] = 1
for i in range(len(x_list)):
    for j in range(x+1):
        if dpx[i][j]:
            dpx[i+1][j] = 1
            if j + x_list[i] <= x:
                dpx[i+1][j+x_list[i]] = 1
for i in range(len(y_list)):
    for j in range(y+1):
        if dpy[i][j]:
            dpy[i+1][j] = 1
            if j + y_list[i] <= y:
                dpy[i+1][j+y_list[i]] = 1

if dpx[-1][-1] and dpy[-1][-1]:
    print('Yes')
else:
    print('No')


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

flg = 1
x_list = []
y_list = []
tmp = 0
for i, si in enumerate(s):
    if si == 'F':
        tmp += 1
    else:
        if flg == 1:
            x_list.append(tmp)
        else:
            y_list.append(tmp)
        flg *= -1
        tmp = 0
if flg == 1:
    x_list.append(tmp)
else:
    y_list.append(tmp)

x = sum(x_list) - x
y = sum(y_list) - y
if x % 2 != 0 or y % 2 != 0:
    print('No')
    exit()

if x < 0 or y < 0:
    print('No')
    exit()

x //= 2
y //= 2

if s[0] == 'F':
    x_list.reverse()
    x_list.pop()

dpx = [[0] * (x+1) for _ in range(len(x_list)+1)]
dpx[0][0] = 1
dpy = [[0] * (y+1) for _ in range(len(y_list)+1)]
dpy[0][0] = 1
for i in range(len(x_list)):
    for j in range(x+1):
        if dpx[i][j]:
            dpx[i+1][j] = 1
            if j + x_list[i] <= x:
                dpx[i+1][j+x_list[i]] = 1
for i in range(len(y_list)):
    for j in range(y+1):
        if dpy[i][j]:
            dpy[i+1][j] = 1
            if j + y_list[i] <= y:
                dpy[i+1][j+y_list[i]] = 1

if dpx[-1][-1] and dpy[-1][-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = list(map(int, input().split()))

if N > 24:
    print(0)
else:
    ans = 0
    for i in range(2 ** N):
        bit = bin(i)[2:].zfill(N)
        D_mod24 = [0] * N
        for j in range(N):
            if bit[j] == '0':
                D_mod24[j] = D[j]
            else:
                D_mod24[j] = 24 - D[j]
        D_mod24.sort()
        ans_temp = min(min(D_mod24), 24 - max(D_mod24))
        for j in range(N-1):
            ans_temp = min(ans_temp, D_mod24[j+1] - D_mod24[j])
        ans = max(ans, ans_temp)
    print(ans)


Fixed submission:
from collections import Counter

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

if N > 23:
    print(0)
elif N > 11:
    D.append(0)
    D_count = Counter(D)
    if D_count.most_common()[0][1] > 2:
        print(0)
    else:
        print(1)
else:
    ans = 0
    for i in range(2 ** (N - 1)):
        bit = '0' + bin(i)[2:].zfill(N - 1)
        D_mod24 = [0] * N
        for j in range(N):
            if bit[j] == '0':
                D_mod24[j] = D[j]
            else:
                D_mod24[j] = 24 - D[j]
        D_mod24.sort()
        ans_temp = min(min(D_mod24), 24 - max(D_mod24))
        for j in range(N-1):
            ans_temp = min(ans_temp, D_mod24[j+1] - D_mod24[j])
        ans = max(ans, ans_temp)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


if K > max(A):
    print('IMPOSSIBLE')
elif K % gcd_list(A) != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')


Fixed submission:
import fractions
from functools import reduce

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


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if K > max(A):
    print('IMPOSSIBLE')
elif K % gcd_list(A) != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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


def gcd(numbers):
    return reduce(math.gcd, numbers)

if K > max(A):
    print('IMPOSSIBLE')
elif K % gcd(A) != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')


Fixed submission:
import fractions
from functools import reduce

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


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if K > max(A):
    print('IMPOSSIBLE')
elif K % gcd_list(A) != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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


def gcd(numbers):
    return reduce(math.gcd, numbers)

if K > max(A):
    print('IMPOSSIBLE')
elif K % gcd(A) != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')


Fixed submission:
import fractions
from functools import reduce

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


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if K > max(A):
    print('IMPOSSIBLE')
elif K % gcd_list(A) != 0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')