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<stdio.h>
int n,m;
int i,j;
int c[15][15],d[15][15];

int main(){
	while(1){
		scanf("%d %d",&m,&n);
		if(n==0&&m==0)return 0;
		int ans=0;
		for(i=0;i<n;i++)for(j=0;j<m;j++)scanf("%d",&c[i][j]);
		for(i=0;i<n;i++)for(j=0;j<m;j++){
			d[i][j]=0;
		}
		for(i=0;i<m;i++)if(c[0][i]!=1)d[0][i]=1;
		for(i=0;i<n;i++)for(j=0;j<m;j++){
			if(c[i][j]==0){
				if(j-1>=0&&j-1<m&&i+1<n&&c[i+1][j-1]==0)d[i+1][j-1]+=d[i][j];
				if(j+1>=0&&j+1<m&&i+1<n&&c[i+1][j+1]==0)d[i+1][j+1]+=d[i][j];
				if(i+1<n&&c[i+1][j]!=1)d[i+1][j]+=d[i][j];
			}
			if(c[i][j]==2){
				if(i+2<n&&c[i+2][j]!=1)d[i+2][j]+=d[i][j];
			}
		}
		for(i=0;i<m;i++)if(c[n-2][i]==2)ans+=d[n-2][i];
		for(i=0;i<m;i++)if(c[n-1][i]!=1)ans+=d[n-1][i];
		printf("%d\n",ans);
	}
}

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

using namespace std;
 
int main(void)
{
    int w, h;
    while (cin >> w >> h, w){
        int field[32][32] = {};
        for (int y = 1; y <= h; y++){
            for (int x = 1; x <= w; x++){
                cin >> field[y][x];
            }
        }
        int dp[32][32];
        memset(dp, 0, sizeof(dp));

        for (int x = 1; x <= w; x++){
            if (field[1][x] == 0){
                dp[1][x] = 1;
            }
        }
        for (int y = 1; y <= h; y++){
            for (int x = 1; x <= w; x++){
                if (field[y][x] == 1){
                    continue;
                }
                if (field[y][x] == 2){
                    dp[y + 2][x] += dp[y][x];
                    continue;
                }
                if (field[y + 1][x - 1] == 0){
                    dp[y + 1][x - 1] += dp[y][x];
                }
                if (field[y + 1][x] != 1){
                    dp[y + 1][x] += dp[y][x];
                }
                if (field[y + 1][x + 1] == 0){
                    dp[y + 1][x + 1] += dp[y][x];
                }
            }
        }
 
        int ret = 0;
        for (int y = h - 1; y <= h; y++){
            for (int x = 1; x <= w; x++){
                if (y == h - 1){
                    if (field[y][x] == 2) ret += dp[y][x];
                    continue;
                }
                else {
                    ret += dp[y][x];
                }
            }
        }
        cout << ret << endl;
    }
 
    return 0;
}

C++: #include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int m[500][500];
int dp[500][500];

int dx[]={-1,0,1};

int solve(int r,int c){
  rep(i,r+2)rep(j,c)dp[i][j]=0;
  rep(j,c)if(m[0][j] == 0)dp[0][j]=1;

  rep(i,r){
    rep(j,c){
      if (m[i][j] == 0 && i != r-1){
	rep(k,3){
	  int nex = j+dx[k];
	  if (nex<0||nex>=c)continue;
	  if (m[i+1][nex] == 0)dp[i+1][nex]+=dp[i][j];
	  else if (m[i+1][nex] == 2 && k == 1)dp[i+1][nex]+=dp[i][j];
	}
      }else if (m[i][j] == 2 ){
	dp[i+2][j]+=dp[i][j];
      }
    }
  }
  
  int ans = 0;
  rep(j,c)ans+=dp[r][j]+dp[r-1][j]+dp[r+1][j];
  return ans;
}

main(){
  int c,r;
  while(cin>>c>>r && r){
    rep(i,r)rep(j,c)cin>>m[i][j];
    rep(j,c)m[r][j]=m[r+1][j]=0;
    cout << solve(r,c) << endl;
  }
}

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 = 0;i < 17;i++ ) if(stage[i][1][0] != 1 ) stage[i][1][1] = 1;
		
		for( int i = 1;i <= y;i++ ){
			for( int j = 1;j <= x;j++ ){
				cin >> stage[j][i][0];
			}
		}

		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 ){
					stage[i][j + 1][1] += stage[i][j][1];
					
					if( stage[i + 1][j + 1][0] == 0 && j != y ) stage[i + 1][j + 1][1] += stage[i][j][1];
					if( stage[i - 1][j + 1][0] == 0 && j != y ) 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];
		}
		cout << count << endl;
	}
	return 0;
}

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

using namespace std;

int field[16][16];
// y,xÌ}X©çènßÄÅ«é·×èûÌ
int dp[16][16];

const int dy[]={1,1,1};
const int dx[]={-1,0,1};
int w,h;

int search(int sx,int sy){
	if(field[sy][sx]==2){
		if(sy>=h-2){
			return 1;
		}
		else if(field[sy+2][sx]==1)
			return 0;
		else{
			return search(sx,sy+2);
		}
	}
	if(dp[sy][sx]!=-1){
		return dp[sy][sx];
	}
	int cnt=0;

	if(sy!=h-1){
		for(int i = 0; i < 3; i++){
			int nx=sx+dx[i];
			int ny=sy+dy[i];
			if(nx>=0&&nx<w){
				if(ny>h-1){
					cnt++;
				}
				else if(ny==h-1&&field[ny][nx]==0){
					cnt++;
				}
				else if(field[ny][nx]==2&&dx[i]==0){
					cnt+=search(nx,ny);
				}
				else if(field[ny][nx]==0){
					cnt+=search(nx,ny);
				}
			}
		}
	}
	else{
		if(field[sy][sx]==0)
			cnt++;
	}

	dp[sy][sx]=cnt;
	return dp[sy][sx];
}


int main(){

	while(cin>>w>>h&&!(w==0&&h==0)){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin>>field[i][j];
				dp[i][j]=-1;
			}
		}
		int sum=0;
		for(int i = 0; i < w; i++){
			if(field[0][i]==0)
				sum+=search(i,0);
		}
		cout<<sum<<endl;
	}

	return 0;
}