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>
#include<algorithm>
#include<string.h>
using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        int t;
        vector<int>v;
        for(int i=0;i<n;i++){
            cin>>t;
            v.push_back(t);
        }
        int r=0,j=0,l=32;
        while(l>0){
            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++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

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

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  while(cin>>n,n){
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int b = 31;
  
    int i = 0;
    cout<<b<<endl;
    while(b-a[i]>0){
      b -= a[i];
      i=(i+1)%n;
      cout<<b<<endl;
      if(b-(b-1)%5<=0)break;
      b -= (b-1)%5;
      cout<<b<<endl;
    }
    cout<<0<<endl;
  }
}

C++: #include<cstdio>
using namespace std;
int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(n == 0) break;
        int a[30] = {0};
        for(int i = 0; i < n; i++){
            scanf("%d",&a[i]);
        }
        int now = 32;
        for(int i = 0; now != 0; i++){
            if(i % 2 == 0) now -= (now-1)%5;
            else now -= a[(i/2)%n];
            now = (now < 0) ? 0:now;
            printf("%d\n",now);
        }
    }

    return 0;
}

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

int main()
{
  int len;

  while (scanf("%d", &len), len){
    int a[4];
    for (int i = 0; i < len; i++){
      scanf("%d", &a[i]);
    }
    int n = 32;
    for (int i = 0, j = 0;; i++){
      if (i % 2 == 0){
        n -= (n - 1) % 5;
      }
      else {
        n -= a[j % len];
        j++;
      }
      if (n <= 0){
        n = 0;
        printf("%d\n", n);
        break;
      }
      printf("%d\n", n);
    }
  }

  return (0);
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n, a[26], s, t, p;
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		s = 32;
		p = 0;
		while(s > 0){
			t = (s-1)%5;
			s -= t;
			cout << s << endl;
			
			s -= a[p%n];
			p++;
			if(s < 0){
				s = 0;
			}
			cout << s << endl;
		}
	}
	
	return 0;
}

C++: #include <iostream>

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		int* array = new int[n];
		for (int i=0; i<n; i++) std::cin >> array[i];
		bool turn = true;
		int stones = 32;
		int index = 0;
		while (stones>0) {
			if (turn) stones -= (stones-1) % 5;
			else { stones -= array[index]; index = (index+1) % n; }
			if (stones<0) stones = 0;
			std::cout << stones << std::endl;
			turn = !turn;
		}
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#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 <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

int main(){
	int n;
	while(cin>>n,n){
		vector<int> a(n); FOR(i,n) cin>>a[i];
		int m = 35;
		int i = 0;
		while(m){
			int x = (m-1)%5;
			m -= x;
			cout << m<< endl;
			x = a[(i++)%sz(a)];
			x = min(x,m);
			m-=x;
			cout<<m<<endl;
		}
	}

	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(P>=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<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;

			if( !r )
				break;

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

			turn ^= true;
		}
	}

	return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int jiro[32]={0};
        for(int i = 1;i <= n; i++){
            scanf("%d",&jiro[i]);
        }
        bool f = 0;
        int now = 32;
        int x = 0,y = 1;
        int ans[64]={0};
        for(;;){
            if(now <= 0){
                ans[x-1] = 0;
                break;
            }
            if(f == 0){
                now -= (now-1)%5;
                ans[x] = now;
                x++;
                f = 1;
            }
            else if(f == 1){
                int ji;
                (y%n == 0)? ji = jiro[n] : ji = jiro[y%n];
                now -= ji;
                ans[x] = now;
                y++;
                x++;
                f = 0;
            }
        }
        for(int i = 0;i < x; i++)printf("%d\n",ans[i]);
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int in;
  while(cin >> in){
    if(in == 0) break;
    int ohajiki = 32;

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

    int j = 0;

    while(1){
      ohajiki -= (ohajiki-1) % 5;
      if(ohajiki <= 0) break;
      cout << ohajiki << endl;
      ohajiki -= data[j];
      if(ohajiki <= 0) break;
      cout << ohajiki <<endl;
      j++;
      if(j == in) j = 0;
    }
    cout << "0" << endl; 
  }

  return 0;
}