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>
const int X=20;
const int Y=20;
int main(){
    int n,m,k;
long long int dp[X][Y],s[X][Y],ans;
    while(true){
        scanf("%d%d",&n,&m);
        if(n==0&&m==0)return 0;
        ans=0;
        for(int i=0;i<n+2;i++)for(int j=0;j<m;j++)dp[i][j]=s[i][j]=0;
        for(int i=0;i<m;i++)dp[0][i]=1;
        for(int i=0;i<n;i++)for(int j=0;j<m;j++){
            scanf("%d",&k);
            if(k==0){
                dp[i][j]+=s[i][j];
                if(i==n-1)continue;
                dp[i+1][j]+=dp[i][j];
                if(j!=0)s[i+1][j-1]+=dp[i][j];
                if(j!=m-1)s[i+1][j+1]+=dp[i][j];
            }
            else if(k==2){
                s[i][j]=0;
                dp[i+2][j]+=dp[i][j];
            }
            else dp[i][j]=0;
        }
        for(int i=0;i<m;i++)ans+=dp[n][i]+dp[n-1][i];
        printf("%lld\n",ans);
    }
}

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

int main(){
	while(1){
		int X, Y, c;
		vector<vector<int> > grid, count;
	
		cin>>X>>Y;
		if((X == 0) && (Y == 0))
			break;

		grid.resize(X+2);
		for(int i=0;i<X+2;i++)
			grid[i].resize(Y+2);

		for(int j=0;j<Y+2;j++){
			for(int i=0;i<X+2;i++){
				if((i == 0) || (i == X+1) || (j == 0) || (j == Y+1)){
					grid[i][j] = 1;
				}else{
					cin>>c;
					grid[i][j] = c;
				}
			}
		}

		count.resize(X+2);
		for(int i=0;i<X+2;i++)
			count[i].resize(Y+2);

		for(int i=0;i<X+2;i++)
			for(int j=0;j<Y+2;j++)
				count[i][j] = 0;

		for(int i=1;i<=X;i++)
			if(grid[i][1] == 0)
				count[i][1]++;

		for(int j=2;j<=Y;j++){
			for(int i=1;i<=X;i++){
				if(grid[i][j] == 1){
					continue;
				}else if(grid[i][j] == 2){
					if(grid[i][j-1] != 2)
						count[i][j] += count[i][j-1];
					if(grid[i][j-2] == 2)
						count[i][j] += count[i][j-2];
				}else{
					for(int k=-1;k<=1;k++)
						if(grid[i+k][j-1] != 2)
							count[i][j] += count[i+k][j-1];
					if(grid[i][j-2] == 2)
						count[i][j] += count[i][j-2];
				}
			}
		}

		int ans = 0;
		for(int i=1;i<=X;i++){
			ans += count[i][Y];
			if(grid[i][Y-1] == 2)
				ans += count[i][Y-1];
		}
		
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int solve(int x,int y);
int ax,ay;
int mas[20][20];
int memo[20][20];
int main(){
  while(1){
    int ans=0;
    cin>>ax>>ay;
    if(ax==0 && ay==0) break;
    for(int i=1;i<=ay;i++){
      for(int j=1;j<=ax;j++){
	cin>>mas[i][j];
	memo[i][j]=0;
      }
    }
    for(int i=1;i<=ax;i++){
      if(mas[1][i]!=1){
	ans+=solve(i,1);
      }
    }
    cout<<ans<<endl;
  }
}
int solve(int x,int y){
  if(y>=ay){
    return 1;
  }else if(memo[y][x]!=0){
    return memo[y][x];
  }else if(mas[y][x]==2){
    if(mas[y+2][x]!=1){
      return memo[y][x]=solve(x,y+2);
    } 
    else{
      return 0;
    }
  }
  else if(mas[y][x]==1){
    return 0;
  }
  else{
    int anss=0; 
    if(mas[y+1][x]!=1){
      anss+=solve(x,y+1);
    }
    if(x+1<=ax && 0<x+1 && mas[y+1][x+1]==0){
      anss+=solve(x+1,y+1);
    }
    if(0<x-1 && x-1<=ax && mas[y+1][x-1]==0){
      anss+=solve(x-1,y+1);
    }
    return memo[y][x]=anss;
  }
}

C++: #include<iostream>

using namespace std;

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

int main() {
  while (true) {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    int c[20][20];
    rep (i, y) rep (j, x) cin >> c[i][j];
    long long dp[20][20][3] = {};
    rep (i, x) if (c[0][i] == 0) dp[0][i][1] = 1;
    rep (i, y - 1) rep (j, x) {
      if (c[i][j] == 0) {
	long long sum = dp[i][j][0] + dp[i][j][1] + dp[i][j][2];
	if (j > 0) dp[i + 1][j - 1][0] += sum;
	dp[i + 1][j][1] += sum;
	dp[i + 1][j + 1][2] += sum;
      } else if (c[i][j] == 2) {
	dp[i + 2][j][1] += dp[i][j][1];
      }
    }
    long long res = 0;
    rep (i, x) if (c[y - 1][i] != 1) rep (k, 3) res += dp[y - 1][i][k];
    rep (i, x) res += dp[y][i][1];
    cout << res << endl;
  }
  return 0;
}

C++: #include<stdio.h>

int main(void){
	int X,Y;
	
	while(scanf("%d%d", &X, &Y) && X && Y){
		int masu[32][32]={0};
		int co[32][32]={0};
		int ans = 0;
		for(int i = 0; i < Y; i++){
			for(int j = 0; j < X; j++){
				scanf("%d", &masu[i][j]);
			}
		}
		
		for(int i = 0; i < X; i++){
			co[0][i] = 1;
		}
		
		for(int i = 0; i < Y-1; i++){
			for(int j = 0; j < X; j++){
				if(masu[i][j] == 0){
					if(masu[i+1][j] != 1)co[i+1][j] += co[i][j];
					if(masu[i+1][j+1] == 0)co[i+1][j+1] += co[i][j];
					if(masu[i+1][j-1] == 0 && j-1 > -1)co[i+1][j-1] += co[i][j];
				}else if(masu[i][j] == 2){
					co[i+2][j] += co[i][j];
				}
			}
		}
		for(int i = 0; i < X; i++){
			co[Y][i] += co[Y-1][i];
		}
		
		
		for(int i = 0; i < X; i++){
			ans += co[Y][i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int w,h;
int s[40][40];
int dp[40][40];
int dx[]={-1,0,1};
int ret(int y,int x){
	if(y>=h-1){
		if(h-1==y&&s[y][x]==1)
		return 0;
		return 1;
	}
	if(dp[y][x]!=-1)
	return dp[y][x];
	if(s[y][x]==1)
		return dp[y][x]=0;
	if(s[y][x]==2){
		return dp[y][x]=ret(y+2,x);
	}
	int ans=0;
	for(int i=0;i<3;i++){
		int nx=dx[i]+x;
		if(nx>=w||nx<0)
			continue;
		
		if(s[y+1][nx]==0){
			ans+=ret(y+1,nx);
		}else if(s[y+1][nx]==2){
			if(i!=1)
				continue;
			ans+=ret(y+1,nx);
		}
	}
	return dp[y][x]=ans;
}
int main(){
	while(cin>>w>>h,w||h){
		memset(dp,-1,sizeof(dp));
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		cin>>s[i][j];
		int ans=0;
		for(int i=0;i<w;i++){
			//if(s[0][i]==0)
				ans+=ret(0,i);
		}
		
		cout<<ans<<endl;
	}
	return 0;
}