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>
#define MAX 15

using namespace std;

int a,b,cnt,ans;
int ski[MAX][MAX];

int compute(int y,int x){

  if( ski[y][x] == 1 ) return cnt;
  if( b - 1 <= y ) return ++cnt;

  if( ski[y][x] == 2 ) compute( y + 2 , x );

  if( ski[y][x] != 2 ){
    if( ski[y + 1][x] == 2 ) compute( y + 3 , x );  
    if( !ski[y + 1][x - 1] && ( 0 <= x - 1 && x - 1 < a ) ) compute( y + 1 , x - 1 );
    if( !ski[y + 1][x + 1] && ( 0 <= x + 1 && x + 1 < a ) ) compute( y + 1 , x + 1 );
    if( !ski[y + 1][x] ) compute( y + 1 , x );
  }

  
  return cnt;
}



int main(void){

  while( cin >> a >> b , a || b ){

    for( int i = 0 ; i < b ; i++ )
      for( int j = 0 ; j < a ; j++ )
	cin >> ski[i][j];

    ans = 0;
    for( int i = 0 ; i < a ; i++ ){
      if( ski[0][i] == 0 ){
	cnt = 0;
	int c = compute( 0 , i );
	// cout << ski[0][i] << endl;
	ans += c;
      }
    }
    cout << ans << endl;


  }
  return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
const int MAX_Y = 100;
const int MAX_X = 100;
int mx, my, c[MAX_Y][MAX_X], dp[MAX_Y][MAX_X];

const int dx[3] = {-1, 0, 1};
const int dy[3] = {1, 1, 1};

int dfs(int y, int x) {  
  int res = 0;
  if (dp[y][x] >= 0) return dp[y][x];
  
  if (y == my - 1) return 1;
  
  if (c[y][x] == 2) {
    if (y+2 >= my - 1) return 1;
    res += dfs(y+2, x);
    return dp[y][x] = res;
  }
  
  rep(z,3) {
    int tx = x + dx[z], ty = y + dy[z];
    if (tx < 0 || ty < 0 || tx >= mx || ty >= my) continue;
    if (c[ty][tx] == 1) continue;
    if (c[ty][tx] == 2 && tx != x) continue;
    res += dfs(ty, tx);
  }

  return dp[y][x] = res;
}

void solve() {
  memset(dp, -1, sizeof dp);
  rep(i,my) rep(j,mx) cin>>c[i][j];

  int res = 0;
  rep(i,mx) {
    if (c[0][i] == 1) continue;
    res += dfs(0, i);
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>mx>>my, mx||my) {
    solve();
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = (1 << 26);
const int MAX_XY = 15;

void solve();

int x, y, f[MAX_XY + 1][MAX_XY], dp[MAX_XY + 1][MAX_XY];

int main(){
    while(cin >>x >>y && x && y){
        rep(i, MAX_XY + 1) rep(j, MAX_XY) f[i][j] = 1;
        rep(i, y) rep(j, x) cin >>f[i][j];
        memset(dp, 0, sizeof(dp));

        solve();

        int ans = 0;
        rep(i, x) ans += dp[y][i];
        cout <<ans <<endl;
    }
    return 0;
}

void solve(){
    rep(i, x) if(f[0][i] == 0) dp[0][i] = 1;

    rep(i, y - 1){
        rep(j, x){
            if(f[i + 1][j] == 1){
                dp[i + 1][j] = 0;
                continue;
            } else if(f[i + 1][j] == 0){
                f(k, -1, 2){
                    if(j + k < x && j + k >= 0) dp[i + 1][j] += dp[i][j + k];
                }
            } else{
                dp[i + 1][j] += dp[i][j];
                if(i + 3 >= y) dp[y][j] += dp[i + 1][j];
                else dp[i + 3][j] += dp[i + 1][j];
                dp[i + 1][j] = 0;
            }
        }
    }
    rep(i, x) dp[y][i] += dp[y - 1][i];
}

C++: #include <iostream> 
#define N 15
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<N+2;i++){
      for(int j=0;j<N;j++){
	data[i][j]=0;
      }
    }
    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++: // 2011/08/02 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;
		if(X==0&&Y==0)
			break;

		int C[17][17];
		for(int i=0; i<=Y+1; i++)
			for(int j=0; j<=X+1; j++)
				C[i][j] = 1;

		for(int i=1; i<=Y; i++)
			for(int j=1; j<=X; j++)
				cin >> C[i][j];

		for(int j=1; j<=X; j++)
			C[Y+1][j] = 0;

		int DP[17][17];
		for(int i=0; i<=Y+1; i++)
			for(int j=0; j<=X+1; j++)
				DP[i][j] = 0;

		for(int j=1; j<=X; j++)
			if(C[1][j]==0)
				DP[1][j] = 1;

		for(int i=1; i<=Y-1; i++)
			for(int j=1; j<=X; j++)
				if(C[i][j]==0){
					for(int k=j-1; k<=j+1; k++)
						if(C[i+1][k]==0){
							DP[i+1][k] += DP[i][j];
						}
						else if(C[i+1][k]==1){
							DP[i+1][k] = 0;
						}
						else if(C[i+1][k]==2){
							if(k==j)
								DP[i+1][k] += DP[i][j];
						}
				}
				else if(C[i][j]==1){
					DP[i][j] = 0;
				}
				else if(C[i][j]==2){
					if(C[i+2][j]==1)
						DP[i+2][j] = 0;
					else
						DP[i+2][j] += DP[i][j];
				}

		for(int j=1; j<=X; j++)
			if(C[Y][j]==1){
				DP[Y][j] = 0;
			}

		int sum = 0;
		for(int i=Y; i<=Y+1; i++)
			for(int j=1; j<=X; j++)
				sum += DP[i][j];

		cout << sum <<endl;
	}

	return 0;
}