#include #include #include #include using namespace std; struct Range { long long begining; long long end; }; vector read_file(const string &FILE_NAME) { ifstream file(FILE_NAME); string s; vector result; while (getline(file, s)) { result.push_back(s); } return result; } vector get_fresh_ids(const vector input) { vector fresh_ids; for (string line : input) { if (line.empty()) { break; } string begining, end; begining = line.substr(0, line.find("-")); end = line.substr(line.find("-") + 1); Range l_range = {stoll(begining), stoll(end)}; fresh_ids.push_back(l_range); } return fresh_ids; } vector get_product_ids(const vector input) { vector product_ids; bool end_of_fresh_ids = false; for (string line : input) { if (line.empty()) { end_of_fresh_ids = true; continue; } if (!end_of_fresh_ids) { continue; } product_ids.push_back(stoll(line)); } return product_ids; } int main() { const string FILE_NAME = "input.txt"; vector input = read_file(FILE_NAME); vector fresh_ids = get_fresh_ids(input); vector product_ids = get_product_ids(input); int count = 0; for (long long number : product_ids) { for (const Range &range : fresh_ids) { if (number >= range.begining && number <= range.end) { count++; break; } } } cout << count; return 0; }