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

Fixed submission:
n = int(input())
count = 0
currCount = 0
ans = 0
for i in range(n+1):
    currCount = 0
    currNum = i
    while (i % 2) == 0:
        if i == 0:
            break
        i = int(i / 2)
        currCount += 1
    if count <= currCount:
        count = currCount
        ans = currNum
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
currCount = 0
ans = 0
for i in range(n+1):
    currCount = 0
    currNum = i
    while (i % 2) == 0:
        if i == 0:
            break
        i = int(i / 2)
        currCount += 1
    if count < caurrCount:
        count = currCount
        ans = currNum
print(ans)
Problem p03679 (python)

Fixed submission:
x, a, b = map(int, input().split())
if a >= b:
    print("delicious")
elif (b - a) <= x:
    print("safe")
else:
    print("dangerous")

Buggy submission (verdict: Runtime Error):
x, a, b = int(input().split())
if a >= b:
    print("delicious")
elif (b - a) <= x:
    print("safe")
else:
    print("dangerous")
Problem p03696 (python)

Fixed submission:
from collections import deque

N = int(input())
S = input()
ans = deque(S)


while S.find("()") != -1:
    S = S.replace("()","")

for i in range(len(S)):
    if S[i] == ")":
        ans.appendleft("(")
    elif S[i] == "(":
        ans.append(")")
print("".join(ans))

Buggy submission (verdict: Runtime Error):
from collections import deque

N = int(input())
S = input()
ans = deque(S)
S += " "

ind = 0
for _ in range(N):
    if S[ind] == "(" and S[ind+1] == ")":
        ind += 2
        continue
    elif S[ind] == ")":
        ans.appendleft("(")
    elif S[ind] == "(":
        ans.append(")")
    ind += 1

print("".join(ans))

Buggy submission (verdict: Runtime Error):
from collections import deque

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

ans = deque(S)

ind = 0
for _ in range(N-1):
    if S[ind] == "(" and S[ind+1] == ")":
        ind += 2
        continue
    elif S[ind] == ")":
        ans.appendleft("(")
    elif S[ind] == "(":
        ans.append(")")
    ind += 1

print("".join(ans))
Problem p03697 (python)

Fixed submission:
a, b = map(int, input().split())
print(a + b) if (a + b) < 10 else print("error")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(input()) for i in range(n)]
total = sum(l)
i = 0
while total % 10 == 0:
    if i = n:
        break
    total = total - l[i]
    i += 1
print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(input()) for i in range(n)]
total = sum(l)
i = 0
while total % 10 == 0:
    total = total - l[i]
    i + 1
print(total)

Buggy submission (verdict: Runtime Error):
a, b = int(input().split())
print(a + b) if a + b  < 10 else print("error")
Problem p03844 (python)

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

if op == "+":
    print(int(a) + int(b))
if op == "-":
    print(int(a) - int(b))

Buggy submission (verdict: Runtime Error):
a, op, b = input().split()

if op == "+":
    print(a + b)
else:
    print(a - b)

Buggy submission (verdict: Runtime Error):
a , op, b = input().split()
if op == "+":
    print(a + b)
elif op == "-":
    print(a - b)
Problem p03860 (python)

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

l = input().split()
print("A" + l[1][0] + "C")

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())


def count(a, n):
    return a // n

print(count(b, x) - count(a-1, x))
Problem p04012 (python)

Fixed submission:
import collections
w = list(input())
c = collections.Counter(w)
print("Yes") if all([i % 2 == 0 for i in c.values()]) else print("No")

Buggy submission (verdict: Runtime Error):
import collections
w = list(input())
c = collections.Counter(w)
print("Yes") if all([i % 2 == 0 for i in list(c)]) else print("No")
Problem p02719 (python)

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

print(min(N % K, abs(K - N % K)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

if K == 1:
    print(0)

elif N == K:
    print(0)

elif N % 2 == 0 and K % 2 == 0 and N > K and K % N == 0:
    print(0)
elif N % 2 == 0 and K % 2 == 0 and N > K and K % N != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break


elif N % 2 == 0 and K % 2 == 0 and N < K and K % N == 0:
    print(N)
elif N % 2 == 0 and K % 2 == 0 and N < K and K % N != 0:
    if abs(N - K) > N:
        print(N)
    else:
        print(abs(N - K))


elif N % 2 == 1 and K % 2 == 1 and N > K and K % N == 0:
    print(0)
elif N % 2 == 1 and K % 2 == 1 and N > K and K % N != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10**18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break


elif N % 2 == 0 and K % 2 == 0 and N < K and K % N == 0:
    print(N)
elif N % 2 == 0 and K % 2 == 0 and N < K and K % N != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break


elif N % 2 == 0 and K % 2 == 1 and N > K and N % K != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break
elif N % 2 == 0 and K % 2 == 1 and N > K and N % K == 0:
    print(0)


elif N % 2 == 0 and K % 2 == 1 and N < K and N % K != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break
elif N % 2 == 0 and K % 2 == 1 and N < K and N % K == 0:
    print(0)


elif N % 2 == 1 and K % 2 == 0 and N > K and N % K != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break
elif N % 2 == 1 and K % 2 == 0 and N > K and N % K == 0:
    print(0)


elif N % 2 == 1 and K % 2 == 0 and N < K and N % K != 0:
    if abs(N - K) > N:
        print(N)
    else:
        for i in range(10 ** 18):
            if N > abs(N - K):
                N = abs(N - K)
            else:
                print(N)
                break
elif N % 2 == 1 and K % 2 == 0 and N < K and N % K == 0:
    print(N)

else:
    print("NG")
Problem p03289 (python)

Fixed submission:
a = input()
S = list(a)

count = 0
if S[0] == "A":
    count += 1
    # print("OK")

vaa = 0
num=[0]
for j in range(2, len(S)-1):
    # print(j)
    if S[j] == "C":
        vaa += 1
        num.append(j)

if vaa == 1:
    count += 1
    # print("OK")

# val = 0
# for i in range(len(S)):
#     for j in range(len(S)):
#         if j == 0 or j == num:
#             print(j)
#             continue
#         else:
#             if S[i] == S_low[j]:
#                 print(S[i])
#                 print(S[j])
#                 val += 1
#             else:
#                 continue
# print("val", val)
# if val == len(S)-2:
#     count +=1
# print(num)
num = reversed(num)
S_pop = [S.pop(i) for i in num]
S_low = [i.lower() for i in S]

# print("S", S)
# print("S_low", S_low)

if S == S_low:
    count += 1

if count == 3:
    print("AC")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
a = input()
S = list(a)
S_low = list(a.lower())

count = 0
if S[0] == "A":
    count += 1

vaa = 0
for j in range(2, len(S)-1):
    # print(j)
    if S[j] == "C":
        vaa += 1
        num = j
        # print(j)
if vaa == 1:
    count += 1

val = 0
for i in range(len(S)):
    for j in range(len(S)):
        if j == 0 or j == num:
            continue
        else:
            if S[i] == S[j]:
                val += 1
            else:
                continue
if val == len(S)-2:
    count +=1

if count == 3:
    print("AC")
else:
    print("WA")
Problem p03086 (python)

Fixed submission:
S = input()
N = len(S)
s = {"A", "T", "C", "G"}

ans = 0
for i in range(N):
    for j in range(i, N):
        if all([c in s for c in S[i:j+1]]):
            ans = max(ans, j-i+1)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
s = {"A", "T", "C", "G"}
low = []
for i in range(len(S)):
    if S[i] in s:
        low.append(i)
high = []
for i in reversed(range(len(S))):
    if S[i] in s:
        high.append(i)

ans = []
for i in low:
    for j in high:
        if (set(S[i:j+1]) - s) == set():
            ans.append(len(S[i:j+1]))

print(max(ans))
Problem p03244 (python)

Fixed submission:
from collections import Counter as C
n = int(input())
v = list(map(int, input().split()))

#偶数番と奇数番の同じ数字の数
evens = C(v[::2]).most_common()
odds = C(v[1::2]).most_common()
#[('数字', 出現数), ('数字', 出現数)...]

#偶数番と奇数番の数字が違うならそのままans
if evens[0][0] != odds[0][0]:
    ans = n - (evens[0][1] + odds[0][1])
#同じ時は各[0][1]と[1][1]の合計を比べて
# 出現数が多いほうがans
else:
    #oddsの長さが1より大きければ
    # rにevensの1番目の出現数とoddsの2番目の出現数の和を代入
    #  そうでなければevensの1番目の出現数を代入（oddsを全換えするため）
    r = evens[0][1] + odds[1][1] if len(odds) > 1 else evens[0][1]
    s = evens[1][1] + odds[0][1] if len(evens) > 1 else odds[0][1]
    if r > s:
        ans = n - r
    else:
        ans = n - s

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
k = [0] * 100000
g = [0] * 100000

num = 1
for i in v:
    if num % 2 == 1:
        k[i] += 1
    else:
        g[i] += 1
    num += 1

max_k = max(k)
max_g = max(g)
print(n - (max_k+max_g))

Buggy submission (verdict: Runtime Error):
# coding:utf-8
n = int(input())
v = list(map(int, input().split()))
k = [0] * 100000
g = [0] * 100000

num = 1
for i in v:
    if num % 2 == 1:
        k[i] += 1
    else:
        g[i] += 1
    num += 1

max_k = max(k)
max_g = max(g)
print(n - (max_k+max_g))
Problem p03377 (python)

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

if a > x:
    print('NO')
elif a + b < x:
    print('NO')
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
a, b, x = [int(x) for x in input().split()]

if a + b <= x:
    input('YES')
else:
    input('NO')

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())

if a + b <= x:
    input('YES')
else:
    input('NO')

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())

if a <= x:
    input('YES')
else:
    input('NO')
Problem p03633 (python)

Fixed submission:
n = int(input())
t = [int(input()) for _ in range(n)]
ans = 1

from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

for v in t:
    ans = lcm(ans, v)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
t = [int(input()) for _ in range(n)]
ans = 1

from math import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

for v in t:
    ans = lcm(ans, v)

print(ans)
Problem p02717 (python)

Fixed submission:
x, y, z = map(int, input().split())
print("{} {} {}".format(z,x,y))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = n - k
if k == 1 or n == 1:
    print(1)
    quit()
if n % k == 0:
    print(0)
    quit()
if n < k:
    print(n)
    quit()

print(min(ans, k - n%k))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = n - k
if k == 1 or n == 1:
    print(1)
    quit()
if n % k == 0:
    print(0)
    quit()
if n < k:
    print(n)
    quit()

print(min(ans, k - n%k))
Problem p02783 (python)

Fixed submission:
def main():
    num = [int(i) for i in input().split()]
    h = num[0]
    a = num[1]
    return attack(h, a)

def attack(h,a):
    if h % a == 0:
        return h // a
    elif h % a >= 1:
        return (h//a) + 1

print(main())

Buggy submission (verdict: Runtime Error):
def main():
    n, k = [int(i) for i in input().split()]
    num = [int(i) for  i in input().split()]
    if k >= n:
        return 0
    else:
        num = sorted(num)
        return sum(num[0:n-k])
print(main())

Buggy submission (verdict: Runtime Error):
def main():
    n, k = [int(i) for i in input().split()]
    num = [int(i) for  i in input().split()]
    if k >= n:
        return 0
    else:
        l = sorted(num)
        return sum(l[0:n-k])
print(main())

Buggy submission (verdict: Runtime Error):
def main():
    n, k = [int(i) for i in input().split()]
    num = [int(i) for  i in input().split()]
    if k >= n:
        return 0
    else:
        l = sorted(num)
        return sum(l[:-k])
print(main())

Buggy submission (verdict: Runtime Error):
def main():
    n, k = [int(i) for i in input().split()]
    num = [int(i) for  i in input().split()]
    sorted(num)
    del num[-k:]
    print(sum(num))
main()
Problem p03086 (python)

Fixed submission:
s = input()
ans = 0
ans_l = [0]*len(s)


for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        ans_l[ans] += 1
    else:
        ans += 1
print(max(ans_l))

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
ans_l = []

if len(s) == 1:
    print(1)
    quit()
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        ans += 1
    else:
        ans_l.append(ans)
        ans = 0
print(max(ans_l))

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
ans_l = []
if "A" or "C" or "G" or "T" in s:
    if len(s) == 1:
        print(1)
        quit()
    for i in range(len(s)):
        if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
            ans += 1
        else:
            ans_l.append(ans)
            ans = 0
else:
    print(0)
    quit()
print(max(ans_l))

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
ans_l = []
if "A" or "C" or "G" or "T" in s:
    for i in range(len(s)):
        if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
            ans += 1
        else:
            ans_l.append(ans)
            ans = 0
else:
    print(0)
    quit()
print(max(ans_l))
Problem p03680 (python)

Fixed submission:
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
a = [e for row in a for e in row]
ans = 0
i = 0
while n > 0:
    ans += 1
    if a[i] == 2:
        print(ans)
        quit()
    else:
        i = a[i]-1
    n -= 1
print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input() for i in range(n)]

ans = 0
i = 0
while n > 0:
    ans += 1
    if a[i] == 2:
        print(ans)
        quit()
    else:
        i = a[i]-1
    n -= 1
print(-1)
Problem p03971 (python)

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

total_cnt = 0
b_cnt = 0
ans = ["No"]*n

for i in range(n):
    if total_cnt >= a+b:
        break
    if s[i] == "c":
        continue
    if s[i] == "a":
        total_cnt += 1
        ans[i] = "Yes"
    if s[i] == "b":
        b_cnt += 1
        if b_cnt <= b:
            total_cnt += 1
            ans[i] = "Yes"

for i in range(n):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
b_cnt = 0
a_cnt = 0
for i in range(n):
    if s[i] == "a" and (a_cnt+b_cnt) < a+b:
        a_cnt += 1
        print("Yes")
    elif s[i] == "b" and (a_cnt+b_cnt) < a+b and b_cnt < b:
        b_cnt += 1
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
print(len(s))
b_cnt = 0
a_cnt = 0
for i in range(n):
    if s[i] == "a" and (a_cnt+b_cnt) < a+b:
        a_cnt += 1
        print("Yes")
    elif s[i] == "b" and (a_cnt+b_cnt) < a+b and b_cnt < b:
        b_cnt += 1
        print("Yes")
    else:
        print("No")
Problem p03078 (python)

Fixed submission:
X, Y, Z, K = [int(i) for i in input().split()]

A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

Anum = 0
Bnum = 0
Cnum = 0

AB = []
for i in range(X):
    for j in range(Y):
        AB.append(A[i]+B[j])

AB = sorted(AB, reverse=True)
AB = AB[:min(X*Y,K)]

ABC = []
for i in range(len(AB)):
    for j in range(Z):
        ABC.append(AB[i]+C[j])

ABC = sorted(ABC, reverse=True) 

for i in range(K):
    print(int(ABC[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np
X, Y, Z, K = [int(i) for i in input().split()]

A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

Anum = 0
Bnum = 0
Cnum = 0

AB=np.zeros(X*Y)
for i in range(X):
    for j in range(Y):
        AB[Y*i+j] = A[i]+B[j]

AB = np.sort(AB)[::-1]
AB = AB[:min(X*Y,K)]

ABC=np.zeros(len(AB)*Z)
for i in range(len(AB)):
    for j in range(Z):
        ABC[Z*i+j]=AB[i]+C[j]

ABC = np.sort(ABC)[::-1]

for i in range(K):
    print(int(ABC[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np
X, Y, Z, K = [int(i) for i in input().split()]

A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

Anum = 0
Bnum = 0
Cnum = 0

AB=np.zeros(X*Y)
for i in range(X):
    for j in range(Y):
        AB[Y*i+j] = A[i]+B[j]

AB = sorted(AB, reverse=True)
AB = AB[:min(X*Y,K)]

ABC=np.zeros(len(AB)*Z)
for i in range(len(AB)):
    for j in range(Z):
        ABC[Z*i+j]=AB[i]+C[j]

ABC = sorted(ABC, reverse=True)

for i in range(K):
    print(int(ABC[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np
X, Y, Z, K = [int(i) for i in input().split()]

A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

Anum = 0
Bnum = 0
Cnum = 0

AB=np.zeros(X*Y)
for i in range(X):
    for j in range(Y):
        AB[Y*i+j] = A[i]+B[j]

AB = sorted(AB, reverse=True)
AB = AB[:min(X*Y,K)]

ABC=np.zeros(len(AB)*Z)
for i in range(len(AB)):
    for j in range(Z):
        ABC[Z*i+j]=AB[i]+C[j]

ABC = sorted(ABC, reverse=True)

for i in range(K):
    print(ABC[i])
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())

a = N % 500
if a <= A:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
List = [input() for i in range(H)]
queue = [(0,0,1)]
shape = sum(row.count("#") for row in List)
used = {(0,0)}

def check(x,y,c):
    if x > W-1 or y > H-1 or x < 0 or y < 0:
        return
    if List[y][x] == '#':
        return
    if (x,y) in used:
        return
    queue.append((x,y,c))
    used.add((x,y))
    
f = -1
while queue:
    x,y,c = queue.pop(0)
    if x == W-1 and y == H-1:
        f = 1
        break
    check(x+1, y, c+1)
    check(x,y+1,c+1)
    check(x-1,y,c+1)
    check(x,y-1,c+1)
print(f if f == -1 else(H*W - c - shape))

Buggy submission (verdict: Runtime Error):
c = [list(map(int, input().split())) for i in range(3)]

if 1 == len({r[0] - r[1] for r in c}) == len({r[1] - r[2] for r in c}):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
c = [list(map(int, input().split())) for i in range(3)]

for i in range(3):
    c[i] = [j - c[i][0] for j in c[i]]
    
if c[0] == c[1] and c[1] == c[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
c = [list(map(int, input().split())) for i in range(3)]

for i in range(3):
    c[i] = [j - min(c[i]) for j in c[i]]
    
if c[0] == c[1] and c[1] == c[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
c_1 = [int(i) for i in input().split()]
c_2 = [int(i) for i in input().split()]
c_3 = [int(i) for i in input().split()]

c1 = [i - min(c_1) for i in c_1]
c2 = [i - min(c_2) for i in c_2]
c3 = [i - min(c_3) for i in c_3]

if c1 == c2 and c2 == c3:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
nlist = [int(i) for i in input().split()]
nlist.sort(reverse = True)
a = 0
b = 0
for j in range(N):
    if j % 2 == 0:
        a += nlist[j]
    else:
        b += nlist[j]

print(a-b)

Buggy submission (verdict: Runtime Error):
N = int(input())
nlist = [int(i) for i in input().split()]
a = 0
b = 0
for i in range(N):
    if N % 2 == 1:
        a += nlist[i]
    else:
        b += nlist[i]
print(a-b)
Problem p03455 (python)

Fixed submission:
a,b = map(int, input().split())
if (a%2==0) | (b%2==0):
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b = input().split()
if (a%2==0) | (b%2==0):
  print("Even")
else:
  print("Odd")
Problem p03469 (python)

Fixed submission:
import re
ipt = input()
regText = r"(\d{4})/(\d{2})/(\d{2})"
repl = r"2018/\2/\3"
print(re.sub(regText,repl,ipt))

Buggy submission (verdict: Runtime Error):
N = int(input())
ipts = [input() for i in range(N)]
dic = {}
for i in ipts:
    if(i not in dic):
        dic[i] =  True
print(len(dic))
Problem p03031 (python)

Fixed submission:
import sys

def all_lighted(input, mod, pattern):
    for i, bulb in enumerate(input):
        if bin(bulb & pattern).count('1') % 2 == mod[i]:
            next
        else:
            return False
    
    return True


def main():
    num_switch, num_bulb = [int(x) for x in sys.stdin.readline().split()]
    input = [0] * num_bulb

    for i in range(num_bulb):
        for x in sys.stdin.readline().split()[1:]:
            input[i] += 2**(int(x) - 1)

    mod = [int(x) for x in sys.stdin.readline().split()]

    count = 0

    for pattern in range(2 ** num_switch):
        if all_lighted(input, mod, pattern): count += 1

    print(count)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

def all_lighted(input, mod, pattern):
    for i, bulb in enumerate(input):
        if bin(bulb and pattern).count('1') % 2 == pattern[i]:
            next
        else:
            return False
    
    return True


def main():
    num_switch, num_bulb = [int(x) for x in sys.stdin.readline().split()]
    input = [0] * num_bulb

    for bulb in input:
        for x in sys.stdin.readline().split()[1:]:
            bulb += 2**(int(x) - 1)

    mod = [int(x) for x in sys.stdin.readline().split()]

    count = 0

    for i in range(2 ** num_switch):
        if all_lighted(input, mod, i): count += 1

    print(count)


if __name__ == "__main__":
    main()
Problem p03037 (python)

Fixed submission:
import sys

def main():
    sinputl = sys.stdin.readline

    num_card, num_gate = [int(x) for x in sinputl().split()]
    input = [[int(x) for x in sinputl().split()] for _ in range(num_gate)]

    card = [1, num_card]

    for gate in input:
        card[0] = max(card[0], gate[0])
        card[1] = min(card[1], gate[1])

    print(max(card[1] - card[0] + 1, 0))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
    import sys
     
    def main():
        sinputl = sys.stdin.readline
     
        num_card, num_gate = [int(x) for x in sinputl().split()]
        input = [[int(x) for x in sinputl().split()] for _ in range(num_gate)]
     
        under_limit = [x[0] for x in input]
        over_limit = [x[1] for x in input]
     
        print(max(min(over_limit) - max(under_limit) + 1, 0))
     
     
    if __name__ == "__main__":
        main()