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<cstdio>
#define long long int
using namespace std;

int A[1000000];

signed main()
{
    int N,B,C;
    while(cin >> N,N){
        int cnt[4001]={};
        bool NAflag=true,used[4001]={};
        for(int i=0;i<N;i++){
            cin>>A[i]>>B>>C;
            cnt[A[i]] += B*C;

        }
        for(int i=0;i<N;i++){
            if(cnt[A[i]]>=1000000 && used[A[i]]==false){
                printf("%d\n",A[i]); used[A[i]]=true; NAflag=false;
            }
        }
        if(NAflag==true){
            puts("NA");
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    long long int ids[4001];
    int id;
    long long price, amount;
    bool exist;
    bool used[4001];
    vector<int> rank;
    while(cin >> n && n)
    {
        exist=false;
        for(int i=1;i<4001;++i)
        {
            ids[i] = 0;
            used[i] = false;
        }
        rank.clear();
        for(int i=0;i<n;++i)
        {
            cin >> id >> price >> amount;
            if(!used[id])
            {
                rank.push_back(id);
                used[id] = true;
            }
            ids[id] += price * amount;
        }
        for(int i=0;i<rank.size();++i)
        {
            if(ids[rank[i]] >= 1000000)
            {
                exist = true;
                cout << rank[i] << endl;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	int n;
	while (cin >> n&&n) {
		long long member[4001] = {};
		bool flag[4001] = {};
		for (int i = 1; i <= 4000; i++) {
			member[i] = 0;
			flag[i] = false;
		}
		long long a, b, c;
		int count = 0;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			member[a] += b*c;
			if (member[a] >= 1000000&&!flag[a]) {
				count++;
				flag[a] = true;
				cout << a << endl;
			}
		}
		if (count == 0)cout << "NA" << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
    int n;
    while(cin>>n, n!=0) {
        int memo[4000] = {0};
        bool F[4000] = {false};
        bool f = true;
        for(int i=0; i<n; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            memo[a] += (b*c);
            if(memo[a]>=1000000 && !F[a]) {
                f = false;
                F[a] = true;
                cout << a << endl;
            }
        }
        if(f) cout << "NA" << endl;
    }
    return 0;
}

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

int main(){

  int n,i,j,cnt=0,tanka,kazu,sum[4002]={0};
  char syain[4000][5],*syokika="GO";

  while(1){

    scanf("%d",&n);
    if(n==0){
      break;
    }

    for(i=0;i<n;i++){
      scanf("%s",syain[i]);
      scanf("%d",&tanka);
      scanf("%d",&kazu);
      sum[i]=tanka*kazu;
    
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(strcmp(syain[i],syain[j])==0 && i!=j){
	  sum[i]=sum[i]+sum[j];
	  sum[j]=0;
	  strcpy(syain[j],syokika);
	}
      }
    }

    for(i=0;i<n;i++){
      if(sum[i]>=1000000){
	cnt=1;
	printf("%s\n",syain[i]);
      }
    }
    if(cnt==0){
      printf("NA\n");
    }

    cnt=0;

  }

  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <stdlib.h>
#include <map>
using namespace std;
ifstream fin("D:\\txt.txt");
#define for0(i,n) for (i=0;i<n;i++)

typedef struct employees
{
	int ID;
	int Sales;
}employees;
map<int,int> data;
#define MV(a,b) map<int,int>::value_type(a,b) 
// int main()
// {
// 	data[0]=123;
// 	data[1]=456;
// 	data[1]=789;
// 	int a=data.size();
// 	a=data[1];
// 	map<int,int>::iterator it=data.begin();
// 	a=it->first;
// 	a=it->second;
// 	it++;
// 	a=it->first;
// 	a=it->second;
// }
int main()
{
	int n,a,b,c,i,j;
	while(fin>>n)
	{
		if(!n)break;
		for0(i,n)
		{
			fin>>a>>b>>c;
			c*=b;
			if (data.find(a)==data.end())
			{
				data.insert(MV(a,c));
			}
			else
			{
				data[a]+=c;
			}
		}
	}
	map<int,int>::iterator it=data.begin();

	while(it!=data.end())
	{
		if (1000000<=it->second)
		{
			cout<<it->first<<endl;
		}
		else
		{
			cout<<"NA"<<endl;
		}
		it++;
	}
	return 0;
}//*/

C++: /*****include*****/
#include <iostream>
#include <fstream>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return 0;
	}
#endif
	/*****変数置き場*****/
	int n;
	int num[4000];
	bool appear[4001];
	int howmany;
	int number;
	long int in_price;
	long int in_sales;
	long int price[4000];
	long int sales[4000];
	/*****処理部*****/
	while(1){
		memset(appear,false,sizeof(appear));
		memset(price,0,sizeof(price));
		memset(sales,0,sizeof(sales));
		memset(num,0,sizeof(num));
		howmany = 0;
		cin >> n;
		if(n==0)	break;
		for(int i=0;i<n;i++){
			cin >> number;
			cin >> in_price;
			cin >> in_sales;
			price[number] += in_price;
			sales[number] += in_sales;
			if(!appear[number])	num[i] = number;
			appear[number] = true;
		}
		for(int i=0;i<n;i++){
			if(num[i] != 0){
				if(price[num[i]] * sales[num[i]] >= 1000000){
					cout << num[i] << endl;
					howmany++;
				}
				//cout << i << " " << price[num[i]] << " " << sales[num[i]] << endl;
			}
		}
		if(howmany == 0)	cout << "NA" << endl;
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

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

int main(){
	while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        long long a[5000] = {0};
        long long int number;
        long long int jun[5000] = {0};
        long long tanka,kazu;
        for(int i = 1; i <= n; i++){
            cin >> number >> tanka >> kazu;
            a[number] += tanka * kazu;
            jun[i] = number;
        }
        for(int i = 0; i < 4000; i++){
            for(int j = i+1; j <= 4000; j++){
                if(jun[i] == jun[j]) jun[j] = 0;
            }
        }
        
        bool flg = 0;
        for(int i = 1; i 4000; i++){
            if(a[jun[i]] >= 1000000){
                cout << jun[i] << endl;
                flg = 1;
            }
        }


        if(!flg) cout << "NA" << endl;
	}
	return 0;
}