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 <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

static const int invalid_order = 1000000;
struct data {
	string ID;
	long long total;
	int order;

	data() {
		ID = -1;
		total = 0;
		order = invalid_order;
	}

	bool operator<(const data d) const {
		return order < d.order;
	}
};

int main() {
	int n;

	while(cin >> n, n) {
		int price, sale;
		string ID;
		data table[4096];
		bool flag = false;
		int order_count = 0;

		/*
		for(int i = 0; i < 4096; i++) {
			table[i].ID = i;
		}
		*/

		for(int i = 0; i < n; i++) {
			char in[128];
			char ID_s[32], price_s[32], sale_s[32];
			int j, k;

			// input
			/*
			fgets(in, 120, stdin);
			for(j = 0,k = 0; in[j + k] != ' ' && in[j + k] != ';'; k++)
				ID_s[k] = in[j + k];
			ID_s[k] = '\0';
			j = k + 1;
			for(k = 0; in[j + k] != ' ' && in[j + k] != ';'; k++)
				price_s[k] = in[j + k];
			price_s[k] = '\0';
			j += k + 1;
			for(k = 0; in[j + k] != ' ' && in[j + k] != ';' && in[j + k] && in[j + k] != '\n'; k++)
				sale_s[k] = in[j + k];
			sale_s[k] = '\0';

			ID = atoi(ID_s);
			price = atoi(price_s);
			sale = atoi(sale_s);
			// */ cin >> ID >> price >> sale;
			
			if(table[atoi(ID.c_str())].order == invalid_order) {
				table[atoi(ID.c_str())].ID = ID;
				table[atoi(ID.c_str())].order = order_count;
				order_count++;
			}
			table[atoi(ID.c_str())].total += price * sale;
		}

		sort(table, table + 4096);

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

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

	return 0;
}

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

int main() {
    int i, N;
    long long p, q;
    map<int, long long> sales;
    
    while (cin >> N && N != 0) {
        cin.get();
        
        for (int n = 0; n != N; ++n) {
            cin >> i >> p >> q;
            sales[i] += p * q;
        }

        bool printNA = true;
        
        for (map<int, long long>::iterator it=sales.begin(); it!=sales.end(); ++it) {
            if (it->second >= 1000000) {
                cout << it->first << endl;
                printNA = false;
            }
        }

        if (printNA) {
            cout << "NA" << endl;
        }

        sales.clear();
    }
    return 0;
}

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;
}