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)
	}
}

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0203

"""
import sys
from sys import stdin
from collections import deque, defaultdict
input = stdin.readline


def solve(field):
    # 0: ????????°, 1: ?????????, 2: ?????£????????°
    ans = 0                     #  ??????????????°???????????°

    dy = [1, 1, 1]  # ?????????????????????????????????????§???????
    dx = [0, -1, 1]
    x_limit = len(field[0])
    y_limit = len(field)

    path = defaultdict(int)     #  ??????????????????????????°???????????°????????????'x???_y???'???????????????
    Q = deque()
    for x, m in enumerate(field[0]):
        if m == 0:              #  ?????????????????°?????´?????????????????????????????????
            t = '{}_{}'.format(x, 0)
            Q.append((x, 0))
            path[t] = 1
    if y_limit < 2:
        return len(Q)

    return 0

    while Q:
        cx, cy = Q.popleft()        #  ?????¨??°?????§?¨?
        t = '{}_{}'.format(cx, cy)
        num = path.pop(t)

        if field[cy][cx] == 1:  #  ?????£????????§?????°?????????????????????
            continue
        elif field[cy][cx] == 2: #  ?????£????????§?????°?????????????????£????????°
            if cy+2 >= y_limit-1:
                ans += num
            else:
                t = '{}_{}'.format(cx, cy+2)
                if not path[t]:
                    Q.append((cx, cy+2))
                path[t] += num
            continue

        for i in range(len(dx)):
            nx = cx + dx[i]     #  ?????°????????§?¨?
            ny = cy + dy[i]

            if 0<= nx < x_limit:
                if (ny >= y_limit - 1) and field[ny][nx] != 1:
                    ans += num
                else:
                    if field[ny][nx] == 2 and dx[i] == 0: #  ?????£????????°????????£??????????????\????????´???
                        if ny+2 > y_limit - 1:
                            ans += num
                        else:
                            t = '{}_{}'.format(nx, ny+2)
                            if not path[t]:
                                Q.append((nx, ny+2))
                            path[t] += num
                    elif field[ny][nx] == 0:
                        t = '{}_{}'.format(nx, ny)
                        if not path[t]:
                            Q.append((nx, ny))
                        path[t] += num
    return ans


def main(args):
    while True:
        X, Y = map(int, input().strip().split())
        if X == 0 and Y == 0:
            break
        field = []
        for _ in range(Y):
            temp = [int(x) for x in input().strip().split()]
            field.append(temp)
        result = solve(field)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

C++: #include<iostream>
using namespace std;
long long solve(int x,int y);
int ax,ay;
int mas[200][200];
long long memo[200][200];
int main(){
  while(1){
    for(int i=0;i<200;i++){
      for(int j=0;j<200;j++){
	memo[i][j]=0;
      }
    }
    long long ans=0;
    cin>>ax>>ay;
    if(ax==0 && ay==0) break;
    
    for(int i=0;i<ay;i++){
      for(int j=0;j<ax;j++){
	cin>>mas[i][j];
      }
    }
    
    for(int i=0;i<ax;i++){
      if(mas[0][i]!=1){
	ans+=solve(i,0);
      }
    }
    cout<<ans<<endl;
  }
}
long long solve(int x,int y){
  if(y>=ay){
    return 1;
  }else if(memo[y][x]!=0){
    return memo[y][x];
  }else if(mas[y][x]==1){
    return 0;
  }else if(mas[y][x]==2){
    return solve(x,y+2);
  } 
  else{
    long long anss=0; 
    if(mas[y+1][x]!=1){
      anss+=solve(x,y+1);
    }
    if(x+1<ax && mas[y+1][x+1]==0 && y+1!=ay){
      anss+=solve(x+1,y+1);
    }
    if(0<=x-1 && mas[y+1][x-1]==0 && y+1!=ay){
      anss+=solve(x-1,y+1);
    }
    return memo[y][x]=anss;
  }
}

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

const int MAX_SIZE = 15;
char field[MAX_SIZE+1][MAX_SIZE+3];
int dp[MAX_SIZE+1][MAX_SIZE+3];
int w, h;

bool judge(int i, int j){
	if(j > 0 && j <= w && field[j][i] == '0' && j <= h)
		return true;
	return false;
}

int main(){
	while(cin >> w >> h){
		if(w == 0 && h == 0) break;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++)
				cin >> field[j][i];
		}
		int pattern = 0;
		for(int i = 0; i < MAX_SIZE+1; i++){
			for(int j = 0; j < MAX_SIZE+3; j++){
				dp[i][j] = 0;
			}
		}
		for(int i = 1; i <= w; i++){
			dp[i][1] = 1;
		}
		for(int i = 1; i < h; i++){
			for(int j = 1; j <= w; j++){
				if(field[j][i] == '2')
					dp[j][i+2] += dp[j][i];
				if(field[j][i] == '0'){
					dp[j][i+1] += dp[j][i];
					if(judge(i+1, j-1)) dp[j-1][i+1] += dp[j][i];
					if(judge(i+1, j+1)) dp[j+1][i+1] += dp[j][i];
				}
			}
		}
		int count = 0;
		for(int i = h; i <= h+1; i++){
			for(int j = 1; j <= w; j++){
				count += dp[j][i];
			}
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int w,h;
int mp[16][16];
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(mp[y][x] == 2) y++;
  
  if((y >= h)||(y==h-1 && mp[y][x] != 1)) ans++;//,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||ny <0||nx >= w|| ny>=h) continue;
      if(mp[ny][nx] == 0){
      saiki(nx,ny);
      }
      else if(nx==x && mp[ny][nx] == 2 ){
	saiki(nx,ny+2);
      }
    } 
  }
}

int main() {

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

    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);
    }
    cout << ans << endl;
    //cout << count << endl;
  }

  return 0;
}