T-Shirt Hunt
Contest: Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
Difficulty rating: 1300
Tags: brute force, implementation

Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.

Unfortunately, you didn't manage to get into top 25, but you got into top 500, taking place p.

Now the elimination round of 8VC Venture Cup 2017 is being held. It has been announced that the Codecraft-17 T-shirt winners will be chosen as follows. Let s be the number of points of the winner of the elimination round of 8VC Venture Cup 2017. Then the following pseudocode will be executed:

Here "div" is the integer division operator, "mod" is the modulo (the remainder of division) operator.

As the result of pseudocode execution, 25 integers between 26 and 500, inclusive, will be printed. These will be the numbers of places of the participants who get the Codecraft-17 T-shirts. It is guaranteed that the 25 printed integers will be pairwise distinct for any value of s.

You're in the lead of the elimination round of 8VC Venture Cup 2017, having x points. You believe that having at least y points in the current round will be enough for victory.

To change your final score, you can make any number of successful and unsuccessful hacks. A successful hack brings you 100 points, an unsuccessful one takes 50 points from you. It's difficult to do successful hacks, though.

You want to win the current round and, at the same time, ensure getting a Codecraft-17 T-shirt. What is the smallest number of successful hacks you have to do to achieve that?

Input format:
The only line contains three integers p, x and y (26 ≤ p ≤ 500; 1 ≤ y ≤ x ≤ 20000) — your place in Codecraft-17, your current score in the elimination round of 8VC Venture Cup 2017, and the smallest number of points you consider sufficient for winning the current round.

Output format:
Output a single integer — the smallest number of successful hacks you have to do in order to both win the elimination round of 8VC Venture Cup 2017 and ensure getting a Codecraft-17 T-shirt.

It's guaranteed that your goal is achievable for any valid input data.

Constraints:
Time limit: 2.0 s
Memory limit: 256.0 MB

Note:
In the first example, there is no need to do any hacks since 10880 points already bring the T-shirt to the 239-th place of Codecraft-17 (that is, you). In this case, according to the pseudocode, the T-shirts will be given to the participants at the following places:

In the second example, you have to do two successful and one unsuccessful hack to make your score equal to 7408.

In the third example, you need to do as many as 24 successful hacks to make your score equal to 10400.

In the fourth example, it's sufficient to do 6 unsuccessful hacks (and no successful ones) to make your score equal to 6500, which is just enough for winning the current round and also getting the T-shirt.

Example input:
239 10880 9889

Example output:
0

Example input:
26 7258 6123

Example output:
2

Editorial:
This problem was inspired by this comment: http://codeforces.com/blog/entry/49663#comment-337281. The hacks don't necessarily have to be stupid, though :)
Initially, we have x points. To win the current round, we need to score any number of points s such that s ≥ y.
If we know our final score s, we can check if we get the T-shirt using the given pseudocode. Moreover, since hacks change our score only by multiples of 50, the difference s - x has to be divisible by 50.
Naturally, out of all s satisfying the conditions above, we need to aim at the smallest possible s, since it's easy to decrease our score, but difficult to increase.
How many successful hacks do we need to make our score equal to s?
If s ≤ x, we need 0 successful hacks, since we can just make (x - s) / 50 unsuccessful hacks.
If s > x and s - x is divisible by 100, we need exactly (s - x) / 100 successful hacks.
If s > x and s - x is not divisible by 100, we need (s - x + 50) / 100 successful hacks and one unsuccessful hack.
All these cases can be described by a single formula for the number of successful hacks: (max(0, s - x) + 50) / 100 (here " / " denotes integer division).
The constraints were low enough, and the number of required hacks was also low enough. A less effective but easier solution can be achieved if we just iterate over both the number of successful and unsuccessful hacks we make. Once we know these two numbers, we know our final score s and we can explicitly check if this score gives us both the victory and the T-shirt.