Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		X, _ := strconv.Atoi(buf[0])
		Y, _ := strconv.Atoi(buf[1])
		if X == 0 && Y == 0 {
			break
		}
		tbl := make([][]int, Y+2)
		field := make([][]int, Y+2)
		for i := range field {
			field[i] = make([]int, X+2)
			tbl[i] = make([]int, X+2)
			for j := range field[i] {
				field[i][j] = 2
				tbl[i][j] = 0
			}
		}
		buf_ := make([][]string, Y)
		for i := range buf_ {
			scanner.Scan()
			buf_[i] = strings.Split(scanner.Text(), " ")
		}
		for i := 1; i <= Y; i++ {
			for j := 1; j <= X; j++ {
				field[i][j], _ = strconv.Atoi(buf_[i-1][j-1])
				switch field[i][j] {
				case 0:
					if i == 1 {
						tbl[i][j] = 1 // スタートy=1
					} else {
						if field[i-1][j-1] != 2 {
							tbl[i][j] += tbl[i-1][j-1] // 左上からやってくる
						}
						if field[i-1][j] != 2 {
							tbl[i][j] += tbl[i-1][j] // 真上からやってくる
						}
						if field[i-1][j+1] != 2 {
							tbl[i][j] += tbl[i-1][j+1] // 右上からやってくる
						}
						if field[i-2][j] == 2 {
							tbl[i][j] += tbl[i-2][j] // ジャンプしてくる
						}
					}
				case 1:
					tbl[i][j] = 0 // 障害物あり
				case 2:
					if field[i-1][j] != 2 {
						tbl[i][j] += tbl[i-1][j] // 真上からくる
					}
					if field[i-2][j] == 2 {
						tbl[i][j] += tbl[i-2][j] // ジャンプ台からジャンプしてくる
					}
				}
			}
		}
		sum := 0
		for i := 1; i <= X; i++ {
			sum += tbl[Y][i] // とびこさないでゴール
			if field[Y-1][i] == 2 {
				sum += tbl[Y-1][i] // 飛び越してゴール
			}
		}
		fmt.Println(sum)
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int X, Y;
  while(scanf("%d%d", &X, &Y) && X+Y){
    int board[15][15], dp[17][15] = {};
    rep(i, Y) rep(j, X) if(scanf("%d", &board[i][j])  && board[i][j] == 1) dp[i][j] = -1;

    rep(i, X) if(!dp[0][i]) dp[0][i] = 1;

    rep(i, Y-1) rep(j, X){
      if(board[i][j] == 1) continue;
      else if(board[i][j] == 2 && board[i+2][j] != 1) dp[i+2][j] += dp[i][j];
      else if(board[i][j] == 0){
	for(int k = -1; k < 2; k++){
	  if(j+k < 0 || j+k >= X) continue;
	  if(dp[i+1][j+k] == -1) continue;
	  if(board[i+1][j+k] == 2){
	    if(k != 0) continue;
	    dp[i+1][j+k] += dp[i][j];
	  }else{
	    dp[i+1][j+k] += dp[i][j];
	  }
	}
      }
    }

    ll res = 0;
    REP(i, Y-1, Y+2)
      rep(j, X)
      if(dp[i][j] != -1)
	res += dp[i][j];
  
    /*    rep(i, 17){ 
      rep(j, 15) printf("%d ", dp[i][j]);
      puts("");
      }*/

    printf("%lld\n", res);
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;

int maps[20][20];
int course[20][20];
int X, Y;

void out();
int way(int y, int x){
  else if(course[y][x] > 0) return course[y][x];
  else if(maps[y][x] == 1) return 0;
  else if(y >= Y) return 1;
  else if(maps[y][x] == 2 && maps[y + 2][x] != 1) return course[y][x] = way(y + 2, x);
  else{
    int SUM = 0;
    for(int i = 0; i < 3; i++){
      int ny = y + 1;
      int nx = x - 1 + i;
      if(maps[ny][nx] != 1 && 1 <= nx && nx <= X){
	int flug = 1;
	if(i != 1 && maps[ny][nx] == 2) flug = 0;
	if(flug) SUM += way(ny, nx);
      }
    }
    return course[y][x] = SUM;
  }
} 

int main(){
  while(1){
    cin >> X >> Y;
    if(X == 0 && Y == 0) break;
    for(int i = 1; i <= Y; i++){
      for(int j = 1; j <= X; j++){
	cin >> maps[i][j];
	course[i][j] = 0;
      }
    }
    int cnt = 0;
    for(int i = 1; i <= X; i++){
      if(maps[0][i] != 1) cnt += way(1, i);
    }
    cout << cnt << endl;
  }
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
int saiki(int x,int y){
  if(y >= h-1) return 1;
  for(int i=-1;i<=1;i++) {
    int nx = x+i, ny = y+1;
    if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;
    if(nx <0|| nx >= w ||mp[ny][nx] != 0) continue;
    if(memo[ny][nx]==0) memo[y][x]+=saiki(nx,ny);
    else memo[y][x] += memo[ny][nx];
  }
  if(memo[y][x]==0) mp[y][x] = 1;
  return memo[y][x];
}
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i=0;i<=19;i++)
      for(int j=0;j<=19;j++)memo[i][j] = mp[i][j] = 0;
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> mp[i][j];
   
    int cnt = 0;  
    for(int i=0;i<w;i++)
      if(mp[0][i] !=1)cnt+=saiki(i,0);
    cout << cnt <<endl;
  }
  return 0;
}

C++: #include<cstdio>

using namespace std;

int run[15][15],w,h;
int memo[15][15];

int ski(int x,int y,bool s)
{
	if(y>=h)			return 1;
	if(memo[y][x]!=-1)	return memo[y][x];
	if(run[y][x]==1)	return memo[y][x]=0;
	if(run[y][x]==2)	return s?ski(x,y+2,true):0;

	if(y==h-1)	return memo[y][x]=1;

	int cnt=0;
	for(int dx=-1;dx<=1;dx++){
		int xx=x+dx;
		if(0<=xx && xx<w)	cnt+=ski(xx,y+1,!dx);
	}
	return memo[y][x]=cnt;
}

int main()
{
	for(;scanf("%d%d",&w,&h),w;){
		for(int y=0;y<h;y++)
			for(int x=0;x<w;x++)
				scanf("%d",run[y]+x),memo[y][x]=-1;

		int cnt=0;
		for(int x=0;x<w;x++)	cnt+=ski(x,0,true);
		printf("%d\n",cnt);
	}

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int field[20][20];
int dp[20][20];

int n, m;

bool isIn(int x, int y){
    return 0 <= x && x < n && 0 <= y && y < m;
}

int main(){
    while(cin >> n >> m, n+m){
        for(int i=0; i < n; i++) for(int j=0; j< m; j++){cin >> field[i][j];}
        for(int i=0; i< 20; i++) for(int j=0; j< 20; j++) dp[i][j] = 0;
        for(int i=0; i < m; i++) dp[0][i] = 1;
        for(int i=0; i < n-1; i++){
            for(int j=0; j < m; j++){
                if(field[i][j] == 0){
                    for(int k=-1; k <= 1; k++){
                        if(isIn(i+1, j+k) && !(k != 0 && field[i+1][j+k] == 2)){
                            dp[i+1][j+k] += dp[i][j];
                        }
                    }
                }
                else if(field[i][j] == 1) dp[i][j] = 0;
                else if(field[i][j] == 2) dp[i+2][j] += dp[i][j];
            }
        }
        for(int i=0; i< m; i++) if(field[n-1][i] != 1)dp[n][i] += dp[n-1][i];
        int count = 0;
        for(int i=0; i< m; i++) count += dp[n][i];
        cout << count << endl;
    }
}

C++: #include<iostream>
#include<stack>

int field[15][15];
int w,h;
int dfs(int x0,int y0);

int main()
{
	while(1)
	{
		std::cin>>w>>h;
		if(w==0&&h==0)break;
		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				std::cin>>field[x][y];
			}
		}
		
		int count=0;
		for(int x=0;x<w;x++)
		{
			if(field[x][0]==0)
			{
				count+=dfs(x,0);
			}
		}
		std::cout<<count<<std::endl;
	}
	return 0;
}

int dfs(int x0,int y0)
{
	std::stack<std::pair<int,int> > stk;
	int count=0;
	stk.push(std::pair<int,int>(x0,y0));
	while(!stk.empty())
	{
		int x=stk.top().first,y=stk.top().second;
		
		stk.pop();
		
		if(y>=h-1)
		{
			count++;
		}
		else
		{
			if(field[x][y]==2)
			{
				stk.push(std::pair<int,int>(x,y+2));
			}
			else if(field[x][y]==0)
			{
				if(x>0&&field[x-1][y+1]==0){stk.push(std::pair<int,int>(x-1,y+1));}
				if(x<w-1&&field[x+1][y+1]==0){stk.push(std::pair<int,int>(x+1,y+1));}
				if(field[x][y+1]!=1){stk.push(std::pair<int,int>(x,y+1));}
			}
		}
	}
	return count;
}