Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

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

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

int main(){
  int n;
  std::map<int,long long> m;
  std::vector<int> v;
  //m数値保存v順序保存
  long long a,b,c;
  //a番号b単価c数量
  bool f; //真か偽を格納
  while(std::cin>>n && n){
     m.clear();
     v.clear();
     f=true;
    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=false;
	std::cout<<v[i]<<std::endl;}
    }
    if(f)std::cout<<"NA"<<std::endl;
  }
  return 0;
}

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

int main() {
	long long number[4001] = {};
	long long e, p, q;
	int MAX = 0;
	int n;
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			if (MAX <= e) { MAX = e; }
			number[e - 1] += p*q;
		}
	}
	int x = 0;
	for (int i = 0; i < e; i++) {
		if (number[i] >= 1000000) {
			cout << number[i];
			x++;
		}
	}
	if (x == 0){cout << "NA" << endl;
	return 0;
}