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<long long, long long> > v(n);
		int num = 0;
		for (int i = 0; i < n; ++i){
			long long id, p, q;
			cin >> id >> p >> q;
			v[i] = make_pair(id, p * q);
		}

		sort(v.begin(), v.end());
		int c = 1;

		for (int i = 0; i < n - 1; ++i){
			if(v[i].first != v[i+1].first){
				c++;
			}
		}

		vector < pair<long long, long long> > sum(c);
		int k = 0;
		for (int i = 0; i < c; ++i){
			sum[i] = make_pair(0, 0);
		}

		long long s = 0;
		for (int i = 0; i < n ; ++i){
			s += v[i].second;
			if(i < n - 1){
				if(v[i].first != v[i+1].first){
					sum[k] = make_pair(v[i].first, s);
					s = 0;
					k++;
				}
			}else{
				sum[k] = make_pair(v[i].first, s);
			}
		}

		for (int i = 0; i < c; ++i){
			if(sum[i].second >= 1000000){
				cout << sum[i].first << endl;
				num++;
			}
		}

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

		cin >> n;
	}

	return 0;
}

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

using namespace std;

int main(void){
  int n, a, b, c;
  map<int, long long int> m;
  vector<int> v;

  while(cin >> n, n){
    v.clear();  m.clear();

    for(int i=0; i<n; i++){
      cin >> a >> b >> c;

      if(m.find(a) != m.end()){
        m[a] += b * c;
      } else {
        v.push_back(a);
        m[a] = b * c;
      }
    }

    bool flag = false;
    for(int i=0; i<v.size(); i++){
      if(m[v[i]] >= 1000000){
        flag = true;
        cout << v[i] << endl;
      }
    }

    if(flag == false){
      cout << "NA" << endl;
    }
  }


  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int>pii;
int main(){
    int n;
    while(cin>>n,n){
        long long S[4000]={0};
        int B[4000]={0},cnt=1;
        while(n--){
            long long n,m,o;
            cin>>n>>m>>o;
            S[n-1]+=m*o;
            if(B[n-1]==0){
                B[n-1]=cnt;
                cnt++;
            }

        }
        vector<pii>V;
        for(int i=0;i<4000;i++)
            if(S[i]>=1000000){
                V.push_back(pii(B[i],i));
            }
        sort(V.begin(),V.end());
        for(int i=0;i<V.size();i++)cout<<V[i].second+1<<endl;
        if(V.size()==0)cout<<"NA"<<endl;
    }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long int lint;

template <typename _Ty>
std::ostream& operator << (std::ostream& ostr, const std::vector<_Ty> v) {
	if (v.empty()) return ostr;
	for (auto itr = v.begin(); itr != v.end(); itr++) {
		if (itr == v.begin()) {
			std::cout << "{" << *itr;
		}
		else std::cout << ", " << *itr;
	}
	std::cout << "}";
	return ostr;
}

class Point2i {
public:
	int x;
	int y;

	Point2i() {
		this->x = x; this->y = y;
	}
	Point2i(int x, int y) {
		this->x = x; this->y = y;
	}

	friend std::ostream& operator << (std::ostream& ostr, const Point2i& p) {
		std::cout << "{" << p.x << ", " << p.y << "}";
		return ostr;
	}
};

bool AOJ0100() {
	lint n, e, p, q;
	cin >> n;
	if (n == 0) return false;

	lint* data = new lint[4001];
	for (int i = 0; i <= 4000; i++) data[i] = 0;

	for (lint i = 0; i < n; i++) {
		cin >> e >> p >> q;
		data[e] += p * q;
	}

	bool flag = false;
	for (int i = 1; i <= 4000; i++) {
		if (data[i] >= 1000000) {
			flag = true;
			cout << i << endl;
		}
	}
	if (!flag) cout << "NA" << endl;

	delete[] data;
	return true;
}

int main()
{
	while (AOJ0100()) {
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
int main() {
	int n;
	int x = 0;
	std::vector<int> A;
	while (std::cin >> n, n != 0) {
		int z = 0;
		++x;
		std::vector<int> m(n);
		std::vector<std::vector<int>> V(n, std::vector<int>(3));
		for (int i = 0;i < n;++i) {
			for (int j = 0;j < 3;++j) {
				std::cin >> V[i][j];
			}
		}
		for (int i = 0;i < n;++i) {
			m[i] = V[i][1] * V[i][2];
		}
		for (int i = 0;i < n;i++) {
			for (int j = 0;j < n;++j) {
				if (i < j) {
					if (V[i][0] == V[j][0]) {
						m[i] += m[j];
						m[j] = 0;
					}
				}
			}
		}
		for (int i = 0;i < n;++i) {
			if (m[i] >= 1000000) {
				std::cout << V[i][0] << std::endl;
				z = 1;
			}
		}
		if (z == 0) {
			std::cout << "NA" << std::endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>

#define MAX 4000

int main(void){
	int i,dataset,snum,unitcost[MAX],amount[MAX],flag,input1,input2;
	while( 1 ){

		for(i=0;i<MAX;i++){
			unitcost[i]=0;
			amount[i]=0;
		}

		scanf("%d",&dataset);
		if( dataset == 0 ){break;}

		else for(i=0;i<dataset;i++){
			scanf("%d %d %d",&snum,&input1,&input2);
			unitcost[snum]=input1;
			amount[snum]=input2;
		}
		

		flag=0;
		for(i=0;i<MAX;i++){
                        if( (unitcost[i]*amount[i]) >= 1000000 ){
				flag=1;
				printf("%d\n",i);
			}
		}
		if( dataset!=0 && flag==0 ){
			printf("NA\n");
		}
	}
}

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

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	long long value[4001];

	int n,num,k,m;
	while(cin >> n && n)
	{
		memset(value,0,sizeof(value));

		vector<int> ans;
		rep(i,n)
		{
			cin >> num >> k >> m;
			vector<int>::iterator ite = find(ans.begin(),ans.end(),num);
			if(ite == ans.end())
			{
				value[num] += k*m;
				
				if(value[num] >= 1000000)
				{
					ans.push_back(num);
				}
			}			
		}

		if(ans.size() == 0)
		{
			cout << "NA" << endl;
		}
		else
		{
			rep(i,ans.size())
			{
				cout << ans[i] << endl;
			}
		}
	}
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);

    vector<int> sum(4001, 0);
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;

        fill(sum.begin(), sum.end(), 0);
        for (int i=0; i<n; ++i) {
            int no, price, quantity;
            cin >> no >> price >> quantity;
            sum[no] += price * quantity;
        }

        bool NA = true;
        for (int i=1; i<=4000; ++i) {
            if (sum[i] >= 1000000) {
                cout << i << endl;
                NA = false;
            }
        }
        if (NA) {
            cout << "NA" << endl;
        }
    }

    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(!n)break;
		int num,price,amount;
		vector<int> v;
		while(n--){
			cin>>num>>price>>amount;
			long long sum = price*amount;
			if(sum>=1000000) v.push_back(num);
		}
		if(!v.empty()){
			for(int i=0;i<v.size();++i)cout<<v[i]<<"\n";
		}else cout<<"NA\n";
	}
	return 0;
}