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 <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int a[25];
		for (int i = 0; i < n; ++i)
			scanf("%d", a+i);

		int left = 32;
		for (int i = 0; left; ++i)
		{
			if (i & 1)
				left -= min(left, a[(i/2) % n]);
			else
				left -= (left - 1) % 5;
			printf("%d\n", left);
		}
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int n,a[100];
main()
{
    while(cin>>n,n)
    {
        for(int i=0;i<n;i++)cin>>a[i];
        int c=32,i=0;
        while(c)
        {
            c-=(c-1)%5;
            cout<<c<<endl;
            c-=(a[i]>c?c:a[i]);
            cout<<c<<endl;
            i=(i+1)%n;
        }
    }
}

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 - 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 <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		int ohajiki = 32;
		bool endFlag = false;
		int pos = 0;
		while(!endFlag)
		{
			ohajiki -= (ohajiki - 1) % 5;
			cout << ohajiki << endl;
			ohajiki -= Vec[pos];
			++pos;
			if(pos >= n)
			{
				pos = 0;
			}
			if(ohajiki <= 0)
			{
				endFlag = true;
				cout << 0 << endl;
				continue;
			}
			else
			{
				cout << ohajiki << endl;
			}
		}
	}
}

int main()
{
	solve();
	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;
			int k = size(b);
			cout << k;
			e -= 5;
		}
		cout << 1 << endl << 0 << endl;
	}
}

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

int main() {
  while(true) {
    vector<int> jiros;
    int n;
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; ++i) {
      int num;
      cin >> num;
      jiros.push_back(num);
    }
    int left = 32;
    for(int i = 0; ; ++i) {
      left -= (left - 1) % 5;
      if(left <= 0) {cout << 0 << endl;break;}
      cout << left << endl;
      left -= jiros[i % n];
      if(left <= 0) {cout << 0 << endl;break;}
      cout << left << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main() {
 int i,n,s,k[25];
 while(cin >> n) {
	 if (n==0) break;
	 for (i=0;i<n;i++) cin >> k[i];
	 s=32; i=0;
	 while (s>0) {
		 s-=(s-1) % 5;
		 cout << s << endl;
		 s=s-k[i]>0 ? s-k[i] : 0;
		 i=(i+1) % n;
		 cout << s << endl;
	 }
 }
return 0;
 }

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int cnt=0,a[25],all=32;
		for(int i=0;i<n;i++)cin>>a[i];
		bool turn=true;//true:?????????false:?¬????
		while(all>0){
			if(turn){
				all=all-(all-1)%5;
				if(all<0)all=0;
				cout<<all<<endl;
				turn=false;
			}else{
				all-=a[cnt];
				if(all<0)all=0;
				cout<<all<<endl;
				cnt++;
				if(cnt==n)cnt=0;
				turn=true;
			}
		}
	}
}

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

main(){
    int n, k;
    int T[30];
    while( cin >>k && k ){
	for ( int i = 0; i < k; i++ ) cin >> T[i];
	n = 32;
	int r = 0;
	while( n ){
	    n -= (n-1)%5;
	    cout << n << endl;
	    if ( n == 0 ) break;
	    n -= min(n, T[r%k]);
	    r++;
	    cout << n << endl;
	}
    }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int a[30];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n)scanf("%d", &a[i]);
		int cnt = 32;
		for (int i = 0; cnt; i++) {
			if (i & 1) {
				if (cnt < a[(i / 2) % n])cnt = 0;
				else cnt -= a[(i / 2) % n];
			}
			else {
				if (cnt == 1)cnt = 0;
				else cnt -= (cnt - 1) % 5;
			}
			printf("%d\n", cnt);
		}
	}
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		int a[30];
		rep(i, n) cin >> a[i];

		int ohajiki = 32,idx = 0;
		while (ohajiki > 0) {
			ohajiki -= (ohajiki - 1) % 5;
			cout << ohajiki << endl;
			if (ohajiki - a[(idx + n) % n] < 0)
				ohajiki = 0;
			else
				ohajiki -= a[(idx + n) % n];
			idx++;
			cout << ohajiki << endl;
		}
	}
	return 0;
}

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

int main()
{
    int n, o, a[25];

    while( cin >> n )
    {
        if( n == 0 )
            break;

        o = 32;

        for( int i = 0; i < n; i++ )
            cin >> a[i];

        int i = 0;
        while( o != 0 )
        {
            o -= ( o - 1 ) % 5;
            if( o < 0 )
                o = 0;
            cout << o << endl;
    
            if( o == 0 )
                break;

            o -= a[i%n];
            if( o < 0 )
                o = 0;
            cout << o << endl;

            i++;
        }
    }
    return 0;
}

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

int main(){
	int n,a[25],i,b,c,on;
	while(cin >> n && n){
		for(i = 0;i < n;i++){
			cin >> b;
			a[i] = b;
		}
		b = c = 0;
		on = 32;
		while(1){
			on -= ((on - 1) % 5);
			cout << on << endl;

			if(a[c] < on) {
				on -= a[c];
				cout << on << endl;
			}
			else {
				on = 0;
				cout << on << endl;
			}
			c++;
			if(c == n) c = 0;
			if(on == 0) break;
		}
	}
	return 0;
}

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

int main() {
	int n, num, turn;
	vector< int > sq;
	
	while(cin >> n, n){
		sq.resize(n);
		for(int i = 0; i < n; ++i) cin >> sq[i];
		
		num = 32;
		turn = 1;
		
		while(num > 0){
			if(turn % 2){
				num -= (num - 1) % 5;
			}else{
				num -= (sq[(turn / 2 - 1) % n]);
				if(num < 0) num = 0;
			}
			++turn;
			
			cout << num << endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int len;
	int a[30];
	
	while (cin >> len, len){
		int n = 32;
		
		for (int i = 0; i < len; i++){
			cin >> a[i];
		}
		
		int i = 0, j = 0;
		while (1){
			if (i % 2 == 0){
				n -= (n - 1) % 5;
			}
			else {
				n -= a[j % len];
				j++;
			}
			
			if (0 >= n){
				n = 0;
				cout << n << endl;
				break;
			}
			cout << n << endl;
			i++;
			
		}
	}
	return (0);
}