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 <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<int> data(4000);
	int i;
	int a,b,c;
	int max;
	bool check;

	cin >> i;
	while(i){
		data.clear();

		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 k = 0;k < 4000;k++){
			if(data[k] >= 1000000){
				printf("%d\n",k+1);
				check = true;
			}
		}
		if(!check) printf("NA\n");
		cin >> i;
	}

	return 0;
}

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

int main() {
  int n,ID,price,quantity,sales[4001] = {0},check,k,kaburi,rep[4001];
  while(cin >> n) {
    int sales[4001] = {0};
    if(n == 0) break;
    check = 0;k=0;
    for(int i=0;i<n;i++) {
      cin >> ID >> price >> quantity;
      //      cout << ID << " " << price << " " << quantity << endl;
      sales[ID] += price * quantity;
      kaburi = 0;
      for(int j=0;j<k;j++) {
        if(rep[j] == ID) {
          kaburi = 1;
        }
      }
      if((sales[ID] >= 1000000) && (kaburi == 0)){
        cout << ID << endl;
        check = 1;
        rep[k] = ID;
        k++;
      }
    }
    if(check == 0)
      cout << "NA" << endl;
  }
}

C++: #include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
using namespace std;
void shoki();
void henkan(string);
int tansaku(int);
pair<string,long long> num[4001];
int n,ban,tanka,kazu,i,j,memo;
bool dp[4001]={false};
int main(){
	int al=0;
	bool y=false;
	while(1){
		shoki();
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>num[i].first>>tanka>>kazu;
			henkan(num[i].first);
			if(dp[memo]==true){
				num[tansaku(i)].second+=tanka*kazu;
			}
			else{
			num[i].second+=tanka*kazu;
			}
			dp[memo]=true;
			memo=0;
		}
		for(int k=0;k<=i;k++){
			if(num[k].second==0){
				continue;
			}
			if(num[k].second>=1000000){
				y=true;
				cout<<num[k].first<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
		memset(dp,false,sizeof(dp));
	}
	return 0;
}
void shoki(){
	for(int i=0;i<4001;i++){
		num[i].first="0";
		num[i].second=0;
	}
	return;
}
void henkan(string str1){
	long long kake=1;
	for(int i=0;i<str1.size();i++){
		memo+=str1[i]*i;
		i*=10;
	}
	return;
}
int tansaku(int rec){
	int res;
	for(int l=0;l<rec;l++){
		if(num[rec].first==num[l].first){
			return res=l;
		}
	}
}

C++: /* -- 0100:Sale Result -- */
#include	<iostream>
#include	<map>

using namespace std;

typedef unsigned __int64 ull;

int main(void) {
	int n, buf_n, buf_c, buf_p;
	bool flag;
	ull buf_t;
	map<int, ull> List;

	while(1) {
		cin >> n;
		if(n == 0) { break; }

		flag = true;
		List.clear();
		for(int i=0; i<n; i++) {
			cin >> buf_n >> buf_p >> buf_c;
			buf_t = buf_p * buf_c;
			if(List.find(buf_n) == List.end()) {
				List[buf_n] = buf_t;
			} else {
				List[buf_n] += buf_t;
			}
		}
		map<int, ull>::iterator it = List.begin();
		while( it != List.end() ) {
			if(it->second >= 1000000) { flag = false; cout << it->first << endl; }
			it++;
		}
		if(flag) { cout << "NA" << endl; }
	}
	return 0;
}

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

int main() {
	long long int i, j, n, no[4000], tanka[4000], num[4000];
	bool flg=false;
	while (1) {
		j=0;
		flg=false;
		cin>>n;
		if (n==0) break;
		for (i=0; i<n; i++)
			cin>>no[i]>>tanka[i]>>num[i];
		for (i=0; i<n; i++) {
			if (tanka[i]*num[i]>=1000000)
				flg=true, cout<<no[i]<<endl;
		}
		if (flg==false) cout<<"NA"<<endl;
	}
	return 0;
}

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

typedef long long Int;

int main(){
	const int AIM = 1000000;
	int n;
	int num, per, sum;
	bool exist;
	
	while(true){
		scanf("%d", &n);
		if(n == 0) break;
		exist = false;
		for(int i = 0; i < n; i++){
			scanf("%d%d%d", &num, &per, &sum);
			if((Int)per * sum >= AIM){
				exist = true;
				printf("%d\n", num);
			}
		}
		if(!exist) printf("NA\n");
	}
	
	return 0;
}

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

int main()
{
	int n;

	while (cin >> n, n){
		long long e[5000] = {0}, p, q, a;
		bool out = false;
		for (int i = 0; i < n; i++){
			cin >> a >> p >> q;
			e[a] += p * q;
		}
		for (int i = 1; i <= 4000; i++){
			if (e[i] >= 1000000){
			 cout << i << endl;
			 out = true;
			}
		}
		if (out == false) cout << "NA" << endl;
	}
	return (0);
}

C++: #include<stdio.h>

int main(void){
	int x,n,a,b,i,nan,k;
	while(0==0){
		scanf("%d",&n);
		if(n==0)break;
		k=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&nan,&a,&b);
			if(a*b>999999){
				printf("%d\n",nan);
				k++;
			}
		}
		if(k==0) printf("NA\n");
	}
	return 0;
}

C++: #include <stdio.h>
#include <string.h>

int main(void) {
int n;
int employees[4000] = {0};
while (1) {
scanf("%d", &n);
if (!n) break;

for (int i = 0; i < n; i++) {
int id, price, sales;
scanf("%d %d %d\n", &id, &price, &sales);
employees[id] += price * sales;
}

int found = 0;
for (int i = 0; i < n; i++) {
if (employees[i] >= 1000000) {
printf("%d\n", i);
found = 1;
}
}
memset(employees, 0, sizeof employees);
if (!found) {
printf("NA\n");
}

}
}

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

int main(){
    int n;
    long int array[n][3];
    int count=0;

    cin>>n;
    if(n==0) goto Exit;

    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }
    
    for(int i=0;i<n-1;i++){
        for(int j=1;i+j<n;j++){
            if(array[i][0]==array[i+j][0]){
                array[i][1]+=array[i+j][1];
                array[i][2]+=array[i+j][2];
                array[i+j][1]=0;
            }
        }
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]>=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }

    Exit:
    ;

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

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

int main(){
	int n;

	while(true){
		int user[4000];
		int usercount = 0;
		
		cin >> n;
		if(n == 0){
			break;
		}

		long long int buf[3];
		for(int i=0;i<n;i++){
			cin >> buf[0] >> buf[1] >> buf[2];
			long long int a = buf[1] * buf[2];
			bool flag = true;
			for(int i=0;i<usercount;i++){
				if(buf[0] == user[i]){
					flag = false;
				}
			}
			if(a >= 1000000 && flag){
				user[usercount] = buf[0];
				usercount++;
			}
		}

		for(int i=0;i<usercount;i++){
			cout << user[i] << endl;
		}
		if(usercount == 0){
			cout << "NA" << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	ll n;
	while (cin >> n, n) {
		map<ll, ll>mp;
		vector<ll>v;
		rep(i, n) {
			ll e, p, q; cin >> e >> p >> q;
			mp[e] += p*q;
			if (!binary_search(v.begin(), v.end(), e))
				v.push_back(e);
		}
		bool flag = false;
		for (ll i : v) {
			if (mp[i] >= 1000000) {
				cout << i << endl;
				flag = true;
			}
		}
		if (!flag)puts("NA");
	}
}