Sequence Generator with Filtering and Transformation
Rust
Medium
iterators
Task «Sequence Generator with Filtering and Transformation»
Write a Rust program that reads an integer N, then N pairs of numbers (a_i, b_i) separated by spaces. Using iterators, form a sequence of numbers a_i for which b_i > 0. Then transform each resulting number by multiplying it by 2 and adding 10. Print the sum of all transformed numbers. If no number passes the filter, print 0.
Input Format
The first line contains an integer N (1 ≤ N ≤ 1000). Then N lines, each contains two integers a_i and b_i (-1000 ≤ a_i, b_i ≤ 1000).
Output Format
One integer — the sum of the converted numbers.
Examples
Example 1
INPUT
6 0
1 2 3 1 2 3
OUTPUT
3
Example 2
INPUT
1
0 0
OUTPUT
0
main.rs