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>
using namespace std;


int main(){
	int map[15][15];
	int ans_map[15][15];
	
	int x,y;
	while(cin>>x>>y,x){
		long int ans=0;
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				cin>>map[i][j];
				ans_map[i][j]=0;
			}
		}
		for(int i=0;i<x;i++){
			ans_map[y][i]=0;
		}
		for(int i=0;i<x;i++){
			if(map[0][i]==0){
				ans_map[0][i]=1;
			}
		}
		for(int i=0;i+1<y;i++){
			for(int j=0;j<x;j++){
				if(map[i][j]==2){
					ans_map[i+2][j]+=ans_map[i][j];
					ans_map[i][j]=0;
				}else if(map[i][j]==1){
					ans_map[i][j]=0;
				}else{ 
					for(int k=-1;k<2;k++){
						if((j+k<0)||(j+k>x-1)){
							continue;
						}else{
							if(map[i+1][j+k]==0){
								ans_map[i+1][j+k]+=ans_map[i][j];
							}else if((k==0)&&(map[i+1][j+k]==2)){
								ans_map[i+1][j+k]+=ans_map[i][j];
							}else{
							}
						}
					}
				}
			}
		}
		for(int i=0;i<x;i++){
			ans_map[y][i]+=ans_map[y-1][i];
		}
		
		for(int i=0;i<x;i++){
			ans+=ans_map[y][i];
		}
		cout<<ans<<endl;
		
	}
}

C++: #include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int W, H;
	while(cin >> W >> H, W) {
		int b[15][20] = { 0 };
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				cin >> b[i][j];
			}
		}

		int dp[15][20] = { 0 };
		for(int i = 0; i < W; i++) {
			if(b[0][i] != 1)
				dp[0][i] = 1;
		}

		for(int i = 0; i < H - 1; i++) {
			for(int j = 0; j < W; j++) {
				if(b[i][j] == 0) {
					for(int d = -1; d <= 1; d++) {
						if(j + d < 0 || W <= j + d) continue;
						if(b[i + 1][j + d] == 0 || b[i + 1][j + d] == 2 && d == 0)
							dp[i + 1][j + d] += dp[i][j];
					}
				}
				else if(b[i][j] == 2) {
					dp[i + 2][j] += dp[i][j];
				}
			}
		}

		int ans = 0;
		for(int i = H - 1; i <= H; i++) {
			for(int j = 0; j < W; j++) {
				if(b[i][j] == 0)
					ans += dp[i][j];
			}
		}
		cout << ans << endl;
	}
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[20][20],f,j,i,k;
	long long int g,h[20][20];
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
		for(i=0;i<s;i++) h[0][i]=1;
		for(i=0;i<a;i++){
			for(j=0;j<s;j++) scanf("%d",&d[i][j]);
		}
		for(i=0;i<s;i++){
			if(d[0][i]==1) h[0][i]=0;
		}
		for(i=1;i<a;i++){
			for(j=0;j<s;j++) h[i][j]=0;
		}
		for(i=0;i<a;i++){
			for(j=0;j<s;j++){
				if(i!=0&&d[i][j]==2){
					if(i+2<a){
						if(d[i+2][j]!=1) h[i+2][j]+=h[i][j];
					}
					else h[i+1][j]+=h[i][j];
				}
				if(d[i][j]==0){
					if(j!=0) if(d[i+1][j-1]==0) h[i+1][j-1]+=h[i][j];
					if(j!=s){
						if(d[i+1][j+1]==0) h[i+1][j+1]+=h[i][j];
						if(d[i+1][j]==0||d[i+1][j]==2) h[i+1][j]+=h[i][j];
					}
				}
			}
		}
		g=0;
		for(j=0;j<s;j++) g+=h[a-1][j];
		/*printf("\n\n");
		for(i=0;i<a;i++){
			for(j=0;j<s;j++) printf("%d ",h[i][j]);
			printf("\n");
		}*/
		printf("%d\n",g);
	}
	return 0;
}

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++) cin >> data[i][j],memo[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]==0) func(0,i);
    /*    cout << endl;
    for(int i=0;i<Y;i++){
      for(int j=0;j<X;j++){
	cout << memo[i][j] << ' ';
      }
      cout << endl;
    }
    cout << endl;*/
    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){
      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 <cstring>
#include <cstdio>
using namespace std;

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

int x, y, c[50][50], dp[50][50];
const int dx[3] = {-1, 0, 1};

void solve() {
  memset(dp, 0, sizeof dp);
  
  rep(i,y) rep(j,x) cin>>c[i][j];
  
  rep(i,x) if (c[0][i] == 0) dp[0][i] = 1;
  
  rep(i,y-1) rep(j,x) {
    if (c[i][j] == 0) {
      rep(z,3) {
        int ti = i + 1, tj = j + dx[z];
        if (ti < 0 || tj < 0 || ti >= y || tj >= x) continue;
        if (c[ti][tj] == 1) continue;
        if (c[ti][tj] == 2 && z != 1) continue;
        dp[ti][tj] += dp[i][j];
      }
    } else if (c[i][j] == 2) {
      dp[i+2][j] += dp[i][j];
    }
  }
  /*
  rep(i,y+1) {
    rep(j,x) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int res = 0;
  rep(j,x) res += dp[y][j] + dp[y-1][j];
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>x>>y, x||y) {
    solve();
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;


int main() {
	while(1) {
		int x, y;
		cin >> y >> x;
		if(x==0 && y==0) break;
		int field[x][y];
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				cin >> field[i][j];
			}
		}
		int dp[x+1][y];
		for(int i=0; i<x+1; i++) {
			for(int j=0; j<y; j++) {
				dp[i][j] = 0;
			}
		}
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				if(i==0 && field[i][j] == 0) dp[i][j] = 1;
				else {
					if(field[i][j] == 0) {
						if(0<j && field[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
						if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
						if(j<y-1 && field[i-1][j+1] == 0) dp[i][j] += dp[i-1][j+1];
					}
					if(field[i][j] == 2) {
						if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
						if(field[i+2][j] != 1) dp[i+2][j] += dp[i][j];
					}
				}
			}
		}
		for(int i=0; i<y; i++) dp[x][i] += dp[x-1][i];

		int sum=0;
		for(int i=0; i<y; i++) sum += dp[x][i];
		cout << sum << endl;
	}
	return 0;
}