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;

struct data{
	int id;
	int value;
	int num;
};

int main(){
	int n;
	int need;
	int officer[4000];
	while(cin >> n){
		if(n == 0) break;
		int count = 0;
		for(int i = 0; i < n; i++){
			data d;
			cin >> d.id >>
				d.value >> d.num;
			if(d.value > 0){
				need = 1000000 % d.value == 0 ? 1000000 / d.value : 1000000 / d.value + 1;
				if(d.num >= need){
					count++;
					officer[count] = d.id;
				}
			}
		}
		if(!count){
			cout << "NA" << endl;
		} else {
			for(int i = 1; i <= count; i++)
				cout << officer[i] << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
int GCD(int a, int b){
    if(b==0) return a;
    return GCD(b, a%b);
}

int main() {
    int n;
    while(cin >> n, n){
        map<ll, ll> mp;
        vector<ll> v;
        for(int i=0; i<n; ++i){
            ll e, p, q; cin >> e >> p >> q;
            mp[e]+=p*q;
            v.push_back(e);
        }
        
        bool check[4010];
        for(int i=0; i<4010; ++i) check[i]=false;
        int cnt=0;
        for(int i=0; i<v.size(); ++i){
            if(mp[v[i]]>=1000000&&!check[v[i]]) {
                cnt++;
                cout << v[i] << endl;
                check[v[i]]=true;
            }
        }
        if(cnt==0) cout << "NA" << endl;
    }
    
    
	return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int number[n];
    bool useN[n];
    long long int total[4000];
    for (int i = 0; i < n; i++) {
      number[n] = 0;
      useN[n] = true;
    }
    for (int i = 0; i < 4000; i++) total[i] = 0;
    
    for (int i = 0; i < n; i++) {
      int a;
      long long int b,c;
      cin >> a >> b >> c;
      number[i] = a;
      for (int j = 0; j < i; j++) {
	if (number[j] == a) {
	  useN[i] = false;
	  break;
	}
      }
      total[a-1] += b*c;
    }
    
    bool NA = true;
    for (int i = 0; i < n; i++) {
      if ( useN[i] && total[number[i]-1] >= 1000000) {
	cout << number[i] << endl;
	NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}

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++;
    }
    }
  }
}