peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
S = input()

ans = 0
x = 0

for s in S:
    if s == 'I':
        x += 1
        if ans < x:
            ans = x
    elif s == 'D':
        x -= 1

print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
N = int(input())
if N % 9 == 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
a, b = [], []
for i in range(N):
    c, d = map(int, input().split())
    a.append(c)
    b.append(d)
a.sort()
b.sort()
if N%2 == 1:
    print(b[N//2] - a[N//2] + 1)
else:
    print((b[N//2]+b[N//2-1]) - (a[N//2]+a[N//2-1]) + 1)
# Judge status: Accepted
N = int(input())
s = input()
t = input()

pos = 0
# スタートを一文字ずつずらして全探索
for i in range(N):
    c = 0
    for j in range(N-i):
        # print('::', i, j)
        # print('!!', s[i+j], t[j])
        if s[i+j] == t[j]:
            c += 1
        else:
            break
    else:
        pos = max(pos, c)

# print(pos)
ans = 2 * N - pos
print(ans)
# Judge status: Accepted
# -*- coding:utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
k = int(input())
x = int(input())
y = int(input())

if k<=n:
  print(k*x+(n-k)*y)
else:
  print(n*x)
# Judge status: Accepted
x, y = map(int, input().split())

print(x + y // 2)
# Judge status: Accepted
def main():
    cnt = 0
    n = int(input())
    numlist = [int(x) for x in input().split()]
    while True:
        temp=0
        for i in range(n):
            if numlist[i]%2 == 0:
                temp+=1
                numlist[i]=numlist[i]/2
        if temp==n:
            cnt+=1
        else:
            break
    print(cnt)

if __name__=='__main__':
    main()
# Judge status: Accepted
n,l=map(int,input().split())
li=[input() for i in range(n)]

sortli=sorted(li)
print(''.join(sortli))
# Judge status: Accepted
def check(s):
  return s == s[::-1]

a, b = map(int, input().split())
print(sum(check(str(v)) for v in range(a, b+1)))
# Judge status: Accepted
from collections import deque
n,m=map(int,input().split())
graph=[[] for i in range(n)]
sirusi=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    graph[a].append(b)
    graph[b].append(a)
D=deque([0])
visited=[False]*n
visited[0]=True
while D:
    v=D.popleft()
    for i in graph[v]:
        if visited[i]:continue
        visited[i]=True
        sirusi[i]=v
        D.append(i)
print("Yes")
for i in range(1,n):
    print(sirusi[i]+1)
# Judge status: Accepted
N,K = map(int,input().split())
mod = 10**9+7
sum_min = 0
sum_max = 0
diff = 0
while K != N+2:
    sum_min = 1/2*K*(K-1)
    sum_max = 1/2*K*(2*N-K+1)
    diff += sum_max - sum_min+1
    K+= 1
diff = diff % mod
print(int(diff))
# Judge status: Wrong Answer
s=int(input())
dp=[0 for i in range(s+10)]
dp[3]=1
mod=10**9+7
for i in range(3,s+3):
    dp[i]=1
    for j in range(i-2): dp[i]=(dp[i]+dp[j])%mod
print(dp)
# Judge status: Accepted
from collections import defaultdict

def solve(n, A):
    count = defaultdict(int)
    for a in A:
        count[a - 1] += 1
        count[a] += 1
        count[a + 1] += 1
    return max(count.values())

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))
# Judge status: Wrong Answer
h = int(input())
for i in range(1, 41):
  x = 2 ** i -1
  if h <= x:
    print(x)
  break
# Judge status: Accepted
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort(reverse=True)
    return divisors

l = make_divisors(n)
ans = float('inf')
for a in l:
    b  = n//a
    ans = min(ans, a+b-2)
print(ans)
# Judge status: Wrong Answer
S = int(input())
ans = [0]*6
ans[2] = 10**9
ans[3] = 1
mod = S%(10**9)
b = (10**9-mod)%(10**9)
ans[4] = (S+b)//(10**9)
ans[5] = b
print(*ans)
# Judge status: Accepted
N,K=map(int, input().split())
a=N%K
print(min(a,K-a))
# Judge status: Accepted
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
if x[N-1] < y[0] and X < Y and x[N-1] > X and y[0] < Y:
    print('No War')
else:
    print('War')
# Judge status: Accepted
n,x,t=map(int,input().split())
if n%x==0:
    print(int(n/x*t))
else:
    print(int(n//x+1)*t)
# Judge status: Wrong Answer
h,n = map(int,input().split())
a = list(map(int,input().split()))
sorted(a)
if h <= sum(a[:n-1]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    N = int( input())
    A = list( map( int, input().split()))
    A.sort(reverse=True)
    ans = A[0]
    for i in range(N-2):
        ans += A[i//2+1]
    print(ans)
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
k = int(input())
s = input()
x = len(s)

if k >= x:
  print(s)

else:
  print(s[0:k+1] + "...")
# Judge status: Accepted
import sys
import math
x=input()
y=int(x)
z=math.sqrt(y)
w=math.floor(z)
print(w**2)
# Judge status: Accepted
n=int(input())
s=list(input())

num=0
for i in range(n):
    x=set(s[:i])
    y=set(s[i:])
    if len(x&y)>num:
        num=len(x&y)

print(num)
# Judge status: Wrong Answer
#!/usr/bin/env python3

# input = stdin.readline

def solve(n,m,original,template):
  def judge(sy,sx):
    for i in range(m):
      for j in range(m):
        if original[sy+i][sx+j] != template[i][j]:
          return False
    return True
  
  for i in range(n-m):
    for j in range(n-m):
      if judge(i,j):
        return True

  return False

def main():
  N,M = map(int,input().split())
  a = [input() for _ in range(N)]
  b = [input() for _ in range(M)]
  print("Yes" if solve(N,M,a,b) else "No")
  pass

if __name__ == '__main__':
  main()
# Judge status: Accepted
D = int(input())
c_list = list(map(int,input().split(' ')))
s_list = []
for i in range(D):
    s_list.append(list(map(int,input().split(' '))))
minc = c_list.index(min(c_list))
for day in range(D):
    maxs = s_list[day].index(max(s_list[day]))
    print(maxs+1)
# Judge status: Wrong Answer
a, b = map(int, input().split())
print((b-1)//(a-1))
# Judge status: Accepted
A,B = map(int,input().split())
if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
S=list(input())

maxlen=0
for i in range(len(S)):
    for j in range(i,len(S)):
        for k in range(i,j+1):
            #cnt=0
            if S[k]!='A' and S[k]!='C' and S[k]!='G' and S[k]!='T':
                break
            if k==j and j-i+1>maxlen:
                maxlen=j-i+1
print(maxlen)
# Judge status: Accepted
#abc064 c
n=int(input())
a=list(map(int,input().split()))
color=[False]*8
strongman=0
for i in a:
    x=i//400
    if x<8:
        color[x]=True
    else:
        strongman+=1
human=0
for i in color:
    if i==True:
        human+=1
color_min=max(human,1)
color_max=human+strongman
print(color_min,color_max)
# Judge status: Accepted
A,B = map(int, input().split())
if (A + B) % 2 == 0 :
  print ((A + B) // 2)
else :
  print ("IMPOSSIBLE")
# Judge status: Accepted
n,k=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(n)]

ab.sort()
total=0
for i in range(n):
    total+=ab[i][1]
    if total>=k:
        print(ab[i][0])
        break
# Judge status: Accepted
n,m = map(int,input().split())
loads = [list(map(int,input().split())) for i in range(m)]
citys = [0]*n
for l in loads:
    for i in l:
        citys[i-1]+=1 
for i in citys:
    print(i)
# Judge status: Wrong Answer
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
li = [list(map(int,input().split())) for i in range(M)]
li.sort(key=lambda x:x[1],reverse=True)

j = count = 0

for i in range(N):
    if A[i]<li[j][1]:
        A[i] = li[j][1]
        count += 1
        if count==li[j][0]:
            j += 1
    else:
        break

print(sum(A))
# Judge status: Accepted
import math
H,W = map(int,input().split())

if H == 1 or W == 1:
    ans = 1
else:
    ans = math.ceil(H * W / 2)

print(ans)
# Judge status: Accepted
n, a, b = map(int, input().split())
print(max(0, b * (n - 1) + a - (a * (n - 1) + b) + 1))
# Judge status: Accepted
from statistics import median
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
for i in range(N):
  B[i]=A[i]-i
b=int(median(B))
ans=0
for i in range(N):
  ans+=abs(B[i]-b)
print(ans)
# Judge status: Accepted
S=str(input())
T=S[::-1]
n=len(S)//2
count=0
for i in range(n):
  if S[i]!=T[i]:
    count+=1
print(count)
# Judge status: Wrong Answer
N=input("")
N=int(N)
if 1<=N<=100:
  if N%2==0:
    N=N/2
    print(N)
  else:
    N=(N+1)/2
    print(N)
else:
  None
# Judge status: Accepted
a, b, c = map(int,input().split())

x = b*(a-1)+c
y = c*(a-1)+b

print(max(0,y-x+1))
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)

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

#from math import gcd
from fractions import gcd

f = gcd(c,d)
f2 = c*d//f

rem_ans = b//c - (a-1)//c + b//d - (a-1)//d - (b//f2 - (a-1)//f2)
ans = b-a+1-rem_ans
print(ans)
# Judge status: Accepted
N,D=map(int,input().split())
c=0
X=[]
for i in range(N):
  X.append(list(map(int,input().split())))

for j in range(N):
  for k in range(j+1,N):
    tmp=sum([(X[j][l]-X[k][l])**2 for l in range(D)])
    if tmp in [y**2 for y in range(130)]:
      c +=1
print(c)
# Judge status: Accepted
s=int(input())
if s%2==0:
  print(s//2)
else:
  print(s//2+1)
# Judge status: Wrong Answer
n = int(input())
memo = [-1]*(n+1)

def func(i):
    if i == 0:
        return 2
    if i == 1:
        return 1
    
    if memo[i] != -1:
        return memo[i]
    
    memo[i] = func(i-2) + func(i-1)
    return memo[i]

func(n)
# Judge status: Accepted
icase=0
if icase==0:
    n=int(input())
    print(int(n**0.5)**2)
# Judge status: Accepted
S = input()
n = len(S)
T = ['dreamer', 'eraser', 'dream', 'erase']
idx = n
res = 'YES'
while idx > 0:
    for t in T:
        if S[idx-len(t):idx] == t:
            idx -= len(t)
            break
    else:
        res = 'NO'
        idx = -1
print(res)
# Judge status: Accepted
N,K=map(int,input().split())
print((N%K>0)+0)
# Judge status: Wrong Answer
num = input()
result = 0
for i in range(len(num)):
  if (0 <= int(num[i]) <= 5):
    result += int(num[i])
  else:
    result += (11 - int(num[i]))
print(result)
# Judge status: Wrong Answer
o = input()
e = input()
for oi, ei in zip(o, e):
    print(oi, ei, end="", sep="")
print()
# Judge status: Accepted
x, n = map(int, input().split())
a = set(map(int, input().split()))
print(min((i for i in range(102) if i not in a), key=lambda y:abs(x-y)))
# Judge status: Accepted
A, B = map(int, input().split())

if 1 <= A <= 9 and 1 <= B <= 9:
    print(A*B)
else:
    print(-1)
# Judge status: Accepted
n = str(input())
if n[0] == n[1] == n[2]:
    print('Yes')
elif n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
S=list(map(int,input().split()))
Z=[]
tmp=[]
for i in range(N):
    Z.append(S[i])
    tmp.append(S[i])
    

Z.sort()


for i in range(N):
    for j in range(N):
        
        R=tmp[i]
        tmp[i]=tmp[j]
        tmp[j]=R
        if tmp==Z:
            print("YES")
            exit()
        R=tmp[i]
        tmp[i]=tmp[j]
        tmp[j]=R        
        

print("NO")
# Judge status: Accepted
def actual(a, b, c):
    if (a + b) == c or (b + c) == a or (c + a) == b:
        return 'Yes'

    return 'No'

a, b, c = map(int, input().split())
print(actual(a, b, c))
# Judge status: Accepted
from heapq import heappush, heappop

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

jobs = sorted(jobs, key=lambda x:x[0])

hq = []
res, j = 0, 0
for i in range(1, m + 1):
    while j < n and jobs[j][0] <= i:
        heappush(hq, -jobs[j][1])
        j += 1
    if len(hq) > 0:
        res += -heappop(hq)
print(res)
# Judge status: Accepted
N = int(input())
def sub(l, d):
  if d == N:
    s = "".join(["abcdefghijklmnopqrstuvwxyz"[i] for i in l])
    print(s)
    return
  for j in range(max(l)+1+1):
    sub(l+[j], d+1)
sub([0], 1)
# Judge status: Accepted
S = int(input())
count = 0
for size in range(1, S//3+1):
  extra = S - 3 * size # 0以上の値をどう分配するか？数列なので純不動ではない
  total = extra + size -1 # extra個の玉とsize-1個の棒の並び替え問題
  number = 1
  for n in range(extra+1, total+1):
    number *= n
  for n in range(1, size):
    number //= n
  count += number
#  print(size,number)
print(count % (10 ** 9 + 7))
# Judge status: Accepted

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

use = [i for i in range(10)] #使える数字
for i in range(K): use.remove(D[i])

ans = N
while True:
    flag = True
    for item in list(str(ans)):
        if not (int(item) in use):
            flag = False
    if flag:
        break
    else:
        ans += 1

print(ans)
# Judge status: Wrong Answer
N = int(input())
L=[0]*N
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            f=x**2+y**2+z**2+x*y+y*z+z*x
            if f<=N:
                if x==y==z:
                    L[f-1]=1
                else:
                    L[f-1]=3
for i in range(N):
    print(L[i])
# Judge status: Accepted
from collections import deque
n = int(input())
A = deque(map(int, input().split()))
b = deque([])

if n%2==0:
    for i in range(n):
        if i%2 ==0:
            b.append(A[i])
        else:
            b.appendleft(A[i])
else:
    for i in range(n):
        if i%2 ==0:
            b.appendleft(A[i])
        else:
            b.append(A[i])            
print(*b)
# Judge status: Accepted
MOD = 10 ** 9 + 7
X, Y = map(int, input().split())

if (X + Y) % 3 or Y > 2 * X or Y < X // 2:
    print(0)
    exit()

n = (X + Y) // 3
r = X - (X + Y) // 3
num, den = 1, 1
if n - r < r:
    r = n - r
for i in range(1, r + 1):
    num *= n - i + 1
    num %= MOD
    den *= i
    den %= MOD

print((num * pow(den, MOD - 2, MOD)) % MOD)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
c = [0]*9
for i in a:
    b = i//400
    if b >= 8:
        c[8] += 1
    else:
        c[b] =1

print(sum(c[:8])+(1 if c[8] and sum(c[:8])==0 else 0),sum(c[:8])+c[8])
# Judge status: Accepted
import math
buf = input().split(" ")
A=int(buf[0])
B=int(buf[1])
H=int(buf[2])
M=int(buf[3])


#omega_min = 360/3600
#omega_hour = 360 / (3600*12)
#theta_min = omega_min*M*60
#theta_hour = omega_hour*H*3600 + M/60/12

"""
if H*5 > M:
  rad = math.radians(theta_hour-theta_min)
else:
  rad = math.radians(theta_min-theta_hour)
"""
rad=math.pi*2 *(H / 12.0 + (M / 60.0) / 12.0 - M / 60.0)
ans = math.sqrt( A**2 + B**2 - 2*A*B*math.cos(rad))
print(ans)
# Judge status: Accepted
N=int(input())
c=0
L=[list(map(int,input().split())) for _ in range(N)]
L=L[::-1]
for i in range(N):
  a,b=L[i]
  a+=c
  c+=b-(a%b)-(a%b==0)*b
print(c)
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
MAX = 0

step = 0
for i in range(n-1):
    if h[i]-h[i+1]>=0:
        step += 1
    else:
        MAX = max(MAX, step)
        step = 0
MAX = max(MAX, step)
print(MAX)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if (a+b)%3:
    print("Impossible")
else:
    print("Possible")
# Judge status: Accepted
n,k,*a=map(int,open(0).read().split())
b=[-1]*(n+1)
b[1]=0
c=a[0]
d=[0]*min(k+1,10**7)
d[0]=1
for i in range(1,k+1):
    d[i]=c
    if b[c]!=-1:
        # print(i,c,b[c])
        print(d[b[c]+(k-b[c])%(i-b[c])])
        exit()
    b[c]=i    
    c=a[c-1]
print(d[-1])
# Judge status: Accepted
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')
# Judge status: Accepted
import collections

N = int(input())
a = [int(i) for i in input().split()]
check = []
dict = collections.Counter(a)
for a, b in dict.items():
    if b >= 2:
        check.append(a)

if len(check) >=2:
    check.sort()
    if dict[check[-1]] >= 4:
        print(check[-1] ** 2)
    else:
        print(check[-1] * check[-2])
elif len(check) == 1:
    if dict[check[-1]] >= 4:
        print(check[-1] ** 2)
    else:
        print(0)
else:
    print(0)
# Judge status: Accepted
X = int(input())
d = X //100
if d >=20:
    print(1)
    exit()
k = X % 100
if 5 * d >= k:
    print(1)
else:
    print(0)
# Judge status: Accepted
A, B = map(int, input().split())

if A < 10 and B < 10:
    print(int(A*B))
else:
    print(-1)
# Judge status: Accepted
import math

n = int(input())

ans = math.ceil(n/1.08)

if n == int(ans*1.08):
  print(ans)
else:
  print(":(")
# Judge status: Accepted
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:K]))
# Judge status: Wrong Answer
import math
from itertools import accumulate

N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

AC1 = list(accumulate(A1))
AC2 = list(accumulate(A2))
#print(AC1,AC2)

ans = 0
if N == 1:
    print(AC1[0] +AC2[0])
else:
    for i in range(N):
        ans = max(ans,AC1[i] + (AC2[-1] - AC2[i-1]))
    print(ans)
# Judge status: Accepted
import sys

s = sys.stdin.readline().rstrip()
S = [s.count(i) for i in ('a','b','c')]
S.sort()
if S[2] - S[0] <= 1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
X, Y = map(int, input().split()) 
ans = 'No'
for a in range(X + 1):
	b=X-a
	if 2 * a + 4 * b == Y:
		ans = 'Yes' 
print(ans)
# Judge status: Accepted
import math

n = int(input())
a = int(math.sqrt(n))
print(a**2)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
s = sum(A)
l = 0
ans = 10**18
for i in range(n-1):
    l += A[i]
    r = s-l
    ans = min(ans, abs(l-r))
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a < c < b or b < c < a:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def resolve():
    A, B = list(map(int, input().split()))
    print((A+B)//2 if (A+B)%2==0 else "IMPOSSIBLE")

    
if '__main__' == __name__:
    resolve()
# Judge status: Wrong Answer
import math
n = int(input())
a = list(map(int, input().split()))
work = math.ceil(sum(a)/n)
result = 0
for el in a:
    result += (work-el)**2
print(result)
# Judge status: Wrong Answer
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

for i in range(T):
    A = A + V
    B = B + W
    if(A>=B):
        print("YES")
        break
    if(i==T-1):
        if(A<B):
            print("NO")
# Judge status: Wrong Answer
from itertools import groupby

N,K = map(int,input().split())
S = input()
gnum = len(list(groupby(S)))
if gnum-1<=K:
  print(N-1)
elif gnum-2==K:
  print(N-2)
else:
  print(N-(gnum-2*K))
# Judge status: Wrong Answer
S = input()
T = input()
L = len(S)
St = []
Tr = []
ans = 'no'
for i in range(L):
    St.append(S[i:i+1])
    Tr.append(T[i:i+1])

for i in range(L):
    if St == Tr:
        ans = 'yes'
        break
    else:
        St.insert(0,St[L-1])
        del St[L]

print(ans)
# Judge status: Wrong Answer
n = int(input())
print(1000 * (n // 500) + (n % 500) // 5)
# Judge status: Accepted
#!/usr/bin/env python3
N = int(input().strip())

print('Christmas' + ' Eve' * (25 - N))
# Judge status: Accepted
#coding:utf-8
N = int(input())
ls_ab = []
for n in range(N):
    a,b = map(int,input().split())
    ls_ab.append([a,b])
ans = 0
for a,b in ls_ab[::-1]:
    a+=ans
    ans += b - ((a-1) % b + 1)
print (ans)
# Judge status: Wrong Answer
n, T = map(int, input().split())
out = list()
for _ in range(n):
    c, t = map(int, input().split())
    # if t > T: continue
    out.append((c, t))
print(min(out)[0]) if out and min(out)[0] <= T else print("TLE")
# Judge status: Wrong Answer
x=int(input())
if(x%2==0):
    a=x/2
else:
    a=x//2+1
y=2*a+1
import math
def is_prime(n):
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
while(True):
    if(is_prime(y)):
        break
    y=y+2
if x==2:
    y = 2
print(str(int(y)))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

x = max(A)

d = 10**18
for a in A:
    if a == x:
        continue
    tmp = abs(x/2-a)
    if tmp < d:
        d = tmp
        y = a

print(x, y)
# Judge status: Accepted
N, M, K = map(int, input().split())

for x in range(M+1):
  for y in range(N+1):
    if x*N + y*M - 2*x*y == K:
      print('Yes')
      exit()
print('No')
# Judge status: Accepted
a, b, t = [int(x) for x in input().split()]

s = 0
x = a
while x <= t + 0.5:
    s += b
    x += a

print(s)
# Judge status: Accepted
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**9

n, k = map(int, input().split())
p = [int(item) for item in input().split()]
total = 0
for i in range(k):
    total += p[i]
max_t = total
l = 0; r = k
for i in range(k, n):
    total += p[i] - p[i-k]
    if total > max_t:
        max_t = total
        l = i - k
        r = i

print(0.5 * k + max_t / 2.0)
# Judge status: Accepted
N, M = map(int, input().split())
for i in range((M + 1) // 2):
	print(i + 1, i + (M - 2 * i) + 1)
for i in range(M - (M + 1) // 2):
	print(M + 1 + i + 1, M + 1 + i + (M - 1 - 2 * i) + 1)
# Judge status: Accepted
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

b = iin()
f = [0] * 1000001
i = 1
while True:
    if f[int(b)] == 0:
        f[int(b)] = i
    else:
        break
    b =  3 * b + 1 if b%2 else b/2
    i = i + 1
print(i)
# Judge status: Wrong Answer


s=input()
n=int(s)

d={}

for i in range(1,n):
	ts=str(i)
	hs=ts[0]+" "+ts[len(ts)-1]

	if(hs in d):
		d[hs]+=1
	else:
		d[hs]=1



ans=0

for i in range(1,10):
	for j in range(1,10):
		if(((str(i)+" "+str(j)) in d) and ((str(j)+" "+str(i)) in d)):
			ans+=d[(str(i)+" "+str(j))]*d[(str(j)+" "+str(i))]

print(ans)
# Judge status: Accepted
x,y = map(int,input().split())
if x % y == 0:
    print("-1")
else:
    print(x)
# Judge status: Accepted
S = input()
count = 0
exist = [0]*2019
flg = False
N = len(S)
sum = 0
for i, s in enumerate(reversed(S)):
    sum += (int(s) * pow(10, i, 2019)) % 2019
    exist[sum % 2019] += 1
for e in exist:
    if e > 1:
        count += e*(e-1)//2
count += exist[0]
print(count)
# Judge status: Wrong Answer
N = int(input())
x = []

while (N == 0):
    N, i = divmod(N, 26)
    x = i + 96
    print(x)
# Judge status: Accepted
S = input()
if S == "ABC":
  print("ARC")
else:
  print("ABC")
# Judge status: Wrong Answer
S = int(input())

a = [0] * 2000
a[0] = 0
a[1] = 0
a[2] = 1
a[3] = 1
a[4] = 1
a[5] = 2
k = 0
for i in range(6, S):
  for l in range(2, i-2):
    k += a[l]
  a[i] = 1 + k
  
p = a[S-1] % (10**9 + 7)
print(p)
# Judge status: Wrong Answer
a,b = map(int,input().split())
print(a - b < a)
# Judge status: Accepted
a = int(input())
s = input()

if a >=3200:
    print(s)
else:
    print("red")
# Judge status: Wrong Answer
N = int(input())
A_l = list(map(int, input().split()))

A_l.append(0)

money = 1000
stock = 0

for i in range(N):

    if A_l[i] < A_l[i+1]:
        stock = money // A_l[i]
        money = money % A_l[i]
    if A_l[i] > A_l[i+1] and stock != 0:
        money = stock * A_l[i] + money
        stock = 0


print(money)
# Judge status: Accepted
n,k,*A=map(int,open(0).read().split());e=enumerate
for _ in '_'*min(k,99):
  S=[0]*(n+1)
  B=[0]*(n+1)
  for i,a in e(A):S[max(0,i-a)]+=1;S[min(n,i+a+1)]-=1
  for i,s in e(S[:-1]):B[i+1]=B[i]+s
  A=B[1:]
print(*A)
# Judge status: Accepted
from collections import deque

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

graph = [[] for _ in range(n+1)]

for i in range(m):
 a, b = map(int, input().split())
 graph[a].append(b)
 graph[b].append(a)

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

ans = [0] * (n+1)
while d:
 v = d.popleft()
 for i in graph[v]:
   if dist[i] != -1:
     continue
   dist[i] = dist[v] + 1
   d.append(i)
   ans[i] = v
print('Yes')
print(*ans[2:], sep='\n')
# Judge status: Accepted
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = [(sum(p[:k])+k)/2]
for i in range(n-k):
    ans.append(ans[-1]+p[i+k]/2-p[i]/2)
print(max(ans))
# Judge status: Accepted
from itertools import accumulate
import bisect
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = list(accumulate(a))
ans = bisect.bisect_right(c, x)
if not ans:
  print(ans)
else:
  print(ans if c[N - 1] >= x else ans - 1)
# Judge status: Wrong Answer
n,*a=map(int,open(0).read().split())
ma=a[0]
ans=0
for q in a:
  if q>ma:
    ans+=(q-ma)
  ma=max(ma,q)
print(ans)