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++: // AOJ 0203
#include <iostream>

using namespace std;

int main(void)
{
	int x, y;
	while (cin >> x >> y, x || y){
		int field[32][32];
		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				cin >> field[i][j];
			}
		}
		int dp[32][32];
		for (int i = 0; i < 32; i++) {
			for (int j = 0; j < 32; j++){
				dp[i][j] = 0;
			}
		}

		for (int j = 1; j <= x; j++){
			if (field[1][j] == 0){
				dp[1][j] = 1;
			}
		}
		for (int i = 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				if (field[i][j] == 1){
					continue;
				}
				if (field[i][j] == 2){
					dp[i + 2][j] += dp[i][j];
					continue;
				}
				if (field[i + 1][j - 1] == 0){
					dp[i + 1][j - 1] += dp[i][j];
				}
				if (field[i + 1][j] != 1){
					dp[i + 1][j] += dp[i][j];
				}
				if (field[i + 1][j + 1] == 0){
					dp[i + 1][j + 1] += dp[i][j];
				}
			}
		}

		// for (int i = 1; i <= y; i++){
		// 	for (int j = 1; j <= x; j++){
		// 		cout << dp[i][j] << " ";
		// 	}
		// 	puts("");
		// }

		int ret = 0;
		for (int i = y - 1; i <= y; i++){
			for (int j = 1; j <= x; j++){
				if (i == y - 1){
					if (field[i][j] == 2) ret += dp[i][j];
					continue;
				}
				else {
					ret += dp[i][j];
					// cout << i << " " << j << endl;
					// cout << ret << endl;
				}
			}
		}
		cout << ret << endl;
	}

	return 0;
}

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]==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<iostream>
//#include
using namespace std;

struct P{
	int way;
	int stt;
};

//グローバルは土俵F、と配列ans

P F[17][17];
//はじめにF.wayを-1で初期化 端っこ.sttを1で初期化

long ans[1000]={0};
int counter=0,flag=0;

long solve(int x,int y);

long jump(int x,int y){
	if(F[x][y-2].stt==2)
		return (F[x][y-2].way==-1) ? solve(x,y-2) : F[x][y-2].way;
	else return 0;
}

long left(int x,int y){
	if(F[x-1][y-1].stt==0) 
		return (F[x-1][y-1].way==-1) ? solve(x-1,y-1) : F[x-1][y-1].way;
	else return 0;
}

long right(int x,int y){
	if(F[x+1][y-1].stt==0) 
		return (F[x+1][y-1].way==-1) ? solve(x+1,y-1) : F[x+1][y-1].way;
	else return 0;
}

long samex(int x,int y){
	if(F[x][y-1].stt==0) 
		return (F[x][y-1].way==-1) ? solve(x,y-1) : F[x][y-1].way;
	else return 0;
}

long solve(int x,int y){//入力した座標までのコース数を返す 0は普通 1は障害物 2はジャンプ台
	if (y==1) return 1;
	if (F[x][y].stt==0)
	return jump(x,y)+left(x,y)+right(x,y)+samex(x,y);
	if (F[x][y].stt==2)
	return jump(x,y)+samex(x,y);
	if (F[x][y].stt==1)
	return 0;
	return 0;
}

//int solve_ex(int x,int y){//最後JUMP通過のとき jumpをそのまま使う


void solver(){
	int X,Y;
	cin >> X >> Y;
	if(X==0) {flag=1;return;}
	
	
	for(int i=0;i<17;i++){
		for(int j=0;j<17;j++){
			F[i][j].way=-1;
			F[i][j].stt=1;
		}
	}
	
	for(int i=1;i<=Y;i++){
		for(int j=1;j<=X;j++){
			cin >> F[j][i].stt;
		}
	}
	
	for(int x=1;x<=X;x++){
		ans[counter]+=(solve(x,Y)+jump(x,Y+1));
	}
	counter++;
}

int main(){
	while(flag==0){
		solver();
	}
	
	for(int i=0;i<counter;i++){
		cout << ans[i]<<"\n";
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[18][18];
int kosu[16][16];
int ans;

int main(){
  int x,y;
  
  while(1){
    cin>>x>>y;
    if(x==0 && y==0) break;
    
    fill(dp[0],dp[18],0);
    ans=0;
    
    for(int i=0;i<y;i++){
      for(int l=0;l<x;l++){
        cin>>kosu[i][l];
      }
    }
    for(int i=0;i<x;i++)
      if(kosu[0][i]==0) dp[0][i]=1;
    
    for(int i=1;i<y;i++){
      for(int l=0;l<x;l++){
        
        if(kosu[i][l]==2){
          dp[i+2][l]=dp[i-1][l]+dp[i-2][l]+dp[i][l];
          dp[i][l]=0;
        }
        else if(kosu[i][l]==0)
          dp[i][l]+=dp[i-1][l-1]+dp[i-1][l]+dp[i-1][l+1];
      }
    }
    
    for(int i=y;i<y+2;i++){
      for(int l=0;l<x;l++){
        dp[i][l]+=dp[i-1][l];
      }
    }
    for(int i=0;i<x;i++)
      ans+=dp[y+1][i];
    
    printf("%d\n",ans);
  }
  return 0;
}

C++: #include <cstdio>

int main(){
	while(true){
		int X, Y;
		scanf("%d%d", &X, &Y);
		if(X == 0 || Y == 0){ break; }
		int field[16][17] = { { 0 } };
		for(int y = 1; y <= Y; y++){
			for(int x = 1; x <= X; x++){
				scanf("%d", &(field[y][x]));
			}
		}
		int dp[16][17] = { { 0 } };
		for(int x = 1; x <= X; x++){
			if(field[1][x] != 1){ dp[1][x] = 1; }
		}
		for(int y = 2; y <= Y; y++){
			for(int x = 1; x <= X; x++){
				if(field[y][x] == 1){ continue; }
				int sum = 0;
				if(field[y][x] == 0){
					if(field[y - 1][x - 1] == 0){ sum += dp[y - 1][x - 1]; }
					if(field[y - 1][x + 1] == 0){ sum += dp[y - 1][x + 1]; }
				}
				if(field[y - 1][x] == 0){ sum += dp[y - 1][x]; }
				if(field[y - 2][x] == 2){ sum += dp[y - 2][x]; }
				dp[y][x] = sum;
			}
		}
		int answer = 0;
		for(int x = 1; x <= X; x++){
			if(field[Y - 1][x] == 2){ answer += dp[Y - 1][x]; }
			answer += dp[Y][x];
		}
		printf("%d\n", answer);
	}
	return 0;
}