peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]
abc.append([0, 0, 0])

dp = [[-1] * 4 for i in range(N + 1)]
dp[0] = [0, 0, 0]
for i in range(1, N + 1):
    dp[i][0] = max([dp[i - 1][1] + abc[i - 1][1], dp[i - 1][2] + abc[i - 1][2]])
    dp[i][1] = max([dp[i - 1][0] + abc[i - 1][0], dp[i - 1][2] + abc[i - 1][2]])
    dp[i][2] = max([dp[i - 1][1] + abc[i - 1][1], dp[i - 1][0] + abc[i - 1][0]])

print(max(dp[N]))
# Judge status: Accepted
a,b = map(str,input().split())
c = int(a + b)
if c ** 0.5 ==int(c ** 0.5):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a,b,c=map(int,input().split())

print(min(c, b // a))
# Judge status: Accepted
import bisect
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            ab = L[i] + L[j]
            idx = bisect.bisect_left(L, ab)
            ans += max(idx - j - 1, 0)

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
if n >= m:
  print(0)
  exit()
s = set(map(int,input().split()))
l = list(s)
l.sort()
gap = []
for i in range(len(l)-1):
  gap.append(l[i+1]-l[i])
gap.sort()
print(sum(gap[:1-n]) if n!= 1 else sum(gap))
# Judge status: Accepted
import itertools

a,b,m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
P = [list(map(int,input().split())) for i in range(m)]
y = []
#普通に足算する
aa = min(A)
bb = min(B)
xx =aa+bb

#割引券使う
for i in range(m):
  y.append(A[P[i][0]-1] + B[P[i][1]-1] - P[i][2])
#min出す
yy = min(y)

print(min(xx,yy))
# Judge status: Accepted
n = int(input())
a = input()
alphabet = {}
for i in a:
    alphabet.update({i: a.count(i)})
for i in range(n-1):
    b = input()
    for j in alphabet:
        alphabet[j] = min(alphabet[j], b.count(j))
ans = []
for i in alphabet:
    ans += [i]*alphabet[i]
print(''.join(sorted(ans)))
# Judge status: Wrong Answer
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    numbers=[]
    dp=[]
    n = int(input())
    numbers=np.array(list(map(int,input().split())),dtype=int)
    numbers.sort()
    t1,t2,t3=np.hsplit(numbers,3)
    print(t2.sum())

if __name__=="__main__":
    main()
# Judge status: Accepted
s=input()
gene = ["A","T","G","C"]
ans=0
counter=0
for i in range(len(s)):
	for j in range(i,len(s)):
		if(s[j] in gene):
			counter += 1
		else:
			if(counter > ans):
				ans=counter
			counter=0
			break
	if(counter > ans):
		ans=counter
	counter=0
print(ans)
# Judge status: Accepted
n = int(input())
a_li = list(map(int,input().split()))
cnt = [0]*(10**6+1)


for i in a_li:
    cnt[i] += 1
unique = []
for i in range(10**6+1):
    if cnt[i] == 1:
        unique.append(i)
#print(unique)

a_li = set(a_li)

cnt = [0]*(10**6+1)

for i in a_li:
    for j in range(i * 2, 10 ** 6 + 1, i):
        cnt[j] = 1

ans = 0
for i in unique:
    if cnt[i] == 0:
        ans += 1
print(ans)
# Judge status: Accepted
N=int(input())

A=[[0 for s in range(10)] for t in range(10)]


for i in range(1,N+1):
	s = str(i)
	A[int(s[0])][int(s[-1])]+=1

x=0
for s in range(10):
	for t in range(10):
		x+=A[s][t]*A[t][s]
print(x)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
c = input()

nR = c.count('R')
#nW = c.count('W')

lnR = c[:nR].count('R')
#lnW = c[:nW].count('W')

print(nR-lnR)
# Judge status: Accepted
N,K = map(int,input().split())
li = []
count = 0
for i in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        li.append(a[j])

for i in range(N):
    if i+1 not in li:
        count += 1

print(count)
# Judge status: Wrong Answer

a, b = map(int, input().split())
cnt = 0
power = 1
if a > b:
    print(1)
    exit()

while(power < b):
    cnt += 1
    power = power - 1 + a 

print(cnt)
# Judge status: Wrong Answer
N, A, B, C, D = map(int, input().split())
S = input()

if "##" in S:
    print("No")
    exit(0)

if C <= D:
    print("Yes")
    exit(0)

ans = False
for i in range(B - 1, D - 1):
    if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
        ans = True
        break

if ans:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()

result = ""
result_old = ""

#現在の文字列の長さ
#1個前の文字列の長さ

for i in range(int(len(s))):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        result = result +s[i] 
    else:
        if int(len(result_old)) < int(len(result)):
            result_old = result
        else:
            result = [None for _ in range(int(len(result)))]
            result = ""
print(len(result_old))
# Judge status: Wrong Answer
n,m=map(int,input().split())
check=[False]*n
check[0]=True
ball=[1]*n
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if check[x]:
        check[y]=True
    else:
        continue
    ball[y]+=1
    ball[x]-=1
    if ball[x]==0:
        check[x]=False

ans=0

for i in range(n):
    if ball[i]==0:
        check[i]=False

for chk in check:
    if chk:
        ans+=1

print(ans)
# Judge status: Accepted
import functools
import fractions

n = int(input())
a = [int(i) for i in input().split()]

gcd = functools.reduce(fractions.gcd, a)
print(gcd)
# Judge status: Accepted
N, M = map(int, input().split())

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

    divisors.sort()
    return divisors
divs = make_divisors(M)
ans = []
for i in divs:
    if i * N <= M:
        ans.append(i)
print(max(ans))
# Judge status: Wrong Answer
x,y=map(int,input().split())
from math import log
print(1+int(log(y/x,2)))
# Judge status: Accepted
from math import ceil
x = int(input())
print(ceil((-1+(-1+8*x)**0.5)/2))
# Judge status: Accepted
def main():
  
  N = int(input())
  alist = list(map(int, input().split()))

  adj4cou = 0
  adjn4y2 = 0
  for a in alist:
    if a%4 == 0:
      adj4cou += 1
      if adj4cou >= N//2:
        return 'Yes'
    elif a%2 == 0:
      adjn4y2 += 1
  if adjn4y2 >= (N - 2*adj4cou):
    return 'Yes'
  return 'No'

if __name__ == '__main__':
  print(main())
# Judge status: Wrong Answer
from itertools import groupby

N = int(input())
S = input()

l = [[i, len(list(j))] for i, j in groupby(S)] + [[0, 0]]

ans = ""
s = 0
if l[0][0] == ")":
    ans += "(" * l[0][1] + ")" * l[0][1]
    s = 1

for i in range(s,len(l)-1)[::2]:
    m = max(l[i][1], l[i+1][1])
    ans += "(" * m + ")" * m
    
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)[::-1]

ans = []
for i in range(n):
    ans.append(a[i::n][1])
print(sum(ans))
# Judge status: Accepted
n = int(input())
print(1 if divmod(n,100)[1] <= divmod(n,100)[0]*5 else 0)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

counter_min = 9
for a in A:
    counter = 0
    while a%2 == 0:
        a /= 2
        counter += 1
    if counter < counter_min:
        counter_min = counter

print(counter_min)
# Judge status: Wrong Answer
import numpy as np

n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(reverse=True)
a = np.array(a)
ans = np.array([0 for i in range(m+1)])
for i in a:
    ans += i

for i in ans[1:]:
    if i < x:
        print(-1)
        exit()

for i in a:
    cnt = 0
    tmp = ans - i
    for j in tmp[1:]:
        if j >= x:
            cnt += 1
            if cnt == m:
                ans -= i

print(ans[0])
# Judge status: Accepted
u = input()
length = list(input().split())
h = [int(i) for i in length]

if max(h) < sum(h)-max(h):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
def main():
    n, l = map(int, input().split())
    s = [input() for _ in range(n)]
    s.sort()
    print("".join(s))


if __name__ == '__main__':
    main()
# Judge status: Accepted
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

lines = [set(x) for x in a] + [set(x) for x in zip(*a)] + [set([a[0][0], a[1][1], a[2][2]]), set([a[0][2], a[1][1], a[2][0]])]
bs = set(b)

if any(line.issubset(bs) for line in lines):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = LS2()

a,b = 0,0
left = []
for i in range(N):
    if S[i] == '(':
        a += 1
    else:
        b += 1
    if a < b:
        a,b = 0,0
        left.append('(')

ANS = left + S + [')']*(a-b)

print(*ANS)
# Judge status: Wrong Answer
S = list(input())
lis = [0] * (len(S)+1)

#最初は < を処理する
for i in range(len(S)):
    if S[i] == "<":
        lis[i+1] = lis[i] + 1




for j in range(len(S)-1,0,-1):
    if S[j] == ">":
        lis[j] = max(lis[j],lis[j+1] + 1)



print(sum(lis))
# Judge status: Wrong Answer
import sys
s=input()
for i in range(len(s)+1):
    for j in range(len(s)+1):
        if s[i]==s[j]:
            print('no')
            sys.exit()
print('yes')
# Judge status: Accepted
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    def count_(num,x):
        i = 0
        while num > 0:
            i += num % x
            num //= x
        return i
    ans = n

    for j in range(n + 1):
        ans = min(ans,count_(j,6)+count_(n-j,9))
    print(ans)




if __name__ == '__main__':
  main()
# Judge status: Accepted
n = int(input())
nums = list(map(int, input().split(' ')))
nums.sort()
total = 0

for i in range(n-1, -1, -1):
    l = 0
    r = i - 1
    while l < r:
        if nums[l] + nums[r] > nums[i]:
            total += r - l
            r -= 1
        else:
            l += 1
print(total)
# Judge status: Wrong Answer
N=int(input())
s=[]
for _ in range(N):
    tmp=list(input())
    s.append(sorted(tmp))

cnt=0
def hantei(s):
    global cnt
    comp=s.pop(0)
    for n,word in enumerate(s):
        if(comp==word):
            cnt+=1
            s.remove(comp)
        else:
            hantei(s[:])

hantei(s[:])

print(cnt)
# Judge status: Accepted
X = input()
print("YES" if X in "753" else "NO")
# Judge status: Accepted
def kipp(i,f):
    if i == 3:
        if eval(f) == 7:
            print(f+"=7")
            exit()
    else:
        kipp(i+1,f+"+"+s[i+1])
        kipp(i+1,f+"-"+s[i+1])

s = input()
kipp(0,s[0])
# Judge status: Accepted
X, K, D = map(int, input().split())
X = abs(X)
q, m = divmod(X, D)
if q >= K:
    print(X-K*D)
elif (q+K)%2==0:
    print(m)
else:
    print(-(m-D))
# Judge status: Wrong Answer
S = input()
T = input()
ls = len(S)
lt = len(T)
a = 0
for i in range(lt):
    for j in range(i+1,lt+1):
        if T[i:j] in S[i:ls-lt+j]:
            if a < j -i:
                a = j - i
print(lt-a)
# Judge status: Wrong Answer
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
import numpy as np
#======================================================#
MOD=10**9+7
def main():
    n = II()
    aa = np.array(MII())
    ans = 0
    for i in range(60):
        cnt1 = ((aa&1).sum())//1
        ans += (cnt1*(n-cnt1)*(2**i))%MOD
        aa >>= 1
    print(ans%MOD)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))

a = len(A)
if a == K:
  ans = 1
else:
  ans = math.ceil(a /(K-1))
print(ans)
# Judge status: Accepted
o = input()
e = input()

p = ''
for i in range(len(e)):
    p += o[i] + e[i]
if len(o) > len(e):
    p += o[-1]
print(p)
# Judge status: Accepted
s = list(input())
t = list(input())
cnt = 0

for i in range(len(s)):
    if s[i] != t[i]:
        cnt += 1

print(cnt)
# Judge status: Wrong Answer
def solve():
  n = int(input())
  a = list(map(int, input().split()))
  state, cut = -1, 0
  for i in range(n-1):
    #print(i, cut, state)
    if a[i] < a[i+1]:
      if state != 1:
        cut += 1
      state = 1
    else:
      if state != 0:
        cut += 1
      state = 0
  print(cut)
  return 0
 
if __name__ == "__main__":
  solve()
# Judge status: Wrong Answer
a, b = [int(i) for i in input().split()]
print(len(list(filter(lambda date: date[0] == date[1], [(m, d) for m in range(1, a + 1) for d in range(1, b + 1)]))))
# Judge status: Accepted
import sys
L=list(input())
N=len(L)
R=N//2
for i in range(R):
  if L[i]!=L[N-1-i]:
    print("No")
    sys.exit()
  elif L[i]!=L[R-1-i]:
    print("No")
    sys.exit()
print("Yes")
# Judge status: Accepted
s = input()
print('2018/01/' + s[-2:])
# Judge status: Wrong Answer
s=input()
for i in range(len(s)):
    s=s[:-1]
    if len(s)%2 ==0 and s[:len(s)//2] == s[len(s)//2:]:
        print(s)
        break
# Judge status: Accepted
s = input()
if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
w = list(input())
w.sort()
i = 0
while i < len(w) -1:
	if w[i] != w[i+1]:
		print('No')
		exit()
	i += 2
else:
	print('Yes')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
print(sum(a[n:2*n]))
# Judge status: Accepted
A,B = map(int,input().split())
if A>9 or B>9:
    print(-1)
else:
    print(A*B)
# Judge status: Wrong Answer
a, b, t = (int(i) for i in input().split())
print(b * t//a)
# Judge status: Accepted
a,b,m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
for i in range(m):
    x.append(list(map(int, input().split())))

min_a = min(a)
min_b = min(b)
money = min_a + min_b

for i in range(m):
    kingaku = a[x[i][0]-1] + b[x[i][1]-1] - x[i][2]
    if kingaku < money:
        money = kingaku

print(money)
# Judge status: Accepted
a, b = map(int, input().split())
flag = 0
for i in range(2000):
    if (i*0.08)//1 == a:
        if (i*0.1)//1 == b:
            print(i)
            flag += 1
            break

else:
    if flag == 0:
        print("-1")
# Judge status: Accepted
if int(input()) >= 3200:
  print(input())
else:
  print("red")
# Judge status: Accepted
n=ord(input())
print(chr(n+1))
# Judge status: Accepted
n = int(input())

count = 0
i = 1
while True:
    temp = 2 * (5 ** i)
    count += n // temp
    if temp > n:
        break
    else:
        i += 1

print(count if n % 2 == 0 else 0)
# Judge status: Wrong Answer
[n, k] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
dp = [10 ** 6 for _ in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i - j >= 0:
            dp[i] = min(dp[i] , dp[i-j] + abs(h[i] - h[i-j]))
print(dp[n-1])
# Judge status: Accepted
n, m, k = map(int, input().split())
flag = False
for r in range(n+1):
    for c in range(m+1):
        if m*r + n*c - 2*c*r == k:
            flag = True
            break
    if flag:
        break
print('Yes' if flag else 'No')
# Judge status: Accepted
import re

N = input()
N = re.sub(r'[A-z]', 'x', N)

print(N)
# Judge status: Wrong Answer
import math
from fractions import gcd
a,b=map(int,input().split())
gd = gcd(a,b)
gd_bun=list()
valid = [0 for i in range(int(math.sqrt(gd))+1)]
b=2
tmp=gd
while 1:
  if tmp %b==0:
    tmp = tmp//b
    gd_bun.append(b)
    while 1:
      tmp = tmp // b
      if tmp%b:
        break
  if tmp==1:
    break
  b+=1
print(1+len(list(set(gd_bun))))
# Judge status: Wrong Answer
## coding: UTF-8

S = input() #文字列型で受け取る
N = len(S)

remainder = [0] * 2019

for i in range(N):
    #print(S[i:], int(S[i:])%2019)
    remainder[int(S[i:])%2019]+= 1
remainder[0] += 1
print(-1)
'''
answer = 0
for i in range(2019):
    p = remainder[i]
    answer += p*(p-1)/2
print(int(answer))
'''
# Judge status: Accepted
n, x, t = map(int, input().split())

if n % x != 0:
    print((n // x + 1) * t)
else:
    print(n // x * t)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

if a%2 == 0 or  b%2 == 0 or c%2 == 0:
    print(0)
else:
    print(min(a*b, b*c, b*c))
# Judge status: Accepted
n = int(input())
x = list(map(int,input().split()))
sx = sorted(x)
a = sx[(n-1)//2]
b = sx[n//2]
for i in x:
    if i>a:print(a)
    else:print(b)
# Judge status: Accepted
digits = int(input())
str = input()

num = int(digits/2)

str_forward = str[num:]
str_backward = str[:num]


if str_forward == str_backward:
 print("Yes")
else:
 print("No")
# Judge status: Wrong Answer
N = int(input())
A = int(input())

a = N % 500
for i in range(A):
    if i == a:
        print('Yes')
        exit()

print('No')
# Judge status: Accepted
input()


A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A ):
  A = [a / 2 for a in A ]
  count += 1
print(count)
# Judge status: Wrong Answer
import numpy as np

N,M = map(int,input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])

bl = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if (A[i:i+M,j:j+M] == B).all():
            bl = True

answer = 'Yes' if bl else 'No'
print(answer)
print(A,B)
# Judge status: Accepted
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = 10 ** 10
for i in range(N-K+1):
    l = x[i]
    r = x[i+K-1]
    ans = min(ans, abs(l) + abs(r-l), abs(r) + abs(l-r))
print(ans)
# Judge status: Accepted
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
x.sort()
y.sort()
if x[-1] < y[0]:
  print('No War')
else:
  print('War')
# Judge status: Accepted
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    if P[i] < P[i+1] < P[i+2] or P[i] > P[i+1] > P[i+2]:
        ans += 1
print(ans)
# Judge status: Accepted
S = input()
answer = float('inf')
for i in range(len(S) - 3 + 1):
    # print(S[i:i + 3])
    if answer > abs(int(S[i:i + 3]) - 753):
        answer = abs(int(S[i:i + 3]) - 753)

print(answer)
# Judge status: Wrong Answer
x, n = map(int, input().split())
p = list(map(int, input().split()))
counter = 1
find = 0
while True:
  ceil = counter / 2 if counter % 2 == 0 else (counter // 2 + 1)
  find = int(ceil * ((-1) ** counter))
  if (x + find) not in p:
    find = x + find
    break
  counter += 1
print(x if n == 0 else find)
# Judge status: Accepted
x, y, a, b, c = map(int, input().split())
red = [int(x) for x in input().split()]
green = [int(x) for x in input().split()]
red.sort(reverse=True)
green.sort(reverse=True)
candidates = [int(x) for x in input().split()] + red[:x] + green[:y]
candidates.sort(reverse=True)
print(sum(candidates[:x+y]))
# Judge status: Wrong Answer
N = int(input()) % 10

if N == 3:
    print("bon")
elif N == 0 or 1 or 6 or 8:
    print("pon")
else:
    print("hon")
# Judge status: Wrong Answer
[N, K] = list(map(int, input().split()))
all_A =[]
for i in range(1, N + 1):
    all_A.append(i)
for j in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    after_A = set(all_A) ^ set(A)
print(len(after_A))
# Judge status: Accepted
k, n = (int(each) for each in input().split(' '))

a = [int(each) for each in input().split(' ')]
distance = []
for i in range(len(a)-1):
    distance.append(a[i+1]-a[i])

distance.append(a[0] + (k-a[-1]))

print(k - max(distance))
# Judge status: Wrong Answer
import math

a, b, c = map(int, input().split())

ra = math.sqrt(a / c)
rb = math.sqrt(b / c)

sahen = math.fsum([ra, rb])

if sahen < 1:
    print("Yes")
elif sahen >= 0:
    print("No")
# Judge status: Wrong Answer
N, M = map(int, input().split())
solve_problem = []
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and p not in solve_problem:
        solve_problem.append(p)
    if S == 'WA' and p not in solve_problem:
        penalty += 1

print('{} {}'.format(len(solve_problem), penalty))
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1,n+1):
    m = n//i
    ans += (m+1)*i*m//2
print(ans)
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    a = int(input().rstrip())
    b = int(input().rstrip())
    h = int(input().rstrip())

    s = (a+b)*h / 2

    print(int(s))


if __name__ == "__main__":
    resolve()
# Judge status: Accepted
if __name__ == '__main__':
    n =int(input())
    max = 1
    for i in range(1,n):
        now = i*i
        if now > n:
            break
        max = now
    print(max)
# Judge status: Accepted
N = int(input())
line = [int(x) for x in input().split(' ')]
count = 1
prev = line[0]
i = 0
while i < len(line):
  if prev == line[i]:
    i += 1
    continue
  elif prev < line[i]:
    for j in range(i,len(line)):
      if line[j] < prev:
        count+=1
        break
      prev = line[j]
    i = j
  elif prev > line[i]:
    for j in range(i,len(line)):
      if line[j] > prev:
        count += 1
        break
      prev = line[j]
    i = j
  prev = line[i]
  i+=1
print(count)
# Judge status: Wrong Answer
n, r = map(int, input().split())

if n < 10:
    a = 100 * (10 - n)
    b = r - a
    if b >=0:
        print(b)
    else:
        print(0)
else:
    print(r)
# Judge status: Accepted
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
a,v = ma()
b,w = ma()
t = ni()
if w>=v:
    print("NO")
    exit()
d = abs(a-b)
if d + w*t <=v*t:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
def main():
    N, A, B = map(int, input().split())
    ans = 0
    for i in range(N+1):
        tw = str(i)
        tn = 0
        for j in range(len(tw)):
            tn += int(tw[j])
        if A <= tn <= B:
            ans += i
    print(ans)
main()
# Judge status: Accepted
s = list(input())

s.sort()
if ''.join(s) == 'abc':
  print('Yes')
else:
  print('No')
# Judge status: Accepted
S = raw_input()
print "Bad" if S[0]==S[1] or S[1]==S[2] or S[2]==S[3] else "Good"
# Judge status: Accepted
N = int(input())
S = input()
S = [i for i in S]

for i in range(len(S)):
    for j in range(0, 26):
        if j+N<=25:
            if S[i]==chr(j+65):
                S[i]=chr(j+65+N)
                break
        else:
            if S[i]==chr(j+65):
                S[i]=chr(j+65+N-26)
                break

print(''.join(S))
# Judge status: Accepted
a,b = input().split()

ab=(int(a+b))**(1/2)
if ab ==int(ab):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,b = input().split()
import math
S = int(a+b)

if math.sqrt(S).is_integer() == True:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = int(input())

x =  (-s) % 10**9
y = (s + x) // 10**9

print(0,0,1,y,10**9,x)
# Judge status: Accepted
N=int(input())
if N % 2 == 0:
  print((N/2)/N)
else:
  print(((N+1)/2)/N)
# Judge status: Wrong Answer
N = int(input())
C = [0]*(N-1)
S = [0]*(N-1)
F = [0]*(N-1)
T = [0]*N
 
for i in range(N-1):
  C[i], S[i], F[i] = map(int, input().split())

for j in range(N-1):
  T[j] = C[j] + S[j]
  for i in range(N-2):
    if T[j] >= S[i+1] or S[i+1] == 0:
      T[j] = T[j] + C[i+1]
    elif T[j] < S[i+1]:
      T[j] = S[i+1]

T[N-1] = 0
for i in range(N):
  print(T[i])
# Judge status: Wrong Answer
x = int(input())
m = 100

import math
count = 0
while m >= x:
    m += math.floor(m / 100)
    count += 1

print(count)
# Judge status: Accepted
S=input()
T=input()
ans=0

for i in range(0, len(S)):
    if S[i] != T[i]:
        ans += 1
print(ans)
# Judge status: Accepted
k, x = [int(i) for i in input().split()]
print('Yes' if 500*k>=x else 'No')
# Judge status: Wrong Answer
N = int(input())

if N % 2 == 1:
    print(0)
    exit(0)

n = 10
ans = 0
while True:
    if n >= N:
        break
    ans += N//n
    n *= 5

print(ans)
# Judge status: Accepted
N, K = map(int, input().split())

N = N % K
if N > abs(N - K):
    print(abs(N - K))
else:
    print(N)