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

import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, K = inpl()
A = inpl()
ls = [1] * (N+10)
for i in range(K):
    ls[K-1] *= A[i]
for i in range(K, N):
    # ls[i] = ls[i-1]//A[i-K] * A[i]
    # if ls[i] > ls[i-1]:
    if A[i] > A[i-K]:
        print('Yes')
    else:
        print('No')

# -----------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)



### FIXED CODE ###

import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, K = inpl()
A = inpl()
for i in range(K, N):
    if A[i] > A[i-K]:
        print('Yes')
    else:
        print('No')

# -----------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

def main():
    n = int(input().rstrip())
    a = list(map(int, input().rstrip().split()))
    count = 0
    b = []
    for i in range(n):
      flag = True
      for x in b:
        if a[i] % x == 0:
          flag = False
          break
      if flag:
        for k in range(n):
          if i != k and a[i] % a[k] == 0:
            flag = False
            break
      if flag:
        count += 1
        b.append(a[i])
    print(count)
  
if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import Counter
import sys
n=int(input())
a=sorted(list(map(int,input().split())))
 
c=[1 for i in range(10**6+1)]
d = Counter(a)
s = list(set(a))
count = 0
if d[1] == 1:
  print(1)
  sys.exit()
elif d[1] >=2:
  print(0)
  sys.exit()
for x in s:
  t = x * 2
  while t <= 10 ** 6:
    c[t] = 0
    t += x
 
for x in a:
  if d[x] == 1 and c[x] == 1:
    count += 1
print(count)
### BUGGY CODE ###

import math
from collections import deque
def nC2(n):
  return math.factorial(n) / math.factorial(2) / math.factorial(n - 2)
N, M = map(int, raw_input().split())

seg_tree = [i for i in range(N)]
seg_height = [1 for _ in range(N)]
seg_size = [1 for _ in range(N)]
def get_root(i):
  if i == seg_tree[i]:
    return i
  else:
    return get_root(seg_tree[i])

def unite(i, j):
  if get_root(i) == get_root(j):
    return
  if seg_height[get_root(i)] > seg_height[get_root(j)]:
    seg_size[get_root(i)] += seg_size[get_root(j)]
    seg_tree[get_root(j)] = get_root(i)
  elif seg_height[get_root(i)] < seg_height[get_root(j)]:
    seg_size[get_root(j)] += seg_size[get_root(i)]
    seg_tree[get_root(i)] = get_root(j)
  else:
    seg_height[get_root(i)] += 1
    seg_size[get_root(i)] += seg_size[get_root(j)]
    seg_tree[get_root(j)] = get_root(i)

def same(i, j):
  return get_root(i) == get_root(j)

A = deque()
B = deque()
rev_res = deque()
rev_res.append(nC2(N))
for _ in range(M):
  a, b = map(int, raw_input().split())
  A.append(a - 1)
  B.append(b - 1)

for _ in range(M):
  a = A.pop()
  b = B.pop()
  res = rev_res[-1] - seg_size[get_root(a)] * seg_size[get_root(b)] if not same(a, b) else rev_res[-1]
  rev_res.append(res)
  unite(a, b)
rev_res.pop()
while len(rev_res) > 0:
  print rev_res.pop()

### FIXED CODE ###

import math
from collections import deque

class UnionFind():
  def __init__(self, n):
    self.seg_tree = [-1 for i in range(n)]
  
  def root(self, i):
    if self.seg_tree[i] < 0:
      return i
    else:
      self.seg_tree[i] = self.root(self.seg_tree[i])
      return self.seg_tree[i]

  def size(self, i):
    return -self.seg_tree[self.root(i)]

  def unite(self, i, j):
    if self.same(i, j):
      return

    if self.size(i) == self.size(j):
      self.seg_tree[self.root(i)] -= self.size(j)
      self.seg_tree[self.root(j)] = self.root(i)
    elif self.size(i) > self.size(j):
      self.seg_tree[self.root(i)] -= self.size(j)
      self.seg_tree[self.root(j)] = self.root(i)
    else:
      self.seg_tree[self.root(j)] -= self.size(i)
      self.seg_tree[self.root(i)] = self.root(j)

  def same(self, i, j):
    return self.root(i) == self.root(j)

def nC2(n):
  return math.factorial(n) / math.factorial(2) / math.factorial(n - 2)

N, M = map(int, raw_input().split())
A = []
B = []
rev_res = []
uf = UnionFind(N)
for _ in range(M):
  a, b = map(long, raw_input().split())
  A.append(a - 1)
  B.append(b - 1)

ans = N * (N - 1) / 2
for a, b in reversed(zip(A, B)):
  rev_res.append(ans)
  if not uf.same(a, b):
    ans -= uf.size(a) * uf.size(b)
  uf.unite(a, b)

for r in reversed(rev_res):
  print r
### BUGGY CODE ###

class Dice():
    def __init__(self, nums):
        self.nums = nums
        self.top, self.front, self.right = 0, 1, 2

    def move(self, op):
        for c in op:
            if c == 'N':
                self.top, self.front = self.front, 5 - self.top
            elif c == 'S':
                self.top, self.front = 5 - self.front, self.top
            elif c == 'E':
                self.top, self.right = 5 - self.right, self.top
            else:
                self.top, self.right = self.right, 5 - self.top

    def getRight(self, t, f):
        top, front = self.nums.index(t), self.nums.index(f)
        for c in "NNNNEEE":
            self.move(c)
            if top == self.top:
                break
        while True:
            self.move("ESW")
            if front == self.front:
                return self.nums[self.right]

    def diffDice(self, dice):
        dice.getRight(self.nums[self.top], self.nums[self.front])
        if self.nums[self.top] == dice.nums[dice.top] and \
                self.nums[self.front] == dice.nums[dice.front] and \
                self.nums[self.right] == dice.nums[dice.right] and \
                self.nums[5 - self.top] == dice.nums[5 - dice.top] and \
                self.nums[5 - self.front] == dice.nums[5 - dice.front] and \
                self.nums[5 - self.right] == dice.nums[5 - dice.right]:
                    print ("Yes")
        else:
            print("No")

dice1 = Dice([int(n) for n in input().split()])
dice2 = Dice([int(n) for n in input().split()])
dice1.diffDice(dice2)

### FIXED CODE ###

class Dice():
    def __init__(self, nums):
        self.nums = nums
        self.top, self.front, self.right = 0, 1, 2

    def __eq__(self, dice):
        for x in "NNNNEEE":
            dice.move(x)
            for _ in range(4):
                dice.move("ESW")
                if self.nums[self.top] == dice.nums[dice.top] and \
                        self.nums[self.front] == dice.nums[dice.front] and \
                        self.nums[self.right] == dice.nums[dice.right] and \
                        self.nums[5 - self.top] == dice.nums[5 - dice.top] and \
                        self.nums[5 - self.front] == dice.nums[5 - dice.front] and \
                        self.nums[5 - self.right] == dice.nums[5 - dice.right]:
                    return True
        return False

    def move(self, op):
        for c in op:
            if c == 'N':
                self.top, self.front = self.front, 5 - self.top
            elif c == 'S':
                self.top, self.front = 5 - self.front, self.top
            elif c == 'E':
                self.top, self.right = 5 - self.right, self.top
            else:
                self.top, self.right = self.right, 5 - self.top

dice1 = Dice([int(n) for n in input().split()])
dice2 = Dice([int(n) for n in input().split()])
if dice1 == dice2:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

import bisect
N,Q = (int(x) for x in input().split())

stop_arr = [(0,0,0) for _ in range(N)]
for i in range(N):
    S,T,X = (int(x) for x in input().split())
    stop_arr[i] = (S,T,X)
Q_arr = [0 for _ in range(Q)]
for i in range(Q):
    Q_arr[i] = int(input())

stop_arr_ind = list(range(N))
stop_arr_ind.sort(key=lambda x:stop_arr[x][2], reverse=True)
# stop_arr.sort(key=lambda x:x[2], reverse=True)
ans_arr = [-1]*Q

for i in stop_arr_ind:
    s,t,x = stop_arr[i]
    q_start = bisect.bisect_left(Q_arr, s-x)
    q_stop = bisect.bisect_left(Q_arr, t-x)
    for i in range(q_start, q_stop):
        ans_arr[i] = x

ans = ""
for a in ans_arr:
    ans += str(a)+"\n"

print(ans, end="")


### FIXED CODE ###

import bisect

N,Q = (int(x) for x in input().split())

stop_arr = [tuple(map(int, input().split())) for _ in range(N)]
Q_arr = [int(input()) for _ in range(Q)]

stop_arr_ind = list(range(N))
stop_arr_ind.sort(key=lambda x:stop_arr[x][2])
# stop_arr.sort(key=lambda x:x[2], reverse=True)
ans_arr = [-1]*Q
skip_arr = [-1]*(Q+1)

def update_skip(skip_arr, x):
    if skip_arr[x] == -1:
        return x
    x_dest = update_skip(skip_arr, skip_arr[x])
    skip_arr[x] = x_dest
    return x_dest

for i in stop_arr_ind:
    s,t,x = stop_arr[i]
    q_start = bisect.bisect_left(Q_arr, s-x)
    q_stop = bisect.bisect_left(Q_arr, t-x)
    l = q_start
    while l < q_stop:
        if skip_arr[l] == -1:
            skip_arr[l] = q_stop
            ans_arr[l] = x
            l += 1
        else:
            l = update_skip(skip_arr, l)

print(*ans_arr, sep="\n")
### BUGGY CODE ###

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

for n in range(N):
  print(A.count(n+1))

### FIXED CODE ###

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

man=1
cnt=0
man_list=[0]*N
A.sort()
A += [0]

for a in A:
  if a != man:
    man_list[man-1] = cnt
    man = a
    cnt=0
  cnt+=1

for l in man_list:
  print(l)
### BUGGY CODE ###

n = int(input())
l = []
for i in range(n):
  a = int(input())
  if a not in l:
    l.append(a)
  elif a in l:
    l.remove(a)
print(len(l))

### FIXED CODE ###

import collections
n = int(input())
l = []
for i in range(n):
  l.append(int(input()))
d = collections.Counter(l)
ans = 0
for v in d.values():
  if v % 2 == 1:
    ans += 1
print(ans)
### BUGGY CODE ###

N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
G = [list(map(int, input().split())) for i in range(N)]

change = [[0]*C for i in range(3)]
for c in range(C):
    for i in range(1, N+1):
        for j in range(1, N+1):
            change[(i+j) % 3][c] += (D[G[i-1][j-1]-1][c] if G[i-1][j-1] != c+1 else 0)

ans = float('inf')
for c1 in range(C):
    for c2 in range(C):
        for c3 in range(C):
            if len(set((c1, c2, c3))) != 3:
                continue
            ans = min(ans, change[0][c1] + change[1][c2] + change[2][c3])

print(ans)


### FIXED CODE ###

N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]
G = [list(map(int, input().split())) for i in range(N)]

change = [[0]*C for i in range(3)]
for c in range(C):
    for i in range(1, N+1):
        for j in range(1, N+1):
            change[(i+j) % 3][c] += (D[G[i-1][j-1]-1][c] if G[i-1][j-1] != c+1 else 0)

ans = float('inf')
for c1 in range(C):
    for c2 in range(C):
        for c3 in range(C):
            if len(set((c1, c2, c3))) != 3:
                continue
            ans = min(ans, change[0][c1] + change[1][c2] + change[2][c3])

print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())
T = [input() for i in range(Q)]

count = 0

for i in range(Q):
  if(int(T[i][0]) == 1):
    count += 1
  else:
    if(int(T[i][2]) == 1):
      if(count % 2 == 0):
        S = T[i][4] + S
      else:
        S = S + T[i][4]
    else:
      if(count % 2 == 0):
        S = S + T[i][4]
      else:
        S = T[i][4] + S

if(count % 2 == 0):
  print(S)
else:
  print(S[::-1])


### FIXED CODE ###

from collections import deque
S = input()
Q = int(input())
T = [input() for i in range(Q)]

d =deque(S)

count = True

for i in range(Q):
  t = T[i]
  if(int(t[0]) == 1):
    count = not count
  else:
    if(int(t[2]) == 1):
      if(count):
        d.appendleft(t[4])
      else:
        d.append(t[4])
    else:
      if(count):
        d.append(t[4])
      else:
        d.appendleft(t[4])

ans = list(d)

if(count):
  print("".join(ans))
else:
  print("".join(ans[::-1]))
### BUGGY CODE ###

from collections import deque
n, m, k = map(int, input().split())
ab = [list(map(lambda x:int(x)-1, input().split())) for _ in range(m)]
cd = [list(map(lambda x:int(x)-1, input().split())) for _ in range(k)]

adlist = [[] for i in range(n)]
neglist = [set() for i in range(n)]
for a, b in ab:
  adlist[a] += [b]
  adlist[b] += [a]
for c, d in cd:
  neglist[c].add(d)
  neglist[d].add(c)

dist = [0]*n 

def pro_bfs(v):
  q = deque([v])
  visited = [0]*n 
  visited[v] = 1 
  dist = [-1]*n 
  dist[v] = 0
  fri = []

  while q:
    u = q.popleft()
    for s in adlist[u]:
      if visited[s] == 0:
        visited[s] = 1
        q += [s]
        dist[s] = dist[u] + 1
        if dist[s] > 1:
          fri += [s]

  return set(fri)

def neg_bfs(v):
  q = deque([v])
  visited = [0]*n 
  visited[v] = 1 
  dist = [-1]*n 
  dist[v] = 0
  fri = []

  while q:
    u = q.popleft()
    for s in adlist[u]:
      if visited[s] == 0:
        visited[s] = 1
        q += [s]
        dist[s] = dist[u] + 1
        if dist[s] == 1:
          fri += [s]

  return fri

ans = []
for i in range(n):
  po = pro_bfs(i)
  ne = neglist[i]
  ans += [len(po-ne)]

ans = list(map(str, ans))
print(' '.join(ans))


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, M, K = map(int, input().split())
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if(x == y):
      return 
    if self.root[x] > self.root[y]:
      x, y = y, x
    self.root[x] += self.root[y]
    self.root[y] = x 
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
  def Count(self, x): # xが属するグループのサイズを返す
    return -self.root[self.Find_Root(x)]
  def Members(self, x): # xが属するグループに属する要素をリストで返す
    return [i for i in range(self.n) if self.Find_Root(i)==self.Find_Root(x)]
  def Roots(self): # 全ての根の要素をリストで返す
    return [i for i, x in enumerate(self.root) if x < 0]
  def Group_Count(self): # グループの数を返す
    return len(self.Roots())

uf = UnionFind(N+1)
roots = {i:0 for i in range(1, N+1)}
each_root = [0]*(N+1)
ad = [0]*(N+1)

for _ in range(M):
  a, b = map(int, input().split())
  uf.Unite(a, b)
  ad[a] += 1
  ad[b] += 1

for i in range(1, N+1):
  r = uf.Find_Root(i)
  roots[r] += 1
  each_root[i] = r

for _ in range(K):
  c, d = map(int, input().split())
  if each_root[c] == each_root[d]:
    ad[c] += 1
    ad[d] += 1

for i in range(1, N+1):
  print(roots[each_root[i]]-ad[i]-1, end=" ")
### BUGGY CODE ###

n,h=map(int,input().split())
l=list(map(int,input().split()))
c=[0]*n
c[1]=abs(l[0]-l[1])
for i in range(2,n):
    c[i]=min( c[i-j]+abs(l[i]-l[i-j]) for j in range(1,h+1) if i-j > -1 )
print(c[-1])

### FIXED CODE ###

n,h=map(int,input().split())
l=list(map(int,input().split()))
c=[10**9]*n
c[0]=0
c[1]=abs(l[0]-l[1])
for i in range(2,n):
    c[i]=min( c[j]+abs(l[i]-l[j]) for j in range(max(0,i-h),i) )
print(c[-1])
### BUGGY CODE ###

import sys, itertools
s = sys.stdin.readline().strip()
l = n1 = len(s)
while True:
    n = l
    skip = False
    _s = ""
    for i, j in itertools.zip_longest(s[:], s[1:]):
        if skip:
            skip = False
            continue
        if i != j and j != None:
            skip = True
        else:
            _s += i
    s = _s
    l = len(s)
    if l != 0 and n != l:
        continue
    else:
        break
print(n1 - len(s))

### FIXED CODE ###

s = input()
print(min(s.count('0'), s.count('1'))*2)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
D = []
result_m = 0
for m in range(M):
  B, C = map(int, input().split())
  D.extend([C]*B)
A.sort()
D.sort(reverse=True)
result = 0
for i in range(min(len(A),len(D))):
  if D[i]-A[i]<=0:
    break
  result+=1
print(sum(D[:result])+sum(A[result:]))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = {}
result_m = 0
for m in range(M):
  B, C = map(int, input().split())
  if BC.get(C) != None:
    BC[C] += B
  else:
    BC[C] = B
A.sort()
BC = sorted(BC.items(), reverse=True)
count = 0
for m in range(len(BC)):
  if count>=len(A):
    break
  if A[count]>BC[m][0]:
    break
  for i in range(BC[m][1]):
    if count>=len(A):
      break
    if BC[m][0] > A[count]:
      A[count] = BC[m][0]
      count+=1
print(sum(A))
### BUGGY CODE ###

from collections import Counter, deque

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    edge = [[i-1, i+1] for i in range(N)]
    edge[0] = [1]
    edge[N-1] = [N-2]
    edge[X].append(Y)
    edge[Y].append(X)

    def bfs(i):
        q = deque()
        q.append(i)
        while len(q):
            now = q.popleft()
            for j in edge[now]:
                if j == i:
                    continue

                if not cost[j]:
                    cost[j] = cost[now] + 1
                    q.append(j)
        
    ct = Counter()
    for i in range(N):
        cost = [0] * N
        bfs(i)
        ct += Counter(cost)

    for i in range(1, N):
        print(ct[i]//2)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import Counter, deque

def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    edge = [[i-1, i+1] for i in range(N)]
    edge[0] = [1]
    edge[N-1] = [N-2]
    edge[X].append(Y)
    edge[Y].append(X)

    def bfs(i):
        q = deque()
        q.append(i)
        while len(q):
            now = q.popleft()
            for j in edge[now]:
                if j == i:
                    continue

                if not cost[j]:
                    cost[j] = cost[now] + 1
                    q.append(j)
        
    ct = Counter()
    for i in range(N):
        cost = [0] * N
        bfs(i)
        ct += Counter(cost)

    for i in range(1, N):
        print(ct[i]//2)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

range_array = [[0 for _ in range(N)] for _ in range(N)]
ans = [[0 for _ in range(N)] for _ in range(N)]

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

for i in range(N):
    sum = 0
    for j in range(N):
        sum += range_array[i][j]
        range_array[i][j] = sum

for i in range(N):
    for j in range(i, N):
        sum = 0
        for k in range(i, j + 1):
            sum += range_array[k][j]
        ans[i][j] = sum

for _ in range(Q):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    sum = 0
    for k in range(p, q + 1):
        sum += range_array[k][q]
    print(sum)


### FIXED CODE ###

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

range_array = [[0 for _ in range(N)] for _ in range(N)]
ans = [[0 for _ in range(N)] for _ in range(N)]

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

for i in range(N):
    sum = 0
    for j in range(N):
        sum += range_array[i][j]
        range_array[i][j] = sum
'''
for i in range(N):
    for j in range(i, N):
        sum = 0
        for k in range(i, j + 1):
            sum += range_array[k][j]
        ans[i][j] = sum
'''
for _ in range(Q):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    sum = 0
    for k in range(p, q + 1):
        sum += range_array[k][q]
    print(sum)
### BUGGY CODE ###

#メモ化したもの(修正版)
n,w=map(int,input().split())
a=[]
dp=[]
for i in range(n):
   a.append(list(map(int,input().split())))
for k in range(n+1):
   dp.append([])
   for l in range(w+1):
       dp[k].append(-1)
def rec(i,j):
   if dp[i][j]>=0:
       return dp[i][j]
   if i==n:
       res=0
   elif j<a[i][0]:
       res=rec(i+1,j)
   else:
       res=max(rec(i+1,j),rec(i+1,j-a[i][0])+a[i][1])
   dp[i][j]=res
   return res
print(rec(0,w))

### FIXED CODE ###

#dpテーブルのみでの解法(順方向)
n,w=map(int,input().split())
a=[]
dp=[]
for i in range(n):
   a.append(list(map(int,input().split())))
for k in range(n+1):
  dp.append([])
  for l in range(w+1):
      dp[k].append(0)
for i in range(n):
   for j in range(w+1):
       if j<a[i][0]:
           dp[i+1][j]=dp[i][j]
       else:
           dp[i+1][j]=max(dp[i][j],dp[i][j-a[i][0]]+a[i][1])
print(dp[n][w])
### BUGGY CODE ###

s = input()
res = s.count('ABC')

for i in range(len(s)):
  s = s.replace('ABC', 'BCA')
  res += s.count('ABC')
  if not 'ABC' in s:
    break
  
  
print(res)

### FIXED CODE ###

import re
import sys
input = sys.stdin.readline

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

for kk in s:
  if not kk:
    continue
  d = 0
  for a in kk[::-1]:
    if a == 'D':
      d += 1
    else:
      res += d
    
print(res)
### BUGGY CODE ###

from collections import deque

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

res = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            stack = deque([])
            flag = [[False for _ in range(W)] for _ in range(H)]
            stack.append([i, j])
            flag[i][j] = True
            start = S[i][j]
            while len(stack) > 0:
                y, x = stack.popleft()
                for nx, ny in ([1, 0], [0, 1], [-1, 0], [0, -1]):
                    if 0<= x + nx < W and 0 <= y + ny < H:
                        if S[y][x] != S[y+ny][x+nx] and flag[y+ny][x+nx] == False:
                            stack.append([y+ny, x+nx])
                            flag[y+ny][x+nx] = True
                            if S[y+ny][x+nx] != start:
                                res += 1
            
                
            
            
print(res)



### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]
flag = [[-1 for _ in range(W)] for _ in range(H)]

now = 0
for i in range(H):
    for j in range(W):
        if flag[i][j] == -1:
            stack = deque([]) 
            stack.append([i, j])
            flag[i][j] = now
            while len(stack) > 0:
                y, x = stack.popleft()
                for nx, ny in ([1, 0], [0, 1], [-1, 0], [0, -1]):
                    if 0<= x + nx < W and 0 <= y + ny < H:
                        if S[y][x] != S[y+ny][x+nx] and flag[y+ny][x+nx] == -1:
                            stack.append([y+ny, x+nx])
                            flag[y+ny][x+nx] = now
            now += 1
    
Black = [0 for _ in range(now+1)]
White = [0 for _ in range(now+1)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            Black[flag[i][j]] += 1
        else:
            White[flag[i][j]] += 1
   
res = 0
for i in range(now + 1):
    res += Black[i] * White[i]
    
print(res)
### BUGGY CODE ###

N = int(raw_input())
a = []
for i in range(N):
	a.append(raw_input())
#print a
for i in range(N):
	a[i] = int(a[i])
cnt = 0
trn = 0
while trn != 1:
	if trn == -1:
		cnt = -1
		break
	#print a

	hako = trn
	trn = a[trn] - 1
	a[hako] = -1
	cnt += 1
	
print cnt

### FIXED CODE ###

N = int(raw_input())
a = []
for i in range(N):
	a.append(raw_input())
#print a
for i in range(N):
	a[i] = int(a[i])
cnt = 0
trn = 0
while trn != 1:
	if trn == -2:
		cnt = -1
		break
	#print a

	hako = trn
	trn = a[trn] - 1
	a[hako] = -1
	cnt += 1
	
print cnt
### BUGGY CODE ###

N = int(input())
S = []
for _ in range(N):
    S.append(input())

char_list = []
for s in S:
    if s not in char_list:
        char_list.append(s)

print(len(char_list))

### FIXED CODE ###

N = int(input())
S = []
for _ in range(N):
    S.append(input())

import collections
print(len(collections.Counter(S)))