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 <bits/stdc++.h>  

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int X, Y;
int field[20][20];
int dp[20][20];

int main() {
	while(scanf("%d %d", &X, &Y), X || Y) {
		rep(i, Y) rep(j, X) scanf("%d", &field[i][j]);
		memset(dp, 0, sizeof(dp));
		rep(j, X) dp[0][j] = (field[0][j] == 0);
		FOR(i, 1, Y) rep(j, X) {
			if(field[i][j] == 0) {
				FOR(k, -1, 2) dp[i][j] += dp[i - 1][j + k];
			}
			else if(field[i][j] == 2) {
				if(i == Y - 1) {
					dp[i][j] += dp[i - 1][j];
				}
				else if(field[i + 2][j] != 1){
					dp[i + 2][j] += dp[i][j] + dp[i - 1][j];
					dp[i][j] = 0;
				}
			}
		}
		rep(i, X) dp[Y][i] += dp[Y - 1][i];
		/*rep(i, Y) {
			rep(j, X) printf("%2d", dp[i][j]);
			puts("");
		}
		rep(i, X) printf("%2d", dp[Y][i]);
		*/
		int res = 0;
		rep(i, X) res += dp[Y][i];
		printf("%d\n", res);
	}
	return 0;
}

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

int main() {
	int x, y;
	while (cin >> x >> y, x, y) {
		vector<vector<int>> course(y + 2, vector<int>(x + 2, 0));
		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				cin >> course[i][j];
			}
		}

		vector<vector<int>> path(y + 2, vector<int>(x + 2, 0));
		//?????????????????????????????????1????????????
		for (int i = 1; i <= x; i++) {
			if (course[1][i] != 1) path[1][i] = 1;
		}

		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				//????????????????????´????????????????????´??????????????????????????????????????????
				//?????????????§????????????????????????´?????????????????????????????£????????°?????´????????????????????????
				if (course[i][j] == 0) {
					if (course[i + 1][j + 1] == 0) path[i + 1][j + 1] += path[i][j];
					if (course[i + 1][  j  ] != 1) path[i + 1][  j  ] += path[i][j];
					if (course[i + 1][j - 1] == 0) path[i + 1][j - 1] += path[i][j];
				}
				//?¬???????????????´???????????£????????°????????????????????????????????????
				//?????????????????£????????§??´??????????????´???????????????(?????£?????????????????????????????´???????????????)
				if (course[i][j] == 2 && course[i+2][j] != 1) {
					path[i + 2][j] += path[i][j];
					if(i + 2 > y && i != y) path[y][j] += path[i][j];
				}
				//???????????´???????????????????????????????????????
				if(course[i][j] == 1){/*do anything*/}
			}
		}

		cout << accumulate(path[y].begin()+1, path[y].end()-1, 0) << endl;

	}
}

C++: #include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int x,y;
        long long ans=0;
        long long 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 <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];
   

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

      cout << endl;
      for(int i=0;i<h+3;i++){
      for(int j=0;j<w;j++)cout << dp[i][j] <<" ";
      cout << endl;
      }

    cout << ans <<endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20];
int memo[20][20];
int ans;
int count;

int saiki(int x,int y) {
  count++;
  // cout << x <<" "<<y <<endl;
  int dx[3] = {-1,0,1};
  int dy[3] = {1,1,1};
  
  if(y >= h-1) ans++,memo[y][x]++;//,cout <<"ok"<<endl;  
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = dx[i]+x;
      int ny = dy[i]+y;
      if(nx <0|| nx >= w || memo[ny][nx] == -1) continue;
      
      if(memo[ny][nx] > 0 && mp[ny][nx] == 0) {
	ans += memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }  
      else if(x == nx && memo[ny][nx] == 2 && memo[ny][nx] > 0) {
	ans += memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	if(memo[ny][nx] > 0) memo[y][x] += memo[ny][nx];
      } 
      else if(nx==x && mp[ny][nx] == 2){
	int ty = ny;
	while(mp[ty][nx] == 2) ty+=2;
	if(mp[ny][nx] == 0)saiki(nx,ty);
	if(memo[ty][nx] > 0) memo[y][x] += memo[ty][nx];
      } 
    }
    if(memo[y][x] == 0) memo[y][x] = -1;
  }
}


int main() {

  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    for(int i=0;i<=19;i++) 
      for(int j=0;j<=19;j++){ 
	memo[i][j] = 0;
	mp[i][j] = 0;
      }
    
    for(int i=0;i<h;i++) 
      for(int j=0;j<w;j++) 
	cin >> mp[i][j];

    /*
      for(int i=0;i<h;i++) {
      for(int j=0;j<w;j++) 
      cout << mp[i][j];
      cout << endl;
      }
    */

    ans = 0;
    count = 0;
    for(int i=0;i<w;i++) {
      if(mp[0][i] !=1) saiki(i,0);
    }

    int ans2 = 0;
    for(int i=0;i<w;i++) 
      if(memo[0][i] > 0) ans2+=memo[0][i];

    cout << ans << endl;
    //    cout << ans2 << endl;
    //cout << count << endl;
  }

  return 0;
}