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

import sys
from collections import deque

H, W, K = map(int, sys.stdin.readline().strip().split())
xs, ys, xg, yg = map(int, sys.stdin.readline().strip().split())

m = []
for _ in range(H):
    m.append(list(map(str, sys.stdin.readline().strip())))

M = [[float('inf')] * W for _ in range(H)]


def bfs(x1, y1, d):
    q = deque()
    q.append((d, x1, y1))

    while q:
        d, x1, y1 = q.popleft()

        M[x1][y1] = d

        if (x1 == xg - 1) and (y1 == yg - 1):
            break

        for dx, dy in ([0, 1], [1, 0], [0, -1], [-1, 0]):
            k = 1
            while k <= K:
                x2 = x1 + dx * k
                y2 = y1 + dy * k
                if x2 < 0 or x2 >= H:
                    break
                if y2 < 0 or y2 >= W:
                    break
                if m[x2][y2] == '@':
                    break
                if M[x2][y2] < d + 1:
                    break

                q.append((d + 1, x2, y2))

                k += 1


if m[xs - 1][ys - 1] != '@':
    bfs(xs - 1, ys - 1, 0)

# for i in range(len(M)):
#     print(M[i])


ans = M[xg - 1][yg - 1]
if ans == float('inf'):
    print(-1)
else:
    print(ans)


### FIXED CODE ###

from collections import deque


def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
        # queueには訪れた地点が入っている。そこから、4方向に移動できるか考え、queueから消す。
        y, x = queue.popleft()  # queueに入っていたものを消す。
        if [y, x] == [gy, gx]:  # もしゴールについていたならば、そのときの手数を出す。
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            l = 1
            while True:
                new_y, new_x = y + j * l, x + k * l
                if (0 <= new_y < H) and (0 <= new_x < W):
                    if maze[new_y][new_x] == "@":
                        break
                    elif visited[new_y][new_x] == -1:  # まだ来たことない点だったという条件
                        visited[new_y][new_x] = visited[y][x] + 1
                        queue.append([new_y, new_x])  # 新しい点を足す。
                    elif visited[new_y][new_x] < visited[y][x] + 1:
                        break
                else:
                    break
                l += 1
                if l == K + 1:
                    break


H, W, K = map(int, input().split())
# K = min(K, max(H, W))
x1, y1, x2, y2 = map(int, input().split())
x1, y1, x2, y2 = x1 - 1, y1 - 1, x2 - 1, y2 - 1
C = [0] * H
for i in range(H):
    C[i] = str(input())
visited = [[-1] * W for i in range(H)]
bfs(C, visited, x1, y1, x2, y2)
# print(visited)
print(visited[x2][y2])
### BUGGY CODE ###

INF = 10 ** 9

def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    dp = [INF] * N
    dp[0] = 0
    for i in range(1, N):
        ks = max(0, i-K)
        hi = H[i]
        for j in range(ks, i):
            dp[i] = min(dp[i], dp[j] + abs(hi - H[j]))
    
    print(dp[N-1])
    

if __name__ == "__main__":
    main()

### FIXED CODE ###

INF = 10 ** 9

def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    dp = [INF] * N
    dp[0] = 0
    for i in range(1, N):
        ks = max(0, i-K)
        hi = H[i]
        for j in range(ks, i):
            dp[i] = min(dp[i], dp[j] + abs(hi - H[j]))
    
    print(dp[N-1])


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

def abc068_c():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(m)]
    first_index = []
    for i in range(m):
        if ab[i][0] == 1:
            first_index.append(ab[i][1])

    for i in range(m):
        if ab[i][0] in first_index and ab[i][1] == n:
            print("POSSIBLE")
            return 0
    print("IMPOSSIBLE")


abc068_c()

### FIXED CODE ###

def abc068_c():
    from collections import Counter
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(m)]
    candidates = []

    for i in range(m):
        if ab[i][0] == 1:
            candidates.append(ab[i][1])
        elif ab[i][1] == n:
            candidates.append(ab[i][0])

    if max(Counter(candidates).values()) >= 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


abc068_c()
### BUGGY CODE ###

S=input()
M=13
MOD=10**9+7
dp=[[0]*M for i in range(len(S)+1)]
dp[0][0]=1
for i in range(len(S)):
  s=S[i]
  if s=='?':
    for s in range(10):
      for j,d in enumerate(dp[i]):
        dp[i+1][(10*j+s)%M]+=d
  else:
    s=int(s)
    for j,d in enumerate(dp[i]):
      dp[i+1][(10*j+s)%M]=d
print(dp[-1][5]%MOD)

### FIXED CODE ###

S=input()
import numpy as np
M=13
MOD=10**9+7
dp=np.zeros(M, dtype=np.int64)
dp[0]=1
idx = np.zeros(M, dtype=np.int8)
window = np.ones(10, dtype=np.int8)
for i in range(M):
  idx[i * 10 % M] = i
for s in S:
  if s=='?':
    tdp=dp[idx]
    ndp = np.concatenate([tdp[4:], tdp])
    dp = np.convolve(ndp, window, mode='valid') % MOD
  else:
    dp=np.roll(dp[idx],int(s))
print(dp[5]%MOD)
### BUGGY CODE ###

from collections import deque

s = input()
q = int(input())
ls = [input().split() for _ in range(q)]

ans = deque(s)

for t in ls:
    if t[0] == '1':
        ans.reverse()
    elif t[0] == '2':
        if t[1] == '1':
            ans.appendleft(t[2])
        elif t[1] == '2':
            ans.append(t[2])

print("".join(ans))

### FIXED CODE ###

from collections import deque

s = input()
q = int(input())
ls = [input().split() for _ in range(q)]

ans = deque(s)
cnt = 0

for t in ls:
    if t[0] == '1':
        cnt += 1
    elif t[0] == '2':
        if cnt % 2 == 0:
            if t[1] == '1':
                ans.appendleft(t[2])
            elif t[1] == '2':
                ans.append(t[2])
        elif cnt % 2 == 1:
            if t[1] == '1':
                ans.append(t[2])
            elif t[1] == '2':
                ans.appendleft(t[2])

if cnt % 2 == 0:
    print("".join(ans))
elif cnt % 2 == 1:
    ans.reverse()
    print("".join(ans))
### BUGGY CODE ###

N = int(input())
S = input()

from itertools import permutations, combinations,combinations_with_replacement,product
L = list(combinations(range(N), 3))   #nCr
A=[]
Cnt = 0
for i in L:
  X = S[i[0]]+S[i[1]]+S[i[2]]
  if X not in A:
    A.append(X)
    Cnt +=1
  if Cnt == 1000:
    break
print(Cnt)

### FIXED CODE ###

N = int(input())
S = input()
Pin = ['{0:03d}'.format(a) for a in range(0,1000)]
cnt = 0
for i in Pin:
  S1 = S
  A1 = S1.find(i[0])
  if A1!=-1:
    S2 = S1[(A1+1):]
    A2 = S2.find(i[1])
    if A2!=-1:
      S3 = S2[(A2+1):]
      A3 = S3.find(i[2])
      if A3!=-1:
        cnt +=1
print(cnt)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
check = 10**18
ans = a[0]

for  i in range(1,n):
    ans = ans * a[i]
if ans <= check:
    print(ans)
else:
    print('-1')

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
check = 10**18

a = sorted(a)
ans = a[0]
tmp = 0


for i in range(n-1,0,-1):
    ans = ans * a[i]
    if ans > check:
        tmp  = 1
        break
    elif a[0] == 0:
        tmp = 2
        break

if tmp == 1:
    print('-1')
elif tmp == 0:
    print(ans)
elif tmp == 2:
    print('0')
### BUGGY CODE ###


from collections import defaultdict

H,W,M=map(int,input().split())
AB=[tuple(map(int,input().split()))for i in range(M)]
AB=[(a-1,b-1)for a,b in AB]
st=set(AB)

Wc=defaultdict(lambda :0)
Hc=defaultdict(lambda :0)
for a,b in AB:
    Hc[a]+=1
    Wc[b]+=1

ans=0
for i in Hc.keys():
    for j in Wc.keys():
        add = -1 if (i,j) in st else 0
        tmp= Hc[i] + Wc[j] + add
        ans=max(ans,tmp)

print(ans)

### FIXED CODE ###


from collections import defaultdict

H,W,M=map(int,input().split())
AB=[tuple(map(int,input().split()))for i in range(M)]
AB=[(a-1,b-1)for a,b in AB]
st=set(AB)

Wc=defaultdict(lambda :0)
Hc=defaultdict(lambda :0)
for a,b in AB:
    Hc[a]+=1
    Wc[b]+=1

Hm=max(Hc.values())
hhh=list(Hc.keys())
www=list(Wc.keys())
for i in hhh:
    if Hc[i]!=Hm:
        Hc.pop(i)
Wm=max(Wc.values())
for j in www:
    if Wc[j]!=Wm:
        Wc.pop(j)

ans=0
count=0
for i in Hc.keys():
    for j in Wc.keys():
        add = -1 if (i,j) in st else 0
        tmp= Hc[i] + Wc[j] + add
        ans=max(ans,tmp)
        if count>300000:
            break
        count+=1

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

import numpy as np

D,G = map(int, input().split())
P = []
C = []

for i in range(D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

cnt = [0 for _ in range(D)]

ans = sum(P)
cnt_tar = 0

for i in range(D):
    tar = i

    ind_list = list(range(D))
    ind_list.remove(tar)
    ind_list = np.array(ind_list)

    P_part = np.array(P[:tar] + P[tar+1:])
    C_part = np.array(C[:tar] + C[tar+1:])

    cnt_part = np.zeros(D-1,dtype=int)#[0 for _ in range(D-1)]
    point_part = np.zeros(D-1,dtype=int)#[0 for _ in range(D-1)]

    for cnt_tar in range(P[tar]+1):
        point_base = cnt_tar*(tar+1)*100

        num_base   = cnt_tar + C[tar]*max(0,cnt_tar-P[tar] + 1)

        if point_base >= G:
            num = num_base
            ans = min(ans,num)
            break
        else:
            for bit_seed in range(2**(D-1)):

                s_bit = (format(bit_seed, '#011b'))[::-1]
                bit_list = np.array(list(s_bit[:D-1]),dtype=int)

                cnt_part = P_part*bit_list
                point_part = cnt_part * (ind_list+1) * 100 + C_part*bit_list

                # for j in range(D-1):
                #     bit = int(s_bit[j:j+1])
                #     cnt_part[j]   = (P_part[j])*bit
                #     point_part[j] = (P_part[j]*(P.index(P_part[j])+1)*100 + C_part[j])*bit
                # print(cnt_part)

                num = num_base + sum(cnt_part)
                point = point_base + sum(point_part)
#                print(cnt_tar,cnt_part,point)
                if point >= G:
                    # print('point = ',point,'/',G)
                    # print(num)
                    ans = min(ans,num)

print(ans)

### FIXED CODE ###

import numpy as np

D,G = map(int, input().split())
P = []
C = []

for i in range(D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

cnt = np.zeros(D,dtype=int)
P = np.array(P)
C = np.array(C)

ans = sum(P)
cnt_tar = 0

ind_list = np.arange(D)

for bit_seed in range(2**D):

    s_bit = (format(bit_seed, '#016b'))[::-1]
    bit_list = np.array(list(s_bit[:D]),dtype=int)

    cnt = P*bit_list
    num_base = np.sum(cnt)

    point_base_array = (P * (ind_list+1) * 100 + C) * bit_list
    point_base = np.sum(point_base_array)
#    print(point_base_array)

    if point_base >= G:
        num = num_base
        ans = min(ans,num)
    elif num_base > ans:
        continue
    else:
        for i,bit in enumerate(bit_list):
            if bit == 0:
                tar = i

        point_max = point_base + P[tar]*(tar+1)*100 + C[tar]
        if point_max >= G:

            tar_min = (G-point_base) // ((tar+1)*100)
            point = point_base + P[tar]*(tar+1)*100*tar_min

            if point < G:
                tar_min += 1

            if tar_min < P[tar]:
                num = num_base + tar_min
            else:
                num = num_base + P[tar]
            ans = min(ans,num)

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

def main():
  from collections import defaultdict
  from heapq import heappush,heappop
  inf=2**31-1
  n,m,*t=map(int,open(0).read().split())
  edge=defaultdict(list)
  used,d={},{}
  l=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    if b<a:a,b=b,a
    x,y=a+n*c,b+n*c
    if b==n:
      l.append(y)
      d[y]=inf
    edge[a].append((1,x))
    edge[b].append((1,y))
    ex,ey=edge[x].append,edge[y].append
    ex((0,a))
    ex((0,y))
    ey((0,b))
    ey((0,x))
    used[a]=used[b]=used[x]=used[y]=True
  used[1]=False
  edgelist=[]
  for e in edge[1]:
    heappush(edgelist,e)
  while edgelist:
    m=heappop(edgelist)
    if not used[m[1]]:
      continue
    d[m[1]]=m[0]
    used[m[1]]=False
    for e in edge[m[1]]:
      if used[e[1]]:
        heappush(edgelist,(e[0]+m[0],e[1]))
  a=min([d[i]for i in l]or[inf])
  print([a,-1][a==inf])
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  from heapq import heappush,heappop,heapify
  inf=2**31-1
  n,m,*t=map(int,open(0).read().split())
  z=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    z.extend([a,b,a+n*c,b+n*c])
  z={i:v for v,i in enumerate(sorted(set(z)))}
  try:
    z[1]
  except:
    print(-1)
    exit()
  edge=[[]for _ in range(len(z))]
  d={}
  l=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    if b<a:a,b=b,a
    i,j,x,y=z[a],z[b],z[a+n*c],z[b+n*c]
    if b==n:
      l.append(y)
    edge[i].append((1,x))
    edge[j].append((1,y))
    edge[x].extend([(0,i),(0,y)])
    edge[y].extend([(0,j),(0,x)])
  used=[False]+[True]*~-len(z)
  d=[0]+[inf]*~-len(z)
  edgelist=edge[0]
  heapify(edgelist)
  while edgelist:
    m=heappop(edgelist)
    if not used[m[1]]:
      continue
    d[m[1]]=m[0]
    used[m[1]]=False
    for e in edge[m[1]]:
      if used[e[1]]:
        heappush(edgelist,(e[0]+m[0],e[1]))
  a=min([d[i]for i in l]or[inf])
  print([a,-1][a==inf])
if __name__=='__main__':
  main()
### BUGGY CODE ###

import collections
def main():
    N, M = map(int, input().split())
    graph = collections.defaultdict(dict)
    for _ in range(M):
        L, R, D = map(int, input().split())
        graph[L][R] = D
        graph[R][L] = -D

    visited = set()
    for i in range(1, N+1):
        if i not in visited:
            cur = dict()
            cur[i] = 0
            while True:
                temp = dict()
                for j in cur:
                    for k in graph[j]:
                        l = cur[j] + graph[j][k]
                        if k not in cur:
                            temp[k] = l
                        elif k in cur and cur[k] != l:
                            return "No"
                        elif k in temp and temp[k] != l:
                            return "No"
                for k in temp:
                    cur[k] = temp[k]
                if len(temp) == 0:
                    break
    return "Yes"

if __name__ == '__main__':
    print(main())

### FIXED CODE ###

import collections
def main():
    N, M = map(int, input().split())
    graph = collections.defaultdict(dict)
    for _ in range(M):
        L, R, D = map(int, input().split())
        graph[L][R] = D
        graph[R][L] = -D

    visited = set()
    used = set()
    for i in range(1, N+1):
        if i not in visited:
            dist = dict()
            dist[i] = 0
            cur = [i]
            visited.add(i)
            while cur:
                temp = []
                for j in cur:
                    for k in graph[j]:
                        if (j, k) not in used and (k, j) not in used:
                            used.add((j, k))
                            used.add((k, j))
                            if k not in dist:
                                dist[k] = dist[j] + graph[j][k]
                                temp.append(k)
                                visited.add(k)
                            elif k in dist:
                                if dist[k] != dist[j] + graph[j][k]:
                                    return "No"
                cur = temp

    return "Yes"

if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

N,X,Y = map(int, input().split())

dist = [[0 for i in range(N)] for j in range(N)]
for i in range(1,N):
    for j in range(i):
        dist[i][j]=i-j
dist[Y-1][X-1]=1

for i in range(N):
    y1 = min(Y-1+i,N-1)
    y2 = max(Y-1-i,0)
    for j in range(N):
        x1 = min(X-1+j,N-1)
        x2 = max(X-1-j,0)
        dist[min(y1+1,N-1)][x1] = min(dist[y1][x1]+1,dist[min(y1+1,N-1)][x1])
        dist[min(y1+1,N-1)][x2] = min(dist[y1][x2]+1,dist[min(y1+1,N-1)][x2])
        dist[max(y2-1,0)][x1] = min(dist[y2][x1]+1,dist[max(y2-1,0)][x1])
        dist[max(y2-1,0)][x2] = min(dist[y2][x2]+1,dist[max(y2-1,0)][x2])
        dist[y1][min(x1+1,N-1)] = min(dist[y1][x1]+1,dist[y1][min(x1+1,N-1)])
        dist[y2][min(x1+1,N-1)] = min(dist[y2][x1]+1,dist[y2][min(x1+1,N-1)])
        dist[y1][max(x2-1,0)] = min(dist[y1][x2]+1,dist[y1][max(x2-1,0)])
        dist[y2][max(x2-1,0)] = min(dist[y2][x2]+1,dist[y2][max(x2-1,0)])

ans = [0]*(N-1)

for i in range(1,N):
    for j in range(i):
        ans[dist[i][j]-1] += 1

for i in ans:
    print(i)

### FIXED CODE ###

N,X,Y = map(int, input().split())

dist = [[0 for i in range(N)] for j in range(N)]
for i in range(1,N):
    for j in range(i):
        dist[i][j]=i-j
dist[Y-1][X-1]=1

for i in range(N):
    y1 = min(Y-1+i,N-1)
    y2 = max(Y-1-i,0)
    for j in range(N):
        x1 = min(X-1+j,N-1)
        x2 = max(X-1-j,0)
        dist[min(y1+1,N-1)][x1] = min(dist[y1][x1]+1,dist[min(y1+1,N-1)][x1])
        dist[min(y1+1,N-1)][x2] = min(dist[y1][x2]+1,dist[min(y1+1,N-1)][x2])
        dist[max(y2-1,0)][x1] = min(dist[y2][x1]+1,dist[max(y2-1,0)][x1])
        dist[max(y2-1,0)][x2] = min(dist[y2][x2]+1,dist[max(y2-1,0)][x2])
        dist[y1][min(x1+1,N-1)] = min(dist[y1][x1]+1,dist[y1][min(x1+1,N-1)])
        dist[y2][min(x1+1,N-1)] = min(dist[y2][x1]+1,dist[y2][min(x1+1,N-1)])
        dist[y1][max(x2-1,0)] = min(dist[y1][x2]+1,dist[y1][max(x2-1,0)])
        dist[y2][max(x2-1,0)] = min(dist[y2][x2]+1,dist[y2][max(x2-1,0)])

ans = [0]*(N-1)

for i in range(1,N):
    for j in range(i):
        ans[dist[i][j]-1] += 1

for i in ans:
    print(i)
### BUGGY CODE ###

n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

cnt = -1

aa = a.copy()
bb = b.copy()

aa = [sum(a[:s+1]) for s in range(n)]
bb = [sum(b[:s+1]) for s in range(m)]
      
ans = 0

for i in range(n):
    bb_sharp = k - aa[i]
    if bb_sharp < 0:
        break
    else:
        bb_below =[bb[s] for s in range(m) if bb[s] <= bb_sharp]
        temp = i+1 + len(bb_below)
        if temp > ans:
           ans = temp
        
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aa = [0]
bb = [0]

for s in range(n):
    aa.append(aa[s] + a[s])
for s in range(m):
    bb.append(bb[s] + b[s])      
ans = 0
j = m

for i in range(n+1):
    if aa[i] > k:
        break
    while bb[j] > k - aa[i]:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())

# Union FInd
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  def size(self, x):
    return -self.parents[self.find(x)]
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
  def group_count(self):
    return len(self.roots())
  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}
  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf=UnionFind(n)
for _ in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  uf.union(a,b)
ans=0
d=uf.all_group_members()
for c in d.values():
  ans=max(ans,len(c))
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

N,Q = map(int,input().split())
par = [i for i in range(N)]
rank = [0]*(N+1)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x]==rank[y]:rank[x]+=1

for _ in range(Q):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  unite(a,b)
from collections import Counter
a=[-1]*N
for i in range(N):
  a[i]=find(i)
ca=Counter(a)
ans=0
for c in ca.values():
  ans=max(ans,c)
print(ans)
### BUGGY CODE ###

from collections import deque

n = int(input())
dll = deque()

for i in range(n):
    input_line = [str(s) for s in input().split()]
    if input_line[0] == "insert":
        dll.appendleft(int(input_line[1]))
    elif input_line[0] == "delete":
        try:
            dll.remove(int(input_line[1]))
        except ValueError:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
print(*dll)

### FIXED CODE ###

from collections import deque
   
n = int(input())
dll = deque()
   
for i in range(n):
    input_line = input().split()
    if input_line[0] == "insert":
        dll.appendleft(input_line[1])
    elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
           
print(*dll)
### BUGGY CODE ###

def resolve():
    from collections import Counter
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    d = Counter(s).most_common()
    e = d[0][1]
    f = ([i for i in s if s.count(i) == e])
    f = sorted(set(f))
    for i in f:
        print(i)
resolve()

### FIXED CODE ###

def resolve():
    import sys
    from collections import Counter
    n = int(input())
    s = [sys.stdin.readline().rstrip() for i in range(n)]
    d = Counter(s).most_common()
    e = d[0][1]
    ans = []
    for i in range(len(d)):
        if d[i][1] != e:
            break
        else:
            ans.append(d[i][0])
    for j in sorted(ans):
        print(j)
resolve()
### BUGGY CODE ###

N = int(input())
s = [str(sorted(input())) for i in range(N)]
count = [0]*N
for i in range(N):
    count[i] = s.count(s[0])-1
    s = s[1:]
print(sum(count))

### FIXED CODE ###

import collections

N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for si in set(s):
    n = c[si]
    ans += n * (n - 1) // 2
print(ans)
### BUGGY CODE ###

s = input()
h = []
n = len(s)
for i in range(0,n):
    h.append(0)

n = len(s)
for i in range(0,n):
    if s[i] == "R":
        j = s.find("RL", i)
        d = j-i
    elif s[i] == "L":
        j = s.rfind("RL", 0, i+1)
        d = i-j
    if d % 2 == 1:
        h[j+1] += 1
    else:
        h[j] += 1

ans = ""
for x in h:
    ans += str(x) + " "
print(ans)


### FIXED CODE ###

import sys
input=sys.stdin.readline

def runLength(s):
    a = []
    for c in s:
        if len(a)==0 or a[-1][0]!=c:
            a.append([c,1])
        else:
            a[-1][1] += 1
    return a

s = input().strip()
a = runLength(s)

#print(a)
ans = [0]*len(s)
j = 0
for i in range(len(s)-1):
    if s[i] == "R" and s[i+1] == "L":
        ans[i] += a[j][1]//2 + a[j+1][1]//2
        ans[i+1] += a[j][1]//2 + a[j+1][1]//2
        if a[j][1] % 2 != 0:
            ans[i] += 1
        if a[j+1][1] % 2 != 0:
            ans[i+1] += 1
#        print(j, ans)
        j += 2
print(*ans)