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<cstring>
#define INF 1<<20
using namespace std;

int w, h;
int data[22][22];
int memo[22][22];

int solve(int x, int y){

  if(x < 0 || x == w || data[y][x]&1) return 0;
  if(y > h-2) return 1;
  if(memo[y][x]) return memo[y][x];

  int ret = 0;
  if(data[y][x] == 2) ret += solve(x, y+2);
  else{
    if(x && !data[y+1][x-1]) ret += solve(x-1, y+1);
    if(!data[y+1][x+1]) ret += solve(x+1, y+1);
    ret += solve(x, y+1);
  }
  
  return memo[y][x] = ret;
}

int main(){

  while(cin >> w >> h, w+h){

    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> data[i][j];

    int ans = 0;
    for(int i=0;i<w;i++){
      memset(memo, 0, sizeof(memo));
      ans += solve(i, 0);
    }

    cout << ans << endl;
  }

}

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

using namespace std;


int main() {
	while(1) {
		int x, y;
		cin >> x >> y;
		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;

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

C++: // AOJ 0203
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
	int x, y;
	while (cin >> x >> y, x || y){
		int field[32][32] = {};
		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				cin >> field[i][j];
			}
		}
		int dp[32][32];
		memset(dp, 0, sizeof(dp));

		for (int j = 1; j <= x; j++){
			if (field[1][j] == 0){
				dp[1][j] = 1;
			}
		}
		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				if (field[i][j] == 1){
					continue;
				}
				if (field[i][j] == 2){
					dp[i + 2][j] += dp[i][j];
					continue;
				}
				if (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 (field[i + 1][j + 1] == 0){
					dp[i + 1][j + 1] += dp[i][j];
				}
			}
		}

		int ret = 0;
		for (int i = y - 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				if (i == y - 1){
					if (field[i][j] == 2) ret += dp[i][j];
					continue;
				}
				else {
					ret += dp[i][j];
				}
			}
		}
		cout << ret << endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int dx[] = {-1,0,1},dy[] = {-1,-1,-1};
int main(){
	int x,y;
	while(cin >> x >> y,x,y){
		int dp[20][20] = {{0}};
		int field[20][20] = {{0}};
		for(int i = 1; i <= y; i++){
			for(int j = 1; j <= x; j++){
				cin >> field[i][j];
			}
		}
		for(int i = 1; i <= y+2; i++){
			for(int j = 1; j <= x; j++){
				if(i == 1 && field[i][j] == 0){
					dp[i][j] = 1;
					continue;
				}
				if(i <= y){
					for(int k = 0; k < 3; k++){
						int px = j+dx[k],py = i+dy[k];
						if(field[i][j] == 0){
							if(field[py][px] == 0)dp[i][j] += dp[py][px];
							else if(field[py][px] == 2)continue;
						}
						else if(field[i][j] == 2){
							if(k == 1)dp[i][j] += dp[py][px];
						}
						else if(field[i][j] == 1)continue;
					}
				}
				if(i > 3){
					int px = j,py = i - 2;
					if(field[py][px] == 2){
						dp[i][j] += dp[py][px];
					}
				}
			}
		}
		int sum = 0;
		for(int i = 1; i <= x; i++){
			sum += dp[y][i];
			sum += dp[y+1][i];
			sum += dp[y+2][i];
		}
		cout << sum << endl;
	}
	return 0;
}

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

int main(){
	int w,h,x,y;
	char map[15][15];
	int dp[15][15];
	int ans;
	
	while(cin>>w>>h,w!=0){
		for(y=0;y<h;y++){
		for(x=0;x<w;x++){
			cin>>map[x][y];
			dp[x][y]=0;
		}
		}

		for(x=0;x<w;x++) if(map[x][0]!='1') dp[x][0]=1;

		for(y=0;y<h-1;y++){
		for(x=0;x<w;x++){
			if(map[x][y]=='0'){
				if(map[x][y+1]!='1') dp[x][y+1]+=dp[x][y];
				if(0<x && map[x-1][y+1]=='0') dp[x-1][y+1]+=dp[x][y];
				if(x<h-1 && map[x+1][y+1]=='0') dp[x+1][y+1]+=dp[x][y];
			}else if(map[x][y]=='2'){
				if(y<h-2 && map[x][y+2]!='1') dp[x][y+2]+=dp[x][y];
			}
		}
		}
		
		ans=0;for(x=0;x<w;x++){
			if(map[x][h-2]=='2') ans+=dp[x][h-2];
			ans+=dp[x][h-1];
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int DP[17][17];
int field[17][17];
int x,y;

int main(){
	while(true){
		cin >> x >> y;
		if(!x && !y)
			return 0;
		
		for(int i=1; i<=y; i++)
			for(int k=1; k<=x; k++)
				cin >> field[i][k];
		for(int i=1; i<=x; i++)
			field[y+1][i] = 0;
		
		for(int i=1; i<=y+1; i++)
			for(int k=0; k<=x+1; k++){
				DP[i][k]=0;
				if(i==1 && k>0 && k<=x)
					if(field[i][k] == 0)
						DP[i][k] = 1;
			}
		
		for(int i=2; i<=y; i++){
			for(int k=1; k<=x; k++){
				if(field[i][k] == 0)
					DP[i][k] += DP[i-1][k-1] + DP[i-1][k] + DP[i-1][k+1];
				else if(field[i][k] == 2)
					int n = i+2;
					while(true){
						if(field[n][k] == 0){
							DP[n][k] += DP[i-1][k];
							break;
						}else if(field[n][k] == 1)
							break;
						else
							n+=2;
					}
				}
			}
		}
		
		int ans=0;
		for(int i=y; i<=y+1; i++)
			for(int k=1; k<=x; k++)
				ans += DP[i][k];
		cout << ans << endl;
	}
}