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>

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;
	long price, num;
	bool nothing;

	
	ios::sync_with_stdio();
	
	while (1) {
		Member *member = new Member[4000];
		memNum=0;
		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 <deque>
#include <iostream>

using namespace std;

int main() {

	int n, num, v, q, c;
	deque<int> x;

	while(cin >> n) {
		if(n==0)
			break;
		c=0;
		for(int i=0; i<n; i++) {
			int f=1;
			cin >> num >> v >> q;
			if(v*q>=1000000) {
				for(int j=0; j<x.size(); j++) {
					if(x[j]==num)
						f=0;
				}
				if(f) {
					x.push_back(num);
					c++;
				}
			}
		}
		if(c==0)
			cout << "NA" << endl;
		else  {
			for(int i=0; i<c; i++) {
				cout << x[i] << endl;
			}
		}
	}
		
	return 0;

}

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        map<int,long long int>M;
        while(n--){
            int a,b,c;
            cin>>a>>b>>c;

            M[a]+=(long long)b*c;
            M[a]%=10000000;
        }

        bool flag=true;
        for(map<int,long long int>::iterator ite=M.begin();ite!=M.end();ite++){
            if(ite->second>=1000000){
                cout<<ite->first<<endl;
                flag=false;
            }
        }
        if(flag)cout<<"NA"<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
 
 

 
int main(void){
	int i,j,k;
	int n,num[4000];
	long long tanka[4000],sale_num[4000];
	int sale_all[4001],judge[4001];
	
	while(scanf("%d",&n),n){
		
		for(i=0;i<n;i++){
			scanf("%d%lld%lld",&num[i],&tanka[i],&sale_num[i]);
		}
		
		//初期化
		k=0;
		for(j=0;j<=4001;j++){
			judge[j]=0;
			sale_all[j]=0;
		}
		
		//idに対応したsaleに+
		for(i=0;i<n;i++){
			sale_all[num[i]] = sale_all[num[i]] + tanka[i]*sale_num[i];
		}
		
		for(i=0;i<n;i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		
		if(k!=1)printf("NA\n");
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long lli;

int main(void){
	int a,b,c;
	int n;
	while(cin>>n,n){
		std::map<int,lli> m;
		while(n--){
			cin>>a>>b>>c;
			m[a]+=b*c;
		}
		for(__typeof(m.begin()) it=m.begin();it!=m.end();it++){
			if(it->second>=1000000)cout<<it->first<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>

#define int64 long long int

using namespace std;
typedef pair<int, int> P;

int main()
{
    int flag[4001];
    int n, c, num, val, sale, na;
    P hoge[4001];
    
    while (1) {
        cin >> n;
        if(n == 0) break;
        
        c = 1;
        na = 1;
        memset(flag, 0, sizeof(int)*4001);
        
        for(int i=0; i<n; i++){
            cin >> num >> val >> sale;
            if(flag[num] == 0){
                flag[num] = c;
                hoge[c].first = num;
                hoge[c].second = val * sale;
                c++;
            } else {
                hoge[flag[num]].second += val * sale;
            }
        }
        for(int i=1; i<c; i++){
            if(hoge[i].second >= 1000000){
                na = 0;
                cout << hoge[i].first << endl;
            }
        }
        if(na == 1) cout << "NA" << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
typedef long long ll;
//vector<pair<bool, ll>> v(4001);
ll a[4001];

int main(){
	int n, num, p, q;
	while(cin >> n, n){
		fill(a, a+4001, 0);
		for(int i = 0;i < n;i++){
			cin >> num >> p >> q;
			a[num] += p * q;
		}
		int f = 1;
		for(int i = 0;i < 4001;i++)if(a[i] >= 1000000)cout << i << endl, f = 0;
		if(f)cout << "NA" << endl;
	}
	return 0;
}

/*
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
*/

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

int main() {
    for (;;) {
        int n;
        scanf("%d", &n);
        if (n == 0) return 0;
        map<int, Int> of;
        vector<int> ids;
        int c = 0;
        rep (_, n) {
            int id, p, q;
            scanf("%d%d%d", &id, &p, &q);
            ids.push_back(id);
            of[id] += (Int)p*q;
        }
        rep (i, n) if (of[ids[i]] >= 1000000) {
            printf("%d\n", ids[i]);
            of[ids[i]] = 0;
            c++;
        }
        if (c == 0) puts("NA");
    }
    return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    long long int total[4000];
    for (int i = 0; i < 4000; i++) total[i] = 0;
    
    for (int i = 0; i < n; i++) {
      int a;
      long long int b,c;
      cin >> a >> b >> c;
      total[a-1] += b*c;
    }
    
    bool NA = true;
    for (int i = 0; i < 4000; i++) {
      if ( total[i] >= 1000000) {
	cout << i+1 << endl;
	NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}

C++: #include <queue>
#include <cstdlib>
#include <iomanip>
#include <utility>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

vector<pair<int,int> > v;

int vsearch(int id)
{
    for(int i = 0;i<v.size();i++)
    {
        if(v[i].first==id)
            return i;
    }
    return -1;
}

int main() {
    
    int const price = 1000000;
    int n;
    while(cin >> n && n!=0)
    {
        int e[n],p[n],q[n];
        for(int i = 0; i<n;i++)
        {
            cin >> e[i] >> p[i] >> q[i];
        }
        
        for(int i = 0; i< n; i++)
        {
            int id = vsearch(e[i]);
            if(id < 0)
                v.push_back({e[i],p[i]*q[i]});
            else
                v[id].second += p[i]*q[i];
        }
        bool ch = true;
        for(int i = 0;i<v.size();i++)
        {
            if(v[i].second >= price)
            {
                cout << v[i].first << endl;
                ch = false;
            }
        }
        if(ch) cout << "NA" << endl;
        vector<pair<int,int> >().swap(v);
    }
    
    return 0;
}