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 <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()
{
	//solve as a dynamic program problem
	
	//initialize table
	memset(&table[0][0], 0, sizeof(int) * 15 * 15);
	for(int x=0; x<X; x++)
	{
		table[Y][x] = 1;
	}
	
	//you can go (x ,y) when
	//(1) p(x, y-2) == 2
	//(2) p(x-1, y-1) ==0 || p(x, y-1)==0 || p(x+1, y-1)==0
	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);
	}
}

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

int main(){
  int x,y;
  int grid[17][15];
  int c[17][15];
  int dx[] = {-1,0,1};

  for(;;){
    cin >> x >> y;
    if(!x && !y)break;

    for(int i=0;i<y;i++)
      for(int j=0;j<x;j++)cin >> grid[i][j];
    for(int i=0;i<x;i++){
      grid[y][i] = 0;
      grid[y+1][i] = 0;
    }

    for(int i=0;i<y+2;i++)
      for(int j=0;j<x;j++)c[i][j] = 0;

    for(int i=0;i<x;i++)
      if(!grid[0][i])c[0][i] = 1;

    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
	if(!grid[i][j] && i!=y-1){
	  for(int k=0;k<3;k++){
	    int sx = j+dx[k];
	    if(sx<0 || x<=sx)continue;
	    if(!grid[i+1][sx] || (grid[i+1][sx]==2 && k==1))c[i+1][sx] += c[i][j];
	  }
	}
	if(grid[i][j] == 2){
	  if(grid[i+2][j]!=1)c[i+2][j] += c[i][j];
	}
      }
    }

    int ans = 0;
    for(int i=0;i<x;i++){
      ans += c[y-1][i];
      ans += c[y][i];
      ans += c[y+1][i];
    }
    /*
    for(int i=0;i<y+2;i++){
      for(int j=0;j<x;j++)cout << c[i][j] << " ";
      cout << endl;
    }
    */
    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int c[20][20];
long long int dp[20][20];
int main() {
	int X,Y;
	while(true){
		long long int ans=0;
		cin>>X>>Y;
		if(X+Y==0) break;
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				cin>>c[i][j];
			}
		}
		for(int i=1;i<=X;i++){
			if(c[1][i]==1){
				dp[1][i]=0;
			}
			if(c[1][i]==0){
				dp[1][i]=1;
			}
			if(c[1][i]==2){
				dp[1][i]=1;
				dp[3][i]=1;
			}
		}
		for(int i=2;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(c[i][j]==1) dp[i][j]=0;
				else if(c[i][j]==0){
					for(int k=0;k<3;k++){
						if(c[i-1][j-1+k]!=2){
							dp[i][j]+=dp[i-1][j-1+k];
						}
					}
				}
				else{
					if(c[i-1][j]!=2){
						dp[i][j]+=dp[i-1][j];
					}
					dp[i+2][j]+=dp[i][j];
				}
			}
		}
		for(int i=Y;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				ans+=dp[i][j];
			}
		}
		for(int i=1;i<=Y+1;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		printf("%lld\n",ans );
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#define fi first
#define se second
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int c[20][20];
long long int dp[20][20];
int main() {
	int X,Y;
	while(true){
		long long int ans=0;
		cin>>X>>Y;
		if(X+Y==0) break;
		for(int i=1;i<=Y;i++){
			for(int j=1;j<=X;j++){
				cin>>c[i][j];
			}
		}
		for(int i=1;i<=X;i++){
			if(c[1][i]==1){
				dp[1][i]=0;
			}
			if(c[1][i]==0){
				dp[1][i]=1;
			}
			if(c[1][i]==2){
				dp[1][i]=1;
				dp[3][i]=1;
			}
		}
		for(int i=2;i<=Y;i++){
			for(int j=1;j<=X;j++){
				if(c[i][j]==1) dp[i][j]=0;
				else if(c[i][j]==0){
					for(int k=0;k<3;k++){
						if(c[i-1][j-1+k]!=2){
							dp[i][j]+=dp[i-1][j-1+k];
						}
					}
				}
				else{
					if(c[i-1][j]!=2){
						dp[i][j]+=dp[i-1][j];
					}
					dp[i+2][j]+=dp[i][j];
				}
			}
		}
		for(int i=Y;i<=Y+2;i++){
			for(int j=1;j<=X;j++){
				ans+=dp[i][j];
			}
		}
		for(int i=1;i<=Y+1;i++){
			for(int j=1;j<=X;j++){
				dp[i][j]=0;
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include<iostream>
using namespace std;
int X,Y;
int dp[20][20];
char maps[20][20];
int bun(int x,int y);
int dx[3]={-1,0,1};
main(){
  while(1){
    cin>>X>>Y;
    if(X==0&&Y==0){
      break;
    }
    for(int i=1;i<=Y;i++){
      for(int j=1;j<=X;j++){
	cin>>maps[i][j];
	dp[i][j]=0;
      }
    }
    int ans=0;
    for(int i=1;i<=X;i++){
      if(maps[1][i]!='1'){
	ans+=bun(1,i);
      }
    }
    cout<<ans<<endl;
  }
}
int bun(int y,int x){
  if(y>=Y){
    return 1;
  }
  else if(dp[y][x]!=0){
    return dp[y][x];
  }
  else if(maps[y][x]=='2'&&(y+2>=Y+1||maps[y+2][x]!='1')){
    return bun(y+2,x);
  }
  else if(maps[y][x]=='1'){
    return 0;
  }
  else{
    int anss=0;
    for(int i=0;i<3;i++){
      int nx=x+dx[i];
      if(i!=1){
	if(nx>0&&nx<=X&&maps[y+1][nx]=='0'){
	  anss+=bun(y+1,nx);
	}
      }
      else{
	if(maps[y+1][nx]!='1'){
	  anss+=bun(y+1,nx);
	}
      }
    }
    return dp[y][x]=anss;
  }	  	  
}