Problem:
Sale Result There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list of data where each item includes the employee ID i , the amount of sales q and the corresponding unit price p . Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that n < 4000, and each employee has an unique ID. The unit price p is less than or equal to 1,000,000 and the amount of sales q is less than or equal to 100,000. Input The input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:  n (the number of data in the list) i  p  q  i  p  q :
 : i  p  q  Output For each dataset, print a list of employee IDs or a text "NA" Sample Input 4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0 Output for the Sample Input 1001
1003
NA
2013

Solution (Python):
if __name__ == '__main__':

	while True:
		try:
			n = int(input())
			if n == 0:
				break

			no = []
			total = []
			for i in range(n):
				e,p,q = map(int,input().split())

				if e not in no:
					no.append(e)
					total.append(p*q)
				else:
					ind = no.index(e)
					total[ind] += p*q

			cnt = 0
			for j,k in enumerate(total):
				if k >= 1000000:
					cnt += 1
					print(no[j])
			if cnt == 0:
				print("NA")

		except EOFError:
			break

Solution (Python):
while True:
    try:
        N=int(input())
        if N==0:break
        ans=[]
        dic={}
        for i in range(N):
            e,p,q=map(int,input().split())
            if e in dic:dic[e] +=p*q
            else:dic[e]=p*q
        for v,m in dic.items():
            if m>=1000000:ans.append(v)
        if len(ans)==0:ans.append("NA")
        for k in ans:
            print(k)
    except:break

Solution (Python):
import sys

while True:
    n=int(input())
    score={}
    if n==0:
        sys.exit()
    for _ in range(n):
        e,p,q=[int(i) for i in input().split(" ")]
        score[e]=score.get(e,0)+p*q

    employee=[]
    for e in score:
        if score[e]>=1000000:
            employee.append(e)

    if len(employee)==0:
        print("NA")
    else:
        for e in employee:
            print(e)

Solution (Python):
while 1:
    n=int(input())
    if n==0:break
    count=0
    member=[0]*4001
    mem_check=[]
    mem_check2=[]
    for i in range(n):
        e,p,q=map(int,input().split())
        member[e]+=p*q
        mem_check.append(e)
    for i in mem_check:
        if not(i in mem_check2):
            if member[i]>=1000000:
                print(i)
                count+=1
                mem_check2.append(i)
    if count==0:
        print("NA")

Solution (Python):
import sys

def sales_result(sales):
    total_sales = {}
    person = []
    for s in sales:
        total_sales[s[0]] = total_sales.get(s[0], 0)
        total_sales[s[0]] += s[1] * s[2]
        if total_sales[s[0]] >= 1000000 and not (s[0] in person):
            person.append(s[0])
    if len(person) == 0:
        print("NA")
    else:
        for p in person:
            print(p)


lineno = 0
n = 0
sales = []
for line in sys.stdin:
    if lineno == 0:
        n = int(line)
        if n == 0:
            break
    elif lineno <= n:
        s = list(map(int, line.strip().split()))
        sales.append(s)
    if lineno == n:
        sales_result(sales)
        lineno = 0
        sales = []
    else:
        lineno += 1

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    result = {}
    order = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if e in result:
            result[e] += p*q
        else:
            result[e] = p*q
            order.append(e)
    flag = True
    for e_i in order:
        if result[e_i] >= 1000000:
            print(e_i)
            flag = False
    if flag:
        print("NA")

Solution (Python):
while True:
    n = int(input())
    if n == 0: break
    personel = {}
    for _ in range(n):
        e, p, q = input().split()
        if e in personel.keys():
            personel[e] += int(p) * int(q)
        else:
            personel[e] = int(p) * int(q)
    result = []
    for key, val in personel.items():
        if val >= 1000000:
            result.append(key)
    if not result:
        print('NA')
    else:
        print('\n'.join(result))

Solution (Python):
n = int(input())
while (n != 0):
    e_ab = {}
    for i in range(n):
        e,a,b = map(int, input().split())
        ab = a*b
        if (e not in e_ab.keys()):
            e_ab[e] = ab
        else:
            e_ab[e] += ab
    c = 0
    for e,ab in e_ab.items():
        if (ab >= 10**6):
            c += 1
            print(e)
    if (c == 0):
        print('NA')
    
    n = int(input())

Solution (Python):
p = []
q = []
while True:
    n = int(input())
    m = 0
    number = [0] * 4000
    if n == 0:
        break
    else:
        for i in range(n):
            p.append(i)
            q.append(i)
            e,p[i],q[i] = [int(s) for s in input().split(' ')]
            if number[e] >= 1000000:
                break
            else:
                number[e] = number[e] + p[i] * q[i]
                if number[e] >= 1000000:
                    print(e)
                else:
                    m = m + 1
            if m == n:
                print('NA')

Solution (Python):
while(True):
    n = int(input())
    if n == 0:
         break
    oe = []
    for i in range(n):
        e,p,q = map(int, input().split())
        for a in oe:
            if a[0] == e:
                a[1] += p*q
                continue
        oe.append([e,p*q])
    lis = [ a[0] for a in oe if a[1] >= 1000000]
    if len(lis):
        print("\n".join(str(l) for l in lis))
    else:
        print("NA")

Solution (Python):
from collections import Counter

while True:
    n = int(input())
    if n == 0:
        break
    counter = Counter()
    for _ in [0]*n:
        a, b, c = map(int, input().split())
        counter[a] += b*c
    result = [str(k) for k, v in counter.items() if v >= 1000000] or ["NA"]
    print("\n".join(result))