peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
mod = 1000000007

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    for i in range(N - 1):
        ans += (A[i] * sum(A[i + 1:]) / mod)
    print(ans % mod)

if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())

tmp = [a, b]
tmp.sort()
if tmp[0] == 2:
    print(1)
if tmp[0] == 1 and tmp[1] == 3:
    print(2)
else:
    print(3)
# Judge status: Wrong Answer
# B - 105

def yakusu_rekkyo(n):
    yakusu = set()
    for i in range(1, int(pow(n, 0.5)+1)):
        if n%i == 0:
            yakusu.add(i)
            yakusu.add(n//i)
    return yakusu

N = int(input())
ans = 0
for i in range(105, N+1, 2):
    Y = yakusu_rekkyo(N)
    if len(Y) == 8:
        ans += 1
        
print(ans)
# Judge status: Wrong Answer
N,P=map(int,input().split())
*A,=map(int,input().split())

if N==1:
    print(1*(P==A[0]%2))
else:
    print(2**(N-1))
# Judge status: Accepted
N,M = map(int,input().split())
d = {}
for i in range(M):
    a,b = map(int,input().split())
    if a in d.keys():
        d[a].append(b)
    else:
        d[a] = [b]

flag = False
for i in d[1]:
    if i in d.keys():
        for j in d[i]:
            if j == N:
                flag = True
                break
        if flag:
            break
if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
inf = 10**5+1
n,m = map(int,input().split())
p = [inf]*n
AA = [0]*m
BB = [0]*m
for i in range(m):
  a,b = map(int,input().split())
  A = max(a,b)
  B = min(a,b)
  AA[i] = A
  BB[i] = B
for i in range(len(AA)):
  if p[AA[i]-1] > BB[i]:
    p[AA[i]-1] = BB[i]
  if p[BB[i]-1] > AA[i]:
    p[BB[i]-1] = AA[i]
p[0] = 'Yes'

if max(p[1:]) == 10**5+1:
  print('No')
else:
  for i in range(len(p)):
    print(p[i])
# Judge status: Accepted
# ABC158 B - Count Balls

M,A,B = map(int,input().split())
import math
C = math.floor(M/(A+B))
N = M%(A+B)
E = C*A

if N >= A:
    E+=A
else:
    E+=N
print(E)
# Judge status: Wrong Answer
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
# print(N, K, A)

answer = N / (K - 1)

print(answer)
# Judge status: Wrong Answer
x,y,z=map(int, input().split())
print(z,y,x)
# Judge status: Accepted
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])
time = 0
for i in range(N):
    if time+AB[i][0] > AB[i][1]:
        print ("No")
        break
    else:
        time += AB[i][0]
else:
    print ("Yes")
# Judge status: Accepted
N = int(input())

print(1 - (N // 2) / N)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = a[::-1]


if a[0] >= 1:
    print(-1)
    exit()
    
ans = [0] * (n + 1)
for i in range(n):
    ans[i + 1] = ans[i] + b[i]

ans = ans[::-1]

ans = ans[1::]
a = a[1::]

res = 1

prev_cnt = 1
for i in range(n):
    cnt = min(prev_cnt * 2, ans[i] + a[i])
    if cnt < a[i]:
        print(-1)
        exit()
    res += cnt
    prev_cnt = cnt - a[i]
print(res)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

sum = 0
k = a[0]

for i in range(n - 1):
    if a[i] >= a[i + 1]:
        sum += k - a[i + 1]
    else:
        k = a[i + 1]
        sum += 0

print(sum)
# Judge status: Accepted
X,A,B = map(int,input().split())

if B - A <= 0:
    print("delicious")
elif B - A <= X:
    print("safe")
else:
    print("dangerous")
# Judge status: Accepted
x,a,b = map(int,input().split())
print("A" if abs(x-a)<abs(x-b) else "B")
# Judge status: Accepted
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
S_Set = set(S)
ans = 0

for s in S_Set:
    ans = max(ans, S.count(s) - T.count(s))

print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())

if A == B == C and A%2 == B%2 == C%2 == 0:
    print(-1)
else:
    ans = 0
    while A%2 == B%2 == C%2 == 0:
        A, B, C = (B+C)//2, (C+A)//2, (A+B)//2
        ans += 1
    print(ans)
# Judge status: Accepted
n = int(input())
lst = list(map(int, input().split()))

lst2 = []
for i, l in enumerate(lst, start= 1):
    lst2.append(l-i)

def median(lst):
    num = len(lst)
    sor = sorted(lst)
    if num%2==0:
        return round((sor[num//2] + sor[num//2-1])/2)
    else:
        return sor[num//2]
b = median(lst2)
ans = sum([abs(val - b) for val in lst2])
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
for i in range(5000):
  z8=int(i*0.08)
  z10=int(i/10)
  if z8==a and z10==b:
    print(i)
    exit()
print("-1")
# Judge status: Accepted
import functools
import operator

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

# prod = functools.partial(functools.reduce, operator.mul)
# tmp_sum_prod = prod(A[:K])
for i in range(K, N):
    sum_prod = (A[i]/A[i-K])
    if sum_prod > 1.0:
        print('Yes')
    else:
        print('No')
    tmp_sum_prod = sum_prod
# Judge status: Wrong Answer
N=int(input())
A=[int(i) for i in input().split()]
X=0
cnt=1
for i in range(N-1):
  if A[i+1]-A[i]>0:
    if X==-1:cnt+=1
    X=1
  elif A[i+1]-A[i]<0:
    if X==1:cnt+=1
    X=-1
print(cnt)
# Judge status: Accepted
import sys
import math
import bisect

def query(n, x):
    return n // x + 1

def main():
    a, b, x = map(int, input().split())
    ans = query(b, x)
    if a > 0:
        ans -= query(a - 1, x)
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
from math import ceil 
n,d=map(int,input().split())
print(ceil((n//d)/2))
# Judge status: Accepted
import heapq
N,M = map(int,input().split())
lsA = list(map(int,input().split()))
lsA = [-i for i in lsA]
heapq.heapify(lsA)
for i in range(M):
    maxA = heapq.heappop(lsA)
    heapq.heappush(lsA,-(-maxA//2))
lsA = [-i for i in lsA]
print(sum(lsA))
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split(" ")))

base=10**9+7
s=0
for i in range(1,len(A),1):
    s=(s+A[i])%base
ans=0
for i in range(len(A)-1):
    ans=(ans+(A[i]*s))%base
    s=(s-A[i+1]+base)%base
print(ans)
# Judge status: Accepted
def main(a: int, b: int, c: int):
    if a < c < b:
        print('Yes')
    elif a > c > b:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    a, b, c = map(int, input().split())

    main(a, b, c)
# Judge status: Wrong Answer
N, C, K = map(int, input().split())
T = sorted(list(int(input()) for _ in range(N)))

bus = 1
pa = 1

for i in range(N-1):
    if pa < C:
        if T[i]+K >= T[i+1]:
            pa += 1
        else:
            bus += 1
            pa = 1
    else:
        bus += 1
        pa = 1
        continue

print(bus)
# Judge status: Accepted
n=int(input())
alist=list(map(int,input().split()))
height=alist[0]
ans=0

for i in range(1,n):
    if height>alist[i]:
        ans+=height-alist[i]
    
    else:
        height=alist[i]

print(ans)
# Judge status: Accepted
k,n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ans = a[-1]-a[0]
for i in range(n-1):
  chk = a[i] + k-a[i+1]
  ans = min(ans,chk)
print(ans)
# Judge status: Accepted
n,l= map(int,input().split())
b =[]
for i in range(1,n+1):
    a = l + i -1
    b.append(a)
    min = b[0]
for i in range(n):
    if abs(min) > abs(b[i]):
        min = b[i]
print(sum(b)- min)
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = '$' + input() + '$'

def isOk(fr, to):
    if S[fr: to + 1].count('##') > 0:
        return False
    return True

if not (isOk(A, C) and isOk(C, D)):
    print('No')
    exit()

def canSwitch():
    if S[max(A, B) - 1: min(C, D) + 2].count('...'):
        return True
    return False

if A < B and D < C or B < A and C < D:
    if not canSwitch():
        print('No')
        exit()

print('Yes')
# Judge status: Wrong Answer
N=str(input())
if N[-1]==3:
    print("bon")
elif N[-1]==0 or 1 or 6 or 8:
    print("pon")
else:
    print("hon")
# Judge status: Wrong Answer
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
ls=[a,b,c]
ls.sort()
print(ls[0]*ls[1])
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
  n=int(input())
  if n==0:
    print(0)
    exit()
  s=1 if n>0 else 0
  n=abs(n)
  for j in range(s,31,2):
    if ((n>>j) & 1): #立っているビットのところで処理が走る
      n+=pow(2,j+1)
  print(bin(n)[2:])
if __name__=='__main__':
  main()
# Judge status: Accepted
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    L, R, d = MI()
    ans = 0
    for i in range(L, R+1):
        if i%d == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
for i in range(1,n+1):
    if i*i>n:
        break
print((i-1)*(i-1))
# Judge status: Accepted
n,m=map(int,input().split())
D=dict()
for i in range(n):
  D[i+1]=0
for i in range(m):
  a,b=map(int,input().split())
  D[a]+=1
  D[b]+=1
for i in range(1,n+1):
  print(D[i])
# Judge status: Accepted
import math
N = int(input())
A = sorted([int(X) for X in input().split()])
GCDA = A[0]
for T in range(1,N):
    GCDA = math.gcd(GCDA,A[T])
    if GCDA==1: break
print(GCDA)
# Judge status: Accepted
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from itertools import accumulate
    acc = [a for a in accumulate([0] + A)]
    ans = acc[-1]
    for i in range(1, N+1):
        a = acc[i]
        b = acc[N] - acc[i]
        v = abs(a-b)
        ans = min(ans, v)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
c=[[0]*10 for _ in range(10)]
for i in range(n):
	s=str(i+1)
	c[int(s[0])][int(s[-1])]+=1
ans=0
for i in range(10):
	for j in range(10):
		ans+=c[i][j]*c[j][i]
print(ans)
# Judge status: Wrong Answer
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N - 1)]
ans = []
for i in range(N - 1):
    temp = 0
    for j in range(i, N - 1):
        c, s, f = CSF[j][0], CSF[j][1], CSF[j][2]
        if temp <= s:
            temp += s - temp
            temp += temp % f
        else:
            temp += f - ((temp - s) % f)
        temp += c
    ans.append(temp)
for i in range(N - 1):
    print(ans[i])
print(0)
# Judge status: Accepted
import sys

s = input()
t = input()
lenS = len(s)
lenT = len(t)
ans =""
for i in range(lenS-lenT,-1,-1):
  sub = s[i:i+lenT]
  for j in range(lenT):
    if sub[j]!=t[j] and sub[j]!="?":
      break
  else:  
    ans = s[:i]+t+s[i+lenT:]
    ans = ans.replace("?","a")
    print(ans)
    sys.exit()
  continue
print("UNRESTORABLE")
# Judge status: Wrong Answer
n, *P = map(int, open(0).read().split())
c = 0
if P[0] == 1:
  c = 1
  P[0] = P[1]
  P[1] = 1
for i, (p0, p1) in enumerate(zip(P, P[1:]), 1):
  if i+1 == p1:
    c += 1
    P[i] = P[i-1]
    P[i-1] = i+1 
print(c)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
temp=n
for i in range(n):
  j=0
  k=0
  while j<n:
    if a[i]<=b[j]:
      while k<n:
        if b[j]<=c[k]:
          ans=ans+n-k
          j=j+1
          break
        else:
          k=k+1
    else:
      j=j+1
print(ans)
# Judge status: Accepted
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		return True


def can_go_halfway(start, goal):
	global S

	way = S[start:goal+1]

	if way.find('...') > -1:
		return True


N, A, B, C, D = map(int, input().split())
S = input()
S = '.' + S

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	if can_go_halfway(B - 1, D + 1):
		if can_goal(A, C):
			if can_goal(B, D):
				print('Yes')
				exit()

print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))  #8 2 7 3 4 5 6 1
# u = [(c, i) for i, c in enumerate(A)]  #タプルはcが優先される
l = list()
for i,c in enumerate(A):  #タプルにする
    l.append((c,i))

l.sort()

for c, i in l:
    print(i+1, end=" ")
# Judge status: Wrong Answer
n=int(input())
s=input()

l=[]

for a in s:
  moji=ord(a)
  moji+=n
  l.append(chr(moji))

print(''.join(l))
# Judge status: Wrong Answer
N = int(input())
S = input()

from collections import Counter
c = Counter()

for si in S:
    c[si] += 1

ans = 1
for n in c.values():
    ans *= n + 1

ans -= 1
print(ans)
# Judge status: Accepted
n=int(input())
M=10**6+1
l=[]
p=[1]*M
for i in range(2,M):
  if p[i]:
    l+=[i]
    for j in range(2*i,M,i):
      p[j]=0
d={}
for k in l:
  c=0
  while n%k==0: n//=k; c+=1
  if c>0: d[k]=c
s=[1]
for i in range(2,9):
  s.append(s[-1]+i)
a=0
for i in d.values():
  for j in s:
    if j>i: break
    a+=1
print(a+(n>1))
# Judge status: Accepted
a,b = map(int, input().split())
print(a if a <= b else a - 1)
# Judge status: Accepted
A,B = map(int,input().split())
ans = 'Impossible'
ls =[A,B,A+B]
for i in ls:
  if i % 3 == 0:
    ans = 'Possible'
print(ans)
# Judge status: Accepted
import math
N, K = list(map(int, input().split()))
p = 0
for n in range(1, N + 1):
    if n >= K:
        p += 1
    else:
        p += (0.5 ** math.ceil(math.log2(K / n)))
print(p / N)
# Judge status: Accepted
n = int(input())
print(sum([((n // i) + 1) * (n // i) * i // 2 for i in range(1, n + 1)]))
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
ans = "R" * dx
ans += "U" * dy
ans += "L" * dx
ans += "D" * dy
ans += "L"
ans += "U" * (dy + 1)
ans += "R" * (dx + 1)
ans += "D"
ans += "R"
ans += "D" * (dy + 1)
ans += "L" * (dx + 1)
ans += "U"
print(ans)
# Judge status: Accepted
N = int(input())
B = list(map(int, input().split()))

A = [0] * N
for i in range(N):
    if i == 0:
        A[i] = B[i]
    elif i == N - 1:
        A[i] = B[i - 1]
    else:
        A[i] = min(B[i - 1], B[i])

answer = sum(A)

print(answer)
# Judge status: Accepted
S=input()
a=set()
for s in S:
  a.add(s)
a=list(a)
if len(a)==4:
  print('Yes')
elif len(a)==2:
  if (a[0]=='N' or a[0]=='S') and (a[1]=='N' or a[1]=='S'):
    print('Yes')
  elif (a[0]=='E' or a[0]=='W') and (a[1]=='E' or a[1]=='W'):
    print('Yes')
  else:
    print('No')
else:
  print('No')
# Judge status: Accepted
a,b=map(int, input().split())
if a<=0<=b:
    print("Zero")
elif 0<a:
    print("Positive")
elif b-a&1:
    print("Positive")
else:
    print("Negative")
# Judge status: Wrong Answer
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
H = sorted(h)
minH = 10000
for x in range(N - K + 1):
    sumh = H[x + K - 1] - H[x]
    if minH > sumh:
        minH = sumh
print(minH)
# Judge status: Accepted
s=input()
n=len(s)
a=[ord(i)-ord('a') for i in s]
k=int(input())
for i in range(n):
    if a[i]+k>=26 and a[i]>0:
        k-=26-a[i]
        a[i]=0
k%=26
a[-1]+=k
a=[chr(i + ord('a')) for i in a]
print(*a,sep="")
# Judge status: Accepted
from sys import stdin
from collections import Counter
inp = stdin.readline

N = int(inp())
A = [int(inp()) for _ in range(N)]

cnt = Counter(A)

ans = 0

for c in cnt.values():
    if c % 2 != 0:
        ans += 1

print(ans)
# Judge status: Accepted
from bisect import bisect_right
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 1
min_vs = [A[-1]]
for i in range(N-2, -1, -1):
    a = A[i]
    idx = bisect_right(min_vs, a)
    if idx == len(min_vs):
        ans += 1
        min_vs.append(a)
    else:
        min_vs[idx] = a
print(ans)
# Judge status: Wrong Answer
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
    if "##" not in S[A-1:D-1]:
        print("Yes")
    else:
        print("No")
elif D<C:
    if "##" not in S[A-1:C-1] and "..." in S[B-1:D-1]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
input()
A = [v for v in map(int, input().split()) if not v % 2]
for v in A:
    if v % 3 and v % 5:
        print('DENIED')
        break
else:
    print('APPROVED')
# Judge status: Accepted
n,k = map(int,input().split())
h = list(map(int,input().split()))


h = sorted(h,reverse = True)
h = h[k:]
print(sum(h))
# Judge status: Accepted
def main():
    n, m = map(int, input().split())
    ans = 0
    if m >= 2*n:
        ans += n
        m -= 2*n
        n = 0
    else:
        ans += m // 2
        m -= ans * 2
    ans += m // 4
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import sys
n = input()
a = [list(map(int,raw_input().split())) for i in range(2)]
if n ==1: 
    print a[0][0]+a[1][0]
    sys.exit()
x = 0
y = 0
total = a[0][0]
while 1:
    right = sum(a[y][i] for i in range(x+1,n))+a[1][n-1] if x != n-1 else 0
    down = sum(a[1][i] for i in range(x,n)) if y != 1 else 0
    if right > down:
        x += 1
        total += a[y][x]
    else:
        total += down
        break
print total
# Judge status: Accepted
N=int(input())
s=input()
R=s.count("R")
G=s.count("G")
B=s.count("B")
ans=R*G*B
 
#全探索する
for i in range(N-2):
  a=s[i]
  for j in range(i+1,N-1):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if k>=N:
      continue
    if s[k]!=a and s[k]!=b:
      ans-=1
print(ans)
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())
count1 = Counter(s)
count2 = Counter(t)
ans = -1 * M
for key in count1.keys():
    ans = max(ans, count1[key] - count2[key])
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ca = cb = 0
for i in range(n):
    if a[i] > b[i]:
        ca += a[i] - b[i]
    elif a[i] < b[i]:
        cb += (b[i] - a[i])//2
if cb >= ca:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def solve():
  N = int(input())
  S = input()
  T = input()
  for i in range(N):
    if S[i:]==T[:N-i]:
      return N+i
  return N*2
print(solve())
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans_lis = []
count = 1
before = A[0]
for i in range(1,N):
  tmp = A[i]
  if tmp == before:
    count += 1
  else:
    if count == 2 or count == 3:
      ans_lis.append(tmp)
    elif count == 4 and len(ans_lis) == 0:
      ans_lis.append(tmp)
      ans_lis.append(tmp)
    count = 0
  if len(ans_lis) == 2:
    break
  before = tmp
if len(ans_lis) < 2:
  print(0)
else:
  print(ans_lis[0] * ans_lis[1])
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

A.sort()

if A[0] == max(A):
    print(A[0])
else:
    ans = 2
    for i in range(N):
        if A[i] % 2 == 1:
            ans = 1
            break
    print(ans)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
l.sort()
s=0
c=0
s+=l[-1]
t=0
for i in range(n-2,n//2-1,-1):
    s+=l[i]*2
    #print(l[i]*2)
if (n%2):
    s-=l[n//2]
    #print(l[n//2])
print(s)
# Judge status: Wrong Answer
a, b, c, x, y = map(int, input().split())

ans = 10**5
for i in range(10**5):
    tmp = 2*c*i + max((x-i), 0)*a + max((y-i), 0)*b
    if x < i and y < i:
            break
    ans = min(ans, tmp)
print(ans)
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

s = 0
cnt = 0
for i in a:
    s += i
    if s > x:
        break
    cnt += 1

if s < x:
    cnt -= 1    
print(cnt)
# Judge status: Accepted
def resolve():
    n = int(input())
    ans = [0] * n
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                a = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if a <= n:
                    ans[a - 1] += 1
    for i in ans:
        print(i)


if __name__ == '__main__':
    resolve()
# Judge status: Wrong Answer
N=int(input())
ans=''
while N:
  ans=str(N%2)+ans
  N//=(-2)
print(ans)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

cnt = 0
while True:
    if (A == B) & (B == C):
        print(-1)
        exit(0)
    elif (A % 2) | (B % 2) | (C % 2):
        print(cnt)
        exit(0)
    else:
        a, b, c = A // 2, B // 2, C // 2
        A, B, C = b + c, a + c, a + b
        cnt += 1
print(cnt)
# Judge status: Accepted
def solve():
    x,n=map(int,input().split())
    if not n==0:
        p=list(map(int,input().split()))
    else:
        print(x)
        return
    
    for i in range(0,100):
        
        if not (x-i) in p:
            print(x-i)
            return
        
        if not (x+i) in p:
            print(x+i)
            return
        
        
solve()
# Judge status: Accepted
s=input()
t=input()
k=len(t)
for i in range(len(s)-len(t)+1):
    q=0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            q+=1
    if k>q:
        k=q
print(k)
# Judge status: Wrong Answer
n=int(input())

nodes=[1]

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

for i in range(n):
    nodes.append(pow(2,i))

nodes = list(reversed(nodes))
a=list(reversed(a))

for i in range(n):
    if i==0:
        nodes[i] = a[i]
    else:
        if (nodes[i-1] + a[i])<=pow(2,n-i):
            nodes[i] = (nodes[i-1] + a[i])
        else:
            nodes[i] = pow(2,n-i)

# print(nodes)

print(sum(nodes))
# Judge status: Accepted
x = input().split()
n, m = int(x[0]), int(x[1])
if n==1:
  if m==1:
    print(1)
  else:
  	print(m-2)
elif m==1:
  if n==1:
    print(1)
  else:
    print(n-2)
else:
	print((n-2)*(m-2))
# Judge status: Wrong Answer
N = int(input())
print(int(N * (N-1) / 2))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
import itertools
b = list(itertools.accumulate(a))
for i in range(n):
  b[i] = abs(2*b[i]-b[-1])
print(min(b))
# Judge status: Wrong Answer
x,n = map(int,input().split())
if n==0:
    print(x)
else:
    p = list(map(int,input().split()))
    for i in range(1,n+10):
        if x - i not in p:
            print(x-i)
            break
        elif x + i not in p:
            print(x+i)
            break
# Judge status: Accepted
n, a, b = map(int, input().split())
if a+b == 0:
  x = 0
else:
	s = n//(a+b)
	t = n%(a+b)
	if t <= a:
		x = s*a+t
	else:
		x = s*a+a
print(x)
# Judge status: Accepted
n = int(input())
x = [0]*n
y = [0]*n
for i in range(n-1, -1, -1):
  a,b = map(int, input().split())
  x[i] = a
  y[i] = b

ans = 0
for i in range(n):
  if (x[i]+ans) % y[i] != 0:
    ans += y[i]-(x[i]+ans)%y[i]
print(ans)
# Judge status: Wrong Answer
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = 111
for i in range(N, 1000):
	if i//100==(i//10)%10:
		if i//100==i%10:
			print(i)
			sys.exit()

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
# Judge status: Accepted
n = int(input())
num = 0
flag = True
for _ in range(n):
    a,b = map(int,input().split())
    if a ==b:num +=1
    else: num =0
    if num ==3:
        flag= False
        print('Yes')
        break
if(flag):print('No')
# Judge status: Wrong Answer
N, K = map(int, input().split())
S = input()
X = S.count("RL")
Y = 0
if S[0] == "L":
    Y += 1
if S[-1] == "R":
    Y += 1

ans = 0
for a, b in zip(S, S[1:]):
    if a == b:
        ans += 1
ans += 2*max(K, X)
if K > X:
    ans += max(Y, K-X)
print(ans)
# Judge status: Accepted
a,b,c,d = map(int,input().split())

if abs(a-c) <= d:
    print('Yes')
elif abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))
l=[0]*N
for i in range(N):
    if a[i]%4:
        if a[i]%2:l[i]=1
        else:l[i]=2
    else:l[i]=4
print('Yes'if(l.count(1)+(1 if l.count(2)else 0)+1)<=l.count(4)else'No')
# Judge status: Accepted
s = input()
print(int(s.count('1')))
# Judge status: Wrong Answer
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    S = list(sys.stdin.readline())

    ret = []
    for s in S:
        n = ord(s) + N
        ret.append(chr(((n - 65)%26)+65))

    test = []
    for s in S:
        n = ord(s) - 65 + N
        test.append(chr(65 + n % 26))

    # print("".join(ret))
    print("".join(test))


if __name__ == '__main__':
    main()
# Judge status: Accepted
S = input()
ans = float('inf')

for i in range(len(S)-2):
    ans = min(ans, abs(753 - int(S[i:i+3])))

print(ans)