Harryxun/stf_run huggingface dataset:
import sys
import numpy as np

todo = [[], []]

input = sys.stdin.readline
H, W = map(int, input().split())
field = np.zeros((H,W), dtype=int)

for i in range(H):
    for j, c in enumerate(input()):
        if c == '#':
            field[(i,j)] = 1
            todo[0].append((i,j))

def findAdjacent(loc):
    x, y = loc[0], loc[1]
    for dx, dy in [(-1,0), (1,0), (0,-1), (0,1)]:
        if -1 < x+dx < W and -1 < y+dy < H:
            yield (x+dx, y+dy)

def colorAdjacent(loc, nxt):
    for l in findAdjacent(loc):
        if field[l] == 0:
            todo[nxt].append(l)
            field[l] += 1

ans = 0
while todo[0] or todo[1]:
    cur = ans % 2
    while todo[cur]:
        colorAdjacent(todo[cur].pop(), (cur+1)%2)
    ans += 1

print(ans-1)


### FIXED CODE ###

import sys
import numpy as np

#%% Smart Solution

input = sys.stdin.readline

H, W = map(int, input().split())

status = np.full((H, W), H*W, dtype=int)
for i in range(H):
    for j, c in enumerate(input()):
        if c == "#":
            status[i,j] = 0


for h in range(1, H):
    status[h, :] = np.minimum(status[h, :], status[h-1, :] + 1)
for h in range(0, H-1)[::-1]:
    status[h, :] = np.minimum(status[h, :], status[h+1, :] + 1)
for w in range(1, W):
    status[:, w] = np.minimum(status[:, w], status[:, w-1] + 1)
for w in range(0, W-1)[::-1]:
    status[:, w] = np.minimum(status[:, w], status[:, w+1] + 1)

print(np.max(status))
ans = True
for i in A:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
            continue
        else:
            ans = False
print("APPROVED" if ans==True else "DENIED")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = True
for i in A:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
            continue
        else:
            ans = False
print("APPROVED" if ans==True else "DENIED")
N = int(input())
arr = list(map(int, input().split()))
while len(arr)>1:
    arr=sorted(arr)
    v1 = arr.pop(0)
    v2 = arr.pop(0)
    arr.append((v1+v2)/2)
print(arr[0])

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print('red')
import sys

n = int(sys.stdin().strip())

result = str(int(n * (n + 1) / 2))

sys.stdout()

### FIXED CODE ###

from sys import stdin, stdout

n = int(stdin.read().strip())

result = str(int(n * (n + 1) / 2))

stdout.write(result)
if __name__ == '__main__':
    N, M, K = map(int, input().split()) 
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    acc_A = []
    acc_B = []
    acc_A.append(0)
    acc_B.append(0)
    
    sum_a = 0
    sum_b = 0

    for a in A:
        sum_a += a
        acc_A.append(sum_a)

    for b in B:
        sum_b += b
        acc_B.append(sum_b)

    large_ar = []
    small_ar = []

    if N > M:
        large_ar = acc_A
        small_ar = acc_B
    else:
        large_ar = acc_B
        small_ar = acc_A
    
    ans = 0
    for i in range(len(large_ar)):
        for j in range(ans - i, len(small_ar)):
            if large_ar[i] + small_ar[j] <= K:
                ans = max(ans, i+j)
    
    print(ans)

### FIXED CODE ###

if __name__ == '__main__':
    N, M, K = map(int, input().split()) 
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    acc_A = []
    acc_B = []
    acc_A.append(0)
    acc_B.append(0)
    
    sum_a = 0
    sum_b = 0

    for a in A:
        sum_a += a
        acc_A.append(sum_a)

    for b in B:
        sum_b += b
        acc_B.append(sum_b)

    large_ar = []
    small_ar = []

    if N > M:
        large_ar = acc_A
        small_ar = acc_B
    else:
        large_ar = acc_B
        small_ar = acc_A
    
    ans = 0
    for i in range(len(small_ar)):
        for j in range(ans-i+1, len(large_ar)):
            if large_ar[j] + small_ar[i] <= K:
                ans = max(ans, i+j)
            else: break
    print(ans)
n = int(input())
m_list = []
for i in range(n):
  X, L = map(int, input().split())
  m_list.append([X-L,X+L])

m_list = sorted(m_list)
  
def MachineArrangementCheck():
  length = len(Machine_list)
  # 配列の上限エラー対策
  for i in range(length):
    if i != length - 1:      
      # m1の上限とm２の下限が接するかを確認
      if (m_list[i][1] - m_list[i+1][0]) < 0:
        del m_list[i+1]
        return False
  return True

while MachineArrangementCheck() == False:
  continue
  
print(len(m_list))

### FIXED CODE ###

n = int(input())
m_list = []
for i in range(n):
    x,l = map(int, input().split())
    m_list.append([x-l, x+l])

m_list = sorted(m_list,key= lambda x:x[1])

result = 0
cur_pos = -1000000000

for min,max in m_list:
    if cur_pos <= min:
        result += 1
        cur_pos = max
print(result)
import sys

sys.setrecursionlimit(10000000)

class tree:
    def __init__(self):
        self.baby_list=[]
        self.counter=0
    
    def add_value(self):
        for i in self.baby_list:
            hoge[i].counter += self.counter
            hoge[i].add_value()

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


hoge={}

for i in range(1,N+1):
    hoge[i] = tree()
    
for i in range(N-1):
    a,b=input().split()
    hoge[a].baby_list.append(b)

for i in range(Q):
    root, value = input().split()
    hoge[root].counter+=int(value)

hoge[1].add_value()
output = ""
for t in hoge:
    output+=str(hoge[t].counter)+" "

print(output[:-1])

### FIXED CODE ###

import sys

sys.setrecursionlimit(10000000)


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

data={i+1:0 for i in range(N)}

# for i in range(N-1):
#     a,b=list(map(int, input().split() ))
#     hoge[a].baby_list.append(b)

relate = [list(map(int, input().split() )) for i in range(N-1)]
relate.sort(key=lambda x :x[0])
    
for i in range(Q):
    root, value = list(map(int, input().split() ))
    data[root]+=value

for a,b in relate:
    data[b]+=data[a]

print(" ".join(list(map(str,list(data.values())))))
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        m,n = LI()
        if n == 0 and m == 0:
            break

        l = min(7368792,n*20)
        a = [None] * l
        j = m
        for i in range(n):
            while a[j]:
                j += 1
            for k in range(j,l,j):
                a[k] = True
        while a[j]:
            j += 1

        print(j)

    return


main()




### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Prime():
    def __init__(self, m):
        self.M = m + 1
        self.A = a = [True] * self.M
        a[0] = a[1] = 0
        self.T = t = []
        sq = int(math.sqrt(self.M))
        q = 0
        for i in range(2, sq + 1):
            if not a[i]:
                a[i] = q
                continue
            t.append(i)
            a[i] = q
            q += 1
            for j in range(i*i,m,i):
                a[j] = False

        for i in range(sq + 1, self.M):
            if a[i]:
                a[i] = q
                q += 1
                t.append(i)
            else:
                a[i] = q

    def is_prime(self, n):
        return self.A[n]


def main():
    rr = []

    M = 7368792
    pr = Prime(M)

    def f(m, n):
        nn = n
        g = [None] * (m*m)
        for i in range(m, m*m):
            if not g[i]:
                if n == 0:
                    return i
                n -= 1
                for j in range(i, m*m, i):
                    g[j] = 1
        d = pr.A[m*m]
        return pr.T[d+n]

    while True:
        m,n = LI()
        if m == 0 and n == 0:
            break
        rr.append(f(m,n))

    return '\n'.join(map(str,rr))




print(main())
from math import ceil

N, X, T = map(int,input().split())

print(ceil(N / X)* T)from math import ceil

N, X, T = map(int,input().split())

print(ceil(N / X)* T)

### FIXED CODE ###

from math import ceil

N, X, T = map(int,input().split())

print(ceil(N / X)* T)
sl = list(input())
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
if len(sl) != 26:
    for s in ascii_lowercase:
        if s not in sl:
            sl.append(s)
            break
    print("".join(sl))
elif "".join(sl) == "zyxwvutsrqponmlkjihgfedcba":
    print("-1")
else:
    ansl = []
    for s, t in zip(sl, ascii_lowercase):
        if s != t:
            ansl[-1] = t
            print("".join(ansl))
            break
        ansl.append(t)

### FIXED CODE ###

S=input()
if S=='zyxwvutsrqponmlkjihgfedcba':
  print(-1)
  exit()
alp='abcdefghijklmnopqrstuvwxyz'
N=len(S)
if N<26:
  T=S+alp
  i=0
  while T.index(alp[i])<N:
    i+=1
  print(S+alp[i])
  exit()
  
i=-1
nums=[alp.index(S[i])]
while max(nums)==nums[-1]:
  i-=1
  nums.append(alp.index(S[i]))

out=S[:-len(nums)]
tmp=26
for i in nums[:-1]:
  if i>nums[-1] and tmp>i:
    tmp=i
    
print(out+alp[tmp])
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range (k, n);
  if a[i] > a[i-k]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
  if a[i] > a[i-k]:
    print("Yes")
  else:
    print("No")
import sys,collections,math,random;sys.setrecursionlimit(10**7)
from math import factorial
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 10**9+7
def comb(n, r):
    return factorial(n)  // (factorial(n - r) * factorial(r)) % MOD
    
N,K = Is()
for i in range(1,K+1):
#    print(K-1,i-1,N-K+1,i)
#    print(comb(K-1,i),comb(i+2,N-K-i))
    print((comb(K-1,i-1) * comb(N-K+1,i)) % MOD)


### FIXED CODE ###

import sys,collections,math,random;sys.setrecursionlimit(10**7)
from math import factorial
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 10**9+7
def comb(n, r):
    return factorial(n)  // (factorial(n - r) * factorial(r)) % MOD
    
N,K = Is()
for i in range(1,K+1):
#    print(i,K-1,i-1,N-K+1,i)
    if N-K+1 < i:
        print(0)
    else:
        print((comb(K-1,i-1) * comb(N-K+1,i)) % MOD)
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)
        e[b].append(a)

    table = [True for _ in range(n)]
    perm = [1]
    for i in range(k - 2, -1, -1):
        perm.append(perm[-1] * i % MOD)

    table[0] = False
    que = collections.deque(e[0])
    ans = k
    for i in range(len(e[0])):
        table[e[0][i]] = False
        ans *= k - i - 1
        ans %= MOD

    while len(que) > 0:
        for _ in range(len(que)):
            q = que.popleft()
            cnt = 0
            for i in range(len(e[q])):
                tmp = e[q][i]
                if table[tmp]:
                    table[tmp] = False
                    cnt += 1
                    que.appendleft(tmp)
            ans *= perm[min(len(perm), cnt)]
            ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)
        e[b].append(a)

    table = [True for _ in range(n)]
    perm = [1]
    for i in range(k - 2, -1, -1):
        perm.append(perm[-1] * i % MOD)

    table[0] = False
    que = collections.deque(e[0])
    ans = k
    for i in range(len(e[0])):
        table[e[0][i]] = False
        ans *= k - i - 1
        ans %= MOD

    while len(que) > 0:
        for _ in range(len(que)):
            q = que.popleft()
            cnt = 0
            for i in range(len(e[q])):
                tmp = e[q][i]
                if table[tmp]:
                    table[tmp] = False
                    cnt += 1
                    que.appendleft(tmp)
            ans *= perm[min(len(perm) - 1, cnt)]
            ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()
import bisect
import collections
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
A = collections.deque(A)
for i in range(M):
  B = A.pop()
  bisect.insort_left(A,B//2)
print(sum(A))
  

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(lambda x: int(x)*(-1),input().split()))
import heapq
heapq.heapify(A)
for i in range(M):
  B = heapq.heappop(A)
  heapq.heappush(A,-1*((-B)//2))
print(-sum(A))
i = list(map(int, input().split()))
print(max([i[0]+i[1], i[0]-i[1], i[0] * i[1]]))

### FIXED CODE ###

i = list(map(int, input().split()))
print(max([i[0]+i[1], i[0]-i[1], i[0] * i[1]]))
n = input()
n = int(n[1:])

if n == 0:
    print(0)
else:
    print(1000-n)

### FIXED CODE ###

n = int(input())
n = n % 1000
print(1000 - n if n != 0 else 0)
S = input()
S = list(S)
S_no_x = []
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True
inds = []
for i,c in enumerate(S):
    if c != "x":
        S_no_x.append(c)
        inds.append(i)
if not is_kaibun(S_no_x):
    print(-1)
else:
    l = len(S_no_x)



    mae = ""
    usiro = ""
    if l % 2 == 0:
        mae_ind = inds[l // 2 - 1]
        usiro_ind = inds[l // 2]
        mae = S[:mae_ind +1]
        usiro = S[usiro_ind :]
    else:
        center = inds[l // 2]
        mae = S[:center]
        usiro = S[center +1:]

    usiro.reverse()
    usiro_x = []
    mae_x = []
    cot = 0
    usiro.append("@")
    for c in usiro:
        if c == "x":
            cot += 1
        else:
            usiro_x.append(cot)
            cot = 0
    cot = 0
    mae.append("@")
    for c in mae:
        if c == "x":
            cot += 1
        else:
            mae_x.append(cot)
            cot = 0
    ans = 0
    for a,b in zip(mae_x,usiro_x):
        ans += abs(a-b)
    print(ans)





### FIXED CODE ###

S = input()
S = list(S)
S_no_x = []
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True
inds = []
for i,c in enumerate(S):
    if c != "x":
        S_no_x.append(c)
        inds.append(i)
if not is_kaibun(S_no_x):
    print(-1)
else:
    l = len(S_no_x)

    if l == 0:
        print(0)
    else:
        mae = ""
        usiro = ""
        if l % 2 == 0:
            mae_ind = inds[l // 2 - 1]
            usiro_ind = inds[l // 2]
            mae = S[:mae_ind +1]
            usiro = S[usiro_ind :]
        else:
            center = inds[l // 2]
            mae = S[:center]
            usiro = S[center +1:]

        usiro.reverse()
        usiro_x = []
        mae_x = []
        cot = 0
        usiro.append("@")
        for c in usiro:
            if c == "x":
                cot += 1
            else:
                usiro_x.append(cot)
                cot = 0
        cot = 0
        mae.append("@")
        for c in mae:
            if c == "x":
                cot += 1
            else:
                mae_x.append(cot)
                cot = 0
        ans = 0
        for a,b in zip(mae_x,usiro_x):
            ans += abs(a-b)
        print(ans)
import sys

n,k=map(int,input().split())
a=list(map(int,input().split()))

if k==0:
    print(max(a))
    sys.exit()

def rf(mm):
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(60):
#    print(ii,um,lm,m)
    if rf(m)>(n+k):
        lm=m
        m=(um+lm)//2
    elif rf(m)<(n+k):
        um=m
        m=(lm+um)//2
    else:
        um=m-1
        m=(lm+um)//2
    if rf(m)==(n+k) and um-lm<5:
        break

for mi in range(m,m-10,-1):
#    print("mi",mi)
    if rf(mi)==(n+k) and rf(mi-1)>(n+k):
        break

print(mi)



### FIXED CODE ###

import sys

n,k=map(int,input().split())
a=list(map(int,input().split()))

if k==0:
    print(max(a))
    sys.exit()

def rf(mm):
    if mm==0:
        mm=1
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(60):
    if m==1:
        break
    if rf(m)<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rf(m)>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rf(m)<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1
#    if rf(m)==(n+k) and um-lm<5:

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break

print(mi)
N = int(input())
A = sorted(list(map(int, input().split())))
Q = int(input())
M = list(map(int, input().split()))

def exhastive_search(target, head, sum):
    for i in range(head, N):
        sum += A[i]
        if target == sum:
            return True
        elif target > sum:
            if exhastive_search(target, i+1, sum):
                return True
            sum -= A[i]
        else:
            return False
    return False


for target in M:
    sum = 0
    result = "no"
    for i in range(N):
        if target < A[i]:
            break
        else:
            if exhastive_search(target, i, sum):
                result = "yes"
                break
    print(result)


### FIXED CODE ###

def solve(dp, a, i, m):
  if m in dp[i]:
    return dp[i][m]

  if m == 0:
    dp[i][m] = True
  elif i >= len(a):
    dp[i][m] = False
  elif solve(dp, a, i+1, m):
    dp[i][m] = True
  elif solve(dp, a, i+1, m-a[i]):
    dp[i][m] = True
  else:
    dp[i][m] = False

  return dp[i][m]

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))

dp = {}
for i in range(N+1):
  dp[i] = {}

for m in M:
  if solve(dp, A, 0, m):
    print('yes')
  else:
    print('no')
n=int(input())
r=[]
a=[]
for i in range(n):
  b,c=(int(j) for j in input().split())
  for k in range(i):
    d=a[k][0]-b
    e=a[k][1]-c
    if d<0:
      d=-d
      e=-e
    r.append([d,e])
  a.append([b,c])
for j in range(n):
  for i in range(n):
    if a[i][0]>a[i+1][0]:
      w=a[i]
      a[i]=a[i+1]
      a[i+1]=w
    elif a[i][1]>a[i+1][1]:
      w=a[i]
      a[i]=a[i+1]
      a[i+1]=w
sortsecond = lambda val: val[1]
a.sort(key=sortsecond)
r.sort()
if n>1:
  p=r[0]
x=1
z=0
t=0
q=[]
for i in range(len(r)-1):
  if r[i]==r[i+1]:
    x=x+1
    if x>z:
      p=r[i]
      z=x
  else:
    x=1
if n==1:
  print(1)
else:
  for i in range(n):
    if a[i] not in q:
      t=t+1
    q.append([a[i][0]+p[0],a[i][1]+p[1]])
    q.append([a[i][0]-p[0],a[i][1]-p[1]])
  print(t)


### FIXED CODE ###

n=int(input())
r=[]
a=[]
for i in range(n):
  b,c=(int(j) for j in input().split())
  for k in range(i):
    d=a[k][0]-b
    e=a[k][1]-c
    if d<0:
      d=-d
      e=-e
    elif d==0:
      if e<0:
        e=-e
    r.append([d,e])
  a.append([b,c])
r.sort()
if n>1:
  p=r[0]
x=1
z=0
t=0
q=[]
for i in range(len(r)-1):
  if r[i]==r[i+1]:
    x=x+1
    if x>z:
      p=r[i]
      z=x
  else:
    x=1
for j in range(n-1):
  for i in range(n-1):
    if a[i][0]>a[i+1][0]:
      w=a[i]
      a[i]=a[i+1]
      a[i+1]=w
    elif a[i][0]==a[i+1][0]:
      if (a[i][1]-a[i+1][1])*p[1]>0:
        w=a[i]
        a[i]=a[i+1]
        a[i+1]=w
if n==1:
  print(1)
else:
  for i in range(n):
    if a[i] not in q:
      t=t+1
    q.append([a[i][0]+p[0],a[i][1]+p[1]])
  print(t)
#!/usr/bin/env python3
#APC1 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a % b == 0:
  print(-1)
tmp = 1
while 1:
  if tmp % a == 0 and tmp % != 0:
    print(tmp)
    quit()
  tmp += 1
  


### FIXED CODE ###

#!/usr/bin/env python3
#APC1 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a % b == 0:
  print(-1)
else:
  print(a)
(a, b, c) = input().rstrip().split()
a = int(a)
b = int(b)
c = int(c)

if a < b < c;
    print('Yes')
else;
    print('No')

### FIXED CODE ###

(a, b, c) = input().rstrip().split()
a = int(a)
b = int(b)
c = int(c)

if a < b < c:
    print('Yes')
else:
    print('No')
#配るDP
n,k=map(int,input().split())
l=[0]*k
r=[0]*k
for j in range(k):
  l[j],r[j] = map(int,input().split())
p=998244353
dp=[0]*(n+100)
dp[1]=1
dp[2]=-1
for i in range(1,n+1):
  dp[i] += dp[i-1]
  dp[i] %= p
  
  for lj,rj in zip(l,r):
    dp[i+lj] += dp[i]
    dp[i+lj] %= p
    dp[i+rj+1] -= dp[i]
    dp[i+rj+1] %= p
print(dp[n])

### FIXED CODE ###

#配るDP
n,k=map(int,input().split())
l=[0]*k
r=[0]*k
for j in range(k):
  l[j],r[j] = map(int,input().split())
p=998244353
dp=[0]*(n+max(r)+100)
dp[1]=1
dp[2]=-1
for i in range(1,n+1):
  dp[i] += dp[i-1]
  dp[i] %= p
  
  for lj,rj in zip(l,r):
    dp[i+lj] += dp[i]
    dp[i+lj] %= p
    dp[i+rj+1] -= dp[i]
    dp[i+rj+1] %= p
print(dp[n])