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>
using namespace std;


int main(){
	int map[20][20];
	int ans_map[20][20];
	int x,y;
	while(cin>>x>>y,(x!=0)&&(y!=0)){
		long int ans=0;
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				cin>>map[i][j];
				ans_map[i][j]=0;
			}
		}
		for(int i=0;i<x;i++){
			ans_map[y][i]=0;
		}
		for(int i=0;i<x;i++){
			if(map[0][i]==0){
				ans_map[0][i]=1;
			}
		}
		for(int i=0;i+1<y;i++){
			for(int j=0;j<x;j++){
				if(map[i][j]==2){
					ans_map[i+2][j]+=ans_map[i][j];
					ans_map[i][j]=0;
				}else if(map[i][j]==1){
					ans_map[i][j]=0;
				}else{ 
					for(int k=-1;k<2;k++){
						if((j+k<0)||(j+k>x-1)){
							continue;
						}else{
							if(map[i+1][j+k]==0){
								ans_map[i+1][j+k]+=ans_map[i][j];
							}else if((k==0)&&(map[i+1][j+k]==2)){
								ans_map[i+1][j+k]+=ans_map[i][j];
							}else{
							}
						}
					}
				}
			}
		}
		for(int i=0;i<x;i++){
			ans_map[y][i]+=ans_map[y-1][i];
		}
		for(int i=0;i<x;i++){
			ans+=ans_map[y][i];
		}
		cout<<ans<<endl;
		
	}
}

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++;
                    if(i+1+c*2<=h-1&&data[i+1+c*2][j]==0){
                        dp[i+1+c*2][j]+=dp[i][j];
                    }
                    else if(i+1+c*2>h-1){
                        dp[h-1][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>

using namespace std;

int X, Y;
int field[17][17];
int dp[18][17];

void solve() {
	fill(dp[0], dp[17], 0);
	for (int x = 1; x <= X; x++)
		if (field[1][x] == 0) dp[1][x] = 1;
	for(int y = 1; y < Y; y++)
		for (int x = 1; x <= X; x++) {
			switch (field[y][x]) {
			case 0:
				if(field[y+1][x-1] == 0) dp[y + 1][x - 1] += dp[y][x];
				dp[y + 1][x] += dp[y][x];
				if(field[y+1][x+1] == 0) dp[y + 1][x + 1] += dp[y][x];
				break;
			case 2:
				dp[y + 2][x] += dp[y][x];
			default:
				break;
			}
		}
	int sum = 0;
	for(int y = Y; y <= Y+1; y++)
		for (int x = 1; x <= X; x++) 
			if (field[y][x] != 1) sum += dp[y][x];
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> X >> Y, X, Y) {
		fill(field[0], field[17], 0);
		for (int y = 1; y <= Y; y++)
			for (int x = 1; x <= X; x++)
				cin >> field[y][x];
		solve();
	}
}

C++: #include <cstdio>
#include <cstring>
#define NORMAL 0
#define TREE 1
#define JUMP 2
#define DR_NUM 3 // 方向数

using namespace std;

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

int main(void){
	int x, y, course[15][15], dp[15][15], i, j, k, l, ans;
	while(1){
		scanf("%d%d",&x,&y);
		if(x == 0 && y == 0){
			break;
		}
		for(i = 0;i < y;i++){
			for(j = 0;j < x;j++){
				scanf("%d",&course[i][j]);
			}
		}
		memset(dp,0,sizeof(dp));
		for(i = 0;i < x;i++){
			if(course[0][i] != TREE)
				dp[0][i] = 1;
		}
		for(j = 0;j < y - 1;j++){
			for(k = 0;k < x;k++){
				if(course[j + 2][k] != TREE && (course[j][k] == JUMP || j == y - 1)){
					if(j + 2 < y){
						dp[j + 2][k] += dp[j][k];
					}else{
						dp[y - 1][k] += dp[j][k];
					}
				}else if(course[j][k] == NORMAL){
					for(l = 0;l < DR_NUM;l++){
						if(k + dx[l] >= 0 && k + dx[l] < x && course[j + dy[l]][k + dx[l]] != TREE && !(l != 1 && course[j + dy[l]][k + dx[l]] == JUMP)){
							dp[j + dy[l]][k + dx[l]] += dp[j][k];
						}
					}
				}
			}
		}
		ans = 0;
		for(i = 0;i < x;i++){
			ans += dp[y - 1][i];
		}
		printf("%d\n",ans);
	}
	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 && m[i+2][j] != 1){
	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;
  }
}