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 <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={-1,0,1};
int X,Y;
int board[20][20];
int cnt;
void dfs(int y,int x){
	while(board[y][x]==2){
		y+=2;
		if(board[y][x]==1){
			return;
		}

	}
	if(board[y][x]==1)return;
	if(y>=Y){
		cnt++;
		//printf("(y,x) =(%d,%d)\n",y,x);
		return;
	}
	
	//cout <<"y = "<<y <<" x = "<<x<<endl;
	for(int i =0; i<3;i++){
		int nx =x +dx[i];
		int ny =y +1;
		if(nx <1||nx>X)continue;
		if(i!=1&&board[ny][nx]==2)continue;
		if(board[ny][nx]==1)continue;
		if(board[ny][nx]==0||board[ny][nx]==2){
			dfs(ny,nx);
		}
	}
	return;
}

int main(){
	while(cin>>X>>Y,X||Y){
		cnt =0;
		rep(i,20)rep(j,20)board[i][j]=0;
		for(int i=1;i <=Y;i++){
			for(int j =1;j <=X;j++){
				cin>>board[i][j];
			}
		}
		for(int i =1;i <=X;i++){
			if(board[1][i]==0){
				dfs(1,i);
			}
			//cout <<endl;
		}
		cout <<cnt<<endl;
	}
	
}

C++: #include <iostream>
using namespace std;
int main(){
  while(1){
    int w,h,mp[20][20]={},dp[20][20] ={};
    cin >> w >> h;
    if(w==0 && h==0) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin >> mp[i][j];
    for(int i=0;i<w;i++) if(mp[0][i]==0) dp[0][i] = 1;
    int ans=0;    
    for(int i=0;i<h-1;i++)
      for(int j=0;j<w;j++) 
	for(int k=-1;k<=1;k++){
	  int nx=j+k,ny=i+1;
	  if(nx<0||nx>=w || mp[i][j] !=0) continue;
	  while(k==0&&mp[ny][nx]==2) ny+=2;
	  if(mp[ny][nx]!=0) continue;
	  dp[ny][nx]+= dp[i][j];
	  if(ny >= h-1) ans+=dp[i][j];
	}
    /*
      cout << endl;
      for(int i=0;i<h+3;i++){
      for(int j=0;j<w;j++)cout << dp[i][j] <<" ";
      cout << endl;
      }
    */
    cout << ans <<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);

    ans=0;
    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];
	  if(i+2>=H)ans+=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];
	    if(i+1>=H)ans+=u[i][j];
	  }else if(t[i+1][j+k]==2&&k==0){
	    u[i+1][j+k]+=u[i][j];
	    if(i+1>=H)ans+=u[i][j];
	  }
	}
      }//j
    }//i
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class point {
public:
	long long num;
	int block;
	point() :num(0), block(1) {}
};
int main() {
	int X, Y;
	while (cin >> X >> Y&&X != 0) {
		vector<vector<point> > map(X + 2, vector<point>(Y + 2));
		for (int y = 1; y <= Y; ++y) {
			for (int x = 1; x <= X; ++x) {
				cin >> map[x][y].block;
			}
		}
		for (int i = 1; i <= X; ++i) {
			map[i][1].num = 1;
		}
		for (int y = 1; y < Y; ++y) {
			for (int x = 1; x <= X; ++x) {
				if (map[x][y].block == 0) {
					for (int k = -1; k <= 1; ++k) {
						if (map[x + k][y + 1].block == 0 || (map[x + k][y + 1].block == 2 && k == 0) ) {
							map[x + k][y + 1].num += map[x][y].num;
						}
					}
				}
				else if (map[x][y].block == 2) {
					if (y + 2 > Y)map[x][Y].num += map[x][y].num;
					else if (map[x][y + 2].block == 0) {
						map[x][y + 2].num += map[x][y].num;
					}
				}
			}
		}
		long long ans = 0;
		for (int i = 1; i <= X; ++i) {
			ans += map[i][Y].num;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
int dx[] = {-1,0,1};

void saiki(int x,int y) {
  if(y >= h-1) memo[y][x]++;
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = x+dx[i], ny = y+1;
      if(nx==x && mp[ny][nx] == 2)while(mp[ny][nx] == 2) ny+=2;
      if(nx <0|| nx >= w ||mp[ny][nx] == 1) continue;

      if(mp[ny][nx] == 0){
	saiki(nx,ny);
	memo[y][x] += memo[ny][nx];
      }
    }
    if(memo[y][x] == 0) mp[y][x] = 1;
  }
}
  
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i=0;i<=19;i++)
      for(int j=0;j<=19;j++)memo[i][j] = mp[i][j] = 0;
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> mp[i][j];
 
    for(int i=0;i<w;i++) 
      if(mp[0][i] !=1) saiki(i,0);
    
    int cnt = 0;
    for(int i=0;i<w;i++)
      if(memo[0][i] > 0) cnt+=memo[0][i];
    cout <<cnt<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[20][20],f,j,i,k;
	long long int g,h[20][20];
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		for(i=0;i<s;i++) h[0][i]=1;
		for(i=0;i<a;i++){
			for(j=0;j<s;j++) scanf("%d",&d[i][j]);
		}
		for(i=0;i<s;i++){
			if(d[0][i]==1) h[0][i]=0;
		}
		for(i=1;i<a;i++){
			for(j=0;j<s;j++) h[i][j]=0;
		}
		for(i=0;i<a-1;i++){
			for(j=0;j<s;j++){
				if(i!=0&&d[i][j]==2){
					if(i+2<a){
						if(d[i+2][j]!=1) h[i+2][j]+=h[i][j];
					}
					else h[i+1][j]+=h[i][j];
				}
				if(d[i][j]==0){
					if(j!=0) if(d[i+1][j-1]==0) h[i+1][j-1]+=h[i][j];
					if(j!=s){
						if(d[i+1][j+1]==0) h[i+1][j+1]+=h[i][j];
						if(d[i+1][j]==0||d[i+1][j]==2) h[i+1][j]+=h[i][j];
					}
				}
			}
		}
		g=0;
		for(j=0;j<s;j++) g+=h[a-1][j];
		printf("\n\n");
		for(i=0;i<a;i++){
			for(j=0;j<s;j++) printf("%7d ",h[i][j]);
			printf("\n");
		}
		printf("%d\n",g);
	}
	return 0;
}