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>
using namespace std;
int main()
{
	int n, m;
	while (true){
		cin >> n >> m;
		if (n == 0 && m == 0){
			break;
		}
		int map[100][100] = { 0 };
		int dp[100][100] = { 0 };
		for (int i = 0; i < n; i++){
			for (int i2 = 0; i2 < m; i2++){
				cin >> map[i][i2];
			}
		}
		for (int i = 0; i < n; i++){
			if (map[0][i] == 0){
				dp[0][i] = 1;
			}
		}
		for (int i = 0; i < m; i++){
			for (int i2 = 0; i2 < n; i2++){
				if (map[i][i2] == 0){
					for (int i3 = -1; i3 <= 1; i3++){
						if (i2 + i3 >= 0 && i2 + i3 < n && (map[i + 1][i2 + i3] == 0 || i3 == 0 && map[i + 1][i2 + i3] == 2)&&(i<m-1||i3==0)){
							dp[i + 1][i2+i3]  += dp[i][i2];
						}
					}	
				}
				else if (map[i][i2] == 2){
							dp[i + 2][i2] += dp[i][i2];
					}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++){
			ans += dp[m][i];
			ans += dp[m+1][i];
		}
		cout << ans << endl;
	}
}

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int x, y, c[16][16], dp[30][30];
const int dx[3] = {-1, 0, 1};

void solve() {
  memset(dp, 0, sizeof dp);
  
  rep(i,y) rep(j,x) cin>>c[i][j];
  
  rep(i,x) if (c[0][i] == 0) dp[0][i] = 1;
  
  rep(i,y) rep(j,x) {
    if (c[i][j] == 0) {
      rep(z,3) {
        int ti = i + 1, tj = j + dx[z];
        if (ti < 0 || tj < 0 || ti >= y || tj >= x) continue;
        if (c[ti][tj] == 1) continue;
        if (c[ti][tj] == 2 && z != 1) continue;
        dp[ti][tj] += dp[i][j];
      }
    } else if (c[i][j] == 2) {
      dp[i+2][j] += dp[i][j];
    }
  }
  /*
  rep(i,y+1) {
    rep(j,x) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int res = 0;
  REP(i,y-1,y+1) rep(j,x) res += dp[i][j];
  cout<<res<<endl;
}

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

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int d[21][21];
ll dp[21][21];
int w, h;

bool isOutofRange(int x, int y){
	if(x < 0 || x >= 0 || y < 0) return true;
	return false;
}

int main(){
	while(cin>>w>>h && w && h){
		rep(i, h) rep(j, w) cin>>d[i][j];
		rep(i, 21) rep(j, 21) dp[i][j] = 0LL;
		for(int i = 0; i < w; i++){
			if(d[0][i] != 1) dp[0][i] = 1LL;
		}

		for(int i = 0; i < h-1; i++){
			for(int j = 0; j < w; j++){
				if(d[i][j]!=0) continue;
				for(int k = 0; k < 3; k++){
					int nx = j + dx[k], ny = i+1;
					if(isOutofRange(nx, ny)) continue;
					if(d[ny][nx] == 0) {
						dp[ny][nx] += dp[i][j];
					}
				}
				if(d[i+1][j]==2) dp[i+2][j]+=dp[i][j];
			}
		}
		ll ans = 0ll;
		rep(i, w){
			ans += dp[h-1][i];
			ans += dp[h][i];
		}
		cout<<ans<<endl;
		// rep(i, h) {
		// 	rep(j, w){
		// 		cout<<dp[i][j]<<" ";
		// 	}
		// 	cout<<endl;
		// }
	}
	
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int c[20][20];
long long int dp[20][20];
int main() {
	int X,Y;
	while(true){
		long long int ans=0;
		cin>>X>>Y;
		for(int i=1;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		if(X+Y==0) break;
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				cin>>c[i][j];
			}
		}
		for(int i=1;i<=X;i++){
			if(c[1][i]==1){
				dp[1][i]=0;
			}
			if(c[1][i]==0){
				dp[1][i]=1;
			}
		}
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(c[i][j]==0){
					for(int k=0;k<3;k++){
						if(c[i+1][j+k-1]==0) dp[i+1][j+k-1]+=dp[i][j];
						else if(k==1&&c[i+1][j+k-1]==2) dp[i+1][j+k-1]+=dp[i][j];
					}
				}
				if(c[i][j]==2){
					dp[i+2][j]+=dp[i][j];
				}
			}
		}
		for(int i=1;i<=X;i++){
			if(c[Y-1][i]==2){
				ans+=dp[Y-1][i];
			}
		}
		for(int i=1;i<=X;i++){
			ans+=dp[Y][i];
		}
		printf("%lld\n",ans );
	}
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<string>
using namespace std;
int X,Y;
int fie[20][20];
int dp[20][20];
int dx[]={-1,0,1};
int solve(int x,int y){
  if(dp[x][y]!=-1) return dp[x][y];
  if(y>=Y-1) return dp[x][y]=1;
  if(fie[x][y]==2 && fie[x][y+2]!=1){
    return dp[x][y]=solve(x,y+2);
  }
  int ret=0;
  for(int i=0;i<3;i++){
    int nx=x+dx[i];
    if(nx < 0 || nx >= X) continue;
    if(fie[nx][y+1]==1) continue;	 
    if(i==1){
      ret += solve(nx,y+1);
    }else{
      if(fie[nx][y+1]==2) continue;
      ret += solve(nx,y+1);
    }
  }
  return dp[x][y]=ret;
}
main(){
  while(1){
    cin >> X >> Y;
    if(X==0 && Y==0) break;
    memset(fie,0,sizeof(fie));
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> fie[j][i];
    memset(dp,-1,sizeof(dp));
    int res=0;
    for(int i=0;i<X;i++){
      if(fie[i][0]==0)
	res += solve(i,0);
    }
    cout << res << endl;
  }
  
}