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> 
#define N 15
using namespace std;
void func(int,int);
int jump(int,int);
int X,Y,data[N][N],memo[N+2][N];
int main(){
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++)
	cin >> data[i][j];
    for(int i=0;i<Y+2;i++)
      for(int j=0;j<X;j++)
	memo[i][j]=0;
    for(int i=0;i<X;i++)
      if(data[0][i]!=1)
	func(0,i);
    int cnt=0;
    for(int i=0;i<X;i++)
      cnt+=memo[0][i];
    cout << cnt << endl;
  }
  return 0;
}
void func(int y,int x){
  if(y>=Y-1){
    memo[Y][x]=memo[Y-1][x]=1;
    return ;
  }
  if(0<=x-1&&data[y+1][x-1]==0){
    if(memo[y+1][x-1]!=0) memo[y][x]+=memo[y+1][x-1];
    else{
      func(y+1,x-1),memo[y][x]+=memo[y+1][x-1];
    }
  }
  if(x+1<=X-1&&data[y+1][x+1]==0){
    if(memo[y+1][x+1]!=0) memo[y][x]+=memo[y+1][x+1];
    else{
      func(y+1,x+1),memo[y][x]+=memo[y+1][x+1];
    }
  }
  if(data[y+1][x]==0){
    if(memo[y+1][x]!=0) memo[y][x]+=memo[y+1][x];
    else{
      func(y+1,x),memo[y][x]+=memo[y+1][x];
    }
  }
  if(data[y+1][x]==2){
    int r=jump(y+1,x);
    if(r==-2) memo[y][x]+=1;
    else if(r!=-1){
      if(memo[r][x]!=0) memo[y][x]+=memo[r][x];
      else{
	func(r,x),memo[y][x]+=memo[r][x];
      }
    }
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  y+=2;
  while(1){
    if(y>=Y-1) return -2;
    if(data[y][x]==1) break;
    if(data[y][x]==0) return y;
    if(data[y][x]==2) y+=2;
  }
  return -1;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n,m;
	int masu[17][17];
	int ura[17][17];
	
	while( cin>>m>>n, n != 0 && m != 0 ){
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				masu[i][j]=ura[i][j]=0;
			}
		}
		
		for(int i=0;i<n;i++){
			for(int j=1;j<=m;j++){
				cin>>masu[i][j];
			}
		}
		
		for(int j=1;j<=m;j++){
			if(masu[0][j]!=1){
				ura[0][j]=1;
			}
		}
		
		
		for(int i=0;i<n-1;i++){
			for(int j=1;j<=m;j++){
				if(masu[i][j]==0){
					if(masu[i+1][j-1]==0){
						ura[i+1][j-1]+=ura[i][j];
					}
					if(masu[i+1][j]!=1){
						ura[i+1][j]+=ura[i][j];
					}
					if(masu[i+1][j+1]==0){
						ura[i+1][j+1]+=ura[i][j];
					}
				}
				
				if(masu[i][j]==2){
					if(masu[i+2][j]!=1){
						ura[i+2][j]+=ura[i][j];
					}
				}
			}
		}
		int cont=0;
		for(int i=1;i<=m;i++){
			cont+=ura[n][i]+ura[n-1][i];
		}
		
		/*
		
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				printf("%2d ",ura[i][j]);
			}
			puts("");
		}*/
		printf("%d\n",cont);
	}
	
}

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

int tt[20][20];
int dp[20][20][20];
int W,H;

int rec(int x,int y,int px){
	if( x < 0 || x >= W ) return 0;
	if( tt[y][x] == 1 ) return 0;
	if( y >= H-1 ) return 1;
	
	if( tt[y][x] == 2 && x != px ) return 0;
	if( dp[x][y][px] != -1 ) return dp[x][y][px];
	int ans = 0;
	if( tt[y][x] == 2 ){
		ans += rec(x,y+2,x);
	}else{
		ans += rec(x,y+1,x);
		ans += rec(x+1,y+1,x);
		ans += rec(x-1,y+1,x);
	}
	return dp[x][y][px] = ans;
}

int main(){
	while(cin >> W >> H&&(W||H)){
		memset(dp,-1,sizeof(dp));
		for(int i = 0 ; i < H ; i++){
			for(int j = 0 ; j < W ; j++)
				cin >> tt[i][j];
		}
		int ans = 0;
		for(int i = 0 ; i < W ; i++){
			ans += rec(i,0,0);
		}
		cout << ans << endl;
		//return 0;
		
	}
}

C++: #include<iostream>
using namespace std;
int solve(int x,int y);
int ax,ay;
int mas[16][16];
int memo[16][16];
int main(){
  while(1){
    int ans=0;
    for(int i=0;i<16;i++){
      for(int j=0;j<16;j++){
	memo[i][j]=0;
      }
    }
    cin>>ax>>ay;
    if(ax==0 && ay==0){
      break;
    }
    for(int i=0;i<ay;i++){
      for(int j=0;j<ax;j++){
	cin>>mas[i][j];
      }
    }
    for(int i=0;i<ax;i++){
      if(mas[0][i]!=1){
	ans+=solve(i,0);
      }
    }
    cout<<ans<<endl;
  }
}
int solve(int x,int y){
  if(memo[y][x]!=0){
    return memo[y][x];
  }
  else if(y==ay){
    return 1;
  }else if(mas[y][x]==1){
    return 0;
  }else if(mas[y][x]==2){
    return solve(x,y+2);
  } 
  else{
    int anss=0; 
    if(mas[y+1][x]!=1){
      anss+=solve(x,y+1);
    }
    if(x+1<ax && mas[y+1][x+1]==0 && y+1!=ay){
      anss+=solve(x+1,y+1);
    }
    if(0<=x-1 && mas[y+1][x-1]==0 && y+1!=ay){
      anss+=solve(x-1,y+1);
    }
    return memo[y][x]=anss;
  }
}

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

int main() {
	int x, y;
	while (cin >> x >> y, x, y) {
		vector<vector<int>> course(y + 2, vector<int>(x + 2, 0));
		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				cin >> course[i][j];
			}
		}

		vector<vector<int>> path(y + 2, vector<int>(x + 2, 0));
		//?????????????????????????????????1????????????
		for (int i = 1; i <= x; i++) {
			if (course[1][i] != 1) path[1][i] = 1;
		}

		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				//????????????????????´????????????????????´??????????????????????????????????????????
				//?????????????§????????????????????????´?????????????????????????????£????????°?????´????????????????????????
				if (course[i][j] == 0) {
					if (course[i + 1][j + 1] == 0) path[i + 1][j + 1] += path[i][j];
					if (course[i + 1][  j  ] != 1) path[i + 1][  j  ] += path[i][j];
					if (course[i + 1][j - 1] == 0) path[i + 1][j - 1] += path[i][j];
				}
				//?¬???????????????´???????????£????????°????????????????????????????????????
				//?????????????????£????????§??´??????????????´???????????????(?????£?????????????????????????????´???????????????)
				if (course[i][j] == 2 && course[i+2][j] != 1) {
					path[i + 2][j] += path[i][j];
					if(i + 2 > y && i != y) path[y][j] += path[i][j];
				}
				//???????????´???????????????????????????????????????
				if(course[i][j] == 1){/*do anything*/}
			}
		}

		cout << accumulate(path[y].begin()+1, path[y].end()-1, 0) << endl;

	}
}