Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

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

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

		int num,x,y;
		int mon=0,cnt=0;
		for(int i=0 ;i<n ;i++){
			cin >> num >> x >> y;

			mon = x*y;
			if(mon >=1000000){
				cout << num << endl;
				cnt++;
			}
		}
		if(cnt==0)
			cout << "NA" << endl;

	}
	return 0;
}

C++: #include <iostream>
using namespace std;main(){int n,m;while(cin>>n&&n){m=1;while(n--){long U,p,s;cin>>U>>p>>s;if(p*s>=1000000)m=0,cout<<U<<endl;}if(m)cout<<"NA\n";}}

C++: #include<cstdio>

using namespace std;
const int target = 1000000;

int main()
{
	int data;
	while (1)
	{
		scanf("%d", &data);
		if (data == 0)break;
		int company[4000] = { 0 };
		int num, sell, cnt;
		bool hero = false;
		for (int i = 0; i < data; i++)
		{
			scanf("%d %d %d", &num, &sell, &cnt);
			company[num - 1] += sell*cnt;
		}
		for (int i = 0; i < 4000; i++)
		{
			if (company[i] >= target)
			{
				printf("%d\n", i + 1);
				hero = true;
			}
		}
		if (hero == false)
			printf("NA\n");
	}
	return 0;
}

C++: #include<cstdio>

int main(){
int a,i;
bool fl;
unsigned long int b,c;
while(1){
scanf("%d",&i);
fl=false;
for(;i>0;i--){


 scanf("%d",&a);
 if(a==0){
 return 0;
}
 scanf("%d",&b);
 scanf("%d",&c);
if(a*c>=1000000) {
 fl=true;
 printf("%d\n",a);
}
if(fl==false) pritnf("NA\n");
}
}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int n;
    int id, price, amount;
    vector<int> rank;
    map<int, long long> ids;
    bool exist;
    while(cin >> n && n)
    {
        exist=false;
        rank.clear();
        ids.clear();
        for(int i=0;i<n;++i)
        {
            cin >> id >> price >> amount;
            if(!ids[id]) rank.push_back(id);
            ids[id] += price * amount;
        }
        for(int i=0;i<rank.size();++i)
        {
            if(ids[rank[i]] >= 1000000)
            {
                exist = true;
                cout << rank[i] << endl;
            }
        }
        if(!exist) cout << "NA" << endl;
    }
}

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,mp2;
		vector <int> vi;
		priority_queue<int, vector<int>, greater<int> >pq;
		for(int i=0;i<N;i++){
			int num,tanka,suuryo;
			cin>>num>>tanka>>suuryo;
			mp[num]+=tanka*suuryo;
			vi.push_back(num);
			if(mp[num]>=1000000){
				mp2[num]++;
			}
		}
		vector<int>::iterator it=vi.begin();
		for(;it!=vi.end();it++){
                        int a=*it;
			if(mp2[a]>=2){
				mp2[a]--;
			}
			else if(mp2[a]==1){
				pq.push(a);
				mp2[a]--;
			}
		}
		if(pq.empty()){
			cout<<"NA"<<endl;
		}
		else{
			int len=pq.size();
			for(int i=0;i<len;i++){
				cout<<pq.top()<<endl;
				pq.pop();
			}
		}
	}
	return 0;
}

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

const int sales = 1000000;

int main()
{
	int n;
	while(scanf("%d",&n),n) {
		bool flag[4000]={false};
		queue<int> employee_n;
		for(int i=0;i<n;++i) {
			int number,a,b;
			scanf("%d %d %d",&number,&a,&b);
			if(sales>a*b||flag[number-1]) continue;
			flag[number-1]=true;
			employee_n.push(number);
		}
		while(!employee_n.empty()){
			printf("%d\n",employee_n.front());
			employee_n.pop();
		}
		if(employee_n.empty()) puts("NA");
	}	
	return 0;
}

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

int main(){
	int n, No, unit, number;

	while( cin >> n , n ){
		map<int,int> employees;
		vector<int> vc;
		bool flag = false;
		for(int i=1 ; i<=4000 ; ++i ){
			employees[i] = 0;
		}
		
		for(int i=0 ; i<n ; ++i ){
			cin >> No >> unit >> number;
			if( count( vc.begin() , vc.end() , No ) == 0 ){
				vc.push_back( No );
			}
			employees[No] += unit * number;	
		}
		for(int i=0 ; i<vc.size() ; ++i ){
			if( employees[ vc[i] ] >= 1000000 ){
				cout << vc[i] << endl;
				flag = true;
			}
		}
		if( flag == false ){
			cout << "NA" << endl;
		}
	}
}

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

int main(){
    int n;
    while( cin >> n, n ){
        vector< long long int > ls(4001, 0);
        bool NA = true;
        for(int i = 0; i < n; i++){
            int a, b, c;
            cin >> a >> b >> c;
            if( ls[a] >= 0 ){
                ls[a] += b*c;
                if( ls[a] >= 1000000){
                    cout << a << endl;
                    NA = false;
                    ls[a] = -1;
                }
            }
        }
        if( NA ) cout << "NA" << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,b,t,s;
  while(cin>>n){
    if(n==0) break;
    int h[4000];
    int index = 0;
    int h2 = 0;
    unsigned long long int p[4001]={0};
    for(int i=0;i<n;i++){
      cin >> b >> t >> s;
      if(p[b]==0){
	h[index] = b;
	index++;
      } 
      p[b] += t * s;
    }
    /*for(int i=0;i<index;i++){
      cout << p[h[i]] << endl;
      cout << h[i] << endl;
      }*/
    for(int i=0;i<index;i++){
      if(p[h[i]]>=1000000){
	cout << h[i] << endl;
	h2 = 1;
      }
    }
    if(h2==0) cout << "NA" << endl;
    //cout << endl;
  }
  return 0;
}

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

class meb{
public:
	int num;
	unsigned long long tanka;
	unsigned long long count;
	unsigned long long sum;
};

int main(){
	int n;
	while(1){
		int cc=0;
		cin>>n;
		meb st[n];
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>st[i].num>>st[i].tanka>>st[i].count;
		}
		for(int k=0;k<n;k++){
			st[k].sum=st[k].tanka*st[k].count;
		}
		for(int j=0;j<n;j++){
			for(int l=j+1;l<n;l++){
				if(st[j].num==st[l].num){
					(st[j].sum)=(st[j].sum)+(st[l].sum);
					st[l].sum=0;
				}
			}
		}
		for(int a=0;a<n;a++){
			if(st[a].sum>=1000000)cout<<st[a].num<<endl;
			else cc++;
		}
		if(cc==n)cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		int no;
		int price;
		int deal;

		bool f = true;
		for ( int i = 0; i < n; i++ )
		{
			cin >> no >> price >> deal;
			if ( price * deal >= 1000000 )
			{
				cout << no << endl;
				f = false;
			}
		}

		if ( f )
			cout << "NA" << endl;

	}

	return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	while(1){
int s[4000];int i;int w;int j;
w=0;
for(int y = 0;y<4000;y++){
	s[y]= 0;
}
cin>>i;
if(i==0){break;}
for(int y = 1;y<=i;y++){
	int a,b,c;
	cin>>a>>b>>c;
	int g = 1000000 - s[a-1];
	if(g%b==0){j = g/b;}
	else{j = (g/b)+1;}
	if(j<c){s[a-1]=1000001;}
	else{s[a-1]=s[a-1]+b*c;}
}
for(int y = 0;y<4000;y++){
	if(s[y]>=1000000){
		cout << y+1<<endl;
		w=1;
		}
}
if(w==0){cout << "NA" << endl;}
}
	return 0;
}