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 <map>
#include <vector>
using namespace std;

int main(){
	int n,number;
	long long a,b;
	bool flag;
	map<int,long long> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number); // 既出だったら表示順記録配列に入れない。単価0円ケースを考慮してません。
			info[number] += a*b;
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}

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

int main()
{
	int num, man, yen, ko;
	int ach;
	int c;
	int g[20][2] = { {} };
	int flag;
	
	while (1){
		c = 0;
		flag = 0;

		cin >> num;
		if (!num)	break;

		for (int i = 1; i <= num; i++){
			int j = i;
			cin >> man >> yen >> ko;
			ach = yen * ko;

			for (; j > 0; j--){
				if (g[j - 1][0] == man)
					g[j - 1][1] += ach;
				else flag = 1;

				if (g[j - 1][1] >= 1000000){
					cout << man << endl;
					c++;
				}
			}

			if (flag){
				g[i][0] = man;
				g[i][1] = ach;
			}

			if (g[i][1] >= 1000000){
					cout << man << endl;
					c++;
			}
		}

		if (c == 0)
			cout << "NA" << endl;
	}

	return 0;
}

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

#define SHINE_MAX 4000
#define ELITE 1000000
#define AHO "NA"

int shineN,eliteN;
long int shineU[SHINE_MAX];	//?£??????????

int num,tanka,suryo;
int i;

int main(){
	while(1){
	 cin>>shineN;
	 if(shineN==0){break;}
	 for(i=0;i<SHINE_MAX;i++){shineU[i]=0;}
	 for(i=0;i<shineN;i++){
	  cin>>num>>tanka>>suryo;
	  shineU[num-1]+=tanka*suryo;
	 }
	 //??¨?????????????????¨
	 eliteN=0;
	 for(i=0;i<SHINE_MAX;i++){
	  if(ELITE<=shineU[i]){
	   cout<<i+1<<endl;
	   eliteN++;
	  }
	 }
	 if(eliteN==0){cout<<AHO<<endl;}
	}
	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 n;

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

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

class Input {
public:
	int n;
	vector<int> numbers, tanka, num;
	
	bool input() {
		scanf("%d", &n);
		if (!n) {
			return false;
		}
		for (int i = 0; i < n; i++) {
			int s, t, u;
			scanf("%d%d%d", &s, &t, &u);
			numbers.push_back(s);
			tanka.push_back(t);
			num.push_back(u);
		}
		return true;
	}
};
class Solver : public Input {
public:

	vector<int> solve() {
		typedef pair<int, int> P;
		map<int, int> data;
		for (int i = 0; i < n; i++) {
			int value = tanka[i] * num[i];
			int number = numbers[i];
			
			if (data.find(number) == data.end() ) {
				data[number] = 0;
			}
			data[number] += value;
		}
		
		vector<int> ret;
		for (map<int, int>::iterator it = data.begin(); it != data.end(); it++) {
			if ((*it).second >= 1000000 ) {
				ret.push_back((*it).first);
			}
		}
		return ret;
	}
};

signed main() {
	while (true) {
		Solver solver;
		if (!solver.input() ) {
			break;
		}
		
		vector<int> res = solver.solve();
		if (res.size() == 0) {
			cout << "NA" << endl;
		}
		else {
			for (int i = 0; i < res.size(); i++) {
				cout << res[i] << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

typedef long long ll;

int main(){
    int n;
    while (cin >> n && n){
        map<string, long long> data;
        vector<string> id;
        rep(i, n){
            string a;
            ll b, c;
            cin >> a >> b >> c;
            ll t = b*c;
            if (data.count(a)){
                data[a] = t;
                id.push_back(a);
            }
            else{
                data[a] += t;
            }
        }

        bool NA = true;
        rep(i, id.size()){
            if (data[id[i]] >= 1000000){
                cout << id[i] << endl;
                NA = false;
            }
        }
        if (NA)
            cout << "NA" << endl;

    }
}

C++: #include<stdio.h>

struct staff_data{
	long unsigned int num,price,volume,total;
};

int main(void){

	int n,i,j,hantei;
	int num,price,volume;
	struct staff_data dt[4000]={0};
	
	while(scanf("%d",&n)!=EOF){
	
		if(n==0){
			break;
		}
		
		hantei=0;	

		for(i=0;i<n;i++){
			
			scanf("%d %d %d",&num,&price,&volume);
			
			for(j=0;j<n;j++){
				
				if(dt[j].num==num || dt[j].num==0){
					
					dt[j].price=price;
					dt[j].volume=volume;
					
					dt[j].total=(dt[j].price)*(dt[j].volume)+dt[j].total;
					
					break;
				}
				
			}
		}

		
		for(i=0;i<n;i++){
		
			if(dt[i].total>=1000000){
				printf("%4d\n",dt[i].num);
				hantei=1;
			}
		}
	
		if(hantei==0){
			printf("NA\n");
		}

	}

	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;

#define MAX 5000


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>=1000000/b){
                inp=1000000;
            }else{
                inp = b*c;
            }
            if(data[a]<1000000) 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]]>=1000000) {
                cout <<pre[j]<<endl;
                ch++;
            }
        }
        if(ch==0) cout << "NA"<<endl;
    }
}