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 <vector>
#include <cstdio>

#define TOTAL_SALES_TH (1000000)

struct SALES_INFO {
  int employeeID;
  int totalSales;
};

void updataSalesInfos(std::vector<SALES_INFO>& salesInfos, 
                      int ID,
                      int unitPrice,
                      int amount)
{
  for (std::vector<SALES_INFO>::iterator it = salesInfos.begin();
    it != salesInfos.end();
    ++it) {
    if (it->employeeID == ID) {
      it->totalSales += unitPrice * amount;
      return;
    }
  }
  SALES_INFO newInfo;
  newInfo.employeeID = ID;
  newInfo.totalSales = unitPrice * amount;
  salesInfos.push_back(newInfo);
}

int main(void)
{
  while (true) {
    int numOfInput;
    std::cin >> numOfInput;

    if (numOfInput == 0) {
      break;
    }

    int ID, unitPrice, amount;
    char deli;

    std::vector<SALES_INFO> salesInfos;

    for (int i = 0; i < numOfInput; i++) {
      scanf("%d %d %d", &ID, &unitPrice, &amount);
      updataSalesInfos(salesInfos, ID, unitPrice, amount);
    }

    std::vector<int> achieveList;

    for (std::vector<SALES_INFO>::iterator it = salesInfos.begin();
      it != salesInfos.end();
      ++it) {
      if (it->totalSales >= TOTAL_SALES_TH) {
        achieveList.push_back(it->employeeID);
      }
    }

    if (achieveList.size() == 0) {
      std::cout << "NA" << std::endl;
    }
    else {
      for (std::vector<int>::iterator it = achieveList.begin();
        it != achieveList.end();
        ++it) {
        std::cout << *it << std::endl;
      }
    }
  }

  return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string.h>

int main()
{
	int n;
	std::pair<int, int> v[4001];
	bool used[4001];
	
	while( 1 ){
		std::cin >> n;
	
		if( !n ) break;
	
		memset( v, 0, sizeof( v ) );
		memset( used, false, sizeof( used ) );
		
		while( n-- ){
			int num;
			int a, b;
		 	std::cin >> num >> a >> b;
			
			if( !used[num] ){
				v[num] = std::pair<int,int>( a, b );
				used[num] = true;
			}
			else{
				v[num].first += a;
				v[num].second += b;		
			}
		}
		
		for( int i = 0; i < 4001; i++ ){
			if( v[i].first == 0 && v[i].second == 0 ) continue;
			
			long long p = v[i].first * v[i].second;
			
			if( p < 1000000 ){
			 	v[i].first = v[i].second = 0;
			}
		}
		
		if( std::count( v, v + 4001, std::pair<int,int>( 0, 0 ) ) == 4001 ){
		 	std::cout << "NA" << std::endl;
		}
		else{
		 	for( int i = 1; i < 4001; i++ ){
				if( v[i].first && v[i].second )std::cout << i << std::endl;
			}
		}
	}

 	return 0;
}

C++: #include<cstdio>

using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			int num, sell, cnt;
			scanf("%d %d %d", &num, &sell, &cnt);
			if (sell*cnt >= target)
			{
				printf("%d\n", num);
				hero = true;
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

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




int n;


void solve()
{
	bool ok=false;
	int total[4000];
	bool check[4000];
	memset(check,false,sizeof(check));
	memset(total,0,sizeof(total));
	for(int i=0;i<n;i++){
		int num,a,b;
		cin>>num>>a>>b;
		total[num]+=a*b;
		if(total[num]>=1000000 && !check[num]){
			cout<<num<<endl;
			check[num]=true;
			ok=true;
		}
	}
	if(!ok) cout<<"NA"<<endl;
}

int main()
{
	while(cin>>n){
		if(n==0) break;
		solve();
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
typedef long long ll;
//vector<pair<bool, ll>> v(4001);
unsigned long long int a[4001];

int main(){
	int n, num, p, q;
	while(cin >> n, n){
		//fill(a, a+4001, 0);
		int f = 1;
		for(int i = 0;i < 4001;i++)a[i] = 0;
		for(int i = 0;i < n;i++){
			cin >> num >> p >> q;
			a[num] += p * q;
			if(a[num]>999999){
                printf("%d\n",num);
                f = 0;
            }
		}
		if(f)cout << "NA" <<endl;
		/*int f = 1;
		for(int i = 1;i <= 4000;i++)if(a[i] >= 1000000)cout << i << endl, f = 0;
		if(f)cout << "NA" << endl;*/
	}
	return 0;
}

/*
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
*/

C++: #include <bits/stdc++.h>
#define INT(name) int name; scanf("%d",&name);
#define VINT(name,n) vector<int> name(n); for(int i = 0;i < n;i++) scanf("%d",&name[i]);

using namespace std;

int main(int argc, char const *argv[]){
	vector<long long> data(4000);
	int i;
	long long a,b,c;
	int max;
	bool check;

	cin >> i;
	while(i){

		for(int j = 0;j < 4000;j++){
			data[j] = 0;
		}


		for(int j = 0;j < i;j++){
			cin >> a >> b >> c;
			data[a - 1] += b * c;
		}


		check = false;

		for(int j = 0;j < 4000;j++){
			if(data[j] >= 1000000){
				printf("%d\n",j+1);
				check = true;
			}
		}

		if(!check) printf("NA\n");

		cin >> i;
	}

	return 0;
}

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

int main(){
  int n;
  while(cin >> n, n){
    int id, cnt = 0;
    ll a, num, sum[5000];
    fill(sum, sum+5000, 0);
    vector<int> in;
    for(int i = 0; i < n ; i++){
      cin >> id >> a >> num;
      if(sum[id] <= 1000000)
	sum[id] += a*num;
      if(find(in.begin(), in.end(),id)==in.end()){
	in.push_back(id);
      }
    }

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

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main()
{
	
	int n;
	long long sn, x, y;
	vector<long long>p;
	map<long, long>m;
	while (1){
		m.clear();
		p.clear();
		cin >> n;

		if (n == 0)break;
		for (int i = 0; i < n; i++){
		cin >> sn >> x >> y;
			if (m.find(sn) == m.end()){
				p.push_back(sn);
			}
				m[sn] += x*y;
		}
		int flag = 0;
		for (int i = 0; i < p.size(); i++){
			if (m[p[i]] >= 1000000){
				cout << p[i] << endl;
				flag++;
			}
		}
		if (flag==0)cout << "NA" << endl;
	}
}

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

int main(){
  int n;
  while(std::cin>>n){
    if(!n)return 0;
    std::vector<int> v;
    int team,price,number;
    for(;n;n--){
      std::cin>>team>>price>>number;
      if(price*number>=1000000)v.push_back(team);
    }
    if(v.empty())std::cout<<"NA"<<std::endl;
    else{
      std::vector<int>::iterator it = v.begin();
      while(it!=v.end()){
        std::cout<<*it<<std::endl;
        it++;
      }
    }
  }
}