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 rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,c;
  while(cin>>n,n){
    int a[10000]={0},c=0,b[n],p,o,u;
    rep(i,n){
      cin>>p>>o>>u;
      a[p]+=o*u;
    }
    rep(i,4001){
      if(a[i]>=1000000){cout<<i<<endl;c++;}
    }
    if(!c)cout<<"NA"<<endl;
  }
}

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

int main(){
    int n;
    while( cin >> n, n ){
        vector< int > ls(4001, 0);
        bool NA = true;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            if( ls[a] >= 0 ){
                ls[a] += b*c;
                if( ls[a] >= 1000000){
                    cout << a << endl;
                    NA = false;
                    ls[a] = -1;
                }
            }
        }
        if( NA ) cout << "NA" << endl;
    }
    return 0;
}

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

typedef unsigned long long int ull;

map<int,ull> mp;

int main() {
  int n;
  
  while(cin>>n, n) {
    mp.clear();
    
    for(int i=0; i<n; i++) {
      int a;
      ull b, c;
      cin >> a >> b >> c;
      mp[a] += b * c;
    }
    bool isExist = false;
    for(map<int, ull>::iterator it = mp.begin(); it!=mp.end(); it++) {
      if( it->second >= 1000000 ) {
	isExist = true;
	cout << it->first << endl;
      }
    }
    if( !isExist ) cout << "NA" << endl;
  }
  
  return 0;
}

C++: #include <stdio.h>

int main()
{
	int n;

	while (1) {
		int x = 0, emp[4000] = {};

		scanf("%d", &n);
		if(n == 0) break;

		for (int i = 0; i < n; i++) {
			int e, p, q;
			scanf("%d %d %d", &e, &p, &q);

			emp[e] += p*q;

			if(emp[e] >= 1000000) {printf("%d\n", e); x = 1;}
		}

		if (x != 1) printf("NA\n");
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    vector<ll> v(4005,0);
    vi e(n);
    rep(i,n){
      ll p,q;
      cin>>e[i]>>p>>q;
      v[e[i]]+=p*q;
    }
    vector<bool> used(4005,true);
    rep(i,n)
      if(v[e[i]]>=1000000 && used[e[i]]){
        cout<<e[i]<<endl;
        used[e[i]]=false;
        used[0]=false;
      }
    if(used[0])cout<<"NA"<<endl;
  }
}

C++: #include<stdio.h>

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

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];PT[c][2]=i;c++;}

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

for(int i=0;i<c;i++)
printf("%ld\n",PT[i][2]);
if(c==0)printf("NA\n");
for(int i=0;i<=4000;i++)
{P[i][0]=0;P[i][1]=0;P[i][2]=0;
 PT[i][0]=0;PT[i][1]=0;PT[i][2]=0;PT[i][3]=0;}

}
return  0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  while(1){
    int n;
    bool f = true;
    cin >> n;
    if(!n) break;
    for(int i = 0; i < n; i++){
      int a,b,c;
      cin >> a >> b>> c;
      if(1000000 <= b*c){
	cout << a << endl;
	f = false;
      }
    }
    if(f) puts("NA");
  }
}

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

using namespace std;

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

    vector<pair<int,int>> data;
    vector<int> nanum;
    for(int i = 0;i < n;++i){
      int num,sa,ko;
      cin>>num;
      cin>>sa;
      cin>>ko;

      int sum = sa * ko;

      if(i == 0){
        nanum.push_back(num);
        data.push_back(make_pair(num,sum));
      }
      else{
        auto a = find(nanum.begin(),nanum.end(),num);
        size_t index = distance(nanum.begin(),a);
        if(index != nanum.size()){
          continue;
        }
        else{
          nanum.push_back(num);
          data.push_back(make_pair(num,sum));
        }
      }
    }

    int check = 0;
    for(pair<int,int> e : data){
      if(e.second >= 1000000){
        check = 1;
        cout<<e.first<<endl;
      }
    }
    if(check == 0){
      cout<<"NA"<<endl;
    }
  }

  return 0;
}

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

int main(){
    int n, a, b, c, d = 0, com[4001] = {};
    cin >> n;
    if(n == 0) goto perm;
    for(int i = 0;i < n;i++){
       cin >> a >> b >> c;
       com[a] += b * c;
      }
    for(int j = 1;j < 4001;j++){
       if(com[j] >= 1000000){
       cout << com[j] << endl;
       d++;
       }  
      }    
    if(d == 0) cout << "NA" << endl;
    perm:
    return 0;
   }

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

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

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

    }

    return 0;
}

C++: #include<cstdio>

using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			int num, sell, cnt;
			scanf("%d %d %d", num, sell, cnt);
			if (sell*cnt >= target)
			{
				printf("%d\n", num);
				hero = true;
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}