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++: // 2011/01/12 Tazoe

#include <iostream>
using namespace std;

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

		int emp[4000][3];
		for(int i=0; i<4000; i++){
			emp[i][0] = i+1;
			emp[i][1] = 0;
			emp[i][2] = 5000;
		}

		int ord = 1;
		for(int i=0; i<n; i++){
			int id, p, q;
			cin >> id >> p >> q;
			if(p!=0&&1000000/p+1<=q)
				emp[id-1][1] = 1000000;
			else if(emp[id-1][1]<1000000)
				emp[id-1][1] += p*q;
			if(emp[id-1][2]==5000){
				emp[id-1][2] = ord;
				ord++;
			}
		}

		for(int i=0; i<3999; i++)
			for(int j=i+1; j<4000; j++)
				if(emp[i][2]>emp[j][2]){
					int tmp1 = emp[i][0];
					int tmp2 = emp[i][1];
					int tmp3 = emp[i][2];
					emp[i][0] = emp[j][0];
					emp[i][1] = emp[j][1];
					emp[i][2] = emp[j][2];
					emp[j][0] = tmp1;
					emp[j][1] = tmp2;
					emp[j][2] = tmp3;
				}

		int cnt =0;
		for(int i=0; emp[i][2]!=5000&&i<4000; i++)
			if(emp[i][1]>=1000000){
				cout << emp[i][0] << endl;
				cnt++;
		}
		if(cnt==0)
			cout << "NA" << endl;
	}

	return 0;
}

C++: num=int(input())
emp=[]
cnt=0
for i in range(num):
    emp.append(num)
    emp[i]=[int(k) for k in input().split()]
for i in range(num):
    for q in range(i+1,num):
        if emp[i][0]==emp[q][0]:
            emp[i][1]=emp[i][1]+emp[q][1]
            emp[i][2]=emp[i][2]+emp[q][2]
            emp[q][1],emp[q][2]=0,0
    if emp[i][1]*emp[i][2]>=1000000:
        print(emp[i][0])
        cnt+=1
if cnt==0:
    print('NA')

C++: #include<iostream>
#include<map>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    int a;
    long long b,c;
    map<int, long long> sale;
    sale.clear();
    bool f = true;
    while(n--){
      cin >>a>>b>>c;
      sale[a]+=b*c;
    }
    for(map<int, long long>::iterator pos = sale.begin(); pos!=sale.end(); pos++){
      if(pos->second >= 1000000){cout <<pos->first<<endl;f = false;}
    }
    if(f){cout <<"NA"<<endl;}
  }
  return 0;
}

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) {
				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<stdio.h>

int main(){
int N;
int n,m,p;
int P[4001][3]={};
int PT[4001][3]={};

while(1){
scanf("%d",&N);if(N==0)break;

for(int i=1;i<=N;i++){
scanf("%d %d %d",&n,&m,&p);
P[n][0]+=m*p;if(P[n][1]==0)P[n][1]=i;
}
int c=0;
for(int i=0;i<4000;i++)
if(1000000<=P[i][0]){PT[c][0]=P[i][0];PT[c][1]=P[i][1];c++;}

for(int i=0;i<c;i++)
for(int j=c-1;j>i;j--)
if(PT[j][1]<PT[j-1][1]){int TT=PT[j][1];PT[j][1]=PT[j-1][1];PT[j-1][1]=TT;}

for(int i=0;i<c;i++)
printf("%d\n",PT[i][1]);
}
RETURN 0;
}

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

int main(){
 int id,price,num,count;
 int sameid[4000];
 bool isBe=false,isSame=false;

 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   sameid[i]=id;
   for(int j=0;j<=i;j++){
    if(j==i){
     break;
    }
    if(id==sameid[j]){
      isSame=true;
      break;
    }
   }
   if(price*num>=100000&&!isSame){
    cout<<id<<'\n';
    isBe=true;
   }
   isSame=false;
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<count;i++){
   sameid[i]=0;
  }
 }
 return 0;
}

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

int main(){
    int n, id, p, q;
    std::map<int, int> workers;
    std::map<int, int>::iterator it;
    
    while(std::cin >> n){
        if(!n)
            break;
            
        for(int i=0; i<n; i++){
            std::cin >> id >> p >> q;
            workers[id] += p * q;
        }
        
        bool found = false;
        for(it = workers.begin(); it != workers.end(); it++){
            if(it->second >= 1000000){
                    std::cout << it->first << std::endl;
                    found = true;
            }
        }
        
        if(!found)
            std::cout << "NA" << std::endl;
        workers.clear();
    }
    
    return 0;
}

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

using namespace std;

int main(void){
  int n, a, b, c;
  map<int, 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 <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        queue<int> output;
        ll man[5000]={};
        rep(i,n){
            int a,b,c;
            cin>>a>>b>>c;
            if(man[a]==0){
                output.push(a);
            }
            if(man[a]<1000000){
                man[a]+=(ll)b*c;
            }
        }
//        while(output.size()){cout<<output.front();output.pop();}
        bool flag=true;
        while(output.size()){
            if(man[output.front()]>=1000000){
                cout<<output.front()<<endl;
                flag=false;
            }
            output.pop();
        }
        if(flag)cout<<"NA"<<endl;
    }
    
    return 0;
}

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

int main(){
   int t, a, b, c, n, emp[4001]={};
  while(1){
   t = 0;
   cin >> n;
   if(n == 0) break;
   for(int i = 0;i < n;++i){
     cin >> a >> b >> c;
     emp[a] += b * c;
  }  
   for(int i = 1;i < 4001;++i){
     if(emp[a] >= 1000000){
       cout << a << endl;
       t++;
    }
  }
   if(t == 0) cout << "NA" << endl;
 }
return 0;
}