Problem p02264 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <math.h> /* pow */
#include <queue>
#include <stdio.h> /* printf */
#include <stdlib.h>
#include <string>
#include <vector>

/*void print_array(std::queue<std::pair<std::string, int> > list)
{
  for(int i = 0; i < list.size(); ++i){
    std::cout << list[i].first << " " << list[i].second<< std::endl;
  }
}*/

void roundRobin(std::queue<std::pair<std::string, int>> &list, int quantum) {
  int timeSpent = 0;
  while (!list.empty()) {
    if (list.front().second <= quantum) {
      timeSpent += list.front().second;
      std::cout << list.front().first << " " << timeSpent << std::endl;

    } else {
      timeSpent += quantum;
      list.front().second -= quantum;
      list.push(list.front());
    }
    list.pop();
  }
  // print_array(list);
  // std::cout << i << std::endl;
}

int main(void) {

  int num;
  std::cin >> num;
  /*    if (num>100000) {
          std::cout << "too many processes" << std::endl;
          return 1;
      }
  */
  int quantum;
  std::cin >> quantum;
  /*    if (num>1000) {
          std::cout << "too long quantum" << std::endl;
          return 1;
      }
    */
  std::queue<std::pair<std::string, int>> list;

  int totalTime = 0;
  for (int i = 0; i < num; i++) {
    std::string value;
    std::cin >> value;
    /*if (value.size()>10) {
        std::cout << "Process name too long" << std::endl;
        return 1;
    } */
    int timeNeeded;
    std::cin >> timeNeeded;
    /*if (timeNeeded>50000) {
        std::cout << "Process time too long" << std::endl;
        return 1;
    } */
    list.push(std::make_pair(value, timeNeeded));
    totalTime += timeNeeded;
  }

  /*    if (totalTime>1000000) {
          std::cout << "All Processes time too long" << std::endl;
          return 1;
      }
  */
  // print_array(list);
  roundRobin(list, quantum);

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h> /* pow */
#include <queue>
#include <stdio.h> /* printf */
#include <stdlib.h>
#include <string>
#include <vector>

void roundRobin(std::queue<std::pair<std::string, int>> &list, int quantum) {
  int timeSpent = 0;
  while (!list.empty()) {
    if (list.front().second <= quantum) {
      timeSpent += list.front().second;
      std::cout << list.front().first << " " << timeSpent << std::endl;

    } else {
      timeSpent += quantum;
      list.front().second -= quantum;
      list.push(list.front());
    }
    list.pop();
  }
  // print_array(list);
  // std::cout << i << std::endl;
}

int main(void) {

  int num;
  std::cin >> num;
  if (num > 100000) {
    std::cout << "too many processes" << std::endl;
    return 1;
  }

  int quantum;
  std::cin >> quantum;
  if (num > 1000) {
    std::cout << "too long quantum" << std::endl;
    return 1;
  }

  std::queue<std::pair<std::string, int>> list;

  int totalTime = 0;
  for (int i = 0; i < num; i++) {
    std::string value;
    std::cin >> value;
    if (value.size() > 10) {
      std::cout << "Process name too long" << std::endl;
      return 1;
    }
    int timeNeeded;
    std::cin >> timeNeeded;
    if (timeNeeded > 50000) {
      std::cout << "Process time too long" << std::endl;
      return 1;
    }
    list.push(std::make_pair(value, timeNeeded));
    totalTime += timeNeeded;
  }

  if (totalTime > 1000000) {
    std::cout << "All Processes time too long" << std::endl;
    return 1;
  }

  // print_array(list);
  roundRobin(list, quantum);

  return 0;
}