Harryxun/stf_run huggingface dataset:
isExist = [0]*2001 
n = int( input() )
q = int( input() )
for i in range( 0, q ):
	if 1 == isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )

### FIXED CODE ###

def solve( p, t ):
	global isExist, n, A
	isExist[ t ] = True
	if p < n:
		solve( p+1, t-A[p] )
		solve( p+1, t )
	else:
		return

isExist = [False]*2001 
n = int( input() )
A = [ int( val ) for val in input().rstrip().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().rstrip().split( ' ' ) ]
s = sum( A )
solve( 0, s )
for i in range( 0, q ):
	if isExist[ M[i] ]:
		print( "yes" )
	else:
		print( "no" )
A,B =map(int,input().split())
if A-B == 0:
    print(A"=="B)
elif A >= B:
    print(A">"B)
else:
    print(A"<"B)


### FIXED CODE ###

A,B =map(int,input().split())
if A-B == 0:
    print("a == b")
elif A >= B:
    print("a > b")
else:
    print("a < b")
n=int(input())
rowdata=[int(i) for i in input().split()]
rowdata.sort()
print(rowdata)

#nが偶数の時
if n%2==0:
    check=[]
    for i in range(1,n,2):
        check.append(i)
        check.append(i)
    if check==rowdata:
        print(int(2**(n/2)))
    else:
        print(0)
else:
    check=[]
    if n==1:
        check=[0]
    else:
        for i in range(0,n,2):
            if i==0:
                check.append(i)
            else:
                check.append(i)
                check.append(i)
    if check==rowdata:
        print(int(2**((n-1)/2)))
    else:
        print(0)

### FIXED CODE ###

n=int(input())

#データを並び替える
rowdata=[int(i) for i in input().split()]
rowdata.sort()

#nが偶数の時
if n%2==0:
    check=[]
    a=1
    for i in range(1,n,2):
        check.append(i)
        check.append(i)
    if check==rowdata:
        for i in range(int(n/2)):
            a*=2
            a=a%1000000007
        print(a)
    else:
        print(0)
        
#nが奇数の時
else:
    check=[]
    a=1
    if n==1:
        check=[0]
    else:
        for i in range(0,n,2):
            if i==0:
                check.append(i)
            else:
                check.append(i)
                check.append(i)
    if check==rowdata:
        for i in range(int((n-1)/2)):
            a*=2
            a=a%1000000007
        print(a)
    else:
        print(0)
h,w = map(int,input().split())
s=[]
for _ in range(h):
  s.append(str(input()))
for i in range(h):
  for j in range(w):
    flag=False
    if s[i][j]!="#":
      continue
    for k in [-1,1]:
      if 0<=i+k<h:
        if s[i+k][j]=="#":
          flag=True
      if 0<=j+k<h:
        if s[i][j+k]=="#":
          flag=True
    if not flag:
      print("No")
      exit()
print("Yes")

### FIXED CODE ###

h,w = map(int,input().split())
s=[]
for _ in range(h):
  s.append(str(input()))
for i in range(h):
  for j in range(w):
    flag=False
    if s[i][j]!="#":
      continue
    for k in [-1,1]:
      if 0<=i+k<h:
        if s[i+k][j]=="#":
          flag=True
      if 0<=j+k<w:
        if s[i][j+k]=="#":
          flag=True
    if not flag:
      print("No")
      exit()
print("Yes")
import numpy as np
N, K=map(int,input().split())

A2 = np.zeros(N)
A = list(map(int,input().split()))
A = list(map(lambda x: x -1 , A))
current_town = 0
 
 
 
i=0
while i<K:
    current_town = A[current_town]
    if  A2[current_town] != 0:
        cycle = i - A2[current_town] 
        i = K - ((K-i) % cycle)
        i=i+1
        break
    else:
        A2[current_town] = i
        i=i+1

while i<K:
    current_town = A[current_town]
    t=i+1
    i=t

print(current_town+1)

### FIXED CODE ###

str1 = input()
str2 = input()

if len(str1) + 1 == len(str2) and str1 == str2[:-1]:
    print('Yes')
else:
    print('No')
s = input()
while len(s)!=0:
    s.pop()
    if len(s)%2==0 and s[:len(s)//2]==s[len(s)//2:]:
        print(len(s))
        exit()

### FIXED CODE ###

s = input()
l = len(s)
h = l//2
if l%2==0:
    for i in range(1,h):
        if s[0:h-i] == s[h-i:-2*i]:
            print(len(s[:-2*i]))
            break
else:
    for i in range(1,h):
        if s[0:h-i+1] == s[h-i+1:-2*i+1]:
            print(len(s[:-2*i+1]))
            break
n,m=map(int,input().split())
L=0
R=n
for i in range(m):
    l,r=map(int,input().split())
    if l>L:
        L=l
    if r<R:
        R=r
if R-L<0:
    print(0)
else:
    print(R-L)

### FIXED CODE ###

n,m=map(int,input().split())
s=[]
for i in range(n):
    a,b=map(int,input().split())
    #n店舗、a値段、b本数
    s.append([a,b])
s.sort()
ans=0
i=0
while m-s[i][1]>0:
    m-=s[i][1]
    ans+=s[i][0]*s[i][1] #値段
    i+=1
print(ans+s[i][0]*m)
s = input()
s = s.split('S')
print(max(len(s)))

### FIXED CODE ###

s = input()
S = s.split('S')

print(max([len(i) for i in S]))
N = str(input())

s = list(map(int,N))

S = sum(s)

if S % 9 = 0:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

N = str(input())
M = list(map(int, N))
S = sum(M)

if S % 9 == 0:
  print("Yes")
else:
  print("No")
import sys

def gcd(m, n):
    r = m % n
    if r == 0:
        return n
    else:
        return gcd(n, r)

lines = sys.stdin.readlines()
for line in lines:
    a, b = map(int, line.split())
    m = max(a, b)
    n = min(a, b)
    print(gcd(m, n) m * n // gcd(m, n))

### FIXED CODE ###

import sys

def gcd(m, n):
    r = m % n
    if r == 0:
        return n
    else:
        return gcd(n, r)

lines = sys.stdin.readlines()
for line in lines:
    a, b = map(int, line.split())
    m = max(a, b)
    n = min(a, b)
    print(gcd(m, n), m * n // gcd(m, n))
import math
a,b = map(int,input().split())
if a % b == 0:
    print("-1")
else:
    c = math.gcd(a,b)
    print(c * a)

### FIXED CODE ###

import math
a,b = map(int,input().split())
if a % b == 0:
    print("-1")
else:
    k = 1
    while ( a * k ) % b == 0:
        k += 1
    print(a * k)
N, K, X, Y = map(int, input().split())
 
if N > K:
  print(K*X + (N-K)*Y)
else:
  print(K*X)


### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())
 
if N > K:
  print(K*X + (N-K)*Y)
else:
  print(N*X)
import numpy as np
#n,k=map(int,input().split())
n=int(input())
abc=[]
for _ in range(n):
      abc.append(list(map(int,input().split())))
dp=np.zeros(n+1)
# dp[i]:i日目までの最大。dp[0]=0。求めるのはdp[n]
dp[1]=max(abc[0])
op1=[i for i in range(3) if abc[0][i]!=dp[1]]
if len(op1)<2:
      op1=[0,1,2]
op2=[0,1,2]
for i in range(2,n+1):
      m=max([abc[i-1][j] for j in op1])
      m1=dp[i-1]+m
      op=[j for j in range(3) if abc[i-1][j]!=m]
      if len(op)<2:
            op=[0,1,2]
      opt=[j for j in range(3) if abc[i-1][j]!=max(abc[i-1])]
      if len(op)<2:
            opt=[0,1,2]
      m2=dp[i-2]+max(abc[i-1])+max([abc[i-2][j] for j in set(op2).intersection(set(opt))])
      dp[i]=max(m1,m2)
      op2=op1
      op1=op

print(int(dp[-1]))

### FIXED CODE ###

import numpy as np
n=int(input())
abc=[]
for _ in range(n):
      abc.append(list(map(int,input().split())))
dp=np.zeros((n+1,3),np.int64)
# dp[i][0]:i日目でaをとった時の最大。dp[0]=[0,0,0]。求めるのはmax(dp[n])
dp[1]=np.array(abc[0])
for i in range(2,n+1):
      dp[i][0]=abc[i-1][0]+max(dp[i-1][1],dp[i-1][2])
      dp[i][1]=abc[i-1][1]+max(dp[i-1][0],dp[i-1][2])
      dp[i][2]=abc[i-1][2]+max(dp[i-1][0],dp[i-1][1])

print(int(np.max(dp[-1])))
a, b = map(int, input().split())
n = 1
e = a
if b = 1:
  print(0)
  quit()
while n > 0:
  if e >= b:
    print(n)
    n = 0
  else:
    e += a-1
    n += 1

### FIXED CODE ###

a, b = map(int, input().split())
n = 1
e = a
if b == 1:
  print(0)
  quit()
while n > 0:
  if e >= b:
    print(n)
    n = 0
  else:
    e += a-1
    n += 1
menu = [int(input()) for i in range(5)]
def kuriage(n):
    if n %10 == 0:
        return 0
    else:
        return 10-(n %10)
ans = 0
mini = 10
for i in range(5):
    if menu[i] %10 < mini and menu[i]%10 !=0:
        mini = menu[i] %10
        k = i
for i in range(5):
    if i == k:
        menu[i], menu[-1] = menu[-1], menu[i]

for i in range(5):
    if i != 4:
        ans += menu[i] + kuriage(menu[i])
    else:
        ans += menu[-1]
        print(ans)


### FIXED CODE ###

menu = [int(input()) for i in range(5)]
def kuriage(n):
    if n %10 == 0:
        return 0
    else:
        return 10-(n %10)
ans = 0
mini = 10
k = 5
for i in range(5):
    if menu[i] %10 < mini and menu[i]%10 !=0:
        mini = menu[i] %10
        k = i
for i in range(5):
    if i == k:
        menu[i], menu[-1] = menu[-1], menu[i]

for i in range(5):
    if i != 4:
        ans += menu[i] + kuriage(menu[i])
    else:
        ans += menu[-1]
        print(ans)
import math
a = int(input())
print((a * 2 ) // math.gcd(a, 2))

### FIXED CODE ###

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

n = int(input())
print((n * 2) // gcd(n, 2))
num = int(input())
given = input()
new = given.split()
x = 0
max = 0
for i in range(num):
  if new[i] == "D":
    x -= 1
  elif new[i] == "I":
    x += 1
  if max < x:
    max = x
print(max)

### FIXED CODE ###

num = int(input())
new = input()

x = 0
m = 0
for i in range(num):
  if new[i] == "D":
    x -= 1
  if new[i] == "I":
    x += 1
  if m < x:
    m = x
print(m)
import copy

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

A.sort()


def div_by_min(a: list, start: int):
    dic = {k: 0 for k in a}
    for i in range(start+1, len(a)):
        if not dic:
            break
        if a[i] % a[start] == 0:
            del dic[a[i]]
    ans_list = list(dic.keys())
    return ans_list


Start = 0
prev_len = 1000000
tmp = A

while True:
    if Start >= len(tmp):
        break
    else:
        tmp = div_by_min(tmp, Start)
        if prev_len == len(tmp):
            Start += 1
        else:
            prev_len = len(tmp)
            Start = 0

print(len(tmp))


### FIXED CODE ###

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

max_A = A[-1] + 1
ans = [0] * max_A

for i in A:
    ans[i] += 1
    if ans[i] == 1:
        for j in range(i*2, max_A, i):
            ans[j] = 2

print(ans.count(1))
n=int(input())
dp=[0]*(n+1)
dp[0]=1
for i in range(n+1):
  for j in range(100,106):
    dp[i]=max(dp[i],dp[i-j])
if dp[n]==1:
  print(1)
else:
  print(0)

### FIXED CODE ###

n=int(input())
cnt=n//100
if n%100<=cnt*5:
  print(1)
else:
  print(0)
a,b,x = map(int,input().split())
mi = 0
ma = 10**9+1
while ma-mi>1:
  me = int((mi+ma)/2)
  if a*me+b*len(str(me))<=x:
    mi = me
  else:
    ma = me
print(mi)

### FIXED CODE ###

a = input()
if a == "SAT":
		print(1)
		
elif a == "FRI" :
		print(2)
		
elif a == "THU" :
		print(3)
			
elif a == "WED" :
		print(4)		
		
elif a == "TUE" :
		print(5)		
	
elif a == "MON" :
		print(6)

else :
		print(7)
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
m=1000000
for i in range(N-K+1):
    m=min(m,max(h[i:K+1])-min(h[i:K+1]))
print(m)

### FIXED CODE ###

N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
m=100000000000000
for i in range(N-K+1):
    m=min(m,h[i+K-1]-h[i])
print(m)
n,m = map(int, input().split())
lmax,rmin=0,n+1
for i in range(m):
  l,r=map(int, input().split()
  lmax=max(l,lmax)
  rmin=min(r,rmin)
print(max(0,lmax-rmin+1)

### FIXED CODE ###

n,m = map(int, input().split())
lmax,rmin=0,n+1
for i in range(m):
  l,r=map(int, input().split())
  lmax=max(l,lmax)
  rmin=min(r,rmin)
print(max(0,rmin-lmax+1))
import sys
input = sys.stdin.readline


"""
if __name__ == '__main__':
    main()
"""
n, q = map(int, input().split())
#n, q = map(int, "4 3".split())
g = []
if i in range(n):
    g.append([])
#g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    #a, b = map(int, ["1 2", "2 3", "2 4"][i].split())
    g[a-1] += append(b-1)

ans = [0] * n
def dfs(start, point):
    stack = [start]
    while stack:
        x = stack.pop()
        ans[x] += point
        stack += g[x]

for i in range(q):
    p, v = map(int, input().split())
    #p, v = map(int, ["2 10", "1 100", "3 1"][i].split())
    dfs(p-1, v)

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


### FIXED CODE ###

import sys

def main():
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    n, q = map(int, input().split())
    #n, q = map(int, "4 3".split())
    g = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        #a, b = map(int, ["1 2", "2 3", "2 4"][i].split())
        g[a-1].append(b-1)
        g[b-1].append(a-1)


    add = [0] * n
    for i in range(q):
        p, v = map(int, input().split())
        #p, v = map(int, ["2 10", "1 100", "3 1"][i].split())
        #dfs(p-1, v)
        add[p-1] += v

    ans = [0] * n
    def dfs(v,p,value): #p: parent of v
        value += add[v]
        ans[v] = value
        for c in g[v]:
            if c == p: continue
            dfs(c,v,value)
    dfs(0, -1, 0)
    """
    def dfs(start, point):
        stack = [start]
        while stack:
            x = stack.pop()
            ans[x] += point
            stack += g[x]
    """

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

if __name__ == '__main__':
    main()
n, d = map(int,input().split())
cnt = 0
while(n>0):
    p,q = map(int,input().split())
    if d <= int((p**2)+(q**2)):
        cnt++
print(cnt)

### FIXED CODE ###

n,d = map(int, input().split())
ans = 0
for i in range(n):
  x, y = map(int, input().split()) 
  if x*x + y*y <= d*d: # since they have given atmost distance d
    ans+= 1
print(ans)
'''
using distance formula check whether the the distance 
from origin is less than x sq and y sq
'''
N,A,B=map(int, input().split())
print(min(N*A, B)

### FIXED CODE ###

N,A,B=map(int, input().split())
print(min(N*A, B))
import sys
#sys.stdin = open('Transit_Tree_Path.txt', 'r')

def dfs(g, start):
    dist = [-1 for i in xrange(len(g))]
    dist[start] = 0

    q = [start]
    while len(q) > 0:
        u = q.pop()
        for v, l in g[u].iteritems():
            if dist[v] == -1 or dist[u] + l < dist[v]:
                dist[v] = dist[u] + l
                if not v in q:
                    q.append(v)
                    
    return dist

n = int(raw_input())
g = [{} for i in xrange(n+1)]

for i in xrange(n-1):
    u, v, l = map(int, raw_input().split())
    g[u][v] = l
    g[v][u] = l


q, k = map(int, raw_input().split())
dist = dfs(g, k)
for i in xrange(q):
    x, y = map(int, raw_input().split())
    print dist[x] + dist[y]
    
    


### FIXED CODE ###

print "Yes" if (lambda x: x == x[::-1])(raw_input()) else "No"
def sentou(NT, ts):
    N, T = map(int, NT.split())
    before_oshitano = None
    total_s = 0
    for t in map(int, ts.split()):
        if before_oshitano is None:
            before_oshitano = t
            continue
        elif T > (t - before_oshitano):
            total_s += t - before_oshitano
        else:
            total_s += T
        before_oshitano = t
    total_s += T

    print(total_s)


# sentou("9 10", "0 3 5 7 100 110 200 300 311")
sentou(input(), input())


### FIXED CODE ###

def is_shiritori(s):
    before_mozi = None
    for mozi in s.split():
        if before_mozi is None:
            before_mozi = mozi
            continue
        else:
            if mozi[0] is not before_mozi[-1]:
                print("NO")
                return False
            before_mozi = mozi
    print("YES")

ss = input()
is_shiritori(ss)
#coding:UTF-8
work = input().split(" ")
r = int(work[0])
b = int(work[1])
g = int(work[2])
num = r*100 + b*10 +c
if(num % 4 == 0):
  print("YES")
else:
  print("NO")
  

### FIXED CODE ###

#coding:UTF-8
work = input().split(" ")
r = int(work[0])
b = int(work[1])
g = int(work[2])
num = r*100 + b*10 +g
if(num % 4 == 0):
  print("YES")
else:
  print("NO")
n=int(input())
a=[int(x) for x in input().split()]
import math
from functools import reduce,partial
import operator
prod = partial(reduce, operator.mul)
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

### FIXED CODE ###

n=int(input())
a=[int(x) for x in input().split()]
print(sum([(ai-1)%ai for ai in a]))
q = int(input())
l = []
r = []
for i in range(q):
  x,y = map(int,input().split())
  l += [x]
  r += [y]


def is_2017(x):
  if x % 2 == 0:
    return False
  return is_p[x] && is_p[(x+1)//2]

def is_prime(x):
  if x == 1:
    return False
  i = 2
  while i * i <= x:
    if x % i == 0:
      return False
  return True
  
is_p = [False] * 100000
n_2017 = [0] * 100000

for i in range(1, 100000):
  is_p[i] = is_prime(i)

for i in range(1, 100000):
  if is_p[i]:
    n_2017[i] = n_2017[i-1] + 1

for i in range(q):
  print(n_2017[r]-n_2017[l-1])


### FIXED CODE ###

q = int(input())
l = []
r = []
for i in range(q):
    x, y = map(int, input().split())
    l += [x]
    r += [y]


def is_2017(x):
    if x % 2 == 0:
        return False
    return is_p[x] and is_p[(x + 1) // 2]

def is_prime(x):
    if x == 1:
        return False
    i = 2
    while i * i <= x:
        if x % i == 0:
            return False
        i += 1
    return True


is_p = [False] * 100000
n_2017 = [0] * 100000

for i in range(1, 100000):
    is_p[i] = is_prime(i)

for i in range(1, 100000):
    if is_2017(i):
        n_2017[i] = n_2017[i - 1] + 1
    else:
        n_2017[i] = n_2017[i - 1]

for i in range(q):
    print(n_2017[r[i]] - n_2017[l[i] - 1])
memo = {}

def gcd(a, b):
    if (a, b) in memo.keys():
        return memo[(a, b)]
    if b == 0:
        return a
    return gcd(b, a % b)

n = input()
a_list = list(map(int, input().split()))
max_g = 0
for exclude in range(n):
    g = a_list[0] if exclude > 0 else a_list[1]
    for i, a in enumerate(a_list):
        if i == 0 or i == exclude:
            continue
        g_new = gcd(g, a)
        if (g, a) not in memo:
            memo[(g, a)] = g_new
        g = g_new
        if g <= max_g:
            break
    if g > max_g:
        max_g = g
print(max_g)


### FIXED CODE ###

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

n = input()
a_list = map(int, raw_input().split())

gs1 = [None] * n
gs1[0] = a_list[0]
for i in xrange(1, n):
    gs1[i] = gcd(gs1[i - 1], a_list[i])

gs2 = [None] * n
gs2[n - 1] = a_list[n - 1]
for i in reversed(xrange(n - 1)):
    gs2[i] = gcd(gs2[i + 1], a_list[i])

max_g = 0
for exclude in xrange(n):
    if exclude == 0:
        g = gs2[1]
    elif exclude == n - 1:
        g = gs1[n - 2]
    else:
        g = gcd(gs1[exclude - 1], gs2[exclude + 1])
    if g > max_g:
        max_g = g
print(max_g)
#include<iostream>
using namespace std;
int main(){
  int k,x,a,b;
  scanf("%d %d",&k,&x);
  if(-1000000<x-k+1){
    a=x-k+1;
  }
  else{
    a=-1000000;
  }
  if(1000000>x+k-1){
    b=x+k-1;
  }
  else{
    b=1000000;
  }
  for(int i=a;i<b;i++){
  cout<<i<<" ";
  }
  cout<<b<<endl;
}

### FIXED CODE ###

k,x=map(int,input().split())
xmin=max(-1000000,x-k+1)
xmax=min(1000000,x+k-1)
for i in range(xmin,xmax+1):
  print(i,end=" ")
#coding:utf-8
a, b, k = map(int, input().split())

for i in range(0, k):
    if i % 2 == 0:
        b += a / 2
        a /= 2
    else:
        a += b / 2
        b /= 2

print(a, b)


### FIXED CODE ###

#coding:utf-8
s = input()

if len(s) == 2:
  print(s)
elif len(s) == 3:
  print(s[::-1])
N = int(input())
p = list(map(int, input().split()))
sum = [i + 1 + x for i, x in enumerate(p)]
dif = [i + 1 - x for i, x in enumerate(p)]
ans = 0

for i in range(N):
    ans += sum.count(dif[i])

print(ans)

### FIXED CODE ###

S = input()
if S == "ABC":
    print("ARC")
else:
    print("ABC")
x, y = map(int, input().split())
d = {'A':10, 'B':11, 'C':12, 'D':13, 'E':14, 'F':15}
if d[x] < d[y]:
  print('<')
if d[x] = d[y]:
  print('=')
else:
  print('>')


### FIXED CODE ###

x, y = input().split()
d = {'A':10, 'B':11, 'C':12, 'D':13, 'E':14, 'F':15}
if d[x] < d[y]:
  print('<')
elif d[x] == d[y]:
  print('=')
else:
  print('>')
N = int(input())
P = [int(i) for i in input().split()]

permulated = len(1 for k, p in enumerate(P, 1) if p != k)
print('YES' if permulated <= 2 else 'NO')  

### FIXED CODE ###

N = int(input())
P = [int(i) for i in input().split()]
p_sorted = list(sorted(P))

if P == p_sorted:
    print('YES')
    exit()
for i in range(N):
    for j in range(i + 1, N):
        P[i], P[j] = P[j], P[i]
        if P == p_sorted:
            print('YES')
            exit()
        P[i], P[j] = P[j], P[i]
print('NO')
N = int(input())
T = []
A = []
for i in range(N):
  a, b = map(int, input().split())
  T.append(a)
  A.append(b)

t = T[0]
a = A[0]

for i in range(1, N):
  if t < T[i] and a < A[i]:
    t = t[i]
    a = A[i]
  else:
    x = int((t + T[i] - 1) / T[i])
    y = int((a + A[i] - 1) / A[i])
    t = T[i] * max(x, y)
    a = A[i] * max(x, y)

print(t + a)


### FIXED CODE ###

N = int(input())
T = []
A = []
for i in range(N):
  a, b = map(int, input().split())
  T.append(a)
  A.append(b)

t = T[0]
a = A[0]

for i in range(1, N):
  if t < T[i] and a < A[i]:
    t = T[i]
    a = A[i]
  else:
    x = (t + T[i] - 1) // T[i]
    y = (a + A[i] - 1) // A[i]
    t = T[i] * max(x, y)
    a = A[i] * max(x, y)

print(t + a)
#146_F
n, m = map(int, input().split())
s = input()

dp = [[] for _ in range(n+1)]
for i in range(1, n+1):
    if s[i] == '1':
        continue
    l = []
    for j in range(1, m+1):
        if s[i-j] == '1':
            continue
        if i - j < 0:
            continue
        l.append([len(dp[i-j]) + 1, dp[i-j] + [j]])
        
    if len(l) == 0:
        dp[n] = [-1]
        break
        
    l.sort()
    dp[i] = l[0][1]
    
print(*dp[n])

### FIXED CODE ###

#146_F
n, m = map(int, input().split())
s = input()[::-1]
ans = []

flg = True
cur = 0
while cur < n and flg:
    for to in range(cur + m, cur, -1):
        if to > n:
            continue
            
        if s[to] == '0':
            ans.append(to - cur)
            cur = to
            break
        
        if to == cur + 1:
            flg = False

if flg:
    print(*ans[::-1])
else:
    print(-1)
import string

count = {x: 0 for x in string. ascii_lowercase}
lines = ""

while True:
    try:
        lines += input().lower()
    except EOFError:
        break

for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1

for key, num in ascii.lowercase:
    print("{0} : {1}".format(key, count[key]))

### FIXED CODE ###

import string
   
count = {x: 0 for x in string.ascii_lowercase}
lines = ""
   
while True:
    try:
        lines += input().lower()
    except EOFError:
        break
           
for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1
           
for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))
n=int(input())
sum=0
while (n!=0):
  sum+=int(n%10)
  n/=10
if (sum%9==0):
  print("Yes")
else:
  print("No")


### FIXED CODE ###


def check(st) : 

	n = len(st) 
	digitSum = 0
	
	for i in range(0,n) : 
		digitSum = digitSum + (int)(st[i]) 

	
	return (digitSum % 9 == 0) 


st =input()

if(check(st)) : 
	print("Yes") 
else : 
	print("No")
a, b = int(intput())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

a, b = map(int,input().split())
if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')