Go: package main

import (
	"bufio"
	"encoding/json"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

type Color int

const (
	ColorBlack Color = iota
	ColorRed
)

var strByColor = map[Color]string{
	ColorBlack: "black",
	ColorRed:   "red",
}

func (c Color) String() string {
	return strByColor[c]
}

type Node struct {
	ID      int
	X, Y    int
	Color   Color
	NextIDs map[int]struct{}
}

func (n *Node) String() string {
	d, _ := json.Marshal(n)
	return string(d)
}

type Map struct {
	Width, Height int
	Nodes         map[int]*Node
}

func (m *Map) GetByID(id int) *Node {
	return m.Nodes[id]
}

func (m *Map) Get(x, y int) *Node {
	return m.Nodes[m.getID(x, y)]
}

func (m *Map) SetColor(x, y int, c Color) {
	m.Nodes[m.getID(x, y)].Color = c
}

func (m *Map) getID(x, y int) int {
	return x + y*m.Width
}

func (m *Map) init() {
	for x := 1; x <= m.Width; x++ {
		for y := 1; y <= m.Height; y++ {
			id := m.getID(x, y)
			m.Nodes[id] = &Node{ID: id, X: x, Y: y}
		}
	}
	for x := 1; x <= m.Width; x++ {
		for y := 1; y <= m.Height; y++ {
			nextIDs := map[int]struct{}{}
			if x > 1 {
				nextIDs[m.getID(x-1, y)] = struct{}{}
			}
			if x < m.Width {
				nextIDs[m.getID(x+1, y)] = struct{}{}
			}
			if y > 1 {
				nextIDs[m.getID(x, y-1)] = struct{}{}
			}
			if y < m.Height {
				nextIDs[m.getID(x, y+1)] = struct{}{}
			}
			m.Get(x, y).NextIDs = nextIDs
		}
	}
}

func NewMap(w, h int) *Map {
	m := &Map{Width: w, Height: h, Nodes: map[int]*Node{}}
	m.init()
	return m
}

type Searcher struct {
	Map        *Map
	queue      []*Node
	touchedIDs map[int]struct{}
	visitedIDs map[int]struct{}
}

func NewSearcher(m *Map) *Searcher {
	return &Searcher{
		Map:        m,
		queue:      []*Node{},
		touchedIDs: map[int]struct{}{},
		visitedIDs: map[int]struct{}{},
	}
}

func (s *Searcher) Search(start *Node) {
	s.enqueue(start)

	for {
		if len(s.queue) == 0 {
			break
		}
		for nextID := range s.dequeue().NextIDs {
			n := s.Map.GetByID(nextID)
			if n.Color == ColorRed || s.hasTouched(n) {
				continue
			}
			s.enqueue(n)
		}
	}
}

func (s *Searcher) VisitedNodeCount() int {
	return len(s.visitedIDs)
}

func (s *Searcher) hasTouched(n *Node) bool {
	_, ok := s.touchedIDs[n.ID]
	return ok
}

func (s *Searcher) enqueue(n *Node) {
	s.queue = append(s.queue, n)
	s.touchedIDs[n.ID] = struct{}{}
}

func (s *Searcher) dequeue() *Node {
	n := s.queue[0]
	s.queue = s.queue[1:]
	s.visitedIDs[n.ID] = struct{}{}
	return n
}

func main() {
	for sc.Scan() {
		if sc.Text() == "0 0" {
			break
		}
		chunks := strings.Split(sc.Text(), " ")
		w, _ := strconv.Atoi(chunks[0])
		h, _ := strconv.Atoi(chunks[1])

		m := NewMap(w, h)

		// Set colors
		var start *Node
		for y := 1; y <= h; y++ {
			sc.Scan()
			for i, c := range sc.Text() {
				switch c {
				case '.', '@':
					m.SetColor(i+1, y, ColorBlack)
					if c == '@' {
						start = m.Get(i+1, y)
					}
				case '#':
					m.SetColor(i+1, y, ColorRed)
				}
			}
		}

		// Search
		s := NewSearcher(m)
		s.Search(start)
		fmt.Println(s.VisitedNodeCount())
	}
}

Python: 
def get_start(tile, h, w):
	for i in range(w):
		for j in range(h):
			if tile[i][j] == '@':
				return (i, j)

dirs = [(-1, 0), (0, -1), (1, 0), (0, 1)]

while True:
	w, h = map(int, input().split())
	if (w,h) == (0,0):
		break
	tile = [list(input()) for i in range(h)]
	start = get_start(tile, w, h)
	count = 0
	q = [start]
	while q:
		(x,y) = q.pop()
		for d in dirs:
			xx = x+d[0]
			yy = y+d[1]
			if (0 <= xx and xx < h) and (0 <= yy and yy < w):
				if tile[xx][yy] == '.':
					tile[xx][yy] = '_'
					count += 1
					q.append((xx,yy))
	print(count+1)

Python: import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
Dy = (-1,0,1,0)
Dx = (0,1,0,-1)

from collections import deque,defaultdict,Counter
def solve(H,W):
    grid = [input() for _ in range(H)]
    cnt = [[0]*W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if grid[i][j] == '@':
                sy,sx = i,j
                break
    
    q = deque([(sy,sx)])
    cnt[sy][sx] = 1
    ans = 1
    while q:
        ny,nx = q.popleft()
        for dy,dx in zip(Dy,Dx):
            y = ny + dy
            x = nx + dx
            if y < 0 or y >= H:
                continue
            if x < 0 or x >= W:
                continue
            if grid[y][x] == '#':
                continue
            if cnt[y][x] == 1:
                continue
            cnt[y][x] = 1
            ans += 1
            q.append((y,x))
    print(ans)
    
def main():
    while True:
        W,H = map(int,input().split())
        if H == 0 and W == 0:
            return
        solve(H,W)
if __name__ == '__main__':
    main()

Python: def solve(w,h,tile):
    # スタート地点探索
    ok = False
    for y in range(h):
        for x in range(w):
            if tile[y][x] == "@":
                s_x = x
                s_y = y
                ok = True
                break
        if ok:
            break
    # 幅優先探索
    count = 0
    check = [[s_x, s_y]]
    check_map = [[False for j in range(w)] for i in range(h)]
    while len(check) > 0:
        x, y = check.pop(0)
        if x in range(w) and y in range(h):
            if check_map[y][x] == False:
                if tile[y][x] == "." or tile[y][x] == "@":
                    check_map[y][x] = True
                    count += 1
                    check.append([x, y-1])
                    check.append([x, y+1])
                    check.append([x+1, y])
                    check.append([x-1, y])
    return count

while True:
    try:
        w, h = map(int, input().split())
        if w == 0:
            break
        tile = [""] * h
        for i in range(h):
            tile[i] = input()

        print(solve(w,h,tile))
    except:
        break

Python: adjR = [-1, 0, 0, 1]
adjC = [0, 1, -1, 0]

def isValid(row, col, ROWS, COLS):
    return row >= 0 and row < ROWS and col >= 0 and col < COLS

def floodfill(board, row, col, ROWS, COLS):
    global adjR
    global adjC

    if not isValid(row, col, ROWS, COLS):
        return 0
    if board[row][col] == '#':
        return 0

    board[row][col] = '#'
    total = 1
    for x in range(4):
        rr = row + adjR[x]
        cc = col + adjC[x]
        total += floodfill(board, rr, cc, ROWS, COLS)
    return total
    

if __name__ == '__main__':
    while True:
        COLS, ROWS = list(map(int, input().split()))
        if ROWS == 0 and COLS == 0:
            break

        board = []
        for i in range(ROWS):
            line = input()
            board.append([ c for c in line ])
            if '@' in line:
                row = i
                col = line.find('@')
        
        print(  floodfill(board, row, col, ROWS, COLS)  )

Python: while True:
    w, h = map(int, input().split())
    if w == 0:
        break
    a = []
    for i in range(h):
        t = list(input())
        a.append(t)
        if '@' in t:
            x = i
            y = t.index('@')
    stk = [[x, y]]
    c = 1
    while True:
        if stk == []:
            break
        x, y = stk.pop()
        if y != w-1 and a[x][y+1] == '.':
            a[x][y+1] = '@'
            stk.append([x, y+1])
        if y != 0 and a[x][y-1] == '.':
            a[x][y-1] = '@'
            stk.append([x, y-1])
        if x != h-1 and a[x+1][y] == '.':
            a[x+1][y] = '@'
            stk.append([x+1, y])
        if x != 0 and a[x-1][y] == '.':
            a[x-1][y] = '@'
            stk.append([x-1, y])
    print(sum([t.count('@') for t in a]))