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>
#include <algorithm>

using namespace std;

int dw[3] = {-1,0,1};

int main(){
    int w,h;

    while(cin >> w >> h){
        if(!(w|h)) break;
        int field[h+2][w+2];
        int dp[h+2][w+2];
        int kind;
        long long ret=0;
        fill((int *)field, (int *)field+(h+2)*(w+2), 1);
        fill((int *)dp, (int *)dp+(h+2)*(w+2), 0);

        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin >> field[i][j];
            }
        }

        for(int i=1;i<=w;i++){
            if(field[1][i] == 0) dp[1][i] = 1;
        }
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                kind = field[i][j];
                if(kind == 0){
                    for(int k=0;k<3;k++){
                        if(field[i+1][j+dw[k]] == 0 || 
                           (field[i+1][j+dw[k]] == 2 && k == 1)){
                            dp[i+1][j+dw[k]] += dp[i][j];
                        }
                    }
                }else if(kind == 2){
                    if(i != h-1){
                        dp[i+2][j] += dp[i][j];
                    }else{
                        ret += dp[i][j];
                    }
                }
            }
        }

        for(int i=1;i<=w;i++){
            ret += dp[h][i];
        }
        cout << ret << endl;
    }
}

C++: # define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

int main()
{
	const int M = 20;
	while (true)
	{
		int x, y;
		int a[M][M];

		cin >> x >> y;
		if (!x&&!y)break;

		FOR(i, M)FOR(j, M)
		{
			a[i][j] = 1;
		}

		FORI(i, 1, y + 1)FORI(j, 1, x + 1)
		{
			cin >> a[i][j];
		}
		FORI(i, 1, x + 1)
		{
			a[y + 1][i] = 0;
		}
		int ans[M][M] = {};
		FORI(i, 1, x + 1)
		{
			if (a[1][i] == 0)ans[1][i] = 1;
		}
			
		FORI(i, 1, y)
		{
			FORI(j, 1, x + 1)
			{
				switch (a[i][j])
				{
				case 0:
					FORI(k, -1, 1 + 1)
					{
						if (a[i+1][j + k] == 0)
						{
							ans[i+1][j + k] += ans[i][j];
						}
					}
					if (a[i + 1][j] == 2)
					{
						ans[i + 1][j] += ans[i][j];
					}
					break;
				case 1:
					ans[i][j] = 0;
					break;
				case 2:
					if (a[i + 2][j] != 1)
					{
						ans[i + 2][j] += ans[i][j];
					}
					break;
				}
			}
		}

		int ANS = 0;
		FORI(i, 1, x + 1)
		{
			ANS += ans[y][i]+ans[y+1][i];
		}
		cout << ANS << endl;



	}
}

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

using namespace std;

int main(){
  int x, y, course[50][50], route[52][52], i, j, sum;
  while(cin >> x >> y, x+y){
    sum = 0;
    for(i=0; i<52; i++){
      for(j=0; j<52; j++){
        route[i][j] = 0;
      }
    }
    for(i=0; i<y; i++){
      for(j=0; j<x; j++){
        cin >> course[i][j];
      }
    }
    for(i=0; i<y; i++){
      for(j=0; j<x; j++){
	if(i==0){
          if(course[i][j]==0){
            route[i][j] = 1;
          }else{
	    route[i][j] = 0;
          }
        }else{
          if(j==0){
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j+1]==0){
                route[i][j] += route[i-1][j+1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
	        route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
            }
          }else if(j==x-1){
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j-1]==0){
                route[i][j] += route[i-1][j-1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
	        route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
            }
          }else{
            if(course[i][j]==0){
              if(course[i-1][j]==0){
                route[i][j] += route[i-1][j];
              }
              if(course[i-1][j-1]==0){
                route[i][j] += route[i-1][j-1];
              }
              if(course[i-1][j+1]==0){
                route[i][j] += route[i-1][j+1];
              }
	    }else if(course[i][j]==1){
              route[i][j] = 0;
            }else{
              if(course[i-1][j]==0){
                route[i][j] = route[i-1][j];
                route[i+2][j] += route[i][j];
              }
              if(course[i-2][j]==2){
                route[i][j] = route[i-2][j];
                route[i+2][j] += route[i][j];
              }
            }
          }
        }
      }
    }
    for(i=y-1; i<y+2; i++){
      for(j=0; j<x; j++){
        sum+=route[i][j];
      }
    }
    cout << sum << endl;
  }
  return 0;
}