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<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;
}

C++: #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (n == 0) { break; }
		ll a[4001];
		rep(i, 4001) { a[i] = 0; }
		rep(i, n) {
			ll d, p, q;
			cin >>  d >> p >> q;
			if (a[d] < 1000000) {
				a[d] += p*q;
				if (p*q >= 1000000) {
					a[d] = 1000000;
				}
			}
		}
		bool flag = false;
		for (int i = 1; i < 4001; i++) {
			if (a[i] >= 1000000) {
				flag = true;
				cout << i << endl;
			}
		}
		if (!flag) { cout << "NA" << endl; }
	}
	return 0;
}

C++: #include <stdio.h>

int main(int argc, char *argv[]){
	int n, f;
	int ID, price, num;
	while(1){
		scanf("%d ", &n);
		if(!n) break;
		f=0;
		while(n--){
			scanf("%d %d %d ", &ID, &price, &num);
			if(1000000 <= price * num){
				printf("%d\n", ID);
				f = 1;
			}
		}
	}
	if(!f) printf("NA\n");
	return 0;
}

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

using namespace std;

int n;
long long id[4000];
long long value[4000];
long long number[4000];

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> id[i] >> value[i] >> number[i];
    }
    vector<long long> v;
    for(int i=0;i<n;i++){
        if(value[i]*number[i] >= 1000000 ){
            v.push_back(id[i]);
        }
    }
    if(v.empty()){
        cout << "NA" <<endl;
        return 0;
    }
    for (vector<long long>::iterator it=v.begin();it!=v.end();++it){
        cout << *it << endl;
    }
}