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;
int solve(int x,int y);
int ax,ay;
int mas[20][20];
int memo[20][20];
int main(){
  while(1){
    int ans=0;
    for(int i=0;i<20;i++){
      for(int j=0;j<20;j++){
	memo[i][j]=0;
      }
    }
    cin>>ax>>ay;
    if(ax==0 && ay==0){
      break;
    }
    for(int i=0;i<ay;i++){
      for(int j=0;j<ax;j++){
	cin>>mas[i][j];
      }
    }
    for(int i=0;i<ax;i++){
      if(mas[0][i]!=1){
	ans+=solve(i,0);
      }
    }
    cout<<ans<<endl;
  }
}
int solve(int x,int y){
  if(memo[y][x]!=0){
    return memo[y][x];
  }
  else if(y==ay){
    return 1;
  }else if(mas[y][x]==1){
    return 0;
  }else if(mas[y][x]==2){
    return solve(x,y+2);
  } 
  else{
    int anss=0; 
    if(mas[y+1][x]!=1){
      memo[y+1][x]=solve(x,y+1);
      anss+=memo[y+1][x];
    }
    if(x+1<ax && mas[y+1][x+1]==0 && y+1!=ay){
      memo[y+1][x+1]=solve(x+1,y+1);
      anss+=memo[y+1][x+1];
    }
    if(0<=x-1 && mas[y+1][x-1]==0 && y+1!=ay){
      memo[y+1][x-1]=solve(x-1,y+1);
      anss+=memo[y+1][x-1];
    }
    return anss;
  }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(void){
  int x,y;
  int m[20][20];
  for( ; ; ){
    cin >> x >> y;
    if(!x && !y) break;

    memset(m,0,sizeof(m));

    for(int i = 0;i < y; i++)
      for(int j = 0;j < x; j++) cin >> m[i][j];

    long long dp[20][20] = {0};
    long long ans = 0;

    for(int i = 0;i < y; i++){
      for(int j = 0;j < x; j++){
	if(i == 0){
	  if(m[i][j] == 0) dp[i][j] = 1;
	}
	if(m[i][j] == 2 && m[i+2][j] != 1) dp[i+2][j] += dp[i][j];
	else if(!m[i][j] && !j){
	  dp[i+1][j] += dp[i][j];
	  if(!m[i+1][j+1]) dp[i+1][j+1] += dp[i][j];
	}
	else if(!m[i][j] && j == x-1){
	  dp[i+1][j] += dp[i][j];
	  if(!m[i+1][j-1]) dp[i+1][j-1] += dp[i][j];
	}
	else if(!m[i][j]){
	  if(!m[i+1][j-1]) dp[i+1][j-1] += dp[i][j];
	  dp[i+1][j] += dp[i][j];
	  if(!m[i+1][j+1]) dp[i+1][j+1] += dp[i][j];
	}
      }
    }

    for(int i = 0;i < x; i++){
      if(m[y-2][i] == 2) ans += dp[y-2][i];
      if(m[y-1][i] != 1) ans += dp[y-1][i];
    }

    cout << ans << endl;
  }
}

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

int DP[18][17];
int field[18][17];
int x,y;

int main(){
	while(true){
		cin >> x >> y;
		if(!x && !y)
			return 0;
		
		for(int i=1; i<=y; i++)
			for(int k=1; k<=x; k++)
				cin >> field[i][k];
		for(int i=1; i<=x; i++){
			field[y+1][i] = 0;
			field[y+2][i] = 0;
		}
		
		for(int i=1; i<=y+2; i++)
			for(int k=0; k<=x+1; k++){
				DP[i][k]=0;
				if(i==1 && k>0 && k<=x)
					if(field[i][k] == 0)
						DP[i][k] = 1;
			}
		
		for(int i=2; i<=y; i++){
			for(int k=1; k<=x; k++){
				if(field[i][k] == 0)
					DP[i][k] += DP[i-1][k-1] + DP[i-1][k] + DP[i-1][k+1];
				else if(field[i][k] == 2){
					int n = i+2;
					while(true){
						if(field[n][k] == 0){
							DP[n][k] += DP[i-1][k];
							break;
						}else if(field[n][k] == 1)
							break;
						else
							n+=2;
					}
				}
			}
		}
		
		int ans=0;
		for(int i=y; i<=y+2; i++)
			for(int k=1; k<=x; k++)
				ans += DP[i][k];
		cout << ans << endl;
	}
}

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