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<map>
#include<vector>
#include<string>

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 mp make_pair

int main(){
    int n;
    string a;
    long long b,c;
    map<string,long long> data;
    vector<string> id;
    while(cin>>n, n){
        id.clear();
        data.clear();
        rep(i,n){
            cin>>a>>b>>c;
            c*=b;
            if(data.find(a)==data.end()){
                data.insert(mp(a,c));
                id.push_back(a);
            }
            else{
                data[a]+=c;
            }
        }

        bool empty = true;
        rep(i,id.size()){
            if(data[id[i]]>=1000000){
                cout<<id[i]<<endl;
                empty = false;
            }
        }
        if (empty)
            cout<<"NA"<<endl;

    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{

    int n=1,num,tanka,suryo;
    long long sum[4001]={0};
    int jyun[100000]={0};
    bool w[4001]={false};
    bool na=true;
    while(true){
        cin>>n;
        if(n==0){
            return 0;
        }
        for(int i=0;i<n;i++){//ツ禿シツ療債つウツづェツつスツ値ツづーツ各ツ配ツ療ア(ツ偲青暗オツ氾板債づ可格ツ納)
            cin>>num>>tanka>>suryo;
            jyun[i]=num;
            sum[num]+=tanka*suryo;
        }
        for(int i=0;i<=100000;i++){
            if(sum[jyun[i]]>=1000000){if(!w[jyun[i]]){cout<<jyun[i]<<endl;w[jyun[i]]=true;}na=false;}
            sum[i]=0;//ツ篠淞づ可使ツつ、ツづヲツつ、ツづ可渉可甘コツ可サツづーツつオツづつィツつュ
            jyun[i]=0;
        }
        if(na)cout<<"NA"<<endl;
        na=true;
        for(int i=0;i<=4000;i++){
            w[i]=false;
        }
    }
}

C++: #include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
int main(){
  int n,inindex;
  long long num,val;
  vector<int> Index;
  map<int,long long> List;
  while(true){
    scanf("%d",&n);
    if(n == 0)break;
    List.clear();
    Index.clear();
    for(int i=0;i<n;i++){
      cin >> inindex >> num >> val;
      if(!List[inindex]){
	Index.push_back(inindex);
      }
      List[inindex]+=val*num;
    }
    bool NAf=true;
    for(int i=0;i<Index.size();i++){
      if(List[Index[i]] >= 1000000){
	printf("%d\n",Index[i]);
	NAf=false;
      }
    }
    if(NAf)printf("NA\n");
  }

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    bool f = false;
    REP(i,n){
      string a;
      ll b,c;
      cin>>a>>b>>c;
      if(b*c >= (ll)1000000){
	cout << a << endl;
	f = true;
      }
    }
    if(!f) cout << "NA" << endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int bangou,tanka,kosuu;
    int number; cin >> number;
    do{
        int man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
        }
        int count =0;
        for(int i=0;i<4000;i++){
            if(man[i]>=1000000){
                cout << i+1;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

C++: #include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> m(4001);
    vector<int> order;
    set<int> already;
    REP(i,n){
      int no, p, num;
      cin>>no>>p>>num;
      if (!already.count(no)) {
        order.push_back(no);
        already.insert(no);
      }
      m[no] += p * num;
    }
    int cnt = 0;
    for(int no:order) {
      if (m[no] >= 1000000) {
        ++cnt;
        cout << no << endl;
      }
    }
    if (!cnt)
      cout << "NA" << endl;
  }
  return 0;
}

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

#define SALES_GOAL 1000000
using namespace std;
int main(void){
  int i,n;
  vector<int> data;
  vector<int>::iterator vc_it;
  while(cin>>n,n){
    int tof = 1;
    int num,price,qua;
    map<int,int> staff;
    map<int,int>::iterator itr;
    while(n-- > 0){
      cin >> num >> price >> qua;
      staff[num] = staff[num]? staff[num]+price*qua : price*qua;
    }
    for(itr = staff.begin(); itr != staff.end(); itr++){
      if(itr->second >= SALES_GOAL){
        data.push_back(itr->first);
        tof = 0;
      }
    }
    if(tof)data.push_back(0);
  }
  for(vc_it = data.begin(); vc_it != data.end(); vc_it++){
    if(*vc_it)cout << *vc_it << endl;
    else cout << "NA" << endl;
  }

}

C++: #include <iostream>
using namespace std;
int main(){
    long long bangou,tanka,kosuu;
    long long number; cin >> number;
    do{
        long long man[4000];
        for(int i=0;i<4000;i++){
            man[i]=0;
        }
        for(int i=0;i<number;i++){
            cin >> bangou >> tanka >> kosuu;
            man[bangou-1] += tanka*kosuu;
        }
        int count =0;
        for(int i=0;i<4000;i++){
            if(man[i]>=1000000){
                cout << i+1 << endl;
                count++;
            }
        }
        if(count==0)
            cout<< "NA" << endl;
        cin >> number;
    }while(number !=0);

}

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

using namespace std;

int main()
{
	
	while(1)
	{
		int sum = 0;
		int n;
		cin >> n;
		if(n == 0) break;
		
		queue<int> q;
		bool checked[4000];
		int list[4000];
		for(int i = 0;i < 4000;i++)
		{
			checked[i] = false;
			list[i] = 0;
		}
		for(int i = 0;i < n;i++)
		{
			int no, x, y;
			cin >> no >> x >> y;
			list[no] += x * y;
			if(!checked[no])
			{
				q.push(no);
				checked[no] = true;
			}
		}
		
		while(!q.empty())
		{
			int no = q.front();
			q.pop();
			if(list[no] >= 1000000)
			{
				cout << no << endl;
				sum++;
			}
		}
		if(sum == 0) cout << "NA" << endl;
	}
	return 0;
}

C++: #include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

int main(void){
	int N;
	int id,p,q;
	while(cin >> N){
		queue<int> que;
		map<int, int> map;
		int check = 0;
		if(!N) break;
		for(int i=0; i<N; ++i){
			cin >> id >> p >> q;
			if(map.find(id) == map.end()){
				map[id] = p*q;
				que.push(id);
			} else {
				map[id] += p*q;
			}
		}
		while(que.size()){
			if(map[que.front()] >= 1000000){
				cout << que.front() << endl;
				check = 1;
			}
			que.pop();
		}
		if(check == 0) cout << "NA" << endl;
	}

	return 0;
}