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<bits/stdc++.h>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

using namespace std;
#define EPS 1e-9
#define MAX 505
#define pb push_back
#define mp make_pair
#define ins insert
#define fi first
#define se second
#define pi acos(-1.0)
#define mod 100000007
#define inf 2147483647
#define ll long long int
#define sss stringstream
#define oss ostringstream
#define iss istringstream
#define llu long long unsigned

#define _sq(a) (a)*(a)
#define sz(a) ((int)a.size())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define _max3(a,b,c) max(a, max(b,c))
#define _min3(a,b,c) min(a, min(b,c))
#define FOR(i, n) for(i=0; i<(int)n; i++)
#define FOR1(i, n) for(i=1; i<=(int)n; i++)
#define mem(a) memset(a, 0, sizeof(a))
#define _set(a) memset(a,-1,sizeof(a))
#define FORI(i, a, b) for(i=a; i>=(int)b; i--)
#define FORab(i, a, b) for(i=a; i<=(int)b; i++)
#define popcount(n) __builtin_popcount(n)
#define popcountl(n) __builtin_popcountll(n)
#define sort_rev(a) sort(a.rbegin(), a.rend())
#define sort_all(a) sort(a.begin(), a.end())
#define dis_twopoints(x1,y1,x2,y2) sqrt(_sq(x1-x2) + _sq(y1-y2))
#define foreach(i,n) for(__typeof((n).begin())i =(n).begin();i!=(n).end();i++)

//If Long Long (mask & (1LL << k))
#define check(mask, k) (mask & (1 << k))
#define set1(mask, k) (mask | (1 << k))
#define set0(mask ,k) (mask & (~(1<<k)))

#define SD(a) scanf("%d",&a)
#define SLF(a) scanf("%lf",&a)
#define SC(a) scanf("%c",&a)
#define SS(a) scanf("%s",a)
#define SLLD(a) scanf("%lld", &a)
#define Si64(a) scanf("%I64d", &a)

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
struct wor
{
    int mon;
    int fla;
};
int main()
{
    wor id[100000];
    int ta,tan,i,s,p,doc[100],j;
    while(cin>>ta&&ta!=0)
    {
        int f=0;
        for(j=0; j<ta; j++)
        {
            cin>>i>>s>>p;
            doc[j]=i;
            if(id[i].fla==2)
            {
                id[i].mon=id[i].mon+(s*p);

            }
            else
            {
                id[i].mon=s*p;
                id[i].fla=2;
            }
        }
        for(j=0; j<ta; j++)
        {
            if(id[doc[j]].fla==3)
            {
                continue;
            }
            else
            {
                if(id[doc[j]].mon>=1000000)
                {
                    cout<<doc[j]<<endl;
                    id[doc[j]].fla=3;
                    f=1;
                }
            }
        }
        for(j=0;j<ta;j++)
        {
           id[doc[j]].fla=0;
        }
        if(f==0)
        {
            cout<<"NA"<<endl;
        }
    }

    return 0;
}

C++: using namespace std;
typedef long long ll;

ll em[4000];
int flag[4000];

int main(){
	int n;
	while(true){
		int id,p,q;
		cin >> n;
		if(!n) return 0;
		for(int i = 0; i < n; i++){
			cin>>id>>p>>q;
			em[id-1] += (ll)p * q;
			flag[i] = id;
		}
		int f = 1;
		for(int i = 0; i < n; i++){
			if(em[flag[i]-1] >= 1000000){
				cout << flag[i] << endl;
				f = 0;
			}
			em[flag[i]-1] = 0;
		}
		if(f) cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
	int n;

	while(cin >> n, n) {
		int ID, price, sale;
		long table[4096];
		bool flag = false;
		memset(table, 0, sizeof(table));
		for(int i = 0; i < n; i++) {
			cin >> ID >> price >> sale;
			table[ID] += price * sale;
		}

		for(int i = 0; i < 4096; i++) {
			if(table[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}

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

	return 0;
}

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

// 定数
const int GOAL_PRICE = 1000000;

int main(){
    // 変数
    int n;                              // 項目数
    int number;                         // 社員番号
    long long int price, quantity;      // 単価・数量
    std::map<int, long long int> result;     // 結果
    std::vector<int> contents;               // 入力内容

    while (true){
        std::cin >> n;

        if (n == 0) break;

        bool isExcess = false;
        result.clear();
        contents.clear();

        number = 0;
        price = 0;
        quantity = 0;

        for (int i = 0; i < n; i++){
            std::cin >> number >> price >> quantity;
            // 計算結果の追加
            if (!result[number]){
                contents.push_back(number);
                result[number] = 0;
            }
            result[number] += price * quantity;
        }

        for (int number : contents){
            if (result[number] >= GOAL_PRICE){
                std::cout << number << std::endl;
                isExcess = true;
            }
        }

        if (!isExcess){
            std::cout << "NA" << std::endl;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<vector>
using namespace std;
long long int sales[4010];
#define foreach(r,p,it) for(r::iterator it=p.begin();it!=p.end();++it)

int main()
{
    int n;
    while(cin>>n)
    {
        vector<int> shains;
        if(n==0)break;
    
        memset(sales,0,sizeof(sales));
        int num,tanka,kazu;

        for(int i=0;i<n;i++)
        {
            cin>>num>>tanka>>kazu;
            sales[num] += tanka*kazu;
            int f=0;
            foreach(vector<int>,shains,it)
            {
                if(*it == num){f=1;break;}
            }
            if(f==0) shains.push_back(num);
        }
        int na = 0;
        foreach(vector<int>,shains,it)
        {
            if(sales[*it] >= 1000000){cout<<*it<<endl;na=1;}
        }
        if(na==0)cout<< "NA"<<endl;
    }
    return 0;
}

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




int main(){
	int n;
	cin >> n;

	while(n != 0){
		vector < pair<long long, long long> > v(n);
		int num = 0;
		for (int i = 0; i < n; ++i){
			long long id, p, q;
			cin >> id >> p >> q;
			v[i] = make_pair(id, p * q);
		}

		sort(v.begin(), v.end());
		int c = 1;

		for (int i = 0; i < n - 1; ++i){
			if(v[i].first != v[i+1].first){
				c++;
			}
		}

		vector < pair<long long, long long> > sum(c);
		int k = 0;
		for (int i = 0; i < c; ++i){
			sum[i] = make_pair(0, 0);
		}

		long long s = 0;
		for (int i = 0; i < n ; ++i){
			s += v[i].second;
			if(i < n - 1){
				if(v[i].first != v[i+1].first){
					sum[k] = make_pair(v[i].first, s);
					s = 0;
					k++;
				}
			}else{
				sum[k] = make_pair(v[i].first, s);
			}
		}

		for (int i = 0; i < c; ++i){
			if(sum[i].second >= 1000000){
				cout << sum[i].first << endl;
				num++;
			}
		}

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

		cin >> n;
	}

	return 0;
}