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

int main(){

  int x,y;
  int a[100][100];
  int w[100][100];

  while(true){
    cin >> x >> y;
    if(!x && !y) break;

    memset(w,0,sizeof(w));
    int ans = 0;

    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++) cin >> a[i][j];
    }

    for(int i=0;i<x;i++){
      if(a[0][i] == 0) w[0][i] = 1;
    }

    for(int i=1;i<y;i++){
      for(int j=0;j<x;j++){

	if(a[i][j] == 1) w[i][j] += 0;

	else if(a[i][j] == 2 && a[i+2][j] != 1) w[i+2][j] += w[i-1][j];

	else if(a[i][j] == 0){
	  if(i-3 > 0 && a[i-3][j+1] == 2 && a[i-3][j-1] == 2) w[i][j] += w[i-1][j];
	  else if(i-3 > 0 && a[i-3][j+1] == 2) w[i][j] += w[i-1][j-1] + w[i-1][j];
	  else if(i-3 > 0 && a[i-3][j-1] == 2) w[i][j] += w[i-1][j] + w[i-1][j+1];
	  else if(j-1 < 0) w[i][j] += w[i-1][j] + w[i-1][j+1];
	  else if(j+1 == y) w[i][j] += w[i-1][j-1] + w[i-1][j];
	  else w[i][j] += w[i-1][j-1] + w[i-1][j] + w[i-1][j+1];
	}


      }
    }

    for(int i=0;i<x;i++) ans += w[y-1][i] + w[y][i] + w[y+1][i];
    cout << ans << endl;
  }
}

C++: #include <cstdio>
#include <cstring>
int w,h;
int f[22][22];
int dp[22][22];
int dx[] = {-1,0,1};
int solve(int x,int y){
  //printf("(%d,%d) = %d\n",x,y,f[x][y]);
  if(f[x][y] == 1) return 0;
  if(y >= h){
    //puts("OK ... 1");
    return 1;
  }
  if(f[x][y] == 1) return 0;
  if(dp[x][y] >= 0){
    //printf("OK ... %d\n",dp[x][y]);
    return dp[x][y];
  }
  if(f[x][y] == 2){
    //puts("Jump");
    return dp[x][y] = solve(x,y + 2);
  }

  int ret = 0;
  for(int i = 0; i < 3; i++){
    int nx = x + dx[i];
    if(!f[nx][y+1] || (!dx[i] && f[nx][y+1] == 2)){
      ret += solve(nx,y+1);
    }
  }
  return dp[x][y] = ret;
}
int main(void){
  while(1){
    scanf("%d%d",&w,&h); if(!w) break;
    memset(f,-1,sizeof(f));
    memset(dp,-1,sizeof(dp));
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
	scanf("%d",&f[j][i]);
      }
    }
    int ans = 0;
    for(int j = 1; j <= w; j++){
      ans += solve(j,1);
    }
    printf("%d\n",ans);
  }
}

C++: #include<iostream>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
int vx[3]={-1,0,1};
int main(){
  int x,y;
  while(cin>>y>>x,x+y!=0){
    int Map[y+3][x+3]={0};
    int cnt=0;
    for(int i=1;i<=y;i++)
      for(int j=1;j<=x;j++)
	cin>>Map[i][j];
    queue<pair<int,int> >qii;
    for(int i=1;i<=x;i++){
      if(Map[1][i]!=1)
	qii.push(make_pair(1,i));
    }
    while(!(qii.empty())){
      pair<int,int>now = qii.front();
      qii.pop();
     
      switch(Map[now.first][now.second]){
      case 0:
	for(int i=0;i<3;i++){
	  if(Map[now.first+1][now.second+vx[i]]==0){ 
	    if(now.second<1||now.second>x)
	      continue;
	    if(now.first > y-1){
	      cnt++;
	      continue;
	    }
	    qii.push(make_pair(now.first+1,now.second+vx[i]));
	  }
	}
	if(Map[now.first+1][now.second]==2){
	  if(now.first > y-1){
	    cnt++;
	    continue;
	  }
	  qii.push(make_pair(now.first+1,now.second));
	}
	break;
      case 2:
	if(Map[now.first+2][now.second]!=1){
	  if(now.first > y-1){
	    cnt++;
	continue;
	  }
	  qii.push(make_pair(now.first+2,now.second));
	}
	break;
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int dw[3] = {-1,0,1};

int main(){
    int w,h;

    while(cin >> w >> h){
        if(!(w|h)) break;
        int field[h+2][w+2];
        int dp[h+2][w+2];
        int kind;
        long long ret=0;
        fill((int *)field, (int *)field+(h+2)*(w+2), 1);
        fill((int *)dp, (int *)dp+(h+2)*(w+2), 0);

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

        for(int i=1;i<=w;i++){
            if(field[1][i] == 0) dp[1][i] = 1;
        }
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                kind = field[i][j];
                if(kind == 0){
                    for(int k=0;k<3;k++){
                        if(field[i+1][j+dw[k]] == 0 || 
                           (field[i+1][j+dw[k]] == 2 && k == 1)){
                            dp[i+1][j+dw[k]] += dp[i][j];
                        }
                    }
                }else if(kind == 2){
                    if(i != h-1){
                        if(field[i+2][j] != 1){
                            dp[i+2][j] += dp[i][j];
                        }
                    }else{
                        ret += dp[i][j];
                    }
                }
            }
        }

        for(int i=1;i<=w;i++){
            ret += dp[h][i];
        }
        cout << ret << endl;
    }
}

C++: #include<iostream>

using namespace std;

int main(){
	int n,m;
	int masu[17][17];
	int ura[17][17];
	cin>>n>>m;
	for(int i=0;i<17;i++){
		for(int j=0;j<17;j++){
			masu[i][j]=ura[i][j]=0;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=1;j<=m;j++){
			cin>>masu[i][j];
		}
	}
	
	for(int j=1;j<=m;j++){
		ura[0][j]=1;
	}
	
	
	for(int i=0;i<n-1;i++){
		for(int j=1;j<=m;j++){
			if(masu[i][j]==0){
				if(masu[i+1][j-1]==0){
					ura[i+1][j-1]+=ura[i][j];
				}
				if(masu[i+1][j]!=1){
					ura[i+1][j]+=ura[i][j];
				}
				if(masu[i+1][j+1]==0){
					ura[i+1][j+1]+=ura[i][j];
				}
			}
			
			if(masu[i][j]==2){
				if(masu[i+2][j]!=1){
					ura[i+2][j]+=ura[i][j];
				}
			}
		}
	}
	int cont=0;
	for(int i=1;i<=n;i++){
		cont+=ura[n][i]+ura[n-1][i];
	}
	
	
	/*
	for(int i=0;i<17;i++){
		for(int j=0;j<17;j++){
			printf("%2d ",ura[i][j]);
		}
		puts("");
	}*/
	printf("%d\n",cont);
	
	
}