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

long calc(int X, int Y, int** ski);

int main(void){
  int X,Y;
  while(true){
    cin>>X>>Y;
    if(X==0 and Y==0){break;}
    int** ski=(int**)malloc(sizeof(int*)*Y);
    for(int i=0;i<Y;i++){
      ski[i]=(int*)malloc(sizeof(int)*X);
      for(int j=0;j<X;j++){
        cin>>ski[i][j];
      }
    }
    cout<<calc(X,Y,ski)<<endl;
    for(int i=0;i<Y;i++){
      free(ski[i]);
    }
    free(ski);
  }
  return 0;
}

long calc(int X, int Y, int** ski){
  long** pattern=(long**)malloc(sizeof(long*)*Y);
  for(int i=0;i<Y;i++){
    pattern[i]=(long*)malloc(sizeof(long)*X);
    for(int j=0;j<X;j++){
      pattern[i][j]=0;
    }
  }

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

  long retval=0;
  for(int j=0;j<X;j++){
    retval+=pattern[Y-1][j];
    if(Y>=2 and ski[Y-2][j]==2){
      retval+=pattern[Y-2][j];
    }
  }
  return retval;
}

C++: #include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int course[16][17][2];
int main()
{
  for(;;){
    int H,W;
    cin >> H >> W;
    if(H==0||W==0) break;
    memset(course,0,sizeof(course));
    for(int h=1; h<=H; h++){
      for(int w=1; w<=W; w++){
        cin >> course[h][w][0];
      }
    }
    for(int w=1; w<=W; w++){
      if(course[1][w][0] == 1) course[1][w][1] = 0;
      else course[1][w][1] = 1;
    }
    for(int h=2; h<=H; h++){
      for(int w=1; w<=W; w++){
        if(course[h][w][0] == 1){
          course[h][w][1] = 0;
        }else if(course[h][w][0] == 2){
          course[h][w][1] = course[h-1][w][1];
          if(course[h-2][w][0] == 2){
            course[h][w][1] += course[h-2][w][1];
          }
        }else {
          for(int i=-1; i<=1; i++){
            if(course[h-1][w+i][0] != 2){
              course[h][w][1] += course[h-1][w+i][1];
            }
          }
          if(course[h-2][w][0] == 2){
            course[h][w][1] += course[h-2][w][1];
          }
        }
      }
    }
    int sum = 0;
    for(int w=1; w<=W; w++){
      sum += course[H][w][1];
      if(course[H-1][w][0] == 2){
        sum += course[H-1][w][1];
      }
    }
    cout << sum << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;

int grid[30][30];

inline bool isAtObstacle(int x, int y) {
  return grid[y][x] == 1;
}

inline bool isAtSkiJump(int x, int y) {
  return grid[y][x] == 2;
}

int main() {
  int n, m;
  
  while(cin >> n >> m && n) {
    fill(grid[0], grid[0]+900, 0);
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
	cin >> grid[i][j];
      }
    }
    
    int dp[30][30][2] = {{{}}};
    
    for(int j=0; j<m; j++) {
      if(grid[0][j]==0) { dp[0][j][0] = 1; }
    }
    
    int extra = 0;
    for(int i=0; i<n-1; i++) {
      for(int j=0; j<m; j++) {
	
	// there is no case such that skier is at obstacle.
	if(isAtObstacle(j, i)) {
	  dp[i][j][0] = dp[i][j][1] = 0;
	  continue;
	}
	
	// A skier is at a ski jump.
	if(isAtSkiJump(j, i)) {
	  if(i+2 > n-1) extra += dp[i][j][0];
	  else {
	    if(isAtObstacle(j, i+2)) continue;
	    dp[i+2][j][0] += dp[i][j][0];
	  }
	}
	
	// skiing without jump.
	else {
	  // from the upper left
	  if( j-1 >= 0
	      && !isAtObstacle(j-1, i+1)
	      && !isAtSkiJump (j-1, i+1) ) {
	    dp[i+1][j-1][1] += dp[i][j][0] + dp[i][j][1];
	  }
	  
	  // from the above
	  if( !isAtObstacle(j, i+1) ) {
	    dp[i+1][j][0] += dp[i][j][0] + dp[i][j][1];
	  }
	  
	  // from the upper right
	  if( j+1 < m
	      && !isAtObstacle(j+1, i+1)
	      && !isAtSkiJump (j+1, i+1) ) {
	    dp[i+1][j+1][1] += dp[i][j][0] + dp[i][j][1];
	  }
	}
	
      }
    }
    
    for(int i=0; i<m; i++) {
      if(isAtObstacle(i, n-1)) {
	dp[n-1][i][0] = dp[n-1][i][1] = 0;
      }
    }
    
    int ans = 0;
    for(int i=0; i<m; i++) {
      ans += dp[n-1][i][0] + dp[n-1][i][1];
    }
    
    cout << ans + extra << endl;
  }
  
  return 0;
}