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 <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(){
	while(true){
		int maxX,maxY;
		cin >> maxX >> maxY;			if(!maxX&&!maxY) return 0;

		int tizu[maxX+2][maxY+2];
		FOR(y,0,maxY+2){
			FOR(x,0,maxX+2){
				if(x==0||x==maxX+1||y==0||y==maxY+1){tizu[x][y]=1;continue;};
				cin >> tizu[x][y];
			}
		}

		int dp[maxX+2][maxY+2];
		FOR(y,0,maxY+2){
			FOR(x,0,maxX+2){
				dp[x][y]=0;
				if(x==0||x==maxX+1){
					continue;
				}
				if(y==0){
					continue;
				}
				if(y==1){
					if(tizu[x][y]==0) dp[x][y]+=1;
					continue;
				}
				if(y==maxY+1){
					if(tizu[x][y-1]==0) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-1]==2) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-2]==2) dp[x][y]+=dp[x][y-2];
					continue;
				}
				if(tizu[x][y]==0){
					if(tizu[x-1][y-1]==0) dp[x][y]+=dp[x-1][y-1];
					if(tizu[x][y-1]==0)   dp[x][y]+=dp[x][y-1];
					if(tizu[x+1][y-1]==0) dp[x][y]+=dp[x+1][y-1];
					if(tizu[x][y-2]==2)   dp[x][y]+=dp[x][y-2];
					continue;
				}
				if(tizu[x][y]==1){
					continue;
				}
				if(tizu[x][y]==2){
					if(tizu[x][y-1]==0) dp[x][y]+=dp[x][y-1];
					if(tizu[x][y-2]==2) dp[x][y]+=dp[x][y-2];
					continue;
				}
			}
		}
/*
		FOR(y,0,maxY+2){
			FOR(x,0,maxY+2){
				cout << dp[x][y];
			}
			cout << endl;
		}
*/


		int res = 0;
		FOR(x,1,maxX+1){ res += dp[x][maxY+1];};
		cout << res << endl;

	}
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char const* argv[])
{
	int x,y;
	int stage[17][17][2];

	while( cin >> x >> y && x != 0 && y != 0 ){
		for( int i = 0;i < 17;i++ ){
			for( int j = 0;j < 17;j++ ){
				stage[i][j][0] = stage[i][j][1] = 0;
			}
		}
		
		for( int i = 0;i < 17;i++ ) stage[i][1][1] = 1;
		
		for( int i = 1;i <= y;i++ ){
			for( int j = 1;j <= x;j++ ){
				cin >> stage[j][i][0];
			}
		}

		for( int j = 1;j <= y;j++ ){
			for( int i = 1;i <= x;i++ ){
				if( stage[i][j][0] == 1 ) continue;
				if( stage[i][j][0] == 0 ){
					stage[i][j + 1][1] += stage[i][j][1];
					
					if( stage[i + 1][j + 1][0] == 0 && j != y ) stage[i + 1][j + 1][1] += stage[i][j][1];
					if( stage[i - 1][j + 1][0] == 0 && j != y ) stage[i - 1][j + 1][1] += stage[i][j][1];

				}
				if( stage[i][j][0] == 2 ){
					stage[i][j + 2][1] += stage[i][j][1];
				}
			}
		}
		int count = 0;
		for( int i = 1;i <= x;i++ ){
			count += stage[i][y+1][1];
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream> 
#define N 16
using namespace std;
void func(int,int);
int jump(int,int);
int X,Y,data[N][N],memo[N+2][N];
int main(){
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j];
    for(int i=0;i<Y+2;i++)
      for(int j=0;j<X;j++) memo[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]!=1)	func(0,i);
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=memo[0][i];
    cout << cnt << endl;
  }
  return 0;
}
void func(int y,int x){
  if(y>=Y-1){
    memo[Y][x]=memo[Y-1][x]=1;
    return ;
  }
  if(y+1<Y&&0<=x-1&&data[y+1][x-1]==0){
    if(memo[y+1][x-1]!=0) memo[y][x]+=memo[y+1][x-1];
    else{
      func(y+1,x-1),memo[y][x]+=memo[y+1][x-1];
    }
  }
  if(y+1<Y&&x+1<X&&data[y+1][x+1]==0){
    if(memo[y+1][x+1]!=0) memo[y][x]+=memo[y+1][x+1];
    else{
      func(y+1,x+1),memo[y][x]+=memo[y+1][x+1];
    }
  }
  if(data[y+1][x]==0){
    if(memo[y+1][x]!=0) memo[y][x]+=memo[y+1][x];
    else{
      func(y+1,x),memo[y][x]+=memo[y+1][x];
    }
  }
  if(data[y+1][x]==2){
    int r=jump(y+1,x);
    if(r!=-1){
      if(memo[r][x]!=0) memo[y][x]+=memo[r][x];
      else func(r,x),memo[y][x]+=memo[r][x];
    }
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  y+=2;
  while(1){
    if(data[y][x]==1) break;
    if(data[y][x]==0) return y;
    if(y>=Y-1) return y;
    y+=2;
  }
  return -1;
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define int long long int

signed main(){
    int w,h;
    while(cin>>w>>h){
        if(w==0&&h==0)break;
        int data[20][20];
        rep(i,h){
            rep(j,w){
                cin>>data[i][j];
            }
        }
        int dp[20][20];
        rep(i,20)rep(j,20)dp[i][j]=0;
        rep(i,w){
            if(data[0][i]==0){
                dp[0][i]=1;
            }
        }
        
        for(int i=0;i<h-1;i++){
            for(int j=0;j<w;j++){
                if(j-1>=0 && data[i+1][j-1]==0)dp[i+1][j-1]+=dp[i][j];
                if(data[i+1][j]==0)dp[i+1][j]+=dp[i][j];
                if(data[i+1][j]==2){
                    int c=1;
                    while(data[i+1+2*c][j]==2)c++;
                    dp[min(h-1,i+1+c*2)][j]+=dp[i][j];
                }
                if(j+1<w && data[i+1][j+1]==0)dp[i+1][j+1]+=dp[i][j];
            }
        }
        int ans=0;
        rep(i,w){
            ans+=dp[h-1][i];
        }
        cout<<ans<<endl;
    }
}