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>
using namespace std;

int solve(int f[20][20] ,int w ,int h ){
	int dp[20][20] = {0};
	for(int x=1 ; x <= w ; x++ ){
		dp[1][x] = 1;
	}

	for(int y=1 ; y <= h-1 ; y++ ){
		for(int x=1 ; x <= w ; x++ ){
			if( f[y][x] == 0 ){
				if( f[y+1][x-1] == 0 ) dp[y+1][x-1] += dp[y][x];
				if( f[y+1][x]   == 0 ) dp[y+1][x]   += dp[y][x];
				if( f[y+1][x+1] == 0 ) dp[y+1][x+1] += dp[y][x];
				if( f[y+1][x]   == 2 ) dp[y+1][x]   += dp[y][x];
			}else if( f[y][x] == 2 ){
				if( f[y+2][x] == 0 || f[y+2][x] == 2 ){
					dp[y+2][x] += dp[y][x];
				}
			}
		}
	}
	int ans = 0;
	for(int x=1 ; x <= w ; x++ ){
		ans += dp[h][x] + dp[h+1][x];
	}
	return ans;
}

int main(){
	int w,h;

	while( cin >> w >> h , w||h ){
		int f[20][20] = {0};
		for(int y=1 ; y <= h ; y++ ){
			for(int x=1 ; x <= w ; x++ ){
				cin >> f[y][x];
			}
		}

		int ans = solve( f , w , h );
		cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
int X,Y;
int fld[15][15];
int dp[15][15];
int main() {
	while(cin>>X>>Y&&X&&Y){
		for(int i=0;i<Y;i++)for(int j=0;j<X;j++)cin>>fld[j][i];
		int ans=0;
		for(int i=0;i<X;i++)if(fld[i][Y-1]!=1)dp[i][Y-1]=1;
		for(int y=Y-2;y>=0;y--){
			for(int x=0;x<X;x++){
				if(fld[x][y]==0){
					for(int k=-1;k<=1;k++){
						int nx=x+k;
						if(nx<0||nx>=X)continue;
						if(nx==x&&fld[nx][y+1]!=1)dp[x][y]+=dp[nx][y+1];
						else if(fld[nx][y+1]==0)dp[x][y]+=dp[nx][y+1];
					}
				}else if(fld[x][y]==2){
					if(y+2>=Y)dp[x][y]=1;
					else dp[x][y]=dp[x][y+2];
				}
				if(y==0)ans+=dp[x][y];
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int width,height,map[17][17],table[17][17],sum;

	while(true){
		scanf("%d %d",&width,&height);
		if(width == 0 && height == 0)break;

		for(int i = 0; i < 17; i++){
			for(int k = 0; k < 17; k++){
				table[i][k] = 0;
				map[i][k] = 2;
			}
		}

		for(int i = 1; i <= height; i++){
			for(int k = 1; k <= width; k++){
				scanf("%d",&map[i][k]);
				if(map[i][k] == 0){
					if(i == 1){
						table[i][k] = 1;
					}else{
						if(map[i-1][k-1] != 2){
							table[i][k] += table[i-1][k-1];
						}
						if(map[i-1][k] != 2){
							table[i][k] += table[i-1][k];
						}
						if(map[i-1][k+1] != 2){
							table[i][k] += table[i-1][k+1];
						}
						if(map[i-2][k] == 2){
							table[i][k] += table[i-2][k];
						}
					}
				}else if(map[i][k] == 1){
					table[i][k] = 0;
				}else{
					if(map[i-1][k] != 2){
						table[i][k] += table[i-1][k];
					}
					if(map[i-2][k] == 2){
						table[i][k] += table[i-2][k];
					}
				}
			}
		}

		sum = 0;

		for(int k = 1; k <= width; k++){
			sum += table[height][k];
			if(map[height-1][k] == 2){
				sum += table[height-1][k];
			}
		}

		printf("%d\n",sum);
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int dp[16][15];
int h,w;
int map[16][15];
main()
{
	while(cin>>w>>h,w)
	{
	    for(int i=0;i<=h;i++)for(int j=0;j<w;j++)map[i][j]=0;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				cin>>map[i][j];
			}
		}
		for(int i=0;i<=h;i++)for(int j=0;j<w;j++)dp[i][j]=0;
		for(int i=0;i<w;i++)dp[0][i]=map[0][i]==0;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if(dp[i][j]==0||map[i][j]==1)continue;
				if(map[i][j]==2)
				{
					dp[i+2<=h?i+2:h][j]+=dp[i][j];
					continue;
				}
				if(i<h-1&&j>0)
				{
					if(map[i+1][j-1]==0)dp[i+1][j-1]+=dp[i][j];
				}
				if(i<h-1&&j<w-1)
				{
					if(map[i+1][j+1]==0)dp[i+1][j+1]+=dp[i][j];
				}
				if(map[i+1][j]!=1)dp[i+1][j]+=dp[i][j];
			}
		}
		int ans=0;
		for(int j=0;j<w;j++)ans+=dp[h][j];
		cout<<ans<<endl;
	}
}

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

#define NONE 0
#define TREE 1
#define JUMP 2

int dp[17][17];
int area_state[17][17];
int h,w;

int solve(int y, int x){

	if (dp[y][x] != -1)
		return dp[y][x];
	if (x == 0 || x == w+1){
		dp[y][x] = 0;
		return 0;
	}	
	if (y == h || y == h+1){
		dp[y][x] = 1;
		return 1;
	}

	if (area_state[y][x] == TREE){
		return 0;

	}else if (area_state[y][x] == JUMP){
		dp[y][x] = (solve(y+2, x));
		return dp[y][x];

	}else if (area_state[y][x] == NONE){
		if(y == h-1){
			dp[y][x] = 1;
			return 1;
		}
		int left = 0;
		int right = 0;

		if(area_state[y+1][x-1] != JUMP){
			left = solve(y+1,x-1);
		}
		if(area_state[y+1][x+1] != JUMP){
			right =  solve(y+1,x+1);
		}
		dp[y][x] =  left + solve(y+1,x) + right;
		return dp[y][x];
	}
}


int main() {
	while (cin >> w >> h && w&&h ){ 
		fill( dp[0], dp[17], -1);
		fill( area_state[0], area_state[17], 0);

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				int zone;
				cin >> zone;
				area_state[i][j+1] = zone;
			}
		}

		int ans = 0;
		for(int i = 1; i < w+1; i++){
			ans += solve(0,i);
		}

		// cout << endl;

		// for(int i = 0; i < h+2; i++){
		// 	for(int j = 0; j < w+2; j++){
		// 		printf("%4d",area_state[i][j]);
		// 	}
		// 	cout << endl;
		// }
		// cout << endl;

		// for(int i = 0; i < h+2; i++){
		// 	for(int j = 0; j < w+2; j++){
		// 		printf("%4d",dp[i][j]);
		// 	}
		// 	cout << endl;
		// }
		
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
	int map[100][100];
	int dp[100][100];
	
	int X, Y;
	while (scanf("%d %d", &X, &Y), X + Y){
		for (int i = 0; i < 100; i++){
			dp[0][i] = 1;
			for (int j = 1; j < 100; j++){
				dp[j][i] = 0;
			}
		}
		
		for (int i = 0; i < Y; i++){
			for (int j = 0; j < X; j++){
				scanf("%d", &map[i][j]);
			}
		}
		
		for (int i = 0; i < Y; i++){
			for (int j = 0; j < X; j++){
				if (map[i][j] == 0){
					for (int k = -1; k <= 1; k++){
						if (j + k >= 0 && j + k < X && (map[i + 1][j + k] == 0 || (k == 0 && map[i + 1][j + k] == 2)) && (i < Y - 1 || k == 0)){
							dp[i + 1][j + k] += dp[i][j];
						}
					}
				}
				else if (map[i][j] == 2){
					dp[i + 2][j] += dp[i][j];
				}
			}
		}
		
		int sum = 0;
		for (int i = 0; i < X; i++){
//			printf("%d ", dp[Y][i]);
			sum += dp[Y][i];
		}
		
		printf("%d\n", sum);
	}
	
	return 0;
}