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>
using namespace std;

int main()
{
  int X, Y;
  while (cin >> X >> Y) {
    if ((X|Y) == 0)
      break;

    vector<vector<int> > cource(Y+1, vector<int>(X, 0));
    for (int i = 0; i < Y; ++i) {
      for (int j = 0; j < X; ++j)
	cin >> cource[i][j];
    }

    vector<vector<int> > dp(Y+1, vector<int>(X, 0));
    for (int i = 0; i < X; ++i) {
      if (cource[0][i] == 0)
	dp[0][i] = 1;
    }

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

    int ans = 0;
    for (int i = 0; i < X; ++i) {
	ans += dp[Y-1][i];
	ans += dp[Y][i];
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int2(b, a);
    while (a) {
        vvi data(a, vi(b));
        rep(i, a) {
            rep(j, b) {
                cin >> data[i][j];
            }
        }
        
       // cout << "=======" << endl;
        vvi dp(a+1, vi(b, 0));
        rep(i, b) {
            if (!data[0][i]) {
                dp[0][i] = 1;
            }
        }
        

        rep(i, a-1) {
            rep(j, b) {
                if (!data[i][j]) {
                    for (int k = -1; k < 2; k++) {
                        if (data[i+1][j+k] == 2) {
                            if (!k) {
                                dp[i+1][j] += dp[i][j];
                            }
                        } else if (!data[i+1][j+k]) {
                            dp[i+1][j+k] += dp[i][j];
                        }
                    }
                } else if (data[i][j] == 2) {
                    dp[i+2][j] += dp[i][j];
                }
            }
        }
/*
        rep(i, a+1) {
            rep(j, b) {
                cout << dp[i][j] << " ";
            }cout << endl;
        }*/

        int ans = 0;
        rep(i, b) {
            if (data[a-1][i] != 1) {
                ans += dp[a][i] + dp[a-1][i];
            } else {
                ans += dp[a][i];
            }
            /*
            if (data[a-1][i] == 1) {
                //cout << dp[a][i] << " ";
                ans += dp[a][i];
            } else {
                //cout << dp[a-1][i] << " ";
                ans += dp[a-1][i];
            }
            */
        }
        cout << ans << endl;
        cin >> b >> a;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  while(1){
    int w,h,mp[20][20]={},dp[20][20] ={};
    cin >> w >> h;
    if(w==0 && h==0) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin >> mp[i][j];
    for(int i=0;i<w;i++) if(mp[0][i]==0) dp[0][i] = 1;

    int ans=0;    
    for(int i=0;i<h-1;i++)
      for(int j=0;j<w;j++) 
	for(int k=-1;k<=1;k++){
	  if(mp[i][j] !=0) break;
	  int nx=j+k,ny=i+1;
	  if(nx<0||nx>=w) continue;
	  while(k==0 && mp[ny][nx]==2) ny+=2;
	  if(mp[ny][nx]!=0) continue;
	  dp[ny][nx]+= dp[i][j];
	  if(i >= h-1) ans+=dp[i][j];
	}
    cout << ans <<endl;
  }
  return 0;
}

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

int maps[20][20];
int course[20][20];
int X, Y;

void out();
int way(int y, int x){
  if(y >= Y) return 1;
  else if(course[y][x] > 0) return course[y][x];
  else if(maps[y][x] == 1) return 0;
  else if(maps[y][x] == 2 && maps[y + 2][x] != 1) return course[y][x] = way(y + 2, x);
  else{
    int SUM = 0;
    for(int i = 0; i < 3; i++){
      int ny = y + 1;
      int nx = x - 1 + i;
      if(maps[ny][nx] != 1 && 1 <= nx && nx <= X){
	int flug = 1;
	if(i != 1 && maps[ny][nx] == 2) flug = 0;
	if(flug) SUM += way(ny, nx);
      }
    }
    return course[y][x] = SUM;
  }
} 

int main(){
  while(1){
    cin >> X >> Y;
    if(X == 0 && Y == 0) break;
    for(int i = 1; i <= Y; i++){
      for(int j = 1; j <= X; j++){
	cin >> maps[i][j];
	course[i][j] = 0;
      }
    }
    int cnt = 0;
    for(int i = 1; i <= X; i++){
      if(maps[0][i] != 1) cnt += way(1, i);
    }
    //out();
    cout << cnt << endl;
  }
}

void out(){
  for(int i = 1; i <= Y; i++){
    for(int j = 1; j <= X; j++){
      cout << course[i][j] << " ";
    }
    cout << endl;
  }
  return;
}

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

int fld[17][17];
int cnt[17][17];

int main()
{
	int X,Y,S;
	while(cin >> X >> Y, (X||Y))
	{
		for(int y=0; y<17; y++)
		for(int x=0; x<17; x++)
		{
			fld[y][x] = 1;
			cnt[y][x] = 0;
		}

		for(int y=0; y< Y; y++)
		for(int x=1; x<=X; x++)
		{
			cin >> fld[y][x];
			cnt[y][x] = ((y==0&&fld[y][x]==0)?1:0);
		}

		for(int y=0; y< Y-1; y++)
		for(int x=1; x<=X  ; x++)
		{
			if(fld[y][x]==0)
			{
				if(fld[y+1][x+1]==0) cnt[y+1][x+1]+=cnt[y][x];
				if(fld[y+1][x-1]==0) cnt[y+1][x-1]+=cnt[y][x];
				if(fld[y+1][x  ]!=1) cnt[y+1][x  ]+=cnt[y][x]; 
			}
			if(fld[y][x]==2)
			{
				cnt[y+2][x]+=cnt[y][x];
			}
			cnt[y][x] = 0;
		}

		S=0;
		for(int y=Y-1; y< Y+2; y++)
		for(int x=1  ; x<=X  ; x++)
		{
			S+=cnt[y][x];
		}

		cout << S << endl;
	}

	return 0;
}