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 <bits/stdc++.h>

using namespace std;

#define MAX 25

int main()
{
    int H, W;
    while (cin >> W >> H, W) {
        vector<vector<int>> a(H, vector<int>(W));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> a[i][j];
            }
        }
        int dp[MAX][MAX] = {{}};
        for (int i = 0; i < W; i++) {
            dp[0][i] = (a[0][i] == 0);
        }

        for (int i = 0; i < H - 1; i++) {
            for (int j = 0; j < W; j++) {
                if (dp[i][j] <= 0 || a[i][j] == 1) continue;
                if (a[i][j] == 2) {
                    int ni = min(i + 2, H - 1);
                    if (i + 2 < H && a[i+2][j] == 1) continue;
                    dp[ni][j] += dp[i][j];
                } else {
                    for (int k = -1; k <= 1; k++) {
                        int ni = i + 1;
                        int nj = j + k;
                        if (nj < 0 || nj >= W) continue;
                        if (a[ni][nj] == 1) continue;
                        if (a[ni][nj] == 2 && j != nj) continue;
                        dp[ni][nj] += dp[i][j];
                    }
                }
            }
        }
        int res = 0;
        for (int i = 0; i < W; i++) {
            res += dp[H-1][i];
        }
        cout << res << endl;
    }
    return 0;
}

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

#define SIZE 15+5

using namespace std;
 
int main(){
    std::ios_base::sync_with_stdio(false);

	int X,Y;
	int course[SIZE+1][SIZE];
	int dp[SIZE+1][SIZE];
	int ans;

	while(1){
		cin>>X>>Y;
		if(X==0&&Y==0) break;

		for(int i=0;i<Y*X;i++) cin>>course[i/X][i%X];
		for(int i=0;i<X;i++) course[Y+1][i]=0;
		for(int i=0;i<(Y+1)*(X);i++) dp[i/X][i%X]=(i/X==0&&course[i/X][i%X]==0)?1:0;

		for(int i=0;i<(Y-1)*X;i++){
			if(dp[i/X][i%X]>0){
				if(course[i/X][i%X]==0){
					if(i%X!=0){
						if(course[i/X+1][i%X-1]==0) dp[i/X+1][i%X-1]+=dp[i/X][i%X];
					}
						if(course[i/X+1][i%X]!=1) dp[i/X+1][i%X]+=dp[i/X][i%X];
						if(i%X!=X-1){
							if(course[i/X+1][i%X+1]==0) dp[i/X+1][i%X+1]+=dp[i/X][i%X];
						}
					}
					else if(course[i/X][i%X]==2){
						if(course[i/X+2][i%X]!=1) dp[i/X+2][i%X]+=dp[i/X][i%X];
					}
				}
		}
		ans=0;
		for(int i=(Y-1)*X;i<(Y+1)*X;i++){
			ans+=dp[i/X][i%X];
		}
		cout<<ans<<endl;
	}
 
 
    return 0;
}

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

int dp[17][17];
int map[17][17];
int y,x;

long long int check(int i,int j)
{
  if(j>=x||j<0)
    return 0;
  if(j>=y)
    return 0;

  if(map[i][j]==1)
    return 0;

  if(dp[i][j]!=-1)
    return dp[i][j];

  long long int sum=0; 
  if(i>=x-1)
    sum=1;
  else if(map[i][j]==2)
    sum=check(i+2,j);
  else
    {
      if(j-1>=0 && map[i+1][j-1]==0)
	sum+=check(i+1,j-1);
      sum+=check(i+1,j);
      if(j+1<x && map[i+1][j+1]==0)
	sum+=check(i+1,j+1);
    }
    

  //  cout<<i<<" "<<j<<" " <<sum<<endl;
  dp[i][j]=sum;
  return sum;
}

int main()
{
  for(;cin>>x>>y,x;)
    {
      memset(dp,-1,sizeof(dp));
      memset(map,0,sizeof(map));
      for(int i=0;i<y;i++)
	for(int j=0;j<x;j++)
	  {
	    cin>>map[i][j];
	  }
      long long int ans=0;
      for(int i=0;i<y;i++)
	ans+=check(0,i);
      cout<<ans<<endl;
    }
}

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;
  }
}

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

int fld[17][17];
int cnt[17][17];

int main()
{
	int X,Y,S;
	while(cin >> X >> Y, (X||Y))
	{
		for(int y=0; y<17; y++)
		for(int x=0; x<17; x++)
		{
			fld[y][x] = 1;
			cnt[y][x] = 0;
		}

		for(int y=0; y< Y; y++)
		for(int x=1; x<=X; x++)
		{
			cin >> fld[y][x];
			cnt[y][x] = ((y==0&&fld[y][x]==0)?1:0);
		}

		for(int y=0; y< Y-1; y++)
		for(int x=1; x<=X  ; x++)
		{
			if(fld[y][x]==0)
			{
				if(fld[y+1][x+1]==0) cnt[y+1][x+1]+=cnt[y][x];
				if(fld[y+1][x-1]==0) cnt[y+1][x-1]+=cnt[y][x];
				if(fld[y+1][x  ]!=1) cnt[y+1][x  ]+=cnt[y][x]; 
			}
			if(fld[y][x]==2)
			{
				cnt[y+2][x]+=cnt[y][x];
			}
		}

		S=0;
		for(int y=Y-1; y< Y+2; y++)
		for(int x=1  ; x<=X  ; x++)
		{
			S+=cnt[y][x];
		}

		cout << S << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, w;
    while(cin >> w >> h, w){
        vector<vector<int>> G(h+2, vector<int>(w+2, 1));
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> G[i+1][j+1];
            }
        }
        vector<vector<int>> dp(h+2, vector<int>(w+2, 0));
        for (int i = 0; i < w; ++i) {
            if(G[1][i+1] != 1) dp[1][i+1] = 1;
        }
        int ans = 0;
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                if(i == h) ans += dp[i][j];
                else if(G[i][j] == 0){
                    for (int k = -1; k <= 1; ++k) {
                        if(G[i+1][j+k] == 0) dp[i+1][j+k] += dp[i][j];
                        else if(G[i+1][j+k] == 2 && !k) dp[i+1][j] += dp[i][j];
                    }
                }else if(G[i][j] == 2){
                    if(i >= h-1) ans += dp[i][j];
                    else if(G[i+2][j] != 1) dp[i+2][j] += dp[i][j];
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}