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++: 
//============================================================================
// Problem     : AOJ0203
// Title       : A New Plan of Aizu Ski Resort (会津山スキー場の新企画)
// Author      : mizo0203
// Status      : Accepted
// Date        : Wed May 30 15:25:20
// Copyright   : Your copyright free
// Description : 動的計画法
//============================================================================

#include <stdio.h>
#include <algorithm>

using namespace std;

int x, y;
int c[17][17];  // 最大15+2

int dp[17][17]; // 動的計画法の計算用

bool input() {
  int i, j;
  scanf("%d %d", &x, &y);
  if (!x && !y) return false; // x = 0 かつ y = 0 なら終了
  fill(c[0], c[0] + 17 * 17, 1); // 配列cを1(木)で初期化
  for (i = 1; i <= y; i++) {
    for (j = 1; j <= x; j++) {
      scanf("%d", &c[i][j]);
    }
  }

  return true;
}

void manage() {
  int i, j, output = 0;

  fill(dp[0], dp[0] + 17 * 17, 0); // 計算用配列を初期化
  for (i = 1; i <= x; i++) {
    if (c[1][i] != 1) dp[1][i] = 1;
  }

  for (i = 2; i <= y; i++) {
    for (j = 1; j <= x; j++) {
        if (c[i][j] == 0) {
          if (c[i - 1][j - 1] == 0) dp[i][j] += dp[i - 1][j - 1];
          if (c[i - 1][j    ] == 0) dp[i][j] += dp[i - 1][j    ];
          if (c[i - 1][j + 1] == 0) dp[i][j] += dp[i - 1][j + 1];
          if (c[i - 2][j    ] == 2) dp[i][j] += dp[i - 2][j    ];
        } else if (c[i][j] == 2) {
          if (c[i - 1][j] == 0) dp[i][j] += dp[i - 1][j];
          if (c[i - 2][j] == 2) dp[i][j] += dp[i - 2][j];
        }
    }
  }
  
  printf("\n");
  for (i = 0; i < 17; i++) {
    for (j = 0; j < 17; j++) {
      printf("%d ", dp[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  
  for (i = 1; i <= x; i++) {
    if (c[y - 1][i] == 2) output += dp[y - 1][i];
    output += dp[y][i];
  }
  printf("%d\n", output);
}


int main() {

  while(input()) {
    manage();
  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int c[20][20];
long long int dp[20][20];
int main() {
	int X,Y;
	while(true){
		long long int ans=0;
		cin>>X>>Y;
		if(X+Y==0) break;
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				cin>>c[i][j];
			}
		}
		for(int i=1;i<=X;i++){
			if(c[1][i]==1){
				dp[1][i]=0;
			}
			if(c[1][i]==0){
				dp[1][i]=1;
			}
			if(c[1][i]==2){
				dp[1][i]=1;
				dp[3][i]=1;
			}
		}
		for(int i=2;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(c[i][j]==1) dp[i][j]=0;
				else if(c[i][j]==0){
					for(int k=0;k<3;k++){
						if(c[i-1][j-1+k]!=2){
							dp[i][j]+=dp[i-1][j-1+k];
						}
					}
				}
				else{
					if(c[i-1][j]!=2){
						dp[i][j]+=dp[i-1][j];
						dp[i+2][j]+=dp[i][j];
					}
					else{
						dp[i][j]=0;
					}
				}
			}
		}
		for(int i=Y;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				ans+=dp[i][j];
			}
		}
		for(int i=1;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << p.first << " " << p.second;return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if (it != v.begin())os << " ";os << *it;
  }return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void print(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void print(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;




int a[20][20], dp[20][20];
int dy[] = {1, 1, 1}, dx[] = {-1, 0, 1};
void init(){
	rep(i,20)rep(j,20)dp[i][j] = 0;
}

signed main(){
	while(1){
		int h, w;
		cin >> w >> h;
		if(w == 0 and h == 0)break;
		rep(i,h)rep(j,w)cin >> a[i][j];
		init();
		rep(i,w)if(a[0][i] == 0)dp[0][i] = 1;
		rep(i,h){
			rep(j,w){
				if(a[i][j] >= 1)continue;
				if(i == h-1){
					dp[i+1][j] += dp[i][j];
					continue;
				}
				rep(k,3){
					int yy = i+dy[k], xx = j+dx[k];
					if(xx < 0 or w <= xx)continue;
					while(k == 1 and a[yy][xx] == 2)yy += 2;
					if(a[yy][xx] == 2)continue;
					dp[yy][xx] += dp[i][j];
				}
			}
		}
		int ans = 0;
		repi(i,h,20)rep(j,w)ans += dp[i][j];
		cout << ans << endl;
	}
	return 0;
}