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 <vector>
#include <cstring>
using namespace std;

int ans[100];

class G{
public:
	int id,n,a,d; //O[vÔ,l,,HÔ

	G(int i){
		id = i;
		n = (i % 5 == 1 ? 5 : 2);
		a = 5 * i;
		d = 17 * (i % 2) + 3 * (i % 3) + 19;
	}
};

//nlA±ÅÈðmÛÅ«éêðÔ·
int indexOfSeat(int *seat,int n){
	int count = 0;

	for(int i=0;i<17;i++){
		if(!seat[i]){
			count++;
			if(count == n) return i - n + 1;
		}
		else{
			count = 0;
		}
	}

	return -1;
}

void solve(void){
	vector<G> v; //Ò¿sñ
	for(int i=0;i<100;i++) v.push_back(G(i));

	int time = 0; //»ÝÌ
	int seat[17]; //Èîñ
	memset(seat,0,sizeof(seat));

	while(!v.empty()){
		while(!v.empty() && v[0].a<=time){
			int idx = indexOfSeat(seat,v[0].n);
			if(idx != -1){
				for(int i=idx;i<idx+v[0].n;i++) seat[i] = v[0].d;
				ans[v[0].id] = time - v[0].a;
				v.erase(v.begin());
			}
			else{
				break;
			}
		}

		time++;
		for(int i=0;i<17;i++) if(seat[i] > 0) seat[i]--;
	}
}

int main(void){
	solve();

	int n;
	while(cin>>n) cout<<ans[n]<<endl;

	return 0;
}

C++: #include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
int main() {
	int n, cntdwn[17]={}, ans[100];
	queue<int> q;
	for (int m=0; m<600; ++m) {
		if (m%5==0 && m/5<100) q.push(m/5);
		for (int i=0; i<17; ++i) --cntdwn[i];
		while ( ! q.empty()) {
			int num = (q.front()%5==1 ? 5 : 2);
			int c = 0, k = -1;
			for (int i=0; i<17; ++i) {
				c = (cntdwn[i]<=0 ? c+1 : 0);
				if (c==num) {
					k = i-num+1;
					break;
				}
			}
			if (k < 0) break;
			for (int i=k; i<k+num; ++i) {
				cntdwn[i] = 17*(q.front()%2)+3*(q.front()%3)+19;
			}
			ans[q.front()] = m-5*q.front();
			q.pop();
		}
	}
	while (cin >> n) {
		cout << ans[n] << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define MAX 100

struct info{
  int g, t;
  info(int g, int t) : g(g), t(t) {}
};

int arr[MAX];
vector<info> seat;

int minite(int i){
  return 17*(i%2) + 3*(i%3) + 19;
}

void make(){
  int g = 0;
  for(int i = 0 ; i < 17 ; i++){
    seat.push_back(info(-1,-1));
  }
  vector<info> _wait;
  for(int i = 0 ; i < 570 ; i++){
    int size = _wait.size();

    if(size){
      for(int j = 0 ; j < size ; j++){
        _wait[j].t++;
      }
    }
   
    for(int j = 0 ; j < 17 ; j++){
      if(seat[j].g != -1){
        seat[j].t--;
        if(seat[j].t == 0){
          seat[j].g = seat[j].t = -1;
        }
      }
    }
 
    if(size){
      for(int j = 0 ; j < size ; j++){
        int n = _wait[j].g;
        int cnt, c;
        bool flg = false;
        if(n % 5 == 1) cnt = c = 5;
        else cnt = c = 2;
        for(int k = 0 ; k < 17 ; k++){
          if(seat[k].g == -1) cnt--;
          else cnt = c;
          if(cnt == 0){
            for(int l = k-c+1 ; l <= k ; l++){
              seat[l].g = n;
              seat[l].t = minite(n);
            }
            arr[n] = _wait[j].t;
            flg = true;
            j--;
            _wait.erase(_wait.begin());
            break;
          }
        }
        if(!flg || !_wait.size()) break;
      }
      size = _wait.size();
    }
    if(g == 100) continue;
    if(i % 5 == 0){
      int cnt, c;
      bool flg = false;
      if(size){
        _wait.push_back(info(g,0));
        g++;
        continue;
      }
      if(g % 5 == 1) cnt = c = 5;
      else cnt = c = 2;
      
      for(int j = 0 ; j < 17 ; j++){
        if(seat[j].g == -1) cnt--;
        else cnt = c;
        if(cnt == 0){
          flg = true;
          for(int k = j-c+1 ;  k <= j ; k++){
            seat[k].g = seat[k].g = g;
            seat[k].t = seat[k].t = minite(g);
          }
          arr[g] = 0;
          break;
        }
      }
      if(!flg){
        _wait.push_back(info(g,0));
      }
      g++;
    }
  }
}

int main(){
  int N;

  make();
  while(cin >> N){
    cout << arr[N] << endl;
  }

  return 0;
}

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

using namespace std;

int chair[17];
int ans[100];

//øÌA±µÄ¢éÀÈÌÅ¬ÔðÔ·
int isempty(int arg){
	int ret=-1;
	int num=0;
	int maxi = 0;
	int begin=0;
	for(int i=0;i<17;i++){
		if(chair[i] == 0){
			if(num == 0) begin = i;
			num++;
		}else{
			if(num >= arg) return begin;
			num = 0;
		}
	}
	if(num >= arg) return begin;
	return -1;
}

int main(){
	memset(chair, 0, sizeof(chair));
	deque<int> waiting;
	for(int t=0;t<600;t++){
		int n;
		for(int i=0;i<17;i++){
			if(chair[i] != 0) chair[i]--; //cèÔð¸ç·
		}
		if(t%5 == 0){ //q`FbN
			waiting.push_back(t/5);
		}
		while(!waiting.empty()){ //È`FbN
			if(waiting.front()%5==1){
				n=5;
			}else{
				n=2;
			}
			int place = isempty(n);
			if(place == -1) break;
			//ÈÉÂ¯é
			for(int j=0;j<n;j++){
				chair[place+j] = 17 * (waiting.front()%2) + 3 * (waiting.front()%3) + 19;
			}
			ans[waiting.front()] = t - waiting.front() * 5;
			waiting.pop_front();
		}
	}
	int q;
	
	while(cin >> q){
		cout << ans[q] << endl;
	}
}