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 <vector>
#include <string.h>

using namespace std;

char field[18][18];
int dp[18][18][18];
int X, Y;

int DFS(int x, int y, int prex)
{
	if ((x < 0 || x >= X) || field[y][x] == '1' || (field[y][x] == '2' && x != prex))
	{
		return(0);
	}
	if (y >= Y - 1)
	{
		return(1);
	}
	if (dp[x][y][prex] != -1)
	{
		return(dp[x][y][prex]);
	}
	int ans = 0;
	if (field[y][x] == '2')
	{
		ans += DFS(x, y + 2, x);
	}
	else
	{
		ans += DFS(x - 1, y + 1, x);
		ans += DFS(x, y + 1, x);
		ans += DFS(x + 1, y + 1, x);
	}
	return(dp[x][y][prex] = ans);
}

void solve()
{
	while (cin >> X >> Y, X || Y)
	{
		for (int i = 0; i < Y; ++i)
		{
			for (int j = 0; j < X; ++j)
			{
				cin >> field[i][j];
			}
		}
		int ans = 0;
		memset(dp, -1, sizeof(dp));
		for (int i = 0; i < X; ++i)
		{
			ans += DFS(i, 0, 0);
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <stdio.h>
const int X=20;
const int Y=20;
int main(){
    int n,m,dp[X][Y],s[X][Y],k,ans;
    while(true){
        scanf("%d%d",&n,&m);
        if(n==0&&m==0)return 0;
        ans=0;
        for(int i=0;i<n+2;i++)for(int j=0;j<m;j++)dp[i][j]=s[i][j]=0;
        for(int i=0;i<m;i++)dp[0][i]=1;
        for(int i=0;i<n;i++)for(int j=0;j<m;j++){
            scanf("%d",&k);
            if(k==0){
                dp[i][j]+=s[i][j];
                if(i==n-1)continue;
                dp[i+1][j]+=dp[i][j];
                if(j!=0)s[i+1][j-1]+=dp[i][j];
                if(j!=m-1)s[i+1][j+1]+=dp[i][j];
            }
            else if(k==2){
                s[i][j]=0;
                dp[i+2][j]+=dp[i][j];
            }
            else dp[i][j]=0;
        }
        for(int i=0;i<m;i++)ans+=dp[n][i]+dp[n-1][i];
        
        printf("%d\n",ans);
    }
}

C++: #include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	int map[100][100];
	int dp[100][100];
	
	int X, Y;
	while (scanf("%d %d", &X, &Y), X + Y){
		for (int i = 0; i < 100; i++){
			dp[0][i] = 1;
			for (int j = 1; j < 100; j++){
				dp[j][i] = 0;
			}
		}
		memset(map, 0, sizeof(map));
		
		for (int i = 0; i < Y; i++){
			for (int j = 0; j < X; j++){
				scanf("%d", &map[i][j]);
			}
		}
		
		for (int i = 0; i < Y; i++){
			for (int j = 0; j < X; j++){
				if (map[i][j] == 0){
					for (int k = -1; k <= 1; k++){
						if (j + k >= 0 && j + k < X && (map[i + 1][j + k] == 0 || (k == 0 && map[i + 1][j + k] == 2)) && (i < Y - 1 || k == 0)){
							dp[i + 1][j + k] += dp[i][j];
						}
					}
				}
				else if (map[i][j] == 2){
					dp[i + 2][j] += dp[i][j];
				}
			}
		}
		
		int sum = 0;
		for (int i = 0; i < X; i++){
//			printf("%d ", dp[Y][i]);
			sum += dp[Y][i];
			sum += dp[Y + 1][i];
		}
		
		printf("%d\n", sum);
	}
	
	return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[17][16],b[17][16],w,h;
  int sm;
  while(cin>>w>>h&&w+h){
    memset(a,-1,sizeof(a));
    for(i=0;i<h;i++){
      for(j=1;j<w+1;j++){
	cin>>a[j][i];
	a[j][i]*=-1;
      }
    }
    for(i=1;i<w+1;i++)
      a[i][h]=0;
    memset(b,0,sizeof(b));
    for(i=1;i<w+1;i++){
      if(a[i][0]==0)
	b[i][0]=1;
    }
    for(i=0;i<h-1;i++){
      for(j=1;j<w+1;j++){
	if(b[j][i]){
	  if(a[j][i]){
	    if(a[j][i+2]==0||a[j][i+2]==-2)
	      b[j][i+2]+=b[j][i];
	  }else{
	    if(a[j-1][i+1]==0)
	      b[j-1][i+1]+=b[j][i];
	    if(a[j+1][i+1]==0)
	      b[j+1][i+1]+=b[j][i];
	    if(a[j][i+1]==0||a[j][i+1]==-2)
	      b[j][i+1]+=b[j][i];
	  }
	}
      }
    }
    sm=0;
    for(i=1;i<w+1;i++)
      sm+=b[i][h-1]+b[i][h];
    cout<<sm<<endl;
  }
  return 0;
}

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) dp[i+2][j] += dp[i][j];
      else{
	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 <cstring>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
const int MAX_Y = 30;
const int MAX_X = 30;
int mx, my, c[MAX_Y][MAX_X], dp[MAX_Y][MAX_X];

const int dx[3] = {-1, 0, 1};
const int dy[3] = {1, 1, 1};

int dfs(int y, int x) {  
  int res = 0;
  if (dp[y][x] >= 0) return dp[y][x];
  
  if (y == my - 1) return 1;
  
  if (c[y][x] == 2) {
    if (y+2 >= my - 1) return 1;
    res += dfs(y+2, x);
    return res;
  }
  
  rep(z,3) {
    int tx = x + dx[z], ty = y + dy[z];
    if (tx < 0 || ty < 0 || tx >= mx || ty >= my) continue;
    if (c[ty][tx] == 1) continue;
    if (c[ty][tx] == 2 && tx != x) continue;
    res += dfs(ty, tx);
  }

  return dp[y][x] = res;
}

void solve() {
  memset(dp, -1, sizeof dp);
  rep(i,my) rep(j,mx) cin>>c[i][j];

  int res = 0;
  rep(i,mx) {
    if (c[0][i] == 1) continue;
    res += dfs(0, i);
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>mx>>my, mx||my) {
    solve();
  }
  return 0;
}