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() {
    ios::sync_with_stdio(false);
 
    int n, id; long long p, q;
    while (cin >> n && n) {
        map<int, int> ids;
        vector<pair<int, long long>> sum;
        for (int i=0; i<n; ++i) {
            cin >> id >> p >> q;
            if (ids.count(id)) {
                sum[ids[id]].second += p * q;
            } else {
                sum.push_back(make_pair(id, p * q));
                ids[id] = sum.size() - 1;
            }
        }
        bool na = true;
        for (auto x : sum) {
            if (1000000 <= x.second) {
                cout << x.first << endl;
                na = false;
            }
        }
        if (na) {
            cout << "NA" << endl;
        }
    }
 
    return 0;
}

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

int main() {
	int max,n;
	vector<int> id;
	vector<int> sum;
	vector<int> table;
	
	id.resize(4000);
	sum.resize(4000);
	table.resize(4000);
	
	while(cin>>n,n){
		int i,f;
		long long int a,b;
		max = 0;
		
		for(int j=0;j<4000;++j){
			id[j] = 0;
			sum[j] = 0;
			table[j] = 0;
		}
		
		for(;n;--n){
			cin>>i>>a>>b;
			
			if(table[i-1]==0){
				id[max]=i;
				table[i-1] = max+1;
				++max;
			}
			if(a*b>=1000000)sum[table[i-1]-1] = 1000000;
			else if(sum[table[i-1]-1]<1000000)sum[table[i-1]-1] += a*b;
			
		}
		f=0;
		for(int j=0;j<max;++j){
			if(sum[j]>=1000000){
				cout<<id[j]<<endl;
				f=1;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long int lli;

lli employees[4001];
bool checked[4001];

signed main()
{
	lli n;
	while (cin >> n, n) {
		for (lli i = 1; i <= 4000; ++i) employees[i] = checked[i] = false;

		vector<lli> ans;

		for (lli i = 0; i < n; ++i) {
			lli num, a, b; cin >> num >> a >> b;

			if (checked[num]) continue;

			employees[num] += a * b;

			if (employees[num] >= 1000000) {
				ans.push_back(num);
				checked[num] = true;
			}
		}

		if (ans.size()) {
			for (lli i = 0; i < ans.size(); ++i) {
				cout << ans[i] << endl;
			}
		} else {
			cout << "NA" << endl;
		}
	}
}

C++: #include <stdio.h>

int output[50000];
int count=0;

void input(int);
int main(void){
	int n,i;
	while(true){
		scanf("%d",&n);
		if(n>0){
			input(n);
		}else{
			break;
		}
	}
	for(i=0;i<count;i++){
		if(output[i]!=0){
			printf("%d\n",output[i]);
		}else{
			printf("NA\n");
		}
	}
	
	return 0;
}
void input(int ns){
	int e[4000];
	int p[1000000];
	int q[100000];
	int c[ns];
	
	int i;
	
	for(i=0;i<ns;i++){
		scanf("%d",&e[i]);
		scanf("%d",&p[i]);
		scanf("%d",&q[i]);
		c[i] = p[i]*q[i];
	}
	
	int j;
	
	for(i=0;i<ns-1;i++){
		for(j=1;j<ns;j++){
			if(e[i]==e[j]){
				c[i]=c[i]+c[j];
				c[j]=0;
			}
		}
	}
	int ch = 0;
	
	for(i=0;i<ns-1;i++){
		if(c[i]>=1000000){
			output[count]=e[i];
			count++;
			ch = 1;
		}
	}
	if(ch == 0){
		output[count]=0;
		count++;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	int n;
	while (cin >> n && n) {
		vector<LL> v;
		map<LL, LL> m;
		LL no, price, amount;
		int na = 1;
		for (int i = 0; i < n; i++) {
			cin >> no >> price >> amount;
			if (m.find(no) != m.end())
				m[no] += price * amount;
			else {
				m[no] = price * amount;
				v.push_back(no);
			}
		}
		vector<LL>::iterator it = v.begin();
		while (it != v.end()) {
			if (m[*it] >= 1000000) {
				cout << *it << endl;
				na = 0;
			}
			it++;
		}
		if (na)
			cout << "NA" << endl;
	}
	return 0;
}

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

int main(){
	int a,hoge;
	bool flag;
	while(1){
		cin >> a;
		if(a == 0) break;
		int number[a];
		int tanka[a];
		int ryo[a];
		int gokei[a];
		flag = false;
		for(int i=0;i<a;i++){
			cin >> number[i] >> tanka[i] >> ryo[i];
			gokei[i] = tanka[i] * ryo[i];
			if(gokei[i] >= 1000000){
				cout << number[i] << endl;
				flag = true;
			}
		}
		if(flag == false) cout << "NA" << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<vector>
using namespace std;
long long sales[4010];
#define foreach(r,p,it) for(r::iterator it=p.begin();it!=p.end();++it)

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0)break;
        vector<int> shains;
        shains.clear();
    
        memset(sales,0,sizeof(sales));
        long long num,tanka,kazu;

        for(int i=0;i<n;i++)
        {
            cin>>num>>tanka>>kazu;
            sales[num] += tanka*kazu;
            int f=0;
            for(int j=0;j<shains.size();j++)
            {
                if(shains[j] == num){f=1;break;}
            }
            if(f==0) shains.push_back(num);
        }
        int na = 0;
        for(int i=0;i<shains.size();i++)
        {
            //cout <<"NUMBER"<<*it <<endl;
            if(sales[shains[i]] >= 1000000){cout<<shains[i]<<endl;na=1;}
        }
        if(na==0)cout<< "NA"<<endl;
    }
    return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
    int n;

    while(scanf("%d",&n),n){

        long long int mem[4500][2] = {{0}};
        int a,x,y;

        for(int i = 0;i < n; i++){
            scanf("%d%d%d",&a,&x,&y);
            mem[i][0] += x*y;
            mem[i][1] += a;
        }
        bool flg = 0;
        for(int i = 0;i < n; i++){
            if(mem[i][0] >= 1000000){
                printf("%lld\n",mem[i][1]);
                flg = 1;
            }
        }
        if(flg == 0)printf("NA\n");
    }
    return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

struct Sales{
	long long int sum;
	int id;
};


int main(){

	int checkTable[4001],index;
	long long int price,amount;
	Sales sales[4001];

	int n,id,count;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 1; i <= 4000; i++){
			sales[i].id = -1;
			sales[i].sum = 0;
			checkTable[i] = -1;	//?????´?????????????????????-1,?????´????????????sales??§?????????????????????
		}

		index = 0;

		for(int i = 1; i <= n; i++){
			scanf("%d %lld %lld",&id,&price,&amount);

			if(checkTable[id] == -1){	//????????´?????´???
				sales[index].id = id;
				sales[index].sum = price*amount;
				checkTable[id] = index;
				index++;
			}else{
				sales[checkTable[id]].sum += price*amount;
			}

		}

		count = 0;

		for(int i = 0; i < index; i++){
			if(sales[i].sum >= 1000000){
				printf("%d\n",sales[i].id);
				count++;
			}
		}
		if(count == 0)printf("NA\n");
	}

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n, a, b, c;
    while(true){
        scanf("%d", &n);
        if(n==0)break;
        bool na = true;
        for(int i = 0; i < n; i++){
            scanf("%d%lld%lld", &a, &b, &c);
            if(b*c>=1000000){
                na = false;
                printf("%d\n", &a);
            }
        }
        if(na) puts("NA");
    }
}