peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,m=map(int,input().split())
l_n=[list(map(int,input().split())) for _ in range(n)]
l_m=[list(map(int,input().split())) for _ in range(m)]
# print(l_n,l_m)


for i,j in l_n:
    distance=0
    cnt = 0
    ans = float ( "inf" )
    for k,l in enumerate(l_m,1):
        a,b=l
        distance=abs(i-a)+abs(j-b)
        if ans>distance:
            ans=min(ans,distance)
            cnt=k
    print(cnt)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

B = [0]*N
for i in range(N-1):
    B[A[i]-1] += 1

for i in range(N):
    print(B[i])
# Judge status: Accepted
n,m,x = map(int, input().split())
C = []
A = []
ans = 10**9
for i in range(n):
  AC = list(map(int,input().split()))
  C.append(AC.pop(0))
  A.append(AC)

for i in range(2**n):
  cost = 0
  crit = [0]*m
  for j in range(n):
    if (i>>j)& 1:#use
      for k in range(m):
        crit[k] += A[j][k]
      cost += C[j]
  if min(crit) >= x:
    ans = min(ans, cost)
  #print(crit, cost)
if ans == 10**9:
  ans = -1
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	x=II()
	q,r=divmod(x,11)
	ans=0
	if r==0:
		ans-=1


	ans+=2*q+1+(r>6)

	print(ans)


if __name__ == "__main__":
	main()
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = map(int, readline().split())

    ans = a - 1

    if a <= b:
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
x, y, r, g, c = map(int, input().split())
r_d = list(map(int, input().split()))
g_d = list(map(int, input().split()))
c_d = list(map(int, input().split()))
r_d.sort(reverse=True)
g_d.sort(reverse=True)
c_d.sort(reverse=True)
a = r_d[:x]+g_d[:y]+c_d
a.sort(reverse=True)
print(sum(a[:x+y]))
# Judge status: Accepted
x = int(input())
for i in range(-120, 121):
    for j in range(-120, 120):
        if i ** 5 - j ** 5 == x:
            print(f'{i} {j}')
            break
    else:
        continue
    break
# Judge status: Wrong Answer
a,b=map(int,input().split())
c=max(a,b)
print(c+(c-1))
# Judge status: Accepted
S = list(input())
S = list(map(lambda x: int(x),S))
ans = 0

for i in range(len(S) - 1,0,-1):
  
  if S[i] == 9:
    tmp = sum(S)
  else:
    S[i] = 9
    S[i - 1] -= 1
    tmp = sum(S)
  
  ans = max(tmp,ans)

if len(S) == 1:
  ans = S[0]

print(ans)
# Judge status: Accepted
x,y=map(int,input().split())
if y%2!=0:
    print('No')
elif (y-2*x)//2 < 0 or (4*x-y)//2 < 0:
    print('No')
elif (y-2*x)//2 == 0 and (4*x-y)//2==0:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
n, m, k = map(int, input().split())
for i in range(n+1):
    for j in range(m+1):
        if (i*m + j*n - 2*i*j) == k:
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
from sys import stdin
import string
from itertools import groupby

n = int(stdin.readline().rstrip())
s = list(stdin.readline().rstrip())
s.sort()
lin = []
for key, value in groupby(s):
    lin.append(len(list(value)))
point = 1
for i in lin:
    point *= i+1
    point %= 10**9+7
print(point-1)
# Judge status: Accepted
N = input()
temp = 0
for i in N:
    temp += int(i)


if temp % 9 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
a,b = map(int,input().split())
maxi = math.ceil(a/b)
minu = math.floor(a/b)
print(maxi - minu)
# Judge status: Accepted
S = str(input())

if S[0] != S[1] and S[0] != S[2] and S[1] != S[2]:
    result = 'Yes'
else:
    result = 'No'

print(result)
# Judge status: Accepted
D = int(input())
cs = list(map(int, input().split()))
#s = [input().split() for l in range(D)]
S=0
for d in range(D):
    s=list(map(int, input().split()))
    max_value = max(s)
    max_index = s.index(max_value)
    print(max_index+1)
    S+=max_value
# Judge status: Accepted
k,x = map(int,input().split())

if k * 500 >= x :
  print('Yes')
else :
  print('No')
# Judge status: Wrong Answer
import numpy as np
N = int(input())
A = np.array([list(map(int, input().split())) for _ in range(2)])

U = A[0][::-1]
cumsum_U = U[:-1].cumsum()[::-1]
D = A[1][::-1]
cumsum_D = D[1:].cumsum()[::-1]
# print('cumsum_U', cumsum_U)
# print('cumsum_D', cumsum_D)

b = cumsum_U >= cumsum_D
# print('b', b)

ans = 0
for i in range(N - 1):
    if b[i]:
        ans += A[0][i + 1]
    else:
        ans += (A[1][i:-1]).sum()
ans += A[0][0] + A[1][-1]
print(ans)
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
cnt = Counter(map(int, input().split()))

L = sum([[] for a, c in cnt.items()], [])
L.sort()

ans = 0 if len(L) < 2 else L[-1] * L[-2]
print(ans)
# Judge status: Accepted
a, b, c = sorted([i for i in input().split()], reverse=True)
print(int(a + b) + int(c))
# Judge status: Wrong Answer
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
a_list = []
for i in range(N):
    a_list.append(A-(T-H[i]*0.006))
print(a_list.index(min(a_list))+1)
# Judge status: Accepted
a = int(input().replace(" ",""))
c=0
for i in range(10**4):
    if i**2 <= a:c=i**2
    else:break
print("Yes" if c == a else "No")
# Judge status: Wrong Answer
N = int(input())

W = [0]*(N+1)
W[1] = 1

for i in range(1, N+1):
    W[i] += W[i-1]
    if W[i] >= N:
        for j in range(1, i+1):
            if j != (W[i] - N):
                print(j)
            break
# Judge status: Accepted
n = int(input())
m = [i for i in range(1,n)]
p = list(map(int,input().split()))
cnt = 0
for i in m:
    if p[i-1] == i:
        p[i-1] = p[i]
        p[i] = i
        cnt += 1

if p[-1] == n:
    cnt += 1
print(cnt)
# Judge status: Wrong Answer
# coding: utf-8
S=list(input())
if len(S)==len(set(S)):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
al = list(int(input()) for _ in range(n))
al_s = sorted(list(set(al)), reverse=True)

if al.count(al_s[0]) == 1:
    for a in al:
        if a != al_s[0]:
            print(al_s[0])
        else:
            print(al_s[1])
else:
    for i in range(n):
        print(al_s[0])
# Judge status: Wrong Answer
S = list(input())

a = 0
ans = 0
for s in S:
  if s == '<':
    a += 1
  elif s == '>':
    a = max(a-1,0)
    
  ans += a
  
print(ans)
# Judge status: Accepted
"""
kari1 = '01B0' #00
kari1 = '0BB1' #1
in1 = kari1
"""
in1 = input()

RC = ''
for idx1 in range(len(in1)):
    if in1[idx1] == '0':
        RC = RC + '0'
    elif in1[idx1] == '1':
        RC = RC + '1'
    elif in1[idx1] == 'B':
        if RC != '':
            RC = RC[0:len(RC) - 1]

print(RC)
# Judge status: Accepted
abk = [int(i) for i in input().split()]
a = abk[0]
b = abk[1]
k = abk[2]

anss = []
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    anss.append(i)
    
anss.sort(reverse=True)
print(anss[k-1])
# Judge status: Accepted
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
a_counter = Counter(a)

ans = 0

if N == 1 and a[0] != 1:
    print(1)
    exit()
elif N == 1 and a[0] == 1:
    print(0)
    exit()


for i in (a_counter.items()):
    key = (i[0])
    value = (i[1])

    if key == value:
        pass
    
    elif key < value:
        ans = ans + (value - key)
    else:
        ans = ans + (value) 

print(ans)
# Judge status: Accepted
N=int(input())
L=list(map(int,input().split()))
count=0
sum=0
A=float("inf")
for i in L:
	sum+=abs(i)
	A=min(A,abs(i))
	if i<0:
		count+=1
if count%2==0:
	print(sum)
else:
	B=float("inf")
	for i in L:
		if abs(i)==A:
			if i==0:
				print(sum)
				exit()
			elif i>0:
				print(sum-2*i)
				exit()
			elif i<0:
				print(sum-2*A)
				exit()
# Judge status: Wrong Answer
a = input()
a=a.replace("0B","").replace("1B","")
if  "B" in a:
    a=a.replace("0B","").replace("1B","").replace("B","")
    print(a)
else:
    print(a)
# Judge status: Wrong Answer
n,d = map(int,input().split())

print(-(-(n-d)/(d+1)))
# Judge status: Wrong Answer
N = int(input())
W = []
for i in range(N):
    W.append(input())
flag = True
for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        flag = False
        break
    for j in range(i+1):
        if W[i] == W[j]:
            flag = False
            break
print("Yes") if flag else print("No")
# Judge status: Accepted
A, B = map(int, input().split(' '))
print((B + A - 3) // (A - 1))
# Judge status: Wrong Answer
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
t = []
for lis in s:
  max_idx = np.argmax(lis)
  t.append(max_idx)
t = np.array(t)

score = 0
li = np.zeros(26)
li_one = np.ones(26)
c_sum = sum(c)
d = 0
for i in t:
  li += li_one
  li[i] = 0
  tmp = sum(c*li)
  score += s[d][i] - tmp
  print(int(score))
  d += 1
# Judge status: Accepted
i1=lambda : input()
i2=lambda : int(input())
i3=lambda : map(int,input().split())
i4=lambda n : [list(map(int,input().split()) for _ in range(n))]

X=i2()
print(1 if X==0 else 0)
# Judge status: Accepted
a,b,n=map(int,input().split())
i=b-1
ans=(min(n,b-1)*a)//b;
while(i<=n):
    if((i*a)//b-a*(i//b)<=ans):
        break;
    ans=max(ans,(i*a)//b-a*(i//b));
    print(ans+"\n")
    i+=b;
print(ans);
# Judge status: Accepted
n=int(input())
a=set(map(int,input().split()))
if n==len(a):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
s = input()
n = int(s)

m = str(int(s[0]) - 1) + (len(s) - 1) * "9" 
ans1 = 0
for i in range(len(m)):
    ans1 += int(m[i])

if s[-1] != "9" and n >= 10:
    n1 = n - (int(s[-1]) + 1)
    s = str(n1)

ans2 = 0
for i in range(len(s)):
    ans2 += int(s[i])

print(max(ans1, ans2))
# Judge status: Wrong Answer
d,n = map(int, raw_input().split())
print (n + (1 if n == 100 else 0)) * (100 ** d)
# Judge status: Accepted
N, M = map(int,input().split())
py = []
for i in range(M):
  py.append(list(map(int,input().split())))
  py[i].append(i)
sorted_py = sorted(py, key=lambda x: x[1])
P = [0]*N
p_num = 0
num = 0
output = ''
output2 = []
outputs = []
for i in range(M):
  P[sorted_py[i][0]-1] += 1
  p_num = sorted_py[i][0]
  num = P[sorted_py[i][0]-1]
  output = str(p_num).zfill(6) + str(num).zfill(6)
  output2 = [output, sorted_py[i][2]]
  outputs.append(output2)
sorted_outputs = sorted(outputs, key=lambda x: x[1])
for out in sorted_outputs:
  print(out[0])
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
f2=lambda x:x%2==0 and x%4!=0
f4=lambda x:x%4==0
c2,c4=0,0
for i in a:
    c2+=f2(i)
    c4+=f4(i)
print('Yes' if c2+c4*2>=n or (c2==0 and c4*2+1>=n)else 'No')
# Judge status: Wrong Answer
l=[]
for _ in range(5):
    l.append(int(input()))
k = int(input())
print('Yay' if l[-1] - l[0]<=k else ':(')
# Judge status: Wrong Answer
a, b = [int(i) for i in input().split()]

if(a > b):
#    for j in range (a):
    print(str(b)*a)

if(a < b):
    #for k in range (b):
    print(str(a)*b)
# Judge status: Accepted
x, y, z = map(int, input().split())

ans = 0
x -= z
while x >= y + z:
    ans += 1
    x -= y + z

print(ans)
# Judge status: Wrong Answer
N=int(input())
S= list(input())
W_count=S.count('W')
R_count=S.count('R')
if((W_count==0) or (R_count==0)):
    print(0)
else:
    if(len(S)%2==0):
        print(min(W_count,R_count-S[:len(S)//2].count('R')))
    else:
        print(min(W_count,R_count-S[:len(S)//2+1].count('R')))
# Judge status: Wrong Answer
n,k = map(int,input().split())
e = list(map(int,input().split()))
c = -1
for i in range(k-1,n):
    b = e[i]+e[i-1]+e[i]
    if i> k-1 and b>c:
        print('Yes')
    elif i > k-1:
        print('No')
    c = b
# Judge status: Accepted
a, b = map(int, input().split())

print(a*b)
# Judge status: Accepted
K = int(input())
a = K//2
b = (K+1)//2
print(a*b)
# Judge status: Accepted
import numpy as np
from scipy import sparse

n, m = map(int, input().split())
ab = np.array([list(map(int, input().split())) for _ in range(m)])

g = sparse.csr_matrix(([1]*m, (ab[:, 0]-1, ab[:, 1]-1)), shape=(n, n))
_bfo, predecessors = sparse.csgraph.breadth_first_order(g, 0, directed=False)
if all(predecessors[1:] >= 0):
    print('Yes')
    for p in predecessors[1:]:
        print(p+1)
else:
    print('No')
# Judge status: Wrong Answer
n, m = map(int, input().split())
x = sorted(set(list(map(int, input().split()))))

d = []
if n<m:
    for i in range(m-1):
        d.append(x[i+1] - x[i])
    print(sum(sorted(d)[:-(n-1)]))
else:
    print(1)
# Judge status: Wrong Answer
n = int(input())
l = [list(map(int, input().split())) for _ in range(n-1)]

ans = [0]*n
for i in range(n):
    time = 0
    for j in range(i, n-1):
        if l[j][1] - time > 0:
            time += l[j][1] - time
        time += time % l[j][2] + l[j][0]
    ans[i] += time

print(ans)
# Judge status: Wrong Answer
a,b = map(int, raw_input().split())
og = b - a - 1
print og * (og + 1) - a
# Judge status: Wrong Answer
import math
n, m = map(int, input().split())
div = 10**9 + 7

if abs(n-m)>1:
    print(0)
    exit()
elif n == m:
    ans1 = math.factorial(n)
    ans = 2 * ans1 * ans1 
else:
    ma = max(n,m)
    mi = max(n,m)
    ans1 = math.factorial(mi)
    ans = ans1*ans1*ma

print(ans % div)
# Judge status: Wrong Answer
N = int(input())

ans = 0
C = [ [0 for i in range(10)] for i in range(10)]

for i in range(1,N):
  first_num = int(str(i)[0])
  last_num = int(str(i)[-1])
  C[first_num][last_num] += 1

for first_num in range(1,10):
  for last_num in range(1,10):
    ans += C[first_num][last_num] * C[last_num][first_num]

print(ans)
# Judge status: Wrong Answer
a=int(input())
if a <= 30:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI',  'SAT', 'SUN']
y = x.index(input())
if (y == 0):
      print(7)
else:
      print(min(abs(7-y),abs(y)))
# Judge status: Wrong Answer
N = int(input())
i = 0
C0 = 0
C1 = 0
C2 = 0
C3 = 0
while (i < N):
  i += 1
  S = input()
  if(S == 'AC'):
    C0 += 1
  elif(S == 'WA'):
    C1 += 1
  elif(S == 'TLE'):
    C2 += 1
  else:
    C3 += 1

print("AC × " +  str(C0))
print("WA × " +  str(C1))
print("TLE × " +  str(C2))
print("RE × " +  str(C3))
# Judge status: Accepted
a=int(input())
s=input()

if a>=3200:
    print(s)
else:
    print("red")
# Judge status: Accepted
def get_ints():
  return list(map(int,input().split()))

n = int(input())
a,b = [],[]
for i in range(n):
  x,y = get_ints()
  a.append(x+y)
  b.append(x-y)

a.sort()
b.sort()
ans = max(a[-1]-a[0], b[-1]-b[0])
print(ans)
# Judge status: Accepted
import math
N, D = map(int, input().split())
print(math.ceil(N/(D * 2 + 1)))
# Judge status: Accepted
N = int(input())
A = [i for i in str(N)]
result = 0
for j in range(len(A)):
  result += int(A[j])
if result == 1 and A[0] == "1":
  print(10)
else:
  print(result)
# Judge status: Accepted
n,k=map(int,input().split())
s=input()
c=1
for i in range(n-1):
 if s[i]!=s[i+1]:c+=1
print(n-c+min(c-1,k*2))
# Judge status: Accepted
nums = [int(input()) for _ in range(5)]
mods = [(10 - num % 10 if num % 10 != 0 else 0) for num in nums]
last = max(mods)
print(sum(nums) + sum(mods) - last)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    x = input().strip()
    tc = 0
    sc = 0
    for c in x[::-1]:
        if c == 'S':
            sc += 1
        else:
            break
    for c in x:
        if c == 'T':
            tc += 1
        else:
            break
    print(max(sc, tc) * 2)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n,a,b = [int(x) for x in input().split()]

ans = 0
for x in range(n+1):
    amount = sum([int(i) for i in list(str(x))])
    if amount >= a and amount <= b:
        ans += x

print(ans)
# Judge status: Accepted
a,b,c=sorted(list(map(int,input().split())))
if (a==b and b!=c)or(a!=b and b==c):print("Yes")
else:print("No")
# Judge status: Wrong Answer
import math
X = int(input())
print(math.floor(X**0.5)**2)
# Judge status: Wrong Answer
N = int(input())
W = [input() for _ in range(N)]
Ws =[]
ans = 'Yes'

for i in range(N):
    Ws.append(W[i])
    for j in range(1,N+1):
        if W[i][-1] == W[j][0]:
            break
        else:
            ans = 'No'
            break
        
#print(Ws)

if len(set(W)) != len(Ws):
    ans = 'No'
print(ans)
# Judge status: Accepted
W, H, x, y = map(int, input().split())
menseki = (W*H)/2
if (x == W/2) & (y == H/2):
	print(str(menseki) + " 1")
else:
	print(str(menseki) + " 0")
# Judge status: Accepted
x,y=map(int, input().split()) #a1 a2 a3

ans=x
i=0
while ans<=y:
  ans*=2
  i+=1

print(i)
# Judge status: Accepted
n = int(input())
m = int(n**0.5)
c = float("inf")
for i in range(m, 0, -1):
  if n%i == 0:
    print(n//i + i - 2)
    exit()
# Judge status: Wrong Answer
a=input()
a=list(map(int,input().split()))
count=0
for itr in range(len(a)):
    if itr==a[itr]: count+=1
print(count-1)
# Judge status: Accepted
k, a, b = map(int, input().split())
if b-a<=2 or a>=k:
    print(k+1)
else:
    print((b-a)*((k-a+1)//2)+(k-a+1)%2+a)
# Judge status: Wrong Answer
A = list(map(int, input().split()))
if sum(A) >= 22:
  print("win")
else:
  print("bust")
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    if n == 1:
        ans = 0
    else:
        mod = pow(10, 9)+7
        ans = pow(10, n, mod) + pow(8, n, mod) - 2*pow(9, n, mod)
    print(ans)


    
if __name__ == "__main__":
    main()
# Judge status: Accepted
S = input()

if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")
# Judge status: Accepted
a,b,c = map(int, input().split())
if b-a == c-b:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
x = list(map(int, input().split()))
n = len(x)
for i in range(n):
    if x[i] == 0:
        print(i+1)
        exit()
# Judge status: Wrong Answer
a,b,c, = map(int,input().split())
if a<b:
    if c<b:
        print("Yes")
    elif c>b:
        print("No")
else:
    if b<c:
        print("Yes")
    elif b>c:
        print("No")
# Judge status: Accepted
N = int(input())
V = sorted(list(map(int, input().split())), reverse=True)

for _ in range(N-1):
    x = V.pop()
    y = V.pop()
    V.append((x + y) / 2)
    V.sort(reverse=True)
print(*V)
# Judge status: Accepted
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
s=input()

x=0
ans=0
for i in s:
  if i=='I':
    x+=1
  else:
    x-=1
  ans=max(ans,x)

print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
k = int(input())

while True:
    if b > a:
        break
    b *= 2
    k -= 1

while True:
    if c > b:
        break
    c *= 2
    k -= 1

if k < 0:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
import math
from functools import reduce
def gcd(*number):
    return reduce(math.gcd, number)
n = int(input())
a, b, c = 1, 1, 1
sum = 0
list_number = []
while True:
    print(a,b,c)
    list_number.append(gcd(a, b, c))
    if n > c:
        c += 1
    elif n == c and n == b and n == a:
        break
    elif n == c and n == b:
        a += 1
        b = 1
        c = 1
    elif n == c:
        b += 1
        c = 1
print(list_number)
for i in list_number:
    sum = sum + i
print(sum)
# Judge status: Wrong Answer
n = int(input())
h = list(map(int, input().split()))
ans = 0

s = 0
c = h[0]
for i in h[1:]:
    if c >= i:
        s += 1
    else:
        s = 0
    c = i
ans = max(ans, s)
print(ans)
# Judge status: Wrong Answer
import collections
S = list(input())
T = list(input())

cntS = collections.Counter(S)
cntT = collections.Counter(T)

if len(cntS) != len(cntT):
    print('No')
    exit()
else:
    valS = cntS.most_common()[::-1]
    valT = cntT.most_common()[::-1]

    for i in range(len(valS)):
        if valS[i][1] != valS[i][1]:
            print('No')
            exit()

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

arc_list = list()
abc_list = list()

harf_num = int(n/2)

d.sort()
abc_list = d[:harf_num]
arc_list = d[harf_num:]

abc_max = max(abc_list)
arc_min = min(arc_list)

print(abc_max - arc_min)
# Judge status: Wrong Answer
import collections

S = input()
c = collections.Counter(S)
c.values()
print(2 * min(c.values()))
# Judge status: Accepted
n = int(input())
s = input()
cnt = s.count(".")
ans = cnt

for c in s:
    if c == "#":
        cnt += 1
    else:
        cnt -= 1
    ans = min(ans, cnt)

print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

prev = 1
crash = 0

if not 1 in a:
  print("-1")
else:
  for i in range(N):
    if a[i] == prev:
      prev += 1
    else:
      crash += 1
  else:
    print(crash)
# Judge status: Accepted
# A - AtCoder *** Contest
a,s,b=list(input().split())
print('A'+s[0]+'C')
# Judge status: Accepted
X = int(input())
coin_500 = X//500
coin_5 = (X%500)//5
print(coin_500*1000 + coin_5*5)
# Judge status: Accepted
import collections
n, k = map(int, input().split())
list = input().split()
c_list = collections.Counter(list)
sorted_c_list = sorted(c_list.values(),reverse=True)
print(sum(sorted_c_list[k:]))
# Judge status: Wrong Answer
X=int(input())
initial=400
kyu=8
for add in range(1,9):
  if X<initial+add*200:
    print(kyu)
    break
    kyu-=1
# Judge status: Accepted
from collections import Counter
s = input()
c = Counter(s)

if len(c) == 4:
    print('Yes')
elif len(c) == 3:
    print('No')
elif len(c) == 1:
    print('No')
elif len(c) == 2:
    if c['N'] > 0 and c['S'] > 0:
        print('Yes')
    elif c['W'] > 0 and c['E'] > 9:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
n,k=map(int,input().split())
_=list(map(int,input().split()))
print((n-1+k-2)//(k-1))
# Judge status: Accepted
from fractions import gcd
from functools import reduce
n, x, *X = map(int, open(0).read().split())
X = sorted(X + [x])

Y = [x1-x0 for x0, x1 in zip(X, X[1:])]
print(reduce(gcd, Y))
# Judge status: Accepted
x = input()

s = list()
cnt = 0
for c in x:
    if c == "S":
        s.append(c)
    elif c == "T" and len(s) != 0:
        s.pop()
        cnt += 1

print(len(x)-cnt*2)
# Judge status: Wrong Answer
s=input()
t=input()
l=[]
import sys
if len(t)>len(s) or (len(t)==len(s) and t!=s):
  import sys
  print("UNRESTORABLE")
  exit()
  
for i in range(len(s)-len(t)+1):
  z=s[:i]
  for j in range(i,i+len(t)):
    if s[j]!=t[j-i] and s[j]!="?":
      break
    else:
      z+=t[j-i]
  else:
    z+=s[i+len(t):]
    l.append(z.replace("?","a"))
l.sort()
print(l[0] if len(l) else "UNRESTORABLE")
# Judge status: Accepted
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A>B:
  D=A-B
else:
  D=B-A
if V<=W:
  print("NO")
elif (V-W)*T>=D:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
i = 10**9
s = 0
z = 0
c = 0
for b in a:
  if b < 0:
    s += 1
  elif b == 0:
    z += 1
    break
  if abs(b) < i:
    i = abs(b)
  c += abs(b)
if z > 0 or s%2 == 0:
  print(c)
else:
  print(c-2*i)
# Judge status: Wrong Answer
s = input().split()
ans = "NO" if s[0] == s[1] == s[2] else "YES"
print(ans)
# Judge status: Accepted
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

num = len(a)//3
ans = sum([a[2*x+1] for x in range(num)])
print(ans)
# Judge status: Accepted
n = input()
  
ans = 'No'
  
for i in n:
    if i == '7':
        ans = 'Yes'
        break

print(ans)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
l.sort()
if sum(l[0:-1]) > l[-1]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a = input()
counter = 0
s_length = len(a)

for i in range(s_length - 2):
    current_mod = int(a[i:i+4])%2019
    for j in range(i+4, s_length ):



        if  current_mod%2019 == 0:
            counter += 1

        print(current_mod)
        current_mod= (current_mod * 10 + int(a[j]))%2019

print(counter+1)
# Judge status: Accepted
#!/usr/bin/env python3
x, y = map(int, input().split())
for i in range(x+1):
    if 2*i+4*(x-i) == y:
        print("Yes")
        quit()
print('No')