Задача A. Количество слов

Автор:Московская олимпиада для 7-9 кл., 2005   Ограничение времени:3 сек
Входной файл:d.in   Ограничение памяти:64 Мб
Выходной файл:d.out  

Условие

Во входном файле записана строка текста, в которой могут встречаться:

Слово — это последовательность подряд идущих латинских букв и знаков дефис, ограниченная с обоих концов. В качестве ограничителей могут выступать начало строки, конец строки, пробел, знак препинания, тире. Тире отличается от дефиса тем, что слева и справа от знака дефис пишутся буквы, а хотя бы с одной стороны от тире идет либо начало строки, либо конец строки, либо пробел, либо какой-либо знак препинания, либо еще одно тире.

Напишите программу, определяющую, сколько слов в данной строке текста.

Формат входного файла

Во входном файле записана строка.

Формат выходного файла

В выходной файл выведите одно число — количество слов, которые содержатся в исходной строке.

Ограничения

Входная строка имеет длину не более 200 символов.

Примеры тестов

Входной файл (d.in) Выходной файл (d.out)
1
Hello , world!
2
2
www.olympiads.ru
3
3
Gyro-compass - this is a ...
4

Задача B. Двухцветная полоса

Автор:А. Кленин   Ограничение времени:1 сек
Входной файл:input.txt   Ограничение памяти:256 Мб
Выходной файл:output.txt  

Условие

Дана полоса, состоящая из N разноцветных клеток. Требуется написать программу, которая найдёт самый длинный отрезок этой полосы, состоящий из клеток не более двух разных цветов.

Формат входного файла

Входной файл содержит единственную строку, состоящую из малых латинских букв. Каждая буква обозначает клетку определённого цвета, разные цвета соответствуют разным буквам.

Формат выходного файла

Выходной файл должен содержать два числа P L, где P — номер первого символа искомого отрезка, L — его длина. Нумерация клеток начинается с 1.

Если существует несколько оптимальных решений, выведите решение с минимальным значением P.

Ограничения

1 ≤ N ≤ 106

Примеры тестов

Входной файл (input.txt) Выходной файл (output.txt)
1
xxxxx
1 5
2
abbaaccca
4 6

Problem C. Inclination

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

Statement

A professor of Fences, Entrances and Frames University has developed a new Fence Inclination theory. According to that theory, a fence is modeled as a sequence of planks. Every plank is either slanted right, represented by character / (ASCII 47), or left, represented by character \ (ASCII 92). For example, a fence of three right-slanted planks followed by two left-slanted planks would be represented by string ///\\.

Fence Inclination theory predicts that plank slants change in steps.

On a single step, the fence is first subdivided into a minimal possible number of plank groups. Each group consists of R ≥ 0 right-slanted planks followed by L ≥ 0 left-slanted planks. In the sample 1 below an initial state is subdivided into 3 groups, while in the sample 2 — into 4 groups.

Next, for every group: if R > L, all planks in the group become right-slanted, if R < L, all planks in the group become left-slanted, if R = L, plank of the group remain unchanged. So after the first step the fence in sample 1 will change into the state //////\\\\.

Steps are repeated until the fence state stops changing.

You program must, given the the initial fence state, output its final state after the changes stop.

Input file format

Input file contains a single string of / and \ characters — representation of the initial fence state.

Output file format

Output file must contain a single string of / and \ characters — representation of the final fence state.

Constraints

The length of the input string is between 1 and 1001 characters.

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
///\\/\/\\
//////////
2
/\\//\/\\///
\\\///\\\///

Problem D. C----

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

Statement

C---- language was designed specifically for students who failed standard course of Compiler Programming. C---- program is a list of statements. Each statement is one of:

Variable names are single small Latin letters. Constants are integers in range from 0 to 109. There are no spaces anywhere except after int and print keywords.

Each variable is declared at most once in the block, but variables with same name may be declared in different blocks. It that case, name refers to the variable declared in the nearest enclosing block. Note that variables may be defined in the middle of the block.

The program is guaranteed to be correct — all blocks are properly balanced, variables are referenced only after declaration, variables are always initialized before reading, etc. Program contains at least one print statement.

Your program must execute a given C---- program.

Input file format

First line of input file contains integer N. Following N lines contain one C---- statement each.

Output file format

Output file must contain a sequence of integers — one integer for each print statement.

Constraints

3 ≤ N ≤ 1000

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
10
int a
int x
{
a=50
int a
a=60
x=a
print x
}
print a
60
50

0.259s 0.011s 19