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>
#define N 15
using namespace std;
void func(int,int);
int jump(int,int);
int X,Y,data[N][N],memo[N][N];
int main(){
  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++)memo[i][j]=0;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j];
    for(int i=0;i<X;i++)
      if(data[0][i]==0) func(0,i);
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=memo[0][i];
    cout << cnt << endl;
  }
  return 0;
}
void func(int y,int x){
  if(y==Y-1){
    memo[Y-1][x]=1;
    return ;
  }
  if(0<=x-1&&data[y+1][x-1]==0){
    if(memo[y+1][x-1]==0) func(y+1,x-1);
    memo[y][x]+=memo[y+1][x-1];
  }
  if(x+1<X&&data[y+1][x+1]==0){
    if(memo[y+1][x+1]==0) func(y+1,x+1);
    memo[y][x]+=memo[y+1][x+1];
  }
  if(data[y+1][x]==0){
    if(memo[y+1][x]==0) func(y+1,x);
    memo[y][x]+=memo[y+1][x];
  }
  if(data[y+1][x]==2){
    int r=jump(y+1,x);
    if(r==-2) memo[y][x]+=1;
    else if(r!=-1){
      if(memo[r][x]==0) func(r,x);
      memo[y][x]+=memo[r][x];
    }
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(data[y][x]==1) break;
    if(y>=Y-1) return -2;
    if(data[y][x]==0) return y;
  }
  return -1;
}

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

using namespace std;

int vis[15][15];

int bfs(int a[15][15], int n, int m, int s, int t)
{
  int c = 0;
  if(s+1 == n){
    vis[s][t] = 1;
    return 1;
  }

  if(vis[s][t] > 0){
    return vis[s][t];
  }

  if(a[s][t] == 2){
    if(s+2 >= n){
      vis[s][t] = 1;
      return 1;
    }
    if(a[s+2][t] != 1){
      c = bfs(a, n, m, s+2, t);
    }
  } else {

    if(t-1 >= 0){
      if(a[s+1][t-1] == 0){
	c += bfs(a, n, m, s+1, t-1);
      }
    }
    if(a[s+1][t] != 1){
      c += bfs(a, n, m, s+1, t);
    }
    
    if(t+1 < m){
      if(a[s+1][t+1] == 0){
      c += bfs(a, n, m, s+1, t+1);
      }
    }
  }
  vis[s][t] = c;

  return c;
}

int main()
{
  int n, m, c;
  int a[15][15];

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

    fill(&vis[0][0], &vis[14][14], -1);

    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
	cin >> a[i][j];
      }
    }
    c = 0;
    for(int i = 0; i < m; i++){
      if(a[0][i] != 1){
	c += bfs(a, n, m, 0, i);
      }
    }

    cout << c << endl;
  }


  return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{
	int w, h;
	while(scanf("%d%d", &w, &h), w){
		vvi field(h, vi(w));
		rep(i, h){
			rep(j, w){
				scanf("%d", &field[i][j]);
			}
		}
		
		vvi dp(h, vi(w, 0));
		rep(i, w){
			dp[0][i] = !field[0][i];
		}
		
		reep(i, 1, h){
			rep(j, w){
				if(field[i][j] == 1)
					continue;
				
				if(i >= 2){
					dp[i][j] += field[i-2][j] == 2 ? dp[i-2][j] : 0;
				}
				reep(k, field[i][j] == 0 ? -1 : 0, field[i][j] == 0 ? 2 : 1){
					int px = j + k;
					if(px < 0 || w <= px)
						continue;
					if(field[i-1][px] != 0)
						continue;
					dp[i][j] += dp[i-1][px];
				}
			}
		}
		
		int sum = 0;
		rep(i, w){
			sum += dp[h-1][i];
			if(h > 1)
				sum += field[h-2][i] == 2 ? dp[h-2][i] : 0;
		}
		printf("%d\n", sum);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[18][18];
int kosu[16][16];
int ans;

int main(){
  int x,y;
  
  while(1){
    cin>>x>>y;
    if(x==0 && y==0) break;
    
    fill(dp[0],dp[18],0);
    ans=0;
    
    for(int i=0;i<y;i++){
      for(int l=0;l<x;l++){
        cin>>kosu[i][l];
      }
    }
    for(int i=0;i<x;i++)
      if(kosu[0][i]==0) dp[0][i]=1;
    
    for(int i=1;i<y;i++){
      for(int l=0;l<x;l++){
        
        if(kosu[i][l]==2){
          dp[i+2][l]+=dp[i-1][l]+dp[i][l];
          dp[i][l]=0;
        }
        else if(kosu[i][l]==0)
          dp[i][l]+=dp[i-1][l-1]+dp[i-1][l]+dp[i-1][l+1];
      }
    }
    for(int i=y-1;i<y+2;i++){
      for(int l=0;l<x;l++){
        ans+=dp[i][l];
      }
    }
    
    printf("%d\n",ans);
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
#define MAX 15
#define BLANK 0
#define BARRIER 1
#define JUMP 2
int main()
{
  int X,Y,field[MAX][MAX],dp[MAX][MAX],i,j,sum;
  while(cin>>X>>Y,X|Y){
    for(i=0;i<Y;i++)for(j=0;j<X;j++){cin>>field[i][j];dp[i][j]=(i==0);}
    for(i=1;i<Y;i++){
      for(j=0;j<X;j++){
	if(field[i][j]==BARRIER)continue;
	if(field[i-1][j]==BLANK)dp[i][j]+=dp[i-1][j];
	if(j+1<X && field[i-1][j+1]==BLANK && field[i][j]!=JUMP)dp[i][j]+=dp[i-1][j+1];
	if(j-1>=0 && field[i-1][j-1]==BLANK && field[i][j]!=JUMP)dp[i][j]+=dp[i-1][j-1];
	if(i-2>=0 && field[i-2][j]==JUMP)dp[i][j]+=dp[i-2][j];
      }
    }
    sum=0;
    for(j=0;j<X;j++){
      if(field[Y-1][j]==BLANK||field[Y-1][j]==JUMP)sum+=dp[Y-1][j];
      if(Y-2>=0 && field[Y-2][j]==JUMP)sum+=dp[Y-2][j];
    }
    cout<<sum<<endl;
  }
}

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

#define SIZE 15

using namespace std;
 
int main(){
    std::ios_base::sync_with_stdio(false);

	int X,Y;
	int course[SIZE][SIZE+1];
	int dp[SIZE][SIZE+1];
	int ans;

	while(1){
		cin>>X>>Y;
		if(X==0&&Y==0) break;

		for(int i=0;i<Y*X;i++) cin>>course[i/X][i%X];
		for(int i=0;i<X;i++) course[Y+1][i]=0;
		for(int i=0;i<Y*(X+1);i++) dp[i/X][i%X]=(i/X==0&&course[i/X][i%X]==0)?1:0;

		for(int i=0;i<(Y-1)*X;i++){
			if(dp[i/X][i%X]>0){
				if(course[i/X][i%X]==0){
					if(i%X!=0){
						if(course[i/X+1][i%X-1]==0) dp[i/X+1][i%X-1]+=dp[i/X][i%X];
					}
						if(course[i/X+1][i%X]!=1) dp[i/X+1][i%X]+=dp[i/X][i%X];
						if(i%X!=X-1){
							if(course[i/X+1][i%X+1]==0) dp[i/X+1][i%X+1]+=dp[i/X][i%X];
						}
					}
					else if(course[i/X][i%X]==2){
						if(course[i/X+2][i%X]!=1) dp[i/X+2][i%X]+=dp[i/X][i%X];
					}
				}
		}
		ans=0;
		for(int i=(Y-1)*X;i<(Y+1)*X;i++){
			ans+=dp[i/X][i%X];
		}
		cout<<ans<<endl;
	}
 
 
    return 0;
}