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 <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++ ) {
			if ( a[j][y-1] != 1) 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 X, Y;
int status[17][18];	//status[x][y]
int i, j;
int count;

void check(int x, int y);

int main(){

	while(1){

		count = 0;

		cin >> X >> Y;

		if(X == 0 && Y == 0){break;}

		else{

			//フィールドの入力
			//i行目について( 1 <= i <= Y+2 )
			for(i = 1; i <= Y+2; i++){
				//j文字目について( 0 <= j <= X+1)
				for(j = 0; j <= X+1; j++){

					//Y+1, Y+2列目に移動できるようにする。
					if(i > Y){
						status[j][i] = 0;
					}
					//両サイドには障害物を敷き詰める。
					else if(j == 0 || j == X+1){
						status[j][i] = 1;
					}
					else{
						cin >> status[j][i];
					}
				}
			}

			for(i = 1; i <= X; i++){
				check(i, 1);
			}

			cout << count << endl;
		}
	}

	return 0;
}


void check(int x, int y){

	if(status[x][y] == 0 && y >= Y){
		count++;
	}
	else if(status[x][y] == 1){}
	else if(status[x][y] == 2){
		check(x, y+2);
	}
	else{
		if(status[x-1][y+1] == 0){
			check(x-1, y+1);
		}
		if(status[x][y+1] == 0 || status[x][y+1] == 2){
			check(x, y+1);
		}
		if(status[x+1][y+1] == 0){
			check(x+1, y+1);
		}
	}
}

C++: #include<iostream>
using namespace std;
int dp[20][20][2];
int x[20][20];
int H, W;
void A(int a, int b, int c, int d) {
	if (x[a][b] == 2) {
		if (d != 0) { return; }
		if (c == 1) { return; }
		if (c == 0) {
			dp[a + 2][b][0] += dp[a][b][c];
			return;
		}
	}
	if (x[a + 1][b + d] == 1) { return; }
	if (x[a + 1][b + d] == 2 && d != 0) { return; }
	if (x[a][b] == 0) {
		if (d == 0) {
			dp[a + 1][b + d][0] += dp[a][b][c];
		}
		else {
			dp[a + 1][b + d][1] += dp[a][b][c];
		}
	}
}
int main() {
	while (true) {
		cin >> W >> H;
		if (H == 0 && W == 0) { break; }
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j];
			}
		}
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 20; j++) {
				dp[i][j][0] = 0;
				dp[i][j][1] = 0;
			}
		}
		for (int i = 1; i <= W; i++) {
			if (x[1][i] == 0) {
				dp[1][i][0] = 1;
			}
		}
		for (int i = 1; i <= H - 1; i++) {
			for (int j = 1; j <= W; j++) {
				A(i, j, 0, -1);
				A(i, j, 0, 0);
				A(i, j, 0, 1);
				A(i, j, 1, -1);
				A(i, j, 1, 0);
				A(i, j, 1, 1);
			}
		}
		int sum = 0;
		for (int j = H; j < 20; j++) {
			for (int i = 1; i <= W; i++) {
				sum += dp[j][i][0] + dp[j][i][1];
			}
		}
		cout << sum << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int x,y,a[17][17],s,i,j;
void dfs(int y1,int x1){
  if(a[y1][x1]==1)return;
  if(x1<1||x1>x)return;
  if(y1>=y){s++;return;}
  if(a[y1][x1]==2)dfs(y1+2,x1);
  else {if(a[y1+1][x1]!=1)dfs(y1+1,x1);
  if(a[y1+1][x1+1]==0)dfs(y1+1,x1+1);
  if(a[y1+1][x1-1]==0)dfs(y1+1,x1-1);}
  return;
}
int main(){
  while(cin>>x>>y,x){
    for(s=0,i=0;i<17;i++)for(j=0;j<17;j++)a[i][j]=0;    
    for(s=0,i=1;i<=y;i++)for(j=1;j<=x;j++)cin>>a[i][j];
    for(i=1;i<=x;i++){if(a[1][i]==0)dfs(1,i);}
    cout<<s<<endl;
  }
}

C++: #include<iostream>
#include<utility>
#include<queue>
#include<functional>
#include<cstring>
#include<vector>
#include<climits>
#include<map>
using namespace std;
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
typedef pair<int,int> pii;
typedef vector<int> vi;
#define int long long

main()
{
	while(1)
	{
		int a[20][20];
		int dp[20][20]={};
		int x,y;
		
		cin>>x>>y;if(!x)break;
		FOR(i,20)FOR(j,20)a[i][j]=1;
		FORI(i,1,y+1)
		{
			FORI(j,1,x+1)
			{
				cin>>a[i][j];
			}
		}
		FORI(i,1,x+1)
		{
			dp[1][i]=1;
			a[y+1][i]=0;
		}
		FORI(i,1,y)
		{
			FORI(j,1,x+1)
			{
				if(a[i][j]==2&&a[i+2][j]!=1)
				{
					dp[i+2][j]+=dp[i][j];
				}
				else if(a[i][j]==1)
				{
					dp[i][j]=0;
				}
				else
				{
					for(int k=-1;k<=1;k++)
					{
						if(a[i+1][j+k]==0)
						{
							dp[i+1][j+k]+=dp[i][j];
						}
					}
					if(a[i+1][j]==2)dp[i+1][j]+=dp[i][j];
				}
			}
		}
		
		int ans=0;
		FORI(i,1,x+1)ans+=dp[y][i]+dp[y+1][i];
		cout<<ans<<endl;
		
	}
}

C++: #include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int x,y,ans=0;
        int dp[17][17]={0};
        int course[17][17]={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+2]!=1)dp[i][j+2]+=dp[i][j];
                }
            }
        }
        for(int j=y-1;j<y+2;++j){
            for(int i=0;i<x;++i){
                ans+=dp[i][j];
            }
        }
        cout<<ans<<endl;
    }
}