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<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);
#define sintttt(i,j,k,m) scanf("%d%d%d%d",&i,&j,&k,&m);

#define INF 1010000000
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
	while(1){
		int n,m;
		sintt(n,m);
		if(n==0)break;
		int masu[17][17];
		int dp[17][17];
		
		rep(i,17)rep(j,17)masu[i][j]=dp[i][j]=0;
		
		rep(i,m)rep(j,n){
			sint(masu[j+1][i]);
		}
		
		reps(j,n){
			if(masu[j][0]!=1){
				dp[j][0]=1;
			}
		}
		
		rep(i,m-1){
			reps(j,n){
				if(masu[j][i]==2){
					if(masu[j][i+2]!=1){
						dp[j][i+2]+=dp[j][i];
					}
					continue;
				}
				if(masu[j][i]==0){
					if(masu[j-1][i+1]==0){
						dp[j-1][i+1]+=dp[j][i];
					}
					if(masu[j+1][i+1]==0){
						dp[j+1][i+1]+=dp[j][i];
					}
					
					if(masu[j][i+1]!=1){
						dp[j][i+1]+=dp[j][i];
					}
				}
			}
		}
		
		int ans=0;
		for(int i=m-1;i<=m;i++){
			reps(j,n){
				ans+=dp[j][i];
			}
		}
		printf("%d\n",ans);
		
		rep(i,m+2){
			rep(j,n+2){
				printf("%d ",dp[j][i]);
			}puts("");
		}
	}
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

int main(){
    int w,h;
    while(cin>>w>>h){
        if(w==0&&h==0)break;
        int data[20][20];
        rep(i,h){
            rep(j,w){
                cin>>data[i][j];
            }
        }
        int dp[20][20];
        rep(i,20)rep(j,20)dp[i][j]=0;
        rep(i,w){
            if(data[0][i]==0){
                dp[0][i]=1;
            }
        }
        
        for(int i=0;i<h-1;i++){
            for(int j=0;j<w;j++){
                if(j-1>=0 && data[i+1][j-1]==0)dp[i+1][j-1]+=dp[i][j];
                if(data[i+1][j]==0)dp[i+1][j]+=dp[i][j];
                if(data[i+1][j]==2){
                    int c=1;
                    while(data[i+1+2*c][j]==2)c++;
                    dp[min(h-1,i+1+c*2)][j]+=dp[i][j];
                }
                if(j+1<w && data[i+1][j+1]==0)dp[i+1][j+1]+=dp[i][j];
            }
        }
        int ans=0;
        rep(i,w){
            ans+=dp[h-1][i];
        }
        cout<<ans<<endl;
    }
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(){
	int x,y;
	while(1){
		cin >> x >> y;
		if(x+y==0) break;
		int a[x][y];
		for(int j=0;j<y;j++) for(int i=0;i<x;i++) cin >> a[i][j];
		int d[x][y];
		for(int i=0;i<x;i++) d[i][0] = 1 - a[i][0];
		for(int j=1;j<y;j++){
			for(int i=0;i<x;i++){
				if(a[i][j]==1) d[i][j] = 0;
				else if(a[i][j]==0){
					if(a[i][j-1]!=2) d[i][j] = d[i][j-1];
					if(i>0 and a[i-1][j-1]!=2) d[i][j] += d[i-1][j-1];
					if(i<x-1 and a[i+1][j-1]!=2) d[i][j] += d[i+1][j-1];
					if(j>1 and a[i][j-2]==2) d[i][j] += d[i][j-2];
				}
				else{
					d[i][j] = d[i][j-1];
					if(j>1 and a[i][j-2]==2) d[i][j] += d[i][j-2];
				}
			}
		}
		int s = 0;
		for(int i=0;i<x;i++){
			if(y>2 and a[i][y-2]==2) s += d[i][y-2];
			s += d[i][y-1];
		}
		cout << s << endl;
	}
}

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

const int MAPSIZE = 20;

using namespace std;

void p(int (*a)[MAPSIZE], int size = MAPSIZE){
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			cout << a[i][j];
		}
		cout << endl;
	}
}

int main(){
	int mapdata[MAPSIZE][MAPSIZE];
	int route[MAPSIZE][MAPSIZE];

	int x, y;
	while(true){
		cin >> x >> y;
		if(!x && !y) break;

		fill((int*)mapdata, (int*)(mapdata + sizeof(mapdata)/sizeof(*(mapdata))), 1);

		for(int i = 1; i <= y; i++){
			for(int j = 1; j <= x; j++){
				cin >> mapdata[i][j];
			}
		}

		fill((int*)route, (int*)(route + sizeof(route)/sizeof(*(route))), 0);

		// 下からルート数を入れていく
		for(int i = y; i >= 0; i--){
			for(int j = 1; j <= x; j++){
				switch(mapdata[i][j]){
				case 0: // 移動可能 => ( x-1 , y+1 )、 ( x , y+1 )、 ( x+1 , y+1 ) の経路数値合計（斜めは移動可能マスのみ加算）
					// 但し、i == yの時は1
					if(i == y){
						route[i][j] = 1;
					}
					else{
						route[i][j] = route[i+1][j-1]*(!mapdata[i+1][j-1]) + route[i+1][j] + route[i+1][j+1]*(!mapdata[i+1][j+1]);
					}
					break;
				case 1:// 障害物 => 0
					route[i][j] = 0;
					break;
				case 2:// ジャンプ台=> (x,y+2) の経路数
					// 但し、i+1 >= y のときは1
					if(i+1 >= y){
						route[i][j] = 1;
					}else{
						route[i][j] = route[i+2][j];
					}
					break;
				}
			}
		}
//		p(route, x+3);
		int sum = 0;
		for(int i = 1; i <= x; i++){
			sum += route[1][i];
		}
		cout << sum << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n, m;
	while (true){
		cin >> n >> m;
		if (n == 0 && m == 0){
			break;
		}
		int map[100][100] = { 0 };
		int dp[100][100] = { 0 };
		for (int i = 0; i < m; i++){
			for (int i2 = 0; i2 < n; i2++){
				cin >> map[i][i2];
			}
		}
		for (int i = 0; i < n; i++){
			if (map[0][i] == 0){
				dp[0][i] = 1;
			}
		}
		for (int i = 0; i < m; i++){
			for (int i2 = 0; i2 < n; i2++){
				if (map[i][i2] == 0){
					for (int i3 = -1; i3 <= 1; i3++){
						if (i2 + i3 >= 0 && i2 + i3 < n && (map[i + 1][i2 + i3] == 0 || i3 == 0 && map[i + 1][i2 + i3] == 2)&&(i<m-1||i3==0)){
							dp[i + 1][i2+i3]  += dp[i][i2];
						}
					}	
				}
				else if (map[i][i2] == 2){
							dp[i + 2][i2] += dp[i][i2];
					}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++){
			ans += dp[m][i];
			ans += dp[m+1][i];
		}
		cout << ans << endl;
	}
}