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 <string.h>
using namespace std;

int  X,Y,dx[]={-1,0,1},dy[]={1,1,1};
long long ans;
int field[15][15];

void dfs(int x,int y){
    if(y >= Y-1){
        if(field[y][x]!=1){
            ans++;
            return;
        }
    }
    if(field[y][x] == 2){
        dfs(x,y+2);
        return ;
    }
    if(field[y][x] == 1){
        return ;
    }
    
    for(int i=0;i<3;i++){
        int nx = x+dx[i],ny = y+dy[i];
        if(nx>=0 && nx<X && ny>=0 && ny<Y && field[ny][nx] != 1 && !(i != 1 && field[ny][nx] == 2)){
            if(field[ny][nx] == 2)dfs(nx,ny+2);
            else dfs(nx,ny);
        }
    }
}

void solve(){
    for(int x=0;x<X;x++){
        if(field[0][x] == 0)dfs(x,0);
    }
}

int main() {
	while(1){
     memset(field,0,sizeof(field));
     ans=0;
     cin>>X>>Y;   
     if(!X&&!Y)break;
     
     for(int i=0;i<Y;i++){
         for(int j=0;j<X;j++){
             cin>>field[i][j];
         }
     }
     
     solve();
     
     cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int H, W;
int maps[15][15];
ll dp[15][15];

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

int main() {
	while (cin >> W >> H, H || W) {
		REP(i, H) REP(j, W) scanf("%d", &maps[i][j]);
		
		memset(dp, 0, sizeof(dp));
		REP(j, W) dp[0][j] = maps[0][j] != 1;
		
		REP(i, H - 1) REP(j, W) if (dp[i][j]) {
			
			if (maps[i][j] == 2) { // jump
				if (i + 2 < H && maps[i + 2][j] == 1) continue;
				dp[min(i + 2, H - 1)][j] += dp[i][j];
			}
			else { // normal
				REP(k, 3) {
					int yy = i + dy[k], xx = j + dx[k];
					if (!(yy >= 0 && yy < H && xx >= 0 && xx < W)) continue;
					if (maps[yy][xx] == 1 || (k != 1 && maps[yy][xx] == 2)) continue;
					dp[yy][xx] += dp[i][j];
				}
			}
		}
		
		ll ans = 0;
		REP(j, W) ans += dp[H - 1][j];
		cout << ans << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<algorithm>


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

using namespace std;

int x,y;
int c[20][20];
int dp[20][20];

void solve() {
	rep(i,20) rep(j,20) c[i][j]=1;
	rep(i,20) rep(j,20) dp[i][j]=0;

	rep(i,y) rep(j,x) cin>>c[i][j];

	rep(i,x) if(c[0][i]!=1) dp[0][i]=1;
	
	for(int i=0;i<y;i++) {
		for(int j=0;j<x;j++) {
			if(c[i][j]==2) {
				dp[i+2][j] += dp[i][j];
			}
			else if(c[i][j]==0) {
				if(c[i+1][j]!=1) {
					dp[i+1][j] += dp[i][j];
				}
				if(0<=j-1 && c[i+1][j-1]==0) {
					dp[i+1][j-1] += dp[i][j];
				}
				if(j+1 < x && c[i+1][j+1]==0) {
					dp[i+1][j+1] += dp[i][j];
				}
			}
		}
	}


	int ans=0;
	rep(i,x) if(c[y-1][i]==0) ans+=dp[y-1][i];
	rep(i,x) if(c[y-2][i]==2) ans+=dp[y][i];

	cout<<ans<<endl;

}

int main() {
	while(cin>>x>>y) {
		if(x+y==0) return 0;
		solve();
	}
	return 0;
}

C++: #include <math.h>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
	while(true) {
		int x;
		int y;
		cin >> x >> y;
		if ( x == 0 ) break;
		int a[15][15] = {0};
		for ( int i = 0; i < y ; i++ ) {
			for ( int j = 0; j < x ; j++ ) {
				cin >> a[j][i];
			}
		}
		int b[15][15] = {0};
		for ( int j = 0; j < x ; j++ ) {
			b[j][y-1] = 1;
		}
		if ( y > 1 ) {
			for ( int j = 0; j < x ; j++ ) {
				if ( a[j][y-2] == 2) b[j][y-2] = 1;
			}
		}
		for ( int i = y - 1; i > 0; i-- ) {
			for ( int j = 0; j < x ; j++ ) {
				if ( a[j][i] == 0 ) {
					for ( int k = j - 1; k < j + 2; k++ ) {
						if ( k < 0 || k >= x ) continue;
						if ( a[k][i-1] == 0 ) {
							b[k][i-1] += b[j][i];
						}
					}
					if ( i > 1 ) {
						if ( a[j][i-2] == 2 ) b[j][i-2] += b[j][i];
					}
				}else if ( a[j][i] == 2 ) {
					if ( a[j][i-1] == 0 ) b[j][i-1] += b[j][i];
					if ( i > 1 ) {
						if ( a[j][i-2] == 2 ) b[j][i-2] += b[j][i];
					}
				}
			}
		}
		int s = 0;
		for ( int j = 0; j < x ; j++ ) {
			s += b[j][0];
		}
		cout << s << endl;
	}
	return 0;
}

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

int dfs(int x,int y);
int mas[20][20];
int memo[20][20];
int X,Y;

int main(){
	while(1){
		cin >> X >> Y;
		if(X == 0 && Y == 0) break;
		for(int i=0;i<20;i++){
			for(int j=0;j<20;j++){
				memo[20][20] = -1;
			}
		}
		for(int i=0;i<Y;i++){
			for(int j=0;j<X;j++){
				cin >> mas[i][j];
			}
		}
		int ans = 0;
		for(int i=0;i<X;i++){
			if(mas[0][i] == 0){
				ans += dfs(i,0);
			}
		}
		cout << ans << endl;
	}
}

int dfs(int x,int y){
	if(memo[y][x] == -1) return memo[y][x];
	if(mas[y][x] == 1) return 0;
	if(y>=Y-1) return 1;
	if(mas[y][x] == 2) return (memo[y][x] = dfs(x,y+2));
	else{
		int cou = 0;
		for(int i=-1;i<2;i++){
			int nx = x + i;
			int ny = y + 1;
			if(nx >= 0 && nx < X && ((i == 0 && mas[ny][nx] == 2) || (mas[ny][nx] == 0))){
				cou += dfs(nx,ny);
			}
		}
		return (memo[y][x] = cou);
	}
}