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>

int main(){
	while(true){
		int X, Y;
		scanf("%d%d", &X, &Y);
		int field[16][17] = { { 0 } };
		for(int y = 1; y <= Y; y++){
			for(int x = 1; x <= X; x++){
				scanf("%d", &(field[y][x]));
			}
		}
		int dp[16][17] = { { 0 } };
		for(int x = 1; x <= X; x++){
			if(field[1][x] != 1){ dp[1][x] = 1; }
		}
		for(int y = 2; y <= Y; y++){
			for(int x = 1; x <= X; x++){
				if(field[y][x] == 1){ continue; }
				int sum = 0;
				if(field[y][x] == 0){
					if(field[y - 1][x - 1] == 0){ sum += dp[y - 1][x - 1]; }
					if(field[y - 1][x + 1] == 0){ sum += dp[y - 1][x + 1]; }
				}
				if(field[y - 1][x] == 0){ sum += dp[y - 1][x]; }
				if(field[y - 2][x] == 2){ sum += dp[y - 2][x]; }
				dp[y][x] = sum;
			}
		}
		int answer = 0;
		for(int x = 1; x <= X; x++){
			if(field[Y - 1][x] == 2){ answer += dp[Y - 1][x]; }
			answer += dp[Y][x];
		}
		printf("%d\n", answer);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
   int x,y;
   while(cin>>x>>y,x||y){
        int field[50][50];
        for(int i=1;i<=y;i++)
            for(int j=1;j<=x;j++)
                cin>>field[i][j];

        int dp[50][50]={{0}};
        for(int i=1;i<=x;i++)dp[1][i]=1;
        for(int i=1;i<=y;i++){
            for(int j=1;j<=x;j++){
                if(field[i][j]==1){
                    dp[i][j]=0;
                    continue;
                }
                if(i==y)continue;
                if(field[i][j]==2){
                    int to=i+2;
                    dp[to][j]+=dp[i][j];
                    continue;
                }
                if(field[i+1][j+1]!=2)dp[i+1][j+1]+=dp[i][j];
                if(field[i+1][j-1]!=2)dp[i+1][j-1]+=dp[i][j];
                dp[i+1][j]+=dp[i][j];
            }
        }
        int sum=0;
        for(int i=1;i<=x;i++)sum+=dp[y][i]+dp[y+1][i];
        cout<<sum<<endl;

   }
}

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

using namespace std;

int x, y;
int c[17][17];

int dp[17][17];

bool input() {
  int i, j;
  scanf("%d %d", &x, &y);
  if (!x && !y) return false;
  fill(c[0], c[0] + 17 * 17, 1);
  for (i = 1; i <= y; i++) {
    for (j = 1; j <= x; j++) {
      scanf("%d", &c[i][j]);
    }
  }
  /*
  printf("\n");

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


int main() {

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

  return 0;
}

C++: #include<iostream>

using namespace std;

int masu[17][17];

int count;
	int n,m;
void saiki(int x,int y){
	
	if(y<1 || y>n){
		return;
	}
	printf("make %d %d\n",x,y);
	if(x>=m){
		printf("ans %d %d\n",x,y);
		count++;
		return;
	}
	
	if(masu[x][y]==0){
		if(masu[x+1][y-1]==0 && x<=m-2){
			saiki(x+1,y-1);
		}
		if(masu[x+1][y]==0){
			saiki(x+1,y);
		}
		if(masu[x+1][y]==2){
			saiki(x+1,y);
		}
		if(masu[x+1][y+1]==0&& x<=m-2){
			saiki(x+1,y+1);
		}
	}
	if(masu[x][y]==1){
	}
	if(masu[x][y]==2){
		if(masu[x+2][y]!=1){
			saiki(x+2,y);
		}
	}
	
	printf("--- %d %d\n",x,y);
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<17;i++){
		for(int j=0;j<17;j++){
			masu[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=1;j<=m;j++){
			cin>>masu[i][j];
		}
	}
	
	count=0;
	
	for(int i=1;i<=n;i++){
		saiki(0,i);
	}
	
	printf("%d\n",count);
}

C++: #include<iostream>
using namespace std;
int X,Y;
int dp[20][20];
char maps[20][20];
int bun(int x,int y);
int dx[3]={-1,0,1};
main(){
  while(1){
    cin>>X>>Y;
    if(X==0&&Y==0){
      break;
    }
    for(int i=1;i<=Y;i++){
      for(int j=1;j<=X;j++){
	cin>>maps[i][j];
	dp[i][j]=0;
      }
    }
    int ans=0;
    for(int i=1;i<=X;i++){
      if(maps[1][i]!='1'){
	ans+=bun(1,i);
      }
    }
    cout<<ans<<endl;
  }
}
int bun(int y,int x){
  if(y>=Y+1){
    return 1;
  }
  else if(dp[y][x]!=0){
    return dp[y][x];
  }
  else if(maps[y][x]=='2'&&(y+2>=Y+1||maps[y+2][x]!='1')){
    return bun(y+2,x);
  }
  else{
    int anss=0;
    for(int i=0;i<3;i++){
      int nx=x+dx[i];
      if(i!=1){
	if(nx>0&&nx<=X&&maps[y+1][nx]=='0'){
	  anss+=bun(y+1,nx);
	}
      }
      else{
	if(maps[y][nx]=='2'&&(y+2>=Y+1||maps[y+2][nx]!='1')){
	  anss+=bun(y+2,nx);
	}
	else if(maps[y+1][nx]!='1'){
	  anss+=bun(y+1,nx);
	}
      }
    }
    return dp[y][x]=anss;
  }	  	  
}