Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

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

int main(){
	while(1){
		long n;
		map<int, long long> mp;
		
		scanf(" %ld", &n);
		if(n==0) break;
		
		for(long i=0; i<n; ++i){
			int num;
			long t, u;
			scanf(" %d %ld %ld", &num, &t, &u);
			
			if(mp.find(num)!=mp.end()) mp[num] += t*u;	
			else mp[num]=t*u;
				
		}		
		
		int count=0;
		for(map<int, long long>::iterator itr=mp.begin(); itr!=mp.end(); ++itr){
			if(itr->second>=1000000){
				printf("%d\n", itr->first);
				++count;
			}		
		}
		
		if(count==0) printf("NA\n");
	}	
}

C++: #include <stdio.h>
struct emp{
    int num;
    long long sale;
};
int main(){
    while(1){
        int n,num,count=0,c,flag1=0,flag2=0;
        long long p,q;
        struct emp e[4000];
        scanf("%d",&n);
        if(n==0) return 0;
        for(int i=0;i<n;i++){
            scanf("%d %lld %lld",&num,&p,&q);
            c=count;
            flag1=0;
            for(int j=0;j<count;j++){
                if(e[j].num==num) {
                    e[j].sale+=p*q;
                    flag1=1;
                    break;
                }
            }
            if(!flag1){
                e[count].num=num;
                e[count].sale=p*q;
                count++;
            }
        }
        for (int i=0; i<count; i++){
            if (e[i].sale>=1000000) {
                printf("%d\n",e[i].num);
                flag2=1;
            }
        }
        if(!flag2) printf("NA\n");
    }
}

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

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

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

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		map<int, unsigned long long int> Map;
		bool Flag = false;
		unsigned long long int a, b, c;
		for(int i = 0; i < N; ++i)
		{
			cin >> a >> b >> c;
			Map[a] += b * c;
		}
		for(map<int, unsigned long long int>::iterator Ite = Map.begin(); Ite != Map.end(); ++Ite)
		{
			if(Ite->second >= 1000000)
			{
				cout << Ite->first << endl;
				Flag = true;
			}
		}
		if(!Flag)
		{
			cout << "NA" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<iostream>
using namespace std;
int ans[4000];

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

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

using namespace std;

int main() {
	int num;
	int LINE = 1000000;

	while(cin>>num, num){
		map<int, long long> employees;
		map<int, long long>::iterator itr;
		bool flg = false;
		for(int i=0; i<num; i++){
			int id =0, q=0, p=0;
			cin>>id>>q>>p;
			employees[id] += (q*p);
		}
		for(itr = employees.begin(); itr != employees.end(); itr++){
			flg = true;
			if(itr->second >= LINE) cout<<itr->first<<endl;
		}
		if(!flg){
			cout<<"NA"<<endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	ll u[4010];
	bool flag;
	vector<int> v;
	while(1)
	{
		for(int i=0;i<4010;i++)
		{
			u[i]=0;
		}
		flag=true;
		int n;
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			int x;
			ll y,z;
			cin >> x >> y >> z;
			if(!(u[x]))
			{
				v.pb(x);
			}
			u[x]+=y*z;
		}
		for(int i=0;i<v.size();i++)
		{
			if(u[v[i]]>=1000000)
			{
				flag=false;
				cout << v[i] << endl;
			}
		}
		if(flag)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main()
{
	array<int, 4000> ar = {};
	vector<int> ans;
	int n,e,p,q;
	
	while (true) {
		cin >> n;
		ar.fill(0);
		if (!n) {
			break;
		}

		bool isNA = true;
		for (int i = 0; i < n; ++i) {
			cin >> e >> p >> q;
			ar[e] += p*q;
		}
		for (int i = 0; i < 4000;++i) {
			if (ar[i] >= 1000000) {
				ans.push_back(i);
				isNA = false;
			}
		}
		if (isNA) {
			ans.push_back(-1);
		}

	}

	for (auto it : ans) {
		if (it != -1) {
			cout << it << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>

int main(void)
{

	int n, a, b, No;

	while(scanf("%d", &n), n != 0){
		bool check = false;
		for(int i = 0; i < n; i++){
			scanf("%d %d %d", &No, &a, &b);
			if(a * b >= 1000000){
				printf("%d\n", No);
				check = true;
			}
		}
		if(!check)
			printf("NA\n");
	}


	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {

    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;

        bool na = true;
        set<ll> st;
        map<ll, ll> mp;

        rep(k, n) {
            ll i, p, q;
            cin >> i >> p >> q;
            st.insert(i);
            mp[i] += p*q;
        }

        auto itr = st.begin();
        for (int i = 0; i < st.size(); i++, itr++) {
            if (mp[*itr] >= 1000000) {
                cout << *itr << endl;
                na = false;
            }
        }

        if (na) cout << "NA" << endl;
    }

    return 0;
}