Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

type chair struct {
	group_id, rest_time int
}

type info struct {
	group_id, num, wait_sum, before_go int
	fixed                              bool
}

func main() {
	ans := make([]int, 100)
	chair := make([]chair, 17)
	for i := 0; i < 17; i++ {
		chair[i].group_id = -1
	}
	info := make([]info, 100)
	for i := 0; i <= 99; i++ {
		info[i].group_id = i
		info[i].before_go = 5 * i
		info[i].wait_sum = 0
		if i%5 == 1 {
			info[i].num = 5
		} else {
			info[i].num = 2
		}
		info[i].fixed = false
	}
	count := 0
	FLG := 0
	tmp_num := 0
	isOK := false
	waitFLG := false
	for {
		for i := 0; i < 17; i++ {
			if chair[i].group_id != -1 {
				chair[i].rest_time--
				if chair[i].rest_time <= 0 {
					chair[i].group_id = -1
				}
			}
		}
		waitFLG = false
		count = 0
		for i := 0; i < 100; i++ {
			if info[i].fixed {
				continue
			}
			if waitFLG == false && info[i].before_go == 0 {
				FLG = -1
				tmp_num = info[i].num
				for k := 0; k <= 17-tmp_num; k++ {
					isOK = true
					for p := 0; p < tmp_num; p++ {
						if chair[k+p].group_id != -1 {
							isOK = false
							break
						}
					}
					if isOK {
						FLG = k
						break
					}
				}
				if FLG != -1 {
					for k := FLG; k < FLG+tmp_num; k++ {
						chair[k].group_id = info[i].group_id
						chair[k].rest_time = 17*(i%2) + 3*(i%3) + 19
						info[i].fixed = true
					}
				} else {
					waitFLG = true
					info[i].wait_sum++
					count++
				}
			} else {
				if info[i].before_go == 0 {
					info[i].wait_sum++
				} else {
					info[i].before_go--
				}
				count++
			}
		}
		if count == 0 {
			break
		}
	}
	for i := 0; i <= 99; i++ {
		ans[i] = info[i].wait_sum
	}
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		fmt.Println(ans[n])
	}
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-3;
const double PI = acos(-1);

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int ans[110], d[18];

int calc(int t, int m){
	vi v(18, 0);
	for(int i = 16; i >= 0; i--){
		if(d[i] <= t) v[i] = v[i+1]+1;
	}
	auto it = max_element(all(v));
	if(*it < m) return -1;
	return it-v.begin();
}

int main(){
	int n, t, idx;
	for(int i = 0; i < 100; i++){
		n = i%5==1?5:2;
		t = max(t,i*5);
		while(1){
			idx = calc(t, n);
			if(idx < 0) {
				t++;
				continue;
			}
			ans[i] = t - i*5;
			for(int j = 0; j < n; j++) d[idx+j] = t + 17*(i%2)+3*(i%3)+19;
			break;
		}
	}
	while(cin>>n){
		printf("%d\n", ans[n]);
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int wtime[100] ={};
  deque<int> deq;  
  int seat[17]={};
  int members[17];
  for(int t = 0; t <= 99*5 || !deq.empty(); t++){
    REP(i,17)if(seat[i] > 0)seat[i]--;
    if(t%5 == 0 && t <= 99*5) deq.push_back(t/5);
    while(!deq.empty()){
      int mem = deq.front();
      int nop = (mem%5==1)?5:2;
      int sitable = -1;
      for(int i = 0, con = 0; i < 17; i++){
        if(seat[i]==0)con++;
        else con = 0;
        if(con == nop){
          sitable = i + 1 - nop;
          break;
        }
      }
      if(sitable >= 0){
        deq.pop_front();
        REP(i,nop){
          seat[sitable+i] = 17*(mem%2)+3*(mem%3)+19;
          members[sitable+i] = mem;
        }
      }else{
        break;
      }
    }
    REP(i,deq.size())wtime[deq[i]]++;
    /*
    printf("%d:",t);
    REP(i,17)cout<< ((seat[i])?members[i]:0) <<" ";
    cout<<endl;
    */
  }
  int n;
  while(cin>>n)cout<<wtime[n]<<endl;
  return 0;
}

C++: #include<stdio.h>
int main(){
  int m[17]={0};
  int mathi[100]={0};
  int i,j,t,n,k,l,mt,s=0;
  for(t=0;1;t++){
    for(i=0;i<17;i++)m[i]--;
    while(s*5<=t){
      n=2;
      if(s%5==1)n=5;
      for(i=0;i<17;i++){
	if(m[i]<1){
	  for(j=0;j<n;j++){
	    if(m[i+j]>0)break;
	  }
	  if(j==n)break;
	}
      }
      if(j==n){
	mt=17*(s%2)+3*(s%3)+19;
	for(j=0;j<n;j++)m[i+j]=mt;
	mathi[s]=t-5*s;
	s++;
	j=-1;
      }
      else break;
      if(s==100)break;
    }
    if(s==100)break;
  }
  while(scanf("%d",&k)!=EOF){
    //for(k=0;k<100;k++){
    printf("%d\n",mathi[k]);
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int seat[17] = {0};
	int X = 0;
	int stop[100] = {0};
	int time = 0;
	queue<int> Q;
	while(X < 100){
		int x;
		if(time%5 == 0 && time < 500){
			Q.push(time/5);
		}
		while(1){
			if(Q.size())x = Q.front();
			else x = -1;
			bool f = false;
			
			if(~x){
				int people = (x%5==1?5:2);
				int use = 19 + 3 * (x%3) + 17 * (x%2);
				rep(i,17-people+1){
					bool flag = true;
					rep(j,people){
						flag &= seat[i+j] == 0;
					}
					if(flag){
						rep(j,people){
							seat[i+j] = use;
						}
						f = true;
						break;
					}
				}
			}
			if(f){	
				stop[x] = time - x * 5;
				Q.pop();
				X++;
			}
			if(!f)break;
		}
		rep(i,17){
			seat[i] = max(0,seat[i]-1);
		}
		time++;
	}
	int n,c=0;
	while(cin >> n){
		cout << stop[n] << endl;
		c++;
	}
	while(c>=7){};
	
}

C++: #include<iostream>
using namespace std;
#define SHEETS 17
#define GROUPS 100
int main()
{
	int ans[GROUPS] = {0,};
	int now;
	int sheets[SHEETS+1] = {-1,};
	int peoples[GROUPS] = {0,};
	int waiting[GROUPS] = {0,};
	int eating[GROUPS] = {0,};

	for(int i = 0; i < SHEETS+1; ++i){
		sheets[i] = -1;
	}
	sheets[SHEETS] = -2;
	for(int i = 0; i < GROUPS; ++i)
	{
		waiting[i] = -i*5;
		peoples[i] = i%5==1?5:2;
		eating[i] = 17*(i%2)+3*(i%3)+19;
	}
	now = 0;
	for(int t = 0; t < 950; ++t){

		/*if( t % 5 == 0 ){
			cout << t / 5 << "ツつウツづアツつェツδ債グツイツδ督つオツづ慊つオツつスツ。\n";
		}*/

		for(int i = 0; i < SHEETS; ++i){
			if( sheets[i] >= 0 ){
				--eating[sheets[i]];
				if( eating[sheets[i]] == 0 ){
					for(;sheets[i+1]==sheets[i];++i)
						sheets[i] = -1;
					sheets[i]=-1;
				}else{
					for(;sheets[i+1]==sheets[i];++i)
						0;
				}
			}
		}

		while( true ){
			bool bCont = false;
			for(int i = 0; i < SHEETS; ++i){
				int cont = 0;
				if( sheets[i] < 0 ){
					for(int j = i; j < SHEETS; ++j){
						if( sheets[j] < 0 ) cont++;
						else break;
					}
					if( cont >= peoples[ now ] && waiting[ now ] >= 0 ){
						for(int j = i; j < i+peoples[now]; ++j)
							sheets[j] = now;
						ans[now] = waiting[now];//<0?0:waiting[now];
						++now;
						bCont = true;
					}
				}
			}
			if( !bCont )
				break;
		}
		for(int i = 0; i < GROUPS; ++i){
			++waiting[i];
		}
		
		/*for(int i = 0; i < SHEETS; ++i){
			cout << sheets[i] << ' ';
		}
		cout << endl;*/
	}
	/*for(int i = 0; i < GROUPS;++i){
		cout << ans[i] << ' ';
	}*/

	while(true){
		int n;
		cin >> n;
		if(cin.eof())
			break;
		cout << ans[n] << endl;
	}

	return 0;
}