## Problem A. Elementary arithmetic ≡

 Author: A. Zhuplev, A. Klenin Input file: input.txt Time limit: 1 sec Output file: output.txt Memory limit: 256 Mb

### Statement

Underwater arithmetic is very elementary. There are just two operations: WITH and WITHOUT which mean addition and subtraction respectively.

Underwater mathematicians did not yet invent brackets, so all expressions are calculated from right to left. For example, the expression 3 WITH 5 WITHOUT 4 WITHOUT 7 is calculated as (3 + (5 − (4 − 7))).

Scientists of Nearsea Institute of Underwater Arithmetic need a program to evaluate such expressions.

### Input file format

First line of input file contains a single integer N. Following 2 × N + 1 lines describe the expression. Odd lines contain integer operands, even lines contain operations.

### Output file format

Output file must contain a single integer — calculation result.

### Constraints

1 ≤ N ≤ 103

All operands are in range from 0 to 103.

### Sample tests

No. Input file (input.txt) Output file (output.txt)
1
1
2
WITH
3
5
2
3
10
WITHOUT
5
WITH
3
WITH
15
-13

## Problem B. How many iterations? ≡

 Author: I. Tuphanov Input file: input.txt Time limit: 1 sec Output file: output.txt Memory limit: 256 Mb

### Statement

Young programmer Vasya is learning the beginnings of the algorithm complexity theory. For starters, he wants to be able to quickly estimate the number of iterations of nested loops. As a first example, he wrote the following code:

 C Pascal long long f(int n) { long long ans = 0; for (int i = 1; i <= n; i++) for (int j = i+1; j <= n; j++) for (int k = j+1; k <= n; k++) ans++; return ans; }  function f(n: integer): int64; var i, j, k: integer; begin result := 0; for i := 1 to n do for j := i+1 to n do for k := j+1 to n do inc(result); end; 

Using your knowledge of the subject, help Vasya calculate f(n) for given n.

### Input file format

Input file contains an integer n.

### Output file format

Output file must contain a single integer — f(n).

1 ≤ n ≤ 106

### Sample tests

No. Input file (input.txt) Output file (output.txt)
1
1

0
2
1000
166167000


## Problem C. Judging tires ≡

 Author: A. Zhuplev Input file: input.txt Time limit: 1 sec Output file: output.txt Memory limit: 256 Mb

### Statement

According to ISO stadnard Metric tire code, tire dimensions are described by a string of letters and numbers in the following format:

• 3-digit nonzero number: The nominal section width of the tire in millimeters, the widest point from both outer edges.
• /: Slash character for separation.
• 2- or 3-digit nonzero number: The aspect ratio of the sidewall height to the nominal section width of the tire, as a percentage.
• Letter R indicating radial construction of the fabric carcass of the tire.
• 2-digit nonzero number: Diameter in inches of the wheel disk that the tires are designed to fit.

Rules of ACM (Any Car Modification) race specify a fixed tire dimensions for all participating cars. Young racer Vasya has not been able to find this type of tire. However, his car will still be approved for the race by judges only if radius of the wheel (wheel disk radius plus sidewall height) differs by at most K percent from that of the specified tire.

Note: 1 inch = 25.4 millimeters. Number a differs from b by at most c percent when 100 × |a − b| / b ≤ c.

### Input file format

First line of input file contains integer K.

Second and third lines contain Metric tire codes of specified tire and Vasya's tire respectively. Tire codes contain only digits, R and slash (ASCII 47) characters.

### Output file format

Output file must contain a single string — APPROVED if Vasya's car is approved to the race or DISAPPROVED otherwise.

0 ≤ K ≤ 100

### Sample tests

No. Input file (input.txt) Output file (output.txt)
1
2
195/65R15
205/55R15

DISAPPROVED
2
1
195/65R15
185/070R15

APPROVED

0.046s 0.007s 13