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<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
  int i, n, m, ohajiki;
  vector<int> sequence;

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

    for(i=0; i<n; ++i){
      cin >> m;
      sequence.push_back(m);
    }

    i = 0;
    ohajiki = 32;
    while(1){
      ohajiki = ohajiki - ((ohajiki - 1) % 5);
      cout << ohajiki << endl;
      if(ohajiki == 0) break;

      if(sequence[i] >= ohajiki) ohajiki = 0;
      else ohajiki -= sequence[i];
      cout << ohajiki << endl;
      if(ohajiki == 0) break;
      if(i == sequence.size()-1) i = 0;
      else ++i;
    }

    sequence.clear();
  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int l,a[25];

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

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

int main(){
    int n;
    while(cin>>n,n){
        int t,r=0,j=0,l=32;
        vector<int>v;
        for(int i=0;i<n;i++){
            cin>>t;
            v.push_back(t);
        }
        while(l){
            r++;
            if(r%2)
                l-=(l - 1) % 5;
            else{
                l-=v[j];
                j=(j+1)%n;
            }
            if(l<0)l=0;
            cout<<l<<endl;
        }
    }
}

C++: # define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto iiiiiiiiii : a)cout << iiiiiiiiii << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

int main()
{
	int n;
	while (cin >> n&&n)
	{
		vi a;
		FOR(i, n)
		{
			INT(x);
			a.push_back(x);
		}
		int j = 32,k=0;
		for (int i = 0;; i++)
		{
			if (i % 2)
			{
				j -= min(a[k%a.size()],j);
				k++;
			}
			else
			{
				j -= (j - 1) % 5;
			}
			cout << j << endl;
			if (!j)break;
		}
	}
}

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

int main(void){
	int n,tm;
	while(cin >> n && n){
		vector<int> j;
		int m=31,p=0;
		for(int i=0;i<n;i++){
			cin >> tm;
			j.push_back(tm);
		}
		cout << m << endl;
		while(m){
			m -= j[p];
			if(m<=0){
				cout << 0 << endl;
				break;
			}
			cout << m << endl;
			m -= 5 - j[p++];
			cout << m << endl;
			if(p == j.size()) p=0;
		}
	}
}

C++: #include <iostream>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int retu[26] ={0};
		for (int i = 0; i < n; i++) {
			cin >> retu[i];
		}
		int oha = 32;
		bool hantei = true;
		int j = 0;
		while (oha > 0) {
			if (hantei) {
				oha -= (oha-1)%5;
				hantei = false;
			} else {
				oha -= retu[j];
				j++;
				if (j >= n) {
					j = 0;
				}
				hantei = true;
				if (oha < 0) {
					oha = 0;
				}
			}
			cout << oha << endl;
		}
	}
	return 0;
}

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

int operate[25];
int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		int m = 31;
		for(int i=0;i<n;i++){
			cin >> operate[i];
		}
		int pos = 0;
		while(true){
			m -= (m-1)%5;
			if(m<0)
				break;
			cout << m << endl;
			m -= operate[pos];
			if(m<0)
				break;
			cout << m << endl;
			pos++;
			if(pos==n)
				pos = 0;
		}
		cout << 0 << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-8;

int main(){
	int len;
	while(~scanf("%d",&len)){
		if(len==0) break;
		int* a = new int[len];
		for(int i=0;i<len;i++){
			scanf("%d",a+i);
		}

		int n=32;
		int idx=0;
		while(n>0){
			n -= (n-1) % 5;
			printf("%d\n",n);
			n -= a[idx % len] >= n ? n : a[idx % len];
			printf("%d\n",n);
			idx++;
		}

		delete[] a;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		int s=32;
		int k=0;
		int f=0;
		vector<int> a(n);
		for(int i=0;i<n;i++)
			cin>>a[i];
		
		while(s!=0){
			if(f==0){
				s-=(s-1)%5;
				f++;
			}
			else{
				s=s-a[k++];
				f=0;
				if(k==n)
					k=0;
			}
			if(s<0){
				s=0;
			}
				cout<<s<<endl;
		}
	}
	
}

C++: #include<iostream>
#include<vector>

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		std::vector<int> v( n );
		for( int i = 0; i != n; ++i )
		{
			int a;
			std::cin >> a;
			v[i] = a;
		}

		int r = 32, p = 0;
		bool turn = false;
		while( true )
		{
			if( !turn )
				r -= ( r - 1 ) % 5;
			else
				r -= std::min( r, v[p] ), p = ( p + 1 ) % n;
	
			std::cout << r << std::endl;

			if( r == 1 )
				break;

			turn ^= true;
		}
	}

	return 0;
}

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

int main()
{
  int i;
  while (cin >> i) {
    if (i == 0)
      break;

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

    int num = 32, cnt = 0;
    while (num != 0) {
      num = num - (num-1)%5;
      cout << num << endl;

      num = num - min(num, a[cnt++%i]);
      cout << num << endl;
    }
  }
  return 0;
}