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()
{
    while(1)
    {
        int x,y,ans=0;
        int dp[17][17]={0};
        int course[17][17]={0};
        cin>>x>>y;if(!x)return 0;
        for(int j=0;j<y;++j){
            for(int i=0;i<x;++i){
            	cin>>course[i][j];
            	if(!course[i][0])dp[i][0]=1;
            }
        }
        for(int j=0;j<y-1;++j){
            for(int i=0;i<x;++i){
                if(!course[i][j]){
                    if(course[i][j+1]!=1)dp[i][j+1]+=dp[i][j];
                    if(i){
                        if(!course[i-1][j+1])dp[i-1][j+1]+=dp[i][j];
                    }
                    if(i<x){
                        if(!course[i+1][j+1])dp[i+1][j+1]+=dp[i][j];
                    }
                }
                if(course[i][j]==2){
                    if(course[i][j]!=1)dp[i][j+2]+=dp[i][j];
                }
            }
        }
        for(int j=y-1;j<y+2;++j){
            for(int i=0;i<x;++i){
                ans+=dp[i][j];
            }
        }
        cout<<ans<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
  int x, y;
  while (cin >> x >> y, x){
    int map[32][32];
    for (int i = 1; i <= y; i++){
      for (int j = 1; j <= x; j++){
        cin >> map[i][j];
      }
    }

    int dp[32][32] = {0};
    for (int j = 1; j <= x; j++) dp[1][j] = (map[1][j] == 1 ? 0 : 1);
    for (int i = 1; i < y; i++){
      for (int j = 1; j <= x; j++){
        if (map[i][j] == 1) continue;
        if (map[i][j] == 2){
          dp[i + 2][j] = dp[i][j];
          continue;
        }
        
        for (int k = -1; k < 2; k++){
          if (map[i + 1][j + k] == 2 && k) continue;
          if (map[i + 1][j + k] == 1) continue;
          dp[i + 1][j + k] += dp[i][j];
        }
      }
    }

    int ans = 0;
    for (int j = 1; j <= x; j++){
      ans += dp[y][j] + dp[y + 1][j];
    }

    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <cstring>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
const int MAX_Y = 30;
const int MAX_X = 30;
int mx, my, c[MAX_Y][MAX_X], dp[MAX_Y][MAX_X];

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

int dfs(int y, int x) {  
  int res = 0;
  if (y == my - 1) return 1;
  
  if (c[y][x] == 2) {
    if (y+2 >= my - 1) return 1;
    res += dfs(y+2, x);
    return res;
  }
  
  rep(z,3) {
    int tx = x + dx[z], ty = y + dy[z];
    if (tx < 0 || ty < 0 || tx >= mx || ty >= my) continue;
    if (c[ty][tx] == 1) continue;
    if (c[ty][tx] == 2 && tx != x) continue;
    res += dfs(ty, tx);
  }

  return res;
}

void solve() {
  memset(dp, -1, sizeof dp);
  rep(i,my) rep(j,mx) cin>>c[i][j];

  int res = 0;
  rep(i,mx) {
    if (c[0][i] == 1) continue;
    res += dfs(0, i);
  }
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>mx>>my, mx||my) {
    solve();
  }
  return 0;
}

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

int x, y;
int map[MAX_XY + 1][MAX_XY + 1], dp[MAX_XY + 1][MAX_XY + 1];

void resetStr();
void makeDp();
void dispAns();

int main(){
    while(cin >>x >>y){
        if(x == 0 && y == 0) break;
        resetStr();
        for(int i = 0; i < y; i++){
            for(int j = 0; j < x; j++){
                cin >>map[i][j];
            }
        }
        makeDp();
        dispAns();
    }
}

void resetStr(){
    for(int i = 0; i <= MAX_XY; i++){
        for(int j = 0; j <= MAX_XY; j++){
            map[i][j] = -1;
            dp[i][j] = 0;
        }
    }
}

void makeDp(){
    int xm[] = {-1, 0, 1}, ym[] = {-1, -1, -1};
    for(int i = 0; i < x; i++){
        if(map[0][i] == 0) dp[0][i]++;
    }
    for(int i = 1; i < y; i++){
        for(int j = 0; j < x; j++){
            if(map[i][j] == 2){
                dp[i][j] += dp[i - 1][j];
                int xn = j, yn = i + 2;
                if(xn >= 0 && yn >= 0 && xn < x && yn < y) dp[yn][xn] = dp[i][j];
                else dp[y - 1][xn] = dp[i][j];
            } else if(map[i][j] == 0){
                for(int k = 0; k < 3; k++){
                    int xn = j + xm[k], yn = i + ym[k];
                    if(xn >= 0 && yn >= 0 && xn < x && yn < y && map[yn][xn] == 0) dp[i][j] += dp[yn][xn];
                }
            }
        }
    }
}

void dispAns(){
    int ans = 0;
    for(int i = 0; i < x; i++){
        ans += dp[y - 1][i];
    }
    cout <<ans <<endl;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main()
{
  int x, y;
  while (cin >> x >> y, x){
    int map[32][32];
    for (int i = 1; i <= y; i++){
      for (int j = 1; j <= x; j++){
        cin >> map[i][j];
      }
    }

    int dp[32][32] = {0};
    for (int j = 1; j <= x; j++) dp[1][j] = 1;
    for (int i = 1; i <= y; i++){
      for (int j = 1; j <= x; j++){
        if (map[i][j] == 1) continue;
        if (map[i][j] == 2){
          dp[i + 2][j] = dp[i][j];
          continue;
        }

        for (int k = -1; k < 2; k++){
          if (map[i + 1][j + k] == 2 && k) continue;
          dp[i + 1][j + k] += dp[i][j];
        }
      }
    }

    int ans = 0;
    for (int j = 1; j <= x; j++){
      ans += dp[y][j];
    }

    cout << ans << endl;
  }
}