Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

C++: #include<iostream>
using namespace std;

class meb{
public:
	int num;
	int tanka;
	int count;
	int sum;
};

int main(){
	int n;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int k=0;k<n;k++){
			st[k].sum=st[k].tanka*st[k].count;
		}
		for(int j=0;j<n;j++){
			for(int l=j+1;l<n;l++){
				if(st[j].num==st[l].num){
					(st[j].sum)=(st[j].sum)+(st[l].sum);
					st[l].sum=0;
				}
			}
		}
		for(int a=0;a<n;a++){
			if(st[a].sum>=1000000)cout<<st[a].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

#define MAX_I (1001)

class Data{
public:
	int e;
	long pq;
	int i;

	Data() : e(0), pq(0), i(MAX_I){
		return;
	}

	~Data(){
		return;
	}

	bool operator < (const Data &r){
		return this->i < r.i;
	}
};

int main(int argc, char **argv){
	int n, e, p, q;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	while(ifs >> n){
#else
	while(std::cin >> n){
#endif
		if(n == 0){ break; }

		std::vector<Data> data(4001);
		std::vector<int> result;

		for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
			ifs >> e >> p >> q;
#else
			std::cin >> e >> p >> q;
#endif
			if(data[e].i == MAX_I){
				data[e].i = i;
			}
			data[e].e = e;
			data[e].pq += p * q;
		}

		std::sort(data.begin(), data.end());

		for(int i = 0; i < data.size(); i++){
			if(data[i].pq >= 1000000){
				result.push_back(data[i].e);
			}
		}
		if(result.empty()){
			std::cout << "NA" << std::endl;
		}
		else{
			for(int i = 0; i < result.size(); i++){
				std::cout << result[i] << std::endl;
			}
		}
	}
	

#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}

C++: #include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long long> m;
		vector <string> data;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			if (!m[str]) data.push_back(str);
			m[str] += (num * a);
		}
		bool flag = true;
		for (int i = 0; i < data.size(); i++){
			if (1000000 <= m[data[i]]){
				cout << data[i] << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
	int n;

	while(true){
		int user[4000];
		int usercount = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}

		long long int buf[3];
		for(int i=0;i<n;i++){
			cin >> buf[0] >> buf[1] >> buf[2];
			if(buf[1] * buf[2] >= 1000000){
				user[usercount] = buf[0];
				usercount++;
			}
		}

		for(int i=0;i<usercount;i++){
			cout << user[i] << endl;
		}
		if(usercount == 0){
			cout << "NA" << endl;
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n,a,p,c;
  while(std::cin>>n,n){
		vector<int> v;
		vector<int>::iterator it;
    for(;n;n--){
      cin>>a>>p>>c;
      it=find(v.begin(),v.end(),a);
      if(p*c>=1000000&&it-v.end())v.push_back(a);
    }
    if(v.empty())cout<<"NA"<<endl;
    else{
    it = v.begin();
    while(it!=v.end()){
      cout<<*it<<endl;
      it++;
    }
    }
  }
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int n;
	
	while(cin >> n, n) {
		ll ban, tan, suu;
		bool flag = true;
		
		REP(i, n) {
			cin >> ban >> tan >> suu;

			if(tan*suu >= 1000000) {
				cout << ban << endl;
				flag = false;
			}
		}

		if(flag) {
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>

using namespace std;

bool find(vector<int> idx, int no);

int main()
{
    while (true) {
        int data_num;
        cin >> data_num;

        if (data_num == 0) {
            break;
        }

        vector<int> idx;
        map<int, long> sale;
        while (data_num--) {
            int no, price, num;
            cin >> no >> price >> num;

            long sum = price * num;
            if (find(idx, no)) {
                sale.at(no) += sum;
            } else {
                idx.push_back(no);
                sale.insert(make_pair(no, sum));
            }
        }

        bool is_exist = false;
        for (size_t i = 0; i < idx.size(); i++) {
            if (sale.at(idx.at(i)) >= 1000000) {
                cout << idx.at(i) << endl;
                is_exist = true;
            }
        }

        if (!is_exist) {
            cout << "NA" << endl;
        }
    }

    return 0;
}

bool find(vector<int> idx, int no)
{
    for (size_t i = 0; i < idx.size(); i++) {
        if (no == idx.at(i)) {
            return true;
        }
    }
    return false;
}

C++: #include <iostream>
#include <algorithim>

using namespace std;
class MAN{
public:
	unsigned int uriage;
	short number;
};

int main(int argc, char const* argv[])
{
	MAN *person;
	int n;
	bool flag;

	while( cin >> n && n != 0 ){
		person  = new MAN[n];
		for( int i = 0;i < n;i++ ){
			int target;
			int a,b;
			cin >> target >> a >> b;

			int j;
			for( j = 0;j < i;j++ ){
				if( person[j].number == target ){
					person[j].uriage += a*b;
					break;
				}
			}
			if( j == i ){
				person[i].number = target;
				person[i].uriage = a * b;
			}
		}
		flag = false;
		for( int i = 0;i < n;i++ ){
			if( person[i].uriage >= 1000000 ){
				cout << person[i].number << endl;
				flag = true;
			}
		}
		if( flag == false ) cout << "NA" << endl;
		delete[] person;
	}

	return 0;
}