peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
    num = list(str(i))
    num = sum([int(i) for i in num])
    if num >= a and num <= b:
        ans += i
print(ans)
# Judge status: Accepted
n=int(input())
s=input()
List=list(s)
for i in range(len(s)):
    if ord(List[i])+n<=90:
        List[i]=chr(ord(List[i])+n)
    else:
        List[i]=chr(ord(List[i])+n-26)
new_s="".join(List)
print(new_s)
# Judge status: Wrong Answer
s = sorted(input())
if s == ["a","b","c"]:
    print("Yes")
else:
    print("No")
print(s)
# Judge status: Wrong Answer
def abc139d():
    n = int(input())
    print(int(n*((n-1)/2)))
abc139d()
# Judge status: Accepted
#!/usr/bin/env python3
import collections
n, m = map(int, input().split())
l = []
ans = 0
for _ in range(n):
    l.extend(list(map(int, input().split()))[1:])
c = collections.Counter(l)
for k in c:
    if c[k] == n: ans += 1
print(ans)
# Judge status: Wrong Answer
W, H, x, y = map(int, input().split())

# 大きくない方とかって書いてあるけど、別にイコールの場合でもいいんかい！
# 中心の座標を求める
centerX = (W // 2)
centerY = (H // 2)

if ((x, y) == (centerX, centerY)):
    print((W * H) / 2, 1)

else:
    print(W * H / 2, 0)
# Judge status: Accepted
n=int(input())
l=list(map(int, input().split()))
a=0
for i in range(n-1):
  if l[i]>l[i+1]:
    a=a+l[i]-l[i+1]
    l[i+1]=l[i]
print(a)
# Judge status: Accepted
def dist(a, b):
	res = 0
	for i in range(D):
		res += (a[i] - b[i]) ** 2
	res = res ** 0.5
	return res


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		if dist(X[i], X[j]).is_integer():
			ans += 1
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())

def dist(a, b):
    return min(abs(a - b), n - abs(a - b))

a, b = n, 1
S = set()
for i in range(m):
    if 2 * dist(a, b) == n or dist(a, b) in S:
        a -= 1
    print(a, b)
    S.add(dist(a, b))
    a -= 1
    b += 1
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

mae = 0
ato = 0
bit = 0
for i in range(n):
    if a[i] != 1 and bit == 0:
        mae += 1
    elif a[i] != 1 and bit == 1:
        ato += 1
    else:
        bit = 1

waru = k-1
ans = (mae+ato+waru-1)//waru
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

def main():
    N, x = map(int, input().split())
    a_list = list(map(int, input().split()))
    if sum(a_list) == x:
      print(N)
      sys.exit()
    for i, a in enumerate(sorted(a_list), start=1):
        x -= a
        if x < 0:
            break
    if x >= 0:
        print(i)
    else:
        print(i-1)
# Judge status: Accepted
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
A,B,C = LI()
K = I()
count = 0
while 1:
    if A<B:
        break
    B *= 2
    count += 1
while 1:
    if B<C:
        break
    C *= 2
    count += 1
print('Yes' if count<=K else 'No')
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
st = []
c = 0
for i in range(0,n):
    if (p[i] == i+1):
        st.append(1)
    else:
        st.append(0)
def cal(a):   
    global c    
    if (st[a]== 1 and  st[a+1]==1):
        c += 1
        return a+2
    return a+1
p=0           
while (p < n-1):
    p = cal(p)
    
y = st.count(1)
print(y-c)
# Judge status: Wrong Answer
N = int(input())
li1 = [input() for _ in range(N)]
li1.sort()
M = int(input())
li2 = [input() for _ in range(M)]
li2.sort()
temp = 0
for i in li1:
    for j in li2:
        if i == j:
            temp -=1
        elif i!=j:
            temp +=1
ans = 0
print(max(ans,temp))
# Judge status: Accepted
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int, input().split()))
for i in range(n):
    if i == 0:
        max = A[i]
    else:
        if max > A[i]:
            ans += max - A[i]
        else:
            max = A[i]
print(ans)
# Judge status: Accepted
import sys

N = int(sys.stdin.readline())
data = sys.stdin.readlines()

for i in range(2):
    data[i] = data[i].split(' ')
    data[i] = [int(j.replace('\n', '')) for j in data[i]]

set = [0]*N
for i in range(N):
    candy = 0
    candy = sum(data[0][0:i+1]) + sum(data[1][i:N])
    set[i] = candy

print(max(set))
# Judge status: Accepted
from collections import defaultdict
d = defaultdict(int)
n = int(input())
a = list(map(int, input().split()))
for num in a:
  if num % 4 == 0:
    d[4] += 1
    continue
  if num % 2 == 0:
    d[2] += 1
    continue
print("Yes" if n//2 <= d[4] + (d[2] // 2) else "No")
# Judge status: Accepted
n = input()
if '7' in n : print('Yes')
else : print('No')
# Judge status: Accepted
print(["SAT","FRI","THU","WED","TUE","MON","SUN"].index(input())+1)
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1,N+1):
    ans += i

print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
K = int(input())
m = max(a, b, c)
print(a + b + c + 2**(K-1) * m)
# Judge status: Accepted
n = int(input())

l = [1]

for i in range(1, n+1):
    for j in range(2, int(n**0.5)):
        if n >= i**j:
            l.append(i**j)
            #print(l)
print(max(l))
# Judge status: Wrong Answer
a = int(input())
b = input()
chr_a = 0
ans = ''
for i in range(len(b)):
    if ord(b[i]) + a <= 90:
        chr_a = ord(b[i]) + a
    else:
        chr_a = ord(b[i]) + a -25
    ans += chr(chr_a)
print(ans)
# Judge status: Accepted
n = int(input())

sum = 0
num_list = []
for i in range(1, 10**7):
    sum += i
    num_list.append(i)
    if sum > n:
        break

for i in num_list:
    if i == (sum - n):
        continue
    else:
        print(i)
# Judge status: Accepted
from collections import deque
import sys
read = sys.stdin.readline

s = deque(read().rstrip())
q = int(read())

rev = 0
for _ in range(q):
    a = tuple(read().split())
    if a[0] == '1':
        rev ^= 1
    else:
        dir = rev ^ int(a[1]) - 1
        if dir == 0:
            s.appendleft(a[2])
        else:
            s.append(a[2])

if rev:
    print(''.join(s)[::-1])
else:
    print(''.join(s))
# Judge status: Accepted
#88 C - X: Yet Another Die Game
import decimal
x = decimal.Decimal(input())

n = x/decimal.Decimal(11)
ans = n*decimal.Decimal(2)
judge = int(ans)
if ans - judge < decimal.Decimal(0.1):
    print(int(ans))
else:
    print(int(ans) + 1)
# Judge status: Accepted
n=int(input())
print(["NO","YES"][n in {3,5,7}])
# Judge status: Wrong Answer
num1,num2 = [int(num) for num in input("Enter a number").split()]
print(num1*num2)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

if k%2==0:
    ans = a-b
else:
    ans = b-a

if abs(ans)>10**18:
    print('Unfair')
else:
    print(ans)
# Judge status: Accepted
s=input()
if s.islower():
    print('a')
else:
    print('A')
# Judge status: Accepted
n = int(input())
t = [int(input()) for i in range(n)]

from functools import reduce
from fractions import gcd
def lcm(x,y):
    return x*y // gcd(x,y)

def lcm2(args):
    return reduce(lcm,args)

print(lcm2(t))
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
l.sort()
p=[1]*(l[-1]+1)
ans=0
for i in range(n):
  a=l[i]
  if p[a]==1:
    b=a
    while a<=l[-1]:
      p[a]=0
      a+=b
    if i<n-1:
      if l[i]==l[i+1]:
        pass
      else:
        ans+=1
    else:
      ans+=1
print(ans)
# Judge status: Accepted
def myAnswer(K:int,A:int,B:int) -> int:
   if((B - A) <=2):
      return K + 1
   else:
      return max(0,(K - (A - 1)) // 2)*(B - A) + A + (K - (A - 1)) % 2


def modelAnswer():
   return
def main():
   K,A,B = map(int,input().split())
   print(myAnswer(K,A,B))
if __name__ == '__main__':
   main()
# Judge status: Accepted
print('YES' if input() == input()[::-1] else 'NO')
# Judge status: Accepted
import math
A,B,C = map(int,input().split())
k = [A,B,C]
k.sort()
k.reverse()
ans = 0
ans += k[0]-k[1]
now = k[2]
now += ans
if (k[0]-now)%2 == 0:
    ans += math.ceil((k[0]-now)/2)
    print(ans)
else:
    ans += math.ceil((k[0]-now)/2)
    ans += 1
    print(ans)
# Judge status: Wrong Answer
n, m = list(map(int, input().split()))
aaa = list(int(input()) for i in range(m))

dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7

for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1])  % MOD
# Judge status: Accepted
import numpy as np
from collections import Counter

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

b = a + 1
c = a - 1

d = np.concatenate((a, b, c))
e = Counter(d)

print(e.most_common()[0][1])
# Judge status: Wrong Answer
from sys import stdin
from collections import deque
input = stdin.readline

s = input().rstrip()
d = deque([])

for i in s:
    if s != "B":
        d.append(s)
    else:
        if d:
            d.pop()
        else:
            pass

while d:
    p = d.popleft()
    print(p, end="")

print()
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

ans = 1
judge = -1
for i in range(n-1):
  if a[i] == a[i+1]:
    break
  elif a[i] < a[i+1]:
    if judge == -1:
      ans += 1
    else:
      judge = 1
  elif a[i] > a[i+1]:
    if judge == 1:
      ans += 1
    else:
      judge = 1      
print(ans)
# Judge status: Accepted
n = int(input())
ans = n//11*2
if 0 < n%11 <= 6:
    ans += 1
elif 6 < n%11 <= 10:
    ans += 2

print(ans)
# Judge status: Accepted
import math

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

#  めぐる式二分探索で実装

def calc(x):
    count = 0
    for a in A:
        count += (a - 1) // x

    return count <= K

ok = 10 ** 9
ng = 0

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    
    if calc(mid):
        ok = mid
    else:
        ng = mid

print(ok)
# Judge status: Wrong Answer
n,k=map(int,input().split())
l=list(map(int,input().split()))


s=0
check=0
f=0
save=0
for i in range(1,k):
	s=s+l[i]-l[i-1]
	if(f==0 and l[i]>= n//2):
		check=i
		f=1
	else:
		if(f==0):
			save=s

s1=0
#print(save,check)
for i in range(check+1,k+1):
	s1=s1+n-abs(l[i%k]-l[(i-1)%k])

s1=s1+save
#print(s,s1)
print(min(s,s1))
# Judge status: Accepted
n = int(input())
dic = {i+1:int(input()) for i in range(n)}
light = dic[1]
ans = 1

for i in range(n):
    if light == 2:
        break
    elif light == 1 or i == n-1:
        ans = -1
        break
    else:
        ans += 1
        light = dic[light]
    
print(ans)
# Judge status: Accepted
def INT(): return int(input())
def MAP(): return map(int, input().split())


X = INT()

year = 0
cash = 100
while cash < X:
    year += 1
    cash = int(cash * 1.01)

print(year)
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))
ctr = 0
for i in range(N):
    if P[i] != i+1:
        ctr += 1
if ctr <= 2:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
    t[i+1]=t[i]+(1 if S[i:i+2]=='AC' else 0)
for i in range(Q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])
# Judge status: Accepted
#!/usr/bin/env python3

from typing import *



# def solve(a: int, b: int, c: int, d: int) -> int:
def solve(a, b, c, d):
    ans=[a*c, a*d, b*c, b*d]
    return max(ans)

def main():
    a, b, c, d = map(int, input().split())
    a1 = solve(a, b, c, d)
    print(a1)

if __name__ == '__main__':
    main()
# Judge status: Accepted
x=int(input())
a=1
for i in range(1,x):
    for y in range(2,x):
        if i**y<=x: a=max(a,i**y)
        else:break
print(a)
# Judge status: Accepted
A, B, C = map(int, input().split())
import fractions
a = fractions.gcd(A, B)
ans = 'NO'
if a == 1:
  ans = 'YES'
elif C % a == 0:
  ans = 'YES'
print(ans)
# Judge status: Wrong Answer
x = str(input())
y = str(input())

if x[0] == y[2] and x[1] == y[1] and x[2] == y[0]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def buy(my_money, A, count):
    return my_money%A, count + my_money//A

def sell(my_money, A, count):
    return my_money + A*count, 0

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

now = 1000  # 所持金
kabu = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        now, kabu = buy(now, A[i], kabu)
    else:
        now, kabu = sell(now, A[i], kabu)

now, kabu = sell(now, A[N-1], kabu)

print(now)
# Judge status: Accepted
a, b, c = map(int, input().split())
if c >= a and c <= b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]

cnt2 = 0
cnt4 = 0

for i in range(n):
    if a[i] % 2 == 0 and a[i] % 4 != 0:
        cnt2 += 1
    elif a[i] % 4 == 0:
        cnt4 += 1

n = n - cnt2
if cnt2 == 0:
    if n-cnt4 <= cnt4+1:
        print("Yes")
    else:
        print("No")
else:
    if n-cnt4 <= cnt4:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
l1 = sorted([i for i,k in l])
l2 = sorted([k for i,k in l])[::-1]

if n%2!=0:
  a = l1[int(n//2)]
  b = l2[int(n//2)]
  print(b-a+1)
  
else:
  a1 = l1[int(n//2)-1]
  a2 = l1[int(n//2)]
  b1 = l2[int(n//2)-1]
  b2 = l2[int(n//2)]
  print((b1-a1+1)+(b2-a2+1)-1)
# Judge status: Wrong Answer
import math
A, B, C, D = input().split()
 
if math.ceil(int(C)*1.0/(int(B)*1.0)) >= math.ceil(int(A)*1.0/(int(D)*1.0)):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
A, B, K = map(int, input().split())
if A >= K:
    A -= K
elif A+B <= K:
    A = 0
    B = 0
else:
    B = A+B-K
    A = 0

print(A, B)
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))

from itertools import combinations
c = combinations(L, 3)
count = 0
for cs in c:
    if len(set(cs)) < 3:
        continue
    cs = sorted(cs)

    if cs[0] + cs[1] <= cs[2]:
        continue

    count += 1
print(count)
# Judge status: Accepted
X, Y, Z = map(int, input().split())
X -= Y + 2 * Z

ans = X // (Y + Z) + 1

print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-

A,B = [int(i) for i in input().rstrip().split()]

if A == 1:
  A=14
if B == 1:
  B=14

if A > B:
  print("Alice")
elif A == B:
  print("Draw")
else:
  print("Bob")
# Judge status: Accepted
w,h,n = map(int, input().split())
l,r,d,u = (0,w,0,h)
for i in range(n):
  x,y,a = map(int, input().split())
  if a == 1:
    l = max(l,x)
  elif a == 2:
    r = min(r,x)
  elif a == 3:
    d = max(d,y)
  else:
    u = min(u,y)
print((r-l)*(u-d) if r>l and u>d else 0)
# Judge status: Accepted
times, first, first_amount, second_amount = [int(input()) for i in range(4)]
total = 0
for i in range(times):
    if first > 0:
        total += first_amount
        first -= 1
    else:
        total += second_amount
print(total)
# Judge status: Accepted

mod = (10 ** 9 + 7)

def comb(n, r):
    p, q = 1, 1

    for i in range(r):
        p = p *(n-i)%mod
        q = q *(i+1)%mod
    
    return p * pow(q, mod-2, mod) % mod


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

s = pow(2, n, mod) - 1

print((s - comb(n, a) - comb(n, b)) % mod)
# Judge status: Accepted
n = int(input())
csf = [list(map(int, input().split())) for i in range(n - 1)]
for i in range(n):
    ans = 0
    for j in range(i, n - 1):
        c, s, f = csf[j][0], csf[j][1], csf[j][2]
        if ans < s:
            ans = s
        elif ans % f != 0:
            ans += f - ans % f
        ans += c
    print(ans)
# Judge status: Accepted
X = int(input())
print("YES" if 105%X == 0 and X != 1 else "NO")
# Judge status: Wrong Answer
import itertools
N,K=map(int,input().split())
D=[int(x) for x in input().split()]
T=[]
answer=10000
for i in range(10):
  if not i in D:
    T+=[i]
for x in itertools.product(T,repeat=4):
    p=x[-1]+x[-2]*10+x[-3]*100+x[-4]*1000
    if p>=N:
      answer=min(p,answer)
print(answer)
# Judge status: Wrong Answer
import math
ND=input().split()
N=int(ND[0])
D=int(ND[1])
cont=0

for i in range(N):
  XY=input().split()
  X=int(XY[0])
  Y=int(XY[1])
  d= math.sqrt( (pow(X,2)) + (pow(Y,2)) )
  if int(d)==D:
    cont+=1  
  
print(cont)
# Judge status: Wrong Answer
i = input().split()
a = int(i[3])-int(i[0])
b = int(i[3])-int(i[0])-int(i[1])

if i[3] <= i[0]:
  print(i[0])
elif a <= int(i[1]):
  print(i[0])
elif b == int(i[2]):
  print(int(i[0])*2 + int(i[1]) - int(i[3]))
else:
  print(int(i[3]) - int(i[1])- int(i[2]))
# Judge status: Accepted
s=input()

tmp1 = ''
tmp2 = ''
for i in range(len(s)):
  if i % 2 == 0:
    tmp1 += '0'
    tmp2 += '1'
  else:
    tmp1 += '1'
    tmp2 += '0'

diff_tmp1 = 0
diff_tmp2 = 0
for i in range(len(s)):
  if tmp1[i] != s[i]:
    diff_tmp1 += 1
  elif tmp2[i] != s[i]:
    diff_tmp2 += 1
print(min(diff_tmp1,diff_tmp2))
# Judge status: Accepted
N, M = map(int, input().split())
ball = [1] * N
red = {1}
ans = 0
for _ in range(M):
    x, y = map(int, input().split())
    ball[x - 1] -= 1
    ball[y - 1] += 1
    if x in red:
        red.add(y)
        if ball[x - 1] == 0:
            red.remove(x)
print(len(red))
# Judge status: Wrong Answer
from sys import exit
X, Y = map(int,input().split())
if X % Y == 0 or Y % X == 0:pass
else:
  for i in range(X,10 ** 18 + 1,X):
    if i % Y != 0:
      print(i)
      exit()
print(-1)
# Judge status: Accepted
from decimal import Decimal
a, b = input().split()

a = Decimal(a)
b = Decimal(b)

print(int(a*b))
# Judge status: Accepted
n,m=map(int,input().split())
A=list(map(int,input().split()))
all=int(0)
for i in range(n):
    all+=A[i]
cnt=int(0)
for i in range(n):
    if A[i]>=all/4/m:
        cnt+=1
if cnt>=m:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c,x,y=map(int,input().split())
c*=2
d=a*x+b*y
f=max(x,y)*c
if x<y:
  
  e=x*c+(y-x)*b
else:
  z=x-y
  e=y*c+(x-y)*a
print(min(d,min(e,f)))
# Judge status: Accepted
l1 = input().split()
a = int(l1[0])
b = int(l1[1])
if a == b:
    print("Draw")
    exit()
if a == 1:
    print("Alice")
    exit()
if b ==1:
    print("Bob")
    exit()
if a > b:
    print("Alice")
if b > a :
    print("Bob")
# Judge status: Wrong Answer
sx, sy, tx, ty = map(int, input().split())

A = "L"
for i in range(ty-sy+1):
    A += "U"
for i in range(tx-sx+1):
    A += "R"
for i in range(ty-sy+1):
    A += "D"
for i in range(tx-sx):
    A += "L"
for i in range(ty-sy):
    A += "U"
for i in range(tx-sx+1):
    A += "R"
for i in range(ty-sy+1):
    A += "D"
for i in range(tx-sx+1):
    A += "L"
A += "U"
# Judge status: Accepted
import math
n = int(input())

res = math.ceil(n/2)
print(res)
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n):
    ans += (n-1)//i
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = [int(input()) for _ in range(N)]
dic = {a: False for a in A}
for a in A:
    dic[a] = True if not dic[a] else False
ans = 0
for a in A:
    ans += dic[a]
print(ans)
# Judge status: Accepted
input()
s = input()
while "DI" in s:
    s = s.replace("DI", "")
print(s.count("I"))
# Judge status: Accepted
#https://mirucacule.hatenablog.com/entry/2020/04/27/090908
#https://drken1215.hatenablog.com/entry/2020/04/29/171300

S=str(input())[::-1]#逆順で格納
N=len(S)
counter=[0]*2019
counter[0]=1
ans=0
num,d=0,1
for c in S:
    num += int(c) * d
    num %= 2019
    d *= 10
    d %= 2019
    counter[num]+=1
for i in counter:
    ans += i*(i-1)//2
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

n,m = map(int,input().split() )
b = [0]*m
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(1, len(a)):
		print(j)
		b[a[j]-1] += 1
ans = b.count(n)
print(ans)
# Judge status: Accepted
n = int(input())
num_list = list(map(int, input().split(" ")))
min = 200001
count = 0

for i in num_list:
    if min >= i:
        count += 1
        min = i

print(count)
# Judge status: Accepted
A, B, C, K = map(int, input().split())
print(A - B if K % 2 == 0 else B - A)
# Judge status: Accepted
n,m=map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]

man = lambda x,y:abs(x[0] - y[0]) + abs(x[1] - y[1])

for i in range(n):
    a,b = ab[i]
    cost = float('INF')
    pos = 0
    for j in range(m):
        c,d = cd[j]
        c = man(ab[i], cd[j])
        if c < cost:
            cost = c
            pos = j+1
    print(pos)
# Judge status: Accepted
if __name__ == '__main__':
    n = int(input())

    total = 0
    data = [[0] * 9 for i in range(9)]
    for i in range(1, n + 1):
        str_num = str(i)
        top = str_num[0]
        bottom = str_num[-1]
        if bottom == '0':
            continue
        else:
            data[int(top) - 1][int(bottom) - 1] += 1

    for i in range(9):
        for j in range(9):
            total += (data[i][j] * data[j][i])

    print(total)
# Judge status: Accepted
Y = int(input())
 
C500 = Y // 500
C5 = (Y - C500*500) // 5 if (Y - C500*500) // 5>0 else 0

print(C500*1000+C5*5)
# Judge status: Accepted
H, N = map(int, input().split())
lst = [int(x) for x in input().split()]
if sum(lst) >= H:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        for j in range(1, int(n**0.5)+2):
            if n%j==0:
                b[j-1] ^= 1
                if j!=n//j:
                    b[n//j-1] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)
# Judge status: Accepted
from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(m):
  g=list(map(int,input().split()))
  l.append(g)
  l[i].append(i)
l.sort()
l[0][1]=1
for i in range(1,m):
  if l[i][0]==l[i-1][0]:
    l[i][1]=int(l[i-1][1])+1
  else:
    l[i][1]=1
newl=sorted(l,key=itemgetter(2))
for i in range(m):  
  print((6-len(str(newl[i][0])))*'0'+str(newl[i][0])+(6-len(str(newl[i][1])))*'0'+str(newl[i][1]))
# Judge status: Accepted
A , B, C, K = map(int, input().split())

if K >= A:
    result = A
    K -= A
else:
    result = K
    K = 0

if K >= B:
    K -= B

if K > 0:
    result -=K
print(result)
# Judge status: Accepted
w, h, x, y = map(int, input().split())
ans_1 = w*h/2
if x == w/2 and y == h/2:
   ans_2 = 1*True
else:
   ans_2 = 1*False
print(ans_1, ans_2)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inpuS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines  

from itertools import permutations

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
P = list(permutations(XY))
ans = 0
count = 0
for p in P:
  for i in range(1,len(p)):
    dist = ((p[i-1][0]-p[i][0])**2 + (p[i-1][1]-p[i][1])**2)
    ans += dist**0.5
print(ans/len(P))
# Judge status: Accepted
#D
N, K = map(int, input().split())
count=0
for i in range(K,N+2):
    min_a=(i-1)*i/2
    max_a=(N+(N-i+1))*i/2
    count+=max_a-min_a+1
print(int(count)%(10**9+7))
# Judge status: Wrong Answer
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

g = [set() for _ in range(N)]
for a, b in AB:
    a, b = a-1, b-1
    g[b].add(a)
    g[a].add(b)

mark = [-1]*N
mark[0] = 0
q = [0]
while q:
    t = q.pop()

    for c in g[t]:
        if mark[c] == -1:
            mark[c] = t
            q.append(c)

print("Yes")
for m in mark[1:]:
    print(m+1)
# Judge status: Wrong Answer
from collections import Counter
n=int(input())
sc=Counter(list(map(int,input().split())))
sm=0
for k,v in sc.items():
  sm+=min(v,(k-v if v-k>=0 else 10**9+1)) 
print(sm)
# Judge status: Wrong Answer
import sys
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def gcd_list(ln):
    tmp = gcd(ln[0], ln[1])
    for x in ln[2:]:
        tmp = gcd(tmp, x)
    return tmp

n = int(input())
a = list(map(int, sys.stdin.readline().split()))
if n == 2:
    print(max(a))
else:
    ans = 0
    for i in range(min(n, 4)):
        tmp = gcd_list(a[:i] + a[i+1:])
        if tmp > ans:
            ans = tmp
    print(ans)