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




int main(){
	int n;
	cin >> n;

	while(n != 0){
		vector < pair<int, int> > v(n);
		int num = 0;
		for (int i = 0; i < n; ++i){
			int id, p, q;
			cin >> id >> p >> q;
			v[i] = make_pair(id, p * q);
		}

		sort(v.begin(), v.end());
		int sum = v[0].second;

		for(int i = 1; i < n ; i++){
			if(v[i].first == v[i-1].first){
				if(i + 1 != n){
					sum += v[i].second;
					
				}else{
					sum += v[i].second;
					if(sum >= 1000000){
						cout << v[i].first << endl;
						num++;
					}
				}
			}else{
				if(sum >= 1000000){
					cout << v[i-1].first << endl;
					num++;
				}
				sum = v[i].second;
				if(sum >= 1000000){
					cout << v[i].first << endl;
					num++;
				}
			}
		}

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

		cin >> n;
	}

	return 0;
}

C++: // a.c.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
int main(void){
	int n;
	int ban, tan, suu;
	long long int bango[4001] = {};
	int flg,i;
	while (1){
		for (i = 1; i <= 4000; i++){
			bango[i] = 0;
		}
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &ban, &tan, &suu);
			bango[ban] += tan*suu;
		}
		flg = 0;
		for (i = 1; i <= 4000; i++){
			if (bango[i]>=1000000){
				printf("%d\n", i);
				flg = 1;
			}
		}
		if (!flg){
			printf("NA\n");
		}
	}
	return 0;
}

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

int main(){
	while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        long long a[5000] = {0};
        long long int number;
        long long int jun[5000] = {0};
        long long tanka,kazu;
        for(int i = 1; i <= n; i++){
            cin >> number >> tanka >> kazu;
            a[number] += tanka * kazu;
            jun[i] = number;
        }
        for(int i = 0; i < 4000; i++){
            for(int j = i+1; j <= 4000; j++){
                if(jun[i] == jun[j]) jun[j] = 0;
            }
        }

        bool flg = 0;
        for(int i = 1; i <= 4000; i++){
            if(a[jun[i]] >= 1000000){
                cout << jun[i] << endl;
                flg = 1;
            }
        }


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

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

typedef struct{
	int sum;
	int pr;
} data;

int main(int argc, char **argv)
{
	int i, p, q, n, size = 0, flag, pri = 1, max;
	data *sarray = (data *)calloc(2000, sizeof(int));
	int *id = (int *)calloc(1000, sizeof(int));
	while(1){
		cin >> n;
		
		if(n == 0){
			cout << "NA" << endl;
			break;
		}
		
		while(n > 0){
			n--;
			cin >> i >> p >> q;
			flag = 0;
			for(int j = 0; j < size; j++){
				if(id[j] == i){
					if(p*q > sarray[i].sum || pri != sarray[i].pr){
						sarray[i].sum = p*q;
						sarray[i].pr = pri;
					}
					flag = 1;
					break;
				}
			}
		
			if(flag == 0){
				id[size] = i;
				sarray[i].sum = p*q;
				sarray[i].pr = pri;
				size++;
			}
		}

		max = id[0];
		for(int j = 1; j < size; j++){
			if(sarray[max].sum < sarray[id[j]].sum){
				max = id[j];
			}
		}
		
		cout << max << endl;
		
		pri++;
	}
	
	free(sarray);
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){

	int n;
	while(cin>>n&&n!=0){
//		vector<pair<int,int> > v;
		ll info[4001];
		bool appeared[4001];
		fill(info,info+4001,0);
		fill(appeared,appeared+4001,false);
		vector<int> numList;
		for(int i = 0; i < n; i++){
			int num;
			int val;
			int ko;
			cin>>num>>val>>ko;
			if(!appeared[num]){
				appeared[num]=true;
				numList.push_back(num);
			}

			info[num]+=((ll)val)*ko;
		}

		bool f=false;
		for(int i = 0; i < numList.size(); i++){
			if(info[numList[i]]>=1000000){
				cout<<numList[i]<<endl;
				f=true;
			}
		}
		if(!f)
			cout<<"NA"<<endl;
	}

	return 0;
}

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

typedef long long ll;

map<int,ll> mp;
vector<int> v;

int main() {
  int n;
  
  while( cin>>n && n ) {
    mp.clear();
    
    for( int i=0; i<n; i++ ) {
      int a;
      ll b, c;
      cin >> a >> b >> c;
      if( !mp[a] )v.push_back( a );
      mp[a] += b * c;
    }

    bool isExist = false;
    for( int i=0; i<v.size(); i++ ) {
      if( mp[v[i]] >= 1000000 ) {
	isExist = true;
	cout << v[i] << endl;
      }
    }
    if( !isExist ) cout << "NA" << endl;
  }
  
  return 0;
}

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