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<bits/stdc++.h>
using namespace std;

struct Group{
	int indx, num;
	Group(){}
	Group(int indx_c, int num_c){
		indx = indx_c; num = num_c;
	}
};

int main(){
	int table[17] = {}, ans[100];
	queue<Group> q;
	for(int t = 0;; t++){
		for(int i = 0; i < 17; i++) table[i]--;
		
		if(t%5 == 0 && t/5 < 100){
			q.push( Group(t/5, ( (t/5)%5 == 1 ) ? 5 : 2 ) );
		}
		if( t/5 >= 100 && q.empty() ) break;
		
		while( !q.empty() ){
		
		Group front_group = q.front();
		int space_cnt = 0;
		bool was_pop = false;
		for(int i = 0; i < 17; i++){
			if( table[i] <= 0) space_cnt++;
			else space_cnt = 0;
			if(space_cnt >= front_group.num){
				for(int j = 0; j < space_cnt; j++){
					table[i-j] = 17*(front_group.indx%2)+3*(front_group.indx%3)+19;
				}
				ans[front_group.indx] = t - front_group.indx*5;
				q.pop();
				was_pop = true;
				break;
			}
		}
		
		if(was_pop == false) break;
		}
	}
	
	int N;
	while(cin >> N){
		printf("%d\n", ans[N]);
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>

#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;

vector<int> ans(100);
vector<int> table(17);

struct K
{
	int id;
	int startT;
	int eatingT;
	int endT;
	int num;
};

queue<K> wait;

int getNum(int n)
{
	rep(i,17)
	{
		if(table[i] > 0) continue;

		REP(j,i+1,17)
		{
			if(table[j] > 0) break;;

			if(j-i+1 == n)
			{
				return i;
			}
		}
	}

	return -1;
}

void task()
{
	int t = 0;
	while(!wait.empty())
	{
		while(!wait.empty() && wait.front().id * 5 <= t)
		{
			K temp = wait.front();
			int start = getNum(temp.num);
			if(start != -1)
			{
				REP(k,start,start + temp.num)
				{
					table[k] = temp.eatingT;
				}
				ans[temp.id] = abs(t - temp.startT);
				wait.pop();
			}
			else break;
		}

		rep(i,17)
		{
			if(table[i] > 0) table[i]--;
		}
		t++;
	}
}

int main()
{
	rep(i,100)
	{
		K k;
		k.id = i;

		if(i%5 == 1) k.num = 5;
		else k.num = 2;

		k.eatingT = 17*(i%2) + 3*(i%3) + 19;
		k.startT = 5*i;
		wait.push(k);
	}

	rep(i,17) table[i] = 0;

	task();

	int n;
	while(cin >> n)
	{
		cout << ans[n] << endl;
	}
	
	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 == 3)c++;
		cout << stop[n] << endl;
	}
	int a = 0;
	while(c>=1){cout << a/a << endl;};
	
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int ans[100]={0};
  vector<int>seki(17,-1);
  vector<int>machi;
  rep(i,100000){
    //cout<<machi.size()<<endl;
    if(i>510&&machi.size()==0)break;
    if(i<100&&i%5==0)machi.pb(i/5);
    rep(j,7)
      if(seki[j]==1)seki[j]=-1;
      else if(seki[j]!=-1)seki[j]--;
    while(1){
      if(machi.size()==0)break;
      int n;
      if(machi[0]%5==1)n=5;
      else n=2;
      bool han=false;
      rep(j,17-n+1){
	bool h=true;
	rep(k,n)if(seki[k+j]!=-1){h=false;break;}
	if(h){
	  han=true;
	  ans[machi[0]]=i-machi[0]*5;
	  rep(k,n)seki[k+j]=17*(machi[0]%2)+3*(machi[0]%3)+19;
	  machi.erase(machi.begin());
	  break;
	}
	//cout<<i<<endl;
      }
      if(han==false)break;
    }
  }
  int in;
  while(cin>>in)cout<<ans[in]<<endl;
}

C++: #include<queue>
#include<cstdio>

#define	mp	make_pair
#define	EMPTY	-1

using namespace std;

typedef	pair<int,int>	pii;

int Numbers(int groupid){
	return groupid%5==1?5:2;
}

int MealTime(int groupid){
	return 17*(groupid%2)+3*(groupid%3)+19;
}

int main()
{
	int counter[17],elapse[17],mealtime[17];
	queue<pii> qu;	// <numbers in a group, group id>

	for(int i=0;i<17;i++)	counter[i]=EMPTY;

	int waittime[100];
	for(int t=0;t<589;t++){
		// enqueue
		if(t%5==0&&t<500){
			qu.push(mp(Numbers(t/5),t/5));
		}

		// going
		for(int i=0;i<17;i++){
			if(counter[i]!=EMPTY){
				elapse[i]++;
				if(elapse[i]==mealtime[i])	counter[i]=EMPTY;
			}
		}

		// coming
		bool came;
		do{
			came=false;
			if(qu.empty())	break;

			pii next=qu.front();
			for(int i=0,cnt=0;i<17;i++){
				if(counter[i]==EMPTY)	cnt++;
				else					cnt=0;

				if(cnt==next.first){
					int mt=MealTime(next.second);
					for(int j=i;j>i-next.first;j--){
						counter[j]=next.second;
						mealtime[j]=MealTime(next.second);
						elapse[j]=0;
					}
					waittime[next.second]=t-5*next.second;
					came=true;
					qu.pop();
					break;
				}
			}
		}while(came);
	}

	for(int n;~scanf("%d",&n);)	printf("%d\n",waittime[n]);

	return 0;
}