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>

int map[15][15],table[15][15],X,Y;

int main(){
while(1){

scanf("%d%d",&X,&Y);
if(X==0&&Y==0) return 0;
memset(map,-1,sizeof(map));
memset(table,0,sizeof(table));
for(int i=0;i<Y;i++){
for(int j=0;j<X;j++){
scanf("%d",&map[i][j]);
if(i==0&&map[i][j]==0) table[i][j]=1;
else if(i!=0&&map[i][j]!=1){
if(j>0&&map[i-1][j-1]==0) table[i][j]+=table[i-1][j-1];
if(j<X-1&&map[i-1][j+1]==0) table[i][j]+=table[i-1][j+1];
if(map[i-1][j]==0)table[i][j]+=table[i-1][j];
if(i>2&&map[i-2][j]==2) table[i][j]+=table[i-2][j]; 
} 
}
}
int sum=0;
for(int i=0;i<X;i++){
sum+=map[Y-1][i];
}
printf("%d\n",sum);



}
}

C++: #include <iostream>

using namespace std;

int main() {
	int width, height, m[15][15];
	while (cin >> width >> height, width || height) {
		for (int y = 0; y < height; ++y)
			for (int x = 0; x < width; ++x)
				cin >> m[y][x];

		int sum = 0, pattern[15][15] = {0};
		for (int x = 0; x < width; ++x)
			pattern[0][x] = 1;

		for (int y = 0; y < height-1; ++y)
			for (int x = 0; x < width; ++x)
				if (m[y][x] == 0) {
					if (x - 1 >= 0) { if (m[y+1][x-1] == 0) pattern[y+1][x-1] += pattern[y][x]; }
					if (x + 1 < width) { if (m[y+1][x+1] == 0) pattern[y+1][x+1] += pattern[y][x]; }
					if (m[y+1][x] != 1) pattern[y+1][x] += pattern[y][x];
				}
				else if (m[y][x] == 2) {
					if (y + 2 == height) sum += pattern[y][x];
					else if (m[y+2][x] != 1) pattern[y+2][x] += pattern[y][x];
				};

		for (int x = 0; x < width; ++x)
			sum += pattern[width-1][x];

		cout << sum << endl;
	}
}

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

#define MAX_XY 16

int X, Y;
int field[MAX_XY][MAX_XY];
int way[MAX_XY][MAX_XY];

int main() {
	while (cin >> X >> Y, X || Y) {
		memset(field, 0, sizeof(field));
		memset(way, 0, sizeof(way));
		for (int i = 0; i < X; i++) {
			cin >> field[0][i];
			if (field[0][i] == 1) {
				way[0][i] = 0;
			} else {
				way[0][i] = 1;
			}
		}

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

		for (int i = 0; i < Y-1; i++) {
			for (int j = 0; j < X; j++) {
				if (field[i][j] == 2 && field[i+2][j] != 1) {
					way[i+2][j] += way[i][j];
				} else {
					if (1 <= j && field[i+1][j-1] == 0) {
						way[i+1][j-1] += way[i][j];
					}
					if (j < X-1 && field[i+1][j+1] == 0) {
						way[i+1][j+1] += way[i][j];
					}
					if (field[i+1][j] != 1) {
						way[i+1][j] += way[i][j];
					}
				}
			}
		}

//		for (int i = 0; i < Y; i++) {
//			for (int j = 0; j < X; j++) {
//				cout << way[i][j] << ' ';
//			}
//			cout << endl;
//		}

		int cnt = 0;
		for (int i = 0; i < X; i++) {
			cnt += way[Y-1][i];
		}
		for (int i = 0; i < X; i++) {
			if (field[Y-2][i] == 2) cnt += way[Y-2][i];
		}

		cout << cnt << endl;

	}
	return 0;
}

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:if(ura[3][i]==0){masu[3][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 <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int X,Y,m[15][17],dp[15][17];

int main(){
	while(cin>>X>>Y&&X){
		rep(i,Y)fill(dp[i],dp[i]+17,0);
		rep(i,Y)rep(j,X){
			cin>>m[i][j+1];
			if(!i&&!m[i][j+1])dp[i][j+1]=1;
		}
		for(int i=1;i<Y;i++)for(int j=1;j<=X;j++){
			if(m[i][j]==0){
				for(int k=-1;k<2;k++)if(m[i-1][j+k]==0)dp[i][j]+=dp[i-1][j+k];
				if(i>1&&m[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				if(i==Y-1&&m[i-1][j]==2)dp[i][j]+=dp[i-1][j];
			}
			if(m[i][j]==1&&i==Y-1&&m[i-1][j]==2)dp[i][j]+=dp[i-1][j];
			if(m[i][j]==2){
				if(m[i-1][j]==0)dp[i][j]=dp[i-1][j];
				if(i>1&&m[i-2][j]==2)dp[i][j]+=dp[i-2][j];
				if(i==Y-1&&m[i-1][j]==2)dp[i][j]+=dp[i-1][j];
			}
		}
		int ans=0;
		rep(i,X)ans+=dp[Y-1][i+1];
		cout<<ans<<endl;
	}
}

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

int course[15][15];
int pattern[16][16];

int main() {

  int X,Y,t,in;
  while(cin>>X>>Y, X|Y) {
    memset(course, 0, sizeof(course));
    memset(pattern, 0, sizeof(pattern));
    for(int i=0; i<Y; ++i) {
      for(int j=0; j<X; ++j) {
	cin>>in;
	course[i][j] = in;
      }
    }

    for(int i=Y-1; i>=0; --i) {
      for(int j=X-1; j>=0; --j) {
	if(i==Y-1) {
	  if(course[i][j] == 0)
	    pattern[i][j] = 1;
	} else if(i == Y-2 && course[i][j] == 2){
	  pattern[i][j] = 1;
	} else {
	  if(course[i][j] == 0) {
	    pattern[i][j] = pattern[i+1][j];
	    if(j > 0 && course[i+1][j-1] == 0)
	      pattern[i][j] += pattern[i+1][j-1];
	    if(j < X && course[i+1][j+1] == 0)
	      pattern[i][j] += pattern[i+1][j+1];
	  }
	  if(course[i][j] == 2 && course[i+2][j] != 1) {
	    pattern[i][j] = pattern[i+2][j];
	  }
	}
      }
    }

    /*
    cout<<endl;
    for(int i=0; i<Y; ++i) {
      for(int j=0; j<X; ++j) {
	cout<<pattern[i][j]<<" ";
      }
      cout<<endl;
    }
    cout<<endl;
    */
    int sum = 0;
    for(int i=0; i<X; ++i) {
      //cout<<pattern[0][i]<<" ";
      sum += pattern[0][i];
    }
    //cout<<endl;
    cout<<sum<<endl;
  }
}