Harryxun/stf_run huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
ct=0

M=max(a)
for i in range(25):
  if 2**i>M:
    x=i
    break
L=[]
for j in range(2**x-1):
  L.append(0)

for j2 in range(n):
  L[a[j2]-1]+=1

for k in range(x,1,-1):
  l1=L[0:2**(k-1)-1]
  l2=L[2**(k-1):2**k]
  l2.reverse()
  if L[2**(k-1)-1]%2==0:
    ct+=int(L[2**(k-1)-1]/2)
  for m in range(len(l1)):
    if l1[m]==l2[m]:
      ct+=l1[m]
      l1[m]=0
      l2[m]=0
  L=l1
ct+=int(L[0]/2)
print(ct)

### FIXED CODE ###

import math
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[]
for i in range(1,50):
  b.append(2**i)
ct=0
check=[1]*n
for i in range(n-1,-1,-1):
  if a[i]==1:
    break
  if check[i]==1 and a[i] not in b:
    check[i]=0
    x=math.floor(math.log2(a[i]))
    x=b[x]-a[i]
    y=bisect.bisect_left(a,x)
    z=bisect.bisect_right(a,x)
    t=bisect.bisect_left(check[y:z],1)+y
    if t!=z:
      check[t]=0
      ct+=1

ctb=0
w=1
for i in range(n):
  if a[i] in b or a[i]==1:
    if a[i]==w:
      if check[i]==1:
        ctb+=1
    else:
      ct+=ctb//2
      w=a[i]
      if check[i]==1:
        ctb=1
      else:
        ctb=0
  else:
    ct+=ctb//2
    ctb=0
ct+=ctb//2

print(ct)
X, Y = map(int, input().split())

points = [-1, 100000, 200000, 300000, 0]
print(400000*(X==Y==1) + points[max(4, X)] + points[max(4, Y)])

### FIXED CODE ###

X, Y = map(int, input().split())

points = [-1, 300000, 200000, 100000, 0]
print(400000*(X==Y==1) + points[min(4, X)] + points[min(4, Y)])
from collections import deque

N, M = map(int, input().split())
ARR = []

for i in range(N):
    ARR.append(list(map(int, input().split())))


def prepare(n, m, arr):
    nodes = [[] for i in range(n)]
    nodeStatus = [False for i in range(n)]
    for i in range(n):
        startNode = arr[i][0] - 1
        endNode = arr[i][1] - 1

        nodes[startNode].append(endNode)
        nodes[endNode].append(startNode)

    return nodes, nodeStatus


def calculate(n, nodes, nodeStatus):
    nodeMarks = [-1 for i in range(n)]

    q = deque()

    q.append((0, -1))

    while len(q) > 0:
        currentNode, parentNode = q.popleft()

        if nodeStatus[currentNode] == True:
            continue

        nodeStatus[currentNode] = True
        nodeMarks[currentNode] = parentNode
        childNodes = nodes[currentNode]

        for childNode in childNodes:
            if nodeStatus[childNode] == True:
                continue
            q.append((childNode, currentNode))

    minusNumber = nodeMarks.count(-1)
    if minusNumber > 1:
        print("No")
        return

    print("Yes")
    for i in range(1, n):
        print(nodeMarks[i] + 1)


nodes, nodeStatus = prepare(N, M, ARR)

calculate(N, nodes, nodeStatus)


### FIXED CODE ###

N, M = 6, 9
ARR = [
    [3, 4],
    [6, 1],
    [2, 4],
    [5, 3],
    [4, 6],
    [1, 5],
    [6, 2],
    [4, 5],
    [5, 6],
]

N, M = 4, 4
ARR = [
    [1, 2],
    [2, 3],
    [3, 4],
    [4, 2],
]

N, M = map(int, input().split())
ARR = []

for i in range(M):
    ARR.append(list(map(int, input().split())))

from collections import deque


def prepare(n, m, arr):
    nodes = [[] for i in range(n)]
    nodeStates = [-1 for i in range(n)]
    prevs = [-1 for i in range(n)]
    for i in range(m):
        startNode = arr[i][0] - 1
        endNode = arr[i][1] - 1

        nodes[startNode].append(endNode)
        nodes[endNode].append(startNode)

    return nodes, nodeStates, prevs


nodes, nodeStates, prevs = prepare(N, M, ARR)


def bfs(nodes, nodeStates, prevs, n):
    q = deque()
    q.append({'prev': -1, 'to': 0})
    while len(q) > 0:
        first = q.popleft()
        currentNode = first['to']
        previousNode = first['prev']
        if nodeStates[currentNode] != -1:
            continue
        prevs[currentNode] = previousNode
        childNodes = nodes[currentNode]
        nodeStates[currentNode] = 1
        for childNode in childNodes:
            q.append({'prev': currentNode, 'to': childNode})

    print("Yes")
    for i in range(1, n):
        print(prevs[i] + 1)


bfs(nodes, nodeStates, prevs, N)
def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

A, B, C, K = ZZ()
S = [1] * A + [0] * B + [-1] * C
print(sum(S[:K]))

### FIXED CODE ###

def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

A, B, C, K = ZZ()
ans = 1 * min(A, K)
K -= min(A, K)
ans += 0 * min(B, K)
K -= min(B, K)
ans += -1 * min(C, K)
print(ans)
N=int(input())
A=[]
for _ in range(N):
    W=input()
    if W in A:
        print('No')
        exit()
    else:
        W.append(A)

for i in range(N-1):
    if A[i][-1]!=A[i+1][-1]:
        print('No')
        exit()
print('Yes')

### FIXED CODE ###

N=int(input())
A=[]
for _ in range(N):
    W=input()
    if W in A:
        print('No')
        exit()
    else:
        A.append(W)

for i in range(N-1):
    if A[i][-1]!=A[i+1][0]:
        print('No')
        exit()
print('Yes')
a,b,c=map(int,input().split())
n=c-a-b
if n**2 > 4*a*b:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(a[n-1])
S = input()
for i in range(len(S)):
    if S[i] == S[i+1]:
        print("Bad")
        exit()
print("Good")

### FIXED CODE ###

S = input()
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        print("Bad")
        exit()
print("Good")
import functools
import operator

N = int(input())
A = list(map(int,input().split()))
result = functools.reduce(operator.mul, A)
if 0 in A :
    print(0)
else :
    if result > 10**18 :
        print('-1')
    else :
        print(result)


### FIXED CODE ###

A,B = map(int,input().split())
print(A*B)
q = input()


for i in range(q):
  X[i] = raw_input()
  Y[i] = raw_input()

for i in range(q):
  count = 0
  for j in range(q):
    if X[i][j] == Y[i][j]:
      count += 1

  print count
    

### FIXED CODE ###

def LCS():
    X = raw_input()
    Y = raw_input()
 
    a, b = len(X), len(Y)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = X[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == Y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i in range(n):
    print LCS()
S=print()
print(-S.count('-'+S.count('+'))

### FIXED CODE ###

S=input()
print(-S.count('-')+S.count('+'))
import sys
input = sys.stdin.readline
N = int(input())
A = map(int, input().split())
S = 0
S2 = 0
M = 10**9+7
for a in A:
  S += a
  S %= M
  S2 += a*a
  S2 %= M

# (S * S - S2)/2 
ans = (S * S - S2) * pow(2, -1, M)
ans %= M
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = map(int, input().split())
S = 0
S2 = 0
M = 10**9+7
for a in A:
  S += a
  S %= M
  S2 += a*a
  S2 %= M

# (S * S - S2)/2 
ans = (S * S - S2) * pow(2, -1, M)
ans %= M
print(ans)
a,b,k=input().split()
if(k<=a):
  print(a-k,b)
elif(k>a and k<=a+b):
  print(0,b-k+a)
else:
  print(0,0)

### FIXED CODE ###

a,b,k=map(int,input().split())
if(k<=a):
  print(a-k,b)
elif(k>a and k<=a+b):
  print(0,b-k+a)
else:
  print(0,0)
n=int(input())
a=26
b=1
import string
array=list(string.ascii_lowercase)
while n>a:
  b+=1
  a+=26**b
if b==1:
  print(array[n-1])
else:
  c=b-1
  d=n-26**c
  brray=[0]
  crray=[d]
  for i in range(c-1):
    brray[i+1]=crray[i]//(26**(c-i))
    crray[i+1]=crray[i]%(26**(c-i))
  ans=[]
  for j in range(1,c):
    ans[j]=array[brray[j]]
  ans.append(array[crray[c]-1])
  print( ''.join( ans ) )

### FIXED CODE ###

n=int(input())
a=26
b=1
import math
import string
array=list(string.ascii_lowercase)
while n>a:
  b+=1
  a+=26**b
if b==1:
  print(array[n-1])
else:
  c=b-1
  d=n-a
  brray=[0]
  crray=[d]
  for i in range(c):
    brray.append(math.ceil(crray[i]/(26**(c-i))))
    crray.append(crray[i]%(26**(c-i)))
  ans=array[brray[1]-1]
  if c>1:
    for j in range(2,b):
      ans=ans+array[brray[j]-1]
  ans=ans+array[crray[c]-1]
  print(ans)
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



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

### FIXED CODE ###

# n,m = map(int, input().split())
# sc = [map(int, input().split()) for _ in range(m)]
# s, c = [list(i) for i in zip(*sc)]
#
#
#
# for i in range(10**n):
#     ans = str(i)
#     if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
#         print(ans)
#         exit()
#
#
# print(-1)

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

s, c = [], []
for _ in range(m):
    s_, c_ = map(int, input().split())
    s.append(s_)
    c.append(c_)

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

print(-1)
from collections import defaultdict
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    N, M, K = map(int, input().split())
    const = 998244353

    def hoge(k):
        return comb(N - 1, k) * M * ((M - 1) ** (N - k - 1))

    ans = sum([hoge(k) for k in range(K + 1)])

    print(ans % const)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
from collections import defaultdict


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

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

    current = 0
    th = -1
    per_loop = -1
    for i in range(1, N+1):
        current = A[current] - 1

        if visited[current] >= 0:
            # print(i, current, visited[current])
            per_loop = i - visited[current]
            th = visited[current]
            break
        else:
            visited[current] = i

    current = 0
    # print(th, per_loop)

    if K < th:
        num_rep = K
    else:
        num_rep = th + (K - th) % per_loop

    for i in range(num_rep):
        current = A[current] - 1

    print(current + 1)


if __name__ == '__main__':
    main()
import numpy as np
import math
def lcm(x, y):
	return (x * y) // math.gcd(x, y)

a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
dc = (b // c) - ((a-1) // c)
dd = (b // d) - ((a-1)  // d)
dcd = (b // lcm(c, d)) - (a // lcm(c, d))
print((b - a) + 1 - (dc + dd - dcd))

### FIXED CODE ###

import fractions

def lcm(x, y):
	return (x * y) // fractions.gcd(x, y)

a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
dc = (b // c) - ((a-1) // c)
dd = (b // d) - ((a-1)  // d)
dcd = (b // lcm(c, d)) - ((a-1) // lcm(c, d))
print((b - a) + 1 - (dc + dd - dcd))
for i in range(2**(l-1)):
    f = ""
    for j in range(l-1):
        f += s[j]
        if i & (1 << j):
            f += "+"
        else:
            f += "-"
        if j == l-2:
             f += s[l-1]
    if eval(f)==7:
        print(f+"=7")
        break

### FIXED CODE ###

s = input()
l = len(s)

for i in range(2**(l-1)):
    f = ""
    for j in range(l-1):
        f += s[j]
        if i & (1 << j):
            f += "+"
        else:
            f += "-"
        if j == l-2:
             f += s[l-1]
    if eval(f)==7:
        print(f+"=7")
        break
N,M = map(int,input().split())
A = [input().split() for i in range(M)]
s1=list()
s2=list()
p=0
w=0
for i in range(M):
    if A[i][0] not in s2 and A[i][1]=="WA":
        s1 +=A[i][0]
    if A[i][0] not in s2 and A[i][1]=="AC":
        p+=1 
        s2 +=A[i][0]
        w += int(s1.count(A[i][0]))        
print(p,w)

### FIXED CODE ###

N = input()
A =[chr(i) for i in range(97, 97+26)]
for k in range(len(A)):
    if N==A[k]:
        print(A[k+1])
import sys

def f(b, n):
    if b > n:
        return n

    return f(b, n//b) + n % b


def main():
    input = sys.stdin.readline
    n = int(input())
    s = int(input())

    if s == n:
        return n+1

    for i in range(2, int(n**0.5)):
        if f(i, n) == s:
            return i

    b = (n - s) // p + 1
    if f(b, n) == s:
        return b
    else:
        return -1


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


### FIXED CODE ###

import sys

def f(b, n):
    if b < 2:
        return -1    

    if b > n:
        return n

    return f(b, n//b) + n % b


def main():
    input = sys.stdin.readline
    n = int(input())
    s = int(input())

    if s > n:
        return -1

    if s == n:
        return n+1

    for i in range(2, int(n**0.5)):
        if f(i, n) == s:
            return i

    for p in range(int(n**0.5) + 1, 0, -1):
        if (n - s) % p != 0:
            continue

        b = (n - s) // p + 1
        if f(b, n) == s:
            return b

    return -1


if __name__ == '__main__':
    print(main())
a,b = map(int,input().split())
import math
print(math.gcd(a, b))

### FIXED CODE ###

a,b = map(int,input().split())
import fractions
print(a * b //fractions.gcd(a, b))
print(max(0,x-t))

### FIXED CODE ###

x,t = map(int,input().split())
print(max(0,x-t))
import math
a, b, c, d = map(int, input().split())
ans = b - a + 1

def lcm(x, y):
  return (x * y) // math.gcd(x, y)

a -= 1
ans = ans - b//c - b//d + b//(lcm(c,d))
ans = ans + a//c + a//d - a//(lcm(c,d))
print(ans)

### FIXED CODE ###

from fractions import gcd
a, b, c, d = map(int, input().split())
ans = b - a + 1

def lcm(x, y):
  return (x * y) // gcd(x, y)

a -= 1
ans = ans - (b//c) - (b//d) + (b//(lcm(c,d)))
ans = ans + (a//c) + (a//d) - (a//(lcm(c,d)))
print(ans)
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, Q = mi()
S = li()
Alist = []
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = mi()
for i in range(N - 1):
    if S[i] == 'A' and S[i + 1] == 'C':
        Alist.append(i)
AClist = [0]*(N+1)
for i in range(N - 1):
    if i in Alist:
        AClist[i + 2] = AClist[i+1] + 1
    else:
        AClist[i+2] = AClist[i+1]

# print(AClist)

for i in range(Q):
    if AClist[l[i] - 1] != AClist[l[i]]:
        print(AClist[r[i]] - AClist[l[i]])
    else:
        print(AClist[r[i]] - AClist[l[i]-1])


### FIXED CODE ###

import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


b = input().rstrip()

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
elif b == 'G':
    print('C')
h = int(input())
w = int(input())
n = int(input())

print(max(h, x)%n)

### FIXED CODE ###

import math

h = int(input())
w = int(input())
n = int(input())

print(math.ceil(n / max(h, w)))
def f(y,x,c0):
  global A
  c=A[y][x]
  if c=="X" or c!=c0:
    return 0
  else:
    A[y][x]="X"
    for i,j in [[0,-1],[0,1],[-1,0],[1,0]]:
      f(y+i,x+j,c0)
    return 1

while 1:
  H,W=map(int,raw_input().split())
  if H==W==0: break
  A=[["X" for _ in range(W+2)] for _ in range(H+2)]
  for i in range(H):
    s=raw_input()
    for j in range(W): A[i+1][j+1]=s[j]
  c=0
  for i in range(1,H+1):
    for j in range(1,W+1):
      c+=f(i,j,A[i][j])
  print c

### FIXED CODE ###

def f(y,x,a):
  M.append([y,x])
  while M:
    y,x=M.pop()
    if A[y][x]==a:
      A[y][x]=' '
      for i,j in [[0,-1],[-1,0],[0,1],[1,0]]: M.append([y+i,x+j])
  return 1

M=[]
while 1:
  H,W=map(int,raw_input().split())
  if H==W==0: break
  A=[list(' '*(W+2)) for _ in range(H+2)]
  for i in range(H): A[i+1][1:W+1]=list(raw_input())
  c=0
  for i in range(1,H+1):
    for j in range(1,W+1):
      a=A[i][j]
      if a!=' ': c+=f(i,j,a)
  print c
a,b=map(int,input().split())
if a>b:
    m+=a
    a=a-1
m+=max(a,b)
print(m)

### FIXED CODE ###

a,b=map(int,input().split())
m=0
if a>b:
    m+=a
    a=a-1
else:
    m+=b
    b=b-1
m+=max(a,b)
print(m)
n=input()
if (n==1):
  print("Hello world")
else:
  a=input()
  b=input()
  print(a+b)

### FIXED CODE ###

n=input()
if int(n) == 1:
  print("Hello World")
else:
  a=input()
  b=input()
  print(int(a)+int(b))
import collections
n, k = map(int, input().split())
a = map(int, input().split())
c = collections.Counter(a)

if len(c) <= k:
  print(0)
else:
  c = c.most_common()
  print(sum(c[:k-1][0]))

### FIXED CODE ###

str = list(input())
c = 0
for s in str:
 c += int(s)
print(c)
d = {"A":"T", "T":"A", "G":"C", "C","G"}
print(d[input()])

### FIXED CODE ###

d = {"A":"T", "T":"A", "G":"C", "C":"G"}
print(d[input()])
S = [i for i in input()]
t = [i for i in input()]

a = 0
for i,j in zip(s,t):
  if i == j:
    a += 1
    
print(a)

### FIXED CODE ###

s = [i for i in input()]
t = [i for i in input()]

a = 0
for i,j in zip(s,t):
  if i == j:
    a += 1
    
print(a)
from math import pi
radius = int(input())
circumfernece = 2*pi*radius
print(circumference)

### FIXED CODE ###

from math import pi

r = int(input())
print(pi*2*r)
import math

A, B, C, D = map(int, input().split())

A -= 1

Z = (C * D // math.gcd(C, D))

A_C = A // C
A_D = A // D
A_Z = A // Z

A_num = A - (A_C + A_D - A_Z)

B_C = B // C
B_D = B // D
B_Z = B // Z


B_num = B - (B_C + B_D - B_Z)


print(B_num - A_num)



### FIXED CODE ###

import fractions

A, B, C, D = map(int, input().split())

A -= 1

Z = ((C * D) // fractions.gcd(C, D))

A_C = A // C
A_D = A // D
A_Z = A // Z

A_num = A - (A_C + A_D - A_Z)

B_C = B // C
B_D = B // D
B_Z = B // Z


B_num = B - (B_C + B_D - B_Z)


print(B_num - A_num)
n, m = [int(x) for x in input().split(' ')]

edges = set([tuple(input().split(' ')) for _ in range(n)])
edges.update([(x[1], x[0]) for x in list(edges)])


def dfs(node, history):
    ans = 0
    if len(history) == n - 1:
        return 1

    nextnodes = [
        x[1] for x in edges if x[1] not in history and x[0] == node and x[1] != node
    ]
    history.add(node)
    for next in nextnodes:
        ans += dfs(next, history)
    history.remove(node)
    return ans


print(dfs('1', set()))


### FIXED CODE ###

n, m = [int(x) for x in input().split(' ')]
 
edges = set([tuple(input().split(' ')) for _ in range(m)])
edges.update([(x[1], x[0]) for x in list(edges)])
 
 
def dfs(node, history):
    ans = 0
    if len(history) == n - 1:
        return 1
 
    nextnodes = [
        x[1] for x in edges if x[1] not in history and x[0] == node and x[1] != node
    ]
    history.add(node)
    for next in nextnodes:
        ans += dfs(next, history)
    history.remove(node)
    return ans
 
 
print(dfs('1', set()))
n,x = list(map(int,input().split()))

l = [int(s) for s in input().split()]
d = 0
i = 1
d = [0] * (n+1)
count = 0
if n == 1 and x >= l[0]:
    print(1)
elif n == 1 and x < l[0] :
    print(0)
else:

    while True:
        
        
        d[i] = d[i-1] + l[i-1]
        count += 1
        
        if d[i] > x:
            break
        i += 1

    print(count)


### FIXED CODE ###

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

l = [int(s) for s in input().split()]
d = 0
i = 1
d = [0] * (n+1)
count = 0
if n == 1 and x >= l[0]:
    print(1)
elif n == 1 and x < l[0] :
    print(0)
else:

    while True:
        
        
        d[i] = d[i-1] + l[i-1]
        count += 1
        
        if d[i] > x:
            break
        
        i += 1
        if i > n:
            print(count+1)
            exit()

    print(count)
import math
import itertools
#k,x = list(list(map(int, input().split())))
n = int(input())
a = list(list(map(int, input().split())))
b = list(list(map(int, input().split())))
ans = 0

for i in itertools.permutations(range(1,n+1,1),n):

    ans +=1
    if list(i) == a:
        ansa = ans
    elif list(i) == b:
        ansb = ans


print(abs(ansa-ansb))

### FIXED CODE ###

import math
import itertools
#k,x = list(list(map(int, input().split())))
n = int(input())
a = list(list(map(int, input().split())))
b = list(list(map(int, input().split())))
ans = 0

for i in itertools.permutations(range(1,n+1,1),n):

    ans +=1
    if list(i) == a:
        ansa = ans
    if list(i) == b:
        ansb = ans


print(abs(ansa-ansb))
s = input()
t = input()
u = t.rstip(t[len(t) - 1])
out = ('No', 'Yes')[s == u]
print(out)

### FIXED CODE ###

s = input()
t = input()
u = t[:-1]
out = ('No', 'Yes')[s == u]
print(out)
N, M = map(int, input().split())
numbers = set(map(int, input().split()))
costs = [2,5,5,4,5,6,3,7,6] # <- 1,2,3,4,5,6,7,8,9
costmap = {}
for num in numbers:
  cost = costs[num-1]
  if cost in costmap and num < costmap[cost]:
    continue
  costmap[cost] = num

def recursive(remain=N):
  maxval = costmap[remain] if remain in costmap else 0
  for cost, num in costmap.items():
    if remain > cost:
      val = recursive(remain-cost)
      if val is None:
        continue
      val = val * 10 + num
      if val > maxval:
        maxval = val
  if maxval == 0:
    return None
  return maxval

print(recursive(N))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
numbers = list(map(int, input().split()))
costs = [2,5,5,4,5,6,3,7,6] # <- 1,2,3,4,5,6,7,8,9
costmap = {}
for num in numbers:
  cost = costs[num-1]
  if cost in costmap and num < costmap[cost]:
    continue
  costmap[cost] = num

from functools import lru_cache
@lru_cache(None)
def recursive(remain=N):
  maxval = costmap[remain] if remain in costmap else 0
  for cost, num in costmap.items():
    if remain > cost:
      val = recursive(remain-cost)
      if val == 0:
        continue
      val = val * 10 + num
      if val > maxval:
        maxval = val
  return maxval
 
print(recursive(N))
K = int(input())

n = 1
x = 7


if K % 2 == 0:
  peint( -1 )
  exit( 0 )
#

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x % K) * 3 + 7
  n += 1
#


### FIXED CODE ###

K = int(input())

n = 1
x = 7


if (K % 2 == 0)or(K % 5 == 0):
  print( -1 )
  exit( 0 )
#

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x * 10 + 7) % K
  n += 1
#
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P) :
 P = sorted(P)
 phU = []
 phU.append(P[0])
 phU.append(P[1])
 for p in P[2:] :
  phU.append(p)
  if isCLKWISE(phU) : continue
  while(True)???:
   del phU[-2]
   try???:
    if isCLKWISE(phU) : break
   except IndexError : break
 phL = []
 phL.append(P[-1])
 phL.append(P[-2])
 for p in P[-3::-1] :
  phL.append(p)
  if isCLKWISE(phL) : continue
  while(True) :
   del phL[-2]
   try:
    if isCLKWISE(phL) : break
   except IndexError : break
 del phL[0]
 del phL[-1]
 ph = phU + phL
 return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])

### FIXED CODE ###

def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
P = [[int(x) for x in input().split()] for _ in range(int(input()))]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])