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<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>

using namespace std;

int main(){
	int n,m;
	int masu[17][17];
	int ura[17][17];
	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]);
			}
		}
		for(int i=1;i<=n;i++){
			switch(ura[1][i]){
				case 0:masu[1][i]+=1;break;
				case 1:masu[1][i]+=0;break;
				case 2:masu[2][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];
			}
		}
		printf("%d\n",cont);
	}
	
}

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

using namespace std;

int vis[15][15];

int bfs(int a[15][15], int n, int m, int s, int t)
{
  int c = 0;
  if(s+1 == n){
    vis[s][t] = 1;
    return 1;
  }

  if(vis[s][t] > 0){
    return vis[s][t];
  }

  if(a[s][t] == 2){
    if(s+2 >= n){
      vis[s][t] = 1;
      return 1;
    }
    c = bfs(a, n, m, s+2, t);
  } else {

    if(t-1 >= 0){
      if(a[s+1][t-1] == 0){
	c += bfs(a, n, m, s+1, t-1);
      }
    }
    if(a[s+1][t] != 1){
      c += bfs(a, n, m, s+1, t);
    }
    
    if(t+1 < m){
      if(a[s+1][t+1] == 0){
      c += bfs(a, n, m, s+1, t+1);
      }
    }
  }
  vis[s][t] = c;

  return c;
}

int main()
{
  int n, m, c;
  int a[15][15];

  while(1){
    cin >> m >> n;
    if(n == 0 && m == 0){
      break;
    }

    fill(&vis[0][0], &vis[14][14], -1);

    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
	cin >> a[i][j];
      }
    }
    c = 0;
    for(int i = 0; i < m; i++){
      if(a[0][i] != 1){
	c += bfs(a, n, m, 0, i);
      }
    }

    cout << c << endl;
  }


  return 0;
}

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


int main() {
    int field[16][17], pattern[17][17];
    int X, Y, i, j, k;

    while ((cin >> X >> Y) && X) {
        for (i = 1; i <= Y; i++) {
            field[i][0] = field[i][X+1] = 0;
            for (j = 1; j <= X; j++) {
                cin >> field[i][j];
            }
        }

        for (i = 2; i <= Y+1; i++) {
            for (j = 0; j <= X + 1; j++) {
                pattern[i][j] = 0;
            }
        }
        for (j = 1; j <= X; j++) {
            pattern[1][j] = field[1][j] == 0;
        }

        for (i = 1; i < Y; i++) {
            for (j = 1; j <= X; j++) {
                switch (field[i][j]) {
                    case 0:
                    for (k = -1; k <= 1; k++) {
                        switch (field[i+1][j+k]) {
                            case 0:
                            pattern[i+1][j+k] += pattern[i][j];
                            break;
                            case 2:
                            if (k == 0) {
                                pattern[i+1][j+k] += pattern[i][j];
                            }
                            break;
                            default: break;
                        }
                    }
                    break;
                    case 2:
                    pattern[i+2][j] += pattern[i][j];
                    break;
                    default: break;
                }
            }
        }
        /*
        for (i = 1; i <= Y; i++) {
            for (j = 1; j <= X; j++) {
                cout << " " << pattern[i][j];
            }
            cout << endl;
        }
        cout << endl;
        */
        int sum = 0;
        for (i = Y; i <= Y + 1; i++) {
            for (j = 1; j <= X; j++) {
                sum += pattern[i][j];
            }
        }
        cout << sum << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<utility>
#include<queue>
#include<functional>
#include<cstring>
#include<vector>
#include<climits>
#include<map>
using namespace std;
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
typedef pair<int,int> pii;
typedef vector<int> vi;


int main()
{
	while(1)
	{
		int a[20][20];
		int dp[20][20]={};
		int x,y;
		
		cin>>x>>y;if(!x)break;
		FOR(i,20)FOR(j,20)a[i][j]=1;
		FORI(i,1,y+1)
		{
			FORI(j,1,x+1)
			{
				cin>>a[i][j];
			}
		}
		FORI(i,1,x+1)
		{
			dp[1][i]=1;
			a[y+1][i]=0;
		}
		FORI(i,1,y)
		{
			FORI(j,1,x+1)
			{
				if(a[i][j]==2&&a[i+2][j]!=1)
				{
					dp[i+2][j]+=dp[i][j];
				}
				else if(a[i][j]==1)
				{
					dp[i][j]=0;
				}
				else
				{
					for(int k=-1;k<=1;k++)
					{
						if(a[i+1][j+k]==0)
						{
							dp[i+1][j+k]+=dp[i][j];
						}
					}
					if(a[i+1][j]==2)dp[i+1][j]+=dp[i][j];
				}
			}
		}
		
		int ans=0;
		FORI(i,1,x+1)ans+=dp[y][i]+dp[y+1][i];
		cout<<ans<<endl;
		
	}
}

C++: #include <iostream>
#include <queue>
#include <map>
#include <string.h>

using namespace std;

const int FIELD_MAX =15;

int X, Y;
int field[FIELD_MAX][FIELD_MAX];
int table[FIELD_MAX+1][FIELD_MAX];
int cnt = 0;

typedef pair<int, int> point;

void solve()
{
	memset(&table[0][0], 0, sizeof(int) * 15 * 16);
	for(int x=0; x<X; x++)
	{
		table[Y][x] = 1;
	}
	
	for(int y=Y; y>=1; y--)
	{	
		for(int x=0; x<X; x++){
			if(field[y][x] ==1)
			{
				continue;
			}
			
			if(y>=2){
				if(field[y-2][x]==2) table[y-2][x]+=table[y][x];
			}
			if(x>=1 && y!=Y && field[y][x] != 2){
				if(field[y-1][x-1]==0) table[y-1][x-1]+=table[y][x];
			}
			if(field[y-1][x]==0) table[y-1][x]+=table[y][x];
			if(x<X-1 && y!=Y && field[y][x] != 2){
				if(field[y-1][x+1]==0) table[y-1][x+1]+=table[y][x];
			}
		}
	}
	
	cnt = 0;
	for(int x=0; x<X; x++){
		cnt += table[0][x];
	}
}

int main()
{
	while( 1 )
	{
		cin >> X >> Y;
		if(X==0 && Y==0)
		{
			break;
		}
		
		for(int y=0; y<Y; y++)
		{
			for(int x=0; x<X; x++)
			{
				cin >> field[y][x];
			}
		}
		
		cnt = 0;
		solve();
		printf("%d\n", cnt);
	}
}