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++: // 2011/10/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;
		if(X==0&&Y==0)
			break;

		int C[18][17];
		for(int i=0; i<=Y+2; i++)
			for(int j=0; j<=X+1; j++)
				C[i][j] = 1;

		for(int i=1; i<=Y; i++)
			for(int j=1; j<=X; j++)
				cin >> C[i][j];

		for(int i=Y+1; i<=Y+2; i++)
			for(int j=1; j<=X; j++)
				C[i][j] = 0;

		int DP[18][17];
		for(int i=0; i<=Y+2; i++)
			for(int j=0; j<=X+1; j++)
				DP[i][j] = 0;

			for(int j=1; j<=X; j++)
				if(C[1][j]==0)
					DP[1][j] = 1;

		for(int i=2; i<=Y; i++)
			for(int j=1; j<=X; j++)
				if(C[i][j]==0){
					DP[i][j] += (DP[i-1][j-1]+DP[i-1][j]+DP[i-1][j+1]);
				}
				else if(C[i][j]==1){
					DP[i][j] = 0;
				}
				else if(C[i][j]==2){
					DP[i+2][j] += (DP[i-1][j]+DP[i][j]);
					DP[i][j] = 0;
				}

		int sum = 0;
		for(int i=Y; i<=Y+2; i++)
			for(int j=1; j<=X; j++)
				sum += DP[i][j];

		cout << sum <<endl;
	}

	return 0;
}

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

using namespace std;

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

int main() {
    while (1) {
        int dp[17][15] = { 0 };
        int field[15][15] = { 0 };
        int h, w;

        cin >> w >> h;
        if (w == 0) {
            break;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> field[i][j];
            }
        }
        
        for (int j = 0; j < w; j++) {
            if (field[0][j] != 1) {
                dp[0][j] = 1;
            }
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (dp[i][j] > 0) {
                    if (i == h - 1) {
                        dp[i + 1][j] = dp[i][j];
                        continue;
                    }
                    if (field[i][j] == 2) {
                        if (field[i + 2][j] != 1) {
                            dp[i + 2][j] += dp[i][j];
                        }
                        continue;
                    }
                    for (int k = 0; k < 3; k++) {
                        int nx = j + dx[k];
                        int ny = i + dy[k];
                        if (nx < 0 || nx >= w) {
                            continue;
                        }
                        if (field[ny][nx] == 0 || (field[ny][nx] == 2 && k == 1)) {
                            dp[ny][nx] += dp[i][j];
                        }
                    }
                }
            }
        }
        
        int ans = 0;
        //for (int i = h; i <= h + 1; i++) {
            for (int j = 0; j < w; j++) {
                ans += dp[h][j];
            }
            //}
        cout << ans << endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int field[20][20];
int 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];
	} 
      }
    }
    int sum = 0;
    for (int i = 0; i <= 1; i++) {
      for (int j = 1; j <= c2; j++) {
	if (i != 0 || field[c1 + i][j] != 1) {
	  sum += dp[c1 + i][j];
	}
      }
    }
    
    printf("%d\n", sum);
  }
}

C++: #include <bits/stdc++.h>

using namespace std;

int X, Y;
int MapData[15][15];
int DpCount[16][15];

void solve() {
	int col, sum;
	int dx[] = { -1,0,1 };

	memset(DpCount, 0, sizeof(DpCount));
	for (int j = 0; j < X; ++j) {
		if (MapData[Y - 1][j] == 1) {
			continue;
		}
		DpCount[Y - 1][j] = 1;
	}

	for (int i = Y - 2; i >= 0; --i) {
		for (int j = 0; j < X; ++j) {
			if (MapData[i][j] == 1) {
				continue;
			}

			if (MapData[i][j] == 2) {
				if (i == Y - 2) {
					DpCount[i][j] = 1;
				}
				else {
					DpCount[i][j] = DpCount[i + 2][j];
				}
				continue;
			}

			sum = 0;
			for (int k = 0; k < 3; ++k) {
				col = j + dx[k];
				if (col < 0 || col > X - 1) {
					continue;
				}
				if (k != 1 && MapData[i + 1][col] == 2) {
					continue;
				}
				sum += DpCount[i + 1][col];
			}
			DpCount[i][j] = sum;
		}
	}

	sum = 0;
	for (int j = 0; j < X; ++j) {
		sum += DpCount[0][j];
	}
	cout << sum << endl;
}

int main() {

	while (cin >> X >> Y, X) {
		for (int i = 0; i < Y; ++i) {
			for (int j = 0; j < X; ++j) {
				cin >> MapData[i][j];
			}
		}
		solve();
	}

	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int field[20][20], dis[20][20];
	int i, j;
	int x, y;
	int 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", &field[i][j]);
				dis[i][j] = 0;
			}
		}
		
		for (i = 0; i < x; i++){
			if (field[0][i] == 0) dis[0][i] = 1;
		}
		for (i = 0; i < x; i++) dis[y][i] = 0;
		
		for (i = 0; i < y - 1; i++){
			for (j = 0; j < x; j++){
				
				if (field[i][j] == 2 && field[i + 2][j] != 1){
					dis[i + 2][j] = dis[i][j];
				}
				else{
					if (field[i + 1][j] != 1){
						dis[i + 1][j] += dis[i][j];
					}
					if (j != x - 1 && field[i + 1][j + 1] == 0){
						dis[i + 1][ j + 1] += dis[i][j];
					}
					if (j != 0 && field[i + 1][j - 1] == 0){
						dis[i + 1][ j - 1] += dis[i][j];
					}
				}
			}
		}
		ans = 0;
		
		for (i = 0; i < x; i++){
			ans += dis[y - 1][i];
			ans += dis[y][i];
		}
		
		printf("%d\n", ans);
	}
	return (0);
}