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 map[20][20];
	int ans_map[20][20];
	int x,y;
	while(cin>>x>>y,(x!=0)&&(y!=0)){
		long int ans=0;
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				cin>>map[i][j];
				ans_map[i][j]=0;
			}
		}
		for(int i=0;i<x;i++){
			ans_map[y][i]=0;
		}
		for(int i=0;i<x;i++){
			if(map[0][i]==0){
				ans_map[0][i]=1;
			}
		}
		for(int i=0;i+1<y;i++){
			for(int j=0;j<x;j++){
				if(map[i][j]==2){
					if(i+2<y){
						ans_map[i+2][j]+=ans_map[i][j];
					}else{
						ans_map[y][j]+=ans_map[i][j];
					}
					ans_map[i][j]=0;
				}else if(map[i][j]==1){
					ans_map[i][j]=0;
				}else{ 
					for(int k=-1;k<2;k++){
						if((j+k<0)||(j+k>x-1)){
							continue;
						}else{
							if(map[i+1][j+k]==0){
								ans_map[i+1][j+k]+=ans_map[i][j];
							}else if((k==0)&&(map[i+1][j+k]==2)){
								ans_map[i+1][j+k]+=ans_map[i][j];
							}else{
							}
						}
					}
				}
			}
		}
		for(int i=0;i<x;i++){
			ans_map[y][i]+=ans_map[y-1][i];
		}
		for(int i=0;i<x;i++){
			ans+=ans_map[y][i];
		}
		cout<<ans<<endl;
		
	}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int X,Y;
	int d[16][16],p[16][16];
	int sum;
	
	while(cin>>X>>Y,X){
		sum=0;
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				cin>>d[j][i];
				if(i==1 && d[j][i]==0)p[j][i]=1;
				else p[j][i]=0;
			}
		}
		
		for(int i=1;i<=Y-1;i++){
			for(int j=1;j<=X;j++){
				if(d[j][i]==0){
					if(j>1)if(d[j-1][i+1]==0)p[j-1][i+1]+=p[j][i];
					if(j<X)if(d[j+1][i+1]==0)p[j+1][i+1]+=p[j][i];
					if(d[j][i+1]!=1)p[j][i+1]+=p[j][i];
				}
				else if(d[j][i]==2){
					if(i==Y-1 || i==Y){
						sum+=p[j][i];
					}
					else if(d[j][i+2]!=1)p[j][i+2]+=p[j][i];
				}
				
			}
			
		}
		
		
		for(int i=1;i<=X;i++)sum+=p[i][Y];
		cout<<sum<<endl;
		
	}
	
	return 0;
}

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

int X, Y;
int field[15][15];
int dp[16][15];

int main()
{
	while( std::cin >> X >> Y, X | Y )
	{
		memset( field, 0, sizeof( field ) );
		memset( dp, 0, sizeof( dp ) );

		for( int i = 0; i != Y; ++i )
			for( int j = 0; j != X; ++j )
				std::cin >> field[i][j];

		for( int i = 0; i != X; ++i )
			dp[0][i] = field[0][i] != 1;
		
		int ans = 0;
		for( int i = 1; i <= Y; ++i )
		{
			for( int j = 0; j != X; ++j )
			{
				if( i < Y && field[i][j] != 1 )
				{
					for( int k = -1; k <= 1; ++k )
					{
						if( field[i][j] == 2 && k != 0 )
							continue;
						
						if( j + k >= 0 && j + k < X && !field[i-1][j+k] )
							dp[i][j] += dp[i-1][j+k];
					}
				}

				if( i - 2 > 0 && field[i-2][j] == 2 )
					dp[i][j] += dp[i-2][j];
			
				if( i >= Y - 1 )
					ans += dp[i][j];
			}
		}

		std::cout << ans << std::endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {1,1,1,1};
const int dx[] = {-1,0,1,0};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y;
  while(cin >> x >> y&&x&&y){
    vector<vector<ll>> grid(x+1,vector<ll>(y+1,0));
    vector<vector<ll>> dp(x+3,vector<ll>(y+3,0));
    rep(i,y){
      rep(j,x){
        cin >> grid[j][i];
      }
    }
    rep(i,x){
      dp[i][0] = grid[i][0] == 0;
    }
    rep(i,y){
      rep(j,x){
        if(grid[j][i] == 0){
          rep(k,3){
            int nx = j+dx[k],ny = i+dy[k];
            if(value(j+dx[k],i+dy[k],x,y)){
              if(grid[nx][ny] == 0){
                dp[nx][ny] += dp[j][i];
              }
              else if(grid[nx][ny] == 2 && k == 1){
                dp[nx][ny] += dp[j][i];
              }
            }
          }
        }
        else if(grid[j][i] == 2){
          dp[j][i+2] += dp[j][i];
        }
      }
    }
    ll ans = 0;
    rep(i,x){
      ans += dp[i][y]+dp[i][y-1];
    }
//     cout << endl;
//     rep(j,y+1){
//       rep(i,x){
// //         ans += dp[i][y];
//         cout << dp[i][j]<< " ";
//       }
//       cout << endl;
//     }
    cout << ans << endl;
  }
  return 0;
}

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

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

int main(){
	while(1){
		cin >> X >> Y;
		if(X == 0 && Y == 0) break;
		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(mas[y][x] == 1) return 0;
	if(y>=Y-1) return 1;
	if(mas[y][x] == 2) return 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 cou;
	}
}