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

Fixed submission:
s = list(input())
l = [-1]
i = 0

while i < len(s):
    if s[i] == "<":
        l.append(l[i] + 1)
    if s[i] == ">":
        cnt = 0
        while s[i + cnt] == ">":
            if i + cnt == len(s) -1:
                cnt += 1
                break
            cnt += 1
        if l[i] < cnt:
            l.append(cnt)
        else:
            l.append(l[i] + 1)
        i += cnt
        cnt -= 1
        while cnt != -1:
            l.append(cnt)
            cnt -= 1
    i += 1
if s[len(s) -1] == "<":
    l.append(l[i] + 1)
del l[0]
ans = sum(l)
print(ans)

Buggy submission (verdict: Runtime Error):
s = list(input())
l = [-1]
i = 0
large = False
small = False

while i < len(s):
    if s[i] == "<":
        l.append(l[i] + 1)
    if s[i] == ">":
        cnt = 1
        while s[i + cnt] == ">":
            if i + cnt == len(s) -1:
                cnt += 1
                break
            cnt += 1
        if l[i] < cnt:
            l.append(cnt)
        else:
            l.append(l[i] + 1)
        i += cnt
        cnt -= 1
        while cnt != -1:
            l.append(cnt)
            cnt -= 1
    i += 1
if s[len(s) -1] == "<":
    l.append(l[i] + 1)
del l[0]
ans = sum(l)
print(ans)
Problem p02891 (python)

Fixed submission:
s = list(input())
k = int(input())
n = len(s)

if s == [s[0]]*n:
    print(n*k//2)
else:
    ss = s*2
    ans1 = 0
    for i in range(1, n):
        if s[i] == s[i -1]:
            s[i] = ""
            ans1 += 1
    ans2 = 0
    for i in range(1, 2*n):
        if ss[i] == ss[i - 1]:
            ss[i] = ""
            ans2 += 1
    j = ans2 - ans1
    print(ans1 + j*(k - 1))

Buggy submission (verdict: Runtime Error):
s = list(input())
k = int(input())
ans = 0
for i in range(1, len(s)):
    if s[i] == s[i -1]:
        ans += 1
        s[i] = ""
j = 0
if s[-1] == s[0]:
    if s[-1] != s[-2]:
        j = 1

print(ans*k - j*(k - 1))
Problem p03745 (python)

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

i = 1
ans = 1
flg = 0
for i, j in zip(A[:-1],A[1:]):
    if i < j:
        if flg == 0:
            flg = 1
        elif flg == 2:
            ans += 1
            flg = 0
    if i > j:
        if flg == 0:
            flg = 2
        elif flg == 1:
            ans += 1
            flg = 0
print(ans)

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

i = 1
ans = 1
plus = False
minus = False
while True:
    while A[i] - A[i-1] == 0:
        i += 1
    if A[i] - A[i - 1] > 0:
        plus = True
    else:
        minus = True
    if plus:
        while A[i] - A[i - 1] >= 0:
            i += 1
            if i == n:
                break
    else:
        while A[i] - A[i -1] <= 0:
            i += 1
            if i == n:
                break
    if i == n:
        break
    if plus:
        minus = True
        plus = False
    else:
        plus = True
        minus = False
    ans += 1
    if i != n -1:
        i += 1

print(ans)
Problem p02659 (python)

Fixed submission:
from math import floor
from fractions import Fraction

A, B = input().split()

print(floor(int(A) * Fraction(B)))

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

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

print(floor(A * B))
Problem p02819 (python)

Fixed submission:
# check
def is_prime(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    else:
        for p in range(2, n):
            if n % p == 0:
                return False
        else:
            return True


# input
X = int(input())

while is_prime(X) is False:
    X += 1

print(X)

Buggy submission (verdict: Runtime Error):
from sympy import nextprime

# input
X = int(input())

print(nextprime(X))
Problem p02831 (python)

Fixed submission:
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


def lcm(m, n):
    return (m * n) // gcd(m, n)


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

# lcm
snack = lcm(A, B) 

print(snack)

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

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

snack = (A * B) // gcd(A, B)

print(snack)

Buggy submission (verdict: Runtime Error):
# input
A, B = int(input())

snack = max([A, B])
while snack % A != 0 and snack % B != 0:
    snack += 1

print(snack)
Problem p02860 (python)

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

# check
if N < 2 or N % 2 != 0:
    print("No")
else:
    if N == 2:
        right = S[0]
        left = S[1]
    else:
        c = N // 2
        right = S[0:c]
        left = S[c:]

    if right == left:
        print("Yes")
    else:
        print("No")

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

# check
if N < 2 or N % 2 != 0:
    print("No")

if N == 2:
    right = S[0]
    left = S[1]
else:
    c = N // 2
    right = S[0:c]
    left = S[c:]

print(f"{right} {left}")

if right == left:
    print("Yes")
else:
    print("No")
Problem p02915 (python)

Fixed submission:
from itertools import combinations

# input
N = int(input())
print(len(set(combinations([i for i in range(1, N + 1)] * 3, 3))))

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

# input
N = int(input())
print(len(list(combinations([for i in range(1, N + 1)] * 3, 3))))
Problem p03073 (python)

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

# check
length = len(S)
if len == 1:
    print(0)
else:
    bwb = ["0", "1"]
    wbw = ["1", "0"]
    cnt = [0] * 2
    for i in range(length):
        if S[i] == bwb[i % 2]:
            cnt[0] += 1
        if S[i] == wbw[i % 2]:
            cnt[1] += 1

    print(min(cnt))

Buggy submission (verdict: Runtime Error):
# check
length = len(S)
if len == 1:
    print(0)
else:
    bwb = ["0", "1"]
    wbw = ["1", "0"]
    cnt = [0] * 2
    for i in range(length):
        if S[i] == bwb[i % 2]:
            cnt[0] += 1
        if S[i] == wbw[i % 2]:
            cnt[1] += 1
    
    print(min([cnt]))
Problem p03135 (python)

Fixed submission:
# input
T, X = map(int, input().split()) 

print(T / X)

Buggy submission (verdict: Runtime Error):
# input
T, X = int(input())

print(T / X)
Problem p03137 (python)

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

X.sort()
K = sorted(
    [
        abs(X[i] - X[i - 1])
        for i in range(1, M)
    ],
    reverse=True
)

print(sum(K[N - 1:]))

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

X.sort()
K = [
    abs(X[i] - X[i - 1])
    for i in range(1, N)
]

print(sum(K[:M - (N - 1)])

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

X.sort()
K = [
    abs(X[i] - X[i - 1])
    for i in range(1, N)
]

print(sum(K[:M - (N - 1)]))

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

X.sort()
K = [
    abs(X[i] - X[i - 1])
    for i in range(1, N)
]

print(sum(K[:M - (N - 1)]))

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

X.sort()
K = [
    abs(X[n] - X[n - 1])
    for i in range(1, N)
]

print(sum(K[:M - (N - 1)]))
Problem p02595 (python)

Fixed submission:
import math

N, D = map(int, input().split())
P = []
for n in range(N):
    X_n, Y_n = map(int, input().split())
    P.append((X_n, Y_n))

def distance(p:tuple):
    return math.sqrt(p[0] ** 2 + p[1] ** 2)

count = [p for p in P if distance(p) <= D]
print(len(count))

Buggy submission (verdict: Runtime Error):
import math

N, D = int(input().split())
P = []
for n in N:
    X_n, Y_n = int(input().split())
    P.append((X_n, Y_n))

def distance(p:tuple):
    # d_2 = p[0] ** 2 + p[1] ** 2
    # d = math.sqrt(d_2)
    return math.sqrt(p[0] ** 2 + p[1] ** 2)

count = [p for p in P if distance(p) <= D]
print(len(count))
Problem p02793 (python)

Fixed submission:
import math
import fractions
n = int(input())


l = list(map(int ,input().split()))

lc = 1

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


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]

print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
import math
import fractions
n = int(input())


l = list(int() ,input().split())

lc = 1

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


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]
    ans%=1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import fractions
n = int(input())


l = list(int ,input().split())

lc = 1

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


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]
    ans%=1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
l = []
for i in range(n):
    l[i] = int(input())
lc = 1



for i in range(n):
    lc = math.gcd(lc , l[i])/lc*l[i]

for i in range(n):
    print(lc/l[i])
    print(" ")
Problem p02689 (python)

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

all_tenbo = list(range(1, N+1))
not_good = []

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1]:
        not_good.append(A)
    if H[B-1] <= H[A-1]:
        not_good.append(B)

print(len(list(set(all_tenbo)-set(not_good))))

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

arr = []
for num in range(N):

  ans = math.floor((A * N) / B) - A * math.floor(N / B)
  arr.append(ans)

arr.sort()

print(arr[len(arr) - 1])

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

for  i  in  range ( 1 , N ):
    b = W[i]
    if max(D) < b:
        D.append(b)
    else:
        for  j  in  range ( len ( D )):
            if D[j] >= b:
                D[j] = b
                break

print ( len ( D ))
Problem p02627 (python)

Fixed submission:
alpha = input()
if alpha == alpha.upper():
    print('A')
else:
    print('a')

Buggy submission (verdict: Runtime Error):
a_list = [chr(ord('a') + i) for i in range(26)]
n = int(input())

l_list = []
ans = ''
while n > 0:
    
    if n % 26 == 0:
        l_list.append(25)
        n = n // 26 - 1
    else:
        l_list.append(n%26)
        n = n // 26
l_list = l_list[::-1]
for i in l_list:
    ans += a_list[i]
print(ans)
Problem p02629 (python)

Fixed submission:
a_list = [chr(ord('a') + i) for i in range(26)]
n = int(input())

l_list = []
ans = ''
while n > 0:
    if n % 26 == 0:
        l_list.append(26)
        n = n // 26 - 1
    else:
        l_list.append(n%26)
        n = n // 26
l_list = l_list[::-1]
for i in l_list:
    ans += a_list[i-1]
print(ans)

Buggy submission (verdict: Runtime Error):
	a_list = [chr(ord('a') + i) for i in range(26)]
n = int(input())

l_list = []
ans = ''
while n > 0:
    
    if n % 26 == 0:
        l_list.append(25)
        n = n // 26 - 1
    else:
        l_list.append(n%26)
        n = n // 26
l_list = l_list[::-1]
for i in l_list:
    ans += a_list[i]
print(ans)
Problem p02699 (python)

Fixed submission:
S, W = input().split()
if int(S) > int(W):
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if W < S:
  print("safe")
else:
  print("unsafe")
Problem p02546 (python)

Fixed submission:
n=list(input())
if n[len(n)-1]=="s":
  n.append("es")
else:
  n.append("s")
print("".join(n))

Buggy submission (verdict: Runtime Error):
n=input()
if n[len(n)-1]=="s":
  n.append("es")
else:
  n.append("s")
print("".join(n))
Problem p02572 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
x=0
for i in range(n):
  x+=a[i]
x=x**2
y=0
for j in range(n):
  y+=a[j]**2
z=(x-y)//2
print(z%(10**9+7))

Buggy submission (verdict: Runtime Error):
n=int(inoput())
a=list(map(int,input()))
total=0
for i in range(0,n-1):
  for j in range(1,n):
    total+=a[i]*a[j]
print(total%(10**9+7))
Problem p02580 (python)

Fixed submission:
H,W,M=map(int,input().split())
row=[0]*H
col=[0]*W
target=set()
for i in range(M):
    h,w=map(int,input().split())
    row[h-1]+=1
    col[w-1]+=1
    target.add((h-1,w-1))
A=max(row)
B=max(col)
a=[x for x in range(H) if row[x]==A]
b=[x for x in range(W) if col[x]==B]
cnt=0
for i in a:
    for j in b:
        cnt+=1
        if (i,j) not in target:
            print(A+B)
            exit(0)
        if cnt>M:
            print(A+B-1)
            exit(0)
print(A+B-1)

Buggy submission (verdict: Runtime Error):
H,W,M=map(int,input().split())
row=[0]*H
col=[0]*W
for i in range(M):
    h,w=map(int,input().split())
    row[h-1]+=1
    col[w-1]+=1
A=max(row)
B=max(col)
a=[x for x in range(H) if row[x]==A]
b=[x for x in range(W) if col[x]==B]
cnt=0
for i in a:
    for j in b:
        cnt+=1
        if (i,j) not in target:
            print(A+B)
            exit(0)
        if cnt>M:
            print(A+B-1)
            exit(0)
print(A+B-1)
Problem p02831 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

A, B = [int(i) for i in input().split(' ')]
gcd_ = gcd(A, B)
print(int(A*B/gcd_))

Buggy submission (verdict: Runtime Error):
import math
A, B = [int(i) for i in input().split(' ')]
gcd = math.gcd(A, B)
print(int(A*B/gcd))
Problem p02688 (python)

Fixed submission:
n,k=map(int,input().split())
s=[]
for i in range(n):
  s.append(0)


for i in range(k):
  d=int(input())
 
  List=list(map(int,input().split()))
  for i in range(d):
    s[List[i]-1]=1
print(n-sum(s))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=[0,0,0]

for i in range(k):
  d=int(input())
 
  List=list(map(int,input().split()))
  for i in range(d):
    s[List[i]-1]=1
print(n-sum(s))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=[0,0,0]

for i in range(k):
  d=int(input())
 
  List=list(map(int,input().split()))
  for i in range(d):
    s[List[i]-1]=1
print(n-sum(s))
Problem p02711 (python)

Fixed submission:
n=input()
if n[0]=='7':
  print('Yes') 
elif n[1]=='7':
  print('Yes')  
elif n[2]=='7':
  print('Yes')  
else:
   print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n[1]=='7':
  print('Yes')
if n[2]=='7':
   print('Yes')
if n[3]=='7':
   print('Yes')
else:
   print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n[1]=='7':
  print('Yes')
if n[2]=='7':
   print('Yes')
if n[3]=='7':
   print('Yes')
else:
   print('No')
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if S > W:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S, W = map(int, input().split())
if S > W:
  print("safe")
  else:
    print("unsafe")

Buggy submission (verdict: Runtime Error):
S = input()
W = input()
if S > W:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if S > W:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if S > W:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if S > W:
  print("safe")
 else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if S > W print('safe')
else: print('unsafe')

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
print(safe if S > W else unsafe)

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
print('safe' if S > W else 'unsafe')

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if S > W print("safe")
 else print("unsafe")

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
print("safe" if S > W else "unsafe")
Problem p02711 (python)

Fixed submission:
N = input()
if "7" in N:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if "7" in input()
 print("Yes")
else print("No")
Problem p02571 (python)

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

best_num_char=0
for i in range(len(S)-len(T)+1):
    # print(T[i:])
    num_char=0
    for j in range(len(T)):
        num_char+=1 if S[i+j]==T[j] else 0
        # print(num_char,S[i + j])
    if best_num_char<num_char:
        best_num_char=num_char

# print(len(T))
print(len(T)-best_num_char)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()

num_char=0
for i in range(len(T)):
    for j in range(i+1,len(T)):
        if T[i:j] in S[i:]:
            print(T[i:j])
            if num_char<j-i:
                num_char=j-i
print(len(T)-num_char)
Problem p02594 (python)

Fixed submission:
x=int(input())

print('Yes') if x>29 else print('No')

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


init=7
for i in range(k+1):
  if init%k ==0:
    print(i+1)
    break
  t = t*10+7
print(-1)
Problem p02596 (python)

Fixed submission:
k=int(input())
 
ans=-1
init=7
for i in range(k+1):
  if init%k ==0:
    ans=i+1
    break
  init = (init*10+7)%k
print(ans)

Buggy submission (verdict: Runtime Error):
k=int(input())
 
 
init=7
for i in range(k+1):
  if init%k ==0:
    print(i+1)
    break
  t = t*10+7
print(-1)
Problem p02549 (python)

Fixed submission:
# 解説などを参考に作成
"""
N = 10, LR = [2, 4] を例とする.
fi:=マスiまで移動する方法の個数とおく.
便宜上0マスから始めると、
    N:  0 1 2 3 4 5 6 7 8 9 10
    fi: 0 1 0 1 1 2 2 4 5 8 11
となる.(1マス目には最初からいるのでf1 = 1とする.)
ここで、N=5,6の時で考えると、LR=[2,4]から
    f5 = f1 + f2 + f3  (∵2～4マス前からしか遷移がないので)
    f6 =      f2 + f3 + f4
よってf5とf6の差はf1とf4によって求めることができる.
    f6 = f5 - f1 + f4
一般化すると、
    fi = fi-1 - fi-1-R + fi-L
LRが複数ある場合でも区間が重複しないので、各区間に対して - fi-1-R + fi-L 部分を計算して fi を求めることができる.
計算量はO(KN) (K:=重複しない区間LRの個数)
"""


# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, K, LR):
    mod = 998244353
    dp = [0] * (N + 1)
    dp[1] = 1
    # dp[0] は基本0として扱ってよいが, dp[2]の計算時のみ,dp[0]とdp[1]の差分=0となる必要がある.
    # => この時のみ、dp[0]を1として計算しないと fi = fi-1 - fi-1-R + fi-L のルールに合わなくなる.
    # 他の人の解答(#16897281, #16895566)見ると階差数列？敵なのを持つことで解決できそうだったけど,
    # 内容が理解できなかったのでdp[2]までは手動実装することにした.
    dp[2] = 1 if 1 in [lr[0] for lr in LR] else 0
    for i in range(3, N + 1):
        x = 0
        for l, r in LR:
            x += dp[max(i - l, 0)] - dp[max(i - 1 - r, 0)]
        dp[i] = (dp[i - 1] + x) % mod
    print(dp[N])


if __name__ == '__main__':
    N, K = map(int, input().split())
    LR = [[int(i) for i in input().split()] for _ in range(K)]
    solve(N, K, LR)

    # # test
    # from random import randint
    # from func import random_str
    # N, K = 2 * 10 ** 5, 1
    # LR = [[1, N]]
    # solve(N, K, LR)

Buggy submission (verdict: Runtime Error):
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, K, LR):
    mod = 998244353
    S = []
    for lr in LR:
        S += [i for i in range(lr[0], lr[1] + 1)]
    S.sort()
    dp = [0] * (N + 1)
    dp[1] = 1
    for i in range(1, N + 1):
        for s in S:
            if i + s > N:
                break
            dp[i + s] = (dp[i + s] + dp[i]) % mod
    print(dp[N])


if __name__ == '__main__':
    # N, K = map(int, input().split())
    # LR = [[int(i) for i in input().split()] for _ in range(K)]
    # solve(N,K,LR)

    # test
    from random import randint
    from func import random_str

    N, K = 2 * 10 ** 5, 1
    LR = [[1, N]]
    solve(N, K, LR)
Problem p02659 (python)

Fixed submission:
# 検証と認識が甘かった


def solve(A, B):
    _B = round(B * 100)
    print(A * _B // 100)


if __name__ == '__main__':
    A, B = [float(i) for i in input().split()]
    A = int(A)
    solve(A, B)

Buggy submission (verdict: Runtime Error):
# 検証と認識が甘かった


def solve(A, B):
    _B = round(B * 100)
    print(A * _B // 100)


if __name__ == '__main__':
    A, B = [float(i) for i in input().split()]
    A = int(A)
    sorted(A, B)
Problem p02679 (python)

Fixed submission:
# 解説と 13355391 を参考に実装予定


import math


def solve():
    N = int(input())
    ABs = [[int(i) for i in input().split()] for _ in range(N)]
    mod = 10 ** 9 + 7

    lonlieness = 0
    pairs = {}
    for AB in ABs:
        a, b = AB
        if a == 0 and b == 0:
            lonlieness += 1
            continue
        elif a == 0:
            a, b = -1, 0
            bad_a, bad_b = 0, 1
        elif b == 0:
            a, b = (0, 1)
            bad_a, bad_b = -1, 0
        else:
            _gcd = math.gcd(a, b)
            a //= _gcd
            b //= _gcd
            bad_a = -b
            bad_b = a
            if b < 0:
                a, b = -a, -b
            if bad_b < 0:
                bad_a, bad_b = -bad_a, -bad_b
        pairs.setdefault((a, b), 0)
        pairs.setdefault((bad_a, bad_b), 0)  # 仲の悪いグループも登録しておく
        pairs[(a, b)] += 1

    permutations = []
    for i, pair in enumerate(pairs.keys()):
        if i % 2 == 1:
            continue
        a, b = pair
        bad_a, bad_b = -b, a
        if bad_b < 0:
            bad_a, bad_b = -bad_a, -bad_b
        group_num = pow(2, pairs[(a, b)], mod) - 1
        badgroup_num = pow(2, pairs[(bad_a, bad_b)], mod) - 1
        permutations.append(group_num + badgroup_num + 1)

    result = 1
    for p in permutations:
        result = result * p % mod

    result = (result + lonlieness - 1) % mod
    print(result)


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
# 解説と 13355391 を参考に実装予定


import math


def solve():
    N = int(input())
    ABs = [[int(i) for i in input().split()] for _ in range(N)]
    mod = 10 ** 9 + 7

    lonlieness = 0
    pairs = {}
    for AB in ABs:
        a, b = AB
        if a == 0 and b == 0:
            lonlieness += 1
            continue
        elif a == 0:
            a, b = 1, 0
            bad_a, bad_b = 0, 1
        elif b == 0:
            a, b = (0, 1)
            bad_a, bad_b = 1, 0
        else:
            _gcd = math.gcd(a, b)
            a //= _gcd
            b //= _gcd
            bad_a = -b
            bad_b = a
            if b < 0:
                a, b = -a, -b
            if bad_b < 0:
                bad_a, bad_b = -bad_a, -bad_b
        pairs.setdefault((a, b), 0)
        pairs.setdefault((bad_a, bad_b), 0)  # 仲の悪いグループも登録しておく
        pairs[(a, b)] += 1

    permutations = []
    for i, pair in enumerate(pairs.keys()):
        if i % 2 == 1:
            continue
        a, b = pair
        bad_a, bad_b = -b, a
        if bad_b < 0:
            bad_a, bad_b = -bad_a, -bad_b
        group_num = pow(2, pairs[(a, b)], mod) - 1
        badgroup_num = pow(2, pairs[(bad_a, bad_b)], mod) - 1
        permutations.append(group_num + badgroup_num + 1)

    result = 1
    for p in permutations:
        result = result * p % mod

    result = (result + lonlieness - 1) % mod
    print(result)


if __name__ == '__main__':
    solve()
Problem p02831 (python)

Fixed submission:
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect


def gcd(a, b):
    """最大公約数"""
    a, b = (a, b) if a >= b else (b, a)
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    """最小公倍数"""
    # from math import gcd
    return (a * b) // gcd(a, b)


# from decorator import stop_watch
#
#
# @stop_watch
def solve(A, B):
    print(lcm(A, B))


if __name__ == '__main__':
    A, B = map(int, input().split())
    solve(A, B)

Buggy submission (verdict: Runtime Error):
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect


def lcm(a, b):
    """最小公倍数"""
    from math import gcd
    return (a * b) // gcd(a, b)


# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(A, B):
    print(lcm(A, B))


if __name__ == '__main__':
    A, B = map(int, input().split())
    solve(A, B)