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

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())
    L = len(S)

    i = 0
    if L % 2 == 1:
        mid = (L - 1) // 2
        m = S[mid]
        while i <= mid and S[mid-i] == S[mid+i] == m:
            i += 1

        print(mid + i)
    else:
        mid =  (L - 1) // 2
        m0 = S[mid]
        m1 = S[mid+1]
        while i <= mid and S[mid-i] == S[mid+i+1] == m0 == m1:
            i += 1

        print(mid + i + 1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())

    if len(S) % 2 == 1:
        mid = (len(S) - 1) // 2
        for i in range(mid):
            if S[mid] != S[mid + i] or S[mid] != S[mid -i]:
                ans = mid + i
                break
    else:
        midr = len(S) // 2
        midl = midr - 1
        for i in range(midr):
            if S[midr] != S[midr + i] or S[midr] != S[midl - i]:
                ans = midr + i
                break

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    S = str(input().strip())

    z = []
    o = []
    i = 0
    while i < len(S):
        j = i + 1
        while j < len(S) and S[i] == S[j]:
            j += 1
        if S[i] == '0':
            z.append(j-i)
        else:
            o.append(j-i)

        i = j

    z = sorted(z, key=lambda x: -x)
    o = sorted(o, key=lambda x: -x)

    if z[0] > o[0]:
        if len(z) > 2 and z[0] == z[1]:
            print(z[0] + 1)
        else:
            print(z[0])
    elif o[0] > z[0]:
        if len(o) > 2 and o[0] == o[1]:
            print(o[0] + 1)
        else:
            print(o[0])
    else:
        if len(z) > 2 and z[0] == z[1]:
            print(z[0] + 1)
        elif len(o) > 2 and o[0] == o[1]:
            print(o[0] + 1)
        else:
            print(o[0])


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

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    S = [str(c) for c in input().strip()]
    X, Y = map(int, input().split())
    F = []
    while len(S) > 0:
        f = 0
        while len(S) > 0 and S[0] == 'F':
            f += 1
            S.pop(0)
        F.append(f)
        if len(S) > 0:
            S.pop(0)

    Fx = []
    Fy = []
    for i in range(1, len(F)):
        if i % 2 == 0:
            Fx.append(F[i])
        else:
            Fy.append(F[i])

    dpx = [[F[0]]] + [0] * len(Fx)
    for i in range(len(Fx)):
        nx = set()
        for a in dpx[i]:
            nx.add(a + Fx[i])
            nx.add(a - Fx[i])
        dpx[i+1] = nx

    dpy = [[0]] + [0] * len(Fy)
    for i in range(len(Fy)):
        ny = set()
        for a in dpy[i]:
            ny.add(a + Fy[i])
            ny.add(a - Fy[i])
        dpy[i+1] = ny


    if X in dpx[-1] and Y in dpy[-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def f(pos, S, goal):
    F = 0
    while len(S) > 0 and S[0] == 'F':
        F += 1
        _ = S.pop(0)

    num_F = sum([c == 'F' for c in S])

    next_pos = set()
    for p in pos:
        x = p[0]
        y = p[1]
        if p[2] == 0:  # Forward to +x
            x += F
        elif p[2] == 1:  # Forward to +y
            y += F
        elif p[2] == 2:  # Forward to -x
            x -= F
        else:              # direct == 3, Foward to -y
            y -= F

        dist = abs(goal[0] - x) + abs(goal[1] - y)
        if num_F < dist:
            continue

        direct1 = (p[2] + 1) % 4
        direct2 = (p[2] + 3) % 4

        np1 = (x, y, direct1)
        np2 = (x, y, direct2)

        next_pos.add(np1)
        next_pos.add(np2)

    if len(next_pos) == 0:
        return False

    if len(S) == 0:
        ans = False
        for p in next_pos:
            if p[0] == goal[0] and p[1] == goal[1]:
                ans = True
                break
        return ans

    _ = S.pop(0)  # Remove 'T' at S[0]
    return f(next_pos, S, goal)


def main():
    input = sys.stdin.readline
    S = [str(c) for c in input().strip()]
    goal = list(map(int, input().split()))

    init = (0, 0, 0)
    pos = set()
    pos.add(init)

    if f(pos, S, goal):
        print('Yes')
    else:
        print('No')


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

Fixed submission:
import sys
from bisect import bisect
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    Bn = [0] * N
    for i in range(N):
        b = B[i]
        m = bisect(C, b)
        Bn[i] = (N - m)

    Bn = list(accumulate(Bn[::-1]))[::-1]
    Bn += [0]

    ans = 0
    for i in range(N):
        a = A[i]
        m = bisect(B, a)
        ans += Bn[m]

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    Bn = [0] * N
    for i in range(N):
        b = B[i]
        m = bisect(C, b)
        Bn[i] = (N - m)

    Bn = list(accumulate(Bn[::-1]))[::-1]

    ans = 0
    for i in range(N):
        a = A[i]
        m = bisect(B, a)
        ans += Bn[m]

    print(ans)


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

Fixed submission:
import sys

def gcd(a, b):
    """Euclidean Algorithm"""
    while b != 0:
        a, b = b, a % b
    return a

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


def main():
    input = sys.stdin.readline
    N = int(input())
    T = [int(input()) for _ in range(N)]
    T = sorted(T)

    t = T[0]
    for i in range(N):
        if T[i] % t == 0:
            t = T[i]
        else:
            t = lcm(t, T[i])

    return t


if __name__ == '__main__':
    print(main())

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

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


def main():
    input = sys.stdin.readline
    N = int(input())
    T = [int(input()) for _ in range(N)]
    T = sorted(T)

    t = T[0]
    for i in range(N):
        if T[i] % t == 0:
            t = T[i]
        else:
            t = lcm(t, T[i])

    return t


if __name__ == '__main__':
    print(main())
Problem p03645 (python)

Fixed submission:
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        A[a].append(b)
        A[b].append(a)

    q = deque()
    for a in A[1]:
        q.append(a)

    while len(q) > 0:
        a = q.popleft()
        if N in A[a]:
            return 'POSSIBLE'

    return 'IMPOSSIBLE'





if __name__ == '__main__':
    print(main())

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

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        A[a].append(b)
        A[b].append(a)

    q = deque()
    q.append(*A[1])

    while len(q) > 0:
        a = q.popleft()
        if N in A[a]:
            return 'POSSIBLE'

    return 'IMPOSSIBLE'





if __name__ == '__main__':
    print(main())
Problem p03797 (python)

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())

    if N >= M // 2:
        ans = M // 2
        #N -= M // 2

        #ans += N // 2

        return ans

    else:
        ans = N
        M -= 2 * N

        ans += M // 4

        return ans


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())

    if N >= M // 2:
        ans = M // 2
        S -= M // 2

        ans += S // 2

        return ans

    else:
        ans = N
        M -= 2 * N

        ans += M // 4

        return ans


if __name__ == '__main__':
    print(main())
Problem p03863 (python)

Fixed submission:
import sys

def check(S):
    even = set()
    odd = set()
    for i in range(len(S)):
        if i % 2 == 0:
            odd.add(S[i])
        else:
            even.add(S[i])

    return len(even) == len(odd) == 1


def can_checkmate(S):
    chrs = set(S)
    if len(chrs) != 3:
        return False

    for c in chrs:
        S_ = S
        S_.remove(c)
        if check(S_):
            return True

    return False


def main():
    input = sys.stdin.readline
    S = [c for c in input().strip()]

    if check(S):
        return 'Second'

    if S[0] == S[-1]:
        if len(S) % 2 == 0 or can_checkmate(S):
            return 'First'

        else:
            return 'Second'
    else:
        if len(S) % 2 == 1:
            return 'First'

        else:
            return 'Second'


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def check(S):
    even = set()
    odd = set()
    for i in range(len(S)):
        if i % 2 == 0:
            odd.add(S[i])
        else:
            even.add(S[i])

    return len(even) == len(odd) == 1


def can_checkmate(S):
    chrs = set(S)
    if len(chrs) != 3:
        return False

    for c in chrs:
        S_ = S.remove(c)
        if check(S_):
            return True

    return False


def main():
    input = sys.stdin.readline
    S = [c for c in input().strip()]

    if check(S):
        return 'Second'

    if S[0] == S[-1]:
        if len(S) % 2 == 0 or can_checkmate(S):
            return 'First'
        else:
            return 'Second'
    else:
        if len(S) % 2 == 1 or can_checkmate(S):
            return 'First'
        else:
            return 'Second'


if __name__ == '__main__':
    print(main())
Problem p04013 (python)

Fixed submission:
import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    N, A = map(int, input().split())
    X = [int(c) - A for c in input().split()]
    d = defaultdict(lambda: 0)

    for x in X:
        d_ = defaultdict(lambda: 0)
        for key in d.keys():
            d_[key + x] += d[key]

        for key in d_.keys():
            d[key] += d_[key]

        d[x] += 1

    return d[0]


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    s = int(input())

    return ans


if __name__ == '__main__':
    print(main())
Problem p04014 (python)

Fixed submission:
import sys

def f(b, n):
    if b < 2:
        return -1    

    if b > n:
        return n

    return f(b, n//b) + n % b


def main():
    input = sys.stdin.readline
    n = int(input())
    s = int(input())

    if s > n:
        return -1

    if s == n:
        return n+1

    for i in range(2, int(n**0.5)):
        if f(i, n) == s:
            return i

    for p in range(int(n**0.5) + 1, 0, -1):
        if (n - s) % p != 0:
            continue

        b = (n - s) // p + 1
        if f(b, n) == s:
            return b

    return -1


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def f(b, n):
    if b > n:
        return n

    return f(b, n//b) + n % b


def main():
    input = sys.stdin.readline
    n = int(input())
    s = int(input())

    if s == n:
        return n+1

    for i in range(2, int(n**0.5)):
        if f(i, n) == s:
            return i


    for p in range(1, int(n**0.5)):
        b = (n - s) // p + 1
        if f(b, n) == s:
            return b

    return -1


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def f(b, n):
    if b > n:
        return n

    return f(b, n//b) + n % b


def main():
    input = sys.stdin.readline
    n = int(input())
    s = int(input())

    if s == n:
        return n+1

    for i in range(2, int(n**0.5)):
        if f(i, n) == s:
            return i

    b = (n - s) // p + 1
    if f(b, n) == s:
        return b
    else:
        return -1


if __name__ == '__main__':
    print(main())
Problem p04045 (python)

Fixed submission:
import sys
from itertools import product

def main():
    input = sys.stdin.readline
    N, K = map(str, input().split())
    D = list(map(str, input().split()))

    nums = set([str(i) for i in range(10)])
    safe = sorted(list(nums - set(D)))
    min_safe = safe[0]
    if min_safe == '0':
        min_safe = safe[1]

    digit = len(str(N))
    safe_num = list(product(safe, repeat=digit))
    ans = 10**5
    for n in safe_num:
        m = int(''.join(n))
        l = int(min_safe + ''.join(n))
        if m >= int(N):
            ans = min(ans, m)

        if l >= int(N):
            ans = min(ans, l)


    return ans


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys
from itertools import product

def main():
    input = sys.stdin.readline
    N, K = map(str, input().split())
    D = list(map(str, input().split()))

    nums = set([str(i) for i in range(10)])
    safe = sorted(list(nums - set(D)))

    digit = len(str(N))
    safe_num = list(product(safe, repeat=digit))
    ans = 10**5
    for n in safe_num:
        m = int(''.join(n))
        l = int(safe[0] + ''.join(n))
        s = int(safe[1] + ''.join(n))
        if m >= int(N):
            ans = min(ans, m)

        if l >= int(N):
            ans = min(ans, l)

        if s >= int(N):
            ans = min(ans, s)

    return ans


if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    D = list(map(int, input().split()))
    safe = list(set(range(10)) - set(D))
    safe = sorted(safe)

    n = [c for c in str(N)]
    for i in range(len(n)):
        if int(n[i]) in safe:
            continue
        
        for s in safe:
            if s > int(n[i]):
                n[i] = str(s)
                replaced = i
                break
        break

    for i in range(replaced+1, len(n)):
        n[i] = str(safe[0])

    return ''.join(n)


if __name__ == '__main__':
    print(main())
Problem p02861 (python)

Fixed submission:
import itertools
import numpy as np

N = int(input())
X = []
Y = []
for i in range(N):
    x, y = list(map(int, input().split()))
    X.append(x)
    Y.append(y)

lst = []
for I in list(itertools.permutations(range(N))):
    kyori = 0
    for i in range(N-1):
        kyori = kyori + ((X[I[i]]-X[I[i+1]])**2 +
                         (Y[I[i]]-Y[I[i+1]])**2) ** 0.5
    lst.append(kyori)

print(np.average(lst))

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

N = int(input())
X = []
Y = []
for i in range(N):
    x, y = list(map(int, input().split()))
    X.append(x)
    Y.append(y)

lst = []
for I in list(itertools.permutations(range(N))):
    kyori = 0
    for i in range(N-1):
        kyori = kyori + ((X[I[i]]-X[I[i+1]])**2 +
                         (Y[I[i]]-Y[I[i+1]])**2) ** 0.5
    lst.append(kyori)

print(np.average(lst))
Problem p02924 (python)

Fixed submission:
print((lambda n: n*(n-1)//2)(int(input())))

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

n = int(input())
a = deque(list(range(1,n,1)))
a.appendleft(n)

c = 0
for i in range(n):
	c += a[i]%(i+1)
print(c)
Problem p02947 (python)

Fixed submission:
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())

ss = []
for i in range(n):
	s = list(input())
	s.sort()
	ss.append("".join(s))

cs = collections.Counter(ss)
l = list(cs.values())
l.sort(reverse=True)

c = 0
for i in l:
	if i > 1:
		c+= cmb(i,2)
	elif i == 1:
		print(int(c))
		exit()
print(int(c))

Buggy submission (verdict: Runtime Error):
from math import factorial
import collections

n = int(input())

ss = []
for i in range(n):
	s = list(input())
	s.sort()
	ss.append("".join(s))

cs = collections.Counter(ss)
l = list(cs.values())
l.sort(reverse=True)

c = 0
for i in l:
	if i > 1:
		a = factorial(i) / factorial(2) / factorial(i - 2)
		c+=a
	elif i == 1:
		print(int(c))
		exit()
print(int(c))

Buggy submission (verdict: Runtime Error):
from math import factorial
import collections

n = int(input())

ss = []
for i in range(n):
	s = list(input())
	s.sort()
	ss.append("".join(s))

cs = collections.Counter(ss)
l = list(cs.values())
l.sort(reverse=True)

c = 0
for i in l:
	if i == 1:
		print(int(c))
		exit()
	else:
		a = factorial(i) / factorial(2) / factorial(i - 2)
		c+=a
print(int(c))

Buggy submission (verdict: Runtime Error):
from math import factorial
import collections

n = int(input())

ss = []
for i in range(n):
	s = list(input())
	s.sort()
	ss.append("".join(s))

cs = collections.Counter(ss)
l = list(cs.values())

c = 0
for i in l:
	if i == 1:
		print(int(c))
		exit()
	else:
		a = factorial(i) / factorial(2) / factorial(i - 2)
		c+=a
print(int(c))
Problem p02963 (python)

Fixed submission:
S = int(input())
lim = 10**9
x1,y1 = 0,0
x2,y2 = 10**9, 1
x3 = (lim-S%lim)%lim
y3 = (S+x3)//lim
print("%d %d %d %d %d %d" % (x1,y1,x2,y2,x3,y3))

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

def prime_decomposition(n):
  i = 2
  t = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      t.append(i)
    i += 1
  if n > 1:
    t.append(n)
  return t

def get_binary(arr):
	lim = 10**9
	a = np.prod(arr[:-1])
	c = 0
	b = arr[-1]
	while a > lim:
		c+=1
		a=np.prod(arr[c:-1])
		tmp = [arr[-1]] + arr[:c]
		b=np.prod(tmp)
		if b > lim:
			return -1,-1
	return a,b

lim = 10**9
S = int(input())
t = prime_decomposition(S)
a = 1
ta = [0,0]
x1,x2,x3,y1,y2,y3 = 0,0,0,0,0,0
if len(t) != 1:
	x2,y3 = get_binary(t)
while max(t) >= lim or max(ta) >= lim or len(t) == 1 or (x2 == -1 and y3 == -1) or (x3 == -1 or y2 == -1):
	a+= S//(10**(len(str(S)) - 9))
	t = prime_decomposition(S+a)
	ta = prime_decomposition(a)
	if len(t) != 1:
		x2,y3 = get_binary(t)
	else:
		x2,y3 = -1,-1
	if len(ta) != 1:
		x3,y2 = get_binary(ta)
	else:
		x3,y2 = -1,-1


print("%d %d %d %d %d %d" % (x1,y1,x2,y2,x3,y3))

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

def prime_decomposition(n):
  i = 2
  t = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      t.append(i)
    i += 1
  if n > 1:
    t.append(n)
  return t

def get_binary(arr):
	lim = 10**9
	a = np.prod(arr[:-1])
	c = 0
	b = arr[-1]
	while a > lim:
		c+=1
		a=np.prod(arr[c:-1])
		tmp = [arr[-1]] + arr[:c]
		b=np.prod(tmp)
		if b > lim:
			return -1,-1
	return a,b

lim = 10**9
S = int(input())
t = prime_decomposition(S)
a = 1
ta = [0,0]
x1,x2,x3,y1,y2,y3 = 0,0,0,0,0,0
x2,y3 = get_binary(t)
while max(t) >= lim or max(ta) >= lim or len(t) == 1 or (x2 == -1 and y3 == -1) or (x3 == -1 or y2 == -1):
	a+= S//(10**(len(str(S)) - 9))
	t = prime_decomposition(S-a)
	ta = prime_decomposition(a)
	x2,y3 = get_binary(t)
	x3,y2 = get_binary(ta)



print("%d %d %d %d %d %d" % (x1,y1,x2,y2,x3,y3))

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

def prime_decomposition(n):
  i = 2
  t = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      t.append(i)
    i += 1
  if n > 1:
    t.append(n)
  return t

def get_binary(arr):
	lim = 10**9
	a = np.prod(arr[:-1])
	c = 0
	b = arr[-1]
	while a > lim or b > lim:
		c+=1
		a=np.prod(arr[c:-1])
		b = arr[-1]
		for i in range(c):
			b = b*arr[i]
	return a,b

lim = 10**9
S = int(input())
t = prime_decomposition(S)
a = 1
ta = [0]

while max(t) >= lim or max(ta) >= lim or len(t) == 1:
	a*= S//(10**(len(str(S)) - 8))
	t = prime_decomposition(S-a)
	ta = prime_decomposition(a)

x1,x2,x3,y1,y2,y3 = 0,0,0,0,0,0

x1,y1 = 0,0
x2,y3 = get_binary(t)
x3,y2 = get_binary(ta)

print("%d %d %d %d %d %d" % (x1,y1,x2,y2,x3,y3))
Problem p02983 (python)

Fixed submission:
L,R = map(int,input().split())
 
ans = 2019
m = []
l = R-L+1
if l < 2019:
	for i in range(L,R+1):
		m.append(i%2019)
else:
	for i in range(L,L+2019):
		m.append(i%2019)

for i in range(len(m)):
	for j in range(i+1,len(m)):
		tmp = (m[i]*m[j])%2019
		if ans> tmp:
			ans = tmp
		if tmp == 0:
			break				
print(ans)

Buggy submission (verdict: Runtime Error):
L,R = map(int,input().split())
 
ans = 2019
m = []
for i in range(L,R+1):
	m.append(i%2019)

for i in range(len(m)):
	for j in range(i+1,len(m)):
		tmp = (m[i]*m[j])%2019
		if ans> tmp:
			ans = tmp
		if tmp = 0:
			break				
print(ans)
Problem p02995 (python)

Fixed submission:
def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b , a%b)	

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

lc = (c*d) // gcd(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+lc_count)

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

lc = (c*d) // math.gcd(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+lc_count)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

lc = lcm(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+lc_count)

Buggy submission (verdict: Runtime Error):
import math

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

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

cd = c * d
cd_count =  (b // cd) - ((a-1) // cd)

lc = lcm(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+cd_count+lc)

Buggy submission (verdict: Runtime Error):
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,c,d = map(int,input().split())
t = 0
l = b-a+1

c_count = (b // c) - ((a-1) // c)

d_count = (b // d) - ((a-1) // d)

cd = c * d
cd_count =  (b // cd) - ((a-1) // cd)

lc = lcm(c,d)
lc_count = (b // lc) - ((a-1) // lc)

print(l-c_count-d_count+cd_count+lc)
Problem p02861 (python)

Fixed submission:
from itertools import permutations

import numpy as np

N = int(input())

xys = []
for _ in range(N):
    xys.append(list(map(int, input().split())))

combs = np.array(list(permutations(xys, N)))
ret = np.array(
    [np.linalg.norm(combs[:, i] - combs[:, i + 1], axis=1) for i in range(N - 1)]
).sum() / len(combs)

print("{:.10f}".format(ret))

Buggy submission (verdict: Runtime Error):
from itertools import permutations

import numpy as np

N = int(input())

xys = []
for _ in range(N):
    xys.append(list(map(int, input().split())))

combs = np.array(list(permutations(xys, N)))
ret = np.array(
    [np.linalg.norm(combs[:, i] - combs[:, i + 1], axis=1) for i in range(N - 1)]
).sum() / len(combs)

print(f"{ret:.10f}")
Problem p02909 (python)

Fixed submission:
S = input().strip()

weather = ["Sunny", "Cloudy", "Rainy"]


idx = weather.index(S) + 1
if idx >= len(weather):
    print(weather[0])
else:
    print(weather[idx])

Buggy submission (verdict: Runtime Error):
S = input().strip()

weather = ["Sunny", "Cloudy", "Rainy"]


idx = weather.index(S) + 1
if idx > len(weather):
    print(weather[0])
else:
    print(weather[idx])
Problem p02924 (python)

Fixed submission:
N = int(input())
n = N -1
print(n*(n+1)//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(range(1,N+1))
P = [A[len(A)-1]]
P.extend(A[:len(A)-1])
s = 0
for i,p in enumerate(P):
    s += p%(i+1)
print(s)