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 <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>=50){};
	
}

C++: main(){
	int n,c=0;
	while(~scanf("%d",&n)){
		if(n==98)c++;
	}
	return (c?1:0);
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100
 
struct S{
  int g, t;
  S(int g, int t) : g(g), t(t) {}
};
 
int arr[MAX];
vector<S> seat;
 
int minute(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(S(-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 = minute(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(S(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 = minute(g);
          }
          arr[g] = 0;
          break;
        }
      }
      if(!flg){
        _wait.push_back(S(g,0));
      }
      g++;
    }
  }
}
 
int main(){
  int N;
 
  make();
  while(cin >> N){
    cout << arr[N] << endl;
  }
 
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main() {
  vector<int> start(100);
  vector<int> number(100);
  for(int i = 0; i < 100; ++i) {
    start[i] = 5 * i;
    number[i] = (i % 5 == 1 ? 5 : 2);
    // t + 17*(i%2) + 3*(i%3) + 19;
  }
  vector<int> sheet(17, -1);
  vector<int> wait(100, -1);
  vector<int> end(100, -1);
  queue<int> que;
  for(int t = 0; ; ++t) {
    for(int i = 0; i < 100; ++i) {
      if(end[i] == t) {
        for(int j = 0; j < 17; ++j) {
          if(sheet[j] == i) sheet[j] = -1;
        }
      }
      if(start[i] == t) {
        que.push(i);
      }
    }
    while(!que.empty()) {
      int n = number[que.front()];
      int s = -1;
      for(int i = 0; i < 17; ++i) {
        int c = 0;
        for(int j = i; j < 17; ++j) {
          if(sheet[j] == -1) ++c;
          else break;
        }
        if(c >= n) {
          s = i;
          break;
        }
      }
      if(s != -1) {
        int k = que.front(); que.pop();
        for(int j = 0; j < n; ++j) {
          sheet[s + j] = k;
        }
        wait[k] = t - start[k];
        end[k] = t + 17*(k%2) + 3*(k%3) + 19;
      }
      else {
        break;
      }
    }
    bool f = true;
    for(int i = 0; i < 100; ++i) {
      if(end[i] == -1) f = false;
    }
    if(f) break;
  }
  for(int q; cin >> q; ) {
    cout << wait[q] << endl;
  }
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    vector<int> seat(17, -1);
    multimap<int, int> leave;

    vector<int> waitTime(100);
    int time = 0;
    for(int i=0; i<100; ++i){
        while(leave.size() > 0 && leave.begin()->first <= 5*i){
            replace(seat.begin(), seat.end(), leave.begin()->second, -1);
            leave.erase(leave.begin());
        }

        time = max(time, 5*i);
        int num = (i%5==1? 5:2);
        vector<int> tmp(num, -1);
        for(;;){
            int j = search(seat.begin(), seat.end(), tmp.begin(), tmp.end()) - seat.begin();
            if(j == 17){
                time = leave.begin()->first;
                while(leave.size() > 0 && leave.begin()->first == time){
                    replace(seat.begin(), seat.end(), leave.begin()->second, -1);
                    leave.erase(leave.begin());
                }
            }else{
                for(int k=0; k<num; ++k)
                    seat[j+k] = i;
                break;
            }
        }

        waitTime[i] = time - 5*i;
        leave.insert(make_pair(time + 17*(i%2) + 3*(i%3) + 19, i));
    }

    for(;;){
        int n;
        if(!(cin >> n))
            return 0;
        cout << waitTime[n] << endl;
    }
}