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 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 - 1; i++){
			for (int i2 = 0; i2 < n; i2++){
				if (map[i][i2] == 0){
					if (map[i + 1][i2] == 0 || map[i + 1][i2] == 2){
						dp[i + 1][i2] += dp[i][i2];
					}
					if (i2+1<m&&map[i + 1][i2 + 1] == 0){
						dp[i + 1][i2 + 1] += dp[i][i2];
					}
					if (i2 - 1 >= 0 && map[i + 1][i2 - 1] == 0){
						dp[i + 1][i2 - 1] += dp[i][i2];
					}
				}
				if (map[i][i2] == 2){
					if (map[i + 2][i2] == 0 || map[i + 2][i2] == 2){
						dp[i + 2][i2] += dp[i][i2];
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++){
			ans += dp[m - 1][i];
			ans += dp[m][i];
		}
		cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int x,y,a[17][17],s,i,j;
void dfs(int y1,int x1){
  if(x1<1||x1>x)return;
  if(y1>=y){s++;return;}
  if(a[y1][x1]==2)dfs(y1+2,x1);
  else {if(a[y1+1][x1]!=1)dfs(y1+1,x1);
  if(a[y1+1][x1+1]==0)dfs(y1+1,x1+1);
  if(a[y1+1][x1-1]==0)dfs(y1+1,x1-1);}
  return;
}
int main(){
  while(cin>>x>>y,x){
    for(s=0,i=0;i<17;i++)for(j=0;j<17;j++)a[i][j]=0;    
    for(s=0,i=1;i<=y;i++)for(j=1;j<=x;j++)cin>>a[i][j];
    for(i=1;i<=x;i++){if(a[1][i]==0)dfs(1,i);}
    cout<<s<<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+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&&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!=-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 y;
    if(data[y][x]==1) break;
    if(data[y][x]==0) return y;
    if(data[y][x]==2) y+=2;
  }
  return -1;
}

C++: #include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);
#define sintttt(i,j,k,m) scanf("%d%d%d%d",&i,&j,&k,&m);

#define INF 1010000000
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
	while(1){
		int n,m;
		sintt(n,m);
		if(n==0)break;
		int masu[17][17];
		int dp[17][17];
		
		rep(i,17)rep(j,17)masu[i][j]=dp[i][j]=0;
		
		rep(i,m)rep(j,n){
			sint(masu[j+1][i]);
		}
		
		reps(j,n){
			if(masu[j][0]!=1){
				dp[j][0]=1;
			}
		}
		
		rep(i,m-1){
			reps(j,n){
				if(masu[j][i]==1){
					dp[i][j]=0;
					continue;
				}
				if(masu[j][i]==2){
					if(masu[j][i+2]!=1){
						dp[j][i+2]+=dp[j][i];
					}
					continue;
				}
				if(masu[j][i]==0){
					if(masu[j-1][i+1]==0){
						dp[j-1][i+1]+=dp[j][i];
					}
					if(masu[j+1][i+1]==0){
						dp[j+1][i+1]+=dp[j][i];
					}
					
					if(masu[j][i+1]!=1){
						dp[j][i+1]+=dp[j][i];
					}
				}
			}
		}
		
		int ans=0;
		for(int i=m-1;i<=m;i++){
			reps(j,n){
				ans+=dp[j][i];
			}
		}
		printf("%d\n",ans);
		
		rep(i,m+2){
			rep(j,n+2){
				printf("%d ",dp[j][i]);
			}puts("");
		}
	}
}

C++: #include <cstdio>
#include <cstring>
typedef long long ll;
int x, y;
ll dp[20][20];
int mp[20][20];
int main() {
  while (scanf("%d%d",&x,&y)) {
    if (!x&&!y) break;
    memset(dp, 0, sizeof(dp));
    memset(mp, 0, sizeof(mp));
    for (int i=0; i<y; i++) {
      for (int j=0; j<x; j++) scanf("%d",&mp[i][j]);
    }
    for (int i=0; i<x; i++) if (mp[0][i]!=1) dp[0][i]=1;
    ll res = 0;
    for (int i=0; i<y-1; i++) {
      for (int j=0; j<x; j++) {
        if (mp[i][j]==2&&mp[i+2][j]!=1) {
          dp[i+2][j]+=dp[i][j];
        } else if (mp[i][j]==0) {
          if (j-1>=0&&mp[i+1][j-1]==0) dp[i+1][j-1]+=dp[i][j];
          if (mp[i+1][j]!=1) dp[i+1][j]+=dp[i][j];
          if (j+1<x&&mp[i+1][j+1]==0) dp[i+1][j+1]+=dp[i][j];
        }
      }
    }
    for (int i=0; i<x; i++) res+=dp[y][i]+dp[y-1][i];
    printf("%lld\n",res);
  }
}

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

using namespace std;

int field[16][16];
// y,xÌ}X©çènßÄÅ«é·×èûÌ
int dp[16][16];

const int dy[]={1,1,1};
const int dx[]={-1,0,1};
int w,h;

int search(int sx,int sy){
	if(field[sy][sx]==2){
		if(sy>=h-2){
			return 1;
		}
		else if(field[sy+2][sx]==1)
			return 0;
		else{
			return search(sx,sy+2);
		}
	}
	if(dp[sy][sx]!=-1){
		return dp[sy][sx];
	}
	int cnt=0;
	for(int i = 0; i < 3; i++){
		int nx=sx+dx[i];
		int ny=sy+dy[i];
		if(nx>=0&&nx<w&&field[ny][nx]!=1){
			if(ny>h-1){
				cnt++;
			}
			else if(ny==h-1&&field[ny][nx]==0){
				cnt++;
			}
			else if(field[ny][nx]==2&&dx[i]==0){
				cnt+=search(nx,ny);
			}
			else if(field[ny][nx]==0){
				cnt+=search(nx,ny);
			}
		}
	}

	dp[sy][sx]=cnt;
	return dp[sy][sx];
}


int main(){

	while(cin>>w>>h&&!(w==0&&h==0)){
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin>>field[i][j];
				dp[i][j]=-1;
			}
		}
		int sum=0;
		for(int i = 0; i < w; i++){
			if(field[0][i]==0)
				sum+=search(i,0);
		}
		cout<<sum<<endl;
	}

	return 0;
}