Harryxun/stf_run huggingface dataset:
import re
S = input()

po=[]
ne=[]
li = [m.span()[0] for m in re.finditer('><', S)]
result = []

n = 0
for i in S:
    if i == "<":
        n += 1
    else:
        po.append(n)
        break
for i in li:
    s = "<"
    n = 0
    while s == S[i+1]:
        n += 1
        i += 1
        if i+1 >= len(S):
            break
    po.append(n)
for i in li:
    s = ">"
    n = 0
    while s == S[i]:
        n += 1
        i -= 1
    ne.append(n)
n = 0
for i in S[::-1]:
    if i == ">":
        n += 1
    else:
        ne.append(n)
        break
if len(po) == 0:
    result.append((1/2)*ne[i]*(ne[i]+1))
if len(ne) == 0:
    result.append((1/2)*po[i]*(po[i]+1))
for i,l in enumerate(po):
    if l < ne[i]:
        if l > 0:
            result.append((1/2)*(l-1)*l)
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]+1))
    else:
        if l > 0:
            result.append((1/2)*l*(l+1))
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]-1))
print(int(sum(result)))

### FIXED CODE ###

import re
S = input()

po=[]
ne=[]
li = [m.span()[0] for m in re.finditer('><', S)]
result = []
n = 0
for i in S:
    if i == "<":
        n += 1
    else:
        break
po.append(n)
for i in li:
    s = "<"
    n = 0
    while s == S[i+1]:
        n += 1
        i += 1
        if i+1 >= len(S):
            break
    po.append(n)
for i in li:
    s = ">"
    n = 0
    while s == S[i]:
        n += 1
        i -= 1
        if i < 0:
            break
    ne.append(n)
n = 0
for i in S[::-1]:
    if i == ">":
        n += 1
    else:
        break
ne.append(n)
for i,l in enumerate(po):
    if l < ne[i]:
        if l > 0:
            result.append((1/2)*(l-1)*l)
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]+1))
    else:
        if l > 0:
            result.append((1/2)*l*(l+1))
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]-1))
print(int(sum(result)))
H, W, K = map(int, input().split())
cake = []
for _ in range(W):
    cake.append(input())
ans = []
count = 1
flg = False
for i in range(H):
    tmp = []
    for k in range(W):
        if flg and cake[i][k] == '#':
            count += 1
            tmp.append(count)
            flg = False
            continue
        if cake[i][k] == '#':
            flg = True
            tmp.append(count)
        else:
            tmp.append(count)
    flg = False
    count += 1
    ans.append(tmp)
for i in ans:
    for k in i:
        print(k,end=" ")
    print()

### FIXED CODE ###

H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]
ans = [[0]*W for _ in range(H)]
empty_index = [False]*H
first_flg = False
cnt = 0
for i in range(H):
    if '#' not in grid[i]:
        empty_index[i] = True
for i in range(H):
    if not empty_index[i] and not first_flg:
        first_flg = True
        first_index = i
    if not first_flg:
        continue
    if empty_index[i]:
        for k in range(W):
            ans[i][k] = ans[i-1][k]
    else:
        cnt += 1
        flg = False
        for k in range(W):
            if grid[i][k] == '#':
                if not flg:
                    flg = True
                else:
                    cnt += 1
            ans[i][k] = cnt
for i in range(H):
    if not empty_index[i]:
        break
    for k in range(W):
        ans[i][k] = ans[first_index][k]
for i in ans:
    print(*i)
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
mod=10*9+7
min=0
max=0
from math import factorial
for i in range(n-k):
   min+=(l[i]*(factorial(n-i-1)/factorial(k)/factorial(n-k-i-1)))%mod
   max+=(l[n-i]*(factorial(n-i-1)/factorial(k)/factorial(n-k-i-1)))%mod
   max=max%mod
   min=min%mod
print((max-min)%mod)

### FIXED CODE ###

n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
mod=10**9+7
n_max=2*10**5
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
  FI[i+1]=pow(F[i+1],mod-2,mod)
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod
total=0
for i in range(n-k+1):
   f=comb(n-i-1,k-1)%mod
   total+=int((l[n-i-1]-l[i])*f)
   total%=mod
print(total)
n = int(input())
 
c = [int(input()) for _ in range(n)]
b = min(c)

if b >= n:
  print(5)
else:
  t = (n - b) // b
  if t % b != 0:
    t += 1
  print(t + 5)

### FIXED CODE ###

n = int(input())
l = [int(input()) for _ in range(5)]

b = min(l)
if b >= n:
    print(5)
else:
    t = (n - b) // b
    if (n -b) % b != 0:
        t += 1
    print(t + 5)
x = input()
x = x*x*x
print(x)


### FIXED CODE ###

x = int(input())
print(x*x*x)
h,w = map(int,input().split())
lst = []
for i in range(h):
  lst.append([s for s in input()])
def dfs(x,y):
  if lst[x][y] == '#':
    lst[x][y] = '.'
    if x + 1 <= h - 1:
      dfs(x + 1,y)
    if x - 1 >= 0:
      dfs(x - 1,y)
    if y + 1 <= w - 1:
      dfs(x, y + 1)
    if y - 1 >= 0:
      dfs(x,y - 1)
flag = True
for i in range(h):
  for j in range(w):
    if lst[i][j] == '#':
      if (i - 1 >= 0 and lst[i - 1][j] == "#") or (i + 1 < h and lst[i + 1][j] == "#") or (j - 1 >= 0 and lst[i][j - 1] == "#") or (j + 1 < w and lst[i][j + 1] == "#"):
        dfs(i,j)
      else:
        flag = False
        break
if flag:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
h,w = map(int,input().split())
lst = []
for i in range(h):
  lst.append([s for s in input()])
def dfs(x,y):
  if lst[x][y] == '#':
    lst[x][y] = '.'
    if x + 1 <= h - 1:
      dfs(x + 1,y)
    if x - 1 >= 0:
      dfs(x - 1,y)
    if y + 1 <= w - 1:
      dfs(x, y + 1)
    if y - 1 >= 0:
      dfs(x,y - 1)
flag = True
for i in range(h):
  for j in range(w):
    if lst[i][j] == '#':
      if (i - 1 >= 0 and lst[i - 1][j] == "#") or (i + 1 < h and lst[i + 1][j] == "#") or (j - 1 >= 0 and lst[i][j - 1] == "#") or (j + 1 < w and lst[i][j + 1] == "#"):
        dfs(i,j)
      else:
        flag = False
        break
if flag:
  print("Yes")
else:
  print("No")
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N - 1)]
px = [list(map(int, input().split())) for i in range(Q)]

root = [[] for _ in range(N + 1)]
result = [0] * (N + 1)

for i in range(N - 1):
    a = ab[i][0]
    b = ab[i][1]
    root[a].append(b)
    root[b].append(a)

for i in range(Q):
    p = px[i][0]
    x = px[i][1]
    result[p] = result[p] + x


def dfs(now, prev):
    for next in root[now]:
        if next == prev:
            continue
        else:
            result[next] = result[next] + result[now]
            dfs(next, now)


dfs(1, -1)
print(*result[1:])

### FIXED CODE ###

N, Q = map(int,input().split()) # 複数の数字を変数に格納
List_ab = [list(map(int,input().split())) for i in range(N-1)] # [[1,2],[3,4],[5,6]]
List_px = [list(map(int,input().split())) for i in range(Q)] # [[1,2],[3,4],[5,6]]

count_list = [0]*N

List_ab.sort()

for i in range(Q):
    count_list[List_px[i][0]-1] += List_px[i][1]
        
for i in range(N-1):
    count_list[List_ab[i][1]-1] += count_list[List_ab[i][0]-1]
    
print(*count_list)
a, b, c, d, e, f = map(int, input().split())

n = f//(100*a)
m = f//(100*b)
p = f//c
q = f//d

mx = 0
for k in range(p+1):
    for l in range(q+1):
        for i in range(n+1):
            for j in range(m+1):
                if i == 0 and j == 0:
                    continue
                s = 100*a*i+100*b*j
                t = c*k+d*l
                u = 100*t/s
                if s + t> f:
                    continue
                if u > e:
                    continue
                if mx < u:
                    mx = u
                    ans1, ans2 = s+t, t
                    if mx == e:
                        print(ans1, ans2)
                        exit()
print(ans1, ans2)


### FIXED CODE ###

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

n = f//(100*a)
m = f//(100*b)
p = f//c
q = f//d

mx = 0
state = True
for k in range(p+1):
    for l in range(q+1):
        for i in range(n+1):
            for j in range(m+1):
                if i == 0 and j == 0:
                    continue
                s = 100*a*i+100*b*j
                t = c*k+d*l
                u = 100*t/s
                if s + t> f:
                    continue
                if u > e:
                    continue
                if mx < u:
                    state = False
                    mx = u
                    ans1, ans2 = s+t, t
                    if mx == e:
                        print(ans1, ans2)
                        exit()
if state:
    print(100*a, 0)
else:
    print(ans1, ans2)
(n, k) = map(int, input().split())
s = list(input())
s[k] = s[k].lower()
print("".join(s))

### FIXED CODE ###

(n, k) = map(int, input().split())
s = list(input())
s[k-1] = s[k-1].lower()
print("".join(s))
n=int(input())
A=list(map(int, input().split()))
B=sorted(A)
for i in range(n+1):
  if B[i]!=i+1:
    a=i
    break
d=[i for i, x in enumerate(A) if x==a]
x=d[0]
y=d[1]

def cmb(n,r,mod):
    if (r<0 or r>n):
      return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7 #出力の制限
N=10**4
g1=[1,1] # 元テーブル
g2=[1,1] #逆元テーブル
inverse=[0,1] #逆元テーブル計算用テーブル

for i in range(2,N+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

for i in range(1,n+2):
  print(cmb(n+1,i,mod)-cmb(x+(n-y),i-1,mod))  

### FIXED CODE ###

n=int(input())
A=list(map(int, input().split()))
B=sorted(A)
for i in range(n+1):
  if B[i]!=i+1:
    a=i
    break
d=[i for i, x in enumerate(A) if x==a]
x=d[0]
y=d[1]

def cmb(n,r,mod):
    if (r<0 or r>n):
      return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod

mod=10**9+7 #出力の制限
N=10**5+10
g1=[1,1] # 元テーブル
g2=[1,1] #逆元テーブル
inverse=[0,1] #逆元テーブル計算用テーブル

for i in range(2,N+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

for i in range(1,n+2):
  ans=cmb(n+1,i,mod)-cmb(x+(n-y),i-1,mod)
  if ans<0:
    print(mod+ans)
  else:
    print(ans)
import sys

mod = int(1e9+7)

def dfs(i,dp,bad):
    if i == 0:
      return 1
    if i in dp:
      return dp[i]
    dp[i] = 0
    for d in (1,2):
      x = i-d;
      if 0 <= x and x not in bad:
        dp[i] += dfs(x,dp,bad)
        dp[i] %= mod
    return dp[i]

n,m = [int(a) for a in input().split()]
bad = set()
for _ in range(m):
  a = int(input())
  bad.add(a)
print(dfs(n,dict(),bad))


### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

mod = int(1e9+7)

def dfs(i,dp,bad):
    if i == 0:
      return 1
    if i in dp:
      return dp[i]
    dp[i] = 0
    for d in (1,2):
      x = i-d;
      if 0 <= x and x not in bad:
        dp[i] += dfs(x,dp,bad)
        dp[i] %= mod
    return dp[i]

n,m = [int(a) for a in input().split()]
bad = set()
for _ in range(m):
  a = int(input())
  bad.add(a)
print(dfs(n,dict(),bad))
X = int(input())
H = X / 3600
X = X%3600
M = X / 60
X %= 60
print(H":",M":",,X":")


### FIXED CODE ###

X = int(input())
H = X // 3600
X = X%3600
M = X // 60
X %= 60
print(str(H)+":"+str(M)+":"+str(X))
word = input()
a,b = 0

for i in word:
    if i == "A":
        a=a+1
    elif i == "B":
        b=b+1

if a==0 or b==0:
    print("No")
else:
    print("Yes")


### FIXED CODE ###

word = input()

if word[0] == word[1] and word[1] == word[2] and word[0] == word[2]:
    print("No")
else:
    print("Yes")
a, b, k = map(int, input().split())

x = min(a, k)
a -= x
k -= x
y = min(b, k)
b -= y

print(str(a),str(b))

### FIXED CODE ###

n = int(input())
S, T = input().split()

ans = ""

for i in range(n):
    ans += S[i]+T[i]
    
print(ans)
s = int(input())
w = int(input())
if w >= s:
    print("unsafe")
else:
    print("safe")

### FIXED CODE ###

S,W = map(int, input().split())
print("unsafe" if W >= S else "safe")
s=input()
ans=1
n=len(s)

for i in range(0,n):
    if s[i] in {'A','T','C','G',''}:
        if i==n:
            ans+=1
        elif s[i+1] in {'A','T','C','G',''}:
            ans+=1

if ans>1:
    print(ans)
else:
    print(0)

### FIXED CODE ###

s=input()
ans=0
ans_list=[]
n=len(s)


for i in range(0,n):
    if s[i] not in {'A','T','C','G',' '}:
        ans_list.append(ans)
        ans=0
#        print(str(ans)+'!')
    else:
        ans+=1
        if i == n-1:
           ans_list.append(ans) 
 #       print(str(ans)+'z')

#print(ans_list)
if max(ans_list)==0:
    print(0)
else:
    print(max(ans_list))
N,M=map(int, input().split())

fi=True
inl=[[] for _ in range(N+1)]
inr=[[] for _ in range(N+1)]
pos=[None for _ in range(N+1)]
det=set()

for _ in range(M):
	l,r,d=map(int, input().split())
	inl[l].append((l,r,d))
	inl[r].append((l,r,d))

	if fi:
		fi=False
		det.add(l)
		det.add(r)
		pos[l]=0
		pos[r]=d

ans = "Yes"

while len(det) > 0 and ans == "Yes":
	p = det.pop()

	for l,r,d in inl[p]:
		if pos[r] is not None:
			if pos[r] != pos[l] + d:
				ans = "No"
				break
		else:
			pos[r] = pos[l] + d
			det.add(r)

	for l,r,d in inr[p]:
		if pos[l] is not None:
			if pos[l] != pos[r] - d:
				ans = "No"
				break
		else:
			pos[l] = pos[r] - d
			det.add(l)

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1145141919)

N,M=map(int, input().split())

path=[[] for _ in range(N+1)]

for _ in range(M):
	l,r,d=map(int, input().split())
	path[l].append((r,+d))
	path[r].append((l,-d))

cost=[None for _ in range(N+1)]

def walk(i, c):
	if cost[i] is None:
		cost[i] = c
		for j,d in path[i]:
			if not walk(j, c+d):
				return False
	return cost[i] == c

ans = "Yes"

for i in range(1, N+1):
	if cost[i] is None and not walk(i, 0):
		ans = "No"
		break

print(ans)
import numpy as np
N, A = map(int, input().split())
x = list(map(int, input().split()))

X = max(x)
if X < A:
    X = A

def check(j, k, s):
    if dp[j][k][s] != -1:
        return dp[j][k][s]
    if j == 0 and k == 0 and s == 0:
        dp[j][k][s] = 1
        return 1
    if j >= 1 and s < x[j-1]:
        a = check(j-1, k ,s)
        dp[j][k][s] = a
        return a
    if j >= 1 and k >= 1 and s >= x[j-1]:
        a = check(j-1, k, s) + check(j-1, k-1, s-x[j-1])
        dp[j][k][s] = a
        return a
    dp[j][k][s] = 0
    return 0
        
dp = [[[-1] * (N*X+1) for _ in range(N+1)] for _ in range(N + 1)]
dp = np.array(dp)
# print (dp)
# for j in range(N+1):
#     for k in range(N+1):
#         for s in range(N*X + 1):
#             print (j, k, s)
#             dp[j][k][s] = check(j, k, s)

ans = 0
for k in range(1, N+1):
    ans += check(N, k, k * A)
    # ans += dp[N][k][k * A]

print (ans)

### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

ans = X * min(K, N) + Y * max(N-K, 0)

print (ans)
n,m=map(int,input().split())
l=[]
for i in range(1,m//n+1):
  if m%i==0:
    l.append(i)
print(max(i))

### FIXED CODE ###

def make_divisors(n,m):
    divisors = []
    for i in range(1,min(int(m**(1/2))+1,int(m//n)+1)):
      if m % i == 0:
          divisors.append(i)
          if i != m // i and m//i<=m//n:
              divisors.append(m//i)
    return divisors
n,m=map(int,input().split())
print(max(make_divisors(n,m)))
a, b, c = map(int,raw_input().split())
if a > b > c:
    print a b c
elif a > c > b:
    print a c b
elif b > a > c:
    print b a c
elif b > c > a:
    print b c a
elif c > a > b:
    print c a b
else:
    print c b a

### FIXED CODE ###

a = map(int,raw_input().split())
a.sort()
for i in xrange(3):
          print a[i],
s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if ord("z") - ord(sArr[i]) + 1 <= K:
        K -= ord("z") - ord(sArr[i]) + 1
        sArr[i] = "a"

while K > 0:
    if ord("z") - ord(sArr[endpoint]) >= K:
        sArr[endpoint] = chr(ord(sArr[endpoint]) + K)
        K = 0
    else:
        sArr[endpoint] = "z"
        K -= ord("z") - ord(sArr[endpoint])
        endpoint -= 1

for j in range(len(sArr)):
    result += sArr[j]

print(result)

### FIXED CODE ###

s = input()
K = int(input())

sArr = list(s)
endpoint = len(sArr) - 1
result = ""

for i in range(len(sArr)):
    if K == 0:
        break
    else:
        if (123 - ord(sArr[i])) <= K:
            K -= (123 - ord(sArr[i])) % 26
            sArr[i] = "a"

if K > 0:
    K %= 26
    sArr[endpoint] = chr(ord(sArr[endpoint]) + K)

for j in range(len(sArr)):
    result += sArr[j]

print(result)
x,k,d=map(int,input().split())

x=abs(x)

if x>k*d:
    print(x-k*d)
else:
    r=k-x//d
    if r%2==0:
        print(x%d)
    else:
        print(d-x%d)


### FIXED CODE ###

S=input()
S=list(S)
c=0
max=0
for i in S:
    if i=="R":
        c+=1
    else:
        if max<c:
            max=c
            c=0

if max<c:
    max=c
    c=0

print(max)
import sys
K = int(input())
if K < 10:
    print(K)
    sys.exit()
lst = [[str(i)] for i in range(10)]
i = 9
while True:
    new_lst = [[] for j in range(10)]
    for j in range(10):     #0-9までについて
        for k in range(-1, 2):  #-1, 0, +1の3つについて
            if j == 0 and k == -1:
                continue
            if j == 9 and k == 1:
                break
            for l in lst[j+k]:
                tmp = str(j) + str(l)
                new_lst[j].append(tmp)
                # print(i, K , i == K)
                if j != 0:
                    i += 1
                    if i == K:
                        print(int(tmp))
                        sys.exit()
    # print(i, new_lst)
    lst = new_lst.copy()

### FIXED CODE ###

import sys
K = int(input())
if K < 10:
    print(K)
    sys.exit()
lst = [[str(i)] for i in range(10)]
i = 9
while True:
    new_lst = [[] for j in range(10)]
    for j in range(10):     #0-9までについて
        for k in range(-1, 2):  #-1, 0, +1の3つについて
            if j == 0 and k == -1:
                continue
            if j == 9 and k == 1:
                break
            for l in lst[j+k]:
                tmp = str(j) + str(l)
                new_lst[j].append(tmp)
                # print(i, K , i == K)
                if j != 0:
                    i += 1
                    if i == K:
                        print(int(tmp))
                        sys.exit()
    # print(i, new_lst)
    lst = new_lst.copy()
s = input()
t = input()
n = len(s)
m = len(t)
cnt = 10000
for i in range(n-m+1):
	st = s[i:i+m]
    if st == t:
      cnt = 0
      break
    else:
      temp = 0
      for j in range(m):
        if t[j] != st[j]:
          temp += 1
      cnt = min(cnt,temp)
print(cnt)
		
      

### FIXED CODE ###

#_______________________________________________________________#
def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x-1)
def lower_bound(li, num): 
	answer = -1
	start = 0
	end = len(li)-1

	while(start <= end):
		middle = (end+start)//2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer #index where x is not less than num
def upper_bound(li, num): 
	answer = -1
	start = 0
	end = len(li)-1

	while(start <= end):
		middle = (end+start)//2

		if li[middle] <= num:
			answer = middle
			start = middle + 1
		
		else:
			end = middle - 1
	return answer #index where x is not greater than num

def abs(x):
	return x if x >=0 else -x
def binary_search(li, val, lb, ub): 
	ans = 0
	while(lb <= ub):
		mid = (lb+ub)//2
		#print(mid, li[mid])
		if li[mid] > val:
			ub = mid-1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
def kadane(x): #maximum sum contiguous subarray
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far,current_sum)
	return sum_so_far
def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

#_______________________________________________________________#
'''
      ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
   ▄███████▀▀▀▀▀▀███████▄
░▐████▀▒▒Aestroix▒▒▀██████
░███▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀████
░▐██▒▒▒▒▒KARMANYA▒▒▒▒▒▒████▌         ________________
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌  ? ?   |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒|
░░█▒▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▒▐███▌   ?    |___CM ONE DAY___|
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▒▐███▌     ? ? |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒|
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌    ? ?    
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌      ? 
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█     ? ? 
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀       ? 
░░░░▄█████████ ████=========█▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
░░░░░████████████████
'''
from math import *
#for _ in range(int(input())):
for _ in range(1):
	#n = int(input())
	#p,f = map(int,input().split())
	#d,t,s = map(int,input().split())
	#ws,wa = map(int,input().split())
	#b = list(input())
	#x = int(input())
	#n = len(b)
	#s2 = input()
	#r, g, b, w = map(int,input().split())
	#a = list(map(int,input().split()))
	#b = list(map(int,input().split()))
	#s1 = list(st)
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	cnt = 10000
	for i in range(n-m+1):
		st = s[i:i+m]
		if st == t:
			cnt = 0
			break
		else:
			temp = 0
			for j in range(m):
				if st[j] != t[j]:
					temp += 1
			cnt = min(cnt,temp)
	print(cnt)
a=[[[0]*10]*3]*4
for _ in range(int(input())):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]=v
for i in range(4):
 for j in range(3):
  print(' '.join(a[i][j]))
 if i!=3:print('#'*20)

### FIXED CODE ###

a=[[10*[0]for _ in[0]*3]for _ in[0]*4]
for _ in[0]*int(input()):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):print('',*a[i][j])
 if i<3:print('#'*20)
n = int(input())
x = list(map(int, input().split()))
l1 = min(x)
l2 = max(x)
ans = 0
for i in range(l1, l2+1):
    for j in x:
        sum += (i-j)**2
    if sum > ans:
        ans = sum
print(ans)

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
l1 = min(x)
l2 = max(x)
ans = 100000000
for i in range(l1, l2+1):
    sum = 0
    for j in x:
        sum += (i-j)**2
    if sum < ans:
        ans = sum
print(ans)
def solve(height, road):
    graph = collections.defaultdict(set)
    for a, b in road:
        graph[a].add(b)
        graph[b].add(a)
    ans = 0
    no_good = set()
    for k in graph:
        for nei in graph[k]:
            if height[nei-1] >= height[k-1]:
                no_good.add(k)
    return len(height) -  len(no_good)

obs, k = map(int, input().split())
height = list(map(int, input().split()))
road = []
for _ in range(k):
    r = list(map(int, input().split()))
    road.append(r)
print(solve(height, road))


### FIXED CODE ###

import collections

def solve(height, road):
    graph = collections.defaultdict(set)
    for a, b in road:
        graph[a].add(b)
        graph[b].add(a)
    ans = 0
    no_good = set()
    for k in graph:
        for nei in graph[k]:
            if height[nei-1] >= height[k-1]:
                no_good.add(k)
    return len(height) -  len(no_good)

obs, k = map(int, input().split())
height = list(map(int, input().split()))
road = []
for _ in range(k):
    r = list(map(int, input().split()))
    road.append(r)
print(solve(height, road))
import math

a, b, c, d = map(int, input().split())
r = 0
bc = b // c
bd = b // d
bcd = b // ((c * d) // math.gcd(c, d))
ac = -(-a // c)
ad = -(-a // d)
acd = -(-a // ((c * d) // math.gcd(c, d)))
print(b - a + 1 - bc + ac - 1 - bd + ad - 1 + bcd - acd + 1)


### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

a, b, c, d = map(int, input().split())
r = 0
bc = b // c
bd = b // d
bcd = b // lcm(c, d)
ac = -(-a // c)
ad = -(-a // d)
acd = -(-a // lcm(c, d))
print(b - a + 1 - bc + ac - 1 - bd + ad - 1 + bcd - acd + 1)