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<utility>
#include<queue>
#include<functional>
#include<cstring>
#include<vector>
#include<climits>
#include<map>
using namespace std;
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
typedef pair<int,int> pii;
typedef vector<int> vi;
#define int long long

main()
{
	while(1)
	{
		int a[20][20];
		int dp[20][20]={};
		int x,y;
		
		cin>>x>>y;if(!x)break;
		FOR(i,20)FOR(j,20)a[i][j]=1;
		FORI(i,1,y+1)
		{
			FORI(j,1,x+1)
			{
				cin>>a[i][j];
			}
		}
		FORI(i,1,x+1)
		{
			if(a[1][i]==0)dp[1][i]=1;
			a[y+1][i]=0;
		}
		FORI(i,1,y)
		{
			FORI(j,1,x+1)
			{
				if(a[i][j]==2&&a[i+2][j]!=1)
				{
					dp[i+2][j]+=dp[i][j];
				}
				else
				{
					for(int k=-1;k<=1;k++)
					{
						if(a[i+1][j+k]==0)
						{
							dp[i+1][j+k]+=dp[i][j];
						}
					}
					if(a[i+1][j]==2)dp[i+1][j]+=dp[i][j];
				}
			}
		}
		
		int ans=0;
		FORI(i,1,x+1)ans+=dp[y][i]+dp[y+1][i];
		cout<<ans<<endl;
		
	}
}

C++: #include<iostream>
using namespace std;
int w,h,xd[]={1,0,-1},p,u[20][20],d[20][20];
int ret(int x,int y){
	int s=x,sum=0;
	if(h-1<=y){
		return 1;
	}
	if(d[y][x]>=1)
	return d[y][x];
	else if(u[y][x]==2)
		return d[y][x]=ret(x,y+2);
	else if(u[y][x]==0){
		y++;
		for(int i=0;i<3;i++){
			x=s+xd[i];
			if(x>=0&&x<=w-1){
				if(u[y][x]==2&&i==1)
					sum+=d[y-1][s]=ret(x,y+2);
				else if(u[y][x]==0)
					sum+=d[y-1][s]=ret(x,y);
			}
		}
		return d[y-1][s]=sum;
	}
	return d[y][s]=-1;
}
int main(){
	int x,y;
	while(cin>>w>>h,w||h){
		p=0;
		for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			cin>>u[i][j];
			d[i][j]=0;
		}
		for(int i=0;i<w;i++){
			if(u[0][i]==0){
				x=i;
				y=0;
				p+=ret(x,y);
			}
			else if(u[0][i]==2){
				x=i;
				y=2;
				p+=ret(x,y);
			}
		}
		cout<<p<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[20][20],f,j,i,k;
	long long int g,h[20][20];
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		for(i=0;i<s;i++) h[0][i]=1;
		for(i=0;i<a;i++){
			for(j=0;j<s;j++) scanf("%d",&d[i][j]);
		}
		for(i=0;i<s;i++){
			if(d[0][i]==1) h[0][i]=0;
		}
		for(i=1;i<a;i++){
			for(j=0;j<s;j++) h[i][j]=0;
		}
		for(i=0;i<a;i++){
			for(j=0;j<s;j++){
				if(i!=0&&d[i+1][j]==1&&d[i][j]==2) h[i+1][j]+=h[i][j];
				if(h[i][j]!=0){
					if(d[i][j]==0) if(j!=0) if(d[i+1][j-1]==0) h[i+1][j-1]+=h[i][j];
					if(j!=s){
						if(d[i][j]==0) if(d[i+1][j+1]==0) h[i+1][j+1]+=h[i][j];
						if(d[i+1][j]==0||d[i+1][j]==2) h[i+1][j]+=h[i][j];
					}
				}
			}
		}
		g=0;
		for(j=0;j<s;j++) g+=h[a-1][j];
		/*printf("\n\n");
		for(i=0;i<a;i++){
			for(j=0;j<s;j++) printf("%d ",h[i][j]);
			printf("\n");
		}*/
		printf("%d\n",g);
	}
	return 0;
}

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

int main(){
	int w,h;

	while( cin >> w >> h , w||h ){
		int f[20][20] = {0};
		for(int y=1 ; y <= h ; y++ ){
			for(int x=1 ; x <= w ; x++ ){
				cin >> f[y][x];
			}
		}

		int dp[20][20] = {0};
		for(int x=1 ; x <= w ; x++ )
			dp[1][x] = 1;
		for(int y=2 ; y <= h ; y++ ){
			for(int x=1 ; x <= w ; x++ ){
				if( f[y][x] == 0 ){
					if( f[y-1][x-1] == 0 ) dp[y][x] += dp[y-1][x-1];
					if( f[y-1][x]   == 0 ) dp[y][x] += dp[y-1][x];
					if( f[y-1][x+1] == 0 ) dp[y][x] += dp[y-1][x+1];
					if( f[y-2][x]   == 2 ) dp[y][x] += dp[y-2][x];
				}else if( f[y][x] == 2 ){
					if( f[y-1][x] == 0 ) dp[y][x] += dp[y-1][x];
					if( f[y-2][x] == 2 ) dp[y][x] += dp[y-2][x];
				}
			}
		}
		int ans = 0;
		for(int x=1 ; x <= w ; x++ ){
			ans += dp[h][x];
			if( f[h-1][x] == 2 ){
				ans += dp[h-1][x];
			}
		}
		cout << ans << 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>
#include<cstring>
#define INF 1<<20
using namespace std;

int w, h;
int data[22][22];
int memo[22][22];

int solve(int x, int y){

  if(x < 0 || x == w || data[y][x]&1) return 0;
  if(y > h-2) return 1;
  if(memo[y][x]) return memo[y][x];

  int ret = 0;
  if(data[y][x] == 2) ret += solve(x, y+2);
  else{
    if(!data[y+1][x-1]) ret += solve(x-1, y+1);
    if(!data[y+1][x+1]) ret += solve(x+1, y+1);
    ret += solve(x, y+1);
  }
  
  return memo[y][x] = ret;
}

int main(){

  while(cin >> w >> h, w+h){

    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> data[i][j];

    memset(memo, 0, sizeof(memo));
    int ans = 0;
    for(int i=0;i<w;i++) ans += solve(i, 0);

    cout << ans << endl;
  }

}