Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		scanner.Scan()
		buf := strings.Split(scanner.Text(), " ")
		input := make([]int, len(buf))
		for i := range input {
			input[i], _ = strconv.Atoi(buf[i])
		}
		fmt.Println(31)
		i, k := 0, 31
		for k > 1 {
			k -= input[i]
			fmt.Println(k)
			k = k - (k-1)%5
			fmt.Println(k)
			i++
			if i >= n {
				i = 0
			}
		}
		fmt.Println(0)
	}
}

C++: #include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

/** Problem0164 : Ohajiki Game **/
int main()
{
	int ohajiki=32;
	vector<int> take;
	int n;
	
	while (cin>>n, n) {
		ohajiki = 32;
		take.clear();
		
		rep(i, n) {
			int a;
			cin>>a; take.push_back(a);
		}
		
		for (int i=0; ; i++) {
			ohajiki -= (ohajiki-1)%5;
			if (ohajiki<=0) {
				ohajiki=0;
				break;
			}
			cout << ohajiki << endl;


			ohajiki -= take[i%take.size()];
			if (ohajiki<=0) {
				ohajiki=0;
				break;
			}
			cout << ohajiki << endl;
		}
		cout << ohajiki << endl;
	}
	return 0;
}

C++: // AOJ 0164
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n) != EOF){
		vector <int> kotori(n);
		int kotori_cnt = 0, honoka = 32;
		for (int i = 0; i < n; i++){
			cin >> kotori[i];
		}
		while (honoka > 0){
			honoka = honoka - ((honoka - 1) % 5);
			cout << honoka << endl;
				// kotori
			honoka -= (kotori[kotori_cnt % n]);
			// cout << "*** DEBUG " << kotori_cnt << endl;
			kotori_cnt++;
			if (honoka <= 0) break;
			cout << honoka << endl;
		}
		cout << 0 << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int m;
	while(cin >> m , m){
		vector<int> data(m);
		rep(i,m)cin >> data[i];
		int n = 32;
		int lp = 0;
		while(n>0){
			n -= (n-1)%5;
			cout << n << endl;
			n -= data[lp%m];
			cout << (n<0?0:n) << endl;
			lp++;
		}
		
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    while(1){
        int r=32;
        int i;
        int a[1000];
        cin>>i;
        if(i==0)break;
        for(int j=0;j<i;j++){
            cin>>a[j];
        }
        int k=0;
        for(int j=0;r>0;j++){
            if(j%2==0)r-=(r-1)%5;
            else if(j%2==1)r-=a[k],k++;
            if(k==i)k=0;
            if(r>0)cout<<r<<endl;
            else cout<<0<<endl;
        }
    }
	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vi a(n);
    rep(i, n) cin >> a[i];
    int t = 32;
    for (int i = 0;; i++) {
      t -= (t - 1) % 5;
      cmax(t, 0);
      cout << t << endl;
      if (t == 0) break;
      t -= a[i % n];
      cmax(t, 0);
      cout << t << endl;
      if (t == 0) break;
    }
  }
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int main() {
	int l;
	vi v(25, 0);
	int a = 32;
	while (cin >> l && l > 0) {
		rep(i, l)cin >> v[i];
		a = 32;
		for (int i = 0; a > 0; i = (i + 1) % l) {
			a -= (a - 1) % 5;
			cout << a << endl;
			a -= v[i];
			if (a < 0)a = 0;
			cout << a << endl;
		}
	}
}

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

int main() {
  int n, c, m;
  int a[25];
  while (1) {
    cin >> n;
    if (!n) break;
    for (int i=0; i<n; i++) {
      cin >> a[i];
    }
    c = 0;
    m = 32;
    while (m) {
      if (c & 1) {
        m -= a[(c/2)%n];
      } else {
        m -= (m-1)%5;
      }
      if (m <= 0) {
        m = 0;
      }
      cout << m << endl;
      ++c;
    }
  }

  return 0;
}

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

int main() {
	int n;
	while (cin >> n, n) {
		int ar[25];
		for (int i = 0;i < n;i++)cin >> ar[i];

		int o = 32;
		int c = 1;
		while (o > 0) {
			if (c % 2 == 1) {
				int a = (o - 1) % 5;
				o -= a;
				cout << o << endl;
			}
			else {
				int a = (c / 2) % n-1;
				if (a == -1)a += n;
				o -= ar[a];
				if (o < 0)o = 0;
				cout << o << endl;
			}
			c++;
		}

	}
	return 0;
}

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

int main(void){
	int n,x[25];

	while(cin>>n && n){
		for(int i=0;i<n;i++) cin>>x[i];

		int rem = 32, k=0;
		for(int j=0;rem > 0;j++){
			if(j % 2 == 0){
				rem -= (rem - 1) % 5;
			}
			else{
				rem -= x[k];
				if(rem < 0) rem = 0;
				k = (k + 1) % n;
			}
			cout<<rem<<endl;
		}
	}

	return 0;
}

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

int main()
{
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>b(a);
		for (int c = 0; c < a; c++) {
			cin >> b[c];
		}
		uint16_t e = 31;
		for (uint16_t f = 0; f < 6; f++){
			cout <<e<<endl;
			cout << (e - b[f % (size(b))]) << endl;
			e -= 5;
		}
		cout << 1 << endl << 0 << endl;
	}
}