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 <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int blank(const vi& table,int num)
{
	rep(i,table.size()-num+1){
		bool flg=true;
		rep(j,num)
			if(table[i+j])
				flg=false;
		if(flg)
			return i;
	}
	return -1;
}

int main()
{
	vi table(17);
	deque<int> customers;
	vi res(100);
	rep(t,1000){
		rep(i,table.size())
			table[i]=max(table[i]-1,0);
		if(t<=500 && t%5==0)
			customers.push_back(t/5);
		while(customers.size()){
			int customer=customers[0];
			int num=customer%5==1?5:2;
			int index=blank(table,num);
			if(index==-1)
				break;;
			res[customer]=t-customer*5;
			rep(i,num)
				table[index+i]=17*(customer%2)+3*(customer%3)+19;
			customers.pop_front();
		}
	}
	
	for(int n;cin>>n;)
		cout<<res[n]<<endl;
	
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int seat[17];
int res[200];

int main() {
	int i;
	int j;
	int k=-1;
	for(i=0;i<600;i++){
//cout<<i<<endl;
		for(j=0;j<17;j++){
			if(seat[j])seat[j]--;
//cout<<" "<<j<<" "<<seat[j]<<endl;
		}
		if(k==-1){
			if(i%5==0){
				k=i/5;
			}
		}
		while(1){
			int l;
			if(k==-1)break;
			if(k%5==1){
				for(l=0;l<17-5;l++){
					if(seat[l]+seat[l+1]+seat[l+2]+seat[l+3]+seat[l+4]==0){
						seat[l]=seat[l+1]=seat[l+2]=seat[l+3]=seat[l+4]=17*(k%2)+3*(k%3)+19;
						res[k]=i-k*5;
						k++;
						if(k>i/5)k=-1;
						goto a;
					}
				}
			}else{
				for(l=0;l<17-2;l++){
					if(seat[l]+seat[l+1]==0){
						seat[l]=seat[l+1]=17*(k%2)+3*(k%3)+19;
						res[k]=i-k*5;
						k++;
						if(k>i/5)k=-1;
						goto a;
					}
				}
			}
			break;
			a:;
		}
	}
	int n;
	while(cin>>n){
		cout<<res[n]<<endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
#define N 100
typedef long long ll;
typedef pair<int,int>P;
typedef struct D
{
	int t,n,e;
	bool operator <(const D &a)const
	{
		if(t==a.t)return n>a.n;
		return t>a.t;
	}
}D;
priority_queue<D>F;
int r[N],s[20],w=0;

int ch(int n)
{
	for(int i=0;i<17;i++)
		if(s[i]==-1)
		{
			int j;
			for(j=0;j<n&&i+j<17;j++)if(s[i+j]!=-1)break;
			if(j==n)return i;
		}
	return -1;
}

void dbg(D t)
{
	printf("%3d    ",t.t);
	for(int i=0;i<17;i++)
		printf("%2d ",s[i]);
	printf("   %d",t.n);
	puts("");
}

int main()
{
	memset(s,-1,sizeof(s));
	for(int i=0;i<N;i++)
	{
		D tmp={i*5,i,0};
		F.push(tmp);
	}
	while(!F.empty())
	{
		D n=F.top();F.pop();

		if(n.e)
		{
			for(int i=0;i<17;i++)
				if(s[i]==n.n)s[i]=-1;
		}
		else
		{
			if(w<n.n)
			{
				n.t++;
				F.push(n);
				continue;
			}
			int a=n.n%5==1?5:2,b=ch(a);
			if(b!=-1)
			{
				for(int j=0;j<a;j++)
					s[b+j]=n.n;
				r[n.n]=n.t-5*n.n;
				w=n.n+1;
				D tmp={n.t+19+17*(n.n%2)+3*(n.n%3),n.n,1};
				F.push(tmp);
			}
			else
			{
				n.t++;
				F.push(n);
			}
		}
		//dbg(n);
	}
	for(;~scanf("%d",&w);)printf("%d\n",r[w]);
	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){
		if(n < 50)c++;
		cout << stop[n] << endl;
	}
	int a = 0;
	while(c>=2){cout << a/a << endl;};
	
}