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>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int x,y;
  while(cin>>x>>y,x+y){
    int Map[y+10][x+10]={};
    int Map2[y+10][x+10]={};
    for(int i=0;i<y;i++)
      for(int j=0;j<x;j++){
	cin>>Map2[i][j];
	if(i==0&&Map2[i][j]==0)
	  Map[i][j]=1;
      }
    for(int i=0;i<y-1;i++){
      for(int j=0;j<x;j++){
	if(Map2[i][j]==0){
	  if(Map2[i+1][j+1]==0)
	    Map[i+1][j+1]+=Map[i][j];
	  if(Map2[i+1][j]!=1)
	    Map[i+1][j]+=Map[i][j];
	  if(j-1>=0&&Map2[i+1][j-1]==0)
	    Map[i+1][j-1]+=Map[i][j];
	}else if(Map2[i][j]==2){
	  if(Map2[i+2][j]!=1)
	    Map[i+2][j]+=Map[i][j];
	}
      }
    }
    ll ans=0;
    for(int i=y-1;i<=y;i++)
      for(int j=0;j<x;j++)
	ans+=Map[i][j];
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n, m;
	while (true){
		cin >> n >> m;
		if (n == 0 && m == 0){
			break;
		}
		int map[100][100] = { 0 };
		int dp[100][100] = { 0 };
		for (int i = 0; i < n; i++){
			for (int i2 = 0; i2 < m; i2++){
				cin >> map[i][i2];
			}
		}
		for (int i = 0; i < n; i++){
			if (map[0][i] == 0){
				dp[0][i] = 1;
			}
		}
		for (int i = 0; i < m; i++){
			for (int i2 = 0; i2 < n; i2++){
				if (map[i][i2] == 0){
					for (int i3 = -1; i3 <= 1; i3++){
						if (i2 + i3 >= 0 && i2 + i3 < n && (map[i + 1][i2 + i3] == 0 || i3 == 0 && map[i + 1][i2 + i3] == 2)&&(i<m-1||i3==0)){
							dp[i + 1][i2+i3]  += dp[i][i2];
						}
					}	
				}
				else if (map[i][i2] == 2){
							dp[i + 2][i2] += dp[i][i2];
					}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++){
			ans += dp[m][i];
			ans += dp[m+1][i];
		}
		cout << ans << endl;
	}
}

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][N];
int main(){
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)memo[i][j]=0;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j];
    for(int i=0;i<X;i++)
      if(data[0][i]==0) 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-1][x]=1;
    return ;
  }
  if(0<=x-1&&data[y+1][x-1]==0){
    if(memo[y+1][x-1]==0) func(y+1,x-1);
    memo[y][x]+=memo[y+1][x-1];
  }
  if(x+1<X&&data[y+1][x+1]==0){
    if(memo[y+1][x+1]==0) 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) 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) func(r,x);
      memo[y][x]+=memo[r][x];
    }
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(data[y][x]==1) break;
    if(y>=Y-1) return -2;
    if(data[y][x]==0) return y;
  }
  return -1;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n,m;
	int masu[17][17];
	int ura[17][17];
	cin>>n>>m;
	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>
using namespace std;
 
int main(){
        int x,y;
        while(cin>>x>>y,x){
                int D[16][16],P[16][16],ans=0;
                for(int i=0;i<256;i++)P[i/16][i%16]=0;
                for(int i=0;i<y;i++)for(int j=0;j<x;j++)cin>>D[i][j];
                for(int i=0;i<x;i++)if(!D[0][i])P[0][i]=1;
                for(int i=0;i<y-1;i++){
                        for(int j=0;j<x;j++){
                                if(!D[i][j]){
                                        P[i+1][j]+=P[i][j];
                                        if(j>0&&!D[i+1][j-1])P[i+1][j-1]+=P[i][j];
                                        if(j<x-1&&!D[i+1][j+1])P[i+1][j+1]+=P[i][j];
                                }
                                if(D[i][j]==2){
                                        if(i==y-2) ans += P[i][j];
                                        else P[i+2][j]+=P[i][j];
                                }
                        }
                }
                for(int i=0;i<x;i++){
                        if (D[y - 1][i] != 1)ans+=P[y-1][i];
                }
                cout<<ans<<endl;
        }
}