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 <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) {
          dp[i+2][j]+=dp[i][j];
        } else {
          if (j!=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!=x-1&&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 <cstdio>
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int i,j,x,y,a[16][15],n[15][15],k,ans;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    for(i=0;i<y;i++){
      for(j=0;j<x;j++){
    cin >> n[i][j];
      }
    }
 
    for(j=0;j<x;j++){
      for(i=0;i<=y;i++) a[i][j] = 0;
      if(n[0][j] == 0) a[0][j] = 1;
    }
 
    for(i=0;i<y;i++){
      for(j=0;j<x;j++){
    if(n[i][j] == 1) continue;
    if(i == y-1) a[i+1][j] += a[i][j];
    else if(n[i][j] == 0){
      for(k=-1;k<=1;k++){
        if(j == 0 && k == -1 || j == x-1 && k == 1) continue;
        if(n[i+1][j+k] == 0) a[i+1][j+k] += a[i][j];
      }
      if(n[i+1][j] == 2) a[i+1][j] += a[i][j];
    }
    else if(n[i][j] == 2){
      if(n[i+2][j] != 1) a[i+2][j] += a[i][j];
    }
      }
    }
 
    ans = 0;
    for(j=0;j<x;j++) ans += a[y][j];
    cout << ans << endl;
 
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	for(;;){
		int x, y;
		int map[100][100];
		int dp[100][100];
		
		cin >> x;
		cin >> y;
		if(x == 0 && y == 0){
			break;
		}
		
		for(int i = 0; i < y; i++){
			for(int j = 0; j < x; j++){
				cin >> map[i][j];
			}
		}
		
		//ツ鳴催渉可づ可暗ェツ氾板湘」ツづ個療アツづ個づつィツづィツ青板づーツ個按津ィ
		//0:ツ暗堋督ョツ嘉つ能
		//1:ツ湘。ツ害ツ閉ィ
		//2:ツジツδδδ督プツ妥、
		
		for(int i = 0; i < x; i++){
			if(map[0][i] == 0){
				dp[0][i] = 1;
			}
			else{
				dp[0][i] = 0;
			}
		}
		for(int i = 1; i < y; i++){
			for(int j = 0; j < x; j++){
				//ツ配ツ療アツ外ツアツクツセツスツづーツづ「ツづ淞づヲツつ、
				if(j == 0){
					if(map[i][j] == 1){
						dp[i][j] = 0;
					}
					else if(map[i][j] == 0){
						if(map[i-1][j] == 2 ||map[i-1][j+1] == 2){
							if(map[i-1][j] == 2 || map[i-1][j-1] == 2 || map[i-1][j+1] == 2){
								if(map[i-1][j] == 2){
									dp[i][j] = dp[i-1][j+1];
								}
								if(map[i-1][j+1] == 2){
									dp[i][j] = dp[i-1][j];
								}
								if(map[i-1][j] == 2 && map[i-1][j+1] == 2){
									dp[i][j] = 0;
								}
							}
						}
						else{
							dp[i][j] = dp[i-1][j] + dp[i-1][j+1];
						}
						if(map[i-2][j] == 2){
							dp[i][j] += dp[i-2][j];
						}
					} 
					else if(map[i][j] == 2){
						dp[i][j] = dp[i-1][j];
					}
				}
				//ツつサツづェツ暗按外
				else{
					if(map[i][j] == 0){
						if(map[i-1][j] == 2 || map[i-1][j-1] == 2 || map[i-1][j+1] == 2){
							if(map[i-1][j] == 2){
								dp[i][j] = dp[i-1][j+1] + dp[i-1][j-1];
							}
							if(map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j] + dp[i-1][j+1];
							}
							if(map[i-1][j+1] == 2){
								dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
							}
							if(map[i-1][j] == 2 && map[i-1][j+1] == 2){
								dp[i][j] = dp[i-1][j-1];
							}
							if(map[i-1][j] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j+1];
							}
							if(map[i-1][j+1] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = dp[i-1][j];
							}
							if(map[i-1][j+1] == 2 && map[i-1][j] == 2 && map[i-1][j-1] == 2){
								dp[i][j] = 0;
							}
						}
						else{
							dp[i][j] = dp[i-1][j] + dp[i-1][j-1] + dp[i-1][j+1];
						}
						if(map[i-2][j] == 2){
							dp[i][j] += dp[i-2][j];
						}
					}
					else if(map[i][j] == 1){
						dp[i][j] = 0;
					}
					else if(map[i][j] == 2){
						dp[i][j] = dp[i-1][j];
						if(map[i-2][j] == 2){
							dp[i][j] += dp[i-2][j];
						}
					}
				}
			}
		}
		
		int ans = 0;
		
		for(int i = 0; i < x; i++){
			ans += dp[y-1][i];
		}
		
		for(int i = 0; i < x; i++){
			if(map[y-2][i] == 2){
				ans+= dp[y-2][i];
			}
		}
		
		cout << ans << endl;
	}
}

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

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int a[16][16];
int count = 0;
int n,m;

void dfs(int y,int x)
{
	if(a[y][x] == 0)
	{

		if(y == m-1)
		{
			count++;
			return;
		}
		if(x-1 >= 0 && y+1 < m)
		{
			if(a[y+1][x-1] != 2)
			{
				dfs(y+1,x-1);
			}
		}
		if(y+1 < m)
		{
			dfs(y+1,x);
		}
		if(x+1 < n && y+1 < m)
		{
			if(a[y+1][x+1] != 2)
			{
				dfs(y+1,x+1);
			}
		}
		return;
	}
	else if(a[y][x] == 1)
	{
		return;
	}
	else if(a[y][x] == 2)
	{
		if(y == m-2 || y == m-1)
		{
			count++;
			return;
		}
		else
		{
			dfs(y+2,x);
		}
	}
}

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

		memset(a,0,sizeof(a));
		rep(i,m)
		{
			rep(j,n)
			{
				cin >> a[i][j];
			}
		}
		count = 0;
		rep(i,n) dfs(0,i);

		cout << count << endl;
	}
	return 0;
}