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<iostream>
#include<map>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    map <int,int> com;
    bool f = false;
    while(n--){
      int a,b,c;
      cin >>a>>b>>c;
      if(com[a]+b*c>1000000){com[a] = 1000000;}
      else{com[a]+=b*c;}
    }
    map<int,int>::iterator m;
    for(m=com.begin();m!=com.end();m++){
      if((m->second)>=1000000){cout <<m->first<<endl;f = true;}
    }
    if(!f){cout <<"NA"<<endl;}
  }
  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int aa[10000]={0},x=0,y=0,z=0,flg=0,a;
    while(cin>>a)
    {
        if(a==0)break;
        for(int i=0;i<a;i++)
        {
            cin>>x>>y>>z;
            aa[x]+=y*z;
        }
        for(int i=0;i<4010;i++)
        {
            if(aa[i]>=1000000)
            {
                flg=1;
                cout<<i<<endl;
            }
        }
        if(flg==0)cout<<"NA"<<endl;
        for(int i=0;i<4010;i++)
        {
            aa[i]=0;
            flg=0;
        }
    }
    return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		set<int> Set;
		vector<int> num;
		map<int, unsigned long long int> Map;
		while(n--)
		{
			unsigned long long int a, b, c;
			cin >> a >> b >> c;
			if(Set.find(a) == Set.end())
			{
				num.push_back(a);
			}
			Set.insert(a);
			Map[a] += b * c;
		}
		bool exist_flag = false;
		for(int i = 0; i < num.size(); ++i)
		{
			if(Map[num[i]] >= 1000000)
			{
				cout << num[i] << endl;
				exist_flag = true;
			}
		}
		if(!exist_flag)
		{
			cout << "NA" << endl;
		}
	}
}

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

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
	stringstream ss;
	ss << t;
	ss >> u;
}

int main(){
	int n;
	while(cin >> n && n!=0){
		map<int, ll> ans;
		int id, price, num;
		for(int i = 0; i < n; i++){
			cin >> id >> price >> num;
			ans[id] += price*num;
		}

		vector<int> ans_id;
		for(map<int, ll>::iterator it = ans.begin(); it != ans.end(); it++){
			if(it->second>=1000000) ans_id.push_back(it->first);
		}
		if(ans_id.size()==0){
			cout << "NA" << endl;
		}else{
			for(int i = 0; i < ans_id.size(); i++){
				cout << ans_id[i] << endl;
			}
		}
	}
	return 0;
}

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

typedef long long Int;

int main(){
    map<int,Int> table;
    vector<int> ids;
    int n;
    bool flug;

    while(cin >> n, n != 0){
        flug = false;
        table.clear();

        for(int i=1; i<=n; i++){
            int id;
            Int tanka;
            Int number;
            cin >> id >> tanka >> number;
            table[id] += (tanka*number);
            vector<int>::iterator fIter = find(ids.begin(), ids.end(), id);
            if(fIter == ids.end()){
                ids.push_back(id);
            }
        }

        for(vector<int>::iterator Iter = ids.begin(); Iter != ids.end(); Iter++){
            if(table[*Iter] >= 1000000){
                cout << *Iter << endl;
                flug = true;
            }
        }

        if(flug == false){
            cout << "NA" << endl;
        }
    }

    return 0;
}

C++: // a.c.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
#include <map>
using namespace std;
map<int, long long> bango;
// long long int bango[4001];
int main(void){
	int n;
	long long ban, tan, suu;
	int flg,i;
	while (1){
		for (i = 1; i <= 4000; i++){
			bango[i] = 0;
		}
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &ban, &tan, &suu);
			bango[ban] += tan*suu;
		}
		flg = 0;
		for (i = 1; i <= 4000; i++){
			if (bango[i]>=1000000){
				printf("%d\n", i);
				flg = 1;
			}
		}
		if (!flg){
			printf("NA\n");
		}
	}
	return 0;
}

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

int main(){
	int n;
	while (cin >> n)
	{	bool f = false;
		int e[4000], p[4000], q[4000], t[4000];
		for (int i = 0; i < n; i++)
		{
			cin >> e[i];
			cin >> p[i];
			cin >> q[i];
			t[i] = p[i] * q[i];
		}

		for (int a = 0; a < n; a++)
		{
			if (t[a] >= 1000000)
			{
				cout << e[a] << endl;
				f = true;
			}
		
		
		}
		if (!f)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

bool p[4001];

int main(){
	int i , n , id , price , num , cnt=0;;
	while(cin>>n){
		if (n==0) break;
		for(i=0 ; i<4001 ; i++){
			p[i]=false;
		}
		for(i=0 ; i<n ; i++){
			cin >> id >> price >> num;
			if (price*num>=1000000) {
				p[id]=true;
				cnt++;
			}
		}
		for(i=0 ; i<4001 ; i++){
			if(p[i]==true){
				cout << i << endl;
			}
			if (cnt==0) {
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
using namespace std;
main(){
  //mlÛ¶vÛ¶
  long long a,b,c,n,f;
  //aÔbP¿cÊ
  while(cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
			cin>>a>>b>>c;
      if(!m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++)
			if(m[v[i]]>999999)f=0,cout<<v[i]<<endl;
    if(f)cout<<"NA"<<endl;
  }
}