+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
Recently, the Computer Engineering Department has launched its professional education under the title of *“Micromasters”*, which has been well received by audiences from various universities. Undoubtedly, the quality of these classes played a significant role in this reception. One of the quality factors is to limit the number of registrations for a class. Although the registration for this semester has ended, the director of professional education has decided to limit the number of registrations for each class to 50 and make an urgent decision for the classes with more than 50 students registered. Help the director of professional education to identify which classes have more than 50 students registered.
# ورودی
The only line of the input consists of $n$ $(1 \leq n \leq 100)$, the number of registrations in a class.
# خروجی
In the only line of output, Print `Yes` if $n > 50$, and `No` otherwise.
## ورودی نمونه ۱
```
45
````
## خروجی نمونه ۱
```
No
````
## ورودی نمونه ۲
```
50
````
## خروجی نمونه ۲
```
No
````
## ورودی نمونه ۳
```
78
````
## خروجی نمونه ۳
```
Yes
````
Micromasters
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
Recently, the Computer Engineering Department has launched its professional education under the title of “Micromasters”, which has been well received by audiences from various universities. Undoubtedly, the quality of these classes played a significant role in this reception. One of the quality factors is to limit the number of registrations for a class. Although the registration for this semester has ended, the director of professional education has decided to limit the number of registrations for each class to 50 and make an urgent decision for the classes with more than 50 students registered. Help the director of professional education to identify which classes have more than 50 students registered.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
Sara, who is deeply concerned about air pollution, has sold her car and bought a horse. She happily leads the horse to the parking lot and takes a very long string of pasta from the kitchen, which she gives to the horse. The horse happily takes several bites of pasta. Sara’s father, who notices the disappearance of the pasta string, finds the remaining pieces of pasta in the parking lot. Being an intelligent person, he knows that the horse selects a piece of pasta longer than 3 inches for each bite. Then, by biting 3 inches from the middle of the selected piece, she divides it into two pieces.
Given the lengths of the remaining pasta pieces, help Sara’s father determine the length of the initial pasta string.
# ورودی
The first line of the input contains an integer $n$ $(1 \leq n \leq 100)$, which is the number of remaining pasta pieces. The next line contains a sequence $l_1, l_2, \dots, l_n$ of $n$ integers, where $l_i$ $(1 \leq l_i \leq 1000)$ represents the length of the $i$-th remaining pasta piece.
# خروجی
In the only line of output, print the length of the initial pasta string.
## ورودی نمونه ۱
```
2
2 5
```
# خروجی نمونه ۱
```
10
```
## ورودی نمونه ۲
```
2
2 5
````
## خروجی نمونه ۲
```
10
````
Sara and Horse
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
Sara, who is deeply concerned about air pollution, has sold her car and bought a horse. She happily leads the horse to the parking lot and takes a very long string of pasta from the kitchen, which she gives to the horse. The horse happily takes several bites of pasta. Sara’s father, who notices the disappearance of the pasta string, finds the remaining pieces of pasta in the parking lot. Being an intelligent person, he knows that the horse selects a piece of pasta longer than 3 inches for each bite. Then, by biting 3 inches from the middle of the selected piece, she divides it into two pieces.
Given the lengths of the remaining pasta pieces, help Sara’s father determine the length of the initial pasta string.
The first line of the input contains an integer n(1≤n≤100), which is the number of remaining pasta pieces. The next line contains a sequence l1,l2,…,ln of n integers, where li(1≤li≤1000) represents the length of the i-th remaining pasta piece.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
---
Sara wants to entertain her niece with $n$ coins she has in her pocket. To do this, she arranges a game. In this game, several coins should initially be placed on the table. Then, in each turn, a player must remove either $1$ or exactly $4$ coins from the table and pass the turn to the other player. The winner is the person who takes the last coin or coins. Sara, due to her love for her niece, allows her niece to start the game. Help Sara determine whether she can definitely win the game by placing all her coins on the table or not.
# ورودی
The input consists of a single integer $n$ $(1 \leq n \leq 10^{18})$, which represents the number of coins Sara has.
# خروجی
In the only line of output, print `Yes` if Sara has a guaranteed winning strategy, and `No` otherwise.
## ورودی نمونه 1
```
1
```
## خروجی نمونه 1
```
No
```
## ورودی نمونه 2
```
2
```
## خروجی نمونه 2
```
Yes
```
The Niece
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
Sara wants to entertain her niece with n coins she has in her pocket. To do this, she arranges a game. In this game, several coins should initially be placed on the table. Then, in each turn, a player must remove either 1 or exactly 4 coins from the table and pass the turn to the other player. The winner is the person who takes the last coin or coins. Sara, due to her love for her niece, allows her niece to start the game. Help Sara determine whether she can definitely win the game by placing all her coins on the table or not.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
---
Majid has a binary string of length $n$ with only 1 values. One morning, his niece accidentally finds this string and starts destroying it. She destroys the string in $t$ steps. The niece first chooses a sequence of integers: $1 \leq a_1 \leq a_2 \leq \dots \leq a_t \leq n$. Then, in the $i$-th step, she selects the first $a_i$ bits and destroys this part as follows:
- First, she negates all the selected bits.
- Then, she reverses the order of the selected part.
To be more precise, if the binary string before the $i$-th step is as follows:
$$S = s_1 s_2, \dots, s_n$$
The binary string after the $i$-th step will be as follows, where $\bar{s}_i$ represents the negation of bit $s_i$:
$$S = \bar{s}_{a_i}, \bar{s}_{a_i-1}, \dots, \bar{s}_1, s_{a_i+1}, \dots, s_n$$
Majid wants to restore the string to its initial state using his superpower. Each time Majid uses his superpower, he chooses two numbers $1 \leq l \leq r \leq n$. Then, magically, all the bits in positions from $l$ to $r$ inclusive are negated. This interval includes the bits at positions $l$ and $r$ themselves. The positions of the bits are considered from left to right, and the leftmost bit has a position of $1$.
Help Majid restore the string to its initial state with the fewest number of uses of his superpower.
# ورودی
The first line of the input consists of two integers $n$ $(1 \leq n \leq 10^{18})$ and $t$ $(1 \leq t \leq 10^5)$ separated by a space, which is the length of the string and the number of steps of string destruction, respectively.
The second line contains a sequence of integers $a_1, a_2, \dots, a_t$ $(1 \leq a_i \leq n)$, chosen by the niece.
# خروجی
Print $k$, the minimum number of times Majid needs to use his superpower in the first line.
Then, in the $(i+1)$th line $(1 \leq i \leq k)$ of the output, print the interval that Majid chooses in his use of superpower as two numbers separated by a space, in ascending order.
## ورودی نمونه 1
```
5 2
2 5
```
## خروجی نمونه 1
```
1
1 3
```
## ورودی نمونه 2
```
5 2
3 3
```
## خروجی نمونه 2
```
0
```
Binary Majid
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
Majid has a binary string of length n with only 1 values. One morning, his niece accidentally finds this string and starts destroying it. She destroys the string in t steps. The niece first chooses a sequence of integers: 1≤a1≤a2≤⋯≤at≤n. Then, in the i-th step, she selects the first ai bits and destroys this part as follows:
First, she negates all the selected bits.
Then, she reverses the order of the selected part.
To be more precise, if the binary string before the i-th step is as follows:
S=s1s2,…,sn
The binary string after the i-th step will be as follows, where sˉi represents the negation of bit si:
S=sˉai,sˉai−1,…,sˉ1,sai+1,…,sn
Majid wants to restore the string to its initial state using his superpower. Each time Majid uses his superpower, he chooses two numbers 1≤l≤r≤n. Then, magically, all the bits in positions from l to r inclusive are negated. This interval includes the bits at positions l and r themselves. The positions of the bits are considered from left to right, and the leftmost bit has a position of 1.
Help Majid restore the string to its initial state with the fewest number of uses of his superpower.
The first line of the input consists of two integers n(1≤n≤1018) and t(1≤t≤105) separated by a space, which is the length of the string and the number of steps of string destruction, respectively. The second line contains a sequence of integers a1,a2,…,at(1≤ai≤n), chosen by the niece.
Print k, the minimum number of times Majid needs to use his superpower in the first line. Then, in the (i+1)th line (1≤i≤k) of the output, print the interval that Majid chooses in his use of superpower as two numbers separated by a space, in ascending order.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
---
Anumber of ants are located on a two-dimensional plane, and each ant moves either upward or rightward. In each step, each ant moves one unit forward in its direction. More precisely, consider an ant located at coordinates $(x_i,y_i)$ before the $i-th$ step. If the ant moves upward, its coordinates after the $i-th$ step will be $(x_i,y_i + 1)$, and if it moves rightward, its coordinates after the $i-th$ step will be $(x_i + 1,y_i)$. Initially, no two ants are located at the same coordinates. If two ants collide at the same coordinate in a step, before the next step begins, their movement direction changes from up to right and from right to up. Sara is curious to know the total number of collisions. Given the initial coordinates of the ants and their directions of movement, calculate the total number of collisions for Sara.
# ورودی
The first line of the input contains an integer $n$ $(2 \leq n \leq 2*10^5)$, which is the the number of ants. Then, for each $1 \leq i \leq n$, the $(i+1)th$ line of the input contains two space-separated integers $x_i$ and $y_i$ $(1 \leq x_i,y_i \leq 10^9)$, and one of the letters `U` or `R`. The integers denote the initial coordinates of the $i-th$ ant, and the letter indicates the initial direction of movement. The letter `U` represents upward movement, and the letter `R` represents rightward movement.
# خروجی
In the only line of output, print the total number of collisions if it is finite, and the word inf otherwise.
## ورودی نمونه 1
```
3
1 2 R
2 1 U
3 1 U
```
## خروجی نمونه 1
```
1
```
## ورودی نمونه 2
```
4
1 4 U
1 2 U
1 3 U
1 1 U
```
## خروجی نمونه 2
```
0
```
Ants’ Movements
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
Anumber of ants are located on a two-dimensional plane, and each ant moves either upward or rightward. In each step, each ant moves one unit forward in its direction. More precisely, consider an ant located at coordinates (xi,yi) before the i−th step. If the ant moves upward, its coordinates after the i−th step will be (xi,yi+1), and if it moves rightward, its coordinates after the i−th step will be (xi+1,yi). Initially, no two ants are located at the same coordinates. If two ants collide at the same coordinate in a step, before the next step begins, their movement direction changes from up to right and from right to up. Sara is curious to know the total number of collisions. Given the initial coordinates of the ants and their directions of movement, calculate the total number of collisions for Sara.
The first line of the input contains an integer n(2≤n≤2∗105), which is the the number of ants. Then, for each 1≤i≤n, the (i+1)th line of the input contains two space-separated integers xi and yi(1≤xi,yi≤109), and one of the letters U or R. The integers denote the initial coordinates of the i−th ant, and the letter indicates the initial direction of movement. The letter U represents upward movement, and the letter R represents rightward movement.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
---
Sara wants to hold a birthday party for her niece. In this ceremony, the guests form a circle around the niece and cheer her up. But the problem is that the heights of the guests present at the birthday party is very different. Therefore, if these guests are randomly placed in the circle, due to the difference in height, they may not be able to hold each other’s hands and form the ring. The desired arrangement is a circular arrangement of guests in which the maximum height difference between consecutive individuals is minimum (there may be more than one desired arrangement). For example, if the heights of guests are $3,2,2,4,3,1$, one desired arrangement could be as follows, where the maximum height difference between consecutive individuals is $1$.

By receiving the heights of guests, calculate the maximum height difference between consecutive individuals in a desired arrangement.
# ورودی
The first line of the input contains an integer $n$ $(2 \leq n \leq 10^5)$, which is the the number of guests. The next line contains a sequence $l_1,l_2,...,l_n$ of $n$ integers, where $l_i$ $(1 \leq l_i \leq 10^9)$ represents the height of the $i-th$ guests.
# خروجی
In the only line of output, print the maximum difference in height between two consecutive individuals in a desired circular arrangement.
## ورودی نمونه 1
```
5
2 1 1 3 2
```
## خروجی نمونه 1
```
1
```
## ورودی نمونه 2
```
3
30 10 20
```
## خروجی نمونه 2
```
20
```
Birthday Party
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
Sara wants to hold a birthday party for her niece. In this ceremony, the guests form a circle around the niece and cheer her up. But the problem is that the heights of the guests present at the birthday party is very different. Therefore, if these guests are randomly placed in the circle, due to the difference in height, they may not be able to hold each other’s hands and form the ring. The desired arrangement is a circular arrangement of guests in which the maximum height difference between consecutive individuals is minimum (there may be more than one desired arrangement). For example, if the heights of guests are 3,2,2,4,3,1, one desired arrangement could be as follows, where the maximum height difference between consecutive individuals is 1.
By receiving the heights of guests, calculate the maximum height difference between consecutive individuals in a desired arrangement.
The first line of the input contains an integer n(2≤n≤105), which is the the number of guests. The next line contains a sequence l1,l2,...,ln of n integers, where li(1≤li≤109) represents the height of the i−th guests.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
---
Majid has $n$ cubic bricks with a unit side length. He wants to arrange these bricks as adjacent columns, such that the height of each column is not less than the height of the previous column. For example, if Majid has two bricks, he can arrange them in two ways. In the first arrangement, he can form a column with a height of $2$, and in the second arrangement, he can create two columns with heights of $1$ each. Majid wants to know in how many ways he can do this. Given $n$, calculate the number of possible desired arrangements.
# ورودی
The input consists of a single integer $n$ $(1 \leq n \leq 2000)$, which represents the number of bricks Majid has.
# خروجی
Print a single line containing the number of desired arrangements of the bricks. Since this number can be very large, print its remainder modulo $10^9 + 7$.
## ورودی نمونه 1
```
1
```
## خروجی نمونه 1
```
1
```
## ورودی نمونه 2
```
2
```
## خروجی نمونه 2
```
2
```
Arranging Bricks
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
Majid has n cubic bricks with a unit side length. He wants to arrange these bricks as adjacent columns, such that the height of each column is not less than the height of the previous column. For example, if Majid has two bricks, he can arrange them in two ways. In the first arrangement, he can form a column with a height of 2, and in the second arrangement, he can create two columns with heights of 1 each. Majid wants to know in how many ways he can do this. Given n, calculate the number of possible desired arrangements.
Print a single line containing the number of desired arrangements of the bricks. Since this number can be very large, print its remainder modulo 109+7.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
---
After facing numerous challenges, Majid succeeded in escaping from the matrix. Upon exiting the matrix, he finds himself in an elevator on the $s-th$ floor of a building with $f$ floors. Majid quickly realizes that this elevator is not an ordinary one. The elevator has only two buttons: `Up` and `Down`. By pressing these buttons, the elevator moves $u$ floors up or $d$ floors down.
Specifically:
- After pressing `Up` button, if $c+u \leq f$, the elevator goes to floor $c+u$. Otherwise, the elevator remains stationary.
- After pressing `Down` button, if c-d \leq 1, the elevator goes to floor $c-d$. Otherwise, the elevator remains stationary. The only way to exit the building is the $g-th$ floor. Since exiting the elevator shouldn’t be easy, each time Majid presses either the `Up` or `Down` button, he has to pay a high cost. Shocked by the conditions, Majid asks you to calculate the minimum cost for him to exit the building.
# ورودی
In the only input line, you are given integers $f$, $s$, $g$, $u$, and $d$ separated by a space from left to right $(1 \leq s,g \leq f \leq 10^6, 0 \leq u,d \leq10^6)$.
# خروجی
In the only line of output, print the minimum number of times Majid needs to press the elevator buttons to exit the building. If it is impossible to reach from floor $s$ to floor $g$ using the elevator, print `use the stairs`.
## ورودی نمونه 1
```
10 1 10 2 1
```
## خروجی نمونه 1
```
6
```
## ورودی نمونه 2
```
100 2 1 1 0
```
## خروجی نمونه 2
```
use the stairs
```
Exiting the Matrix
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
After facing numerous challenges, Majid succeeded in escaping from the matrix. Upon exiting the matrix, he finds himself in an elevator on the s−th floor of a building with f floors. Majid quickly realizes that this elevator is not an ordinary one. The elevator has only two buttons: Up and Down. By pressing these buttons, the elevator moves u floors up or d floors down.
Specifically:
After pressing Up button, if c+u≤f, the elevator goes to floor c+u. Otherwise, the elevator remains stationary.
After pressing Down button, if c-d \leq 1, the elevator goes to floor c−d. Otherwise, the elevator remains stationary. The only way to exit the building is the g−th floor. Since exiting the elevator shouldn’t be easy, each time Majid presses either the Up or Down button, he has to pay a high cost. Shocked by the conditions, Majid asks you to calculate the minimum cost for him to exit the building.
In the only line of output, print the minimum number of times Majid needs to press the elevator buttons to exit the building. If it is impossible to reach from floor s to floor g using the elevator, print use the stairs.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
---
As spring arrives, Majid plans to beautify his backyard by planting flowers. To achieve this, he has divided his backyard into an $m×n$ grid and has decided to plant red or blue roses in each cell. Majid has a keen eye for colour combinations and wants to ensure that each cells has at most one neighboring cell of the same color. Two cells are considered adjacent if they share at least one side. Given m and $n$, calculate the number of desired ways to arrange the flowers in the grid for Majid. For example, if the dimensions of the grid are $2\times3$, there are $8$ possible ways to arrange the flowers in the grid as shown below:

# ورودی
The first line of the input consists of two integers $m$ $(1 \leq m \leq 10^5)$ and $n$ $(1 \leq n \leq 10^5)$ separated by a space, which is the number of rows and the number of columns, respectively.
# خروجی
Print a single line containing the number of desired ways to plant the flowers. Since this number can be very large, print its remainder modulo $10^9 + 7$.
## ورودی نمونه 1
```
2 3
```
## خروجی نمونه 1
```
8
```
## ورودی نمونه 2
```
1 2
```
## خروجی نمونه 2
```
4
```
Planting Flowers
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
As spring arrives, Majid plans to beautify his backyard by planting flowers. To achieve this, he has divided his backyard into an m×n grid and has decided to plant red or blue roses in each cell. Majid has a keen eye for colour combinations and wants to ensure that each cells has at most one neighboring cell of the same color. Two cells are considered adjacent if they share at least one side. Given m and n, calculate the number of desired ways to arrange the flowers in the grid for Majid. For example, if the dimensions of the grid are 2×3, there are 8 possible ways to arrange the flowers in the grid as shown below:
The first line of the input consists of two integers m(1≤m≤105) and n(1≤n≤105) separated by a space, which is the number of rows and the number of columns, respectively.
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
---
The subway system in Barareh consists of $n$ stations and $m$ subway lines. The stations are numbered from $1$ to $n$. Each line is managed by a company and each company has a unique identifier. The $i-th$ subway line $(1 \leq i \leq m)$ is managed by company $c_i$ and connects only two stations, $p_i$ and $q_i$, in both directions. When arriving at a station, if more than one subway line is connected to that station, passengers can easily switch between lines. The cost of using the subway in Barareh is a bit different.
When a passenger uses only subway lines operated by a single company, he only need to pay $1$ Bararehian dollar. However, if a passenger changes their subway line at a station, and these two lines are managed by different companies, he have to pay an additional $1$ Bararehian dollar. In other words, the passenger pays $1$ Bararehian dollar at the first station, and then at each intermediate station, they only need to pay an additional $1$ Bararehian dollar if the two lines used for arriving and departing the station belong to different companies.
Calculate the minimum cost required to travel from station $1$ to station $n$.
# ورودی
The first line of the input consists of two integers $n$ $(2 \leq n \leq 10^5)$ and $m$ $(0 \leq m \leq 2*10^5)$ separated by a space, which is the number of stations and the number of subway lines, respectively. Then, for each $1 \leq i \leq m$ , the $(i + 1)-th$ line of input contains three integers $p_i$, $q_i$, and $c_i$ $(1 \leq ci \leq 10^6)$, separated by a space $(p_i \neq q_i, 1 \leq p_i,q_i \leq n)$.
# خروجی
In the only line of output, if it is impossible to travel from station $1$ to station $n$ using the subway lines, print $1$. Otherwise, print the minimum cost required to travel from station $1$ to station $n$.
## ورودی نمونه 1
```
3 3
1 2 1
2 3 1
3 1 2
```
## خروجی نمونه 1
```
1
```
## ورودی نمونه 2
```
8 11
1 3 1
1 4 2
2 3 1
2 5 1
3 4 3
3 6 3
3 7 3
4 8 4
5 6 1
6 7 5
7 8 5
```
## خروجی نمونه 2
```
2
```
In the example above, initially, one can traverse the following path by paying $1$ Bararehian dollar: $1->3->2->5->6$
Then, with another $1$ Bararehian dollar payment, continue the path as follows: $6-> 7 ->8$.
Travel
محدودیت زمان: ۱ ثانیه
محدودیت حافظه: ۲۵۶ مگابایت
The subway system in Barareh consists of n stations and m subway lines. The stations are numbered from 1 to n. Each line is managed by a company and each company has a unique identifier. The i−th subway line (1≤i≤m) is managed by company ci and connects only two stations, pi and qi, in both directions. When arriving at a station, if more than one subway line is connected to that station, passengers can easily switch between lines. The cost of using the subway in Barareh is a bit different.
When a passenger uses only subway lines operated by a single company, he only need to pay 1 Bararehian dollar. However, if a passenger changes their subway line at a station, and these two lines are managed by different companies, he have to pay an additional 1 Bararehian dollar. In other words, the passenger pays 1 Bararehian dollar at the first station, and then at each intermediate station, they only need to pay an additional 1 Bararehian dollar if the two lines used for arriving and departing the station belong to different companies.
Calculate the minimum cost required to travel from station 1 to station n.
The first line of the input consists of two integers n(2≤n≤105) and m(0≤m≤2∗105) separated by a space, which is the number of stations and the number of subway lines, respectively. Then, for each 1≤i≤m , the (i+1)−th line of input contains three integers pi, qi, and ci(1≤ci≤106), separated by a space (pi≠qi,1≤pi,qi≤n).
In the only line of output, if it is impossible to travel from station 1 to station n using the subway lines, print 1. Otherwise, print the minimum cost required to travel from station 1 to station n.
In the example above, initially, one can traverse the following path by paying 1 Bararehian dollar: 1−>3−>2−>5−>6
Then, with another 1 Bararehian dollar payment, continue the path as follows: 6−>7−>8.