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>

using namespace std;

main(){
  int data[30];
  int n, in;
  while(1){
    cin >> in;
    if(in==0) break;

    for(int i=0;i<in;i++){
      cin >> data[i];
    }

    n=32;
    int turn=0;
    int p=0;
    while(1){
      if(turn==0){
	n-=(n-1)%5;
      }else{
	if(p==in) p=0;
	n-=data[p++];
      }
      if(n<=0){
	printf("0\n");
	break;
      }else{
	printf("%d\n", n);
      }
      turn=(turn+1)%2;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int i; cin >> i&&i;) {
		int o = 32;
		vector<int> a(i);
		rep(j, 0, i)cin >> a[j];
		for (int j = 0; ; (++j) %= i) {
			o -= (o - 1) % 5;
			cout << o << endl;
			o -= a[j];
			if (o <= 0) {
				cout << 0 << endl;
				break;
			}
			cout << o << endl;
		}
	}

	return 0;
}

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

using namespace std;


int main()
{
    int N;
    while(cin >> N, N){
        int n;
        vector<int> ns{};
        for(int i=0;i<N;++i) { cin >> n; ns.push_back(n); }
        
        int rem = 32, idx = 0;
        while(rem){
            rem -= (rem - 1) % 5;
            cout << rem << endl;
            rem -= min(ns[idx % N], rem);
            cout << rem << endl;
            ++idx;
        }
    }
}

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

int main(){
	int n;
	int a[30];

	while( cin >> n , n ){
		for(int i=0 ; i<n ; ++i ){
			cin >> a[i];
		}
		int m = 32;
		
		for(int i=0 ; m ; ++i ){
			m -= (m-1)%5;
			m = (m<0)? 0 : m ;
			cout << m << endl;
			if(!m) break;
			m -= a[i%n];
			m = (m<0)? 0 : m ;
			cout << m << endl;
		}
	}
}

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

int main(void){
	while(1){
		int n;
		vector<int> num;
		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			int t;
			cin >> t;
			num.push_back(t);
		}

		int a = 32;
		int i=0;
		while(1){
			a -= (a-1)	% 5;
			if(a < 0) {
				cout << 0 << endl;
				break;
			}
			cout << a << endl;
			a -= num[i % num.size()];
			i++;
			if(a < 0) {
				cout << 0 << endl;
				break;
			}
			cout << a << endl;
		}

	}


	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main()
{
  int array[25];
  int n;
  int now;
  int cnt;
  int turn; //1:ichiro 0:jiro

  while( cin >> n, n ) {
    now = 32;
    turn = 1;
    cnt = 0;
    for(int i=0; i<n; i++) {
      cin >> array[i];
    }

    while( now > 0 ) {
      if( cnt >= n ) cnt = 0;
      if( turn ) {
	now -= (now - 1) % 5;
	turn = 0;
      } else {
	now -= array[cnt];
	cnt++;
	turn = 1;
      }
      cout << max(0, now) << endl;
    }

  }

}

C++: 
#include <stdio.h>
 
int main(){
 
  int i,j,a[26];
  int n,h = 32;
 
 
  while(1) {
    h = 32;
  scanf("%d",&n);
  if(n == 0) break;
 
 
  for(i=0;i<n;i++) scanf("%d",&a[i]);
 
  i = 0;
  while(1) {
 
    h = h -(h-1)%5;
    printf("%d\n",h);
 
 
    h -= a[i%n];
    if(h>0) printf("%d\n",h);
    else {
      printf("0\n");
      break;
    }
 
    i++;
 
  }
   
  }
 
  return 0;
 
}

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

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

  while(1){
    cin >> n;
    if(!n)break;

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

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

      o -= a[i];
      if(o<0)o=0;
      i++;
      if(i==n)i=0;
      cout << o << endl;
      if(!o)break;
    }
  }
}

C++: #include<iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int P[100];
        for(int i=0;i<n;i++)cin>>P[i];
        int left=32;
        for(int i=0;;i++){
            if(i%2==0){
                left-=(left-1)%5;
                cout<<left<<endl;
            }
            else{
                left-=P[(i/2)%n];
                if(left<=0)left=0;
                cout<<left<<endl;
                if(!left)break;
            }
        }
    }
}

C++: #include<iostream>
#define TARO 0
#define JIRO 1
using namespace std;

int main(){
	int i, str[25], marbles, flag, cou;
	
	while(1){
		cin >>i;
		if(i == 0) break;
		for(int j = 0; j < i; j++){
			cin >>str[j];
		}
		
		marbles = 32;
		cou = 0;
		flag = TARO;
		
		while(marbles){
			if(flag == TARO){
				marbles = marbles - ((marbles - 1) % 5);
				flag = JIRO;
				if(marbles < 0) marbles = 0;
			} else{
				marbles -= str[cou];
				cou++;
				if(cou >= i) cou = 0;
				flag = TARO;
				if(marbles < 0) marbles = 0;
			}
			cout <<marbles <<endl;
		}
	}
	return 0;
}

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

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

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<int> v;
		rep(i,n)
		{
			int temp;
			cin >> temp;
			v.push_back(temp);
		}

		int o = 32;
		int i = 0;
		while(o > 0)
		{
			o -= (o-1) % 5;

			if(o >= 0) cout << o << endl;
			else cout << 0 << endl;

			if(o == 0) break;
			
			o -= v[i%n];
			i++;

			if(o >= 0) cout << o << endl;
			else cout << 0 << endl;

		}
	}
	return 0;
}

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

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

		int ohajiki = 32;
		int turn = 0;

		while(ohajiki) {
			if(turn % 2) {
				ohajiki = ohajiki - jiro[(turn / 2) % n];
				ohajiki = ohajiki < 0 ? 0 : ohajiki;
			}
			else {
				ohajiki = ohajiki - (ohajiki - 1) % 5;
			}
			cout << ohajiki << endl;
			turn++;
		}
	}
}