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 <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
	
	int n;
	
	while(cin >> n, n) {
		bool f = false;
		vector<int> IDs;
		unordered_map<int, long long> result;
		
		for(int i = 0; i < n; ++i) {
			int ID;
			long long price, number;
			cin >> ID >> price >> number;
			
			IDs.push_back(ID);
			result[ID] += price * number;
		}
		
		unordered_set<int> used;
		
		for(int ID : IDs) {
			if(used.count(ID)) continue;
			
			if(result[ID] >= 1000000) {
				cout << ID << endl;
				f = true;
			}
			used.insert(ID);
		}
		
		if(!f) {
			cout << "NA" << endl;
		}
		
	}
	
	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
//1000
#include <ctype.h>
using namespace std;long a,z,x,y,b[4001];bool s,p[4001];
int main(){
	while(cin>>a){
		if(a==0){break;}
	for(int aa=1;aa<=4000;aa++){
	b[aa]=0;p[aa]=false;}
	s=false;
	for(int i=0;i<a;i++){cin>>x>>y>>z;
	b[x]+=y*z;if(b[x]>=1000000&&p[x]==false){cout<<x<<endl;s=true;p[x]=true;}}
	if(s==false){cout<<"NA"<<endl;}}
return 0;}

C++: 
#include <iostream>
#include <math.h>

using namespace std;

int order[4000];

bool search(int);

class Member {
public:
	Member() {sum = 0; order = -1;}
	
	void add(long price, long num) {
		sum += price*num;
	}
	
	bool milion()
	{
		if (sum >= 1000000) return true;
		else return false;
	}
	
private:
	long long int sum;
	int id, order;
};


bool search(int num)
{
	for (int i=0; i<4000; i++) 
		if (order[i] == num ) return true;
	
	return false;
	
}

int main()
{
	int n, idx, memNum = 0;
	long price, num;
	bool nothing;

	
	ios::sync_with_stdio();
	
	while (1) {
		Member *member = new Member[4000];
		nothing =true;
		
		for (int i=0; i<4000; i++) order[i] = -1;
		
		if (cin >> n, !n) break;
		for (int i=0; i<n; i++) {
			scanf("%d %ld %ld", &idx, &price, &num);
			member[idx].add(price, num);
			if (!search(idx)) order[memNum++] = idx;
		}
		
		for (int i=0; i<4000 && order[i] > 0; i++) 
			if (member[order[i]].milion()) { cout << order[i] << endl; nothing = false; }
		if (nothing) cout << "NA" << endl;
	}
}

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

using namespace std;

int n;
long long id[4000];
unsigned long long value[4000];
unsigned long long number[4000];
map<unsigned long long, unsigned long long> total;

int main() {
  while(true){
    cin >> n;
    if(n==0){
        return 0;
    }
    for (int i = 0; i < n; i++) {
        cin >> id[i] >> value[i] >> number[i];
        if(total.find(id[i])==total.end()){
          total.insert(make_pair(id[i], 0));
        }
        total[id[i]] += value[i] * number[i];
    }
    vector<long long> v;
    if(!total.empty()) {
        map<unsigned long long, unsigned long long>::iterator it = total.begin();
        while (it != total.end()) {
            if ((*it).second >= 1000000) {
                v.push_back((*it).first);
            }
            ++it;
        }
    }
    if (v.empty()) {
        cout << "NA" << endl;
    }
    for (vector<long long>::iterator it = v.begin(); it != v.end(); ++it) {
        cout << *it << endl;
    }
    v.clear();
    total.clear();
  }
}

C++: #include <iostream>

using namespace std;

int N, M;

int main() {
	int goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		int v[4000];
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			int e, p, q;
			cin >> e >> p >> q;
			v[e - 1] += p*q;
		}
		bool flag = false;
		for (int i = 0; i < 4000; i++) {
			if (v[i] >= goal) {
				flag = true;
				cout << i + 1 << endl;

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

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std ;
#define P pair<int,long long int>

main(){
	int n,num,p,m,j ;
	bool t ;
	while( cin >> n , n ){
		vector<P> V ;
		for( int i=0 ; i<n ; i++ ){
			cin >> num >> p >> m ;
			t = true ;
			for( j=0 ; j<V.size() ; j++ ){
				if( V[j].first == num ){
					t = false ;
					break ;
				}
			}
			if( t ) V.push_back( P(num,p*m) ) ;
			else {
				if( V[j].second < 1000000 ) V[j].second += p*m ;
			}
		}
		
		t = false ;
		for( int i=0 ; i<V.size() ; i++ ){
			if( V[i].second >= 1000000 ){
				cout << V[i].first << endl ;
				t = true ;
			}
		}
		if( !t ) cout << "NA" << endl ;
	}
}

C++: #include<algorithm>
#include<iostream>
#include<vector>
#include<stdio.h>
struct su{
	int num;
	int sum;
}p[4001];
using namespace std;
int main()
{
	int n,i2;
	int sn,x, y,l=0;
	while (1){
		l = 0;
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++){
			cin >> sn >> x >> y;
			for (i2 = 0; i2 < l; i2++){
				if (p[i2].num == sn){
					p[i2].sum += x*y;
					break;
				}
			}
			if (i2 == l){
				p[l].sum = 0;
				p[l].num = sn;
				p[l].sum += x*y;
				l++;
			}
		}
		int maxn = 0;
		int maxc = 0;
		for (int i = 0; i < l; i++){
			if (maxn < p[i].sum){
				swap(maxn, p[i].sum);
				maxc = p[i].num;
			}
		}
		if (maxn >= 1000000){
			cout << maxc << endl;
		}
		else
			cout << "NA" << endl;
	}
}

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

int main() {
	while(scanf("%d\n", &n) != EOF) {
		map<int, ll> m;
		vector<int> id, p, q;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			id.push_back(x);
			p.push_back(y);
			q.push_back(z);
		}
		rep(i,n) {
			map<int, ll>::iterator it = m.find(id.at(i));
			if(it == m.end()) {
				m.insert(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
			} else {
				(*it).second += p.at(i) * q.at(i);
			}
		}
		bool flag = false;
		for(map<int, ll>::iterator it = m.begin(); it != m.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

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

int main(){

    return 0;
}

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

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		map<int,pair<long long,int> > m; // id,price,appear
		for(int i=0;i<n;i++){
			int id,price,num;
			cin>>id>>price>>num;
			m[id].first+=(long long)price*num;
			if(m[id].second==0)
				m[id].second=i+1;
		}
		
		map<int,int> m2; // first,id
		for(map<int,pair<long long,int> >::iterator i=m.begin();i!=m.end();i++)
			if(i->second.first>=1000000)
				m2[i->second.second]=i->first;
		
		for(map<int,int>::iterator i=m2.begin();i!=m2.end();i++)
			cout<<i->second<<endl;
		if(m2.size()==0)
			cout<<"NA"<<endl;
	}
	
	return 0;
}