Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

h, w, k = map(int, input().split())
s = [list(map(int, list(input()))) for _ in range(h)]
result = []
if h*w<=k:
    result.append(0)
else:
    for i in range(2**(h-1)):
        checker, num = 0, i
        while num > 0:
            checker += num%2
            num >>= 1
        x = 0
        c = [0]*(checker+1)

        for j in range(w):
            num = i
            p = 0
            nex = [0]*(checker+1)
            for m in range(h):
                nex[p] += s[m][j]
                p += num%2
                num = num >> 1          
            if max(nex)>k:
                x = 10**5
                break

            if all(nex[m]+c[m] <= k for m in range(checker+1)):
                c = [c[I]+nex[I] for I in range(checker+1)]
            else:
                x += 1
                c = nex
        result.append(checker+x)
print(min(result))

### FIXED CODE ###

h, w, k = map(int, input().split())
s = [list(map(int, list(input()))) for _ in range(h)]
result = []
if h*w<=k:
    result.append(0)
else:
    for i in range(2**(h-1)):
        checker, num = 0, i
        while num > 0:
            checker += num%2
            num >>= 1
        x = 0
        c = [0 for _ in range(checker+1)]
        
        num = i
        p = 0
        nex = [0 for _ in range(checker+1)]
        for m in range(h):
            nex[p] += s[m][0]
            p += num%2
            num = num >> 1
        if max(nex) > k:
            x = float('inf')
            continue

        if all(nex[m]+c[m] <= k for m in range(checker+1)):
            c = [c[I]+nex[I] for I in range(checker+1)]
        else:
            x += 1

        for j in range(1, w):
            num = i
            p = 0
            nex = [0 for _ in range(checker+1)]
            for m in range(h):
                nex[p] += s[m][j]
                p += num%2
                num = num >> 1
            if max(nex) > k:
                x = float('inf')
                break            
            
            if all(nex[m]+c[m] <= k for m in range(checker+1)):
                c = [c[I]+nex[I] for I in range(checker+1)]
            else:
                x += 1
                c = nex
        result.append(checker+x)
print(min(result))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 1 
if 0 in a:
    print(0)
    sys.exit()
for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 1 
if 0 in a:
    print(0)
    sys.exit(0)
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit(0)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, W = [int(i) for i in input().split()]
wv = [[int(i) for i in input().split()] for j in range(N)]

def ans(N, W, wv):
    d = [[0] * (W+1) for i in range(N+1)]

    for i in range(N):
        for j in range(W+1):
            if wv[i][0] > j:
                d[i+1][j] = d[i][j]
            else:
                d[i + 1][j] = max(d[i][j], d[i][j-wv[i][0]] + wv[i][1])
    return d[N][W]

print(ans(N, W, wv))


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, W = [int(i) for i in input().split()]

def ans(N, W):
    d = [0] * (W+1)

    for i in range(N):
        wi, vi = [int(i) for i in input().split()]
        for w in range(W, wi - 1, -1):
            v_ = d[w - wi] + vi
            if v_ > d[w]:
                d[w] = v_
    return d[W]

print(ans(N, W))
### BUGGY CODE ###

inputs = input().split(' ')
a = int(inputs[0])
b = int(inputs[1])
n = int(inputs[2]) + 1

output = 0
loop_cnt = n if n < b else b
for x in range(1, loop_cnt):
    buf = (a*x//b)
    if buf > output:
        output = buf

print(output)

### FIXED CODE ###

inputs = input().split(' ')
a = int(inputs[0])
b = int(inputs[1])
n = int(inputs[2]) + 1

x = (n if n < b else b) - 1
output = (a*x//b)

print(output)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
sum = 0
count = []
for i in set(A):
    j = A.count(i)
    sum += j * (j - 1) // 2
for i in A:
    print(sum - A.count(i) + 1)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c= Counter(A)
sum = 0
for i in c.values():
    sum += i * (i - 1) // 2
for i in A:
    print(sum - c[i] + 1)
### BUGGY CODE ###

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

S += "X"
j = 0
count = 1
change = [] if S[0] != "0" else [0]
while True:
  if S[j:j+2] == "10":
    change.append(count)
    count = 0
  elif S[j:j+2] == "01":
    change.append(count)
    count = 0
    
  j += 1
  if j == len(S)-1:
    change.append(count)
    break
  count += 1

i = 0
max_len = 0
while i < len(change):
  max_len = max([sum(change[i:i+2*K+1]), max_len])
  i += 2
  
print(max_len)

### FIXED CODE ###

N, K = list(map(int, input().split()))
S = input()
 
S += "X"
i = 0
j = 0
max_len = 0
change = 0 if S[0] != "0" else 1
while j < len(S)-1:
  if change <= K:
    #print(i, j)
    max_len = max([j-i+1, max_len])
    if S[j:j+2] == "10":
      change += 1
    j += 1
  else:
    if S[i:i+2] == "01":
      change -= 1
    i += 1

print(max_len)
### BUGGY CODE ###

class RollingHash():
    def __init__(self, string):
        self.n = len(string)
        self.BASE = 1007
        self.MOD = (1 << 61) - 1
        self.hash = [0] * (self.n + 1)
        self.pow = [1] * (self.n + 1)
        
        for i, char in enumerate(string):
            self.hash[i+1] = (self.hash[i] * self.BASE + ord(char)) % self.MOD
            self.pow[i+1] = (self.pow[i] * self.BASE) % self.MOD
            
    def get_hash(self, l, r):
        res = (self.hash[r] - self.hash[l] * self.pow[r-l]) % self.MOD
        return res
      

n = int(input())
s = input()

rh = RollingHash(s)

ans = 0
for length in range(n + 1):
    set_ = set([])
    for l in range(n):
        # [l, l + length), [l + length, l + 2*length)
        if l + 2*length > n:
            break
        set_.add(rh.get_hash(l, l + length))
        tmp = rh.get_hash(l + length, l + 2*length)
        if tmp in set_:
            ans = length
            break

print(ans)

### FIXED CODE ###

def LRS(str): 
  
    n = len(str) 
    LCSRe = [[0 for x in range(n + 1)]  
                for y in range(n + 1)] 
  
    res = ""
    res_length = 0
  
    index = 0
    for i in range(1, n + 1): 
        for j in range(i + 1, n + 1): 
              
            if (str[i - 1] == str[j - 1] and
                LCSRe[i - 1][j - 1] < (j - i)): 
                LCSRe[i][j] = LCSRe[i - 1][j - 1] + 1
  
                if (LCSRe[i][j] > res_length): 
                    res_length = LCSRe[i][j] 
                    index = max(i, index) 
                  
            else: 
                LCSRe[i][j] = 0
  
    if (res_length > 0): 
        for i in range(index - res_length + 1, 
                                    index + 1): 
            res = res + str[i - 1] 
  
    return res 
  
n = int(input())
s = input()

print(len(LRS(s)))
### BUGGY CODE ###

import itertools
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
ans=float('inf')
for i in itertools.permutations(h,k):
    tmp=max(i)-min(i)
    ans=min(ans,tmp)
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()
ans=float('inf')
for i in range(n-k+1):
    tmp=h[i+k-1]-h[i]
    ans=min(tmp,ans)
print(ans)
### BUGGY CODE ###

n,m = map(int,input().split())
dic={}
P,Y = [],[]
for i in range(m):
  p,y = map(int,input().split())
  P.append(p)
  Y.append(y)
  target = dic.get(p) if dic.get(p)!=None else []
  target.append(y)
  dic[p] = target

def fill_zero(num):
  s = str(num)
  dif = 6-len(s)
  return '0'*dif+s
  
for i in range(m):
  li = sorted(dic[P[i]])
  ord = li.index(Y[i])+1
  print(fill_zero(P[i])+fill_zero(ord))
  
  

### FIXED CODE ###

N, M = map(int, input().split())
D = [[] for i in range(N)]
 
for i in range(M):
  p, y = map(int, input().split())
  D[p-1].append((y, i)) 

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')
### BUGGY CODE ###

def comb(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
    for i in range(k):
        ans //= i+1
    return ans%(10**9+7)

def path(x, y):
    return comb(x+y+2, min(x+1, y+1))-1

r1, c1, r2, c2 = list(map(int, input().split()))
print((path(r2, c2)-path(r1-1, c2)-path(r2, c1-1)+path(r1-1, c1-1))%(10**9+7))

### FIXED CODE ###

MOD = 10**9+7

fact = [1]*(2*10**6+10)
for i in range(1, len(fact)):
    fact[i] = (fact[i-1]*i)%MOD

def comb(n, k):
    return fact[n]*pow(fact[n-k], MOD-2, MOD)*pow(fact[k], MOD-2, MOD)

def path(x, y):
    return comb(x+y+2, min(x+1, y+1))-1

r1, c1, r2, c2 = list(map(int, input().split()))
print((path(r2, c2)-path(r1-1, c2)-path(r2, c1-1)+path(r1-1, c1-1))%(10**9+7))
### BUGGY CODE ###

import heapq

X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

que = []
heapq.heappush(que, [(A[0]+B[0]+C[0])*-1,0,0,0])
data = [[0,0,0]]
for i in range(K):
    tmp = heapq.heappop(que)
    print(tmp[0]*-1)
    if tmp[1]+1 < len(A) and [(A[tmp[1]+1]+B[tmp[2]]+C[tmp[3]])*-1,tmp[1]+1,tmp[2],tmp[3]] not in data:
        heapq.heappush(que, [(A[tmp[1]+1]+B[tmp[2]]+C[tmp[3]])*-1,tmp[1]+1,tmp[2],tmp[3]])
        data.append([(A[tmp[1]+1]+B[tmp[2]]+C[tmp[3]])*-1,tmp[1]+1,tmp[2],tmp[3]])
    if tmp[2]+1 < len(B) and [(A[tmp[1]]+B[tmp[2]+1]+C[tmp[3]])*-1,tmp[1],tmp[2]+1,tmp[3]] not in data:
        heapq.heappush(que, [(A[tmp[1]]+B[tmp[2]+1]+C[tmp[3]])*-1,tmp[1],tmp[2]+1,tmp[3]])
        data.append([(A[tmp[1]]+B[tmp[2]+1]+C[tmp[3]])*-1,tmp[1],tmp[2]+1,tmp[3]])
    if tmp[3]+1 < len(C) and [(A[tmp[1]]+B[tmp[2]]+C[tmp[3]+1])*-1,tmp[1],tmp[2],tmp[3]+1] not in data:
        heapq.heappush(que, [(A[tmp[1]]+B[tmp[2]]+C[tmp[3]+1])*-1,tmp[1],tmp[2],tmp[3]+1])
        data.append([(A[tmp[1]]+B[tmp[2]]+C[tmp[3]+1])*-1,tmp[1],tmp[2],tmp[3]+1])

### FIXED CODE ###

import heapq

X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

que = []
heapq.heappush(que, [(A[0]+B[0]+C[0])*-1,0,0,0])
data = [[0,0,0]]
for i in range(K):
    tmp = heapq.heappop(que)
    print(tmp[0]*-1)
    if tmp[1]+1 < len(A) and [(A[tmp[1]+1]+B[tmp[2]]+C[tmp[3]])*-1,tmp[1]+1,tmp[2],tmp[3]] not in data:
        heapq.heappush(que, [(A[tmp[1]+1]+B[tmp[2]]+C[tmp[3]])*-1,tmp[1]+1,tmp[2],tmp[3]])
        data.append([(A[tmp[1]+1]+B[tmp[2]]+C[tmp[3]])*-1,tmp[1]+1,tmp[2],tmp[3]])
    if tmp[2]+1 < len(B) and [(A[tmp[1]]+B[tmp[2]+1]+C[tmp[3]])*-1,tmp[1],tmp[2]+1,tmp[3]] not in data:
        heapq.heappush(que, [(A[tmp[1]]+B[tmp[2]+1]+C[tmp[3]])*-1,tmp[1],tmp[2]+1,tmp[3]])
        data.append([(A[tmp[1]]+B[tmp[2]+1]+C[tmp[3]])*-1,tmp[1],tmp[2]+1,tmp[3]])
    if tmp[3]+1 < len(C) and [(A[tmp[1]]+B[tmp[2]]+C[tmp[3]+1])*-1,tmp[1],tmp[2],tmp[3]+1] not in data:
        heapq.heappush(que, [(A[tmp[1]]+B[tmp[2]]+C[tmp[3]+1])*-1,tmp[1],tmp[2],tmp[3]+1])
        data.append([(A[tmp[1]]+B[tmp[2]]+C[tmp[3]+1])*-1,tmp[1],tmp[2],tmp[3]+1])
### BUGGY CODE ###

N,W = map(int, input().split())
wv = []
V = 0
for x in range(N):
    w,v = map(int, input().split())
    wv.append([w,v])
    V += v

INF = 10**9+1

DP = [[INF]*(V+1) for _ in range(N+1)]

for i in range(N):
    for j in range(V):
        if j >= wv[i][1]:
            DP[i+1][j] = min(DP[i][j], DP[i][j-wv[i][1]]+wv[i][0])
        else:
            DP[i+1][j] = min(DP[i][j], wv[i][0])
        
ans = 0
for i in range(N+1):
    for j in range(V+1):
        if DP[i][j] <= W:
            ans = max(ans, j+1)
print(ans)

### FIXED CODE ###

N,W = map(int, input().split())
wv = []
V = 0
for x in range(N):
    w,v = map(int, input().split())
    wv.append([w,v])
    V += v

INF = 10**9+1

DP = [[INF]*(V+1) for _ in range(N+1)]

for i in range(N):
    for j in range(V):
        if j >= wv[i][1]:
            DP[i+1][j] = min(DP[i][j], DP[i][j-wv[i][1]]+wv[i][0])
        else:
            DP[i+1][j] = min(DP[i][j], wv[i][0])
        
ans = 0
for i in range(N+1):
    for j in range(V+1):
        if DP[i][j] <= W:
            ans = max(ans, j+1)
print(ans)
### BUGGY CODE ###

h,w=map(int, input().split())
a=[input() for i in range(h)]

non=3000
import numpy as np
b=np.full((h,w),non,dtype=int)
q=[]
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            q.append((i,j))
            b[i][j]=0
ans=-1
while len(q)>0:
    ans+=1
    q2=[]
    for i,j in q:
        if j>0 and b[i][j-1]==non:
            q2.append((i,j-1))
            b[i][j-1]=b[i][j]+1
        if j<w-1 and b[i][j+1]==non:
            q2.append((i,j+1))
            b[i][j+1]=b[i][j]+1
        if i>0 and b[i-1][j]==non:
            q2.append((i-1,j))
            b[i-1][j]=b[i][j]+1
        if i<h-1 and b[i+1][j]==non:
            q2.append((i+1,j))
            b[i+1][j]=b[i][j]+1
    q=q2
print(ans)

### FIXED CODE ###

h,w=map(int, input().split())
a=[input() for i in range(h)]

from collections import deque
b=[[0]*w for i in range(h)]
q=deque()
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            q.append((i,j))
            b[i][j]=1
ans=-1
while len(q)>0:
    ans+=1
    q2=deque()
    for i,j in q:
        if j>0 and b[i][j-1]==0:
            q2.append((i,j-1))
            b[i][j-1]=1
        if j<w-1 and b[i][j+1]==0:
            q2.append((i,j+1))
            b[i][j+1]=1
        if i>0 and b[i-1][j]==0:
            q2.append((i-1,j))
            b[i-1][j]=1
        if i<h-1 and b[i+1][j]==0:
            q2.append((i+1,j))
            b[i+1][j]=1
    q=q2
print(ans)
### BUGGY CODE ###

s = input()

counter = 0
while 'BW' in s:
    counter += s.count('BW')
    s = s.replace('BW', 'WB')

print(counter)

### FIXED CODE ###

import re
s = input()
iter = re.finditer('W', s)
indices = [m.start(0) for m in iter]
cnt = len(indices)
total = sum(indices)
print(total - (cnt * (cnt -1)) // 2)
### BUGGY CODE ###

x = map(int,raw_input().split())
n=x[0]
m=x[1]
a = map(int,raw_input().split())

for i in range(m):
    a.sort(reverse=True)
    a[0]=float(a[0])/2

a=list(map(int, a))

print(sum(a))


### FIXED CODE ###

import heapq

x = map(int,raw_input().split())
n=x[0]
m=x[1]
a = map(int, raw_input().split())

def minus(n):
    return float(n*(-1))

def plus(n):
    return int(n*(-1))

a=list(map(minus, a))
heapq.heapify(a)

for i in range(m):
    heapq.heappush(a, heapq.heappop(a)/2)

a=list(map(plus, a))

print(sum(a))
### BUGGY CODE ###

n = int(input())
arr = list(map(int,input().split()))
arr.insert(0,0)
arr.append(0)
ans = 0
tmp = 0
for i in range(1,n + 1):
    for j in range(1,len(arr)):
        if i != j:
            ans += abs(arr[j] - tmp)
            tmp = arr[j]
    print(ans)
    ans = 0

### FIXED CODE ###

n = int(input())
arr = [0] + list(map(int,input().split())) + [0]
tmp= [ abs(arr[i] - arr[i + 1]) for i in range(len(arr) - 1)]
_sum = sum(tmp)
for i in range(n):
    ans = _sum - tmp[i] - tmp[i + 1] + abs(arr[i + 2] - arr[i])
    print(ans)
### BUGGY CODE ###

N, K = map(int,input().split()) 
P = list(map(int,input().split()))
max_index = 0
max_size = 0
for i in range(N-K+1):
    sum_3 = sum(P[i:i+K])
    if sum_3 > max_size:
        max_index = i
        max_size = sum_3
expect = 0
for j in range(K):
    expect += (P[max_index+j]+1)/2
print(expect)

### FIXED CODE ###

def expect(n):
    return (int(n)+1)/2
N, K = map(int,input().split()) 
P = list(map(expect,input().split()))
sumlist = [sum(P[0:K])]
sumnumber = sum(P[0:K])
for i in range(N-K):
    sumnumber -=P[i]
    sumnumber +=P[i+K]
    sumlist.append(sumnumber)
print(max(sumlist))
### BUGGY CODE ###

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

if M==6700417:
    print(1)
else:
    for i in range(M//N,0,-1):
        if M%i==0:
            print(i)
            break



### FIXED CODE ###

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

base=M//N
li=[]


for i in range(1,int(pow(M,1/2))+1):
    if i<=base and M%i==0:
        li.append(i)
    if M%i==0 and M//i<=base:
        li.append(M//i)

print(max(li))
### BUGGY CODE ###

n,m = map(int,input().split())
o = [int(input()) for _ in range(m)]
#print(o)
mod = (10**9)+7
dp = [1]+[0]*(n)
 
for i in range(1,n+1):
  dp[i] = dp[i-1]+dp[i-2]
  if i in o:
    dp[i] = 0
  #print(i,dp)
#print(dp)
print(dp[-1]%mod)

### FIXED CODE ###

n,m = map(int,input().split())
o = set(int(input()) for _ in range(m))
#print(o)
mod = (10**9)+7
dp = [0]*(n+1)
dp[0] = 1

for i in range(1,n+1):
  dp[i] = (dp[i-1]+dp[i-2])%mod
  if i in o:
    dp[i] = 0
  #print(i,dp)
#print(dp)
print(dp[-1])
### BUGGY CODE ###

# absotutely TLE
arr=[]
n,w=map(int,input().split())
for _ in range(n):
	arr.append(tuple(map(int,input().split())))
def f(pos,W):
	if(pos==n):
		return 0
	res=f(pos+1,W)
	if(arr[pos][0]<=W):
		res=max(res,f(pos+1,W-arr[pos][0])+arr[pos][1])
	return res
print(f(0,w))

### FIXED CODE ###

import numpy as np 
IN = lambda:map(int, input().split())
 
n, k = IN()
dp = np.zeros(k + 1)
 
for i in range(n):
    w, c = IN()
    dp[w:] = np.maximum(dp[w:], dp[:-w] + c)
    
print(int(dp[-1]))
### BUGGY CODE ###

N = int(input())
h = list(map(int , input().split()))
dp = [[0]*10000 for i in range(N)]
def dfs(i,c):
    if i == N:
        return 10000
    if dp[i][c] >0:
        return dp[i][c]
    else:
        if i == N-1:
            return abs(h[i] - c)
        dp[i][c] = min(dfs(i+1, h[i])+abs(h[i]-c),dfs(i+2, h[i])+abs(h[i]-c))
        return dp[i][c]
print(dfs(0,h[0]))


### FIXED CODE ###

N = int(input())
h = list(map(int , input().split()))
dp = [10**9+1]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    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])
### BUGGY CODE ###

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

expect = [(pi+1) / 2 for pi in p]

em = 0
for i in range(n-k+1):
  em = max(em, sum(expect[i:i+k]))

print(em)

### FIXED CODE ###

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

rsum = [(p[0] + 1) / 2]
for i in range(1, n):
  rsum.append((p[i] + 1) / 2 + rsum[i-1])
  
result = 0
if (n == k):
  result = rsum[-1]

else:
  for i in range(n-k):
    if result < rsum[i+k] - rsum[i]:
      result = rsum[i+k] - rsum[i]

print(result)
### BUGGY CODE ###

n = int(input())
s = str(input())

s_r = s.count("R")
s_g = s.count("G")
s_b = s.count("B")

s = s.replace("R", "0")
s = s.replace("G", "1")
s = s.replace("B", "2")

def conditions(a, b):
  c = [-1, -1, -1]
  if (a+b) % 2 == 0:
    c[0] = (a+b) / 2
    c[1] = 2*b - a
    c[2] = 2*a - b
  else:
    c[1] = 2*b - a
    c[2] = 2*a - b
  list = []
  for i in range(3):
    if c[i] >= 0 and c[i] <= n-1:
      list.append(c[i])
  return list

def noteq(a, b, c):
  if a != b and b != c and c != a:
    return True
  else:
    return False

count = 0
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      a = int(s[i])
      b = int(s[j])
      c = int(s[k])
      if k in conditions(i, j) and noteq(a, b, c):
        count += 1
    
ans = s_r * s_g * s_b - count
print(ans)

### FIXED CODE ###

import collections

n = int(input())
s = str(input())

aaa = collections.Counter(s)
s_r = aaa["R"]
s_g = aaa["G"]
s_b = aaa["B"]

def noteq(a, b, c):
  if a != b and b != c and c != a:
    return True
  else:
    return False

ans = s_r * s_g * s_b

for i in range(n):
  for d in range(n):
    j = i + d
    k = j + d
    if k >= n:
      break;
    else:
      a = s[i]
      b = s[j]
      c = s[k]
      if noteq(a, b, c):
        ans -= 1
    
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(m)]
ikeruheya = [[] for i in range(n)]
ans = [0]*(n+1)

ans[0]=-1
ans[1]=1
for i in range(m):
    if a[i][0]==1:
        ikeruheya[0].append(a[i][1])
    elif a[i][1]==1:
        ikeruheya[0].append(a[i][0])
    else:
        ikeruheya[a[i][0]-1].append(a[i][1])
        ikeruheya[a[i][1]-1].append(a[i][0])

#print(ikeruheya)
next=[1]
count = 1
while count < n and len(next)!=0:
    
    imaheya = next.pop(0)
    j = 0
    while j < len(ikeruheya[imaheya-1]) and count < n:
    
        if ans[ikeruheya[imaheya-1][j]]==0:
            ans[ikeruheya[imaheya-1][j]]= imaheya             
            next.append(ikeruheya[imaheya-1][j])
            count += 1
            j+=1
        else:
            j+=1


print("Yes")
for i in range(2, n+1):
    print(ans[i])


    
    


### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())
a=[list(map(int, input().split())) for i in range(m)]
b=[[] for j in range(n)] 

michi=[-1]*(n)
michi[0]=0
heya=[]


for i in range(m):
    b[a[i][0]-1].append(a[i][1])
    b[a[i][1]-1].append(a[i][0])



heya.append(1)


while len(heya):
    now=heya.pop(0)-1
    
    for i in range(len(b[now])):
        if michi[b[now][i]-1] == -1:
            heya.append(b[now][i])
            michi[b[now][i]-1] = now+1
print("Yes")
for i in range(1,n):
    print(michi[i])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# D

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

l = [0] * 60

for a in a:
    temp = bin(a)[2:][::-1]
    # print(temp)
    for i in range(60):
        if i < len(temp):
            l[i] += int(temp[i])
        else:
            l[i] += 0

# print(l)

ans = 0
mod = 10**9 + 7

for i in range(60):
    ans += ((2**i) % mod) * l[i] * (N-l[i])
    ans = ans % mod

print(ans)


### FIXED CODE ###

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

max_len = len(bin(max(a))[2:])
l = [0] * max_len

ans = 0
mod = 10**9 + 7

for i in range(max_len):
    for x in a:
        l[i] += x >> i & 1
    ans += pow(2, i, mod) * l[i] * (N-l[i])

print(ans % mod)
### BUGGY CODE ###

N=input()
s=input()

N=int(N)
wn=[]
bn=[]
a=0
b=0

#各行間よりも前と後ろに何個白（黒）があるかをカウント
for i in range(N):
    j=N-(i+1)
    if(s[j]=="."):
        a+=1
    if(s[i]=="#"):
        b+=1
    bn.insert(0,a)
    wn.append(b)
bn.append(0)
wn.insert(0,0)
#print(bn)
#print(wn)

#各行間のscore算出
min=1000000
for i in range(N+1):
    score=bn[i]+wn[i]
    if(score<min):
        min=score

print(min)

### FIXED CODE ###

N=input()
s=input()

N=int(N)
wn=[]
bn=[]
a=0
b=0

#各行間よりも前と後ろに何個白（黒）があるかをカウント
wn.append(0)
for i in range(N):
    j=N-(i+1)
    if(s[j]=="."):
        a+=1
    if(s[i]=="#"):
        b+=1
    bn.append(a)
    wn.append(b)

bn.reverse()
bn.append(0)
#print(bn)
#print(wn)

#各行間のscore算出
min=1000000
for i in range(N+1):
    score=bn[i]+wn[i]
    if(score<min):
        min=score

print(min)