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

int main()
{
	array<long long, 4000> ar;
	vector<long long> ans;
	long long n;
	int e,p,q;
	
	while (true) {
		cin >> n;
		ar.fill(0);
		if (!n) {
			break;
		}

		bool isNA = true;
		for (int i = 0; i < n; ++i) {
			cin >> e >> p >> q;
			ar[e] += p*q;
		}
		for (int i = 0; i < 4000;++i) {
			if (ar[i] >= 1000000) {
				auto it = ans.begin();
				//it = std::find(it, ans.end(), i);
				if (it == ans.end()) {
					ans.push_back(i);
				}
				isNA = false;
			}
		}
		if (isNA) {
			ans.push_back(-1);
		}

	}

	for (auto it : ans) {
		if (it != -1) {
			cout << it << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void shoki();
	vector<long long> num(4001,0);
	int n,ban,tanka,kazu,i,j;
int main(){
	
	bool y=false;
	for(j=0;j<50;j++){
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>ban>>tanka>>kazu;
			num[ban]+=tanka*kazu;
		}
		for(int k=0;k<4001;k++){
			if(num[k]==0){
				continue;
			}
			if(num[k]>=1000000){
				y=true;
				cout<<k<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
	}
	
	return 0;
}
void shoki(){
	for(int i=0;i<4000;i++){
		num[i]=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;
    map<int, long long int> emp;
    vector<int> seq;
    while(cin >> n && n) {
        bool isExist = false;
        emp.clear();
        seq.clear();
        rep(l, n) {
            cin >> i >> p >> q;
            if(!emp[i]) seq.push_back(i);
            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 <map>
#include <vector>
using namespace std;

int main(){
	int n,number;
	long long a,b;
	bool flag;
	map<int,long long> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number); // ツ甘ケツ出ツつセツづつスツづァツ表ツ篠ヲツ渉記ツ録ツ配ツ療アツづ可禿シツづェツづ按つ「ツ。ツ単ツ可ソ0ツ円ツケツーツスツづーツ考ツ猟カツつオツづづ慊つケツづアツ。
			info[number] += a*b;
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}

C++: #include <iostream>

int main(){
  int i, n, q;
  long long int p;
  while(cin >> n, n){
    bool NfAlg = false;
    while(n--){
      cin >> i >> p >> q;
      if((p * q) >= static_cast<int>(1e6)){
	cout << i << endl;
	NAflg = true;
      }
    }
    if(NAflg)
      cout << "NA" << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
struct date{
    long long int tanka;
    long long int uriage;
    long long int sum;
};
int main(){
	while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        date a[5000] = {0};
        int number;
        for(int i = 0; i < n; i++){
            cin >> number;
            cin >> a[number].tanka >> a[number].uriage;
            a[number].sum += a[number].tanka * a[number].uriage;
        }
        bool flg = 0;
        for(int i = 1; i <= 4000; i++){
            if(a[i].sum >= 1000000) cout << i << endl,flg = 1;
        }
        if(!flg) cout << "NA" << endl;
	}
	return 0;
}

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

struct employee {
    int id;
    int price;
    int quantity;

    int total_sales() const {
        return price * quantity;
    }
};

employee read_employee(std::istream& in) {
    employee e{};
    in >> e.id >> e.price >> e.quantity;
    return e;
}

int main() {
    while (std::cin) {
        std::vector<employee> employees;
        int num;
        std::cin >> num;
        if (num <= 0)
            continue;
        for (int i = 0; i < num; ++i) {
            if (!std::cin) {
                std::cerr << "malformed input\n";
                std::exit(1);
            }
            auto e = read_employee(std::cin);
            employees.push_back(e);
        }
        std::vector<int> checked_ids;
        bool na = true;
        for (auto const& employee: employees) {
            if (std::find(checked_ids.begin(), checked_ids.end(), employee.id) != checked_ids.end())
                continue;
            checked_ids.push_back(employee.id);
            int sum = 0;
            for (auto const& e: employees) {
                if (e.id == employee.id)
                    sum += e.total_sales();
            }
            if (sum >= 1000000) {
                std::cout << employee.id << '\n';
                na = false;
            }
        }
        if (na)
            std::cout << "NA\n";
    }
}

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

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    vector<pair<int, long long>> seq;
    long long int id, p, q;
    for (int i = 0; i < n; ++i) {
      cin >> id >> p >> q;

      bool flag = true;
      for (auto &v : seq) {
        if (v.first == id) {
          flag = false;
          v.second += p * q;
          break;
        }
      }
      if (flag)
        seq.push_back(make_pair(id, p * q));
    }

    bool flag2 = true;
    for (auto &v : seq) {
      if (v.second >= 1e6) {
        cout << v.first << endl;
        flag2 = false;
      }
    }

    if (flag2)
      cout << "NA" << endl;
  }
}

C++: #include<iostream>

using namespace std;


int main(){

	long all[4001] = {};
	long code, a, b, n, i,j;

	while (1){
		j = 0;
		for (i = 0; i < 4001; i++){
			all[i] = 0;
		}


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

		for (i = 0; i < n; i++){
			cin >> code >> a >> b;
			all[code] += a*b;
			
		}

		for (i = 0; i < 4001; i++){
			if (all[i] >= 1000000){
				cout << i << endl;
				j++;
			}
		}

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

	}
}

C++: #include <iostream>
using namespace std;
 
int main() {
	while(1){
int s[4000];int i;int w;
w=0;
for(int y = 0;y<4000;y++){
	s[y]= 0;
}
cin>>i;
if(i==0){break;}
for(int y = 1;y<=i;y++){
	int a,b,c;
	cin>>a>>b>>c;
	s[a-1]=s[a-1]+b*c;
}
for(int y = 0;y<4000;y++){
	if(s[y]>=1000000){
		cout << y+1<<endl;
		w=1;
		}
}
if(w==0){cout << "NA" << endl;}
}
	return 0;
}