Go: package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

C++: #include <iostream>

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

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

	while( cin >> n && n != 0 ){
		for( int i = 0;i < n;i++ ){
			int target;
			long long 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;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int  existnum(vector<int> v,int e){
    for(int i=0;i<v.size();i++){
        if(v[i]==e)return i;
    }
    return -1;
}

int main(void){
    int n,b=0,e,p,q,num;
    vector<int> se,sp,sq;
    while(1){
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>e;
            cin>>p;
            cin>>q;
            //cout<<existnum(se,e)<<endl;
            if((num=existnum(se,e))!=-1){
                sp[num]+=p;
                //cout<<sp[num]<<endl;
                sq[num]+=q;
                //cout<<sq[num]<<endl;
            }else{
                se.push_back(e);
                sp.push_back(p);
                sq.push_back(q);
            }
            //cout<<se.back()<<endl;
        }
        for(int i=0;i<n;i++){
            if(sp[i]*sq[i]>=1000000){
                cout<<se[i]<<endl;
                b=1;
            }
        }
        if(b==0){
            cout<<"NA"<<endl;
        }
        sp.clear();
        se.clear();
        sq.clear();
        b=0;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

string int_to_str(int n) {
	stringstream ss;
	string ret;

	ss << n;
	ss >> ret;

	return ret;
}


int keta(int n) {
	string str = int_to_str(n);

	return str.size();
}

int main() {
	int n;
	while (cin >> n, n) {
		bool f = false;
		map<int, ll> datas;
		vector<int> noes;
		for (int i = 0; i < n; ++i) {
			int no, a, b; cin >> no >> a >> b;

			if ( find( noes.begin(), noes.end(), no) == noes.end() )
				noes.push_back(no);

			if (datas[no] < 1000000) {
				if (keta(a) + keta(b) - 2 >= 6)
					datas[no] = 1000000,
					f = true;

				else if ((datas[no] += a * b) >= 1000000)
					f = true;
			}
		}
		for (int i = 0; i < noes.size(); ++i)
			if (datas[noes[i]] >= 1000000)
				cout << noes[i] << endl;

		if (!f) cout << "NA" << endl;
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS 1

#include <cstdio>
#include <vector>
using namespace std;
int main()
{
	long long n;
	while (scanf("%Ld\n", &n), n) {
		vector<pair<long long, long long> > v;
		for (long long i = 0; i < n; i++) {
			long long p, q, r, f = 1;
			scanf("%Ld %Ld %Ld\n", &p, &q, &r);
			for (long long j = 0; j < v.size(); j++) {
				if (v[j].first == p) {
					f = 0;
					v[j].second += q * r;
				}
			}
			if (f) {
				pair<long long, long long> pa(p, q * r);
				v.push_back(pa);
			}

		}
		long long g = 1;
		for (long long i = 0; i < v.size(); i++) {
			if (1000000 <= v[i].second) {
				g = 0;
				printf("%Ld\n", v[i].first);
			}
		}
		if (g) puts("NA");
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <algorithm>
#include <utility>

using Sale=std::pair<int,int>;

int main(){
  int n;

  while(1){
    std::cin>>n;
    if(n==0)break;
    std::vector<Sale> data(n);

    for(auto &d:data){
      int price,num;
      std::cin>>d.first>>price>>num;
      d.second=price*num;
    }

    std::vector<Sale> unduplicate_data;

    for(auto &d:data){
      auto s=std::find_if(unduplicate_data.begin(),unduplicate_data.end(),[d](const Sale& s)->bool{ return s.first==d.first; });
      if(s==unduplicate_data.end()){
        unduplicate_data.push_back(d);
      }else{
        s->second+=d.second;
      }
    }

  
    bool isNA=true;
    for(auto d:unduplicate_data){
      if(d.second>=1000000){
        std::cout<<d.first<<std::endl;
        isNA=false;
      }
    }
    if(isNA)std::cout<<"NA"<<std::endl;
  }
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int NORMA = 1000000;

int main() {
  int N;
  while(cin >>N && N){
    map<int, int> m;
    set<int> s;
    vector<int> v;
    REP(i, N){
      int a, b, c; cin >>a >>b >>c;
      m[a] += b * c;
      if(s.find(a) == s.end()) v.push_back(a);
      s.insert(a);
    }
    vector<int> ans;
    REP(i, v.size()) if(m[v[i]] >= NORMA) ans.push_back(v[i]);
    if(ans.size() == 0) cout <<"NA" <<endl;
    else REP(i, ans.size()) cout <<ans[i] <<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int n;
    while (cin >> n, n) {
        vector<ll> s(4000, 0);
        REP(i,n) {
            int e,p,q;
            cin >> e >> p >> q;
            s[e-1] += p*q;
        }
        bool flag = false;
        REP(i,4000) {
            if (s[i] >= 1000000) {
                cout << i + 1 << endl;
                flag = true;
            }
        }
        if (!flag) cout << "NA" << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
typedef long long ll;
ll a[4001];

int main(){
	int n, num, p, q;
	while(cin >> n, n){
		fill(a, a+4001, 0);
		int f = 1;
		
		for(int i = 0;i < n;i++){
			cin >> num >> p >> q;
			a[num] += p * q;
			if(a[num]>999999)cout << num << endl, f = 0;
		}
		
		if(f)cout << "NA" <<endl;
	}
	return 0;
}