Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
num = 1
for i in range(0,N):
    if A[i]==0:
      	num=0
      	break
for i in range(0,N):
    if num>10**18:
        break
    else:
        num *=A[i]
if num>10**18:
    print(-1)
else:
    print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
num = 1
for i in range(0,N):
    if A[i]==0:
      	num=0
      	break
    else if num>10**18:
      break
    else:
      num *=A[i]
 
  
if num>10**18:
    print(-1)
else:
    print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
num = 1
for i in range(0,N):
    if A[i]==0:
      	num=0
      	break
    else:
  		num *= A[i]
  
if num>10**18:
    print(-1)
else:
    print(num)
Problem p02555 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = int(input())
    MOD = 10 ** 9 + 7

    if S <= 2:
        print(0)
        exit()

    dp = [1] * (S + 1)
    dp[0] = 0
    dp[1] = 0
    dp[2] = 0


    for i in range(3, S + 1):
        for j in range(i - 3, 1, -1):
            dp[i] += dp[j]
            dp[i] %= MOD

    print(dp[S] % MOD)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = int(input())
    MOD = 10 ** 9 + 7

    dp = [1] * (S + 1)
    dp[0] = 0
    dp[1] = 0
    dp[2] = 0

    for i in range(3, S + 1):
        for j in range(i - 3, 1, -1):
            dp[i] += dp[j]
            dp[i] %= MOD

    print(dp[S] % MOD)


if __name__ == '__main__':
    main()
Problem p02608 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    ans = [0] * (10000 + 1)

    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                if x * x + y * y + z * z + x * y + y * z + z * x >= 10001:
                    continue
                ans[x * x + y * y + z * z + x * y + y * z + z * x] += 1

    for i in range(1, N + 1):
        print(ans[i])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    ans = [0] * (1000 + 1)

    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                if x * x + y * y + z * z + x * y + y * z + z * x >= 1001:
                    continue
                ans[x * x + y * y + z * z + x * y + y * z + z * x] += 1

    for i in range(1, N + 1):
        print(ans[i])


if __name__ == '__main__':
    main()
Problem p02642 (python)

Fixed submission:
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    aset = list(set(A))
    aset.sort()

    ans = [0] * (10 ** 6 + 1)

    for a in aset:
        for i in range(2, 10 ** 6 + 1):
            if a * i > 10 ** 6:
                break
            ans[a * i] += 1

    res = 0
    c = collections.Counter(A)
    for a in A:
        if ans[a] == 0 and c[a] == 1:
            res += 1

    print(res)



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import collections
import sympy

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    aset = list(set(A))
    aset.sort()

    past = set()
    ans = 0
    ansset = set()
    for a in aset:
        divs = sympy.divisors(a)
        for div in divs:
            if div in past:
                break
        else:
            ansset.add(a)
            ans += 1

        past.add(a)

    c = collections.Counter(A)
    for cc in c.most_common():
        if cc[1] == 1:
            break

        if cc[1] > 1 and cc[0] in ansset:
            ans -= 1

    print(ans)


if __name__ == '__main__':
    main()
Problem p02696 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, N = [int(x) for x in input().split()]

    def f(m):
        return (A * m) // B - A * (m // B)

    l = f(0)
    e = f(N)

    def isOK(mid):
        if f(mid) - l >= 0:
            return True
        else:
            return False
    def isOK2(mid):
        if f(mid) - e >= 0:
            return True
        else:
            return False

    ok = 0
    ng = N + 1

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    ans = max(l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

    ok = N
    ng = 0

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK2(mid):
            ok = mid
        else:
            ng = mid

    ans = max(ans, l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

    print(max(ans, f(min(B - 1, N))))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if not (1 <= M):
    1 // 0
if not (M * 2 + 1 <= N <= 200000:
    1 // 0
Problem p02697 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    ans = [[] for j in range(M)]

    if N % 2:
        for i in range(M):
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)
    else:
        memo = 0
        for i in range(M):
            memo = i
            if (i + 1) * 4 >= N:
                break
            ans[i].append(i + 1)
            ans[i].append(N - i - 1)
            memo += 1

        for j in range(memo, M):
            ans[j].append(j + 1)
            ans[j].append(N - j - 2)
    for a in ans:
        print(*a)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if not (1 <= M):
    1 // 0
if not (M * 2 + 1 <= N <= 100000):
    1 // 0

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if not (1 <= M):
    1 // 0
if not (M * 2 + 1 <= N <= 100000:
    1 // 0
Problem p02761 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    SC = [[int(x) for x in input().split()] for _ in range(M)]

    f = False
    for i in range(1000):
        if len(str(i)) != N:
            continue

        x = str(i)
        for s, c in SC:
            if int(x[s - 1]) != c:
                break
        else:
            f = True

        if f:
            print(i)
            return
    else:
        print(-1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    SC = [[int(x) for x in input().split()] for _ in range(N)]

    f = False
    for i in range(1000):
        if len(str(i)) != N:
            continue

        x = str(i)
        for s, c in SC:
            if int(x[s - 1]) != c:
                break
        else:
            f = True

        if f:
            print(i)
            return
    else:
        print(-1)


if __name__ == '__main__':
    main()
Problem p02882 (python)

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

def main():
    a, b, x = [int(x) for x in input().split()]
    b_now = x / (a * a)
    menseki = b_now * a
    ans_a = menseki * 2 / b

    if a * a * b == x:
        print(0)
        exit()

    if ans_a <= a:
        z = math.degrees(math.atan(ans_a / b))
        print(90 - z)
        exit()
    else:
        menseki = a * b - menseki
        ans_b = menseki * 2 / a
        z = math.degrees(math.atan(a / ans_b))
        print(90 - z)
        exit()



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math

def main():
    a, b, x = [int(x) for x in input().split()]
    b_now = x / (a * a)
    menseki = b_now * a
    ans_a = menseki * 2 / b

    if ans_a <= a:
        z = math.degrees(math.atan(ans_a / b))
        print(90 - z)
        exit()
    else:
        menseki = a * b - menseki
        ans_b = menseki * 2 / a
        z = math.degrees(math.atan(a / ans_b))
        print(90 - z)
        exit()



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math

def main():
    a, b, x = [int(x) for x in input().split()]
    b_now = x / (a * a)
    menseki = b_now * a
    ans_a = menseki * 2 / b

    # 三角形の場合
    if ans_a <= a:
        z = math.degrees(math.atan(ans_a / b))
        print(90 - z)
        exit()

    # 三角形 + 平行四辺形の場合
    else:
        menseki = a * b - menseki
        ans_b = menseki * 2 / a
        z = math.degrees(math.atan(a / ans_b))
        print(90 - z)
        exit()



if __name__ == '__main__':
    main()
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
count = 0
for x in range(len(S)):
    if S[x] == T[x]:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(sum(range(1, N)))
Problem p02937 (python)

Fixed submission:
import bisect

S = input().strip()
T = input().strip()

x = [[] for j in range(26)]

for i, s in enumerate(S):
    x[ord(s) - ord('a')].append(i)

sett = list(set(T))

for t in sett:
    if len(x[ord(t) - ord('a')]) == 0:
        print(-1)
        exit()

c = 0
z = 0

for t in T:
    y = bisect.bisect_left(x[ord(t) - ord('a')], c)
    if y == len(x[ord(t) - ord('a')]):
        z += 1
        c = x[ord(t) - ord('a')][0] + 1
    else:
        c = x[ord(t) - ord('a')][y] + 1

print(z * len(S) + c)

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

including = True
for x in t:
    if x  not in s:
        including = False
        break
if not including:
    print(-1)
    return


x = 0
y = 0
while True:
    index = x % len(s)
    if s[index] == t[y]:
        y += 1
        if y == len(t):
            break
    x += 1

print(x + 1)
Problem p02960 (python)

Fixed submission:

S = input()

MOD = 10 ** 9 + 7
count = 0
S_len = len(S)

dp = [[0 for i in range(13)] for j in range(100006)]
c = -1
if S[0] != '?':
    c = int(S[0])
for j in range(10):
    if c == -1:
        dp[1][j] = 1
    else:
        dp[1][c] = 1

for i in range(2, S_len + 1):
    c = -1
    if S[i - 1] != '?':
        c = ord(S[i - 1]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i][(k * 10 + j) % 13] += dp[i - 1][k] % MOD


print(dp[S_len][5] % MOD)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

S = input().strip()

MOD = 10 ** 9 + 7

lens = len(S)

sys.setrecursionlimit(10 ** 8)

@lru_cache(maxsize=None)
def solve(amari, keta):
    if keta == lens - 1:
        if S[keta] == "?":
            cnt = 0
            for i in range(9, -1, -1):
                if (amari + i) % 13 == 5:
                    cnt += 1
            return cnt
        else:
            if (amari + int(S[keta])) % 13 == 5:
                return 1 % MOD
            else:
                return 0
    else:
        if S[keta] == "?":
            x = 0
            for i in range(9, -1, -1):
                x += solve((amari + (i * 10 ** (lens - 1 - keta)) % 13) % 13, keta + 1)
            return x % MOD
        else:
            return solve((amari + (int(S[keta]) * 10 ** (lens - 1 - keta)) % 13) % 13, keta + 1) % MOD


print(solve(0, 0) % MOD)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

S = input().strip()

MOD = 10 ** 9 + 7

lens = len(S)


@lru_cache(maxsize=None)
def solve(amari, keta):
        if keta == lens - 1:
            if S[keta] == "?":
                cnt = 0
                for i in range(9, -1, -1):
                    if (amari + i) % 13 == 5:
                        cnt += 1
                return cnt
            else:
                if (amari + int(S[keta])) % 13 == 5:
                    return 1
                else:
                    return 0
        else:
            if S[keta] == "?":
                x = 0
                for i in range(9, -1, -1):
                    x += solve((amari + (i * 10 ** (lens - 1 - keta)) % 13) % 13, keta + 1)
                return x % MOD
            else:
                return solve((amari + (int(S[keta]) * 10 ** (lens - 1 - keta)) % 13) % 13, keta + 1) % MOD


print(solve(0, 0) % MOD)
Problem p02971 (python)

Fixed submission:
N = int(input().rstrip())
A = []
for _ in range(N):
    A.append(int(input().rstrip()))

A_sorted = sorted(A)

for i in range(N):
    if A[i] != A_sorted[-1]:
        print(A_sorted[-1])
    else:
        print(A_sorted[-2])

Buggy submission (verdict: Runtime Error):
N = int(input().rstrip())
A = []
for _ in range(N):
    A.append(int(input().rstrip()))

max_num = max(A)

for i in range(N):
    if A[i] != max_num:
        print(max_num)
    else:
        if i == N - 1:
            print(max(A[0:i]))
        else:
            print(max(max(A[0:i]),max(A[i + 1:])))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

max_num = max(A)

for i in range(N):
    if A[i] != max_num:
        print(max_num)
    else:
        print(max(max(A[0:i]),max(A[i + 1:])))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

max_num = max(A)

for i in range(N):
    if A[i] != max_num:
        print(max_num)
    else:
        print(max(max(A[0:i]),max(A[i + 1:]))
Problem p02995 (python)

Fixed submission:
import fractions

A, B, C, D = [int(x) for x in input().split()]

X = (C * D) // fractions.gcd(C, D)
ans = (B - A + 1)\
      - (B // C - A // C)\
      - (B // D - A // D)\
      + (B // X - A // X)
if A % C == 0:
      ans -= 1
if A % D == 0:
      ans -= 1
if A % X == 0:
      ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = [int(x) for x in input().split()]

X = (C * D) // math.gcd(C, D)
ans = (B - A + 1)\
      - (B // C - A // C)\
      - (B // D - A // D)\
      + (B // X - A // X)
if A % C == 0:
      ans -= 1
if A % D == 0:
      ans -= 1
if A % X == 0:
      ans += 1

print(ans)
Problem p03006 (python)

Fixed submission:
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    XY = [[int(x) for x in input().split()] for _ in range(N)]

    c = collections.Counter()

    if N == 1:
        print(1)
        return

    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            xi, yi = XY[i]
            xj, yj = XY[j]
            c[(xi - xj, yi - yj)] += 1

    print(N - c.most_common()[0][1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    XY = [[int(x) for x in input().split()] for _ in range(N)]

    c = collections.Counter()

    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            xi, yi = XY[i]
            xj, yj = XY[j]
            c[(xi - xj, yi - yj)] += 1

    print(N - c.most_common()[0][1])


if __name__ == '__main__':
    main()
Problem p03061 (python)

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    A_sorted = sorted(A)
    div0 = make_divisors(A_sorted[0])
    ans = 1
    for d in div0[1:]:
        count = 0
        isAns = True
        for i in A_sorted[1:]:
            if i % d != 0:
                count += 1
                if count == 2:
                    isAns = False
                    break
        if isAns:
            ans = max(ans, d)
    div1 = make_divisors(A_sorted[1])
    for d in div1[1:]:
        count = 0
        isAns = True
        for i in A_sorted[2:]:
            if i % d != 0:
                isAns = False
                break
        if isAns:
            ans = max(ans, d)

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import fractions
input = sys.stdin.readline
import heapq


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    A_sorted = sorted(list(set(A)))

    if len(A_sorted) <= 2:
        print(max(A_sorted))
        exit()

    min = 10 ** 10
    min_index = -1
    for i in range(N - 1):
        x = fractions.gcd(A_sorted[i], A_sorted[i + 1])
        if min > x:
            min = x
            min_index = i

    gcd = A_sorted[0]
    if min_index == 0:
        gcd = A_sorted[2]

    for i in range(N):
        if i == min_index or i == min_index + 1:
            continue
        gcd = fractions.gcd(gcd, A_sorted[i])

    x = fractions.gcd(gcd, A_sorted[min_index])
    y = fractions.gcd(gcd, A_sorted[min_index + 1])

    print(max([x, y]))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import fractions
input = sys.stdin.readline
import heapq


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    A_sorted = sorted(set(A))

    if len(A) == 2:
        print(max(A))
        exit()

    min = 10 ** 10
    min_index = -1
    for i in range(N - 1):
        x = fractions.gcd(A_sorted[i], A_sorted[i + 1])
        if min > x:
            min = x
            min_index = i

    gcd = A_sorted[0]
    if min_index == 0:
        gcd = A_sorted[2]

    for i in range(N):
        if i == min_index or i == min_index + 1:
            continue
        gcd = fractions.gcd(gcd, A_sorted[i])

    x = fractions.gcd(gcd, A_sorted[min_index])
    y = fractions.gcd(gcd, A_sorted[min_index + 1])

    print(max([x, y]))

if __name__ == '__main__':
    main()
Problem p03087 (python)

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


def main():
    N, Q = [int(x) for x in input().split()]
    S = input().strip()

    ac = []
    for i in range(len(S) - 1):
        if S[i] == 'A' and S[i + 1] == 'C':
            ac.append(i)

    for _ in range(Q):
        x, y = [int(x) for x in input().split()]
        l = bisect.bisect_left(ac, x - 1)
        r = bisect.bisect_right(ac, y - 2)
        print(r - l)

    
    




if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import bisect


def main():
    N, Q = [int(x) for x in input().split()]
    S = input().strip()

    ac = []
    for i, s in enumerate(S):
        if s == 'A' and S[i + 1] == 'C':
            ac.append(i)

    for _ in range(Q):
        x, y = [int(x) for x in input().split()]
        l = bisect.bisect_left(ac, x - 1)
        r = bisect.bisect_right(ac, y - 2)
        print(r - l)

    
    




if __name__ == '__main__':
    main()
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0 
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if x == (i * 500 + j * 100 + k * 50):
                count += 1

print(count)

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

    count = 0 
    for i in range(a + 1):
        for j in range(b + 1):
            for k in range(c + 1):
                if x == (i * 500 + j * 100 + k * 50):
                    count += 1
    
    print(count)
Problem p03608 (python)

Fixed submission:
import sys
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, csgraph_from_dense
import itertools

input = sys.stdin.readline


def main():
    N, M, R = [int(x) for x in input().split()]
    r = [int(x) - 1 for x in input().split()]
    ABC = [[int(x) for x in input().split()] for _ in range(M)]

    EDGE = [[10 ** 9] * N for j in range(N)]

    for a, b, c in ABC:
        EDGE[a - 1][b - 1] = c
        EDGE[b - 1][a - 1] = c

    G = csgraph_from_dense(EDGE, null_value=10 ** 9)

    d = floyd_warshall(G)

    ans = float("inf")
    for a in itertools.permutations(r):
        tmp = 0
        c = a[0]
        for n in a:
            tmp += int(d[c][n])
            c = n
        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, csgraph_from_dense
import itertools

input = sys.stdin.readline


def main():
    N, M, R = [int(x) for x in input().split()]
    r = [int(x) - 1 for x in input().split()]
    ABC = [[int(x) for x in input().split()] for _ in range(M)]

    EDGE = [[10 ** 9] * N for j in range(N)]

    for a, b, c in ABC:
        EDGE[a - 1][b - 1] = c
        EDGE[b - 1][a - 1] = c

    G = csgraph_from_dense(EDGE, null_value=10 ** 9)

    d = floyd_warshall(G)

    ans = float("inf")
    for a in itertools.permutations(r):
        tmp = 0
        c = a[0]
        for n in a:
            tmp += int(d[c][n])
            c = n
        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()
Problem p03651 (python)

Fixed submission:
import sys
import fractions

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    A.sort()

    if N == 1:
        if A[0] == K:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return

    g = fractions.gcd(A[0], A[1])

    for a in A:
        g = fractions.gcd(g, a)

    for a in A:
        if a >= K:
            if (K - a) % g == 0:
                print("POSSIBLE")
                return
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()

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

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    A.sort()

    if N == 1:
        if A[0] == K:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        return

    g = math.gcd(A[0], A[1])

    for a in A:
        g = math.gcd(g, a)

    for a in A:
        if a >= K:
            if (K - a) % g == 0:
                print("POSSIBLE")
                return
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()
Problem p02784 (python)

Fixed submission:
H, N = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) >= H:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H, N = map(int, input().split())
A = list(map(int, input().split()))
import itertools
a = list(itertools.combinations(A, 2))

if sum(max(a)) >= H:
    print('Yes')
else:
    print('No')