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<algorithm>
#include<functional>
#include<iomanip>
#include<map>
using namespace std;

int main(){

	while (true) {
		int cnt = 0;
		cin >> cnt;
		if (cnt == 0) break;

		std::map<int, int> data;
		for (int i = 0; i < cnt; ++i) {
			int id, price, amount;
			cin >> id >> price >> amount;
			int g = price * amount;

			if (data.find(id) == data.end()) data[id] = 0;
			data[id] += g;
		}
		bool bHitted = false;
		for (std::map<int, int>::iterator it = data.begin(); it != data.end(); ++it) {
			// cout << "--" << it->first << ", " << it->second << "\n";
			if (it->second >= 1000000) {
				cout << it->first << "\n";
				bHitted = true;
			}
		}
		if (!bHitted) {
			cout << "NA\n";
		}
	}
	return 0;
}

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

int main() {
  int num = 0;
  while (cin >> num, num) {
    int data[4000] = { 0 };
    int count = 0;
    for (int i = 0; i < num; i++) {
      int id, price, sold_num;
      cin >> id >> price >> sold_num;
      data[id] += price*sold_num;
    }
    for (int i = 0; i < 4000; i++) {
      if (data[i] >= 1000000) {
        cout << i << endl;
        count++;
      }
    }
    if (count == 0) {
      cout << "NA" << endl;
    }
  }
}

C++: #include<iostream>
#include<vector>
#include<map>
#define SALES_GOAL 1000000
using namespace std;
int main(void){
  int i,n;
  vector<int> data;
  vector<int>::iterator vc_it;
  while(cin>>n,n){
    int tof = 1;
    int num,price,qua;
    map<int,long long int> staff;
    map<int,long long int>::iterator itr;
    while(n-- > 0){
      cin >> num >> price >> qua;
      staff[num] = staff[num]? staff[num]+(long long int)price*qua : (long long int)price*qua;

    }
    for(itr = staff.begin(); itr != staff.end(); itr++){

      if(itr->second >= SALES_GOAL){
        data.push_back(itr->first);
        tof = 0;
      }
    }
    if(tof)data.push_back(0);
  }
  for(vc_it = data.begin(); vc_it != data.end(); vc_it++){
    if(*vc_it)cout << *vc_it << endl;
    else cout << "NA" << endl;
  }

}

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

int main(){
  long long int nin;
  while(1){ 
    scanf("%d",&nin);
    if(!nin)break;

    long long int human[4002]={0};
    long long int no[4002],tanka,kazu,outflag=0;;
    
    for(int i=0;i<nin;i++){
      scanf("%d %d %d",&no[i],&tanka,&kazu);
      human[no[i]]+=tanka*kazu;
    }
    
    for(int i=0;i<nin;i++){
      if(human[no[i]]>=1000000 && human[no[i]]!=-1){
	printf("%d\n",no[i]);
	human[no[i]]=-1;
	outflag=1;
      }
    }
    
    if(outflag==0)printf("NA\n");
    
  }
}

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

using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        map<int, long long> m;
        int i;
        long long p, q;
        for (int k=0; k<n; ++k) {
            cin >> i >> p >> q;
            m[i] += p * q;
        }
        bool na = true;
        for (auto it=m.begin(); it!=m.end(); ++it) {
            if (1000000LL <= it->second) {
                cout << it->first << endl;
                na = false;
            }
        }
        if (na) cout << "NA" << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

long long int nums[10000];

bool flags[10000];
int index[10000];

int main(){
	
	while(true){
		
		int n;
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < 10000; i++){
			nums[i] = 0;
			flags[i] = true;
		}
		
		for(int i = 0; i < n; i++){
			long long int e, p, q;
			cin >> e >> p >> q;
			nums[e] += p * q;
			index[i] = e;
		}
		
		bool check = false;
		
		for(int i = 0; i < n; i++){
			if(nums[index[i]] >= 1000000 && flags[index[i]]){
				cout << index[i] << endl;
				check = true;
				flags[index[i]] = false;
			}
		}
		
		if(!check){
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

using namespace std;
#define EPS 1e-9
#define MAX 505
#define pb push_back
#define mp make_pair
#define ins insert
#define fi first
#define se second
#define pi acos(-1.0)
#define mod 100000007
#define inf 2147483647
#define ll long long int
#define sss stringstream
#define oss ostringstream
#define iss istringstream
#define llu long long unsigned

#define _sq(a) (a)*(a)
#define sz(a) ((int)a.size())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define _max3(a,b,c) max(a, max(b,c))
#define _min3(a,b,c) min(a, min(b,c))
#define FOR(i, n) for(i=0; i<(int)n; i++)
#define FOR1(i, n) for(i=1; i<=(int)n; i++)
#define mem(a) memset(a, 0, sizeof(a))
#define _set(a) memset(a,-1,sizeof(a))
#define FORI(i, a, b) for(i=a; i>=(int)b; i--)
#define FORab(i, a, b) for(i=a; i<=(int)b; i++)
#define popcount(n) __builtin_popcount(n)
#define popcountl(n) __builtin_popcountll(n)
#define sort_rev(a) sort(a.rbegin(), a.rend())
#define sort_all(a) sort(a.begin(), a.end())
#define dis_twopoints(x1,y1,x2,y2) sqrt(_sq(x1-x2) + _sq(y1-y2))
#define foreach(i,n) for(__typeof((n).begin())i =(n).begin();i!=(n).end();i++)

//If Long Long (mask & (1LL << k))
#define check(mask, k) (mask & (1 << k))
#define set1(mask, k) (mask | (1 << k))
#define set0(mask ,k) (mask & (~(1<<k)))

#define SD(a) scanf("%d",&a)
#define SLF(a) scanf("%lf",&a)
#define SC(a) scanf("%c",&a)
#define SS(a) scanf("%s",a)
#define SLLD(a) scanf("%lld", &a)
#define Si64(a) scanf("%I64d", &a)

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
struct wor
{
    int mon;
    int fla;
};
int main()
{
    wor id[9999];
    int ta,tan,i,s,p,doc[50],j;
    while(cin>>ta&&ta!=0)
    {
        int f=0;
        for(j=0; j<ta; j++)
        {
            cin>>i>>s>>p;
            doc[j]=i;
            if(id[i].fla==2)
            {
                id[i].mon=id[i].mon+(s*p);

            }
            else
            {
                id[i].mon=s*p;
                id[i].fla=2;
            }
        }
        for(j=0; j<ta; j++)
        {
            if(id[doc[j]].fla==3)
            {
                continue;
            }
            else
            {
                if(id[doc[j]].mon>=1000000)
                {
                    cout<<doc[j]<<endl;
                    id[doc[j]].fla=3;
                    f=1;
                }
            }
        }
        for(j=0;j<ta;j++)
        {
           id[doc[j]].fla=0;
        }
        if(f==0)
        {
            cout<<"NA"<<endl;
        }
    }

    return 0;
}