Harryxun/stf_run huggingface dataset:
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)
def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

      
from collections import defaultdict
 
N, K, L = map(int, input().split())

# 道路のUnionFind
uf1 = UnionFind(N)
for i in range(K):
    p, q = map(int, input().split())
    uf1.union(p - 1, q - 1)
 
# 鉄道のUnionFind
uf2 = UnionFind(N)
for i in range(L):
    r, s = map(int, input().split())
    uf2.union(r - 1, s - 1)
 
# 道路と鉄道の連結の組み合わせ（根のペアのカウント）
c = {}
for i in range(N):
    if (uf1.find(i), uf2.find(i)) in c:
      c[(uf1.find(i), uf2.find(i))] += 1
    else:
      c[(uf1.find(i), uf2.find(i))] = 1      

# 回答を出力
for i in range(N):
    print(c[(uf1.find(i), uf2.find(i))])

### FIXED CODE ###

from collections import defaultdict
 
N, K, L = map(int, input().split())

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)
    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

# 道路のUnionFind
uf1 = UnionFind(N)
for i in range(K):
    p, q = map(int, input().split())
    uf1.union(p - 1, q - 1)
 
# 鉄道のUnionFind
uf2 = UnionFind(N)
for i in range(L):
    r, s = map(int, input().split())
    uf2.union(r - 1, s - 1)
 
# 道路と鉄道の連結の組み合わせ（根のペアのカウント）
c = defaultdict(int)
for i in range(N):
    c[(uf1.find(i), uf2.find(i))] += 1

# 回答を出力
for i in range(N):
    print(c[(uf1.find(i), uf2.find(i))])
N = int(input())
*H, = map(int, input().split())

dp = [-1]*N

#動的計画法
#メモ化再帰
def dfs(n):#足場nまでにたどり着くのに必要なコスト
    if dp[n]!=-1:
        return dp[n]

    if n==0:
        return 0
    if n-1==0:
        return abs(H[n]-H[n-1])

    ret = min(abs(H[n]-H[n-1])+dfs(n-1), abs(H[n]-H[n-2])+dfs(n-2))
    dp[n] = ret
    return ret

print(dfs(N-1))

### FIXED CODE ###

N = int(input())
*h, = map(int, input().split())

dp = [0] * N

for i in range(1, N, 1):
        if i==1:
                dp[i]=abs(h[i]-h[i-1])
        else:
                dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])
import sys
import numpy as np



def main(N, dp):
    dp=np.zeros((2,len(N)),dtype=np.int64)
    dp[0, 0] = min(N[0], 11 - N[0])
    dp[0, 1] = min(N[0] + 1, 10 - N[0])
    for i in range(1, len(N)):
        dp[i, 0] = min(dp[i - 1, 0] + N[i], dp[i - 1, 1] + 10 - N[i])
        dp[i, 1] = min(dp[i - 1, 0] + N[i] + 1, dp[i - 1, 1] + 9 - N[i])
    print(dp[-1][0])


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8,i8[:],)')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    #from my_module import main
    N = np.array([int(_) for _ in input()])
    main(N)


### FIXED CODE ###

N = [int(_) for _ in input()]
dp = [[0, 0] for _ in range(len(N))]
dp[0][0] = min(N[0], 11 - N[0])
dp[0][1] = min(N[0] + 1, 10 - N[0])
for i in range(1, len(N)):
    dp[i][0] = min(dp[i - 1][0] + N[i], dp[i - 1][1] + 10 - N[i])
    dp[i][1] = min(dp[i - 1][0] + N[i] + 1, dp[i - 1][1] + 9 - N[i])
print(dp[-1][0])
a, b = input().split()
print(max(a+b,a-b,a*b))


### FIXED CODE ###

a, b = map(int,input().split())
print(max(a+b,a-b,a*b))
S = input()
K = int(input())

print(S * K)

X = []
b = S[0]
cnt = 1
for i in range(1, len(S)):
    s = S[i]
    if b == s:
        cnt += 1
    else:
        X.append([b, cnt])
        cnt = 1
        b = s
X.append([b, cnt])

result = 0
for x in X:
    result += x[1] // 2

result = result * K
if X[0][0] == X[-1][0]:
    result += 1
print(result)


### FIXED CODE ###

S = input()
K = int(input())

X = []
b = S[0]
cnt = 1
for i in range(1, len(S)):
    s = S[i]
    if b == s:
        cnt += 1
    else:
        X.append([b, cnt])
        cnt = 1
        b = s
X.append([b, cnt])

result = 0
if len(X) == 1:
    print(X[0][1] * K // 2)
elif X[0][0] == X[-1][0]:
    s = X.pop(0)
    e = X.pop()
    for x in X:
        result += x[1] // 2
    result *= K

    result += s[1] // 2
    result += e[1] // 2
    x = (s[1] + e[1]) // 2
    result += x * (K - 1)
    print(result)
else:
    for x in X:
        result += x[1] // 2
    result *= K
    print(result)
= list(input())
L = len(A)

ans = 'WA'
flag = 0
f = 0
count = 0
if A[0] == 'A':
    flag = flag + 1

for i in range(2,L-1):
    if A[i] == 'C':
        count = count + 1
        if f == 0:
            j = i
            f = 1
if count == 1:
    flag = flag + 1

count = 0
for i in range(1,L-1):
    if A[i].islower():
        conut = count + 1
        if i == j:
            count = count - 1
if count == 0:
    flag = flag + 1

if flag == 3:
    ans = 'AC'
    
print(ans)

### FIXED CODE ###

A = list(input())
L = len(A)

ans = 'WA'
flag = 0
f = 0
j = 0

if A[0] == 'A':
    if A[0].isupper():
        flag = flag + 1
#print(flag)
count = 0
i=2
while(1):
    if A[i] == 'C':
        if A[i].isupper():
            count = count + 1
    i = i + 1
    if (L-2-i < 0):
        break
#print(count)
if count == 1:
    flag = flag + 1
#print(flag)
count = 0
for i in range(1,L):
    #print(A[i].isupper())
    if A[i].isupper():
        count = count + 1
#print(count)
if count == 1:
    flag = flag + 1
#print(flag)
if flag == 3:
    ans = 'AC'

print(ans)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

# もしすべてaから選んだ場合
time = k
aOnly = 0
for i in range(len(a)):
    time -= a[i]
    if time < 0:
        time += a[i]
        i -= 1
        break
    aOnly += 1
a_idx = i
b_idx = -1

for i in range(len(b)):
    time -= b[i]
    if time < 0:
        time += b[i]
        i -= 1
        break
    aOnly += 1
b_idx = i
ans = aOnly

ans_kari = ans
for i in range(a_idx, -1, -1):
    time += a[i]
    ans_kari -= 1
    for j in range(b_idx+1, len(b)):
        time -= b[i]
        if time < 0:
            time += b[i]
            b_idx = i-1
            break
        ans_kari += 1
    ans = max(ans, ans_kari)
    
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

# もしすべてaから選んだ場合
time = k
aOnly = 0
for i in range(len(a)):
    time -= a[i]
    if time < 0:
        time += a[i]
        i -= 1
        break
    aOnly += 1
a_idx = i
b_idx = -1

for i in range(len(b)):
    time -= b[i]
    if time < 0:
        time += b[i]
        i -= 1
        break
    aOnly += 1
b_idx = i
ans = aOnly

ans_kari = ans
for i in range(a_idx, -1, -1):
    time += a[i]
    ans_kari -= 1
    for j in range(b_idx+1, len(b)):
        time -= b[j]
        if time < 0:
            time += b[j]
            b_idx = j-1
            break
        ans_kari += 1
    ans = max(ans, ans_kari)
    
print(ans)
import collections
from pprint import pprint as pp

N,M = tuple(map(int, input().split()))
#LRD = [tuple(map(int, input().split())) for _ in range(M)]

LRD = collections.defaultdict(list)
Lset = set()
Rset = set()
for _ in range(M):
  l,r,d = map(int, input().split())
  l -= 1
  r -= 1
  LRD[l].append((r,d))
  Lset.add(l)
  Rset.add(r)

n = [ None for _ in range(N) ]

def func(l):
  lst = LRD.pop(l)
  for r,d in lst:
    if n[l] != None:
      d2 = n[l] + d
    else:
      n[l] = 0
      d2 = d
    if n[r] not in (d2, None):
      return True
    n[r] = d2
    if r in LRD:
      if func(r):
        return True
  return False

def func2():
  lst = Lset-Rset
  for l in lst:
    n[l] = 0
  while lst:
    for l in lst:
      if func(l):
        return True
    Lset2 = set(LRD.keys())
    Rset2 = set(r for r,d in LRD)
    lst = Lset2-Rset2
  lst = tuple(LRD.keys())
  for l in lst:
    if l in LRD:
      if func(l):
        return True
  return False

if func2():
  print('No')
else:
  print('Yes')


### FIXED CODE ###

import collections
from pprint import pprint as pp

N,M = tuple(map(int, input().split()))
LRD = collections.defaultdict(list)
Lset = set()
Rset = set()
for _ in range(M):
  l,r,d = map(int, input().split())
  l -= 1
  r -= 1
  LRD[l].append((r,d))
  Lset.add(l)
  Rset.add(r)

n = [ None for _ in range(N) ]

deq = collections.deque()

def func(l):
  lst = LRD.pop(l,[])
  for r,d in lst:
    if n[l] != None:
      d2 = n[l] + d
    else:
      n[l] = 0
      d2 = d
    if n[r] not in (d2, None):
      return True
    n[r] = d2
    deq.append(r)
  return False

def func2():
  lst = Lset-Rset
  for l in lst:
    n[l] = 0
    deq.append(l)
  while deq:
    l = deq.popleft()
    if l in LRD:
      if func(l):
        return True
  deq.extend(LRD.keys())
  while deq:
    l = deq.popleft()
    if l in LRD:
      if func(l):
        return True
  return False

if func2():
  print('No')
else:
  print('Yes')
A, B = int(input())
if 2*B >= A:
  print(0)
else:
  print(A-(2*B))

### FIXED CODE ###

A, B = list(map(int, input().split())) 
if 2*B >= A:
  print(0)
else:
  print(A-(2*B))
H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())

from collections import defaultdict


y = [[] for i in range(W)]
x=0
left=-1

ans=1

for i in range(H):
    left=-1
    for j in range(W):
        if S[i][j]=='.' and left==-1:
            left=j
        elif (S[i][j]=='#' and left!=-1) or j==W-1:
            if S[i][j]=='#':
                x=j-left
            else:
                x=j-left+1

            for k in range(left,left+x):
                if y[i][k]!=0:
                    ans=max(ans,x+y[i][k]-1)
                else:
                    l=i+1
                    while l<H and S[l][k]==".":
                        l+=1
                    y_val=l-i
                    ans = max(ans,x+y_val-1)
                    for m in range(i+1,l):
                        y[m][k]=y_val
            left=-1

print(ans)



### FIXED CODE ###

H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())

L = [[0 for i in range(W)] for j in range(H)]
R = [[0 for i in range(W)] for j in range(H)]
U = [[0 for i in range(W)] for j in range(H)]
D = [[0 for i in range(W)] for j in range(H)]

ans=0

for i in range(H):
    for j in range(W):
        if S[i][j]=='.':
            if j==0:
                L[i][j]=1
            else:
                L[i][j]=L[i][j-1]+1
        if S[i][-j-1]=='.':
            if j==0:
                R[i][-j-1]=1
            else:
                R[i][-j-1]=R[i][-j]+1
        if S[i][j]=='.':
            if i==0:
                U[i][j]=1
            else:
                U[i][j]=U[i-1][j]+1
        if S[-i-1][j]=='.':
            if i==0:
                D[-i-1][j]=1
            else:
                D[-i-1][j]=D[-i][j]+1
for i in range(H):
    for j in range(W):
        ans = max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(ans)
n = int(input())
dl = list(map(int,input().split()))
if dl[0] != 0:
  print(0)
  exit()
d_dic = dict()
for d in dl:
  if d in d_dic:
    d_dic[d] += 1
  else:
    d_dic[d] = 1
l = max(d_dic.keys())
ans = 1
for i in range(l):
  ans *= d_dic[i]**d_dic[i+1]
  ans = ans%998244353
print(ans)

### FIXED CODE ###

n = int(input())
dl = list(map(int,input().split()))
if dl[0] != 0:
  print(0)
  exit()
d_dic = dict()
for d in dl:
  if d in d_dic:
    d_dic[d] += 1
  else:
    d_dic[d] = 1
l = max(d_dic.keys())
for i in range(l):
  if not i in d_dic:
    print(0)
    exit()
if d_dic[0] != 1:
  print(0)
  exit()
ans = 1
for i in range(l):
  ans *= d_dic[i]**d_dic[i+1]
  ans = ans%998244353
print(ans)
from math import sqrt 
N = int(input())
k = [list(map(int, input().split())) for _ in range(N)]
result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((k[i][0] - k[j][0]) * (k[i][0] - k[j][0]) + (k[i][1] - k[j][1]) * (k[i][1] - k[j][1]))
print(result / N)

### FIXED CODE ###

r = int(input())

print(r**2)
a=int(input())
b=int(input())
print(a*b,(a+b)*2)


### FIXED CODE ###

a=input().split()
b=int(a[1])
a=int(a[0])
print(a*b,(a+b)*2)
n,k = map(int, input().split())
a = list(map(int, input().split()))

G = {}
for i in range(1, n + 1):
    G.update({i: a[i - 1]})

seen = [False] * (n + 1)
path = []

def dfs(graph, start):
    global return_ans
    seen[start] = True
    path.append(start)
    
    if seen[graph[start]]:
        return graph[start]
    else:
        dfs(graph, graph[start])


point = dfs(G, 1)
m = path.index(point)

if m > k:
    print(path[k])
else:
    k -= m
    path = path[m:]
    k %= len(path)
    print(path[k])


### FIXED CODE ###

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

G = {}
for i in range(1, n + 1):
    G.update({i: a[i - 1]})

seen = [False] * (n + 1)
path = [1]

i = 1
while True:
    seen[i] = True
    i = G[i]
    
    if seen[i]:
        break
    else:
        path.append(i)

m = path.index(i)

if m > k:
    print(path[k])
else:
    k -= m
    path = path[m:]
    k %= len(path)
    print(path[k])
import numpy as np
import pandas as pd
N = int(input())
print(pd.Series(np.arange(1, N+1)).map(lambda x: x % 2).mean())

### FIXED CODE ###

import numpy as np
N = int(input())
a = np.arange(1, N+1)
print((a % 2).mean())
n, k, q = map(int, input().split())
points = []
minus = []
for i in range(n):
    points.append(k)
    minus.append(-1)
for i in range(q):
    a = int(input())
    points = np.array(points) + np.array(minus)
    points[a - 1] += 1
for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

import numpy as np
n, k, q = map(int, input().split())
points = np.full(n, k)
z = np.full(n, 0)
points = points - q
for i in range(q):
    a = int(input())
    z[a - 1] += 1
points = points + z
for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")
MOD = 10**9+7
r1,c1,r2,c2 = map(int,input().split())

size = 101000*2
f_list = [1]*(size)
for i in range(1,size):
    f_list[i] = (f_list[i-1]*i)%MOD

def func(r,c):
    return (f_list[r+c]*pow(f_list[r],MOD-2,MOD)*pow(f_list[c],MOD-2,MOD))

ans = func(r2+1,c2+1)-1
ans += func(r1,c1)-1
ans -= func(r2+1,c1)-1
ans -= func(r1,c2+1)-1
print(ans%MOD)



### FIXED CODE ###

MOD = 10**9+7
r1,c1,r2,c2 = map(int,input().split())

size = 1010000*2
f_list = [1]*(size)
for i in range(1,size):
    f_list[i] = (f_list[i-1]*i)%MOD

def func(r,c):
    return (f_list[r+c]*pow(f_list[r],MOD-2,MOD)*pow(f_list[c],MOD-2,MOD))

ans = func(r2+1,c2+1)-1
ans += func(r1,c1)-1
ans -= func(r2+1,c1)-1
ans -= func(r1,c2+1)-1
print(ans%MOD)
L=input().split()
A,B,C=int(L[0]),int(L[1]),int(L[2])
X=set([5,7])
ans = []
for i in range(len(X)):
    ans.append([A,B,C].count(X[i]))
if ans == [2,1]:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

L=input().split()
A,B,C=int(L[0]),int(L[1]),int(L[2])
X=[5,7]
ans = []
for i in range(len(X)):
    ans.append([A,B,C].count(X[i]))
if ans == [2,1]:
  print("YES")
else:
  print("NO")
print(input()).count("1")

### FIXED CODE ###

A=list(input())
print(eval("+".join(A)))
import math
x1,y1,x2,y2 = map(int, input().split())
dist = math.sqrt((x2-x1)**2+(y2-y1)**2)
print("%.5f" % (dist))

### FIXED CODE ###

import math
x1,y1,x2,y2 = map(float, input().split())
dist = math.sqrt((x2-x1)**2+(y2-y1)**2)
print("%.6f" % (dist))
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
smax=0
for i in range(k-1,n):
    if i==k-1:
        sumnow=sum(a[:i+1])
    else:
        sumnow+=a[i]-a[i-k]
    smax=max(smax,sumnow)
print((smax+k)/2)

### FIXED CODE ###

import numpy as np

s,t=input().split()
a,b=map(int,input().split())
u=input()
if s==u:
    a-=1
else:
    b-=1
print(a,b)
a,b,n = map(int, input().split())

if n < b:
    print(math.floor(a*n/b) - a*math.floor(n/b))
else:
    print(math.floor(a * (b-1) / b) - a * math.floor((b-1) / b))


### FIXED CODE ###

import math

a,b,n = map(int, input().split())

if n < b:
    print(math.floor(a*n/b) - a*math.floor(n/b))
else:
    print(math.floor(a * (b-1) / b) - a * math.floor((b-1) / b))
import sys
import numpy as np
import math
input = sys.stdin.readline
 
N = int(input())
A = np.array(list(map(int,input().split())))
r = np.array(list(range(1,N+1)))
B = A-r
C = list(map(abs,B-(math.ceil(sum(B)/len(B)))))
D = list(map(abs,B-(math.floor(sum(B)/len(B)))))
E = list(map(abs,B-(B[N//2])))
F = list(map(abs,B-(B[N//2+1])))

ans = min(sum(C),sum(D))
ans = min(ans,sum(E))
ans = min(ans,sum(F))

print(ans)

### FIXED CODE ###

import sys
import numpy as np
import math
import copy
input = sys.stdin.readline
 
N = int(input())
A = np.array(list(map(int,input().split())))
if N ==1:
    ans = 0
else:
    r = np.array(list(range(1,N+1)))
    B = np.array(sorted(A-r))
    ans = float('inf')
    for i in range(max(N//2-1,0),min(N//2+2,N)):
        c = list(map(abs,(B - B[i])))
        ans = min(ans,sum(c))
print(ans)
a, b, c = map(int, input().aplit())
if b - a == c - b:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a, b, c = map(int, input().split())
if b - a == c - b:
    print("YES")
else:
    print("NO")
import math

c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]

d = math.sqrt(pow(c1x-c2x, 2) +  pow(c1y-c2y, 2))

if d > c1r + c2r:
    print(4)
elif d == c1r + c2r:
    print(3)
elif d > s/2:
    print(2)
elif d == s/2:
    print(1)
else:
    print(0)


### FIXED CODE ###

import math

c1x,c1y,c1r = [int(i) for i in input().split()]
c2x,c2y,c2r = [int(i) for i in input().split()]

d = math.sqrt(pow(c1x-c2x, 2) +  pow(c1y-c2y, 2))

bcr = 0
scr = 0

if c1r > c2r:
    bcr = c1r
    scr = c2r
else:
    bcr = c2r
    scr = c1r


if d > bcr + scr:
    print(4)
elif d == bcr + scr:
    print(3)
elif d + scr > bcr:
    print(2)
elif d + scr == bcr:
    print(1)
else:
    print(0)
import sys
from itertools import accumulate
N = int(input())
S = input()
if S == '.'*N or S == '#'*N:
    print(0)
    sys.exit()
else:
    ind1 = 0
    for i, x in enumerate(S):
        if x == '#':
            ind1 = i
            break
        if i == N-1:
            print(0)
            sys.exit()
    num = 0
    for i, x in enumerate(S[::-1]):
        if x == '.':
            num = i
            break
        if i == N-1:
            print(0)
            sys.exit()
    ind2 = N - num
    if ind1 > ind2:
        print(0)
        sys.exit()
    s = S[ind1:ind2]
    if s[0] == '.' or s[-1] == '#' or len(s) == 0:
        print(0)
        sys.exit()
    else:
        a = s.split('.')
        b = s.split('#')
        aa = []
        bb = []
        for x, y in zip(a, b):
            if len(x) != 0:
                aa.append(len(x))
            if len(y) != 0:
                bb.append(len(y))
        d = [0] + list(accumulate(aa))
        e = [0] + list(accumulate(bb))
        p = d[-1]
        ls = []
        for i in range(len(d)):
            ls.append(e[i]+p-d[i])
        print(min(ls))
        

### FIXED CODE ###

import sys
from itertools import accumulate
N = int(input())
S = input()

if S == '.'*N or S == '#'*N:
    print(0)
    sys.exit()

ind1 = 0
for i, x in enumerate(S):
    if x == '#':
        ind1 = i
        break
num = 0
for i, x in enumerate(S[::-1]):
    if x == '.':
        num = i
        break
ind2 = N - num
s = S[ind1:ind2]
if len(s) == 0:
    print(0)
    sys.exit()

a = s.split('.')
b = s.split('#')
aa = []
bb = []
for x in a:
    if len(x) != 0:
        aa.append(len(x))
for x in b:
    if len(x) != 0:
        bb.append(len(x))
c = [0] + list(accumulate(aa))
d = [0] + list(accumulate(bb))
ls = []
for i in range(len(c)):
    ls.append(c[i] + d[-1] - d[i])
print(min(ls))
n,k=map(int,input().split())
s=list(input())
s=list(map(int,s))
stack=[]
tmp=1
for i in range(1,len(s)):
  if s[i]!=s[i-1]:
    stack.append(tmp)
    tmp=1
  else:
    tmp+=1
stack.append(tmp)
if s[0]==1:
  if len(s)//2<=k:
    print(len(s))
    exit()
if s[0]==0:
  if (len(s)+1)//2<=k:
    print(len(s))
    exit()
acc=[]
acc2=[]
ans=0
if s[0]==1:
  Acc=stack[0]
  Acc2=0
  acc.append(Acc)
  acc2.append(0)
  for i in range(1,len(stack)-len(stack)%2,2):
    Acc+=stack[i]
    Acc+=stack[i+1]
    acc.append(Acc)
    Acc2+=stack[i-1]
    Acc2+=stack[i]
    acc2.append(Acc2)
  if len(stack)%2==0:
    Acc2+=stack[i+1]
    Acc2+=stack[i+2]
    acc2.append(Acc2)
  if len(stack)%2==1:
    Acc+=stack[-1]
    acc.append(Acc)
    Acc2+=stack[-2]
    Acc2+=stack[-1]
    acc2.append(Acc2)
  for i in range(len(acc)-k):
    ans=max(ans,acc[i+k]-acc2[i])
if s[0]==0:
  Acc=stack[0]
  Acc2=0
  acc.append(0)
  acc.append(Acc)
  acc2.append(0)
  for i in range(1,len(stack)-1-len(stack)%2,2):
    Acc+=stack[i]
    Acc+=stack[i+1]
    acc.append(Acc)
    Acc2+=stack[i-1]
    Acc2+=stack[i]
    acc2.append(Acc2)
  if len(stack)%2==0:
    Acc2+=stack[i+1]
    Acc2+=stack[i+2]
    acc2.append(Acc2)
  if len(stack)%2==1:
    Acc+=stack[-1]
    acc.append(Acc)
    Acc2+=stack[-2]
    Acc2+=stack[-1]
    acc2.append(Acc2)
  for i in range(len(acc)-k):
    ans=max(ans,acc2[i+k]-acc[i])
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s=list(map(int,s))
stack=[]
tmp=0
now=1
for i in range(n):
  if s[i]==now:
    tmp+=1
  else:
    stack.append(tmp)
    tmp=1
    now=1-now
stack.append(tmp)
if len(stack)%2==0:
  stack.append(0)
Acc=[0]*(len(stack)+1)
for i in range(len(stack)):
  Acc[i+1]=Acc[i]+stack[i]
ans=0
for i in range(0,len(stack),2):
  left = i
  right = min(i+k*2+1,len(stack))
  ans=max(ans,Acc[right]-Acc[left])
print(ans)
"""
じょえちゃんねる
高評価・チャンネル登録よろしくお願いします！
https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
"""
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r + 100 * (10 - k))


### FIXED CODE ###

"""
じょえちゃんねる
高評価・チャンネル登録よろしくお願いします！
https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
"""
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r + 100 * (10 - n))
s=int(input())
print("2018"+[:4])

### FIXED CODE ###

s=input()
print("2018"+s[4:])