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<string.h>
using namespace std;

int course[15][15];
int pattern[16][16];

int main() {

  int X,Y,t,in;
  while(cin>>X>>Y, X|Y) {
    memset(course, 0, sizeof(course));
    memset(pattern, 0, sizeof(pattern));
    for(int i=0; i<Y; ++i) {
      for(int j=0; j<X; ++j) {
	cin>>in;
	course[i][j] = in;
      }
    }

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

    /*
    cout<<endl;
    for(int i=0; i<Y; ++i) {
      for(int j=0; j<X; ++j) {
	cout<<pattern[i][j]<<" ";
      }
      cout<<endl;
    }
    cout<<endl;
    */
    int sum = 0;
    for(int i=0; i<X; ++i) {
      //cout<<pattern[0][i]<<" ";
      sum += pattern[0][i];
    }
    //cout<<endl;
    cout<<sum<<endl;
  }
}

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

int memo[16][16];

int calc(std::vector<std::vector<int> > &v, int x, int y){

	if (memo[x][y] != -1)return memo[x][y];
	int res = 0;
	if (x >= v[y].size() - 1)return 1;

	if (v[x][y] == 2)res += calc(v, x + 2, y);

	if (v[x][y] == 0){
		if (v[x + 1][y] == 0)res += calc(v, x + 1, y);
		else if (v[x + 1][y] == 2)res += calc(v, x + 1, y);

		if (y < v.size()-1 && v[x + 1][y + 1] == 0)res += calc(v, x + 1, y + 1);

		if (y > 0 && v[x + 1][y - 1] == 0)res += calc(v, x + 1, y - 1);
	}

	return memo[x][y]=res;
}


int main(){

	int x, y;
	while (std::cin >> x >> y){

		if (x == 0 && y == 0)break;

		int res = 0;
		std::vector<std::vector<int> >v(x, std::vector<int>(y));

		for (int i = 0; i < 16; i++){
			for (int j = 0; j < 16; j++){
				memo[i][j] = -1;
			}
		}

		for (int i = 0; i < x; i++){
			for (int j = 0; j < y; j++){
				std::cin >> v[i][j];
			}
		}

		for (int i = 0; i < v.size(); i++)res += calc(v, 0, i);

		std::cout << res << std::endl;
	}
	return 0;
}

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

using namespace std;

int x,y;
int fie[20][20];
long long int dp[20][20];
long long int ans=0;

int main(void){
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0)break;
		memset(fie,0,sizeof(fie));
		memset(dp,0,sizeof(dp));
		ans=0;

		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				scanf("%d",&fie[j][i]);
			}
		}
		for(int i=0;i<x;i++){
			if(fie[i][0]==0)dp[i][0]=1;
			if(fie[i][0]==2)dp[i][2]=1;
		}
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				if(fie[j][i]==0){
					for(int k=j-1;k<=j+1;k++){
						if(k>=0 && k<x){
							if(fie[k][i+1]==0){
								dp[k][i+1]+=dp[j][i];
							}
							if(fie[k][i+1]==2 && k==j){
								dp[k][i+1]+=dp[j][i];
							}
						}
					}
				}
				if(fie[j][i]==2){
					dp[j][i+2]+=dp[j][i];
				}
			}
		}
		for(int i=0;i<y;i++){
				for(int j=0;j<x;j++){
					if(i>=y-2 && fie[j][i]==2)ans+=dp[j][i];
					if(i==y-1 && fie[j][i]==0)ans+=dp[j][i];
			}
		}
		printf("%lld\n",ans);
	}
    return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	for(;;){
		int x, y;
		int map[100][100];
		int dp[100][100];
		
		cin >> x;
		cin >> y;
		if(x == 0 && y == 0){
			break;
		}
		
		for(int i = 0; i < y; i++){
			for(int j = 0; j < x; j++){
				cin >> map[i][j];
			}
		}
		
		//ツ鳴催渉可づ可暗ェツ氾板湘」ツづ個療アツづ個づつィツづィツ青板づーツ個按津ィ
		//0:ツ暗堋督ョツ嘉つ能
		//1:ツ湘。ツ害ツ閉ィ
		//2:ツジツδδδ督プツ妥、
		
		for(int i = 0; i < x; i++){
			if(map[0][i] == 0){
				dp[0][i] = 1;
			}
			else{
				dp[0][i] = 0;
			}
		}
		for(int i = 1; i < y; i++){
			for(int j = 0; j < x; j++){
				//ツ配ツ療アツ外ツアツクツセツスツづーツづ「ツづ淞づヲツつ、
				if(j == 0){
					if(map[i][j] == 1){
						dp[i][j] = 0;
					}
					else if(map[i][j] == 0){
						if(map[i-1][j] == 2 ||map[i-1][j+1] == 2){
							if(map[i-1][j] == 2 || map[i-1][j-1] == 2 || map[i-1][j+1] == 2){
								if(map[i-1][j] == 2){
									dp[i][j] = dp[i-1][j+1];
								}
								if(map[i-1][j+1] == 2){
									dp[i][j] = dp[i-1][j];
								}
							}
						}
						else{
							dp[i][j] = dp[i-1][j] + dp[i-1][j+1];
						}
						if(map[i-2][j] == 2){
							dp[i][j] += dp[i-2][j];
						}
					} 
					else if(map[i][j] == 2){
						dp[i][j] = dp[i-1][j];
					}
				}
				//ツつサツづェツ暗按外
				else{
					if(map[i][j] == 0){
						if(map[i-1][j] == 2 || map[i-1][j-1] == 2 || map[i-1][j+1] == 2){
							if(map[i-1][j] == 2){
								dp[i][j] = dp[i-1][j+1] + dp[i-1][j-1];
							}
							if(map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j] + dp[i-1][j+1];
							}
							if(map[i-1][j+1] == 2){
								dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
							}
							if(map[i-1][j] == 2 && map[i-1][j+1] == 2){
								dp[i][j] = dp[i-1][j-1];
							}
							if(map[i-1][j] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j+1];
							}
							if(map[i-1][j+1] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j];
							}
							if(map[i-1][j+1] == 2 && map[i-1][j] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = 0;
							}
						}
						else{
							dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + dp[i-1][j+1];
						}
						if(map[i-2][j] == 2){
							dp[i][j] += dp[i-2][j];
						}
					}
					else if(map[i][j] == 1){
						dp[i][j] = 0;
					}
					else if(map[i][j] == 2){
						dp[i][j] = dp[i-1][j];
						if(map[i-2][j] == 2){
							dp[i][j] += dp[i-2][j];
						}
					}
				}
			}
		}
		
		int ans = 0;
		
		for(int i = 0; i < x; i++){
			ans += dp[y-1][i];
		}
		
		for(int i = 0; i < x; i++){
			if(map[y-2][i] == 2){
				ans+= dp[y-2][i];
			}
		}
		
		cout << ans << endl;
	}
}