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>
using namespace std;

class meb{
public:
	int num;
	int tanka;
	int count;
	int sum;
};

int main(){
	int n,m,t,c;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int k=0;k<n;k++){
			st[k].sum=st[k].tanka*st[k].count;
		}
		for(int j=0;j<n;j++){
			for(int l=j+1;l<n;l++){
				if(st[j].num==st[l].num){
					(st[j].sum)=(st[j].sum)+(st[l].sum);
					st[l].sum=0;
				}
			}
		}
		for(int a=0;a<n;a++){
			if(st[a].sum>=1000000)cout<<st[a].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}

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

typedef pair<int,int> P; //社員番号、売上

int main(void)
{
	int n;

	while(cin >> n,n){
		vector<P> d;
	
		int no,m,k;
		bool f = false;

		for(int i = 0; i < n; i++){
			cin >> no >> m >> k;
			
			int j;
			for(j = 0; j < d.size(); j++){
				if(d[j].first == no){
					d[j].second += m*k;
				}
			}

			if(j == d.size()){
				d.push_back(P(no,m*k));
			}
		}
		int j;
		for(j = 0; j < d.size(); j++)
			if(d[j].second >= 1000000){
				f = true;
				break;
			}
		if(!f)
			cout << "NA\n";

		else{
			for(j = 0; j < d.size(); j++)
				if(d[j].second >= 1000000){
					cout << d[j].first << endl;
				}
		}
	}

	

	return 0;
}

C++: #include<stdio.h>

int main()
{
	int i,ryou,bangou[4000],nedan[4000],kazu[4000],check;
	while(1)
	{
		check=0;
		scanf("%d",&ryou);
		if(ryou==0)
			break;
		for(i=0;i<ryou;i++)
		{
			scanf("%d%d%d",&bangou[i],&nedan[i],&kazu[i]);
			
				if(nedan[i]*kazu[i]>=1000000)
					check=1;
				else
					bangou[i]=0;
			
		}
		if(check=1)
		{
			for(i=0;i<ryou;i++)
			{
				if(bangou[i]!=0)
					printf("%d\n",bangou[i]);
			}
		}
		if(check==0)
				printf("NA\n");
	}
}

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

int main(){
	
	int n , id , price , num, cnt;
	while(cin >> n , n!=0){
		vector<int> p(4001,0);
		vector<int> a;
		
		while(n--){
			cin>>id>>price>>num;
			if(find(a.begin(),a.end(),id)==a.end()) a.push_back(id);
			p[id]+=price*num;
			}
		cnt=0;	
		for(int i=0;i<a.size();i++){
			if(p[a[i]]>=1000000){
				cout << a[i] << endl; 
				cnt++;
			} 
		}
		if (cnt==0) cout << "NA" << endl;
	}
		return 0;
}

C++: #include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
  bool f;
  vector<pair<int, int>> v;
  int n, a, b, c;
  while (cin >> n && n > 0) {
    v.clear();
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      f = 0;
      for (int j = 0; j < v.size(); j++) {
        if (v[j].first == a) {
          v[j].second += b * c;
          f = 1;
        }
      }
      if (!f) {
        v.push_back(pair<int, int>(a, b * c));
      }
    }
    f = 0;
    for (int i = 0; i < v.size(); i++) {
      if (v[i].second >= 1000000) {
        cout << v[i].first << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
	long long N, X, Y, Z;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		vector<long long> P(4001, 0);

		for (int i = 0; i < N; i++)
		{
			cin >> X >> Y >> Z;

			P[X] += Y * Z;
		}

		int count_ = 0;

		for (int i = 1; i <= 4000; i++)
		{
			if (P[i] >= 1000000)
			{
				cout << i << endl; count_++;
			}
		}

		if (!count_)
		{
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,num,flag=0,flag2=0;
  long long tanka,sell;
  while(cin>>n,n!=0){
    flag=0;flag2=0;
    vector<int> nu;
    vector<int> vi;
    vector<pair<int,long long> > pii;
    for(int i=0;i<n;i++){
      cin>>num>>tanka>>sell;
      for(int j=0;j<vi.size();j++){
	if(num==vi[j]){
	  flag2=1;
	  break;
	}
      }
      if(flag2==0){
	flag=0;
	for(int j=pii.size()-1;j>=0;j--){
	  if(pii[j].first==num){
	    flag=1;
	    pii.push_back(make_pair(num,((tanka*sell)+pii[j].second)));
	    if(((tanka*sell)+pii[j].second)>=1000000)
	      vi.push_back(num);
	    break;
	  }
	}
	if(flag==0){
	  nu.push_back(num);
	  pii.push_back(make_pair(num,tanka*sell));
	  if((tanka*sell)>=1000000)
	    vi.push_back(num);
	}
      }
    }
    if(vi.empty())
      cout<<"NA"<<endl;
    else{
      for(int k=0;k<nu.size();k++){
	for(int l=0;l<vi.size();l++){
	  if(nu[k]==vi[l])
	    cout<<nu[k]<<endl;
	}
      }
    }
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
    int i,l,k;
    int n;
    long long id,c,q;
    long long data_list[4001]={0};
    int id_list[4000];
    bool id_flag;
    bool na_flag;
    
    while(cin>>n,n!=0){
        k=0;
        fill(data_list,data_list+4001,0);
        for(l=0;l<n;l++){
            data_list[id]+=(c*q);
            cin>>id>>c>>q;
            id_flag=true;
            for(i=0;i<k+1;i++){
                if(id_list[i]==id){
                    id_flag=false;
                }
            }
            if(id_flag){
                id_list[k]=id;
                k++;
            }
        }
        na_flag=true;
        for(l=0;l<k;l++){
            if(data_list[id_list[l]]>=1000000){
                cout<<id_list[l]<<endl;
                na_flag=false;
            }
        }
        if(na_flag){
            cout<<"NA"<<endl;
        }
    }
    return(0);
}

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

typedef pair<long long, long long> pairLL;
typedef vector<pairLL> resArr;

//#include <fstream>

int main(void)
{
	//ifstream fin("in.txt");
	istream& in=cin;
	resArr result;

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

		result.clear();

		for(int i=0; i<n; i++)
		{
			long long id, p, q;
			in >> id >> p >> q;

			resArr::iterator it;
			for(it=result.begin(); it!=result.end(); it++)
				if(it->first == id)
					break;
			
			if(it == result.end())
				result.push_back( pairLL(id, p*q) );
			else
				it->second += p*q;
		}

		bool exist=false;
		resArr::iterator it=result.begin();
		for(it; it!=result.end(); it++)
		{
			if((*it).second >= 1000000)
			{
				cout << (*it).first << endl;
				exist=true;
			}
		}
		if(!exist)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
int main()
{
    int n;
    while(1)
    {
        cin>>n;if(!n)return 0;
        int count=0;
        map<int,long long> sl;
        sl.clear();
        for(int i=0;i<n;++i){
            int sn;
            long long t,v;
            cin>>sn>>t>>v;
            map<int,long long>::iterator it=sl.find(sn);
            if(it==sl.end())sl.insert(make_pair(sn,t*v));
            else it->second=t*v;
        }
        map<int,long long>::iterator it=sl.begin();
        while(it!=sl.end())
        {
            if(it->second>=1000000){cout<<it->first<<endl;++count;}
            ++it;
        }
        if(!count)cout<<"NA"<<endl;
    }
}