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

int maps[20][20];
int course[20][20];
int X, Y;

int way(int y, int x){
  if(y >= Y) return 1;
  else if(course[y][x] > 0) return course[y][x];
  else if(maps[y][x] == 1) return 0;
  else if(maps[y][x] == 2) return course[y][x] = way(y + 2, x);
  else{
    int SUM = 0;
    for(int i = 0; i < 3; i++){
      int ny = y + 1;
      int nx = x - 1 + i;
      if(maps[ny][nx] != 1 && 1 <= nx && nx <= X){
	int flug = 1;
	if(i != 1 && maps[ny][nx] == 2) flug = 0;
	if(flug) SUM += way(ny, nx);
      }
    }
    return course[y][x] = SUM;
  }
} 

int main(){
  while(1){
    cin >> X >> Y;
    if(X == 0 && Y == 0) break;
    for(int i = 1; i <= Y; i++){
      for(int j = 1; j <= X; j++){
	cin >> maps[i][j];
	course[i][j] = 0;
      }
    }
    int cnt = 0;
    for(int i = 1; i <= X; i++){
      if(maps[0][i] != 1) cnt += way(1, i);
    }
    cout << cnt << endl;
  }
}

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

int main() {
	int x, y;
	while (cin >> x >> y ,x,y) {
		vector<vector<int>> course(y + 2, vector<int>(x + 2, 0));
		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				cin >> course[i][j];
			}
		}

		vector<vector<int>> path(y + 2, vector<int>(x + 2, 0));
		//?????????????????????????????????1????????????
		for (int i = 1; i <= x; i++) {
			if (course[1][i] != 1) path[1][i] = 1;
		}

		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				//????????????????????´????????????????????´??????????????????????????????????????????
				//?????????????§????????????????????????´?????????????????????????????£????????°?????´????????????????????????
				if (course[i][j] == 0) {
					if (course[i + 1][j + 1] == 0) path[i + 1][j + 1] += path[i][j];
					if (course[i + 1][j] != 1) path[i + 1][j] += path[i][j];
					if (course[i + 1][j - 1] == 0) path[i + 1][j - 1] += path[i][j];
				}
				//?¬???????????????´???????????£????????°????????????????????????????????????
				//?????????????????£????????§??´??????????????´???????????????(?????£?????????????????????????????´???????????????)
				if (course[i][j] == 2 && course[i + 2][j] != 1) {
					if (i + 2 > y) path[y][j] += path[i][j];
					else path[i + 2][j] += path[i][j];
				}
				//???????????´???????????????????????????????????????
				if (course[i][j] == 1) {/*do anything*/ }
			}
		}

		cout << accumulate(path[y].begin() + 1, path[y].end() - 1, 0) << 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++) 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++){
	  if(mp[i][j] !=0) break;
	  int nx=j+k,ny=i+1;
	  if(nx<0||nx>=w) continue;
	  while(k==0&&mp[ny][nx]==2) ny+=2;
	  if(mp[ny][nx]!=0) continue;
	  if(dp[i][j]>0)dp[ny][nx]+= dp[i][j];
	  if(i >= h-1) ans+=dp[i][j];
	}
    cout << ans <<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int field[20][20];
int dp[20][20];

int n, m;

bool isIn(int x, int y){
    return 0 <= x && x < n && 0 <= y && y < m;
}

int main(){
    while(cin >> m >> n, n+m){
        for(int i=0; i < n; i++) for(int j=0; j< m; j++){cin >> field[i][j];}
        for(int i=0; i< 20; i++) for(int j=0; j< 20; j++) dp[i][j] = 0;
        for(int i=0; i < m; i++) dp[0][i] = 1;
        for(int i=0; i < n-1; i++){
            for(int j=0; j < m; j++){
                if(field[i][j] == 0){
                    for(int k=-1; k <= 1; k++){
                        if(isIn(i+1, j+k) && !(k != 0 && field[i+1][j+k] == 2)){
                            dp[i+1][j+k] += dp[i][j];
                        }
                    }
                }
                else if(field[i][j] == 2) dp[i+2][j] += dp[i][j];
            }
        }
        for(int i=0; i< m; i++) if(field[n-1][i] != 1)dp[n][i] += dp[n-1][i];
        long long count = 0;
        for(int i=0; i< m; i++) count += dp[n][i];
        cout << count << endl;
    }
}

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

int main()
{
	int X, Y;

	while( cin >> X >> Y && ( X || Y ) ){
		vector< vector< int > > map( Y + 1, vector< int >( X + 2, 0 ) );
		vector< vector< int > > memo = map;
		for( int i = 1; i < Y + 1; ++i ){
			for( int j = 1; j < X + 1; ++j ){
				cin >> map[ i ][ j ];
			}
		}
		for( int i = 1; i < X + 1; ++i ){
			if( map[ 1 ][ i ] == 0 ){
				memo[ 1 ][ i ] = 1;
			}
		}
		for( int i = 2; i < Y + 1; ++i ){
			for( int j = 1; j < X + 1; ++j ){
				if( map[ i ][ j ] == 1 ) continue;
				if( map[ i ][ j ] == 2 ){
					if( map[ i - 1 ][ j ] == 0 ){
						memo[ i ][ j ] = memo[ i - 1 ][ j ];
					}
				}else{
					for( int k = -1; k < 2; ++k ){
						if( map[ i - 1 ][ j + k ] == 0 ){
							memo[ i ][ j ] += memo[ i - 1 ][ j + k ];
						}
					}
				}
				if( map[ i - 2 ][ j ] == 2 ){
					memo[ i ][ j ] += memo[  i - 2 ][ j ];
				}
			}
		}
		int ans = 0;
		for( int i = 1; i < X + 1; ++i ){
			ans += memo[ Y ][ i ];
			if( map[ Y - 1 ][ i ] == 2 ){
				ans += memo[ Y - 1 ][ i ];
			}
		}
		cout << ans << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int X,Y;
int dp[20][20];
char maps[20][20];
int bun(int x,int y);
int dx[3]={-1,0,1};
main(){
  while(1){
    cin>>X>>Y;
    if(X==0&&Y==0){
      break;
    }
    for(int i=1;i<=Y;i++){
      for(int j=1;j<=X;j++){
	cin>>maps[i][j];
	dp[i][j]=0;
      }
    }
    int ans=0;
    for(int i=1;i<=X;i++){
      if(maps[1][i]!='1'){
	ans+=bun(1,i);
      }
    }
    cout<<ans<<endl;
  }
}
int bun(int y,int x){
  if(y>=Y){
    return 1;
  }
  else if(dp[y][x]!=0){
    return dp[y][x];
  }
  else if(maps[y][x]=='2'&&maps[y+2][x]!='1'){
    return bun(y+2,x);
  }
  else if(maps[y][x]=='1'){
    return 0;
  }
  else{
    int anss=0;
    for(int i=0;i<3;i++){
      int nx=x+dx[i];
      if(i!=1){
	if(nx>0&&nx<=X&&maps[y+1][nx]=='0'){
	  anss+=bun(y+1,nx);
	}
      }
      else{
	if(maps[y+1][nx]!='1'){
	  anss+=bun(y+1,nx);
	}
      }
    }
    return dp[y][x]=anss;
  }	  	  
}