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 <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int X, Y;
  while(scanf("%d%d", &X, &Y) && X+Y){
    int board[15][15], dp[17][15] = {};
    rep(i, Y) rep(j, X) if(scanf("%d", &board[i][j])  && board[i][j] == 1) dp[i][j] = -1;

    rep(i, X) if(!dp[0][i]) dp[0][i] = 1;

    rep(i, Y-1) rep(j, X){
      if(board[i][j] == 1) continue;
      else if(board[i][j] == 2) dp[i+2][j] += dp[i][j];
      else{
	for(int k = -1; k < 2; k++){
	  if(j+k < 0 || j+k >= X) continue;
	  if(dp[i+1][j+k] == -1) continue;
	  if(board[i+1][j+k] == 2){
	    if(k != 0) continue;
	    dp[i+1][j+k] += dp[i][j];
	  }else{
	    dp[i+1][j+k] += dp[i][j];
	  }
	}
      }
    }

    ll res = 0;
    REP(i, Y-1, Y+1)
      rep(j, X)
      if(dp[i][j] != -1)
	res += dp[i][j];
  
    /*    rep(i, 17){ 
      rep(j, 15) printf("%d ", dp[i][j]);
      puts("");
      }*/

    printf("%lld\n", res);
  }
  return 0;
}

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

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

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

void resetStr();
void makeDp();
void dispAns();
void disp();

int main(){
    while(cin >>x >>y){
        if(x == 0 && y == 0) break;
        resetStr();
        for(int i = 0; i < y; i++){
            for(int j = 0; j < x; j++){
                cin >>map[i][j];
            }
        }
        makeDp();
        dispAns();
    }
}

void resetStr(){
    for(int i = 0; i <= MAX_XY; i++){
        for(int j = 0; j <= MAX_XY; j++){
            map[i][j] = -1;
            dp[i][j] = 0;
        }
    }
}

void makeDp(){
    int xm[] = {-1, 0, 1}, ym[] = {-1, -1, -1};
    for(int i = 0; i < x; i++){
        if(map[0][i] == 0) dp[0][i]++;
    }
    for(int i = 1; i < y; i++){
        for(int j = 0; j < x; j++){
            if(map[i][j] == 2){
                dp[i][j] += dp[i - 1][j];
                int xn = j, yn = i + 2;
                if(i != y - 1){
                    if(yn >= 0 && yn < y) dp[yn][xn] += dp[i][j];
                    else dp[y - 1][xn] += dp[i][j];
                }
            } else if(map[i][j] == 0){
                for(int k = 0; k < 3; k++){
                    int xn = j + xm[k], yn = i + ym[k];
                    if(xn >= 0 && yn >= 0 && xn < x && yn < y && map[yn][xn] == 0) dp[i][j] += dp[yn][xn];
                }
            }
//            disp();
        }
    }
}

void dispAns(){
    int ans = 0;
    for(int i = 0; i < x; i++){
        ans += dp[y - 1][i];
    }
    cout <<ans <<endl;
}

void disp(){
    cout <<endl;
    for(int i = 0; i < y; i++){
        for(int j = 0; j < x; j++){
            cout <<dp[i][j] <<" ";
        }
        cout <<endl;
    }
}

C++: // AOJ 0203
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
	int x, y;
	while (cin >> x >> y, x || y){
		int field[32][32] = {};
		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				cin >> field[i][j];
			}
		}
		int dp[32][32];
		memset(dp, 0, sizeof(dp));

		for (int j = 1; j <= x; j++){
			if (field[1][j] == 0){
				dp[1][j] = 1;
			}
		}
		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				if (field[i][j] == 1){
					continue;
				}
				if (field[i][j] == 2){
					dp[i + 2][j] += dp[i][j];
					continue;
				}
				if (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];
				}
				if (field[i + 1][j + 1] == 0){
					dp[i + 1][j + 1] += dp[i][j];
				}
			}
		}

		int ret = 0;
		for (int i = y - 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				if (i == y - 1){
					if (field[i][j] == 2) ret += dp[i][j];
					continue;
				}
				else if (field[i][j] != 1){
					ret += dp[i][j];
				}
			}
		}
		cout << ret << endl;
	}

	return 0;
}