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 main(){
    int x, y;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0)    break;
    
        int dp[y+2][x];
        char mat[y+2][x];
        for(int i = 0; i < y+2; i++){
            for(int j = 0; j < x; j++){
                dp[i][j] = 0;
                mat[i][j] = '0';
            }
        }

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

        for(int j = 0; j < x; j++){
            if(mat[0][j] == '0')    dp[0][j] = 1;
        }

        for(int i = 0; i < y-1; i++){
            for(int j = 0; j < x; j++){
                if(mat[i][j] == '0'){
                    if(j != 0 && mat[i+1][j-1] == '0')      dp[i+1][j-1] += dp[i][j];
                    if(mat[i+1][j] != '1')                  dp[i+1][j] += dp[i][j];
                    if(j != x-1 && mat[i+1][j+1] == '0')    dp[i+1][j+1] += dp[i][j];
                }else if(mat[i][j] == '1'){
                    // do nothing.
                }else if(mat[i][j] == '2'){
                    dp[i+2][j] += dp[i][j];
                }
            }
        }

        int accum = 0;
        for(int j = 0; j < x; j++)  if(mat[y-1][j] != '1')  accum += dp[y-1][j];
        for(int j = 0; j < x; j++)  accum += dp[y][j];
        cout << accum << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int w,h;cin>>w>>h,w|h;){
		vvi field(h+1,vi(w));
		rep(i,h) rep(j,w)
			cin>>field[i][j];
		
		vvi dp(h+1,vi(w));
		rep(i,w)
			if(field[0][i]==0)
				dp[0][i]=1;
		rep(i,h-1) rep(j,w){
			if(field[i][j]==1)
				dp[i][j]=0;
			else if(field[i][j]==2){
				if(field[i+2][j]!=1)
					dp[i+2][j]+=dp[i][j];
			}
			else{
				if(field[i+1][j]==2)
					dp[i+1][j]+=dp[i][j];
				for(int k=-1;k<=1;k++)
					if(0<=j+k && j+k<w && field[i+1][j+k]==0)
						dp[i+1][j+k]+=dp[i][j];
			}
		}
		ll res=0;
		repi(i,h-1,h+1) rep(j,w)
			if(field[i][j]!='1')
				res+=dp[i][j];
		cout<<res<<endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
    int W, H;


    while ( cin >> W >> H, W || H ) {
        int dp[22][22] = {};
        int mas[22][22] = {};

        for ( int i = 0; i < H; i++ ) {
            for ( int j = 0; j < W; j++ ) {
                cin >> mas[i][j];
            }
        }

        for ( int i = 0; i < W; i++ ) {
            if ( mas[0][i] == 0 ) {
                dp[0][i] = 1;
            }
        }

        for ( int i = 0; i < H - 1; i++ ) {
            for ( int j = 0; j < W; j++ ) {
                if ( mas[i][j] == 2 ) {
                    if ( mas[i + 2][j] != 1 ) {
                        dp[i + 2][j] += dp[i][j];
                    }
                } else {
                    for ( int k = -1; k <= 1; k++ ) {
                        if ( 0 <= j + k && j + k < W ) {
                            if ( mas[i + 1][j + k] == 0 ) {
                                dp[i + 1][j + k] += dp[i][j];
                            } else if ( k == 0 && mas[i + 1][j] == 2 ) {
                                dp[i + 1][j] += dp[i][j];
                            }
                        }
                    }
                }
            }
        }
        int sum = 0;
        for ( int i = 0; i < W; i++ ) {
            sum += dp[H - 1][i] + dp[H][i];
        }

        cout << sum << endl;
    }
    return ( 0 );
}

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++) 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)dp[ny][nx]+= dp[i][j];
	  if(ny >= h-1) ans+=dp[i][j];
	}
    cout << ans <<endl;
  }
  return 0;
}

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

int 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 1:break;
				case 2:suberikata[f + 2][g] += suberikata[f][g]; break;
				}
			}
		}
		int s = 0;
		for (int j : suberikata[suberikata.size() - 2]) {
			s += j;
		}
		cout << s << endl;
	}
}