import sequtils,queues proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord let h = scan() let w = scan() var isWater : array[3001,array[3001,bool]] for y in 0.. 0: let x = X.dequeue() let y = Y.dequeue() template regist(nx,ny:int) = if isWater[nx][ny] : X.enqueue(nx) Y.enqueue(ny) isWater[nx][ny] = false if x > 0: regist(x-1,y) if y > 0: regist(x,y-1) if x < w-1: regist(x+1,y) if y < h-1: regist(x,y+1) var ans = 0 for x in 0.int32..