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 <vector>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int n;
int main(){
	while((cin >> n) != 0){
		int num = 0;
		vector<pair<int, int> > pairs(n);

		for(int i = 0; i < n; i++){
			int p, q;
			cin >> pairs[i].first >> p >> q;
			pairs[i].second = p * q;
		}

		sort(pairs.begin(), pairs.end());

		int sum = 0;
		sum = pairs[0].second;
		for(int i = 1; i < n; i++){
			if(pairs[i].first == pairs[i-1].first){
				sum += pairs[i].second;
			}else{
				if(sum >= 1000000){
					cout << sum << "\n";
					num++;
				}
				sum = pairs[i].second;
			}
		}

		if(num == 0){
			cout << "NA\n";
		}
	}
	
    return 0;
}

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]=0,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      for(f=0;f<i;f++){
	if(data[0][f]==id){
	  data[1][f]+=a*b,f=-1;
	  break;
	}
      }
      if(f!=-1)data[0][i]=id;data[1][i]=a*b;
    }
    for(i=0,f=0;i<n;i++)
      if(data[1][i]>999999)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<"\n";
  }
}

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

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long> m;
		vector <string> data;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			if (!m[str]) data.push_back(str);
			m[str] += (num * a);
		}
		bool flag = true;
		for (int i = 0; i < data.size(); i++){
			if (1000000 <= m[data[i]]){
				cout << data[i] << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define ll long long

ll data[4010];
bool out[4010];

int main(){
  int i,j,k,n;
  int id;
  ll a, b;

  while(scanf("%d",&n)){
    if(n == 0) break;
    bool f = false;
    memset(out,true,sizeof(out));
    memset(data,0,sizeof(data));

    while(n--){
      scanf("%d %lld %lld",&id,&a,&b);
      data[id] += a * b;
      if(data[id] >= 1000000LL && out[id]){
        out[id] = false;
        printf("%d\n",id);
        f = true;
      }
    }
    if(f) puts("NA");
  }

  return 0;
}

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

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;
		int id, price, amount;
		vector<int> v;
		for(int i = 0; i < n; i++){
			cin >> id >> price >> amount;
			if(price * amount >= 10000){
				vector<int>::iterator itr = find(v.begin(), v.end(), id);
				if(itr == v.end()){
					v.push_back(id);
				}
			}
		}
		if(v.empty()){
			cout << "NA" << endl;
		}
		else{
			for(int i = 0; i < v.size(); i++){
				cout << v[i] << endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

typedef long long int lli;

lli employees[4001];
bool checked[4001];

signed main()
{
	lli n;
	while (cin >> n, n) {
		for (lli i = 1; i <= 4000; ++i) employees[i] = checked[i] = false;

		vector<lli> ans;

		for (lli i = 0; i < n; ++i) {
			lli num, a, b; cin >> num >> a >> b;

			if (checked[num]) continue;

			employees[num] += a * b;

			if (employees[num] >= 1000000) {
				ans.push_back(num);
				checked[num] = true;
			}
		}

		if (ans.empty()) cout << "NA" << endl;

        for (lli i = 0; i < ans.size(); ++i) {
            cout << ans[i] << endl;
        }
	}
}

C++: #include <cstdio>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;

int n;

int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		rep(i,n){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			if(it->second >= 1000000){
				ok = false;
				printf("%d\n", it->first);
			}
		}
		if(ok) printf("NA\n");
	}
}

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[10000000001]={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<=10000000000;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 <vector>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

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

            auto pre = find_if(
                vec.begin(), vec.end(),
                [&](const pair<int, long> &tar) { return tar.first == id; });
            if (pre != vec.end())
                pre->second += p * q;
            else
                vec.push_back(make_pair(id, p * q));
        }
        int count = 0;
        for (auto v : vec) {
            if (v.second >= 1000000) {
                cout << v.first << endl;
                count++;
            }
        }
        if (count == 0) cout << "NA" << endl;
        vec.clear();
    }
    return EXIT_SUCCESS;
}

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

int main(){
  const int Sale = 1000000;
  while(true){
    int n; //????????°
    int counter = 0;
    cin >> n;
    if(n == 0){
      break;
    }
    int id[n],sale[n],result[n];
    for(int i=0; i<n; i++){
      cin >> id[i] >>sale[i] >> result[i];
      if(sale[i]*result[i] >= Sale){
        cout << id[i] << endl;
        counter++;
      }
    }
    if(counter == 0){
        cout << "NA" << endl;
    }
  }
}