peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    ans = 0
    for i in range(1,N+1):
        n = N//i
        ans += n*(n+1)*i//2
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    n,k,*a=map(int,open(0).read().split())
    for _ in range(k):
        b=[0]*n
        m=10**18
        for i,t in enumerate(a):
            if t<m:m=t
            b[max(0,i-t)]+=1
            if i-~t<n:b[i-~t]-=1
        if m>=n:break
        for i in range(n-1):b[i+1]+=b[i]
        a=b
    print(' '.join(map(str,a)))
main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort()


dig = 0
while A[0] >= 10:
    A[0] = A[0] // 10
    dig += 1

ans = 2
for i in range(N):
    if A[i] % (2 * 10 ** dig) == 1:
        ans = 1
        break

print(ans * 10 ** dig)
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x=0
y=0
for i in range(N):
  if i%2==0:
    x+=i
  else:
    y+=i
print(x-y)
# Judge status: Wrong Answer

N = int(input())
M = [list(map(int, input().split())) for _ in range(N-1)]

def dfs(i):
  DP = [99999999999999] * N
  DP[i] = M[i][1]

  for j in range(i+1, N):
    prev = DP[j-1] + M[j-1][0]
    start = M[j-1][1] + M[j-1][0]
    if start >= prev:
      DP[j] = start
    else:
      DP[j] = prev + ( DP[j-1] - M[j-1][1] ) % M[j-1][2]
  
  print(DP[N-1])

for i in range(N-1):
  dfs(i)

print(0)
# Judge status: Wrong Answer
x = int(input())
if x == 1:
    print(0)
elif x <= 6:
    print(1)
elif x <= 12:
    print(2)
else:
    a = x // 11
    b = x % 11
    n = 11 * a
    if x == n:
        print(a)
    elif n + 5 >= x:
        print(2 * a + 1)
    else:
        print(2 * a + 2)
# Judge status: Wrong Answer
import math
X = int(input())
n = 100
ans = 1
for i in range(10000000):
    if n >= X:
        print(ans)
        break
    else:
        n = math.ceil(n*1.01)
        ans += 1
# Judge status: Accepted
O=input()
E=input()
lengthO=len(O)
lengthE=len(E)
for i in range(len(O)+len(E)):
  if i%2==0:
    print(O[i//2],end="")
  else:
    print(E[i//2],end="")
# Judge status: Accepted
a, b, k = map(int,input().split())
# for i in range(k):
#     if a >= 1:
#         a -= 1
#     elif b >= 1:
#         b -= 1
#     else:
#         continue

tmp = min(k, a)
a -= tmp
k -= tmp
b = max(0, b - k)

print(a, b)
# Judge status: Wrong Answer
from math import log2, floor
X, Y = map(int, input().split())
ans = floor(log2(Y/X)) + 1
print(ans)
# Judge status: Accepted
N,M,K = map(int,input().split())
flag = False
for i in range(N+1):
  for j in range(M+1):
    if i*M + j*N - 2*i*j == K:
      flag = True
    
print("Yes" if flag else "No")
# Judge status: Accepted
import numpy as np

n = int(input())
p = np.array([int(i) for i in input().split()])

a = np.arange(-1, -n-1, -1)
print('YES' if np.count_nonzero(p+a) < 3 else 'NO')
# Judge status: Accepted
s=input()
alph=[chr(i) for i in range(97,97+26)]
for i in s:
    if i in alph:
        alph.remove(i)
if alph:
    print(alph[0])
else:
    print("None")
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
x, k, d = map(int, input().split())

for i in range(1, k+1):
  if x >= 0:
    x = x - d
  if x < 0:
    x = x + d
    
print(abs(x))
# Judge status: Wrong Answer
numbers = input()
print(numbers)
if int(numbers) == 000: 
    print(0)
elif int(numbers) == 111:
    print(3)
elif int(numbers) == 101 or int(numbers) == 110 or int(numbers) == 11:
    print(2)
else:
    print(1)
# Judge status: Accepted
n,w=map(int,input().split())
print(abs(n*w-n*2-w*2+4))
# Judge status: Accepted
N = int(input())

L = [2,1]

for i in range(100):
  L.append(L[i]+L[i+1])

print(L[N])
# Judge status: Wrong Answer
x = input()
x = '000'+x
z = x[:-2]
y = x[-2:]
s = 0
z = int(z)
y = int(y)
L = []
for i in range(1,15):
    s +=i
    if s>=y and z>=i:
        print(1)
        exit()
if z>=14:
    print(1)
    exit()
print(0)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort()
M = A[-1]
a = M // 2
for i in range(N-1):
  if A[i] <= a and A[i+1] >= a:
    if (M-A[i])*A[i] >= (M-A[i+1])*A[i+1]:
      ans = [M, A[i]]
    else:
      ans = [M, A[i+1]]
ans = [str(b) for b in ans]
ans = ' '.join(ans)
print(ans)
# Judge status: Accepted
import sys

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

cnt = 0
for i in range(N-1):
  if A[i] - A[i+1] == 0:
    cnt +=1
if cnt < 2:
  print("0")
  sys.exit()

leng1 = 0
leng2 = 0
diff = 10**9

i = 0
while diff != 0:
  diff = A[i] - A[i+1]
  i += 1  
leng1= A[i]

A.remove(leng1)
A.remove(leng1)

i = 0
diff = 10**9
while diff != 0:
  diff = A[i] - A[i+1]
  i += 1  
leng2= A[i]

print(leng1*leng2)
# Judge status: Accepted
a,b = (int(i) for i in input().split())

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))
# Judge status: Accepted
la = [1,3,5,7,8,10,12]
lb = [4,6,9,11]
lc = [2]

x, y = map(int, input().split())

if x in la and y in la:
  print('Yes')
elif x in lb and y in lb:
  print('Yes')
elif x in lc and y in lc:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
import statistics
import math
import numpy as np

N=int(input())
X=list(map(int,input().split()))
X.sort()
#print(X)
med=int(statistics.median(X))

min=10**10
sum=0
while True:
    sum=0
    for i in range(N):
        sum+=(X[i]-med)**2
    if sum<min:
        min=sum
        prev=sum
        med+=1
    else:
        break

print(prev)
# Judge status: Accepted
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)

u = ""
v = ""
for i in s:
    u += i
for j in t:
    v += j
if u < v:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N =int(input())
amari = N % 10
if str(2) or str(4) or str(5) or str(7) or str(9) in str(amari) :
        print ("{}hon".format(str(N)))
elif str(0) or str(1) or str(6) or str(8) in str(amari) :
    print ("{} pon".format(str(N)))
else :
     print ("{}bon".format(str(N)))
# Judge status: Accepted
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

for i in range(N - K):
  if A[i] < A[i + K]:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
#ABC162B
n = int(input())
ans = 0 
for i in range(1,n+1):
    if (i%3 !=0) and (i%5 !=0):
        ans += i
print(ans)
# Judge status: Accepted
import sys
from collections import defaultdict

lines = sys.stdin.read().splitlines()

total_num_employee = int(lines[0])
list_of_zyoshi = lines[1].split()
num_of_buka = defaultdict(int)
result = ""
for zyoshi_id in list_of_zyoshi:
    num_of_buka[zyoshi_id] += 1

for employee_id in range(1, total_num_employee + 1):
    result += str(num_of_buka[str(employee_id)]) + "\n"
print(result)
# Judge status: Accepted
n = int(input())
print((int)(n*(n+1)/2))
# Judge status: Wrong Answer
N=int(input())

for i in range(N):
 t,x,y=list(map(int,input().split()))
 a=[(x+y)%2]
 b=[t%2]

if a==b and (x+y)<=t:
  print("Yes")
else :
  print("No")
# Judge status: Accepted
K, S = map(int, input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        if K >= S - x - y >= 0:
            ans += 1
print(ans)
# Judge status: Accepted
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, M = in_nn()

    ans = 1
    inf = M // N + 1
    for i in range(inf, 1, -1):
        if i * N <= M and M % i == 0:
            ans = i
            break

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
l = input().split(' ')

print(str(l[2])+str(l[0])+str(l[1]))
# Judge status: Accepted
li = list(input())

print(li.count("1"))
# Judge status: Wrong Answer
n = int(input())
x = list(map(int,input().split()))
if n == 2:
    print(x[1])
    print(x[0])
else:
    srt_x = sorted(x)
    print(x)
    print(srt_x)
    m = n//2
    for i in range(n):
        if x[i]<srt_x[m]:
            print(srt_x[m])
        else:
            print(srt_x[m-1])
# Judge status: Accepted
N = int(input())
for i in range(0,26):
  for k in range(0,15):
    if N == 4*i + 7*k:
      print('Yes')
      exit()
print('No')
# Judge status: Accepted
# パナソニック2020D
from queue import deque
n = int(input())
q = deque([("a", "a")])
while True:
    s, m = q.pop()
    if len(s)==n:
        print(s)
    elif len(s)>=n+1:
        break
    for o in range(ord("a"), ord(m)+2):
        if ord(m)<o:
            m = chr(o)
        q.appendleft((s + chr(o), m))
# Judge status: Accepted
from fractions import gcd
a,b,c,d = map(int,input().split())
cd = gcd(c,d)

#A-1
A1 = (a-1) - (a-1)//c -(a-1)//d +(a-1)//(c*d//cd)
 
#Bまで
B = b - b//c - b//d +b//(c*d//cd)
 
print(B-A1)
# Judge status: Accepted
x, y = map(int, input().split())
ans = 'No'
for a in range(x+1):
    if 4*x-y == 2*a:
        ans = 'Yes'
        break
print(ans)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
ans = 1
p = m = 0
c = A[0]
for i in A[1:]:
    if i > c:
        p = 1
    elif i < c:
        m = 1
    if p == 1 and m == 1:
        p = m = 0
        ans += 1
    c = i
print(ans)
# maybe pills will work??
# Judge status: Wrong Answer
S = str(input())
T = str(input())

flg = False

for i in range(0,len(S)-1):
    temp = S[-i-1:]
    
    ret = temp + S[:len(S)- i -1]
    
    if ret == T:
        flg = True
        break
        
        
if flg == True:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
t = list(input())
for i in range(len(t)):
    if t[i] == "?":
        t[i] = "D"

print("".join(t))
# Judge status: Accepted
import sys
input = sys.stdin.readline

N=int(input())
ANS=0
for i in range(1,N):
    ANS+=(N-1)//i

print(ANS)
# Judge status: Accepted
N = input()
_1 = N[:-1]
_2 = N[1:]

ans = 'No'
if _1[0] == _1[1]:
  if _1[1] == _1[2]:
    ans = 'Yes'

if _2[0] == _2[1]:
  if _2[1] == _2[2]:
    ans = 'Yes'

print(ans)
# Judge status: Wrong Answer
n = int(input())
l = []
for i in range(1,n):
    sur = n%i
    ans = n/i
   # print(i,ans,sur)
    if ans < i:
        break
    elif sur == 0:
        l.append(i)
l.sort(reverse=True)
max = l[0]
max_op = n/max
ite = max-1+max_op-1
print(ite)
# Judge status: Accepted
import sys


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


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

L.sort()

ans = 0
# a(一番短い辺)を固定して，b, cで尺取
for a in range(N):
    c = a + 1
    for b in range(a + 1, N):
        while c < N and L[c] < L[a] + L[b]:
            c += 1
        ans += c - (b + 1)

print(ans)
# Judge status: Accepted
x,a,b = map(int,input().split())
if abs(x - a) <= abs(x - b):
  print('A')
else:
  print('B')
# Judge status: Wrong Answer
n = int(input())
if n%2 == 0:
  print(n//2)
else:
  print(n//2)
# Judge status: Accepted
# B

import numpy as np
N, M = map(int, input().split())

A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])

flag=0
for i in range(N-M+1):
    for j in range(N-M+1):
        A_tmp = A[i:i+M,j:j+M]
        # print(A_tmp)
        # print(B)
        if (B==A_tmp).all():
            flag=1
        if flag==1:
            break
    if flag==1:
        break
if flag==1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
A,B,H,M = map(int,input().split())

H %= 12
ra = 0.5*(60*H+M)-6*M
ra = min(ra,360-ra)
cos_ra = math.radians(ra)
C = math.sqrt((A**2+B**2)-(2*A*B*math.cos(cos_ra)))
print(C)
# Judge status: Wrong Answer
H,N=map(int,input().split())
AB=[]
bestmagic=0
bestdpc=0
for i in range(N):
    A,B=map(int,input().split())
    dpc=A/B
    if bestdpc<dpc:
        bestmagic=i
        bestdpc=dpc
    AB.append([A,B])

bestfire=AB[bestmagic][0]
bestcost=AB[bestmagic][1]

ans=float("inf")
for a,b in AB:
    repeat=-(-(H-a)//bestfire)
    ans=min(ans,bestcost*repeat+b)
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

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

print("Yes" if H <= A else "No")
# Judge status: Accepted
def c(n):
    b = 2
    f = set()
    while b * b <= n:
        while n % b == 0:
            n //= b
            f |= {b}
        b += 1
    if n > 1:
        f |= {n}
    return f
a, b = map(int, input().split())
print(len(c(a) & c(b)) + 1)
# Judge status: Accepted
from collections import Counter

n=int(input())
l=[int(i) for i in input().split()]
c=Counter(l).most_common()
s=sorted([key,val] for key,val in c if val>=2)

if len(s)<2:
    ans=0
elif s[-1][1]>=4:
    ans=s[-1][0]**2
else:
    ans=s[-1][0]*s[-2][0]

print(ans)
# Judge status: Accepted
w,h,n = map(int,input().split())

x1 = 0
x2 = w
y1 = 0
y2 = h

for _ in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    else:
        y2 = min(y2, y)

if x2 - x1 > 0 and y2 - y1 > 0:
    print((x2-x1) * (y2-y1))
else:
    print(0)
# Judge status: Accepted
'''ABC172 C'''
import numpy as np
n,m,k = map(int,input().split())
a = np.array([int(i) for i in input().split()], dtype='int64')
b = np.array([int(i) for i in input().split()], dtype='int64')

a_c = np.zeros(n+1,dtype='int64')
a_c[1:] = np.cumsum(a)

b_c = np.zeros(m+1,dtype='int64')
b_c[1:] = np.cumsum(b)

a_c = a_c[a_c <= k]
b_c = b_c[b_c <= k]
ans = 0
for i,ai in enumerate(a_c):
    n = np.searchsorted(b_c, k - ai, side = 'right')
    ans = max(i + n-1, ans)
print(ans)
# Judge status: Accepted
s = input()
if ord(s[0]) + ord(s[1]) + ord(s[2]) == ord('a') + ord('b') + ord('c'):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a,b,c = map(int, input().split())
if abs(a-b) == c or abs(a-c) == b or abs(b-c) == a:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
if a[0] >= 1 or n == 0:
    print(1 if a[0] == 1 and n == 0 else -1)
    exit()
b = [0] * (n + 1)
for i in range(1, n + 1):
    b[i] = a[i] + b[i - 1]
v = 1
ans = 1
for i in range(n):
    if v < 2 * a[i + 1]:
        print(-1)
        exit()
    v = min(b[n] - b[i], 2 * (v - a[i]))
    if v <= 0:
        print(-1)
        exit()
    ans += v
print(ans)
# Judge status: Wrong Answer
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(N):
  total+=A[i]
if A[M-1]>total/(4*M):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n, a, b, c, d = map(int, input().split())
S = input()
if c < d:
    if "##" in S[a:d-3]:
        print("No")
    else:
        print("Yes")
else:
    f = S[b-2:].find("...")
    if f != -1 and f != (d-1) and ("##" not in S[a:d-3]):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))

check = 1
ans = 0


for i in a:
  ans+=1
  if i == check:
    ans -=1
    check+=1
    
if a==[j for j in range(1,N+1)]:
  print(0)
  exit()
  
elif ans==N:
  print(-1)
  exit()

print(ans)
# Judge status: Accepted
S = input()
s = ans = 0
for c in S:
    if c=='S':
        s += 1
    else:
        if s:
            s -= 1
        else:
            ans += 1
print(ans+s)
# Judge status: Wrong Answer
N = int(input())
AB = [0] * N
for n in range(N):
  AB[-1-n] = [int(x) for x in input().strip().split()]
ans = 0
cnt = 0
for (a, b) in AB:
  if b == 1:
    if a == 0:
      ans += 1
  else:
    t = b - ((a + cnt) % b)
    cnt += t
    ans += t
print(ans)
# Judge status: Wrong Answer
N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
 
for i in range(M):
    counter += A[i]
    
print(N-counter)
# Judge status: Accepted
A = [int(x) for x in input().split()]
if sum(A) % 2 == max(A) % 2:
    ans = (max(A) * 3 - sum(A)) // 2
else:
    ans = ((max(A) + 1) * 3 - sum(A)) // 2
print(ans)
# Judge status: Accepted
n = int(input())

for v in range(int(n//1.08)+2):
    if int(v*1.08) == n:
        print(v)
        exit()
print(':(')
# Judge status: Wrong Answer
n,k = map(int, input().split())
s = input()
s = s.replace(s[k-1], s[k-1].lower())
print(s)
# Judge status: Accepted
N,K = map(int,input().split())
count = 0

while N//K != 0:
    N = N//K
    count += 1
print(count+1)
# Judge status: Accepted
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
n=int(input())
l=[int(i) for i in input().split()]
l.sort()

longest=l.pop()
remain=sum(l)
if longest<remain:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())
print(int(0.5*h*(a+b)))
# Judge status: Wrong Answer
a,b,c,d = map(int, input().split())
if b*d > 0:
    print(b*d)
else:
    print(-1*min(abs(a),abs(b))*min(abs(c),abs(d)))
# Judge status: Accepted
A, B, C = map(int, input().split())
S = A + B + C
M = max(A, B, C)
if S%2 != M%2:
  M = M + 1
print((3*M-S)//2)
# Judge status: Accepted
s=list(input())
dna = ["A","T","G","C"]
res=[0]
x=0
for i in range(len(s)):
    if s[i] in dna:
        x+=1
    else:
        res+=[x]
        x=0
print(max(x,max(res)))
# Judge status: Wrong Answer
s = list(input())

flag = 0
pos_a, pos_z = 1, 1
length = 0

for i, ltr in enumerate(s, 1):
  if ltr == 'A':
    pos_a = i
    flag = 1
  elif ltr == 'Z' and flag == 1:
      pos_z = i
      if pos_z - pos_a > length:
        length = pos_z - pos_a
      else:
        flag = 0

print(length)
# Judge status: Accepted
# vim: fileencoding=utf-8


def main():
    n = int(input())
    t, x, y = 0, 0, 0
    for i in range(n):
        a, b, c = map(int, input().split())
        d = a - t
        m = abs(x - b) + abs(y - c)
        if d - m < 0 or (d - m) % 2 == 1:
            print("No")
            return
        t, x, y = a, b, c
    print("Yes")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
c=input()
if c>='A' and c<='Z':
  print('A')
else:
  print('B')
# Judge status: Accepted
N=int(input())
n=N%10
if n==3:
    print("bon")
elif n==0 or n==1 or n==6 or n==8:
    print("pon")
else:
    print("hon")
# Judge status: Accepted
#!/usr/bin/env python3
x, k, d = map(int, input().split())
x = abs(x)
if (n := k - x // d) < 0:
    print(x - k * d)
else:
    print(abs(d - x % d) if n % 2 else x % d)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
num = 0
mi = 10**9
for i in range(n):
    num += abs(a[i])
    if abs(mi) >= abs(a[i]):
        mi = a[i]
cnt = 0
for i in range(n):
    if a[i] < 0:
        cnt += 1
if cnt%2 == 1:
    print(num-2*mi)
else:
    print(num)
# Judge status: Wrong Answer
N=int(input())
a=N%1000
print(a)
# Judge status: Accepted
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = set([int(input()) for i in range(N)])
flag = False
for i in range(3):
  if A[i][0] in b and A[i][1] in b and A[i][2] in b:
    flag = True
  if A[0][i] in b and A[1][i] in b and A[2][i] in b:
    flag = True
if A[0][0] in b and A[1][1] in b and A[2][2] in b:
  flag = True
if A[0][2] in b and A[1][1] in b and A[2][0] in b:
  flag = True
print(['No','Yes'][flag])
# Judge status: Wrong Answer
X = int(input())
if X == 7 or X == 5 or X == 3:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = list(map(int,input().split()))

for i in range(k,n):
    if a[i-3] < a[i]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
N = int(input())

n = N/1000

for i in range(11):
    if i >= n:
        print(i*1000-N)
        break
# Judge status: Accepted
n, a, b = map(int, input().split())
s = input()
jap_c = 0
ab_c = 0
for i in list(s):
    if i == 'a':
        if jap_c + ab_c < a+b:
            jap_c += 1
            print('Yes')
            continue
    if i == 'b':
        if jap_c + ab_c < a+b:
            if ab_c < b:
                ab_c += 1
                print('Yes')
                continue
    print('No')
# Judge status: Accepted
s = [int(i) for i in input()]
for i in range(8):
    a = s[0]
    lst = []
    for j in range(3):
        if i>>j & 1 == 1:
            a += s[j+1]
            lst.append("+")
        else:
            a -= s[j+1]
            lst.append("-")
    if a == 7:
        lst.append("=7")
        break

for i,j in zip(s,lst):
    print(i,j,sep="",end="")
else:
    print("")
# Judge status: Accepted
N, M = map(int, input().split())
from_one = []
to_n = []
for _ in range(M):
  a, b = map(lambda x:int(x)-1, input().split())
  if a == 0:
    from_one += [b]
  elif b == 0:
    from_one += [a]
  elif a == N-1:
    to_n += [b]
  elif b == N-1:
    to_n += [a]

from_one = set(from_one)
to_n = set(to_n)
if len(from_one & to_n) >= 1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Judge status: Accepted
from bisect import bisect_left

n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
min_dis = 10 ** 20
a = 0
for i in range(n - k + 1):
    dis = x[i + k - 1] - x[i] + min(abs(x[i]), abs(x[i + k - 1]))
    if min_dis > dis:
        ans = dis
        min_dis = dis
print(ans)
# Judge status: Accepted
a,b,c = map(int, input().split())
print('Yes' if c >= a and c <= b else 'No')
# Judge status: Accepted
def findProductSum(A, n): 
    array_sum = sum(A)
    array_sum_square = array_sum ** 2
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
    return (array_sum_square -
            individual_square_sum) // 2

n = input()
arr = list(map(int, input().split()))
res = findProductSum(arr, len(arr)) % (10**9 + 7)
print(res)
# Judge status: Wrong Answer
a,b,c = input().split()
if c >= a and c <= b:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
K,X= input().split()

if 500 * K >= X:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i, b in enumerate(B):
    l = min(A[i], b)
    b -= l
    r = min(A[i + 1], b)
    ans += l + r

print(ans)
# Judge status: Accepted
def main():
    n = int(input())
    p = [int(x) for x in input().split()]
    ans = 0
    for i in range(1, n - 1):
        a = [p[i - 1], p[i], p[i + 1]]
        if p[i] != max(a) and p[i] != min(a):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
#B
import math
a,b = map(int,input().split())

k = math.ceil((b-1)/(a-1))

if b == 1:
    print(0)
elif a == b:
    print(1)
else:
    print(k)
# Judge status: Accepted
from sys import stdin
s = stdin.readline().rstrip()
k = len(s)
if k%2 == 1:
    print("No")
else:
    if s == "hi"*(k//2):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import itertools
import numpy as np
S = str(input())
if S == "ARC":
    print("ABC")
else:
    print("ARC")
# Judge status: Accepted
N = int(input())
S = list(input())

d = S.count('D')
i = S.count('I')
cnt = 0
cntold = 0
for n in range(N):
    if S[n] == 'D':
        cnt -= 1
    else:
        cnt += 1
    
    if cnt > cntold:
        cntold = cnt
print(cntold)
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))

def code(n,p):
  answer = 0
  for idx, pp in enumerate(p):
    if pp>n:
      answer = idx+1
      
  return idx

idx = code(n,p)
if idx == None:
  print(n)
else:
  print(idx)
# Judge status: Accepted
import bisect
n=int(input())
a = list(map(int, input("").split()))
b = list(map(int, input("").split()))
c = list(map(int, input("").split()))
out=0
a.sort()
b.sort()
c.sort()
for i in b:
    na = bisect.bisect_left(a,i)
    nc = bisect.bisect(c,i)
    out += na * (len(c)-nc)
print(out)
# Judge status: Accepted
a = list(map(int,input().split()))

b = a[0] // a[1]
c = a[0] % a[1]
if c != 0:
    c = 1
ans = (b + c) * a[2]
print(str(ans))