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

int main()
{
	int n, i;
	bool f;
	long long int a, b, c;
	map<int, long long int> member;
	vector<int> order;
	vector<int>::iterator it;
	while (cin>>n, n) {
		member.clear();
		order.clear();
		for (i = 0; i < n; i++) {
			cin>>a>>b>>c;
			member[a] += b*c;
			if ( order.end() == find( order.begin(), order.end(), a ) ) {
				order.push_back(a);
			}
		}
		f = true;
		for (it = order.begin(); it != order.end(); it++) {
			if (member[*it] >= 1000000) {
				cout<<*it<<endl;
				f = false;
			}
		}
		if (f) cout<<"NA"<<endl;
	}

	return 0;
}

C++: #include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    while (1) {
        int id;
        long long int ids[4000],n,cost,amount;
        bool exist = false;
        vector<int> num;
        cin >> n;
        if (n==0) break;
        for(int i=0;i<4000;i++) ids[i]=-1;
        for(int i=0;i<n;i++){
            cin >> id >> cost >> amount;
            if(ids[id]==-1){
                num.push_back(id);
                ids[id]=0;
            }
            ids[id]+=cost*amount;
        }
        for(int i=0;i<num.size();i++){
            if(ids[num[i]]>=1000000){
                cout << num[i] << endl;
                exist = true;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
    
    return 0;
}

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

struct sale{
	int price;
	int num;
};

int main(){

	while(1){
		int n, cost, piece, num, count = 0;
		cin>>n;
		if(n == 0)
			break;

		sale a[N];
		for(int i=0;i<N;i++){
			a[i].price = 0;
			a[i].num = 0;
		}

		for(int i=0;i<n;i++){
			cin>>num>>cost>>piece;
			a[num-1].price += cost;
			a[num-1].num   += piece;
		}

		for(int i=0;i<N;i++){
			if(a[i].price * a[i].num >= 1000000){
				cout<<i+1<<endl;
				count++;
			}
		}

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

	return 0;
}

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

struct data{
    int id;
    long long int sales;
    data(int a, long long int b) : id(a), sales(b) {}
    bool operator<( const data& o ) const{
        return id < o.id;
    }
};

bool invec(int id, vector<int> v){
    for(vector<int>::iterator it = v.begin(); it != v.end(); it++){
        if( *it == id ) return true;
    }
    return false;
}

int main(){
    int n;
    while( cin >> n, n ){
        vector< data > ls;
        vector<int> good;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            vector<data>::iterator it = ls.begin();
            for(; it != ls.end(); it++){
                if( it->id == a ){
                    it->sales += b*c;
                    if( it->sales >= 1000000 &&
                        !invec(it->id, good)){
                        good.push_back( it->id );
                    }
                    break;
                }
            }
            if( it == ls.end() ){
                ls.push_back( data(a, b*c) );
                if( b*c >= 1000000 &&
                    !invec(a, good)){
                    good.push_back( a );
                }
            }
        }
        if( !good.size() ){
            cout << "NA" << endl;
        }else{
            for(vector<int>::iterator it = good.begin(); it != good.end(); it++){
                cout << *it << endl;
            }
        }
    }
    return 0;
}

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

typedef long long Int;

int main(){
    map<int,Int> table;
    int n;
    bool flug;

    while(cin >> n, n != 0){
        flug = false;
        table.clear();

        for(int i=1; i<=n; i++){
            int id;
            int tanka;
            int number;
            cin >> id >> tanka >> number;
            table[id] += (tanka*number);
        }

        for(map<int,Int>::iterator itpair = table.begin(); itpair != table.end(); itpair++){
            if(itpair->second >= 1000000){
                cout << itpair->first << endl;
                flug = true;
            }
        }
        if(flug != true){
            cout << "NA" << endl;
        }
    }

    return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int number[n];
    bool useN[n];
    long long int total[4000];
    for (int i = 0; i < n; i++) {
      number[n] = 0;
      useN[n] = true;
    }
    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;
      number[i] = a;
      for (int j = 0; j < i; j++) {
	if (number[j] == a) {
	  useN[i] = false;
	  break;
	}
      }
      total[a-1] += b*c;
    }
    
    bool NA = true;
    for (int i = 0; i < n; i++) {
      if ( useN[i] && total[number[i]-1] >= 1000000) {
	cout << number[i]+1 << endl;
	NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	int number[4000];
	int tanka[4000];
	int ryou[4000];
	long goukei[4000];
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>number[i];
			cin>>tanka[i];
			cin>>ryou[i];
			goukei[i]=tanka[i]*ryou[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				if(number[i]==number[j]){
					goukei[i]+=goukei[j];
					goukei[j]=0;
					}
			}
		}
		int flag=-1;
		for(int i=0;i<n;i++){
			if(goukei[i]>=1000000){
				flag=0;
				cout<<number[i]<<endl;
				}
		}
		if(flag==-1)
			cout<<"NA"<<endl;
	}
	return 0;
}

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

int main(){
	int n;

	while(true){
		int user[4000];
		int usercount = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}

		long long buf[3];
		for(int i=0;i<n;i++){
			cin >> buf[0] >> buf[1] >> buf[2];
			if(buf[1] * buf[2] >= 1000000){
				user[usercount] = buf[0];
				usercount++;
			}
		}

		for(int i=0;i<usercount;i++){
			cout << user[i] << endl;
		}
		if(usercount == 0){
			cout << "NA" << endl;
		}
	}
}

C++: /* -- 0100:Sale Result -- */
#include	<iostream>
#include	<map>

using namespace std;

typedef unsigned long long ull;

int main(void) {
	int n, buf_n, buf_c, buf_p;
	bool flag;
	ull buf_t;
	map<int, ull> List;

	while(1) {
		cin >> n;
		if(n == 0) { break; }

		flag = true;
		List.clear();
		for(int i=0; i<n; i++) {
			cin >> buf_n >> buf_p >> buf_c;
			buf_t = buf_p * buf_c;
			if(List.find(buf_n) == List.end()) {
				List[buf_n] = buf_t;
			} else {
				List[buf_n] += buf_t;
			}
		}
		map<int, ull>::iterator it = List.begin();
		while( it != List.end() ) {
			if(it->second >= 1000000) { flag = false; cout << it->first << endl; }
			it++;
		}
		if(flag) { cout << "NA" << endl; }
	}
	return 0;
}