## p172ex8 - Mode

Determine the mode of a set of data.

### Input

A sequence of lines. Each line will contain a non-negative integer no greater than 100 and represents one element of the data, except the last line, which contains the single integer -1 and is not part of the data.

### Output

The mode of the set of data. If there is more than one mode, output all modes sorted in ascending order on separate lines.

```2
3
4
4
-1
```

### Sample Output

```4
```

Point Value: 4
Time Limit: 2.00s
Memory Limit: 16M

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

• (0/0)
i can find one mode, but i dont know how to find multiple modes,(note, im asking this for other questions as well). please help me

• (0/0)
I ran my code on my computer (windows cmd) and it works fine but when I submit it says RE? Please take a look at my code and give me a hint on what went wrong?

• (0/0)
The judge version of Python is 2.6.8, and you're trying to use collections.Counter, which was introduced in 2.7.

We may upgrade the version at some point, but for now you'll have to solve this another way. Apologies for the inconvenience.

• (0/1)
Hi,
while programming I stumbled across on how to make the numbers equal the same amount of each other. If anybody could help me it would be much Appreciated.
THX
zainnaiz

• (3/0)
You just do regular assignment. x = y, much as x = int(raw_input()).

• (0/0)
If there is one of every number is every number the mode or does the question exclude this type of input?

• (0/0)
I would not bother thinking about this extreme scenario: a good code should work for this problem no matter if there is one mode, ten modes or even the whole set is a mode.

• (0/0)
Thanx

• (0/0)
Why am I exceeding the time limit.

• (1/0)
your code simply is not fast enough
try approaching this problem in another way or finding optimizations

• (2/1)
Because your code does not produce the correct answer fast enough, obviously.

• (0/0)
If I may suggest, imho you are using one loop too many: you should be able to find the most common element in a single swoop, if your array is set in a particular configuration. Either that or you use another loop in a smarter way, that's your pick.

Btw, even if Python 3 here usually performs rather poorly, even compared to Python 2, know that it can be solved with it (I did) :)

• (0/0)
Thanx to all

• (1/0)
what is the most amount of elements that will be entered

• (0/1)
Longints will suffice.

• (0/0)
If you have the right algorithm, you shouldn't have to worry about how many lines of input there can be.

• (0/0)
Can someone tell me where i am going wrong in my program