Harryxun/stf_run huggingface dataset:
n, z, w = map(int, input().split())
a = list(map(int, input().split()))

cache = {}

def f(idx, turn, x, y):
    if idx == n:
        return abs(x - y)
    
    key = (idx, turn)
    if key in cache:
        return cache[key]

    if turn == 0:
        ans = -float('inf')
        for i in range(idx, n):
            ans = max(ans, f(i + 1, 1 - turn, a[i], y))
    else:
        ans = float('inf')
        for i in range(idx, n):
            ans = min(ans, f(i + 1, 1 - turn, x, a[i]))

    cache[key] = ans
    return cache[key]



print(f(0, 0, z, w))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

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

cache = {}

def f(idx, turn, x, y):
    if idx == n:
        return abs(x - y)
    
    key = (idx, turn)
    if key in cache:
        return cache[key]

    if turn == 0:
        ans = -float('inf')
        for i in range(idx, n):
            ans = max(ans, f(i + 1, 1 - turn, a[i], y))
    else:
        ans = float('inf')
        for i in range(idx, n):
            ans = min(ans, f(i + 1, 1 - turn, x, a[i]))

    cache[key] = ans
    return cache[key]

print(f(0, 0, z, w))
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,K = map(int, lines.pop(0).split(' '))
    NLIST = list(range(A,B+1))
    res = list(set(NLIST[:K] +  NLIST[-K:]))
    for i in res:
        print(i)

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,K = map(int, lines.pop(0).split(' '))
    NLIST = set()
    for i in range(K):
        if A+i <= B:
            NLIST.add(A+i)
        if A <= B-i:
            NLIST.add(B-i)

    NLIST = list(NLIST)
    NLIST.sort()
    for i in NLIST:
        print(i)

#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
a,b = map(int,input().split())  
c = a * b 
if c % 2 == 0:     
    print("Even") 
else:     
    print("Odd")


### FIXED CODE ###

a,b = map(int,input().split())
c = a * b
if c % 2 == 0:
    print("Even")
else:
    print("Odd")
import sys

def tax(p,x):
    return int(p*(100+x)/100)


while True:
    x,y,s=[int(i) for i in  input().split(" ")]

    if x==0 and y==0 and s==0:
        sys.exit()

    maximum=0
    for i in range(1,s-1):
        for j in range(1,s-1):
            if tax(i,x)+tax(j,x)==s:
                maximum=max(tax(i,y)+tax(j,y),maximum)

    print(maximum)

### FIXED CODE ###

import sys

def tax(p,x):
    return int(p*(100+x)/100)


while True:
    x,y,s=[int(i) for i in  input().split(" ")]

    if x==0 and y==0 and s==0:
        sys.exit()

    maximum=0
    p=int(100*s/(100+x))
    for i in range(1,s):
        for j in range(p-i-3,p-i+3):
            if tax(i,x)+tax(j,x)==s and j>0:
                maximum=max(tax(i,y)+tax(j,y),maximum)

    print(maximum)
def resolve():
    S = input()
    a = 0
    for i in range(len(S) - 1):
        if (S[i] == S[i + 1]):
            a = 1
    if (a == 0):
        print("Good")
    else:
        print("Bad")
resoluve()

### FIXED CODE ###

import sys
from io import StringIO
import unittest
def resolve():
    S = input()
    a = 0
    for i in range(len(S) - 1):
        if (S[i] == S[i + 1]):
            a = 1
    if (a == 0):
        print("Good")
    else:
        print("Bad")
resolve()
n,m = map(int,input().split())
MOD = 10 ** 9 + 7

def combo(p,q):
    if p == 0:
        return 1
    elif q == 0 or q == p:
        return 1
    else:
        ret = (combo(p-1,q-1) + combo(p-1,q)) % MOD
        return ret

#print(combo(2,1))


fac = [0] * (m+1)
mm = m
for i in range(2,m+1):
    while mm % i == 0:
        mm = mm // i
        fac[i] += 1
        #print(mm,fac)

count = 1

for i in range(2,m+1):
    if fac[i] >= 1:
        count = (count * combo(fac[i]+n-1,fac[i])) % MOD
    #print(count)
    
print(count)

### FIXED CODE ###

n,m = map(int,input().split())
mod = 10 ** 9 + 7

def combo(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    else:
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod



N = n + 100
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

#print(combo(2,1))

#print(m)
fac = {}
mm = m
#print(mm)
count = 0
while mm % 2 == 0:
    count += 1
    mm //= 2
if count > 0:
    fac[2] = count
f = 3
count = 0
while f ** 2 <= mm:
    while mm % f == 0:
        count += 1
        mm //= f
        #print(f,count)
    if count > 0:
        fac[f] = count
        count = 0
    f += 2
    #print(fac)
if mm != 1:
    if mm in fac:
        fac[mm] += 1
    else:
        fac[mm] = 1
#print(fac)

count = 1

for i in fac:
    if fac[i] >= 1:
        count = (count * combo(fac[i]+n-1,fac[i],mod)) % mod
    #print(count)
    
print(count)
zimport sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

A,B = MI()
print(A*B)


### FIXED CODE ###

import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

A,B = MI()
print(A*B)
a, b, c = map(int, input().split())
rest = set()
for i in range(b):
    rest.add(a * i % b)
if c in list(set):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a, b, c = map(int, input().split())
rest = set()
for i in range(b):
    rest.add(a * i % b)
if c in list(rest):
    print("YES")
else:
    print("NO")
n,m=map(int,input().split())
mod=10**9+7
if n==1:
  print(1)

if n>1:
  a=[1]*n
  for i in range(m):
    a[int(input())-1]=0
  a[1]=a[0]+1
  for i in range(2,n):
    if a[i]==0:continue
    else:a[i]=a[i-1]+a[i-2]
print(a[n-1]%mod)

### FIXED CODE ###

n,m=map(int,input().split())
mod=10**9+7

a=set([int(input()) for i in range(m)])

dp=[0]*(n+1)
dp[0]=1

for i in range(1,n+1):
  dp[i]=(dp[i-1]+dp[i-2])%mod
  if i in a:dp[i]=0
print(dp[n])
s = input()
print(s.count("1!)

### FIXED CODE ###

s = input()
print(s.count("1"))
n = int(input())
apple = []

number = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in number:
    if i - n > 0:
        apple.append(i)
    else:
        pass

print(min(apple))

### FIXED CODE ###

n = int(input())
apple = []

number = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in number:
    if i - n >= 0:
        apple.append(i)

print(min(apple))
n = int(input())
h = list(map(int, input().split()))
ans = []
for i in range(0,n-1):
  if h[i] < h[i+1]:
    ans.append(count)
    count = 0
  if h[i] >= h[i+1]:
    count+= 1
print(max(ans))

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
ans = -1*float('inf')
cnt = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
ans = max(ans, cnt)
print(ans)
n, x = [ int(v) for v in input().split() ]
candy_list = sorted([ int(v) for v in input().split() ])
candy_list_2 = cumsum(candy_list)

if sum(candy_list) <= x:
    print(n)
else:
    for i in range(n):
        if candy_list_2[i] > x:
            print(i)
            break 


### FIXED CODE ###

def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

n, x = [ int(v) for v in input().split() ]
candy_list = sorted([ int(v) for v in input().split() ])
candy_list_2 = cumsum(candy_list)

ans = 0
for i in range(n):
    if i != n-1 and candy_list_2[i] <= x:
        ans += 1
    elif i == n-1 and candy_list_2[i] == x:
        ans += 1
print(ans)
import datetime
a = input().split("/")

date1 = datetime.datetime(a[0], a[1], a[2])
date2 = datetime.datetime(2019, 4, 30)

if date1 > date2:
    print("TBD")
else:
    print("Heisei")

### FIXED CODE ###

import datetime
a = input().split("/")

date1 = datetime.datetime(int(a[0]), int(a[1]), int(a[2]))
date2 = datetime.datetime(2019, 4, 30)

if date1 > date2:
    print("TBD")
else:
    print("Heisei")
#N,K入力
N,K= map(int,input().split())
#街の番号入力
A = [int(i) for i in input().split()]

# 重複した要素があるかどうかを判定
def has_duplicates(seq):
    return len(seq) == len(set(seq))

#移動経路
warp = [1]
a = 1

#同じ街にたどり着くまでループ
while has_duplicates(warp):
    a = A [a - 1]
    warp.append(a)
    #同じ街にたどり着かなかった場合はこっち
    if len(warp) == K +1:
        print(warp[K])
        break

l = [i for i, x in enumerate(warp) if x == a]

# 何回ワープしたらループする街に戻ってくるか
width = l[1] - l[0]

#　ループのどこに行くか
d = (K - l[0]) % (l[1]-l[0])

#結果の出力
print(A[d + l[0]])

### FIXED CODE ###

#N,K入力
N,K= map(int,input().split())
#街のテレポート先入力
A = [int(i)-1 for i in input().split()]
judge = [-1] * N
judge[0] = 0
#初期位置
a = 0
#移動回数
step = 1

while step != K +1:
    #移動する街を決める
    a = A[a]
    if judge[a] > -1:
        break
    #何回目の移動なのか加える
    judge[a] = step
    step = step + 1

if step == K +1:
    print(a+1)
    # プログラム終了
else:
    width = step - judge[a]
    s =(K - judge[a]) % width
    print(judge.index(judge[a]+s)+1)
import sys
from collections import Counter
import bisect


# \n
def input():
    return sys.stdin.readline().rstrip()


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

    AA = Counter(A)
    BB = Counter(B)

    max_con = 1
    conA = 0

    for key, value in AA.items():
        if not BB[key]:
            continue

        if BB[key] + value > max_con:
            max_con =BB[key] + value
            conkey = key

        if BB[key] + value > N:
            print("No")
            exit()

    print("Yes")

    A_key = bisect.bisect_right(A, conkey)
    B_key = bisect.bisect_left(B, conkey)


    S=[0]*N

    for i in range(N):
        S[(i+A_key)%N] =B[(B_key+i)%N]

    print(*S)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import heapq
from functools import lru_cache


# \n
def input():
    return sys.stdin.readline().rstrip()


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

    n = N // 3

    @lru_cache(maxsize=None)
    def diff(s):
        count = 0
        for i in range(N):
            if A[i] == B[(i + s) % N]:
                count += 1

        if count == 0:
            print("Yes")
            L = []
            for i in range(N):
                L.append(B[(i + s) %N])
            print(*L)
            exit()

        return count

    l = 0
    r = N - 1
    diff(l)
    diff(r)

    while r - l > 2:
        a = diff(l + (r - l) // 3)
        b = diff(l + 2 * (r - l) // 3)
        if a > b:
            l = l + (r - l) // 3
        else:
            r =l + 2 * (r - l) // 3
    diff((l+r)//2)

    print("No")


if __name__ == "__main__":
    main()
from numba import njit

@njit
def solve():
    n, k = map(int,input().split())
    l = list(map(int,input().split()))
    
    if k >= 50:
        k = 50
    
    dp = [[0] * 2 for i in range(n)]
    
    ans = l[:]
    
    for i in range(k):
        for j in range(n):
            tmp = ans[j]
            dp[j][0] = (j+1 - tmp)
            dp[j][1] = (j+1 + tmp)
    
        ans = [0] * n
    
        for x in range(n):
            for y in range(n):
                if dp[y][0] <= x+1 <= dp[y][1]:
                    ans[x] += 1
    
    else:
        return ans

print(*solve())



### FIXED CODE ###

import numpy as np
from numba import njit

@njit #処理の並列化

def imos(n, a):
    
    l=np.zeros((n+1), dtype = np.int64)

    for i in range(n):
        ai = a[i] # 光の強さ_これにより照らせる範囲が決まる
        start = max(0, i - ai) #StartIndex_照らせる範囲
        end = min(n, i + ai + 1) #EndIndex + 1_照らせる範囲
        l[start] += 1 # 各々を'+1'と'-1'で表し...
        l[end] -= 1
    return np.cumsum(l)[:n] # 累積和をとる_cumulative sum

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

for _ in range(k):
    a = imos(n, a)
    if a.min() == n: # すべての要素が最大値'n'になるとbreak
        break

print(*a)
l , r = map(int,input().split())

if r - l >= 2020:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            p.append((i*j)%2019)
    print(min(p))

### FIXED CODE ###

l , r = map(int,input().split())
p = []
if r - l >= 2018:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            p.append((i*j)%2019)
    print(min(p))
from collections import defaultdict
from numba import njit, b1, i4, i8, f8

def get_prime_factors(x):
    out = set()
    if x < 1:
        return out
    while not x%2:
        out.add(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.add(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.add(x)
    return out


def main():
    n = int(input())
    a = list(map(int, input().split()))
    df = defaultdict(lambda : 0)
    
    @njit((i8, i8, i8[:]), cache=True)
    for ai in a:
        primes = get_prime_factors(ai)
        for prime in primes:
            df[prime] += 1
    if df.values():
        val = max(df.values())
        if val == 1:
            print("pairwise coprime")
        elif val == n:
            print("not coprime")
        else:
            print("setwise coprime")
    else:
        print("pairwise coprime")

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import defaultdict


def get_prime_factors(x):
    out = set()
    if x < 1:
        return out
    while not x%2:
        out.add(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.add(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.add(x)
    return out


def main():
    n = int(input())
    a = list(map(int, input().split()))
    df = defaultdict(lambda : 0)
    for ai in a:
        primes = get_prime_factors(ai)
        for prime in primes:
            df[prime] += 1
    if df.values():
        val = max(df.values())
        if val == 1:
            print("pairwise coprime")
        elif val == n:
            print("not coprime")
        else:
            print("setwise coprime")
    else:
        print("pairwise coprime")

if __name__ == "__main__":
    main()
pi = 3.14159265359 
r = int(input()) 
area = pi*r*r 
length = pi*r*2 

print('{:.6f}'.format(area),'{:.6f}'.format(length))


### FIXED CODE ###

pi = 3.14159265359 
r = float(input()) 
area = r*r*pi 
length = 2*r*pi 

print('{:.6f}'.format(area),'{:.6f}'.format(length))
N = int(input())
A = [int(hoge) for hoge in input().split()]
ans = 1
cur = A[0]
Decided = A[0] != A[1]
Flat = A[0] == A[1]
Up = A[0] < A[1]
for n in range(1,N):
    if Decided:
        if (A[n]>=cur) == Up:#数列が続く
            cur = A[n]
        else:
            cur = A[n]
            Up = 1 -  Up
            Decided = False
            ans += 1
    else:
        if A[n] != cur:
            Up = A[n] > cur
            cur = A[n]
            Decided = True
print(ans)

### FIXED CODE ###

N = int(input())
if N == 1:print(1);exit()
A = [int(hoge) for hoge in input().split()]
ans = 1
cur = A[0]
Decided = A[0] != A[1]
Flat = A[0] == A[1]
Up = A[0] < A[1]

for n in range(1,N):
    if Decided:
        if A[n] == cur:
            continue
        if (A[n]>=cur) == Up:#数列が続く
            cur = A[n]
        else:
            cur = A[n]
            Up = 1 - Up
            Decided = False
            ans += 1
    else:
        if A[n] != cur:
            Up = A[n] > cur
            cur = A[n]
            Decided = True
print(ans)
import sys
sys.setrecursionlimit(10**8)

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

dp = [float("inf")] * n #dpテーブル
#dp[i]メモ化テーブル

def rec(i):#再帰による全探索
    if dp[i] != float("inf"):
        return dp[i]
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[0]-h[1])
    else:
        return dp[i] = min(rec(i-1)+abs(h[i]-h[i-1]),rec(i-2)+abs(h[i]-h[i-2]))

print(rec(n-1))


### FIXED CODE ###

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

dp = [float("inf")] * n #dpテーブル
#dp[i]:=i番目の足場まで来るのに必要な最小コスト

#初期条件
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]) ,dp[i-2] + abs(h[i-2]-h[i]))

print(dp[n-1])
in = raw_input().split()
N = in[0]
P = in[1:]

Q = range(N)

for i in range(N):
	Q[P[i]-1] = i+1

count = 0
max = 0
for i in range(N-1):
	if Q[i]<Q[i+1]:
		count+=1
	else:
		count=0
	
	if max < count:
		max = count

print N-count-1

### FIXED CODE ###

N = int(raw_input())
P = []
for i in range(N):
	P.append(int(raw_input()))

Q = range(N)

for i in range(N):
	Q[P[i]-1] = i+1

count = 0
max = 0
for i in range(N-1):
	if Q[i]<Q[i+1]:
		count+=1
	else:
		count=0
	
	if max < count:
		max = count

print N-max-1
# ABC122_B
s = input()
ACGT = ['A', 'C', 'G', 'T']

cnt_list = []
cnt = 0
for i in s:
    for k in ACGT:
        if i == k:
            cnt += 1
        if all([i != k for k in ACGT]):
            cnt_list.append(cnt)
            cnt = 0
print(max(cnt_list))

### FIXED CODE ###

s =input()
s += ' '
ACGT = ['A', 'C', 'G', 'T']

cnt_list = []
cnt = 0
for i in s:
    if i in ACGT:
        cnt += 1
    else:
        cnt_list.append(cnt)
        cnt = 0
print(max(cnt_list))
from collections import defaultdict
from itertools import combinations
import sys
input = sys.stdin.readline

n = int(input())
s = [input().split()[0] for _ in range(n)]
cnt = defaultdict(int)
for i in range(n):
    s[i].sort()
    cnt["".join(s[i])] += 1
result = 0
for c in cnt:
    result += len(list(combinations([""] * cnt[c], 2)))
print(result)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
s = ["".join(sorted(input().split()[0])) for _ in range(n)]
cnt = {}
result = 0
for si in s:
    if si in cnt:
        result += cnt[si]
        cnt[si] += 1
    else:
        cnt[si] = 1
print(result)
from collections import deque

H, W, K=map(int, input().split())
cake=[input() for _ in range(H)]
rows_list=[]
upper=0
for i in range(H):
  for j in range(W):
    if cake[i][j]=="#":
      rows_list.append([upper, i])
      upper=i+1
      break
rows_list[-1][-1]=H-1
ans_list=[]
for rows in rows_list:
  for i in range(rows[0], rows[1]+1):
    left=0
    for j in range(W):
      if cake[i][j]=="#":
        ans_list.append([rows[0], rows[1], left, j])
        left=j+1
    ans_list[-1][-1]=W-1
ans=[[0 for _ in range(W)] for _ in range(H)]
key=1
for l in ans_list:
  for i in range(l[0], l[1]+1):
    for j in range(l[2], l[3]+1):
      ans[i][j]=key
  key+=1
for a in ans:
  print(*a)

### FIXED CODE ###

from collections import deque

H, W, K=map(int, input().split())
cake=[input() for _ in range(H)]
rows_list=[]
upper=0
for i in range(H):
  for j in range(W):
    if cake[i][j]=="#":
      rows_list.append([upper, i])
      upper=i+1
      break
rows_list[-1][-1]=H-1
ans_list=[]
for rows in rows_list:
  for i in range(rows[0], rows[1]+1):
    left=0
    for j in range(W):
      if cake[i][j]=="#":
        ans_list.append([rows[0], rows[1], left, j])
        left=j+1
    if ans_list:
      ans_list[-1][-1]=W-1
ans=[[0 for _ in range(W)] for _ in range(H)]
key=1
for l in ans_list:
  for i in range(l[0], l[1]+1):
    for j in range(l[2], l[3]+1):
      ans[i][j]=key
  key+=1
for a in ans:
  print(*a)
import math
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if N > 1:
    mini = min([x[1] - x[0],  abs(X - x[0])])
elif N == 1:
    mini = abs(x[0] - X)
for i in range(1, N):
    if mini > min([x[i] - x[i - 1], abs(X - x[i])]):
        mini = min([x[i] - x[i - 1], abs(X - x[i])])
    if (x[i] - x[i - 1]) % mini != 0:
        mini = math.gcd(mini, x[i] - x[i - 1])
    if abs(X - x[i]) % mini != 0:
        mini = math.gcd(mini, X - x[i])
        

print(mini)


### FIXED CODE ###

import fractions
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if N > 1:
    mini = x[1] - x[0]
    if mini > abs(X - x[0]) and abs(X - x[0]) != 0:
        mini = abs(X - x[0])
elif N == 1:
    mini = abs(x[0] - X)
for i in range(1, N):
    if mini > x[i] - x[i - 1]:
        mini = x[i] - x[i - 1]
    if mini> abs(X - x[i]) and abs(X - x[i]) != 0:
        mini = abs(X - x[i])
    if (x[i] - x[i - 1]) % mini != 0:
        #break
        mini = fractions.gcd(mini, x[i] - x[i - 1])
    if abs(X - x[i]) % mini != 0:
        #break
        mini = fractions.gcd(mini, X - x[i])
        

print(mini)
def run():
    n = int(input())
    nodes = []
    for _ in range(n):
        order = [o.strip() for o in input().split()]
        if order[0] == 'insert':
            nodes.insert(0, (int(order[1]))
        elif order[0] == 'delete':
            if int(order[1]) in nodes:
                nodes.remove(int(order[1]))
        elif order[0] == 'deleteFirst':
            nodes.pop(0)
        elif order[0] == 'deleteLast':
            nodes.pop()
    print(' '.join([str(n) for n in nodes]))
    
if __name__ == '__main__':
    run()




### FIXED CODE ###

from collections import deque

def run():
    n = int(input())
    dq = deque()
    for _ in range(n):
        order = input()
        if order[0] == 'i':
            dq.appendleft(order[7:])
        elif order[6] == ' ':
            key = order.split()[1]
            if not key in dq:
                continue
            for i in range(len(dq)):
                if dq[i] == key:
                    dq.remove(key)
                    break
        elif order[6] == 'F':
            dq.popleft()
        elif order[6] == 'L':
            dq.pop()

    print(' '.join(dq))

if __name__ == '__main__':
    run()
while 1:
	n,a,b = map(int,raw_input().split())
	if n == 0: break
	dp = [0]*(max(n,a,b)+1)
	dp[a] = dp[b] = 1
	for i in range(n+1-min(a,b)):
		if dp[i]:
			dp[i+a] = dp[i+b] = 1
	print n - sum(dp[:n+1])

### FIXED CODE ###

while 1:
	n,a,b = map(int,raw_input().split())
	if n == 0: break
	S = [1]*(n+1)
	for i in range(a):
		s = b*i
		while s <= n:
			S[s] = 0
			s += a
	print sum(S)