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

#!/usr/bin/env python3
#A
import numpy as np
import math
import re

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

c = [list(map(str,input().split()))for i in range(a)]
d = [[0 for j in range(b)]  for i in range(a)]
e = [[0 for j in range(b)]  for i in range(a)]#コピー用
#print(c,d,e)

for i in range(a):#初期のリスト設定
    for j in range(b):
        if c[i][0][j] == '#':
            d[i][j] = 1
            e[i][j] = 1
#print(c,d,e)

def check(list,a,b):#全て1であるかの判定
    for i in range(a):
        for j in range(b):
            if list[i][j] == 0:
                return False
    return True

def copy(list1,list2,a,b):
    for i in range(a):
        for j in range(b):
            if list2[i][j] == 1:
                list1[i][j] = 1


count = 0
while not check(d,a,b):
    count += 1
    for i in range(a):
        for j in range(b):
            if d[i][j] == 1:
                if i != 0:#上があるなら
                    e[i-1][j] = 1
                if j != 0:#左があるなら
                    e[i][j-1] = 1
                if i != a-1:#下があるなら
                    e[i+1][j] = 1
                if j != b-1:#右があるなら
                    e[i][j+1] = 1
    copy(d,e,a,b)
    check(d,a,b)
print(count)

### FIXED CODE ###

#!/usr/bin/env python3
#AGC33 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,w = LI()
maze = [list(input()) for _ in range(h)]
check = [[True]*w for _ in range(h)]
dx,dy = [0,1,0,-1],[1,0,-1,0]
que = deque()
for i in range(h):
    for j in range(w):
        if maze[i][j] == '#':
            check[i][j] = False
            que.append((j,i))
res = 0
while que:
    que2 = deque(que)
    que = deque()
    flg = False
    while que2:
        x,y = que2.popleft()
        for i in range(4):
            nx,ny = x + dx[i], y + dy[i]
            if 0 <= nx < w and 0 <= ny < h:
                if check[ny][nx]:
                    check[ny][nx] = False
                    que.append((nx,ny))
                    flg = True
    if flg:
        res += 1
print(res)
### BUGGY CODE ###

L,R=map(int,input().split())
ans=2020
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a=(i*j)%2019
        ans=min(ans,a)
print(ans)

### FIXED CODE ###

L,R=map(int,input().split())
ans=2020
if R-L>=2019:
    ans=0
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            a=(i*j)%2019
            ans=min(ans,a)
print(ans)
### BUGGY CODE ###

count = 0
a = []
while(1):
    try:
        count += 1
        a.append([int(i) for i in input().split(",")])
    except EOFError:
        break
dim = int(count/2)
b = [[0 for i in range(dim+1)] for j in range(dim+1)]
for i in range(dim):
    for j in range(i+1):
        b[i-j][j] = a[i][j]
for i in range(dim-1):
    for j in range(dim-i-1):
        b[dim-1-j][i+1+j] = a[i+dim][j]

dp_ = [[True if i < dim else 0 for i in range(dim+1)] if j < dim else [0 for i in range(dim+1)] for j in range(dim+1)]

def dp(i,j):
    if dp_[i][j]:
        dp_[i][j] = b[i][j] + max(dp(i+1,j),dp(i,j+1))
        return dp_[i][j]
    else:
        return dp_[i][j]

print(dp(0,0))


### FIXED CODE ###

from copy import copy
import sys
sys.setrecursionlimit(1000000)

count = 0
a = []
while(1):
    try:
        a.append([int(i) for i in input().split(",")])
        count += 1
    except EOFError:
        break
dim = int(count/2)+1
b = [[0 for i in range(dim+1)] for j in range(dim+1)]
for i in range(dim):
    for j in range(i+1):
        b[i-j][j] = a[i][j]
for i in range(dim-1):
    for j in range(dim-i-1):
        b[dim-1-j][i+1+j] = a[i+dim][j]

dp_ = [[True if i < dim else 0 for i in range(dim+1)] if j < dim else [0 for i in range(dim+1)] for j in range(dim+1)]

def dp(i,j):
    global dp_
    if dp_[i][j] is True:
        dp_[i][j] = b[i][j] + max(dp(i+1,j),dp(i,j+1))
        return dp_[i][j]
    else:
        return dp_[i][j]

print(dp(0,0))
### BUGGY CODE ###

s = list(input())
q = int(input())
ones = 0
for _ in range(q):
	inp = list(input().split())
	if inp[0] == '1':
		ones+=1	
	else:
		if ones % 2 == 1:
			s = s[::-1]
		ones = 0
		if inp[1] == '1':
			s.insert(0, inp[2])	
		else:
			s.append(inp[2])
if ones % 2 == 1:
	s = s[::-1]
print(''.join(s))

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())
s = deque(list(S))
re = False
 
for i in range(Q):
    q = list(map(str,input().split()))
    if q[0] == "1":
        re = not re
    else:
        b = int(q[1])-1
        if (re and b) or not(re or b):
            s.appendleft(q[2])
        else:
            s.append(q[2])
 
ans = ""
if re:
    while s:
    	ans += s.pop()
else:
    while s:
        ans += s.popleft()
print(ans)
### BUGGY CODE ###

import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
H, W = map(int, readline().split())
S = [0 for i in range(H)]
for i in range(H):
    S[i] = readline().decode().strip()

def bfs(start, H, W):
    visited = [False] * (H * W)
    import queue
    q = queue.Queue()
    q.put((start[0], start[1], 0))
    max_dist = 0
    while not q.empty():
        (i, j, dist) = q.get()
        max_dist = max(dist, max_dist)
        visited[i * W + j] = True 
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dx * dy != 0 or dx == dy:
                    continue
                if i + dy < 0 or i + dy >= H or j + dx < 0 or j + dx >= W:
                    continue
                if S[i + dy][j + dx] == '#':
                    continue
                if visited[(i + dy) * W + j + dx]:
                    continue
                q.put((i + dy, j + dx, dist + 1))
    return max_dist

ans = 0
for i in range(H * W):
    start = (i // W, i % W)
    if S[start[0]][start[1]] == '#':
        continue
    ans = max(ans, bfs(start, H, W))
print(ans)


### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
 
from functools import reduce
# from math import *
from fractions import *
H, W = map(int, readline().split())
S = [0 for i in range(H)]
for i in range(H):
    S[i] = readline().decode().strip()

from collections import deque
def bfs(start, H, W):
    INF = 10 ** 9
    dist = [INF] * (H * W)
    q = deque([start])
    dist[start[0] * W + start[1]] = 0
    while q:
        (i, j) = q.popleft()
        d = dist[i * W + j]
        for dy in range(-1, 2):
            for dx in range(-1, 2):
                if dx * dy != 0:
                    continue
                if dx == dy:
                    continue
                if i + dy < 0 or i + dy >= H or j + dx < 0 or j + dx >= W:
                    continue
                if S[i + dy][j + dx] == '#':
                    continue
                if dist[(i + dy) * W + j + dx] != INF:
                    continue
                dist[(i + dy) * W + j + dx] = d + 1
                q.append((i + dy, j + dx))
    return max(x for x in dist if x < INF)

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        start = (i, j)
        ans = max(ans, bfs(start, H, W))
print(ans)
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
S = 0
for i in range(N):
    S = S^a[i]

Ans = ""
for i in range(N):
    Ans = Ans + str(S^a[i]) + " "

print(Ans)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
S = 0
for i in range(N):
    S ^= a[i]

Ans = ""
for i in range(N):
    print(S^a[i])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list()
for i in range(n):
  b.append(1+a.index(1+i))
print(*b)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[[a[i],i] for i in range(n)]
b.sort()
for i in b:
  print(i[1]+1,end=" ")
### BUGGY CODE ###

s = list(input())
s.reverse()
n = len(s)
now = 0
mods = [0] * 2019
for i in range(n):
    now += (10 ** i) * int(s[i])
    now %= 2019
    mods[now] += 1
ans = mods[0]
for i in mods:
    ans += (i * (i - 1)) // 2
print(ans)


### FIXED CODE ###

if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    ten = 1
    for i in range(n):
        now += ten * int(s[i])
        now %= 2019
        ten *= 10
        ten %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)
### BUGGY CODE ###

N = int(input())
l = []
c = 0
for i in range(N):
    x = input()
    if c == 0:
        l.append(x)
        c += 1
    else:
        good = True
        for j in range(c):
            if x == l[j]:
                good = False
        if good:
            l.append(x)
            c += 1
print(c)


### FIXED CODE ###

import collections

N = int(input())
l = [input() for i in range(N)]
print(len(collections.Counter(l)))
### BUGGY CODE ###

from collections import deque
l=lambda:[int(x) for x in input().split()]
H,W=l()
CH,CW=l()
DH,DW=l()
S=[[x=='#' for x in list(input())] for _ in range(H)]
d={(CH-1,CW-1):0}
q=deque([(CH-1,CW-1,0)])
def check(h,w,c,o):
    if h < 0 or h >= H or w < 0 or w >= W:
        return False
    key=(h,w)
    if key in d:
        if d[key]<=c:
            return False
    if S[h][w]:
        return False
    if o:
        q.append((h,w,c))
        d[key]=c
    else:
        q.appendleft((h,w,c+1))
        d[key]=c+1
    return True
dh=DH-1
dw=DW-1
key=(dh,dw)
while q:
    h,w,c=q.pop()
    if h==dh and w==dw:
        print(d[key])
        exit(0)
    # walk
    check(h-1,w-0,c,True)
    check(h-0,w-1,c,True)
    check(h+1,w+0,c,True)
    check(h+0,w+1,c,True)
    # warp
    check(h-1,w-1,c,False)
    check(h+1,w+1,c,False)
    for i in [-2,+2]:
        for j in range(-2,3):
            check(h+i,w+j,c,False)
            check(h+j,w+i,c,False)

print(-1)


### FIXED CODE ###

def l():
    return [int(x) for x in input().split()]
def main():
    H,W=l()
    ch,cw=l()
    dh,dw=l()
    ch-=1
    cw-=1
    dw-=1
    dh-=1
    s=[[-2 if x=='#' else -1 for x in list(input())] for _ in range(H)]
    pad1=[-2,-2]
    pad2=[[-2]*(W+4)]*2
    s=pad2+[pad1+x+pad1 for x in s]+pad2
    move1=[(-1,0),(1,0),(0,-1),(0,1)]
    move2=list(set([(i,j) for i in range(-2,3) for j in range(-2,3)])-set(move1)-set([(0,0)]))
    q1=[(0,ch+2,cw+2)]
    q2=[]
    s[ch+2][cw+2]=0
    def mark(c,h,w):
        #if 0<=h<H and 0<=w<W and s[h][w]==-1:
        if s[h][w]==-1:
            s[h][w]=c
            q1.append((c,h,w))
    while q1:
        #print(q1)
        c,h,w=q1.pop()
        for i,j in move1:
            mark(c,h+i,w+j)
        q2.append((c+1,h,w))
        if not q1:
            for c,h,w in q2:
                for i,j in move2:
                    mark(c,h+i,w+j)
            q2=[]
    ans=s[dh+2][dw+2]
    if ans>=0:
        print(ans)
    else:
        print(-1)
main()
### BUGGY CODE ###

from itertools import product, compress

N = int(input())
Ss = input()

Fss = [list(compress(Ss[:N], sels))[::-1] for sels in product([0, 1], repeat=N)]

ans = 0
for iFs in range(2 ** N):
    Fs = Fss[iFs]
    Gs = Fss[2 ** N - 1 - iFs]

    lenF = len(Fs)
    lenG = N - lenF
    dp = [1] + [0] * lenF
    for i, s in enumerate(Ss[N:], 1):
        dp2 = [0] * (lenF + 1)
        for j in range(lenF + 1)[::-1]:
            if 0 <= j-1 and s == Fs[j-1]:
                dp2[j] += dp[j-1]
            if 0 <= i-j-1 < lenG and s == Gs[i-j-1]:
                dp2[j] += dp[j]
        dp = dp2

    ans += dp[lenF]

print(ans)


### FIXED CODE ###

from itertools import product, compress

N = int(input())
Ss = input()

Fss = [list(compress(Ss[:N], sels))[::-1] for sels in product([0, 1], repeat=N)]

ans = 0
for iFs in range(2 ** N):
    Fs = Fss[iFs]
    Gs = Fss[2 ** N - 1 - iFs]

    lenF = len(Fs)
    lenG = N - lenF
    dp = [1] + [0] * lenF
    for i, s in enumerate(Ss[N:]):
        dp2 = [0] * (lenF + 1)
        for j in range(lenF + 1):
            if dp[j] == 0: continue
            if j < lenF and s == Fs[j]:
                dp2[j+1] += dp[j]
            if 0 <= i-j < lenG and s == Gs[i-j]:
                dp2[j] += dp[j]
        dp = dp2

    ans += dp[lenF]

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

N = int(input())
A = [int(input()) for i in range(N)]
A = sorted(A)
set_A = set(A)
ans = 0

for a in set_A:
    if A.count(a) % 2 == 1:
        ans += 1

print(ans)

### FIXED CODE ###

# 要素であるかの確認は配列じゃなくsetを使う
# setはハッシュで実装されているため

N = int(input())
s = set()
 
for i in range(N):
    a=int(input())
    if a in s:
        s.remove(a)
    else:
        s.add(a)
 
print(len(s))
### BUGGY CODE ###

import math
import bisect
import heapq
from fractions import gcd #math in python 3.7
from collections import deque

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

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


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


def scm(a):
    for i in range(n-1):
        if format(a[i], 'b')[::-1].find('1') != format(a[i+1], 'b')[::-1].find('1'):
            return 0
        
    l = 1
    for i in range(n):
        a[i] = a[i] // 2
        l = lcm(l,a[i])

    count = 0
    lc = l
    if not 1 <= l <= m:
        return 0

    for i in range(l, m+1, 2*lc):
        count += 1

    return count

print(scm(a))



### FIXED CODE ###

from fractions import gcd
n, m = map(int, input().split())

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

ans = -1
b = [0] * n
for i in range(n):
    if a[i] % 2 != 0:
        ans = 0
        break

    else:
        b[i] = a[i] // 2


    if i == 0:
        num = format(a[i], 'b')[::-1].find('1')

    else:
        if format(a[i], 'b')[::-1].find('1') != num:
            ans = 0
            break
        else:
            num = format(a[i], 'b')[::-1].find('1')


if ans != 0:
    g = b[0]
    for i in range(1,n):

        g = (g*b[i]) // gcd(b[i],g)

    if g > m: ans = 0
    else:
        ans = (1 + (m-g)//(2*g))

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

from collections import deque
from sys import stdin


def main():
    height, width = map(int, stdin.readline().split())
    q = deque([])
    grid = []
    for i in range(height):
        now = list(stdin.readline())
        for j in range(width):
            if now[j] == "#":
                q.append([i, j, 0])
        grid.append(now)
    answer = 0

    def is_next_cell_white(ny, nx):
        return 0 <= ny < height and 0 <= nx < width and grid[ny][nx] == "."

    while q:
        y, x, time = q.popleft()
        answer = max(answer, time)
        if is_next_cell_white(y - 1, x):
            grid[y - 1][x] = "#"
            q.append([y - 1, x, time + 1])

        if is_next_cell_white(y + 1, x):
            grid[y + 1][x] = "#"
            q.append([y + 1, x, time + 1])

        if is_next_cell_white(y, x - 1):
            grid[y][x - 1] = "#"
            q.append([y, x - 1, time + 1])

        if is_next_cell_white(y, x + 1):
            grid[y][x + 1] = "#"
            q.append([y, x + 1, time + 1])

    print(answer)


if __name__ == '__main__':
    main()



### FIXED CODE ###

from collections import deque
from sys import stdin


def main():
    height, width = map(int, stdin.readline().split())
    q = deque([])
    grid = [stdin.readline() for _ in range(height)]
    distance = [[-1 for _ in range(width)] for _ in range(height)]
    for i in range(height):
        for j in range(width):
            if grid[i][j] == "#":
                q.append((i, j))
                distance[i][j] = 0
    answer = 0
    delta = ((0, 1), (1, 0), (0, -1), (-1, 0))
    while q:
        y, x = q.popleft()
        answer = distance[y][x]
        for dy, dx in delta:
            new_y = y + dy
            new_x = x + dx
            if 0 <= new_y < height and 0 <= new_x < width and distance[new_y][new_x] < 0:
                distance[new_y][new_x] = answer + 1
                q.append((new_y, new_x))
    print(answer)


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


N, W = [int(x) for x in input().split()]
items = [tuple(map(int, input().split())) for _ in range(N)]

#bottomup
memo = [10**10]*(10**5+1)
memo[0] = 0

for weight, value in items:
    for i in reversed(range(len(memo)-value)):
            memo[i+value] = min(memo[i+value],memo[i] + weight)

ans = 0
for i in range(len(memo)):
    if memo[i] != 10**10 and memo[i] <= W:
        ans = i

print(ans)


### FIXED CODE ###


N, W = [int(x) for x in input().split()]
items = [tuple(map(int, input().split())) for _ in range(N)]

#bottomup
memo = [10**10]*(10**5+1)
memo[0] = 0

for weight, value in items:
    for i in reversed(range(len(memo)-value)):
            memo[i+value] = min(memo[i+value],memo[i] + weight)

ans = 0
for i in range(len(memo)):
    if memo[i] != 10**10 and memo[i] <= W:
        ans = i

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

import itertools

N, M, K = map(int, input().split())
A = list(map(int, input().split()))  # (N,)
B = list(map(int, input().split()))  # (M,)

book_num = 0

A_accum = [0] + list(itertools.accumulate(A))
B_accum = [0] + list(itertools.accumulate(B))
for n in range(N + 1):
    for m in range(M + 1):
        if K < A_accum[n] + B_accum[m]:
            break
        if book_num < n + m:
            book_num = n + m

print(book_num)


### FIXED CODE ###

import itertools

N, M, K = map(int, input().split())
A = list(map(int, input().split()))  # (N,)
B = list(map(int, input().split()))  # (M,)


A_accum = [0] + list(itertools.accumulate(A))
B_accum = [0] + list(itertools.accumulate(B))

book_num = 0

b_best = M
for n in range(N + 1):
    for m in range(b_best, -1, -1):
        if A_accum[n] + B_accum[m] <= K:
            b_best = m
            if book_num < n + m:
                book_num = n + m
            break

print(book_num)
### BUGGY CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[[0 for i in range(N)] for j in range(N)] 
for i in range(M):
  A,B=map(int,input().split())
  L[A-1][B-1]+=1
  L[B-1][A-1]+=1
count=[0 for i in range(N)]

for i in range(N):
  for j in range(N):
    if L[i][j]!=0 and H[i]>H[j]:
      count[i]+=1
c=0
for i in range(N):
  if count[i]==(N-L[i].count(0)):
    c+=1
print(c)

### FIXED CODE ###

N,M=map(int,input().split())
H=list(map(int,input().split()))
L=[0 for i in range(N)] 
P=[0 for i in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  P[A-1]+=1
  P[B-1]+=1
  if H[A-1]>H[B-1]:
    L[A-1]+=1
  if H[B-1]>H[A-1]:  
    L[B-1]+=1

count=0 
for i in range(N):
  if P[i]==L[i]:
    count+=1
print(count)
### BUGGY CODE ###

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

i = k-1
bef = 0
hyouka = 1
while i < len(listA):
    if i == k-1:
        p = 0
        while p < k:
            hyouka*=listA[p]
            p+=1
    else:
        newHyouka = hyouka*listA[i]//listA[i-k]
        if newHyouka > hyouka:
            print("Yes")
        else:
            print("No")
        hyouka = newHyouka
    i+=1

### FIXED CODE ###

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

i = k
while i < len(listA):
    if listA[i] > listA[i-k]:
        print("Yes")
    else:
        print("No")
    i+=1
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
count = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] < L[j]+L[k] and L[j] < L[k]+L[i] and L[k] < L[i]+L[j]:
                count += 1

print(count)

### FIXED CODE ###

import bisect
N = int(input())
L = list(map(int, input().split()))
count = 0

L.sort()

for i in range(N-2):
    for j in range(i+1,N-1):
        k = bisect.bisect_left(L,L[i]+L[j])
        count += k-j-1

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

# 毎回ソートしても別にいいんじゃないの
n, m = map(int, input().split())
arr = list(map(int, input().split()))

while m > 0:
    arr = list(sorted(arr))[::-1]
    arr[0] = arr[0] // 2
    m -= 1

print(sum(arr))


### FIXED CODE ###

# 毎回ソートしても別にいいんじゃないの -> ダメでした
# 毎回最大のものがほしいならheapq使うか
import heapq

n, m = map(int, input().split())
# heapは最小のものを取り出すので予め-1をかけて大小を見かけ上逆転しておく
arr = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(arr)
for _ in range(m):
    a = heapq.heappop(arr)
    # 負数にしたときの誤差がめんどくさい
    a *= -1
    a //= 2
    heapq.heappush(arr, a * -1)
print(sum(arr) * -1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
N = int(input())
arr = list(map(int, input().split()))
tmp = [0]*(max(arr)+1)
for i in arr:
    tmp[i] += 1
ans = 0
for i in range(N):
    flg = True
    for k in make_divisors(arr[i]):
        if k == arr[i]:
            if tmp[k] >= 2:
                flg = False
                break
        elif tmp[k] != 0:
            flg = False
            break
    if flg:
        ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
arr = list(map(int, input().split()))
arr.sort()
ma = max(arr)
check = [True]*(ma+1)
cnt = [0]*(ma+1)
for i in arr:
    cnt[i] += 1
ans = 0
for i in arr:
    if not check[i]:
        continue
    for k in range(i,ma+1,i):
        check[k] = False
    if cnt[i] <= 1:
        ans += 1
print(ans)
### BUGGY CODE ###

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

if (b-a)%2==0:
    print((b-a)//2)
else:
    if a < math.floor(n/2):
        i = 0
        while True:
            a -= i
            b -= i
            if a <= 1:
                a = 1
            if a == b:
                print(i)
                break
            i += 1
    else:
        i = 0
        while True:
            a += i
            b += i
            if b >= n:
                b = n
            if a == b:
                print(i)
                break
            i += 1
    
#min  median max

### FIXED CODE ###

n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))
### BUGGY CODE ###

import sys
MOD=10**9+7
def solve(N:int,K:int,A:list)->int:
    #dp[i][j]:=i人目までの子供にj個の飴を配る場合の数
    dp=[[0]*(K+1) for i in range(N+1)]
    for i in range(N):dp[i][0]=1
    sum=[0]*(K+2)
    for i in range(N):
        for j in range(K+1):#累積和
            sum[j+1]=(sum[j]+dp[i][j])%MOD
        for j in range(K+1):
            dp[i+1][j]=(sum[j+1]-sum[max(0,j-A[i])]+MOD)%MOD
            dp[i+1][j]%=MOD
    return dp[N][K]
def main(lines):
    N,K=map(int,lines[0].split())
    A=list(map(int,lines[1].split()))
    print(solve(N,K,A))
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)


### FIXED CODE ###

import sys
MOD=10**9+7
def solve(N:int,K:int,A:list)->int:
    #dp[i][j]:=i人目までの子供にj個の飴を配る場合の数
    dp=[[0]*(K+1) for i in range(N+1)]
    for i in range(N):dp[i][0]=1
    sum=[0]*(K+2)
    for i in range(N):
        for j in range(K+1):#累積和
            sum[j+1]=(sum[j]+dp[i][j])%MOD
        for j in range(K+1):
            dp[i+1][j]=(sum[j+1]-sum[max(0,j-A[i])]+MOD)%MOD
            dp[i+1][j]%=MOD
    return dp[N][K]
def main(lines):
    N,K=map(int,lines[0].split())
    A=list(map(int,lines[1].split()))
    print(solve(N,K,A))
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)