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 <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int n, bg, tn, su;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		map<int,int> sk;
		vector<int> jun;
		rep(i,n){
			cin >> bg >> tn >> su;
			sk[bg] += tn * su;
			bool adsw=true;
			rep(j,i) if(jun[j]==bg) adsw=false;
			if(adsw) jun.push_back(bg);
		}
		int cnt=0;
		rep(i,jun.size()){
			if(sk[jun[i]] >= 1000000){
				cout << jun[i] << endl;
				cnt++;
			}
		}	
		if(cnt==0) cout << "NA" << endl;
	}
	return 0;
	
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

long long int n,a,b,c;



int main(){
    
        
    while(cin >> n){
        if(n==0)break;
        
        long long int ans[4001]={0};
        int ans_n[4001]={0};
        
        bool flag=true;
        for(int i=0; i<n; i++){
            cin>>a>>b>>c;
            ans_n[i]=a;
            ans[a]+=b*c;
        }
        
        for(int i=0; i<n; i++){
            if(ans[ans_n[i]]>=1000000){
                cout<<ans_n[i]<<endl;
                ans[ans_n[i]]=0;
                flag=false;
            }
        }
        
        if(flag)cout<<"NA"<<endl;
    }
            
}

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

typedef struct{
	int sum;
	int pr;
} data;

int main(int argc, char **argv)
{
	int i, p, q, n, size = 0, flag, pri = 1, max;
	data *sarray = (data *)calloc(4000, sizeof(data));
	int *id = (int *)calloc(1000, sizeof(int));
	while(1){
		cin >> n;
		
		if(n == 0){
			cout << "NA" << endl;
			break;
		}
		
		while(n > 0){
			n--;
			cin >> i >> p >> q;
			flag = 0;
			for(int j = 0; j < size; j++){
				if(id[j] == i){
					if(p*q > sarray[i].sum || pri != sarray[i].pr){
						sarray[i].sum = p*q;
						sarray[i].pr = pri;
					}
					flag = 1;
					break;
				}
			}
		
			if(flag == 0){
				id[size] = i;
				sarray[i].sum = p*q;
				sarray[i].pr = pri;
				size++;
			}
		}

		max = id[0];
		for(int j = 1; j < size; j++){
			if(sarray[max].sum < sarray[id[j]].sum){
				max = id[j];
			}
		}
		
		cout << max << endl;
		
		pri++;
	}
	
	free(sarray);
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

int main(void){

	int n,number,money,sum;
	int data[4001]={0},dataF[4001]={0};
	queue<int> ok;

	while(1){

		for(int i=0;i<4000;i++) data[i]=0,dataF[i]=0;

		cin>>n;
		if(n==0) break;

		for(int i=0;i<n;i++){
			cin>>number>>money>>sum;
			data[number]+=money*sum;
			if(data[number]>=1000000&&dataF[number]==0){
				dataF[number]=1;
				ok.push(number);
			}
		}
		if(ok.empty()){
			cout<<"NA"<<endl;
		}
		else{
			while(!ok.empty()){
				cout<<ok.front()<<endl;
				ok.pop();
			}
		}
	}

	return 0;
}

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

using namespace std;

struct data{
  int id;
  int price;
  int amount;
  int rate;
};

int main(){
  int n=0;
  while(1){
    cin>>n;
    if(n==0){return 0;}
    vector<struct data> data(n);
    int c=0;
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&data[i].id,&data[i].price,&data[i].amount);
      data[i].rate=data[i].price*data[i].amount;
    }
    for(int i=0;i<n;i++){
      if(data[i].rate>=1000000){
	cout<<data[i].id<<"\n";
	c++;
      }
    }
    if(c==0){
      cout<<"NA\n";
    }
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n,ans[4000];
	double a,b;
	
	for(;;)
	{
		cin >> n;
		if(n==0)
			break;
		int i,j;
		for(i=0,j=0;i<n;i++)
		{
			int num,flag=1;
			cin >> num >> a >> b ;
			if(a/10000.0*b>=100.0)
			{
				for(int k=0;k<j;k++)
				{
					if(ans[k]==num)
						flag=0;
				}
				if(flag==1)
				{
					ans[j]=num;
					j++;
				}
			}
		}
		
		if(j!=0)
		{
			for(int i=0;i<j;i++)
			{
				cout << ans[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}

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

int main(){
    int n, a, b, c, d = 0, com[4001] = {};
    cin >> n;
    if(n != 0){
    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) continue;
       cout << com[j] << endl;
       d++;
      }    
    if(d == 0) cout << "NA" << endl;
     }
    return 0;
   }

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

using namespace std;

int main(){
  int n;
  
  while(true){
    cin >> n;
    if(n==0)
      break;
    map<int,int> isi;
    int i, p, q;
    for(int j=0; j<n; j++){
      cin >> i >> p >> q;
      if(isi.find(i)==isi.end())
	isi[i] = p*q;
      else
	isi[i] += p*q;
    }

    map<int,int>::iterator it;
    bool cc = true;
    for(it=isi.begin(); it!=isi.end(); ++it){
      if(it->second >= 1000000){
	cout << it->first << endl;
	cc = false;
      }
    }
    if(cc)
      cout << "NA\n";
    
  }
  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, int> 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, int>::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>
using namespace std;

int p[4001];
int result[1000000];

int main(){
	int i ,j=0 , n , id , price , num , cnt;
	while(cin>>n){
		cnt=0;
		memset(p,0 , sizeof(p)/sizeof(p[0]));
		if (n==0) break;
		for(i=0 ; i<4001 ; i++){
			p[i]=false;
		}
		for(i=0 ; i<n ; i++){
			cin >> id >> price >> num;
				p[id]+=price*num;
			}
		for(i=0 ; i<4001 ; i++){
			if(p[i]>=1000000){
				result[j++]=i;
				cnt++;
			}
		}
		if (cnt==0) {
				result[j++]=0;
			}
	}
	for(i=0;i<j;i++){
		if (result[i]==0) {
			cout << "NA" << endl;
		} else {
		cout << result[i] << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	long long i,n,value,count,number,f;
	while(cin >> n, n)
	{
		f=0;
		for(i = 0; i < n; i++)
		{
			cin >> number >> value >> count;
			if(value*count >= 1000000LL)
				cout << number << endl, ++f;
		}
		if(!f)
			cout << "NA" << endl;
	}
	return 0;
}