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 <cstring>

using namespace std;

int main()
{
    int X, Y;

    while (cin >> X >> Y, X || Y) {
        int grid[Y + 2][X + 2];

        // 0: 移動可能 1: 障害物がある 2: ジャンプ台がある
        for (int i = 0; i <= Y + 1; ++i) {
            for (int j = 0; j <= X + 1; ++j) {
                if (i == 0 || j == 0 || j == X + 1)
                    grid[i][j] = 1;
                else if (i == Y + 1)
                    grid[i][j] = 0;
                else
                    cin >> grid[i][j];
            }
        }

        int cnt[Y + 2][X + 2];

        memset(cnt, 0, sizeof(cnt));
        for (int i = 1; i <= X; ++i)
            if (grid[1][i] != 1)
                cnt[1][i] = 1;

        for (int i = 1; i < Y; ++i) {
            for (int j = 1; j <= X; ++j) {
                if (grid[i][j] == 0) {
                    for (int k = -1; k <= 1; ++k)
                        if (grid[i + 1][j + k] == 0 || (k == 0 && grid[i + 1][j + k] == 2))
                            cnt[i + 1][j + k] += cnt[i][j];
                }
                else if (grid[i][j] == 2 && grid[i + 2][j] != 1)
                    cnt[i + 2][j] += cnt[i][j];
            }
        }

        int ans = 0;
        for (int i = 1; i <= X; ++i)
            ans += cnt[Y][i] + cnt[Y + 1][i];

        cout << ans << endl;
    }


    return 0;
}

C++: #include <iostream>

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 = 1;i <= y;i++ ){
			for( int j = 1;j <= x;j++ ){
				cin >> stage[j][i][0];
			}
		}

		for( int i = 0;i < 17;i++ ) if(stage[i][1][0] != 1 ) stage[i][1][1] = 1;

		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 ){
					if( stage[i][j + 1][0] != 1 ) stage[i][j + 1][1] += stage[i][j][1];
					
					if( stage[i + 1][j + 1][0] == 0 && ( i + 1 ) <= x ) stage[i + 1][j + 1][1] += stage[i][j][1];
					if( stage[i - 1][j + 1][0] == 0 && ( i - 1 ) >= 1 ) stage[i - 1][j + 1][1] += stage[i][j][1];

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

C++: #include <cstdio>
#include <cstring>
#define NORMAL 0
#define TREE 1
#define JUMP 2
#define DR_NUM 3 // 方向数

using namespace std;

const int dy[DR_NUM] = {1,1,1}, dx[DR_NUM] = {-1,0,1};

int main(void){
	int x, y, course[15][15], dp[17][15], i, j, k, l, ans;
	while(1){
		scanf("%d%d",&x,&y);
		if(x == 0 && y == 0){
			break;
		}
		for(i = 0;i < y;i++){
			for(j = 0;j < x;j++){
				scanf("%d",&course[i][j]);
			}
		}
		ans = 0;
		memset(dp,0,sizeof(dp));
		for(i = 0;i < x;i++){
			dp[0][i] = 1;
		}
		for(j = 0;j < y - 1;j++){
			for(k = 0;k < x;k++){
				if(course[j][k] == NORMAL){
					for(l = 0;l < DR_NUM;l++){
						if(k + dx[l] >= 0 && k + dx[l] < x && course[j + dy[l]][k + dx[l]] != TREE && !(l != 1 && course[j + dy[l]][k + dx[l]] == JUMP)){
							dp[j + dy[l]][k + dx[l]] += dp[j][k];
						}
					}
				}else if(course[j][k] == JUMP && course[j + 2][k] != TREE){
					dp[j + 2][k] += dp[j][k];
				}
			}
		}
		for(i = 0;i < x;i++){
			ans += dp[y - 1][i] + dp[y][i] + dp[y + 1][i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
typedef long long Int;

int a[20][20];
int dp[20][20];

int main() {
  for (;;) {
      memset(dp, 0, sizeof(dp));
      memset(a, 0, sizeof(a));
      int C, R; cin >> C >> R;
      if ((C | R) == 0) break;
      REP(r, R) REP(c, C) cin >> a[r][c];

      REP(c, C) if (a[0][c] == 0) dp[0][c] = 1;
      REP(r, R - 1) {
          REP(c, C) if (a[r][c] == 0) {
              if (c - 1 >= 0) dp[r + 1][c - 1] += dp[r][c];
              if (c + 1 <  C) dp[r + 1][c + 1] += dp[r][c];

              int d = 1;
              while (a[r + d][c] == 2) d += 2;
              dp[r + d][c] += dp[r][c];
          }
      }

      Int ans = 0;
      REP(c, C) {
          if (a[R - 1][c] == 0) ans += dp[R - 1][c];
          ans += dp[R][c];
          ans += dp[R + 1][c];
      }

      cout << ans << endl;

  }
  return 0;
}

C++: #include<iostream>
using namespace std;

#define MAX 15
#define BLANK 0
#define TREE 1
#define JUMP 2

int main(){
 int field[MAX+2][MAX+2],pass[MAX+2][MAX+2];
 int X,Y,i,j,n;
 for(i=0;i<MAX+2;i++){
   field[i][0]=TREE;
   field[i][1]=TREE;
   field[0][i]=TREE;
   field[MAX+1][i]=TREE;
 }
 while(cin>>X>>Y,X|Y){
  for(j=2;j<Y+2;j++)for(i=1;i<X+1;i++)cin>>field[i][j];
  for(j=2;j<Y+2;j++)for(i=1;i<X+1;i++)pass[i][j]=0;
  for(j=0;j<Y+2;j++)field[X+1][j]=TREE;
  for(i=0;i<X+2;i++)pass[i][2]=1;
  for(j=2;j<Y+2;j++){
   for(i=1;i<X+1;i++){
    if(field[i][j]==TREE)continue;
    if(field[i][j]==JUMP){
     if(field[i][j-1]==BLANK)pass[i][j]+=pass[i][j-1];
     if(field[i][j-2]==JUMP)pass[i][j]+=pass[i][j-2];
     continue;
    }
    if(field[i-1][j-1]==BLANK)pass[i][j]+=pass[i-1][j-1];
    if(field[i][j-1]==BLANK)pass[i][j]+=pass[i][j-1];
    if(field[i+1][j-1]==BLANK)pass[i][j]+=pass[i+1][j-1];
    if(field[i][j-2]==JUMP)pass[i][j]+=pass[i][j-2];
   }
  }
  n=0;
  for(i=1;i<X+1;i++){
   if(field[i][Y]==JUMP)n+=pass[i][Y];
   n+=pass[i][Y+1];
  }
/*
for(j=2;j<Y+2;j++){
for(i=1;i<X+1;i++)
{
cout<<pass[i][j]<<" ";
}
cout<<endl;
}
*/
  cout<<n<<endl;
 }
}