Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = []
num_range = list(range(A, B + 1))
if A == B:
    print(A)
else:
    for i in range(K if len(num_range) > K else len(num_range)):
        nums.append(num_range[i])
        nums.append(num_range[- (i + 1)])
    for num in sorted(list(set(nums))):
        print(num)


Fixed submission:
A, B, K = map(int, input().split())
num_range = range(A, B + 1)
for i in sorted(set(num_range[:K]) | set(num_range[-K:])):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = []
num_range = list(range(A, B + 1))
if A == B:
    print(A)
else:
    for i in range(K if (B + 1 - A) > K else (B + 1 - A)):
        nums.append(num_range[i])
        nums.append(num_range[- (i + 1)])
    for num in sorted(list(set(nums))):
        print(num)


Fixed submission:
A, B, K = map(int, input().split())
num_range = range(A, B + 1)
for i in sorted(set(num_range[:K]) | set(num_range[-K:])):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = []
num_range = list(range(A, B + 1))
for i in range(K if (B + 1 - A) > K else (B + 1 - A)):
    nums.append(num_range[i])
    nums.append(num_range[- (i + 1)])
for num in sorted(list(set(nums))):
    print(num)


Fixed submission:
A, B, K = map(int, input().split())
num_range = range(A, B + 1)
for i in sorted(set(num_range[:K]) | set(num_range[-K:])):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
try:
    small = list(range(A, B + 1))[:K]
    big = list(range(A, B + 1))[-K:]
    nums = small + big
except:
    nums = list(range(A, B + 1))
for num in sorted(list(set(nums))):
    print(num)


Fixed submission:
A, B, K = map(int, input().split())
num_range = range(A, B + 1)
for i in sorted(set(num_range[:K]) | set(num_range[-K:])):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
try:
    small = list(range(A, B + 1))[:K]
    big = list(range(A, B + 1))[-K:]
    nums = small + big
except:
    nums = list(range(A, B + 1))
for num in set(nums):
    print(num)


Fixed submission:
A, B, K = map(int, input().split())
num_range = range(A, B + 1)
for i in sorted(set(num_range[:K]) | set(num_range[-K:])):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
nums = list(range(A, B + 1))[:K] + list(range(A, B + 1))[-K:]
for num in nums:
    print(num)


Fixed submission:
A, B, K = map(int, input().split())
num_range = range(A, B + 1)
for i in sorted(set(num_range[:K]) | set(num_range[-K:])):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
print("\n".join(list(range(A, B + 1))[:K] + list(range(A, B + 1))[-K:]))


Fixed submission:
A, B, K = map(int, input().split())
num_range = range(A, B + 1)
for i in sorted(set(num_range[:K]) | set(num_range[-K:])):
    print(i)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
counter = 0
for _ in range(A,B+1):
    str = str(_)
    alist = list(str)
    list_ = []
    long = len(alist)
    for i in range(long-1,-1,-1):
        list_.append(alist[i])
    num = "".join(list_)
    if num == str:
        counter += 1
        continue
    else:
        continue

print(counter)


Fixed submission:
A, B = map(int, input().split())
counter = 0
for num in range(A, B + 1):
    if str(num) == str(num)[::-1]:
        counter += 1

print(counter)

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
counter = 0
for _ in range(A,B+1):
    str = str(_)
    alist = list(str)
    print(alist)
    list_ = []
    long = len(alist)
    for i in range(long-1,-1,-1):
        list_.append(alist[i])
    num = "".join(list_)
    if num == str:
        counter += 1
        continue
    else:
        continue

print(counter)


Fixed submission:
A, B = map(int, input().split())
counter = 0
for num in range(A, B + 1):
    if str(num) == str(num)[::-1]:
        counter += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([c[2] for line in c]) - sum([c[1] for line in c])) % 3 == 0
    assert (sum([c[1] for line in c]) - sum([c[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")


Fixed submission:
c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([line[2] for line in c]) - sum([line[1] for line in c])) % 3 == 0
    assert (sum([line[1] for line in c]) - sum([line[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
txy = [tuple() for _ in range(N)]
for i in range(N - 1):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    print("Yes")


Fixed submission:
N = int(input())
txy = [(0, 0, 0)] + [tuple(map(int, input().split())) for _ in range(N)]


for i in range(N):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    if N == 1:
        root = txy[1][1] + txy[1][2]
        time = txy[1][0]
        if time < root:
            print("No")
        else:
            if (time - root) % 2 == 0:
                print("Yes")
            else:
                print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
S = input()
from collections import Counter
C = Counter(S)
if len(C.keys()) == 1:
    if C.values()[0] >= 2:
        print("No")
    else:
        print("Yes")
elif len(C.keys()) == 2:
    if sum(C.values()) < 3:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")


Fixed submission:
from collections import Counter
S = input()
Sc = Counter(S)
if len(Sc.keys()) == 1:
    print("YES" if len(S)==1 else "NO")
elif len(Sc.keys()) == 2:
    if (list(Sc.values())[0] != list(Sc.values())[1]) or (list(Sc.values())[0] > 2 or  list(Sc.values())[1] > 2):
        print("NO")
    else:
        print("YES")
else:
    temp = list(Sc.values())
    if max(temp) - min(temp) <= 1:
        print("YES")
    else:
        print("NO")
Buggy python submission (verdict: Runtime Error):
S = input()
for _ in range(S - 1):
    if S[_:_ + 2] == "AC":
        print("Yes")
        break
else:
    print("No")


Fixed submission:
S = input()
for _ in range(len(S) - 1):
    if S[_:_ + 2] == "AC":
        print("Yes")
        break
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
graph = [list(input()) for _ in range(H)]


def count_bomb(x, y):
    bomb = 0
    one_steps = ((1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1))
    for dx, dy in one_steps:
        nx, ny = x + dx, y + dy
        if (0 <= nx < H) and (0 <= ny <= W):
            if graph[nx][ny] == "#":
                bomb += 1
    return bomb


for x in range(H):
    for y in range(W):
        if graph[x][y] == ".":
            graph[x][y] = count_bomb(x, y)
for line in graph:
    print(line)


Fixed submission:
H, W = map(int, input().split())
Slist = [["."] * (W + 2), ]
for _ in range(H):
    line = list(input())
    line.insert(0, ".")
    line.append(".")
    Slist.append(line)
Slist.append(["."] * (W + 2))
# print(Slist)
point_tuple = ((-1, -1), (-1, 0), (-1, 1),
               (0, -1), (0, 1),
               (1, -1), (1, 0), (1, 1))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        # print(Slist[i][j], i, j)
        if Slist[i][j] == ".":
            counter = 0
            for a, b in point_tuple:
                if Slist[i - a][j - b] == "#":
                    counter += 1
            Slist[i][j] = str(counter)

for i in range(1, H + 1):
    print("".join(Slist[i][1:-1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N):
    if plist[i] == i + 1:
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
        ans += 1
if plist[-1] == N:
    ans += 1
print(ans)


Fixed submission:
N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if plist[i] == i + 1:
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
        ans += 1
if plist[-1] == N:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N):
    if p[i] == i + 1:
        ans += 1
        p[i], p[i + 1] = p[i + 1], p[i]
if p[-1] == N:
    ans += 1
print(ans)


Fixed submission:
N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N - 1):
    if plist[i] == i + 1:
        plist[i], plist[i + 1] = plist[i + 1], plist[i]
        ans += 1
if plist[-1] == N:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
program name

    implicit none
    integer x,a,b
    integer xa,xb
    read*, x,a,b
    xa = abs(x-a)
    xb = abs(x-b)
    if ( xa<xb ) then
        print*, "A"
    else
        print*, "B"
    end if

end program

Fixed submission:
def ABC():
    x,a,b = map(int,input().split())
    if abs(x-a) < abs(x-b):
        print("A")
    else:
        print("B")

ABC()
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))

ans = []
for k in sorted(Ac.keys())[::-1]:
  if len(ans) == 2:
    break
  if Ac[k] >=4:
    if ans:
      ans.append(k)
    else:
      ans.append(k)
      ans.append(k)
  elif Ac[k] >= 2:
    ans.append(k)
print(ans[0]*ans[1])

Fixed submission:
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))
over2 = [ele for ele in Ac.items() if ele[1]>=2]
if len(over2) == 0:
  print(0)
elif len(over2) == 1:
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
else:
  over2.sort(reverse=True)
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
  else:
    print(over2[0][0]*over2[1][0])

Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))
over2 = [ele for ele in Ac.items() if ele[1]>=2]
if len(over2) == 0:
  print(0)
elif len(over2) == 1:
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
else:
  over2.sort()[::-1]
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
  else:
    print(over2[0][0]*over2[1][0])

Fixed submission:
from collections import Counter
N = int(input())
Ac = Counter(list(map(int, input().split())))
over2 = [ele for ele in Ac.items() if ele[1]>=2]
if len(over2) == 0:
  print(0)
elif len(over2) == 1:
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
else:
  over2.sort(reverse=True)
  if over2[0][1] >= 4:
    print(over2[0][0]**2)
  else:
    print(over2[0][0]*over2[1][0])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
from heapq import heapify, heappush, heappop

inf = float("inf")
def dijkstra(graph, start):  # graphは隣接リスト(繋がっている先, コスト)
    vsize = len(graph)
    dist = [inf] * vsize
    seen = [False] * vsize
    prev = [None] * vsize
    pq = []
    heapify(pq)

    dist[start] = 0
    heappush(pq, (0, start))  # heapではtuple[0]で比較されるのでこの順番で追加する
    while pq:
        cost, u = heappop(pq)
        seen[u] = True
        if dist[u] < cost:
            continue
        for v, w in graph[u]:
            temp_cost = dist[u] + w
            if not seen[v] and temp_cost < dist[v]:
                dist[v] = temp_cost
                prev[v] = u
                heappush(pq, (dist[v], v))
    return dist
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))
shortest_path = [dijkstra(graph, i) for i in range(N)]
Q, K = map(int, input().split())
for _ in range(Q):
    x, y = map(int, input().split())
    print(shortest_path[x-1][K-1]+shortest_path[K-1][y-1])


Fixed submission:
N = int(input())
from heapq import heapify, heappush, heappop

inf = float("inf")
def dijkstra(graph, start):  # graphは隣接リスト(繋がっている先, コスト)
    vsize = len(graph)
    dist = [inf] * vsize
    seen = [False] * vsize
    prev = [None] * vsize
    pq = []
    heapify(pq)

    dist[start] = 0
    heappush(pq, (0, start))  # heapではtuple[0]で比較されるのでこの順番で追加する
    while pq:
        cost, u = heappop(pq)
        seen[u] = True
        if dist[u] < cost:
            continue
        for v, w in graph[u]:
            temp_cost = dist[u] + w
            if not seen[v] and temp_cost < dist[v]:
                dist[v] = temp_cost
                prev[v] = u
                heappush(pq, (dist[v], v))
    return dist
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    graph[a-1].append((b-1, c))
    graph[b-1].append((a-1, c))
Q, K = map(int, input().split())
shortest_path_K = dijkstra(graph, K-1)
for _ in range(Q):
    x, y = map(int, input().split())
    print(shortest_path_K[x-1]+shortest_path_K[y-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(alist[i])
    b = b[::-1]

for _ in b:
    print(_, end=" ")


Fixed submission:
n = int(input())
alist = list(map(int, input().split()))
b = alist[::-2] + alist[n % 2::2]
print(" ".join(list(map(str, b))))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
dic = {}
for i in range(N):
    a, b = map(int, input().split())
    if a not in dic.keys():
        dic[a] = 0
    dic[a] += b
count = 0
for k, v in sorted(dic.items()):
    count += v
    if count >= K:
        print(k)
        break


Fixed submission:
from collections import Counter
N, K = map(int, input().split())
c = Counter()
for _ in range(N):
    a, b = map(int, input().split())
    c[a] += b
for item in sorted(c.items(), key=lambda x: x[0]):
    if item[1] >= K:
        print(item[0])
        break
    else:
        K -= item[1]

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
array = []
for _ in range(N):
    a, b = map(int, input().split())
    array.extend([a] * b)
array.sort()
print(array[K - 1])


Fixed submission:
from collections import Counter
N, K = map(int, input().split())
c = Counter()
for _ in range(N):
    a, b = map(int, input().split())
    c[a] += b
for item in sorted(c.items(), key=lambda x: x[0]):
    if item[1] >= K:
        print(item[0])
        break
    else:
        K -= item[1]
Buggy python submission (verdict: Runtime Error):
N = int(input())
array = list(map(int, input().split()))
ans = 1
rels = []
for i in range(1, N):
    a, b = array[i], array[i-1]
    if b < a:
        rels.append("<")
    if b > a:
        rels.append(">")
    if a == b:
        rels.append("=")
now = rels[0]
skip = False
for i in range(N-1):
    rel = rels[i]
    if skip:
        skip = False
        now = rel
        continue
    if rel == now or rel == "=":
        continue
    elif now == "=":
        now = rel
    else:
        skip = True
        ans += 1


print(ans)

Fixed submission:
N = int(input())
array = list(map(int, input().split()))
ans = 1
rels = []
if N == 1:
    print(1)
    exit()
for i in range(1, N):
    a, b = array[i], array[i-1]
    if b < a:
        rels.append("<")
    if b > a:
        rels.append(">")
    if a == b:
        rels.append("=")
now = rels[0]
skip = False
for i in range(N-1):
    rel = rels[i]
    if skip:
        skip = False
        now = rel
        continue
    if rel == now or rel == "=":
        continue
    elif now == "=":
        now = rel
    else:
        skip = True
        ans += 1


print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
Alist = list(map(int, input().split()))
if N < 3:
    print(1)
else:
    ans = 1
    last = Alist[0]
    new_a = [last]
    for i in range(N):
        now = Alist[i]
        if now != last:
            new_a.append(now)
        last = now
    now = "up" if new_a[0] < new_a[1] else "down
    f = now
    for i in range(1, len(new_a)):
        if new_a[i - 1] == new_a[i]:
            continue
        elif new_a[i - 1] < new_a[i]:
            if now == "down":
                now = "up"
        elif new_a[i - 1] > new_a[i]:
            if now == "up":
                now = "down"
        if now != f:
            ans += 1
        # print(i, now, ans)
    print(ans + 1)

Fixed submission:
N = int(input())
array = list(map(int, input().split()))
ans = 1
rels = []
if N == 1:
    print(1)
    exit()
for i in range(1, N):
    a, b = array[i], array[i-1]
    if b < a:
        rels.append("<")
    if b > a:
        rels.append(">")
    if a == b:
        rels.append("=")
now = rels[0]
skip = False
for i in range(N-1):
    rel = rels[i]
    if skip:
        skip = False
        now = rel
        continue
    if rel == now or rel == "=":
        continue
    elif now == "=":
        now = rel
    else:
        skip = True
        ans += 1


print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, Counter
def f():
    return 10**9
d = defaultdict(f)
n = int(input())
for _ in range(N):
    S = Counter(input())
    for k, v in S.items():
        d[k] = min(d[k], v)
ans = ""
for k, v in d.items():
    ans += k * v
print(ans)


Fixed submission:
from collections import Counter
n = int(input())
Slist = [Counter(list(input())) for _ in range(n)]
ans = []
for i in range(ord("a"), ord("a") + 26):
    searching_alpha = chr(i)
    min_num = 10**9
    for S in Slist:
        min_num = min(min_num, S[searching_alpha])
    ans.append(searching_alpha * min_num)
print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = range(1, int(input()) + 1)
prod = 1
for i in N:
    prod *= i
print(prod % (10**9 + 7))


Fixed submission:
num = 1
for i in range(1, int(input()) + 1):
  num = (num * i) % (10**9 + 7)
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
d = math.factorial(N)

k, ans = 1, 1
for i in range(1, N + 1):
    while d % i == 0:
        d //= i
        k += 1
    ans *= k
    k = 1
print(ans % (10**9 + 7))


Fixed submission:
import math
N = int(input())
d = math.factorial(N)

k, ans = 1, 1
for i in range(2, N + 1):
    while d % i == 0:
        d //= i
        k += 1
    ans *= k
    k = 1
print(ans % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
X = input()
rep = X.replace("ST", "")
while X != rep:
    X = rep
    rep = X.replace("ST", "")
print(len(X))

Fixed submission:
X = input()
stack = []
for s in X:
    if s == "S":
        stack.append(s)
    elif s == "T":
        if len(stack) == 0 or stack[-1] == "T":
            stack.append(s)
        else:
            stack.pop(-1)
print(len(stack))

Buggy python submission (verdict: Time Limit Exceeded):
X = input()
X_length = len(X)
change = True
while change:
    X = X.replace("ST", "", 1)
    change = len(X) != X_length
    X_length = len(X)
print(X_length)


Fixed submission:
X = input()
stack = []
for s in X:
    if s == "S":
        stack.append(s)
    elif s == "T":
        if len(stack) == 0 or stack[-1] == "T":
            stack.append(s)
        else:
            stack.pop(-1)
print(len(stack))
Buggy python submission (verdict: Runtime Error):
//https://atcoder.jp/contests/abc044/tasks/abc044_b
//044-BをC++でといてみる
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

int main(void){
    string w; cin >> w;
    map<char,int> mp;
    int i;
    for (i = 0; i < w.size(); i++){
        mp[w[i]] += 1;
    }

    for (pair<char,int> x :mp){
        if (x.second%2 != 0){
            cout << "No" << endl; return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Fixed submission:
w = list(input())
counter = 0
for _ in w:
    if w.count(_)%2 == 0:
        counter += 1
    else:
        print("No")
        break
    if counter == len(w):
        print("Yes")
Buggy python submission (verdict: Runtime Error):
s = input()
ans = []
for c in s:
    if c == "0":
        ans.append("0")
    if c == "1":
        ans.append("1")
    if c == "B":
        ans.pop(-1)
print("".join(ans))


Fixed submission:
s = list(input())
ans = []
for char in s:
    if char == "B":
        if ans:
            ans.pop(-1)
        else:
            pass
    else:
        ans.append(char)

print("".join(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
Llist = sorted(list(map(int, input().split())))[::-1]
ans = 0
for i in range(0, 2*N):
    ans += min(Llist[i], Llist[i+1])
print(ans)


Fixed submission:
N = int(input())
Llist = sorted(list(map(int, input().split())))[::-1]
ans = 0
for i in range(0, 2*N, 2):
    ans += min(Llist[i], Llist[i+1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
v = 1
for i in range(n):
  v *= a[i]
if v > 1000000000000000000:
  print(-1)
else:
  print(v)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  print(0)
  exit()
v = 1
for i in range(n):
  v *= a[i]
  if v>1000000000000000000:
    print(-1)
    exit()
if v > 1000000000000000000:
  print(-1)
else:
  print(v)
Buggy python submission (verdict: Runtime Error):
a[]=list(map(int,input().split()))
n=min(a[1],a[3])-max(a[0],a[2])
print(n if n>0 else 0)

Fixed submission:
a=list(map(int,input().split()))
n=min(a[1],a[3])-max(a[0],a[2])
print(n if n>0 else 0)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a % b)   

n=int(input())
p=1
for i in range(n):
  m=int(input())
  p=p*m/gcd(p,m)
print(p)

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

n=int(input())
p=1
for i in range(n):
  m=int(input())
  p=p*m//gcd(p,m)
print(int(p))