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>

using namespace std;

int N, M;

int main() {
	int goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		int v[4000];
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			int e, p, q;
			cin >> e >> p >> q;
			v[e - 1] += p*q;
		}
		bool flag = false;
		for (int i = 0; i < 4000; i++) {
			if (v[i] >= goal) {
				flag = true;
				cout << i + 1 << endl;

			}
		}
		if (!flag) cout << "NA" << endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std ;
#define P pair<int,long long int>

main(){
	int n,num,p,m,j ;
	bool t ;
	while( cin >> n , n ){
		vector<P> V ;
		for( int i=0 ; i<n ; i++ ){
			cin >> num >> p >> m ;
			t = true ;
			for( j=0 ; j<V.size() ; j++ ){
				if( V[j].first == num ){
					t = false ;
					break ;
				}
			}
			if( t ) V.push_back( P(num,p*m) ) ;
			else {
				if( V[j].second < 1000000 ) V[j].second += p*m ;
			}
		}
		
		t = false ;
		for( int i=0 ; i<V.size() ; i++ ){
			if( V[i].second >= 1000000 ){
				cout << V[i].first << endl ;
				t = true ;
			}
		}
		if( !t ) cout << "NA" << endl ;
	}
}

C++: #include<algorithm>
#include<iostream>
#include<vector>
#include<stdio.h>
struct su{
	int num;
	int sum;
}p[4001];
using namespace std;
int main()
{
	int n,i2;
	int sn,x, y,l=0;
	while (1){
		l = 0;
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i < n; i++){
			cin >> sn >> x >> y;
			for (i2 = 0; i2 < l; i2++){
				if (p[i2].num == sn){
					p[i2].sum += x*y;
					break;
				}
			}
			if (i2 == l){
				p[l].sum = 0;
				p[l].num = sn;
				p[l].sum += x*y;
				l++;
			}
		}
		int maxn = 0;
		int maxc = 0;
		for (int i = 0; i < l; i++){
			if (maxn < p[i].sum){
				swap(maxn, p[i].sum);
				maxc = p[i].num;
			}
		}
		if (maxn >= 1000000){
			cout << maxc << endl;
		}
		else
			cout << "NA" << endl;
	}
}

C++: #include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;
int n;

int main() {
	while(scanf("%d\n", &n) != EOF) {
		map<int, ll> m;
		vector<int> id, p, q;
		rep(i,n) {
			int x, y, z;
			cin >> x >> y >> z;
			id.push_back(x);
			p.push_back(y);
			q.push_back(z);
		}
		rep(i,n) {
			map<int, ll>::iterator it = m.find(id.at(i));
			if(it == m.end()) {
				m.insert(make_pair(id.at(i), (ll)p.at(i) * q.at(i)));
			} else {
				(*it).second += p.at(i) * q.at(i);
			}
		}
		bool flag = false;
		for(map<int, ll>::iterator it = m.begin(); it != m.end(); ++it) {
			if((*it).second >= 1000000) {
				flag = true;
				cout << (*it).first << endl;
			}
		}
		if(!flag) cout << "NA" << endl;
	}
	return 0;
}

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

int main(){

    return 0;
}

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

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		map<int,pair<long long,int> > m; // id,price,appear
		for(int i=0;i<n;i++){
			int id,price,num;
			cin>>id>>price>>num;
			m[id].first+=(long long)price*num;
			if(m[id].second==0)
				m[id].second=i+1;
		}
		
		map<int,int> m2; // first,id
		for(map<int,pair<long long,int> >::iterator i=m.begin();i!=m.end();i++)
			if(i->second.first>=1000000)
				m2[i->second.second]=i->first;
		
		for(map<int,int>::iterator i=m2.begin();i!=m2.end();i++)
			cout<<i->second<<endl;
		if(m2.size()==0)
			cout<<"NA"<<endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	
	int n;
	long long sn, x, y;
	vector<long long>nm;
	long long p[4001] = { 0 };
	while (1){
		nm.clear();
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i <= 4000; i++)p[i] = 0;
		for (int i = 0; i < n; i++){
			cin >> sn >> x >> y;
			p[sn] += x*y;
		}
		long long maxn = 0;
		for (int i = 1; i <= 4000; i++){
			if (maxn < p[i]){
				nm.clear();
				swap(maxn, p[i]);
				nm.push_back(i);
			}
			else if (maxn == p[i]){
				nm.push_back(i);
			}
		}
		if (maxn >= 1000000){
			for (int i = 0; i < nm.size(); i++){
				cout << nm[i] << endl;
			}
		}
		else
			cout << "NA" << endl;
	}
}

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

int main(void)
{
    int data_num, data_num_update;
    int employee_num[4000] = {};
    long long unit_sale_num[4000] = {};
    long long sale_num[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 %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; ++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;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void shoki();
	vector<long long> num(3999,0);
	int n,ban,tanka,kazu,i,j;
int main(){
	bool y=false;
	for(j=0;j<49;j++){
		cin>>n;
		if(n==0){
			break;
		}
		int count=0;
		for(i=0;i<n;i++){
			cin>>ban>>tanka>>kazu;
			num[ban]+=tanka*kazu;
		}
		for(int k=0;k<3999;k++){
			if(num[k]==0){
				continue;
			}
			if(num[k]>=1000000){
				y=true;
				cout<<k<<endl;
			}
		}
		if(y==false){
			cout<<"NA"<<endl;
		}
		y=false;
		shoki();
	}
	return 0;
}
void shoki(){
	for(int i=0;i<3999;i++){
		num[i]=0;
	}
}

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

int main()
{
    int n;
    long long int e[4000], p[4000], q[4000], sum[4000];
    bool ej[4000];

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

        for( int i = 0; i < 4000; i++ )
        {
            sum[i] = 0;
            ej[i] = false;
        }

        for( int i = 0; i < n; i++ )
        {
            cin >> e[i] >> p[i] >> q[i];
            sum[e[i]] += p[i] * q[i];
        }
        
        bool judge = false;
        for( int i = 0; i < n; i++ )
        {
            if( sum[e[i]] >= 1000000 && ej[e[i]] == false )
            {
                cout << e[i] << endl;
                judge = true;
                ej[e[i]] = true;
            }
        }
        if( judge == false )
            cout << "NA" << endl;
    }
    return 0;
}