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 rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
	#define rep(x,to) rep2(x,0,to)
	using namespace std;
	int main(){
		int x, y;
		while(cin >> x >> y && (x||y) ) {
			int b[15][15] = {};
			rep(i,y) {
				rep(j,x) {
					cin >> b[i][j];
				}
			}
			int ret[20][20] = {};
			rep(i,x) {
				if(b[0][i] == 0) {
					ret[0][i+1] = 1;
				}
			}
			rep2(i,1,y) {
				rep(j,x) {
					if(b[i][j] == 0) {
						ret[i][j+1] += ret[i-1][j] + ret[i-1][j+1] + ret[i-1][j+2];
						rep2(k,-1,2) {
							if(b[i-1][j+k] == 2) ret[i][j+1] -= ret[i-1][j+k+1];
						}
					} else if(b[i][j] == 2) {	
						if(b[i-1][j] == 0) ret[i][j+1] += ret[i-1][j+1];
						if(y <= i+2 || b[i+2][j] != 1) ret[i+2][j+1] += ret[i][j+1];
					}
				}
			}
			int ans = 0;
			rep2(i,y-1,y+2) {
				rep(j,x) {
					ans += ret[i][j+1];
				}
			}
			cout << ans << endl;
		}
	}

C++: #include<iostream>
using namespace std;
int X,Y;
int dp[20][20];
char maps[20][20];
int bun(int x,int y);
int dx[3]={-1,0,1};
main(){
  while(1){
    cin>>X>>Y;
    if(X==0&&Y==0){
      break;
    }
    for(int i=1;i<=Y;i++){
      for(int j=1;j<=X;j++){
	cin>>maps[i][j];
	dp[i][j]=0;
      }
    }
    int ans=0;
    for(int i=1;i<=X;i++){
      if(maps[1][i]!='1'){
	ans+=bun(1,i);
      }
    }
    cout<<ans<<endl;
  }
}
int bun(int y,int x){
  if(y>=Y){
    return 1;
  }
  else if(dp[y][x]!=0){
    return dp[y][x];
  }
  else if(maps[y][x]=='2'){
    if(maps[y+2][x]!='1'){
      return dp[y][x]=bun(y+2,x);
    }
    else{
      return 0;
    }
  }
  else if(maps[y][x]=='1'){
    return 0;
  }
  else{
    int anss=0;
    for(int i=0;i<3;i++){
      int nx=x+dx[i];
      if(i!=1){
	if(nx>0&&nx<=X&&maps[y+1][nx]=='0'){
	  anss+=bun(y+1,nx);
	}
      }
      else{
	if(maps[y+1][nx]!='1'){
	  anss+=bun(y+1,nx);
	}
      }
    }
    return dp[y][x]=anss;
  }	  	  
}

C++: #include <iostream>
#include <cstring>

using namespace std;

#define MAX 20

int W,H;
int arr[MAX][MAX];
int dp[MAX][MAX];
const int dx[] = {-1,0,1};
const int dy[] = {1,1,1};

bool inField(int y,int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

int solve(int y,int x){
  if(y == H-1){
    if(arr[y][x] == 0){
      return 1;
    }else{
      return 0;
    }
  }
  if(dp[y][x] != -1) return dp[y][x];

  int res = 0;
  if(arr[y][x] != 2){
    for(int i = 0 ; i < 3 ; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(!inField(ny,nx)) continue;
      if(arr[ny][nx] == 1) continue;
      if(arr[ny][nx] == 0){
        res += solve(ny,nx);
      }else{
        if(x == nx){
          res += solve(ny,nx);
        }
      }
    }
  }else{
    int nx = x, ny = y + 2;
    if(!inField(ny,nx)) return 1;
    res += solve(ny,nx);
  }
  return dp[y][x] = res;
}

int main(){
  while(cin >> W >> H, (W | H)){
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> arr[i][j];
        dp[i][j] = -1;
      }
    }
    int res = 0;
    for(int i = 0 ; i < W ; i++){
      if(arr[0][i] == 0){
        res += solve(0,i);
      }
    }
    cout << res << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

int X, Y, c[16][16], mem[20][20];

// tate 1, migi 2, hidari 3
int solve(int x, int y, int tate) {
  if(x < 0 || x >= X) return 0;
  if(y >= Y) {
    if(tate == 1)
      return 1;
    else
      return 0;
  }
  if(c[y][x] == 1) return 0;
  if(tate == 1 && c[y][x] == 2) {
    return solve(x, y+2, 1);
  }
  if(c[y][x] == 2) return 0;
  if(mem[y][x] != -1) return mem[y][x];
  int tmp = solve(x-1, y+1, 2) + solve(x+1, y+1, 3) + solve(x, y+1, 1);
  mem[y][x] = tmp;
  return tmp;
}
  

int main() {
  while(cin >> X >> Y, X) {
    int res = 0;
    
    rep(i, Y) {
      rep(j, X) {
        cin >> c[i][j];
        mem[i][j] = -1;
      }
    }
    
    rep(i, X) {
      res += solve(i, 0, 1);
    }
    
    cout << res << endl;
  }
  return 0;
}

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

int main() {
	int W, H;
	while(cin >> W >> H, W) {
		int b[20][15] = { 0 };
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				cin >> b[i][j];
			}
		}

		int dp[20][15] = { 0 };
		for(int i = 0; i < W; i++) {
			if(b[0][i] != 1) dp[0][i] = 1;
		}

		for(int i = 0; i < H - 1; i++) {
			for(int j = 0; j < W; j++) {
				if(b[i][j] == 0) {
					for(int d = -1; d <= 1; d++) {
						if(0 <= j + d &&  j + d < W && (b[i + 1][j + d] == 0) || (b[i + 1][j + d] == 2 && d == 0))
							dp[i + 1][j + d] += dp[i][j];
					}
				}
				else if(b[i][j] == 2) {
					dp[i + 2][j] += dp[i][j];
				}
			}
		}

		int ans = 0;
		for(int i = H - 1; i <= H; i++) {
			for(int j = 0; j < W; j++) {
				if(b[i][j] != 1)
					ans += dp[i][j];
			}
		}
		cout << ans << endl;
	}
}