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()
{
    while(1)
    {
        int x,y,ans=0;
        int dp[16][16]={0};
        int course[15][15]={0};
        cin>>x>>y;if(!x)return 0;
        for(int j=0;j<y;++j){
            for(int i=0;i<x;++i){
            	cin>>course[i][j];
            	if(!course[i][0])dp[i][0]=1;
            }
        }
        for(int j=0;j<y-1;++j){
            for(int i=0;i<x;++i){
                if(!course[i][j]){
                    if(course[i][j+1]!=1)dp[i][j+1]+=dp[i][j];
                    if(i){
                        if(!course[i-1][j+1])dp[i-1][j+1]+=dp[i][j];
                    }
                    if(i<x){
                        if(!course[i+1][j+1])dp[i+1][j+1]+=dp[i][j];
                    }
                }
                if(course[i][j]==2){
                    if(course[i][j]!=1)dp[i][j+2]+=dp[i][j];
                }
            }
        }
        for(int j=y-1;j<y+1;++j){
            for(int i=0;i<x;++i){
                ans+=dp[i][j];
            }
        }
        cout<<ans<<endl;
    }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int dx[] = {-1,0,1},dy[] = {1,1,1};
int main(){
	int x,y;
	while(cin >> x >> y,x,y){
		int field[20][20] = {{0}};
		int dp[20][20] = {{0}};
		for(int i = 0; i < 20; i++)for(int j = 0; j < 20; j++)field[i][j] = 1;
		for(int i = 1; i <= y; i++){
			for(int j = 1; j <= x; j++){
				cin >> field[i][j];
			}
		}
		for(int i = 1; i <= x; i++){
			if(field[1][i] == 0)dp[1][i] = 1;
		}
		int sum = 0;
		for(int i = 1; i <= y; i++){
			for(int j = 1; j <= x; j++){
				if(field[i][j] == 0){
					for(int k = 0; k < 3; k++){
						int px = j + dx[k],py = i + dy[k];
						if((field[py][px] == 2 && k == 1) || field[py][px] == 0){
							dp[py][px] += dp[i][j];
						}
					}
				}
				else if(field[i][j] == 2){
					if(i == y-1)sum += dp[i][j];
					else{
						if(field[i+2][j] != 1)dp[i+2][j] += dp[i][j];
					}
				}
			}
		}
		for(int i = 1; i <= x; i++){
			sum += dp[y][i];
		}
		printf("%d\n",sum);
	}
	return 0;
}

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

int X, Y;
int field[16][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 <iostream>
	#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
	#define rep(x,to) rep2(x,0,to)
	using namespace std;
	int main(){
		int x, y;
		while(cin >> x >> y && (x||y) ) {
			int b[15][15] = {};
			rep(i,y) {
				rep(j,x) {
					cin >> b[i][j];
				}
			}
			int ret[20][20] = {};
			rep(i,x) {
				if(b[0][i] == 0) {
					ret[0][i+1] = 1;
				}
			}
			rep2(i,1,y) {
				rep(j,x) {
					if(b[i][j] == 0) {
						ret[i][j+1] += ret[i-1][j] + ret[i-1][j+1] + ret[i-1][j+2];
						rep2(k,-1,2) {
							if(b[i-1][j+k] == 2) ret[i][j+1] -= ret[i-1][j+k+1];
						}
					} else if(b[i][j] == 2) {	
						if(b[i-1][j] == 0) ret[i][j+1] += ret[i-1][j+1];
						if(y <= i+2 || b[i+2][j] != 1) ret[i+2][j+1] += ret[i][j+1];
					}
				}
			}
			int ans = 0;
			rep2(i,y-1,y+2) {
				rep(j,x) {
					if(y <= i || b[i][j] != 2) ans += ret[i][j+1];
				}
			}
			cout << ans << endl;
		}
	}

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

using namespace std;

const int MAX = 17;
int in[MAX][MAX], X,Y,data[MAX][MAX],ans;
int dx[4] = {-1,0,1};


void init(){
  memset(data,0,sizeof(data));
  ans = 0;
}


void solve(){
  for(int i = 1; i <= Y; i++)
    for(int j = 1; j <= X; j++){
      for(int k = 0; k < 3; k++)
	if(i-1 > 0 && j + dx[k] > 0 && j+dx[k] <= X && in[i][j] != 1 && in[i-1][j+dx[k]] != 2){
	  if(in[i][j] == 2) data[i][j] = data[i-1][j];
	  else data[i][j] += data[i-1][j+dx[k]];
	}
      if(i-2 > 0 && in[i-2][j] == 2 && in[i][j] != 1) data[i][j] += data[i-2][j];
    }

  for(int j = 1; j <= X; j++){
    if(Y-1 > 0 && in[Y-1][j] == 2) ans+=data[Y-1][j];
    ans+=data[Y][j];
  }
  cout << ans << endl;
}

void print(){
  for(int i = 1; i <= Y; i++){
    for(int j = 1; j <= X; j++)
      cout << data[i][j]<< " ";
    cout << endl;
  }
}
int main(){
  while(cin >> X >> Y && X+Y){
    init();
    for(int i = 1; i <= Y; i++)
      for(int j = 1; j <= X; j++)
	cin >> in[i][j];
    
    for(int i = 1; i <= X; i++)
      if(in[1][i] == 0) data[1][i] = 1;

    solve();
    // print();
  }
  return 0;
}

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

int memo[16][16];
int x, y;

int calc(std::vector<std::vector<int> > &v, int x, int y){

	if (memo[x][y] != -1)return memo[x][y];
	int res = 0;
	if (x >= v.size() - 1)return 1;

	if (v[x][y] == 2)res += calc(v, x + 2, y);

	if (v[x][y] == 0){
		if (v[x + 1][y] == 0 || v[x + 1][y] == 2)res += calc(v, x + 1, y);

		if (y < v[x].size() - 1 && v[x + 1][y + 1] == 0)res += calc(v, x + 1, y + 1);

		if (y > 0 && v[x + 1][y - 1] == 0)res += calc(v, x + 1, y - 1);
	}

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


int main(){

	while (std::cin >> x >> y){

		if (x == 0 && y == 0)break;

		int res = 0;
		std::vector<std::vector<int> >v(y, std::vector<int>(x));

		for (int i = 0; i < 16; i++){
			for (int j = 0; j < 16; j++){
				memo[i][j] = -1;
			}
		}

		for (int i = 0; i < y; i++){
			for (int j = 0; j < x; j++){
				std::cin >> v[i][j];
			}
		}

		for (int i = 0; i < v[0].size(); i++)res += calc(v, 0, i);

		std::cout << res << std::endl;
	}
	return 0;
}