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

using namespace std;

void saiki(vector<int> &v,int ind,int rest){
    if(ind >= v.size()){
        ind = 0;
    }
    rest -= (rest-1) % 5;
    cout << rest << endl;
    if(rest <= v[ind]){
        cout << 0 << endl;
        return;
    }
    rest -= v[ind];
    cout << rest << endl;

    ind++;
    saiki(v,ind,rest);
}
void solve(vector<int> nexts){
    saiki(nexts,0,32);
}

int main(){
    int n = 0;
    while(cin >> n && n!=0){
        vector<int> nexts;
        for(int i=0;i<n;i++){
            int x;
            cin >> x;
            nexts.push_back(x);
        }
        solve(nexts);
    }
}

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

int main()
{
	int n;
	while( cin >> n && n ){
		int pickup[ 25 ] = {0};
		for( int i = 0; i < n; ++i ){
			cin >> pickup[ i ];
		}
		int stone = 32;
		int turn = 0;
		while( stone > 0 ){
			if( turn % 2 ){
				stone -= pickup[ ( turn / 2 ) % n ];
			}else{
				stone -= ( ( stone - 1 ) % 5 );
			}
			if( stone < 0 ){
				stone = 0;
			}
			cout << stone << endl;
			++turn;
		}
	}

	return 0;
}

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( r )
		{
			if( !turn )
				r -= std::min( r, ( r - 1 ) % 5 );
			else
				r -= std::min( r, v[p] ), p = ( p + 1 ) % n;

			std::cout << r << std::endl;

			turn ^= true;
		}
	}

	return 0;
}

C++: #include<stdio.h>

int main(){

int n[5]={};
int N;
int r=0;
while(1){
scanf("%d",&N);if(N==0)break;

for(int i=0;i<N;i++)
scanf("%d",&n[i]);

int P=32;
int j=0;
while(1){
if(P==1)break;
P-=(P-1)%5;printf("%d\n",P);
if(P==1)break;
P-=n[j];printf("%d\n",P);
j++;j=j%N;
}
P-=1;printf("%d\n",P);
}
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<int> deq;
    int n,a,tmp,hoge;
    hoge=32;
    tmp=0;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            for (int i=0;i<n;i++) {
                cin>>a;
                deq.emplace_back(a);
            }
            while (n>1) {
                hoge=hoge-((hoge-1)%5);
                cout<<hoge<<endl;
                hoge=hoge-deq[tmp];
                if (hoge<=0) {
                    cout<<0<<endl;
                    break;
                } else {
                    cout<<hoge<<endl;
                    if (tmp!=n-1) {
                        tmp++;
                    } else {
                        tmp=0;
                    }
                }
            }
        }
        hoge=32;
        tmp=0;
        deq.clear();
    }
}

C++: #include<iostream>
using namespace std;
int t[25],n,cnt,a;
int main(){

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

    cnt=32;
    a=0;

    while(cnt>0){

      cnt-=((cnt-1)%5);
      if(cnt<0)cnt=0;
      cout<<cnt<<endl;

      cnt-=t[a];
      a++;
      if(a==n)a=0;

      if(cnt<0)cnt=0;
      cout<<cnt<<endl;
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
  int i;
  for(;cin>>i,i;)
    {
      int count=32;
      int a[i];
      for(int j=0;j<i;j++)
	  cin>>a[j]; 
      for(int x=0;count!=0;x++)
	{
	  count-=(count-1)%5;
	  cout<<count<<endl;
	  count-=a[x%i];
	  if(count<0)
	    count=0;
	  cout<<count<<endl;
	}
    }
}

C++: #include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int nums[100];

int main(){
	int n;
	int c, pos;
	bool turn;
	while(cin >> n && n){
		turn = true;
		pos = 0;
		c = 32;
		rep(i, n)cin >> nums[i];
		while(c > 0){
			if(turn){
				c -= (c-1)%5;
			}else{
				c -= nums[pos];
				pos = (pos+1)%n;
			}
			cout << max(c, 0) << endl;
			turn = !turn;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  int n;
  while(cin>>n,n){
    int re[n];
    rep(i,n)cin>>re[i];
    int oh=32;
    bool ban=true;
    int ji=0;
    while(oh){
      if(ban){
        oh-=(oh+4)%5;
        cout<<oh<<endl;
      }else{
        oh-=re[ji++%n];
        if(oh<0)oh=0;
        cout<<oh<<endl;
      }
      ban=!ban;
    }
  }
}

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(m>0){
			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++: #include <cstdio>
#include <algorithm>
using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    while(scanf("%d",&n) && n){
        int r=32;
        int p[40];
        rep(i,n)scanf("%d",p+i);
        rep(i,1000){
            r-=(r-1)%5;
            printf("%d\n",r);
            r-=p[i%n];
            printf("%d\n",max(0,r));
            if(r<0) break;
        }
    }
}

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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP(a, b) make_pair(a, b)
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;
using namespace std;
int main(){
  int n,a[30];
  while(1){
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin >> a[i];
    }

    int r=32;
    for(int i=0;;i++){
      r -= (r-1) % 5;
      printf("%d\n", r);

      r -= a[i%n];
      if(r<0) r=0;
      printf("%d\n", r);

      if(r==0) break;
    }
  }
}