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>
using namespace std;
int main(){
    int n,a,b,c;
    while(cin>>n,n){
        map<int,long long>M;
        while(n--){
            cin>>a>>b>>c;
            M[a]+=b*c;

        }

        bool flag=true;
        for(map<int,long long>::iterator ite=M.begin();ite!=M.end();ite++){
            if(ite->second>=1000000){
                cout<<ite->first<<endl;
                flag=false;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}

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

int main(){
//old
		/* 2014 ??????1
		int a[2],ans;
		cin >> a[0] >> a[1];
		ans = a[0] * a[1];
		cout << ans << endl;
		*/
		/* 2014 ??????2
		int a[6],ans = 0;
		cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
		if(a[0] + a[1] * 5 + a[2] * 10 + a[3] * 50 + a[4] * 100 + a[5] * 500 >= 1000) ans = 1;
		cout << ans << endl;
		*/
		/* 2014 ??????3
		int a,i = 0;
		cin >> a;
		int b[a],c[a],ans[a];
		while(a > i){
			cin >> b[i] >> c[i];
			ans[i] =  b[i] % c[i];
			if(ans[i] == 0) ans[i] = c[i];
			i++;
		}
		i = 0;
		while(a > i){
		cout << ans[i] << endl;
		i++;
		}
		*/
		/* 2014 ??????4
		int a[2],i = 1;
		cin >> a[0];
		int n[a[0]],m[a[0]];
		while (a[0] >= i){
			cin >> n[i] >> m[i];
			i++;
		}
		i = 1;
		cin >> a[1];
		int o[a[1]],p[a[1]];
		while (a[1] >= i){
			cin >> o[i] >> p[i];
			i++;
		}
		i = 1;
		int ii,c,aa;
		aa = a[0] + a[1];
		int ans[aa][2],hh[aa],mm[aa],chk,count = 1;
		while(aa >= i){
			ii = 1;
			chk = 1;
			if(a[0] >= i){
				while(i - 1 >= ii){
					if(n[i] == hh[ii] and m[i] == mm[ii]){
						chk = 0;
					}
					ii++;
				}
				if(chk == 1){ 
					hh[count] = n[i];
					mm[count] = m[i];
					count++;
				}
			}else{
				while(i - 1 >= ii){
					if(o[i - a[0]] == hh[ii] and p[i - a[0]] == mm[ii]){
						chk = 0;
					}
					ii++;
				}
				if(chk == 1){ 
					hh[count] = o[i - a[0]];
					mm[count] = p[i - a[0]];
					count++;
				}		

			}
			i++;
		}
		aa = count - 1;
		i = 1;
		while(aa >= i){
			ii = 1;
			c = 1;
				while(aa >= ii){
						if(hh[i] > hh[ii] or hh[i] == hh[ii] and mm[i] > mm[ii] and i != ii){
							c++;
						}
				ii++;
				}
			ans[c][0] = hh[i];
			ans[c][1] = mm[i];
		 i++;
		}
		i = 1;
		while(aa >= i){
			if(aa == i){
				if(ans[i][1] < 10){
					cout << ans[i][0] << ":" << "0" << ans[i][1] << endl;;
				}else{
					cout << ans[i][0] << ":" << ans[i][1] << endl;;
				}

			}else{
				if(ans[i][1] < 10){
					cout << ans[i][0] << ":" << "0" << ans[i][1] << " ";
				}else{
					cout << ans[i][0] << ":" << ans[i][1] << " ";
				}
			}
			i++;
		}
		*/	
//old		
int in;
cin >> in;
int p[in][in * 3],i,ii,c = 0,uri[in],k;	
	for(i = 1;in >= i;i++){ cin >> p[i][0] >> p[i][1] >> p[i][2];uri[i] = 0;}	
	for(i = 1;in >= i;i++){
		for(ii = 1;in >= ii;ii++){if(p[i][0] == p[ii][0]){ uri[ii] = uri[ii] + p[i][1] * p[i][2];}}
	}
	for(i = 1;in >= i;i++){
		k = 0;
		for(ii = 1;i > ii;ii++){if(p[i][0] == p[ii][0]){ k = 1;} }		
			if(uri[i] >= 1000000 and k == 0){cout << p[i][0] << endl; c++;} 
	}
	if(c == 0 and in != 0) cout << "NA" << endl;

}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
	int n;
	while(scanf("%d\n", &n), n){
		vector<pair<ll, ll> > v;
		rep(i,n) {
			ll x, y, z;
			cin >> x >> y >> z;
			bool f = false;
			for(int j = 0; j < v.size(); ++j) {
				if(v[j].first == x) {
					v[j].second += y * z;
					f = true;
					break;
				}
			}
			if(!f) {
				v.push_back(make_pair(x, y * z));
			}
		}
		bool flag = false;
		for(int j = 0; j < v.size(); ++j) {
			if(v[j].second >= 1000000) {
				flag = true;
				cout << v[j].first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <set>
#include <algorithm>
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";}}

C++: #include <iostream>

using namespace std;

int main(){
	int n;
	int x[4001] = {0};
	int m[4001] = {0};
	
	while(1){
		int e, p, q, count = 0;
		cin >> n;
		if(n == 0) break;
		
		for(int i = 1; i <= n; i++){
			cin >> e >> p >> q;
			x[e] += p * q;
			if(x[e] >= 1000000){
				if(m[e] == 0){
					cout << e << endl;
					count++;
					m[e]++;
				}
			}
		}
		if(count < 0) cout << "NA" << endl;
	}
	
	return 0;
}

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

int N, M;

int main() {
	int goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		long long int v[4000];
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			int e, p, q;
			cin >> e >> p >> q;
			v[e - 1] += p*q;
		}
		bool flag = false;
		for (int i = 0; i < 4000; i++) {
			if (v[i] >= goal) {
				flag = true;
				cout << i + 1 << endl;

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

	return 0;
}

C++: #include <iostream>
using namespace std;
typedef long long ll;
//vector<pair<bool, ll>> v(4001);
unsigned long long int 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 < 4001;i++)a[i] = 0;
		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;
		/*int f = 1;
		for(int i = 1;i <= 4000;i++)if(a[i] >= 1000000)cout << i << endl, f = 0;
		if(f)cout << "NA" << endl;*/
	}
	return 0;
}

/*
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
*/

C++: #include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int i=0;
        int na=0;
        cin>>i;
        if(i==0)
            break;
        else
        {
            int h[4001];
            for(int k=0;k<=4000;k++)
            {
                h[k]=0;
            }
            for(int k=1;k<=i;k++)
            {
                int j=0;int l=0;int m=0;
                cin>>j>>l>>m;
                h[j]+=l*m;

            }
            for(int k=1;k<=4000;k++)
            {
                if(h[k]>=1000000)
                {
                    cout<<k<<endl;
                    na=1;
                }

            }
            if(na==0)
            {
                cout<<"NA"<<endl;
            }

        }
    }

    return 0;
}