The first line of the input contains two integers n and a (1 ≤ a ≤ n ≤ 100) — the number of cities and the index of city where Limak lives. The second line contains n integers t1, t2, ..., tn (0 ≤ ti ≤ 1). There are ti criminals in the i-th city.

#include<stdio.h>
int main()
{
int n,i,j,pos,counter;
int criminals[100];
counter=0;
scanf("%d%d",&n,&pos);
for(i=0;i<n;i++)
scanf("%d",&criminals[i]);
if(criminals[pos-1]==1)
counter+=1;
for(j=1;j<=i;j++)
{
if((pos-1-j>=0)&&(pos-1+j<n)&&((criminals[pos-1-j]&criminals[pos-1+j])==1))
counter+=2;
else if((pos-1-j>=0)&&(pos-1+j>=n)&&(criminals[pos-1-j]==1))
counter+=1;
else if((pos-1-j<0)&&(pos-1+j<n)&&(criminals[pos-1+j]==1))
counter+=1;}
printf("%d",counter);
return 0;}

NoteIn the first sample, there are six cities and Limak lives in the third one (blue arrow below). Criminals are in cities marked red.  Using the BCD gives Limak the following information:  There is one criminal at distance 0 from the third city — Limak is sure that this criminal is exactly in the third city.  There is one criminal at distance 1 from the third city — Limak doesn't know if a criminal is in the second or fourth city.  There are two criminals at distance 2 from the third city — Limak is sure that there is one criminal in the first city and one in the fifth city.  There are zero criminals for every greater distance. So, Limak will catch criminals in cities 1, 3 and 5, that is 3 criminals in total.In the second sample (drawing below), the BCD gives Limak the information that there is one criminal at distance 2 from Limak's city. There is only one city at distance 2 so Limak is sure where a criminal is.

Print the number of criminals Limak will catch.

There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he knows that there is at most one criminal in each city.Limak is going to use a BCD (Bear Criminal Detector). The BCD will tell Limak how many criminals there are for every distance from a city a. After that, Limak can catch a criminal in each city for which he is sure that there must be a criminal.You know in which cities criminals are. Count the number of criminals Limak will catch, after he uses the BCD.

Input:
6 3
1 1 1 0 1 0

Output: 3

Input:
5 2
0 0 0 1 0

Output: 1

Input:
1 1
1

Output: 1

Input:
1 1
0

Output: 0

Input:
9 3
1 1 1 1 1 1 1 1 0

Output: 8

Input:
9 5
1 0 1 0 1 0 1 0 1

Output: 5

Input:
20 17
1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0

Output: 10

Input:
100 60
1 1 1 1 1 1 0 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 0 0 0 0 1 1 1 0 1 1 0 0 0 1 0 0 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 1 0 0

Output: 27

Input:
8 1
1 0 1 1 0 0 1 0

Output: 4

Input:
11 11
0 1 0 0 1 1 1 0 0 0 0

Output: 4

Input:
19 10
0 1 1 0 1 0 0 1 1 0 0 1 0 1 0 0 1 0 1

Output: 4

Input:
100 38
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 0

Input:
100 38
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 1

Input:
100 38
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 3

Input:
99 38
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 25

Input:
99 38
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 24

Input:
99 38
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 24

Input:
98 70
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 41

Input:
99 70
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 9

Input:
99 60
0 0 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 0 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1

Output: 34

Input:
98 24
0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 1 0 0 1 1 1 0 0 1 0 0 1 0 1 0 0 1 1 0 1 1 1 0 1 0 0 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 0 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 0 0 1 1

Output: 39

Input:
100 100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 100

Input:
100 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 0

Input:
2 1
0 1

Output: 1


The only line contains four integer numbers $$$n$$$, $$$m$$$, $$$a$$$ and $$$b$$$ ($$$1 \le n, m \le 10^{12}$$$, $$$1 \le a, b \le 100$$$), where $$$n$$$ is the initial number of the commentary boxes, $$$m$$$ is the number of delegations to come, $$$a$$$ is the fee to build a box and $$$b$$$ is the fee to demolish a box.

#include<stdio.h>
int main()
{
    long long int c,a,n,m,b,d,e,f;
    scanf("%lld%lld%lld%lld",&n,&m,&a,&b);
    c=n%m;
    d=m-n%m;
    b=b*c;
    a=a*d;
    if(a>b)
        printf("%lld\n",b);
    else
        printf("%lld\n",a);
    return 0;
}

NoteIn the first example organizers can build $$$5$$$ boxes to make the total of $$$14$$$ paying $$$3$$$ burles for the each of them.In the second example organizers can demolish $$$2$$$ boxes to make the total of $$$0$$$ paying $$$7$$$ burles for the each of them.In the third example organizers are already able to distribute all the boxes equally among the delegations, each one get $$$5$$$ boxes.

Output the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by $$$m$$$). It is allowed that the final number of the boxes is equal to $$$0$$$.

Berland Football Cup starts really soon! Commentators from all over the world come to the event.Organizers have already built $$$n$$$ commentary boxes. $$$m$$$ regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied then the delegations will be upset. So each box should be occupied by exactly one delegation.If $$$n$$$ is not divisible by $$$m$$$, it is impossible to distribute the boxes to the delegations at the moment.Organizers can build a new commentary box paying $$$a$$$ burles and demolish a commentary box paying $$$b$$$ burles. They can both build and demolish boxes arbitrary number of times (each time paying a corresponding fee). It is allowed to demolish all the existing boxes.What is the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by $$$m$$$)?

Input: 9 7 3 8

Output: 15

Input: 2 7 3 7

Output: 14

Input: 30 6 17 19

Output: 0

Input: 500000000001 1000000000000 100 100

Output: 49999999999900

Input: 1000000000000 750000000001 10 100

Output: 5000000000020

Input: 1000000000000 750000000001 100 10

Output: 2499999999990

Input: 42 1 1 1

Output: 0

Input: 1 1000000000000 1 100

Output: 100

Input: 7 2 3 7

Output: 3

Input: 999999999 2 1 1

Output: 1

Input: 999999999999 10000000007 100 100

Output: 70100

Input: 10000000001 2 1 1

Output: 1

Input: 29 6 1 2

Output: 1

Input: 99999999999 6 100 100

Output: 300

Input: 1000000000000 7 3 8

Output: 8

Input: 99999999999 2 1 1

Output: 1

Input: 1 2 1 1

Output: 1

Input: 999999999999 2 1 1

Output: 1

Input: 9 2 1 1

Output: 1

Input: 17 4 5 5

Output: 5

Input: 100000000000 3 1 1

Output: 1

Input: 100 7 1 1

Output: 2

Input: 1000000000000 3 100 100

Output: 100

Input: 70 3 10 10

Output: 10

Input: 1 2 5 1

Output: 1

Input: 1000000000000 3 1 1

Output: 1

Input: 804289377 846930887 78 16

Output: 3326037780

Input: 1000000000000 9 55 55

Output: 55

Input: 957747787 424238336 87 93

Output: 10162213695

Input: 25 6 1 2

Output: 2

Input: 22 7 3 8

Output: 8

Input: 10000000000 1 1 1

Output: 0

Input: 999999999999 2 10 10

Output: 10

Input: 999999999999 2 100 100

Output: 100

Input: 100 3 3 8

Output: 6

Input: 99999 2 1 1

Output: 1

Input: 100 3 2 5

Output: 4

Input: 1000000000000 13 10 17

Output: 17

Input: 7 2 1 2

Output: 1

Input: 10 3 1 2

Output: 2

Input: 5 2 2 2

Output: 2

Input: 100 3 5 2

Output: 2

Input: 7 2 1 1

Output: 1

Input: 70 4 1 1

Output: 2

Input: 10 4 1 1

Output: 2

Input: 6 7 41 42

Output: 41

Input: 10 3 10 1

Output: 1

Input: 5 5 2 3

Output: 0

Input: 1000000000000 3 99 99

Output: 99

Input: 7 3 100 1

Output: 1

Input: 7 2 100 5

Output: 5

Input: 1000000000000 1 23 33

Output: 0

Input: 30 7 1 1

Output: 2

Input: 100 3 1 1

Output: 1

Input: 90001 300 100 1

Output: 1

Input: 13 4 1 2

Output: 2

Input: 1000000000000 6 1 3

Output: 2

Input: 50 4 5 100

Output: 10

Input: 999 2 1 1

Output: 1

Input: 5 2 5 5

Output: 5

Input: 20 3 3 3

Output: 3

Input: 3982258181 1589052704 87 20

Output: 16083055460

Input: 100 3 1 3

Output: 2

Input: 7 3 1 1

Output: 1

Input: 19 10 100 100

Output: 100

Input: 23 3 100 1

Output: 2

Input: 25 7 100 1

Output: 4

Input: 100 9 1 2

Output: 2

Input: 9999999999 2 1 100

Output: 1

Input: 1000000000000 2 1 1

Output: 0

Input: 10000 3 1 1

Output: 1

Input: 22 7 1 6

Output: 6

Input: 100000000000 1 1 1

Output: 0

Input: 18 7 100 1

Output: 4

Input: 10003 4 1 100

Output: 1

Input: 3205261341 718648876 58 11

Output: 3637324207

Input: 8 3 100 1

Output: 2

Input: 15 7 1 1

Output: 1

Input: 1000000000000 1 20 20

Output: 0

Input: 16 7 3 2

Output: 4

Input: 1000000000000 1 1 1

Output: 0

Input: 7 3 1 100

Output: 2

Input: 16 3 1 100

Output: 2

Input: 13 4 1 10

Output: 3

Input: 10 4 5 5

Output: 10

Input: 14 3 1 100

Output: 1

Input: 100 33 100 1

Output: 1

Input: 22 7 1 8

Output: 6

Input: 10 4 2 1

Output: 2

Input: 6 4 2 2

Output: 4

Input: 17 4 2 1

Output: 1

Input: 7 3 100 10

Output: 10

Input: 702 7 3 2

Output: 4

Input: 8 3 1 5

Output: 1

Input: 3 2 5 2

Output: 2

Input: 99 19 1 7

Output: 15

Input: 16 3 100 1

Output: 1

Input: 100 34 1 100

Output: 2

Input: 100 33 1 1

Output: 1

Input: 2 3 4 3

Output: 4

Input: 15 4 4 10

Output: 4

Input: 1144108931 470211273 45 79

Output: 11993619960

Input: 2 3 3 4

Output: 3

Input: 29 5 4 9

Output: 4

Input: 15 7 1 5

Output: 5

Input: 1 1 1 1

Output: 0

Input: 1 1 3 4

Output: 0

Input: 10 12 2 1

Output: 4

Input: 1 2 3 4

Output: 3


The only line of the input contains one integer n (1 ≤ n ≤ 1018) — the prediction on the number of people who will buy the game.

#include<stdio.h>
int main()
{
	long long int i,j,n,l,a,k;
	scanf("%lld",&n);
	k=2520;
	a=n/k;
	printf("%lld\n",a);
	return 0;
}

Output one integer showing how many numbers from 1 to n are divisible by all numbers from 2 to 10.

IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 to 10 every developer of this game gets a small bonus.A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.


The first line of the input contains four integers d, L, v1, v2 (1 ≤ d, L, v1, v2 ≤ 10 000, d < L) — Luke's width, the initial position of the second press and the speed of the first and second presses, respectively.

#include<stdio.h>

main(){
    double d,l,v1,v2;
    scanf("%lf %lf %lf %lf",&d,&l,&v1,&v2);
    printf("%0.10lf",(l-d)/(v1+v2));
}

NoteIn the first sample Luke should stay exactly in the middle of the segment, that is at coordinates [2;4], as the presses move with the same speed.In the second sample he needs to occupy the position . In this case both presses move to his edges at the same time.

Print a single real value — the maximum period of time Luke can stay alive for. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.  Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity we will assume that everything happens on a straight line, the presses are initially at coordinates 0 and L, and they move towards each other with speed v1 and v2, respectively. Luke has width d and is able to choose any position between the presses. Luke dies as soon as the distance between the presses is less than his width. Your task is to determine for how long Luke can stay alive.

Input: 2 6 2 2

Output: 1.0000000

Output: 1.000000

Output: 1.0

Output: 1.0000000000

Input: 1 9 1 2

Output: 2.66666666667

Output: 2.6666666666666665

Output: 2.6666667

Output: 2.666667

Output: 2.6666666667

Input: 1 10000 1 1

Output: 4999.500000

Output: 4999.5

Output: 4999.5000000

Output: 4999.5000000000

Input: 9999 10000 10000 10000

Output: 0.000050

Output: 0.0000500000

Output: 0.0000500

Output: 5.0E-5

Output: 5e-05

Input: 1023 2340 1029 3021

Output: 0.3251852

Output: 0.325185

Output: 0.325185185185

Output: 0.3251851852

Output: 0.3251851851851852

Input: 2173 2176 10000 9989

Output: 0.0001500825454

Output: 0.0001500825

Output: 0.0001501

Output: 1.5008254539996998E-4

Output: 0.000150

Input: 1 2 123 1

Output: 0.0080645

Output: 0.008064516129032258

Output: 0.008065

Output: 0.00806451612903

Output: 0.0080645161

Input: 123 1242 12 312

Output: 3.4537037037037037

Output: 3.453704

Output: 3.4537037037

Output: 3.4537037

Input: 2 9997 3 12

Output: 666.3333333333334

Output: 666.333333

Output: 666.333333333

Output: 666.3333333333

Output: 666.3333333

Input: 1 10000 10000 10000

Output: 0.4999500000

Output: 0.49995

Output: 0.4999500

Output: 0.499950

Input: 3274 4728 888 4578

Output: 0.2660080

Output: 0.26600804976216613

Output: 0.2660080498

Output: 0.266008049762

Output: 0.266008

Input: 4600 9696 5634 8248

Output: 0.3670941

Output: 0.367094

Output: 0.3670940787

Output: 0.367094078663

Output: 0.36709407866301685

Input: 2255 7902 8891 429

Output: 0.6059013

Output: 0.605901

Output: 0.605901287554

Output: 0.6059012876

Output: 0.605901287553648

Input: 6745 9881 2149 9907

Output: 0.260119442601

Output: 0.2601194426011944

Output: 0.2601194

Output: 0.2601194426

Output: 0.260119

Input: 4400 8021 6895 2089

Output: 0.403049866429

Output: 0.4030498664292075

Output: 0.403050

Output: 0.4030498664

Output: 0.4030499

Input: 5726 9082 7448 3054

Output: 0.319558179394

Output: 0.3195582

Output: 0.3195581794

Output: 0.319558

Output: 0.31955817939440107

Input: 3381 9769 4898 2532

Output: 0.859757738896

Output: 0.8597577

Output: 0.8597577389

Output: 0.8597577388963661

Output: 0.859758

Input: 1036 6259 5451 4713

Output: 0.513872

Output: 0.5138724911

Output: 0.5138724911452184

Output: 0.513872491145

Output: 0.5138725

Input: 5526 6455 197 4191

Output: 0.2117137648131267

Output: 0.2117137648

Output: 0.211713764813

Output: 0.2117138

Output: 0.211714

Input: 1196 4082 4071 9971

Output: 0.2055263

Output: 0.2055262783

Output: 0.205526278308

Output: 0.205526

Output: 0.20552627830793335

Input: 8850 9921 8816 9449

Output: 0.0586367

Output: 0.0586367369

Output: 0.0586367369286

Output: 0.058637

Output: 0.058636736928551876

Input: 3341 7299 2074 8927

Output: 0.3597854740

Output: 0.359785474048

Output: 0.35978547404781386

Output: 0.3597855

Output: 0.359785

Input: 7831 8609 6820 2596

Output: 0.082625

Output: 0.0826253186

Output: 0.08262531860662702

Output: 0.0826253186066

Output: 0.0826253

Input: 2322 7212 77 4778

Output: 1.007209062821833

Output: 1.00720906282

Output: 1.0072091

Output: 1.007209

Output: 1.0072090628

Input: 9976 9996 4823 4255

Output: 0.0022031284

Output: 0.00220312844239

Output: 0.002203128442388191

Output: 0.002203

Output: 0.0022031

Input: 7631 9769 5377 6437

Output: 0.1809717285

Output: 0.180971728458

Output: 0.1809717

Output: 0.180972

Output: 0.18097172845776197

Input: 8957 9525 8634 107

Output: 0.064981

Output: 0.0649811

Output: 0.06498112344125385

Output: 0.0649811234

Output: 0.0649811234413

Input: 6612 9565 3380 2288

Output: 0.520995

Output: 0.5209950599858857

Output: 0.520995059986

Output: 0.5209951

Output: 0.5209950600

Input: 1103 6256 3934 9062

Output: 0.39650661742074483

Output: 0.3965066

Output: 0.396506617421

Output: 0.3965066174

Output: 0.396507

Input: 1854 3280 1481 2140

Output: 0.393814

Output: 0.3938139

Output: 0.393813863574

Output: 0.39381386357359843

Output: 0.3938138636

Input: 2 6 2 2

Output: 1.0

Output: 1

Output: 1.000000

Output: 1.0000000000

Input: 1 9 1 2

Output: 2.6666666667

Output: 2.6666666666666665

Output: 2.666667

Input: 1 10000 1 1

Output: 4999.5

Output: 4999.500000

Output: 4999.5000000000

Input: 9999 10000 10000 10000

Output: 0.000050

Output: 0.0000500000

Output: 5.0E-5

Output: 5e-005

Input: 1023 2340 1029 3021

Output: 0.325185

Output: 0.3251852

Output: 0.3251851852

Output: 0.3251851851851852

Input: 2173 2176 10000 9989

Output: 0.0001500825

Output: 1.5008254539996998E-4

Output: 0.000150

Input: 1 2 123 1

Output: 0.0080645161

Output: 0.008064516129032258

Output: 0.008064516

Output: 0.008065

Input: 123 1242 12 312

Output: 3.453704

Output: 3.4537037037037037

Output: 3.4537037037

Input: 2 9997 3 12

Output: 666.3333333333

Output: 666.333333

Output: 666.3333

Output: 666.3333333333334

Input: 1 10000 10000 10000

Output: 0.49995

Output: 0.4999500000

Output: 0.499950

Input: 3274 4728 888 4578

Output: 0.26600804976216613

Output: 0.2660080498

Output: 0.266008

Input: 4600 9696 5634 8248

Output: 0.367094

Output: 0.36709407866301685

Output: 0.3670941

Output: 0.3670940787

Input: 2255 7902 8891 429

Output: 0.605901

Output: 0.6059012876

Output: 0.605901287553648

Output: 0.6059013

Input: 6745 9881 2149 9907

Output: 0.2601194426011944

Output: 0.2601194426

Output: 0.2601194

Output: 0.260119

Input: 4400 8021 6895 2089

Output: 0.4030499

Output: 0.4030498664

Output: 0.4030498664292075

Output: 0.403050

Input: 5726 9082 7448 3054

Output: 0.31955817939440107

Output: 0.319558

Output: 0.3195581794

Output: 0.3195582

Input: 3381 9769 4898 2532

Output: 0.8597577388963661

Output: 0.8597577

Output: 0.8597577389

Output: 0.859758

Input: 1036 6259 5451 4713

Output: 0.5138724911452184

Output: 0.5138724911

Output: 0.5138725

Output: 0.513872

Input: 5526 6455 197 4191

Output: 0.2117137648

Output: 0.211714

Output: 0.2117138

Output: 0.2117137648131267

Input: 1196 4082 4071 9971

Output: 0.205526

Output: 0.2055263

Output: 0.2055262783

Output: 0.20552627830793335

Input: 8850 9921 8816 9449

Output: 0.058637

Output: 0.05863674

Output: 0.0586367369

Output: 0.058636736928551876

Input: 3341 7299 2074 8927

Output: 0.359785

Output: 0.3597854740

Output: 0.35978547404781386

Output: 0.3597855

Input: 7831 8609 6820 2596

Output: 0.082625

Output: 0.08262532

Output: 0.0826253186

Output: 0.08262531860662702

Input: 2322 7212 77 4778

Output: 1.007209

Output: 1.0072090628

Output: 1.007209062821833

Input: 9976 9996 4823 4255

Output: 0.002203128442388191

Output: 0.002203

Output: 0.0022031284

Output: 0.002203128

Input: 7631 9769 5377 6437

Output: 0.1809717

Output: 0.18097172845776197

Output: 0.1809717285

Output: 0.180972

Input: 8957 9525 8634 107

Output: 0.06498112344125385

Output: 0.06498112

Output: 0.064981

Output: 0.0649811234

Input: 6612 9565 3380 2288

Output: 0.520995

Output: 0.5209951

Output: 0.5209950599858857

Output: 0.5209950600

Input: 1103 6256 3934 9062

Output: 0.39650661742074483

Output: 0.3965066

Output: 0.3965066174

Output: 0.396507

Input: 1854 3280 1481 2140

Output: 0.393814

Output: 0.3938139

Output: 0.3938138636

Output: 0.39381386357359843


The only line of the input contains a single integer n (2 ≤ n ≤ 2·1018) — the power in which you need to raise number 5.

#include <stdio.h>
#include <math.h>
int main(){
		int i;
		scanf("%d",&i);
		printf("25");
		return 0;
}

Output the last two digits of 5n without spaces between them.

The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. "Do I give such a hard task?" — the HR manager thought. "Just raise number 5 to the power of n and get last two digits of the number. Yes, of course, n can be rather big, and one cannot find the power using a calculator, but we need people who are able to think, not just follow the instructions."Could you pass the interview in the machine vision company in IT City?


The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the half-length of the resulting regular bracket sequences (the resulting sequences must have length equal to $$$2n$$$). The second line of the input contains one string $$$s$$$ ($$$1 \le |s| \le 200$$$) — the string $$$s$$$ that should be a substring in each of the resulting regular bracket sequences ($$$|s|$$$ is the length of $$$s$$$).

#include <stdio.h>
#include <string.h>
enum { BIG = 1000000007 };

int n;
char s[240];
int slen;
int dp[201][101];
int next[201][2];
int fail[201];

void nextstep(int eo) {
    int i, j;
    for (i = 0; i <= slen; i++) {
        int lp = next[i][0];
        int rp = next[i][1];
        for (j = eo; j <= n; j+=2) {
            int now = dp[i][j];
            if (j < n) {
                int add = dp[lp][j+1] + now;
                dp[lp][j+1] = add < BIG ? add : add - BIG;
            }
            if (j > 0) {
                int add = dp[rp][j-1] + now;
                dp[rp][j-1] = add < BIG ? add : add - BIG;
            }
        }
    }
    for (i = 0; i <= slen; i++) {
        for (j = eo; j <= n; j+=2) {
            dp[i][j] = 0;
        }
    }
    /*for (i=0;i<=slen;i++){
        for (j=0;j<=n;j++){
            printf("%3d,",dp[i][j]);
        }
        puts("");
    }
    puts("");*/
}

int main() {
    scanf("%d", &n);
    scanf(" %202s", s);
    slen = strlen(s);
    int i;
    // build state machine
    fail[0] = fail[1] = 0;
    if (s[0] == '(') {
        next[0][0] = 1;
        next[0][1] = 0;
    }
    else {
        next[0][0] = 0;
        next[0][1] = 1;
    }
    for (i = 1; i < slen; i++) {
        int r = s[i] == ')';
        int f = fail[i];
        next[i][r] = i+1;
        next[i][1-r] = next[f][1-r];
        fail[i+1] = next[f][r];
    }
    next[slen][0] = next[slen][1] = slen;
    dp[0][0] = 1;
    for (i = 0; i < n; i++) {
        nextstep(0);
        nextstep(1);
    }
    printf("%d\n", dp[slen][0]);
    return 0;
}

NoteAll regular bracket sequences satisfying the conditions above for the first example:   "(((()))())";  "((()()))()";  "((()))()()";  "(()(()))()";  "()((()))()". All regular bracket sequences satisfying the conditions above for the second example:   "((()))";  "(()())";  "(())()";  "()(())". And there is no regular bracket sequences of length $$$4$$$ containing "(((" as a substring in the third example.

Print only one integer — the number of regular bracket sequences containing the given bracket sequence $$$s$$$ as a substring. Since this number can be huge, print it modulo $$$10^9+7$$$ ($$$1000000007$$$).

You are given a bracket sequence $$$s$$$ (not necessarily a regular one). A bracket sequence is a string containing only characters '(' and ')'.A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For example, bracket sequences "()()" and "(())" are regular (the resulting expressions are: "(1)+(1)" and "((1+1)+1)"), and ")(", "(" and ")" are not.Your problem is to calculate the number of regular bracket sequences of length $$$2n$$$ containing the given bracket sequence $$$s$$$ as a substring (consecutive sequence of characters) modulo $$$10^9+7$$$ ($$$1000000007$$$).

Input:
5
()))()

Output: 5

Input:
3
(()

Output: 4

Input:
2
(((

Output: 0

Input:
100
()(()))))(()((((()())()))(()))()()))(((()))))))))(

Output: 979898526

Input:
100
()(()(()((()(()(()()()(()((()))())())))()))())()()

Output: 711757760

Input:
100
(()))(()())()()((())(()((()()))(())()(((((()(((()()))())))))(())((((()()()()()))(()))(())(())(()))((

Output: 599470552

Input:
100
(()(()()()()(()(()()(((()((()(((()(((()(()()((()())))))()()()))))()()())))()()))()))()()()()())()())

Output: 812513651

Input:
100
(()))()())((())))((((())()((())(()(())))(()()(((()()())())()()(())))())((((()())(())())((((()((()((()()(())))(())))))()(()))))())()()))))()(()(()())((

Output: 657505568

Input:
100
()()()(((((()(()((((()((((((()()()((()()(()()()(((()()((()()((()()()))()()()))()))))())()())()()()())()()()())())())))())()())())))())()))))()()()()()

Output: 264738339

Output: 0

Output: 1

Input:
100
()

Output: 558488487

Output: 1

Output: 1

Output: 2

Output: 3

Input:
100
)

Output: 558488487

Input:
100
))

Output: 558488486

Input:
100
))())())()))()())())()(((((((()()))())()())()(((()()))(())()((((()()()())()((()()()())()(((((()()()(()(()()((((()())))()))()(())(())))))))))((()((()())())(()((())((())()(()(()

Output: 325

Input:
100
()())(((()((())))((())((()(())))(((((((()))))))()(()((()()(((())))())()((((())()(())))(((((()))())(()))))((()))((())()(((())((()())(()(()))((()()()())())())))(()()()))()))))())))))))()(

Output: 1820

Input:
100
()(()())()(())))()())()(())((()(()()((()((((((())()))(()(()()))(()()())((()())))())())))())))(())(()()))(((())))(((((())(())(()))((())(())))())))()))()((())()()())()))(()())(()(()))(()(())))

Output: 1

Input:
12
()()()

Output: 62316

Input:
20
()(()()())

Output: 296672330

Input:
32
()((()()()())())

Output: 468509380

Input:
50
(

Output: 265470434

Input:
10
)()))())))())(())(()(((())(()))))))(()())))))))(((

Output: 0

Input:
20
))()))(()()))(())()))()(((((((((()((())((((((())(())(()())))(()()((())(()()()()(()())()()))))))())((

Output: 0

Input:
1
(

Output: 1

Input:
2
)

Output: 2

Input:
3
)

Output: 5

Input:
4
(

Output: 14

Input:
5
(

Output: 42

Input:
6
)

Output: 132

Input:
7
)

Output: 429

Input:
8
(

Output: 1430

Input:
9
(

Output: 4862

Input:
10
)

Output: 16796

Input:
11
(

Output: 58786

Input:
12
(

Output: 208012

Input:
13
)

Output: 742900

Input:
14
)

Output: 2674440

Input:
15
(

Output: 9694845

Input:
16
(

Output: 35357670

Input:
17
)

Output: 129644790

Input:
18
)

Output: 477638700

Input:
19
(

Output: 767263183

Input:
20
)

Output: 564120378

Input:
21
(

Output: 466266852

Input:
22
(

Output: 482563003

Input:
23
)

Output: 59611249

Input:
1
(((

Output: 0

Output: 0


The only line contains three integers n, x and y (1 ≤ n ≤ 107, 1 ≤ x, y ≤ 109) — the number of letters 'a' in the input file and the parameters from the problem statement.

#include<stdio.h>
#include<stdlib.h>

int main()
{
    unsigned long long n, x, y;
    unsigned long nl, xl, yl;

    fscanf(stdin, "%ld %ld %ld", &nl, &xl, &yl);

    n = (unsigned long long)nl;
    x = (unsigned long long)xl;
    y = (unsigned long long)yl;

    unsigned long long* f = malloc(10000001*sizeof(unsigned long long));

    f[1] = x;
    f[2] = x < y? x + f[1] : y + f[1];

    unsigned long long k;

    for (unsigned long long m = 3; m < n+1; m++)
    {
        k = (m+1)/2;
        if (m % 2 == 1)
            f[2*k-1] = f[k]+y+x < f[2*k-2]+x ? f[k]+y+x : f[2*k-2]+x;
        else
            f[2*k] = f[k]+y < f[2*k-2]+2*x ? f[k]+y : f[2*k-2]+2*x;
    }
    unsigned long pref = f[n] / 1000000000Lu;
    unsigned long rest = f[n] % 1000000000Lu;
    int digs = 9;
    int pow10 = 100000000Lu;
    while (digs > 1)
    {
        if (rest >= pow10)
            break;
        pow10 /= 10;
        digs = digs-1;
    }
    if (pref > 0)
    {
        if (9-digs == 0)
            printf("%lu%lu\n", pref, rest);
        else
        {
            char* zeros = malloc((9-digs+1)*sizeof(char));
            for (int i = 0; i < 9-digs; i++) zeros[i] = '0';
            zeros[9-digs] = 0;
            printf("%lu%s%lu\n", pref, zeros, rest);
        }
    }
    else
        printf("%lu\n", rest);
}

Print the only integer t — the minimum amount of time needed to generate the input file.

zscoder wants to generate an input file for some programming competition problem.His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.Initially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.zscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.

Input: 8 1 1

Output: 4

Input: 8 1 10

Output: 8

Input: 10 62 99

Output: 384

Input: 88 417 591

Output: 4623

Input: 57 5289 8444

Output: 60221

Input: 382 81437847 324871127

Output: 2519291691

Input: 244 575154303 436759189

Output: 5219536421

Input: 85 902510038 553915152

Output: 6933531064

Input: 1926 84641582 820814219

Output: 7184606427

Input: 3768 561740421 232937477

Output: 5042211408

Input: 2313 184063453 204869248

Output: 2969009745

Input: 35896 278270961 253614967

Output: 5195579310

Input: 483867 138842067 556741142

Output: 10712805143

Input: 4528217 187553422 956731625

Output: 21178755627

Input: 10000000 1000000000 1

Output: 8000000023

Input: 10000000 1 100

Output: 1757

Input: 10000000 1 1000000000

Output: 10000000

Input: 10000000 1 1000

Output: 14224

Input: 10000000 1 10

Output: 214

Input: 1 1 1

Output: 1

Input: 10000000 998 998

Output: 30938

Input: 9999999 987654321 123456789

Output: 11728395036

Input: 9999999 1 2

Output: 54

Input: 10000000 1 1

Output: 31

Input: 11478 29358 26962

Output: 556012

Input: 4314870 1000000000 1

Output: 7000000022

Input: 7186329 608148870 290497442

Output: 12762929866

Input: 9917781 1 1

Output: 35

Input: 7789084 807239576 813643932

Output: 25165322688

Input: 58087 1 100000000

Output: 58087

Input: 9999991 2 3

Output: 88


The single line contains a non-empty string s whose length can range from 1 to 50, inclusive. The string only contains digits. The string can contain leading zeroes.

#include <stdio.h>
# include <string.h>
int main()
{
    char ch[100];
    scanf("%s",&ch);
    int i,c1=0,c2=0;
     for(i=0;i<strlen(ch);i++)
      {
         if(ch[i]==4+48)
             c1++;
         else if(ch[i]==7+48)
              c2++;
     }
     if(c1==0 && c2==0)
         printf("-1\n");
       else if(c1>=c2)
           printf("4\n");
          else
          printf("7\n");
         return 0;
        }

NoteThe lexicographical comparison of strings is performed by the < operator in the modern programming languages. String x is lexicographically less than string y either if x is a prefix of y, or exists such i (1 ≤ i ≤ min(|x|, |y|)), that xi < yi and for any j (1 ≤ j < i) xj = yj. Here |a| denotes the length of string a.In the first sample three conditions are fulfilled for strings "4", "7" and "47". The lexicographically minimum one is "4".In the second sample s has no substrings which are lucky numbers.In the third sample the three conditions are only fulfilled for string "7".

In the only line print the answer to Petya's problem. If the sought string does not exist, print "-1" (without quotes).

Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.One day Petya was delivered a string s, containing only digits. He needs to find a string that represents a lucky number without leading zeroes, is not empty, is contained in s as a substring the maximum number of times.Among all the strings for which the three conditions given above are fulfilled, Petya only needs the lexicographically minimum one. Find this string for Petya.


The first line contains two integers a and b, ( - 109 ≤ a, b ≤ 109). The second line contains a string s (1 ≤ |s| ≤ 100, s only contains characters 'U', 'D', 'L', 'R') — the command.

NoteIn the first and second test case, command string is "RU", so the robot will go right, then go up, then right, and then up and so on.The locations of its moves are (0, 0)  →  (1, 0)  →  (1, 1)  →  (2, 1)  →  (2, 2)  →  ...So it can reach (2, 2) but not (1, 2).

Print "Yes" if the robot will be located at (a, b), and "No" otherwise.

Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all:  'U': go up, (x, y)  →  (x, y+1);  'D': go down, (x, y)  →  (x, y-1);  'L': go left, (x, y)  →  (x-1, y);  'R': go right, (x, y)  →  (x+1, y). The robot will do the operations in s from left to right, and repeat it infinite times. Help Fox Ciel to determine if after some steps the robot will located in (a, b).

Input:
2 2
RU

Output: Yes

Input:
1 2
RU

Output: No

Input:
-1 1000000000
LRRLU

Output: Yes

Input:
0 0
D

Output: Yes

Input:
0 0
UURRDL

Output: Yes

Input:
987654321 987654321
UURRDL

Output: Yes

Input:
4 2
UURRDL

Output: No

Input:
4 3
UURRDL

Output: Yes

Input:
4 4
UURRDL

Output: Yes

Input:
4 6
UURRDL

Output: Yes

Input:
4 7
UURRDL

Output: No

Input:
1000000000 1000000000
UURRDL

Output: Yes

Input:
-1 -1
UR

Output: No

Input:
1 1
UURRDDLL

Output: No

Input:
987654321 2
UURDD

Output: Yes

Input:
0 123456789
RRULL

Output: Yes

Input:
4 4
UUUURRRRDDDDLLLL

Output: Yes

Input:
-491226083 -49122610
UDRLDURLDLLLDUDURLRDUUDDUUULUDRDRDUULURDRLLDDDLUDUURLUUDLLDULLLLDDLDDUU

Output: Yes

Input:
-261597957 418556728
LLLDLUDUULLRDDULLRRUDRDLULRLRLLRRUUDRRLRUDLRRLUDRDLLUUDUULRURLDLULUUULDDUURLRUDURRL

Output: Yes

Input:
-771928144 -3
RUDULULDRDLLLULDDUDDDDUDULRULRUULDDDURUDLUURULLLDLLDDRDDRLRURUULRUURRUDLDLDDRLLULRRDRRLLUULUDRUUDRRD

Output: Yes

Input:
397346346 1
DDURRUURLDLRRLULD

Output: Yes

Input:
-528551525 0
UDRLRRLDLDLURRRRULDLRLRLURUUDDLRLLDRRULLUDLURDLUUULLLRUUUDRRURLDUDULDDRDDDRDL

Output: Yes

Input:
311692421 -129871846
LLLDURULDDDDUDDURRLUUDRLDDRDURDDRUDUURLUDUDLDRUDDDUUURDRRUDRDRDURLLDURUUDRLDLDURRRRRRDULURDRU

Output: Yes

Input:
485940814 728911221
URURU

Output: Yes

Input:
-843450986 632588242
LURLULULRUDUDULRDDLUL

Output: Yes

Input:
647999516 -809999401
UDLDDLLULUDDLLDUULRRRDLUDDLDDLRLRRDRURURDRRDRULUDRDULRULLRRLLDDRLRRUDRURDUULUDLRRLRDR

Output: Yes

Input:
352820537 -764444491
RDDUDLUDDUDLRRRDRRRDRRDUDUDDURLRRLDRLLRLLLLUULUDRURRDRLDDLLDRDURDUDRUDDLUDRLURUDRURDRDDLDRLDLDLLU

Output: Yes

Input:
-284973644 -1
DLULLDLRUUDRR

Output: Yes

Input:
356922591 -2
RRLDLDUDRUUUULUUDDULDDUDD

Output: No

Input:
27033101 54066203
UDDDRDLLLRUUDDLRDLDRLRUDDULRLLRULR

Output: No

Input:
-199335150 39867031
LLURRDUULRUDDRDUUULDLDRDDLURDRLDRLLLRRRRRULRRRUUDD

Output: No

Input:
609504072 609504074
ULRLUDLDDR

Output: No

Input:
497684357 829473929
RRLDUUURULURRLLRRLRLURRLDU

Output: Yes

Input:
551922835 183974295
DUDUUULDRLRURRDULRRUDDLRLLUULLRLRDRDRR

Output: No

Input:
825368095 -825368096
RD

Output: No

Input:
-458990423 -229495204
DLLDDRLUDLRLUL

Output: No

Input:
285102789 570205594
RRDULRULULRRDUURRLURUDDULLRDUL

Output: No

Input:
109928480 219856920
LRURLRLURDRDLDRDLRDDUUDDLULDRRUUURRUDLLUULUUUR

Output: No

Input:
-532674020 532674026
UURLLL

Output: No

Input:
999999999 0
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR

Output: Yes

Input:
0 0
UDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLR

Output: Yes

Input:
1 1
UDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLRUDLR

Output: No

Input:
-1000000000 -1000000000
DLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL

Output: Yes

Input:
3 3
UURR

Output: No

Input:
-2 -2
UR

Output: No

Input:
5 5
UDLR

Output: No

Input:
0 -1
U

Output: No

Input:
-1 0
R

Output: No

Input:
1000000000 1000000000
URURURUR

Output: Yes

Input:
-1 -1
RU

Output: No

Input:
1 1
LD

Output: No

Input:
-2 -2
UURR

Output: No

Input:
1000000000 0
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR

Output: Yes

Input:
2 6
RUUUURLDDDL

Output: Yes

Input:
0 1
LUUR

Output: No

Input:
1 1
URDLDL

Output: Yes

Input:
-10 -10
RU

Output: No

Input:
1000000000 1000000000
RURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURU

Output: Yes

Input:
-1000000000 -500000000
URR

Output: No

Input:
-2 0
ULLLDDRRRR

Output: Yes

Input:
999999999 -999999999
RRRRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUU

Output: Yes

Input:
-100 -100
RU

Output: No

Input:
100 100
RUL

Output: No

Input:
0 1
UDLR

Output: Yes

Input:
0 1
D

Output: No

Input:
0 -3
RDDL

Output: No

[{'input': '485940814 728911221\r\nURURU\r\n', 'output': ['Yes']}, {'input': '1000000000 1000000000\r\nUURRDL\r\n', 'output': ['Yes']}, {'input': '-261597957 418556728\r\nLLLDLUDUULLRDDULLRRUDRDLULRLRLLRRUUDRRLRUDLRRLUDRDLLUUDUULRURLDLULUUULDDUURLRUDURRL\r\n', 'output': ['Yes']}, {'input': '-1000000000 -1000000000\r\nDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDL\r\n', 'output': ['Yes']}, {'input': '-100 -100\r\nRU\r\n', 'output': ['No']}]

[{'input': '4 7\r\nUURRDL\r\n', 'output': ['No']}, {'input': '999999999 -999999999\r\nRRRRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUU\r\n', 'output': ['Yes']}, {'input': '4 4\r\nUURRDL\r\n', 'output': ['Yes']}, {'input': '1 1\r\nURDLDL\r\n', 'output': ['Yes']}, {'input': '1000000000 1000000000\r\nRURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURURU\r\n', 'output': ['Yes']}]

[{'input': '0 1\r\nUDLR\r\n', 'output': ['Yes']}, {'input': '-261597957 418556728\r\nLLLDLUDUULLRDDULLRRUDRDLULRLRLLRRUUDRRLRUDLRRLUDRDLLUUDUULRURLDLULUUULDDUURLRUDURRL\r\n', 'output': ['Yes']}, {'input': '-2 -2\r\nUURR\r\n', 'output': ['No']}, {'input': '987654321 987654321\r\nUURRDL\r\n', 'output': ['Yes']}, {'input': '1 2\r\nRU\r\n', 'output': ['No']}]

[{'input': '999999999 0\r\nRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\r\n', 'output': ['Yes']}, {'input': '-1 0\r\nR\r\n', 'output': ['No']}, {'input': '100 100\r\nRUL\r\n', 'output': ['No']}, {'input': '-1 1000000000\r\nLRRLU\r\n', 'output': ['Yes']}, {'input': '999999999 -999999999\r\nRRRRRRRRRRRRRRRRRRRRRRRRRDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLUUUUUUUUUUUUUUUUUUUUUUU\r\n', 'output': ['Yes']}]


The first line contains two integers n and x (1 ≤ n ≤ 100, 0 ≤ x ≤ 100) — the size of the set Dr. Evil owns, and the desired MEX. The second line contains n distinct non-negative integers not exceeding 100 that represent the set.

#include <stdio.h>
int main(){
	int n,x,i,t;
	scanf("%d %d", &n,&x);
	int ans = x;
 	for(i = 0; i < n; i++){
		scanf("%d", &t);
		if(t < x) ans--;
        else if(t==x)ans++;
	}
	printf("%d\n", ans);
	return 0;
}

NoteFor the first test case Dr. Evil should add 1 and 2 to the set performing 2 operations.For the second test case Dr. Evil should erase 0 from the set. After that, the set becomes empty, so the MEX of it is 0.In the third test case the set is already evil.

The only line should contain one integer — the minimal number of operations Dr. Evil should perform.

Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go.Dr. Evil is interested in sets, He has a set of n integers. Dr. Evil calls a set of integers evil if the MEX of it is exactly x. the MEX of a set of integers is the minimum non-negative integer that doesn't exist in it. For example, the MEX of the set {0, 2, 4} is 1 and the MEX of the set {1, 2, 3} is 0 .Dr. Evil is going to make his set evil. To do this he can perform some operations. During each operation he can add some non-negative integer to his set or erase some element from it. What is the minimal number of operations Dr. Evil has to perform to make his set evil?

Input:
5 3
0 4 5 6 7

Output: 2

Input:
1 0
0

Output: 1

Input:
5 0
1 2 3 4 5

Output: 0

Input:
10 5
57 1 47 9 93 37 76 70 78 15

Output: 4

Input:
10 5
99 98 93 97 95 100 92 94 91 96

Output: 5

Input:
10 5
1 2 3 4 59 45 0 58 51 91

Output: 0

Input:
100 100
79 13 21 11 3 87 28 40 29 4 96 34 8 78 61 46 33 45 99 30 92 67 22 97 39 86 73 31 74 44 62 55 57 2 54 63 80 69 25 48 77 98 17 93 15 16 89 12 43 23 37 95 14 38 83 90 49 56 72 10 20 0 50 71 70 88 19 1 76 81 52 41 82 68 85 47 6 7 35 60 18 64 75 84 27 9 65 91 94 42 53 24 66 26 59 36 51 32 5 58

Output: 0

Input:
100 50
95 78 46 92 80 18 79 58 30 72 19 89 39 29 44 65 15 100 59 8 96 9 62 67 41 42 82 14 57 32 71 77 40 5 7 51 28 53 85 23 16 35 3 91 6 11 75 61 17 66 13 47 36 56 10 22 83 60 48 24 26 97 4 33 76 86 70 0 34 64 52 43 21 49 55 74 1 73 81 25 54 63 94 84 20 68 87 12 31 88 38 93 37 90 98 69 99 45 27 2

Output: 0

Input:
100 33
28 11 79 92 88 62 77 72 7 41 96 97 67 84 44 8 81 35 38 1 64 68 46 17 98 83 31 12 74 21 2 22 47 6 36 75 65 61 37 26 25 45 59 48 100 51 93 76 78 49 3 57 16 4 87 29 55 82 70 39 53 0 60 15 24 71 58 20 66 89 95 42 13 43 63 90 85 52 50 30 54 40 56 23 27 34 32 18 10 19 69 9 99 73 91 14 5 80 94 86

Output: 0

Input:
99 33
25 76 41 95 55 20 47 59 58 84 87 92 16 27 35 65 72 63 93 54 36 96 15 86 5 69 24 46 67 73 48 60 40 6 61 74 97 10 100 8 52 26 77 18 7 62 37 2 14 66 11 56 68 91 0 64 75 99 30 21 53 1 89 81 3 98 12 88 39 38 29 83 22 90 9 28 45 43 78 44 32 57 4 50 70 17 13 51 80 85 71 94 82 19 34 42 23 79 49

Output: 1

Input:
100 100
65 56 84 46 44 33 99 74 62 72 93 67 43 92 75 88 38 34 66 12 55 76 58 90 78 8 14 45 97 59 48 32 64 18 39 89 31 51 54 81 29 36 70 77 40 22 49 27 3 1 73 13 98 42 87 37 2 57 4 6 50 25 23 79 28 86 68 61 80 17 19 10 15 63 52 11 35 60 21 16 24 85 30 91 7 5 69 20 71 82 53 94 41 95 96 9 26 83 0 47

Output: 0

Input:
100 100
58 88 12 71 22 1 40 19 73 20 67 48 57 17 69 36 100 35 33 37 72 55 52 8 89 85 47 42 78 70 81 86 11 9 68 99 6 16 21 61 53 98 23 62 32 59 51 0 87 24 50 30 65 10 80 95 7 92 25 74 60 79 91 5 13 31 75 38 90 94 46 66 93 34 14 41 28 2 76 84 43 96 3 56 49 82 27 77 64 63 4 45 18 29 54 39 15 26 83 44

Output: 2

Input:
89 100
58 96 17 41 86 34 28 84 18 40 8 77 87 89 68 79 33 35 53 49 0 6 22 12 72 90 48 55 21 50 56 62 75 2 37 95 69 74 14 20 44 46 27 32 31 59 63 60 10 85 71 70 38 52 94 30 61 51 80 26 36 23 39 47 76 45 100 57 15 78 97 66 54 13 99 16 93 73 24 4 83 5 98 81 92 25 29 88 65

Output: 13

Input:
100 50
7 95 24 76 81 78 60 69 83 84 100 1 65 31 48 92 73 39 18 89 38 97 10 42 8 55 98 51 21 90 62 77 16 91 0 94 4 37 19 17 67 35 45 41 56 20 15 85 75 28 59 27 12 54 61 68 36 5 79 93 66 11 70 49 50 34 30 25 96 46 64 14 32 22 47 40 58 23 43 9 87 82 26 53 80 52 3 86 13 99 33 71 6 88 57 74 2 44 72 63

Output: 2

Input:
77 0
27 8 20 92 21 41 53 98 17 65 67 35 81 11 55 49 61 44 2 66 51 89 40 28 52 62 86 91 64 24 18 5 94 82 96 99 71 6 39 83 26 29 16 30 45 97 80 90 69 12 13 33 76 73 46 19 78 56 88 38 42 34 57 77 47 4 59 58 7 100 95 72 9 74 15 43 54

Output: 0

Input:
100 50
55 36 0 32 81 6 17 43 24 13 30 19 8 59 71 45 15 74 3 41 99 42 86 47 2 94 35 1 66 95 38 49 4 27 96 89 34 44 92 25 51 39 54 28 80 77 20 14 48 40 68 56 31 63 33 78 69 37 18 26 83 70 23 82 91 65 67 52 61 53 7 22 60 21 12 73 72 87 75 100 90 29 64 79 98 85 5 62 93 84 50 46 97 58 57 16 9 10 76 11

Output: 1

Input:
77 0
12 8 19 87 9 54 55 86 97 7 27 85 25 48 94 73 26 1 13 57 72 69 76 39 38 91 75 40 42 28 93 21 70 84 65 11 60 90 20 95 66 89 59 47 34 99 6 61 52 100 50 3 77 81 82 53 15 24 0 45 44 14 68 96 58 5 18 35 10 98 29 74 92 49 83 71 17

Output: 1

Input:
100 70
25 94 66 65 10 99 89 6 70 31 7 40 20 92 64 27 21 72 77 98 17 43 47 44 48 81 38 56 100 39 90 22 88 76 3 83 86 29 33 55 82 79 49 11 2 16 12 78 85 69 32 97 26 15 53 24 23 91 51 67 34 35 52 5 62 50 95 18 71 13 75 8 30 42 93 36 45 60 63 46 57 41 87 0 84 54 74 37 4 58 28 19 96 61 80 9 1 14 73 68

Output: 2

Input:
89 19
14 77 85 81 79 38 91 45 55 51 50 11 62 67 73 76 2 27 16 23 3 29 65 98 78 17 4 58 22 20 34 66 64 31 72 5 32 44 12 75 80 47 18 25 99 0 61 56 71 84 48 88 10 7 86 8 49 24 43 21 37 28 33 54 46 57 40 89 36 97 6 96 39 95 26 74 1 69 9 100 52 30 83 87 68 60 92 90 35

Output: 2

Input:
89 100
69 61 56 45 11 41 42 32 28 29 0 76 7 65 13 35 36 82 10 39 26 34 38 40 92 12 17 54 24 46 88 70 66 27 100 52 85 62 22 48 86 68 21 49 53 94 67 20 1 90 77 84 31 87 58 47 95 33 4 72 93 83 8 51 91 80 99 43 71 19 44 59 98 97 64 9 81 16 79 63 25 37 3 75 2 55 50 6 18

Output: 13

Input:
77 0
38 76 24 74 42 88 29 75 96 46 90 32 59 97 98 60 41 57 80 37 100 49 25 63 95 31 61 68 53 78 27 66 84 48 94 83 30 26 36 99 71 62 45 47 70 28 35 54 34 85 79 43 91 72 86 33 67 92 77 65 69 52 82 55 87 64 56 40 50 44 51 73 89 81 58 93 39

Output: 0

Input:
89 100
38 90 80 64 35 44 56 11 15 89 23 12 49 70 72 60 63 85 92 10 45 83 8 88 41 33 16 6 61 76 62 71 87 13 25 77 74 0 1 37 96 93 7 94 21 82 34 78 4 73 65 20 81 95 50 32 48 17 69 55 68 5 51 27 53 43 91 67 59 46 86 84 99 24 22 3 97 98 40 36 26 58 57 9 42 30 52 2 47

Output: 11

Input:
77 0
55 71 78 86 68 35 53 10 59 32 81 19 74 97 62 61 93 87 96 44 25 18 43 82 84 16 34 48 92 39 64 36 49 91 45 76 95 31 57 29 75 79 13 2 14 24 52 23 33 20 47 99 63 15 5 80 58 67 12 3 85 6 1 27 73 90 4 42 37 70 8 11 89 77 9 22 94

Output: 0

Input:
77 0
12 75 31 71 44 8 3 82 21 77 50 29 57 74 40 10 15 42 84 2 100 9 28 72 92 0 49 11 90 55 17 36 19 54 68 52 4 69 97 91 5 39 59 45 89 62 53 83 16 94 76 60 95 47 30 51 7 48 20 70 67 32 58 78 63 34 56 93 99 88 24 1 66 22 25 14 13

Output: 1

Input:
100 70
91 82 8 85 26 25 95 97 40 87 81 93 7 73 38 94 64 96 74 18 90 19 65 68 72 61 23 43 36 41 60 88 30 33 71 24 52 39 15 3 16 89 86 79 55 4 9 58 67 44 46 29 6 48 84 69 27 21 78 54 51 57 80 53 76 50 47 77 45 12 34 10 100 0 17 31 56 99 98 11 92 5 2 42 32 59 66 62 37 63 28 75 35 1 22 13 83 49 20 14

Output: 0

Input:
77 0
51 5 81 62 30 22 11 0 83 16 79 85 52 70 69 10 8 47 58 3 24 34 44 14 82 66 99 17 28 31 64 67 23 49 94 45 4 12 27 15 21 6 43 72 87 2 63 92 35 39 59 9 90 78 93 20 65 36 60 89 50 41 61 84 77 86 76 100 38 68 53 97 96 95 7 19 88

Output: 1

Input:
1 100
0

Output: 99

Input:
1 0
100

Output: 0

Input:
1 100
100

Output: 101

Input:
2 100
0 100

Output: 100

Input:
5 5
1 2 3 4 5

Output: 2

Input:
5 3
0 3 4 5 6

Output: 3

Input:
7 10
0 1 2 3 4 5 10

Output: 5

Input:
2 2
0 2

Output: 2

Input:
2 1
1 2

Output: 2

Input:
5 1
1 2 3 4 5

Output: 2

Input:
5 2
1 2 3 4 5

Output: 2

Input:
5 6
0 1 2 3 4

Output: 1

Input:
3 2
3 4 5

Output: 2


The input data contains integers vp, vd, t, f and c, one per line (1 ≤ vp, vd ≤ 100, 1 ≤ t, f ≤ 10, 1 ≤ c ≤ 1000).

#include<stdio.h>
int main(){
  float vp,vd,t,f,c;
  float phm,d=0,time=0;
  int bijous=0;
  scanf("%f%f%f%f%f",&vp,&vd,&t,&f,&c);
  for(phm=t*vp;;){
    //printf("%f\n",phm);
    if(vd<=vp)
      break;
    phm+=phm*vp/(vd-vp);
    if(phm>=c)
      break;
    else{
      phm+=f*vp+(phm/vd)*vp;
      bijous++;
    }

  }
  printf("%d",bijous);
  return 0;
}

NoteIn the first case one hour after the escape the dragon will discover it, and the princess will be 1 mile away from the cave. In two hours the dragon will overtake the princess 2 miles away from the cave, and she will need to drop the first bijou. Return to the cave and fixing the treasury will take the dragon two more hours; meanwhile the princess will be 4 miles away from the cave. Next time the dragon will overtake the princess 8 miles away from the cave, and she will need the second bijou, but after this she will reach the castle without any further trouble.The second case is similar to the first one, but the second time the dragon overtakes the princess when she has reached the castle, and she won't need the second bijou.

Output the minimal number of bijous required for the escape to succeed.

The princess is going to escape the dragon's cave, and she needs to plan it carefully.The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess noticed that the dragon is very greedy and not too smart. To delay him, the princess decides to borrow a couple of bijous from his treasury. Once the dragon overtakes the princess, she will drop one bijou to distract him. In this case he will stop, pick up the item, return to the cave and spend f hours to straighten the things out in the treasury. Only after this will he resume the chase again from the very beginning.The princess is going to run on the straight. The distance between the cave and the king's castle she's aiming for is c miles. How many bijous will she need to take from the treasury to be able to reach the castle? If the dragon overtakes the princess at exactly the same moment she has reached the castle, we assume that she reached the castle before the dragon reached her, and doesn't need an extra bijou to hold him off.

Input:
1
2
1
1
10

Output: 2

Input:
1
2
1
1
8

Output: 1

Input:
5
8
1
2
100

Output: 2

Input:
2
100
10
10
739

Output: 22

Input:
17
99
2
3
293

Output: 3

Input:
5
5
1
1
1000

Output: 0

Input:
100
99
1
1
1000

Output: 0

Input:
1
100
1
1
1

Output: 0

Input:
1
100
1
1
1000

Output: 152

Input:
10
1
10
1
11

Output: 0

Input:
98
94
4
3
437

Output: 0

Input:
58
4
1
10
392

Output: 0

Input:
74
11
8
7
835

Output: 0

Input:
86
21
7
2
982

Output: 0

Input:
2
27
4
9
937

Output: 15

Input:
62
89
8
1
83

Output: 0

Input:
78
7
7
6
38

Output: 0

Input:
94
14
2
3
481

Output: 0

Input:
6
24
9
8
628

Output: 3

Input:
59
7
8
10
357

Output: 0

Input:
75
26
4
3
504

Output: 0

Input:
87
32
3
8
754

Output: 0

Input:
51
42
10
4
901

Output: 0

Input:
63
4
7
1
48

Output: 0

Input:
79
10
4
6
3

Output: 0

Input:
95
20
9
3
149

Output: 0

Input:
55
35
5
10
592

Output: 0

Input:
71
45
2
6
547

Output: 0

Input:
83
7
7
7
46

Output: 0

Input:
100
32
1
8
537

Output: 0

Input:
17
42
10
5
684

Output: 1

Input:
77
1
6
8
831

Output: 0

Input:
93
19
3
3
82

Output: 0

Input:
5
25
8
9
228

Output: 2

Input:
21
35
5
6
535

Output: 1

Input:
85
45
2
1
682

Output: 0

Input:
97
4
8
8
829

Output: 0

Input:
13
14
3
3
79

Output: 0

Input:
25
28
4
9
226

Output: 0

Input:
34
9
6
6
70

Output: 0

Input:
50
15
1
3
216

Output: 0

Input:
10
25
9
8
363

Output: 1

Input:
26
36
4
7
318

Output: 0

Input:
38
50
1
8
761

Output: 1

Input:
2
12
6
4
907

Output: 10

Input:
14
18
5
9
862

Output: 1

Input:
30
28
4
6
9

Output: 0

Input:
46
39
8
3
964

Output: 0

Input:
6
45
7
8
407

Output: 4

Input:
67
34
7
4
954

Output: 0

Input:
31
40
6
1
397

Output: 0

Input:
43
50
1
8
544

Output: 1

Input:
59
9
7
3
498

Output: 0

Input:
71
19
2
10
645

Output: 0

Input:
35
37
9
5
792

Output: 0

Input:
47
43
10
9
43

Output: 0

Input:
63
53
5
4
189

Output: 0

Input:
79
11
2
1
144

Output: 0

Input:
39
22
8
6
291

Output: 0

Input:
49
7
2
5
326

Output: 0

Input:
2
1
1
1
1000

Output: 0

Input:
100
1
1
1
1000

Output: 0

Input:
2
1
1
1
100

Output: 0

Input:
2
1
1
1
10

Output: 0

Input:
5
3
3
3
999

Output: 0


The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000).

#include <stdio.h>
#include <math.h>

int chk(long long x)
{
	int ret = 0;
	while(x)
	{
		ret += (x%10);
		x/=10;
	}
	return ret;
}

long long po(long long int a,long long x)
{
	if(x == 0)
		return 1;
	long long temp;
	temp = po(a,x/2);
	temp *= temp;
	if(x%2)
		temp *= a;
	return temp;
}

int main()
{
	long long int a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	long long int i;
	int cnt = 0;
	long long ans[100];
	for(i=1;i<=81;i++)
	{
		long long temp = b*(po(i,a)) + c;
		if(temp <= 1000000000 && temp >=0  && chk(temp) == i)
			ans[cnt++] = temp;
	}

	printf("%d\n",cnt );
	for(i=0;i<cnt;i++)
		printf("%d ",ans[i] );
	return 0;
}

Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 109.

Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 109) of the equation:x = b·s(x)a + c,  where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits in the decimal representation of number x.The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem.

Input: 3 2 8

Output:
3
10 2008 13726

Input: 1 2 -18

Output: 0

Input: 2 2 -1

Output:
4
1 31 337 967

Input: 1 1 0

Output:
9
1 2 3 4 5 6 7 8 9

Input: 1 37 963

Output:
16
1000 1111 1222 1333 1370 1407 1444 1481 1518 1555 1592 1629 1666 1777 1888 1999

Input: 1 298 -1665

Output:
17
123 421 1017 1315 1613 1911 2209 2507 2805 4295 4593 4891 5189 5487 5785 6679 6977

Input: 1 3034 -9234

Output:
23
12004 21106 24140 30208 33242 39310 42344 48412 51446 54480 57514 60548 63582 66616 69650 72684 75718 78752 81786 87854 90888 96956 99990

Input: 5 9998 9998

Output: 0

Input: 5 10000 10000

Output: 0

Input: 5 65 352

Output:
1
208000352

Input: 5 9999 9999

Output: 0

Input: 4 2099 -38

Output: 0

Input: 1 1 -6708

Output: 0

Input: 5 36 -46

Output: 0

Input: 5 8975 -4

Output: 0

Input: 3 2794 -3354

Output:
5
165733932 308990694 392855398 415958984 999999980

Input: 5 1 4473

Output:
11
1424330 14353380 17214841 52526348 60470649 69348430 164920697 184532598 205967449 418199966 459169497

Input: 5 1 -9999

Output:
6
90001 2466100 17200369 52511876 60456177 205952977

Input: 4 4 6

Output:
13
10 1030 40006 114250 202506 262150 521290 937030 1562506 2458630 3694090 4743690 7496650

Input: 5 19 -666

Output: 0

Input: 5 5 -865

Output: 0

Input: 2 8468 -3666

Output:
2
7117922 14933886

Input: 4 9359 -3039

Output: 0

Input: 5 5706 -1856

Output: 0

Input: 2 6828 -39

Output:
2
7435653 17759589

Input: 5 3903 -9847

Output: 0

Input: 3 1727 4771

Output:
1
42124574

Input: 4 1870 9912

Output: 0

Input: 3 6300 7035

Output:
1
466761435

Input: 5 8704 -6190

Output: 0

Input: 2 68 3

Output:
1
45971

Input: 5 6 -95

Output:
1
416063647

Input: 2 28 12

Output:
2
4044 7180

Input: 3 37 -70

Output: 0

Input: 5 3 53

Output:
1
100663349

Input: 3 2570 4109

Output:
2
427587859 999777799

Input: 3 1139 6335

Output:
2
12134407 499999999

Input: 3 2278 -1329

Output:
3
61504671 145790671 999985999

Input: 4 30 719

Output:
2
21219149 899597999

Input: 4 9023 312

Output: 0

Input: 5 10000 9

Output: 0

Input: 5 7698 5337

Output: 0

Input: 5 1 0

Output:
5
1 17210368 52521875 60466176 205962976

Input: 5 12 3

Output: 0

Input: 5 3903 153

Output: 0

Input: 5 10000 0

Output:
1
10000

Input: 3 2570 -6691

Output:
1
999766999

Input: 5 5 13

Output:
1
579281018


The first line contains six integers n, m, x1, y1, x2, y2 — the board sizes and the coordinates of the first and second chips, correspondingly (1 ≤ n, m ≤ 100; 2 ≤ n × m; 1 ≤ x1, x2 ≤ n; 1 ≤ y1, y2 ≤ m). The numbers in the line are separated by single spaces. It is guaranteed that the chips are located in different squares.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i, j, n, m, x1, y1, x2, y2;

    scanf("%d %d %d %d %d %d", &n, &m, &x1, &y1, &x2, &y2);

    i = abs(x1 - x2);
    j = abs(y1 - y2);

    if (i > j) {
        int aux = i;
        i = j;
        j = aux;
    }

    if ((i <= 2 && j <= 4) || (i == 3 && j == 3)) {
        puts("First");
    } else {
        puts("Second");
    }

    return 0;
}

If the first player wins, print "First" without the quotes. Otherwise, print "Second" without the quotes.

Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of superglue.We'll describe the rules of the game in more detail.The players move in turns. The first player begins.With every move the first player chooses one of his unglued chips, and shifts it one square to the left, to the right, up or down. It is not allowed to move a chip beyond the board edge. At the beginning of a turn some squares of the board may be covered with a glue. The first player can move the chip to such square, in this case the chip gets tightly glued and cannot move any longer.At each move the second player selects one of the free squares (which do not contain a chip or a glue) and covers it with superglue. The glue dries long and squares covered with it remain sticky up to the end of the game.If, after some move of the first player both chips are in the same square, then the first player wins. If the first player cannot make a move (both of his chips are glued), then the second player wins. Note that the situation where the second player cannot make a move is impossible — he can always spread the glue on the square from which the first player has just moved the chip.We will further clarify the case where both chips are glued and are in the same square. In this case the first player wins as the game ends as soon as both chips are in the same square, and the condition of the loss (the inability to move) does not arise.You know the board sizes and the positions of the two chips on it. At the beginning of the game all board squares are glue-free. Find out who wins if the players play optimally.

Input: 1 6 1 2 1 6

Output: First

Input: 6 5 4 3 2 1

Output: First

Input: 10 10 1 1 10 10

Output: Second

Input: 1 2 1 1 1 2

Output: First

Input: 4 4 1 4 4 1

Output: First

Input: 25 32 17 18 20 19

Output: First

Input: 30 1 10 1 20 1

Output: Second

Input: 28 17 20 10 27 2

Output: Second

Input: 5 5 1 1 5 5

Output: Second

Input: 5 4 1 4 5 1

Output: Second

Input: 95 28 50 12 50 13

Output: First

Input: 7 41 3 5 3 6

Output: First

Input: 45 62 28 48 28 50

Output: First

Input: 57 17 12 7 12 10

Output: First

Input: 73 88 30 58 30 62

Output: First

Input: 33 13 12 1 12 6

Output: Second

Input: 49 34 38 19 38 25

Output: Second

Input: 61 39 14 30 14 37

Output: Second

Input: 100 32 71 12 71 22

Output: Second

Input: 96 54 9 30 9 47

Output: Second

Input: 57 85 29 40 29 69

Output: Second

Input: 64 96 4 2 4 80

Output: Second

Input: 99 100 24 1 24 100

Output: Second

Input: 18 72 2 71 3 71

Output: First

Input: 24 68 19 14 18 15

Output: First

Input: 24 32 6 2 7 4

Output: First

Input: 28 14 21 2 20 5

Output: First

Input: 30 85 9 45 8 49

Output: First

Input: 34 55 7 25 8 30

Output: Second

Input: 34 39 18 1 17 7

Output: Second

Input: 21 18 16 6 15 17

Output: Second

Input: 37 100 33 13 32 30

Output: Second

Input: 11 97 2 29 1 76

Output: Second

Input: 89 100 54 1 55 100

Output: Second

Input: 80 97 70 13 68 13

Output: First

Input: 24 97 21 54 19 55

Output: First

Input: 76 7 24 4 26 6

Output: First

Input: 20 77 5 49 3 52

Output: First

Input: 18 18 11 12 13 16

Output: First

Input: 60 100 28 80 26 85

Output: Second

Input: 14 96 3 80 1 86

Output: Second

Input: 40 43 40 9 38 28

Output: Second

Input: 44 99 10 5 8 92

Output: Second

Input: 52 70 26 65 23 65

Output: First

Input: 13 25 4 2 7 3

Output: First

Input: 36 76 36 49 33 51

Output: First

Input: 64 91 52 64 49 67

Output: First

Input: 87 15 56 8 59 12

Output: Second

Input: 48 53 24 37 21 42

Output: Second

Input: 71 85 10 14 13 20

Output: Second

Input: 23 90 6 31 9 88

Output: Second

Input: 47 95 27 70 23 70

Output: First

Input: 63 54 19 22 23 23

Output: First

Input: 47 91 36 61 32 63

Output: First

Input: 63 22 54 16 58 19

Output: Second

Input: 15 11 12 5 8 9

Output: Second

Input: 31 80 28 70 24 75

Output: Second

Input: 15 48 6 42 10 48

Output: Second

Input: 21 68 2 13 6 57

Output: Second

Input: 73 64 63 32 68 32

Output: Second

Input: 89 81 33 18 28 19

Output: Second

Input: 13 62 10 13 5 15

Output: Second

Input: 35 19 4 8 9 11

Output: Second

Input: 51 8 24 3 19 7

Output: Second

Input: 73 27 40 8 45 13

Output: Second

Input: 51 76 50 5 45 76

Output: Second

Input: 74 88 33 20 39 20

Output: Second

Input: 28 7 17 5 11 6

Output: Second

Input: 8 33 2 21 8 23

Output: Second

Input: 30 47 9 32 3 35

Output: Second

Input: 10 5 10 1 4 5

Output: Second

Input: 84 43 71 6 77 26

Output: Second

Input: 87 13 77 7 70 7

Output: Second

Input: 41 34 27 7 20 8

Output: Second

Input: 73 79 17 42 10 67

Output: Second

Input: 48 86 31 36 23 36

Output: Second

Input: 16 97 7 4 15 94

Output: Second

Input: 48 11 33 8 24 8

Output: Second

Input: 39 46 21 22 30 35

Output: Second

Input: 96 75 15 10 6 65

Output: Second

Input: 25 68 3 39 20 41

Output: Second

Input: 41 64 10 21 29 50

Output: Second

Input: 24 65 23 18 3 64

Output: Second

Input: 40 100 4 1 30 100

Output: Second

Input: 73 95 58 11 11 24

Output: Second

Input: 89 51 76 1 25 51

Output: Second

Input: 77 99 56 1 3 99

Output: Second

Input: 97 94 96 2 7 93

Output: Second

Input: 100 100 1 1 100 100

Output: Second

Input: 100 94 1 30 100 30

Output: Second

Input: 10 10 1 1 4 5

Output: Second

Input: 5 5 1 1 4 5

Output: Second

Input: 100 100 1 1 5 4

Output: Second

Input: 100 100 10 10 13 14

Output: Second

Input: 10 10 1 1 5 4

Output: Second

Input: 10 10 1 1 1 6

Output: Second

Input: 100 100 1 1 4 5

Output: Second

Input: 100 100 1 1 3 5

Output: First

Input: 4 5 1 1 4 5

Output: Second

Input: 5 5 1 1 3 5

Output: First

Input: 50 50 1 1 5 4

Output: Second

Input: 5 5 1 5 4 1

Output: Second

Input: 100 100 1 1 2 6

Output: Second

Input: 50 50 1 1 4 5

Output: Second

Input: 5 5 1 1 5 4

Output: Second

Input: 10 10 1 1 3 5

Output: First

Input: 6 6 1 1 6 1

Output: Second

Input: 5 4 1 1 5 4

Output: Second

Input: 6 2 6 1 1 2

Output: Second

Input: 10 10 3 4 3 5

Output: First

Input: 10 10 1 1 5 3

Output: First

Input: 10 10 6 1 1 1

Output: Second

Input: 10 10 1 1 6 2

Output: Second

Input: 50 50 1 1 5 2

Output: First

Input: 3 5 1 1 3 5

Output: First

Input: 5 5 1 1 5 3

Output: First

Input: 10 10 7 7 3 4

Output: Second

Input: 100 100 1 1 5 1

Output: First

Input: 6 6 1 1 1 6

Output: Second


The first line of the input contains two integers, given in the decimal notation, n and m (1 ≤ n, m ≤ 109) — the number of hours in one day and the number of minutes in one hour, respectively.

#include <stdlib.h>
#include <stdio.h>

int main() {
	int n, m, d;
	scanf("%d%d", &n, &m);
	int dn = 1, dm = 1;
	for(int k = 7 ; k < n ; k *= 7) dn++;
	for(int k = 7 ; k < m ; k *= 7) dm++;
	d = dn + dm;
	if(d > 7) {
		printf("0\n");
		return 0;
	}
	int r = 0;
	for(int i=0 ; i<n ; i++) {
		for(int j=0 ; j<m ; j++) {
			int u[7] = {0};
			int a = i, b = j;
			for(int k=0 ; k<dn ; k++) {
				u[a%7]++;
				a /= 7;
			}
			for(int k=0 ; k<dm ; k++) {
				u[b%7]++;
				b /= 7;
			}
			r++;
			for(int k=0 ; k<7 ; k++) {
				if(u[k] > 1) {
					r--;
					break;
				}
			}
		}
	}
	printf("%d\n", r);
	return 0;
}

NoteIn the first sample, possible pairs are: (0: 1), (0: 2), (1: 0), (1: 2).In the second sample, possible pairs are: (02: 1), (03: 1), (04: 1), (05: 1), (06: 1).

Print one integer in decimal notation — the number of different pairs of hour and minute, such that all digits displayed on the watches are distinct.

Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.First, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they divide one day in n hours, and each hour in m minutes. Personal watches of each robber are divided in two parts: first of them has the smallest possible number of places that is necessary to display any integer from 0 to n - 1, while the second has the smallest possible number of places that is necessary to display any integer from 0 to m - 1. Finally, if some value of hours or minutes can be displayed using less number of places in base 7 than this watches have, the required number of zeroes is added at the beginning of notation.Note that to display number 0 section of the watches is required to have at least one place.Little robber wants to know the number of moments of time (particular values of hours and minutes), such that all digits displayed on the watches are distinct. Help her calculate this number.

Input: 2 3

Output: 4

Input: 8 2

Output: 5

Input: 1 1

Output: 0

Input: 1 2

Output: 1

Input: 8 8

Output: 0

Input: 50 50

Output: 0

Input: 344 344

Output: 0

Input: 282475250 282475250

Output: 0

Input: 8 282475250

Output: 0

Input: 1000000000 1000000000

Output: 0

Input: 16808 7

Output: 720

Input: 2402 50

Output: 0

Input: 343 2401

Output: 5040

Input: 1582 301

Output: 2874

Input: 421414245 4768815

Output: 0

Input: 2401 343

Output: 5040

Input: 2 1

Output: 1

Input: 282475250 8

Output: 0

Input: 8 7

Output: 35

Input: 50 7

Output: 120

Input: 16808 8

Output: 0

Input: 2402 49

Output: 720

Input: 123 123

Output: 360

Input: 123 456

Output: 150

Input: 1 9

Output: 0

Input: 1 10

Output: 1

Input: 50 67

Output: 6

Input: 7 117649

Output: 5040

Input: 2400 342

Output: 5040

Input: 2400 227

Output: 3360

Input: 117648 5

Output: 3600

Input: 16808 41

Output: 0

Input: 3 16808

Output: 240

Input: 823542 3

Output: 0

Input: 3 823544

Output: 0

Input: 117650 5

Output: 0

Input: 50 50

Output: 0

Input: 50 3

Output: 40

Input: 2402 343

Output: 0


The first line contains four integers a, b, c, d (250 ≤ a, b ≤ 3500, 0 ≤ c, d ≤ 180).  It is guaranteed that numbers a and b are divisible by 250 (just like on any real Codeforces round).

#include <stdio.h>
int max(int a, int b){
    int maxim;
    return maxim=(a>=b)?a:b;
}

int main(void)
{
    int a,b,c,d, misha, vasya;
    scanf("%d %d %d %d", &a,&b,&c,&d);
    misha = max((3*a)/10 ,a- ((a*c)/250));
    vasya = max((3*b)/10 ,b-((b*d)/250));
    if(misha>vasya) printf("Misha");
    else if(misha<vasya) printf("Vasya");
    else printf("Tie");

    return 0;
}

Output on a single line:  "Misha" (without the quotes), if Misha got more points than Vasya. "Vasya" (without the quotes), if Vasya got more points than Misha. "Tie" (without the quotes), if both of them got the same number of points.

Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c minutes after the contest started and Vasya submitted the problem d minutes after the contest started. As you know, on Codeforces the cost of a problem reduces as a round continues. That is, if you submit a problem that costs p points t minutes after the contest started, you get  points. Misha and Vasya are having an argument trying to find out who got more points. Help them to find out the truth.

Input: 500 1000 20 30

Output: Vasya

Input: 1000 1000 1 1

Output: Tie

Input: 1500 1000 176 177

Output: Misha

Input: 1500 1000 74 177

Output: Misha

Input: 750 2500 175 178

Output: Vasya

Input: 750 1000 54 103

Output: Tie

Input: 2000 1250 176 130

Output: Tie

Input: 1250 1750 145 179

Output: Tie

Input: 2000 2000 176 179

Output: Tie

Input: 1500 1500 148 148

Output: Tie

Input: 2750 1750 134 147

Output: Misha

Input: 3250 250 175 173

Output: Misha

Input: 500 500 170 176

Output: Misha

Input: 250 1000 179 178

Output: Vasya

Input: 3250 1000 160 138

Output: Misha

Input: 3000 2000 162 118

Output: Tie

Input: 1500 1250 180 160

Output: Tie

Input: 1250 2500 100 176

Output: Tie

Input: 3500 3500 177 178

Output: Tie

Input: 3000 3250 16 34

Output: Tie

Input: 1750 3000 137 49

Output: Vasya

Input: 500 1500 179 71

Output: Vasya

Input: 1250 2000 101 180

Output: Misha

Input: 250 750 180 176

Output: Vasya

Input: 2250 2250 163 145

Output: Vasya

Input: 3000 3000 176 78

Output: Vasya

Input: 250 3500 8 178

Output: Vasya

Input: 1750 1250 179 180

Output: Misha

Input: 2750 1750 13 164

Output: Misha

Input: 1750 2250 178 53

Output: Vasya

Input: 2500 2750 73 179

Output: Misha

Input: 1000 3500 178 175

Output: Vasya

Input: 1000 500 7 162

Output: Misha

Input: 1000 250 175 48

Output: Misha

Input: 1750 500 166 177

Output: Misha

Input: 250 250 0 0

Output: Tie

Input: 250 3500 0 0

Output: Vasya

Input: 250 3500 0 180

Output: Vasya

Input: 3500 3500 180 180

Output: Tie

Input: 3500 250 0 180

Output: Misha


The first line contains three integers s, x1 and x2 (2 ≤ s ≤ 1000, 0 ≤ x1, x2 ≤ s, x1 ≠ x2) — the maximum coordinate of the point to which the tram goes, the point Igor is at, and the point he should come to. The second line contains two integers t1 and t2 (1 ≤ t1, t2 ≤ 1000) — the time in seconds in which the tram passes 1 meter and the time in seconds in which Igor passes 1 meter. The third line contains two integers p and d (1 ≤ p ≤ s - 1, d is either 1 or ) — the position of the tram in the moment Igor came to the point x1 and the direction of the tram at this moment. If , the tram goes in the direction from the point s to the point 0. If d = 1, the tram goes in the direction from the point 0 to the point s.

NoteIn the first example it is profitable for Igor to go by foot and not to wait the tram. Thus, he has to pass 2 meters and it takes 8 seconds in total, because he passes 1 meter per 4 seconds. In the second example Igor can, for example, go towards the point x2 and get to the point 1 in 6 seconds (because he has to pass 3 meters, but he passes 1 meters per 2 seconds). At that moment the tram will be at the point 1, so Igor can enter the tram and pass 1 meter in 1 second. Thus, Igor will reach the point x2 in 7 seconds in total.

Print the minimum time in seconds which Igor needs to get from the point x1 to the point x2.

The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points x = 0 and x = s.Igor is at the point x1. He should reach the point x2. Igor passes 1 meter per t2 seconds. Your task is to determine the minimum time Igor needs to get from the point x1 to the point x2, if it is known where the tram is and in what direction it goes at the moment Igor comes to the point x1.Igor can enter the tram unlimited number of times at any moment when his and the tram's positions coincide. It is not obligatory that points in which Igor enter and exit the tram are integers. Assume that any boarding and unboarding happens instantly. Igor can move arbitrary along the line (but not faster than 1 meter per t2 seconds). He can also stand at some point for some time.

Input:
4 2 4
3 4
1 1

Output: 8

Input:
5 4 0
1 2
3 1

Output: 7

Input:
5 4 0
5 14
1 -1

Output: 55

Input:
10 7 2
7 9
9 -1

Output: 45

Input:
20 5 19
163 174
4 1

Output: 2436

Input:
1000 610 733
226 690
357 1

Output: 84870

Input:
40 31 14
628 1000
36 1

Output: 17000

Input:
100 20 83
186 434
64 -1

Output: 27342

Input:
200 179 81
126 457
37 -1

Output: 44786

Input:
400 30 81
193 1000
338 1

Output: 51000

Input:
500 397 440
202 1000
75 1

Output: 43000

Input:
600 443 587
260 1000
548 -1

Output: 144000

Input:
799 254 294
539 1000
284 -1

Output: 40000

Input:
801 489 351
86 702
125 1

Output: 96836

Input:
999 951 297
62 106
574 1

Output: 69324

Input:
1000 711 437
42 126
745 1

Output: 34356

Input:
1000 812 761
230 1000
696 -1

Output: 51000

Input:
1000 913 474
34 162
566 -1

Output: 71118

Input:
1000 394 798
155 673
954 -1

Output: 271560

Input:
1000 876 884
299 1000
825 1

Output: 8000

Input:
2 0 2
1 1
1 1

Output: 2

Input:
5 4 2
1 2
3 1

Output: 4

Input:
4 2 4
3 4
2 1

Output: 6

Input:
200 10 100
1 100
20 1

Output: 480

Input:
6 4 2
1 2
3 1

Output: 4

Input:
3 1 3
1 2
1 1

Output: 2

Input:
10 3 6
1 2
3 1

Output: 3

Input:
1000 50 51
1 3
50 1

Output: 1

Input:
100 1 2
1 100
1 1

Output: 1

Input:
5 1 4
1 100
1 1

Output: 3

Input:
10 0 5
1 100
7 1

Output: 18

Input:
5 4 1
1 100
4 -1

Output: 3

Input:
10 6 9
3 100
5 1

Output: 12

Input:
50 10 30
1 50
10 1

Output: 20

Input:
4 1 4
1 100
2 1

Output: 10

Input:
10 5 9
1 10
5 1

Output: 4

Input:
20 15 10
5 2
3 1

Output: 10

Input:
2 2 0
7 3
1 1

Output: 6

Input:
10 1 9
1 10
1 1

Output: 8

Input:
1000 2 902
1 1000
2 1

Output: 900

Input:
100 9 6
3 100
5 1

Output: 300

Input:
10 1 6
1 10
3 -1

Output: 9

Input:
1000 902 2
1 1000
902 -1

Output: 900

Input:
100 50 25
1 1000
10 1

Output: 165

Input:
5 3 0
1 2
4 -1

Output: 4

Input:
4 1 2
1 10
3 1

Output: 7

Input:
10 4 8
1 5
4 -1

Output: 12


The first line contains an integer m (0 ≤ m ≤ 10), which is the number of relations of acquaintances among the five friends of Igor's. Each of the following m lines contains two integers ai and bi (1 ≤ ai, bi ≤ 5;ai ≠ bi), where (ai, bi) is a pair of acquainted people. It is guaranteed that each pair of the acquaintances is described exactly once. The acquaintance relation is symmetrical, i.e. if x is acquainted with y, then y is also acquainted with x.

Print "FAIL", if among those five people there are no either three pairwise acquainted or three pairwise unacquainted people. Otherwise print "WIN".

One day Igor K. stopped programming and took up math. One late autumn evening he was sitting at a table reading a book and thinking about something. The following statement caught his attention: "Among any six people there are either three pairwise acquainted people or three pairwise unacquainted people"Igor just couldn't get why the required minimum is 6 people. "Well, that's the same for five people, too!" — he kept on repeating in his mind. — "Let's take, say, Max, Ilya, Vova — here, they all know each other! And now let's add Dima and Oleg to Vova — none of them is acquainted with each other! Now, that math is just rubbish!"Igor K. took 5 friends of his and wrote down who of them is friends with whom. Now he wants to check whether it is true for the five people that among them there are either three pairwise acquainted or three pairwise not acquainted people.

Input:
4
1 3
2 3
1 4
5 3

Output: WIN

Input:
5
1 2
2 3
3 4
4 5
5 1

Output: FAIL

Input:
1
4 3

Output: WIN

Input:
6
1 3
2 3
1 2
5 3
4 2
4 5

Output: WIN

Input:
2
1 3
2 5

Output: WIN

Input:
3
5 3
4 3
4 5

Output: WIN

Input:
5
1 3
3 2
2 4
5 4
1 5

Output: FAIL

Input:
7
1 3
5 1
1 4
2 1
5 3
4 5
2 5

Output: WIN

Input:
5
5 1
4 1
2 3
4 5
3 1

Output: WIN

Output: WIN

Input:
10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

Output: WIN

Input:
4
1 2
2 3
3 4
4 1

Output: WIN

Input:
1
3 5

Output: WIN

Input:
1
5 4

Output: WIN

Input:
2
5 3
1 3

Output: WIN

Input:
2
3 4
1 4

Output: WIN

Input:
2
3 1
2 3

Output: WIN

Input:
2
4 5
5 3

Output: WIN

Input:
3
2 4
1 4
4 5

Output: WIN

Input:
3
5 1
4 1
3 4

Output: WIN

Input:
3
1 3
5 3
4 5

Output: WIN

Input:
3
4 1
1 5
2 5

Output: WIN

Input:
3
2 1
3 1
4 3

Output: WIN

Input:
3
5 1
3 1
1 2

Output: WIN

Input:
4
4 1
4 2
4 5
3 5

Output: WIN

Input:
4
5 1
4 2
1 2
3 4

Output: WIN

Input:
4
4 5
3 5
1 2
4 2

Output: WIN

Input:
4
5 3
2 5
3 1
1 2

Output: WIN

Input:
4
3 4
5 4
2 4
3 1

Output: WIN

Input:
4
5 1
3 2
5 3
2 5

Output: WIN

Input:
4
2 5
2 3
3 5
1 4

Output: WIN

Input:
4
1 2
5 2
3 5
1 5

Output: WIN

Input:
5
2 4
3 1
4 5
5 3
1 2

Output: FAIL

Input:
5
5 1
3 5
1 2
2 4
4 3

Output: FAIL

Input:
5
1 2
2 3
5 1
4 5
3 4

Output: FAIL

Input:
5
2 1
4 3
1 5
5 4
3 2

Output: FAIL

Input:
5
3 2
1 4
4 5
5 3
2 1

Output: FAIL

Input:
5
1 3
4 2
3 4
2 5
5 1

Output: FAIL

Input:
5
1 2
2 5
5 4
4 3
3 1

Output: FAIL

Input:
5
1 4
4 2
2 5
3 1
5 3

Output: FAIL

Input:
5
3 5
2 4
1 3
5 2
4 1

Output: FAIL

Input:
5
1 2
4 3
5 1
3 5
2 4

Output: FAIL

Input:
5
1 4
5 4
5 1
3 4
3 5

Output: WIN

Input:
5
1 5
3 4
1 4
5 4
4 2

Output: WIN

Input:
5
2 3
4 3
1 3
5 2
5 1

Output: WIN

Input:
5
3 5
4 5
3 1
1 5
2 4

Output: WIN

Input:
5
5 4
3 4
4 1
3 5
3 2

Output: WIN

Input:
5
3 2
5 4
2 1
1 5
3 1

Output: WIN

Input:
5
4 5
5 3
2 3
3 1
5 1

Output: WIN

Input:
5
2 4
1 3
5 3
3 2
4 3

Output: WIN

Input:
5
3 5
4 2
1 4
3 4
5 2

Output: WIN

Input:
5
1 3
1 4
2 1
4 3
1 5

Output: WIN

Input:
5
4 2
5 2
2 3
1 3
4 1

Output: WIN

Input:
5
3 2
5 3
2 5
1 4
3 4

Output: WIN

Input:
5
2 5
1 3
4 3
2 1
2 3

Output: WIN

Input:
5
1 4
4 2
1 3
3 4
1 2

Output: WIN

Input:
5
4 1
5 2
3 1
4 3
3 5

Output: WIN

Input:
5
4 1
5 1
2 3
2 5
1 2

Output: WIN

Input:
5
3 2
3 1
2 5
1 5
4 3

Output: WIN

Input:
5
5 1
5 3
3 2
4 5
3 4

Output: WIN

Input:
5
1 5
2 1
5 2
2 4
4 3

Output: WIN

Input:
5
2 3
1 4
3 5
1 5
5 4

Output: WIN

Input:
6
5 4
5 1
3 1
2 3
3 5
2 4

Output: WIN

Input:
6
5 4
1 4
4 2
3 2
5 1
3 1

Output: WIN

Input:
6
1 4
2 1
5 2
3 5
3 2
2 4

Output: WIN

Input:
6
1 5
4 2
1 3
4 5
2 1
1 4

Output: WIN

Input:
6
3 1
5 2
1 2
2 3
3 4
4 2

Output: WIN

Input:
6
4 5
3 4
2 4
1 3
2 3
4 1

Output: WIN

Input:
6
5 1
4 2
2 1
4 1
3 4
3 2

Output: WIN

Input:
6
3 2
2 1
2 4
2 5
5 3
1 4

Output: WIN

Input:
7
4 2
3 1
4 5
3 2
5 2
5 3
1 5

Output: WIN

Input:
7
3 1
1 2
4 1
4 5
4 2
2 3
1 5

Output: WIN

Input:
7
1 5
1 4
5 4
5 3
1 2
2 3
5 2

Output: WIN

Input:
7
2 3
3 4
2 5
4 5
5 3
5 1
2 4

Output: WIN

Input:
7
2 3
2 1
4 5
5 2
3 4
3 1
4 1

Output: WIN

Input:
7
2 5
2 1
3 5
1 4
3 4
4 5
4 2

Output: WIN

Input:
8
5 1
5 3
4 5
3 4
2 4
1 3
2 5
2 3

Output: WIN

Input:
8
4 3
1 5
4 1
2 4
2 5
5 3
1 3
4 5

Output: WIN

Input:
8
3 2
3 1
4 1
2 4
3 5
1 5
3 4
1 2

Output: WIN

Input:
8
3 4
4 2
4 5
2 3
3 5
2 1
1 5
3 1

Output: WIN

Input:
9
3 2
5 1
5 2
2 1
1 4
1 3
2 4
5 3
5 4

Output: WIN

Input:
9
2 4
3 2
2 5
4 5
3 5
1 3
5 1
1 2
4 3

Output: WIN

Input:
3
3 4
4 5
5 3

Output: WIN

Input:
3
1 2
1 3
4 5

Output: WIN

Input:
3
2 3
3 5
2 5

Output: WIN

Input:
1
2 1

Output: WIN

Input:
1
2 5

Output: WIN

Input:
2
2 1
1 5

Output: WIN

Input:
2
4 2
1 5

Output: WIN

Input:
2
3 4
5 2

Output: WIN

Input:
2
1 5
4 3

Output: WIN

Input:
3
4 1
4 5
2 1

Output: WIN

Input:
3
5 1
5 3
2 5

Output: WIN

Input:
3
1 2
4 2
1 3

Output: WIN

Input:
3
3 2
1 5
5 3

Output: WIN

Input:
3
1 2
2 4
3 2

Output: WIN

Input:
3
2 1
1 3
5 4

Output: WIN

Input:
4
4 2
2 5
1 4
4 5

Output: WIN

Input:
4
5 2
2 4
5 3
1 5

Output: WIN

Input:
4
2 5
1 3
4 3
4 2

Output: WIN

Input:
4
1 4
3 1
2 3
1 2

Output: WIN

Input:
4
5 4
2 3
1 5
5 2

Output: WIN

Input:
4
2 5
5 4
1 4
5 3

Output: WIN

Input:
4
2 1
2 4
5 1
4 1

Output: WIN

Input:
4
1 2
1 5
4 5
2 3

Output: WIN

Input:
5
4 1
2 4
3 2
5 3
1 5

Output: FAIL

Input:
5
1 3
4 1
5 2
2 4
3 5

Output: FAIL

Input:
5
3 5
4 2
1 3
2 1
5 4

Output: FAIL

Input:
5
5 2
1 3
4 5
2 1
3 4

Output: FAIL

Input:
5
2 3
3 5
1 2
4 1
5 4

Output: FAIL

Input:
5
1 2
4 5
5 3
3 1
2 4

Output: FAIL

Input:
5
5 3
3 2
2 4
1 5
4 1

Output: FAIL

Input:
5
3 2
4 1
2 5
1 3
5 4

Output: FAIL

Input:
5
3 5
1 4
5 1
2 3
4 2

Output: FAIL

Input:
5
4 2
5 3
2 1
3 4
1 5

Output: FAIL

Input:
5
3 1
5 1
4 5
2 4
5 3

Output: WIN

Input:
5
5 4
5 3
3 1
1 4
2 3

Output: WIN

Input:
5
4 1
3 5
3 4
5 4
5 2

Output: WIN

Input:
5
4 1
5 2
3 1
4 2
5 1

Output: WIN

Input:
5
2 3
1 5
5 3
2 4
1 4

Output: FAIL

Input:
5
5 4
5 3
2 3
5 2
5 1

Output: WIN

Input:
5
2 4
3 4
1 4
2 1
3 2

Output: WIN

Input:
5
2 3
3 4
1 3
4 1
5 2

Output: WIN

Input:
5
1 2
2 5
4 2
4 3
3 1

Output: WIN

Input:
5
2 1
2 5
4 5
2 3
3 5

Output: WIN

Input:
5
4 1
5 1
5 4
4 3
5 2

Output: WIN

Input:
5
1 3
2 4
1 5
5 2
4 1

Output: WIN

Input:
5
1 5
3 5
2 3
4 1
3 1

Output: WIN

Input:
5
5 2
3 2
2 1
4 3
4 2

Output: WIN

Input:
5
1 3
4 5
3 4
3 5
5 1

Output: WIN

Input:
5
4 5
2 5
5 3
4 2
4 1

Output: WIN

Input:
5
2 5
1 5
1 3
3 5
1 2

Output: WIN

Input:
5
2 4
1 2
5 2
5 3
4 5

Output: WIN

Input:
5
2 1
4 5
5 3
1 5
1 4

Output: WIN

Input:
5
1 3
2 5
4 2
3 4
4 1

Output: WIN

Input:
6
3 2
2 4
3 1
3 5
5 2
1 2

Output: WIN

Input:
6
2 1
5 1
5 4
3 5
3 4
4 1

Output: WIN

Input:
6
3 1
1 4
5 4
2 1
4 2
1 5

Output: WIN

Input:
6
5 1
5 4
3 4
1 3
1 4
4 2

Output: WIN

Input:
6
1 3
5 4
4 2
2 1
4 1
2 3

Output: WIN

Input:
6
4 3
5 3
4 1
1 3
1 2
2 4

Output: WIN

Input:
6
4 1
3 5
4 5
3 1
4 3
5 2

Output: WIN

Input:
6
2 1
1 4
4 5
5 2
1 3
3 2

Output: WIN

Input:
7
5 1
3 5
2 5
4 5
2 3
3 1
4 3

Output: WIN

Input:
7
5 3
5 1
4 2
4 5
3 2
3 4
1 3

Output: WIN

Input:
7
3 5
1 4
5 2
1 5
1 3
4 2
4 3

Output: WIN

Input:
7
5 1
5 4
2 4
2 3
3 5
2 5
4 1

Output: WIN

Input:
7
1 3
2 5
4 3
2 1
2 3
4 5
2 4

Output: WIN

Input:
7
3 1
4 5
3 5
5 1
2 4
1 2
1 4

Output: WIN

Input:
8
1 5
3 1
2 5
4 2
2 1
4 5
4 3
4 1

Output: WIN

Input:
8
4 2
3 1
4 3
2 5
3 2
4 5
1 2
3 5

Output: WIN

Input:
8
2 4
3 2
2 5
3 4
3 1
5 1
4 5
5 3

Output: WIN

Input:
8
2 3
1 5
1 3
4 5
2 4
1 4
3 5
3 4

Output: WIN

Input:
9
3 5
3 2
1 5
4 3
5 4
1 4
1 3
4 2
5 2

Output: WIN

Input:
9
3 5
2 5
5 1
4 5
1 3
3 2
1 4
4 3
4 2

Output: WIN


The first input line contains the single integer n (1 ≤ n ≤ 1000) — the number of pages in the book. The second line contains seven non-negative space-separated integers that do not exceed 1000 — those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.

#include<stdio.h>
int main()
{
    int i,j,t,a,b,page, sum =0;
    int day[8];

    scanf ("%d",&page);

    for(i=1; i<8; i++){
        scanf("%d", &day[i]);
    }

    j = 0;
    while(1){
        j++;
        sum = sum + day[j];
        if(sum >= page){
            printf("%d\n", j);
            break;
        }
        else if(j==7){
            j = 0;
        }

    }
}

NoteNote to the first sample:By the end of Monday and therefore, by the beginning of Tuesday Petr has 85 pages left. He has 65 pages left by Wednesday, 45 by Thursday, 30 by Friday, 20 by Saturday and on Saturday Petr finishes reading the book (and he also has time to read 10 pages of something else).Note to the second sample:On Monday of the first week Petr will read the first page. On Monday of the second week Petr will read the second page and will finish reading the book.

Print a single number — the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.

Input:
100
15 20 20 15 10 30 45

Output: 6

Input:
2
1 0 0 0 0 0 0

Output: 1

Input:
100
100 200 100 200 300 400 500

Output: 1

Input:
3
1 1 1 1 1 1 1

Output: 3

Input:
1
1 1 1 1 1 1 1

Output: 1

Input:
20
5 3 7 2 1 6 4

Output: 6

Input:
10
5 1 1 1 1 1 5

Output: 6

Input:
50
10 1 10 1 10 1 10

Output: 1

Input:
77
11 11 11 11 11 11 10

Output: 1

Input:
1
1000 1000 1000 1000 1000 1000 1000

Output: 1

Input:
1000
100 100 100 100 100 100 100

Output: 3

Input:
999
10 20 10 20 30 20 10

Output: 3

Input:
433
109 58 77 10 39 125 15

Output: 7

Input:
1
0 0 0 0 0 0 1

Output: 7

Input:
5
1 0 1 0 1 0 1

Output: 1

Input:
997
1 1 0 0 1 0 1

Output: 1

Input:
1000
1 1 1 1 1 1 1

Output: 6

Input:
1000
1000 1000 1000 1000 1000 1000 1000

Output: 1

Input:
1000
1 0 0 0 0 0 0

Output: 1

Input:
1000
0 0 0 0 0 0 1

Output: 7

Input:
1000
1 0 0 1 0 0 1

Output: 1

Input:
509
105 23 98 0 7 0 155

Output: 2

Input:
7
1 1 1 1 1 1 1

Output: 7

Input:
2
1 1 0 0 0 0 0

Output: 2

Input:
1
0 0 0 0 0 1 0

Output: 6

Input:
10
0 0 0 0 0 0 1

Output: 7

Input:
5
0 0 0 0 0 6 0

Output: 6

Input:
3
0 1 0 0 0 0 0

Output: 2

Input:
10
0 0 0 0 0 0 10

Output: 7

Input:
28
1 2 3 4 5 6 7

Output: 7

Input:
100
5 5 5 5 5 5 5

Output: 6

Input:
4
1 0 0 0 0 0 1

Output: 7

Input:
2
0 0 0 0 0 0 1

Output: 7

Input:
7
0 0 0 0 0 0 7

Output: 7

Input:
7
2 1 1 1 1 1 0

Output: 6

Input:
2
0 0 1 1 0 0 0

Output: 4

Input:
6
1 1 1 1 1 1 0

Output: 6

Input:
5
1 1 1 0 0 1 1

Output: 7

Input:
100
10 20 30 10 10 10 10

Output: 7

Input:
1
0 0 0 1 0 0 0

Output: 4

Input:
70
10 10 10 10 10 10 10

Output: 7

Input:
22
1 2 3 4 5 6 10

Output: 7

Input:
5
0 0 0 1 0 0 0

Output: 4

Input:
2
0 0 0 1 0 0 0

Output: 4

Input:
6
1 0 0 0 0 0 2

Output: 7

Input:
10
1 2 2 1 2 1 1

Output: 7

Input:
5
0 0 0 0 0 0 10

Output: 7

Input:
4
0 1 1 0 0 0 0

Output: 3

Input:
100
0 0 0 0 0 1 0

Output: 6


The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space.

#include<stdio.h>
int main()
{
    int n,m,sum,d;
    scanf("%d %d",&n,&m);
    sum=n;
    rich:
    d=n/m;
    if(d>0)
    {
    sum=sum+d;
    if(((n%m)+d)>=m)
    {
    n=(n%m)+d;
    goto rich;
    }
    }
    printf("%d",sum);
    return 0;
}

NoteIn the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.

Print a single integer — the answer to the problem.

Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks?

Input: 2 2

Output: 3

Input: 9 3

Output: 13

Input: 1 2

Output: 1

Input: 2 3

Output: 2

Input: 1 99

Output: 1

Input: 4 4

Output: 5

Input: 10 2

Output: 19

Input: 10 9

Output: 11

Input: 100 100

Output: 101

Input: 2 27

Output: 2

Input: 99 100

Output: 99

Input: 99 2

Output: 197

Input: 100 3

Output: 149

Input: 98 3

Output: 146

Input: 100 2

Output: 199

Input: 62 4

Output: 82

Input: 99 10

Output: 109

Input: 100 5

Output: 124

Input: 80 80

Output: 81

Input: 95 16

Output: 101

Input: 75 16

Output: 79

Input: 99 74

Output: 100

Input: 20 21

Output: 20

Input: 52 96

Output: 52

Input: 24 5

Output: 29


The first three lines of the input contain the Little Elephant's notes. The first line contains elements of the first row of the magic square. The second line contains the elements of the second row, the third line is for the third row. The main diagonal elements that have been forgotten by the Elephant are represented by zeroes. It is guaranteed that the notes contain exactly three zeroes and they are all located on the main diagonal. It is guaranteed that all positive numbers in the table do not exceed 105.

Print three lines, in each line print three integers — the Little Elephant's magic square. If there are multiple magic squares, you are allowed to print any of them. Note that all numbers you print must be positive and not exceed 105. It is guaranteed that there exists at least one magic square that meets the conditions.

Little Elephant loves magic squares very much.A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns and diagonals equals 15.  The Little Elephant remembered one magic square. He started writing this square on a piece of paper, but as he wrote, he forgot all three elements of the main diagonal of the magic square. Fortunately, the Little Elephant clearly remembered that all elements of the magic square did not exceed 105. Help the Little Elephant, restore the original magic square, given the Elephant's notes.

Input:
0 1 1
1 0 1
1 1 0

Output:
1 1 1
1 1 1
1 1 1

Output:
1 1 1
 1 1 1
 1 1 1

Output:
1 1 1
1 1 1
1 1 1

Input:
0 3 6
5 0 5
4 7 0

Output:
6 3 6
 5 5 5
 4 7 4

Output:
6 3 6
5 5 5
4 7 4

Output:
6 3 6
5 5 5
4 7 4

Input:
0 4 4
4 0 4
4 4 0

Output:
4 4 4
 4 4 4
 4 4 4

Output:
4 4 4
4 4 4
4 4 4

Output:
4 4 4
4 4 4
4 4 4

Input:
0 54 48
36 0 78
66 60 0

Output:
69 54 48
36 57 78
66 60 45

Output:
69 54 48
36 57 78
66 60 45

Output:
69 54 48
 36 57 78
 66 60 45

Input:
0 17 14
15 0 15
16 13 0

Output:
14 17 14
 15 15 15
 16 13 16

Output:
14 17 14
15 15 15
16 13 16

Output:
14 17 14
15 15 15
16 13 16

Input:
0 97 56
69 0 71
84 43 0

Output:
57 97 56
69 70 71
84 43 83

Output:
57 97 56
 69 70 71
 84 43 83

Output:
57 97 56
69 70 71
84 43 83

Input:
0 1099 1002
1027 0 1049
1074 977 0

Output:
1013 1099 1002
1027 1038 1049
1074 977 1063

Output:
1013 1099 1002
1027 1038 1049
1074 977 1063

Output:
1013 1099 1002
 1027 1038 1049
 1074 977 1063

Input:
0 98721 99776
99575 0 99123
98922 99977 0

Output:
99550 98721 99776
99575 99349 99123
98922 99977 99148

Output:
99550 98721 99776
 99575 99349 99123
 98922 99977 99148

Output:
99550 98721 99776
99575 99349 99123
98922 99977 99148

Input:
0 6361 2304
1433 0 8103
7232 3175 0

Output:
5639 6361 2304
1433 4768 8103
7232 3175 3897

Output:
5639 6361 2304
1433 4768 8103
7232 3175 3897

Output:
5639 6361 2304
 1433 4768 8103
 7232 3175 3897

Input:
0 99626 99582
99766 0 99258
99442 99398 0

Output:
99328 99626 99582
99766 99512 99258
99442 99398 99696

Output:
99328 99626 99582
99766 99512 99258
99442 99398 99696

Output:
99328 99626 99582
 99766 99512 99258
 99442 99398 99696

Input:
0 99978 99920
99950 0 99918
99948 99890 0

Output:
99904 99978 99920
99950 99934 99918
99948 99890 99964

Output:
99904 99978 99920
 99950 99934 99918
 99948 99890 99964

Output:
99904 99978 99920
99950 99934 99918
99948 99890 99964

Input:
0 840 666
612 0 948
894 720 0

Output:
834 840 666
612 780 948
894 720 726

Output:
834 840 666
 612 780 948
 894 720 726

Output:
834 840 666
612 780 948
894 720 726

Input:
0 28 10
12 0 24
26 8 0

Output:
16 28 10
12 18 24
26 8 20

Output:
16 28 10
12 18 24
26 8 20

Output:
16 28 10
 12 18 24
 26 8 20

Input:
0 120 83
98 0 90
105 68 0

Output:
79 120 83
98 94 90
105 68 109

Output:
79 120 83
 98 94 90
 105 68 109

Output:
79 120 83
98 94 90
105 68 109

Input:
0 86900 85807
85836 0 86842
86871 85778 0

Output:
86310 86900 85807
 85836 86339 86842
 86871 85778 86368

Output:
86310 86900 85807
85836 86339 86842
86871 85778 86368

Output:
86310 86900 85807
85836 86339 86842
86871 85778 86368

Input:
0 74 78
78 0 74
74 78 0

Output:
76 74 78
78 76 74
74 78 76

Output:
76 74 78
 78 76 74
 74 78 76

Output:
76 74 78
78 76 74
74 78 76

Input:
0 505 681
605 0 657
581 757 0

Output:
707 505 681
605 631 657
581 757 555

Output:
707 505 681
 605 631 657
 581 757 555

Output:
707 505 681
605 631 657
581 757 555

Input:
0 662 918
822 0 854
758 1014 0

Output:
934 662 918
822 838 854
758 1014 742

Output:
934 662 918
 822 838 854
 758 1014 742

Output:
934 662 918
822 838 854
758 1014 742

Input:
0 93 95
93 0 97
95 97 0

Output:
97 93 95
93 95 97
95 97 93

Output:
97 93 95
93 95 97
95 97 93

Output:
97 93 95
 93 95 97
 95 97 93

Input:
0 709 712
719 0 695
702 705 0

Output:
700 709 712
 719 707 695
 702 705 714

Output:
700 709 712
719 707 695
702 705 714

Output:
700 709 712
719 707 695
702 705 714

Input:
0 7 6
9 0 1
4 3 0

Output:
2 7 6
9 5 1
4 3 8

Output:
2 7 6
9 5 1
4 3 8

Output:
2 7 6
 9 5 1
 4 3 8

Input:
0 9 2
3 0 7
8 1 0

Output:
4 9 2
3 5 7
8 1 6

Output:
4 9 2
3 5 7
8 1 6

Output:
4 9 2
 3 5 7
 8 1 6

Input:
0 1 43
13 0 61
31 73 0

Output:
67 1 43
 13 37 61
 31 73 7

Output:
67 1 43
13 37 61
31 73 7

Output:
67 1 43
13 37 61
31 73 7

Input:
0 100000 100000
100000 0 100000
100000 100000 0

Output:
100000 100000 100000
100000 100000 100000
100000 100000 100000

Output:
100000 100000 100000
100000 100000 100000
100000 100000 100000

Output:
100000 100000 100000
 100000 100000 100000
 100000 100000 100000


The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space. The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).

NoteIn the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.In the second example nobody got a positive score.

Output the number of participants who advance to the next round.

"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.

Input:
8 5
10 9 8 7 7 7 5 5

Output: 6

Input:
4 2
0 0 0 0

Output: 0

Input:
5 1
1 1 1 1 1

Output: 5

Input:
5 5
1 1 1 1 1

Output: 5

Input:
1 1
10

Output: 1

Input:
17 14
16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Output: 14

Input:
5 5
3 2 1 0 0

Output: 3

Input:
8 6
10 9 8 7 7 7 5 5

Output: 6

Input:
8 7
10 9 8 7 7 7 5 5

Output: 8

Input:
8 4
10 9 8 7 7 7 5 5

Output: 6

Input:
8 3
10 9 8 7 7 7 5 5

Output: 3

Input:
8 1
10 9 8 7 7 7 5 5

Output: 1

Input:
8 2
10 9 8 7 7 7 5 5

Output: 2

Input:
1 1
100

Output: 1

Input:
1 1
0

Output: 0

Input:
50 25
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 50

Input:
50 25
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 25

Input:
50 25
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 26

Input:
50 25
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 50

Input:
11 5
100 99 98 97 96 95 94 93 92 91 90

Output: 5

Input:
10 4
100 81 70 69 64 43 34 29 15 3

Output: 4

Input:
11 6
87 71 62 52 46 46 43 35 32 25 12

Output: 6

Input:
17 12
99 88 86 82 75 75 74 65 58 52 45 30 21 16 7 2 2

Output: 12

Input:
20 3
98 98 96 89 87 82 82 80 76 74 74 68 61 60 43 32 30 22 4 2

Output: 3

Input:
36 12
90 87 86 85 83 80 79 78 76 70 69 69 61 61 59 58 56 48 45 44 42 41 33 31 27 25 23 21 20 19 15 14 12 7 5 5

Output: 12

Input:
49 8
99 98 98 96 92 92 90 89 89 86 86 85 83 80 79 76 74 69 67 67 58 56 55 51 49 47 47 46 45 41 41 40 39 34 34 33 25 23 18 15 13 13 11 9 5 4 3 3 1

Output: 9

Input:
49 29
100 98 98 96 96 96 95 87 85 84 81 76 74 70 63 63 63 62 57 57 56 54 53 52 50 47 45 41 41 39 38 31 30 28 27 26 23 22 20 15 15 11 7 6 6 4 2 1 0

Output: 29

Input:
49 34
99 98 96 96 93 92 90 89 88 86 85 85 82 76 73 69 66 64 63 63 60 59 57 57 56 55 54 54 51 48 47 44 42 42 40 39 38 36 33 26 24 23 19 17 17 14 12 7 4

Output: 34

Input:
50 44
100 100 99 97 95 91 91 84 83 83 79 71 70 69 69 62 61 60 59 59 58 58 58 55 55 54 52 48 47 45 44 44 38 36 32 31 28 28 25 25 24 24 24 22 17 15 14 13 12 4

Output: 44

Input:
50 13
99 95 94 94 88 87 81 79 78 76 74 72 72 69 68 67 67 67 66 63 62 61 58 57 55 55 54 51 50 50 48 48 42 41 38 35 34 32 31 30 26 24 13 13 12 6 5 4 3 3

Output: 13

Input:
50 30
100 98 96 94 91 89 88 81 81 81 81 81 76 73 72 71 70 69 66 64 61 59 59 56 52 50 49 48 43 39 36 35 34 34 31 29 27 26 24 22 16 16 15 14 14 14 9 7 4 3

Output: 30

Input:
2 1
10 10

Output: 2

Input:
2 2
10 10

Output: 2

Input:
2 2
10 0

Output: 1

Input:
2 2
10 1

Output: 2

Input:
2 1
10 0

Output: 1

Input:
2 1
10 2

Output: 1

Input:
50 13
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 0

Input:
50 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 0

Input:
50 50
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 0

Input:
10 1
5 5 5 3 3 3 0 0 0 0

Output: 3

Input:
10 2
5 5 5 3 3 3 0 0 0 0

Output: 3

Input:
10 3
5 5 5 3 3 3 0 0 0 0

Output: 3

Input:
10 4
5 5 5 3 3 3 0 0 0 0

Output: 6

Input:
10 5
5 5 5 3 3 3 0 0 0 0

Output: 6

Input:
10 6
5 5 5 3 3 3 0 0 0 0

Output: 6

Input:
10 7
5 5 5 3 3 3 0 0 0 0

Output: 6

Input:
10 8
5 5 5 3 3 3 0 0 0 0

Output: 6

Input:
10 9
5 5 5 3 3 3 0 0 0 0

Output: 6

Input:
10 10
5 5 5 3 3 3 0 0 0 0

Output: 6