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;

#define MAX 15
#define BLANK 0
#define BARRIER 1
#define JUMP 2
int main()
{
  int X,Y,field[MAX][MAX],dp[MAX][MAX],i,j,sum;
  while(cin>>X>>Y,X|Y){
    for(i=0;i<Y;i++)for(j=0;j<X;j++){cin>>field[i][j];dp[i][j]=(i==0);}
    for(i=1;i<Y;i++){
      for(j=0;j<X;j++){
	if(field[i][j]==BARRIER)continue;
	if(field[i-1][j]==BLANK)dp[i][j]+=dp[i-1][j];
	if(j+1<X && field[i-1][j+1]==BLANK && field[i][j]!=JUMP)dp[i][j]+=dp[i-1][j+1];
	if(j-1>=0 && field[i-1][j-1]==BLANK && field[i][j]!=JUMP)dp[i][j]+=dp[i-1][j-1];
	if(i-2>=0 && field[i-2][j]==JUMP)dp[i][j]+=dp[i-2][j];
      }
    }
    sum=0;
    for(j=0;j<X;j++){
      if(field[Y-1][j]==BLANK)sum+=dp[Y-1][j];
      if(Y-2>=0 && field[Y-2][j]==JUMP)sum+=dp[Y-2][j];
    }
    cout<<sum<<endl;
  }
}

C++: //============================================================================
// Problem     : AOJ0203
// Title       : A New Plan of Aizu Ski Resort (会津山スキー場の新企画)
// Author      : mizo0203
// Status      : Accepted
// Date        : Wed May 30 15:25:20
// Copyright   : Your copyright free
// Description : 動的計画法
//============================================================================

#include <stdio.h>
#include <algorithm>

using namespace std;

int x, y;
int c[17][17];  // 最大15+2

int dp[17][17]; // 動的計画法の計算用

bool input() {
  int i, j;
  scanf("%d %d", &x, &y);
  if (!x && !y) return false; // x = 0 かつ y = 0 なら終了
  fill(c[0], c[0] + 17 * 17, 1); // 配列cを1(木)で初期化
  for (i = 1; i <= y; i++) {
    for (j = 1; j <= x; j++) {
      scanf("%d", &c[i][j]);
    }
  }

  return true;
}

void manage() {
  int i, j, output = 0;

  fill(dp[0], dp[0] + 17 * 17, 0); // 計算用配列を初期化
  for (i = 1; i <= x; i++) {
    if (c[1][i] != 1) dp[1][i] = 1;
  }

  for (i = 1; i < y; i++) {
    for (j = 1; j <= x; j++) {
      if (dp[i][j]) {
        if (c[i][j] == 0) {
          if (c[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
          if (c[i + 1][j    ] == 0) dp[i + 1][j    ] += dp[i][j];
          if (c[i + 1][j + 1] == 0) dp[i + 1][j + 1] += dp[i][j];
          if (c[i + 1][j    ] == 2) dp[i + 1][j    ] += dp[i][j];
        } else if (c[i][j] == 2) {
          if (c[i + 2][j] == 0) dp[i + 2][j] += dp[i][j];
          if (c[i + 2][j] == 2) dp[i + 2][j] += dp[i][j];
        }
      }
    }
  }
  /*
  printf("\n");
  for (i = 0; i < 17; i++) {
    for (j = 0; j < 17; j++) {
      printf("%d ", dp[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  */
  for (i = 1; i <= x; i++) {
    if (c[y - 1][i] == 2) output += dp[y - 1][i];
    output += dp[y][i];
  }
  printf("%d\n", output);
}


int main() {

  while(input()) {
    manage();
  }

  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int m[500][500];
int dp[500][500];

int dx[]={-1,0,1};

int solve(int r,int c){
  rep(i,r+2)rep(j,c)dp[i][j]=0;
  rep(j,c)if(m[0][j] == 0)dp[0][j]=1;

  rep(i,r-1){
    rep(j,c){
      if (m[i][j] == 0 ){
	      rep(k,3){
	        int nex = j+dx[k];
	          if (nex<0||nex>=c)continue;
	  if (m[i+1][nex] == 0)dp[i+1][nex]+=dp[i][j];
	  else if (m[i+1][nex] == 2 && k == 1)dp[i+1][nex]+=dp[i][j];
	}
      }else if (m[i][j] == 2 && m[i+2][j] != 1){
	dp[i+2][j]+=dp[i][j];
      }
    }
  }
  
  /*
  rep(i,r+1) {
    rep(j,c) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int ans = 0;
  rep(j,c)ans+=dp[r][j]+dp[r-1][j];
  return ans;
}

main(){
  int c,r;
  while(cin>>c>>r && r){
    rep(i,r)rep(j,c)cin>>m[i][j];
    rep(j,c)m[r][j]=0;
    cout << solve(r,c) << endl;
  }
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[20][20];
int memo[20][20];
int ans;
int count;

int saiki(int x,int y) {
  count++;
  // cout << x <<" "<<y <<endl;
  int dx[3] = {-1,0,1};
  int dy[3] = {1,1,1};
  
  if((y >= h-1 && mp[y][x] != 1)) ans++,memo[y][x]++;//,cout <<"ok"<<endl;  
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = dx[i]+x;
      int ny = dy[i]+y;
      if(nx <0|| nx >= w || memo[ny][nx] == -1) continue;
      
      if(memo[ny][nx] > 0 && mp[ny][nx] == 0) {
	ans += memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }  
      else if(x == nx && memo[ny][nx] == 2 && memo[ny][nx] > 0) {
	ans += memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	if(memo[ny][nx] > 0) memo[y][x] += memo[ny][nx];
      } 
      else if(nx==x && mp[ny][nx] == 2){
	int ty = ny;
	while(mp[ty][nx] == 2) ty+=2;
	saiki(nx,ty);
	if(memo[ty][nx] > 0) memo[y][x] += memo[ty][nx];
      } 
    }
    if(memo[y][x] == 0) memo[y][x] = -1;
  }
}


int main() {

  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    for(int i=0;i<=19;i++) 
      for(int j=0;j<=19;j++){ 
	memo[i][j] = 0;
	mp[i][j] = 0;
      }
    
    for(int i=0;i<h;i++) 
      for(int j=0;j<w;j++) 
	cin >> mp[i][j];

    /*
      for(int i=0;i<h;i++) {
      for(int j=0;j<w;j++) 
      cout << mp[i][j];
      cout << endl;
      }
    */

    ans = 0;
    count = 0;
    for(int i=0;i<w;i++) {
      if(mp[0][i] !=1) saiki(i,0);
    }

    int ans2 = 0;
    for(int i=0;i<w;i++) 
      if(memo[0][i] > 0) ans2+=memo[0][i];

    cout << ans << endl;
    //    cout << ans2 << endl;
    //cout << count << endl;
  }

  return 0;
}