Problem:

What Color Is The Universe?

On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered,

"There are many stars in the space. What color is the universe if I look up it from outside?"

Until he found the answer to this question, he couldn't sleep. After a moment's thought, he proposed a hypothesis,

"When I observe the stars in the sky, if more than half of the stars have the same color, that is the color of the universe."

He has collected data of stars in the universe after consistently observing them. However, when he try to count the number of star, he was in bed sick with a cold. You decided to help him by developing a program to identify the color of the universe.

You are given an array A. Let |A| be the number of element in A, and let Nm be the number of m in A. For example, if A = {3, 1, 2, 3, 3, 1, 5, 3}, |A| = 8, N3 = 4, N1 = 2, N5 = 1. Your program have to find m such that:

 Nm > (|A| / 2 )

If there is no such m, you also have to report the fact. There is no
such m for the above example, but for a array A = {5, 2, 5, 3, 4, 5, 5}, 5 is the answer.

Input

There are several test cases. For each test case, in the first line |A| is given. In the next line, there will be |A| integers. The integers are less than 231 and |A| < 1,000,000. The input terminate with a line which contains single 0.

Output

For each test case, output m in a line. If there is no answer, output "NO COLOR" in a line.

Sample Input

8
3 1 2 3 3 1 5 3
7
5 2 5 3 4 5 5
0

Output for the Sample Input

NO COLOR
5



Sample input:
8
3 1 2 3 3 1 5 3
7
5 2 5 3 4 5 5
0


Sample output:
NO COLOR
5

Submission status: Wrong Answer

Solution code:
while 1:
    n = int(raw_input())
    if(n==0):break
    nums = map(int, raw_input().split())
    dicS = {}
    ans = "NO COLOR"
    for s in nums:
        if(s in dicS):
            dicS[s] = dicS[s]+1
            if(dicS[s]> n/2):
                ans = s
                break
        else:
            dicS[s]=1
    #
    #print dicS
    print ans

Submission status: Wrong Answer

Solution code:
while True:
    a = int(input())
    if a == 0: break
    cnt = 1
    flag=0
    li = input().split()
    lis = sorted(li)
    for i in range(len(lis)):
        if i != len(lis)-1 and lis[i]==lis[i+1]:
            cnt+=1
            if cnt>a/2:
                print(lis[i])
                flag=1
                break
        else: cnt=1
    if flag==0:
        print("NO COLOR")

Submission status: Wrong Answer

Solution code:
while True:
    a = int(input())
    if a == 0: break
    cnt = 1
    flag=0
    li = input().split()
    lis = sorted(li)
    for i in range(len(lis)-1):
        if lis[i]==lis[i+1]:
            cnt+=1
            if cnt>a/2:
                print(lis[i])
                flag=1
                break
        else: cnt=1
    if flag==0:
        print("NO COLOR")

Submission status: Wrong Answer

Solution code:
while True:
    a = int(input())
    if a == 0: break
    cnt = 1
    flag=0
    li = input().split()
    lis = sorted(li)
    
    for i in range(len(lis)-1):
        if lis[i]==lis[i+1]:
            cnt+=1
            if cnt>a/2:
                print(lis[i])
                flag=1
                break
        else: cnt=1
        if cnt>a/2:
                print(lis[i])
                flag=1
                break

    if flag==0:
        print("NO COLOR")

Submission status: Wrong Answer

Solution code:
while True:
    n=input()
    if n==0:break
    A=map(int,raw_input().split())
    A.sort()
    cnt=1
    pre=A[0]
    for c in A[1:]:
        if c==pre:
            cnt+=1
            if cnt>n/2:
                print c
                break
        else:
            cnt=1
            pre=c
    else:
        print "NO COLOR"

Submission status: Wrong Answer

Solution code:
while 1:
	n = input()
	if n == 0: break
	A = sorted(map(int,raw_input().split()))
	if len(set(A)) > n/2:
		print "NO COLOR"
		continue
	c,l = A[0],1
	for i in range(1,n):
		if A[i] == c:
			l += 1
			if l > n/2:
				print c
				break
		else:
			c = A[i]
			l = 1
	else:
		print c if l > n/2 else "NO COLOR"

Submission status: Time Limit Exceeded

Solution code:
while True:
    n = int(input())
    if not n:
        break
    stars = list(map(int, input().split()))
    half_n = n // 2
    for s in set(stars):
        if stars.count(s) > half_n:
            print(s)
            break
    else:
        print('NO COLOR')

Submission status: Time Limit Exceeded

Solution code:
while True:
    num=int(input())
    if num==0:
        break
    stars=input().split()
    star_list=list(set(stars))
    for i in star_list:
        if stars.count(i) > num/2:
            print(i)
            break
    else:
        print("NO COLOR")

Submission status: Time Limit Exceeded

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break
    a = map(int, raw_input().split())
    b = list(set(a))
    flag = 0
    for i in b:
        if a.count(i) > n/2.0:
            ans = i
            flag = 1
            break
    print ans if flag == 1 else "NO COLOR"

Submission status: Time Limit Exceeded

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break
    a = map(int, raw_input().split())
    b = list(set(a))
    flag = 0
    if len(b) < n/2.0:
        for i in b:
            if a.count(i) > n/2.0:
                ans = i
                flag = 1
                break
    print ans if flag == 1 else "NO COLOR"

Submission status: Time Limit Exceeded

Solution code:
while 1:
	n = input()
	if n == 0: break
	A = map(int,raw_input().split())
	S = set(A)
	for i in S:
		if A.count(i) > n/2:
			print i
			break
	else:
		print "NO COLOR"

Submission status: Time Limit Exceeded

Solution code:
while 1:
	n = input()
	if n == 0: break
	A = sorted(map(int,raw_input().split()))
	for i in set(A):
		if (n-A[::-1].index(i)-1) - A.index(i) + 1 > n/2:
			print i
			break
	else:
		print "NO COLOR"

Submission status: Memory Limit Exceeded

Solution code:
while 1:
    nums = int(input())
    if nums != 0:
        stars = list(map(int,input().split()))
        cnt = [0 for i in range((2**31)-1)]
        for x in stars:
            cnt[x] += 1
        m = max(cnt)
        if m > nums/2:
            res = cnt.index(m)
            print(res)
        else:
            print("NO COLOR")
    else:break

Submission status: Accepted

Solution code:
import bisect

while(1):
    n=int(raw_input())
    m=n/2+1
    if n==0:
        break
    else:
        S=sorted([int(x) for x in raw_input().split()])
        i=0
        while(i<n):
            s=S[i]
            num=bisect.bisect(S,s)-bisect.bisect_left(S,s)
            if num>=m:
                print s
                break
            else:
                i=bisect.bisect(S,s)
        else:
            print 'NO COLOR'

Submission status: Accepted

Solution code:
from collections import defaultdict

while True:
    n = int(input())
    if not n:
        break
    stars = defaultdict(int)
    for s in map(int, input().split()):
        stars[s] += 1
    half_n = n // 2
    for i, s in stars.items():
        if s > half_n:
            print(i)
            break
    else:
        print('NO COLOR')

Submission status: Accepted

Solution code:
while True:
    num=int(input())
    if num==0:
        break
    stars=sorted(input().split())
    if stars.count(stars[num//2]) > num/2 :
        print(stars[num//2])
    else:
        print("NO COLOR")

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    s=sorted(input().split())
    print(s[n//2] if s.count(s[n//2])>n/2 else 'NO COLOR')

Submission status: Accepted

Solution code:
while 1:
    nums = int(input())
    if nums != 0:
        d = {}
        stars = list(map(int,input().split()))
        for x in stars:
            if x not in d:
                d[x] = 1
            else:
                d[x] += 1

        key = list(d.keys())
        val = list(d.values())
        m = int(max(val))
        if m > nums/2:
            res = key[val.index(m)]
            print(res)
        else:
            print("NO COLOR")
    else:break

Submission status: Accepted

Solution code:
while True:
    N = int(input())
    if N == 0:
        break
    A = list(map(int, input().split()))
    A.sort()
    m = 0
    flag = True
    for i in range(N):
        m += 1
        if i == N - 1 or A[i] != A[i + 1]:
            if 2 * m > N:
                print(A[i])
                flag = False
                break
            m = 0
    if flag:
        print("NO COLOR")

Submission status: Accepted

Solution code:
# AOJ 1008: What Color Is The Universe?
# Python3 2018.7.4 bal4u

import sys
from sys import stdin
input = stdin.readline
 	
from collections import Counter
while True:
	n = int(input())
	if n == 0: break
	a = tuple(map(int, input().split()))
	x, w = Counter(a).most_common()[0]
	print(x if w>(n>>1) else "NO COLOR")

Submission status: Accepted

Solution code:
while True:
    n=input()
    if n==0:break
    A=map(int,raw_input().split())
    A.sort()
    cnt=0
    pre=A[0]
    for c in A:
        if c==pre:
            cnt+=1
            if cnt>n/2:
                print c
                break
        else:
            cnt=1
            pre=c
    else:
        print "NO COLOR"

Submission status: Accepted

Solution code:
while 1:
	n = input()
	if n == 0: break
	A = sorted(map(int,raw_input().split()))
	c,l = A[0],1
	for i in range(1,n):
		if A[i] == c:
			l += 1
			if l > n/2:
				print c
				break
		else:
			c = A[i]
			l = 1
	else:
		print c if l > n/2 else "NO COLOR"

Submission status: Accepted

Solution code:
while 1:
    n = input()
    if n == 0: break
    A = sorted(map(int,raw_input().split()))
    c,l = A[0],0
    for i in A:
        if i == c:
            l += 1
            if l > n/2:
                print c
                break
        else:
            c = i
            l = 1
    else:
        print "NO COLOR"

Submission status: Accepted

Solution code:
while 1:
    n = input()
    if n == 0: break
    A = map(int,raw_input().split())
    A.sort()
    c,l = A[0],0
    for i in A:
        if i == c:
            l += 1
            if l > n/2:
                print c
                break
        else:
            c = i
            l = 1
    else:
        print "NO COLOR"

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    n = input()
    if n == 0:
        break
    A = map(int, raw_input().split())
    m = {}
    for i in A:
        if i in m:
            m[i] += 1
        else:
            m[i] = 1
    ans = [key for key in m if m[key] * 2 > len(A)]
    print ans[0] if len(ans) > 0 else "NO COLOR"

Submission status: Accepted

Solution code:
from collections import Counter
while 1:
    N = int(input())
    if N == 0:
        break
    ct = Counter(map(int, input().split()))
    (a, b), *c = ct.most_common()
    if b*2 > N:
        print(a)
    else:
        print("NO COLOR")

Submission status: Output Limit Exceeded

Solution code:
while True:
    num=int(input())
    if num==0:
        break
    stars=sorted(input().split())
    print(stars)
    if stars.count(stars[num//2]) > num/2 :
        print(stars[num//2])
    else:
        print("NO COLOR")

Submission status: Output Limit Exceeded

Solution code:
while True:
    a = int(input())
    if a == 0: break
    cnt = 1
    flag=0
    li = input().split()
    lis = sorted(li)
    print(lis)
    for i in range(len(lis)-1):
        if lis[i]==lis[i+1]:
            cnt+=1
            if cnt>a/2:
                print(lis[i])
                flag=1
                break
        else: cnt=1
        if cnt>a/2:
                print(lis[i])
                flag=1
                break

    if flag==0:
        print("NO COLOR")

Submission status: Runtime Error

Solution code:
while 1:
    nums = int(input())
    if nums != 0:
        stars = list(map(int,input().split()))
        cnt = [0 for i in range((2*31)-1)]
        for x in stars:
            cnt[x] += 1
        m = max(cnt)
        if m > nums/2:
            res = cnt.index(m)
            print(res)
        else:
            print("NO COLOR")
    else:break

Submission status: Runtime Error

Solution code:
while 1:
	size_a=int(input())
	if size_a==0:
		break
	a = list(int(input().split()))
	check = []
	cond=0
	for i in range(size_a):
		if a[i] in check:
			pass
		elif a.count(a[i]) > int(size_a/2):
			print(a[i])
			cond=1
			break
		else:
			check.append(a[i])
	if cond==0:
		print('NO COLOR')

Submission status: Runtime Error

Solution code:
while 1:
	size_a=int(input())
	if size_a==0:
		break
	a = list(map(int,input().split()))
	check = []
	cond=0
	for i in range(size_a):
		if a[i] in check:
			pass
		elif a.count(a[i]) > int(size_a/2):
			print(a[i])
			cond=1
			break
		else:
			check.append(a[i])
	if cond==0:
		print('NO COLOR')

Submission status: Runtime Error

Solution code:
import sys

def count(i,data):
    res = 0
    for x in data:
        if(x == i):
            res += 1
    return res

def print_color(size,data):
    data = sorted(data)
    for i in data:
        if(count(i,data) > int(size / 2)):
            print(i)
            return
    print("NO COLOR")

l = []
for i in sys.stdin:
    l.append(i)

for i in range(0,len(l),2):
    l[i] = int(l[i])
    if(i < len(l) - 1):
        l[i+1] = l[i+1].split()
        for j in range(0,len(l[i+1])):
            l[i+1][j] = int(l[i+1][j])

for i in range(0,len(l),2):
    if(l[i] != 0):
        print_color(l[i],l[i+1])

Submission status: Runtime Error

Solution code:
import sys

def count(i,data):
    res = 0
    for x in data:
        if(x == i):
            res += 1
    return res

def print_color(size,data):
    data = sorted(data)
    for i in data:
        if(count(i,data) > int(size / 2)):
            print(i)
            return
    print("NO COLOR")

l = []
for i in sys.stdin:
    l.append(i)

for i in range(0,len(l),2):
    if(isinstance(l[i],str) == True):
        continue
    l[i] = int(l[i])
    if(i < len(l) - 1):
        l[i+1] = l[i+1].split()
        for j in range(0,len(l[i+1])):
            l[i+1][j] = int(l[i+1][j])

for i in range(0,len(l),2):
    if(l[i] != 0):
        print_color(l[i],l[i+1])

Submission status: Runtime Error

Solution code:
ans = []
while True:
    n = input()
    n2 = n / 2
    if n == 0:
        break
    lst = [0] * n
    col = map(int,raw_input().split())
    for i in col:
        lst[i] += 1
    flag = 0
    for i in lst:
        if i > n2:
            flag = 1
            ans.append(lst.index(i))
            break
    if flag == 0:
        ans.append("NO COLOR")

for i in ans:
    print i

Submission status: Runtime Error

Solution code:
while True:
    n=input()
    if n==0:break
    A=map(int,raw_input().split())
    S=set(A)
    for c in S:
        if A.count(c)>n/2:
            print c
            break
    else:
        print "NO COLOR"

Submission status: Runtime Error

Solution code:
while True:
    n = int(raw_input())
    a = []
    for i in range(n):
        a.append(int(raw_input())
    b = list(set(a))
    flag = 0
    for i in b:
        if a.count(i) > n/2.0:
            ans = i
            flag = 1
    print ans if flag = 1 else "NO COLOR"

Submission status: Runtime Error

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break
    a = map(int, raw_input().split())
    b = list(set(a))
    flag = 0
    for i in b:
        if a.count(i) > n/2.0:
            ans = i
            flag = 1
            break
    print ans if flag = 1 else "NO COLOR"