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<map>
#include <vector>
using namespace std;

int main(){
    int n,i;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        long long p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
//        for (map<int,long long>::iterator it=m.begin(); it!=m.end(); ++it){
//            cout<<it->first<<endl;
//            if(it->second>=1000000){
//                s=1;
//                cout<<it->first<<endl;
//            }
//        }
        for (int i=0;i<vec.size();i++){
            if(m.find(vec[i])->second>=1000000){
                s=1;
                cout<<m.find(vec[i])->first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

C++: #include<iostream>

using namespace std;

int main(){
	bool tf = 0;
	int n,e,p,q;
	while(cin >> n){
		if(n == 0){
			break;
		}
		int r[4001]={0};
		tf = 0;
		for(int i = 0; i < n; i++){
			cin >> e >> p >> q;
			r[e] += p * q;
			//r[e] = r[e] + p*q;
		}
		for(int i = 1; i <= 4000; i++){
			if(r[i] >= 1000000){
				cout << i << endl;
				tf = 1;
			}
		}
		if(tf != 1){
				cout << "NA" << endl;
			}
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

void Solution()
{
	while(true)
	{
		int n;
		int count = 0;
		int number, perPrice, amount;

		cin>>n;

		int m = n;

		if (n == 0)
		{
			break;
		}

		while(n--)
		{
			cin>>number>>perPrice>>amount;

			long long allValue = perPrice * amount;
			
			if ( allValue >= 1000000)
			{
				cout<<number<<endl;
			}
			else
			{
				count++;
			}

			if (count == m)
			{
				cout<<"NA"<<endl;
			}
		}
	}
}

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

C++: #include <iostream>
using namespace std;
int main(){
	long x,y;
	int n,num,cnt=0,sum=0;
	while(cin>>n&&n!=0){
		cnt=0,sum=0;
		bool a[4000]={0};
		long p[4000]={0};
		for(int i=0;i<n;i++){
			cin>>num>>x>>y;
			if(a[num]==0)cnt++;
			a[num]=1,p[num]+=x*y;
		}
		for(int i=1;i<=4000;i++){
			if(a[i]==1&&p[i]>=1000000){
				cout<<i<<endl;
			}else if(a[i]==1){
				sum++;
			}
			if(cnt==sum){
				cout<<"NA"<<endl;
				break;
			}
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
 
int n;
 
int main(){
	while(scanf("%d", &n),n){
		map<int,ll> m;
		map<int,ll>::iterator it;
		for(int i = 0; i < n; i++){
			int x; ll p, q;
			scanf("%d%lld%lld", &x, &p, &q);
			m[x] += p*q;
		}
		bool ok = true;
		for(it = m.begin(); it != m.end(); it++){
			if(it->second >= 1000000){
				ok = false;
				printf("%d\n", it->first);
			}
		}
		if(ok) printf("NA\n");
	}
	return 0;
}

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

#define TAR 1000000

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

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

using namespace std;

int main()
{
    const int TARGET = 1000000;
    map<int, int> sale;
    int n_data, id, amount, price, n_target;
    for (;;) {
	cin >> n_data;
	if (n_data == 0)
	    break;
	for (int i = 0; i != n_data; ++i) {
	    cin >> id >> price >> amount;
	    sale[id] += price * amount;
	}
	map<int, int>::iterator it = sale.begin();
	n_target = 0;
	while (it != sale.end()) {
 	    if (it->second >= TARGET) {
		cout << it->first << endl;
		++n_target;
	    }
	    ++it;
	}
	if (n_target == 0)
	    cout << "NA" << endl;
	sale.clear();
    }
}

C++: #include<stdio.h>
int n,i,b;
int syain[4001],a,suu;
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=1;i<=4000;i++){
			syain[i]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&suu);
			syain[a]+=(b*suu);
		}
		int flg=0;
		for(i=1;i<=4000;i++){
			if(syain[i]>=1000000){
				printf("%d\n",i);
				flg=1;
			}
		}
		if(flg==0){
			printf("NA\n");
		}
	}
	return 0;
}

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

int main(void)
{
    int data_num, data_num_update;
    int employee_num[4000] = {};
    int employee_sale_num[4000] = {};
    int employee_sale[4000] = {};
    
    while ((scanf("%d", &data_num)) != EOF) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %d %d", &employee_num[i], &employee_sale_num[i],  &employee_sale[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    employee_sale[data_check] += employee_sale[i];
                    employee_sale_num[data_check] += employee_sale_num[i];
                    data_num_update--;
                }

                
            }
            data_check++;
            
        }
        
        //printf("%d", data_num_update);
        
        bool result_flag = true;
        for (int i = 0; i < data_num_update; ++i) {
            if (employee_sale_num[i] * employee_sale[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}

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

int main()
{
  int n;
  
  while (cin >> n, n){
    long long s[4000] = {0}, p, q;
    int e;

    for (int i = 0; i < n; i++){
      cin >> e >> p >> q;
      s[e - 1] += (p * q);
    }
    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;
    }

  }

  return 0;
}

C++:     while (scanf("%d", &data_num)) {
        
        if (data_num == 0) break;
        
        data_num_update = data_num;
        for (int i = 0; i < data_num; ++i) {
            scanf("%d %lld %lld", &employee_num[i], &unit_sale_num[i],  &sale_num[i]);
        }
        
        int data_check = 0;

        while (data_check < data_num - 1) {
            for (int i = data_check + 1; i < data_num; ++i) {
                if (employee_num[data_check] == employee_num[i]) {
                    sale_num[data_check] += sale_num[i];
                    unit_sale_num[data_check] += unit_sale_num[i];
                    data_num_update--;
                }
            }
            data_check++;
        }
        
        bool result_flag = true;
        
        for (int i = 0; i < data_num_update; ++i) {
            if (unit_sale_num[i] * sale_num[i] >= 1000000) {
                printf("%d\n", employee_num[i]);
                result_flag = false;
            }
            
            if (result_flag) {
                printf("NA\n");
                break;
            }
        }
    }

    return 0;
}