Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<int>  number;
	long long d,num,item,ko;
	while(cin>>d){
		if(d==0) break;
		for(int i=0;i<d;i++){
			cin>>num>>item>>ko;
			item *= ko;
			if(item>=1000000){
				number.push_back(num);
			}
		}
		if(number.size()==0) cout<<"NA"<<endl;
		else{
				for(int j=0;j<number.size();j++){
				cout<<number[j]<<endl;
			}
			number.clear();
		}
	}
}

C++: #include <iostream>
#include <string>
#include <map>
using namespace std;
int main(void){
	int n;
	while(cin >> n,n){
		map<int,int> name;
		long long int list[4001]={0};
		int a,b,c,j=0;
		for(int i=0;i<n ;i++){
			cin >> a >> b >> c;
			name[j]=a,j++;
			list[a]+=b*c;
		}
		bool check=true;
		for(int i=0;i<4000;i++)
			if(list[name[i]]>=1000000)
				cout << (name[i]) << endl,check=false,list[name[i]]=0;
		if(check)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n;
  while(cin >> n, n){
    int id, cnt=0;
    ll a, num, sum[5000];
    fill(sum, sum+5000, 0);
    vector<int> in;
    for(int i = 0; i < n ; i++){
      cin >> id >> a >> num;
      sum[id] += a*num;
      if(find(in.begin(), in.end(),id)==in.end()){
	in.push_back(id);
      }
    }

    for(int i = 0; i < in.size(); i++){
      if(sum[in[i]] >= 1000000){
	cout << sum[in[i]] << endl;
	cnt++;
	cout << in[i] << endl;
      }
    }
    if(!cnt) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<map>
#include<vector>
int main() {
	std::map<int, int> mp;
	std::vector<int> v;
	int n, i, e, p, q;
	while (true) {
		mp.clear();
		v.clear();
		scanf("%d", &n);
		if (n == 0)break;
		for (i = 0; i < n; i++) {
			scanf("%d%d%d", &e, &p, &q);
			if (mp.count(e) == 0) mp.emplace(e, p*q);
			else mp[e] += p*q;
		}
		for (std::map<int, int>::iterator itr = mp.begin(); itr != mp.end(); ++itr) {
			if (itr->second >= 1000000)v.push_back(itr->first);
		}
		if (v.size() == 0)printf("NA\n");
		else {
			for (std::vector<int>::iterator itr = v.begin(); itr != v.end(); ++itr) {
				printf("%d\n", *itr);
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1)

int main(){
  int n;
  while(cin >> n, n){
    map<int,int> e;
    vector<int> num;
    int cntnum[4000] = {0};
    for(int i = 1; i <= 4000; i++){
      e[i] = 0;
    }
    for(int i = 0; i < n; i++){
      int tmp[3];
      cin >> tmp[0] >> tmp[1] >> tmp[2];
      e[tmp[0]] += tmp[1] * tmp[2];
      if(cntnum[tmp[0]] == 0){
        num.push_back(tmp[0]);
        cntnum[tmp[0]]++;
      }
    }
    int cnt = 0;
    for(int i = 0; i < num.size(); i++){
      if(e[num[i]] >= 1000000){
        cout << num[i] << endl;
        cnt++;
      }
    }
    if(cnt == 0){
      cout << "NA" << endl;
    }
  }
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int aa[10000]={0},x=0,y=0,z=0,flg=0,a;
    while(cin>>a)
    {
        if(a==0)break;
        for(int i=0;i<a;i++)
        {
            cin>>x>>y>>z;
            aa[x]+=y*z;
        }
        for(int i=0;i<4010;i++)
        {
            if(aa[i]>=1000000)
            {
                flg=1;
                cout<<i<<endl;
            }
        }
        if(flg==0)cout<<"NA"<<endl;
        for(int i=0;i<4010;i++)
        {
            aa[i]=0;
            flg=0;
        }
    }
    return 0;
}

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

using namespace std;

int N, M;

int main() {
	long long  goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		long long  v[4000];
		queue<int> que;
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			long long  e, p, q;
			cin >> e >> p >> q;
			que.push(e);
			v[e - 1] += p*q;
		}
		bool flag = false;
		while(!que.empty()){
			if (v[que.front()] >= goal) {
				flag = true;
				v[que.front()] = 0;
				cout << que.front() + 1 << endl;
			}
			que.pop();
		}
		if (!flag) cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(T) __typeof((T).begin())
#define each(T, it) for(ITER(T) it =(T).begin(); it!=(T).end(); it++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 4001;
const int B = (int)1e6;

int main(void){
    for(int n; cin >> n, n;){
        bool f = false;
        vector<ll> in(N);
        vi p;

        while(n --){
            int id, v, m; cin >> id >> v >> m;
            
            if((in[id] += v * m) >= B) in[id] = B;
            if(find(ALL(p), id) == p.end()) p.pb(id);
        }
        each(p, it) if(in[*it] == B) cout << *it << endl, f = true;

        if(!f) cout << "NA" << endl;
    }
 
    return 0;
}

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

using namespace std;

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0)
			break;
		int c[4001]={} , id[10000000];
		for (int i=0; i<n; i++){
			int p , q;
			cin >> id[i] >> p >> q;
			c[id[i]] += p*q;
		}
		bool f=1;
		for (int i=0; i<n; i++){
			if (c[id[i]]>=1000000){
				cout << id[i] << endl;
				c[id[i]]=0;
				f=0;
			}
		}
		if (f)
			cout << "NA" << endl;

	}

	return 0;
}

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

int main()
{
    int e[4001],p[100000],q[1000000],n;
    std::list<int> Anslist;
    
    while(cin>>n){
        
        if(n==0)
            break;
        
        for(int i=0,j=0; i<n; i++){
            cin>>e[i]>>p[i]>>q[i];
        
            if(p[i]*q[i]>=1000000){
                Anslist.push_back(e[i]);
                j++;
            }
        
        }
    
        if(Anslist.empty()){
            cout << "NA" <<endl;
        }
    
        else{
            list<int>::iterator it = Anslist.begin();
            while( it != Anslist.end())
            {
                cout<< *it << endl;
                it++;
            }
        }
    }
    
    
    
    return 0;
}