7302: CodeChef COMPILER - Compilers and parsers
Description
Lira is now very keen on compiler development. :)
She knows that one of the most important components of a compiler, is its parser.
A parser is, in simple terms, a software component that processes text, and checks it's semantic correctness, or, if you prefer, if the text is properly built.
As an example, in declaring and initializing an integer, in C/C++, you can't do something like:
int = x ;4
as the semantics of such statement is incorrect, as we all know that the datatype must precede an identifier and only afterwards should come the equal sign and the initialization value, so, the corrected statement should be:
int x = 4;
Today, Lira is concerned with an abstract instruction which is composed of the characters "<" and ">" , which she will use on the design of her language, L++ :D.
She is using it as an abstraction for generating xm
So, for instance, the instructions:
<
<
<
are all valid. While:
>>
><
are not.
Given some ex
Input
Input will consist of an integer T denoting the number of test cases to follow.
Then, T strings follow, each on a single line, representing a possible ex
Output
Constraints
1 ≤ The length of a single ex
Sample 1 Input
3
<<>>
><
<>>>
Sample 1 Output
4
0
2