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<cmath>
#include<algorithm>
#include<string>
using namespace std;

int n,num,flag;
long int shine[4000],tannka,kosu;

int main(){
	while(1){
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>num>>tannka>>kosu;
			shine[num]+=tannka*kosu;
			if(shine[num]>=1000000){
				cout<<num<<endl;
				flag++;
			}
		}
		if(flag==0){cout<<"NA"<<endl;}
		else{flag=0;}
		for(int i=0;i<4000;i++){
			shine[i]=0;
		}
	}
	
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf_s("%d", &data);
		if (data == 0)break;
		vector<pair<int,int>> company;
		pair<int, int> sells;
		bool hero = false;
		int num, sell, cnt;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			bool search = false;
			for (int j = 0; j < company.size(); j++)
			{
				if (company[j].first == num){
					search = true;
					company[j].second += sell*cnt;
					break;
				}
			}
			if (search == false)
			{
				sells.first = num;
				sells.second = sell*cnt;
				company.push_back(sells);
			}
		}
		for (int i = 0; i < company.size(); i++)
		{
			if (company[i].second >= target)
			{
				hero = true;
				printf("%d\n", company[i].first);
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

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

int main() {
	long long e, p, q;
	int n;
	while (cin >> n, n) {
		long long number[4001];
		for (int i = 0; i < 4001; i++) {
			number[i] = 0;
		}

		for (int i = 0; i < n; i++) {
			cin >> e >> p >> q;
			number[e] += p*q;
		}

		int x = 0;
		for (int i = 1; i < 4001; i++) {
			if (number[i] >= 1000000) {
				cout << i << endl;
				x++;
			}
		}
		if (x == 0) { cout << "NA" << endl; }
	}
	return 0;
}

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

int main(){

	int N,Q;
	while(1){
	cin>>N;if(N==0)break;
	long long int n[4001][2]={};
	for(int i=0;i<N;i++){
		int x,y,z;
		cin>>x>>y>>z;
		n[x][0]+=y*z;
		if(n[x][1]==0)n[x][1]=i;
	
	}
	for(int i=0;i<4001;i++){
		for(int j=i;j>i;j--){
			if(n[j][1]<n[j-1][1]){
				int t=n[j][0];n[j-1][0];n[j-1][0]=t;
				int T=n[j][1];n[j-1][1];n[j-1][1]=T;
			}
		}
	}
	bool f=false;
	for(int i=0;i<4001;i++){
		if(n[i][0]>=1000000){cout<<i<<endl;f=true;}
	}
	if(f==false)cout<<"NA"<<endl;

	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
int main() {
	int n;
	std::cin >> n;
	int x = 0;
	std::vector<int> A;
	while (n != 0) {
		int z = 0;
		++x;
		std::vector<int> m(n);
		std::vector<std::vector<int>> V(n, std::vector<int>(3));
		for (int i = 0;i < n;++i) {
			for (int j = 0;j < 3;++j) {
				std::cin >> V[i][j];
			}
		}
		for (int i = 0;i < n;++i) {
			m[i] = V[i][1] * V[i][2];
		}
		for (int i = 0;i < n;i++) {
			for (int j = 0;j < n;++j) {
				if (i < j) {
					if (V[i][0] == V[j][0]) {
						m[i] += m[j];
						m[j] = 0;
					}
				}
			}
		}
		for (int i = 0;i < n;++i) {
			if (m[i] >= 1000000) {
				A.push_back(V[i][0]);
				z = 1;
			}
		}
		if (z == 0) {
			A.push_back(0);
		}
		std::cin >> n;
	}
	for (int i = 0;A.size()>i;++i) {
		if (A[i] == 0) 
			std::cout << "NA" << std::endl;
		else 
			std::cout << A[i] << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,num,mon,cont,a[4000],nacount;
  while(scanf("%d",&n)!=EOF){
    if(n==0){break;}
    for(int i=0;i<4000;i++){
      a[i]=0;
    }
    nacount=0;
    for(int i=0;i<n;i++){
      cin>>num>>mon>>cont;
      a[num]+=mon*cont;
    }
    for(int i=0;i<4000;i++){
      if(a[i]>=1000000){
	cout<<i<<endl;
	nacount++;
      }
    }if(nacount==0){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        long long S[4000]={0};
        while(n--){
            int n,m,o;
            cin>>n>>m>>o;
            S[n-1]+=m*o;
        }
        bool F=false;
        for(int i=0;i<4000;i++)
            if(S[i]>=1000000){
                cout<<i+1<<endl;
                F=true;
            }

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

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("lld", &x); return (x); }

int main()
{
	list<int> staffList;
	map<int, lint> saleResult;
	int n;
	int staffNum;
	lint unitPrice;
	lint quantity;
	while( 1 )
	{
		n = in();
		if( n == 0 )break;

		staffList.clear();
		saleResult.clear();
		loop(i, 0, n)
		{
			staffNum = in();
			unitPrice = lin();
			quantity = lin();
			staffList.push_back(staffNum);
			saleResult[staffNum] += unitPrice * quantity;
		}
		bool flag = false;
		for(list<int>::iterator it = staffList.begin(); it != staffList.end(); it++)
		{
			if( saleResult[*it] >= 1000000 )
			{
				printf("%d\n", *it);
				saleResult[*it] = 0;
				flag = true;
			}
		}
		if( !flag )
		{
			cout << "NA" << endl;
		}
	}
	return (0);
}

C++: 
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()


int main(void){
  int n;
  while(cin>>n,n){
    vector<pair<int , long long > > sales;
    while(n--){
      int id,code,num;
      cin>>id>>code>>num;
      int i = 0 ;
      for(; i < sales.size();i++){
	if(sales.at(i).first==id){
	  sales.at(i).second += (long long) code * num;
	  break;
	}
      }
      if(i == sales.size()){
	pair<int , long long> worker;
	worker.first = id;
	worker.second = (long long)code * num;
	sales.push_back(worker);
      }
      
    }
    bool found = false;
    rep(i,sales.size()){
      if(sales.at(i).second >= 1000000){
	found = true;
	cout << sales.at(i).first << endl;
      }
    }
    if(!found)
      cout << "NA" << endl;
    
  }
}

C++: #include <iostream>
#include <map>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

string int_to_str(int n) {
	stringstream ss;
	string ret;

	ss << n;
	ss >> ret;

	return ret;
}


int keta(int n) {
	string str = int_to_str(n);

	return str.size();
}

int main() {
	int n;
	while (cin >> n, n) {
		bool f = false;
		map<int, ll> datas;
		vector<int> noes;
		for (int i = 0; i < n; ++i) {
			int no, a, b; cin >> no >> a >> b;

			if ( find( noes.begin(), noes.end(), no) == noes.end() )
				noes.push_back(no);

			if (datas[no] < 1000000) {
				if (keta(a) + keta(b) - 2 >= 6) {
					cout << no << endl;
					datas[no] = 1000000;
					f = true;
				}

				else if ((datas[no] += a * b) >= 1000000) {
					cout << no << endl;
					f = true;
				}
			}
		}

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