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 <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	int w, h;
	while(scanf("%d%d", &w, &h), w){
		vvi field(h+1, vi(w, 0));
		rep(i, h) rep(j, w)
			scanf("%d", &field[i][j]);
		
		vvi dp(h+1, vi(w));
		rep(i, w)
			dp[0][i] = field[0][i] == 0;
		
		reep(i, 1, h+1){
			rep(j, w){
				if(field[i][j] == 1){
					dp[i][j] = 0;
				}
				else{
					if(i<h){
						const int dx[] = {-1, 0, 1};
						rep(k, 3){
							int px = j + dx[k];
							if(px<0 || w<=px || field[i-1][px] != 0 || (field[i][j]==2 && dx[k]!=0))
								continue;
							dp[i][j] += dp[i-1][px];
						}
					}
					if(i>=2 && field[i-2][j] == 2)
						dp[i][j] += dp[i-2][j];
				}
			}
		}

		int sum = 0;
		rep(i, 2) rep(j, w)
			sum += dp[h-i][j];
		printf("%d\n", sum);
	}
	return 0;
}

C++: #include<iostream>
#include<string>

using namespace std;

int main(){
  int x, y, course[50][50], route[52][52], i, j, sum;
  while(cin >> x >> y, x+y){
    sum = 0;
    for(i=0; i<52; i++){
      for(j=0; j<52; j++){
        route[i][j] = 0;
      }
    }
    for(i=0; i<y; i++){
      for(j=0; j<x; j++){
        cin >> course[i][j];
      }
    }
    for(i=0; i<y; i++){
      for(j=0; j<x; j++){
	if(i==0){
          if(course[i][j]==0){
            route[i][j] = 1;
          }else{
	    route[i][j] = 0;
          }
        }else{
          if(j==0){
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j+1]==0){
                route[i][j] += route[i-1][j+1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
	        route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
            }
          }else if(j==x-1){
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j-1]==0){
                route[i][j] += route[i-1][j-1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
	        route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
            }
          }else{
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j-1]==0){
                route[i][j] += route[i-1][j-1];
              }
              if(course[i-1][j+1]==0){
                route[i][j] += route[i-1][j+1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
                route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
              if(course[i-2][j]==2){
                route[i][j] = route[i-2][j];
                route[i+2][j] += route[i][j];
              }
            }
          }
        }
      }
    }
    for(i=0; i<x; i++){
      if(course[y-1][i]==0){
	route[y][i] += route[y-1][i];
      }
    }

    for(i=y; i<y+2; i++){
      for(j=0; j<x; j++){
        sum+=route[i][j];
      }
    }
    cout << sum << endl;
  }
  return 0;
}

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+2][N];
int main(){
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y+2;i++)
      for(int j=0;j<X;j++) data[i][j]=0,memo[i][j]=0;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j];
    for(int i=0;i<X;i++)
      if(data[0][i]!=1)	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]=memo[Y][x]=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!=-1){
      if(memo[r][x]==0) func(r,x);
      memo[y][x]+=memo[r][x];
    }else data[y+1][x]=1;
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(data[y][x]==1) break;
    if(data[y][x]==0||y>=Y-1) return y;
  }
  return -1;
}

C++: // AOJ 0203
#include<iostream>
#include<cstring>

int X, Y;
int field[16][15];
int dp[16][15];

int main()
{
	while( std::cin >> X >> Y, X | Y )
	{
		memset( field, 0, sizeof( field ) );
		memset( dp, 0, sizeof( dp ) );

		for( int i = 0; i != Y; ++i )
			for( int j = 0; j != X; ++j )
				std::cin >> field[i][j];

		for( int i = 0; i != X; ++i )
			if( field[0][i] != 1 )
				dp[0][i] = 1;
		
		int ans = 0;
		for( int i = 1; i <= Y; ++i )
		{
			for( int j = 0; j != X; ++j )
			{
				if( i < Y && field[i][j] != 1 )
				{
					for( int k = -1; k <= 1; ++k )
					{	
						if( field[i][j] == 2 && k )
							continue;

						if( j + k >= 0 && j + k < X && !field[i-1][j+k] )
							dp[i][j] += dp[i-1][j+k];
					}
				}

				if( i - 2 >= 0 && field[i][j] != 1 && field[i-2][j] == 2 )
					dp[i][j] += dp[i-2][j];

				if( i >= Y - 1 )
					ans += dp[i][j];
			}
		}

		std::cout << ans << std::endl;
	}

	return 0;
}