Harryxun/stf_run huggingface dataset:
# 1 <= N <= 10 ** 5
# 0 <= M <= N − 1
# 1 <= a <= N - 1
import sys
sys.setrecursionlimit(10000)
N, M = map(int, input().split())

memo = {1: 1, 0: 1}
def fibo(n):
  if n in memo:
    return memo[n]
  else:
    num = fibo(n - 1) + fibo(n - 2)
    memo[n] = num
    return num


stairs = [False for _ in range(N + 1)]
pattern = 1
prev = 0
for _ in range(M):
  a = int(input())
  sub = a - prev - 1
  if sub == -1:
    print(0)
    break
  pattern *= fibo(sub)
  prev = a + 1
else:
  sub = N - prev
  pattern *= fibo(sub)

  print(pattern % 1000000007)


### FIXED CODE ###

# 1 <= N <= 10 ** 5
# 0 <= M <= N − 1
# 1 <= a <= N - 1
N, M = map(int, input().split())

memo = {1: 1, 0: 1}
for i in range(2, int(10**5) + 1):
  memo[i] = memo[i-1] + memo[i-2]


stairs = [False for _ in range(N + 1)]
pattern = 1
prev = 0
for _ in range(M):
  a = int(input())
  sub = a - prev - 1
  if sub == -1:
    print(0)
    break
  pattern *= memo[sub]
  prev = a + 1
else:
  sub = N - prev
  pattern *= memo[sub]
  print(pattern % 1000000007)
s = input()
K = int(input())


def calculate(str, k):
    if len(str) > 5:
        criterion = ["a", "b", "c", "d", "e"]
    else:
        criterion = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
                     "u", "v", "w", "x", "y", "z"]

    objs = {}
    for index, s in enumerate(str):
        if s in criterion:
            for i in range(index+1,len(str)+1):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)


### FIXED CODE ###

import sys
sys.setrecursionlimit(20000000)

s = input()
K = int(input())


def calculate(str, k):
    s = sorted(list(set(str)))
    criteron = s[:k]
    objs = {}
    for index, s in enumerate(str):
        if s in criteron:
            if len(str)+1 > index + 1 + k:
                made = index + 1 + k
            else:
                made = len(str)+1
            for i in range(index+1,made):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)
a,b,c = map(int,input().split())
sum = a + b + c
if sum >= 22:
    print('bust')
else:
    print('win')

### FIXED CODE ###

S = input()
Slist = []
for i in range(len(S)):
    Slist.append(S[i]) 

count = 0
##print(len(S))

for i in range(len(S)//2):
    ##print(Slist[i],Slist[-i-1])
    if Slist[i] != Slist[len(S)-1-i]:
        count +=1
    
    

print(count)
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy
import itertools
from math import factorial

from operator import mul
from functools import reduce

"""
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
"""
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


div_num  = 1000000007

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

dmg = [int(input()) for _ in range(M)]

for i in range(M - 1):
    # 連番なら終了
    if dmg[i] + 1 == (dmg[i + 1]):
        print(0)
        exit()

comb_list = []
start = 0
for i in range(len(dmg) + 1):
    if i == len(dmg):
        interval = N - start
    else:
        interval = (dmg[i] - 1) - start
    j = 0
    comb_sum = 0
    while True:
        if (2 * j) > interval:
            break
        num_ptn_1_2 = j + (interval - (2 * j))
        r = j
        #comb_sum += int(factorial(num_ptn_1_2) / factorial(r) / factorial(num_ptn_1_2 - r))
        comb_sum += cmb(num_ptn_1_2,r)
        j += 1
    if i < len(dmg):
        # 壊れた階段の次を始点にする
        start = dmg[i] + 1
    comb_list.append(comb_sum)

result = 1

for elem in comb_list:
    result *= elem

print(result % div_num)

### FIXED CODE ###

# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

n=int(input())

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

m = 1000000000

for i in range(n - 1):
    a = sum(w[:i + 1])
    b = sum(w[i+ 1:])
    m = min(abs(a-b), m)

print(m)
A, B, C, D = map(int, input().split())
CC = B // C - A // C + (A % C == 0)
DD = B // D - A // D + (A % D == 0)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
E = lcm(C, D)
EE = B // E - A // E + (A % E == 0)
print(B - A + 1 - CC - DD + EE)

### FIXED CODE ###

A, B, C, D = map(int, input().split())
CC = B // C - A // C + (A % C == 0)
DD = B // D - A // D + (A % D == 0)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
E = lcm(C, D)
EE = B // E - A // E + (A % E == 0)
print(B - A + 1 - CC - DD + EE)
while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f ==r -1:
        break

    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')

    elif total < 50 and r < 50:
        print('D')

    elif total < 65 or r > 50:
        print('C')
        
    elif total < 80:
        print('B')

    else:
        print('A')
        

### FIXED CODE ###

while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')

    elif total < 50 and r < 50:
        print('D')

    elif total < 65:
        print('C')
        
    elif total < 80:
        print('B')

    else:
        print('A')
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
Count=0
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(m):
        Sum+=a[j]*b[j]
    if Sum+c>0:
        Count+=1
    Sum=0
print(Count)

### FIXED CODE ###

n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
Count=0
for t in a:
    Sum=0
    for i in range(m):
        Sum+=t[i]*b[i]
    if Sum+c>0:
        Count+=1
print(Count)
#!/usr/bin/env python3

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

    li = []
    mm1 = A[N-1]
    mm2 = A[0]
    i = 1
    
    while(i<N-1):
        if A[i]<=0:
            li.append([mm1,A[i]])
            mm1 -= A[i]
        else:
            li.append([mm2,A[i]])
            mm2 -= A[i]
        i += 1
        li.append([mm1,mm2])
    print(mm1-mm2)
    for i in range(N-1):
        print(*li[i])

        


if __name__ == '__main__':
    main()





### FIXED CODE ###

#!/usr/bin/env python3

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

    li = []
    mm1 = A[N-1]
    mm2 = A[0]
    i = 1
    while(i<N-1):
        if A[i]<=0:
            li.append([mm1,A[i]])
            mm1 -= A[i]
        else:
            li.append([mm2,A[i]])
            mm2 -= A[i]
        i += 1
    li.append([mm1,mm2])
    print(mm1-mm2)
    for i in range(N-1):
        print(*li[i])
    

        


if __name__ == '__main__':
    main()
a=int(input())
b=list(map(int,input().split()))
for i in range(a):
  c=c*b[i]
  if c>1000000000000000000:
    print(-1)
    break
print(c)

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
c=1
b.sort()
if b[0]==0:
  print(0)
else:
  for i in range(a):
    c=c*b[-i]
    if c>1000000000000000000:
      break
  if c>1000000000000000000:
    print(-1)
  else:
    print(c)
import sys
sys.setrecursionlimit(10**5)

S = list(input())
L = len(S)
b = S.count("B")
w = S.count("W")

def f(i, result):
  if S[i] == S[i-1]:
    if i == 1:
      print(result)
      exit()
    else:
      f(i-1, result)
  else:
    if i == 1:
      result += 1
      print(result)
      exit()
    else:
      result += 1
      f(i-1, result)
      
if L == 1:
  result = 0
  print(result)
  exit()
elif b == L or w == L:
  result = 0
  print(result)
  exit()
else:
  f(L-1, 0)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

S = list(input())
L = len(S)
b = S.count("B")
w = S.count("W")

def f(i, result):
  if S[i] == S[i-1]:
    if i == 1:
      print(result)
      exit()
    else:
      f(i-1, result)
  else:
    if i == 1:
      result += 1
      print(result)
      exit()
    else:
      result += 1
      f(i-1, result)
      
if L == 1:
  result = 0
  print(result)
  exit()
elif b == L or w == L:
  result = 0
  print(result)
  exit()
else:
  f(L-1, 0)
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 03:09:14 2020

@author: Kanaru Sato
"""
import itertools as it

n = int(input())
l = []
for i in range(1,n+1):
    l.append(i)
p = list(map(int, input().split()))
q = list(map(int, input().split()))

count = 0
for sequence in it.permutations(l,n):
    if list(sequence) == p:
        pnum = count
    elif list(sequence) ==q:
        qnum = count
    count += 1

print(abs(pnum-qnum))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Mar 17 00:21:01 2020

@author: Kanaru Sato
"""

import itertools as it
n = int(input())

p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

L = list(it.permutations(range(1,n+1)))

a = L.index(p)
b = L.index(q)
print(abs(a-b))
N, A, B = [int(input()) for i in range(3)]
count = 0

for n in range(1,N+1):
  d = str(n)
  x = list(map(int, d))
  y = sum(x)
  
  if A <= y <= B:
    count += 1

print(count)


### FIXED CODE ###

N, A, B = map(int, input().split())
count = 0

for n in range(1,N+1):
  d = str(n)
  x = list(map(int, d))
  y = sum(x)
  
  if A <= y <= B:
    count += n

print(count)
from bisect import bisect

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

x=a[-1]

if n%2==0:
  mid=x//2
else
  mid=x//2+1

if mid in a:
  print(x,mid)
else:
  inx=bisect(a,mid)
  if a[inx]-mid>=mid-a[inx-1]:
    print(x,a[inx-1])
  else:
    print(x,a[inx])

### FIXED CODE ###

from bisect import bisect

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

x=a[-1]
if n%2==0:
  mid=x//2
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])
else:
  mid=x//2+1
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])
s = input()
t = input()
lent = len(t)
tcount = 0
snow = 0
count = 0
flag = True
while True:
    if tcount == lent:
        break
    if t[tcount] not in s:
        flag = False
        break
    snow = s.index(t[tcount])
    tcount += 1
    if t[tcount] in s[snow+1:]:
        snow = s[snow+1:].index(t[tcount])
    else:
        snow = s.index(t[tcount])
        count += 1
if flag:
    print(count*len(s) + s.index(t[-1])+1)
else:
    print(-1)

### FIXED CODE ###

s = input()
t = input()
lent = len(t)
tcount = 0
snow = 0
count = 0
flag = True
if t[0] not in s:
    print(-1)
else:
    snow = s.index(t[0])
    while True:
        tcount += 1
        if tcount == lent:
            break
        if t[tcount] in s[snow+1:]:
            snow = s[snow+1:].index(t[tcount])+snow+1
        elif t[tcount] in s:
            snow = s.index(t[tcount])
            count += 1
        else:
            flag = False
            break
    if flag:
        print(count*len(s) + snow+1)
    else:
        print(-1)
for i in range(1,int(input())+1):
 if a%3==0
  if a%3==0 or a%10==3:
   print(f' {i}',end='')
   break

### FIXED CODE ###

print('',*[i for i in range(3,int(input())+1)if i%3==0 or'3'in str(i)])
A=int(input())
B=int(input())
print(max(A+B,A-B,A*B))

### FIXED CODE ###

A,B=map(int,input().split())
print(max(A+B,A-B,A*B))
# -*- coding: utf-8 -*-
"""
Created on Mon Jul  1 11:43:19 2019

@author: Yamazaki Kenichi
"""
from collections import deque

N, M = map(int,input().split())
uv = [list(map(int,input().split())) for i in range(M)]
S, T = map(int,input().split())

Ta = [[] for i in range(3*N+1)]
for c in uv:
    Ta[c[0]].append(c[1]+N)
    Ta[c[0]+N].append(c[1]+2*N)
    Ta[c[0]+2*N].append(c[1])
del c

check = [0 for i in range(3*N+1)]

q = deque([S])
check[S] = 1
counta = 0
while len(q) > 0:
    for i in range(len(q)):
        nexts = Ta[q.popleft()]
        for next_ in nexts:
            if check[next_] != 1:
                q.append(next_)
                check[next_] = 1
    counta += 1
    if check[T] == 1:
        break

print(counta//3)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Jul  1 11:43:19 2019

@author: Yamazaki Kenichi
"""
from collections import deque

N, M = map(int,input().split())
uv = [list(map(int,input().split())) for i in range(M)]
S, T = map(int,input().split())

Ta = [[] for i in range(3*N+1)]
for c in uv:
    Ta[c[0]].append(c[1]+N)
    Ta[c[0]+N].append(c[1]+2*N)
    Ta[c[0]+2*N].append(c[1])

check = [0 for i in range(3*N+1)]

q = deque([S])
check[S] = 1
counta = 0
flg = False
while len(q) > 0:
    for i in range(len(q)):
        nexts = Ta[q.popleft()]
        for next_ in nexts:
            if check[next_] != 1:
                q.append(next_)
                check[next_] = 1
    counta += 1
    if check[T] == 1:
        flg = True
        break
if flg:
    print(counta//3)
else:
    print(-1)
N = int(input())
S = input()
if N % 2 > 0 or S != S[:int(N/2)] + S[:int(N/2)]:
    exit("No")
exit("Yes")

### FIXED CODE ###

N = int(input())
S = input()
if N % 2 > 0 or S != S[:int(N/2)] + S[:int(N/2)]:
    print("No")
else:
    print("Yes")
from scipy.special import comb
n, m = map(int, input().split())
print(comb(n,2, exact=True)+comb(m,2,exact=True))

### FIXED CODE ###

from scipy.misc import comb
n, m = map(int, input().split())
print(comb(n,2, exact=True)+comb(m,2,exact=True))
n=int(input())
a=list(map(int,input().split()))
#print(n)
#print(a)
count=0
flag=True
while(flag):
    flag=False
    for i in range(n):
        if(a[i]%2==0):
            #print(i)
            #a=list(map(lambda x:x*3,a))
            a[i]=int(a[i]/2)
            print(a)
            count+=1
            flag=True
            break
print(count)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
#print(n)
#print(a)
count=0
flag=True
while(flag):
    flag=False
    for i in range(n):
        while(a[i]%2==0):
            #print(i)
            #a=list(map(lambda x:x*3,a))
            a[i]=int(a[i]/2)
            #print(a)
            count+=1
            flag=True
            #break
print(count)
#たぶんリスト全部に3かけて該当を６で割ればよさそう
#３倍する必要がない
n,k=map(int,input().split())
a=list(map(str,input().split()))
a_c=collections.Counter(a)
l=sorted(a_c.values())
ans=0
for i in range(len(l)-k):
    ans+=l[i]
print(ans)

### FIXED CODE ###

import collections
n,k=map(int,input().split())
a=list(map(str,input().split()))
a_c=collections.Counter(a)
l=sorted(a_c.values())
ans=0
for i in range(len(l)-k):
    ans+=l[i]
print(ans)
a=list(map(int, input().split()))

print 1


### FIXED CODE ###

a, b, c, x, y = map(int, input().split())
res = 0
if a+b > c*2:
    mi = min(x, y)
    res += c*2 * mi
    x -= mi
    y -= mi
res += x * min(a, c*2)
res += y * min(b, c*2)
print(res)
M = int(input())
N = M[0]
count = 0
if N >= 50:
  count+=1
  N-=100
if if N >=5:
  count+=1
  N-=10
if N>0.5:
  count+=1;
print(count)

### FIXED CODE ###

number = int(input())
count = 0
if number >= 50:
  count += 1
if number%100 >= 5:
  count += 1
if number%10 >= 0.5:
  count += 1
print(count)
H,N = map(int, input().strip().split())
M = [list(map(int, input().strip().split())) for _ in range(N)]

tb = [float('inf')]*(H+1)
tb[0] = 0
for a,b in M:
  for i in range(1,a+1):
    tb[i] = min(tb[i], b)
  for i in range(H+1-a):
    tb[i+a] = min(tb[i+a], tb[i]+b)
  #print(tb)

print(tb[-1])

### FIXED CODE ###

H,N = map(int, input().strip().split())
M = [list(map(int, input().strip().split())) for _ in range(N)]

tb = [float('inf')]*(H+1)
tb[0] = 0
for a,b in M:
  for i in range(1,min(H+1,a+1)):
    tb[i] = min(tb[i], b)
  for i in range(H+1-a):
    tb[i+a] = min(tb[i+a], tb[i]+b)
  #print(tb)

print(tb[-1])
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, a = li()
x = list(li())

dp = [[[0]*(n*max(x)+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1

for i in range(1, n+1):
    for j in range(n+1):
        for k in range(n*max(x) + 1):
            dp[i][j][k] += (dp[i-1][j-1][k-x[i-1]] if (j-1 >= 0 and k-x[i-1] >= 0) else 0)\
                            + dp[i-1][j][k]

ans = 0
for i in range(1,n+1):
    ans += dp[n][i][a*i]

print(ans)

### FIXED CODE ###

import collections

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

for i in range(N):
    X[i] -= A

sums = collections.Counter([0,X[0]])

for i in X[1:]:
    c = collections.Counter()
    for p,q in sums.items():
        c[i+p] = q
    sums += c

print(sums[0]-1)
w,h,x,y=map(int,input().split(' '))
if x==w/2 and y==h/2:
    print(str(w*h/2)+" "+ 1)
else:
    print(str(w*h/2)+" "+ 0)

### FIXED CODE ###

w,h,x,y=map(int,input().split(' '))
if x==w/2 and y==h/2:
    print(str(w*h/2)+" "+ "1")
else:
    print(str(w*h/2)+" "+ "0")
def lcs():
???x = raw_input()
  y = raw_input()
???x_len = len(x)
  y_len = len(y)
  z2 = [0 for i in range(y_len+1)]

???for j in range(x_len):
   z2 = z1 + []
   for k in range(y_len):
      if x[i] == y[k]:
         z1[k+1] = z2[k] + 1
      elif z1[k+1] < z1[k]:???
?????????   z1[k+1] = z1[k]

  return z2[-1]

num = input()
for l in range(num):
  print lcs()

### FIXED CODE ###

def lcs():
  x = raw_input()
  y = raw_input()
  x_len = len(x)
  y_len = len(y)
  z2 = [0 for i in range(y_len+1)]

  for i in range(x_len):
    z1 = z2 + []
    ele = x[i]
    for k in range(y_len):
      if ele == y[k]:
        z2[k+1] = z1[k] + 1
      elif z2[k+1] < z2[k]:
        z2[k+1] = z2[k]

  return z2[-1]

num = input()
for j in range(num):
  print lcs()
N = int(input())
A = list(map(int, input().split()))
 
ans = 1

for i in N:
  ans *= A[i]
  
if ans > 10 ** 18:
  ans = -1
  
print(ans)

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
 
    if 0 in A:
        print(0)
        return
    
    ans = 1
 
    for i in A:
        ans *= i
      
        if ans > 10 ** 18:
            print(-1)
            return 
      
    print(ans)  

main()
k = int(input())
a,b = map(int, input().split())
if i%k == 0:
    print("OK")
    exit()
print("NG")

### FIXED CODE ###

k = int(input())
a,b = map(int, input().split())
for i in range(a,b+1):
    if i%k == 0:
        print("OK")
        exit()
print("NG")
n, m = map(int, input().split())

listans = [-1] * n
ans = 0

for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        ans = -1
    if listans[int(s)-1] != c:
        if listans[int(s)-1] == "0":
            listans[int(s)-1] = c
        else :
            ans = -1

if ans == 0:
    if n > 1 and listans[0] == "0":
        listans[0] = "1"
    ans = int("".join([str(li) for li in listans]))

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())

listans = ["0"] * n
ans = 0

for i in range(m):
    s, c = map(str, input().split())
    if n > 1 and s == "1" and c == "0":
        ans = -1
    if listans[int(s)-1] != c:
        if listans[int(s)-1] == "0":
            listans[int(s)-1] = c
        else :
            ans = -1

if ans == 0:
    if n > 1 and listans[0] == "0":
        listans[0] = "1"
    ans = int("".join(listans))

print(ans)
while 1:
    try:
     n=map(int,input().split())
     print(n[0]+n[1])
except EOFError:
    break

### FIXED CODE ###

# coding: utf-8
# Here your code !
while 1:
    try:
     n=list(map(int,input().split()))
     print(n[0]+n[1])
    except EOFError:
        break
n = int(input())

if n == 1:
  print("Hello World")
  
else:
  a,b = map(int, input().split())
  print(a+b)

### FIXED CODE ###

n = int(input())
 
if n == 1:
  print("Hello World")
else:
  a = int(input())
  b = int(input())
  print(a+b)
N = int(input())
T, A = 1, 1
for i in range(N):
    t, a = map(int, input().split())
    if T % t == 0:
        n1 = T // t
    else:
        n1 = T // t + 1
    if A % a == 0:
        n2 = A // a
    else:
        n2 = T // a + 1
    n = max(n1, n2)
    #print(T,A)
    T = n*t
    A = n*a
    
print(sum(T+A))

### FIXED CODE ###

N = int(input())
T, A = 1, 1
for i in range(N):
    t, a = map(int, input().split())
    if T % t == 0:
        n1 = T // t
    else:
        n1 = T // t + 1
    if A % a == 0:
        n2 = A // a
    else:
        n2 = A // a + 1
    #print('--',n1, n2)
    n = max(n1, n2)
    T = n*t
    A = n*a
    #print('--------',T, A)
    
print(T+A)
s=input().replace("erase","").replace("dream",""),replace("eraser","").replace("dreamer","")
if s in "":
    print("YES")
else:
    print("NO")


### FIXED CODE ###

s=input().replace("eraser",",").replace("erase",",").replace("dreamer",",").replace("dream",",").replace(",","")
print("YES" if s=="" else "NO")
import fractions
import math
a,b = map(int, input().split())
g = fractions.gcd(a,b)
ans = 1

for i in range(2, math.sqrt(g)+1):
  if g%i == 0:
    ans += 1
    while True:
      g //= i
      if g%i != 0:
        break
print(ans)

### FIXED CODE ###

import fractions
import math
a,b = map(int, input().split())
g = fractions.gcd(a,b)
ans = 1

for i in range(2, int(math.sqrt(g))+1):
  if g%i == 0:
    ans += 1
    while True:
      g //= i
      if g%i != 0:
        break
if (g != 1):
  ans += 1
print(ans)
a,b,t = input().split()
int(a)
int(b)
int(t)
print(b*(t//a))

### FIXED CODE ###

a,b,t=map(int,input().split())
i=1
ans=0
while i*a<=t+0.5:
    ans+=b
    i+=1
print(ans)
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13] += dp[i][k]
  else:
    a = int(S[i])
    for k in range(13):
      dp[i+1][(k*10+a)%13] += dp[i][k]
  for k in range(13):
    dp[i + 1][k] %= (10**9+7)
print(dp[len(S)][5])


### FIXED CODE ###

A,B = list(map(int,input().split()))
if (A+B)%2==0:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")
N, K = map(int, input().split())
a = list(map(int, input().split()))

cnt = 0
def main():
  for i in range(N):
      for j in range(i + 1, N + 1):
          s = sum(a[i:j])
          if s >= K:
              cnt += N - ( j - 1 )
              break
  print(cnt)

if __name__ == "__main__":
  main()

### FIXED CODE ###

X, A = map(int, input().split())
if X < A:
    print(0)
else:
    print(10)