peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import heapq

k = int(input())
i=0
lunlun = [1,2,3,4,5,6,7,8,9]
heapq.heapify(lunlun)

while True:
    i += 1
    if i == k:
        break
    x = heapq.heappop(lunlun)
    if x % 10 != 0:
        heapq.heappush(lunlun,10 * x + (x % 10) -1)
    heapq.heappush(lunlun,10 * x + (x % 10))
    if x % 10 != 9:
        heapq.heappush(lunlun,10 * x + (x % 10) +1)

print(lunlun[0])
# Judge status: Accepted
a = int(input())
if a < 1000:
    print("ABC")
else:
    print("ABD")
# Judge status: Accepted
import collections


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

F = [-1 for _ in range(N)]

que = collections.deque([0])
while que:
    target = que.popleft()
    for g in G[target]:
        if F[g] == -1:
            F[g] = target
            que.append(g)

res = [F[i] + 1 for i in range(N)]
res[0] = "Yes"
print("\n".join(map(str, res)))
# Judge status: Wrong Answer
#!/usr/bin/env python
# -*- coding: utf-8 -*-

num=int(input())
pow=1

for i in range(1,num):
  pow=pow*i
  
print(pow%(10**9+7))
# Judge status: Accepted
A,B = map(int,input().split())

x = 0
while True:
    if (x*2) // 25 == A and x//10 == B:
        print(x)
        exit()
    if (x*2) // 25 > A and x//10 > B:
        print(-1)
        exit()
    
    x += 1
# Judge status: Wrong Answer
S = input()
T = input()
res = "UNRESTORABLE"

for i in range(len(S)-1, len(T)-1, -1)[::-1]:
  
  s = list(S[::])
  j = i
  flag = True
  for k in range(len(T)-1, -1, -1):
    if s[j] == "?":
      s[j] = T[k]
    elif s[j] == T[k]:
      continue
    elif s[j] != T[k]:
      flag = False
      break
    j -= 1

  if flag:
    for j in range(len(s)):
      if s[j] == "?": s[j] = "a"
    res = s
    break

print("".join(res))
# Judge status: Accepted
n = int(input())
strings = [[] for _ in range(n)]
for i in range(n):
    if not i:
        strings[i].append("a")
        continue
    for s in strings[i-1]:
        for j in range(ord("a"),ord(max(s))+2):
            c = chr(j)
            strings[i].append(s+c)
print(*strings[-1])
# Judge status: Accepted
n, d = map(int, input().split())
print(((n - 1) // (2 * d + 1)) + 1)
# Judge status: Accepted
a, b, c, d = map(int, input().split())

if a < c:
    st = c
else:
    st = a

if b < d:
    ed = b
else:
    ed = d

if st < ed:
    print(ed-st)
else:
    print(0)
# Judge status: Accepted
a, b = map(int, input().split())
if (a-b) % 2 == 0:
    print((a+b)//2)
else:
    print("IMPOSSIBLE")
# Judge status: Accepted
def main():
    N = int(input())
    dp = [N] * (N+1)
    dp[0] = 0

    for i in range(1, N+1):
        j = 1
        while j <= N:
            dp[i] = min(dp[i], dp[i-j]+1)
            j *= 6
        j = 1
        while j <= N:
            dp[i] = min(dp[i], dp[i-j]+1)
            j *= 9
    
    res = dp[N]
    print(res)



if __name__ == "__main__":
    main()
# Judge status: Accepted
K,X = map(int,input().split())

for i in range(2*K-1):
  print(X-K+1+i,end=" ")
# Judge status: Accepted
A,B = map(str,input().split())
print(B+A)
# Judge status: Accepted
a, b, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(m)]

ans = min(a) + min(b)
for x, y, c in xyc:
    ans = min(ans, a[x-1] + b[y-1] - c)

print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
if a>=13:
    print(b)
elif 6<=a<=12:
    print(b//2)
else:
    print(0)
# Judge status: Accepted
S = input()
S = S[::-1]
pattern = ["dream","dreamer","erase","eraser"]
for i in range(len(pattern)):
  pattern[i] = pattern[i][::-1]
while True:
  flag = False
  for v in pattern:
    if S[:len(v)] == v:
      S = S[len(v):]
      flag = True
  if S == "":
    print("YES")
    break
  elif not flag:
    print("NO")
    break
# Judge status: Accepted
n = int(input())

ans = 0
for i in range(1, n + 1):
    if i & (i - 1) == 0:
        ans = i
print(ans)
# Judge status: Accepted
N = int(input())
numbers_r = tuple(map(int, input().split(' ')))
numbers_s = sorted(numbers_r)

med_high = numbers_s[N // 2]
med_low = numbers_s[N // 2 - 1]

for number in numbers_r:
    if number <= med_low:
        print(med_high)
    else:
        print(med_low)
# Judge status: Accepted
N,K = map(int,input().split())
H = sorted(list(map(int,input().split())))

if not N <= K:
    print(sum(H[0:N-K]))
else:
    print(0)
# Judge status: Accepted
n,m = map(int,input().split())
li=[list(map(int,input().split())) for i in range(m)]
ans_li = [0] * n

for i, j in li:
    ans_li[i-1] += 1
    ans_li[j-1] += 1

print(*ans_li,sep="\n")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

s = sum(A)
r = 10**10
n = 0
for i in range(N-1):
    n += A[i]
    r = min(abs(s-n*2), r)

print(r)
# Judge status: Accepted
N,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
total=sum(a)
#おかしが余る場合
if total<x:
  print(N-1)
#配りきれる場合
elif total==x:
  print(N)
#子供が余る場合
else:
  ans=0
  d=[0]*N
  for i in range(N):
    if x>=a[i]:
      x-=a[i]
      d[i]=1
  ans=d.count(1)
  print(ans)
# Judge status: Accepted
from fractions import gcd

n, m = map(int, input().split())
a = list(map(int, input().split()))
l = 1
num = a[0]
bin = 1
while num % 2 == 0:
    bin *= 2
    num //= 2
for num in a:
    l = (l * num // 2) // gcd(l, num // 2)
    if num % bin != 0 or num % (bin * 2) == 0:
        print(0)
        exit()
print((m + l) // (2 * l))
# Judge status: Accepted
w = input()
duplex = set(w)
before_w = ''
result = 'Yes'
diff = 0
for i in duplex:
    before_w = w.replace(i, '')
    diff = diff + (len(w) - len(before_w))
    w = before_w
    if diff % 2 == 0:
        pass
    else:
        result = 'No'
        break

print(result)
# Judge status: Accepted
n,m=map(int,input().split())
if (n==1 or m==1) and n!=m:
  print(n*m-2)
elif n==1 and m==1:
  print(1)
else:
  print((n-2)*(m-2))
# Judge status: Accepted
n,a,b=map(int,input().split())
s=list(input())
i=0
j=0
for c in s:
    if c=="a":
        if i+j<a+b:
            i+=1
            print("Yes")
        else:
            print("No")
    elif c=="b":
        if i+j<a+b and j<b:
            j+=1
            print("Yes")
        else:
            print("No")
    else:
        print("No")
# Judge status: Accepted
#!/usr/bin/env python3
def main():
    S = input()
    T = input()

    ans = 10 ** 6
    for i in range(len(S) - len(T) + 1):
        cnt = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
c = 0
m = 10*10
flag = 0
ans = 0
for i in a:
    if i == 0:
        flag = 1
    if i < 0:
        c += 1
    ans += abs(i)
    m = min(m,abs(i))
if c%2 == 0:
    flag = 1
if flag:
    print(ans)
else:
    print(ans-(2*m))
# Judge status: Accepted
a = [int(input())]

i = 0
while True:
    if a[i]%2 == 0:
        a.append(int(a[i]/2))
    else:
        a.append(int((3*a[i])+1))
    if a.count(a[i]) == 2:
        break
    i += 1

print(i+1)
# Judge status: Accepted
a, b = map(int, input().split())

for i in range(10, 1001):
  if int(i * 0.08) == a and int(i * 0.1) == b:
    print(i)
    exit()
print(-1)
# Judge status: Wrong Answer
n,m=map(int,input().split())

if n>=3 and m>=3:
  a=n*m
  b=n*2+m*2-4
elif n==1 or m==1:
  a=n*m
  b=2
elif n==2 or m==2:
  a=0
  b=0
  
print(a-b)
# Judge status: Accepted
A,B,C = map(str, input().split())
ans =[A[0],B[0],C[0]]
print(''.join(map(str, ans)))
# Judge status: Accepted
S = str(input())
T = str(input())
Snagasa = len(S)
Tnagasa = len(T)
saisyuicchi = 0
for i in range (Snagasa-Tnagasa+1):
 icchi = 0
 for j in range (Tnagasa):
  if S[i+j] == T[j]:
   icchi = icchi + 1
  else:
   icchi = icchi
 if icchi > saisyuicchi:
  saisyuicchi = icchi
ans = Tnagasa - saisyuicchi
print (ans)
# Judge status: Wrong Answer
import math
N, M ,L= map(int, input().split())
a=math.sqrt(N)+math.sqrt(M)
b=math.sqrt(L)
if a<b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
c = [list(map(int, input().split())) for _ in range(3)]
def a(c):
    for j in range(2):
        if not ((c[0][j]-c[0][j+1]) == (c[1][j]-c[1][j+1]) and (c[1][j]-c[1][j+1]) == (c[2][j]-c[2][j+1])):
            return print('No')
        if not ((c[j][0]-c[j+1][0]) == (c[j][1]-c[j+1][1]) and (c[j][1]-c[j+1][1]) == (c[j][2]-c[j+1][2])):
            return print('No')
    return print('Yes')
a(c)
# Judge status: Wrong Answer
sx,sy,tx,ty = map(int,input().split())

dx = tx - sx
dy = ty - sy

iki_yoko = 'R' if dx >= 0 else 'L'
kaeri_yoko = 'L' if dx >= 0 else 'R'
iki_tate = 'U' if dx >= 0 else 'D'
kaeri_tate = 'D' if dx >= 0 else 'U'

print(iki_yoko*abs(dx) + iki_tate*abs(dy) + kaeri_yoko*abs(dx) + kaeri_tate*abs(dy) + kaeri_tate + iki_yoko*abs(dx) + iki_tate*abs(dy) + kaeri_yoko + iki_tate + kaeri_yoko*abs(dx) + kaeri_tate*abs(dy) + iki_yoko)
# Judge status: Accepted
def get_num(s, t):
    cnt = len(s)
    for i in range(len(s)):
        if s[i] == t[i]:
            cnt -= 1
    return cnt


def main():

    s = input()
    t = input()
    len_s, len_t = len(s), len(t)
    ans = len_t
    for i in range(len_s - len_t + 1):
        new_s = s[i:len(t) + i]
        tmp = get_num(new_s, t)
        ans = min(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a = list(map(int, input().split()))
print("bust" if sum(a) else "win")
# Judge status: Accepted
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, C * A))
# Judge status: Accepted
A, B, T = list(map(int,input().split()))
count = 0
t = A
while t <= T + 0.5:
  count += B
  t += A
print(count)
# Judge status: Accepted
def string(s, t):
	summ1 = 0
	summ2 = 0
	for i in range(len(s)):
		summ1 += ord(s[i])
	for j in range(len(t)):
		summ2 += ord(t[j])
	if summ1 > summ2:
		print(t, end="")
		print(s)
	else:
		print(t, end="")
		print(s)


s, t = map(str, input().split())
string(s, t)
# Judge status: Accepted
S = list(input())
if S.count('A') >= 1 and S.count('B') >= 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
ans = ""
if n == 0:
    print(0)
    exit()
while n != 0:
    tmp = n % 2
    ans+=str(tmp)
    n=(n-tmp)//(-2)
ans = ans[::-1]
print(ans)
# Judge status: Accepted
from collections import Counter
n = int(input())
a = [int(input()) for i in range(n)]
c = Counter(a).values()
ans = 0
for i in c:
    if i % 2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
n=int(input())

if n%2==1:
    print(0)
else:
    m=n//2
    ans=0
    while m>0:
        ans+=m//5
        m=m//5
    print(ans)
# Judge status: Accepted
N , T = map(int,input().split())
ans =[]
for i in range(N):
    c , t = map(int,input().split())
    if t <= T:
        ans.append(c)

if len(ans) == 0:
    print('TLE')
else:
    print(min(ans))
# Judge status: Accepted
def main():
    n = int(input())
    abl = []
    for _ in range(n):
        a, b = map(int, input().split()) 
        abl.append([a,b])

    abl.sort(key=lambda x:x[1])
    curr_time = 0
    for curr_ab in abl:
        # print(curr_time)
        a,b = curr_ab
        curr_time += a
        if curr_time > b:
            print('No')
            return
    print('Yes')


if __name__ == "__main__":
    main()
# Judge status: Accepted
N=int(input())

A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
ans=0
for i in range(N):
    temp=sum(A1[:i+1])+sum(A2[i:])
    if temp>ans:
        ans=temp

print(ans)
# Judge status: Accepted
S = { "a":input(), "b":input(), "c":input() }
ba = "a"

while True:
    if 0 == len(S[ba]):
        print(ba.upper())
        break
    else:
        p = S[ba][0]
        S[ba] = S[ba][1:]
        ba = p
# Judge status: Accepted
a = input()
if a.isupper():
  print("A")
else:
  print("a")
# Judge status: Accepted
from fractions import gcd

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

lcm = (c*d) // gcd(c, d)

all_count = b - a + 1
c_count = b // c - (a-1) // c
d_count = b // d - (a-1) // d
cd_count = b // lcm - (a-1) // lcm

print(all_count - c_count - d_count + cd_count)
# Judge status: Wrong Answer
n = int(input())
aa = list(map(int, input().split()))
c2 = 0
c4 = 0

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
  else:
    print('No')
    exit()

if c4 + c2 == n:
  print('Yes')

elif n/2 -1 < c4 < n/2 + 1:
  print('Yes')
  
elif n % 4 == 2:
  if c4 == n / 2 - 1 and c2 == 2:
    print('Yes')
else:
  print('No')
# Judge status: Accepted
c=input()

if c=='a' or c=='i' or c=='u' or c=='e' or c=='o':
  print('vowel')
else:
  print('consonant')
# Judge status: Wrong Answer
#!/usr/bin/env python3

S = int(input())

e = S
cnt = 0
while True:
    if e % 2 == 0:
        v = e//2
    else:
        v = 3*e+1
    e = v
    cnt += 1
    if v == 4:
        print(cnt+4)
        exit()
# Judge status: Wrong Answer
x = int(input())
Su = int(2*x/11)
M = x%11
if x < 11:
    if x <=5:
        print(1)
    else:
        print(2)
else:
    if M ==0:
        print(Su)
    else:
        if M <= 5:
            print(Su+1)
        else:
            print(Su+2)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
alice = []
bob = []

for i in range(n):
    if i % 2 == 0:
        alice.append(max(a))
        a.remove(max(a))
    else:
        bob.append(max(a))
        a.remove(max(a))

print(sum(alice)-sum(bob))
# Judge status: Accepted
n,m = map(int,input().split())
city = []
for i in range(n):
    city.append([])

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

for r in city:
    print (len(r))
# Judge status: Wrong Answer
from collections import Counter
w = input()
c = Counter(w)

s = "No"
while(True):
  for t in c.most_common():
    if (t[1]%2) == 0:
      s = "Yes"
    else:
      break
  break
print(s)
# Judge status: Accepted
H, N = map(int, input().split())
A = [int(x) for x in input().split()]
print('Yes' if sum(A) >= H else 'No')
# Judge status: Accepted
n,m = map(int,input().split())
total = 0

for a in range(n+1):
  for b in range(n+1):
    total=10000*a+5000*b+1000*(n-a-b)
    if total == m and a+b <=n:
      print(a,b,n-a-b)
      exit()
    
print(-1,-1,-1)
# Judge status: Accepted
n = int(input())
B = list(a-i-1 for i,a in zip(range(n), map(int,input().split())))
B.sort()
ans = sum(B[n//2 + (n%2) :]) - sum(B[: n//2]) # sum(median left) - sum(median right)
print(ans)
# Judge status: Accepted
import sys
import math
input = sys.stdin.readline


def main():
    X = int(input())
    bank = 100
    i = 0
    while bank < X:
        bank = math.floor(bank*1.01)
        i += 1
    print(i)


if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import Counter
N = int(input())
A = tuple(map(int, input().split()))
A_count = Counter(A)
ans = 0
for i, j in A_count.items():
    ans += j * (j - 1) // 2
for k in range(1, N+1):
    n = A_count[A[k-1]]
    ans_ = ans - (n - 1)
    print(ans_)
# Judge status: Accepted
import sys
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

N = int(read())
print(main(N))
# Judge status: Accepted
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
print("Yes" if count == N else "No")
# Judge status: Accepted
a,b,c = map(int,input().split())
k = int(input())
p = 0
for i in range(k+1):
	if c*(2**i) > b*(2**(k-i)) and b*(2**(k-i)) > a:
		p += 1
		break
if p == 1:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
S = input()
n = len(S) + 1

A = [0 for _ in range(n)]
for i in range(n - 1):
    prev = A[i]
    if S[i] == "<":
        A[i + 1] = max(A[i + 1], prev + 1)

for i in range(n - 1):
    j = n - i - 2
    prev = A[j + 1]
    if S[j] == ">":
        A[j] = max(A[j], prev + 1)

print(sum(A))
# Judge status: Accepted
s = input()
if not s[0]=="A":
  print("WA")
elif not s[1].islower():
  print("WA")
else:
  cnC = 0
  for i in range(2,len(s)-1):
    if s[i]=="C":
      cnC += 1
    elif s[i].isupper():
      print("WA")
      quit()
  if cnC==1 and s[len(s)-1].islower():
    print("AC")
  else:
    print("WA")
# Judge status: Accepted
def seive(num,n):
    li=[True]*(n+1)
    x=2
    li[0]=False
    li[1]=False
    while x*x<n:
        if li[x]:
            for i in range(x*x,len(li),x):
                
                li[i]=False
                
        x+=1
        
        
    for i in range(num,len(li)):
        if li[i]:
            return i
num=int(input())
print(seive(num,1000000))
# Judge status: Accepted
S = input()
if S[2]==S[3]:
    if S[4]==S[5]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()
if N == M:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import collections

s = str(input())
t = str(input())
f = s + t
c = collections.Counter(f)
red = False
if len(c) == 1:
    if len(s) < len(t):
        red = True

for i in s:
    for k in t:
        if i < k:
            red = True
            break
if red:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n+1):
    ans += i
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
PY = [list(map(int,input().split())) + [i] for i in range(M)]

PY.sort()

pnow = PY[0][0]
c = 1

ans = [-1 for i in range(M)]

for i in range(M):
    if pnow != PY[i][0]:
        c = 1
        pnow = PY[i][0]
    ans[PY[i][2]] = str(PY[i][0]).zfill(6) + str(c).zfill(6)
    c += 1

print('\n'.join(ans))
# Judge status: Wrong Answer
N = int(input())
c = str(input())

w = c.count("W")
r = c.count("R")

ans = r

if w == 0:
    print(0)
else:
    if c[0]=="R":
        for i in range(N):
            if c[i] == "W":
                ans -= i
                print(ans)
                break
            break
# Judge status: Wrong Answer
days, num = map(int, input().split())
hwk = map(int, input().split())
if days >= sum(hwk):
  print(days - sum(hwk))
else:
  print(-1)
# Judge status: Accepted
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
print(sum(H[K:]))
# Judge status: Accepted
N = int(input())
cnt = 0
for i in range(1, N+1):
  if i * (1 + i) // 2 >= N:
    cnt = i
    break
for i in range(cnt, 0, -1):
  if i <= N:
    print(i)
    N -= i
# Judge status: Accepted
def solve():
  N, L = map(int, input().split())
  S = [input() for _ in range(N)]
  S.sort()
  ans = ''.join(S)
  return ans
print(solve())
# Judge status: Wrong Answer
import numpy
N, K = map(int, input().split())
p = list(map(int, input().split()))

lis = list()

p = [(i + 1)/2 for i in p ]
numpy.set_printoptions(precision=16)

cumSum = numpy.cumsum(p)

cumSum2 = list(cumSum)

cumSum2.insert(0,0)

for i in range(0, N-K+1):
    lis.append(cumSum2[K+i] - cumSum2[i])

print('{:.12f}'.format(int(max(lis))))
# Judge status: Accepted
import math
x = int(input())
money = 100
c = 0
while money < x:
    c += 1
    money = math.floor(money*1.01)
print(c)
# Judge status: Accepted
n,k = map(int, input().split())
a = []
for i in range(1,n+1):
  j = i
  b =0
  while j<k:
    j*=2
    b+=1
  a.append(b)
ans = 0
for i in range(n):
  ans+=0.5**a[i]
print(ans/n)
# Judge status: Accepted
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, X = il()
    print('YES' if A > X - B and X >= A else 'NO')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
O = [input()]
E = [input()] + [""]

for o, e in zip(O,E): print(o+e , end="")
# Judge status: Accepted
s = int(input())

A = set()
while(True):
    if s in A:
        break    
    else:
        A.add(s)
        if s%2==0:
            s = s/2
        else:
            s = 3*s+1

print(len(A)+1)
# Judge status: Accepted
S = input()

if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys

if __name__ == '__main__':
    n = int(sys.stdin.readline().rstrip())
    ans = ''
    while True:
        n -= 1
        ans += chr(65+32+(n % 26))
        if n < 26:
            break
        n = n // 26
    print(ans[::-1])
# Judge status: Accepted
h1,m1,h2,m2,k=map(int,input().split())
print(60*(h2-h1)+m2-m1-k)
# Judge status: Accepted
a, b = map(int, input().split())
print(min(str(a) * b, str(b) * a))
# Judge status: Wrong Answer
D = int(input())

print("Chiristmas", end ="")
days = 25 - D
for i in range(days):
    print(" Eve", end ="")
# Judge status: Wrong Answer
for i in {1,2,3}.difference(set(map(int,input().split(' ')))):
    print(i)
# Judge status: Accepted
a,b,c=map(int, input().split())
print(max(b+c-a,0))
# Judge status: Accepted
n = int(input())
al = [int(input()) for i in range(n)]

i = 0
for j in range(n):
    i = al[i]-1
    if i == 1:
        print(j+1)
        exit()
print(-1)
# Judge status: Accepted
def main():
  N = int(input())
  S = []
  for i in range(N):
    S.append(str(input()))

  print(len(set(S)))
  
if __name__ == "__main__":
  main()
# Judge status: Accepted
s = list(input())
n = len(s) + 1

l = [0] * n
r = [0] * n

for i, c in enumerate(s, 1):
    if c == '>':
        l[i] = 0
    else:
        l[i] = l[i - 1] + 1

for i, c in enumerate(s[::-1]):
    i = n - 2 - i
    if c == '<':
        r[i] = 0
    else:
        r[i] = r[i + 1] + 1

seq = [x if x > y else y for x, y in zip(l, r)]

ans = sum(seq)
print(ans)
# Judge status: Accepted
import itertools
N,M,Q = map(int,input().split())
pair = [list(map(int,input().split())) for i in range(Q)]

ans = 0

for A in itertools.combinations_with_replacement(range(1,M + 1),N):
  temp = 0
  for p in pair:
    if A[p[1]-1] - A[p[0]-1] == p[2]:
      temp += p[3]
      ans = max(ans,temp)
    
print(ans)
# Judge status: Accepted
N=int(input())
[3,5,7,11,13]
A=[105,135,165,189,195]
ans=0
for i in A:
  if i <=N:
    ans+=1
print(ans)
# Judge status: Accepted
n = int(input())

a = n // 2
b = n % 2

print(a+b)
# Judge status: Accepted
n, y = map(int, input().split())
for a in range(n+1):
    for b in range(n+1):
        c = n - (a+b)
        if a*10000 + b*5000 + c*1000 == y and a+b+c == n and c >= 0:
            print(a, b, c)
            exit()
print('-1 -1 -1')
# Judge status: Wrong Answer
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    S = [readline().rstrip() for _ in range(n)]
    c = collections.Counter(S)
    maxS = c.most_common()[0][1]
    for i in range(len(c)):
        if c.most_common()[i][1] == maxS:
            print(c.most_common()[i][0])


if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()

N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")


if (N == S == 0 or (N > 0 and S > 0)) and (E == W == 0 or (W > 0 and E > 0)):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N=int(input())
print((N+1)*N/2)
# Judge status: Accepted
s = '0' + input()
m = len(s)
up = 0
cnt = 0
y = []
for i in range(-1, -m-1, -1):
    cs = int(s[i]) + up
    if cs < 5 or (cs == 5 and int(s[i-1]) < 5):
        cnt += cs
        y.append([cs, s[i]])
        up = 0
    else:
        cnt += 10 - cs
        y.append([10 - cs, s[i]])
        up = 1
        
print(cnt)