peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
if n == 3:
    l = range(100, 1000)
if n == 2:
    l = range(10, 100)
if n == 1:
    l = range(0, 10)
flag = False
for i in l:
    num = str(i)
    if all([num[s-1] == str(c) for s, c in sc]):
        #print(num)
        #exit()
        flag = True
        ans = num
        break
if flag:
    print(num)
else:
    print(-1)
# Judge status: Wrong Answer
a, b, t = map(int, input().split())

turn = (t + 0.5) // a
count = b * turn

print(count)
# Judge status: Accepted
def inpl():
    return list(map(int, input().split()))


S = input()

if len(S) % 2 == 1:
    print("No")
    exit()

for i in range(0, len(S), 2):
    if S[i:i + 2] != "hi":
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
N = int(input())
A = N*(N+1)/2-N
print(int(A))
# Judge status: Wrong Answer
N = int(input())
A=list(map(int, input().split()))

if A[1]-A[0]+1>=N:
    print("OK")
else:
    print("NG")
# Judge status: Accepted
k,x = map(int,input().split())
k -= 1
start = x - k
end = x + k + 1
ans = list(range(start,end))
print(*ans)
# Judge status: Accepted
S, T = input().split()
print(T + S)
# Judge status: Wrong Answer
def marks():
    N, K = map(int, input().split())
    A = list(map(int,input().split()))
    std = 1
    for i in range(K):
        std *= A[i]
    lis = [std]
    for i in range(N - K):
        a = (lis[i] / A[i]) * A[K+i]
        if std < a:
            print("Yes")
        else:
            print("No")
        lis.append(a)
        
marks()
# Judge status: Accepted
a = int(input())
b = int(input())
x = int(input())

counter = 0
output = 0

while True:
    if counter >= x:
        break
    if a > b:
        counter += a
        output += 1
    else:
        counter += b
        output += 1

print(output)
# Judge status: Accepted
# coding: utf-8
# Your code here!
# coding: utf-8

def main():
    date = list(input().split('/'))
    
    if date[0] != '2018':
        date[0] = '2018'
        
    
    mojiretu = '/'.join(date)
    print(mojiretu)
    return 0


if __name__ == '__main__':
    main()
# Judge status: Accepted
n, k, s = map(int,input().split())
if s == 10**9:
    ans = [1 for i in range(n)]
    for i in range(k):
        ans[i] = 10**9
else:
    ans = [10**9 for i in range(n)]
    for i in range(k):
        ans[i] = s

print(" ".join(map(str,ans)))
# Judge status: Accepted
a, b, c = map(int, input().split())
if a == b and b == c:
  print("No")
elif a == b:
  print("Yes")
elif b == c:
  print("Yes")
elif a == c:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from heapq import heappush,heappop

n,m=[int(x) for x in input().rstrip().split()]
ab=[[] for i in range(10**5)]

for i in range(n):
  a,b=[int(x) for x in input().rstrip().split()]
  if a<=m:
    ab[m-a].append(-b)

ans=0
l=[]
for i in range(m-1,-1,-1):
  for b in ab[i]:
    heappush(l,b)

  if l:
    ans-=heappop(l)

print(ans)
# Judge status: Accepted
import heapq
N, M = map(int, input().split())
w = [[] for i in range(M)]
for i in range(N):
    a, b = map(int, input().split())
    try:
        w[a-1].append(-b)
    except:
        pass
ans = 0
a = []
heapq.heapify(a)
for i in range(M):
    for x in w[i]:
        heapq.heappush(a, x)
    try:
        ans += -heapq.heappop(a)
    except:
        pass
print(ans)
# Judge status: Wrong Answer
import sys
s = input()

l = len(s)
if s[0] != "A":
    print("WA")
    sys.exit()
ss =  s[2:l-1]
if ss.count("C") != 1:
    print("WA")
    sys.exit()

cidx = ss.find("C")+2
sss = s[1:cidx]+s[cidx+1:-1]

if sss.islower():
    print("AC")
    sys.exit()

print("WA")
# Judge status: Wrong Answer
n=int(input())
a=[int(x) for x in input().split()]
mx=max(a)
rem=sum(a)-mx
if mx > rem:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
s = input()
r = len(list(filter(lambda c: c == 'R', s)))
g = len(list(filter(lambda c: c == 'G', s)))
b = len(list(filter(lambda c: c == 'B', s)))
ans = r * g * b - sum([sum([1 for j in range(i + 1, (n + i + 1) // 2) if s[i] != s[j] and s[j] != s[(k := 2 * j - i)] and s[k] != s[i]]) for i in range(n)])
print(ans)
# Judge status: Wrong Answer
import math
s = int(input().replace(' ',''))
t = math.sqrt(s)
t = math.floor(t)
t = int(t)
if s**2 ==t:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
	#N = int(input())
	#S = input().rstrip()
	Q,H,S,D = map(int,input().split())
	N = int(input())
	
	H = min(H, 2*Q)
	S = min(S, 2*H)
	D = min(D, 2*S)
	res = D*(N//2) + S*(N%2)
	
	print(res)
	
main()
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))
ans = []
for i in l:
  ans.append(i)
  ans = ans[::-1]
print(ans)
# Judge status: Accepted
from math import ceil
n, m = map(int, input().split())
a = ceil(n / (2 * m + 1))
print(a)
# Judge status: Wrong Answer
import numpy as np
original = 1 * 1 * np.pi
N = int(input())
area = N * N * np.pi
ratio = int(area / original)
print(ratio)
# Judge status: Wrong Answer
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, A = readline().decode('utf8').split()
S = int(N + A)

print('Yes' if S == S ** .5 * S ** .5 else 'No')
# Judge status: Accepted
n = int(input())
s= list(input())
ans = 'Yes'

if n%2==1:
	ans = 'No'
else:
	for i in range(n//2):
		if s[i]!=s[n//2+i]:
			ans = 'No'
print(ans)
# Judge status: Accepted
n, k = list(map(int, input().split(' ')))
r, s, p = list(map(int, input().split(' ')))
d = dict(r=p,
         s=r,
         p=s)
ttt = input()
ans = 0
prevs = []
for i in range(n):
    if i < k or ttt[i] != prevs[i-k]:
        ans += d[ttt[i]]
        prevs.append(ttt[i])
    else:
        prevs.append('hoge')
print(ans)
# Judge status: Accepted
n = int(input())

waru = int(n**0.5)
while True:
    if n%waru == 0:
        a = waru
        b = n//waru
        break
    else:
        waru -= 1
print(a+b-2)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int, input().split()))
k=len(a)
for i in range(k):
  del a[i]
  ans=0
  for j in range(n):
    ac=a.count(j)
    ans+=ac*(ac-1)//2
  print(ans)
  a.insert(k, 'k')
# Judge status: Accepted
c = [list(map(int,input().split())) for _ in range(3)]

for a1 in range(100):
    b1 = c[0][0] -a1
    b2 = c[0][1] -a1
    b3 = c[0][2] -a1

    a2 = c[1][0] -b1
    a3 = c[2][0] -b1

    if (a2+b2)==c[1][1] and (a2+b3)==c[1][2] and (a3+b2)==c[2][1] and (a3+b3)==c[2][2]:
        print("Yes")
        break
else:
    print("No")
# Judge status: Wrong Answer
import itertools
N=int(input())
I=[str(i) for i in range(1,N+1)]
P=''.join(input().split())
Q=''.join(input().split())
li=list(itertools.permutations(I,N))

a=0
b=0
for i in range(len(li)):
    if(''.join(li[i])==P):
        a=i
    elif(''.join(li[i])==Q):
        b=i
print(abs(b-a))
# Judge status: Wrong Answer
from collections import defaultdict
s=list(input())
t=list(input())
change_st=defaultdict(int)
change_ts=defaultdict(int)
for i in range(len(s)):
    if change_st[s[i]]==0:
        change_st[s[i]]=t[i]
    else:
        if change_st[s[i]]!=t[i]:
            print("No")
            break
    if change_ts[t[i]]==0:
        change_ts[t[i]]==0
    else:
        if change_ts[t[i]]!=s[i]:
            pritn("No")
            break
else:
    print("Yes")
# Judge status: Wrong Answer
n=int(input())
a=0
for i in range(n):
  if i**2>=n:
    break
  else:
    a=i
print(a)
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))

route = [1]
current_town = 1
loop = False
while not loop:
    current_town = A[current_town-1]
    if current_town in route:
        route.append(current_town)
        loop = True
    else:
        route.append(current_town)  
        
start_index = route.index(route[-1])
loop_cnt = len(route) - (start_index+1)
K -= route.index(route[-1])
add_num = K % loop_cnt

print(route[start_index+add_num])
# Judge status: Wrong Answer
N,M=map(int, input().split())
a=[[int(j) for j in input().split()] for i in range(M)]

ans = a[0][1]-a[-1][0]+1

print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    dp = [10**4]*N
    dp[0] = 0

    for i in range(N):
        for j in range(1, min(K+1, N-i)):
            dp[i+j] = min(dp[i+j], abs(H[i+j] - H[i]) + dp[i])

    print(dp.pop())

main()
# Judge status: Accepted
a, b = map(int,input().split())

if 500*a >= b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
#abc077 b
import math 
n=int(input())
m=int(math.sqrt(n))
print(m*m)
# Judge status: Accepted
N = int(input())

P = 1

for i in range(2,N+1):
    P = P*i
    P = P % (10 ** 9 + 7)

print(P)
# Judge status: Wrong Answer
import numpy as np
import sys

input = sys.stdin.readline

a,b = input().split()

c = int(a+b)

for i in range(1,1000):
    if c/i == i:
        print(i)
        print("Yes")
        exit()

print("No")
# Judge status: Accepted


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    c=input()
    L=["a","i","u","e","o"]
    f=0
    for i in range(5):
        if c==L[i]:
            f=1
            
    if f==1:
        print("vowel")
    else:
        print("consonant")

main()
# Judge status: Wrong Answer
A, B = map(float, input().split())

A = int(A)
B = int(B*100)

x = A*B/100

ans = int(x)

print(ans)
# Judge status: Accepted
N = int(input())
s = list()

for a in range(1, N+1):
    S, P = input().split()
    P = int(P)
    s.append([S, P, a])

s = sorted(s, key=lambda x: (x[0], -x[1]))  # 複数のキーでソートしたい時　昇順と降順を混ぜたい時はマイナスつける

for a in range(N):
    print(s[a][2])
# Judge status: Wrong Answer
def main():
    a, b, c, d = map(int, input().split())

    if b <= c:
        ans = 0
    else:
        if b <= d:
            ans = b - c
        else:
            ans = d - c

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline
import math
def main():
    N, D = map(int, input().split())
    X = [list(map(int, input().split())) for i in range(N)]
    DIST, CNT = 0, 0
    for i in range(N-1):
        for j in range(i+1,N):
            for d in range(D):
                DIST += abs(X[i][d] - X[j][d])**2
            if math.sqrt(DIST).is_integer():
                CNT +=1
            DIST = 0
    print(CNT)
    

if __name__ == '__main__':
    main()
# Judge status: Accepted
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
# Judge status: Accepted
N = int(input())

ans = 0
for i in range(1,N):
    ans += N//i
    if N%i == 0:
        ans -= 1

print(ans)
# Judge status: Accepted
S = input()
if int(S[5:7]) <= 4:
  print("Heisei")
else:
  print("TBD")
# Judge status: Wrong Answer
x = int(input())

num = [x ** 5 for x in range(-63, 63)]


for i in range(-63, 63):
    flag = False
    for j in range(-63, 63):
        tmp = i ** 5 - j ** 5
        if tmp == x:
            print('{} {}'.format(i, j))
            flag = True
            break
    if flag:
        break
# Judge status: Wrong Answer
N,P = map(int,input().split())
A = list(map(int,input().split()))

c = [0,0]
for a in A:
    c[a%2] += 1
print(2**(c[0]+c[1]-1))
# Judge status: Wrong Answer
N = int(input())
S = input()

s = list(S)
for i in range(len(S)):
    if ord(s[i]) + N == 90:
        p = 64 + 26
    else:
        p = (ord(s[i]) - 64 + N) % 26 + 64

    s[i] = chr(p)
    

print("".join(s))
# Judge status: Accepted
import sys
N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]
ans = 0
for i in range(1, N):
    ans += (A[i - 1] + A[i]) // 2
    if A[i]:
        A[i] = (A[i - 1] + A[i]) % 2
print(A[0] // 2 if N == 1 else ans)
# Judge status: Wrong Answer
weather = input()

if len(weather) != 3:
    print("0")
if weather in ["RRR"]:
    print("3")
elif weather in ["SRR","RSR","RRS"]:
    print("2")
elif weather in ["SSR","SRS","RSS"]:
    print("1")
else:
    print("0")
# Judge status: Accepted
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
Asort = sorted(A)[:: -1]

L=[0]*N
R=[0]*N
L[0]=A[0]
R[0]=A[N-1]

for n in range(1,N):
  L[n]=gcd(A[n],L[n-1])
  R[n]=gcd(A[N-n-1],R[n-1])
  
  ans=max(L[N-2],R[N-2])

for i in range(1,N-1):
  ans=max(ans,gcd(L[i-1],R[N-i-2]))

print(ans)
# Judge status: Accepted
s1=list(str(input()))
s2=list(str(input()))
a=s2.pop()
if(s1==s2):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())
A = LI()
Q = int(input())
BC = [LI() for _ in range(Q)]

MAX = 10 ** 5


def main():
    d = {i: 0 for i in range(MAX + 1)}
    s = 0
    for a in A:
        d[a] += 1
        s += a
    for b, c in BC:
        x = d[b]
        s += (c - b) * x
        print(s)
        d[c] += d[b]
        d[b] = 0


if __name__ == "__main__":
    main()
# Judge status: Accepted
#C
import itertools
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

l = [i+1 for i in range(N)]
p_list = list(itertools.permutations(l, N))
p_list.sort()
a = p_list.index(P)
b = p_list.index(Q)
 
print(abs(a-b))
#print(p_list)
# Judge status: Wrong Answer
n = int(input())
order = input().split()
a = dict.fromkeys(range(1, n+1, 1))
for i in a:
    a[i] = order[i-1]
print(a)
for key, value in sorted(a.items(), key=lambda item: item[1]):
    print(key, end = '')
    if(value != str(n)):
        print(end = ' ')
# Judge status: Wrong Answer
W, H, N = map(int, input().split())
x = [0, W]
y = [0, H]
a = []

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

for j in a:
  if j[2] == 1:
    x[0] = j[0]
  elif j[2] == 2:
    x[1] = j[0]
  elif j[2] == 3:
    y[0] = j[1]
  else:
    y[1] = j[1]
    
if x[0] >= x[1] or y[0] >= y[1]:
  print('0')
else:
  ans = (x[1] - x[0]) * (y[1] - y[0])
  print(int(ans))
# Judge status: Wrong Answer
N=int(input())
ans=0
for i in range(1,N+1):
  a=N//i
  ans+=(a*(a+1)*i)//2
print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())


if a >= 0 and b >= 0 and c < 0 and d < 0:
  print(min(a, b) * max(c, d))
elif a < 0 and b < 0 and c >= 0 and d >= 0:
  print(min(c, d) * max(a, b))
else:
  print(max(abs(a), abs(b)) * max(abs(c), abs(d)))
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
if(n<=a):
    print(n)
elif(n<=a+b):
    print(a)
else:
    print(n//(a+b)+n%(a+b))
# Judge status: Accepted
import sys
import math
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    n = math.ceil((-1 + math.sqrt(1+8*N))/2)
    jokyo = n*(n+1)//2 - N
    for i in range(1,n+1):
        if i == jokyo:
            continue
        else:
            print(i)
if __name__ == '__main__':
    main()
# Judge status: Accepted
N, A, B = map(int, input().split())

if A > B:
    print(0)
elif N == 1:
    if A == B:
        print(1)
    else:
        print(0)
elif N == 2:
    print(1)
else:
    temp = (N - 2) * (B - A) + 1
    print(temp)
# Judge status: Accepted


import numpy as np

s="".join(sorted(input()))
t="".join(sorted(input(),reverse=True))

if(s<t):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,M = map(int,input().rstrip().split(" "))
A = list(map(int,input().rstrip().split(" ")))
A.sort(reverse = True)
Q = []
for i in range(M):
    B,C = map(int,input().rstrip().split(" "))
    Q.append([C,B])
Q.sort(reverse = True)

p = 0
j = 0
while p < N and j < M:
    for i in range(Q[j][1]):
        if i + p > N:
            break
        A.append(Q[j][0])
    p += Q[j][1]
    j += 1
ans = 0
A.sort(reverse = True)

for i in range(N):
    ans += A[i]

print(ans)
# Judge status: Accepted
A = [int(i) for i in input().split()]
if len(set(A)) == 2:print('Yes')
else:print('No')
# Judge status: Accepted
n=int(input())
a=[int(input())for _ in range(5)]
print(4--n//min(a))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
count = 0

for i in range(1, n-1):
  ans_list = []
  for j in range(n-i):
    ans_list.append(a[j]+a[j+i])
  count += ans_list.count(i)
print(count)
# Judge status: Wrong Answer
a,b = [int(i) for i in input().split()]
if a<=0 and 0<=b:
    print("Zero")
elif a>0:
    print("Positive")
else:
    print("Negative")
# Judge status: Accepted
import math

def plusup(a , b):

    return math.ceil((a + b) / 2)

def main():
    a , b = map(int , input().split())
    print(plusup(a , b))

if __name__ == '__main__':
    main()
# Judge status: Accepted
S = str(input())
K = int(input())

if len(S) == 1:
        print(S[0])
        exit(0)

i = 0
while S[i] == '1' and i <= len(S)-2:
        if K <= i + 1:
                print(S[i])
                exit(0)
        i += 1
print(S[i])
# Judge status: Wrong Answer
s = int(input())

a = s
ar = []
for i in range(1, 100000000):
    if(a % 2 == 0):
        a = a/2
    else:
        a = 3*a + 1
    if(ar.count(a) == 1):
        print(i+1)
        break
    # print(a)
    ar.append(a)
# Judge status: Wrong Answer
import copy
n = int(input())
a = list(map(int,input().split()))

a_2 = set(a)
ans = 0
for i in a_2:
    p = a.count(i)
    ans += int((p * (p-1)) / (2 * 1))
#print(ans)
final = [ans for i in range(n)]
for i in range(n):
    a_2 = copy.copy(a)
    del a_2[i]
    h = a_2.count(a[i])
    final[i] -= int((h-1))
for i in final:
    print(i)
# Judge status: Accepted
n=int(input())
def dfs(s):
    if len(s)==n:print(s)
    else:
        for i in range(97,ord(max(s))+1+1):
            dfs(s+chr(i))
dfs("a")
# Judge status: Wrong Answer
a = [int(input()) for _ in range(5)]
k = int(input())
if k > a[4] - a[0]:
    print("Yay!")
else:
    print(":(")
# Judge status: Wrong Answer
X,N = map(int,input().split())
p = list(map(int, input().split()))
n =max(X,N)

for i in range(n):
  if X-i not in p:
    print(X-i)
    break
  elif X+i not in p:
    print(X+i)
    break
  else:
    continue
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
m=[i for i in range(a,min(a+k,b))]
M=[i for i in range(b,max(b-k,a),-1)]
ans=sorted(set(m)|set(M))
for i in ans:
  print(i)
# Judge status: Accepted
import math
import fractions

A, B = map(int,input().split())
gcd = fractions.gcd(A,B)
N = int(math.ceil(math.sqrt(gcd)))
cd = []

for i in range(1,N):
    if A%i==0 and B%i==0:
        cd.append(i)
        cd.append(gcd//i)
if N==1:
    cd.append(N)

ans=0
cd.sort()


for i in range(len(cd)):
    tr=1
    for j in range(1,i):
        if cd[i]%cd[j]==0:
            tr=0
            break
    if tr==1:
        ans+=1

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

def count(k,i):
    cnt=0
    while k>i:
        i**=2
        cnt+=1
    return cnt

p=0
for i in range(1,n+1):
    p+=((1/2)**(count(k,i)))
print(p/n)
# Judge status: Wrong Answer
n,m=map(int,input().split())
print(n+max(m-2*n,0)//4)
# Judge status: Wrong Answer
n,m = map(int,input().split())
drink=[]
for _ in range(n):
  a,b = map(int,input().split())
  drink.append((a,b))
drink.sort(reverse=1)

ans = 0
while m<0:
  a,b = drink.pop(-1)
  ans += a*min(m, b)
  m -= b
print(ans)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
s = input() + input()
c = Counter(list(s))
l = len(list(filter(lambda x : x > 1, c.values())))

if l == 0:
  print(2*n)
else:
  print(2*n - l)
# Judge status: Accepted
from collections import deque

K = int(input())

d = [-1, 0, 1]

que = deque([])
for i in range(1, 10):
    que.append(i)
cnt = 0
while que:
    p = que.popleft()
    cnt += 1
    if cnt == K:
        print(p)
        break
    for i in d:
        if 0 <= int(str(p)[-1]) + i <= 9:
            que.append(int(str(p) + str(int(str(p)[-1]) + i)))
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
S = input()
a = 0
b = 0
for s in S:
    if s == 'a' and a+b < A+B:
        print('YES')
        a += 1
    elif s == 'b' and a+b < A+B and b < B:
        print('YES')
        b += 1
    else:
        print('NO')
# Judge status: Accepted
N = input()
print('Yes' if '9' in N else 'No')
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
result = 0

if a % x == 0:
    result += 1

result += ((b - a) // x)

print(result)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]+l[j]>l[k] and l[i]!=l[j]!=l[k]:
                ans+=1
print(ans)
# Judge status: Accepted
N=int(input())
S=input()
cnt=0
black=[0]*N
white=[0]*N
for i in range(N):
    if S[i]==".":
        white[i]=1
    else:
        black[i]=1
    if i>=1:
        white[i]+=white[i-1]
        black[i]+=black[i-1]
        
B=black[-1]
W=white[-1]

ans=min(B,W)
for i in range(1,N):
    num=black[i-1]+W-white[i-1]
    ans=min(ans,num)
    
print(ans)
# Judge status: Accepted
import heapq
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
day = {i+1: [] for i in range(M)}
for a, b in ab:
  if a <= M:
    day[a] += [-b]
q = []
heapq.heapify(q)
pay = 0
for i in range(M):
  for b in day[i+1]:
    heapq.heappush(q, b)
  if len(q) > 0:
    pay += -heapq.heappop(q)

print(pay)
# Judge status: Accepted
S=input()
a=int(S[:2])
b=int(S[2:])
if 1<=a<=12 and 1<=b<=12:
    print("AMBIGUOUS")
elif 1<=a<=12 and (b>=13 or b==0):
    print("MMYY")
elif a>=13 and (b>=13 or b==0):
    print("NA")
elif a>=13 and 1<=b<=12:
    print("YYMM")
elif a==0 and (b>=13 or b==0):
    print("NA")
elif a==0 and (1<=b<=12):
    print("YYMM")
# Judge status: Accepted
a, b = map(int, input().split())
x = 2*(max(a,b))-1
y = a+b
print(x if x > y else y)
# Judge status: Accepted
n = int(input())

i=0
while (n-i)**0.5 % 1 != 0:
    i+=1
print(n-i)
# Judge status: Accepted
ab = input().split(' ')
print(min(ab[0]*int(ab[1]), ab[1]*int(ab[0])))
# Judge status: Accepted
def dfs(a='', b=chr(ord('a'))):
	if len(a) == N:
		print(a)
	else:
		i = chr(ord('a'))
		while i < b:
			dfs(a + i, b)
			i = chr(ord(i) + 1)
		dfs(a + b, chr(ord(b) + 1))

N = int(input())
dfs()
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import math


# In[14]:


N = int(input())


# In[15]:


for x in range(1,int(math.sqrt(N)+1))[::-1]:
    if N%x == 0:
        print((x-1)+(N//x-1))
        break


# In[ ]:
# Judge status: Wrong Answer
n,d=map(int,input().split(" "))
c = 0
d *= d
for i in range(n):
  a,b=map(int,input().split(" "))
  if(a**2+b**2==d):
    c+=1
print(c)
# Judge status: Accepted
N = int(input())
cnt = 0
for i in range(1,N+1,2):
    ans=0
    for j in range(1,i+1):
        if i % j == 0:
            ans += 1
        else:
            pass
    if ans == 8:
        cnt += 1
    else:
        pass
print(cnt)
# Judge status: Wrong Answer
#C
n, m = map(int, input().split())
probrem = [0] * n
warn = [0] * n
for i in range(m):
    a, b = map(str, input().split())
    a=int(a)
    if probrem[a - 1] == 0 and b == 'AC':
        probrem[a - 1] = 1
    if probrem[a - 1] == 0 and b == "WA":
        warn[a - 1] += 1
# print(probrem,warn)
print(sum(probrem),sum(warn))
# Judge status: Accepted
def median(array):
    L = len(array)
    if L%2==0:
        return (array[L//2-1]+array[L//2])/2
    else:
        return array[L//2]

N = int(input())
A = []
for i, a in enumerate(map(int, input().split())):
    A.append(a-i)
A.sort()
b = median(A)
res = 0
for a in A:
    res += abs(a-b)
print(round(res))
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())

aoki = c - b
takahasi = a - d

for i in range(100):
  if i % 2 == 0:
    c -= b
    if c <= 0:
      print('Yes')
      exit()
  elif i % 2 == 1:
    a -= d
    if a <= 0:
      print('No')
      exit()
# Judge status: Wrong Answer
from statistics import median

N = int(input())
A = []
B = []

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ans = int(median(B)-median(A))
if N%2==0:
    ans = ans*2
print(ans+1)