Harryxun/stf_run huggingface dataset:
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
from numpy.linalg import solve
def nasu(a, b, c):
  A = a[0] ** 2 - b[0] ** 2 + a[1] ** 2 - b[1] ** 2
  B = b[0] ** 2 - c[0] ** 2 + b[1] ** 2 - c[1] ** 2
  x = [2 * (b[0] - a[0]), 2 * (c[0] - b[0])]
  y = [2 * (b[1] - a[1]), 2 * (c[1] - b[1])]

  if x[0] * y[0] == x[1] * y[1]:
    return 0
  t = 0.000001
  left = [[x[0] + t, y[0]],
          [x[1], y[1] + t]]
  right = [-A, -B]
  Cx, Cy = solve(left, right)
  r = ((a[0] - Cx) ** 2 + (a[1] - Cy) ** 2) ** (1 / 2)
  for i in range(N):
    if honya(xy[i], Cx, Cy) > r:
      return 0
  return r

def honya(a, Cx, Cy):
  return ((a[0] - Cx) ** 2 + (a[1] - Cy) ** 2) ** (1 / 2)
ans = 10 ** 10
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      ans = min(ans, nasu(xy[i], xy[j], xy[k]))

print(ans)

### FIXED CODE ###

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
def nasu(a, b, c):
  A = a[0] ** 2 - b[0] ** 2 + a[1] ** 2 - b[1] ** 2
  B = b[0] ** 2 - c[0] ** 2 + b[1] ** 2 - c[1] ** 2
  x = [2 * (b[0] - a[0]), 2 * (c[0] - b[0])]
  y = [2 * (b[1] - a[1]), 2 * (c[1] - b[1])]
  k = x[1] * y[0] - x[0] * y[1]
  if k == 0:
    return 10 ** 10
  Cx = -(y[0] * B - y[1] * A) / k
  Cy = (x[0] * B - x[1] * A) / k
  return honyamorake(Cx, Cy)

def honya(x, y, Cx, Cy):
  return ((x - Cx) ** 2 + (y - Cy) ** 2) ** (1 / 2)

def honyaraka(a, b):
  Cx = (a[0] + b[0]) / 2
  Cy = (a[1] + b[1]) / 2
  return honyamorake(Cx, Cy)

def honyamorake(Cx, Cy):
  r = honya(xy[0][0], xy[0][1], Cx, Cy)
  for i in range(1, N):
    r = max(r, honya(xy[i][0], xy[i][1], Cx, Cy))
  return r

ans = 10 ** 10
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      ans = min(ans, nasu(xy[i], xy[j], xy[k]))
for i in range(N - 1):
  for j in range(i + 1, N):
    ans = min(ans, honyaraka(xy[i], xy[j]))

print(ans)
n,k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]

l = [1]
now = 1
next = a[0]
count = 0
dupl = -1

for i in range(k):
  now = next
  next = a[now-1]
  
  if now in l:
    dupl = now
    break
  else:
    l.append(now)
    
count = l.index(dupl)
length = len(l)-count
print(l[(k-count)%length+count])


### FIXED CODE ###

n,k = (int(x) for x in input().split())
a = tuple([int(x) for x in input().split()])
 
c = [0] + [-1]*(n)
l = [1]
now = 1
dupl = -1

for i in range(k):
  now = a[now - 1]
  c[now - 1] += 1
   
  if c[now - 1] == 1:
    dupl = now
    break
  else:
    l.append(now)
    
if dupl == -1:
  print(now)
  exit()
       
notloop = l.index(dupl)
length = len(l)-notloop
print(l[(k-notloop)%length+notloop])
from decimal import *
N = input()

# print(Decimal(N) // Decimal(3))
print(N**3 // 27)

### FIXED CODE ###

N = int(input())

print((N/3)**3)
N=int(input())
S=[]
for _ in range(N):
    S.append(list(input()))
# print(S)

count = {
    'M': 0,
    'A': 0,
    'R': 0,
    'C': 0,
    'H': 0
}

for s in S:
    if s[0] in ['M','A','R','C','H']:
        count[s[0]] += 1

# print(count)

H=['M','A','R','C','H']
res = 0
for i in range(0,N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            cnt = count[H[i]] * count[H[j]] * count[H[k]]
            # print(i,j,k,cnt)
            res += cnt

print(res)

### FIXED CODE ###

N=int(input())
S=[]
for _ in range(N):
    S.append(list(input()))
# print(S)

count = {
    'M': 0,
    'A': 0,
    'R': 0,
    'C': 0,
    'H': 0
}

for s in S:
    if s[0] in ['M','A','R','C','H']:
        count[s[0]] += 1

# print(count)

H=['M','A','R','C','H']
res = 0
for i in range(0,5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            cnt = count[H[i]] * count[H[j]] * count[H[k]]
            # print(i,j,k,cnt)
            res += cnt

print(res)
N, K = map(int, input().split())
a = list(map(int, input().split()))

i = 0
count = 0
while i < N:
  for j in range(N-i):
    if sum(a[j:j+1+i]) >= K:
      count += 1
  i += 1
  
print(count)

### FIXED CODE ###

N, K = map(int, input().split())

if N < K:
  print(0)
else:
  print(10)
n,m=map(int,input().split())
py=[list(map(int,input().split())) for i in range(m)]
l=[[] for j in range(n)]
for p,y in py:
  l[p-1].append(y)
for j in range(n):
  l[j].sort()

for j in range(n):
  for t in len(l[j]):
    pre='0'*(6-len(str(l[j][t])))+str(l[j][t])
    y='0'*(6-len(str(t+1)))+str(t+1)
    print(pre+str)

### FIXED CODE ###

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

l=[[] for j in range(n)]
for i in range(m):
  p,y=map(int,input().split())
  l[p-1].append([y,i])
for j in range(n):
  l[j].sort(key=lambda x:x[0])
lis=[]
for j in range(n):
  for t in range(len(l[j])):
    pre='0'*(6-len(str(j+1)))+str(j+1)
    y='0'*(6-len(str(t+1)))+str(t+1)
    b=pre+y
    lis.append([b,l[j][t][1]])
lis.sort(key=lambda x:x[1])
for li in lis:
  print(li[0])
n,a,b = map(int,input().split())
box = ''
for i in range(n//(a+b)+1):
  box += ('b' * a)
  box += ('r' * b)
print(box)
print(len([i for i in box[0:n] if i == 'b']))

### FIXED CODE ###

n, a, b = map(int, input().split())
#aとbの合計値がnを割り切れるだけの個数 X aの個数分
ans = n // (a + b) * a
#aとbの合計値でnが余ってしまった時の個数
rem = n % (a + b)
#aだけ入れれた場合か、bも混ざっている場合か、どちらかをansに追加
ans += min(rem, a)
print(ans)
import math
n,w=map(int,input().split())
if h==1 or w==1:
    print(1)
else:
    ans=math.ceil(w/2)*math.ceil(n/2)+(w//2)*(n//2)
print(ans)

### FIXED CODE ###

import math
n,w=map(int,input().split())
if n==1 or w==1:
    print(1)
else:
    ans=math.ceil(w/2)*math.ceil(n/2)+(w//2)*(n//2)
    print(ans)
from collections import Counter

N = int(input())
A = [int(input()) for i in range(N)]

c = Counter(A)

mx = max(A)
B = list(set(A))
B.remove(mx)
bmx = max(B)
for i in range(N):
    if A[i] != mx:
        print(mx)
    elif c[mx] == 1:
        print(bmx)
    else:
        print(mx)

### FIXED CODE ###

from collections import Counter

N = int(input())
A = [int(input()) for i in range(N)]

c = Counter(A)

mx = max(A)
B = list(set(A))
B.remove(mx)
for i in range(N):
    if A[i] != mx:
        print(mx)
    elif c[mx] == 1:
        print(max(B))
    else:
        print(mx)
from sys import stdin
a = int(stdin.readline())
b = int(stdin.readline())
ans = 'GREATER'
if a < b:
 ans = 'LESS'
elilf a==b:
 ans = 'EQUAL'
print ans

### FIXED CODE ###

from sys import stdin
a = int(stdin.readline())
b = int(stdin.readline())
ans = 'GREATER'
if a < b:
 ans = 'LESS'
elif a==b:
 ans = 'EQUAL'
print ans
n = int(input())
s = list(map(str,input()))
k = input()

a = s[k-1]

for i in range(n):
    if s[i]==a:
        continue
    else:
        s[i] = "*"

print("".join(s))

### FIXED CODE ###

n = int(input())
s = list(map(str,input()))
k = int(input())

a = s[k-1]

for i in range(n):
    if s[i]==a:
        continue
    else:
        s[i] = "*"

print("".join(s))
# Fast IO (only use in integer input)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import heapq

T = int(input())
for _ in range(T):
    N = int(input())
    frontCamel = []
    backCamel = []
    indifferentCamel = []
    Happiness = 0
    for _ in range(N):
        k,l,r = map(int,input().split())
        if l > r:
            frontCamel.append((k,l-r))
            Happiness += r
        elif r > l:
            backCamel.append((N-k,r-l))
            Happiness += l
        else:
            indifferentCamel.append((k,0))
            Happiness += l
    frontQ = []
    backQ = []
    frontCamel.sort(key = lambda x:x[0])
    backCamel.sort(key = lambda x:x[0])
    for Camel in frontCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(frontQ):
            heapq.heappush(frontQ,Camel[1])
        else:
            if frontQ[0] < Camel[1]:
                heapq.heapreplace(frontQ,Camel[1])
    for Camel in backCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(backQ):
            heapq.heappush(backQ,Camel[1])
        else:
            if frontQ[0] < Camel[1]:
                heapq.heapreplace(backQ,Camel[1])
    Happiness += sum(frontQ)
    Happiness += sum(backQ)
    print(Happiness)


### FIXED CODE ###

# Fast IO (only use in integer input)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import heapq

T = int(input())
for _ in range(T):
    N = int(input())
    frontCamel = []
    backCamel = []
    indifferentCamel = []
    Happiness = 0
    for _ in range(N):
        k,l,r = map(int,input().split())
        if l > r:
            frontCamel.append((k,l-r))
            Happiness += r
        elif r > l:
            backCamel.append((N-k,r-l))
            Happiness += l
        else:
            indifferentCamel.append((k,0))
            Happiness += l
    frontQ = []
    backQ = []
    frontCamel.sort(key = lambda x:x[0])
    backCamel.sort(key = lambda x:x[0])
    for Camel in frontCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(frontQ):
            heapq.heappush(frontQ,Camel[1])
        else:
            if frontQ[0] < Camel[1]:
                heapq.heapreplace(frontQ,Camel[1])
    for Camel in backCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(backQ):
            heapq.heappush(backQ,Camel[1])
        else:
            if backQ[0] < Camel[1]:
                heapq.heapreplace(backQ,Camel[1])
    Happiness += sum(frontQ)
    Happiness += sum(backQ)
    print(Happiness)
import itertools

n = int(input())
a = [int(input()) for i in range(n)]
max_list = list(itertools.accumulate(a, func=max))
max_list_r = list(itertools.accumulate(reversed(a), func=max))

for i in range(n):
    print(max(max_list[i - 1], max_list_r[i - 1]))


### FIXED CODE ###

import itertools

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

max_list = [0] + list(itertools.accumulate(a, func=max))
max_list_r = ([0] +list(itertools.accumulate(reversed(a), func=max)))[::-1]
for i in range(n):
    print(max(max_list[i], max_list_r[i + 1]))
n =int(input())
if n%2=0:
  answer = n//2
  print(answer)
else:
  answer = n//2+1
  print(answer)


### FIXED CODE ###

n =int(input())
if n%2==0:
  answer = n//2
  print(answer)
else:
  answer = n//2+1
  print(answer)
import numpy as np

H, W, D = map(int, input().split())
pos = [None]*(H*W)

for i in range(H):
    row = list(map(int, input().split()))
    for j in row:
        pos[row[j]] = (i, j)

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    if L == R:
        print(0)
    else:
        to_be_checked = [i for i in range(L, R+1, D)]
        moves = len(to_be_checked)
        pos_list = [tpl for tpl in to_be_checked]

        MP = sum([np.absolute(pos_list[i][0] - pos_list[i+1][0]) for i in range(moves-1)]) + sum([np.absolute(pos_list[i][1] - pos_list[i+1][1]) for i in range(moves-1)])

        print(MP)

### FIXED CODE ###

H, W, D = map(int, input().split())
pos = [None]*(H*W)

for i in range(H):
    row = list(map(int, input().split()))
    for j in range(W):
        pos[row[j]-1] = (i, j)

costs = [0]*(H*W)
for i in range(1, D+1):
    current = i + D
    while current <= H*W:
        costs[current - 1] = costs[current - 1 - D] + abs(pos[current - 1][0] - pos[current - 1 - D][0]) + abs(pos[current - 1][1] - pos[current - 1 - D][1])
        current += D

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    MP = costs[R-1] - costs[L-1]
    print(MP)
a,b,c=map(int,raw_input().split())

sum=0

for i in len(a,b):   
  if c % a ==0:
     sum=sum+1
print 'sum'

### FIXED CODE ###

a,b,c=map(int,raw_input().split())
sum=0

for i in range(a,b+1):   
   if c % i ==0:
     sum=sum+1
print sum
def solve(n):
	A=[0 for i in range(n+1)]
	A[2]=1
	for i in range(2,n+1):
		cnt=0
		for j in range(1,i+1,2):
			if i%j==0:
				cnt+=1
		if cnt==2:#1??¨????????°??????
			A[i]=1
	return sum(A) 

while True:
	try:
		n = int(input())
		print(solve(n))
	except EOFError:
		break

### FIXED CODE ###

def sieve(n):
	p=[True for i in range(n+1)]
	p[0]=p[1]=False
	for i in range(2,n+1):
		if p[i]==True:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p

def solve(n):
		if n<2:return 0
		c=1
		for i in range(3,n+1,2):
			if p[i]==1:
				c+=1
		return c

p=sieve(1000000)
while True:
	try:
		n = int(input())
		print(solve(n))
	except EOFError:
		break
n,q=map(int,input().split())
ki=[[] for i in range(n+100)]
#ki[0]="null"

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

scores=[0 for i in range(n+100)]
#scores[0]="null"
for i in range(q):
    p,x=map(int,input().split())
    scores[p]+=x


ans=[0 for i in range(n+100)]
#ans[0]="null"
point=0

ed=[]

def tansa(n,point):
    global ed
    point+=scores[n]
    ed.append(n)
    for p in ki[n]:
        if not p in ed:
            tansa(p,point)
    else:
        ans[n]=point
        
tansa(1,0)

ans=ans[1:n+1]
ans=[str(i) for i in ans]
print(" ".join(ans))

### FIXED CODE ###

n,q=map(int,input().split())
L=[[] for i in range(n+1)]
S=[0 for i in range(n+1)]
V=[0 for i in range(n+1)]

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

for _ in range(q):
    p,x=map(int,input().split())
    S[p]+=x


que=[1]
head=0
V[1]=1
while len(que)>head:
    now=que[head]
    head+=1
    for nex in L[now]:
        if V[nex]==0:
            V[nex]=1
            que.append(nex)
            S[nex]+=S[now]

print(" ".join([str(i) for i in S[1:]]))
n = int(input())
if n % 9 == 0:
print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
cur = 0

for x in n:
    cur += int(x)

if cur % 9 == 0:
    print("Yes")
else:
    print("No")
A, V = map(int, input().split())
B, W = map(int, input().split())
T = input()
time = 0
timeyosou = abs(B-A)/(V-W)

if (V <= W):
    if (A < B):
        time = (10**9-A)/V
    else:
        time = (10**9+A)/V
else:
   if (A < B):
       if ((10**9 - B)/W > timeyosou):
           time = timeyosou
        else:
            time = (10**9 - A)/V
    if (A > B):
        if ((10**9 + B)/W > timeyosou):
           time = timeyosou
        else:
            time = (10**9 + A)/V



### FIXED CODE ###

A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if (V <= W):
    print("NO")
elif(T < abs(A - B)/(V-W)):
    print("NO")
else:
    print("YES")
import sys

for line in sys.stdin.readlines():
 a, b, c = map(int, line.strip().sprit())
 if (a<b) and (b<c):
  print "Yes"
 else:
  print "No"

### FIXED CODE ###

a,b,c = raw_input().split()
if a<b<c:
    print 'Yes'
else:
    print 'No'
R = int(input())

if R < 1200:
    print('ABC')
elif R < 2800:
    print('ARC')
else
    print('AGC')



### FIXED CODE ###

R = int(input())

if R < 1200:
    print('ABC')
elif R < 2800:
    print('ARC')
else:
    print('AGC')
N,M=map(int,input().split())
H=list(map(int,input().split()))
flg=[0]*N
T=[[] for _ in range(N)]

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

for n in range(N):
  if not T[n]:
    flg[n] =1
  else:
    MAX=max([H[t-1] for t in T[n]])
  if H[n]>MAX:
    flg[n]=1

print(sum(flg))
    

### FIXED CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
flg=[1]*N


for m in range(M):
  a,b =map(int,input().split())
  if H[a-1]<H[b-1]:
    flg[a-1]=0
  elif H[a-1]>H[b-1]:
    flg[b-1]=0
  else:
    flg[a-1]=flg[b-1]=0
  
print(flg.count(1))
n, m = map(int, input().split())
values = list(map(int, input().split()))

count_table = [None, 2,5,5,4,5,6,3,7,6]

dp = [None for _ in range(n + 1)]
dp[0] = {0: 0}

for i in range(m):
    my_value = values[i]
    for j in range(n):
        dic = dp[j]
        if dic is not None and len(dic) > 0:
            my_count = 1
            while j + count_table[my_value] * my_count <= n:
                already = dp[j + count_table[my_value] * my_count] or {}
                new_dic = {my_value: my_count, **dic}

                s = ''
                for value, cnt in reversed(sorted(already.items())):
                    s += str(value) * cnt
                s_already = s
                s = ''
                for value, cnt in reversed(sorted(new_dic.items())):
                    s += str(value) * cnt

                if s_already == '':
                    dp[j + count_table[my_value] * my_count] = new_dic
                elif s == '':
                    pass
                elif int(s_already) < int(s):
                    dp[j + count_table[my_value] * my_count] = new_dic

                my_count += 1

pin_dic = dp[n]

s = ''
for value, cnt in reversed(sorted(pin_dic.items())):
    s += str(value) * cnt
print(s)


### FIXED CODE ###

n, m = map(int, input().split())
aa = reversed(sorted(map(int, input().split())))

t = ['_', 2, 5, 5, 4, 5, 6, 3, 7, 6]

# n 本使ってできる最大の桁数
dp = [-1 for _ in range(n + 1)]
dp[0] = 0

for a in aa:
    for i in range(len(dp)):
        if dp[i] >= 0 and i + t[a] < len(dp):
            dp[i + t[a]] = max(dp[i + t[a]], dp[i] * 10 + a)

print(dp[n])
W,E,R = map(int,input().split())
if W + E + R >= 22:
    ans("bust")
else :
    ans("win")
print(ans)


### FIXED CODE ###

W,E,R = map(int,input().split())
if W + E + R >= 22:
    ans="bust"
else :
    ans="win"
print(ans)
n, m = map(int,input().split())
    
tbin_o = []

tbin_1 = []
tbin_n = []
for i in range(m):
    xxx = list(map(int,input().split()))
    if xxx[0] == 1:
        tbin_1.append(xxx[1]):
    elif xxx[1] == n :
        tbin_n.append(xxx[0])
    else:
        None

aaa = 0
for i in tbin_1:
    if i in tbin_n:
        aaa = 1
        break

if aaa == 1 :
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

### FIXED CODE ###

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

boolins =[]
for i in range(n):
    boolins.append(0)
    
for i in range(m):
    xxx = list(map(int,input().split()))
    if xxx[0] == 1:
        boolins[xxx[1]] = boolins[xxx[1]] + 1
    elif xxx[1] == n :
        boolins[xxx[0]]=boolins[xxx[0]]+ 1
    else:
        None


if 2 in boolins:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
import System
if sys.version_info[0]>=3: raw_input=InputStream

def insertionSort(a,g):
    global cnt
    for i in range(g,len(a)):
        v=a[i]
        j=i-g
        while j>=0 and a[j]>v:
            a[j+g]=a[j]
            j=j-g
            cnt+=1
            a[j+g]=v

def shellSort(a):
    global cnt
    cnt=0
    g=[]
    h=1
    while h <=len(a):
        g.append(h)
        h=3*h+1
    g.reverse()
    m=len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(a,g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)


### FIXED CODE ###

#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
 
def insertionSort(a,g):
    global cnt
    for i in range(g,len(a)):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt+=1
            a[j+g] = v
 
def shellSort(a):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= len(a):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(a,g[i])
 
a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)
a, b, h = map(int, input().split())
print((a + b) * h / 2)

### FIXED CODE ###

a, b, h = [int(input()) for _ in range(3)]
print(int((a + b) * h / 2))
wor = input().upper()

import re
while True :
    tes = input()
    if tes == 'END_OF_TEXT': break
    tes = tes.upper()
    m = re.findall(wor, tes)
    cou += len(m)

print(cou)

### FIXED CODE ###

wor = input().upper()
cou = 0

import re
while True :
    tes = input().split()
    if tes[0] == 'END_OF_TEXT': break
    tes = [temp.upper() for temp in tes]
    cou += tes.count(wor)

print(cou)
a, b = map(int, input().split())
print(max([a+b, a-b, a*b])

### FIXED CODE ###

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

print(max(A+B, A-B, A*B))
from sys import stdin

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

print(f'{c} {a} {b}')

### FIXED CODE ###

from sys import stdin

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

print('{} {} {}'.format(c, a, b))
H A = input().split(' ')
print(H // A + 1)

### FIXED CODE ###

H, A = [int(i) for i in input().split(' ')]
print(H // A + min(H % A, 1))
N = int(input())
S = [1 if i == "." else 0 for i in input()]
# 黒は#,白が.
# 黒は0,白は1
# 黒の右に白は許されない
# ある場所を境に左は全部白、右は全部黒にするから、それの逆の個数を数える
# ある境より右にある白の数
rw = sum(S)
# ある境より左にある黒の数
lb = 0
min_temp = rw+lb
for idx,s in enumerate(S):
    # 黒の場合
    if s==0:
        # rw pass
        lb *= 1
    # 白の場合
    elif s==1:
        rw += 1
        lb -= 1
    # 小さい方を残す
    min_temp = min([min_temp,rw+lb])
    if min_temp == 0:break
print(min_temp)

### FIXED CODE ###

X= [int(i) for i in input().split()]
if (X[0] > X[2] and X[1] < X[2]) or (X[0] < X[2] and X[1] > X[2]) :
    print("Yes")
else:
    print("No")
import collections
import sys

N = int(input())
S = [input() for _ in range(N)]
S.sort()
c = collections.Counter(S)
values, counts = zip(c.most_common())
if len(values) == 1:
    print(values[0])
else:
    for i in range(N):
        if counts[i] == counts[0]:
            print(values[i])
        else:
            sys.exit()

### FIXED CODE ###

import collections

n = int(input())

res = []

for _ in range(n):
  res.append(input())

c = collections.Counter(res)
aa = c.most_common()

ss = aa[0][1]
res2 = []

aa.sort()
for i in aa:
  if i[1] == ss:
    res2.append(i[0])

for i in res2:
  print(i)
num  = [int(n)] for n in input().rstrip().split()]

if num.count(5) == 2 and num.count(7) == 1:
    print("YES")

else:
    print("NO")


### FIXED CODE ###

num  = [int(n) for n in input().rstrip().split()]

if num.count(5) == 2 and num.count(7) == 1:
    print("YES")

else:
    print("NO")
N = map( int , raw_input().split() )

a = N[0]
b = N[1]
c = N[2]
 
if a < b < c:
  print "%d %d %d" %(a,b,c)
elif a < c < b:
  print "%d %d %d" %(a,c,b)
elif b < a < c:
  print "%d %d %d" %(b,a,c)
elif b < c < a:
  print "%d %d %d" %(b,c,a)
elif c < a < b:
  print "%d %d %d" %(c,a,b)
else c < b < a:
  print "%d %d %d" %(c,b,a)

### FIXED CODE ###

N = map( int , raw_input().split() )
 
if N[0] < N[1] < N[2] or N[0] == N[1] == N[2] or N[0] < N[1] == N[2] or N[0] == N[1] < N[2]:
  print "%d %d %d" %(N[0],N[1],N[2])
elif N[0] < N[2] < N[1]:
  print "%d %d %d" %(N[0],N[1],N[2])
elif N[1] < N[0] < N[2]:
  print "%d %d %d" %(N[1],N[0],N[2])
elif N[1] < N[2] < N[0] or N[1] < N[2] == N[0] or N[1] == N[2] < N[0]: 
  print "%d %d %d" %(N[1],N[2],N[0])
elif N[2] < N[0] < N[1] or N[2] < N[0] == N[1] or N[2] == N[0] < N[1]:
  print "%d %d %d" %(N[2],N[0],N[1])
elif N[2] < N[1] < N[0]:
  print "%d %d %d" %(N[2],N[1],N[0])
#!/usr/bin/env python3
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
z = p[-x:].extend(q[-y:]).extend(r)
z.sort()
print(sum(z[-x-y]))

### FIXED CODE ###

#!/usr/bin/env python3
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
z = p[-x:]
z.extend(q[-y:])
z.extend(r)
z.sort()
#print(z)
print(sum(z[-x-y:]))
n, m = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(m)]
def make_id(num):
  s = len(str(num))
  add_zero = '0'*(6-s)
  return add_zero + str(num)

P = [[] for _ in range(m)]
ans = []
sort_P = []
for i in range(len(PY)):
  P[PY[i][0]-1].append(PY[i][1])
for i in range(len(P)):
  sort_P.append(sorted(P[i]))
for i in range(len(PY)):
  p,y=PY[i][0],PY[i][1]
  ord = sort_P[p-1].index(y)+1
  print(make_id(p)+make_id(ord))


### FIXED CODE ###

N, M = map(int, input().split())
D = [[] for i in range(N)]
 
for i in range(M):
  p, y = map(int, input().split())
  D[p-1].append((y, i)) 

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')