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;

int field[20][20];
long long dp[20][20];

int main()
{
  int c1, c2;
  while (scanf(" %d %d ", &c1, &c2) == 2) {
    if (c1 == 0 && c2 == 0) {break;}
    for (int i = 0; i < 20; i++) {
      fill(field[i], &field[i][20], 1);
      fill(dp[i], &dp[i][20], 0);
    }
    for (int i = 1; i <= c1; i++) {
      for (int j = 1; j <= c2; j++) {
	scanf(" %d ", &field[i][j]);
      }
    }
    /*for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
	printf("%d", field[i][j]);
      }
      printf("\n");
      }*/
    
    for (int i = 1; i <= c2; i++) {
      dp[1][i] = 1;
    }
    for (int i = 1; i < c1; i++) {
      for (int j = 1; j <= c2; j++) {
	if (field[i][j] == 0) {
	  if (field[i + 1][j - 1] != 2) {dp[i + 1][j - 1] += dp[i][j];}
	  dp[i + 1][j] += dp[i][j];
	  if (field[i + 1][j + 1] != 2) {dp[i + 1][j + 1] += dp[i][j];}
	} else if (field[i][j] == 2) {
	  dp[i + 2][j] += dp[i][j];
	} 
      }
    }
    long long sum = 0;
    for (int i = 0; i <= 2; i++) {
      for (int j = 1; j <= c2; j++) {
	if ((i != 0 || field[c1 + i][j] != 1) && (i != 0 || field[c1 + i][j] != 2)) {
	  sum += dp[c1 + i][j];
	}
      }
    }
    
    printf("%d\n", sum);
  }
}

C++: #include<iostream>
using namespace std;
int solve(int x,int y);
int ax,ay;
int mas[200][200];
long long memo[200][200];
int main(){
  while(1){
    for(int i=0;i<200;i++){
      for(int j=0;j<200;j++){
	memo[i][j]=0;
      }
    }
    long long ans=0;
    cin>>ax>>ay;
    if(ax==0 && ay==0) break;
    
    for(int i=0;i<ay;i++){
      for(int j=0;j<ax;j++){
	cin>>mas[i][j];
      }
    }
    
    for(int i=0;i<ax;i++){
      if(mas[0][i]!=1){
	ans+=solve(i,0);
      }
    }
    cout<<ans<<endl;
  }
}
int solve(int x,int y){
  if(memo[y][x]!=0){
    return memo[y][x];
  }
  else if(y>=ay){
    return 1;
  }else if(mas[y][x]==1){
    return 0;
  }else if(mas[y][x]==2){
    return solve(x,y+2);
  } 
  else{
    long long anss=0; 
    if(mas[y+1][x]!=1){
      anss+=solve(x,y+1);
    }
    if(x+1<ax && mas[y+1][x+1]==0 && y+1!=ay){
      anss+=solve(x+1,y+1);
    }
    if(0<=x-1 && mas[y+1][x-1]==0 && y+1!=ay){
      anss+=solve(x-1,y+1);
    }
    return memo[y][x]=anss;
  }
}

C++: #include <cstdio>
int a[16][16];
long long dp[18][16];
int main()
{
    while (true) {
        int h, w;
        scanf("%d%d", &w, &h);
        if (!(w | h)) break;
        for (int i = 0; i < 16; ++i) for (int j = 0; j < 16; ++j)
            dp[i][j] = 0;
        for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j)
            scanf("%d", &a[i][j]);

        for (int j = 0; j < w; ++j)
            if (a[0][j] == 0) dp[0][j] = 1;
        for (int i = 1; i < h; ++i) for (int j = 0; j < w; ++j) {
            if (a[i][j] == 1) continue;
            if (a[i-1][j] != 2) dp[i][j] = dp[i-1][j];
            if (a[i][j] == 0) {
                if (j > 0 && a[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
                if (j < w-1 && a[i-1][j+1] == 0) dp [i][j] += dp[i-1][j+1];
            }
            if (i > 1 && a[i-2][j] == 2) dp[i][j] += dp[i-2][j];
        }
        for (int i = h; i < h+2; ++i) for (int j = 0; j < w; ++j) {
            dp[i][j] = dp[i-1][j];
            if (i > 1 && a[i-2][j] == 2) dp[i][j] += dp[i-2][j];
        }
        int res = 0;
        for (int j = 0; j < w; ++j) res += dp[h+1][j];
        printf("%d\n", res);
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstring>
 
using namespace std;
 
const int MAX = 20;
int in[MAX][MAX], X,Y,data[MAX][MAX],ans;
int dx[4] = {-1,0,1};
 
 
void init(){
  memset(data,0,sizeof(data));
  ans = 0;
}
 
 
void solve(){
  for(int i = 1; i <= Y; i++)
    for(int j = 1; j <= X; j++){
      for(int k = 0; k < 3; k++)
	if(in[i][j] == 2){
	  if(in[i+2][j] != 1) data[i+2][j] += data[i][j];
	  break;
	}else if(in[i][j] == 0){
	  int nex = j+dx[k];
	  if(nex < 1 || nex > X) continue;

	  if(in[i+1][nex] == 2 && dx[k] == 0) data[i+1][nex] += data[i][j];
	  if(in[i+1][nex] == 0) data[i+1][nex] += data[i][j];

	}
    }
  
  for(int j = 1; j <= X; j++){
    if(Y-1 > 0 && in[Y-1][j] == 2) ans+=data[Y-1][j];
    ans+=data[Y][j];
  }
  cout << ans << endl;
}
 
void print(){
  for(int i = 1; i <= Y; i++){
    for(int j = 1; j <= X; j++)
      cout << data[i][j]<< " ";
    cout << endl;
  }
}
int main(){
  while(cin >> X >> Y && X+Y){
    init();
    for(int i = 1; i <= Y; i++)
      for(int j = 1; j <= X; j++)
    cin >> in[i][j];
     
    for(int i = 1; i <= X; i++)
      if(in[1][i] == 0) data[1][i] = 1;
 
    solve();
    //print();
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n, m;
	while (true){
		cin >> n >> m;
		if (n == 0 && m == 0){
			break;
		}
		int map[100][100] = { 0 };
		int dp[100][100] = { 0 };
		for (int i = 0; i < n; i++){
			for (int i2 = 0; i2 < m; i2++){
				cin >> map[i][i2];
			}
		}
		for (int i = 0; i < n; i++){
			if (map[0][i] == 0){
				dp[0][i] = 1;
			}
		}
		for (int i = 0; i < m-1; i++){
			for (int i2 = 0; i2 < n; i2++){
				if (map[i][i2] == 0){
					if (map[i + 1][i2] == 0 || map[i + 1][i2] == 2){
						dp[i + 1][i2] += dp[i][i2];
					}
					if (i2+1<m&&map[i + 1][i2 + 1] == 0){
						dp[i + 1][i2 + 1] += dp[i][i2];
					}
					if (i2 - 1 >= 0 && map[i + 1][i2 - 1] == 0){
						dp[i + 1][i2 - 1] += dp[i][i2];
					}
				}
				if (map[i][i2] == 2){
					if (map[i + 2][i2] == 0 || map[i + 2][i2] == 2){
						dp[i + 2][i2] += dp[i][i2];
					}
				}
			}
		}
		for (int i = 0; i < n; i++){
			if (map[m - 1][i]==2){
				dp[m + 1][i] += dp[m - 1][i];
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++){
			ans += dp[m - 1][i];
			ans += dp[m][i];
			ans += dp[m + 1][i];
		}
		cout << ans << endl;
	}
}