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<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
   	int n;
    
    int number, perPrice, amount;
    
    bool isUsed;
    //long long valueCheck[4000];
    vector<long long> valueCheck(4000, 0);
    queue<int> que;
    
    while(true)
    {
        isUsed = false;
        
        cin>>n;
        
        if (n == 0)
        {
            break;
        }
        
        while(n--)
        {
            cin>>number>>perPrice>>amount;
            
            valueCheck[number] += perPrice * amount;
            que.push(number);
        }
        
        while (!que.empty()) //if empty return true
        {
            if (valueCheck[que.front()] >= 1000000) //check the first element
            {
                cout<<que.front()<<endl;
                
                isUsed = true;
            }
            
            valueCheck[que.front()] = 0;
            
            que.pop(); //delete the beginning element, do the next judgement
        }
        
        if (!isUsed)
        {
            cout<<"NA"<<endl;
        }
        
    }
}

int main()
{
    Solution();
    return 0;
}

C++: #include <stdio.h>
 
int n,num[4000];
long long int tanka[4000],sale_num[4000],sale_all[4001];
bool judge[4001];
 
int main(void)
{
int i,j,k;
     
while(scanf("%d",&n),n){
    for(i=0;i<n;i++){
        scanf("%lld %lld %lld",&num[i],&tanka[i],&sale_num[i]);
    }
    k=0;
    for(j=0;j<4001;j++){
    judge[j]=0;
    sale_all[i]=0;
    }
    for(i=0;i<n;i++){
        sale_all[num[i]] += tanka[i]*sale_num[i];
    }
    for(i=0; i < n; i++){
        if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
            printf("%d\n",num[i]);
            judge[num[i]]=1;
            k=1;
        }
    }
    if(k!=1)printf("NA\n");
}
 
    return 0;
}

C++: #include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    map<int,long long> emps;
    vector<int> ids;
    bool exist=false;
    int id,cost,amount,n;
    while(cin >> n,n){
        for(int i=0;i<n;i++){
            cin >> id >> cost >> amount;
            if(emps.find(id)!=emps.end()){
                emps[id]+=cost*amount;
            }else{
                emps[id]=cost*amount;
                ids.push_back(id);
            }
        }
        for(int i=0;i<ids.size();i++){
            if(emps.at(ids[i])>=1000000){
                cout << ids[i] << endl;
                exist=true;
            }
        }
        if(exist) cout << "NA" << endl;

    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
  int n,val,num,inindex;
  vector<int> Index;
  map<int,ll> List;
  while(true){
    scanf("%d",&n);
    if(n == 0)break;
    List.clear();
    Index.clear();
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&inindex,&val,&num);
      if(!List[inindex]){
	Index.push_back(inindex);
      }
      List[inindex]+=val*num;
    }
    bool NAf=true;
    for(int i=0;i<Index.size();i++){
      if(List[Index[i]] >= 1000000){
	printf("%d\n",Index[i]);
	NAf=false;
      }
    }
    if(NAf)printf("NA\n");
  }

  return 0;
}

C++: #include <stdio.h>
  
int n,num[4000];
long long int tanka[4000],sale_num[4000],sale_all[4001];
short judge[4001];
  
int main(void){
	int i,j,k;
	
	while(scanf("%d",&n),n){
		for(i=0;i<n;i++){
			scanf("%d %lld %lld",&num[i],&tanka[i],&sale_num[i]);
		}
		k=0;
		for(j=0;j<4001;j++){
			judge[j]=0;
			sale_all[i]=0;
		}
		for(i=0;i<n;i++){
			sale_all[num[i]] += tanka[i]*sale_num[i];
		}
		for(i=0; i < n; i++){
			if((sale_all[num[i]] >= 1000000)&&(judge[num[i]]==0)){
				printf("%d\n",num[i]);
				judge[num[i]]=1;
				k=1;
			}
		}
		if(k!=1)printf("NA\n");
	}

    return 0;
}

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

int main(void)
{
	int n, num;
	string str;
	long a;
	
	while (cin >> n, n){
		map <string, long> m;
		for (int i = 0; i < n; i++){
			cin >> str >> num >> a;
			m[str] += (num * a);
		}
		map <string, long> ::iterator it;
		bool flag = true;
		/*
		for (it = m.begin(); it != m.end(); it++){
			cout << it->first << " -- " << it->second << endl;
		}*/
		
		for (it = m.begin(); it != m.end(); it++){
			if (1000000 <= it->second){
				cout << it->first << endl;
				flag = false;
			}
		}
		if (flag) cout << "NA" << endl;
	}
	
	return 0;
}

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

int main(){
	int n;
	while(cin>>n,n){
		long long number[4000]={};
		for(int i=0;i<n;i++){
		int e,p,q;
		cin>>e>>p>>q;
		number[e-1]+=p*q;
			}
		vector<int>v;
		for(int i=0;i<4000;i++){
			if(number[i]>=1000000){
				v.push_back(i+1);
				}
			}
			
		if(v.empty()){cout<<"NA"<<endl;}
		else{
			for(int i=0;i<v.size();i++){
				cout<<v[i]<<endl;
				}
			}		
		
		}
		return 0;
	}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n, i, buf[3], *idlist, index_idlist = 0, milcount = 0;
	unsigned long long int *sale;

	scanf("%d", &n);

	sale = (unsigned long long int *)calloc(4000, sizeof(unsigned long long int));
	idlist = (int *)calloc(n, sizeof(int));

	while (n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d", &buf[0], &buf[1], &buf[2]);
			sale[buf[0] - 1] += buf[1] * buf[2];
			idlist[index_idlist++] = buf[0];
		}

		for (i = 0; i < n; i++){
			if (sale[idlist[index_idlist]] >= 1000000){
				printf("%d\n", idlist[index_idlist]);
				sale[idlist[index_idlist--]] = 0;
			}
			milcount++;
		}

		if (milcount == 0){
			puts("NA");
		}
		milcount = 0;
		scanf("%d", &n);
	}
	return 0;
}

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

int main(){
    int n;
    long int array[n][3];
    int count=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>array[i][0]>>array[i][1]>>array[i][2];
    }

    for(int i=0;i<n;i++){
        if(array[i][1]*array[i][2]<=1000000){
            cout<<array[i][0]<<"\n";
            count++;
        }
    }
    if(count==0) cout<<"NA\n";
}

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

int main(){

	while (true) {
		int cnt = 0;
		cin >> cnt;
		if (cnt == 0) break;

		typedef std::pair<long, long> elemType;
		typedef std::vector<elemType> dataType;
		dataType data;
		for (int i = 0; i < cnt; ++i) {
			int id, price, amount;
			cin >> id >> price >> amount;
			int g = price * amount;

			bool found = false;
			for (unsigned int i = 0; i < data.size(); ++i) {
				if (data[i].first == id) {
					data[i].second += g;
					found = true;
				}
			}
			if (!found) data.push_back(elemType(id, g));
		}
		bool bHitted = false;
		for (dataType::iterator it = data.begin(); it != data.end(); ++it) {
			if (it->second >= 1000000) {
				cout << it->first << "\n";
				bHitted = true;
			}
		}
		if (!bHitted) {
			cout << "NA\n";
		}
	}
	return 0;
}