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 <cstring>
#include <cstdio>
using namespace std;

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

int x, y, c[16][16], dp[30][30];
const int dx[3] = {-1, 0, 1};

void solve() {
  memset(dp, 0, sizeof dp);
  
  rep(i,y) rep(j,x) cin>>c[i][j];
  
  rep(i,x) if (c[0][i] == 0) dp[0][i] = 1;
  
  rep(i,y) rep(j,x) {
    if (c[i][j] == 1) {
      continue;
    } else if (c[i][j] == 0) {
      rep(z,3) {
        int ti = i + 1, tj = j + dx[z];
        if (ti < 0 || tj < 0 || ti >= y || tj >= x) continue;
        if (c[ti][tj] == 1) continue;
        if (c[ti][tj] == 2 && tj != j) continue;
        dp[ti][tj] += dp[i][j];
      }
    } else if (c[i][j] == 2) {
      dp[i+2][j] += dp[i][j];
    }
  }
  /*
  rep(i,y+1) {
    rep(j,x) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int res = 0;
  REP(i,y-1,y+1) rep(j,x) res += dp[i][j];
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>x>>y, x||y) {
    solve();
  }
  return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps=1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt"

int main() {
	while (1) {
		int H, W; cin >> W >> H;
		if (!H)break;
		vector<vector<int>>field(H + 3, vector<int>(W + 2,1));
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin >> field[i][j+1];
			}
		}
		for (int i = H; i < H + 3; ++i) {
			for (int j = 1; j <= W; ++j) {
				field[i][j] = 0;
			}
		}
		vector<vector<long long int>>nums(H + 3, vector<long long int>(W + 2, 0));
		for (int j = 0; j < W + 2; ++j) {
			if (!field[0][j])nums[0][j] = 1;
		}
		long long int ans = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 1; j < W + 1; ++j) {
				for (int dx = -1; dx <= 1;++dx) {
					const int nextx = j + dx;
					int nexty = i + 1;
					
					if (field[nexty][nextx] == 1) {

					}
					else if (field[nexty][nextx] == 2) {
						if (!dx) {
							while (1) {
								nexty += 2;
								if (nexty >= H - 1 && field[nexty][nextx] != 1) {
									ans += nums[i][j];
									break;
								}
								else {
									if (field[nexty][nextx] == 1) {
										break;
									}
									else if (field[nexty][nextx] == 0) {

										nums[nexty][nextx] += nums[i][j];
										break;
									}
								}
							}
							
						}
					}
					else {
						if (nexty >= H - 1)ans += nums[i][j];
						else {
							nums[nexty][nextx] += nums[i][j];
						}
					}
				}
				
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main() {
	int y, x;
	while (1) {
		cin >> y >> x;
		if (y + x == 0) break;
		int d[20][20] = { 0 };
		rep(i, 0, y) {
			rep(j, 0, x) {
				cin >> d[i][j];
			}
		}
		int dp[20][20] = { 0 };
		rep(i, 0, x) {
			if (d[0][i] == 0) dp[0][i] = 1;
		}
		rep(i, 0, y) {
			rep(j, 0, x) {
				if (d[i][j] == 1) continue;
				if (d[i][j] == 2 && d[i + 2][j] != 1) {
					dp[i + 2][j] += dp[i][j];
					continue;
				}
				rep(k, -1, 2) {
					if (j + k < 0 || j + k >= x || d[i + 1][j + k] != 0) continue;
					dp[i + 1][j + k] += dp[i][j];
				}
				if (d[i + 1][j] == 2) {
					dp[i + 1][j] += dp[i][j];
				}
			}
		}
		/*cout << endl;
		rep(i, 0, y + 2) {
			rep(j, 0, x) {
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}*/
		int ans = 0;
		rep(i, 0, x) {
			ans += dp[y - 1][i];
			if (d[y - 2][i] == 2) {
				ans += dp[y - 2][i];
			}
		}
		cout << ans << endl;
	}
}

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

int main(){
  int i,j,x,y,a[16][15],n[15][15],k,ans;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    for(i=0;i<y;i++){
      for(j=0;j<x;j++){
	cin >> n[i][j];
      }
    }

    for(j=0;j<x;j++){
      for(i=0;i<=y;i++) a[i][j] = 0;
      if(n[0][j] == 0) a[0][j] = 1;
    }

    for(i=0;i<y;i++){
      for(j=0;j<x;j++){
	if(n[i][j] == 1) continue;
	if(i == y-1) a[i+1][j] += a[i][j];
	else if(n[i][j] == 0){
	  for(k=-1;k<=1;k++){
	    if(j == 0 && k == -1 || j == x-1 && k == 1) continue;
	    if(n[i+1][j+k] == 0) a[i+1][j+k] += a[i][j];
	  }
	  if(n[i+1][j] == 2) a[i+1][j] += a[i][j];
	}
	else if(n[i][j] == 2){
	  if(n[i+2][j] != 1) a[i+2][j] += a[i][j];
	}
      }
    }

    ans = 0;
    for(j=0;j<x;j++) ans += a[y][j];
    cout << ans << endl;

  }
  return 0;
}

C++: #include <iostream>
#include <queue>
#include <map>
#include <string.h>

using namespace std;

const int FIELD_MAX =15;

int X, Y;
int field[FIELD_MAX][FIELD_MAX];
int table[FIELD_MAX+1][FIELD_MAX];
int cnt = 0;

typedef pair<int, int> point;

void solve()
{
	memset(&table[0][0], 0, sizeof(int) * 15 * 16);
	for(int x=0; x<X; x++)
	{
		table[Y][x] = 1;
	}
	
	for(int y=Y; y>=1; y--)
	{	
		for(int x=0; x<X; x++){
			int a = 0;
			if(y>=2){
				if(field[y-2][x]==2) table[y-2][x]+=table[y][x];
			}
			if(x>=1 && y!=Y && field[y][x] != 2){
				if(field[y-1][x-1]==0) table[y-1][x-1]+=table[y][x];
			}
			if(field[y-1][x]==0) table[y-1][x]+=table[y][x];
			if(x<X-1 && y!=Y && field[y][x] != 2){
				if(field[y-1][x+1]==0) table[y-1][x+1]+=table[y][x];
			}
		}
	}
	
	cnt = 0;
	for(int x=0; x<X; x++){
		cnt += table[0][x];
	}
}

int main()
{
	while( 1 )
	{
		cin >> X >> Y;
		if(X==0 && Y==0)
		{
			break;
		}
		
		for(int y=0; y<Y; y++)
		{
			for(int x=0; x<X; x++)
			{
				cin >> field[y][x];
			}
		}
		
		cnt = 0;
		solve();
		printf("%d\n", cnt);
	}
}