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 <vector>
#include <string>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
	int x,y;
	while(cin >> x >> y, x|y){
		vvi field(y,vi(x));
		REP(i,y){
			REP(j,x){
				cin >> field[i][j];
			}
		}
		vvi dp(y,vi(x,0));
		REP(i,y){
			REP(j,x){
				if(i==0&&field[i][j]==0){
					dp[i][j]=1;
				}
				if(i<y-1&&field[i][j]==0){
					if(j>0&&field[i+1][j-1]==0){
						dp[i+1][j-1]+=dp[i][j];
					}
					if(j<x-1&&field[i+1][j+1]==0){
						dp[i+1][j+1]+=dp[i][j];
					}
					if(field[i+1][j]!=1){
						dp[i+1][j]+=dp[i][j];
					}
				}
				if(i<y-2&&field[i][j]==2){
					if(field[i+2][j]!=1){
						dp[i+2][j]+=dp[i][j];
					}
				}
			}
		}
		int result=0;
		REP(i,x){
			result+=dp[y-1][i];
			if(field[y-2][i]==2){
				result+=dp[y-2][i];
			}
		}
		cout << result << endl;
	}
}

C++: #include<stdio.h>

int main(void){
	int X,Y;
	
	while(scanf("%d%d", &X, &Y) && X && Y){
		int masu[32][32]={0};
		int co[32][32]={0};
		int ans = 0;
		for(int i = 0; i < Y; i++){
			for(int j = 0; j < X; j++){
				scanf("%d", &masu[i][j]);
			}
		}
		
		for(int i = 0; i < X; i++){
			if(!masu[0][i])co[0][i] = 1;
		}
		
		for(int i = 0; i < Y-1; i++){
			for(int j = 0; j < X; j++){
				if(masu[i][j] == 0){
					if(masu[i+1][j] != 1)co[i+1][j] += co[i][j];
					if(masu[i+1][j+1] == 0)co[i+1][j+1] += co[i][j];
					if(masu[i+1][j-1] == 0 && j-1 > -1)co[i+1][j-1] += co[i][j];
				}else if(masu[i][j] != 1){
					co[i+2][j] += co[i][j];
				}
			}
		}
		
		for(int i = 0; i < X; i++){
			ans += co[Y-1][i];
		}
		for(int i = 0; i < X; i++){
			ans += co[Y][i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen

using namespace std;
// 0 :Ú®Â\Å é
// 1 :áQ¨ª é
// 2 :Wväª é
int field[15+1][15];
int memo[15+1][15];
int main()
{
	const int dir[][2] = {  { 1, -1 }, { 1, 0 }, { 1, 1 } };
//	cut here before submit 
//	freopen ("testcase.new_plan", "r", stdin );
	int X, Y;

	while (cin >> X >> Y && X && Y ){
		memset (field, 0, sizeof (field ) );
		memset (memo, 0, sizeof (memo) );

		for (int i = 0; i < Y; ++i ){
			for (int j = 0; j < X; ++j ){
				cin >> field[i][j];
			} // end for
		} // end for
		
		for (int j = 0; j < X; ++j ){ 
			field[Y][j] = 0;
			memo[Y][j] = 1;
		} // end for

		for (int j = 0; j < X; ++j ){
			if (field[Y-1][j] == 0 || field[Y-1][j] == 2 ){
				memo[Y-1][j] = 1;
			} // end if
		} // end for
		
		for (int i = Y - 2; i >= 0 ; --i ){
			for (int j = 0; j < X; ++j ){
				if (field[i][j] == 1 ){
					continue;
				}else
				if (field[i][j] == 0 ){
					for (int k = 0; k < 3; ++k ){
						int ny = i + dir[k][0];
						int nx = j + dir[k][1];
						if (nx < 0 || nx >= X ){
							continue;
						} // end if
						if (field[ny][nx] == 1 ){
							continue;
						} // end if
						if ((k == 0 || k == 2) && field[ny][nx] == 2 ){
							continue;
						} // end if
						if (field[ny][nx] == 2 && field[ny+2][nx] == 1 ){
							continue;
						} // end if
						memo[i][j] += memo[ny][nx];
					} // end for
				}else{ // if (field[i][j] == 2 )
					if (field[i+2][j] != 1 ){
						memo[i][j] += memo[i+2][j];
					} // end for
				} // end if
			} // end for
		} // end for
		
		int res = 0;
		for (int j = 0; j < X; ++j ){
			res += memo[0][j];
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;


int main() {
	while(1) {
		int x, y;
		cin >> y >> x;
		if(x==0 && y==0) break;
		int field[x][y];
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				cin >> field[i][j];
			}
		}
		int dp[x+1][y];
		for(int i=0; i<x+1; i++) {
			for(int j=0; j<y; j++) {
				dp[i][j] = 0;
			}
		}
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				if(i==0 && field[i][j] == 0) dp[i][j] = 1;
				else {
					if(field[i][j] == 0) {
						if(0<j && field[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
						if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
						if(j<y-1 && field[i-1][j+1] == 0) dp[i][j] += dp[i-1][j+1];
					}
					if(field[i][j] == 2) {
						dp[i][j] += dp[i-1][j];
						dp[i+2][j] += dp[i][j];
					}
				}
			}
		}
		for(int i=0; i<y; i++) dp[x][i] += dp[x-1][i];

		int sum=0;
		for(int i=0; i<y; i++) sum += dp[x][i];
		cout << sum << endl;

		//cout << endl;
		//for(int i=0; i<x+1; i++) {
			//for(int j=0; j<y; j++) {
				//cout << dp[i][j] << ' ';
			//}
			//cout << endl;
		//}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
int X,Y;
int fld[20][20];
long long dp[20][20];
int main() {
	while(cin>>X>>Y&&X&&Y){
		for(int i=0;i<Y;i++)for(int j=0;j<X;j++)cin>>fld[j][i];
		long long ans=0;
		for(int i=0;i<20;i++)for(int j=0;j<20;j++)dp[i][j]=0;
		for(int i=0;i<X;i++)if(fld[i][Y-1]!=1)dp[i][Y-1]=1;
		for(int y=Y-2;y>=0;y--){
			for(int x=0;x<X;x++){
				if(fld[x][y]==0){
					for(int k=-1;k<=1;k++){
						int nx=x+k;
						if(nx<0||nx>=X)continue;
						if(nx==x&&fld[nx][y+1]!=1)dp[x][y]+=dp[nx][y+1];
						else if(fld[nx][y+1]==0)dp[x][y]+=dp[nx][y+1];
					}
				}else if(fld[x][y]==2){
					if(y+2>=Y)dp[x][y]=1;
					else dp[x][y]=dp[x][y+2];
				}
				if(y==0)ans+=dp[x][y];
			}
		}
		cout<<ans<<endl;
	}
}