Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

import re
import numpy as np

s = [i.span()[0] for i in list(re.finditer("AC", S))]
#print(s)

count = np.array([0] * (N+1))
for i in range(len(s)):
    count[s[i]+1:] += 1
    
#print(count)

ans = []
for i in range(Q):
    l, r = map(int, input().split())
    #print(S[l-1:r])
    #print(count[r-1], count[l-1])
    ans.append(count[r-1] - count[l-1])

print(" ".join(map(str, ans)))

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

import re

s = [i.span()[0] for i in list(re.finditer("AC", S))]
#print(s)

count = [0] * (N+1)
c = 0
for i in range(N):
    try:
        if s[0]+1 == i:
            s.pop(0)
            c += 1
    except:
        pass
            
    count[i] = c
    
#print(count)

ans = []
for i in range(Q):
    l, r = map(int, input().split())
    #print(S[l-1:r])
    #print(count[r-1], count[l-1])
    ans.append(count[r-1] - count[l-1])

print(" ".join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r])
    
import re
    
for i in range(len(lr)):
    #print(S[lr[i][0]-1 : lr[i][1]])
    #print(re.findall("AC", S[lr[i][0]-1 : lr[i][1]]))
    #print(len(re.findall("AC", S[lr[i][0]-1 : lr[i][1]])))
    print(S[lr[i][0]-1 : lr[i][1]].count("AC"))

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

import re

s = [i.span()[0] for i in list(re.finditer("AC", S))]
#print(s)

count = [0] * (N+1)
c = 0
for i in range(N):
    try:
        if s[0]+1 == i:
            s.pop(0)
            c += 1
    except:
        pass
            
    count[i] = c
    
#print(count)

ans = []
for i in range(Q):
    l, r = map(int, input().split())
    #print(S[l-1:r])
    #print(count[r-1], count[l-1])
    ans.append(count[r-1] - count[l-1])

print(" ".join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r])
    
import re
    
for i in range(len(lr)):
    #print(S[lr[i][0]-1 : lr[i][1]])
    #print(re.findall("AC", S[lr[i][0]-1 : lr[i][1]]))
    print(len(re.findall("AC", S[lr[i][0]-1 : lr[i][1]])))

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

import re

s = [i.span()[0] for i in list(re.finditer("AC", S))]
#print(s)

count = [0] * (N+1)
c = 0
for i in range(N):
    try:
        if s[0]+1 == i:
            s.pop(0)
            c += 1
    except:
        pass
            
    count[i] = c
    
#print(count)

ans = []
for i in range(Q):
    l, r = map(int, input().split())
    #print(S[l-1:r])
    #print(count[r-1], count[l-1])
    ans.append(count[r-1] - count[l-1])

print(" ".join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):

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

a = bin(A)[2:].zfill(len(bin(B))-2)
b = bin(B)[2:]
#print(a, b)

import math

MAX = math.floor(math.log2(B)) + 1
#print("二進数の桁数の最大値", MAX)

c = [0] * (MAX+1)

for i in range(1, MAX):
    #print("桁", 2**i)
    ma = B//(2**i) * (2**i)
    mi = A//(2**i) * (2**i) + (2**i)
    #print(ma, mi)
    sum = int(a[-(i+1)]) * (mi - A) + int(b[-(i+1)]) * (B+1 - ma)
    #print(sum, sum % 2)
    c[-(i+1)] = sum % 2
    
a = (A+1)//2 if A % 2 == 1 else (A+2)//2
b = (B+1)//2 if B % 2 == 1 else B//2
    
c[-1] = (b-(a-1)) % 2

#print(c)
print(int("".join(map(str, c)), 2))

Fixed submission:

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

A -= 1

if (A+1) % 2 == 0:
    a = (A+1) // 2 % 2
else:
    a = (A // 2 % 2) ^ A

if (B+1) % 2 == 0:
    b = (B+1) // 2 % 2
else:
    b = (B // 2 % 2) ^ B
    
#print(a, b)
print(a ^ b)

Buggy python submission (verdict: Runtime Error):

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

a = bin(A)[2:].zfill(len(bin(B))-2)
b = bin(B)[2:]
#print(a, b)

import math

MAX = math.floor(math.log2(B)) + 1
#print("二進数の桁数の最大値", MAX)

c = [0] * (MAX+1)

for i in range(1, MAX):
    #print("桁", 2**i)
    ma = B//(2**i) * (2**i)
    mi = A//(2**i) * (2**i) + (2**i)
    #print(ma, mi)
    sum = int(a[-(i+1)]) * (mi - A) + int(b[-(i+1)]) * (B+1 - ma)
    #print(sum, sum % 2)
    c[-(i+1)] = sum % 2
    
c[-1] = (A % 2 + (B-A) // 2 % 2) % 2

#print(c)
print(int("".join(map(str, c)), 2))

Fixed submission:

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

A -= 1

if (A+1) % 2 == 0:
    a = (A+1) // 2 % 2
else:
    a = (A // 2 % 2) ^ A

if (B+1) % 2 == 0:
    b = (B+1) // 2 % 2
else:
    b = (B // 2 % 2) ^ B
    
#print(a, b)
print(a ^ b)

Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())

XOR = A
for i in range(A+1, B+1):
    XOR ^= i

print(XOR)


Fixed submission:

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

A -= 1

if (A+1) % 2 == 0:
    a = (A+1) // 2 % 2
else:
    a = (A // 2 % 2) ^ A

if (B+1) % 2 == 0:
    b = (B+1) // 2 % 2
else:
    b = (B // 2 % 2) ^ B
    
#print(a, b)
print(a ^ b)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

AB = []
for i in range(M):
    A, B = map(int, input().split())
    AB.append([A, B, i])

AB_ = AB[::-1]

#print(AB)
#print(AB_)

ma = N * (N-1) // 2

path = []
subs = [0]
for i in range(len(AB_)):
    f0 = -1
    f1 = -1
    sub = 0
    for p in range(len(path)):
        if AB_[i][0] in path[p]:
            path[p] += [AB_[i][1]]
            f0 = p
        elif AB_[i][1] in path[p]:
            path[p] += [AB_[i][0]]
            f1 = p
            
    if  (f0 > -1) and (f1 > -1):
        #print("@", path[f0] + path[f1])
        s = list(set(path[f0] + path[f1]))
        if f0 > f1:
            path.pop(f0)
            path.pop(f1)
            path.append(s)
        elif f1 > f0:
            path.pop(f1)
            path.pop(f0)
            path.append(s)

    if  (f0 == -1) and (f1 == -1):
        path.append([AB_[i][0], AB_[i][1]])
        
    for p in range(len(path)):
        sub += len(list(set(path[p]))) * (len(list(set(path[p])))-1) // 2
    subs.append(sub)

#print(subs)

for i in range(2, len(subs)+1):
    print(ma-subs[-i])

Fixed submission:

class UnionFind:
    def __init__(self, N):
        self.parents = [i for i in range(N)]
        self.sizes = [1 for _ in range(N)]
        
    # 木の根をまとめる, 頂点 v が属するグループ番号を得る (O(α(n)))
    def root(self, x):
        if self.parents[x] == x:
            return x # 根
        else:
            self.parents[x] = self.root(self.parents[x]) # 経路圧縮
            return self.parents[x]
            
    # xとyが同じ集合に属するか否か
    def is_same(self, x, y):
        return self.root(x) == self.root(y)
        
    # xとyの属する集合を併合, 頂点 u が属するグループと頂点 v が属するグループを併合し、同じグループにする (O(α(n)))
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.sizes[x] += self.sizes[y]
        self.parents[y] = x
        return True
    
    # 頂点 v が属するグループと同じグループに属する頂点数を得る (O(1))
    def size(self, x):
        return self.sizes[self.root(x)]
        
        
        
N, M = map(int, input().split())

tree = UnionFind(N)

AB = []
for _ in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])

AB = AB[::-1]

tree = UnionFind(N)
ans = [N*(N-1)//2]
for i in range(M):
    a, b = AB[i]
    a, b = tree.root(a-1), tree.root(b-1)
    if a != b:
        ans.append(ans[-1] - tree.size(a)*tree.size(b))
    else:
        ans.append(ans[-1])
    tree.unite(a, b)

ans = ans[:M][::-1]
for i in range(M):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):


def main():
  n = int(input())
  print((n - 1) * n) // 2)



if __name__ == "__main__":
  main()

Fixed submission:


def main():
    n = int(input())
    print( (n * (n- 1) ) // 2)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):

	
def main():
	linie = input()
	vector = [int(x) for x in linie.split()]	
	x = vector[0]
	y = vector[1]
	h = vector[2]
	print(((x + y) * h) // 2)
 
if __name__ == "__main__":
	main()

Fixed submission:

	
def main():	
	x = int(input())
	y = int(input())
	h = int(input())
	print(((x + y) * h) // 2)
 
if __name__ == "__main__":
	main()
Buggy python submission (verdict: Time Limit Exceeded):
H,W,K  =(map(int,input().split(" "))) #  H × W のグリッド
nums = [list(map(int,list(input())))  for  _ in range(H)]
ruiseki_2d = [ [0] * (W + 1)  for _ in range(H + 1) ] # 0 → 0
for w in range(W):
    for h in range(H):
        ruiseki_2d[h + 1][w + 1] =ruiseki_2d[h + 1][w] + ruiseki_2d[h][w + 1] + nums [h ][w]  - ruiseki_2d[h][w]


# Hの分割は決め打ち
# H =10 → 9箇所の分け目
# Wの分割は必要ならする
ans = 10 ** 6
for i in range(2 ** (H - 1)):
    # print(i)
    cand = 0
    # print("pattern {}: ".format(i), end="")
    cuts = [0] #一番端っこでカット
    for j in range(0,H -1 ):  #
        if ((i >> j) & 1):  # j + 1の箇所でHを切る
            # print(i,j + 1)
            cuts.append(j + 1)
            cand += 1
    cuts.append(H)
    beforeW = 0 #個数が変化するのは beforeW からwの区間とwより右の区間
    for w in range(1,W + 1):
        mi = 10 ** 6
        ss = []
        for i in range(len(cuts) - 1): #広げたら超えてしまっていたら、その一個前で線を引く
            y1 = cuts[i]
            y2 = cuts[i + 1]
            x2  = w
            x1 = beforeW
            s = ruiseki_2d[y2][x2] -ruiseki_2d[y2][x1] -ruiseki_2d[y1][x2] +ruiseki_2d[y1][x1]
            ss.append(s)


        ma = max(ss)
        if ma > K :
            cand += 1
            beforeW = w -1


    ans = min(cand,ans)
print(ans)




Fixed submission:
H,W,K  =(map(int,input().split(" "))) #  H × W のグリッド
nums = [list(map(int,list(input())))  for  _ in range(H)]
ruiseki_2d = [ [0] * (W + 1)  for _ in range(H + 1) ] # 0 → 0
for w in range(W):
    for h in range(H):
        ruiseki_2d[h + 1][w + 1] =ruiseki_2d[h + 1][w] + ruiseki_2d[h][w + 1] + nums [h ][w]  - ruiseki_2d[h][w]


# Hの分割は決め打ち
# H =10 → 9箇所の分け目
# Wの分割は必要ならする
ans = 10 ** 10
for i in range(2 ** (H )):
    # print(i)
    cand = 0
    # print("pattern {}: ".format(i), end="")
    cuts = [0] #一番端っこでカット
    for j in range(0,H -1 ):  #
        if ((i >> j) & 1):  # j + 1の箇所でHを切る
            # print(i,j + 1)
            cuts.append(j + 1)
            cand += 1
    cuts.append(H)
    beforeW = 0 #個数が変化するのは beforeW からwの区間とwより右の区間
    for w in range(1,W + 1):
        mi = 10 ** 6
        ss = []
        for i in range(len(cuts) - 1): #広げたら超えてしまっていたら、その一個前で線を引く
            y1 = cuts[i]
            y2 = cuts[i + 1]
            x2  = w
            x1 = beforeW
            s = ruiseki_2d[y2][x2] -ruiseki_2d[y2][x1] -ruiseki_2d[y1][x2] +ruiseki_2d[y1][x1]
            ss.append(s)


        ma = max(ss)
        if ma > K :
            cand += 1
            beforeW = w -1
    ss = []
    for i in range(len(cuts) - 1):  # 広げたら超えてしまっていたら、その一個前で線を引く
        y1 = cuts[i]
        y2 = cuts[i + 1]
        x2 = W
        x1 = beforeW
        s = ruiseki_2d[y2][x2] - ruiseki_2d[y2][x1] - ruiseki_2d[y1][x2] + ruiseki_2d[y1][x1]
        ss.append(s)


    if max(ss) <= K :
        ans = min(cand,ans)
# if ruiseki_2d[-1][-1] <= K:
#     ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import collections

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


def bit_add(A,a,w): #リストAのa番目にwを足す
    ind = a

    while len(A) > ind:
        A[ind] += w
        lsb = ind & (-ind)
        # print(ind)
        ind += lsb

    return

def bit_sum(A, a):  # リストAのa番目までの和を取る
    s = 0
    ind = a
    while ind != 0:
        s += A[ind]
        lsb = ind & (-ind)
        ind -= lsb

    return s
# cs = set(list(S))
li = {}
for c in "abcdefghijklmnopqrstuvwxyz":
    li[c] = [0] * (N + 1)

for i in range(1,N + 1):
    char = S[i - 1]
    bit_add(li[char],i,1)

# li → 1 スタート
# S → 0スタート
Q = int(input())
queries = [input().split() for _ in range(Q)]
for query in queries:
    a,b,c = query
    a = int(a)
    b = int(b)
    if a == 1: # 書き換え
        i = b

        c_org = S[i - 1] # 元の文字
        # li[c_org][i] -= 1
        S[i - 1] = c
        bit_add(li[c_org], i,  -1)#元の文字をbiマイナス
        bit_add(li[c], i, 1) #新たな文字をbiプラス

    if a == 2:
        ans = 0
        l = b
        r = int(c)
        for c in "abcdefghijklmnopqrstuvwxyz":
            temp = li[c]
            r_sum = bit_sum(temp,r)
            l_sum = bit_sum(temp,l - 1)
            diff = r_sum-l_sum
            if diff > 0: # ある文字
                ans += 1
        print(ans)




Fixed submission:
import math
import collections

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

S = list(S)
def bit_add(A,a,w): #リストAのa番目にwを足す
    ind = a

    while len(A) > ind:
        A[ind] += w
        lsb = ind & (-ind)
        # print(ind)
        ind += lsb

    return

def bit_sum(A, a):  # リストAのa番目までの和を取る
    s = 0
    ind = a
    while ind != 0:
        s += A[ind]
        lsb = ind & (-ind)
        ind -= lsb

    return s
# cs = set(list(S))
li = {}
for c in "abcdefghijklmnopqrstuvwxyz":
    li[c] = [0] * (N + 1)

for i in range(1,N + 1):
    char = S[i - 1]
    bit_add(li[char],i,1)

# li → 1 スタート
# S → 0スタート
Q = int(input())
queries = [input().split() for _ in range(Q)]
for query in queries:
    a,b,c = query
    a = int(a)
    b = int(b)
    if a == 1: # 書き換え
        i = b

        c_org = S[i - 1] # 元の文字
        # li[c_org][i] -= 1
        S[i - 1] = c
        bit_add(li[c_org], i,  -1)#元の文字をbiマイナス
        bit_add(li[c], i, 1) #新たな文字をbiプラス

    if a == 2:
        ans = 0
        l = b
        r = int(c)
        for c in "abcdefghijklmnopqrstuvwxyz":
            temp = li[c]
            r_sum = bit_sum(temp,r)
            l_sum = bit_sum(temp,l - 1)
            diff = r_sum-l_sum
            if diff > 0: # ある文字
                ans += 1
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

import heapq
import collections
from collections import deque

n = int(input())
ab = []
visit = [-1 for _ in range(n+1)]
tree = [[]  for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int,input().split())
    ab.append([a, b])
    tree[a].append(b)
    tree[b].append(a)

colors = [ [-1] * (n + 1)  for _ in range(n + 1)] # abの色を格納
visit[1]=1

q = deque([(1,0)]) #V,color のtuple
K = 0
while q:
    v,from_color = q.popleft()
    c = 1
    for next_v in tree[v]:
        if visit[next_v] == -1:
            visit[next_v] = 1
            if c == from_color:
               c += 1
            colors[v][next_v] = colors[next_v][v] = c
            q.append((next_v,c))
            c += 1
anss = []
K = 0
for temp in ab:
    a,b = temp
    K = max(K, colors[a][b])
    anss.append(colors[a][b])

print(K)
for c in anss:
    print(c)





# for k,v in di:
#     color = max(colors,len(v))


Fixed submission:

import heapq
import collections
from collections import deque

n = int(input())
ab = []
visit = [-1 for _ in range(n+1)]
tree = [[]  for _ in range(n+1)]
colors = {}
for i in range(n-1):
    a, b = map(int,input().split())
    ab.append((a, b))
    tree[a].append(b)
    tree[b].append(a)
    colors[(a,b)] = -1
    colors[(b,a)] = -1

# abの色を格納
visit[1]=1

q = deque([(1,0)]) #V,color のtuple
K = 0
while q:
    v,from_color = q.popleft()
    c = 1
    for next_v in tree[v]:
        if visit[next_v] == -1:
            visit[next_v] = 1
            if c == from_color:
               c += 1
            colors[(v,next_v)] = colors[(next_v,v)] = c
            q.append((next_v,c))
            c += 1
anss = []
K = 0
for temp in ab:
    a,b = temp
    K = max(K, colors[(a,b)] )
    anss.append(colors[(a,b)])

print(K)
for c in anss:
    print(c)





# for k,v in di:
#     color = max(colors,len(v))
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i * j == n:
      print("Yes")
      exit(1)
print("No")

Fixed submission:
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i * j == n:
      print("Yes")
      exit(0)
print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  fof j in range(1,10):
    if i * j == n:
      print("Yes")
      exit(0)
print("No")

Fixed submission:
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i * j == n:
      print("Yes")
      exit(0)
print("No")
Buggy python submission (verdict: Time Limit Exceeded):

import heapq
N = int(input())
nums = list(map(int,input().split(" ")))
nums.sort()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if nums[k] < nums[i] +nums[j]:
                ans +=1
            else:
                break

print(ans)

Fixed submission:
import collections
import heapq
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
nums = list(map(int,input().split(" ")))
nums.sort()
ans = 0
di = collections.defaultdict(lambda :0)
for i in range(N):
    for j in range(i+1,N):
        key = nums[i] + nums[j]
        di[key] += 1
co = 0
for k,v in di.items():
    for temp in nums:
        if k <= temp:
            co += v

temp = combinations_count(N,3)
print(temp- co)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
cot = 0
before = ""
seq = []

if len(S) == 1:
    ans = len(K)//2
else:
    for i in range(len(S)):
        c = S[i]
        if cot == 0:
            cot += 1
            before =c
        else:
            if c == before:
                cot += 1
            else:
                before = c
                seq.append(cot)
                cot = 1

    seq.append(cot)
    ans = 0
    for temp in seq:
        ans +=temp//2
    ans *= K
    if S[0] == S[-1]:
        ans += (seq[0] + seq[-1]) * (K - 1) //2 - (seq[0] //2 + seq[-1]//2 )* (K - 1)
print(ans)

Fixed submission:
S = input()
K = int(input())
cot = 0
before = ""
seq = []


for i in range(len(S)):
    c = S[i]
    if cot == 0:
        cot += 1
        before =c
    else:
        if c == before:
            cot += 1
        else:
            before = c
            seq.append(cot)
            cot = 1

seq.append(cot)
ans = 0
for temp in seq: #素の状態で連続してる文字列
    ans +=temp//2
ans *= K
if S[0] == S[-1]: #頭と尾で一緒→つなげたときに長い連続区間が発生
    ans += (seq[0] + seq[-1]) //2 * (K - 1) - (seq[0] //2 + seq[-1]//2 )* (K - 1)
if len(seq) == 1:
    ans = min(ans,seq[0] * K //2)
print(ans)
Buggy python submission (verdict: Runtime Error):
n =int(input())
ans =0

for i in range(1,n+1):
  if i%2= 1:
    ans+= 1
print(ans/ n)

Fixed submission:
n =int(input())
ans =0

for i in range(1,n+1):
  if i%2== 1:
    ans+= 1
print(ans/ n)

Buggy python submission (verdict: Runtime Error):
n =int(input())
cot =0

for i in range(1,n+1):
  if i%2= 1:
    ans+= 1
print(ans/ n)

Fixed submission:
n =int(input())
ans =0

for i in range(1,n+1):
  if i%2== 1:
    ans+= 1
print(ans/ n)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print( sum(range(1,N)))

Fixed submission:
N = int(input())
print( int( (N * (N -1) )//2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
nums = [int(input()) for _ in range(N)]
ans = 0
nums_sorted = nums[:]
nums_sorted = list(set(nums_sorted))
nums_sorted.sort(reverse=True)
di = {}





for i in range(N-1):
    if nums[i] > nums[i+1]:
        ans += 1

nums_l = len(nums)
nums_s = len(list(set(nums)) )
ans += nums_l - nums_s
if len(nums_s) == 1:
    ans += 1



print(ans)

Fixed submission:
import bisect
from collections import deque
N = int(input())
nums = deque()

for i in range(N):
    temp =  int(input())
    ind = bisect.bisect_left(nums, temp)
    if ind == 0:
        nums.appendleft(temp)
    else:
        nums[ind - 1] = temp
print(len(nums))
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def do():
    A,B,C,D =  list(map(int,input().split(" ")))
    CD = lcm(C,D)
    A1 = A- 1
    ans = (B//C + B//D - B//CD) - (A1//C + A1//D - A1//CD)
    ans = (B-A+1) - ans
    print(ans)

if __name__ == "__main__":
    do()

Fixed submission:
import  fractions

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


def do():
    A,B,C,D =  list(map(int,input().split(" ")))
    CD = lcm(C,D)
    A1 = A- 1
    ans = (B//C + B//D - B//CD) - (A1//C + A1//D - A1//CD)
    ans = (B-A+1) - ans
    print(ans)

if __name__ == "__main__":
    do()

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

A,B,C,D =  list(map(int,input().split(" ")))
CD = lcm(C,D)
A1 = A- 1
ans = (B//C + B//D - B//CD) - (A1//C + A1//D - A1//CD)



ans = (B-A+1) - ans
print(ans)

Fixed submission:
import  fractions

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


def do():
    A,B,C,D =  list(map(int,input().split(" ")))
    CD = lcm(C,D)
    A1 = A- 1
    ans = (B//C + B//D - B//CD) - (A1//C + A1//D - A1//CD)
    ans = (B-A+1) - ans
    print(ans)

if __name__ == "__main__":
    do()
Buggy python submission (verdict: Runtime Error):
n = int(input())

points = [list( map(int,input().split(" "))) for _ in range(n)]
X = 0
Y = 1
ans = 10 ** 14
for i  in range(n):
  for j in range(n):
    if i == j:
      continue
    x1,y1 = points[i]
    x2,y2 = points[j]
    p = x1 - x2
    q = y1 - y2
    cost = n
    for point1 in points: #そのpointからcost0で遷移できる先があるかどうか
      fromx,fromy = point1
      for point2 in points:
        tox,toy = point2
        if fromx - tox == p and fromy - toy == q:
          cost -= 1
          break
    if ans < cost:
      ans = cost
print(cost)
        
      
    

Fixed submission:
n = int(input())

points = [list(map(int, input().split(" "))) for _ in range(n)]
X = 0
Y = 1
ans = 10 ** 14
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        x1, y1 = points[i]
        x2, y2 = points[j]
        p = x1 - x2
        q = y1 - y2
        cost = n
        for point1 in points:  # そのpointからcost0で遷移できる先があるかどうか
            fromx, fromy = point1
            for point2 in points:
                tox, toy = point2
                if fromx - tox == p and fromy - toy == q:
                    cost -= 1
                    break
        if ans > cost:
            ans = cost
if n == 1:
    print(1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
Xs = []
Ys = []
za = []

for i in range(N):
    x,y = list(map(int, input().split(" ")))
    Xs.append(x)
    Ys.append(y)
    za.append((x,y))

za.sort(key=lambda x:x[0])
dix = defaultdict(lambda :0)
diy = defaultdict(lambda :0)
for i,z in enumerate(za[1:]):
    x = z[0]
    before = za[i][0]
    tempx = x -before
    y = z[1]
    before = za[i][1]
    tempy =  y -before
    diy[(tempx,tempy)] += 1

ymax = max(diy.values())
cand = [N - ymax]


za.sort(key=lambda x:x[1])
dix = defaultdict(lambda :0)
diy = defaultdict(lambda :0)
for i,z in enumerate(za[1:]):
    x = z[0]
    before = za[i][0]
    tempx = x -before
    y = z[1]
    before = za[i][1]
    tempy =  y -before
    diy[(tempx,tempy)] += 1

ymax = max(diy.values())
cand.append(N - ymax)


print(min(cand))


Fixed submission:
n = int(input())

points = [list(map(int, input().split(" "))) for _ in range(n)]
X = 0
Y = 1
ans = 10 ** 14
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        x1, y1 = points[i]
        x2, y2 = points[j]
        p = x1 - x2
        q = y1 - y2
        cost = n
        for point1 in points:  # そのpointからcost0で遷移できる先があるかどうか
            fromx, fromy = point1
            for point2 in points:
                tox, toy = point2
                if fromx - tox == p and fromy - toy == q:
                    cost -= 1
                    break
        if ans > cost:
            ans = cost
if n == 1:
    print(1)
else:
    print(ans)