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

from collections import deque
import itertools

H,W = map(int,input().split())
labyrinth = [[] for i in range(H)]
points = []

for i in range(H):
  w = list(input())
  labyrinth[i] = w
  for j in range(W):
    if w[j] == ".":
      points.append([j,i])


com = list(itertools.combinations(points,2))

#移動パターン
movex = [1,0,-1,0]
movey = [0,1,0,-1]

def shortest_path(sx,sy,gx,gy,labyrinth):
  INF = 10 ** 2

  x_length = W
  y_length = H
  distance = [[INF for i in range(x_length)] for j in range(y_length)]
  
  queue = deque()
  queue.append((sx,sy))
  distance[sy][sx] = 0
  
  #幅優先探索
  def bfs():
    #探索候補がある限り
    while len(queue) > 0:
      x,y = queue.popleft()
      
      #ゴールの座標に達したら中止
      if x == gx and y == gy:
        break
        
      for i in range(0, 4):
        nx = x + movex[i]
        ny = y + movey[i]

        #探索迷路内であり
        if (0 <= nx and ny < y_length and 0 <= ny and nx < x_length):
          #通行可能かつ未到達であれば
          if (labyrinth[ny][nx] != "#"  and distance[ny][nx] == INF):
            queue.append((nx,ny))
            distance[ny][nx] = distance[y][x] + 1
    
    return distance[gy][gx]

  return bfs()

path = []

for i in range(len(com)):
  s = com[i][0]
  g = com[i][1]
  sx = s[0]
  sy = s[1]
  gx = g[0]
  gy = g[1]
  dist = shortest_path(sx,sy,gx,gy,labyrinth)
  path.append(dist)
  
print(max(path))


### FIXED CODE ###

from collections import deque
import itertools

H,W = map(int,input().split())
labyrinth = [[] for i in range(H)]
points = []

for i in range(H):
  w = list(input())
  labyrinth[i] = w
  for j in range(W):
    if w[j] == ".":
      points.append([j,i])

com = list(itertools.combinations(points,2))

#移動パターン
movex = [1,0,-1,0]
movey = [0,1,0,-1]

def shortest_path(sx,sy,labyrinth):
  INF = -(10 ** 6)

  x_length = W
  y_length = H
  distance = [[INF for i in range(x_length)] for j in range(y_length)]
  
  queue = deque()
  queue.append((sx,sy))
  distance[sy][sx] = 0
  
  #幅優先探索
  def bfs():
    #探索候補がある限り
    while len(queue) > 0:
      x,y = queue.popleft()

      #上下左右を探索
      for i in range(0, 4):
        nx = x + movex[i]
        ny = y + movey[i]
        #print(nx,ny)
        #探索迷路内であり
        if (0 <= nx and ny < y_length and 0 <= ny and nx < x_length):
          #通行可能かつ未到達であれば
          if (labyrinth[ny][nx] != "#"  and distance[ny][nx] == INF):
            queue.append((nx,ny))
            distance[ny][nx] = distance[y][x] + 1
    
    dismax = max(list(itertools.chain.from_iterable(distance)))

    return dismax
    
  return bfs()

path = 0

for i in range(len(points)):
  sx = points[i][0]
  sy = points[i][1]
  dist = shortest_path(sx,sy,labyrinth)
  if path < dist:
    path = dist
  
print(path)
### BUGGY CODE ###

# ABC171 E 

import itertools

n = int(input())
a_l = [list(format(int(x), "030b")) for x in input().split()]

a_l = list(zip(*a_l))

for _d,_tp in enumerate(a_l):
    if "1" not in _tp:
        continue
    if "0" not in _tp:
        continue
    else:
        _num = _tp.count("0")
        if _num % 2 == 1:
            a_l[_d] = ["1" if x == "0" else "0" for x in a_l[_d]]

a_l = list(zip(*a_l))
print(*[int("".join(x), 2) for x in a_l])

### FIXED CODE ###

# ABC171 E 

import itertools

n = int(input())
a_l = [list(format(int(x), "030b")) for x in input().split()]

for _d,_tp in enumerate(zip(*a_l)):
    if "1" not in _tp:
        continue
    if "0" not in _tp:
        continue
    else:
        _num = _tp.count("0")
        if _num % 2 == 1:
            for i in range(n):
                if a_l[i][_d] == "0":
                    a_l[i][_d] = "1"
                else:
                    a_l[i][_d] = "0"

print(*[int("".join(x), 2) for x in a_l])
### BUGGY CODE ###

import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 998244353

    n,k = get_nums_l()

    steps = []
    for _ in range(k):
        l,r = get_nums_l()
        for i in range(l, r+1):
            steps.append(i)

    # dp[i] = iマスまで行く方法のパターン数
    dp = [0] * (n+1)

    dp[1] = 1

    for i in range(1, n):
        for step in steps:
            if i+step <= n:
                dp[i+step] = (dp[i+step] + dp[i]) % MOD

    print(dp[n] % MOD)

main()

### FIXED CODE ###

import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 998244353

    n,k = get_nums_l()

    steps = []
    for _ in range(k):
        l,r = get_nums_l()
        steps.append((l,r))
    
    # log(steps)

    # dp[i] = iマスまで行く方法のパターン数
    dp = [0] * (n)
    ruiseki = [0] * (n+1)

    dp[0] = 1
    ruiseki[1] = 1

    for i in range(1, n):
        for a,b in steps:
            l = max(0, i-b)
            r = i-a
            # log("A", i,l,r)
            if r < 0:
                continue

            add = (ruiseki[r+1] - ruiseki[l])
            dp[i] = (dp[i] + add) % MOD
            # log("  B", add)
        ruiseki[i+1] = (ruiseki[i] + dp[i]) % MOD
        # log(dp, ruiseki)

    print(dp[n-1] % MOD)

main()
### BUGGY CODE ###

import bisect

N=int(input())
A=sorted(list(map(int,input().split())))
Q=int(input())
for i in range(Q):
  b,c=map(int,input().split())
  l=bisect.bisect_left(A,b)
  r=bisect.bisect_right(A,b)
  for j in range(l,r):
    A[j]=c
  print(sum(A))

### FIXED CODE ###

import sys

def input():
  return sys.stdin.readline()

N=int(input())
A=list(map(int,input().split()))
B=[0]*(10**5)
for a in A:
  B[a-1]+=1
s=sum(A)
Q=int(input())
for i in range(Q):
  b,c=map(int,input().split())
  bb,bc=B[b-1],B[c-1]
  B[c-1]+=bb
  B[b-1]=0
  s+=bb*c-bb*b
  print(s)
### BUGGY CODE ###

import copy
N = int(input())
a = [input() for i in range(N)]
a = list(map(int, a))

for i in range(N):
    a_copy = copy.copy(a)
    a_copy.pop(i)
    print(max(a_copy))


### FIXED CODE ###

import copy
N = int(input())
a = [input() for i in range(N)]
a = list(map(int, a))
max_a = sub_max_a = max(a)
count = 0
for i in range(N):
    if max_a == a[i]:
        count += 1
        max_i = i
if count == 1:
    a.pop(max_i)
    sub_max_a = max(a)

for j in range(N):
    if max_i == j:
        print(sub_max_a)
    else:
        print(max_a)
### BUGGY CODE ###

N = int(input())

arr = []
for i in range(N):
    arr.append(str(input()))

count = 0

def sort_str(s):
    return "".join(sorted(list(s)))


sorted_str_arr = []

for item in arr:
    sorted_str_arr.append(sort_str(item))

for i, item in enumerate(sorted_str_arr):
    for j in range(i+1, N):
        if item == sorted_str_arr[j]:
            count += 1

print(count)

### FIXED CODE ###

N = int(input())

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

m = {}

def sort_str(s):
    return "".join(sorted(list(s)))

for i in range(N):
    s = str(input())
    ss = sort_str(s)

    if ss in m:
        m[ss] += 1
    else:
        m[ss] = 1


count = 0

for c in m.values():
    if c > 1:
        count += cmb(c, 2)

print(count)
### BUGGY CODE ###


N = int(input())
L = [int(input()) for i in range(N)]

M = []
P = []
for p in L:
    try:
        s = M.index(p-1)
    except:
        M.append(p)
        P.append(1)
        continue
    M[s] = p
    P[s] += 1

print(N-max(P))

### FIXED CODE ###

N = int(input())
L = [int(input()) for i in range(N)]


P = [0] * (N + 1)

for p in L:
    P[p] = P[p-1] + 1


print(N-max(P))
### BUGGY CODE ###

def main():
    n = int(input())

    s = []
    e = []
    tls = []
    buff = {}
    for i in range(n):
        tmp = list(map(int, input().split()))
        s.append(tmp[0] - tmp[1])
        e.append(tmp[0] + tmp[1])
    for i in range(n):
        buff[s[i]] = e[i]
    
    maxcount = 0
    sorted_s = sorted(s)
    preve = 0
    while len(sorted_s) > 0:
        tmps = sorted_s[0]
        tmpe = buff[tmps]
        if preve == 0:
            maxcount += 1
            preve = tmpe
            sorted_s = sorted_s[1:]
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
            sorted_s = sorted_s[1:]
        elif tmpe < preve:
            preve = tmpe
            sorted_s = sorted_s[1:]
        else:
            sorted_s = sorted_s[1:]
    print(maxcount)
    return
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

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

n = int(input())
A = [0] + list(map(int, input().split())) + [0]

D = [abs(A[i+1]-A[i]) for i in range(len(A)-1)]

for i in range(n):
  print(sum(D)-D[i]-D[i+1]+abs(A[i+2]-A[i]))

### FIXED CODE ###

n = int(input())
A = [0] + list(map(int, input().split())) + [0]

D = [abs(A[i+1]-A[i]) for i in range(len(A)-1)]
base = sum(D)

for i in range(n):
  print(base-D[i]-D[i+1]+abs(A[i+2]-A[i]))
### BUGGY CODE ###

import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
# import numpy as np
starttime = time.time()
# import numpy as np
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    # sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    # sys.stdout = open("../output.txt", "w")
except:
    pass

n,k=L()
H=L()
dp=[10**10 for i in range(n)]
dp[0]=0
dp[1]=abs(H[1]-H[0])
for i in range(2,n):
    for j in range(1,k+1):
        dp[i]=min(dp[i-j]+abs(H[i]-H[i-j]),dp[i])
print(dp[-1])



endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")



### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline().strip()
 
def main():
    nk=list(map(int,input().split()))
    h=list(map(int,input().split()))
    n=nk[0]
    k=nk[1]
    dp=[10**9]*n
    dp[0]=0
    dp[1]=abs(h[1]-h[0])
    for i in range(2,n):
        dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i))
        # for j in range(max(0,i-k),i):
        #     dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i])
 
    print (dp[-1])
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

ans = 0

for i in range(n-1):
  si = l[i]
  for j in range(i+1, n):
    sj = l[j]
    for k in range(10):
      sj = sj.replace(si[k], '', 1)
    if sj == '':
      ans += 1

print(ans)

### FIXED CODE ###

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

d = {}

for i in range(n):
  s = l[i]
  # print(s)
  if s in d:
    d[s] += 1
  else:
    d[s] = 1

ans = 0
for x in d.values():
  ans += x*(x-1)/2
print(int(ans))
### BUGGY CODE ###

def Warshall_Floyd(edges,N):
  import copy
  d=copy.deepcopy(edges)
  for k in range(N):
    for i in range(N):
      for j in range(N):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

import sys
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
B=Warshall_Floyd(A,N)
if A!=B:
  print(-1)
  sys.exit()

ans=0
for i in range(N):
  for j in range(i):
    need=1
    for k in range(N):
      if k!=i and k!=j:
        if A[i][j]==A[i][k]+A[k][j]: need=0
    ans+=need*A[i][j]
print(ans)

### FIXED CODE ###

def Warshall_Floyd(edges,N):
  """頂点N個のグラフ上の隣接行列edges(空欄はinfとせよ)が与えられたとき, 
  2点間の最短距離距離を隣接行列で返す"""
  for k, i, j in itertools.product(range(N), range(N),range(N)):
    if edges[i][j]>edges[i][k]+edges[k][j]: return 1
  return 0
 
import sys
import itertools
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if Warshall_Floyd(A,N):
  print(-1)
  sys.exit()
 
ans=0
for i, j in itertools.product(range(N),range(N)):
  need=1
  for k in range(N):
    if k!=i and k!=j and A[i][j]==A[i][k]+A[k][j]:
      need=0
      break
  if need:ans+=A[i][j]
print(ans//2)
### BUGGY CODE ###

import bisect

n, m = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(n)]
ls.sort(key=lambda x: x[0])
la = [x[0] for x in ls]
lb = [x[1] for x in ls]

selected = []
res = 0
for i in range(1, m + 1):
    k = bisect.bisect(la, i)
    bs = lb[:k]
    index = -1
    temp = 0
    for j, b in enumerate(bs):
        if j in selected:
            continue
        if temp < b:
            index = j
            temp = b
    if index >= 0:
        selected.append(index)
        res += temp

print(res)

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(n)]
ls.sort(key=lambda x: x[0])

q = []
res = 0
index = 0
for i in range(1, m + 1):
    while index < n and ls[index][0] <= i:
        heapq.heappush(q, -ls[index][1])
        index += 1
    if len(q) > 0:
        res += -heapq.heappop(q)
print(res)
### BUGGY CODE ###

import heapq as hp
n = int(input())
p = list(map(int, input().split(' ')))
res = 0
for i in range(n):
    q = []
    for j in range(i+1):
        hp.heappush(q,p[j])
    if hp.heappop(q) >= p[i]:
        res += 1
print(res)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split(' ')))
res = 0
y = p[0]
for i in range(n):
    z = p[i]
    if y >= z:
        y = z
        res += 1
print(res)
### BUGGY CODE ###

import heapq

H, W = map(int, input().split())
board = []
visited = [[False for _ in range(W)] for _ in range(H)]
goal_dst = [[float("inf") for _ in range(W)] for _ in range(H)]
no = 0

for _ in range(H):
	board.append(list(map(str, input())))
	no += board[-1].count("#")
	
# bfsで最短路を求める
Q = [[1, 0, 0]]
juuji = [[-1, 0], [1, 0], [0, -1], [0, 1]]

while Q:
	cur = heapq.heappop(Q)
	visited[cur[1]][cur[2]] = True
	dist = cur[0]
	if goal_dst[cur[1]][cur[2]] < dist or goal_dst[-1][-1] < dist: continue
	goal_dst[cur[1]][cur[2]] = dist
	for move in juuji:
		new_y = cur[1] + move[0]
		new_x = cur[2] + move[1]
		if not (0 <= new_x and new_x <= W - 1 and 0 <= new_y and new_y <= H - 1): continue 
		if board[new_y][new_x] == "." and visited[new_y][new_x] == False:
			heapq.heappush(Q, [dist + 1, new_y, new_x])
			
if goal_dst[-1][-1] == float("inf"):
	print(-1)
else:
	print(H * W - goal_dst[-1][-1] - no)

### FIXED CODE ###

from heapq import heappush, heappop
H, W = map(int, input().split())
s = [input() for _ in range(H)]

dist = [[float('inf')] * W for _ in range(H)]
q = [(0, 0, 0)]
while q :
    cost, cx, cy = heappop(q)
    if cost >= dist[cy][cx] :
        continue
    dist[cy][cx] = cost
        
    for dx, dy in ((0, 1), (0, -1), (1, 0), (-1, 0)) :
        if 0 <= cx + dx < W and 0 <= cy + dy < H and s[cy+dy][cx+dx] != '#' :
            heappush(q, (cost+1, cx+dx, cy+dy))
            
if dist[H-1][W-1] == float('inf') :
    print(-1)
else :
    ret = 0
    for s_ in s :
        ret += s_.count('#')
    print(H * W - ret - dist[H-1][W-1] - 1)
### BUGGY CODE ###

import math
import itertools
from collections import deque
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def lIN(): return list(input())
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
ans = 0

def bfs(sx,sy,gx,gy):
    d = [[float("inf")] * w for i in range(h)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))#スタート座標の記録
    d[sx][sy] = 0#スタートからスタートへの最短距離は0

    while que:#中身がなくなるまで
        p = que.popleft()
        if p[0] == gx and p[1] == gy:#ゴールなら終わり
            break
        for m in range(4):#現在地から4方向の移動を考える
            nx = p[0] + dx[m]
            ny = p[1] + dy[m]

            if 0 <= nx < h and 0 <= ny < w:
              if maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                que.append((nx, ny))#↑格子点からでない＆壁でない＆まだ通ってない
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[gx][gy]


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

for i in range(h):#sx座標指定0~h-1
  for j in range(w):#sy座標指定0~w-1
    for k in range(h):#gx座標指定
      for l in range(w):#gy座標指定
        if maze[i][j] == '.' and maze[k][l] == '.':
          ans = max(bfs(i,j,k,l),ans)
    
print(ans)

### FIXED CODE ###

import math
import itertools
from collections import deque
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def lIN(): return list(input())
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
ans = 0

def bfs(sx,sy):
    d = [[-1] * w for i in range(h)]
    MAX = 0

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))#スタート座標の記録
    d[sx][sy] = 0#スタートからスタートへの最短距離は0

    while que:#中身がなくなるまで
        p = que.popleft()
       
        for m in range(4):#現在地から4方向の移動を考える
            nx = p[0] + dx[m]
            ny = p[1] + dy[m]

            if 0 <= nx < h and 0 <= ny < w:
              if maze[nx][ny] != "#" and d[nx][ny] == -1:
                que.append((nx, ny))#↑格子点からでない＆壁でない＆まだ通ってない
                d[nx][ny] = d[p[0]][p[1]] + 1

    for k in range(h):
      MAX = max(max(d[k]),MAX)
      
    return MAX

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

for i in range(h):#sx座標指定0~h-1
  for j in range(w):#sy座標指定0~w-1
    if maze[i][j] == '.':
      ans = max(bfs(i,j),ans)
      
print(ans)
### BUGGY CODE ###


def lcm(x,y):
    for i in range(1,10**10):
        if i%x==0:
            if i%y==0:
                return(i)
                break

A,B=map(int,input().split())
print(lcm(A,B))

### FIXED CODE ###

def gcd(x,y):
    while y!=0:
        x,y=y,x%y
    return x

def lcm(x,y):
    return x*y/gcd(x,y)

A,B=map(int,input().split())
print(int(lcm(A,B)))
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()
l = [0]*q
r = [0]*q
for i in range(q) :
  l[i], r[i] = map(int,input().split())
  c = []
  for j in range(n) :
    if s[j:j+2] == 'AC' :
      c.append(j)

  a = 0
  for k in c :
    if l[i]-1 <= k and k <= r[i]-2 :
      a += 1
  print(a)

### FIXED CODE ###

n,q = map(int,input().split())
s = input()
l = [0]*q
r = [0]*q

c = [0]
a = 0
for j in range(n) :
  if s[j:j+2] == 'AC' :
    a += 1
  c.append(a)

for i in range(q) :
  l[i], r[i] = map(int,input().split())
  print(c[r[i]-1] - c[l[i]-1])
### BUGGY CODE ###

n, x, y = map(int, input().split())
d_list = [0] * (n-1)
for i in range(1, int(n)):
    for j in range(i+1, int(n)+1):
        d = min(abs(i-j), abs(i-x)+abs(j-y)+1, abs(i-y)+abs(j-x)+1)
        d_list[d-1] += 1
print("\n".join(str(d) for d in d_list))

### FIXED CODE ###

import collections

def distances(n,x,y):
    for i in range(1, int(n)):
        for j in range(i+1, int(n)+1):
            yield min(abs(i-j), abs(i-x)+abs(j-y)+1, abs(i-y)+abs(j-x)+1)

n, x, y = map(int, input().split())

c = collections.Counter(distances(n,x,y))

for i in range(1,n):
    print(c[i])
### BUGGY CODE ###

n,m = map(int,input().split())
arr= list(map(int,input().split()))
 
while m > 0: 
    arr[arr.index(max(arr))] = max(arr)//2
    m -= 1
    
print(sum(arr))

### FIXED CODE ###

import heapq
n,m = map(int,input().split())
arr= list(map(lambda x: int(x)*(-1) ,input().split()))
heapq.heapify(arr)
for i in range(m):
    d = heapq.heappop(arr)
    heapq.heappush(arr,-( -d//2))
print(sum(arr)*-1)
### BUGGY CODE ###

#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    s = input()
    ans = 0
    for idx1, letter1 in enumerate(s):
        for idx2, letter2 in enumerate(s[idx1+1:]):
            if letter1 != letter2:
                for idx3, letter3 in enumerate(s[idx2+idx1+2:]):
                    if letter1 != letter3 and letter2 != letter3 and idx2 != idx3:
                        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from math import ceil, floor, gcd
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = input()

    c = Counter(S)
    r_c = c['R']
    g_c = c['G']
    b_c = c['B']
    ans = r_c * g_c * b_c

    for i in range(N):
        for j in range(i+1, N):
            k = 2 * j - i
            if k > N-1:
                break
            elif i < j < k and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
    print(ans)

if __name__ == '__main__':
    main()