Language: C++

#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long ll;

int n, id, p, q;

const ll MAX = 1000000;

struct Mem {
    int id;
    ll c;

    Mem() {}
    Mem(int _id, ll _c) { id = _id; _c = c; }
};

Mem array[40010];

int main(void) {
    while(cin >> n && n) {
        for(int i = 0; i < n; i++) {
            cin >> array[i].id >> p >> q;
            array[i].c = p * q;
        }
        for(int i = 0; i < n - 1; i++) {
            for(int j = i + 1; j < n; j++) {
                if(array[i].id == array[j].id && array[j].id) {
                    array[i].c += array[j].c;
                    array[j].id = 0;
                }
            }
        }
        bool hap = false;
        for(int i = 0; i < n; i++) {
            if(array[i].id && array[i].c >= MAX) {
                cout << array[i].id << endl;
                hap = true;
            }
        }
        if(!hap) {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:11: error: 'cin' was not declared in this scope
   25 |     while(cin >> n && n) {
      |           ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <stdio.h>
  +++ |+#include <iostream>
    5 | 
a.cc:27:20: error: reference to 'array' is ambiguous
   27 |             cin >> array[i].id >> p >> q;
      |                    ^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/vector:62,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:28:13: error: reference to 'array' is ambiguous
   28 |             array[i].c = p * q;
      |             ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:32:20: error: reference to 'array' is ambiguous
   32 |                 if(array[i].id == array[j].id && array[j].id) {
      |                    ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:32:35: error: reference to 'array' is ambiguous
   32 |                 if(array[i].id == array[j].id && array[j].id) {
      |                                   ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:32:50: error: reference to 'array' is ambiguous
   32 |                 if(array[i].id == array[j].id && array[j].id) {
      |                                                  ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:33:21: error: reference to 'array' is ambiguous
   33 |                     array[i].c += array[j].c;
      |                     ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:33:35: error: reference to 'array' is ambiguous
   33 |                     array[i].c += array[j].c;
      |                                   ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:34:21: error: reference to 'array' is ambiguous
   34 |                     array[j].id = 0;
      |                     ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:40:16: error: reference to 'array' is ambiguous
   40 |             if(array[i].id && array[i].c >= MAX) {
      |                ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:40:31: error: reference to 'array' is ambiguous
   40 |             if(array[i].id && array[i].c >= MAX) {
      |                               ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:41:17: error: 'cout' was not declared in this scope
   41 |                 cout << array[i].id << endl;
      |                 ^~~~
a.cc:41:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:41:25: error: reference to 'array' is ambiguous
   41 |                 cout << array[i].id << endl;
      |                         ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:22:5: note:                 'Mem array [40010]'
   22 | Mem array[40010];
      |     ^~~~~
a.cc:41:40: error: 'endl' was not declared in this scope
   41 |                 cout << array[i].id << endl;
      |                                        ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    4 | #include <stdio.h>
  +++ |+#include <ostream>
    5 | 
a.cc:46:13: error: 'cout' was not declared in this scope
   46 |             cout << "NA" << endl;
      |             ^~~~
a.cc:46:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:46:29: error: 'endl' was not declared in this scope
   46 |             cout << "NA" << endl;
      |                             ^~~~
a.cc:46:29: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'