## Problem S1: It's Cold Here!

Canada is cold in winter, but some parts are colder than others. Your task is very simple - you need to find the coldest city in Canada. So, when given a list of cities and their temperatures, you are to determine which city in the list has the lowest temperature and is thus the coldest.

### Input

The input is a sequence of city names and temperature values. Temperatures are integer, possibly preceded with a minus sign. There is a single space between the city name and the temperature. No city name contains any whitespace and is always less than 256 characters in length. There is at least one city in the list, no more than 10000 cities, and the last city is always Waterloo. You may assume that the temperature is not less than -273 and not more than 200.

### Output

You are to output the name of the coldest city on a single line with no whitespace before or after the name. You may assume that there will not be more than one city which is the coldest.

### Sample Input

```Saskatoon -20
Toronto -2
Winnipeg -40
Vancouver 8
Halifax 0
Montreal -4
Waterloo -3```

### Sample Output

`Winnipeg`

Point Value: 5
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 think my code is right, but when I submit it, it keeps saying my output is 'Waterloo' It even happens when you make your code specifically output something else, so there must be something wrong...

• (0/0)
Your parser is one character off.
``writeln('Parsed: ', city, ' ', temp, ' (', t, ')');``
right before
``t1:=temp;``
to see what I mean.)

• (0/0)
okay, i fixed that, but it still says that I'm always outputting 'Waterloo'

• (0/0)
The val method has the following prototype:
``procedure Val(const s: string; var v; var code: word);``

It takes the string s and tries converting it into a number, held by v. If it fails, it stores the position of the failure in code. (If it succeeds, Code is set to zero.)

Add the snippet I asked you to attach to your code and run it against the sample data. What is the problem?

• (0/0)
i got it now, thank you.

• (0/0)
I still don't know how to read in a string and an integer seperated by a space. Can anyone help?

• (0/0)
You could read in the whole line and then parse it yourself and use the Val function to convert a string to an integer. Or you could use this: http://www.freepascal.org/docs-html/rtl/sysutils/sscanf.html

• (0/0)
The website has too little information. Can you explain to me how to use it in the code to read in stuff? I still don't get it.

• (0/0)
You could also read StealthAdept's suggestion (which you will find at the bottom of this page). I think the page I linked you to does give you enough information, but if you haven't learned pointers yet, then I guess it might not make that much sense. StealthAdept's suggestion is better anyway.

• (0/0)
Okay, so it's repeating read(char) until char=' ' and then keep adding to a string right? And after that, readln. Thank you.

• (0/0)
"You can also try reading individual characters and putting them at the end of a string until you get to a space, at which point you read an integer."

• (0/0)
yeah...about that...my code still doesnt work...check it for me plz?

• (0/0)
yeah kk i got it
thnx to brian
Ur Awesome :) btw, wat grade r u in?

• (0/0)
I graduated from Woburn last year. I'm a first-year university student now.

• (1/0)
As said above, though, there is no need for an array.
It's actually much simpler to code this way, too.

• (0/0)
found the problem...this problem is a pain

• (0/1)

• (0/0)
Yes, although it's not necessary for this problem. And I advise you to try things before you ask us if they'll work or not.

• (0/0)
i did try..but it didnt work. btw...this is pascal

• (0/0)
Evidently, the problem with your submissions is not that you aren't allowed to have arrays of strings, but rather what is discussed below, the difficulty of reading the input in Pascal.

Also, an array of 10000 strings won't compile in Turbo Pascal - that uses too much memory. An array of 200 strings would fit, though.

• (1/1)
lol, love how all the pascal solutions are faster than C++

• (0/0)
Aarg, I was going to submit a fast C++ solution, but I've exceeded the 3/5 ptr limit.

Basically it's because C++ strings are slow.

• (0/0)
I tried to read in 2 variables of different types continuously in Pascal, but it only gave me errors of ... lol

• (1/2)
read in the string and parse it manually. i.e. separate the string and number yourself.

the reason you can't do something like this (It's been while since I coded in pascal),