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

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

def longest_path(s):
    global dp
    if dp[s-1]<1:
        if edge[s]:
            dp[s-1]=max((longest_path(t)+1)for t in edge[s])
        else:
            dp[s-1]=0
    return dp[s-1]

N,M=map(int,input().split())
edge={}
for i in range(1,N+1):
    edge.setdefault(i,[])
for _ in range(M):
    x,y=map(int,input().split())
    edge[x].append(y)
dp=[0]*N
for i in range(1,N+1):
    if dp[i-1]==0:
        longest_path(i)

print(max(dp))

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

def longest_path(s):
    global dp
    if dp[s-1]<1:
        if edge[s]:
            dp[s-1]=max((longest_path(t)+1)for t in edge[s])
        else:
            dp[s-1]=0
    return dp[s-1]

N,M=map(int,input().split())
edge={}
for i in range(1,N+1):
    edge.setdefault(i,[])
for _ in range(M):
    x,y=map(int,input().split())
    edge[x].append(y)
dp=[0]*N
for i in range(1,N+1):
    if dp[i-1]==0:
        longest_path(i)

print(max(dp))

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

def longest_path(s):
    global dp
    if dp[s-1]>=1:
        return dp[s-1]
    else:
        if edge[s]:
            dp[s-1]=max((longest_path(t)+1)for t in edge[s])
        else:
            dp[s-1]=0
    return dp[s-1]

N,M=map(int,input().split())
edge={}
for i in range(1,N+1):
    edge.setdefault(i,[])
for _ in range(M):
    x,y=map(int,input().split())
    edge[x].append(y)
dp=[0]*N
check=[False]*N
for i in range(1,N+1):
    if dp[i-1]==0:
        longest_path(i)

print(max(dp))
Problem p03167 (python)

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

def grid(y,x,mp):
    mod=10**9+7
    dp=[[0]*x for _ in range(y)]
    dp[0][0]=1
    for h in range(y):
        for w in range(x):
            if mp[h][w]=='.':
                if 1<=h<y and 1<=w<x:
                    dp[h][w]=((dp[h][w-1]+dp[h-1][w])%mod)
                elif h==0 and 1<=w<x:
                    dp[h][w]=(dp[h][w-1]%mod)
                elif 1<=h<y and w==0:
                    dp[h][w]=(dp[h-1][w]%mod)
    return dp[y-1][x-1]


H,W=map(int,input().split())
mp=[list(input()) for _ in range(H)]
print(grid(H,W,mp))

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

def grid(y,x):
    global dp,visited
    if visited[y][x]:
        return dp[y][x]
    else:
        visited[y][x]=True
        if mp[y][x]!='#' and dp[y][x]==0:
            dp[y][x]=(grid(y-1,x)+grid(y,x-1))%mod
        return dp[y][x]

H,W=map(int,input().split())
mp=[['#']*(W+1)]
for _ in range(H):
    mp.append(['#']+list(input()))

dp=[[0]*(W+1)for _ in range(H+1)]
dp[1][1]=1
visited=[[False]*(W+1)for _ in range(H+1)]
mod=10**9+7
grid(H,W)
print(dp[H][W])

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

def grid(y,x,mp):
    mod=10**9+7
    dp=[[0]*y for _ in range(x)]
    dp[0][0]=1
    for h in range(y):
        for w in range(x):
            if mp[h][w]=='.':
                if h>=1:
                    dp[h][w]+=(dp[h-1][w]%mod)
                if w>=1:
                    dp[h][w]+=(dp[h][w-1]%mod)
    return dp[y-1][x-1]%mod


H,W=map(int,input().split())
mp=[]
for _ in range(H):
    mp.append(list(input()))
print(grid(H,W,mp))

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

def grid(y,x,mp):
    mod=10**9+7
    dp=[[0]*y for _ in range(x)]
    dp[0][0]=1
    for h in range(H):
        for w in range(W):
            if mp[h][w]=='.':
                if h>=1:
                    dp[h][w]+=(dp[h-1][w]%mod)
                if w>=1:
                    dp[h][w]+=(dp[h][w-1]%mod)
    return dp[y-1][x-1]%mod


H,W=map(int,input().split())
mp=[]
for _ in range(H):
    mp.append(list(input()))
print(grid(H,W,mp))

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

def grid(y,x,mp):
    dp=[[0]*y for _ in range(x)]
    dp[0][0]=1
    for h in range(H):
        for w in range(W):
            if mp[h][w]=='.':
                if h>=1:
                    dp[h][w]+=dp[h-1][w]
                if w>=1:
                    dp[h][w]+=dp[h][w-1]
    return dp[y-1][x-1]%(10**9+7)


H,W=map(int,input().split())
mp=[]
for _ in range(H):
    mp.append(list(input()))
print(grid(H,W,mp))
Problem p02606 (python)

Fixed submission:
L, R, d = map(int, input().split())
count = 0
for i in range(L, R + 1):
    if i % d == 0:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = int(input(), 2)

f = {}


def calcF(i, count):
    if i == 0:
        return count
    if i in f:
        return count + f[i]
    icount = bin(i).count("1")
    if icount == 0:
        return count + 1
    r = i % icount
    if r != 0:
        return calcF(r, count + 1)
    else:
        return count + 1


for i in range(1, 2 ** N):
    f[i] = calcF(i, 0)

for i in range(1, N + 1):
    a = X ^ 2 ** ((N - 1) - (i - 1))
    if a == 0:
        print(0)
    else:
        print(f[a])
Problem p02684 (python)

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

vis = set()
vis.add(1)
cnt = 0
cnt2town = {}
town2cnt = {}
cnt2town[0] = 1
town2cnt[1] = 0

cnt = 1
prev = 1
while cnt <= K:
    a = A[prev - 1]

    if a in vis:
        c = town2cnt[a]

        rem = K - cnt
        num_loop = cnt - c

        r = rem % num_loop
        print(cnt2town[c + r])

        exit()

    cnt2town[cnt] = a
    town2cnt[a] = cnt
    vis.add(a)

    prev = a
    cnt += 1


print(a)

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

vis = set()
vis.add(1)
cnt = 0
cnt2town = {}
town2cnt = {}
cnt2town[0] = 1
town2cnt[1] = 0

for a in A:
    if a in vis:
        c = town2cnt[a]
        rem = K - cnt
        num_loop = cnt - c

        k = rem % num_loop
        print(cnt2town[c + k + 1])
        exit()

    if cnt == K:
        print(a)
        exit()

    cnt += 1
    cnt2town[cnt] = a
    town2cnt[a] = cnt
    vis.add(a)

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

vis = set()
vis.add(1)
cnt = 0
cnt2town = {}
town2cnt = {}
cnt2town[0] = 1
town2cnt[1] = 0

for a in A:
    if a in vis:
        c = town2cnt[a]
        rem = K - cnt
        num_loop = cnt - c

        k = rem % num_loop
        print(cnt2town[c + k + 1])
        exit()

    if cnt == K:
        print(a)
        exit()

    cnt += 1
    cnt2town[cnt] = a
    town2cnt[a] = cnt
    vis.add(a)
Problem p02718 (python)

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

A.sort(reverse=True)

s = sum(A)
c = s / (4 * M)

if A[M - 1] < c:
    print('No')
else:
    print('Yes')

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

A.sort(reverse=True)

s = sum(A)
c = s / (4 * M)

if A[M] < c:
    print('No')
else:
    print('Yes')
Problem p02733 (python)

Fixed submission:
H, W, K = map(int, input().split())
S = [list(map(int, input())) for i in range(H)]

ret = W - 1 + H - 1

for i in range(1 << (H - 1)):
    sep = bin(i)[2:].rjust(H - 1, '0')[::-1]

    tile_idx = [0] * H
    cut = 0

    for j in range(H):
        tile_idx[j] = cut

        if j == H - 1:
            break

        if sep[j] == '1':
            cut += 1

    cnt_lst = [0] * (cut + 1)
    num_cnt = 0

    for w in range(W):
        col_new = [0] * (cut + 1)

        flag = False
        flag1 = False
        for h in range(H):
            if S[h][w] == 1:
                idx = tile_idx[h]
                col_new[idx] += 1

        for a in col_new:
            if a > K:
                flag1 = True
                break

        if flag1:
            break

        for k in range(cut + 1):
            if cnt_lst[k] + col_new[k] > K:
                num_cnt += 1
                for l in range(cut + 1):
                    cnt_lst[l] = col_new[l]

                flag = True
                break

        if not flag:
            for k in range(cut + 1):
                cnt_lst[k] += col_new[k]

    if not flag1:
        ret = min(ret, num_cnt + cut)


print(ret)

Buggy submission (verdict: Runtime Error):
H, W, K = map(int, input().split())
S = [list(map(int, input())) for i in range(H)]

ret = W - 1 + H - 1

for i in range(1 << (H - 1)):
    sep = bin(i)[2:].rjust(H - 1, '0')[::-1]

    tile_idx = [0] * H
    cut = 0

    for j in range(H):
        tile_idx[j] = cut

        if j == H - 1:
            break

        if sep[j] == '1':
            cut += 1

    cnt_lst = [0] * (cut + 1)

    num_cnt = 0

    for w in range(W):
        col_new = [0] * (cut + 1)

        flag = False
        for h in range(H):
            if S[h][w] == 1:
                idx = tile_idx[h]
                col_new[idx] += 1

        for a in col_new:
            if a > K:
                flag = True
                break

        for k in range(cut + 1):
            if cnt_lst[k] + col_new[k] > K:
                num_cnt += 1
                cnt_lst = col_new.copy()
                flag = True
                break

        if not flag:
            for k in range(cut + 1):
                cnt_lst[k] += col_new[k]

    ret = min(ret, num_cnt + cut)


print(ret)
Problem p02787 (python)

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


max_magic = 0
for a, _ in magic:
    max_magic = max(max_magic, a)

amount = H + 1
dp = [0] * (amount + max_magic)
dp[0] = 0

ret = float('inf')

for amt in range(1, amount + max_magic):
    t = [dp[amt - a] + b for a, b in magic]
    dp[amt] = min(t)

    if amt >= H:
        ret = min(dp[amt], ret)

print(ret)

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


max_magic = 0
for a, _ in magic:
    max_magic = max(max_magic, a)

amount = H + 1
dp = [0] * (amount + max_magic)
dp[0] = 0

ret = float('inf')

for amt in range(1, amount + max_magic):
    t = [dp[amt - a] + b if amt - a >= 0 for a, b in magic]
    dp[amt] = min(t)

    if amt >= H:
        ret = min(dp[amt], ret)

print(ret)
Problem p02789 (python)

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

if N == M:
    print('Yes')
else:
    print('No')

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

N = int(input())
d = defaultdict(int)

for n in range(N):
    n = str(n)

    a = n[0]
    b = n[-1]

    d[(a, b)] += 1


s = 0
for i in range(1, 10):
    for j in range(10):

        s += d[(str(j), str(i))] * d[(str(i), str(j))]

print(s)
Problem p02885 (python)

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


print(max(A - B * 2, 0))

Buggy submission (verdict: Runtime Error):
import bisect

N = int(input())
L = sorted(list(map(int, input().split())))

cnt = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        idx = bisect.bisect_left(L, L[i] + L[j], lo=j + 1)
        cnt += max(0, idx - (j + 1))
        
print(cnt)
Problem p02889 (python)

Fixed submission:
from scipy.sparse.csgraph import floyd_warshall

N, M, L = map(int, input().split())

G = [list(map(int, input().split())) for _ in range(M)]
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

# neighborhood graph
nei_graph = [[0] * N for _ in range(N)]
for a, b, c in G:
    nei_graph[a - 1][b - 1] = c
    nei_graph[b - 1][a - 1] = c

# Warshall Floyd
nei_graph = floyd_warshall(nei_graph)

# 1 if distance is less than L
for i in range(N):
    for j in range(N):
        if nei_graph[i][j] <= L:
            nei_graph[i][j] = 1
        else:
            nei_graph[i][j] = 0

nei_graph = floyd_warshall(nei_graph)

for start, end in Query:
    if nei_graph[start - 1][end - 1] - 1 == float('inf'):
        print(-1)
    else:
        print(int(nei_graph[start - 1][end - 1] - 1))

Buggy submission (verdict: Runtime Error):
    from heapq import heapify, heappop, heappush, nlargest, nsmallest
     
     
    N, M, L = map(int, input().split())
     
    G = [list(map(int, input().split())) for _ in range(M)]
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
     
    nei_graph = [[float('inf')] * N for _ in range(N)]
    for a, b, c in G:
        if c <= L:
            nei_graph[a - 1][b - 1] = c
            nei_graph[b - 1][a - 1] = c
     
    for a, b, c in G:
        nei_graph[a - 1][a - 1] = 0
     
     
    def dijkstra(start_node, end_node, nei_graph):
        visited = set()
     
        nodes = []
        heapify(nodes)
        heappush(nodes, [start_node, 0, L, 0])
     
        dist = [float('inf')] * N
        dist[start_node] = 0
     
        while nodes:
            node, d, remain, cnt = heappop(nodes)
            if node in visited:
                continue
     
            if node == end_node:
                return cnt
     
            visited.add(node)
     
            for i, edge in enumerate(nei_graph[node]):
                if edge == float('inf') or d + edge > dist[i]:
                    continue
     
                dist[i] = d + edge
     
                if remain < edge:
                    new_remain = L - edge
                    new_cnt = cnt + 1
                else:
                    new_remain = remain - edge
                    new_cnt = cnt
     
                heappush(nodes, [i, dist[i], new_remain, new_cnt])
     
        if end_node not in visited:
            return -1
     
     
    for start, end in Query:
        print(dijkstra(start - 1, end - 1, nei_graph))
Problem p02900 (python)

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


def prime_factorization(n):
    from collections import Counter
    counter = Counter()

    if n < 2:
        return counter

    for i in range(2, int(n ** 0.5) + 1):
        if i * i > n:
            break

        while n % i == 0:
            counter[i] += 1
            n //= i

    if n > 1:
        counter[n] += 1

    return counter


x = prime_factorization(A)
y = prime_factorization(B)

z = set(x.keys()) & set(y.keys())
print(len(z) + 1)

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())


def dv(x1, x2):
    ret = []
    v = int(math.sqrt(min(x1, x2))) + 1

    check = [0] * (v + 1)

    for n in range(2, v + 1):
        if check[n] == 1:
            continue

        if x1 % n == 0 and x2 % n == 0:
            ret.append(n)

            cnt = 1
            while n * cnt <= v:
                check[n * cnt] = 1
                cnt += 1

    return ret

can = 0
if A >= B:
    if A % B == 0:
        can = B
else:
    if B % A == 0:
        can = A

cf = [1] + dv(A, B)

flag = False

for c in cf:
    if c % can == 0:
        flag = True
        break
        
if not flag:
    cf = cf + [can]

print(len(cf))

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())


def dv(x1, x2):
    ret = []
    v = int(math.sqrt(min(x1, x2))) + 1

    check = [0] * (v + 1)

    for n in range(2, v + 1):
        if check[n] == 1:
            continue

        if x1 % n == 0 and x2 % n == 0:
            ret.append(n)

            cnt = 1
            while n * cnt <= v:
                check[n * cnt] = 1
                cnt += 1

    return ret

can = 0
if A >= B:
    if A % B == 0:
        can = B
else:
    if B % A == 0:
        can = A

cf = [1] + dv(A, B)

flag = False

for c in cf:
    if c % can == 0:
        flag = True
        break
        
if not flag:
    cf = cf + [can]

print(len(cf))

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


def dv(x1, x2):
    ret = []

    v = min(x1, x2) + 1
    check = [0] * v

    for n in range(2, v):
        if check[n] == 1:
            continue

        if x1 % n == 0 and x2 % n == 0:
            ret.append(n)

            cnt = 2
            while n * cnt <= v:
                check[n * cnt] = 1
                cnt += 1

    return ret


cf = [1] + dv(A, B)
print(len(cf))
Problem p02921 (python)

Fixed submission:
S = input()
T = input()


cnt = 0
for i in range(3):
    if S[i] == T[i]:
        cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())

print(int((N * (N - 1)) // 2))

Buggy submission (verdict: Runtime Error):
N = int(input())

print(int((N * (N - 1)) / 2))
Problem p02936 (python)

Fixed submission:
from collections import deque

N, Q = map(int, input().split())

connect_lst = [[] for _ in range(N + 1)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    connect_lst[a].append(b)
    connect_lst[b].append(a)

query_weight = [0] * (N + 1)
for _ in range(Q):
    q, x = map(int, input().split())
    query_weight[q] += x

used = set()
dq = deque([1])
used.add(1)
ans = [0] * (N + 1)

while dq:
    node = dq.popleft()
    can = connect_lst[node]

    used.add(node)
    ans[node] += query_weight[node]

    for c in can:
        if c not in used:
            ans[c] += ans[node]
            dq.append(c)


ans = [str(w) for w in ans[1:]]
print(' '.join(ans))

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

N, Q = map(int, input().split())

parent_child = defaultdict(list)

AB_lst = [list(map(int, input().split())) for _ in range(N - 1)]
AB_lst.sort(key=lambda x: (x[0], x[1]))

for a, b in AB_lst:
    parent_child[a].append(b)

query_weight = defaultdict(int)
for _ in range(Q):
    q, x = map(int, input().split())
    query_weight[q] += x


dq = deque([])
dq.append((1, query_weight[1]))

ans = [0] * N
while dq:
    node, w = dq.popleft()
    children = parent_child[node]

    ans[node - 1] = str(w)

    for c in children:
        dq.append((c, w + query_weight[c]))


print(' '.join(ans))

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

N, Q = map(int, input().split())

parent_child = defaultdict(set)

for i in range(N - 1):
    a, b = map(int, input().split())
    parent_child[a].add(b)

query_weight = defaultdict(int)
for _ in range(Q):
    q, x = map(int, input().split())
    query_weight[q] += x


dq = deque([])
dq.append((1, query_weight[1]))

ans = [0] * N
while dq:
    node, w = dq.popleft()
    children = parent_child[node]

    ans[node - 1] = str(w)

    for c in children:
        dq.append((c, w + query_weight[c]))


print(' '.join(ans))
Problem p02947 (python)

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

dic = {}
cnt = 0

for moji in moji_lst:
    x = ''.join(sorted(moji))

    if x in dic:
        dic[x] += 1
        cnt += dic[x]
    else:
        dic[x] = 0


print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
import numpy as np
import itertools

N = int(input())

moji = [input() for _ in range(N)]

check = np.zeros((N, N))


for i in range(N):
    c = []
    x = collections.Counter(moji[i])

    c.append(i)

    for j in range(i + 1, N):
        if check[i, j] == 1:
            continue

        y = collections.Counter(moji[j])

        if x == y:
            c.append(j)

    for v in itertools.combinations(c, 2):
        check[v] = 1

print(int(np.sum(check)))

Buggy submission (verdict: Runtime Error):
import collections
import numpy as np
# import math
import itertools

N = int(input())

moji = [input() for _ in range(N)]

check = np.zeros((N, N))


for i in range(N):
    c = []
    x = collections.Counter(moji[i])

    c.append(i)

    for j in range(i + 1, N):
        if check[i, j] == 1:
            continue

        y = collections.Counter(moji[j])

        if x == y:
            c.append(j)

    for v in itertools.combinations(c, 2):
        check[v] = 1

# print(check)
print(int(np.sum(check)))
Problem p02957 (python)

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

K = (A + B) / 2

if int(K) == K:
    print(int(K))
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
x = 1000000007

S = input()
S = [int(s) if s != '?' else s for s in S]
S = S[::-1]

dp = [[0 for j in range(13)] for i in range(len(S) + 1)]

dp[0][0] = 1

for i, s in enumerate(S):
    for j in range(10):
        if s != '?' and s != j:
            continue

        digit_r = ((10 ** i) * j) % 13

        for k in range(13):
            r = (digit_r + k) % 13
            dp[i + 1][r] += dp[i][k]

    dp[i + 1][r] %= x

print(int(dp[-1][5] % x))

Buggy submission (verdict: Runtime Error):
import numpy as np

x = 1000000007

S = input()
S = [int(s) if s != '?' else s for s in S]
S = S[::-1]

r = np.zeros((13,))
new_r = np.zeros((13,))

r[0] = 1

for i, s in enumerate(S):
    for j in range(10):
        if s != '?' and s != j:
            continue

        digit_r = ((10 ** i) * j) % 13

        for k in range(13):
            new_r[(digit_r + k) % 13] += r[k]

    new_r %= x

    r = new_r
    new_r = np.zeros((13,))

print(int(r[5] % x))
Problem p02960 (python)

Fixed submission:
x = 1000000007

S = input()
S = [int(s) if s != '?' else s for s in S]

dp = [[0 for j in range(13)] for i in range(len(S) + 1)]
dp[0][0] = 1

for i, s in enumerate(S):
    for j in range(10):
        if s != '?' and s != j:
            continue

        for k in range(13):
            dp[i + 1][(10 * k + j) % 13] += dp[i][k] % x

print(int(dp[-1][5] % x))

Buggy submission (verdict: Runtime Error):
import numpy as np

x = 1000000007

S = input()
S = [int(s) if s != '?' else s for s in S]
S = S[::-1]

r = np.zeros((13,))
new_r = np.zeros((13,))

r[0] = 1

for i, s in enumerate(S):
    for j in range(10):
        if s != '?' and s != j:
            continue

        digit_r = ((10 ** i) * j) % 13

        for k in range(13):
            new_r[(digit_r + k) % 13] += r[k]

    new_r %= x

    r = new_r
    new_r = np.zeros((13,))

print(int(r[5] % x))
Problem p02981 (python)

Fixed submission:
x, y, z = input().split()

n = int(x)
a = int(y)
b = int(z)

sum = n * a
print(min(sum, b))

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())

all_mod =[]

cnt1 = 0
for i in range(l, r, 1):
    cnt = 0
    for j in range(l + 1, r + 1, 1):
        mod = (i * j) % 2019
        all_mod.append(mod)

        cnt += 1

        if cnt > 2019:
            break

    cnt1 += 1
    if cnt1 > 2019:
        break

print(min(all_mod))

Buggy submission (verdict: Runtime Error):
l, r = map(int, input().split())

all_mod =[]

cnt1 = 0
for i in range(l, r, 1):
    cnt = 0
    for j in range(l + 1, r + 1, 1):
        mod = (i * j) % 2019
        all_mod.append(mod)

        cnt += 1

        if cnt > 2019:
            break

    cnt1 += 1
    if cnt1 > 2019:
        break

print(min(all_mod))
Problem p02993 (python)

Fixed submission:
S = input()

l = len(S)

for i in range(1, l):
    if S[i - 1] == S[i]:
        print("Bad")
        break
    else:
        if i == l - 1:
            print("Good")
            break
        else:
            continue

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

a, b, c, d = map(int, input().split())


def cnt_div(a, b, x):
    q, r = divmod(a, x)

    if r == 0:
        m = q - 1
    else:
        m = q

    n = b // x

    return n - m


num_c = cnt_div(a, b, c)
num_d = cnt_div(a, b, d)
lcm = int((c * d) / gcd(c, d))
num_c_d_gcd = cnt_div(a, b, lcm)

print((b - a + 1) - (num_c + num_d - num_c_d_gcd))
Problem p02995 (python)

Fixed submission:
from fractions import gcd

a, b, c, d = map(int, input().split())


def cnt_div(a, b, x):
    q, r = divmod(a, x)

    if r == 0:
        m = q - 1
    else:
        m = q

    n = b // x

    return n - m


num_c = cnt_div(a, b, c)
num_d = cnt_div(a, b, d)
lcm = int((c * d) / gcd(c, d))
num_c_d_gcd = cnt_div(a, b, lcm)

print((b - a + 1) - (num_c + num_d - num_c_d_gcd))

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

a, b, c, d = map(int, input().split())


def cnt_div(a, b, x):
    q, r = divmod(a, x)

    if r == 0:
        m = q - 1
    else:
        m = q

    n = b // x

    return n - m


num_c = cnt_div(a, b, c)
num_d = cnt_div(a, b, d)
lcm = int((c * d) / gcd(c, d))
num_c_d_gcd = cnt_div(a, b, lcm)

print((b - a + 1) - (num_c + num_d - num_c_d_gcd))