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>
#include <map>
#include <algorithm>
using namespace std;

typedef long long int lli;

int main() {
  int n;
  
  while(cin>>n, n) {
    map<lli,lli> mp;

    for(int i=0; i<n; i++) {
      lli a, b, c;
      cin >> a >> b >> c;
      mp[a] += b * c;
    }
    bool isExist = false;
    for(map<lli, lli>::iterator it = mp.begin(); it!=mp.end(); it++) {
      if( it->second >= 1000000 ) {
	isExist = true;
	cout << it->first << endl;
      }
    }
    if( !isExist ) cout << "NA" << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		set <int> T;
		bool flag = true;
		while ( n-- )
		{
			int no;
			long long p, q;
			cin >> no >> p >> q;

			if ( T.find( no ) == T.end() && p * q >= 1000000 )
			{
				flag = false;
				cout << no << endl;
				T.insert( no );
			}
		}

		if ( flag )
			cout << "NA\n";
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int n;

int main() {
	while(scanf("%d\n", &n) != EOF) {
		vector<pair<int, ll>> v;
		vector<int> id, p, q;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			id.push_back(x);
			p.push_back(y);
			q.push_back(z);
		}
		rep(i,n) {
			bool flag = false;
			for(vector<pair<int, ll>>::iterator it = v.begin(); it != v.end(); ++it) {
				if((*it).first == id.at(i)) {
					(*it).second += p.at(i) * q.at(i);
					flag = true;
					break;
				}
			}
			if(!flag) {
				v.push_back(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
			}
		}
		bool flag = false;
		for(vector<pair<int, ll>>::iterator it = v.begin(); it != v.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n;
	int a,b,c,bc;
	int i;
	int flg;
	bc=0;
	flg=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		bc=b*c;
		if(bc>1000000){
			printf("%d\n",a);
			flg=1;
		}
	}
	if(flg==0){
		printf("NA");
	}
	return 0;
}

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

int n;
int a[3];
std::vector<std::pair<int, int>> vec;
bool x[4001];

int main() {
	while (1) {
		std::cin >> n;
		if (n == 0)
			break;
		int count = 0;
		vec.clear();
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 3; ++j)
				std::cin >> a[j];
			if (x[a[0]]) {
				for (int k = 0; k < vec.size(); ++k) {
					if (vec[k].first == a[0])
						vec[k].second += a[1] * a[2];
				}
			}
			else {
				vec.push_back(std::make_pair(a[0], a[1] * a[2]));
				x[a[0]] = true;
			}
		}
		for (auto it = vec.begin(); it != vec.end(); ++it) {
			if ((*it).second >= 1000000) {
				std::cout << (*it).first << std::endl;
				++count;
			}
		}
		if (count==0)
			std::cout << "NA" << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
long long a[5000];
bool check[5000];
int main(){
	int n;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<5000;i++){
		a[i]=0;
		check[i]=true;
	}
	bool na=true;
	long long b,c,d;
	for(int i=0;i<n;i++){
		cin>>b>>c>>d;
		a[b]+=c*d;
		if(a[b]>=1000000&&check[b]==true){
			check[b]=false;
			na=false;
			cout<<b<<endl;
		}
	}
	if(na==true)
		cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <cmath>
#include <map>


int main(int,char**){
	typedef std::map<short,long long> Data;
	
	int n;
	while(std::cin>>n){
		if(!n) break;
		bool ex(0);
		Data tbl;
		while(n--){
			int Cnum,at,num;
			std::cin >>Cnum>>at>>num;
			tbl[Cnum]+=at*num;
		}
		for(Data::const_iterator it=tbl.begin();it!=tbl.end();++it){
			if((it->second)>=1000000){ std::cout<< it->first << std::endl; ex=1;}
		}
		if(!ex) std::cout << "NA"<<std::endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main() {
	int n;
	while (cin >> n, n) {
		ll data[4001] = {};
		bool uni[4001] = {};
		vi order;
		
		REP(i, n) {
			ll a, b, c;
			scanf("%lld %lld %lld", &a, &b, &c);
			if (!uni[a]) {
				uni[a] = true;
				order.push_back(a);
			}
			data[a] += b * c;
		}
		
		bool f = false;
		REP(i, order.size()) {
			int num = order[i];
			if (data[num] >= 1000000) {
				printf("%d\n", num);
				f = true;
			}
		}
		if (!f) puts("NA");
	}
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct salary{
	int no;
	long long sell;
};

int main() {
	
	int n;
	while(cin>>n,n){
		vector<salary> vs;
		set<int> si;
		REP(i, n){
			int no,v,sum;
			cin >> no >> v >> sum;
			if (si.find(no) == si.end()){
				vs.push_back({ no, (long long)(v*sum) });
				si.insert(no);
			}
			else
				REP(j, vs.size()){
				if (vs[j].no == no)
					vs[j].sell += (long long)(v*sum);
			}
		}
		bool b = false;
		REP(j, vs.size()){
			if (vs[j].sell >= 1000000){
				cout << vs[j].no << endl;
				b = true;
			}
		}
		if (!b)
			cout <<"NA" << endl;
	}
}

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

typedef pair<int,int> P;

int main(void)
{
	int N;
	while(cin >> N, N){
		P d[4001] = {};
		bool f = false;

		int a,b,c;
		for(int i = 0; i < N; i++){
			cin >> a >> b >> c;

			int j;
			for(j = 0; d[j].first != 0; j++){
				if(d[j].first == a){
					d[j].second += b*c;
					if(d[j].second >= 1000000)
						f = true;
				}
			}
			if(d[j].first == 0){
				d[j].first = a;
				d[j].second += b*c;
			}
		}

		if(!f)
			printf("NA\n");

		else
			for(int i = 0; d[i].first != 0; i++)
				if(d[i].second >= 1000000)
					printf("%d\n", d[i].first);
	}
		





	return 0;
}

C++: #include <iostream>
#include <set>
using namespace std;main(){int n,m;while(cin>>n&&n){set<long>T;m=1;while(n--){long U,p,s;cin>>U>>p>>s;if(T.find(U)==T.end()&&p*s>=1000000)m=0,cout<<U<<'\n',T.insert(U);}if(m)cout<<"NA\n";}}