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()
{
	int next[3]={-1,0,1};
	int x,y,i,j;
	
	for(;;)
	{
		cin >> x >> y ;
		if(x==0 && y==0)
			break;
		int map[20][20]={0};
		int ansmap[20][20]={0};
		int ans=0;
		for(i=0;i<y;i++)
		{
			for(j=0;j<x;j++)
			{
				cin >> map[i][j] ;
			}
		}
		for(i=0;i<x;i++)
		{
			ansmap[0][i]=1;
		}
		for(i=0;i<y;i++)
		{
			for(j=0;j<x;j++)
			{
				if(i==0)
				{
					if(map[i][j]==1)
					{
						ansmap[i][j]=0;
					}
					else if(map[i][j]==2)
					{
						ansmap[i+2][j]+=ansmap[i][j];
					}
					else if(map[i][j]==0 && i<y-1)
					{
						for(int k=0;k<3;k++)
						{
							if(j+next[k]>=0 && j+next[k]<x)
							{
								if(map[i+1][j+next[k]]==0)
								{
									ansmap[i+1][j+next[k]]+=ansmap[i][j];
								}
								else if(map[i+1][j+next[k]]==2 && next[k]==0)
								{
									ansmap[i+1][j]+=ansmap[i][j];
								}
							}
						}
					}
				}
				else
				{
					if(map[i][j]==1)
					{
						ansmap[i][j]=0;
					}
					else if(map[i][j]==2)
					{
						ansmap[i+2][j]+=ansmap[i][j];
					}
					else if(map[i][j]==0 && i<y-1)
					{
						for(int k=0;k<3;k++)
						{
							if(j+next[k]>=0 && j+next[k]<x)
							{
								if(map[i+1][j+next[k]]==0)
								{
									ansmap[i+1][j+next[k]]+=ansmap[i][j];
								}
								else if(map[i+1][j+next[k]]==2 && next[k]==0)
								{
									ansmap[i+1][j+next[k]]+=ansmap[i][j];
								}
							}
						}
					}
				}
			}
		}
		for(i=-1;i<1;i++)
		{
			for(j=0;j<x;j++)
			{
				ans+=ansmap[y+i][j];
			}
		}
		cout << ans << endl;
	}
}

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

int maps[20][20];
int course[20][20];
int X, Y;

int way(int y, int x){
  if(course[y][x] > 0) return course[y][x];
  else if(maps[y][x] == 1) return 0;
  else if(y >= Y) return 1;
  else if(maps[y][x] == 2 && maps[y + 2][x] != 1) return course[y][x] = way(y + 2, x);
  else{
    int SUM = 0;
    for(int i = 0; i < 3; i++){
      int ny = y + 1;
      int nx = x - 1 + i;
      if(maps[ny][nx] != 1 && 1 <= nx && nx <= X){
	int flug = 1;
	if(i != 1 && maps[ny][nx] == 2) flug = 0;
	if(flug) SUM += way(ny, nx);
      }
    }
    return course[y][x] = SUM;
  }
} 

int main(){
  while(1){
    cin >> X >> Y;
    if(X == 0 && Y == 0) break;
    for(int i = 1; i <= Y; i++){
      for(int j = 1; j <= X; j++){
	cin >> maps[i][j];
	course[i][j] = 0;
      }
    }
    int cnt = 0;
    for(int i = 1; i <= X; i++){
      if(maps[0][i] != 1) cnt += way(1, i);
    }
    cout << cnt << endl;
  }
}

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

using namespace std;

#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main(){
    int w,h;
    while(cin>>w>>h, w||h){
        int G[100][100]={};
        int dp[100][100]={};

        rep(i,h)rep(j,w) cin>> G[i][j];
        rep(i,w) dp[0][i] = G[0][i]==0;

        rep(i,h-1) rep(j,w){
            if( G[i][j]==1){
                dp[i][j]=0;
            } else if(G[i][j]==2 && G[i+2][j]!=1){
                dp[i+2][j]+=dp[i][j];
            } else {
                if(G[i+1][j]==2) dp[i+1][j]+=dp[i][j];
                loop(k,-1,2){
                    if(0<=j+k && j+k<w && G[i+1][j+k]==0){
                        dp[i+1][j+k]+=dp[i][j];
                    }
                }
            }
        }

        ull res=0;
        for(int i: {h-1,h}) rep(j,w){
            res+=dp[i][j];
        }

        cout<<res<<endl;
    }
}

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

int X, Y;
int a[15][15];
int b[16][15];

bool input() {
  cin >> X >> Y;
  if (!X && !Y) {
    return false;
  }
  for (int y = 0; y < Y; ++y) {
    for (int x = 0; x < X; ++x) {
      cin >> a[y][x];
    }
  }
  return true;
}

void solve() {
  for (int y = 0; y <= Y; ++y) {
    for (int x = 0; x < X; ++x) {
      b[y][x] = 0;
    }
  }
  for (int x = 0; x < X; ++x) {
    if (a[0][x] != 1) {
      b[0][x] = 1;
    }
  }

  for (int y = 0; y < Y - 1; ++y) {
    for (int x = 0; x < X; ++x) {
      if (!a[y][x]) {
        for (int dx = -1; dx <= 1; ++dx) {
          int nx = x + dx;
          if (nx >= 0 && nx < X && !a[y + 1][nx]) {
            b[y + 1][nx] += b[y][x];
          }
        }
        if (a[y + 1][x] == 2) {
          b[y + 1][x] += b[y][x];
        }
      } else if (a[y][x] == 2) {
        if (a[y + 2][x] != 1) {
          b[y + 2][x] += b[y][x];
        }
      }
    }
  }

  int ans = 0;
  for (int y = Y - 1; y <= Y; ++y) {
    for (int x = 0; x < X; ++x) {
      ans += b[y][x];
    }
  }
  cout << ans << endl;
}

int main() {
  while (input()) {
    solve();
  }
}

C++: #include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int m[500][500];
int dp[500][500];

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

int solve(int r,int c){
  rep(i,r+1)rep(j,c)dp[i][j]=0;
  rep(j,c)if(m[0][j] == 0)dp[0][j]=1;

  rep(i,r-1){
    rep(j,c){
      if (m[i][j] == 0){
	rep(k,3){
	  int nex = j+dx[k];
	  if (nex<0||nex>=c)continue;
	  if (m[i+1][nex] == 0)dp[i+1][nex]+=dp[i][j];
	  else if (m[i+1][nex] == 2 && k == 1)dp[i+1][nex]+=dp[i][j];
	}
      }else if (m[i][j] == 2){
	dp[i+2][j]+=dp[i][j];
      }
    }
  }
  
  int ans = 0;
  rep(j,c)ans+=dp[r][j]+dp[r-1][j];
  return ans;
}

main(){
  int c,r;
  while(cin>>c>>r && r){
    rep(i,r)rep(j,c)cin>>m[i][j];
    rep(j,c)m[r][j]=0;
    cout << solve(r,c) << endl;
  }
}