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 <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;

#define int long long
namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int vv[20][20];
int table[20][20];
/*
1 1 1 1 1 
1 1 1 1 1 
1 1 3 1 1 
0 3 3 0 1 
4 3 3 1 0 
4 0 0 0 0 
*/
/*
5 5
0 0 0 0 1
2 1 0 2 0
1 0 0 1 1
0 2 1 2 0
0 1 0 0 0
*/
void mainmain(){
	int w,h;
	while(cin>>w>>h,w||h){
		rep(i,20){
			rep(j,20){
				vv[i][j]=0;
			}
		}
		rep(i,20){
			rep(j,20){
				table[i][j]=0;
			}
		}
		reep(i,1,w+1){
			vv[0][i]=1;
		}
		rep(i,h){
			rep(j,w){
				cin>>table[i+1][j+1];
			}
		}
		rep(i,h){
			reep(j,1,w+1){
				if(table[i][j]==2){
					vv[i+2][j]+=vv[i][j];
					continue;
				}
				if(table[i][j]==1) continue;
				vv[i+1][j]+=vv[i][j];
				if(i&&j-1>0&&table[i+1][j-1]==0){
					vv[i+1][j-1]+=vv[i][j];
				}
				if(i&&j+1<=w&&table[i+1][j+1]==0){
					vv[i+1][j+1]+=vv[i][j];
				}
			}
		}
		int ans=0;
		reep(i,h,h+2){
			reep(j,1,w+1){
				ans+=vv[i][j];
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: #include<iostream>
#include<string>

using namespace std;

int main(){
  int x, y, course[50][50], route[52][52], i, j, sum;
  while(cin >> x >> y, x+y){
    sum = 0;
    for(i=0; i<52; i++){
      for(j=0; j<52; j++){
        route[i][j] = 0;
      }
    }
    for(i=0; i<y; i++){
      for(j=0; j<x; j++){
        cin >> course[i][j];
      }
    }
    for(i=0; i<y; i++){
      for(j=0; j<x; j++){
	if(i==0){
          if(course[i][j]==0){
            route[i][j] = 1;
          }else{
	    route[i][j] = 0;
          }
        }else{
          if(j==0){
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j+1]==0){
                route[i][j] += route[i-1][j+1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
	        route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
            }
          }else if(j==x-1){
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j-1]==0){
                route[i][j] += route[i-1][j-1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
	        route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
            }
          }else{
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j-1]==0){
                route[i][j] += route[i-1][j-1];
              }
              if(course[i-1][j+1]==0){
                route[i][j] += route[i-1][j+1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
                route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
              if(course[i-2][j]==2){
                route[i][j] = route[i-2][j];
                route[i+2][j] += route[i][j];
              }
            }
          }
        }
      }
    }

    for(i=y; i<y+1; i++){
      for(j=0; j<x; j++){
        sum+=route[i][j];
      }
    }
    cout << sum << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int field[20][20];
long long dp[20][20];

int main()
{
  int c1, c2;
  while (scanf(" %d %d ", &c1, &c2) == 2) {
    if (c1 == 0 && c2 == 0) {break;}
    for (int i = 0; i < 20; i++) {
      fill(field[i], &field[i][20], -1);
      fill(dp[i], &dp[i][20], 0);
    }
    for (int i = 1; i <= c1; i++) {
      for (int j = 1; j <= c2; j++) {
	scanf(" %d ", &field[i][j]);
      }
    }
    /*for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
	printf("%d", field[i][j]);
      }
      printf("\n");
      }*/
    
    for (int i = 1; i <= c2; i++) {
      dp[1][i] = 1;
    }
    for (int i = 1; i < c1; i++) {
      for (int j = 1; j <= c2; j++) {
	if (field[i][j] == 0) {
	  if (field[i + 1][j - 1] != 2) {dp[i + 1][j - 1] += dp[i][j];}
	  dp[i + 1][j] += dp[i][j];
	  if (field[i + 1][j + 1] != 2) {dp[i + 1][j + 1] += dp[i][j];}
	} else if (field[i][j] == 2) {
	  dp[i + 2][j] += dp[i][j];
	} 
      }
    }
    long long sum = 0;
    for (int i = 0; i <= 1; i++) {
      for (int j = 1; j <= c2; j++) {
	if (field[c1 + i][j] != 1) {sum += dp[c1 + i][j];}
      }
    }
    /*for (int i = 1; i <= c1; i++) {
      for (int j = 1; j <= c2; j++) {
	printf("%d", dp[i][j]);
      }
      printf("\n");
      }*/
    
    printf("%d\n", sum);
  }
}