Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0])

print((a // 10 + (1 if a % 10 != 0 else 0)) * 10 + (b // 10 + (1 if b % 10 != 0 else 0)) * 10 + (c // 10 + (1 if c % 10 != 0 else 0)) * 10 + (d // 10 + (1 if d % 10 != 0 else 0)) * 10 + (e // 10 + (1 if e % 10 != 0 else 0)) * 10 - 10 + m)


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if len([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0]) > 0:
    m = min([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0])
else:
    m = 10

print((a // 10 + (1 if a % 10 != 0 else 0)) * 10 + (b // 10 + (1 if b % 10 != 0 else 0)) * 10 + (c // 10 + (1 if c % 10 != 0 else 0)) * 10 + (d // 10 + (1 if d % 10 != 0 else 0)) * 10 + (e // 10 + (1 if e % 10 != 0 else 0)) * 10 - 10 + m)
Buggy python submission (verdict: Runtime Error):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()

l = {i: 0 for i in range(13)}

for d in D:
    l[d] += 1

possible_lists = [[]]

for k, v in l.items():
    if v > 2:
        possible_lists = [0]
        break
    elif v > 1:
        new = [[0]] + [pl + [k, 24-k] for pl in possible_lists]
        # new = [pl + [k, k] for pl in possible_lists] + [pl + [24-k, 24-k] for pl in possible_lists] + [pl + [k, 24-k] for pl in possible_lists]
        possible_lists = new
    elif v > 0:
        new = [pl + [k] for pl in possible_lists] + [pl + [24-k] for pl in possible_lists]
        possible_lists = new

Max = -1
for pl in possible_lists:
    Min = 13
    pl.sort()
    for i in range(len(pl)):
        if i == 0:
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        elif i == len(pl)-1:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        else:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
    Max = max(Min, Max)

print(Max)


Fixed submission:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()

l = {i: 0 for i in range(13)}

for d in D:
    l[d] += 1

possible_lists = [[]]

for k, v in l.items():
    if v > 2:
        possible_lists = [[0]]
        break
    elif v > 1:
        new = [[0]] + [pl + [k, 24-k] for pl in possible_lists]
        # new = [pl + [k, k] for pl in possible_lists] + [pl + [24-k, 24-k] for pl in possible_lists] + [pl + [k, 24-k] for pl in possible_lists]
        possible_lists = new
    elif v > 0:
        new = [pl + [k] for pl in possible_lists] + [pl + [24-k] for pl in possible_lists]
        possible_lists = new

Max = -1
for pl in possible_lists:
    Min = 13
    pl.sort()
    for i in range(len(pl)):
        if i == 0:
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        elif i == len(pl)-1:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
            cand = pl[i]-0
            Min = min(Min, min(cand, 24-cand))
        else:
            cand = pl[i]-pl[i-1]
            Min = min(Min, min(cand, 24-cand))
    Max = max(Min, Max)

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N = ir()
start = ir()
next = 0
for n in range(1, N):
    next = ir()
    start = lcm(start, next)

print(start)


Fixed submission:
import sys
import fractions

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N = ir()
start = ir()
next = 0
for n in range(1, N):
    next = ir()
    start = lcm(start, next)

print(start)
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
E = {i+1: [] for i in range(M)}
first = []
for m in range(M):
    a, b = lr()
    if b == N:
        first.append(a)
    E[a].append(b)
for f in first:
    if f in E[1]:
        print("POSSIBLE")
        exit(0)
print("IMPOSSIBLE")


Fixed submission:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
E = {i+1: set() for i in range(N)}
first = set()
for m in range(M):
    a, b = lr()
    if b == N:
        first.add(a)
    E[a].add(b)
if not first.isdisjoint(E[1]):
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
A = [0 for _ in range(M)]
B = [0 for _ in range(M)]
first = []
for m in range(M):
    a, b = lr()
    if a == 1:
        first.append(b)
    A[m] = a
    B[m] = b
for i, b in enumerate(B):
    if b == N:
        if A[i] in first:
            print("POSSIBLE")
            exit(0)
print("IMPOSSIBLE")


Fixed submission:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
E = {i+1: set() for i in range(N)}
first = set()
for m in range(M):
    a, b = lr()
    if b == N:
        first.add(a)
    E[a].add(b)
if not first.isdisjoint(E[1]):
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from itertools import combinations

MOD = 2  # type: int


def solve(N: int, P: int, A: "List[int]"):
    c = 0
    for i in range(N+1):
        for com in combinations(A, i):
            if sum(com) % 2 == P:
                c += 1
    print(c)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from itertools import combinations

MOD = 2  # type: int


def solve(N: int, P: int, A: "List[int]"):
    if all(map(lambda a: a % 2 == 0, A)):
        print(2 ** N if P == 0 else 0)
        return
    print(2 ** (N-1))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    A = 14 if A == 1 else A
    B = 14 if B == 1 else B
    if A == B:
        print("Draw")
    elif A > B:
        print("Alice")
    else:
        print("Bob")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    A = 14 if A == 1 else A
    B = 14 if B == 1 else B
    if A == B:
        print("Draw")
    elif A > B:
        print("Alice")
    else:
        print("Bob")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            for z in range(K+1):
                if x + y + z == S:
                    count += 1
    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    count = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                count += 1
    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(X: str):
    next = X.replace("ST", "")
    while next != X:
        X = next
        next = X.replace("ST", "")
    print(len(X))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = next(tokens)  # type: str
    solve(X)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections import deque


def solve(X: str):
    stack = deque(X[0])
    for i in range(1, len(X)):
        if not stack:
            stack.append(X[i])
            continue
        if stack[-1] == "T":
            stack.append(X[i])
            continue
        if X[i] == "T":
            stack.pop()
            continue
        stack.append(X[i])

    print(len(stack))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = next(tokens)  # type: str
    solve(X)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(X: str):
    i = X.find("ST")
    while i >= 0:
        X = X[:i] + X[i+2:]
        i = X.find("ST")
    print(len(X))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = next(tokens)  # type: str
    solve(X)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections import deque


def solve(X: str):
    stack = deque(X[0])
    for i in range(1, len(X)):
        if not stack:
            stack.append(X[i])
            continue
        if stack[-1] == "T":
            stack.append(X[i])
            continue
        if X[i] == "T":
            stack.pop()
            continue
        stack.append(X[i])

    print(len(stack))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = next(tokens)  # type: str
    solve(X)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split())) 
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if A[i] + A[j] == abs(i-j):
            ans += 1
print(ans)

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

"""
A[i] + A[j] = j - i
A[i] + i = j - A[j]

a = A[i] + i
b = j - A[j]
"""

ans = 0
dic = {}

for i in range(N-1, -1, -1):
    wa = A[i] + i
    if wa in dic:
        ans += dic[wa]
    sa = i - A[i]
    if sa in dic:
        dic[sa] += 1
    else:
        dic[sa] = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def bisearch(function, ok, ng):
    tmp = 0
    while abs(ok-ng) > 1:
        mid = (ok + ng)//2
        ans = function(mid)
        if ans > tmp:
            ok = mid
        else:
            ng = mid
        print("mid:{}".format(mid))
        tmp = ans
    return ok

def calc(x):
    return (math.floor(A*x/B) - A*math.floor(x/B))

A, B, N = map(int, input().split())
ok = N
ng = 0

# print(bisearch(calc, ok, ng))
ans = []
tmp = calc(1)
for i in range(1, N+1):
    a = calc(i)
    ans.append(a)
    if tmp > a:
        break
    tmp = a

print(max(ans))

Fixed submission:
import math

def calc(x):
    return (math.floor(A*x/B) - A*math.floor(x/B))

A, B, N = map(int, input().split())
print(calc(min(B-1, N)))

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

def bisearch(function, ok, ng):
    tmp = 0
    while abs(ok-ng) > 1:
        mid = (ok + ng)//2
        ans = function(mid)
        if ans > tmp:
            ok = mid
        else:
            ng = mid
        print("mid:{}".format(mid))
        tmp = ans
    return ok

def calc(x):
    return (math.floor(A*x/B) - A*math.floor(x/B))

A, B, N = map(int, input().split())
ok = N
ng = 0

# print(bisearch(calc, ok, ng))
ans = []
tmp = calc(1)
for i in range(1, min(N+1)):
    a = calc(i)
    ans.append(a)
    if tmp > a:
        break
    tmp = a

print(max(ans))

Fixed submission:
import math

def calc(x):
    return (math.floor(A*x/B) - A*math.floor(x/B))

A, B, N = map(int, input().split())
print(calc(min(B-1, N)))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

if K != 1:
    ans = N%(abs(N-K))
else:
    ans = 0
print(ans)

Fixed submission:
N, K = map(int, input().split())
ans = min(K-(N%K), N%K)
print(ans)
Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

anslist = p[:x] + q[:y]
anslist.sort()
for i, x in enumerate(r):
    if x > anslist[i]:
        anslist[i] = x

print(sum(anslist))

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

anslist = p[:x] + q[:y]
anslist.sort()
for i, num in enumerate(r):
    if i >= x+y:
        break
    if num > anslist[i]:
        anslist[i] = num

print(sum(anslist))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
query = []
for _ in range(Q):
    query.append(input().split(" "))

def calc(q, S):
    if q[0] == "1":
        S = S[::-1]
    else:
        if q[1] == "1":
            S = q[2] + S
        else:
            S = S + q[2]
    return S

for q in query:
    S = calc(q, S)
print(S)

Fixed submission:
import collections
S = input()
dq = collections.deque(S)
Q = int(input())
q = []
hanten = False
for _ in range(Q):
    q = input().split(" ")
    if q[0] == '1':
        hanten = not hanten
    else:
        if q[1] == '1' and not hanten:
            dq.appendleft(q[2])
        elif q[1] == '1' and hanten:
            dq.append(q[2])
        elif q[1] == '2' and not hanten:
            dq.append(q[2])
        else:
            dq.appendleft(q[2])
if not hanten:
    print(''.join(dq))
else:
    print(''.join(dq)[::-1])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
query = [list(input().split()) for _ in range(M)]

for num in range(10**N):
    if len(str(num)) != N:
        continue
    else:
        cnt = 0
        s = str(num)
        for sc in query:
            if s[int(sc[0])-1] == sc[1]:
                cnt += 1
        if cnt == M:
            ans = num
            break
print(ans)

Fixed submission:
N, M = map(int, input().split())
query = [list(input().split()) for _ in range(M)]
ans = -1
for num in range(10**N):
    if len(str(num)) != N:
        continue
    else:
        cnt = 0
        s = str(num)
        for sc in query:
            if s[int(sc[0])-1] == sc[1]:
                cnt += 1
        if cnt == M:
            ans = num
            break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [sum(range(1, p+1))/p for p in P]

cumsum = [0]*(N+1)
for i in range(1, N+1):
    cumsum[i] = cumsum[i-1] + P[i-1]
ans = 0
for i in range(N-K+1):
    if ans < cumsum[i+K]-cumsum[i]:
        ans = cumsum[i+K]-cumsum[i]
print(ans) 

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [(1+p)/2 for p in P]

cumsum = [0]*(N+1)
for i in range(1, N+1):
    cumsum[i] = cumsum[i-1] + P[i-1]
ans = 0
for i in range(N-K+1):
    if ans < cumsum[i+K]-cumsum[i]:
        ans = cumsum[i+K]-cumsum[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [sum(range(1, p+1))/p for p in P]
anses = [sum(P[i:i+K]) for i in range(N-K+1)]
print(max(anses))

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [(1+p)/2 for p in P]

cumsum = [0]*(N+1)
for i in range(1, N+1):
    cumsum[i] = cumsum[i-1] + P[i-1]
ans = 0
for i in range(N-K+1):
    if ans < cumsum[i+K]-cumsum[i]:
        ans = cumsum[i+K]-cumsum[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(int(A*B/math.gcd(A, B)))

Fixed submission:
from fractions import gcd
A, B = map(int, input().split())
print(int(A*B/gcd(A, B)))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys
n = int(input())
h = list(map(int, input().split()))
tmp = h[0]
for i in range(1, n):
    if h[i] - tmp == 0:
        tmp = h[i]
        continue
    elif h[i] - tmp >= 1:
        tmp = h[i] - 1
        continue
    else:
        print("No")
        sys.exit(1)
print("Yes")

Fixed submission:
#!/usr/bin/env python
import sys
n = int(input())
h = list(map(int, input().split()))
tmp = h[0]
for i in range(1, n):
    if h[i] - tmp == 0:
        tmp = h[i]
        continue
    elif h[i] - tmp >= 1:
        tmp = h[i] - 1
        continue
    else:
        print("No")
        sys.exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
n, m = map(int, input().split())
l = []
r = []
for i in range(m):
    x, y = map(int, input().split())
    l.append(x)
    r.append(y)
ans = 0
for i in range(1,n+1):
    if max(l) <= i and i <= min(r):
        ans += 1
print(ans) 

Fixed submission:
import fractions
n, m = map(int, input().split())
l = []
r = []
for i in range(m):
    x, y = map(int, input().split())
    l.append(x)
    r.append(y)
ans = 0
M = max(l)
m = min(r)
for i in range(1,n+1):
    if M <= i and i <= m:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
devisors = [1]
for i in range(2, max(a, b)):
    if a%i == 0 and b%i == 0:
        devisors.append(i)
print(devisors[-k])

Fixed submission:
a, b, k = map(int, input().split())
devisors = [1]
for i in range(2, min(a, b)+1):
    if a%i == 0 and b%i == 0:
        devisors.append(i)
print(devisors[-k])
Buggy python submission (verdict: Runtime Error):
import sympy
n = int(input())
a = list(map(int, input().split()))

print(sympy.gcd(a))

Fixed submission:
import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in a:
    ans = fractions.gcd(ans, i)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

x = []
for _ in range(3):
    x.extend(list(map(int,input().split())))
cnt = [0]*4
for i in range(6):
    cnt[x[i]-1] += 1
for a in cnt:
    if a > 2:
        print("NO")
        sys.exit(1)
print("YES")


Fixed submission:
x = []
f  = 1
for _ in range(3):
    x.extend(list(map(int,input().split())))
cnt = [0]*4
for i in range(6):
    cnt[x[i]-1] += 1
for a in cnt:
    if a > 2:
        f = 0
if f:
    print("YES")
else:
    print("NO")

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

x = []
for _ in range(3):
    x.extend(list(map(int,input().split())))
a = b = c = d = 0
for i in range(6):
    if x[i] == 1:
        a += 1
    if x[i] == 2:
        b += 1
    if x[i] == 3:
        c += 1
    if x[i] == 4:
        d += 1
if a == 3:
    print("NO")
    sys.exit(1)
if b == 3:
    print("NO")
    sys.exit(1)
if c == 3:
    print("NO")
    sys.exit(1)
if d == 3:
    print("NO")
    sys.exit(1)
print("YES")

Fixed submission:
x = []
f  = 1
for _ in range(3):
    x.extend(list(map(int,input().split())))
cnt = [0]*4
for i in range(6):
    cnt[x[i]-1] += 1
for a in cnt:
    if a > 2:
        f = 0
if f:
    print("YES")
else:
    print("NO")

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

x = []

for _ in range(3):
    x.extend(list(map(int,input().split())))
x.sort()
a = b = c = d = 0
for i in range(6):
    if x[i] == 1:
        a += 1
    elif x[i] == 2:
        b += 1
    elif x[i] == 3:
        c += 1
    else:
        d += 1
if a > 2 or a < 0:
    print("NO")
    sys.exit(1)
elif b > 2 or b < 0:
    print("NO")
    sys.exit(1)
elif c > 2 or c < 0:
    print("NO")
    sys.exit(1)
elif d > 2 or d < 0:
    print("NO")
    sys.exit(1)
print("YES")

Fixed submission:
x = []
f  = 1
for _ in range(3):
    x.extend(list(map(int,input().split())))
cnt = [0]*4
for i in range(6):
    cnt[x[i]-1] += 1
for a in cnt:
    if a > 2:
        f = 0
if f:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')]*N
dp[0] = 0
for i in range(N):
    for j in range(max(0, i - K), i):
        dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]))
print(dp[-1])

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

dp = [float('inf')]*N
dp[0] = 0
for i in range(N):
    for j in range(max(0, i - K), i):
        dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]))
print(dp[-1])