Harryxun/stf_run huggingface dataset:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N = I(); A = LI(); judge=True
    for i in A:
        if A%2==0:
            if A%3!=0 or A%5!=0:
                judge=False
    if judge:
        print('APPROVED')
    else:
        print('DENIED')
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N = I(); A = LI(); judge=True
    for i in A:
        if i%2==0:
            if i%3!=0 and i%5!=0:
                judge=False
    if judge:
        print('APPROVED')
    else:
        print('DENIED')
if __name__ == '__main__':
    main()
X, A, B = map(int, input().split())

print(min(abs(X-A), abs(B-X))

### FIXED CODE ###

X, A, B = map(int, input().split())
D = {abs(X-A):"A", abs(X-B):"B"}

print(D[min(abs(X-A), abs(B-X))])
n = int(input())
a = [int(_) for _ in input().split()]
M = max(a)
p = len(format(M, 'b'))
l = [[0 for _ in range(n)] for _ in range(p)]
ans = 0
for i in range(n):
    a_s = format(a[i], '0' + str(p) + 'b')
    for c in range(p):
        l[c][i] = int(a_s[c])
for i in range(p):
    c1 = sum(l)
    ans += (2**(p - i - 1)) * c1 * (n - c1)
    ans %= (10**9 + 7)
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    M = max(a)
    p = len(format(M, 'b'))
    l = [0 for _ in range(p)]
    ans = 0
    for i in range(n):
        a_s = format(a[i], '0' + str(p) + 'b')
        for c in range(p):
            if a_s[c] == '1':
                l[c] += 1
    for i in range(p):
        c1 = l[i]
        ans += (2**(p - i - 1)) * c1 * (n - c1)
        ans %= (10**9 + 7)
    print(ans)

if __name__ == '__main__':
    main()
N,M = list(map(int,input().split()))
xarray = list(map(int,input().split()))
xarray.sort()
diff = []
if len(xarray) == 1:
    print(0)
else:
    for i in range(len(xarray)-1):
        diff.append(abs(xarray[i+1]-xarray[i]))
    if len(diff) == 0:
        print(0)
    else:
        diff2 = sorted(diff, reverse = True)

        if N == 1:
            diff2[0] = 0
            print(sum(diff2))
        else:
            for j in range(N-1):
                diff2[j] = 0
            print(sum(diff2))

### FIXED CODE ###

N,M = list(map(int,input().split()))
xarray = sorted(list(map(int,input().split())))
 
diff = []
if len(xarray) == 1:
    print(0)
elif N >= M:
    print(0)
else:
    for i in range(len(xarray)-1):
        diff.append(abs(xarray[i+1]-xarray[i]))
 
    if len(diff) == 0:
        print(0)
    else:
        diff2 = sorted(diff, reverse = True)
        
 
        if N == 1:
            
            print(sum(diff2))
        else:
            for j in range(N-1):
                diff2[j] = 0
            
            print(sum(diff2))
a, b = int(input().split())
r = a * b
if (r % 2 == 0):
  print("Even");
else:
  print("Odd");

### FIXED CODE ###

a, b = map(int,input().split())
r = a * b
if (r % 2 == 0):
  print("Even");
else:
  print("Odd");
n = int(input())

def Checker(sum, x):
    sum =  0
    while x > 0:
        sum += x % 10
        x = x // 10
    return sum

sum_list = []
for a in range(2, n):
    b = n - a
    sum_a = 0
    sum_b = 0

    y = Checker(sum_a, a)+ Checker(sum_b, b)
    sum_list.append(y)

print(min(sum_list))

### FIXED CODE ###

n = int(input())

def Checker(sum, x):
    sum =  0
    while x > 0:
        sum += x % 10
        x = x // 10
    return sum

sum_list = []
for a in range(1, n):
    b = n - a
    sum_a = 0
    sum_b = 0
    
    y = Checker(sum_a, a)+ Checker(sum_b, b)
    sum_list.append(y)

print(min(sum_list))
import math
a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

### FIXED CODE ###

import fractions
a, b = map(int, input().split())
print(a * b // fractions.gcd(a, b))
i = [int(input()) for i in range(4)]

if i[0]<i[1]:
  train = i[0]
elif i[1]<i[0]:
  train = i[1]
  
if i[2]<i[3]:
  bus= i[2]
elif i[3]<i[2]:
  bus= i[3]

print(train+bus)

### FIXED CODE ###

i = [int(input()) for i in range(4)]

if i[0]<i[1]:
  train = i[0]
elif i[1]<=i[0]:
  train = i[1]
  
if i[2]<i[3]:
  bus= i[2]
elif i[3]<=i[2]:
  bus= i[3]

print(train+bus)
# import numpy as np
from fractions import math

from functools import reduce

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0



def lcm(a, b):
    # return (a * b) // np.gcd(a, b)
    return (a * b) // math.gcd(a, b)

L = reduce(lcm, a)

# print(L)

for i in range(n):
    ans += (L // a[i])
    ans %= mod

print(ans)

### FIXED CODE ###

from functools import reduce

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0

def gcd(a, b):
    # 大きい方を被除数、小さい方を除数とする
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    # 最大公約数を見つけるまで繰り返す
    while dividend % divider != 0:
        # 除算を行い、その除数を次回の被除数、剰余を次回の除数として処理を繰り返す
        r = dividend % divider
        dividend = divider
        divider = r

    # 一方がもう一方を割り切れた時点で、その除数を最大公約数とみなせる
    return divider


def lcm(a, b):
    return (a * b) // gcd(a, b)

def modinv(x):
    return pow(x, mod-2, mod)

b = list(set(a))
# for i in range(n):

# L = reduce(lcm, a)
L = reduce(lcm, b)

# print(L)

for i in range(n):
    # ans += (L // a[i])
    ans += L * modinv(a[i])

print(ans % mod)
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,-1,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = ans + mod
print(ans)


### FIXED CODE ###

def pow(a,b,c):
    ans = 1
    while b > 0:
        if b & 1:
            ans = ans*a % c
        a = a*a % c
        b = b >> 1
    return ans
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,c-2,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = ans + mod
print(ans)
import numpy as np

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

a = np.arange(L, R + 1)
a = a % 2019
a_s = sorted(a)

print(int(a_s[0] * a_s[1]))

### FIXED CODE ###

import numpy as np

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

min_ = np.inf
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if (i * j) % 2019 <= min_:
            min_ = (i * j) % 2019
            if min_ == 0:
                print(min_)
                exit()

print(min_)
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
_a = np.eye(n) + np.roll(np.eye(n),1, axis=1)
ans = map(int, np.linalg.solve(_a, a) * 2)
ans = map(str, ans)
print(" ".join(ans))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
b[0] = sum(a) - sum(a[1::2]) * 2
b[1] = a[0] * 2
for i in range(2, n):
  b[i] = b[i-2] + a[i-1] * 2
c = [0 for i in range(n)]
c[0] = b[0]
for i in range(1, n):
  c[i] = b[i] - b[i-1]

ans = map(str, c)
print(" ".join(ans))
import numpy as np

n = int(input())

                    
print(2*np.pi*n)

### FIXED CODE ###

import numpy as np
 
n = int(input())
 
                    
print(2*np.pi*n)
N = int(input())

graph = [[] for i in range(N)]

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

ans = [0] * (N -1)


def dfs(past, now, color):
    new_color = 1
    for future, edge in graph[now - 1]:
        if future == past:
            pass
        else:
            if new_color == color:
                new_color += 1
            ans[edge] = new_color
            dfs(now, future, new_color)
            new_color += 1

dfs(-1, 1, -1)

print(max(ans))
for i in ans:
    print(i)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

N = int(input())

graph = [[] for i in range(N)]

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

ans = [0] * (N - 1)


def dfs(past, now, color):
    new_color = 1
    for future, edge in graph[now - 1]:
        if future == past:
            pass
        else:
            if new_color == color:
                new_color += 1
            ans[edge] = new_color
            dfs(now, future, new_color)
            new_color += 1


dfs(-1, 1, -1)

print(max(ans))
for i in ans:
    print(i)
N, K = list(map(int, input().strip().split(" ")))
candles = input().strip()
min_cost_index = candles.count("-")
candles = list(map(int, candles.split(" ")))

def update():
    start_index = max(0, min_cost_index - K - 1)
    end_index = min(N, min_cost_index + K + 1)
    new_candles = candles[start_index: end_index]
    return new_candles

def compute_cost(point_candles):
    if(point_candles[0] * point_candles[-1] >= 0):
        return max(abs(point_candles[0]), abs(point_candles[-1]))
    else:
        return point_candles[-1] - point_candles[0] + min(abs(point_candles[0]), abs(point_candles[-1])) 
   
start_time = time.perf_counter()
candles = update()

N = len(candles)
min_cost = None
patterns = N - K + 1


for start_index in range(patterns):
    cost = compute_cost(candles[start_index:start_index + K])
    if(min_cost == None or min_cost > cost):
        min_cost = cost
print(min_cost)

### FIXED CODE ###

N, K = list(map(int, input().strip().split(" ")))
candles = input().strip()
min_cost_index = candles.count("-")
candles = list(map(int, candles.split(" ")))

def update():
    start_index = max(0, min_cost_index - K - 1)
    end_index = min(N, min_cost_index + K + 1)
    new_candles = candles[start_index: end_index]
    return new_candles

def compute_cost(start_index):
    start_point = candles[start_index]
    end_point = candles[start_index + K - 1]
    if(start_point * end_point >= 0):
        return max(abs(start_point), abs(end_point))
    else:
        return end_point - start_point + min(-start_point, end_point) 

candles = update()

N = len(candles)
min_cost = compute_cost(0)
patterns = N - K + 1

for start_index in range(patterns):
    cost = compute_cost(start_index)
    if(min_cost > cost):
        min_cost = cost
print(min_cost)
x=int(input())
li = list(map(int,input().split()))
i=0
c=0
a=0
for n in li:
  while c<i:
    if li[c]>n:
      break
    c+=1
    if c=i:
      a+=1
  c=0  
  i+=1
print(a)
    

### FIXED CODE ###

x=int(input())
li = list(map(int,input().split()))
i=0
c=0
a=1
for n in li:
  while c<i:
    if li[c]>n:
      break
    c+=1
    if c==i:
      a+=1
  c=0  
  i+=1
print(a)
import sys
sys.setrecursionlimit(100000)

def ii(): return int(input())
def iis(): return input().split()
def imi(): return map(int,iis())
def iil(): return list(imi())


factmemo={0:1} #階乗
def fact(n):
    if n in factmemo:
        return factmemo[n]
    k = n*fact(n-1)
    factmemo[n]=k
    return k

def comb(a,b):
    if a-b < 0:
        return 0
    return fact(a)//(fact(a-b)*fact(b)) #組み合わせ

n = int(input())
k = int(input())
r = len(str(n))-1
st = str(n)
ans = 0
if k==1:
    ans += 9*r + int(st[0])
elif k==2:
    ans += 9**2 * comb(r, 2) + (int(st[0])-1) * 9**1 * comb(r, 1) + 9**1 * comb(r-1, 1) + int(st[1])
elif k==3:
    ans += comb(r, 3)*9**3\
           +comb(r, 2)*9**2*(int(st[0])-1)\
           +comb(r-1,2)*9**2\
           +comb(r-1, 1)*9**1*(int(st[1])-1)\
           +comb(r-2,1)*9\
           +int(st[2])




print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def ii(): return int(input())
def iis(): return input().split()
def imi(): return map(int,iis())
def iil(): return list(imi())


factmemo={0:1} #階乗
def fact(n):
    if n in factmemo:
        return factmemo[n]
    k = n*fact(n-1)
    factmemo[n]=k
    return k

def comb(a,b):
    if a-b < 0:
        return 0
    return fact(a)//(fact(a-b)*fact(b)) #組み合わせ

def aaa(n,k):
    r = len(str(n))-1
    st = str(n)
    ans = 0
    if k==1 and r>=0:
        ans += 9*r \
               + int(st[0])
    elif k==2 and r>=1:
        ans += 9**2 * comb(r, 2) \
               + (int(st[0])-1) * 9**1 * comb(r, 1) \
               + aaa(n%(10**r), k-1)
    elif k==3 and r>=2:
        ans += comb(r, 3)*9**3\
               +comb(r, 2)*9**2*(int(st[0])-1)\
               +aaa(n%(10**r), k-1)
    return ans

n = int(input())
k = int(input())
ans = aaa(n,k)
print(ans)
#スペース区切りの整数の入力
N,M = map(int, input().split())
#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

sum_ = 0
for i in range(len(A_list)):
  sum_ = sum + A_list[i]
  
ans = N - sum_

print(ans)

### FIXED CODE ###

#スペース区切りの整数の入力
N,M = map(int, input().split())
#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

sum_ = 0
for i in range(len(A_list)):
  sum_ = sum_ + A_list[i]
  
  
ans = N - sum_
if(ans>=0):
  print(ans)
else:
  print("-1")
x = int(input())
if x >= 1200:
	pirnt('ARC')
else:
    print('ABC')


### FIXED CODE ###

x = int(input())
if x >= 1200:
	print('ARC')
else:
    print('ABC')
N=int(input())
s=[input() for i in range (N)]

for q in range N:
  for i in range N-1:
    if s[i]>s[i+1]:
      s0=s[i]
      s[i]=s[i+1]
      s[i+1]=s0

count=1
maximum=0

for j in range N-1:
  if s[j]=s[j+1]:
    count+=1
  else:
    if count>maximum:
      a=[]
      a.append(s[j])
      maximum=count
      number=1
    elif count=maximum:
      a.append(s[j])
      number+=1
    count=0
    
for p in range number:
  print(a[p])

### FIXED CODE ###

N=int(input())
s=[input() for i in range (N)]

s.sort()
count=1
maximum=0

for j in range (N-1):
  if s[j]==s[j+1]:
    count+=1
    if j==N-2:
      if count>maximum:
        a=[]
        a.clear()
        a.append(s[j])
        maximum=count
        number=1
      elif count==maximum:
        a.append(s[j])
        number+=1
  else:
    if count>maximum:
      a=[]
      a.clear()
      a.append(s[j])
      maximum=count
      number=1
    elif count==maximum:
      a.append(s[j])
      number+=1
    count=1   
  if maximum==1 and j==N-2:
    a.append(s[N-1])
    number+=1
for p in range (number):
  print(a[p])
n,m = map(int,input().split())
H = list(map(int,input().split()))

l = [1] * n

for i in range(n):
  A,B = map(int,input().split())
  if H[A-1] > H[B-1]:
    l[B - 1] = 0
  elif H[A - 1] < H[B - 1]:
    l[A - 1] = 0
  elif H[A - 1] == H[B - 1]:
    l[A - 1], l[B - 1] = 0, 0
print(l.count(1))


### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
l = [1] * N
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        l[B - 1] = 0
    elif H[A - 1] < H[B - 1]:
        l[A - 1] = 0
    elif H[A - 1] == H[B - 1]:
        l[A - 1], l[B - 1] = 0, 0
print(l.count(1))
print(sum([int(i) for i in range(int(input()))]))

### FIXED CODE ###

S = input()
T = input()

counter = 0

for i in range(0,3):
  if S[i] == T[i]:
    counter += 1
    
print(counter)
s = input()
while 1:
    if len(S) == 0:
        print("YES")
        break
    if s[len(s)-5:] == "dream":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-7:] == "dreamer":
        s = s[:len(s)-7]
        continue
    elif s[len(s)-5:] == "erase":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-6:] == "eraser":
        s = s[:len(s)-6]
        continue
    else:
        print("NO")
        break
    

### FIXED CODE ###

s = input()
while 1:
    if len(s) == 0:
        print("YES")
        break
    if s[len(s)-5:] == "dream":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-7:] == "dreamer":
        s = s[:len(s)-7]
        continue
    elif s[len(s)-5:] == "erase":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-6:] == "eraser":
        s = s[:len(s)-6]
        continue
    else:
        print("NO")
        break
import math

a,b = map(int,input().split())
print(math.ciel((a+b)/2))

### FIXED CODE ###

import math

a,b = map(int,input().split())
print(math.ceil((a+b)/2))
while True:
    num = input()
    if(num == 0): break
    ret = 0
    for i in num:
        ret += int(i)
    print(ret)


### FIXED CODE ###

while True:
    num = input()
    if(num == "0"): break
    ret = 0
    for i in num:
        ret += int(i)
    print(ret)
import sys
import numpy as np
import random
import math
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	x, y = 1, 1
	for _ in range(n):
		t, a = LI()
		m = max((x+t-1)//a,(y+a-1)//b)
		x, y = m*t, m*a
	print(x+y)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import numpy as np
import random
import math
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	x, y = 1, 1
	for _ in range(n):
		t, a = LI()
		m = max((x+t-1)//t,(y+a-1)//a)
		x, y = m*t, m*a
	print(x+y)


if __name__ == '__main__':
    main()
N,K = map(int, input().split())
p = input().split()

p.sort()
print(sum(p[0:k]))


### FIXED CODE ###

N,K = map(int, input().split())
p = list(map(int, input().split()))

p.sort()
print(sum(p[0:K]))
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
def mcost(arr,n,dp):
    if n==1:return 0
    if dp[n]!=-1:return dp[n]
    if n==2:
        dp[n]=abs(arr[1]-arr[0])
        return dp[n]
    elif n==3:
        dp[n]=abs(arr[0]-arr[2])
        return dp[n]
    else:
        dp[n]=min(abs(arr[n-1]-arr[n-2])+mcost(arr,n-1,dp),abs(arr[n-1]-arr[n-3])+mcost(arr,n-2,dp))
        return dp[n]


try:
    for _ in range(1):
        n=int(input())
        arr=[int(i) for i in input().split()]
        dp=[-1]*(n+1)
        print(mcost(arr,n,dp))
    
except EOFError as e:
    print(e)


### FIXED CODE ###

import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
sys.setrecursionlimit(10**7)
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
def mcost(arr,n,dp):
    if n==1:return 0
    if dp[n]!=-1:return dp[n]
    if n==2:
        dp[n]=abs(arr[1]-arr[0])
        return dp[n]
    elif n==3:
        dp[n]=abs(arr[0]-arr[2])
        return dp[n]
    else:
        dp[n]=min(abs(arr[n-1]-arr[n-2])+mcost(arr,n-1,dp),abs(arr[n-1]-arr[n-3])+mcost(arr,n-2,dp))
        return dp[n]


try:
    for _ in range(1):
        n=int(input())
        arr=[int(i) for i in input().split()]
        dp=[-1]*(n+1)
        print(mcost(arr,n,dp))
    
except EOFError as e:
    print(e)
s = input()
k = int(input())
ans = "1"
for i in s[:k]:
    if a!= "1":
        ans = a
        exit()
print(ans)

### FIXED CODE ###

s = input()
k = int(input())
ans = "1"
for i in s[:k]:
    if i != "1":
        ans = i
        break
print(ans)
A, B = list(map(int, input().split()))
print(A * B

### FIXED CODE ###

A, B = list(map(int, input().split()))
print(A * B)
import collections
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=collections.Counter(A).most_common()

print(sum(B[::-1][:K][i][1] for i in range(len(B[K:]))))

### FIXED CODE ###

from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!=c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] == -1: num[i] = 0
if num[0] == 0 and len(num)!=1: num[0] = 1
print(int(''.join(num)))

### FIXED CODE ###

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

num = 0
dic = {}

for i in range(m):
  s,c = map(int, input().split())
  if n!=1 and s==1 and c==0: 
    print(-1)
    exit()
  if s not in dic:
    dic[s] = c
    num = num + c*(10**(n-s))
  elif c!=dic[s]:
    print(-1)
    exit()

if 1 not in dic and n>1:
  num = num + 10**(n-1)

print(num)
base = ['A','T','C','G']

ind = base.index(input())
if(ind%2 == 0):
  printf(base[ind+1])
else:
  printf(base[ind-1])

### FIXED CODE ###

base = ['A','T','C','G']
 
ind = base.index(input())
if(ind%2 == 0):
  print(base[ind+1])
else:
  print(base[ind-1])
x = map(int, input())

def is_sosu(num):
  st = 2
  while st <= num:
    if num % st == 0:
      print(num)
      return
    st += 1
  else:
    st += 1
    if num == st:
      is_sosu(num+1)

is_sosu(x)

### FIXED CODE ###

x = input()

def is_sosu(num):
  st = 2
  while True:
    if num % st == 0:
      break
    st += 1
  if st == num:
    print(num)
    return
  is_sosu(num+1)

is_sosu(int(x))
# coding: utf-8
# Here your code !
data = input()

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






### FIXED CODE ###

# coding: utf-8
# Here your code !
data = input()

if data == "SUN":
    print(7)
elif data == "MON":
    print(6)
elif data == "TUE":
    print(5)
elif data == "WED":
    print(4)
elif data == "THU":
    print(3)
elif data == "FRI":
    print(2)
elif data == "SAT":
    print(1)
from fractions import gcd
A,B,C,D = map(int,input())
N=B-A+1
print(N-(N//C)-(N//D)+(N//(gcd(C,D))))

### FIXED CODE ###

from fractions import gcd
A,B,C,D = map(int,input().split())

Ans = []

for i in [B,A-1]:
  N = i
  E = (C * D) // gcd(C,D)
  modC = N//C
  modD = N//D
  modE = N//E
  Ans += [N - modC - modD + modE]
  
print(Ans[0]-Ans[1])