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 <vector>
using namespace std;
int main( void )
{
	int X, Y;
	while ( cin >> X >> Y && X && Y )
	{
		vector < vector <int> > map( Y, vector <int>(X, 0) );
		vector < vector <int> > dp( Y, vector <int>(X, 0) );
		for ( int i = 0; i < Y; i++ )
		{
			for ( int j = 0; j < X; j++ )
			{
				cin >> map[i][j];
			}
		}

		for ( int i = 0; i < X; i++ )
		{
			if ( map[0][i] == 0 )
				dp[0][i] = 1;
		}

		for ( int i = 0; i < Y-1; i++ )
		{
			for ( int j = 0; j < X; j++ )
			{
				if ( map[i][j] == 2 )
				{
					if ( i+2 < Y )
					{
						if ( map[i+2][j] != 1 )
							dp[i+2][j] += dp[i][j];
					}
					else
					{
						dp[Y-1][j] += dp[i][j];
					}
				}
				if ( map[i][j] == 0 )
				{
					if ( i+1 < Y )
					{
						if ( map[i+1][j] == 2 )
						{
							dp[i+1][j] += dp[i][j];
						}
					}
				}
				for ( int k = -1; k < 2; k++ )
				{
					if ( j+k<0 || j+k>=X )
						continue;

					if ( map[i][j] == 0 && map[i+1][j+k] == 0 )
					{
						dp[i+1][j+k] += dp[i][j];
					}
				}
			}
		}

		int answer = 0;
		for ( int i = 0; i < X; i++ )
		{
			answer += dp[Y-1][i];
		}

		cout << answer << endl;

	}
	return 0;
}

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

using namespace std;


	int n,m;
	int masu[17][17];
	int ura[17][17];
	
int motom(){
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				masu[i][j]=0;
			}
		}
		for(int i=1;i<=m;i++){
			switch(ura[1][i]){
				case 0:masu[1][i]+=1;break;
				case 1:masu[1][i]+=0;break;
				case 2:masu[1][i]+=1;break;
			}
		}
		for(int i=1;i<n;i++){
			for(int j=1;j<=m;j++){
				if(ura[i][j]==0){
					if(ura[i+1][j-1]==0){
						masu[i+1][j-1]+=masu[i][j];
					}
					if(ura[i+1][j]!=1){
						masu[i+1][j]+=masu[i][j];
					}
					if(ura[i+1][j+1]==0){
						masu[i+1][j+1]+=masu[i][j];
					}
				}else if(ura[i][j]==2){
					if(ura[i+2][j]!=1){
						masu[i+2][j]+=masu[i][j];
					}
				}
			}
		}
		
		int cont=0;
		for(int i=n;i<=n+1;i++){
			for(int j=1;j<=m;j++){
				cont+=masu[i][j];
			}
		}
		return cont;
}

int main(){
	srand(time(NULL));
	int cc=0;
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0){
			break;
		}
		for(int i=0;i<17;i++){
			for(int j=0;j<17;j++){
				masu[i][j]=0;
				ura[i][j]=0;
			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				scanf("%d",&ura[i][j]);
			}
		}
		
		printf("%d\n",motom());
	}
	
}

C++: #include <stdio.h>

int main(void){
	int x,y,i,j;
	while(scanf("%d%d",&x,&y),x,y){
		int masu[20][20]={ 0 };
		int dp[20][20]={0};
		int ans=0;
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++){
				scanf("%d",&masu[i][j]);
			}
		}
		for(i=0;i<=y;i++)masu[i][0]=1;
		for(j=0;j<=x;j++)masu[0][j]=1;
		
		for(j=1;j<=x;j++){
			if(masu[1][j]==0)dp[1][j]=1;
		}
		for(i=2;i<=y;i++){
			for(j=1;j<=x;j++){
				if(masu[i][j]==0){
					if(masu[i-1][j-1]!=2)dp[i][j]+=dp[i-1][j-1];
					if(masu[i-1][j]!=2)	 dp[i][j]+=dp[i-1][j];
					if(masu[i-1][j+1]!=2)dp[i][j]+=dp[i-1][j+1];
					if(masu[i-2][j]==2){
						dp[i][j]+=dp[i-2][j];
					}
				}
				if(masu[i][j]==1){
					dp[i][j]=0;
				}
				if(masu[i][j]==2){
					dp[i][j]=dp[i-1][j];
					if(masu[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				}
			}
		}
		for(i=1;i<=x;i++){
			ans+=dp[y][i];
			if(masu[y-1][i]==2)ans+=dp[y-1][i];
		}
		
		printf("%d\n",ans);
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int solve(int x,int y);
int ax,ay;
int mas[200][200];
long long memo[200][200];
int main(){
  while(1){
    for(int i=0;i<200;i++){
      for(int j=0;j<200;j++){
	memo[i][j]=0;
      }
    }
    long long ans=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{
    long long 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 <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

bool is_inside(int x, int y, int X, int Y){
	if(x < 0 || y < 0 || x >= X || y >= Y){
		return false;
	}
	return true;
}

int main(){
	
	int X, Y;
	
	int course[20][20];
	long long int sum[20][20];
	
	while(true){
		cin >> X >> Y;
		
		if(X == 0 && Y == 0){
			break;
		}
		
		for(int i = 0; i < Y; i++){
			for(int j = 0; j < X; j++){
				cin >> course[j][i];
				sum[j][i] = 0;
			}
		}
		
		for(int i = 0; i < X; i++){
			sum[i][0] = 1;
		}
		
		for(int y = 0; y < Y; y++){
			for(int x = 0; x < X; x++){
				if(course[x][y] == 0){
					for(int dx = -1; dx <= 1; dx++){
						if(is_inside(x + dx, y + 1, X, Y)){
							if(course[x + dx][y + 1] != 2 || dx == 0){
								sum[x + dx][y + 1] += sum[x][y];
							}
						}
					}
				}else if(course[x][y] == 2){
					if(is_inside(x, y + 2, X, Y)){
						sum[x][y + 2] += sum[x][y];
					}
				}else{
					sum[x][y] = 0;
				}
			}
		}
		
		long long int ans = 0;
		
		for(int i = 0; i < X; i++){
			if(course[i][Y - 1] == 0){
				ans += sum[i][Y - 1];
			}
			if(Y >= 2 && course[i][Y - 2] == 2){
				ans += sum[i][Y - 2];
			}
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}