Harryxun/stf_run huggingface dataset:
N = int(input())
a1, a2, a3 = map(int, input().split())
b1, b2, b3 = map(int, input().split())
A = [a1, a2, a3]
B = [b1, b2, b3]
if (a1<=b1 and a2<=b2 and a3<=b3) or (a1>=b1 and a2>=b2 and a3>=b3):
    if a1>b1 or a2>b2 or a3>b3:
        A, B = B, A
    dp = [[-float("inf")]*(N+1+5050) for _ in range(4)]
    dp[0][0] = 0
    for i in range(3):
        ai = A[i]
        bi = B[i]
        for j in range(N+1):

            dp[i+1][j] = max(dp[i][j], dp[i+1][j-ai]+bi)
    print(max(dp[3]))
    #print(dp[3][:30])
else:
    C, D = [], []
    for a, b in zip(A, B):
        if a <= b:
            C.append([a,b])
        else:
            D.append([b, a])

    if len(C)==1:
        a, b = C[0]
        q, n = divmod(N, a)
        N_ = q*b + n
    else:
        N_ = N
        (a1, b1), (a2, b2) = C
        for i in range(N + 1):
            j = N - i
            q1, n1 = divmod(i, a1)
            q2, n2 = divmod(j, a2)
            N_ = max(N_, q1 * b1 + q2 * b2 + n1 + n2)

    if len(D)==1:
        a, b = D[0]
        q, n = divmod(N_, a)
        print(q*b + n)
        #print("a")
    else:
        assert False
        ans = N_
        (a1, b1), (a2, b2) = D
        for i in range(N_+1):
            j = N_ - i
            q1, n1 = divmod(i, a1)
            q2, n2 = divmod(j, a2)
            ans = max(ans, q1*b1+q2*b2+n1+n2)
        print(ans)


### FIXED CODE ###

N = int(input())
a1, a2, a3 = map(int, input().split())
b1, b2, b3 = map(int, input().split())
A = [a1, a2, a3]
B = [b1, b2, b3]
if (a1<=b1 and a2<=b2 and a3<=b3) or (a1>=b1 and a2>=b2 and a3>=b3):
    if a1>b1 or a2>b2 or a3>b3:
        A, B = B, A
    dp = [[-float("inf")]*(N+1) for _ in range(4)]
    dp[0][0] = 0
    for i in range(3):
        ai = A[i]
        bi = B[i]
        for j in range(N+1):
            if j-ai>=0:
                dp[i+1][j] = max(dp[i][j], dp[i+1][j-ai]+bi)
            else:
                dp[i+1][j] = dp[i][j]
    ans = 0
    for i, v in enumerate(dp[3]):
        ans = max(ans, v+(N-i))
    print(ans)

    #print(dp[3][:30])
else:
    C, D = [], []
    for a, b in zip(A, B):
        if a <= b:
            C.append([a, b])
        else:
            D.append([b, a])

    if len(C)==1:
        a, b = C[0]
        q, n = divmod(N, a)
        N_ = q*b + n
    else:
        N_ = N
        (a1, b1), (a2, b2) = C
        for i in range(N + 1):
            j = N - i
            q1, n1 = divmod(i, a1)
            q2, n2 = divmod(j, a2)
            N_ = max(N_, q1 * b1 + q2 * b2 + n1 + n2)

    if len(D)==1:
        a, b = D[0]
        q, n = divmod(N_, a)
        print(q*b + n)
        #print("a")
    else:
        ans = N_
        (a1, b1), (a2, b2) = D
        for i in range(N_+1):
            j = N_ - i
            q1, n1 = divmod(i, a1)
            q2, n2 = divmod(j, a2)
            ans = max(ans, q1*b1+q2*b2+n1+n2)
        print(ans)
s = input()
if s == "SAT":
  print(1)
elif s == "FRI":
  print(2)
elif s == "THU":
  print(3)
elif s == "WED":
  print(4)
elif s == "TUE":
  print(5)
elif s == "MON:
  print(6)
else:
  print(7)

### FIXED CODE ###

s = input()
if s == "SAT":
  print(1)
elif s == "FRI":
  print(2)
elif s == "THU":
  print(3)
elif s == "WED":
  print(4)
elif s == "TUE":
  print(5)
elif s == "MON":
  print(6)
else:
  print(7)
a,b,c,d,e,k= map(int, input().split())

A-B = b-a
A-C = c-a
A-D = d-a
A-E = e-a
B-C = c-b
B-D = d-b
B-E = e-b
C-D = d-c
C-E = e-c
D-E = e-d

if A-B and A-C and A-D and A-E and B-C and B-E and C-D and C-E and D-E > k :
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())



if e-a > k:
    print(":(")
else:
    print("Yay!")
import numpy as np
K = int(input())
lis = ['1','2','3','4','5','6','7','8','9']
lis = np.array(lis)
if K == 1:
  print(1)
elif K < 10:
  print(K)
else:
  count = 9
  sub_count = 0
  while count < K:
    if lis[sub_count][-1] == '9':
      count += 2
      lis.append(lis[sub_count] + '8')
      lis.append(lis[sub_count] + '9')
      sub_count += 1
    elif  lis[sub_count][-1] == '0':
      count += 2
      lis.append(lis[sub_count] + '0')
      lis.append(lis[sub_count] + '1')
      sub_count += 1
    else:
      count += 3
      for i in range(-1,2):
        lis.append(lis[sub_count] + str(int(lis[sub_count][-1]) + i))
      sub_count += 1
  print(lis[count-1])

### FIXED CODE ###

import queue
K = int(input())
q = queue.Queue()
count = 0
for i in range(1,10):
  q.put(str(i))
while count < K:
  tmp = q.get()
  count += 1
  if count == K:
    print(tmp)
    break
  if tmp[-1] == '0':
    for add in ['0', '1']:
      q.put(tmp + add)
  elif tmp[-1] == '9':
    for add in ['8', '9']:
      q.put(tmp + add)
  else:
    for add in [str(int(tmp[-1]) - 1),tmp[-1], str(int(tmp[-1]) + 1)]:
      q.put(tmp + add)
N,X,T=map(int, raw_input().split())
mod=int((N/X))*T
if N%X!=0:
  print(mod)
else:
  print(mod+T)

### FIXED CODE ###

n,x,t= map(int, input().split())
if n%x==0:
  print( int((n/x))*t )
else:
  print(int((n/x + 1))*(t))
def main(a):
  print("aaa")
  
if __name__ == "__main__":
  main(a)

### FIXED CODE ###

def main():
  a = list(input().split())
  a = [int(aa) for aa in a]
  a = sorted(a)
  if a==[5,5,7]:
    print('YES')
  else:
    print('NO')
  
  
if __name__ == "__main__":
  main()
import math
a,b,h,m=map(int,input().split())
 
dh=30*h+m/2
dm=6*m
 
if dm==dh:
    length=abs(a-b)
else:
    rad=abs(dm-dh)
    
if rad>180:
    rad-=180
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif 0<rad and rad<180:
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif rad==180:
    length=a+b
    
print(length)

### FIXED CODE ###

import math
a,b,h,m=map(int,input().split())
 
dh=30*h+m/2
dm=6*m
 
if dm==dh:
    rad=0
else:
    rad=abs(dm-dh)
    
if rad>180:
    rad=360-rad
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif 0<rad and rad<180:
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif rad==180:
    length=a+b
    
else:
    length=abs(a-b)
    
print(length)
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))

N,M = LI()
A = LI()
ans = N - sum(A)
if ans < 0:
    ans = -1
print (ans)

### FIXED CODE ###

import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

R = NI()
print (2 * math.pi * R)
n = int(input())
ta = [list(map(int, input().split())) for i in range(n)]

t = 1
a = 1

for i in range(n):
    x = max(t//ta[i][0], a//ta[i][1])
    if t > ta[i][0] * x or a > ta[i][1] * x
        x += 1
    t = ta[i][0] * x
    a = ta[i][1] * x

print(t+a)

### FIXED CODE ###

n = int(input())
ta = [list(map(int, input().split())) for i in range(n)]

t = 1
a = 1

for i in range(n):
    x = max(t//ta[i][0], a//ta[i][1])
    if t > ta[i][0] * x or a > ta[i][1] * x:
        x += 1
    t = ta[i][0] * x
    a = ta[i][1] * x

print(t+a)
k = input()
x = input()
cal = k*500

if cal<=x:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import sys
# input=sys.stdin.readline

val = []
val = input()

arrays = val.split(' ')
a = int(arrays[0])*500

if a>=int(arrays[1]):
    print("Yes")
elif a<int(arrays[1]):
    print("No")

sys.exit()
N = int(input())
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    ai, bi, ci = map(int, input().split())
    edges[ai].append((bi, ci))
    edges[bi].append((ai, ci))
Q, K = map(int, input().split())
queries = [tuple(map(int, input().split())) for _ in range(Q)]

weighted_nodes = [0]*(N+1)
def add_weight(k, pre):
    for v in edges[k]:
        d, w = v
        if d != pre:
            weighted_nodes[d] = w + weighted_nodes[k]
            add_weight(d, k)
add_weight(K, -1)

for q in queries:
    s, e = q
    print(weighted_nodes[s] + weighted_nodes[e])

### FIXED CODE ###

from collections import deque

N = int(input())
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    ai, bi, ci = map(int, input().split())
    edges[ai].append((bi, ci))
    edges[bi].append((ai, ci))
Q, K = map(int, input().split())

distance = [-1]*(N+1)
# def add_weight(k, pre):
#     for v in edges[k]:
#         d, w = v
#         if d != pre:
#             distance[d] = w + distance[k]
#             add_weight(d, k)
# add_weight(K, -1)
que = deque()
que.append(K); distance[K] = 0
while len(que):
    a = que.popleft()
    for b, c in edges[a]:
        if distance[b] == -1:
            distance[b] = c + distance[a]
            que.append(b)

# print(distance)

for _ in range(Q):
    s, e = map(int, input().split())
    print(distance[s] + distance[e])
n, m = map(int, input().split())

j = []
for _ in range(n):
    a,b = map(int, input().split())
    if a <= m :
        j.append([a,b])
j.sort()
p = 0
temp = []
for i in range(1, m+1):
    while j and j[0][0] <= i:
        a,b = j.pop(0)
        temp.append(b)
    p+=max(temp)
    temp.remove(max(temp))
print(p)

### FIXED CODE ###


from heapq import *
n, m = map(int, input().split())

j = []
for _ in range(n):
    a,b = map(int, input().split())
    if a <= m :
        j.append((a,b))
j.sort(reverse=True)

ans = 0
q = []
for i in range(1, m+1):
    while j and j[-1][0] <= i:
        a,b = j.pop()
        heappush(q, -b)
    if q:
        ans -= heappop(q)
print(ans)
N = int(input())
A = list(map(int, input().split()))
ans = 0
flg = "True"

while flg == "True":
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] / 2
        else:
            flg = "False"
    ans = ans + 1

print(ans)


### FIXED CODE ###

a = str(input())
ans = 0
if a[0] == "1":
    ans = ans + 1

if a[1] == "1":
    ans = ans + 1

if a[2] == "1":
    ans = ans + 1

print(ans)
dbflag=0
def debug(*args):
  if dbflag: print(*args)

result = 0

N =  input() 
N=int(N)

#A =  map(int,input() .split())
A = [int(i) for i in input().split(' ')]

flag= 1

while flag:
	for i in range(len(A)):
		debug(i, A[i])
		if A[i] %2 == 0:
			A[i] = A[i] //2
		else:
			flag = 0
			break
		
	if flag:
		result += 1

print(result

### FIXED CODE ###

dbflag=0
def debug(*args):
	if dbflag: print(*args)

result = 0

N =  input() 
N=int(N)

#A =  map(int,input() .split())
A = [int(i) for i in input().split(' ')]

flag= 1

while flag:
	for i in range(len(A)):
		debug(i, A[i])
		if A[i] %2 == 0:
			A[i] = A[i] //2
		else:
			flag = 0
			break
		
	if flag:
		result += 1

print(result)
input();a=1
for i in input().split():a*=int(i);a=[-1,a][1=<a<=eval('1'+'0'*18)]
print(a)

### FIXED CODE ###

input()
a=1
d=1000000000000000000
for i in input().split():
  a=min(a*int(i), d+1)
print([a,-1][a>d])
ar = [0, 0, 0, 0]
for _ in range(int(input())):
  s = input()
  ar[{"AC": 0, "WA": 1, "TLE": 2, "RE": 3}[s]] += 1
print("AC x", arr[0])
print("WA x", arr[1])
print("TLE x", arr[2])
print("RE x", arr[3])

### FIXED CODE ###

arr = [0, 0, 0, 0]
for _ in range(int(input())):
  s = input()
  arr[{"AC": 0, "WA": 1, "TLE": 2, "RE": 3}[s]] += 1
print("AC x", arr[0])
print("WA x", arr[1])
print("TLE x", arr[2])
print("RE x", arr[3])
N = int(input())

P = []

for i in range(N):
  x, y, h = map(int, input().split())
  P.append((x,y,h))

for x in range(101):
  for y in range(101):
    height = -1
    for p in range(N):
      (cx, cy, ch) = P[p]
      if height == -1:
        height = ch + abs(cx - x) + abs(cy - y)
        if height < 1:
          height = -1
      elif height == -2:
        break
      else:
        tmp = ch + abs(cx - x) + abs(cy - y)
        if tmp != height:
          height = -2
    
    if height != -2:
      valid = True
      for p in range(N):
        (cx, cy, ch) = P[p]
        if ch == 0:
          if height - abs(cx - x) - abs(cy - y) > 0:
            valid = False
        else
          if max(0, height - abs(cx - x) - abs(cy - y)) != ch:
            valid = False
      if valid:
        print(x, y, height)
        exit()

### FIXED CODE ###

# 全探索を試みるもWAを解決できず
# ゼロの扱いに対する思考が足りなかった

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

for X in range(101):
  for Y in range(101):

    for i in range(N):
      x, y, h = map(int, C[i])
      if h > 0:
        htop = abs(x-X) + abs(y-Y) + h
    
    for i in range(N):
      x, y, h = map(int, C[i])
      if h == 0:
        if htop - (abs(x-X) + abs(y-Y)) > 0:
          break
      if h > 0:
        if htop - (abs(x-X) + abs(y-Y)) != h:
          break
    else:
      print(X, Y, htop)
      exit()
import fractions

N=int(input())
T0=int(input())
for i in range(1,N):
    T=int(input())
    ans=(T0*T)//fractions.gcd(T0,T)
    T0=ans
print(ans)

### FIXED CODE ###

import fractions

N=int(input())
T0=int(input())

if N==1:
  print(T0)
  exit()

for i in range(1,N):
    T=int(input())
    g=fractions.gcd(T0,T)
    ans=T0*T//g
    T0=ans
print(ans)
A, B = map(int, innput().split())
ans = A - B - B
if ans > 0:
  print(ans)
else:
  print(0)

### FIXED CODE ###

A, B = map(int, input().split())
ans = A - B - B
if ans > 0:
  print(ans)
else:
  print(0)
x = map(input(int,list(x))
if 0 != x[0]:
    print sum(x)

### FIXED CODE ###

while True:
    x = map(int,list(raw_input()))
    if 0 != x[0]:
        print sum(x)
    else:
        break
count = 0
while True:
    set = int(input()):
    count +=1
    if set == 0:
        break
    print('Case {0}:{1}'.format(count,set))



### FIXED CODE ###

c = 0
while True:
    x = int(input()); c += 1
    if x == 0: break
    print("Case {}: {}".format(c, x))
[N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS && j + k < N:
                ANS[j+k] = i
                count += 1
    if count > N : break

for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
while True:
    s = input().split()
    if s == "-":
        break
    card = [x for x in s]
    for i in range(int(input())):
        h = int(input())
        card = card[h:] + card[:h]
    print("".join(card))

### FIXED CODE ###

while True:
    s = input()
    if s == '-':
        break

    m = int(input())
    for mi in range(m):
        h = int(input())
        s = s[h:] + s[:h]

    print(s)
import math
n=int(input())
x=[*map(int,input().split())]
a=x[0]
for i in range(1,n):
    a=math.gcd(a,x[i])
print(a)

### FIXED CODE ###

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

n=int(input())
x=list(map(int,input().split()))
a=x[0]
for i in range(1,n):
    a=gcd(a,x[i])
print(a)
X = input()
if X >= 30:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

X = int(input())
if X >= 30:
  print("Yes")
else:
  print("No")
N = int(input())
A = list(map(int, input().split(" ")))
A.sort()
A = deque(A)
ans = 0
t_max = len(bin(A[-1])) - 2
for t in range(t_max, 0, -1):
    if len(A) < 2: break
    pow2 = 1 << t
    A_tmp = deque()
    while t == len(bin(A[-1])) - 2:
        r = A.pop()
        idx = bisect_left(A, pow2 - r)
        for _ in range(idx):
            A_tmp.appendleft(A.popleft())
        if len(A) == 0: break
        if A[0] + r == pow2:
            A.popleft()
            ans += 1
        if len(A) < 2: break
    A.extendleft(A_tmp)
                    
print(ans)

### FIXED CODE ###

from bisect import bisect_left, bisect_right
from collections import deque

N = int(input())
A = list(map(int, input().split(" ")))
A.sort()
A = deque(A)
ans = 0
t_max = len(bin(A[-1])) - 2
for t in range(t_max, 0, -1):
    if len(A) < 2: break
    while len(bin(A[-1])) - 2 > t:
        A.pop()
        if len(A) < 2: break
    if len(A) < 2: break
    pow2 = 1 << t
    A_tmp = deque()
    while t == len(bin(A[-1])) - 2:
        r = A.pop()
        idx = bisect_left(A, pow2 - r)
        for _ in range(idx):
            A_tmp.appendleft(A.popleft())
        if len(A) == 0: break
        if A[0] + r == pow2:
            A.popleft()
            ans += 1
        if len(A) < 2: break
    A.extendleft(A_tmp)
                    
print(ans)
import numpy as np
import math
n, m, q = map(int,input().split())
max = 0
j = []
for i in range(q):
    aa,b,c,d = map(int,input().split())
    j.append([aa,b,c,d])

a = [0 for k in range(11)]
for i1 in range(1,11):
    a[1] = i1
    for i2 in range(i1,11):
        a[2] = i2
        for i3 in range(i2,11):
            a[3] = i3
            for i4 in range(i3,11):
                a[4] = i4
                for i5 in range(i4,11):
                    a[5] = i5
                    for i6 in range(i5,11):
                        a[6] = i6
                        for i7 in range(i6,11):
                            a[7] = i7
                                for i8 in range(i7,11):
                                a[8] = i8
                                    for i9 in range(i8,11):
                                    a[9] = i9
                                        for i10 in range(i9,11):
                                        a[10] = i10
                                        s = 0
                                        for i in j:
                                            if a[i[1]]-a[i[0]] = i[2]:
                                                s += i[3]
                                        if max < s:
                                            max = s

print(max)



### FIXED CODE ###

import numpy as np
import math
n, m, q = map(int,input().split())
max = 0
j = []
for i in range(q):
    aa,b,c,d = map(int,input().split())
    j.append([aa,b,c,d])

a = [0 for k in range(11)]
for i1 in range(1,11):
    a[1] = i1
    for i2 in range(i1,m+1):
        a[2] = i2
        for i3 in range(i2,m+1):
            a[3] = i3
            for i4 in range(i3,m+1):
                a[4] = i4
                for i5 in range(i4,m+1):
                    a[5] = i5
                    for i6 in range(i5,m+1):
                        a[6] = i6
                        for i7 in range(i6,m+1):
                            a[7] = i7
                            for i8 in range(i7,m+1):
                                a[8] = i8
                                for i9 in range(i8,m+1):
                                    a[9] = i9
                                    for i10 in range(i9,m+1):
                                        a[10] = i10
                                        s = 0
                                        for i in j:
                                            if a[i[1]]-a[i[0]] == i[2]:
                                                s += i[3]
                                        if max < s:
                                            max = s

print(max)
N = input()
A = list(map(int, input()))
s = sum(A)
if s%2==0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

N = input()
A = list(map(int, input().split()))
s = sum(A)
if s%2==0:
  print("YES")
else:
  print("NO")
N = int(input())
str = [input().sort for i in range(N)]
dict = {}
count = 0

print(str)

### FIXED CODE ###

N = int(input())
str = [''.join(sorted(input())) for i in range(N)]
dict = {}
sum = 0

for i in range(N):
  try:
    dict[str[i]] += 1
  except KeyError:
    dict[str[i]] = 1

for i in dict.values():
  sum += (i*(i-1))//2

print(sum)
import string

n, q = map(int, input().split())
s = input()
tds = list(tuple(input().split()) for _ in range(q))

left = 0
right = n-1

for t, d in reversed(tds):
    if d=="L":
        if t==s[left]:
            left += 1
    if d=="R":
        if t==s[right]:
            right -= 1

print(right - left + 1)


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
tds = list(tuple(input().split()) for _ in range(q))

left = 0
right = n-1

for t, d in reversed(tds):
    if d=="L":
        if t==s[left]:
            left = left+1
            if left > n-1:
                right = 0
                left = n-1
                break
        if right < n-1 and t==s[right+1]:
            right = min(right+1, n-1)

    if d=="R":
        if t==s[right]:
            right = right-1
            if 0 > right:
                right = 0
                left = n-1
                break
        if left > 0 and t==s[left-1]:
            left = max(left-1, 0)

print(max(right - left + 1, 0))
a,b = map(int.input().split())
for i in range(b-a+1,b+a):
  print(i)

### FIXED CODE ###

a,b = map(int,input().split())
for i in range(b-a+1,b+a):
  print(i)
N = int(input())

if N < 10:
  print(N)
  
elif N < 100:
  print(9)
  
elif N < 1000:
  print(9+ N-99)
  
elif N < 10000:
  print(909)

elif N < 100000:
  print(909 + N - 9999)

else:
  print(90909)


### FIXED CODE ###

A, B, C = (int(i) for i in input().split(" "))
 
D = A - B

 
if C - D <= 0:
  print(0)
else:
  print(C-D)
A=sorted(list(map(int,input.split())))
print(A[2]-A[0])

### FIXED CODE ###

A=sorted(list(map(int,input().split())))
print(A[2]-A[0])
x = input()
x = x.split(" ")
a = x[0]
b = x[1]
c = x[2]
n = c // a 
return(n * b)

### FIXED CODE ###

x = input()
x = x.split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
n = c // a 
print(n * b)
n, W = [int(x) for x in input().split()]
weight = []
value = []
for i in range(n):
    wi, vi = [int(x) for x in input().split()]
    weight.append(wi)
    value.append(vi)

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

for i in range(n):
    for w in range(W+1):
        if w >= weight[i]:
            dp[i+1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
   
ans = dp[n][W]
print(ans)

### FIXED CODE ###

import sys

n, W = map(int, sys.stdin.readline().split())
wv = map(int, sys.stdin.read().split())

wv = sorted(zip(*[wv] * 2))
min_w = wv[0][0]
W2 = 4 * n

def main():
    dp = [[[0] * (W2 + 1) for _ in range(n+1)] for _ in range(n+1)]
    
    for i in range(n):
        w, v = wv[i]
        w -= min_w - 1
        for j in range(1, i+2):
            for k in range(W2 + 1):
                if k + (min_w - 1) * j > W:
                    break
                dp[i+1][j][k] = dp[i][j][k]
                if k >= w:
                    dp[i+1][j][k] = max(dp[i][j][k], dp[i][j-1][k-w] + v)

    res = 0
    for j in dp[n]:
        res = max(res, max(j))

    return res

if __name__ == '__main__':
    ans = main()
    print(ans)