#include <iostream>
#include <regex>

using namespace std;

const std::string CpuInfo =
  "Architecture:        x86_64\n"
  "CPU op-mode(s):      32-bit, 64-bit\n"
  "Byte Order:          Little Endian\n"
  "Address sizes:       43 bits physical, 48 bits virtual\n"
  "CPU(s):              12\n"
  "On-line CPU(s) list: 0-11\n"
  "Thread(s) per core:  2\n"
  "Core(s) per socket:  6\n"
  "Socket(s):           1\n"
  "NUMA node(s):        1\n"
  "Vendor ID:           AuthenticAMD\n"
  "CPU family:          23\n"
  "Model:               1\n"
  "Model name:          AMD Ryzen 5 1600 Six-Core Processor\n"
  "Stepping:            1\n"
  "CPU MHz:             2482.474\n"
  "CPU max MHz:         3200.0000\n"
  "CPU min MHz:         1550.0000\n"
  "BogoMIPS:            6387.25\n"
  "Virtualization:      AMD-V\n"
  "L1d cache:           32K\n"
  "L1i cache:           64K\n"
  "L2 cache:            512K\n"
  "L3 cache:            8192K\n"
  "NUMA node0 CPU(s):   0-11";

int main() {
  std::regex reg_ex("CPU MHz:\\s+([^\\n]+)\\n?");
  std::smatch reg_match;
  std::string result = (std::regex_search(CpuInfo, reg_match, reg_ex)) ? 
    reg_match[1] : std::string("Not found!"); 
  std::cout << "CPU MHz: " << result << std::endl;
  return 0;
}