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<algorithm>
#include<vector>
using namespace std;
int main()
{
	
	int n;
	long sn, x, y;
	while (1){
		long p[4001] = { 0 };
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++){
			cin >> sn >> x >> y;
			p[sn] += x*y;
		}
		long maxn = 0;
		long maxc = 0;
		for (int i = 1; i <= 4000; i++){
			if (maxn < p[i]){
				swap(maxn, p[i]);
				maxc = i;
			}
		}
		if (maxn >= 1000000){
			cout << maxc << endl;
		}
		else
			cout << "NA" << endl;
	}
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main() {
	int n;
	while (scanf("%d",&n)&&n!=0) {
		map<int, long long> sales;
		vector<int> log;
		long long prc, mnt;
		int num;
		for (int i=0; i<n; i++) {
			scanf("%d%lld%lld",&num,&prc,&mnt);
			if (!sales[num]) {
				log.push_back(num);
			}
			sales[num] += prc * mnt;
		}
		bool flag = true;
		for (int i=0; i<log.size(); i++) {
			if (sales[log[i]]>=1000000) {
				flag = false;
				printf("%d\n", log[i]);
			}
		}
		if (flag) printf("NA\n");
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  int data[2][4000],n,i,f,id,a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0; i<4000; i++) data[0][i]=-1,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      for(f=0;f<i+1;f++){
	if(data[0][f]==id){
	  data[1][f]+=(a*b);
	  break;
	}else if(data[0][f]==-1){
	  data[0][f]=id;
	  data[1][f]=a*b;
	  break;
	}
      }
    }
    for(i=0,f=0;i<n;i++)
      if(data[1][i]>=1000000)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<"\n";
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl;
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  ll n,d=1000000;
  while(cin >> n && n)  {
    map<ll,ll> m,m2,m3;
    set<ll> se;
    m.clear();
    m2.clear();
    m3.clear();
    se.clear();
    rep(i,n) {
      ll x,y,z;
      cin >> x >> y >> z;
      if(se.count(x)) {
	m2[m[x]]+=y*z;
      } else {
	m[x]=m.size()+1;
	m3[m[x]]=x;
	se.insert(x);
	m2[m[x]]=y*z;
      }
    }
    bool ck=true;
    tr(it,m2) {
      iter(m3) it2=m3.find(it->F);
      if(it->S>=d) {
	cout <<it2->S << endl;
	ck=false;
      }
    }
    if(ck) pr("NA");
  }
  return 0;
}

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

typedef struct
{
    long long score;
    bool is_first;
}WORKER;

int main()
{
    int n;
    while(1)
    {
        WORKER worker[4000];
        vector<int> id_list;
        int cnt = 0;
        for(int i=0; i<4000; i++)
        {
            worker[i].score = 0;
            worker[i].is_first = true;
        }
        cin >> n;
        if(n == 0)
        {
            break;
        }
        for(int i=0; i<n; i++)
        {
            int id;
            long long p;
            long long q;
            cin >> id >> p >> q;
            worker[id].score += p * q;
            if(worker[id].score >= 1000000 && worker[id].is_first)
            {
                id_list.push_back(id);
                worker[id].is_first = false;
            }
        }
        for(int i=0; i<id_list.size(); i++)
        {
            cout << id_list[i] << endl;
        }
        if(id_list.size() == 0)
        {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

int main(){
    int n;
    
    while(true){
        int cnt = 0;
        int s[4002]={0},gs[4002]={0};
        
        cin >> n;
        if(!n) break;
        
        int num,t,cost;
        for(int i = 0 ; i < n ; i++){
            cin >> num >> t >> cost;
            s[num] += t*cost;
            gs[i] = num;
        }
        
        for(int i = 0 ; i < n ; i++){
            for(int j = i+1 ; j < n ; j++){
                if(gs[i]==gs[j]&&i < j){
                    s[gs[i]] += s[j];
                    gs[j] = 4001;
                }
            }
        }
        for(int i = 0 ; i < n ; i++){
            if(s[gs[i]] >= 1000000){
                cout << gs[i] << endl;
                cnt++;
            }
        }
        if(!cnt) cout << "NA" << endl;
    }
    
    return 0;
}

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int n;
  while(cin >> n, n) {
    unsigned long long a[4100] = {};
    vi in(n);
    rep(i, n) {
      int p, q, r; cin >> p >> q >> r;
      a[p] += q*r;
      in[i] = p;
    }

    bool b = false;
    rep(i, n) {
      if(a[in[i]] >= 1000000) {
        cout << in[i] << endl;
        a[in[i]] = 0;
        b = true;
      }
    }
    if(!b) cout << "NA" << endl;
  }
}

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

class employee {
public:
	int id;
	int p, q;
	bool more_than_million() {
		return (p * q >= 1000000);
	}
};

int n;
std::vector<employee> data;

void init()
{
	n = 0;
	data.clear();
}

bool get_input()
{
	init();
	std::cin >> n;
	if (n == 0) {
		return false;
	}
	for (int i = 0; i < n; i++) {
		employee tmp;
		std::cin >> tmp.id >> tmp.p >> tmp.q;
		data.push_back(tmp);
	}
	return true;
}

void solve()
{
    std::vector<employee>::iterator i = data.begin();
    std::vector<int> top_salers;
    while(i != data.end()){
       if((*i).more_than_million()){
    	   top_salers.push_back((*i).id);
        }
       i++;
     }
    if (top_salers.empty()) {
    	std::cout << "NA" << std::endl;
    } else {
    	for (std::vector<int>::iterator j = top_salers.begin(); j != top_salers.end(); j++) {
    		std::cout << (*j) << std::endl;
    	}
    }
}

int main()
{
	while (get_input()) {
		solve();
	}
	return 0;
}

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

int main(){
 int id,price,num,count;
 bool isBe=false;
 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   if(price*num>=100000){
    cout<<id<<'\n';
    isBe=true;
   }
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
 }
 return 0;
}