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

Fixed submission:
N = int(input())
s = [input() for _ in range(N)]

end_A = 0
start_B = 0
AB_count = 0
both = 0

for i in range(N):
    if 'AB' in s[i]:
        AB_count += s[i].count('AB')
    if s[i][0] == 'B':
        start_B += 1
    if s[i][len(s[i])-1] == 'A':
        end_A += 1
    if s[i][0] == 'B' and s[i][len(s[i])-1] == 'A':
        both += 1
start_B -= both
end_A -= both

if both == 0:
    print(AB_count + min(start_B, end_A))
elif end_A + start_B > 0:
    print(AB_count + both + min(start_B, end_A))
else:
    print(AB_count + both - 1)

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

end_A = 0
start_B = 0
AB_count = 0
both = 0

for i in range(N):
    if 'AB' in s[i]:
        AB_count += s[i].count('AB')
    if s[i][0] == 'B':
        start_B += 1
    if s[i][len(s[i])-1] == 'A':
        end_A += 1
    if s[i][0] == 'B' and s[i][len(s[i])-1] == 'A':
        both += 1
start_B -= both
end_A -= both

if both == 0:
    print(AB_count + min(start_B, end_A))
elif end_A + start_B > 0:
    print(AB_count + both + min(start_B, end_A))
elif end_A + end_B == 0:
    print(AB_count + both - 1)

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

end_A = 0
start_B = 0
AB_count = 0
both = 0

for i in range(N):
    if 'AB' in s[i]:
        AB_count += s[i].count('AB')
    if s[i][0] == 'B':
        start_B += 1
    if s[i][len(s[i])-1] == 'A':
        end_A += 1
    if s[i][0] == 'B' and s[i][len(s[i])-1] == 'A':
        both += 1
start_B -= both
end_A -= both

if both == 0:
    print(AB_count + min(start_B, end_A))
elif end_A + start_B > 0:
    print(AB_count + both + min(start_B, end_A))
elif end_A + end_B == 0:
    print(both - 1)
Problem p03061 (python)

Fixed submission:
import fractions


def solute(n, a):
    gcd_left = [0]
    gcd_right = [0]
    for i in range(n):
        gcd_left.append(fractions.gcd(gcd_left[i], a[i]))
        gcd_right.append((fractions.gcd(gcd_right[i], a[-(i+1)])))
    gcd_right = gcd_right[::-1]

    ans = []
    for i in range(n):
        ans.append(fractions.gcd(gcd_left[i], gcd_right[i+1]))
    return max(ans)


n = int(input())
a = [int(x) for x in input().split()]
print(solute(n, a))

Buggy submission (verdict: Runtime Error):
import math


def solute(n, a):
    gcd_left = [0]
    gcd_right = [0]
    for i in range(n):
        gcd_left.append(math.gcd(gcd_left[i], a[i]))
        gcd_right.append((math.gcd(gcd_right[i], a[-(i+1)])))
    gcd_right = gcd_right[::-1]

    ans = []
    for i in range(n):
        ans.append(math.gcd(gcd_left[i], gcd_right[i+1]))
    return max(ans)


n = int(input())
a = [int(x) for x in input().split()]
print(solute(n, a))
Problem p03069 (python)

Fixed submission:
N = int(input())
S = str(input())

suu = []
s_count = S.count('.')
k_count = 0
suu.append(s_count + k_count)
for i in range(N):
    if S[i] == "#":
        k_count += 1
    else:
        s_count -= 1
    suu.append(k_count + s_count)

print(min(suu))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())
new_S = ""

for i in range(N):
    if S[i] == "#":
        S = S[i:]
        break
else:
    S = S

for i in reversed(S):
    new_S += i

for i in range(N):
    if new_S[i] == ".":
        S_new = S[i:]
        break
else:
    S_new = ""

print(min(S_new.count('#'), S_new.count('.'), len(S_new)))
Problem p03074 (python)

Fixed submission:
import sys
from collections import deque
input = sys.stdin.readline


def main():
    n,k = map(int,input().split())
    s = list(input())

    #tank: '0...0'と'1...1'の塊の数リスト
    #ex. 0001011ならtank = [3,1,1,2] (0が3つ,1が1つ,0が2つ,1が2つ)
    tank = []
    cnt = 1
    for i in range(1,n):
        if s[i] != s[i-1]:
            tank.append(cnt)
            cnt = 0
        cnt += 1
        if i == n-1:
            tank.append(cnt)
    #p:tankの長さ
    p = len(tank)

    #全部1にできてしまう場合
    if s[0] == '0' and (p+1)//2 <= k:
        print(n)
        exit()
    if p//2 <= k and s[0] == '1':
        print(n)
        exit()

    
    ans = 0
    #res:tank[j]が1...1の右端の時の解
    res = 0
    if s[0] == '0':
        for j in range(2*k):
            res += tank[j]
        ans = res
        for j in range(2*k,p):
            if j == 2*k:
                res -= tank[0]
            elif j%2 == 0:
                res= res - tank[j-2*k] -tank[j-2*k-1]
            res += tank[j]
            ans = max(ans,res)

    else:
        for j in range(2*k+1):
            res += tank[j]
        ans = res
        for j in range(2*k+1,p):
            if j % 2 == 1:
                res = res- tank[j-2*k-1]-tank[j-2*k]
            res += tank[j]
            ans = max(ans,res)

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    s = list(input())
    
    tank = []
    cnt = 1
    for i in range(1, n):
        if s[i] != s[i-1]:
            tank.append(cnt)
            cnt = 0
        cnt += 1
        if i == n-1:
            tank.append(cnt)
            
    p = len(tank)
    
    if s[0] == '0' and (p+1)//2 <= k:
        print(n)
        exit()
    if p//2 <= k and s[0] == '1':
        print(n)
        exit()
        
    ans = 0
    res = 0
    if s[0] == '0':
        for j in range(2*k):
            res += tank[j]
        ans = res
        for j in range(2*k, p):
            if j == 2*k:
                res -= tank[0]
            elif j%2 == 0:
                res = res - tank[j-2*k] - tank[j*2*k-1]
            res += tank[j]
            ans = max(ans, res)
            
    else:
        for j in range(2*k+1):
            res += tank[j]
        ans = res
        for j in range(2*k+1, p):
            if j%2 == 1:
                res = res - tank[j-2*k-1] - tank[j-2*k]
            res += tank[j]
            ans = max(ans, res)
            
    print(ans)
    
if __name__ == '__main__':
    main()
Problem p03161 (python)

Fixed submission:
# Educational DP Contest B-Frog 2

def frog(N, K, h):
    # initialize
    inf = float('inf')
    dp = [inf] * N
    
    minKN = min(K, N)
    for i in range(minKN):
        if i == 0:
            dp[i] = 0
        else: 
            dp[i] = abs(h[0] - h[i])
            for j in range(minKN):
                if j == i:
                    continue
                elif j < i:
                    dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))
    # DP
    for i in range(N):
        if i == 0:
            continue
        elif i < K:
            continue
        else:
            dp[i] = min([abs(h[k] - h[i]) + dp[k] for k in range(i-K, i)])
    return dp[N-1]
    
if __name__ == "__main__":
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    print(frog(N, K, h))

Buggy submission (verdict: Runtime Error):
# ducational DP Contest B-Frog 2
    
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf') for _ in range(N+K)]
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]))
        
print(dp[N-1])
Problem p03162 (python)

Fixed submission:
# Educational DP Contest C-Vacation

def solve():
    n = int(input())
    dpa = [0] * n
    dpb = [0] * n
    dpc = [0] * n
    
    a, b, c = list(map(int, input().split()))
    dpa[0] = a
    dpb[0] = b
    dpc[0] = c
    for i in range(1, n):
        a, b, c = list(map(int, input().split()))
        dpa[i] = max(dpb[i-1] + a, dpc[i-1] + a)
        dpb[i] = max(dpa[i-1] + b, dpc[i-1] + b)
        dpc[i] = max(dpb[i-1] + c, dpa[i-1] + c)
    return(max(dpa[-1], dpb[-1], dpc[-1]))

if __name__ == "__main__":
    print(solve())

Buggy submission (verdict: Runtime Error):
N = int(input())
dpa = [0] * N
dpb = dpa.copy()
dpc = dpa.copy()

a, b, c = map(int, input().split())
dpa[0] = a
dpb[0] = b
dpc[0] = c
for i in range(1, N):
    a, b, c = map(int, input().split())
    dpa[i] = max(dpb[i-1] + a, dpc[i-1] + a)
    dpb[i] = max(dpa[i-1] + b, dpc[i-1] + b)
    dpc[i] = max(dpa[i-1] + c, dpb[i-1] + c)

print(max(dpa[N-1], dpb[N-1], dpc[N-1]))
Problem p03163 (python)

Fixed submission:
# Educational DP Contest D-knapsack

def knapsack(N, W, wv):
    # initialize
    dp = [list(0 for _ in range(W+1)) for j in range(N+1)]
    
    # DP
    for i in range(N):
        for j in range(W+1):
            if j >= wv[i][0]:
                dp[i+1][j] = max(dp[i][j], dp[i][j - wv[i][0]] + wv[i][1])
            else:
                dp[i+1][j] = dp[i][j]
    return dp[N][W]

if __name__ == "__main__":
    N, W = map(int, input().split())
    wv = []
    for _ in range(N):
        wv.append(list(map(int, input().split())))
    print(knapsack(N, W, wv))

Buggy submission (verdict: Runtime Error):
 N, W = map(int, input().split())
 wv = [list(map(int, input().split())) for _ in range(N)]

 dp = []
 for _ in range(N+1):
     dp.append([0] * (W+1))

for i in range(N):
    for j in range(W+1):
        if j >= wv[i][0]:
            dp[i+1][j] = max(dp[i][j], dp[i][j - wv[i][0]] + wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000)
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1) # 有向グラフ

# メモ化再帰
dp = [-1 for _ in range(100100)]
def rec(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for i in graph[v]:
        res = max(res, rec(i) + 1)
    dp[v] = res
    return res

res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)

Buggy submission (verdict: Runtime Error):
# Longest path
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)
dp = [-1 for _ in range(N)]

def rec(c):
    if dp[c] != -1:
        return dp[c]
    res = 0
    for i in graph[c]:
        res = max(res, rec(i) + 1)
    dp[c] = res
    return res

for i in range(N):
    rec(i)
print(max(dp))

Buggy submission (verdict: Runtime Error):
sys.setrecursionlimit(10000)
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1) # 有向グラフ

# メモ化再帰
dp = [-1 for _ in range(100100)]
def rec(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for i in graph[v]:
        res = max(res, rec(i) + 1)
    dp[v] = res
    return res

res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1) # 有向グラフ

# メモ化再帰
dp = [0 for _ in range(100100)]
def rec(v):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for i in graph[v]:
        res = max(res, rec(i) + 1)
    dp[v] = res
    return res

for i in range(N):
    dp[i] = -1
res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)
Problem p03169 (python)

Fixed submission:
import sys
from collections import Counter
sys.setrecursionlimit(10000)

N = int(input())
a = list(map(int, input().split()))
dp = [[[-1 for i in range(N+1)] for j in range(N+1)] for k in range(N+1)]

def rec(i, j, k):
    if dp[i][j][k] >= 0:
        return dp[i][j][k]
    if i == 0 and j == 0 and k == 0:
        return 0.0
    res = 0.0
    if i > 0:
        res += rec(i-1, j, k) * i
    if j > 0:
        res += rec(i+1, j-1, k) * j
    if k > 0:
        res += rec(i, j+1, k-1) * k
    res += N
    res *= 1.0/(i+j+k)

    dp[i][j][k] = res
    return res

c = Counter(a)
one, two, three = c[1], c[2], c[3]
print(rec(one, two, three))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N = int(input())
a = list(map(int, input().split()))
one = a.count(1)
two = a.count(2)
three = a.count(3)
dp = [[[-1 for i in range(three + 10)] for j in range(two + 10)] for k in range(one + 10)]

def rec(i, j, k):
    if dp[i][j][k] >= 0:
        return dp[i][j][k]
    if i == 0 and j == 0 and k == 0:
        return 0.0
    res = 0.0
    if i > 0:
        res += rec(i-1, j, k) * i
    if j > 0:
        res += rec(i+1, j-1, k) * j
    if k > 0:
        res += rec(i, j+1, k-1) * k
    res += N
    res /= i+j+k
    dp[i][j][k] = res
    return res

rec(one, two, three)
print(dp[one][two][three])
Problem p03386 (python)

Fixed submission:
A, B, K = map(int, input().split())
L = [A+i for i in range(K) if A+i <= B]
R = [B-i for i in range(K) if B-i >= A]
S = set(L+R)
S = sorted(S)
for v in S:
    print(v)

Buggy submission (verdict: Runtime Error):
import sys
A, B, K = map(int, input().split())

box = list(range(A, B+1))
s = set()

if len(box) < K:
    for i in box:
        print(i)
    sys.exit()

for i in range(K):
    s.add(box[i])
nb = box[len(box) - K:]
for i in range(K):
    s.add(nb[i])

for k in s:
    print(k)

Buggy submission (verdict: Runtime Error):
import sys
A, B, K = map(int, input().split())
box = list(range(A, B+1))
if 2*K < len(box):
    box.sort()
    for i in box:
        print(i)
    sys.exit()
if A == B:
    if K >= 1:
        print(A)
        sys.exit()
    else:
        print()
        sys.exit()
box.sort()
temp1 = box[:K] + box[-K:]
temp = sorted(set(temp1), key=temp1.index)
temp.sort()
for i in temp:
    print(i)

Buggy submission (verdict: Runtime Error):
import sys
A, B, K = map(int, input().split())
box = list(range(A, B+1))
if K >= 2*len(box):
    box.sort()
    for i in box:
        print(i)
    sys.exit()
if A == B:
    if K >= 1:
        print(A)
        sys.exit()
    else:
        print()
        sys.exit()
box.sort()
temp1 = box[:K] + box[-K:]
temp = sorted(set(temp1), key=temp1.index)
temp.sort()
for i in temp:
    print(i)

Buggy submission (verdict: Runtime Error):
import sys
A, B, K = map(int, input().split())
box = list(range(A, B+1))
if K >= 2*len(box):
    box.sort()
    for i in box:
        print(i)
    sys.exit()
box.sort()
temp1 = box[:K] + box[-K:]
temp = sorted(set(temp1), key=temp1.index)
temp.sort()
for i in temp:
    print(i)

Buggy submission (verdict: Runtime Error):
import sys
A, B, K = map(int, input().split())
box = list(range(A, B+1))
if K >= 2*len(box):
    box.sort()
    print(box)
    sys.exit()
box.sort()
res = set()
for i in range(K):
    res.add(box[i])
box.reverse()
for i in range(K):
    res.add(box[i])
res = list(res)
res.sort()
print(res)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
box = list(range(A, B+1))
if K >= B - A:
    K = B - A
box.sort()
res = set()
for i in range(K):
    res.add(box[i])
box.reverse()
for i in range(K):
    res.add(box[i])
res = list(res)
res.sort()
print(res)
Problem p02556 (python)

Fixed submission:
N = int(input())
M = [list(map(int, input().split())) for _ in range(N)]

s = []
l = []
top = 2*(10**9)+1
low = 0
for j in range(N):
    t = sum(M[j])
    if low == t:
        s.append(M[j])
    elif low < t:
        low = t
        s = []
        s.append(M[j])

    if top == t:
        l.append(M[j])
    elif top > t:
        top = t
        l = []
        l.append(M[j])


def cal_man(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


s.sort()
l.sort()


high = []
small = []
lowest = 2*(10**9)+1
topest = -2*(10**9)+1
for j in range(N):
    t = M[j][1] - M[j][0]
    if lowest > t:
        lowest = t
        small = []
        small.append(M[j])
    elif lowest == t:
        small.append(M[j])

    if topest < t:
        topest = t
        high = []
        high.append(M[j])
    elif topest == t:
        high.append(M[j])
high.sort()
small.sort()


print(max([cal_man(s[0], l[-1]), cal_man(s[-1], l[0]),
           cal_man(high[0], small[-1]), cal_man(high[-1], small[0])]))

Buggy submission (verdict: Runtime Error):
N = int(input())
M = [list(map(int, input().split())) for _ in range(N)]

s = []
l = []
top = 2*(10**9)+1
low = 0
for j in range(N):
    t = sum(M[j])
    if low == t:
        s.append(M[j])
    elif low < t:
        low = t
        s = []
        s.append(M[j])

    if top == t:
        l.append(M[j])
    elif top > t:
        top = t
        l = []
        l.append(M[j])


def cal_man(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


s.sort()
l.sort()


high = []
small = []
low = 2*(10**9)+1
top = 0
for j in range(N):
    t = M[j][1] - M[j][0]
    if low > t:
        low = t
        small = []
        small.append(M[j])
    elif low == t:
        small.append(M[j])

    if top < t:
        top = t
        high = []
        high.append(M[j])
    elif top == t:
        high.append(M[j])
high.sort()
small.sort()


print(max([cal_man(s[0], l[-1]), cal_man(s[-1], l[0]),
           cal_man(high[0], small[-1]), cal_man(high[-1], small[0])]))
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
tmp = [0 for _ in range(N)]
# bagに入る要素が多すぎてエラーが出ている

spot = 1
road = [1]
tmp[0] = 1
for _ in range(K):
    n_s = A[spot-1]
    if not tmp[n_s-1] == 1:
        road.append(n_s)
        tmp[n_s-1] = 1
        spot = n_s
    else:
        spot = n_s
        break

till_loop = road.index(spot)
# print(till_loop)
loop = road[till_loop:]
# print(loop)
cycle_len = len(road) - road.index(spot)
# print(cycle_len)
answer = loop[(K-till_loop) % cycle_len]

print(answer)

Buggy submission (verdict: Runtime Error):
class UnionFind:
    # この時点でそれぞれのノードは自分を親としている
    # 初期化時に問題が0の頂点を認めるかに注意すること
    def __init__(self, n):
        self.N = n
        self.parent = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    # xの根を返す関数
    def root(self, x):
        visited_nodes = []
        while True:
            p = self.parent[x]
            if p == x:
                # 縮約
                for node in visited_nodes:
                    self.parent[node] = x
                return x
            else:
                visited_nodes.append(x)
                x = p

    # 木の結合を行う。親の配下に入る
    def unite(self, x, y):
        if not self.root(x) == self.root(y):
            if self.rank[x] > self.rank[y]:
                self.parent[self.root(y)] = self.root(x)
            else:
                self.parent[self.root(x)] = self.root(y)
                if self.rank[x] == self.rank[y]:
                    self.rank[self.root(y)] += 1

    def ifSame(self, x, y):
        return self.root(x) == self.root(y)

    # 木の根に到達すまでにたどるノードの配列を返す
    def printDebugInfo(self):
        print([self.root(i) for i in range(self.N)])


N, K = map(int, input().split())
A = [int(x) for x in input().split()]
tmp = [0 for _ in range(N)]
# bagに入る要素が多すぎてエラーが出ている

spot = 1
road = []
for _ in range(K):
    if not tmp[spot-1]:
        road.append(spot)
        tmp[spot-1] = 1
        spot = A[spot-1]
    else:
        break

# print(road)
till_loop = road.index(spot)
# print(till_loop)
loop = road[till_loop:]
# print(loop)
cycle_len = len(road) - road.index(spot)
# print(cycle_len)
answer = loop[(K-till_loop) % cycle_len]

print(answer)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
bag = set()

spot = 1
road = []
for _ in range(K):
    if not spot in bag:
        road.append(spot)
        bag.add(spot)
        spot = A[spot-1]
    else:
        break

# print(road)
till_loop = road.index(spot)
# print(till_loop)
loop = road[till_loop:]
# print(loop)
cycle_len = len(road) - road.index(spot)
# print(cycle_len)
answer = loop[(K-till_loop) % cycle_len]

print(answer)
Problem p02837 (python)

Fixed submission:
import itertools
import copy

n = int(input())
indexes = [_ for _ in range(1, n+1)]

def ifCorrect(data, fakes):
    answer_sheet = [1 for i in range(n+1)]
    answer_sheet[0] = -1
    for i in fakes:
        answer_sheet[i] = 0

    #このあたりで、fakeでない人の情報とも比較して、正直者の証言がそれらのリストと合致しているかを確認すれば良い
    for i in range(len(data)):
        for j in data[i]:
            if not i in fakes and not answer_sheet[j[0]] == j[1]:
                return False
                    
    return True

data = [[] for _ in range(n+1)]
for i in range(n):
    id = int(input())
    for _ in range(id):
        x, y = map(int, input().split(" "))
        data[i+1].append([x,y])

fakePersonCount = 0
flag = True
while fakePersonCount <= n and flag:
    comb = itertools.combinations(indexes, fakePersonCount)
    for fakePeople in comb:
        if ifCorrect(data, fakePeople):
            print(n - fakePersonCount)
            flag = False
            break
    fakePersonCount += 1

if flag:
    print(0)

#[[], [[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]

Buggy submission (verdict: Runtime Error):
import itertools

n = 10
data = [_ for _ in range(1,n+1)]
print(data)

dt = [2,4635,534,534,5,2345,13,41,51,23]

for i in itertools.combinations(data, 1):
    print(i)





for i in fakePeople:
            if turndata[i] != []:
                for j in turndata[i]:
                    if j[1] == 0:
                        j[1] = 1
                    else:
                        j[1] = 0

import itertools
import copy

n = int(input())
indexes = [_ for _ in range(1, n+1)]

def ifCorrect(data, fakes):
    answer_sheet = [-1 for i in range(n+1)]
    for i in fakes:
        answer_sheet[i] = 0

    #このあたりで、fakeでない人の情報とも比較して、正直者の証言がそれらのリストと合致しているかを確認すれば良い
    for i in range(len(data)):
        for j in data[i]:
            if not i in fakes:
                if answer_sheet[j[0]] == -1:
                    if j[1] == 0 and not j[0] in fakes:
                        return False
                    else:
                        answer_sheet[j[0]] = j[1]
                elif not answer_sheet[j[0]] == j[1]:
                    return False
                    
    return True

data = [[] for _ in range(n+1)]
for i in range(n):
    id = int(input())
    for _ in range(id):
        x, y = map(int, input().split(" "))
        data[i+1].append([x,y])

fakePersonCount = 0
flag = True
while fakePersonCount <= n and flag:
    comb = itertools.combinations(indexes, fakePersonCount)
    for fakePeople in comb:
        if ifCorrect(data, fakePeople):
            print(n - fakePersonCount)
            flag = False
            break
    fakePersonCount += 1

if flag:
    print(0)

#[[], [[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]
Problem p02995 (python)

Fixed submission:
from fractions import gcd

A, B, C, D = map(int, input().split())
lcm = C*D//gcd(C, D)


divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
divL = B//lcm - (A-1)//lcm

print((B-A+1) - divC - divD + divL)

Buggy submission (verdict: Runtime Error):
from math import gcd

A, B, C, D = map(int, input().split())
lcm = C*D//gcd(C, D)


divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
divL = B//lcm - (A-1)//lcm

print((B-A+1) - divC - divD + divL)
Problem p03086 (python)

Fixed submission:
s = list(input())
ACGT = ['A', 'C', 'G', 'T']

count = 0
result = []
for w in s:
    if w in ACGT:
        count += 1
    else:
        result.append(count)
        count = 0
result.append(count)

print(max(result))

Buggy submission (verdict: Runtime Error):
s = list(input())
ACGT = ['A', 'C', 'G', 'T']

count = 0
result = []
for w in s:
    if w in ACGT:
        count += 1
    else:
        result.append(count)
        count = 0

print(max(result))