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 <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std ;

int member[4010][3] ;
int price[4010] ;
int idx[4010] ;

struct ANS{
	bool ans ;
	int num ;
}A[4010];

bool cmp ( int a , int b ) ;

int main ( )
{
	int n ; 
	bool na ;
	while ( scanf ( "%d" , &n ) == 1 && n ){
		na = false ;
		memset ( price , 0 , sizeof ( price ) ) ;
		for ( int i = 0 ; i < 4010 ; i++ ){
			A[i] . ans = false ;
			A[i] . num = 9999 ;
			idx[i] = i ;
		}
		for ( int i = 0 ; i < n ; i++ ){
			scanf ( "%d %d %d" , &member[i][0] , &member[i][1] , &member[i][2] ) ;
			int tmp = member[i][1] * member[i][2] ;
			price[member[i][0]] += tmp ;
			if ( price[member[i][0]] >= 1000000 ){
				A[member[i][0]] . ans = true ;
				na = true ;
			}
			A[member[i][0]] . num = ( A[member[i][0]].num == 9999 ) ? i : A[member[i][0]] . num ;
		}
		if ( ! na ){
			printf ( "NA\n" ) ;
		}
		else{
			sort ( idx , idx + 4010 , cmp ) ;
			for ( int i = 0 ; i < n - 1 ; i++ ){
				if ( A[idx[i]] . ans == true ){
					printf ( "%d\n" , idx[i] ) ;
				}
			}
		}
	}
	return 0 ;
} 

bool cmp ( int a , int b )
{
	return A[a] . num < A[b] . num ;
}

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

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;
        
        float ans[4001]={0};
        
        bool flag=true;
        for(int i=0; i<n; i++){
            cin>>a>>b>>c;
            
            ans[a]+=b*c;
        }
        
        for(int i=1; i<=4000; i++){
            if(ans[i]>=1000000){
                cout<<i<<endl;
                flag=false;
            }
        }
        
        if(flag)cout<<"NA"<<endl;
    }
            
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int nin;
  while(1){ 
    scanf("%d",&nin);
    if(!nin)break;

    long long int human[4002]={0};
    int no[4002],tanka,kazu,outflag=0;;
    
    for(int i=0;i<nin;i++){
      scanf("%d %d %d",&no[i],&tanka,&kazu);
      human[no[i]]+=tanka*kazu;
    }
    
    for(int i=0;i<nin;i++){
      if(human[no[i]]>=1000000 && human[no[i]]!=-1){
	printf("%d\n",no[i]);
	human[no[i]]=-1;
	outflag=1;
      }
    }
    
    if(outflag==0)printf("NA\n");
    
  }
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int n;
   while(cin>>n&&n)
   {
     map<int,long long int> mm;
     bool flag=false;
     for(int i=0;i<n;i++)
     {
       int id,p,q;
       cin>>id>>p>>q;
       mm[id]+=(p*q);        
     }           
     map<int,long long int>::iterator iter;
     for(iter=mm.begin();iter!=mm.end();++iter)
     {
       if((iter->second)>=1000000) cout<<(iter->first)<<endl;        
       flag=true;                                  
     }
     if(!flag) cout<<"NA"<<endl;
   }
   //while(1);
   return 0;
 }

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

typedef long long ll;
typedef queue<int> qi;

const int lim = 1000000;

int n; ll en, price, qty, check[4001]; qi que;

int main()
{
    while(cin >> n && n) {
       if (n == 0) break;
       
       for(int i=0; i < n; ++i) {
           cin >> en >> price >> qty;
           if (check[en] >= 0) check[en] += price*qty;
           if (check[en] >= lim) {
               que.push(en);
               check[en]=-1;
           }
       }
        
       if (que.empty()) cout << "NA" << "\n";
       else {
           for(int i=0,len=que.size(); i < len; ++i) {
               cout << que.front() << "\n";
               que.pop();
           }
       }
    }

    return 0;
}

C++: #include<iostream>

using namespace std;


int main(){

	long long all[4001] = {};
	long long code, a, b, n, i,j;

	while (1){
		j = 0;
		for (i = 0; i < 4001; i++){
			all[i] = 0;
		}

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

		for (i = 0; i < n; i++){
			cin >> code >> a >> b;
			all[code] += a*b;
			
		}

		for (i = 0; i < 4001; i++){
			if (all[i] >= 1000000){
				cout << i << endl;
				j++;
			}
		}

		if (j == 0){
			cout << "NA" << endl;
		}

	}
}

C++: #include <iostream>

int main()
{
    bool loop = true;

    while (loop) {
        int dataset_num;
        std::cin >> dataset_num;

        if (dataset_num == 0) {
            loop = false;
            break;
        }

        for (int i = 0; i < dataset_num; i++) {
            int officer_num;
            int price;
            int figure;

            std::cin >> officer_num;
            std::cin >> price;
            std::cin >> figure;

            if (price * figure >= 1000000) {
                std::cout << officer_num;
            }
        }
    }

    return 0;
}

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

using namespace std;

int main()
{
    int data_num;
    while (cin >> data_num && data_num != 0) {
        vector<int> idx;
        map<int, long long> sale;

        while (data_num--) {
            int no, price, num;
            cin >> no >> price >> num;

            long long sum = price * num;
            if (sale.find(no) == sale.end()) {
                idx.push_back(no);
                sale.insert(make_pair(no, sum));
            } else {
                sale.at(no) += sum;
            }
        }

        bool is_NA = true;
        for (size_t i = 0; i < idx.size(); i++) {
            if (sale.at(idx.at(i)) >= 1000000) {
                cout << idx.at(i) << endl;
                is_NA = false;
            }
        }

        if (is_NA) {
            cout << "NA" << endl;
        }
    }

    return 0;
}

C++: #include "stdio.h"
#include "string.h"
long long N[4001];
int f[4001];
int main(){
    int x,n,p,i,j,c=0;
    scanf("%d",&i);
    while(i!=0){
        c=0;
        for(j=0;j<i;j++){
            scanf("%d%d%d",&x,&n,&p);
            N[x]+=n*p;
                if(N[x]>=1000000){
                    f[c]=x;
                    c++;
                    N[x]=-10000000000000;
                }
            }
        }
        if(c==0)
            printf("NA\n");
        else 
            for(j=0;j<c;j++)printf("%d\n",f[j]);
        memset(N,0L,4001);
        memset(f,0,4001);
        scanf("%d",&i);
    }
    return 0;
}