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 <vector>
using namespace std;

int main()
{
  int X, Y;
  while (cin >> X >> Y) {
    if ((X|Y) == 0)
      break;

    vector<vector<int> > cource(Y, vector<int>(X));
    for (int i = 0; i < Y; ++i) {
      for (int j = 0; j < X; ++j)
	cin >> cource[i][j];
    }

    vector<vector<int> > dp(Y, vector<int>(X, 0));
    for (int i = 0; i < X; ++i) {
      if (cource[0][i] == 0)
	dp[0][i] = 1;
    }

    int out = 0;
    for (int i = 0; i < Y-1; ++i) {
      for (int j = 0; j < X; ++j) {
	if (cource[i][j] == 0) {
	  dp[i+1][j] += dp[i][j];
	  if (j > 0 && cource[i+1][j-1] == 0)
	    dp[i+1][j-1] += dp[i][j];
	  if (j < X-1 && cource[i+1][j+1] == 0)
	    dp[i+1][j+1]+= dp[i][j];

	} else if (cource[i][j] == 2) {
	  if (i+2 < Y)
	    dp[i+2][j] += dp[i][j];
	  else
	    out += dp[i][j];
	}
      }
    }

    int ans = 0;
    for (int i = 0; i < X; ++i) {
      if (cource[Y-1][i] == 0)
	ans += dp[Y-1][i];
    }
    cout << ans+out << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int H,W,ans;
int t[20][20];
int u[20][20];

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 j=0;j<=W+1;j++){
      ans+=u[H][j];
      ans+=u[H+1][j];
    }
    
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int dp[16][15];
int h,w;
int map[16][15];
main()
{
	while(cin>>w>>h,w)
	{
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				cin>>map[i][j];
			}
		}
		for(int i=0;i<=h;i++)for(int j=0;j<w;j++)dp[i][j]=0;
		for(int i=0;i<w;i++)dp[0][i]=map[0][i]==0;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if(dp[i][j]==0||map[i][j]==1)continue;
				if(map[i][j]==2)
				{
					dp[i+2<=h?i+2:h][j]+=dp[i][j];
					continue;
				}
				if(i<h-1&&j>0)
				{
					if(map[i+1][j-1]==0)dp[i+1][j-1]+=dp[i][j];
				}
				if(i<h-1&&j<w-1)
				{
					if(map[i+1][j+1]==0)dp[i+1][j+1]+=dp[i][j];
				}
				if(map[i+1][j]!=1)dp[i+1][j]+=dp[i][j];
			}
		}
		int ans=0;
		for(int j=0;j<w;j++)ans+=dp[h][j];
		cout<<ans<<endl;
	}
}

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 x = 0; x < a; x++) {
			s += suberikata[b][x]; 
		}
		cout << s << 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&&data[y][x]==1) break;
    if(y>=Y-1) return -2;
    if(data[y][x]==0) return y;
  }
  return -1;
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char const* argv[])
{
	int x,y;
	int stage[17][17][2];

	while( cin >> x >> y && x != 0 && y != 0 ){
		for( int i = 0;i < 17;i++ ){
			for( int j = 0;j < 17;j++ ){
				stage[i][j][0] = stage[i][j][1] = 0;
			}
		}
		
		
		for( int i = 1;i <= y;i++ ){
			for( int j = 1;j <= x;j++ ){
				cin >> stage[j][i][0];
			}
		}

		for( int i = 0;i < 17;i++ ) if(stage[i][1][0] != 1 ) stage[i][1][1] = 1;

		for( int j = 1;j < y;j++ ){
			for( int i = 1;i <= x;i++ ){
				if( stage[i][j][0] == 1 ) continue;
				if( stage[i][j][0] == 0 ){
					if( stage[i][j + 1][0] != 1 ) stage[i][j + 1][1] += stage[i][j][1];
					
					if( stage[i + 1][j + 1][0] == 0 ) stage[i + 1][j + 1][1] += stage[i][j][1];
					if( stage[i - 1][j + 1][0] == 0 ) stage[i - 1][j + 1][1] += stage[i][j][1];

				}
				if( stage[i][j][0] == 2 ){
					stage[i][j + 2][1] = stage[i][j][1];
				}
			}
		}
		int count = 0;
		for( int i = 1;i <= x;i++ ){
			count += stage[i][y+1][1] + stage[i][y][1];
		}
		cout << count << endl;
	}
	return 0;
}