LCOV - code coverage report
Current view: top level - 01 - b.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 15 15
Test Date: 2025-10-12 18:20:59 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 100.0 % 6 6

             Branch data     Line data    Source code
       1                 :             : #include <iostream>
       2                 :             : #include <fstream>
       3                 :             : #include <vector>
       4                 :             : #include <unordered_map>
       5                 :             : #include <numeric>
       6                 :             : using namespace std;
       7                 :             : 
       8                 :           2 : int main() {
       9                 :           2 :   ifstream file("input.txt");
      10         [ +  + ]:           2 :   if (!file) {
      11                 :           1 :     cerr << "Error: Could not open input file." << endl;
      12                 :           1 :     return 1;
      13                 :             :   }
      14                 :             : 
      15                 :           1 :   vector<int> list1;
      16                 :           1 :   unordered_map<int, int> freq;
      17                 :             : 
      18                 :             :   int a;
      19                 :             :   int b;
      20         [ +  + ]:        1001 :   while (file >> a >> b) {
      21                 :        1000 :     list1.push_back(a);
      22                 :        1000 :     ++freq[b];
      23                 :             :   }
      24                 :             : 
      25                 :        1000 :   cout << accumulate(list1.begin(), list1.end(), 0, [&freq](int sum, int num) {
      26                 :        1000 :            return sum + num * freq[num];
      27                 :           1 :          })
      28                 :           1 :        << endl;
      29         [ +  + ]:           3 : }
        

Generated by: LCOV version 2.0-1