Go: package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func CountPatterns(i int, patternNums []int) int {
	if patternNums[i] != 0 {
		return patternNums[i]
	}
	if i == 0 {
		return 1
	}
	patternNums[i] += CountPatterns(i-1, patternNums)
	if i > 1 {
		patternNums[i] += CountPatterns(i-2, patternNums)
	}
	if i > 2 {
		patternNums[i] += CountPatterns(i-3, patternNums)
	}
	return patternNums[i]
}

func Solve(N int) int {
	patternNums := MakeFilledInts(N+1, 0)
	return (CountPatterns(N, patternNums) + 3649) / 3650
}

func main() {
	for N := scan.Int(); N != 0; N = scan.Int() {
		ans := Solve(N)
		fmt.Println(ans)
	}
}

// --------------------------------------------------------------------------------
// Input

var scan = NewScanner()

type Scanner struct{ *bufio.Scanner }

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 100000000)
	return &Scanner{sc}
}

func (s *Scanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *Scanner) Strings(l int) []string {
	if l == 0 {
		return []string{}
	}
	sl := make([]string, l, l)
	for i := range sl {
		sl[i] = s.String()
	}
	return sl
}

func (s *Scanner) Int() int {
	n, _ := strconv.Atoi(s.String())
	return n
}

func (s *Scanner) Ints(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *Scanner) Int64() int64 {
	n, _ := strconv.ParseInt(s.String(), 10, 64)
	return n
}

func (s *Scanner) BigInt() *big.Int {
	return big.NewInt(s.Int64())
}

func (s *Scanner) BigInts(l int) []*big.Int {
	if l == 0 {
		return []*big.Int{}
	}
	sl := make([]*big.Int, l, l)
	for i := range sl {
		sl[i] = s.BigInt()
	}
	return sl
}

func (s *Scanner) Float64() float64 {
	f, _ := strconv.ParseFloat(s.String(), 64)
	return f
}

func (s *Scanner) Floats64(l int) []float64 {
	if l == 0 {
		return []float64{}
	}
	sl := make([]float64, l, l)
	for i := range sl {
		sl[i] = s.Float64()
	}
	return sl
}

// --------------------------------------------------------------------------------
// Output

const (
	Yes = "Yes"
	No  = "No"

	YES = "YES"
	NO  = "NO"
)

func PrintBool(v bool, trueStr, falseStr string) {
	if v {
		fmt.Println(trueStr)
	} else {
		fmt.Println(falseStr)
	}
}

// --------------------------------------------------------------------------------
// sort.BigIntSlice

type BigIntSlice []*big.Int

func (sl BigIntSlice) Len() int {
	return len(sl)
}

func (sl BigIntSlice) Less(i, j int) bool {
	return sl[i].Cmp(sl[j]) == -1
}

func (sl BigIntSlice) Swap(i, j int) {
	sl[i], sl[j] = sl[j], sl[i]
}

// --------------------------------------------------------------------------------
// Mint

const (
	Mod = 1000000007
)

type Mint int

func NewMint(value int) Mint {
	return Mint((value%Mod + Mod) % Mod)
}

func (x Mint) Add(y Mint) Mint {
	if v := x + y; v >= Mod {
		return v - Mod
	} else {
		return v
	}
}

func (x Mint) Sub(y Mint) Mint {
	if v := x + Mod - y; v >= Mod {
		return v - Mod
	} else {
		return v
	}
}

func (x Mint) Mul(y Mint) Mint {
	return (x * y) % Mod
}

func (x Mint) pow(n int) Mint {
	if n == 0 {
		return Mint(1)
	}
	a := x.pow(n >> 1)
	a = a.Mul(a)
	if n&1 != 0 {
		a = a.Mul(x)
	}
	return a
}

func (x Mint) Inverse() Mint {
	return x.pow(Mod - 2)
}

func (x Mint) Div(y Mint) Mint {
	return x * y.Inverse()
}

func (x Mint) Neg() Mint {
	return NewMint(int(-x))
}

// --------------------------------------------------------------------------------
// Factorial

type Factorial struct {
	fact        []Mint
	factInverse []Mint
}

func NewFactorial(n int) *Factorial {
	f := new(Factorial)
	f.init(n)
	return f
}

func (f *Factorial) init(n int) {
	fact := make([]Mint, n+1, n+1)
	fact[0] = NewMint(1)
	for i := 1; i <= n; i++ {
		fact[i] = fact[i-1].Mul(NewMint(i))
	}

	inv := make([]Mint, n+1, n+1)
	inv[n] = fact[n].Inverse()
	for i := n; i >= 1; i-- {
		inv[i-1] = inv[i].Mul(NewMint(i))
	}

	f.fact = fact
	f.factInverse = inv
}

func (f *Fa

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int A[31] = { 1,1 };

int a(int n) {
	if (A[n])return A[n];
	if (n - 1 >= 0)A[n] += A[n - 1] ? A[n - 1] : a(n - 1);
	if (n - 2 >= 0)A[n] += A[n - 2] ? A[n - 2] : a(n - 2);
	if (n - 3 >= 0)A[n] += A[n - 3] ? A[n - 3] : a(n - 3);
	return A[n];
}

int main() {
	for (int n; cin >> n&&n;)
		cout << ceil((double)a(n) / (365 * 10)) << endl;
	return 0;
}

C++: #include <iostream>

using namespace std;
typedef long long ll;

ll memo[40];

ll calc(int n){
    if(memo[n] != -1) return memo[n];
    ll retval = 0;
    for(int i=1;i<=3;i++){
        retval += calc(n-i);
    }
    return memo[n] = retval;
}

int main(){
    for(int i=0;i<40;i++){
        memo[i] = -1;
    }
    memo[1] = 1;
    memo[2] = 2;
    memo[3] = 4;
    calc(30);

    int n;
    while(cin>>n && n != 0){
        cout << calc(n) / 3650 + 1 << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int num(int n);
int main()
{
  int n;
  cin >> n;
  cout << num(num(n)) <<endl;
  return 0;
}

int num(int n){
  if(n<1)return 0;
  if(n=1)return 1;
  return num(n-1)+num(n-2)+num(n-3);
}

C++: #include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0)break;
    int dp[n];
    memset(dp, 0, sizeof(dp));

    dp[0] = 1;
    dp[1] = 2;
    dp[2] = 4;
    rep(i,n-3){
      dp[i+3] = dp[i+2] + dp[i+1] + dp[i];
    }
    cout << ceil(ceil(dp[n-1],10), 365) << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <stack>

#define rep(i,x) for(int i=0;i<x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int num[1000]={};
	int add[1000]={};
	int n;
	cin>>n;

	double sum=1;
	rep(i,n)
	{
		if(i<=3)add[i]=i;
		else add[i]+=(add[i-3]+add[i-2]+add[i-1]);
		sum+=add[i];
	}
	cout<<ceil(sum/3650)<<endl;


	return 0;
}

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

int dx[31];

int main(){
	int n;
	dx[1] = 1;
	dx[2] = 2;
	dx[3] = 4;
	for(int i = 4; i <= 30; i++){
		dx[i] = dx[i - 3] + dx[i - 2] + dx[i - 1];
	}
	while(cin >>n){
		if(n == 0) break;
		int day, year;
		day = dx[n] / 10;
		if(dx[n] % 10 != 0) day++;
		year = day / 365;
		if(day % 365 != 0) year++;
		cout <<year <<endl;
	}
	return 0;
}

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

int num(int n);

int main(){
  int n;
  cin>>n;
  cout << num(n)/3650 <<endl;
}

int num(int n){
    switch (n)
    {
        case 1: return 1;
        case 2:  return 2;
        case 3:  return 4;
    }
  return num(n-1)+num(n-2)+num(n-3);
}