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<stdio.h>
#include<cstdio>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<functional>
#include<math.h>
#include<queue>
#include<ctype.h>
#define MAX  1000000000
#define MIN -1000000000
using namespace std;
int i,j;
int x,y;
long long int dp[1000][1000];
int map[1000][1000];
int main(void){
	scanf("%d %d",&x,&y);
	while(x!=0 && y!=0){
		for(i=1;i<=17;i++){
			for(j=1;j<=15;j++){
				dp[i][j]=0;
				map[i][j]=0;
			}
		}
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++){
				scanf("%d",&map[i][j]);
			}
		}
		for(i=1;i<=x;i++){
			if(map[1][i]!=1){
				dp[1][i]=1;
			}
		}
		for(i=1;i<y;i++){
			for(j=1;j<=x;j++){
				if(dp[i][j]>0 && map[i][j]!=2){
					if(map[i+1][j-1]==0){
						if(j-1<0);
						else {
							dp[i+1][j-1]+=dp[i][j];
						}
					}
					if(map[i+1][j]!=1 ){
						if(map[i+1][j]==0){
							dp[i+1][j]+=dp[i][j];
						}
						else {
							int temp;
							temp=i+1;
							while(map[temp][j]==2){
								temp+=2;
								dp[temp][j]+=dp[i][j];
							}
						}
					}
					if(map[i+1][j+1]==0){
						if(j+1>x);
						else {
							dp[i+1][j+1]+=dp[i][j];
						}
					}
				}
			}
		}
/*		for(i=1;i<=y+2;i++){
			printf("%d=",i);
			for(j=1;j<=x;j++){
				printf("%d ",dp[i][j]);
			}
			printf("\n");
		}*/
		int cnt=0;
		for(i=0;i<=2;i++){
			for(j=1;j<=x;j++){
				cnt+=dp[y+i][j];
			}
		}
		printf("%d\n",cnt);
		scanf("%d %d",&x,&y);
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;


int main() {
	while(1) {
		int x, y;
		cin >> x >> y;
		if(x==0 && y==0) break;
		int field[x][y];
		int dp[x][y];
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				cin >> field[i][j];
				dp[i][j] = 0;
			}
		}
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				if(i==0) dp[i][j] = 1;
				else {
					if(field[i][j] == 0) {
						if(0<j && field[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
						if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
						if(j<y-1 && field[i-1][j+1] == 0) dp[i][j] += dp[i-1][j+1];
					}
					if(field[i][j] == 2) {
						dp[i][j] += dp[i-1][j];
						if(j+1 < x) dp[i+1][j] += dp[i][j];
						if(j+2 < x) dp[i+2][j] += dp[i][j];
					}
				}
			}
		}
		int sum=0;
		for(int i=0; i<y; i++) sum += dp[x-1][i];
		cout << sum;
	}
	return 0;
}

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

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

int x, y, c[16][16], dp[30][30];
const int dx[3] = {-1, 0, 1};

void solve() {
  memset(dp, 0, sizeof dp);
  
  rep(i,y) rep(j,x) cin>>c[i][j];
  
  rep(i,x) if (c[0][i] == 0) dp[0][i] = 1;
  
  rep(i,y-1) rep(j,x) {
    if (c[i][j] == 0) {
      rep(z,3) {
        int ti = i + 1, tj = j + dx[z];
        if (ti < 0 || tj < 0 || ti >= y || tj >= x) continue;
        if (c[ti][tj] == 1) continue;
        if (c[ti][tj] == 2 && z != 1) continue;
        dp[ti][tj] += dp[i][j];
      }
    } else if (c[i][j] == 2) {
      dp[i+2][j] += dp[i][j];
    }
  }
  /*
  rep(i,y+1) {
    rep(j,x) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int res = 0;
  rep(j,x) res += dp[y][j] + dp[y-1][j];
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>x>>y, x||y) {
    solve();
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int mp[16][16];
int dp[16][16];
int main() {
	int x, y;
	while (cin >> x >> y, x) {
		memset(dp, 0, sizeof(dp));
		rep(i, y)rep(j, x)cin >> mp[i][j];
		rep(i, x)if (!mp[0][i])dp[0][i] = 1;
		rep(i, y - 1)rep(j, x) {
			if (mp[i][j] == 0) {
				if (j > 0 && !mp[i + 1][j - 1])dp[i + 1][j - 1] += dp[i][j];
				if (mp[i + 1][j] != 1)dp[i + 1][j] += dp[i][j];
				if (j + 1 < x && !mp[i + 1][j + 1])dp[i + 1][j + 1] += dp[i][j];
			}
			if (mp[i][j] == 2 && i + 2 < y&&mp[i + 2][j] != 1)
				dp[i + 2][j] += dp[i][j];
		}
		int sum = 0;
		rep(i, x) {
			if (mp[y - 2][i] == 2)sum += dp[y - 2][i];
			sum += dp[y - 1][i];
		}
		cout << sum << endl;
	}
}

C++: #include<iostream>
using namespace std;
int dp[20][20][2];
int x[20][20];
int H, W;
void A(int a, int b, int c, int d) {
	if (x[a][b] == 2) {
		if (d != 0) { return; }
		if (c == 1) { return; }
		if (c == 0) {
			dp[a + 2][b][0] += dp[a][b][c];
			return;
		}
	}
	if (x[a + 1][b + d] == 1) { return; }
	if (x[a + 1][b + d] == 2 && d != 0) { return; }
	if (x[a][b] == 0) {
		if (d == 0) {
			dp[a + 1][b + d][0] += dp[a][b][c];
		}
		else {
			dp[a + 1][b + d][1] += dp[a][b][c];
		}
	}
}
int main() {
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) { break; }
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j];
			}
		}
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 20; j++) {
				dp[i][j][0] = 0;
				dp[i][j][1] = 0;
			}
		}
		for (int i = 1; i <= W; i++) {
			if (x[1][i] == 0) {
				dp[1][i][0] = 1;
			}
		}
		for (int i = 1; i <= H - 1; i++) {
			for (int j = 1; j <= W; j++) {
				A(i, j, 0, -1);
				A(i, j, 0, 0);
				A(i, j, 0, 1);
				A(i, j, 1, -1);
				A(i, j, 1, 0);
				A(i, j, 1, 1);
			}
		}
		int sum = 0;
		for (int j = H; j < 20; j++) {
			for (int i = 1; i <= W; i++) {
				sum += dp[j][i][0] + dp[j][i][1];
			}
		}
		cout << sum << endl;
	}
	return 0;
}