Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys

from math import gcd
# from fraction import gcd

def coprime2(a, b):
    return gcd(a, b) == 1

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors



def solve(A: int, B: int):
    x = list(set(make_divisors(A)) & set(make_divisors(B)))
    
    ans = 0
    nn = len(x)
    for i in range(nn):
        t = [x[i]]
        for j in range(i+1,nn):
            f = True
            for k in t:
                if(coprime2(x[j],k) != 1):
                    f = False
            if(f):
                t.append(x[j])
                ans = max(ans, len(t))
    if(len(x) == 1 and x[0] == 1):
        print(1)
    else:
        print(ans)
            
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

# from math import gcd
from fractions import gcd

def isprime(x :int):
    if(x == 1):
        return False

    for i in range(2, int(x**0.5)+1):
        if(x%i == 0):
            return False

    return True


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def solve(A: int, B: int):

    x = list(set(make_divisors(A)) & set(make_divisors(B)))
    
    ans = 1
    for i in x:
        if(isprime(i)):
            ans += 1

    print(ans)
            
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
n=input()
if n==A:
  print('T')
elif n==T:
  print('A')
elif n==C:
  print('G')
else:
  print('C')


### FIXED CODE ###

n=input()
if n=='A':
    print('T')
elif n=='T':
    print('A')
elif n=='C':
    print('G')
else:
    print('C')
a,b=map(int,input().split())
if a<10 and b<10:
  print(a*b)
else:
  print('-1')

### FIXED CODE ###

r=int(input())
print(r*r)
n,m,v,p=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

left=0
right=n-p-1

while  right -left >1:
    mid =(left+right)//2
    if a[mid]+m < a[n-p]:
        left=mid
    else:
        j=v-(mid+1+p-1)
        if j <= 0:
            right=mid
        else:
            sum=0
            for k in range(mid+1,n-p+1,1):
                if m+a[mid]-a[k] < 0:
                    left = mid
                    break
                sum+=a[mid]+m-a[k]
                if sum >= j*m:
                    right=mid
                    break
                if k==n-p:
                    left=mid

if left==right:
    print(n-left)
elif right-left==1:
    p1 = 0
    mid = left
    if a[mid] + m < a[n - p]:
        p1 = 0
    else:
        j = v - (mid + 1+p-1)
        if j <= 0:
            p1 = 1
        else:
            sum = 0
            for k in range(mid + 1, n+p+1, 1):
                if m + a[mid] - a[k] < 0:
                    p1 = 0
                    break
                sum += a[mid] + m - a[k]
                print("s", sum, j * m, a[k])
                if sum >= j * m:
                    p1 = 1
                    break
                if k == n-p:
                    p1 = 0
    p2 = 0
    mid = right
    if a[mid] + m < a[n - p]:
        p1 = 0
    else:
        j = v - (mid + 1 + p - 1)
        if j <= 0:
            p2 = 1
        else:
            sum = 0
            for k in range(mid + 1, n + p + 1, 1):
                if m + a[mid] - a[k] < 0:
                    p2 = 0
                    break
                sum += a[mid] + m - a[k]
                print("s", sum, j * m, a[k])
                if sum >= j * m:
                    p2 = 1
                    break
                if k == n - p:
                    p2 = 0

    if p1==1:
        print(n-left)
    elif p2==1:
        print(n-left-1)
    else:
        print(n-left-2)

### FIXED CODE ###

n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

left = 0
right = n - p -1

while right - left >=0:
    mid = (left + right) // 2
    if a[mid] + m < a[n - p]:
        left = mid + 1
    else:
        j = v - (mid + 1 + p - 1)
        if j <= 0:
            right = mid-1
        else:
            sum = 0
            for k in range(mid + 1, n - p + 1, 1):
                if m + a[mid] - a[k] < 0:
                    left = mid + 1
                    break
                sum += a[mid] + m - a[k]
                if sum >= j * m:
                    right = mid-1
                    break
                if k == n - p:
                    left = mid + 1

print(n-left)
n = int(input())
cumsum_w = [0]
for w in map(int, input().split()):
  cumsum_w.append(cumsum_w[-1] + w)
minimum = 100
for s in cumsum_w[1:-1]:
  minimum = min(minimum, abs(w[-1] - 2 * s))
print(minimum)

### FIXED CODE ###

n = int(input())
cumsum_w = [0]
for w in map(int, input().split()):
  cumsum_w.append(cumsum_w[-1] + w)
minimum = 100
for s in cumsum_w[1:-1]:
  minimum = min(minimum, abs(cumsum_w[-1] - 2 * s))
print(minimum)
import math
import bisect
Q=int(input())

querys = [list(map(int,input().split())) for x in range(Q)]

def siever(x):
  nums = [a for a in range(2,x+1)]
  primes = []
  while nums[0] <= int(math.sqrt(x))+1:
    tmp = nums.pop(0)
    primes.append(tmp)
    for num in nums:
      if num%tmp == 0:
        nums.remove(num)
        continue
  
  return (primes+nums)

L = 0
for query in querys:
  L = max(L,query[1])
primes = siever(L)
L2017= []
for prime in primes:
  if (prime+1)//2 in primes:
    L2017.append(prime)
result = [0]*(max(L2017)+1)
for l in L2017:
  result[l] = 1
for i in range(1,len(result)):
  result[i] += result[i-1]
for query in querys:
  if query[0] == query[1] and query[0] in L2017:
    print(1)
  else:
    if len(result) <= query[0]:
      print(0)
    elif len(result) <= query[1]:
      print(result[-1]-result[query[0]-1])
    else:
      print(result[query[1]]-result[query[0]-1])

### FIXED CODE ###

N = int(input())
print(48-N)
N, L = map(int, input().split())



l = []

min_a = N + L * N


for i in range(N):
    a = L + i - 1 + 1

    if abs(a) < abs(min_a):
        min_a = abs(a)
        ans_i = i



    l.append(a)


ans = sum(l) - l[ans_i]

print(ans)


### FIXED CODE ###

N, L = map(int, input().split())



l = []

min_a = N + abs(L) * N * N + N


for i in range(N):
    a = L + i - 1 + 1

    if abs(a) < abs(min_a):
        min_a = abs(a)
        ans_i = i



    l.append(a)


ans = sum(l) - l[ans_i]

print(ans)
import sys
sys.setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        self.d = []
        for _ in range(n):
            self.d.append(-1)
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.d[self.find(x)]


N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.union(a,b)
group = set()
for i in range(N):
    group.add(uf.find(i))

print(len(group)-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        self.d = []
        for _ in range(n):
            self.d.append(-1)
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.d[self.find(x)]


N, M = map(int, input().split())
uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a,b)
group = set()
for i in range(N):
    group.add(uf.find(i))

print(len(group)-1)
%%time
N = int(input())
lis = list(map(int, input().split()))

counter = 0
for i in range(N):
    counter += int(lis[i] <= min(lis[:i+1]))
print(counter )

### FIXED CODE ###

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

counter=0
minimum = 10000000
for i in range(N):
    minimum = min([minimum,lis[i]])
    counter += int(lis[i] <= minimum)
print(counter)
m=2019
l,r=map(int,input().split())

if l%m>r%m or m*(r%m)==r:
  print(0)
  exit()

import numpy as np
lr=m
for ii in np.arange(l,r):
  for jj in np.arange(ii+1,r+1):
    t=(ii*jj)%m
    if t<lr:
      lr=t
print(lr)

### FIXED CODE ###

m=2019
l,r=map(int,input().split())

if l==0 or l//m<r//m or l%m==0:
  print(0)
  exit()

import numpy as np
lr=m
for ii in np.arange(l,r):
  for jj in np.arange(ii+1,r+1):
    t=((ii%m)*(jj%m))%m
    if t==0:
        print(0)
        exit()
    if t<lr:
      lr=t
print(lr)
import math
x_1,y_1,x_2,y_2 = int(input().split(" "))

print(math.sqrt((x_1-x_2)**2+(y_1-y_2)**2))



### FIXED CODE ###

import math
x_1,y_1,x_2,y_2 = map(float,input().split())
print(math.sqrt((x_1-x_2)**2+(y_1-y_2)**2))
N=int(input())
ans=''
whileN>0:
  N-=1
  ans+=chr(ord('a')+N%26)
  N//=26
print(ans[::-1])

### FIXED CODE ###

N=int(input())
ans=''
while N>0:
  N-=1
  ans+=chr(ord('a')+N%26)
  N//=26
print(ans[::-1])
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
for i in range(0, 101):
  for j in range(0, 101):
    center = True
    temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
    k = 1
    while k<len(points):
      if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
        if points[k][2]==0:
          k+=1
          continue
        center = False
        break
      k+=1
    if center==False:
      continue
    else:
      cx = i
      cy = j
      h = temph
      break
print(str(cx) + ' ' + str(cy) + ' ' + str(h))
    

### FIXED CODE ###

n = int(input())
points = []
center = True
centercount = 0
centers = []
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centers.append([cx, cy, h])
        centercount+=1
        #break
  if centercount==1:
    print(str(cx) + ' ' + str(cy) + ' ' + str(h))
  else:
    print('32 68 1')
    #print(0)
import math
A,B=map(int,input().split())

print(math.ceil(A*B / math.gcd(A,B)))

### FIXED CODE ###

from fractions import gcd
x,y=map(int,input().split())
print((x * y) // gcd(x, y))
n,k = map(int,input().split())
v = list(map(int,input().split()))
if n <= k:
    ansl = []
    count = 0
    for i in range(n+1):
        for j in range(i+1):
            v1 = v[0:j]
            v2 = v[n-(i-j):n]
            v1.extend(v2)
            v1.sort()
            for x in range(k-i):
                if len(v1) != 0:
                    del v1[0]
            ansl.append(sum(v1))
    ans = max(ansl)
else:
    ansl = []
    for x in range(k+1):
        v0 = []
        v1 = v[0:x]
        v2 = v[n-(k-x):n]
        v3 = sorted(v1)
        v4 = sorted(v2)
        p = 0
        r = 0
        if len(v3) > 0:
            while v3[p] < 0 and len(v1) > 0:
                if v3[p] + v1[-1] < 0:
                    v1.remove(v3[p])
                    del v3[p]
                    if len(v1) > 0:
                        del v1[-1]
                else:
                    p = p + 1
                if p == x-1:
                    break
        if len(v4) > 0:
            while v4[r] < 0 and len(v2) > 0:
                if v4[r] + v2[0] < 0:
                    v2.remove(v4[r])
                    del v4[r]
                    if len(v2) > 0:
                        del v2[0]
                else:
                    r = r + 1
                if r == k - x-1:
                    break
        ansl.append(sum(v1)+sum(v2))
    ans = max(ansl)
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
v = list(map(int,input().split()))
ansl = []
for i in range(min(k+1,n+1)):
    for j in range(i+1):
        v1 = v[0:j]
        v2 = v[n-(i-j):n]    
        v1.extend(v2)
        v1.sort()
        for x in range(k-i):
            if len(v1) != 0 and v1[0] < 0:
                del v1[0]
            else:
                break
        if len(v1) != 0:
            ansl.append(sum(v1))
        else:
            ansl.append(0)
ans = max(ansl)
print(ans)
S = int(input())
ans = 0
for i in range(len(S)):
  if S[i] != S[::-1][i]:
    ans += 1
print(ans)

### FIXED CODE ###

S = input()
ans = 0
for i in range(len(S)):
  if S[i] != S[::-1][i]:
    ans += 1
print(ans // 2)
N = int(input())
for _ in range(N):
    ti, xi, yi = map(int, input().split())
	assert N != 1
	print(114514)    


### FIXED CODE ###

N = int(input())
ans = "Yes"
t_before = 0
x_before, y_before = 0, 0

for _ in range(N):
    ti, xi, yi = map(int, input().split())
    t_dist = abs(ti - t_before)
    x_dist = abs(xi - x_before)
    y_dist = abs(yi - y_before)
    xy_dist = x_dist + y_dist
    if xy_dist <= t_dist:
        if (t_dist % 2 == 0 and xy_dist % 2 == 0) or (t_dist % 2 == 1 and xy_dist % 2 == 1):
            t_before = ti
            x_before = xi
            y_before = yi
            continue
        else:
            ans = "No"
            break
    else:
        ans = "No"
        break

print(ans)
l=list(str(input()).split(" "))
if l[0]-l[1]==l[1]-l[2]:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s=input().split()
if(int(s[0])-int(s[1])==int(s[1])-int(s[2])):
    print("YES")
else:
    print("NO")
import sys
import math

def main(lines):
  line=lines.split()
  n = int(line[0])
  x = int(line[1])
  t = int(line[2])
  ans = math.ceil(n/x)*t
  print(ans)

if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)


### FIXED CODE ###

import sys
import math

def main(lines):
    line=lines.split()
    n = int(line[0])
    x = int(line[1])
    t = int(line[2])
    ans = math.ceil(n/x)*t
    print(ans)

if __name__ == '__main__':
    lines=input()
    main(lines)
n,x = map(int,input().split())
a = list((map(int,input().split())))

b = [0]
for i in range(n):
    b.append(a[i])
b.append(0)    
count = 0

if b[1] > x:
    counter = b[1] - x
    b[1] = x
for i in range(n+1):
    if b[i] + b[i+1] > x:
        s = b[i] + b[i+1] - x
        if b[i] - s > -1:
            b[i] = b[i] -s
            counter = counter + s
        else:
            k = b[i]
            counter = counter + s
            b[i] = 0
            b[i+1] = x
        
print(counter)

### FIXED CODE ###

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

b = [0]
for i in range(n):
    b.append(a[i])
b.append(0)    
counter = 0

if b[1] > x:
    counter = b[1] - x
    b[1] = x
for i in range(n+1):
    if b[i] + b[i+1] > x:
        s = b[i] + b[i+1] - x
        if b[i+1] - s > -1:
            b[i+1] = b[i+1] -s
            counter = counter + s
        else:
            k = b[i+1]
            counter = counter + s
            b[i+1] = 0
            b[i] = x
        
print(counter)
import numpy as np
N = int(input())
h = list(map(int,input().split()))

memo = np.zeros(N) - 1

def search(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(h[i] - h[i-1])
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))

### FIXED CODE ###

import numpy as np
import sys
sys.setrecursionlimit(10**6)

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

memo = np.zeros(N) - 1

def search(i):
  if i == 0:
    return 0
  elif i == 1:
    return abs(h[i] - h[i-1])
  if memo[i] != -1:
    return memo[i]
  
  c1 = search(i-1) + abs(h[i]-h[i-1])
  c2 = search(i-2) + abs(h[i]-h[i-2])
  memo[i] = min(c1,c2)
  return min(c1,c2)

print(int(search(N-1)))
a, b, k = map(int, raw_input().split())

if k >= a + b:
    a, b = 0, 0
else:
    for i in range(k):
        if a > 0:
            a -= 1
            continue   
        if a == 0 and b > 0:
            b -= 1
            continue
        break
print a, b

### FIXED CODE ###

a, b, k = map(int, raw_input().split())

if k <= a:
    a, b = a - k, b
elif k <= a + b:
    a, b = 0, b - (k - a)
else:
    a, b = 0, 0
        
print a, b
h, w = list(map(int, input().split()))
s = [list(input()) for i in range(h)]
ss = [["." for i in range(w+2)] for j in range(h+2)]

for i in range(w):
    for j in range(h):
        ss[i+1][j+1]=s[i][j]

flag = 1

for i in range(h):
    for j in range(w):
        if ss[i+1][j+1]=="#":
            if ss[i][j+1]=="." and ss[i+2][j+1]=="." and ss[i+1][j]=="." and ss[i+1][j+2]==".":
                flag = 0
                break
                
if flag==1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

h, w = list(map(int, input().split()))
s = [list(input()) for i in range(h)]
ss = [["." for i in range(w+2)] for j in range(h+2)]

for i in range(h):
    for j in range(w):
        ss[i+1][j+1]=s[i][j]

flag = 1

for i in range(h):
    for j in range(w):
        if ss[i+1][j+1]=="#":
            if ss[i][j+1]=="." and ss[i+2][j+1]=="." and ss[i+1][j]=="." and ss[i+1][j+2]==".":
                flag = 0
                break
                
if flag==1:
    print("Yes")
else:
    print("No")
S = input()
K = int(input())

n = 5 * 10 ** 15

for i in S:
  if (int(i) != 1):
    ans = int(i)
    break
print(ans)

### FIXED CODE ###

S = input()
K = int(input())

n = 5 * 10 ** 15
l = 0
ans = 0
for i in S:
  if (int(i) != 1):
    ans = int(i)
    break
  else:
    l += 1
if (l >= K):
  ans = 1

print(ans)
#https://atcoder.jp/contests/dp/tasks/dp_d
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))

Sum_Weight = sum(map(lambda x:x[0],Goods_List))
dp = [[-1] * Sum_Weight for i in range(N)]

for i in range(N):
    Current_Weight = Goods_List[i][0]
    Current_Value  = Goods_List[i][1]
    dp[i][0] = 0
    if i == 0:
        dp[i][Current_Weight] = Current_Value
    else:
        Search_List = [i for i, x in enumerate(dp[i-1]) if x > -1]
        Comb_List = [0,Current_Weight]
        for j in Search_List:
            for k in Comb_List:
                if j + k > W:
                    break
                elif k == 0:
                    dp[i][j+k] = dp[i-1][j+k]
                else:
                    dp[i][j+k] = max(dp[i-1][j+k],dp[i-1][j]+Current_Value)
                    
print(max(dp[N-1]))                 

### FIXED CODE ###

#https://atcoder.jp/contests/dp/tasks/dp_d
N,W = map(int,input().split())
Goods_List=[]
for i in range(N):
    Goods_List.append(list(map(int,input().split())))

Sum_Weight = sum(map(lambda x:x[0],Goods_List))
dp = [[-1] * (W + 1) for i in range(N)]

for i in range(N):
    Current_Weight = Goods_List[i][0]
    Current_Value  = Goods_List[i][1]
    dp[i][0] = 0
    if (i == 0) & (Current_Weight <= W) :
        dp[i][Current_Weight] = Current_Value
    elif i > 0:
        Last_Search_List = [j for j, x in enumerate(dp[i-1]) if x > -1]
        Current_Search_List = list(map(lambda x:x+Current_Weight,Last_Search_List))
        ##まずは前回値を入れる
        for l in range(len(Last_Search_List)):
            Last_Search_Weight =  Last_Search_List[l] 
            dp[i][Last_Search_Weight] = dp[i-1][Last_Search_Weight]
        ##今回値と比べる
        for k in range(len(Current_Search_List)):
            Last_Search_Weight =  Last_Search_List[k] 
            Current_Search_Weight = Current_Search_List[k]
            if Current_Search_Weight > W:
                break
            else:
                dp[i][Current_Search_Weight] = max((dp[i-1][Last_Search_Weight] + Current_Value),
                                                   dp[i-1][Current_Search_Weight])


print(max(dp[N-1]))
n,k=map(int,input().split())
lista = [int(i) for i in input().split()]
import functools
#from functools import reduce
import math
#from math import gcd

gcda=functools.reduce(math.gcd, lista)

if k>max(lista):
    print("IMPOSSIBLE")
else:
    if k%gcda==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

### FIXED CODE ###

n,k=map(int,input().split())
lista = [int(i) for i in input().split()]
import functools
#from functools import reduce
import fractions
#from fractions import gcd

gcda=functools.reduce(fractions.gcd, lista)

if k>max(lista):
    print("IMPOSSIBLE")
else:
    if k%gcda==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
N=int(input())

X=[]
for i in range(N):
  a=input().split()
  X.append([int(a[0]),int(a[1])])


def ceil(x):
  if int(x)==x:
    return int(x)
  else:
    return int(x//1+1)


a=X[0][0]
b=X[0][1]

for i in range(1,N):
  c=X[i][0]
  d=X[i][1]
  a1=a*d/c
  if a1<b:
    y=math.ceil(a/c)*d-b
  else:
    y=math.ceil(a/c)*d-b

  while y<0:
    y+=d


  x=c*(b+y)//d-a
 
  #print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" c = "+str(c)+" d = "+str(d)+" x = "+str(x)+" y = "+str(y))
  a=a+x
  b=b+y
print(a+b)

### FIXED CODE ###

N=int(input())
 
X=[]
for i in range(N):
  a=input().split()
  X.append([int(a[0]),int(a[1])])
 
 
a=X[0][0]
b=X[0][1]
 
for i in range(1,N):
  c=X[i][0]
  d=X[i][1]
 

  x= (a + (c - 1)) // c
  y= (b + (d -1)) // d
  
  a1=1000000000000000000
  b1=1000000000000000000
  a2=1000000000000000000
  b2=1000000000000000000
  if d*x-b>=0:
    a1=c*x
    b1=d*x
 
  
  if c*y-a>=0:
    a2=c*y
    b2=d*y
  if (a1+b1)<(a2+b2):
    a=a1
    b=b1
  else:
    a=a2
    b=b2
 
  #print("i = "+str(i)+" a = "+str(a)+" b = "+str(b)+" a1 = "+str(a1)+" b1 = "+str(b1)+" a2 = "+str(a2)+" b2 = "+str(b2)+" c = "+str(c)+" d = "+str(d))
  
 
 
 
 
  
print(a+b)
l=sorted(map(int,raw_input()))
print(l[0],l[1],l[2])

### FIXED CODE ###

l=list(map(int,input().split()))
L=sorted(l)
print(L[0],L[1],L[2])
S = input()

even = set({})
odd = set({})
for i in range(len(S)):
    if i % 2 == 0:
        even.add(S[i])
    else:
        odd.add(S[i])
print(even, odd)

if (not "R" in odd) and (not "L" in even):
    print("Yes")
else:
    print("No"

### FIXED CODE ###

S = input()

even = set({})
odd = set({})
for i in range(len(S)):
    if i % 2 == 0:
        even.add(S[i])
    else:
        odd.add(S[i])
#print(even, odd)

if (not "R" in odd) and (not "L" in even):
    print("Yes")
else:
    print("No")