peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())

totalcount = 0

for j in range(1, N+1, 2):
    count = 0
    for i in range(1, N+1):
        if j % i == 0:
            count = count + 1
    if count == 8:
        totalcount = totalcount + 1
print(totalcount)
# Judge status: Wrong Answer
import numpy as np
N,K=map(int,input().split())
A=np.array(list(map(int,input().split())))

Appeared=[]
flag=0
k=0
location=0
T=0
T_List=[]
while flag==0:
    k+=1
    Appeared.append(location)
    location=A[location]-1
    if location in Appeared:
        flag=1
        T=k-Appeared.index(location)
        T_List=Appeared[k-T:k]
Destination=(K-(k-T-1))%T
print(T_List[Destination-1]+1)
# Judge status: Accepted
import math
 
N = int(input())
 
M = int(math.sqrt(N))

ans = 0 
check = [True for _ in range(M + 1)]
e = [0 for _ in range(M + 1)]

for p in range(2, M + 1):
    if check[p] == True:
        for j in range(2, M // p + 1):
            check[p * j] = False

        while N % p == 0:
            N = N // p
            e[p] += 1
        
        ans += int((math.sqrt(1 + 8 * e[p]) - 1)/2)

if N > 1:
    ans += 1

print(ans)
# Judge status: Accepted
import math

N = int(input())
lines = [list(map(int, input().split())) for i in range(N-1)]

cost = []

for i in range(N):
    time = 0
    for j in range(i, N-1):
        C, S, F = lines[j]
        if time < S:
            time = S + C
        else:
            time = F*math.ceil(time/F) + C
    cost.append(time)

for c in cost:
    print(c)
# Judge status: Wrong Answer
n, k = map(int, input().split())
s, p, r = map(int, input().split())
t = input()
pre = "0"
ans = 0

for i in range(k):
    for j in t[i::k]:
        if j != pre:
            if j == "s":
                ans += s
            elif j == "p":
                ans += p
            else:
                ans += r
            pre = j
        else:
            pre = "0"
print(ans)
# Judge status: Wrong Answer
import fractions

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

import math
def prime_number(n):
    prime_list = []
    p = 2
    last = n

    while p <= math.sqrt(last)+1:
        cnt = 0
        if n % p != 0: pass
        else:
            while n % p == 0:
                n //= p
                cnt += 1

            prime_list.append((p, cnt))

        p += 1
    return len(prime_list)

n = fractions.gcd(a, b)
print(prime_number(n) + 1)
# Judge status: Accepted
S = input()
Q = int(input())

forward = True
que0 = []
que1 = []

for _ in range(Q):
    query = input().split()

    if query[0] == '1':
        forward = not forward

    else:
        head = (query[1] == '1')
        if head ^ forward:
            que1.append(query[2])
        else:
            que0.append(query[2])

S = ''.join(que0[::-1]) + S + ''.join(que1)

if forward:
    print(S)
else:
    print(S[::-1])
# Judge status: Wrong Answer
import math
A,B,C,D,E = [int(input()) for _ in range(5)]
A1 = math.ceil(A/10) * 10
B1 = math.ceil(B/10) * 10
C1 = math.ceil(C/10) * 10
D1 = math.ceil(D/10) * 10
E1 = math.ceil(E/10) * 10
A2 = A % 10
B2 = B % 10
C2 = C % 10
D2 = D % 10
E2 = E % 10
for i in range(1,11):
    if A2 == i or B2 == i or C2 == i or D2 == i or E2 == i:
        print(A1+B1+C1+D1+E1-(10-i))
        break
# Judge status: Accepted
N,H=map(int,input().split())
a=0
b=[]
for _ in range(N):
    A,B=map(int,input().split())
    a=max(a,A)
    b.append(B)
b=sorted(b,reverse=True)
ans=0
for i in range(N):
    if b[i]<=a:
        break
    H-=b[i]
    ans+=1
    if H<=0:
        print(ans)
        exit()
print(ans-(-H//a))
# Judge status: Accepted
import sys
n, a, b = map(int, sys.stdin.readline().split())
c = b - a
if c % 2:
  d = min(a - 1, n - b)
  e = 1
  f = (b - a - 1) // 2
  print(d + e + f)
else:
  print(c // 2)
# Judge status: Accepted
from bisect import bisect_right
from bisect import bisect_left
 
n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))
cnt = 0
bn = []
for i in range(n):
    x1 = bisect_left(a, b[i])
    x2 = bisect_right(c, b[i])
    cnt += x1*(n-x2)
print(cnt)
# Judge status: Wrong Answer
a, b = map(int, raw_input() .split())
x = ''
for i in range(a):
  x += str(b)
  print x
# Judge status: Accepted
import sys
n=int(input())
a=list(map(int,sys.stdin.read().split()))
check_a=[False for _ in range(n)]
c=0
i=0
while True:
  if i == 1:
    print(c)
    exit()
  nex=a[i]-1
  if check_a[i]:
    break
  check_a[i]=True
  i=nex
  c+=1
print(-1)
# Judge status: Accepted
S = input ()
T = S.replace('A', '')
T = T.replace('C', '')
U = T.lower ()
if S[0]=='A' and S.count('A')==1 and S[2:-1].count('C')==1 and S.count('C')==1 and T==U:
  print ('AC')
else:
  print ('WA')
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
ls = [A,B,C,D,E]

last = -1
amari = 10
tmp = -1
for i in range(5):
    if ls[i] %10 != 0:
        if amari > ls[i] % 10:
            amari = ls[i] % 10
            tmp = i
        ls[i] += 10 -ls[i] % 10

print(sum(ls)-(10-amari))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

m = 1000
cnt = 0
have = False
for i in range(n-1):
    if cnt:
        if a[i] >= a[i+1]:
            m += cnt * a[i]
            cnt = 0
    else:
        if a[i] < a[i+1]:
            cnt += m // a[i]
            m -= a[i] * cnt
m += cnt * a[n-1]

print(m)
# Judge status: Wrong Answer
l = [int(x) for x in input().split()]

l.sort(reverse=True)


if len([x for x in l if x % 2 != 0]) == 0:
    print(0)
else:
    ans = ((l[0]//2+1) - (l[0]//2)) * l[1] * l[2]
    print(ans)
# Judge status: Wrong Answer
n=int(input())

ab = []
for _ in range(n):
    a, b, c = (int(x) for x in input().split())
    ab.append([a, b, c])

dp = [0]*n
memo = -1
memos = -1

for i in range(n):
    for j in range(3):
        if i == 0:
            dp[i] = max(ab[0])
            memos = j
        elif memo != j and dp[i] < dp[i-1]+ab[i][j]:
            dp[i] = dp[i-1]+ab[i][j]
            memos = j
    memo = memos
print(dp)
# Judge status: Accepted
import bisect
N, Q = map(int, input().split())
S = input()
arr = []
for i in range(N-1):
  if S[i:i+2] == "AC":
    arr.append(i)
#print(arr)
for i in range(Q):
  l, r = map(int, input().split())
  print(bisect.bisect_right(arr, r-2) - bisect.bisect_left(arr, l-1))
# Judge status: Accepted
A, B, C = map(int, input().split())
K = int(input())

for i in range(K):
    if A >= B:
        B *= 2
    elif B >= C:
        C *= 2

if A < B and B < C:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if P[i] == i + 1:
        P[i],P[i+1] = P[i+1],P[i]
        ans += 1
if P[-1] == N:
    ans += 1
print(ans)
# Judge status: Accepted
N=int(input())
S=input()
cnt=S.count("E")
m=cnt
for i in S:
    if i=="E":
        cnt-=1
    else:
        cnt+=1
    m=min(m,cnt)
print(m)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
if abs(a-c) <= d: print('Yes')
elif abs(a-b) <= d and abs(b-c) <= d: print('Yes')
else: print('No')
# Judge status: Accepted
X, Y = map(int, input().split())
i = 1
if X % Y == 0:
    print(-1)
else:
    print(X)
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
l = [a,b,c]
l.sort()
#print(l)
print('Yes'if (l[1]-l[0]) <= d and (l[2]-l[1]) <= d  else 'No')
# Judge status: Wrong Answer
a = int(input())
mx = 1

for i in range(2,a):
    j=2
    while i**j <= a:
        mx = max(i**j,mx)
        j+=1
    else: break

print(mx)
# Judge status: Accepted
print(int('1'*(len(str(bin(int(input()))))-2), 2))
# Judge status: Accepted
# A
S = input()
ans = [0] * (len(S)+1)
for i in range(len(S)):
  if S[i] == "<":
    ans[i+1] = max(ans[i+1],ans[i]+1)
  
for i in range(len(S)-1,-1,-1):
  if S[i] == ">":
    ans[i] = max(ans[i],ans[i+1]+1)

print(sum(ans))
# Judge status: Accepted
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

n, k = map(int, input().split())
nums = list(map(int, stdin.readline().split()))
nums.sort()
print(sum(nums[:k]))
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
S = False
for i in range(n):
    if not S:
        S = Counter(list(input()))
    else:
        S = S & Counter(list(input()))

ans = ''
for key in sorted(S.keys()):
    ans += key * S[key]
print(ans)
# Judge status: Wrong Answer
from math import factorial
n,a,b=map(int,input().split())
sum=0
for i in range(n):
    if i==a or i==b:
        continue
    com=factorial(n)//(factorial(i)*factorial(n-i))
    sum+=com
print(sum%(10**9+7))
# Judge status: Accepted
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)][::-1]

ans = 0
for a, b in ab:
    a += ans
    ans += -(-a//b)*b - a
print(ans)
# Judge status: Accepted
N, L = map(int, input().split())
list = [L+i for i in range(N)]
a = float("inf")
for i in range(N):
  if abs(a) > abs(list[i]):
    a = list[i]
print(sum(list) - a)
# Judge status: Wrong Answer
a = input()
b = list(a)

c = sorted(b, reverse = True)

if c[0] == '1':
  print("pon")
elif c[0] == '2':
  print("hon")
elif c[0] == '3':
  print("bon")
elif c[0] == '4':
  print("hon")
elif c[0] == '5':
  print("hon")
elif c[0] == '6':
  print("pon")
elif c[0] == '7':
  print("hon")
elif c[0] == '8':
  print("pon")
elif c[0] == '9':
  print("hon")
elif c[0] == '0':
  print("pon")
# Judge status: Accepted
#C
import math

A,B,H,M = map(int,input().split())
a2 = A*A+B*B-2*A*B*math.cos(math.pi*2*((H/12+M/720)-M/60))
print(math.sqrt(a2))
# Judge status: Accepted
a, b = map(int, input().split())

if (a > 8 or b > 8):
   print(':(')
else:
   print('Yay!')
# Judge status: Accepted
n,k=map(int,input().split())
record=[]
for i in range(k):
    d=input()
    record.extend(list(map(int,input().split())))
record=list(set(record))
print(n-len(record))
# Judge status: Wrong Answer
a,b,c,k = map(int,input().split())
ans = 0
if a >= k:
    ans = a
    print(ans)
else:
    ans += a
    k -= a
    if b >= k:
        print(ans)
    else:
        k -= b
        ans -= k
        print(ans)
# Judge status: Accepted
n,k,q=map(int,input().split())
b=[k-q]*n
for i in range(q):
  a=int(input())
  b[a-1]+=1
for i in range(n):
  if b[i]<=0:
    print("No")
  else:
    print("Yes")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = 0
i = 0
while i < n:
  if i+1 == a[i]:
    ans += 1
    i += 1
  i += 1
    
print(ans)
# Judge status: Accepted
from collections import Counter
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

cnt = Counter(A)


def comb(n):
    return n * (n - 1) // 2


sumall = 0

for i in cnt.values():
    sumall += comb(i)

for a in A:
    ans = sumall - (cnt[a] - 1)
    print(ans)
# Judge status: Wrong Answer
import numpy as np
n = int(input())

sg = []

for i in range(n):
    x, l = map(int, input().split())
    sg.append([max(x - l + 1, 0), x + l - 1])

sg.sort()

prev = sg[0]

ans = 0
for i in range(1, n):
    if prev[1] >= sg[i][0]:
        ans += 1
    if prev[1] < sg[i][1]:
        prev = sg[i]

print(n - ans)
# Judge status: Accepted
X = int(input())

if X in [3,5,7]:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
s = input()

dic1 = dict()

for i in s:
    if not i in dic1:
        dic1[i] = 1

for i in range(ord("a"),ord("z")+1):
    if not chr(i) in dic1:
        print(chr(i))
        exit()

print("None")
# Judge status: Wrong Answer
a,b=input().split()
if a != 1 and b == 1:
  print('Bob')
elif a == 1 and b != 1:
  print('Alice')
elif a == b:
  print('Draw')
elif a > b:
  print('Alice')
else:
  print('Bob')
# Judge status: Wrong Answer
k, x = map(int, input().split())
ans = [int(x) for x in range(x-k+1, x+k-1)]
print(' '.join(map(str, ans)))
# Judge status: Wrong Answer
n, l = map(int, input().split())
a = list(input() for i in range(n))
print(sorted(a))
# Judge status: Accepted
a,b = map(str, input().split())
a = int(a)
b = int(b[0]+b[2:])
print(int(a*b)//100)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

for i in range(M):
  if A[i] < sum(A) / (4*M):
    print('No')
    exit()

print('Yes')
# Judge status: Accepted
n,m=map(int,input().split())
wa_check=[0 for _ in range(n+1)]
ac_check=[0 for _ in range(n+1)]
for i in range(m):
    p,s=input().split()
    p=int(p)
    if(ac_check[p]==0):
        if(s=='AC'):
            ac_check[p]=1
        else:
            wa_check[p]+=1
wa_ans=[wa_check[i] for i in range(n+1) if ac_check[i]!=0]
print(sum(ac_check),sum(wa_ans))
# Judge status: Accepted
L, R, d = [int(x) for x in input().split(" ")]

count = 0
for i in range(L, R+1):
    if i % d == 0:
        count += 1
print(count)
# Judge status: Wrong Answer
import sys
from bisect import bisect

n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
b = list(map(int, sys.stdin.buffer.readline().split()))
c = list(map(int, sys.stdin.buffer.readline().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in a:
    for j in range(bisect(b, i), n):
        ans += n - bisect(c, j)
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
min = min(A, B)
max = max(A, B)

cnt = 1
while True:
    if max * cnt % min == 0:
        print(max * cnt)
        exit()
    cnt += 1
# Judge status: Accepted
#ABC056-C
x = int(input())

#2次方程式を解く
t = int((-1+(1+8*x)**0.5)//2)

if t * (t+1) // 2 >= x:
    print(t)
else:
    print(t+1)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())

a = N // (A + B)
if N % (A+B) != 0:
    a_cnt = ( a * A ) + ( N % (A+B) )
else:
    a_cnt = a * A

print(a_cnt)
# Judge status: Accepted
r=int(input())
print(int(r**2))
# Judge status: Wrong Answer
n=int(input())
s=input()
ans=""
for i in range(len(s)):
    tmp=ord(s[i])+2
    if tmp>90:
        tmp-=26
    ans+=chr(tmp)
print(ans)
# Judge status: Accepted
a=[int(input()) for i in range(5)]
result=0
ans=0
x=10
for i in a:
    if i%10!=0:
        result+=(i//10+1)*10
    else:
        result+=i
for i in a:
    if i%10!=0:
        ans=i%10
        if ans<x:
            x=ans
print(result+x-10)
# Judge status: Accepted
n = [0] + list(map(int, input())) + [0]
n = n[::-1]
#print(n)

b0 = [0]*len(n)
b1 = [0]*len(n)
b1[0] = 1
for i in range(1, len(n)):
  num = n[i]
  b0[i] = min(b0[i-1]+num, b1[i-1]+num+1)
  b1[i] = min(b0[i-1]+10-num, b1[i-1]+10-(num+1))

print(min(b0[-1], b1[-1]))
#print(b0[-1], b1[-1])
# Judge status: Wrong Answer
a=int,input()
if a==7 or 5 or 3:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
a=input().split()
print(len(set(a)))
# Judge status: Accepted
import sys


input = sys.stdin.readline


def main():
  k, n = map(int, input().rstrip().split())
  a = [int(_) for _ in input().rstrip().split()]
  
  dist = [(a[i] - a[i - 1]) % k for i in range(n)]
  
  print(k - max(dist))


if __name__ == "__main__":
  main()
# Judge status: Accepted
N,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
A.sort()
sums=0
for i in range(N):
    sums+=A[i][1]
    if sums>=K:
        print(A[i][0])
        break
# Judge status: Wrong Answer
from collections import deque

N, M, K = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))

count = 0
for i in range(N + M):
  if len(A) == 0:
    book = B[0]
    B.popleft()
  elif len(B) == 0:
    book = A[0]
    A.popleft()
  else:
    if A[0] <= B[0]:
      book = A[0]
      A.popleft()
    else:
      book = B[0]
      B.popleft()
  
  if K >= book:
    count += 1
    K -= book
  else:
    break

print(count)
# Judge status: Accepted
a,b,c=map(int, input().split())
if a<=c<=b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n=int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab=ab[::-1]
#print(ab)
ans=0
for a,b in ab:
    if (a+ans)%b!=0:
        ans+=b-(a+ans)%b
print(ans)
# Judge status: Accepted
d, n = map(int, input().split())
if n == 100:
    print(101*100**d)
else:
    print(100**d*n)
# Judge status: Accepted
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
l = [[] for i in range(n)]
ab.sort()
for i in range(m):
    x = ab[i]
    l[x[0]-1].append(x[1]-1)
    l[x[1]-1].append(x[0]-1)
for i in l[0]:
    if n-1 in l[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
# Judge status: Wrong Answer
import collections
n=int(input())
data=[""]*n
for i in range(n):
    data[i]=input()
count=collections.Counter(data)
num=max(count.values())
for v,k in count.items():
    if k==num:
        print(v)
# Judge status: Accepted
s = input()

ans = 0
if s.count("R") == 3:
    print(3)
elif s.count("R") == 2:
    if s[0] == s[1] or s[1] == s[2]:
        print(2)
    else:
        print(1)
elif s.count("R") == 1:
    print(1)
else:
    print(0)
# Judge status: Accepted
def factorial(n):
  fact = 1
  for i in range(2, n+1):
    fact = fact * i % (10**9+7)
  return fact

N, M = map(int, input().split())
MOD = 10**9+7
if N == M:
  print(2*factorial(N)**2 % MOD)
elif abs(N-M) == 1:
  print(factorial(min(N, M))**2 * max(N, M) % MOD)
else:
  print(0)
# Judge status: Accepted
n,m = map(int,input().split())
l = [-1] + [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    l[a].append(b)
    l[b].append(a)
for mid in l[1]:
    if n in l[mid]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a
c = [1]
x = True
y = [1, 1] + [0]*(n-1)

while x:
    c.append(a[c[-1]])
    y[c[-1]] += 1
    if y[c[-1]] == 2:
        x = False

t = c.index(c[-1])
if k <= t:
    ans = c[k]
else:
    ans = c[t + ((k-t) % (len(c)-1-t))]

print(ans)
# Judge status: Accepted
N = int(input())
s = set()

ans = 0
for i in range(1, N + 1):
    ans += i
    s.add(i)
    if ans >= N:
        break

if ans > N:
    s.remove(ans - N)

for n in s:
    print(n)
# Judge status: Accepted
a,b=map(int,input().split())

if a>=13:
  print(b)
elif a<=12 and a>=6:
  print(int(b/2))
else:
  print(0)
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))
S = []
s = 0
for i in range(N):
  s += W[i]
  S.append(s)
print(min([abs(S[N-1] - 2 * S[i]) for i in range(N)]))
# Judge status: Accepted
n = input()
s = input()

if n == s[:-1] and len(n) == len(s)-1:
    print('Yes')
else :
    print('No')
# Judge status: Accepted
import math
import itertools
#n = int(input())
#n, d = list(input().split())
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
point = 0
i = 0
while N > point:
    i+=1
    if i==1:
        point+=K
    else:
        point+=(K-1)

print(i)
# Judge status: Accepted
X = int(input())

err = 0
while X >= 0:
    X -= 100
    err += 5
    #print(X, err)
    if 0 <= X <= err:
        print('1')
        break
else:
    print('0')
# Judge status: Accepted
n = int(input())
b = list(map(int, input().split()))
ans = b[0]

for i in range(1,n-1):
    if b[i-1] <= b[i]:
        ans += b[i-1]
    else:
        ans += b[i]
print(ans+b[-1])
# Judge status: Accepted
n,a,b=map(int,input().split())
# x=n//(a+b)
# y=n%(a+b)
# print(a*x+min(y,a))
if a==0:
    print(0)
else:
    x=n//(a+b)
    y=n%(a+b)
    print(a*x+min(y,a))
# Judge status: Accepted
from math import ceil

def check(A, K, L):
    i = 0
    for a in A:
        i += ceil(a/L)-1
        if i > K:
            return False
    return True

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
l = 0
r = A[0]
while l + 1 < r:
    m = (l+r)//2
    if check(A, K, m):
        r = m
    else:
        l = m
print(r)
# Judge status: Accepted
N, K, Q = (int(x) for x in input().split())
A = [int(input()) for i in range(Q)]
ans = [K-Q for i in range(N)]

for a in A:
    ans[a-1] += 1

for b in ans:
    if b > 0:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort()

sum=0
for i in range(n):
  sum+=a[n+i*2]
  
print(sum)
# Judge status: Accepted
def main():
    N, T = map(int, input().split())
    ans = 1001
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            ans = min(c, ans)
    if ans == 1001:
        print("TLE")
    else:
        print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
A,B=map(int,input().split())
N=B-A
X=N*(N+1)//2
print(X-B)
# Judge status: Wrong Answer
import math

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

print(math.ceil(math.log(n, k)))
# Judge status: Wrong Answer
import math

N=int(input())
A=list(map(int,input().split()))
a=math.gcd(A[0],A[1])
b=A[0]
c=A[1]
for i in range(2,N):
  a=math.gcd(a,A[i])
  b=max(a,math.gcd(b,A[i]))
  c=max(a,math.gcd(c,A[i]))
print(max(a,b,c))
# Judge status: Accepted
import sys
input = sys.stdin.readline
import sys
sys.setrecursionlimit(10**7)
def main():
  n=int(input())
  s=input()
  sw,sb=[0],[0]
  w,b=0,0
  for si in s:
    if si=='#':
      b+=1
    else:
      w+=1
    sw.append(w)
    sb.append(b)
  ans=n
  for i in range(n+1):
    ans=min(ans,sw[n]-sw[i]+sb[i])
  print(ans)
if __name__=='__main__':
  main()
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      x, y, z = sorted([l[i], l[j], l[k]])
      if x + y > z and x != y and y != z:
        ans += 1
print(ans)
# Judge status: Accepted
import math

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

ar = a[::-1]
l = [0]
r = []

tmp1 = 0
tmp2 = 0
for i in range(n-1):
    tmp1 = math.gcd(tmp1, a[i])
    l.append(tmp1)
    tmp2 = math.gcd(tmp2, ar[i])
    r.append(tmp2)

r.reverse()
r.append(0)
ans = 1
for i in range(n):
    ans = max(ans, math.gcd(l[i], r[i]))
print(ans)
# Judge status: Accepted
A,B=map(int,input().split())
if A==B:
    print(A+A)
else:
    print(max(A,B)*2-1)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

b = a[0]
for v in a[1:]:
    b ^= v
for v in a:
    print(v ^ b)
print(*map(lambda x: x ^ b, a))
# Judge status: Accepted
N = int(input())
currentTime = 0
current = [0, 0]
for i in range(N):
    timeStamp = list(map(int, input().split()))
    reqLen = abs(timeStamp[1] - current[0]) + abs(timeStamp[2] - current[1])
    timeLen = timeStamp[0] - currentTime
    if reqLen > timeLen:
        print("No")
        exit()
    if reqLen % 2 != timeLen % 2:
        print("No")
        exit()
    currentTime = timeStamp[0]
    current = timeStamp[1:]
print("Yes")
# Judge status: Wrong Answer
s=list(input())
k=int(input())

cnt=0
for i in range(len(s)):
    num_al=ord(s[i])
    a_=123-num_al
    if k==0:break
    if a_<=k:
        k-=a_
        s[i]='a'
    elif a_>k and i<len(s)-1:continue
    else:
        s[i]=chr(num_al+k)
        k=0
print(''.join(s))
# Judge status: Wrong Answer
X = int(input())

a, mod = divmod(X, 500)
b = mod % 5

print(a * 1000 + b * 5)
# Judge status: Accepted
from collections import Counter
n = int(input())
ans = []
cnt = 0
for i in range(n):
    s = input()
    l = list(s)
    l.sort()
    ans.append("".join(l))
c = Counter(ans)


for i in c.values():
    cnt += i*(i-1)//2

print(cnt)
# Judge status: Wrong Answer
a,b,x = map(int,input().split())
if a<x and b>x:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
def solve():
    N = input()
    target = 753
    ans = 1000
    for i in range(len(N)-2):
        ans = min(ans, abs(753-int(N[i:i+3])))

    print(ans)


if __name__ == '__main__':
    solve()
# Judge status: Wrong Answer
n,d = map(int,input().split())
try:
  a = [list(map(int,input().split())) for j in range(0,n)]
except EOFError:
  pass
c = 0
r = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    for k in range(0,d):
      c+=(a[i][k]-a[j][k])**2
ans = c**(1/2)
if isinstance(ans,int) == True:
  r += 1
print(r)
# Judge status: Accepted

def makeLunLun(num):
  lunlunNums = []
  m = num % 10 -1
  z = m + 1
  p = m + 2
  if m >= 0:
    lunlunNums.append(num * 10 + m)
  lunlunNums.append(num * 10 + z)
  if p <= 9:
    lunlunNums.append(num * 10 + p)
  return lunlunNums

K=int(input())

queue = [1,2,3,4,5,6,7,8,9]
i=0
while K > len(queue):
  lunluns = makeLunLun(queue[i])
  queue += lunluns
  i += 1
print(queue[K-1])