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 <map>
int main(){
  int n;
  std::map<int,long long> m;
  std::vector<int> v;
  //mlÛ¶vÛ¶
  long long a,b,c;
  //aÔbP¿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()
{
    while(1)
    {
        int i=0;
        int na=0;
        cin>>i;
        if(i==0)
            break;
        else
        {
            int h[4000];
            for(int k=1;k<4000;k++)
            {
                h[k]=0;
            }
            for(int k=1;k<=i;k++)
            {
                int j=0;int l=0;int m=0;
                cin>>j>>l>>m;
                h[j]+=l*m;
                
            }
            for(int k=1;k<=i;k++)
            {
                if(h[k]>=1000000)
                {
                    cout<<k<<endl;
                    na=1;
                }
                
            }
            if(na==0)
            {
                cout<<"NA"<<endl;
            }

        }
    }

    return 0;
}

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

typedef long long ll;

int main()
{
	int n;
	std::map<int, ll> m;

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

		for( ll a, b, c, i = 0; i < n; ++i )
		{
			std::cin >> a >> b >> c;
			m[a] += b * c;
		}

		bool f = false;
		for( auto it = m.begin(); it != m.end(); ++it )
			if( it->second >= 1000000 )
				std::cout << it->first << std::endl, f = true;

		if( !f )
			std::cout << "NA" << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		int a,b,c;
		int f=0;
		long long unsigned s[4001]={0};
		
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			if(s[a]<=1000000)
			s[a]+=b*c;
		}
		for(int i=1;i<4001;i++){
			if(s[i]>=1000000){
				cout<<i<<endl;
				f=1;
			}
			
		}
		if(f!=1)
			cout<<"NA"<<endl;
	
	}
	
}

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

#define ll long long

int main(void){
  map<int,ll> m;
  vector<int> order;
  int n;
  int no,amount,price;

  while(cin >> n){
	bool exist = false;
	if(!n) break;
	for(int i=0;i<n;i++){
	  cin >> no >> amount >> price;
	  if(find(order.begin(), order.end(), no) == order.end()){
		order.push_back(no);
	  }
	  m[no] += (ll)amount*price;
	}
	for(int i=0;i<order.size();i++){
	  if(m[order[i]] >= 1e+6){
		cout << order[i] << endl;
		exist = true;
	  }
	}
	if(!exist) cout << "NA" << endl;
	m.clear();
  }
}

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

int main() {
	long long e, p, q;
	int n;
	while (cin >> n, n) {
		long long number[4001] = {};
		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			number[e - 1] += p*q;
		}

		int x = 0;
		for (int i = 0; i < 4001; i++) {
			if (number[i] >= 1000000) {
				cout << i + 1 << endl;
				x++;
			}
		}
		if (x == 0) { cout << "NA" << endl; }
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main(void){
    int n, i, p, q;
    while(cin >> n && n) {
        bool isExist = false;
        map<int, long long int> emp;
        vector<int> seq;
        rep(l, n) {
            cin >> i >> p >> q;
            if(!emp[i]) seq.push_back(i);
            if(emp[i] != -1) {
                emp[i]+=p*q;
            }
        }
        rep(i, seq.size()) {
            if(emp[seq[i]] >= 1000000) {
                cout << seq[i] << endl;
                isExist = true;
            }
        }
        if(!isExist) cout << "NA" << endl;
    }
}

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

int main() {
	vector<int> emp_nums;
	vector<int> grades;
	
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;
		int e, p, q;
		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			bool be_already = false;
			int same_emp_index;
			for (int j = 0; j < emp_nums.size(); j++) {
				if (emp_nums[j] == e) {
					be_already = true; same_emp_index = j; break;
				}
			}
			if (be_already) {
				grades[same_emp_index] += p*q;
			}
			else {
				emp_nums.push_back(e);
				grades.push_back(p*q);
			}
		}
	}
	for (int i = 0; i < emp_nums.size(); i++) {
		if (grades[i] >= 1000000)cout << emp_nums[i] << endl;
		else cout << "NA" << endl;
	}
}

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

int main()
{
	while (true){
		int n;
		cin >> n;
		if (!n){ break; }

		int sold[4001];
		bool already[4001];
		queue<int> input;
		for (int i = 1; i <= 4000; i++){
			sold[i] = 0;
			already[i] = false;
		}
		for (int i = 0; i < n; i++){
			int number, yen, times;
			cin >> number >> yen >> times;
			if (already[number] == false){
				already[number] = true;
				input.push(number);
			}
			sold[number] += yen * times;
		}
		bool f = false;
		while (!input.empty()){
			if (sold[input.front()] >= 1000000){
				cout << input.front() << endl;
				f = true;
			}
			input.pop();
		}
		if (f == false){
			cout << "NA" << endl;
		}
	}
	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) {
				A.push_back(V[i][0]);
				z = 1;
			}
		}
		if (z == 0) {
			A.push_back(0);
		}
	}
	for (int i = 0;A.size()>i;++i) {
		if (A[i] == 0) 
			std::cout << "NA" << std::endl;
		else 
			std::cout << A[i] << std::endl;
	}
	return 0;
}