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 <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
	
	while(1)
	{
		int w,h; cin >> w >> h;
		if(w == 0) return 0;
		int f[20][20]={};
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				cin >> f[i][j];
			}
		}
		ll dp[20][20]={};
		for(int i=1;i<=w;i++) if(f[1][i] != 1) dp[1][i] = 1LL;
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				if(!dp[i][j]) continue;
				if(f[i][j] == 0)
				{
					if(j != 1)
					{
						if(f[i+1][j-1] == 0 && i+1 <= h) dp[i+1][j-1] += dp[i][j];
					}
					if(f[i+1][j] != 1 && i+1 <= h) dp[i+1][j] += dp[i][j];
					if(j != w)
					{
						if(f[i+1][j+1] == 0 && i+1 <= h) dp[i+1][j+1] += dp[i][j];
					}
				}
				else if(f[i][j] == 2)
				{
					if(f[i+2][j] != 1 && i+2 <= h) dp[i+2][j] += dp[i][j];
				}
			}
		}
		ll res = 0;
		for(int i=1;i<=w;i++) if(f[h-1][i] == 2) res += dp[h-1][i];
		for(int i=1;i<=w;i++) res += dp[h][i];
		cout << res << endl;
	}
}

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

using namespace std;

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

int solve(int i,int j,bool naname){
  //cout<<"a"<<i<<"\t"<<j<<endl;
  if(j < 0 ||j >= x) return 0;
  if(i >= y) return 1;
  if(naname)
    if(map[i][j] == 2)
      return 0;
  if(dp[i][j] >= 0) return dp[i][j];
 
  int ret;

  //cout<<i<<"\t"<<j<<endl;
  switch(map[i][j]){
  case 0:
    ret = solve(i+1,j-1,true) + solve(i+1,j,false)+solve(i+1,j+1,true);
    break;
  case 2:
    ret = solve(i+2,j,false);
    break;
  }

  return dp[i][j] = ret;
}


int main(){
  while(cin>>x>>y){
    if(x == 0 && y==0)
      return 0;
    memset(dp,-1,sizeof(dp));
    for(int i = 0;i<y;i++){
      for(int j = 0;j<x;j++){
	cin>>map[i][j];
	if(map[i][j] == 1)
	  dp[i][j] = 0;
      }
    }
    int ans = 0;
    for(int j = 0;j<x;j++){
      if(map[y-1][j] != 1)
	dp[y-1][j] = 1;
    }
    for(int j = 0;j<x;j++){
      ans += solve(0,j,false);
      // cout<<"ans:"<<ans<<endl;
    }
    cout<<ans<<endl;
    
  }

  return 0;
}

C++: //03
#include<iostream>

using namespace std;

int main(){
  for(int x,y;cin>>x>>y,x|y;){
    int g[17][16]={};
    for(int i=1;i<=x;i++){
      for(int j=1;j<=y;j++){
	cin>>g[i][j];
      }
    }
    int a[17][16]={};
    for(int i=1;i<=x;i++){
      a[1][i]=1;
    }
    for(int i=1;i<=y-1;i++){
      for(int j=1;j<=x;j++){
	if(g[i][j]==0){
	  for(int k=-1;k<=1;k++){
	    if(1<=j+k&&j+k<=x){
	      if(g[i+1][j+k]==0){
		a[i+1][j+k]+=a[i][j];
	      }else if(k==0&&g[i+1][j]==2){
		a[i+1][j]+=a[i][j];
	      }
	    }
	  }
	}else if(g[i][j]==2){
	  if(g[i+2][j]!=1){
	    a[i+2][j]+=a[i][j];
	  }
	}
      }
    }
    int ans=0;
    for(int i=1;i<=x;i++){
      ans+=a[y][i]+a[y+1][i];
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
main(){for(int X,Y,f[15][15],d[15][15],i,j;std::cin>>X>>Y,X;printf("%d\n",Y)){for(i=0;i<Y;i++)for(j=0;j<X;d[i][j++]=i==0)std::cin>>f[i][j];for(i=1;i<Y;i++)for(j=0;j<X;j++){!f[i-1][j]&&(d[i][j]+=d[i-1][j]);if(f[i][j]-2){j+1<X&!f[i-1][j+1]&&(d[i][j]+=d[i-1][j+1]);j>0&!f[i-1][j-1]&&(d[i][j]+=d[i-1][j-1]);}i>1&f[i-2][j]==2&&(d[i][j]+=d[i-2][j]);}for(Y=j=0;j<X;j++){f[i-1][j]-1&&(Y+=d[i-1][j]);i>1&f[i-2][j]==2&&(Y+=d[i-2][j]);}}}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

bool is_inside(int x, int y, int X, int Y){
	if(x < 0 || y < 0 || x >= X || y >= Y){
		return false;
	}
	return true;
}

int main(){
	
	int X, Y;
	
	int course[20][20];
	int sum[20][20];
	
	while(true){
		cin >> X >> Y;
		
		if(X == 0 && Y == 0){
			break;
		}
		
		for(int i = 0; i < Y; i++){
			for(int j = 0; j < X; j++){
				cin >> course[j][i];
			}
		}
		for(int i = 0; i <= Y; i++){
			for(int j = 0; j < X; j++){
				sum[j][i] = 0;
			}
		}
		
		for(int i = 0; i < X; i++){
			if(course[i][0] == 1){
				sum[i][0] = 0;
			}else{
				sum[i][0] = 1;
			}
		}
		
		for(int y = 0; y < Y; y++){
			for(int x = 0; x < X; x++){
				if(course[x][y] == 0){
					for(int dx = -1; dx <= 1; dx++){
						if(is_inside(x + dx, y + 1, X, Y)){
							if(course[x + dx][y + 1] != 2 || dx == 0){
								sum[x + dx][y + 1] += sum[x][y];
							}
						}
					}
				}else if(course[x][y] == 2){
					if(is_inside(x, y + 2, X, Y)){
						sum[x][y + 2] += sum[x][y];
					}
				}else{
					sum[x][y] = 0;
				}
			}
		}
		
		int ans = 0;
		
		for(int i = 0; i < X; i++){
			if(course[i][Y - 1] == 0){
				ans += sum[i][Y - 1];
			}
			if(Y >= 2 && course[i][Y - 2] == 2){
				ans += sum[i][Y - 2];
			}
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

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

using namespace std;

const int MAX = 17;
int in[MAX][MAX], X,Y,data[MAX][MAX],ans;
int dx[3] = {-1,0,1};

void init(){
  memset(data,0,sizeof(data));
  memset(in,-1,sizeof(in));
  ans = 0;
}


void solve(){
  for(int i = 1; i <= Y; i++)
    for(int j = 1; j <= X; j++){
      for(int k = 0; k < 3; k++)
	if(in[i][j] == 0){
	  int f = j+dx[k];
	  if(i-1 > 0 && 0 < f && f <= X){
	    if(in[i-1][f] != 2) data[i][j] += data[i-1][f];
	  }

	}else if(in[i][j] == 2){
	  if(i-1 > 0) data[i][j] += data[i-1][j];
	  if(i+2 <= Y && in[i+2][j] != 1) data[i+2][j] += data[i][j];
	  break;
	}
    }

  for(int j = 1; j <= X; j++){
    if(Y-1 > 0 && in[Y-1][j] == 2) ans+=data[Y-1][j];
    ans+=data[Y][j];
  }
  cout << ans << endl;
}

int main(){
  while(cin >> X >> Y && X+Y){
    init();
    for(int i = 1; i <= Y; i++)
      for(int j = 1; j <= X; j++)
	cin >> in[i][j];
    
    for(int i = 1; i <= X; i++)
      if(in[1][i] == 0) data[1][i] = 1;

    solve();
  }
  return 0;
}