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 N 15
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<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j],memo[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]==0) 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-1][x]=1;
    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==-2) memo[y][x]+=1;
    else if(r!=-1){
      if(memo[r][x]==0) func(r,x);
      memo[y][x]+=memo[r][x];
    }
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(data[y][x]==1) break;
    if(y>=Y-1) return -2;
    if(data[y][x]==0) return y;
  }
  return -1;
}

C++: #include<iostream>
#include<vector>
#include<string>
#define int long long
using namespace std;

signed main() {
	int a, b;
	while (cin >> a >> b, a | b) {
		vector<vector<int>>masu(b + 1, vector<int>(a));
		vector<vector<int>>suberikata(b + 1, vector<int>(a));
		for (int c = 0; c < b; c++) {
			for (int d = 0; d < a; d++) {
				cin >> masu[c][d];
			}
		}
		for (int e = 0; e < b; e++) {
			if (masu[0][e] ==0)suberikata[0][e]++;
		}
		for (int f = 0; f < b-1; f++) {
			for (int g = 0; g < a; g++) {
				switch (masu[f][g]) {
				case 0:
					suberikata[f + 1][g] += suberikata[f][g];
					if (g > 0&&masu[f+1][g-1]!=2)suberikata[f + 1][g - 1] += suberikata[f][g];
					if (g < a - 1 && masu[f + 1][g + 1] != 2)suberikata[f + 1][g + 1] += suberikata[f][g];
					break;     
				case 2:suberikata[f + 2][g] += suberikata[f][g]; break;
				}
			}
		}
		int s = 0;
		for (int x = 0; x < a; x++) {
			if (masu[b-1][x] != 1)s += suberikata[b-1][x];
		}
		for (int j : suberikata[b]) {
			s += j;
		}
		cout << s << endl;
	}
}

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

int field[19][17];
int DP[19][17];
int main()
{
	int w,h;
	while(cin >> w >> h){
		if(!w && !h)
			break;
		for(int i=0;i<19;i++){
			for(int j=0;j<17;j++){
				field[i][j] = 0;
				DP[i][j] = 0;
			}
		}
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				cin >> field[i][j];
			}
		}
		for(int j=1;j<=w;j++){
			if(field[1][j] == 1)
				DP[1][j] = 0;
			else if(field[1][j] == 0)
				DP[1][j] = 1;
		}
		
		for(int i=2;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(field[i][j] == 1)
					DP[i][j] = 0;
				else if(field[i][j] == 0)
					DP[i][j] += DP[i-1][j-1] + DP[i-1][j] + DP[i-1][j+1];
				else if(field[i][j] == 2){
					DP[i][j] = 0;
					int dy = 0;
					while(field[i+dy][j] == 2){
						DP[i+dy][j] = 0;
						dy+=2;
					}
					DP[i+dy][j] += DP[i-1][j];
				}
			}
		}
		
		int sum = 0;
		for(int i=h;i<=h+2;i++){
			for(int j=1;j<=w;j++){
				sum += DP[i][j];
			}
		}
		cout << sum << endl;		
		/*
		for(int i=0;i<18;i++){
			for(int j=0;j<17;j++){
				cout << DP[i][j];
			}
			cout << endl;
		}*/
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<string>
using namespace std;
int X,Y;
char fie[20][20];
int dp[20][20];
int dx[]={-1,0,1};
int solve(int x,int y){
  if(dp[x][y]!=-1) return dp[x][y];
  if(y>=Y-1) return dp[x][y]=1;
  if(fie[x][y]=='2' && fie[x][y+2]!='1'){
    return dp[x][y]=solve(x,y+2);
  }
  int ret=0;
  for(int i=0;i<3;i++){
    int nx=x+dx[i];
    if(nx < 0 || nx >= X) continue;
    if(fie[nx][y+1]=='1') continue;	 
    if(i==1){
      ret += solve(nx,y+1);
    }else{
      if(fie[nx][y+1]=='2') continue;
      ret += solve(nx,y+1);
    }
  }
  return dp[x][y]=ret;
}
main(){
  while(1){
    cin >> X >> Y;
    if(X==0 && Y==0) break;
    memset(fie,0,sizeof(fie));
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> fie[j][i];
    memset(dp,-1,sizeof(dp));
    int res=0;
    for(int i=0;i<X;i++){
      if(fie[i][0]=='0')
	res += solve(i,0);
      //      cout << solve(i,0) << " " << i << endl;
    }/*
    for(int i=0;i<Y+1;i++){
      for(int j=0;j<X;j++)
	cout << dp[j][i];
      cout << endl;
      }*/
    cout << res << endl;
  }
  
}

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(y <= i+2 || b[i+2][j] != 1) {
						ret[i][j+1] += ret[i-1][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>
#include<algorithm>
using namespace std;

int maps[20][20];
int course[20][20];
int X, Y;

void out();
int way(int y, int x){
  if(course[y][x] > 0) return course[y][x];
  else if(maps[y][x] == 1) return 0;
  else if(y >= Y) return 1;
  else if(maps[y][x] == 2 && maps[y + 2][x] != 1) return course[y][x] = way(y + 2, x);
  else{
    int SUM = 0;
    for(int i = 0; i < 3; i++){
      int ny = y + 1;
      int nx = x - 1 + i;
      if(maps[ny][nx] != 1 && 1 <= nx && nx <= X){
	int flug = 1;
	if(i != 1 && maps[ny][nx] == 2) flug = 0;
	if(flug) SUM += way(ny, nx);
      }
    }
    return course[y][x] = SUM;
  }
} 

int 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];
	course[i][j] = 0;
      }
    }
    int cnt = 0;
    for(int i = 1; i <= X; i++){
      if(maps[0][i] != 1) cnt += way(1, i);
    }
    cout << cnt << endl;
  }
}

void out(){
  for(int i = 1; i <= Y; i++){
    for(int j = 1; j <= X; j++){
      cout << course[i][j] << " ";
    }
    cout << endl;
  }
  return;
}