peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
rate=int(input())
a,b,c,d,e,f,g,h=400,600,800,100,1200,1400,1600,1800

if rate>=a and rate<=a+199:
  print(8)

elif rate>=b and b+199>=rate:
  print(7)
elif rate>=c and c+199>=rate:
  print(6)
  
elif rate>=d and d+199>=rate:
  print(5)
  
elif rate>=e and e+199>=rate:
  print(4)
  
elif rate>=f and f+199>=rate:
  print(3)
  
elif rate>=g and g+199>=rate:
  print(2)
  
  
elif rate>=h and h+199>=rate:
  print(1)
# Judge status: Accepted
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

N %= 1000
if N==0:
    print(0)
else:
    print(1000-N)
# Judge status: Accepted
n = int(input())

lis = []
for _ in range(n):
    lis.append(input())
    
if len(lis) != len(set(lis)):
    print("No")
    exit()
 
tmp = lis[0][-1]
for i in range(1,n):
    if lis[i][:1] != tmp:
        print("No")
        exit()
    else:
        tmp = lis[i][-1]

print("Yes")
# Judge status: Accepted
N, L = map(int,input().split())
A = [L+k for k in range(N)]
t = 10**9
for e in A:
    if abs(e) < abs(t):
        t = e
print(sum(A)-t)
# Judge status: Wrong Answer
x,y,a,b,c = map(int,input().split())
print(sum(sorted(sorted(list(map(int,input().split())))[:-x-1:-1] + list(map(int,input().split()))[:-y-1:-1] + list(map(int,input().split())))[:-x-y-1:-1]))
# Judge status: Accepted
import sys
input = sys.stdin.readline
# 二分木
import bisect

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

for _ in range(n):
    ai = int(input()) * -1
    i = bisect.bisect_right(a,ai)
    if(i==len(a)):
        a.append(ai)
    else:
        a[i] = ai

print(len(a))
# Judge status: Accepted
x,y = map(int,input().split())
print(x + y // 2)
# Judge status: Accepted
print("Yes" if sorted(input())<sorted(input())[::-1] else "No")
# Judge status: Accepted
x, y = map(int,input().split())
print([x, -1][x%y==0])
# Judge status: Accepted
N,K = map(int,input().split())
A = list(map(int,input().split()))
#最終的にすべての値は1になる
if N==K:
    print(1)
    exit()
ans = 1
t = K
while(1):
    if t >= N:
        print(ans)
        exit()
    t += (K-1)
    ans += 1
# Judge status: Accepted
S = input()
if S[-1] == 's':
  print(S + 'es')
else:
  print(S + 's')
# Judge status: Accepted
import sys
import math

n,m=map(int,input().split())
mod=10**9+7
val1=math.factorial(m)
val2=math.factorial(n)
if abs(n-m)>1:
	print("0")
elif (n==m):
	print((val1*val2*2)%mod)
else:
	print((val1*val2)%mod)
# Judge status: Accepted
L,R = map(int,input().split())

if R-L >= 2100 :
    ans = 0
else :
    ans = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            if (i*j)%2019 < ans :
                ans = (i*j)%2019
                if ans == 0 :
                    break

print(ans)
# Judge status: Wrong Answer
x = int(input())

if x >= 30:
  print('yes')
else:
  print('no')
# Judge status: Accepted
n = int(input())
s_list = sorted([int(input()) for _ in range(n)])
m = 0
ans = 0
for s in s_list:
    ans += s
    if m == 0 and s % 10 != 0:
        m = s
if m == 0:
    ans = 0
elif ans % 10 == 0:
    ans -= m
print(ans)
# Judge status: Wrong Answer
S = list(input())
K = int(input())

for s in S:
    if s != '1':
        print(s)
        exit(0)
# Judge status: Accepted
g1 = [4,6,9,11]
g2 = [2]
g3 = [1,3,5,7,8,10,12]

x,y = map(int,input().split())

if x in g1 and y in g1:
    print("Yes")
    exit()

if x == y == 2:
    print("Yes")
    exit()

if x in g3 and y in g3:
    print("Yes")
    exit()

print("No")
# Judge status: Accepted
n,a,b,c,d=map(int,input().split());s=input()
if c<=d:
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")
else:
  if "..." not in s[max(0,b-2):d+1]:print("No");exit()
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")
# Judge status: Accepted
A, B = map(int,input().split())

if A + B < 24:
    print (A + B)
else:
    print((A + B) -24)
# Judge status: Accepted
n = int(input())
a_list = [int(input()) - 1 for _ in range(n)]
s = set()
i = 0
ans = -1
while i not in s:
    if i == 1:
        ans = len(s)
        break
    s.add(i)
    i = a_list[i]
print(ans)
# Judge status: Accepted
N,R = map(int,input().split())

if N<10:
  print(100*(10-N)+R)
else:
  print (R)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = [0] * n

for i in range(n, 0, -1):
    j = i
    tmp = 0
    while True:
        j += i
        if j > n:
            break
        tmp = tmp + a[j-1]
    b[i-1] = int(tmp % 2 != a[i-1])

m = sum(b)
print(m)
if m > -1:
    for i in range(n):
        if b[i]: print(i+1)
# Judge status: Wrong Answer
N, X = map(int, input().split())
L = list(map(int ,input().split()))
D = 0

for i in range(N):
    D += L[i]
    if D >= X:
        print(i + 1)
        break
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))

nums = sorted(x)
m1 = n//2-1
m2 = n//2
for i in range(n):
  if x[i] <= nums[m1]: print(nums[m2])
  elif nums[m2] <= x[i]: print(nums[m1])
# Judge status: Wrong Answer
N = int(input())
c = 0
for i in range(1,N+1):
  if(N%3!=0 and N%5!=0):
    c += i
print(c)
# Judge status: Accepted
def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)

def main():
    K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                tmp = GCD(i, j)
                ans += GCD(tmp, k)
    print(ans)

    return 0


if __name__ == '__main__':
    main()
# Judge status: Accepted
A = input()
B = input()
C = input()

turn = 'a'
win = ''
while win == '':
  if turn == 'a':
    if len(A) == 0:
      win = 'A'
    else:
      turn = A[0]
      A = A[1:]
  elif turn == 'b':
    if len(B) == 0:
      win = 'B'
    else:
      turn = B[0]
      B = B[1:]
  elif turn == 'c':
    
    if len(C) == 0:
      win = 'C'
    else:
      turn = C[0]
      C = C[1:]
print(win)
# Judge status: Wrong Answer
n,k = map(int,input().split())

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

id_one = lst.index(1)
left_length = len(lst[0:id_one+1])-1
right_length = len(lst[id_one:])-1

counter = 0



while left_length > 0:
    counter += 1
    left_length -= k-1


while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)
# Judge status: Accepted
import math
from functools import reduce
import itertools
import numpy as np

K = int(input())



ans = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i == j and j == k:
                dup_num = 1
            elif i == j or j == k:
                dup_num = 3
            else:
                dup_num = 6
            ans += math.gcd(math.gcd(i, j), k) * dup_num

print(ans)
# Judge status: Accepted
a,b,k = map(int,input().split())
if k<=(b-a)-k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
# Judge status: Accepted
#!/usr/bin/env python3
from math import ceil

n = int(input())
a = ceil(((1 + 8 * n)**0.5 - 1) / 2)
for i in range(a):
    if a * (a + 1) // 2 - n - 1 != i:
        print(i + 1)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
count = 0
Ai = [A[i] + i for i in range(N)]
Aj = [j + A[j] for j in range(N)]
setAi = set(Ai)
setAj = set(Aj)

intersection = setAi.intersection(setAj)
print(len(intersection))
# Judge status: Wrong Answer
K,S = map(int, input().split())
count = 0
for i in range(K):
  for j in range(K-i):
    for k in range(K-i-j):
      if i + j + k == S:
        count += 1
print(count)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 12:41:57 2020

@author: shinba
"""

a = int(input())
b = int(input())
h = int(input())

print(int((a+b)*h/2))
# Judge status: Wrong Answer
N, M = list(map(int, input().split()))

A = [input().strip() for _ in range(N)]
B = [input().strip() for _ in range(M)]
temp = "".join(B)


ans = False

for j in range(N-M+1):
    for i in range(N-M+1):
        tmp = ""
        for y in range(M):
            tmp += A[y][i: i + M]
        if tmp == temp:
            ans = True

if ans:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a, b = map(int, input().split())
if (1 <= a <= 9) and (1 <= b <= 9):
    print(a*b)
else:
    print(-1)
# Judge status: Accepted
A, B = map(int, input().split())
S = input()
num = '1234567890'
for i in S[:A]:
    if i in num:
        continue
    else:
        print('No')
        exit()
if S[A] != '-':
    print('No')
    exit()
for i in S[A+1:]:
    if i in num:
        continue
    else:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
from math import sqrt
N = int(input())
ans = 10**12+1
for x in range(1, int(sqrt(N))+1):
  if N % x == 0:
    y = N // x
    l = (x - 1) + (y - 1)
    ans = min(ans, l)
print(ans)
# Judge status: Wrong Answer
from math import *

def trycut(val):
	ret = 0
	for i in range(n):
		ret += ceil(a[i]/val)-1
	return ret 

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

low = 0
high = 1000000000
ans  =-1

while low < high:
	mid = (low + high)/2
	cut = trycut(mid)
	# ~ print("low=",low, "high=", high,"val = ",mid,"ret = ",cut)
	if cut <= k:
		high = mid-0.01
		ans = mid
	else:
		low = mid+0.01
	# ~ if low < high: print(low, high, "je reviens")
print(round(ans))
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,a,b = iim()

if (a%2)^(b%2):
    num = min(a-1,n-b)+1
    print((b-a)//2+num)
else:
    print((b-a)//2)
# Judge status: Wrong Answer
A = list(map(int, input().split()))
ave = sum(A)//2
if ave in A:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, k = map(int, input().split())
H = list(map(int, input().split()))
H.sort()

if k >= n:
    print(0)
    exit()

for _ in range(k):
    H.pop()
ans = sum(H)
print(ans)
# Judge status: Wrong Answer
# input
N = int(input())
A = list(map(int, input().split()))

# check
print(sum([a if a >= 0 else a * -1 for a in A]))
# Judge status: Accepted
a, b, x = map(int, input().split())

print(b // x - a // x + (1 if a % x == 0 else 0))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

def gcd(a,b):
  aa=max(a,b)
  bb=min(a,b)
  cc=aa%bb
  return gcd(bb,cc) if cc else bb
  
p=gcd(a[0],a[1])
for i in range(2,n):
  p=gcd(p,a[i])
print(p)
# Judge status: Wrong Answer
x, y = input().split()

if  x == y:
  print('Yes')
elif x > y:
  print('No')
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))
ans = 0
a = sorted(a)
for i in range(N):
    ans += a[-2 - 2 * i]
print(ans)
# Judge status: Accepted
import sys
#input = sys.stdin.buffer.readline

def main():
    N = int(input())
    s = input()
    ans = s.count(".")
    count = ans
    for st in s:
        if st == "#":
            count += 1
        else:
            count -= 1
        ans = min(ans,count)
        
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
import collections

s = input()
d = collections.Counter(s)
if len(d) < 3:
    num = max(d.values())
else:
    num = max(d.values()) - min(d.values())
print('YES' if num<2 else 'NO')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
Ans = "Yes"
List = []

for e in A:
    if e in List:
        Ans = "No"
        break
    else:
        List.append(e)

print(Ans)
# Judge status: Accepted
#%%
n, m = map(int, input().split())

route = {}
for _ in range(m):
    a, b = map(int, input().split())
    route.setdefault(a, []).append(b)

#%%
flag = False
for r1 in route[1]:
    if n in route.get(r1, []):
        flag = True
        break

if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Judge status: Accepted
k = int(input())
s = input()
L = len(s)
if L <= k:
    print(s)
else:
    ans = s[:k]+'...'
    print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
mod = pow(10,9)+7

def f(x,mod):
    k = 1
    res = 1
    while k<x:
        k+=1
        res*=k
        res %= mod
    return res

if abs(N-M)>1:print(0)
elif abs(N-M)==1:
    a = f(min(N,M),mod)
    print(pow(a,2,mod)*max(N,M)%mod)
else:
    a = f(N,mod)
    print(2*pow(a,2,mod)%mod)
# Judge status: Accepted
N, X = map(int, input().split(' '))
L = list(map(int, input().split(' ')))
D = [0 for _ in range(N + 1)]
for i in range(1, N + 1):
  D[i] = D[i-1] + L[i-1]
  count = 0
for i in range(N + 1):
  if D[i] <= X:
    count += 1
print(count)
# Judge status: Wrong Answer
s, t = input().split()
a,b = map(int, input().split())
u = input()
if s == u:
    print(a-1, b)
elif s == t:
    print(a, b-1)
# Judge status: Accepted
K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    print(S[:K]+"...")
# Judge status: Accepted
import itertools
s = int(input())
if s < 3:
    print(0)
    exit()

l = [1]*(s - 2)
total = 0
three_cnt = s // 3

for i in range(three_cnt):
    total += l[s - 3 - (i*3)]
    for j in range(s - 3):
        l[j + 1] += l[j]
print(total % ((10 ** 9) + 7))
# Judge status: Wrong Answer
num=list(map(int,input().split()))
k=int(input())
ans1=sum(num)-max(num)
ans2=0

while k>0:
  ans2+=max(num)*2
  k-=1
  
print(ans1+ans2)
# Judge status: Accepted
s=input()
flag=True
for i in range(len(s)-1):
    for j in range(i+1,len(s)):
        if s[i]==s[j]:
            flag=False
            break
    if not(flag):
        break
print("yes") if flag else print("no")
# Judge status: Accepted
N = int(input())
B = list(map(int, input().split()))
A = [0] * N
for x in range(N - 1, -1, -1):
    if x == N - 1:
        A[x] = B[x - 1]
    elif x == 0:
        A[x] = B[x]
    else:
        A[x] = min(B[x], B[x - 1])
print(sum(A))
# Judge status: Accepted
s=list(input())
n=len(s)
for i in range(n):
  s[i]=int(s[i])
dec_flg=0
for i in range(n):
  if i==0:continue
  if dec_flg==0:
    if 0<=s[i]<=8 and s[i-1]>0:
      s[i-1]-=1
      s[i]=9
      dec_flg=1
  else:
    if 0<=s[i]<=8:
      s[i]=9
ans=0
for ss in s:
  ans+=ss
print(ans)
# Judge status: Accepted
a=list(input())
count=1
ans = 0
temp = 0
for i in range(len(a)-1):
  if a[i] ==a[i+1]:
    count+=1
  else:
    if a[i]=='<':
      ans += count*(count+1)//2
      temp = count
      #print('<', count, ans)
      count = 1
      
    else:
      ans += count*(count+1)//2
      ans -= min(count, temp)
      #print('>', count, ans)
      count =1
else:
  if a[-1]=='<':
    ans += count*(count+1)//2
  else:
    ans += count*(count+1)//2
    ans -= min(count, temp)
print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
ls = list(map(int,input().split()))
ls1 = [0]*N
s = sum(ls)
for i in range(N):
  if ls[i]>=s/(4*M):
    ls1[i]=1
ss = sum(ls1)
if ss>=M:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
#D
n,k=map(int, input().split())
r,s,p=map(int, input().split())
t=str(input())
te=[]
score=0
for i in range(n):
  if i>=k and t[i]==t[i-k]:#k回前に相手が同じ手を出している場合
    score+=0
    te.append(t[i])
  else:
    if t[i]=='r':
      score+=p
      te.append('p')
    elif t[i]=='s':
      score+=r
      te.append('r')
    elif t[i]=='p':
      score+=s
      te.append('s')
print(score)
# Judge status: Accepted
from collections import Counter
n, *d = map(int, open(0).read().split())
MOD = 998244353
c = Counter(d)
if d[0] != 0 or c[0] != 1:
    ans = 0
else:
    ans = 1
    for i in range(1, max(d)+1):
        ans *= (c[i-1] ** c[i]) % MOD
print(ans % MOD)
# Judge status: Accepted
#17
N = int(input())
V = list(map(int,input().split()))
num = 0

V.sort()

for i in range(N-1):
    num = (V[i] + V[i+1])/2
    V[i+1] = num
    
print(V[-1])
# Judge status: Wrong Answer
s = input()

n = len(s) - 1
ans = 0
for i in range(1 << n):
    exp = s[0]
    for j in range(n):
        if i & (1 << j):
            exp += "+"
        else:
            exp += "-"
        exp += s[j + 1]
    if eval(exp) == 7:
        ans = exp

print(ans)
# Judge status: Wrong Answer
n=int(input())
l=[]

for i in range(n):
  x,y=(map(int,input().split()))
  we=int(((x**2)+(y**2))**0.5)
  ll=[we,x,y]
  l.append(ll)

l.sort()
#print(l)
print((l[-1][2]-l[0][2])+(l[-1][1]-l[0][1]))

'''
  ll1=[ll[1],ll[0]]
  lan.append(ll1)

l.sort()
lan.sort()
we=abs(l[0][0]-l[-1][0])+abs(l[0][1]-l[-1][1])
we1=abs(lan[0][0]-lan[-1][0])+abs(lan[0][1]-lan[-1][1])
print(max(we,we1))
'''
# Judge status: Accepted
n = int(input())
s = input()

x = 0
x_max = 0

for i in s:
    x = x+1 if i=='I' else x-1
    x_max = max(x, x_max)

print(x_max)
# Judge status: Accepted
a, b, c = map(int, input().split())
k = int(input())
print(sum([a, b, c]) + max(a, b, c) * 2**k - max(a, b, c))
# Judge status: Accepted
S = [int(input()) for _ in range(5)]
k=int(input())
a=max(S)
b=min(S)
if a-b>k:
    print(':(') 
    exit()       
else:
    print('Yay!')
# Judge status: Accepted
x,y=map(int,input().split())
i=0
while x<=y:
  x*=2
  i+=1
print(i)
# Judge status: Accepted
#A - Range Product 
a,b = map(int,input().split())
if a <= 0 and b >= 0:
    print('Zero')
elif a < 0 and b < 0:
    if abs(a - b) % 2 == 0:
        print('Negative')
    else :
        print('Positive')
elif a > 0 and b > 0:
    print('Positive')
# Judge status: Accepted
c = list(list(map(int, input().split())) for i in range(3))

d = [0, 1, 2, 0, 1]
x = c[0][0] + c[1][1] + c[2][2]
ok = True
for i in range(3):
    a = c[d[i]][0] + c[d[i+1]][1] + c[d[i+2]][2]
    b = c[d[i]][2] + c[d[i+1]][1] + c[d[i+2]][0]

    if x != a or x != b:
        ok = False

print('Yes' if ok else 'No')
# Judge status: Accepted
import math
a,b,x=map(int, input().split())
s = x/a
if s<=a*b/2:
    d = b/(s*2/b)
else :
    d = (b*2-s*2/a)/a
print(math.degrees(math.atan(d)))
# Judge status: Accepted
*c, = map(int,open(0).read().split())
for i in range(2):
    if( (c[1+i]-c[0+i])!=(c[4+i]-c[3+i]) or (c[1+i]-c[0+i])!=(c[7+i]-c[6+i])
       or (c[3+i*3]-c[i*3])!=(c[4+i*3]-c[1+i*3]) or (c[3+i*3]-c[i*3])!=(c[5+i*3]-c[2+i*3]) ):
        print("No")
        break
else:
    print("Yes")
# Judge status: Accepted
N, H = map(int,raw_input().split())
a = []
b = []
for i in range(N):
    ai, bi = map(int,raw_input().split())
    a.append(ai)
    b.append(bi)

a_max = max(a)
b = sorted(b)


ans = 0
for i in reversed(range(N)):
    if b[i] >= a_max:
        ans = ans + 1
        H = H - b[i]
    if H <= 0:
        print ans
	exit()

ans = ans + -(-H//a_max)

print ans
# Judge status: Wrong Answer
a,b,c=map(int, input().split())
if a+b>=c:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
def main():
    n = int(input())
    A = map(int,input().split())
    for a in A:
        if (a % 2 == 0):
            if ((a % 3 != 0) and (a % 5 != 0)):
                print("DENIED")
                return
    print("APPROVED")
main()
# Judge status: Accepted
n,l=map(int,input().split())
s=sorted(input() for i in range(n))
print(*s, sep="")
# Judge status: Accepted
n, m = map(int,input().split())
s = []
c = []
for _ in range(m):
  x, y = map(int,input().split())
  s.append(x)
  c.append(y)

for i in range(10 ** (n + 1)):
    Str = str(i)

    if len(Str) == n and all([Str[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(Str)
        exit()

print(-1)
# Judge status: Accepted
# solution
import io

print("Yes" if input() in input()*2 else "No")
# Judge status: Accepted
k,n=map(int,input().split())
for i in range(k-1):
  print(n-k+i+1,end=" ")
print(n,end=" ")
for i in range(k-1):
  print(n+i+1,end=" ")
# Judge status: Accepted
N  = int(input())
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))

min_dif = 99999999999999999
min_pt = 0
for i, h in enumerate(H):
  dif = abs(A - (T - h*0.006))
  if dif < min_dif:
    min_pt=i+1
    min_dif = dif
    
print(min_pt)
# Judge status: Wrong Answer
N = int(input())
H = list(map(int, input().split()))

if N == 1:
    print("Yes")
    exit()

flag = True
for i in range(N-1, -1, -1):

    if H[i] >= H[i-1]:
        pass
    elif H[i] + 1 == H[i-1]:
        H[i-1] -= 1
    else:
        flag = False

print(H)
if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]
now = 1
for i in range(N):
    if A[i] == now:
        now += 1
print(N-now+1 if now != 1 else -1)
# Judge status: Accepted
from collections import Counter
n = int(input())
x = []
for i in range(n):
    s = input()
    t = Counter(s)
    x.append(t)
ans = ""
for i in "abcdefghijklmnopqrstuvwxyz":
    tmp = []
    for j in x:
        tmp.append(j[i])
    ans += i*min(tmp)
print(ans)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
e = a * c
f = a * d
g = b * c
h = b * d
print(max(e, f, g, h))
# Judge status: Accepted
# -*- coding:utf-8 -*-

n = int(input())
t, x, y = [0], [0], [0]
for i in range(n):
  t_i, x_i, y_i = map(int, input().strip().split())
  t.append(t_i)
  x.append(x_i)
  y.append(y_i)

  
can = "Yes"
for i in range(n):
  dt = t[i+1] - t[i]
  dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if (dt < dist):
    can = "No"
  if(dist % 2 != dt % 2):
    can = "No"
print(can)
# Judge status: Accepted
s,w = map(int, input().split())

if w >= s:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted

from collections import deque


def submit():
    s = input().strip()
    q = deque()
    ans = 0

    for c in s:
        if len(q) == 0:
            q.append(c)
        else:
            top = q.pop()
            if top != c:
                ans += 2
            else:
                q.append(top)
                q.append(c)
            
    print(ans)


if __name__ == "__main__":
    submit()
# Judge status: Accepted
N = int(input())
s = input()
t = input()

for i in range(N):
    if s[i:] == t[:N - i]:
        print(N + i)
        exit()
print(2 * N)
# Judge status: Wrong Answer
N=int(input())
A=int(input())
mod=N%500
if mod<A:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N=int(input())
cnt=0
max=10**6
but=0
id=0
for i in range(1,max,1):
    cnt=cnt+i
    if cnt>=N:
        buf=cnt-N
        break
id=i
seq=[i+1 for i in range(id)]
for i in range(len(seq)):
    if seq[i]!=buf:
        print(seq[i])
# Judge status: Accepted
n,m=map(int,input().split())
data=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    data[b-1]+=1
    if data[b-1]==2:
      print('POSSIBLE')
      exit()
  if b==n:
    data[a-1]+=1
    if data[a-1]==2:
      print('POSSIBLE')
      exit()

print('IMPOSSIBLE')
# Judge status: Accepted
N, M = map(int, input().split())
a = []
for i in range(N):
    a += [list(map(int, input().split()))]
a.sort(key=lambda x: x[0])
i, ans = 0, 0
while M != 0 or i < N:
    if M > a[i][1]:
        M -= a[i][1]
        ans += a[i][0]*a[i][1]
    else:
        ans += a[i][0]*M
        M = 0
        break
    i += 1
print(ans)
# Judge status: Wrong Answer
week = ["MON","TUE","WED","THU","FRI","SAT","SUN"]
week.reverse()
print(week.index(input()))
# Judge status: Wrong Answer
# d
import numpy as np
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = np.array(list(input()))
t = np.where(t == 'r', p, t)
t = np.where(t == 's', r, t)
t = np.where(t == 'p', s, t)
t = t.astype(dtype='int64')
tt = t
point = 0
point += np.sum(t[:k])

for i in range(k,n):
    if t[i] != t[i-k]:
        point += t[i]
    elif t[i] == t[i-k]:
        t[i] = 0

print(point)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
li = [0]*10**6
for i in range(N):
    li[A[i]] += 1
# print(li)
li.sort(reverse=True)
# print(li)
print(sum(li[K:]))
# Judge status: Wrong Answer
N = int(input())
m = 5
ans = 0

if N % 2 == 1:
  pass
else:
  for i in range(1, 10000):
    m = pow(5, i) * 2
    if m > N:
      break
    else:
      ans += int(round(N / m, 0))
print(ans)
# Judge status: Accepted
K = int(input())
INF = 10**18

a = [INF] * (K+1)
a[0] = 0

for n in range(1, K+1):
    a[n] = (10 * a[n-1] + 7) % K
    if a[n] == 0:
        print(n)
        break
else:
    print(-1)
# Judge status: Accepted
N,M=map(int,input().split())
if 2*N>M:
    print(M//2)
else:
    print((2*N+M)//4)