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>

int main(){
	int num,age,tanka;
	int i,j,n,temp;
	int sya[4000];
	double uriage[4000][2]={ 0 };
	
	
	for(;;temp=0){
		scanf("%d", &n);
		
		for(i=0;i<n;i++){
			scanf("%d%d%d", &num, &tanka, &age);
			
			for(j=0;j<=i;j++){
				if(sya[j]==num){
					uriage[j][0]+=tanka*age;
					break;
				} else {
					sya[i]=num;
					uriage[i][0]+=tanka*age;
					break;
				}
			}
		}
		for(i=0;i<4000;i++){
			if(uriage[i][0]>=1000000 && uriage[i][1] != 1){
				uriage[i][1]=1;
				temp=1;
				break;
			}
		}
		if(temp==1)printf("%d\n",sya[i]);
		else puts("NA");
		if(n==0)break;
	}
	return 0;
}

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

int main(void) {
int n;
int employees[4000] = {0};
while (1) {
scanf("%d", &n);
if (!n) break;

for (int i = 0; i < n; i++) {
int id, price, sales;
scanf("%d %d %d\n", &id, &price, &sales);
employees[id] += price * sales;
}

int found = 0;
for (int i = 0; i < 4000; i++) {
if (employees[i] >= 1000000) {
printf("%d\n", i);
found = 1;
}
}
memset(employees, 0, sizeof employees);
if (!found) {
printf("NA\n");
}

}
}

C++: #include<cstdio>
#include<algorithm>
#include<iostream>
#include<functional>
#define inf 1000000
using namespace std;
long long int p[114514],x,y,z,w;
int main(void)
{
	int i,j,k,f,n,cnt;
	while(1) {
		cin>>n;
		f=0,cnt=0;
		if(!n)break;
		for(i=0;i<4001;i++) p[i]=0;
		for(i=0;i<n;i++) {
			cin>>x>>y>>z;
			if(y>=inf) y=w;
			else w=y*z;
			if(p[x]>=inf) {}
			else p[x]+=y*z;
		}
		for(i=0;i<4001;i++) {
			if(p[i]>=inf) {
				cout<<i<<endl;
				f=1;
			}
		}
		if(f==0) cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <vector>

int main() {
    int n;
    while (~scanf("%d", &n)) {
        if (n == 0) break;
        
        std::vector<unsigned int> v;
        std::map<unsigned int, unsigned long long int> m;
        
        unsigned int a;
        unsigned long long int b, c;
        for (int i = 0; i < n; ++i) {
            scanf("%u %llu %llu", &a, &b, &c);
            v.push_back(a);
            m[a] += b * c;
        }
        
        std::set<unsigned int> dup;
        bool found = false;
        for (auto i : v) {
            if (m[i] >= 1000000 && dup.count(i) == 0) {
                printf("%u\n", i);
                dup.insert(i);
                found = true;
            }
        }
        if (!found) {
            printf("NA\n");
        }
    }
}

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

int main(){
	int N;
	
	while(cin>>N,N){
		map<int,long long int> mp;
		vector <int> vi;
		queue<int >q;
		for(int i=0;i<N;i++){
			int num,tanka,suuryo;
			cin>>num>>tanka>>suuryo;
			if(mp[num]==0){
				vi.push_back(num);
			}
			mp[num]+=tanka*suuryo;
		}
		vector<int>::iterator it=vi.begin();
		for(;it!=vi.end();it++){
			if(mp[*it]>=1000000){
				q.push(*it);
			}
		}
		if(q.empty()){
			cout<<"NA"<<endl;
		}
		else{
			int len=q.size();
			for(int i=0;i<len;i++){
				cout<<q.front()<<endl;
				q.pop();
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>
#include<memory.h>
int main(){
	int n,i,j,k,e[100],p[100],q[100];
	int c[100],count=0,count2=0;
	int gokei=0;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&e[i],&p[i],&q[i]);
			gokei=p[i]*q[i];
			for(j=0;j<i;j++){
				if(e[i]==e[j]){
					gokei+=p[j]*q[j];
				}
			}
			for(k=0;k<count;k++){
				if(e[i]==c[k]){
					goto a;
				}
			}
			if(gokei>=1000000){
				c[count]=e[i];
				count++;
			}
			a:
			gokei=0;
		}
		for(i=0;i<count;i++){
			printf("%d\n",c[i]);
		}
		if(count==0){
			printf("NA\n");
		}
		count=0;
		memset(c,0,sizeof(c));
	}
	
	return 0;
}

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

int main(void) {
    int n;
    int employees[4000] = {0};
    while (~scanf("%d", &n)) {
        for (int i = 0; i < n; i++) {
            int id, price, sales;
            scanf("%d %d %d", &id, &price, &sales);
            employees[id] += price * sales;
        }

        int found = 0;
        for (int i = 0; i < 4000; i++) {
            if (employees[i] >= 1000000) {
                printf("%d\n", i);
                found = 1;
            }
        }
        memset(employees, 0, sizeof employees);
        if (!found) {
            printf("NA\n");
        }

    }

    return 0;
}

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

int main(){
  int n;
  while(cin >> n,n){
    map<int, long long> m;
    vector<int> order;
    for(int i = 0 ; i < n ; i++ ){
      int id;
      long long a, b;
      cin >> id >> a >> b;
      if( m.find(id) == m.end()){
	order.push_back(id);
	m[id] = a*b;
      }else{
	m[id] += a*b;
      }
    }
    bool isAns = false;
    for(int i = 0; i < (int)order.size(); i++){
      long long money = m[ order[i] ];
      if( money  >= 1000000){
	cout << order[i] << endl;
	isAns = true;
      }
    }
    if( !isAns )cout << "NA" << endl;
  }
  return 0;
}

C++: #include <cstdio>   /* printf, scanf */
#include <utility>  /* pair, make_pair */
#include <vector>   /* vector */

using namespace std;
int GetContainsNumber(const vector<pair<int, int>> v, const int e) {

    int i = 0;
    for (vector<pair<int, int>>::const_iterator it = v.begin(); it != v.end(); it++) {
        if (e == it->first) {
            return i;
        }
        i++;
    }
    return -1;
}

int main()
{
    int n = 0, e = 0, p = 0, q = 0;
    vector<pair<int, int>> vec;
    while (true) {
        scanf("%d", &n);
        if(0 == n)
            break;

        bool isFind = false;
        for (int i = 0; i < n; i++) {
            scanf("%d%d%d", &e, &p, &q);
            int idx = GetContainsNumber(vec, e);
            if (-1 == idx) {
                vec.push_back(make_pair(e, p * q));
            }
            else {
                vec[idx].second += p * q;
            }
        }

        for (vector<pair<int, int>>::iterator it = vec.begin(); it != vec.end(); it++) {
            if (1000000 <= it->second) {
                printf("%d\n", it->first);
                isFind = true;
            }
        }

        if (!isFind) {
            printf("NA\n");
        }
        vec.clear();
    }

    return 0;
}

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

using namespace std;

int main(){
  int n, i, p, q;
  while(true){
    cin >> n;
    if(n==0)
      break;

    map<int,int> mop;
    vector<int> ord;
    bool check = true;

    for(int j=0; j<n; j++){
      cin >> i >> p >> q;
      if(mop.find(i) == mop.end()){
	mop[i] = p*q;
	ord.push_back(i);
      }
      else if(mop[i] < 1000000){
	mop[i] += p*q;
      }
    }
    
    for(int j=0; j<ord.size(); j++){
      if(mop[ord[j]] >= 1000000){
	cout << ord[j] << endl;
	check = false;
      }
    }
    if(check)
      cout << "NA\n";
  }
  return 0;
}