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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;


int n;
int index, a, b;
ll sum[5000];

int main(){
	while (cin >> n&&n){
		vector<ll> vi;
		fill(sum, sum + 5000, 0);
		REP(i, n){
			cin >> index >> a >> b;
			if (find(ALL(vi), index) == vi.end()){
				vi.push_back(index);
			}
			if (sum[index] > 1000000)continue;
			sum[index] += a*b;
		}
		bool f = 1;
		REP(i, vi.size()){
			if (sum[vi[i]] >= 1000000){
				cout << vi[i] << endl;
				f = 0;
			}
		}
		if (f)cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n;

int main(){
	while(scanf("%d", &n)){
		if(n == 0) break;
		map<ll,ll> m;
		map<ll,ll>::iterator it;
		rep(i,n){
			ll x,p,q; scanf("%lld%lld%lld", &x, &p, &q);
			if(m.find(x) == m.end()) m[x] = p*q;
			else m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			if(it->second >= 1000000){
				ok = false;
				cout << it->first << endl;
			}
		}
		if(ok) cout << "NA" << endl;
	}
}

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

using namespace std;

int n;
long long id[4000];
 long long value[4000];
 long long number[4000];
map<long long,  long long> total;

int main() {
  while(true){
    cin >> n;
    if(n==0){
        return 0;
    }
    vector<long long> v;
    for (int i = 0; i < n; i++) {
        cin >> id[i] >> value[i] >> number[i];
        if(total.find(id[i])==total.end()){
          total.insert(make_pair(id[i], 0));
        }
        total[id[i]] += value[i] * number[i];
        // if (total[id[i]] > 1000000 && find(v.begin(), v.end(), id[i]) == v.end()) {
        //   v.push_back(id[i]);
        // }
    }
    if(!total.empty()) {
        map< long long,  long long>::iterator it = total.begin();
        while (it != total.end()) {
            if ((*it).second >= 1000000) {
                v.push_back((*it).first);
            }
            ++it;
        }
    }
    if (v.empty()) {
        cout << "NA" << endl;
    }
    // for (vector<long long>::iterator it = v.begin(); it != v.end(); ++it) {
    //     cout << *it << endl;
    // }
    vector<long long> used;
    for(int i=0; i<n;i++){
      if(std::find(v.begin(), v.end(), id[i]) != v.end() && std::find(used.begin(), used.end(), id[i]) == used.end()){
        cout << id[i] << endl;
        used.push_back(id[i]);
      }
    }
    v.clear();
    total.clear();
  }
}

C++: #include<map>
#include<iostream>
using namespace std;
int main()
{
    map<int,int> total;

	int d,num,item,ko,cont=0;
	bool ok;

	while(cin>>d, d)
	{
		for(int i=0;i<d;i++)
		{
			cin>>num>>item>>ko;
			item *= ko;
			if(total.count(num))
			{
				continue;
			}
			else
			{
				total.insert(make_pair(num, item));
			}
		}

		ok = false;
		map<int,int>::iterator it;
		for(it = total.begin(); it != total.end(); it++)
		{
			if((*it).second >= 1000000)
			{
				cout << (*it).first <<endl;
				ok = true;
			}
		}

		if(ok == false)
		{
			cout<<"NA"<<endl;
		}
		
		total.clear();
	}
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using ull = unsigned long long;
const unsigned bound = 1000000;
 

void solve(unsigned n);

int main()
{
	using namespace std;
	unsigned n = 0;
	cin >> n;

	while (n != 0)
	{
		solve(n);
		cin >> n;
	}

}

void solve(unsigned n)
{
	using namespace std;
	map<int, ull> records;

	for (int i = 0; i < n; i++)
	{
		int id = 0;
		unsigned price = 0, amount = 0;
		cin >> id >> price >> amount;

		records[id] += ull(price) * ull(amount);
	}

	vector<int> idList;
	for (auto man : records)
	{
		if (man.second >= bound)
			idList.push_back(man.first);
	}

	if (!idList.empty())
	{
		for (int id : idList)
			cout << id << endl;
	}
	else
	{
		cout << "NA" << endl;
	}
}

C++: #include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 

using namespace std;

int main()
{
	int n,f,b;
	long long c,d;

	while(1){
		f=1;int k=0;
		long long a[4000][2]={0};
		cin>>n; if(n==0) return 0;

		for(int i=0;i<n;i++){
			cin>>b>>c>>d;
			for(int j=0;j<k;j++){
				if(a[j][0]==b && a[j][1]>0){ a[j][1]+=c*d; f=0;}
			}
			if(f){
				a[k][0]=b; a[k++][1]=c*d;
			}
		}

		f=0;
		for(int i=0;i<k;i++){
			if(a[i][1]>=1000000) {cout<<a[i][0]<<endl; f=1;}
		}
		if(f) cout<<"NA"<<endl;
	}
}

C++: struct employee
{
		int N;
		long long int P,A,M;
};
int main(void)
{	
	struct employee person[4000];
	int a,b,c,d;
	for(b=0;;b=0)
	{
		scanf("%d",&c);
		for(a=0;a<c;a++)
		{
			scanf("%d %lld %lld",&person[a].N,&person[a].P,&person[a].A);
			person[a].M=person[a].P*person[a].A;
			for(d=0;d<a;d++)
				if(person[a].N==person[d].N)
				{
					person[a].M+=person[d].M;
					person[d].M=0;
				}
		}
		for(a=0;a<c;a++)
			if(person[a].M>=1000000 )
			{
				printf("%d\n",person[a].N);
				b++;
			}
		if(b==0)
			printf("NA\n");
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		long long no;
		long long price;
		long long deal;

		bool f = true;
		for ( int i = 0; i < n; i++ )
		{
			cin >> no >> price >> deal;
			if ( price * deal >= 1000000 )
			{
				cout << no << endl;
				f = false;
			}
		}

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

	}

	return 0;
}