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 MP make_pair
#define PB push_back
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
int X,Y;
int fld[15][15];
int dp[15][15];
int main() {
	while(cin>>X>>Y&&X&&Y){
		for(int i=0;i<Y;i++)for(int j=0;j<X;j++)cin>>fld[j][i];
		int ans=0;
		for(int i=0;i<X;i++)for(int j=0;j<Y;j++)dp[i][j]=0;
		for(int i=0;i<X;i++)if(fld[i][Y-1]!=1)dp[i][Y-1]=1;
		for(int y=Y-2;y>=0;y--){
			for(int x=0;x<X;x++){
				if(fld[x][y]==0){
					for(int k=-1;k<=1;k++){
						int nx=x+k;
						if(nx<0||nx>=X)continue;
						if(nx==x&&fld[nx][y+1]!=1)dp[x][y]+=dp[nx][y+1];
						else if(fld[nx][y+1]==0)dp[x][y]+=dp[nx][y+1];
					}
				}else if(fld[x][y]==2){
					if(y+2>=Y)dp[x][y]=1;
					else dp[x][y]=dp[x][y+2];
				}
				if(y==0)ans+=dp[x][y];
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

int field[15][15];
int dp[16][15];

int n, m;

bool isIn(int x, int y){
    return 0 <= x && x < n && 0 <= y && y < m;
}

int main(){
    while(cin >> n >> m, n+m){
        for(int i=0; i < n; i++) for(int j=0; j< m; j++){cin >> field[i][j];}
        for(int i=0; i< 16; i++) for(int j=0; j< 15; j++) dp[i][j] = 0;
        for(int i=0; i < m; i++) dp[0][i] = 1;
        for(int i=0; i < n-1; i++){
            for(int j=0; j < m; j++){
                if(field[i][j] == 0){
                    for(int k=-1; k <= 1; k++){
                        if(isIn(i+1, j+k) && !(k != 0 && field[i+1][j+k] == 2)){
                            dp[i+1][j+k] += dp[i][j];
                        }
                    }
                }
                else if(field[i][j] == 1) dp[i][j] = 0;
                else if(field[i][j] == 2) dp[i+2][j] += dp[i][j];
            }
        }
        for(int i=0; i< m; i++) if(field[n-1][i] != 1)dp[n][i] += dp[n-1][i];
        int count = 0;
        for(int i=0; i< m; i++) count += dp[n][i];
        cout << count << endl;
    }
}

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

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

using namespace std;

int a[16][16];
int count = 0;
int n,m;

void dfs(int y,int x)
{
	if(y > m-1)
	{
		return;
	}

	if(a[y][x] == 0)
	{
		if(y == m-1)
		{
			count++;
			return;
		}
		if(x-1 >= 0 && y+1 < m)
		{
			if(a[y+1][x-1] != 2)
			{
				dfs(y+1,x-1);
			}
		}
		if(y+1 < m)
		{
			dfs(y+1,x);
		}
		if(x+1 < n && y+1 < m)
		{
			if(a[y+1][x+1] != 2)
			{
				dfs(y+1,x+1);
			}
		}
		return;
	}
	else if(a[y][x] == 1)
	{
		return;
	}
	else if(a[y][x] == 2)
	{
		if(y == m-2 || y == m-1)
		{
			count++;
			return;
		}
		else
		{
			dfs(y+2,x);
		}
	}
}

int main()
{
	while(cin >> n >> m)
	{
		if(n == 0 && m == 0)
		{
			break;
		}

		memset(a,0,sizeof(a));
		rep(i,n)
		{
			rep(j,m)
			{
				cin >> a[i][j];
			}
		}
		count = 0;
		rep(i,n) dfs(0,i);

		cout << count << endl;
	}
	return 0;
}

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

int DP[17][17];
int field[17][17];
int x,y;

int main(){
	while(true){
		cin >> x >> y;
		if(!x && !y)
			return 0;
		
		for(int i=1; i<=y; i++)
			for(int k=1; k<=x; k++)
				cin >> field[i][k];
		for(int i=1; i<=x; i++)
			field[y+1][i] = 0;
		
		for(int i=1; i<=y+1; i++)
			for(int k=0; k<=x+1; k++){
				DP[i][k]=0;
				if(i==1 && k>0 && k<=x){
					if(field[i][k] == 0)
						DP[i][k] = 1;
					else if(field[i][k] == 2){
						DP[i][k] = 0;
						int n = i+2;
						while(true){
							if(field[n][k] == 0){
								DP[n][k] = 1;
								break;
							}else if(field[n][k] == 1)
								break;
							else
								n+=2;
						}
					}
				}
			}
		
		for(int i=2; i<=y; i++){
			for(int k=1; k<=x; k++){
				if(field[i][k] == 0)
					DP[i][k] += DP[i-1][k-1] + DP[i-1][k] + DP[i-1][k+1];
				else if(field[i][k] == 1)
					DP[i][k] = 0;
				else{
					DP[i][k] = 0;
					int n = i+2;
					while(true){
						if(field[n][k] == 0){
							DP[n][k] += DP[i-1][k];
							break;
						}else if(field[n][k] == 1)
							break;
						else
							n+=2;
					}
				}
			}
		}
		
		int ans=0;
		for(int i=y; i<=y+1; i++)
			for(int k=1; k<=x; k++)
				ans += DP[i][k];
		cout << ans << endl;
	}
}

C++: #include <iostream>
#define N 15
using namespace std;
int jump(int,int);
int X,Y,data[N][N],dp[N][N];
int main(){
  bool q[N][N];
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j],q[i][j]=false,dp[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]==0) q[0][i]=true,dp[0][i]=1;
    for(int i=0;i<Y-1;i++){
      for(int j=0;j<X;j++){
	if(q[i][j]==true){
	  if(0<=j-1&&data[i+1][j-1]==0) dp[i+1][j-1]+=dp[i][j],q[i+1][j-1]=true;
	  if(j+1<X&&data[i+1][j+1]==0) dp[i+1][j+1]+=dp[i][j],q[i+1][j+1]=true;
	  if(data[i+1][j]==0) dp[i+1][j]+=dp[i][j],q[i+1][j]=true;
	  else if(data[i+1][j]==2){
	    int r=jump(i+1,j);
	    if(r==-1) dp[Y-1][j]+=dp[i][j];
	    else if(r!=-2) dp[r][j]+=dp[i][j],q[r][j]=true;
	  }
	}
      }
    }
    /*    cout << endl;
    for(int i=0;i<Y;i++){
      for(int j=0;j<X;j++){
	cout << q[i][j] << ' ';
      }
      cout << endl;
    }
    cout << endl;
    for(int i=0;i<Y;i++){
      for(int j=0;j<X;j++){
	cout << dp[i][j] << ' ';
      }
      cout << endl;
      }*/
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=dp[Y-1][i];
    cout << cnt << endl;
  }
  return 0;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(y<Y&&data[y][x]==1) break;
    if(y>=Y-1) return -1;
    if(data[y][x]==0) return y;
  }
  return -2;
}

C++: #include<iostream>

using namespace std;

int masu[17][17];

int count;
	int n,m;
void saiki(int x,int y){
	
	if(y<1 || y>n){
		return;
	}
	if(x>=m){
		count++;
		return;
	}
	
	if(masu[x][y]==0){
		if(masu[x+1][y-1]==0 && x<=m-2){
			saiki(x+1,y-1);
		}
		if(masu[x+1][y]==0){
			saiki(x+1,y);
		}
		if(masu[x+1][y]==2){
			saiki(x+1,y);
		}
		if(masu[x+1][y+1]==0&& x<=m-2){
			saiki(x+1,y+1);
		}
	}
	if(masu[x][y]==1){
	}
	if(masu[x][y]==2){
		if(masu[x+2][y]!=1){
			saiki(x+2,y);
		}
	}
	
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<17;i++){
		for(int j=0;j<17;j++){
			masu[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=1;j<=m;j++){
			cin>>masu[i][j];
		}
	}
	
	count=0;
	
	for(int i=1;i<=m;i++){
		saiki(0,i);
	}
	
	printf("%d\n",count);
}