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>

using namespace std;

int masu[17][17];

int count;
	int n,m;
void saiki(int x,int y){
	
	if(y<1 || y>n){
		return;
	}
	//printf("make %d %d\n",x,y);
	if(x>=m){
		//printf("ans %d %d\n",x,y);
		count++;
		return;
	}
	
	if(masu[x][y]==0){
		if(masu[x+1][y-1]==0 && x<=m-2){
			saiki(x+1,y-1);
		}
		if(masu[x+1][y]==0){
			saiki(x+1,y);
		}
		if(masu[x+1][y]==2){
			saiki(x+1,y);
		}
		if(masu[x+1][y+1]==0&& x<=m-2){
			saiki(x+1,y+1);
		}
	}
	if(masu[x][y]==1){
	}
	if(masu[x][y]==2){
		if(masu[x+2][y]!=1){
			saiki(x+2,y);
		}
	}
	
	//printf("--- %d %d\n",x,y);
}

int main(){
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0){
			break;
		}
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				masu[i][j]=0;
			}
		}
		
		for(int i=0;i<n;i++){
			for(int j=1;j<=m;j++){
				cin>>masu[i][j];
			}
		}
		
		count=0;
		
		for(int i=1;i<=n;i++){
			saiki(0,i);
		}
		
		printf("%d\n",count);
	}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <bitset>

#define REP(i,m,n) for(int i=m;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
#define drep(i,n) for(int i = n; i >= 0; i--)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

int chmax(int& a,int b){
	if(b > a){
		a=b;
	}
	return a;
}
int chmin(int& a,int b){
	if(b < a){
		a=b;
	}
	return a;
}

int X,Y;
int m[18][18];
int dp[20][20];


int main(int argc, char const *argv[])
{
	while(cin >> X >> Y, X){
		memset(m, -1 ,sizeof(m));
		memset(dp, 0 ,sizeof(m));
		rep(i,Y){
			rep(j,X){
				cin >> m[i+1][j+1];
			}
		}
		for(int i=1;i<=X;i++){
			if(m[1][i])
				dp[1][i]=0;
			else
				dp[1][i]=1;
		}
		for(int i=2;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(m[i][j]==1){
					dp[i][j]=0;
				}else if(m[i][j]== 2){
					if(m[i-1][j]==0)
						dp[i][j] += dp[i-1][j];
					if(m[i-2][j]==2)
						dp[i][j] += dp[i-2][j];
				}else{
					for(int k=-1;k<=1;k++){
						if(m[i-1][j+k]==0){
							dp[i][j] += dp[i-1][j+k];
						}
					}
					if(m[i-2][j]==2)
						dp[i][j] += dp[i-2][j];
				}
			}
		}
		int ans=0;
	//	for(int i=1;i<=Y;i++){
	//		for(int j=1;j<=X;j++){
	//			cout << dp[i][j] << " ";
	//		}
	//		cout << endl;
	//	}

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

	}




	return 0;
}

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

int main(){
	int x,y;
	while(1){
		cin >> x >> y;
		if(!x) break;
		int dp[17][15] = {},field[17][15] = {};
		for(int i = 1;i <= y;i++){
			for(int j = 0;j < x;j++) cin >> field[i][j];
		}
		for(int i = 0;i < x;i++) dp[0][i] = 1;
		for(int i = 0;i <= y;i++){
			for(int j = 0;j < x;j++){
				if(field[i][j] == 1) continue;
				if(i == 0){
					if(field[i + 1][j] != 1) dp[i + 1][j] = dp[i][j];
				}
				else if(field[i][j] == 0){
					if(i != y){
						if(j >= 1 && field[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
						if(j <= x - 2 && 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];
				}else{
					if(field[min(i + 2,y + 1)][j] != 1) dp[min(i + 2,y + 1)][j] += dp[i][j];
				}
			}
		}
		int cnt = 0;
		for(int i = 0;i < x;i++) cnt += dp[y + 1][i];
		cout << cnt << endl;
	}
	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];
   

    int ans=0;   
    for(int i=0;i<w;i++) {
      if(mp[0][i]==0) dp[0][i] = 1;
      if(i >=h-1) ans++;
    }
    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;
}