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>
using namespace std;

int main(){
 int id,price,num,count;
 int sameid[4000];
 bool isBe=false,isSame=false;
 while(true){
  cin>>count;
  if(count==0){
   break;
  }
  for(int i=0;i<count;i++){
   cin>>id>>price>>num;
   sameid[i]=id;
   for(int j=0;j<i;j++){
    if(id==sameid[j]){
      isSame=true;
      break;
    }
   }
   if(price*num>=100000&&!isSame){
    cout<<id<<'\n';
    isBe=true;
   }
   isSame=false;
  }
  if(!isBe){
   cout<<"NA\n";
  }
  count=0;
  isBe=false;
  for(int i=0;i<count;i++){
   sameid[i]=0;
  }
 }
 return 0;
}

C++: #include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	int n, id, value, num, buf[4000], bufnum, i, j;
	long long int yen[4000];
	bool f;
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		memset(yen,0ll,sizeof(yen));
		bufnum = 0;
		for(i = 0;i < n;i++){
			scanf("%d%d%d",&id,&value,&num);
			for(j = 0;j < bufnum;j++){
				if(buf[j] == id){
					break;
				}
			}
			if(j == bufnum){
				buf[bufnum++] = id;
			}
			yen[id - 1] += (long long int)value * num;
		}
		f = true;
		for(i = 0;i < bufnum;i++){
			if(yen[buf[i] - 1] >= 1000000ll){
				printf("%d\n",buf[i]);
				f = false;
			}
		}
		if(f){
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int data[2][4000],n,i,f,id;
  long long a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0;i<4000;i++) data[0][i]=-1,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      if(a*b>999999) a=1000000,b=1;
      for(f=0;f<i+1;f++){
	if(data[0][f]==id){
	  data[1][f]+=(a*b);
	  break;
	}else if(data[0][f]==-1){
	  data[0][f]=id;
	  data[1][f]=(a*b);
	  break;
	}
      }
    }
    for(i=0,f=0;i<n;i++)
      if(data[1][i]>=1000000)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<endl;
  }
}

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

int main(){
    int n;

    while(cin>>n,n){
        int id;
        ll p,q;
        vector<pair<int,ll>> v;

        for(int i=0;i<n;i++){
            cin >> id >> p >> q;

            for( auto &t:v ){
                if( t.first==id ){
                    t.second += p*q;
                    id=-1;
                    break;
                }
            }

            if(id!=-1){
                v.push_back(make_pair(id,p*q));
            }
        }

        bool flag=false;
        for( auto t:v ){
            if( t.second>=1000000 ){
                cout<<t.first<<endl;
                flag=true;
            }
        }

        if(!flag) cout<<"NA"<<endl;
    }

    return 0;
}

C++: #include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

int main(){
    int e, p, q;
    while(cin >> n, n != 0) {
        ll m[4001] = {};
        int a[1000] = {};
        REP(i, n){
            cin >> e >> p >> q;
            m[e] += p * q;
            a[i] = e;
        }
        bool f = true;
        REP(i, n){
            if(m[a[i]] >= 1000000){
                cout << a[i] << '\n';
                m[a[i]] = 0;
                f = false;
            }
        }
        if(f) cout << "NA\n";
    }
    return 0;
}

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

using namespace std;

// 連想配列に売り上げを記録していく。同じ社員が複数のデータを持つこともあるので加算。
// 1000000以上の場合に社員番号を出力する。
// 該当する社員0人の場合はNAを出力する。

int main() {

	int N;
	cin >> N;

	map<int, int> data;

	for (int i = 0; i < N; ++i) {
		int number, price, sales;
		cin >> number >> price >> sales;
		data[number] += price * sales;
	}
	int cnt = 0;
	for (const auto a : data) {
		if (a.second >= 1000000) {
			++cnt;
			cout << a.first << endl;
		}
	}
	if (0 == cnt) {
		cout << "NA" << endl;
	}

	return 0;
}

C++: #include<stdio.h>
int main(void){
    int n,i,j,k=0,l=0,x[4001],y,z;
    int a[4001]={0};
    long long b[4001]={0};
    int c[4001]={0};
    int flag[4001]={0};
    for(;;){
        k=0;
        for(j=0;j<n;j++){
            a[j]=0;
            b[j]=0;
            flag[j]=0;
            x[j]=0;
            c[j]=0;
            }
        scanf("%d",&n);
        if(n==0)break;
        for(i=0;i<n;i++){
            scanf("%d%d%d",&x[i],&y,&z);
            if(flag[i]==1);
            else {
                if(a[i]!=0)b[i]=b[i]+y*z;
                else {
                    a[i] = x[i];
                    b[i] = y*z;
                }
            }
            if(b[i]>=1000000){
                c[k]=a[i];
                flag[i]++;
                k++;
            }

        }
        if(k==0)printf("NA\n");
        for(l==0;l<n;l++){
            if(c[l]!=0){
                printf("%d\n",c[l]);
            }
        }
    }
return 0;
}

C++: #include <cstring>
#include <iostream>
using namespace std;
int main() {
  bool f;
  long long int n, a, b, c, d[4001], i;
  while (cin >> n && n > 0) {
    memset(d, 0, sizeof(d));
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      d[a] += b * c;
    }
    for (i = 1, f = 0; i <= 4000; i++) {
      if (d[i] >= 1000000) {
        cout << i << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	string str = "";

	while (getline (cin, str ) ){
		int n;
		stringstream ssn(str);
		ssn >> n;
		
		if (n == 0){
			break;
		} // end if

		map<int, long long> res;
		int i;

		for (i = 0; i < n; ++i){
			getline (cin, str );
			int id, p, q;
			stringstream ss(str);

			ss >> id >> p >> q;
			long long sum = (long long)(p*q);
			res[id] += sum;
		} // end loop

		map<int, long long>::iterator it = res.begin();
		map<int, long long > R;

		for (; it != res.end(); ++it){
			int id = (*it).first;
			long long sum = (*it).second;

			if (sum >= 1000000LL ){
				R[id] = sum;
			} // end if
		} // end for

		if (R.empty() ){
			cout << "NA" << endl;
		}else{
			map<int, long long>::iterator itr = R.begin();
			for (; itr != R.end(); ++itr ){
				cout << (*itr).first << endl;
			} // end for
		} // end if
	} // end while
		
	return 0;
}