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 <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n,a) for(int i=a;i<n;i++)
int main(){
	int X,Y;
	int mp[23][23];
	int obj[22][22];
	int sum = 0;
	while(cin >> X >> Y && X && Y){
		rep(i,22)rep(j,22)mp[i][j]=0;
		rep(i,22)rep(j,22)obj[i][j]=1;
		REP(i,X+1,1)mp[1][i]=1;
		
		rep(i,Y)rep(j,X){
			cin >> obj[1+i][1+j];
		}
		
		REP(i,Y+1,1	)REP(j,X+1,1){
			if(obj[i][j]==1){
				mp[i][j]=0;
			}else if(obj[i][j]==2){
				if(obj[i-1][ j ]==0)mp[i][j] =mp[i-1][ j ];
				if(obj[i-2][ j ]==2)mp[i][j]+=mp[i-2][ j ];
			}else{
				if(obj[i-1][j-1]==0)mp[i][j]+=mp[i-1][j-1];
				if(obj[i-1][ j ]==0)mp[i][j]+=mp[i-1][ j ];
				if(obj[i-1][j+1]==0)mp[i][j]+=mp[i-1][j+1];
				if(obj[i-2][ j ]==2)mp[i][j]+=mp[i-2][ j ];
			}
		}
		
		sum = 0;
		for(int i=1;i<=X;i++){
			sum += mp[Y][i];
			if(obj[Y-1][i]==2)sum+=mp[Y-1][i];
		}
		cout << sum << endl;
	}
}

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

int map[15][15],table[15][15],X,Y;

int main(){
while(1){

scanf("%d%d",&X,&Y);
if(X==0&&Y==0) return 0;
memset(map,-1,sizeof(map));
memset(table,0,sizeof(table));
for(int i=0;i<Y;i++){
for(int j=0;j<X;j++){
scanf("%d",&map[i][j]);
if(i==0&&map[i][j]==0) table[i][j]=1;
else if(i!=0&&map[i][j]==0){
if(j>0&&map[i-1][j-1]==0) table[i][j]+=table[i-1][j-1];
if(j<X-1&&map[i-1][j+1]==0) table[i][j]+=table[i-1][j+1];
if(map[i-1][j]==0)table[i][j]+=table[i-1][j];
if(i>2&&map[i-2][j]==2) table[i][j]+=table[i-2][j]; 
} 
}
}
int sum=0;
for(int i=0;i<X;i++){
sum+=map[Y-1][i];
}
printf("%d\n",sum);



}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = (1 << 26);
const int MAX_XY = 16;

void solve();

int x, y, f[MAX_XY][MAX_XY], dp[MAX_XY][MAX_XY];

int main(){
    cin >>x >>y;
    rep(i, MAX_XY) rep(j, MAX_XY) f[i][j] = 1;
    rep(i, y) rep(j, x) cin >>f[i][j];
    memset(dp, 0, sizeof(dp));

    solve();

    int ans = 0;
    rep(i, x) ans += dp[y][i];
    cout <<ans <<endl;
    return 0;
}

void solve(){
    rep(i, x){
        if(f[0][i] != 1) dp[0][i] = 1;
    }

    rep(i, y - 1){
        rep(j, x){
            if(f[i + 1][j] == 1){
                dp[i + 1][j] = 0;
                continue;
            } else if(f[i + 1][j] == 0){
                f(k, -1, 2){
                    if(j + k < x && j + k >= 0) dp[i + 1][j] += dp[i][j + k];
                }
            } else{
                dp[i + 1][j] += dp[i][j];
                if(i + 3 >= y) dp[y][j] += dp[i + 1][j];
                else dp[i + 3][j] += dp[i + 1][j];
                dp[i + 1][j] = 0;
            }
        }
    }
    rep(i, x) dp[y][i] += dp[y - 1][i];
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

int X,Y;
int board[20][20];
int cnt;
int memo[20][20];
int solve(int x,int y,int dir){
	if(x <1||x >X||board[y][x]==1||(board[y][x]==2&&dir !=0)){
		return 0;
	}else if(y >=Y){
		return 1;
	}
	if(memo[y][x]!=-1){
		return memo[y][x];
	}
	if(board[y][x]==2){
		return memo[y][x]=solve(x,y+2,0);
	}else {
		return memo[y][x] =solve(x-1,y+1,-1)+solve(x,y+1,0)+solve(x+1,y+1,1);
	}
}

int main(){
	while(cin>>X>>Y,X||Y){
		cnt =0;
		rep(i,20){
			rep(j,20){
				board[i][j]=0;
				memo[i][j] =-1;
			}
		}
		for(int i=1;i <=Y;i++){
			for(int j =1;j <=X;j++){
				cin>>board[i][j];
			}
		}
		for(int i =1;i <=X;i++){
			if(board[1][i]==0){
				cnt+=solve(i,1,0);
			}
			//cout <<endl;
		}
		cout <<cnt<<endl;
	}
	
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20];
int memo[20][20];
int ans;
int count;

int saiki(int x,int y) {
  count++;
  // cout << x <<" "<<y <<endl;
  int dx[3] = {-1,0,1};
  int dy[3] = {1,1,1};
  
  if((y >= h-1 && mp[y][x] != 1)) ans++,memo[y][x]++;//,cout <<"ok"<<endl;  
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = dx[i]+x;
      int ny = dy[i]+y;
      if(nx <0|| nx >= w || memo[ny][nx] == -1) continue;
      
      if(memo[ny][nx] > 0) {
	ans+= memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }  
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	if(memo[ny][nx] > 0) memo[y][x] += memo[ny][nx];
      } 
      else if(nx==x && mp[ny][nx] == 2){
	int ty = ny;
	while(mp[ty][nx] == 2) ty+=2;
	saiki(nx,ty);
	if(memo[ty][nx] > 0) memo[y][x] += memo[ty][nx];
      } 
    }
    if(memo[y][x] == 0) memo[y][x] = -1;
  }
}


int main() {

  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    for(int i=0;i<=19;i++) 
      for(int j=0;j<=19;j++){ 
	memo[i][j] = 0;
	mp[i][j] = 0;
      }
    
    for(int i=0;i<h;i++) 
      for(int j=0;j<w;j++) 
	cin >> mp[i][j];

    /*
      for(int i=0;i<h;i++) {
      for(int j=0;j<w;j++) 
      cout << mp[i][j];
      cout << endl;
      }
    */

    ans = 0;
    count = 0;
    for(int i=0;i<w;i++) {
      if(mp[0][i] !=1) saiki(i,0);
    }

    int ans2 = 0;
    for(int i=0;i<w;i++) 
      if(memo[0][i] > 0) ans2+=memo[0][i];

    cout << ans << endl;
    //    cout << ans2 << endl;
    //cout << count << endl;
  }

  return 0;
}