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>
#include <map>
using namespace std;
int main(){
  int n;
  //mlÛ¶vÛ¶
  int a,b,c;
  //aÔbP¿cÊ
  int f;
  while(cin>>n,n){
		map<int,long long> m;
		vector<int> v;
		f=1;
    for(;n;n--){
      std::cin>>a>>b>>c;
      if(!m[a])v.push_back(a);
      m[a] += b*c;
    }
    
    for(int i=0;i<v.size();i++){
      if(m[v[i]]>=1000000){
				f=0;
				cout<<v[i]<<endl;}
    }
    if(f)cout<<"NA"<<endl;
  }
  return 0;
}

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

std::vector<std::string> split(const std::string& ref,const char c){
std::vector<std::string> res;
size_t current=0, found;
while((found=ref.find_first_of(c,current))!=std::string::npos){
res.push_back(std::string(ref,current,found-current));
current=found+1;
}
res.push_back(std::string(ref,current,ref.size()-current));
return res;
}

int main(void){

int it_num;
std::string str;
std::vector<std::string> ref;
std::vector<int> res;

std::cin >> it_num;
while(it_num!=0){
for(int i=0;i<it_num;i++){
std::getline(std::cin,str);
ref=split(str," ");
if((std::stoi(ref[1])*std::stoi(ref[2]))>=1000000){
res.push_back(ref[0]);
}
}
std::cin >> it_num
}
for(int j=0;j<res.size();j++){
std::cout << res[j] << std::endl;
}

return 0;
}

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

int main(){
  
  while(1){
  
    int n,no[4002],unit,qua;
    int emp[4002]={0};
    int empflag[4002]={0};
    
    scanf("%d",&n);
    
    if(n==0)break;
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&no[i],&unit,&qua);
      emp[no[i]]+=unit*qua;	
    }
    
    sort(no,no+n);

    int flag=0;
    for(int i=0;i<n;i++){
      if(emp[no[i]]>=1000000 && empflag[no[i]]==0){
	printf("%d\n",no[i]);
	flag=1;
	empflag[no[i]]=1;
      }
    
    }
    
    if(flag==0)printf("NA\n");
  }
  return(0);
}

C++: #include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;
struct P{
	int id;
	int tanka;
	int kosuu;
};

int main()
{
	int n;

	while (cin >> n && n ){
		vector<P> data (n );
		rep (i, n ){
			cin >> data[i].id >> data[i].tanka >> data[i].kosuu;
		} // end rep
		bool found = false;
		rep (i, n ){
			ll total = (ll)data[i].tanka*data[i].kosuu;
			if (total >= 1000000LL ){
				cout << data[i].id << endl;
				if (!found )
					found = true;
			} // end if
		} // end rep
		if (!found ){
			cout << "NA" << endl;
		} // end if
	} // end loop
		
	return 0;
}

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;

const ll MAX = 1000000;

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

C++: #include<stdio.h>

int main(){

	int n, i, x[4000] = {}, xx[4000] = {}, xxx[4000] = {}, r, y = 0, w;
	scanf("%d", &n);
	for (w = 0; w < n; w++){

		for (i = 0; i < n; i++){
			scanf("%d %d %d",&x[i],&xx[i],&xxx[i]);
		}
		for (r = 0; r < 4000; r++){
			if (xx[r] * xxx[r] > 1000000){
				printf("%d\n", x[r]);
			}	
		}if (y == 0){ printf("NA"); (y = 0); }		scanf("%d", &n);
	}
	return 0;
}

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


int main() {
	int n;
	while(scanf("%d\n", &n), n){
		vector<pair<int, ll>> v;
		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) {
			bool flag = false;
			for(int j = 0; j < v.size(); ++j) {
				if(v[j].first == id[i]) {
					v[j].second += p[i] * q[i];
					flag = true;
					break;
				}
			}
			if(!flag) {
				v.push_back(make_pair(id[i], (ll)p[i] * q[i]));
				}
		}
		bool flag = false;
		for(int j = 0; j < v.size(); ++j) {
			if(v[j].second >= 1000000) {
				flag = true;
				cout << v[j].first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)break;
		long long u[4010] = { 0 };
		for (int i = 0; i < n; i++){
			long a, b, c;
			cin >> a >> b >> c;
			u[a] += b*c;
		}
		bool b = true;
		for (int i = 1; i < 4001; i++){
			if (u[i] >= 1000000) {
				cout << i << endl;
				b = false;
			}
		}
		if (b)cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int order[4000];

bool search(int);

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


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;
	}
}