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 <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <climits>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++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+1, vi(w, 0));
		rep(i, h) rep(j, w)
			scanf("%d", &field[i][j]);
		
		vvi dp(h+1, vi(w, 0));
		rep(i, w)
			dp[0][i] = field[0][i] == 0;
		
		rep(i, h-1){
			rep(j, w){
				if(field[i][j] == 0){
					const int dx[] = {-1, 0, 1};
					rep(k, 3){
						int px = j + dx[k];
						if(px<0 || w<=px || field[i+1][px] == 1 || (dx[k]!=0 && field[i+1][px]==2))
							continue;
						dp[i+1][px] += dp[i][j];
					}
				}
				else if(field[i][j] == 2){
					if(i+1<h && field[i+2][j] != 1)
						dp[i+2][j] += dp[i][j];
				}
			}
		}
		
		int sum = 0;
		rep(i, 2) rep(j, w)
			sum += dp[h-i][j];
		printf("%d\n", sum);
	}
	return 0;
}

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

using namespace std;

const int MOVE = 0;
const int BARRIIER = 1;
const int JUMP = 2;

int course[15][15];
int prog[15][15];
int sizeX, sizeY;
int answer = 0;

void init() {
  for (int i = 0; i < 15; i++) {
    for (int j = 0; j < 15; j++) {
      prog[i][j] = 0;
      course[i][j] = -1;
    }
  }
}

void inputCourse() {
  for (int i = 0; i < sizeY; i++) {
    for (int j = 0; j < sizeX; j++) {
      cin >> course[i][j];
    }
  }
}

int main(int argc, char* argv[]) {
  while (cin >> sizeX >> sizeY, sizeX) {
    init();
    inputCourse();
    answer = 0;
    for (int x = 0; x < sizeX; x++) {
      if (course[0][x] == MOVE) {
        prog[0][x] = 1;
      }
    }
    for (int y = 0; y < sizeY; y++) {
      for (int x = 0; x < sizeX; x++) {
        if (course[y][x] == MOVE) {
          if (y + 1 >= sizeY) {
            answer += prog[y][x];
          } else {
            if (course[y + 1][x] == MOVE || course[y + 1][x] == JUMP) {
              prog[y + 1][x] += prog[y][x];
            }
            if (x - 1 >= 0 && course[y + 1][x - 1] == MOVE) {
              prog[y + 1][x - 1] += prog[y][x];
            }
            if (x + 1 < sizeX && course[y + 1][x + 1] == MOVE) {
              prog[y + 1][x + 1] += prog[y][x];
            }
          }
        }
        if (course[y][x] == JUMP) {
          if (y + 2 >= sizeY) {
            answer += prog[y][x];
          } else {
            prog[y + 2][x] += prog[y][x];
          }
        }
      }
    }
    cout << answer << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int solve(int x,int y);
int ax,ay;
int mas[200][200];
int 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;
      }
    }
    int 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{
    int 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 <iostream>

using namespace std;

int main() {
	int width, height, m[15][15];
	while (cin >> width >> height, width && height) {
		for (int y = 0; y < height; ++y)
			for (int x = 0; x < width; ++x)
				cin >> m[y][x];

		int sum = 0, pattern[15][15] = {0};
		for (int x = 0; x < width; ++x)
			pattern[0][x] = 1;

		for (int y = 0; y < height-1; ++y)
			for (int x = 0; x < width; ++x)
				if (m[y][x] == 0) {
					if (x - 1 >= 0 && m[y+1][x-1] == 0) pattern[y+1][x-1] += pattern[y][x];
					if (x + 1 < width && m[y+1][x+1] == 0) pattern[y+1][x+1] += pattern[y][x];
					if (m[y+1][x] != 1) pattern[y+1][x] += pattern[y][x];
				}
				else if (m[y][x] == 2) {
					if (y + 2 == height) sum += pattern[y][x];
					else if (m[y+2][x] != 1) pattern[y+2][x] += pattern[y][x];
				}

		for (int x = 0; x < width; ++x)
			sum += pattern[width-1][x];

		cout << sum << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20],memo[20][20];
int dx[] = {-1,0,1};

void saiki(int x,int y) {
  if(y >= h-1) memo[y][x]++;
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = dx[i]+x, ny = y+1;
      if(nx <0|| nx >= w ||mp[ny][nx] == 1) continue;
      if(memo[ny][nx] > 0 && mp[ny][nx] == 0) memo[y][x] += memo[ny][nx];
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	memo[y][x] += memo[ny][nx];
      }
      else if(nx==x && mp[ny][nx] == 2){
	int ty = ny;
	while(mp[ty][nx] == 2) ty+=2;
	if(mp[ty][nx] == 0 && memo[ty][nx] == 0){
	  saiki(nx,ty);
	  memo[y][x] += memo[ty][nx];
	}
	else if(mp[ty][nx] == 0 && memo[ty][nx] > 0) memo[y][x] += memo[ty][nx];
      }
    }
    if(memo[y][x] == 0) mp[y][x] = -1;
  }
}
  
int main() {
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    for(int i=0;i<=19;i++)
      for(int j=0;j<=19;j++)memo[i][j] = mp[i][j] = 0;
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> mp[i][j];
 
    for(int i=0;i<w;i++) 
      if(mp[0][i] !=1) saiki(i,0);
    
    int cnt = 0;
    for(int i=0;i<w;i++)
      if(memo[0][i] > 0) cnt+=memo[0][i];
    cout <<cnt<<endl;
  }
  return 0;
}