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 <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	int n;
	
	while(cin>>n,n!=0){
		int a,b,c;
		int f=0;
		int s[4001]={0};
		
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			s[a]+=b*c;
		}
		for(int i=0;i<4001;i++){
			if(s[i]>=1000000){
				cout<<i<<endl;
				f=1;
			}
			
		}
		if(f!=1)
			cout<<"NA"<<endl;
	
	}
	
}

C++: #include <stdio.h>
struct emp{
    int num,sale;
};
int main(){
    while(1){
        int n,num,p,q,count=0,c,flag1=0,flag2=0;
        struct emp e[4000];
        scanf("%d",&n);
        if(n==0) return 0;
        for(int i=0;i<n;i++){
            scanf("%d %d %d",&num,&p,&q);
            c=count;
            flag1=0;
            for(int j=0;j<count;j++){
                if(e[j].num==num) {
                    e[j].sale+=p*q;
                    flag1=1;
                    break;
                }
            }
            if(!flag1){
                e[count].num=num;
                e[count].sale=p*q;
                count++;
            }
        }
        for (int i=0; i<count; i++){
            if (e[i].sale>=1000000) {
                printf("%d\n",e[i].num);
                flag2=1;
            }
        }
        if(!flag2) printf("NA\n");
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;
	while( cin >> n, n ){
		long long emp[4001];
		vector<int> nums;
		bool exist = false;
		memset( emp, 0, sizeof(emp) );
		rep(i,n){
			int num;
			long long val, am;
			cin >> num >> val >> am;
			emp[num] += val*am;
			if( find(nums.begin(), nums.end(), num) == nums.end() ){
				nums.push_back(num);
			}
		}
		rep(i,nums.size()){
			if( emp[nums[i]] >= 1000000 ){
				exist = true;
				cout << nums[i] << endl;
			}
		}
		if(!exist){
			cout << "NA" << endl;
		}

	}
	return 0;
}

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, int> saleResult;
	int n;
	int staffNum;
	int unitPrice;
	int quantity;
	while( 1 )
	{
		n = in();
		if( n == 0 )break;

		staffList.clear();
		saleResult.clear();
		loop(i, 0, n)
		{
			staffNum = in();
			unitPrice = in();
			quantity = in();
			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>
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 < n; i++) {
			cin >> e >> p >> q;

			if (number[e - 1] <= 1000000) {
				number[e - 1] += p*q;
			}
		}

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

C++: #include<iostream>
#include<cstdio>
using namespace std;
typedef struct result{
  int nam;
  int mon;
  int cont;
  int sum;
}P;
int main(){
  P a[4000];
  int n,nacount;
  while(1){
    cin >> n;
    nacount=0;
    if(n==0){break;}
    for(int i=0;i<n;i++){
      cin>>a[i].nam>>a[i].mon>>a[i].cont;
      a[i].sum=a[i].mon*a[i].cont;
    }
    for(int i=0;i<n;i++){
      for(int j=n-1;j>i;j--){
	if(a[i].nam==a[j].nam){
	  a[i].sum+=a[j].sum;
	  a[j].sum=0;
	}
      }
    }
    for(int i=0;i<n;i++){
      if(a[i].sum>=1000000){
	cout<<a[i].nam<<endl;
	nacount++;
      }
    }if(nacount==0){
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

#define TAR 1000000

int main() {
	unsigned long n,num,t,k,ch;
	while(cin >> n){
		ch = 0;
		while(n){
			scanf("%ld %ld %ld",&num,&t,&k);
			if((t!=0)&&(k!=0)){
				if((k >= TAR/t)&&(TAR%t == 0)){
					cout << num << endl;
					ch++;
				}else if((t >= TAR/k)&&(TAR%k == 0)){
					cout << num << endl;
					ch++;
				}else if((k > TAR/t)&&(t > TAR/k)){
					cout << num << endl;
					ch++;
				}
				if(((--n)==0)&&(ch==0)){
					cout << "NA" << endl;
				}
			}
		}
	}
	return 0;
}

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

using namespace std;

int main(void) {
	int n;
	while(1) {
		bool isOK = false;
		map<int, long long> MP;
		
		cin >> n;
		
		if(n == 0) { break; }
		
		for(int i = 0; i < n; i++) {
			int n, p, c;
			cin >> n >> p >> c;
			MP[n] += p * c;
		}
		for(map<int, long long>::iterator it = MP.begin(); it != MP.end(); it++) {
			if(it->second >= 1000000) {
				cout << it->first << endl;
				isOK = true;
			}
		}
		if(isOK == false) {
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;


ll n;

int main(){
	while(cin>>n,n!=0){
		ll id[4005]={0};
		int a[8000]={0};
		
		int cou;
		rep(i,n){
			ll t1,t2,t3;
			cin>>t1>>t2>>t3;
			a[i]=t1;
			//if(id[t1]>0){
				id[t1]+=t2*t3;
			//}
			/*
			else{
				id[t1]=t2*t3;
			}
			*/
			cou=i;
		}
		bool f=true;
		rep(i,cou+100){
			if(id[a[i]]>=1000000){
				cout<<a[i]<<endl;
				id[a[i]]=0;
				f=false;
			}
		}
		if(f) cout<<"NA"<<endl;
	}
	return 0;
}

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

int main(){
	int n,number;
	long long a,b;
	bool flag;
	map<int,long long> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number); // ??¢????????£????????¨???????¨???????????????\??????????????????0?????±?????????????????????????????????
			info[number] += a*b;
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}