peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n=int(input())
cnt=0
ans=0
for i in range(n):
    d,e=map(int,input().split())
    if d!=e:
        if cnt==3:
            ans=0
            break
        cnt=1
    else:
        cnt+=1
        if cnt==3:
            ans=1
            break
if cnt>=3:
    ans=1
if ans==1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted

S = input()

dic = [0,0]

for i in S:

    dic[int(i)] += 1

print (min(dic)*2)
# Judge status: Wrong Answer
l,r = map(int,input().split())
x = l%2019
y = min(r,l+2018)%2019
if x<y:
    ans = x*(x+1)
else:
    ans = 0
print(ans)
# Judge status: Accepted
r,g,b=input().split()
a=int(r+g+b)
print("YES" if a%4==0 else "NO")
# Judge status: Wrong Answer
from collections import defaultdict
n = int(input())
s = input()
lmap = defaultdict(lambda:0)
rmap = set()
lmax = 0
for i in range(n):
  lmap[s[i]]+=1
i = n-1
while i>=0:
  lmap[s[i]]-=1
  rmap.add(s[i])
  if lmap[s[i]]==0:
    del lmap[s[i]]
  x = len(lmap)
  if x==len(rmap):
    #print(i,end=',')
    lmax = max(lmax,x)
  i-=1
print(lmax)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
prev = '-'
for c in list(input()):
    if c == prev:
        print('no')
        quit()
    else:
        prev = c
else:
    print('yes')
# Judge status: Accepted
x, y, z = map(int, input().split())
print((x-z) // (y+z))
# Judge status: Accepted
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    K = int(input())

    i = 0

    for i in range(K):
        if S[i]=="1":
            continue
        else:
            print(S[i])
            exit()
    print(1)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]

if n%2==0:
    print(int((x[(n//2)][-1]-x[(n//2)-1][0])//0.5)-1)
else:
    tmp = x[n//2]
    print(len(range(tmp[0], tmp[-1]+1)))
# Judge status: Accepted
s=input()
k=int(input())
if s.count('1') == len(s):
  print(1)
else:
  count = 0
  for i in s:
    if i != '1':
      print(i)
      break
    else:
      count+=1
      if count == k:
        print(1)
        break
# Judge status: Accepted
def c_replacing_integer():
    N, K = [int(i) for i in input().split()]
    return min(N % K, K - (N % K))

print(c_replacing_integer())
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import fractions
from functools import reduce
n,x = map(int,input().split())
x_list = list(map(int,input().split()))
if n == 1:
    print (abs(x_list[0]-x))
    exit (0)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

y_list = []
for i in x_list:
    y_list.append(abs(i-x))

print (gcd_list(y_list))
# Judge status: Accepted
W,H,x,y=map(int,input().split())
if x==W/2 and y==H/2:
	c=1
else:
	c=0
print(W*H/2,c)
# Judge status: Accepted
l, r = map(int, input().split())
m = 2019
if r - l >= 673:
    print(0)
else:
    ans = 2018
    l = l%m
    r = r%m
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%m)
    print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
C = a + b
A = b + c
B = c + a

if a == A or b == B or C == c: print("Yes")
else: print("No")
# Judge status: Wrong Answer
n,m,k = map(int,input().split())

def hantei(n,m,k):
    for i in range(1,n+1):
        for j in range(1,m+1):
            if i*m + j*(n-2*i)==k:
                return True
    return False

print("Yes" if hantei(n,m,k) else "No")
# Judge status: Accepted
import bisect
n = int(input())
lis = list(map(int, input().split()))
lis = sorted(lis)

a = bisect.bisect(lis, 0)
su = 0
mi = 10**10

for b in lis:
    su += abs(b)
    mi = min(mi, abs(b))

if a % 2 == 0:
    print(su)
else:
    print(su - 2 * mi)
# Judge status: Wrong Answer
# agc002_b.py
N, M = map(int,input().split())
flg = [False]*N
flg[0] = True
cnt = [1]*N
for i in range(M):
    x, y = map(int,input().split())
    if not flg[x-1]:
        continue
    if cnt[x-1]>1:
        flg[y-1] = True
    elif cnt[x-1]==1:
        flg[y-1] = True
        flg[x-1] = False
    else:
        continue
    cnt[x-1]-=1
    cnt[y-1]+=1

print(flg.count(True))
# Judge status: Wrong Answer
import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for _ in range(N)])

INF = 10**7 + 2
dp = np.full(2 * 10**4 + 2, INF, np.int32)
dp[0] = 0

for a, b in AB:
    for _ in range(H // a):
        prev = dp.copy()
        np.minimum(dp[a:], prev[:-a] + b, out=dp[a:])

print(np.min(dp[H:]))
# Judge status: Wrong Answer
import math
a,b,x=map(int,input().split())
v = a * b
x = x / a
if x < v/a:
    c = x * 2 / b
    d = math.sqrt(b * b + c * c)
    print(math.degrees(math.asin(b/d)))
else:
    rest = v - x
    c = rest * 2 / a
    d = math.sqrt(a * a + c * c)
    print(math.degrees(math.acos(a/d)))
# Judge status: Accepted
x=list(map(int,input().split()))
x.sort()
if x[0]+x[1]==x[2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x, y, a, b, c = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
A = A[:x]
B.sort(reverse=True)
B = B[:y]

AB = A + B
AB.sort(reverse=True)
total = sum(AB)
C.sort()

while AB and C:
    point = AB.pop()
    candidate = C.pop()
    if candidate > point:
        total += candidate - point
    else:
        break

print(total)
# Judge status: Wrong Answer
n = int(input())
count = 0
max = 0
for i in range(1, n+1):
    while(i%2 ==0):
        i = i/2
        count +=1
    if(max < count):
        max = count
        count = 0
print(2**max)
# Judge status: Wrong Answer
a = input().split()
if a[0] == a[1] and a[0] == a[2]:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
o = input()
e = list(input())+[""]

for i, j in zip(o, e):
  print(i+j, end="")
# Judge status: Accepted
N,A,B = map(int,input().split())
if((B-A+1)%2==1):
    print((B-A)//2)
else:
    print(min(A-1,N-B)+1+(B-A-1)//2)
# Judge status: Accepted
A, B, C = sorted([int(i) for i in input().split()])
K = int(input())
print(A + B + (C * (2**K)))
# Judge status: Accepted
a, b, c, k = map(int, input().split())
if k % 2 == 0:
    print(a-b)
else:
    print(b-a)
# Judge status: Accepted
import sys
import math

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

cA = 360*H/12 + 30 * M/60
cB = 360*M/60
cC = abs(cA - cB)
if cC > 180:
    cC = 360 - cC

coscC = math.cos(math.radians(cC))
C = A**2 + B**2 - 2 * A*B*coscC

print(C**(1/2))
# Judge status: Wrong Answer
w = list(input())
w = sorted(w)
flag = True
print(w)
for i in range(0,len(w)-1,2):
    print(i)
    if w[i]!=w[i+1]:
        flag = False
        break
if flag and len(w)%2==0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a, b = [int(i) for i in input().split()]

list = [str(a)*b, str(b)*a]
list = sorted(list)

print(list[0])
# Judge status: Wrong Answer
n,x,t = (int(x) for x  in input().split())

print( t * ( n//x + 1 ) )
# Judge status: Accepted
X = int(input())

M = 21148

ns = [i**5 for i in range(M)]
n5s = {i**5:i for i in range(M)}

result = None
for i in range(M):
    b = ns[i]
    if b + X in n5s:
        result = n5s[b + X], i
    if X - b in n5s:
        result = i, -n5s[X - b]

print(*result)
# Judge status: Accepted
x, y = map(int, input().split())
a = [2]
b = [4, 6, 9, 11]
c = [1, 3, 5, 7, 8, 10, 12]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
A,B,C = map(int, input().split())

ret = 0

if not (A%2 == B%2 and B%2 == C%2):
    # どれか一つにイレギュラーがある
    ret += 1
    if A%2 == B%2:
        A += 1
        B += 1
    else:
        B += 1
        C += 1

# print(A,B,C)
max_elem = max(A,B,C)
ret += (max_elem-A)//2 + (max_elem-B)//2 + (max_elem-C)//2

print(ret)
# Judge status: Wrong Answer
import bisect
N = int(input())
nums = []

for i in range(N):
    num = int(input())
    if i == 0:
        nums.append(num)
    else:
        if nums[-1] < num:
            nums[-1] = num
        else:
            insert_index = bisect.bisect_left(nums, num)
            if insert_index == 0:
                nums.insert(0, num)
            else:
                nums[insert_index] = num
#     print(nums)
# print(nums)
print(len(nums))
# Judge status: Accepted
a,b,c=map(int,input().split())
A=[a,b,c]
B=len(set(A))
if B==2:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a = int( input() )
s = input()
if a < 3200:
  print( s )
else:
  print( "red" )
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
#  A,B = map(int, input().split())
  S = input().rstrip()
  SS = sorted(S)

  result = 'No'
  if SS[0] == SS[1]:
    if SS[2] == SS[3]:
      if SS[0] != SS[2]:
        result = 'Yes'
  print(result)
  
if __name__ == "__main__":
  main()
# Judge status: Wrong Answer
K, X = map(int, input().split())
for x in range(X-K+1,X+K-1):
  print(x, end=" ")
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
assets = 1000
for i in range(n - 1):
        if a[i] < a[i + 1]:
            assets = assets//a[i] * a[i + 1] + assets%a[i]
print(assets)
# Judge status: Accepted
import sys
input = sys.stdin.readline

H,N = map(int, input().split())
A = list(map(int,input().split()))

print("Yes" if sum(A)>=H else "No")
# Judge status: Accepted
a,b,c = map(int, input().split())

tmp = a-b

if tmp <= c:
    print(c-tmp)
else:
    print(0)
# Judge status: Wrong Answer
import sys

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

if k < 3:
    print(sum(p))
    sys.exit()

p.sort()

print(p[0] + p[1] + p[2])
# Judge status: Accepted
import heapq
N = int(input())
A = list(map(int, input().split()))+[0]*4
A = list(map(lambda x: x*(-1), A))
heapq.heapify(A)
a, b = -10**18, -10**18
while True:
  x = heapq.heappop(A)
  if a == x:
    break
  else:
    a = x
while True:
  x = heapq.heappop(A)
  if b == x:
    break
  else:
    b = x
print(a*b)
# Judge status: Accepted
import sys

input = sys.stdin.readline

P = 10 ** 9 + 7


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

    ans = 0
    for k in reversed(range(1, (N+1)+1)):
        a = (N + (N-k+1))*k//2
        b = k*(k-1)//2
        ans += a - b + 1
        ans %= P

        if k == K :
            break

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)
for l1 in l:
    print(len(l1))
# Judge status: Accepted


def main():
    N, M = map(int, input().split())
    skip = (N // 2) // 2 + 1 if N % 2 == 0 else None
    count = 0
    left, right = 0, N + 1
    while count < M:
        left += 1
        if left == skip:
            continue
        right -= 1
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
h = [int(x) for x in input().split()]
inf = float('inf')
dp = [inf] * n  # initialize dp
dp[0] = 0
for i in range(1, n):
    if i == 1:
        dp[i] = abs(h[i] - h[i-1])
    elif abs(dp[i-1] + h[i] - h[i-1]) < abs(dp[i-2] + h[i] - h[i-2]):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = dp[i-2] + abs(h[i] - h[i-2])
print(dp[-1])
# Judge status: Accepted

n,m=map(int,input().split())
a = [int(input()) for _ in range(m)]

mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
NG=[False]*n
for i in range(m):
    NG[a[i]-1]=True

for i in range(1,n+1):
    if NG[i-1]==False:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[-1])

"""
#DP問題
"""
# Judge status: Accepted
n=int(input())
from math import ceil
a,b,c,d,e=[int(input()) for i in range(5)]
print(max( ceil(n/a),ceil(n/b),ceil(n/c),ceil(n/d),ceil(n/e), )+4)
# Judge status: Accepted
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
b = intl()

a = b[0] + b[-1]
for i in range(n-2):
	a += min( b[i], b[i+1] )
print(a)
# Judge status: Accepted
X,Y=map(int,input().split())
mod=pow(10,9)+7
m=(2*X-Y)//3
n=(2*Y-X)//3
if  m!=(2*X-Y)/3 or n!=(2*Y-X)/3 or m<0 or n<0:
    print(0)

else:
    bunsi = 1
    bunbo = 1
    for i in range(0, n):
        bunsi = (bunsi * (m + 1 + i)) % mod
        bunbo = (bunbo * (1 + i)) % mod
    print((bunsi * pow(bunbo, mod - 2, mod)) % mod)
# Judge status: Wrong Answer
n = int(input())
print('ABC') if n > 0 and n < 100 else print('ABD')
# Judge status: Wrong Answer
N=int(input())
S=input()

ans=1

for i in range(1,N):
    X=S[:i]
    Y=S[i:]
    setX=set(X)
    setY=set(Y)
    intersectionXY=setX & setY
    _temp=len(intersectionXY)
    if _temp>ans:
        ans=_temp
    else:
        pass
print(ans)
# Judge status: Wrong Answer
H1, M1, H2, M2, K = [int(s) for s in input().split()]
if H2 < H1:
    H2 += 24
elif H2 == H1 and M1 > M2:
    H2 += 24
print(H2 * 60 + M2 - H1 * 60 + M1 - K)
# Judge status: Wrong Answer
a,b,c = map(int, input().split())
print('Yes' if a<c<b else 'No')
# Judge status: Accepted
import math
h = int(input())
w = int(input())
n = int(input())
m = 0
ans = math.ceil(n / max(h, w))
print(ans)
# Judge status: Accepted
#TwoAnagrams
s = input()
t = input()
S = sorted(s)
T = sorted(t, reverse = True)
ST = sorted([S, T])
if ST[0] != T:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
import math
A, B, H, M = map(int, input().split())
h = (H / 12 + M / 720)
m = M / 60
rad = (abs(h-m) * 360) % 180
print( round((A**2 + B**2 - 2 * A * B *  round(math.cos( math.radians(rad) ),20) )** 0.5, 10) )
# Judge status: Accepted
N,M = map(int,(input().split()))
if N %2 == 1:
    for i in range(M):
        print(i+1,N-i)
else:
    for i in range(min(M,N//4)):
        print(i+1,N-i)
    for i in range(max(0,M-N//4)):
        print(N//4+i+1,N-N//4-i-1)
# Judge status: Accepted
A=[int(y) for y in input().split()]

if A[0]%A[1]==0:
   print(A[0]//A[1])
else:
   print(A[0]//A[1]+1)
# Judge status: Accepted
n = int(input())
ans = n - n//2
print(ans/n)
# Judge status: Accepted

import collections

N=input()

N=int(N)

aaa=[]

for i in range(N):
    a1=input()
    aaa.append(a1)


M=input()

M=int(M)


bbb=[]

for i in range(M):
    a1=input()
    bbb.append(a1)
    
#print(aaa)

#print(bbb)


c = collections.Counter(aaa)

d = collections.Counter(bbb)

#print(c)

#print(d)

#print(c-d)

dic2 = sorted((c-d).items(), key=lambda x:x[1], reverse=True)


#print(len(dic2))

if len(dic2)==0:
    print(0)
else:
    print(dic2[0][1])
# Judge status: Accepted
w,a,b=map(int,input().split())
if a>b+w:
    print(a-b-w)
elif a+w>b:
    print(0)
else:
    print(b-a-w)
# Judge status: Accepted
import collections

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

gb = [1]*n;
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] == h[b]:
        gb[a] = 0
        gb[b] = 0

    elif h[a]<h[b]:
        gb[a] = 0
    else:
        gb[b] = 0

l = collections.Counter(gb)
print(l[1])
# Judge status: Accepted
X,Y= map(int,input().split())

print(X+Y//2)
# Judge status: Wrong Answer
# 144 A

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

if 1 <= (a and b) <= 9:
    print(a * b)
else:
    print(-1)
# Judge status: Wrong Answer
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
    print("No" if "##" in s[a-1:d] else "Yes")
else:
    print("Yes" if "##" not in s[b-1:d] and "..." in s[a-1:c] else "No")
# Judge status: Wrong Answer
a,b=input().split()
w=[a*int(b),b*int(a)]
sorted(w)
print(w[1])
# Judge status: Wrong Answer
N = int(input())
li = []
max1 = 0
max2 = 0
for i in range(N):
  s = int(input())
  li.append(s)
  
  if s > max1:
    max1 = s
    
  if max1 > s > max2:
    max2 = s

for index, i in enumerate(li):
  s = max(li)
  
  if s == li[index]:
    print(max2)
  else:
    print(max1)
# Judge status: Wrong Answer
N = int(input())
h = list(map(int, input().split()))
l = list(map(int, input().split()))
c = h[0]

for i in range(N):
    if sum(h[i+1:])+l[N-1] < sum(l[i:]):
        c += sum(l[i:])
        print(c)
        exit()
    elif i == N-1:
        c += l[N-1]
        print(c)
        exit()
    else:
        c += h[i+1]
# Judge status: Accepted
S = input()
# RC = S.count('R')
# if S[1] == 'S' and RC == 2:
    # print(1)
# else:
    # print(RC)

rs = S.split('S')
ans = 0
for r in rs:
    ans = max(ans, len(r))
print(ans)
# Judge status: Wrong Answer
n = int(input())
ans = [0 for i in range(n)]


for i in range(101):
  for j in range(101):
    for k in range(101):
      a = i*i +j*j + k*k + i*j +j*k + k*i
      if a < n:
        ans[a]+=1
for i in ans:
  print(i)
# Judge status: Wrong Answer
N,A,B = map(int,input().split())
n = B - A
if n % 2 == 0:
    print(n//2)
else:
    print(min(B-1,N-2))
# Judge status: Wrong Answer
n = int(input())
ans = [0 for _ in range(n)]
for i in range(1,32):
  for j in range(1,32):
    for k in range(1,32):
      s = i**2 + j**2 + k**2 +i*j + j*k + k*i
      if s <= n:
        ans[s-1] += 1
for i in range(n):
  print(ans[i])
# Judge status: Wrong Answer
n,m = map(int,input().split())
l = []
for _ in range(m):
    a,b = map(int,input().split())
    l.append([a,b])

for x in l:
    if x[0] == 1:
        for y in l:
            if y[1] == n:
                print ("POSSIBLE")
                exit ()
print ("IMPOSSIBLE")
# Judge status: Accepted
from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int, input().split()))

d = defaultdict(int)
for i in range(N):
  d[A[i]] += 1
  
cnt = len(d.keys()) - K
d = sorted(d.items(), key=lambda x:x[1])
ans = 0
for val in d:
  if cnt <= 0:
    print(ans)
    exit()
  ans += val[1]
  cnt -= 1
# Judge status: Wrong Answer
N = int(input())
ans = 0
for j in range(1, N+1):
    for i in range(1, N+1):
        if i % j == 0:
            ans += i
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
l = []

for i in range(m):
    p, y = input().split()
    l.append([p, y, i])

l.sort()

l[0][1] = 1

for i in range(1, m):
    if l[i][0] == l[i - 1][0]:
        l[i][1] = l[i - 1][1] + 1
    else:
        l[i][1] = 1

sortthird = lambda val: val[2]
l.sort(key = sortthird)

for i in l:
    ans = "0"*(6 - len(i[0])) + i[0] + "0"*(6 - len(str(i[1]))) + str(i[1])
    print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
list=[]
s=[]
for i in range(N):
    list.append(input().split())
    s = set(s) & set(list[1:])
    list=[]
print(len(s))
# Judge status: Accepted
# import numpy 
n = int(input())
a = list(map(int,input().split()))
re = 1
if 0 in a:
    print("0")
else:
    for i in a :
        re = re * i
        if re > 1000000000000000000:
            print("-1")
            quit()
    print(re)
# Judge status: Accepted
n,k=map(int,input().split())
A=list(map(int,input().split()))
s=[]
v=1
ord=[-1]*(n+1)
c=1
l=0
while ord[v]==-1:
  ord[v]=len(s)
  s.append(v)
  v=A[v-1]
c=len(s)-ord[v]
l=ord[v]

if k<l:
  print(s[k])
else:
  k-=l
  k%=c
  print(s[l+k])
# Judge status: Accepted
import itertools
l=list(map(int,input().split()))
L=[]
p=itertools.permutations(l,2)
for a,b in p:
  L.append(a+b)
print(min(L))
# Judge status: Wrong Answer
a, b, x = map(int, input().split())

if a == 0 and b != 0 and b < x:
    print(0)
elif (a/x).is_integer():
    print(b//x-a//x+1)
else:
    print(b//x-a//x)
# Judge status: Accepted
N = int(input())
L = [str(input()) for i in range(N)]
flag = 1

for i in range(N):
    if L.count(str(L[i]))<2:
        if str(L[i-1])[-1] == str(L[i])[0]:
            pass
        elif i == 0:
            pass
        else:
            flag = 0
    else:
        flag = 0

if flag:
    print("Yes")

else:
    print("No")
# Judge status: Wrong Answer
from collections import defaultdict
n = int(input())
s = list(input())
cnt = defaultdict(int)
for c in s:
    cnt[c] += 1
ans = 1
for k, v in cnt.items():
    ans *= v + 1

print(ans - 1)
# Judge status: Accepted
n ,k = map(int, input().split())
total = 0

for i in range(k, n+2):
    total += i*n - (i-1)*i +1

print(total%(10**9+7))
# Judge status: Accepted
k, n = map(int, input().split())
array = list(input().split())
array2 = []
for i in range(len(array)-1):
    array2.append(int(array[i+1]) - int(array[i]))
first = int(array[0]) + k - int(array[len(array)-1])
array2.append(first)
print(k - max(array2))
# Judge status: Accepted
n,m=(int(i) for i in input().split())
p=[[int(i) for i in input().split()] for i in range(m)]
c=[0]*(n)
i={}
for pe,pk in sorted(p, key=lambda x: x[1]):
  c[pe-1]+= 1
  i[pk]='%06d%06d' % (pe, c[pe-1])
for _,pk in p:
  print(i[pk])
# Judge status: Accepted
a, b, n = [int(i) for i in input().split()]
x = min(b - 1, n)
print((a*x//b)-a*(x//b))
# Judge status: Accepted
h,w = map(int,input().split(" "))
if h == 1 or w == 1:
    print(1)
    exit()
if h % 2 == 0:
    print((h // 2) * w)
else:
    if w % 2 == 0:
        print((h // 2) * w + (w // 2))
    else:
        print((h // 2) * w + (w // 2) + 1)
# Judge status: Accepted
from collections import Counter
 
n = input()
c = Counter(n)
c.pop('0', None)
 
if len(c) == 1 and '1' in c and c['1'] == 1:
    print(10)
else:
    print(sum(int(f) * m for f, m in c.items()))
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]
pre_a = A[0]
ans = 0

for a in A[1:]:
  ans += max(0, pre_a - a)
  pre_a = max(pre_a, a)

print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
ans = max(a, b)
if a > b:
    a -= 1
else:
    b -= 1
ans += max(a, b)
print(ans)
# Judge status: Accepted
n = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
alice = 0
bob = 0
for i in range(n):
    if i%2==0:
      alice += A[i]
    else:
        bob += A[i]
print(alice-bob)
# Judge status: Accepted
q,h,s,d = map(int, input().split())
n = int(input())
q_cp=q*4
h_cp=h*2
s_cp=s
d_cp=d/2

vals = [[q_cp,0.25],[h_cp,0.5],[s_cp,1],[d_cp,2]]
vals.sort()

if vals[0][1] <= 1:
        print(n * vals[0][0])
else:
        ans=d*(n//2)
        if n%2==0:
                print(ans)
        else:
                ans+=vals[1][0]
                print(ans)
# Judge status: Accepted
ls1 = input()
ls2 = input()

num = len(ls1)

ans = 0

for i in range(num):
    if ls1[i] != ls2[i]:
        ans += 1

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

flag = 1
for i in range(q):
  st = input().split()
  if int(st[0]) == 1:
    flag *= -1
  else:
    tmp = int(st[1])*flag
    if tmp == 1 or -2:
      s = st[2] + s
    else:
      s = s + st[2]

if flag == -1:
  s = s[::-1]
print(s)
# Judge status: Accepted
def make_divisors(n):
    ans = 10 ** 12 + 10
    i = 1
    while i*i <= n:
        if n % i == 0:
            t = 0
            if i != n // i:
                t = i + (n//i) - 2
            else:
                t = i * 2 - 2
            #print(i, n//i, t)
            if ans > t:
                ans = t
        i += 1
    return ans

n = int(input())
print(make_divisors(n))
# Judge status: Wrong Answer
N=int(input())
A=sorted(map(int,input().split()))
ans=0
for i in range(N-1):
  ans+=A[i]
if ans>=A[N-1]:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
# -*- coding: utf-8 -*-
count = {}
for c in input():
    if c in count:
        count[c] = not(count[c])
    else:
        count[c] = False

print(['Yes', 'No'][False in count.values()])
# Judge status: Accepted
import sys
l,r = map(int,input().split())
mn = 2018
for i in range(l,r+1):
    for j in range(i+1,r+1):
        mod = (i * j) % 2019
        if mod == 0:
            print(0)
            sys.exit()
        
        mn = min(mn,mod)
print(mn)
# Judge status: Accepted
a, b, c = map(int, input().split())

if ( a % 2 == 0 and b % 2 == 0 and c % 2 == 0 and a == b == c):
    print(-1)
    quit()

count = 0
while(a % 2 == 0 and b % 2 == 0 and c % 2 == 0):
    _a = b / 2 + c /2
    _b = a / 2 + c /2
    _c = a / 2 + b /2
    a = _a
    b = _b
    c = _c
    count += 1
print(count)
# Judge status: Accepted
N, L = map(int, input().split())
char_list = sorted([input() for i in range(N)])

combined_char = ""

for cl in char_list:
    combined_char += cl

print(combined_char)
# Judge status: Accepted
sx,sy,tx,ty = map(int, input().split())

x = tx - sx
y = ty - sy

ans = ''
ans += 'U'*y+'R'*x
ans += 'D'*y+'L'*x
ans += 'L'+'U'*(y+1)+'R'*(x+1)+'D'
ans += 'R'+'D'*(y+1)+'L'*(x+1)+'U'
print(ans)
# Judge status: Accepted
N = int(input())
print((1 + N) * N // 2)