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 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[height-1][x];

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

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, char const* argv[])
{
	int x,y;
	int stage[17][17][2];

	while( cin >> x >> y && x != 0 && y != 0 ){
		for( int i = 0;i < 17;i++ ){
			for( int j = 0;j < 17;j++ ){
				stage[i][j][0] = stage[i][j][1] = 0;
			}
		}
		
		for( int i = 0;i < 17;i++ ) stage[i][1][1] = 1;
		
		for( int i = 1;i <= y;i++ ){
			for( int j = 1;j <= x;j++ ){
				cin >> stage[j][i][0];
			}
		}

		for( int j = 1;j <= y;j++ ){
			for( int i = 1;i <= x;i++ ){
				if( stage[i][j][0] == 1 ) continue;
				if( stage[i][j][0] == 0 ){
					stage[i][j + 1][1] += stage[i][j][1];
					
					if( stage[i + 1][j + 1][0] == 0 && j != y ) stage[i + 1][j + 1][1] += stage[i][j][1];
					if( stage[i - 1][j + 1][0] == 0 && j != y ) stage[i - 1][j + 1][1] += stage[i][j][1];

				}
				if( stage[i][j][0] == 2 ){
					stage[i][j + 2][1] += stage[i][j][1];
				}
			}
		}
		int count = 0;
		for( int i = 0;i <= x+1;i++ ) count += stage[i][y+1][1];
		cout << count << endl;
	}
	return 0;
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=a&&a<b)
using namespace std;
int dx[]={-1,0,1};
int main(){
	int X,Y,c[15][15],land[15][15],ans;
	while(cin>>X>>Y,X){
		rep(i,Y)rep(j,X)cin>>land[i][j],c[i][j]=i==0&&land[i][j]!=1;
		rep(i,Y){
			rep(j,X)cout<<c[i][j]<<" "; cout<<endl;
		}
		rep(i,Y-1)rep(j,X)if(land[i+1][j]!=1){
			if(land[i+1][j]==2)c[i+1][j]+=c[i][j];
			else rep(d,3)if(ck(j+dx[d],X)&&land[i][j+dx[d]]==0)
			c[i+1][j]+=c[i][j+dx[d]];
			if(i>0&&land[i-1][j]==2)c[i+1][j]+=c[i-1][j];
		}
		ans=0;
		rep(i,X){
			ans+=c[Y-1][i];
			if(Y>1&&land[Y-2][i]==2)ans+=c[Y-2][i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

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

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

void initCourse() {
  for (int i = 0; i < 15; i++) {
    for (int j = 0; j < 15; j++) {
      course[i][j] = EMPTY;
    }
  }
}

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

void move(int x, int y) {
  if (course[y][x] == BARRIIER) {
    return;
  }
  if (y >= sizeY - 1) {
    answer++;
    return;
  }
  if (course[y][x] == JUMP) {
    move(x, y + 2);
  }
  if (course[y][x] == MOVE) {
    if ((x - 1) >= 0) {
      if (course[y + 1][x - 1] == MOVE) {
        move(x - 1, y + 1);
      }
    }
    if (course[y + 1][x] == MOVE || course[y + 1][x] == JUMP) {
      move(x, y + 1);
    }
    if ((x + 1) < sizeX) {
      if (course[y + 1][x + 1] == MOVE) {
        move(x + 1, y + 1);
      }
    }
  }
}

int main(int argc, char* argv[]) {
  while (cin >> sizeX >> sizeY, sizeX) {
    initCourse();
    inputCourse();
    answer = 0;
    for (int i = 0; i < sizeX; i++) {
      if (course[0][i] == MOVE) {
        move(i, 0);
      }
    }
    cout << answer << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<algorithm>


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

using namespace std;

int x,y;
int c[20][20];
int dp[20][20];

void solve() {
	rep(i,20) rep(j,20) c[i][j]=1;
	rep(i,20) rep(j,20) dp[i][j]=0;

	rep(i,y) rep(j,x) cin>>c[i][j];

	rep(i,x) if(c[0][i]!=1) dp[0][i]=1;
	
	for(int i=0;i<y;i++) {
		for(int j=0;j<x;j++) {
			if(c[i][j]==2) {
				dp[i+2][j] += dp[i][j];
			}
			else if(c[i][j]==0) {
				if(c[i+1][j]!=1) {
					dp[i+1][j] += dp[i][j];
				}
				if(0<=j-1 && c[i+1][j-1]==0) {
					dp[i+1][j-1] += dp[i][j];
				}
				if(j+1 < x && c[i+1][j+1]==0) {
					dp[i+1][j+1] += dp[i][j];
				}
			}
		}
	}


	int ans=0;
	rep(i,x) if(c[y-1][i]!=1) ans+=dp[y-1][i];
	rep(i,x) ans+=dp[y][i];

	cout<<ans<<endl;

}

int main() {
	while(cin>>x>>y) {
		if(x+y==0) return 0;
		solve();
	}
	return 0;
}