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 <vector>
#include <cstdio>

#define TOTAL_SALES_TH (1000000)

struct SALES_INFO {
  int employeeID;
  int totalSales;
};

void updataSalesInfos(std::vector<SALES_INFO>& salesInfos, 
                      int ID,
                      int unitPrice,
                      int amount)
{
  for (std::vector<SALES_INFO>::iterator it = salesInfos.begin();
    it != salesInfos.end();
    ++it) {
    if (it->employeeID == ID) {
      it->totalSales += unitPrice * amount;
      return;
    }
  }
  SALES_INFO newInfo;
  newInfo.employeeID = ID;
  newInfo.totalSales = unitPrice * amount;
  salesInfos.push_back(newInfo);
}

int main(void)
{
  while (true) {
    int numOfInput;
    std::cin >> numOfInput;

    if (numOfInput == 0) {
      break;
    }

    int ID, unitPrice, amount;
    char deli;

    std::vector<SALES_INFO> salesInfos;

    for (int i = 0; i < numOfInput; i++) {
      scanf_s("%d %d %d", &ID, &unitPrice, &amount);
      updataSalesInfos(salesInfos, ID, unitPrice, amount);
    }

    std::vector<int> achieveList;

    for (std::vector<SALES_INFO>::iterator it = salesInfos.begin();
      it != salesInfos.end();
      ++it) {
      if (it->totalSales >= TOTAL_SALES_TH) {
        achieveList.push_back(it->employeeID);
      }
    }

    if (achieveList.size() == 0) {
      std::cout << "NA" << std::endl;
    }
    else {
      for (std::vector<int>::iterator it = achieveList.begin();
        it != achieveList.end();
        ++it) {
        std::cout << *it << std::endl;
      }
    }
  }

  return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
using namespace std;
int main(){
	for(;;){
		int n;
		cin >> n;
		if(n == 0) break;
		map<string, int> mpa;
		for(int i = 0; i < n; i++){
			string e;
			int p, q;
			cin >> e;
			cin >> p >> q;
			mpa[e] += p * q;
		}
		map<string, int>::iterator itr;
		bool flag = false;
		for(itr = mpa.begin(); itr != mpa.end(); itr++){
			if(itr->second >= 1e6){
				cout << itr->first << endl;
				flag = true;
			}
		}
		if(flag == false) cout << "NA" << endl;
	}
	return 0;
}

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

typedef long int lint;
typedef long long int llint;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl "\n"

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  
  while (cin >> n, n){
    int p, q;
    llint e[1010] = {0}, res[4010] = {0};
    bool judge = false;
    REP(i, n){
      cin >> e[i] >> p >> q;
      res[e[i]] += p * q;
    }
    sort(e, e + n);
    REP(i, n){
      if (res[e[i]] >= 1000000 && e[i] != e[i + 1]){
        cout << e[i] << endl;
        judge = true;
      }
    }
    if (!judge) cout << "NA" << endl;
  }
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

#define MAX 5000

int main(){
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<ll> num(4000,0),pre(n,0),data(4000,0);
        for (int i=0; i<n; i++) {
            int a,b,c;
            cin >>a >>b >>c;
            data[a]+=b*c;
            if(num[a]==0) num[a]=i+1;
        }
        for (int k=0;k< 4000; k++) {
            if(num[k]!=0) pre[num[k]]=k;
        }
        int ch=0;
        for (int j=0; j<n; j++) {
            if (data[pre[j]]>=1000000) {
                cout <<pre[j]<<endl;
                ch++;
            }
        }
        if(ch==0) cout << "NA"<<endl;
    }
}

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

struct staff {
	int num;
	int price;
	int quan;
	int total;
};

int main()
{
	int num, i, k, j, datas;
	int sn, sp, sq;
	map<int, staff> staffs[4000];

	datas = 0;
	while(1)
	{
		cin >> num; if(num == 0) break;

		for(i = 0; i < num; i++)
		{
			cin >> sn >> sp >> sq;
			staffs[datas][sn].num = sn;
			staffs[datas][sn].price = sp;
			staffs[datas][sn].quan = sq;
			staffs[datas][sn].total += staffs[datas][sn].price * staffs[datas][sn].quan;
		}
		datas++;
	}
	map<int, staff>::iterator staffs_it;
	for(i = 0; i < datas; i++)
	{
		staffs_it = staffs[i].begin();
		int over = 0;

		while(staffs_it != staffs[i].end())
		{
			if(staffs[i][(*staffs_it).first].total >= 1000000)
			{
				cout << staffs[i][(*staffs_it).first].num << endl;
				over++;
			}
			staffs_it++;
		}
		if(over == 0) cout << "NA" << endl;
	}
}

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

int main()
{
	while ( true )
	{
		int n; cin>>n;
		if ( n == 0 )
			break;
		vector<pair<int,long long> > E;

		for ( int i=0; i<n; i++ )
		{
			int a, b, c;
			cin>>a>>b>>c;
			int j;
			for ( j=0; j<(int)E.size(); j++ )
				if ( E[j].first==a )
					break;
			if ( j==(int)E.size() )
				E.push_back( make_pair(a,0) );
			E[j].second += b*c;
		}
		bool f = false;
		for ( int i=0; i<(int)E.size(); i++ )
			if ( E[i].second >= 1000000 )
				cout << E[i].first << endl,
				f = true;
		if ( ! f )
			cout << "NA" << endl;
	}
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int N = 4000;
int n;
ll cost[N+1];
int id;
ll dc, dn;
ll res[N];

int main()
{
  while((cin >> n) && n){
    bool flag = true;
    rep(i, N+1) cost[i] = 0LL;
    int ptr = 0;

    rep(i, n){
      cin >> id >> dc >> dn;
      if(!cost[id]) res[ptr++] = id;
      cost[id] += dc * dn;
    }

    rep(i, ptr) if(cost[res[i]] >= 1000000){
      flag = false;
      cout << res[i] << endl;
    }
    if(flag) puts("NA");
  }

  return 0;
}