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>
using namespace std;
typedef long long ll;
int H,W;
int t[20][20];
ll u[20][20],ans;

bool inField(int x){
  if(1<=x&&x<=W)return true;
  return false;
}

int main(){
  while(cin>>W>>H){
    if(H==0&&W==0)break;
    for(int i=0;i<20;i++)for(int j=0;j<20;j++)u[i][j]=0;
    for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)cin>>t[i][j];

    for(int i=0;i<20;i++)u[1][i]=(t[1][i]==1?0:1);

    for(int i=1;i<H;i++){
      for(int j=1;j<=W;j++){
	if(t[i][j]==1)u[i][j]=0;
	if(u[i][j]==0)continue;
	if(t[i][j]==2){
	  u[i+2][j]+=u[i][j];
	  continue;
	}
	for(int k=-1;k<=1;k++){
	  if(!inField(j+k))continue;
	  if(t[i+1][j+k]==0){
	    u[i+1][j+k]+=u[i][j];
	  }else if(t[i+1][j+k]==2&&k==0){
	    u[i+1][j+k]+=u[i][j];
	  }
	}
      }//j
    }//i
    ans=0;
    for(int i=H;i<20;i++){
      for(int j=1;j<=W;j++){
	if(t[i][j]==1)continue;
	ans+=u[i][j];
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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(y<=Y-1&&data[y][x]==1) break;
    if(y>=Y-1) return -2;
    if(data[y][x]==0) return y;
  }
  return -1;
}

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

int main() {
	int s,i,j,x,y,c[15][15],d[17][15];
	while(cin >> x >> y) {
		if (x+y==0) break;
		for (i=0;i<y;i++) for (j=0;j<x;j++) cin >> c[i][j];
		for (i=1;i<y+2;i++) for (j=0;j<x;j++) d[i][j]=0;
		for (j=0;j<x;j++) d[0][j]=1;
		for (i=0;i<y-1;i++) for (j=0;j<x;j++) {
			s=d[i][j];
			if (c[i][j]==0) { 
				if (j>0) if (c[i+1][j-1]==0) d[i+1][j-1]+=s;
				if (j<x-1) if (c[i+1][j+1]==0) d[i+1][j+1]+=s;
				if (c[i+1][j]!=1) d[i+1][j]+=s;
			}
			if (c[i][j]==2 && c[i+2][j]!=1) d[i+2][j]+=s;
		}
		s=0;
		for (i=y-1;i<=y;i++) for (j=0;j<x;j++) s+=d[i][j];
		cout << s << endl; 
	 }
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int X, Y;
  while (cin >> X >> Y, X) {
    int c[20][20];
    int dp[20][20] = {};
    for (int i = 0; i < Y; i++) {
      for (int j = 0; j < X; j++) {
        cin >> c[i][j];
      }
    }
    for (int i = 0; i < X; i++) {
      if (c[0][i] == 0) dp[0][i] = 1;
    }
    for (int i = 0; i < Y - 1; i++) {
      for (int j = 0; j < X; j++) {
        if (c[i][j] == 0) {
          if (j > 0 && c[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
          if (c[i + 1][j] != 1) dp[i + 1][j] += dp[i][j];
          if (j + 1 < X && c[i + 1][j + 1] == 0) dp[i + 1][j + 1] += dp[i][j];
        } else if (c[i][j] == 2 && i + 2 < Y) {
          if (c[i + 2][j] != 1) dp[i + 2][j] += dp[i][j];
        }
      }
    }
    int ans = 0;
    for (int i = 0; i < X; i++) {
      if (c[Y - 2][i] == 2) ans += dp[Y - 2][i];
      ans += dp[Y - 1][i];
    }
    cout << ans << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int course[16][17][2];
int main()
{
  for(;;){
    int H,W;
    cin >> W >> H;
    if(H==0||W==0) break;
    memset(course,0,sizeof(course));
    for(int h=1; h<=H; h++){
      for(int w=1; w<=W; w++){
        cin >> course[h][w][0];
      }
    }
    for(int w=1; w<=W; w++){
      if(course[1][w][0] == 1) course[1][w][1] = 0;
      else course[1][w][1] = 1;
    }
    for(int h=2; h<=H; h++){
      for(int w=1; w<=W; w++){
        if(course[h][w][0] == 1){
          course[h][w][1] = 0;
        }else if(course[h][w][0] == 2){
          course[h][w][1] = course[h-1][w][1];
          if(course[h-2][w][0] == 2){
            course[h][w][1] += course[h-2][w][1];
          }
        }else {
          for(int i=-1; i<=1; i++){
            if(course[h-1][w+i][0] != 2){
              course[h][w][1] += course[h-1][w+i][1];
            }
          }
          if(course[h-2][w][0] == 2){
            course[h][w][1] += course[h-2][w][1];
          }
        }
      }
    }
    long long sum = 0;
    for(int w=1; w<=W; w++){
      sum += course[H][w][1];
      if(course[H-1][w][0] == 2){
        sum += course[H-1][w][1];
      }
    }
    cout << sum << endl;
  }
  return 0;
}

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

#define MAX_XY 16

int X, Y;
int field[MAX_XY][MAX_XY];
int way[MAX_XY][MAX_XY];

int main() {
	while (cin >> X >> Y, X || Y) {
		memset(field, 0, sizeof(field));
		memset(way, 0, sizeof(way));
		for (int i = 0; i < X; i++) {
			cin >> field[0][i];
			if (field[0][i] == 1) {
				way[0][i] = 0;
			} else {
				way[0][i] = 1;
			}
		}

		for (int i = 1; i < Y; i++) {
			for (int j = 0; j < X; j++) {
				cin >> field[i][j];
			}
		}

		for (int i = 0; i < Y-1; i++) {
			for (int j = 0; j < X; j++) {
				if (field[i][j] == 2) {
				   	if (field[i+2][j] != 1) {
						way[i+2][j] += way[i][j];
					}
				} else {
					if (1 <= j && field[i+1][j-1] == 0) {
						way[i+1][j-1] += way[i][j];
					}
					if (j < X-1 && field[i+1][j+1] == 0) {
						way[i+1][j+1] += way[i][j];
					}
					if (field[i+1][j] != 1) {
						way[i+1][j] += way[i][j];
					}
				}
			}
		}

//		for (int i = 0; i < Y; i++) {
//			for (int j = 0; j < X; j++) {
//				cout << way[i][j] << ' ';
//			}
//			cout << endl;
//		}

		int cnt = 0;
		for (int i = 0; i < X; i++) {
			cnt += way[Y-1][i];
		}
		for (int i = 0; i < X; i++) {
			if (field[Y-2][i] == 2) cnt += way[Y-2][i];
		}

		cout << cnt << endl;

	}
	return 0;
}