Valera is a coder. Recently he wrote a funny program. The pseudo code for this program is given below://input: integers x, k, pa = x;for(step = 1; step <= k; step = step + 1){    rnd = [random integer from 1 to 100];    if(rnd <= p)        a = a * 2;    else        a = a + 1;}s = 0;while(remainder after dividing a by 2 equals 0){    a = a / 2;    s = s + 1;}Now Valera wonders: given the values x, k and p, what is the expected value of the resulting number s?

The first line of the input contains three integers x, k, p (1 ≤ x ≤ 109; 1 ≤ k ≤ 200; 0 ≤ p ≤ 100).

Print the required expected value. Your answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6.

NoteIf the concept of expected value is new to you, you can read about it by the link: http://en.wikipedia.org/wiki/Expected_value

#include <bits/stdc++.h>
#include <algorithm>
#define int long long
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,x,n) for(int i=x;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define itr_ iterator
#define p_b push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define m_p make_pair
#define debug(x) cout<<#x<<":"<<x<<endl;
#define lowbit(x) (x&(-x))
#define setp setprecision
#define over(x) {cout<<x<<endl; return ;}
using namespace std;
const int INF=0x3f3f3f3f;
const ll INFL=1e18;
const ll mod=1000000007;
const ld eps=1e-14;

const int N=305;
int x,k;
ld p,f[N][N];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	cin>>x>>k>>p;
	p/=100;
	for(int i=0;i<=k;i++){
		for(int j=x+i;!(j&1);j>>=1)
			f[0][i]++;
	}
	for(int i=0;i<k;i++){
		for(int j=0;j<=k;j++){
			if(j) f[i+1][j-1]+=(1-p)*f[i][j];
			if(j*2<=k) f[i+1][j*2]+=p*(f[i][j]+1);
		}
	}
	cout<<fixed<<setp(13)<<f[k][0]<<endl;
	return 0;
}


One day as Petya and his friend Vasya were having one of their numerous trips, they decided to visit a museum castle. The museum has a specific shape: it consists of n rooms connected with m corridors so that one can access any room from any other one.After the two friends had a little walk around the museum, they decided to split and watch the pieces of art each of them found interesting. They agreed to meet in one of the rooms at six p.m. However, they forgot one quite essential thing: they didn't specify the place to meet and when the time came, they started to rush about the museum looking for each other (they couldn't call each other as roaming made a call's cost skyrocket).Yet, even despite the whole rush, they couldn't get enough of the pieces of art, that's why each of them has the following strategy: each minute he make a decision where to go — with probability pi he doesn't move to any other place during this minute (i.e. he stays in the room). With probability 1 - pi he equiprobably choose one of the adjacent rooms and went there along the corridor. Here i is the ordinal number of the current room. Building was expensive in ancient times, that's why each corridor connected two different rooms, and any two rooms had no more than one corridor between them. The boys act simultaneously. As the corridors are dark, it is impossible to meet there; however, one can walk along the corridors in both directions (besides, the two boys can be going through the same corridor simultaneously without meeting). The boys act like that until they meet each other. More formally, the two friends meet when at some moment of time both of them decided to appear in the same room.For each room find the probability that the boys will meet there considering that at 6 p.m. they are positioned in rooms a and b correspondingly.

The first line contains four integers: n (1 ≤ n ≤ 22), representing the numbers of rooms; m , representing the number of corridors; a, b (1 ≤ a, b ≤ n), representing the numbers of Petya's and Vasya's starting rooms correspondingly. Next m lines contain pairs of numbers — the numbers of rooms connected by a corridor. Next n lines contain probabilities pi (0.01 ≤ pi ≤ 0.99) with the accuracy of up to four digits after the decimal point — the probability to stay in room i. It is guaranteed that every room can be reached from every other room by corridors.

In the only line print n space-separated numbers, the i-th number should represent the probability that the friends meet in the i-th room with absolute or relative error of no more than 10 - 6.

NoteIn the first sample the museum is symmetric. That means the probabilities to meet in rooms 1 and 2 are equal. And their sum equals to one. So, each probability equals 0.5.

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)      REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(C)   (C).begin(),(C).end()
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}
typedef complex<double>P;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N = 22;
const int M = N*N+10;
const double eps = 1e-10;
vector<int> edge[N];
bool e[N][N];
double ori[M][M];

//n matrix size  a00+x0+...=c0
//k current step
//mat Matrix
bool select_pivot(int n,int k,double mat[M][M]){
 int s=k;//selected pivot
 double val=fabs(mat[k][k]);
 REP(i,k+1,n)if (fabs(mat[i][k]) >val)val=fabs(mat[i][k]),s=i;
 if (val<eps)return false;//cannot solve this linear equations.
 REP(i,k,n+1)swap(mat[k][i],mat[s][i]);
 return true;//no problem for this pivot;
}

//n matrix size  x0,x1,...xn-1 =constant
//row n,column n+1
bool gauss(int n,double mat[M][M]){
 //step1
 rep(k,n){
   if (select_pivot(n,k,mat)==false)return false;
   REP(i,k+1,n+1)mat[k][i]/=mat[k][k];//devided by m[k][k];
   mat[k][k]=1;//for looking the equation
   REP(i,k+1,n){//
     REP(j,k+1,n+1)mat[i][j]+=-mat[i][k]*mat[k][j];
     mat[i][k]=0;//For looking the equation
   }
 }
 //step2
 for(int i=n-1;i>=0;i--){//solve ith row
   REP(j,i+1,n){
     mat[i][n]-=mat[i][j]*mat[j][n];
   }
 }
 return true;
}

main(){
  int n,m,a,b;
  double mat[M][M];
  while(cin>>n>>m>>a>>b){
    a--;b--;
    rep(i,n){
      rep(j,n)e[i][j]=false;
      e[i][i]=true;
      edge[i].clear();
    }
    rep(i,m){
      int f,t;cin>>f>>t;f--;t--;edge[f].pb(t);edge[t].pb(f);
      e[f][t]=e[t][f]=true;
    }
    double st[n],move[n];
    rep(i,n)cin>>st[i],move[i]=(1-st[i])/edge[i].size();
    int size=n*n;
    rep(i,size)rep(j,size)mat[i][j]=0;

    rep(i,n){//first player is on i,
      rep(j,n){//first player is on j
	//(i,j) -> (k,l)
	int pos1 = i*n+j;
	//if (i == j){continue;}
	mat[pos1][pos1]-=1;
	rep(k,n){
	  if (!e[i][k])continue;
	  double p1 = i==k ?st[k]:move[k];
	  rep(l,n){
	    if (!e[j][l])continue;
	    if (k == l)continue;
	    int pos2=k*n+l;
	    double p2 = j==l ?st[l]:move[l];
	    mat[pos1][pos2]+=p1*p2;
	  }
	}
      }
    }
    mat[a*n+b][size]=-1;
    //if (n <= 3)rep(i,size)rep(j,size+1)printf("%.5lf%c",mat[i][j],j==size?'\n':' ');
    gauss(size,mat);
    //if (n <= 3)rep(i,size)rep(j,size+1)printf("%.5lf%c",mat[i][j],j==size?'\n':' ');

    for(int i=0;i<n;i++){
      if (i)printf(" ");
      printf("%.10lf",mat[i*n+i][size]);
    }
    printf("\n");

#ifdef DEBUG
    cout <<"end " <<  endl;
#endif
  }
  return false;
}


Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.Then Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so on (arbitrary number of changes could be made in each number). At some point it turned out that if we sum the resulting numbers, then the number of zeroes with which the sum will end would be maximum among the possible variants of digit permutations in those numbers.Given number n, can you find the two digit permutations that have this property?

The first line contains a positive integer n — the original number. The number of digits in this number does not exceed 105. The number is written without any leading zeroes.

Print two permutations of digits of number n, such that the sum of these numbers ends with the maximum number of zeroes. The permutations can have leading zeroes (if they are present, they all should be printed). The permutations do not have to be different. If there are several answers, print any of them.

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

string s;
int cnt1[11], cnt2[11], res1[100005], res2[100005];

int main() {
    cin>>s;
    for(int i= 0;i<s.size();++i) {
        ++cnt1[s[i]-'0'];
        ++cnt2[s[i]-'0'];
    }
    int res = 0, cntZero = 0, t1 = -1, t2 = -1;
    for(int x = 0;x<=cnt1[0];++x) {
        cnt1[0] -= x;
        cnt2[0] -= x;
        for(int i = 1;i<=5;++i) {
            int j = 10-i;
            if(cnt1[i] && cnt2[j]) {
                --cnt1[i];
                --cnt2[j];
                int numZeroes = x + 1;
                for(int k = 0;k<=9;++k)
                    numZeroes += min(cnt1[k],cnt2[9-k]);
                if(numZeroes > res) {
                    res = numZeroes;
                    cntZero = x;
                    t1 = i;
                    t2 = j;
                }
                ++cnt1[i];
                ++cnt2[j];
            }
        }
        cnt1[0] += x;
        cnt2[0] += x;
    }
    if(t1 == -1 && t2 == -1) {
        sort(s.begin(),s.end());
        reverse(s.begin(),s.end());
        cout<<s<<endl;
        cout<<s<<endl;
        return 0;
    }

    for(int i = 0;i<cntZero;++i)
        res1[i] = res2[i] = 0;

    cnt1[0] -= cntZero;
    cnt2[0] -= cntZero;
    --cnt1[t1];
    --cnt2[t2];
    res1[cntZero] = t1;
    res2[cntZero] = t2;
    for(int i = cntZero+1;i<s.size();++i) {
        bool ok = false;
        for(int j = 0;j<=9;++j) {
            if(cnt1[j] && cnt2[9-j]) {
                --cnt1[j];
                --cnt2[9-j];
                ok = true;
                res1[i] = j;
                res2[i] = 9-j;
                break;
            }
        }
        if(!ok) {
            for(int j = 0;j<=9;++j) {
                if(cnt1[j]) {
                    res1[i] = j;
                    --cnt1[j];
                    break;
                }
            }
            for(int j = 0;j<=9;++j) {
                if(cnt2[j]) {
                    res2[i] = j;
                    --cnt2[j];
                    break;
                }
            }
        }
    }

    for(int i = s.size()-1;i>=0;--i)
        printf("%d",res1[i]);
    printf("\n");
    for(int i = s.size()-1;i>=0;--i)
        printf("%d",res2[i]);
    printf("\n");

    return 0;
}


Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.Two lines rhyme if their suffixes that start from the k-th vowels (counting from the end) match. If a line has less than k vowels, then such line can't rhyme with any other line. For example, if k = 1, lines commit and hermit rhyme (the corresponding suffixes equal it), and if k = 2, they do not rhyme (ommit ≠ ermit).Today on a literature lesson Vera learned that quatrains can contain four different schemes of rhymes, namely the following ones (the same letters stand for rhyming lines):   Clerihew (aabb);  Alternating (abab);  Enclosed (abba). If all lines of a quatrain pairwise rhyme, then the quatrain can belong to any rhyme scheme (this situation is represented by aaaa).If all quatrains of a poem belong to the same rhyme scheme, then we can assume that the whole poem belongs to this rhyme scheme. If in each quatrain all lines pairwise rhyme, then the rhyme scheme of the poem is aaaa. Let us note that it doesn't matter whether lines from different quatrains rhyme with each other or not. In other words, it is possible that different quatrains aren't connected by a rhyme.Vera got a long poem as a home task. The girl has to analyse it and find the poem rhyme scheme. Help Vera cope with the task.

The first line contains two integers n and k (1 ≤ n ≤ 2500, 1 ≤ k ≤ 5) — the number of quatrains in the poem and the vowel's number, correspondingly. Next 4n lines contain the poem. Each line is not empty and only consists of small Latin letters. The total length of the lines does not exceed 104. If we assume that the lines are numbered starting from 1, then the first quatrain contains lines number 1, 2, 3, 4; the second one contains lines number 5, 6, 7, 8; and so on.

Print the rhyme scheme of the poem as "aabb", "abab", "abba", "aaaa"; or "NO" if the poem does not belong to any of the above mentioned schemes.

NoteIn the last sample both quatrains have rhymes but finding the common scheme is impossible, so the answer is "NO".

2 1
day
may
sun
fun
test
hill
fest
thrill

//In The Name Of God ( Of programming )

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll Maxn = 1e5 + 7;
const ll Max = 1e3 + 7;
const ll Mod = 1e9 + 7;
const ll Inf = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define P_ll pair<ll, ll>
#define P_cl pair<char, ll>
#define P_lc pair<ll, char>
#define Sort( a ) sort ( a.begin(), a.end() )
#define help_me_God ios_base::sync_with_stdio ( false )

string s[Maxn], V[Maxn];
ll ans[5];

ll check ( char t )
{
    if ( t == 'u' || t == 'o' || t == 'a' || t == 'i' || t == 'e' )
        return true;
    return false;
}

void f ( ll a, ll b, ll c, ll d )
{
    if ( V[a] == V[b] && V[c] == V[d] );
    else    ans[1] = 0;
    if ( V[a] == V[c] && V[b] == V[d] );
    else    ans[2] = 0;
    if ( V[a] == V[d] && V[c] == V[b] );
    else    ans[3] = 0;
    if ( V[a] == V[b] && V[c] == V[d] && V[c] == V[b] );
    else    ans[4] = 0;
}

void print ( ll i )
{
    if ( i == 1 )
        cout << "aabb" << endl;
    if ( i == 2 )
        cout << "abab" << endl;
    if ( i == 3 )
        cout << "abba" << endl;
    if ( i == 4 )
        cout << "aaaa" << endl;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    for ( ll i = 1; i <= 4 * n; i++ )
    {
        cin >> s[i];
        ll K = k;
        for ( ll j = s[i].size() - 1; K && j >= 0; j-- )
        {
            V[i] += s[i][j];
            if ( check ( s[i][j] ) )
                 K--;
        }
        if ( K )
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    ans[1] = ans[2] = ans[3] = ans[4] = 1;
    for ( ll i = 1; i <= n; i++ )
    {
        ll st = ( i - 1 ) * 4;
        f ( st + 1, st + 2, st + 3, st + 4 );
    }
    for ( ll i = 4; i >= 1; i-- )
    {
        if ( ans[i] )
        {
            print ( i );
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

[{'input': '1 1\r\nday\r\nmay\r\nsun\r\nfun\r\n', 'output': ['aabb\r\n']}, {'input': '1 1\r\nday\r\nmay\r\ngray\r\nway\r\n', 'output': ['aaaa\r\n']}, {'input': '2 1\r\na\r\na\r\na\r\na\r\na\r\na\r\ne\r\ne\r\n', 'output': ['aabb\r\n']}, {'input': '2 1\r\nday\r\nmay\r\nsun\r\nfun\r\ntest\r\nhill\r\nfest\r\nthrill\r\n', 'output': ['NO\r\n']}, {'input': '2 5\r\na\r\na\r\na\r\na\r\na\r\na\r\ne\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nrezwbgy\r\nxakgmv\r\njogezwbgy\r\napezwbgy\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\nnuqfxwrb\r\napqfkw\r\nuqfxwrb\r\nnhcuqfxwrb\r\nogkznwncmt\r\nevf\r\nogkznwncmt\r\nogkznwncmt\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\naawjvkxx\r\nawjvkxx\r\nxawjvkxx\r\nawjvkxx\r\n', 'output': ['aaaa\r\n']}, {'input': '2 2\r\nrhcujgxabk\r\nnjgdqpurul\r\nueoedt\r\ncpcfhbyvo\r\nzmfwnieog\r\npkpylassbf\r\nhrfeod\r\ncdwuil\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\nol\r\nol\r\nol\r\nzol\r\nek\r\nek\r\nek\r\nqek\r\n', 'output': ['aaaa\r\n']}, {'input': '3 2\r\nexdaoao\r\nrdwunurp\r\ndunurp\r\ntyqzuxao\r\ndupocgsps\r\nzsiravcm\r\nnqiravcm\r\nlnupocgsps\r\niwashk\r\neepkqcykbv\r\nyviwashk\r\neepkqcykbv\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\ndaihacbnhgfts\r\nsqihpntjvczkw\r\nmihpntjvczkw\r\nvyacbnhgfts\r\ntsvovdpqajmgvcj\r\ncexqkwrvctomb\r\njxbomb\r\ngnpajmgvcj\r\n', 'output': ['abba\r\n']}, {'input': '3 2\r\netba\r\ntfecetba\r\nzkitbgcuuy\r\nuuy\r\nbuxeoi\r\nmekxoi\r\nblviwoehy\r\niwoehy\r\njyfpaqntiz\r\nqvaqntiz\r\nhciak\r\niak\r\n', 'output': ['aabb\r\n']}, {'input': '4 3\r\niixxiojrrdytjcbkvymw\r\nbjqixxiojrrdytjcbkvymw\r\nogjixxiojrrdytjcbkvymw\r\nevixxpfxpgicpg\r\njkotitixiughfhphliuurx\r\ngyubkqtonejprfjzvqxbdpn\r\ndpudxfoqnhekjytbwiuurx\r\noubkqtonejprfjzvqxbdpn\r\npgzaendrxjhsfzjmijv\r\npomuaendrxjhsfzjmijv\r\nafyuyxueaendrxjhsfzjmijv\r\naendrxjhsfzjmijv\r\nyubweicj\r\ntbnsuxqigmxdfnmbipubweicj\r\nfuftydlmoo\r\nmdkuftydlmoo\r\n', 'output': ['NO\r\n']}, {'input': '5 2\r\nqurcmcbxyoddgyyccsmb\r\nlsdzsqoa\r\neurcmcbxyoddgyyccsmb\r\noa\r\nutyxmdhcvaclynmstwsx\r\nmkyycelbmkmdrilmbvr\r\nutyxmdhcvaclynmstwsx\r\nrduyelbmkmdrilmbvr\r\nhmguhvqswwciowwgu\r\nnoe\r\nzmyncuwrowwgu\r\nqrhymghavvbmigzsjoe\r\nbvofhknbzusykztlxwms\r\nbpbfmvjaimkdeddy\r\neofhknbzusykztlxwms\r\nmhivpkxkpazimkdeddy\r\negvywnhmfngllaknmn\r\nmblkvhenlggoftwjgk\r\nzegvywnhmfngllaknmn\r\ngrdenlggoftwjgk\r\n', 'output': ['abab\r\n']}, {'input': '7 3\r\nferwljzwakxedlgwl\r\noerwljzwakxedlgwl\r\nhyqombizhuhxedprb\r\netptjrizhuhxedprb\r\nurtuckar\r\ndkartmwramklcmi\r\nrurtuckar\r\nnurartmwramklcmi\r\niraziomsv\r\nsaziomsv\r\nbprapiqpayzurgij\r\nusyemayzurgij\r\nztstmeecvmkvuu\r\nquexlecvmkvuu\r\nrlhwecvmkvuu\r\nzecvmkvuu\r\niikymgbncljtub\r\nqiikymgbncljtub\r\nbcavhexqamyszgfya\r\nojexqamyszgfya\r\nieyxqinjinjv\r\nxtiudieyxqinjinjv\r\nthtceyxqinjinjv\r\nmuneyxqinjinjv\r\nwreae\r\nqylcjhjzfhteae\r\nozcjthgyuchqo\r\nfcjozcjthgyuchqo\r\n', 'output': ['NO\r\n']}, {'input': '16 1\r\ni\r\ni\r\ni\r\ni\r\ni\r\nu\r\ni\r\ni\r\no\r\na\r\na\r\no\r\na\r\ni\r\na\r\na\r\ni\r\ni\r\no\r\no\r\ni\r\ni\r\ni\r\ni\r\nu\r\nu\r\nu\r\nu\r\no\r\ne\r\ne\r\ne\r\no\r\ni\r\no\r\ni\r\na\r\na\r\na\r\na\r\nu\r\no\r\no\r\nu\r\ni\r\no\r\no\r\ni\r\na\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\na\r\no\r\na\r\na\r\nu\r\na\r\nu\r\nu\r\n', 'output': ['NO\r\n']}, {'input': '16 1\r\neb\r\neb\r\nfe\r\nce\r\ner\r\ner\r\new\r\new\r\nu\r\ncu\r\nu\r\nu\r\nud\r\nik\r\nud\r\nik\r\nve\r\niw\r\niw\r\nne\r\nel\r\nob\r\nel\r\nob\r\no\r\neo\r\no\r\nyo\r\nav\r\nav\r\nei\r\nmi\r\nu\r\noh\r\noh\r\nzu\r\niw\r\niw\r\na\r\nma\r\ni\r\nu\r\nku\r\ngi\r\nac\r\no\r\no\r\nac\r\ni\r\ner\r\nai\r\ner\r\nyu\r\nuf\r\nuf\r\nhu\r\nef\r\nef\r\nef\r\nef\r\nmu\r\nu\r\nqe\r\nie\r\n', 'output': ['NO\r\n']}, {'input': '25 1\r\nw\r\ni\r\nv\r\nx\r\nh\r\ns\r\nz\r\ny\r\no\r\nn\r\nh\r\ni\r\nf\r\nf\r\ny\r\nr\r\nb\r\nu\r\no\r\np\r\nz\r\nh\r\nt\r\no\r\nw\r\nx\r\nh\r\no\r\nj\r\ny\r\nw\r\nj\r\ny\r\nh\r\nh\r\nr\r\ns\r\nb\r\ny\r\nr\r\nw\r\no\r\nl\r\nl\r\nh\r\nh\r\nw\r\nu\r\na\r\nv\r\no\r\nx\r\nd\r\nw\r\nc\r\nf\r\ni\r\ne\r\nj\r\nq\r\nk\r\na\r\ne\r\nl\r\nw\r\nm\r\nf\r\na\r\nc\r\na\r\nb\r\nf\r\nj\r\nb\r\nx\r\ni\r\nx\r\ne\r\nu\r\nh\r\nm\r\no\r\ni\r\nq\r\nm\r\nk\r\nn\r\nd\r\nl\r\np\r\nc\r\nw\r\nu\r\nz\r\nc\r\nk\r\ng\r\ny\r\nj\r\ny\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\ne\r\ne\r\ne\r\n', 'output': ['aaaa\r\n']}, {'input': '1 1\r\na\r\ne\r\ne\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\na\r\ne\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\na\r\ne\r\ne\r\n', 'output': ['aabb\r\n']}, {'input': '1 1\r\ne\r\ne\r\na\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\ne\r\na\r\ne\r\n', 'output': ['abab\r\n']}, {'input': '1 1\r\ne\r\na\r\na\r\ne\r\n', 'output': ['abba\r\n']}, {'input': '1 1\r\na\r\na\r\na\r\ne\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\ne\r\ne\r\na\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\ne\r\ne\r\na\r\n', 'output': ['abba\r\n']}, {'input': '1 1\r\ne\r\na\r\ne\r\na\r\n', 'output': ['abab\r\n']}, {'input': '1 1\r\na\r\na\r\ne\r\na\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\ne\r\na\r\na\r\n', 'output': ['aabb\r\n']}, {'input': '1 1\r\na\r\ne\r\na\r\na\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\ne\r\na\r\na\r\na\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\na\r\na\r\na\r\n', 'output': ['aaaa\r\n']}, {'input': '1 2\r\neraub\r\nbee\r\naab\r\nttbee\r\n', 'output': ['NO\r\n']}, {'input': '10 1\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\na\r\ny\r\n', 'output': ['NO\r\n']}, {'input': '1 2\r\neeereaatktb\r\nbee\r\niaattb\r\nottbee\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nab\r\nac\r\nad\r\naf\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nar\r\nat\r\nay\r\naw\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\na\r\ne\r\na\r\ne\r\na\r\na\r\na\r\na\r\n', 'output': ['abab\r\n']}, {'input': '1 1\r\na\r\ne\r\na\r\ni\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\na\r\ne\r\na\r\ne\r\n', 'output': ['abab\r\n']}, {'input': '1 1\r\nabbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbfbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbxbbbbbbbbbbbbbbbb\r\nabbbbbbbbbbbbbbbbdbbbbbbbbbbbbbbbb\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\na\r\n', 'output': ['abba\r\n']}, {'input': '1 1\r\nbug\r\nsuy\r\nluh\r\ngut\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nam\r\nat\r\nan\r\nag\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\na\r\na\r\ne\r\ne\r\na\r\na\r\na\r\na\r\n', 'output': ['aabb\r\n']}, {'input': '1 4\r\naieoabcd\r\naeioabcd\r\naoeiabcd\r\naoieabcd\r\n', 'output': ['NO\r\n']}, {'input': '1 2\r\naec\r\naed\r\naek\r\naem\r\n', 'output': ['NO\r\n']}, {'input': '1 1\r\nar\r\nab\r\nak\r\naz\r\n', 'output': ['NO\r\n']}, {'input': '2 1\r\na\r\na\r\na\r\na\r\na\r\nb\r\nb\r\nb\r\n', 'output': ['NO\r\n']}]


The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they should just go to bed early. They are desperate to come to an amicable agreement, so they decide to leave this up to chance.They take turns drawing a mouse from a bag which initially contains w white and b black mice. The person who is the first to draw a white mouse wins. After each mouse drawn by the dragon the rest of mice in the bag panic, and one of them jumps out of the bag itself (the princess draws her mice carefully and doesn't scare other mice). Princess draws first. What is the probability of the princess winning?If there are no more mice in the bag and nobody has drawn a white mouse, the dragon wins. Mice which jump out of the bag themselves are not considered to be drawn (do not define the winner). Once a mouse has left the bag, it never returns to it. Every mouse is drawn from the bag with the same probability as every other one, and every mouse jumps out of the bag with the same probability as every other one.

The only line of input data contains two integers w and b (0 ≤ w, b ≤ 1000).

Output the probability of the princess winning. The answer is considered to be correct if its absolute or relative error does not exceed 10 - 9.

NoteLet's go through the first sample. The probability of the princess drawing a white mouse on her first turn and winning right away is 1/4. The probability of the dragon drawing a black mouse and not winning on his first turn is 3/4 * 2/3 = 1/2. After this there are two mice left in the bag — one black and one white; one of them jumps out, and the other is drawn by the princess on her second turn. If the princess' mouse is white, she wins (probability is 1/2 * 1/2 = 1/4), otherwise nobody gets the white mouse, so according to the rule the dragon wins.

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1010;
double dp[MAXN][MAXN];
int b,w;
int main()
{
	scanf("%d%d",&w,&b);
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=w;i++)
	{
		dp[i][0]=1;
	}
	for(int i=1;i<=w;i++)
	{
		for(int j=1;j<=b;j++)
		{
			dp[i][j]+=(double)i/(i+j);
			if(j>=3)
			{
				dp[i][j]+=dp[i][j-3]*(double)j/(i+j)*((double)(j-1)/(i+j-1))*((double)(j-2)/(i+j-2));
			}
			if(j>=2)
			{
				dp[i][j]+=dp[i-1][j-2]*(double)j/(i+j)*((double)(j-1)/(i+j-1))*((double)i/(i+j-2));
			}
		}
	}
	printf("%.9f\n",dp[w][b]);
}


As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked each one: "Which one committed the crime?". Suspect number i answered either "The crime was committed by suspect number ai", or "Suspect number ai didn't commit the crime". Also, the suspect could say so about himself (ai = i).Sherlock Holmes understood for sure that exactly m answers were the truth and all other answers were a lie. Now help him understand this: which suspect lied and which one told the truth?

The first line contains two integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ n) — the total number of suspects and the number of suspects who told the truth. Next n lines contain the suspects' answers. The i-th line contains either "+ai" (without the quotes), if the suspect number i says that the crime was committed by suspect number ai, or "-ai" (without the quotes), if the suspect number i says that the suspect number ai didn't commit the crime (ai is an integer, 1 ≤ ai ≤ n). It is guaranteed that at least one suspect exists, such that if he committed the crime, then exactly m people told the truth.

Print n lines. Line number i should contain "Truth" if suspect number i has told the truth for sure. Print "Lie" if the suspect number i lied for sure and print "Not defined" if he could lie and could tell the truth, too, depending on who committed the crime.

NoteThe first sample has the single person and he confesses to the crime, and Sherlock Holmes knows that one person is telling the truth. That means that this person is telling the truth.In the second sample there are three suspects and each one denies his guilt. Sherlock Holmes knows that only two of them are telling the truth. Any one of them can be the criminal, so we don't know for any of them, whether this person is telling the truth or not.In the third sample the second and the fourth suspect defend the first and the third one. But only one is telling the truth, thus, the first or the third one is the criminal. Both of them can be criminals, so the second and the fourth one can either be lying or telling the truth. The first and the third one are lying for sure as they are blaming the second and the fourth one.

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cctype>
#include <bitset>
#include <sstream>
#include <set>
#include <map>

using namespace std;
template <class T> T sqr(T a) { return a * a; }

int a[101000];
int murs[101000];
int b[101000][2];

int n, m;

int main()
{
#ifdef IMPETUS
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] > 0)
            b[a[i] - 1][0]++;
        else
            b[-a[i] - 1][1]++;
    }
    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += b[i][1];
    int sols = 0;
    for (int i = 0; i < n; i++)
        if (sum - b[i][1] + b[i][0] == m)
        {
            sols++;
            murs[i] = 1;
        }
    string y = sols > 1 || sum == m ? "Not defined" : "Truth";
    string z = sols > 1 || sum == m ? "Not defined" : "Lie";
    for (int i = 0; i < n; i++)
        if (a[i] > 0)
        {
            if (murs[a[i] - 1])
                cout << y << endl;
            else
                cout << "Lie" << endl;
        }
        else
        {
            if (murs[-a[i] - 1])
                cout << z << endl;
            else
                cout << "Truth" << endl;
        }
    return 0;
}

[{'input': '1 1\r\n+1\r\n', 'output': ['Truth\r\n']}, {'input': '3 2\r\n-1\r\n-2\r\n-3\r\n', 'output': ['Not defined\r\nNot defined\r\nNot defined\r\n']}, {'input': '4 1\r\n+2\r\n-3\r\n+4\r\n-1\r\n', 'output': ['Lie\r\nNot defined\r\nLie\r\nNot defined\r\n']}, {'input': '1 0\r\n-1\r\n', 'output': ['Lie\r\n']}, {'input': '2 2\r\n+1\r\n+1\r\n', 'output': ['Truth\r\nTruth\r\n']}, {'input': '2 1\r\n+2\r\n+1\r\n', 'output': ['Not defined\r\nNot defined\r\n']}, {'input': '2 0\r\n-2\r\n-2\r\n', 'output': ['Lie\r\nLie\r\n']}, {'input': '3 1\r\n+2\r\n+3\r\n+3\r\n', 'output': ['Truth\r\nLie\r\nLie\r\n']}, {'input': '6 3\r\n+5\r\n+5\r\n+5\r\n+1\r\n+1\r\n+1\r\n', 'output': ['Not defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\n']}, {'input': '4 3\r\n-4\r\n-3\r\n-1\r\n-3\r\n', 'output': ['Not defined\r\nTruth\r\nNot defined\r\nTruth\r\n']}, {'input': '10 4\r\n-8\r\n+1\r\n-6\r\n-10\r\n+5\r\n-6\r\n-8\r\n-8\r\n-4\r\n-8\r\n', 'output': ['Lie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': '10 5\r\n-4\r\n+4\r\n+4\r\n-9\r\n-9\r\n-4\r\n-4\r\n+2\r\n-9\r\n-4\r\n', 'output': ['Lie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': '7 2\r\n+5\r\n+5\r\n+5\r\n-2\r\n+1\r\n-5\r\n-6\r\n', 'output': ['Lie\r\nLie\r\nLie\r\nNot defined\r\nLie\r\nTruth\r\nNot defined\r\n']}, {'input': '7 4\r\n+7\r\n-3\r\n-3\r\n-4\r\n+3\r\n+3\r\n+3\r\n', 'output': ['Not defined\r\nNot defined\r\nNot defined\r\nTruth\r\nNot defined\r\nNot defined\r\nNot defined\r\n']}, {'input': '6 3\r\n-6\r\n-1\r\n+5\r\n+1\r\n+6\r\n+1\r\n', 'output': ['Truth\r\nNot defined\r\nNot defined\r\nNot defined\r\nLie\r\nNot defined\r\n']}, {'input': '5 3\r\n-2\r\n+2\r\n+2\r\n-3\r\n+5\r\n', 'output': ['Not defined\r\nNot defined\r\nNot defined\r\nTruth\r\nNot defined\r\n']}, {'input': '3 0\r\n-2\r\n-2\r\n-2\r\n', 'output': ['Lie\r\nLie\r\nLie\r\n']}, {'input': '5 3\r\n-1\r\n-1\r\n-4\r\n+1\r\n-4\r\n', 'output': ['Lie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\n']}, {'input': '9 6\r\n+2\r\n+7\r\n+7\r\n-1\r\n-4\r\n+7\r\n-7\r\n+7\r\n+5\r\n', 'output': ['Lie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': '43 18\r\n-14\r\n-28\r\n+16\r\n+10\r\n+25\r\n-30\r\n+25\r\n+30\r\n+25\r\n+25\r\n+25\r\n+25\r\n-25\r\n+22\r\n+3\r\n-17\r\n+16\r\n-25\r\n+10\r\n+14\r\n+41\r\n+25\r\n-25\r\n+33\r\n+24\r\n-23\r\n-25\r\n+25\r\n-22\r\n+29\r\n+28\r\n-25\r\n-25\r\n-29\r\n+11\r\n+26\r\n-25\r\n+25\r\n+10\r\n+1\r\n-20\r\n-17\r\n+23\r\n', 'output': ['Truth\r\nTruth\r\nNot defined\r\nLie\r\nNot defined\r\nTruth\r\nNot defined\r\nLie\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nLie\r\nLie\r\nTruth\r\nNot defined\r\nNot defined\r\nLie\r\nLie\r\nLie\r\nNot defined\r\nNot defined\r\nLie\r\nLie\r\nTruth\r\nNot defined\r\nNot defined\r\nTruth\r\nLie\r\nLie\r\nNot defined\r\nNot defined\r\nTruth\r\nLie\r\nLie\r\nNot defined\r\nNot defined\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\n']}, {'input': '28 12\r\n+10\r\n-7\r\n+17\r\n-20\r\n+7\r\n-7\r\n+13\r\n-21\r\n-7\r\n-7\r\n-18\r\n+7\r\n+7\r\n+3\r\n+6\r\n+14\r\n+7\r\n-24\r\n-21\r\n-7\r\n-7\r\n+4\r\n+7\r\n-7\r\n+21\r\n-7\r\n-26\r\n+7\r\n', 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\n']}, {'input': '17 9\r\n-6\r\n+16\r\n+5\r\n+16\r\n-17\r\n+17\r\n-11\r\n+5\r\n+14\r\n+5\r\n-8\r\n-5\r\n+6\r\n-2\r\n-11\r\n+4\r\n+17\r\n', 'output': ['Truth\r\nNot defined\r\nNot defined\r\nNot defined\r\nTruth\r\nLie\r\nTruth\r\nNot defined\r\nLie\r\nNot defined\r\nTruth\r\nNot defined\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nLie\r\n']}, {'input': '14 3\r\n+14\r\n+12\r\n-9\r\n+9\r\n-9\r\n-9\r\n+8\r\n+9\r\n+2\r\n+1\r\n-13\r\n-9\r\n+13\r\n+3\r\n', 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\n']}, {'input': '10 4\r\n-9\r\n-8\r\n-5\r\n-9\r\n-7\r\n-9\r\n-9\r\n-9\r\n-4\r\n-9\r\n', 'output': ['Lie\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': '10 5\r\n-10\r\n-10\r\n-10\r\n-5\r\n-1\r\n+10\r\n-3\r\n-10\r\n-9\r\n-10\r\n', 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': '10 4\r\n-3\r\n-3\r\n-3\r\n-3\r\n-3\r\n-2\r\n-2\r\n-6\r\n-7\r\n-3\r\n', 'output': ['Lie\r\nLie\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\n']}, {'input': '10 6\r\n-9\r\n-7\r\n-5\r\n-5\r\n-4\r\n-2\r\n-8\r\n-5\r\n-5\r\n-9\r\n', 'output': ['Truth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': '10 4\r\n-8\r\n-2\r\n-8\r\n+1\r\n-4\r\n-8\r\n-2\r\n-8\r\n-8\r\n-1\r\n', 'output': ['Lie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': '10 2\r\n-8\r\n+10\r\n+1\r\n+8\r\n+4\r\n+8\r\n+6\r\n-8\r\n+10\r\n+1\r\n', 'output': ['Not defined\r\nLie\r\nLie\r\nNot defined\r\nLie\r\nNot defined\r\nLie\r\nNot defined\r\nLie\r\nLie\r\n']}, {'input': '10 3\r\n+9\r\n+3\r\n+8\r\n+3\r\n+6\r\n-3\r\n+6\r\n+8\r\n+3\r\n+7\r\n', 'output': ['Lie\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nNot defined\r\nLie\r\n']}, {'input': '10 8\r\n-2\r\n+9\r\n+9\r\n-4\r\n+9\r\n+9\r\n+4\r\n-9\r\n-3\r\n+9\r\n', 'output': ['Truth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\n']}, {'input': '10 7\r\n-4\r\n+6\r\n+4\r\n+9\r\n+6\r\n+6\r\n+6\r\n+6\r\n+6\r\n+2\r\n', 'output': ['Truth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\n']}, {'input': '10 4\r\n+3\r\n+5\r\n+6\r\n+10\r\n+5\r\n+5\r\n+6\r\n+8\r\n+5\r\n+6\r\n', 'output': ['Lie\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': '10 7\r\n-6\r\n-10\r\n-3\r\n-1\r\n-3\r\n-7\r\n-2\r\n-7\r\n-7\r\n-3\r\n', 'output': ['Truth\r\nTruth\r\nNot defined\r\nTruth\r\nNot defined\r\nNot defined\r\nTruth\r\nNot defined\r\nNot defined\r\nNot defined\r\n']}, {'input': '10 5\r\n-4\r\n-4\r\n-1\r\n-5\r\n-7\r\n-4\r\n-4\r\n-4\r\n-1\r\n-7\r\n', 'output': ['Lie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\n']}, {'input': '10 5\r\n-9\r\n-7\r\n-6\r\n-3\r\n-10\r\n-10\r\n-10\r\n-10\r\n-10\r\n-2\r\n', 'output': ['Truth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': '10 3\r\n-10\r\n-10\r\n-10\r\n-3\r\n-10\r\n-10\r\n-10\r\n-8\r\n-4\r\n-10\r\n', 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nLie\r\n']}, {'input': '10 5\r\n-8\r\n-8\r\n-4\r\n-9\r\n-10\r\n-2\r\n-9\r\n-8\r\n-8\r\n-8\r\n', 'output': ['Lie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\n']}, {'input': '10 5\r\n+7\r\n+8\r\n+9\r\n+1\r\n+7\r\n+7\r\n+7\r\n+6\r\n+6\r\n+7\r\n', 'output': ['Truth\r\nLie\r\nLie\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': '10 5\r\n+2\r\n+2\r\n+2\r\n+2\r\n+9\r\n+10\r\n+8\r\n+7\r\n+4\r\n+2\r\n', 'output': ['Truth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nLie\r\nLie\r\nLie\r\nTruth\r\n']}, {'input': '10 9\r\n+7\r\n+7\r\n+7\r\n+7\r\n+7\r\n+7\r\n+5\r\n+7\r\n+7\r\n+7\r\n', 'output': ['Truth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nTruth\r\nTruth\r\n']}, {'input': '10 3\r\n+10\r\n+2\r\n+10\r\n+9\r\n+1\r\n+9\r\n+4\r\n+9\r\n+3\r\n+2\r\n', 'output': ['Lie\r\nLie\r\nLie\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nTruth\r\nLie\r\nLie\r\n']}, {'input': '10 6\r\n+10\r\n+10\r\n+10\r\n+3\r\n+10\r\n+10\r\n+6\r\n+6\r\n+10\r\n+8\r\n', 'output': ['Truth\r\nTruth\r\nTruth\r\nLie\r\nTruth\r\nTruth\r\nLie\r\nLie\r\nTruth\r\nLie\r\n']}, {'input': '3 2\r\n-1\r\n+2\r\n+3\r\n', 'output': ['Truth\r\nNot defined\r\nNot defined\r\n']}]


After the Search Ultimate program that searched for strings in a text failed, Igor K. got to think: "Why on Earth does my program work so slowly?" As he double-checked his code, he said: "My code contains no errors, yet I know how we will improve Search Ultimate!" and took a large book from the shelves. The book read "Azembler. Principally New Approach".Having carefully thumbed through the book, Igor K. realised that, as it turns out, you can multiply the numbers dozens of times faster. "Search Ultimate will be faster than it has ever been!" — the fellow shouted happily and set to work.Let us now clarify what Igor's idea was. The thing is that the code that was generated by a compiler was far from perfect. Standard multiplying does work slower than with the trick the book mentioned.The Azembler language operates with 26 registers (eax, ebx, ..., ezx) and two commands:   [x] — returns the value located in the address x. For example, [eax] returns the value that was located in the address, equal to the value in the register eax.  lea x, y — assigns to the register x, indicated as the first operand, the second operand's address. Thus, for example, the "lea ebx, [eax]" command will write in the ebx register the content of the eax register: first the [eax] operation will be fulfilled, the result of it will be some value that lies in the address written in eax. But we do not need the value — the next operation will be lea, that will take the [eax] address, i.e., the value in the eax register, and will write it in ebx. On the first thought the second operation seems meaningless, but as it turns out, it is acceptable to write the operation as lea ecx, [eax + ebx],lea ecx, [k*eax]or evenlea ecx, [ebx + k*eax],where k = 1, 2, 4 or 8.As a result, the register ecx will be equal to the numbers eax + ebx, k*eax and ebx + k*eax correspondingly. However, such operation is fulfilled many times, dozens of times faster that the usual multiplying of numbers. And using several such operations, one can very quickly multiply some number by some other one. Of course, instead of eax, ebx and ecx you are allowed to use any registers.For example, let the eax register contain some number that we should multiply by 41. It takes us 2 lines:lea ebx, [eax + 4*eax] // now ebx = 5*eaxlea eax, [eax + 8*ebx] // now eax = eax + 8*ebx = 41*eaxIgor K. got interested in the following question: what is the minimum number of lea operations needed to multiply by the given number n and how to do it? Your task is to help him.Consider that at the initial moment of time eax contains a number that Igor K. was about to multiply by n, and the registers from ebx to ezx contain number 0. At the final moment of time the result can be located in any register.

The input data contain the only integer n (1 ≤ n ≤ 255), which Igor K. is about to multiply.

On the first line print number p, which represents the minimum number of lea operations, needed to do that. Then print the program consisting of p commands, performing the operations. It is guaranteed that such program exists for any n from 1 to 255. Use precisely the following format of commands (here k is equal to 1, 2, 4 or 8, and x, y and z are any, even coinciding registers): lea x, [y] lea x, [y + z] lea x, [k*y] lea x, [y + k*z] Please note that extra spaces at the end of a command are unacceptable.

2
lea ebx, [eax + 4*eax]
lea ecx, [eax + 8*ebx]

#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cfloat>

using namespace std;

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define FORD(i,a,b) for (int i = int(b)-1; i >= (a); i--)
#define FORIT(i,c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)

int memo[12];
int len[12];
int op[12][3];
int best, n;
int bop[12][3];
void rek(int dep){
	if(dep>=best)return;
	int le = dep+1;
	int maxi = memo[dep];
	if(maxi>n)return;
	if(maxi==n){
		best = dep;
		FOR(i,0,dep)FOR(j,0,3)bop[i][j]=op[i][j];
		return;
	}
	FORD(p1,0,le)FORD(p,0,le)FORD(i,0,4){
		int res = (1<<i)*memo[p]+memo[p1];
		if(res<=maxi)continue;
		op[dep][0]=p1;
		op[dep][1]=1<<i;
		op[dep][2]=p;
		memo[le]=res;
		rek(le);
	}
	FORD(p,0,le)FORD(i,1,4){
		int res = (1<<i)*memo[p];
		if(res<=maxi)continue;
		op[dep][0]=-1;
		op[dep][1]=1<<i;
		op[dep][2]=p;
		memo[le]=res;
		rek(le);
	}
}
int calc(int num){
	best = 6;
	memo[0]=1;
	n = num;
	rek(0);
	return best;
}
int main(){
	int N;
	cin >> N;
	calc(N);
	cout << best << endl;
	FOR(i,0,best){
		cout << "lea e" << (char)('b'+i) <<"x, [";
		if(bop[i][0]!=-1)cout << "e" <<(char)('a'+bop[i][0]) << "x + ";
		if(bop[i][1]!=1)cout << bop[i][1] << "*";
		cout <<"e"<< (char)('a'+bop[i][2])<< "x]\n";
	}
	return 0;
}

[{'input': '41\r\n', 'output': ['2\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 8*ebx]\r\n']}, {'input': '2\r\n', 'output': ['1\r\nlea ebx, [eax + eax]\r\n']}, {'input': '4\r\n', 'output': ['1\r\nlea ebx, [4*eax]\r\n']}, {'input': '6\r\n', 'output': ['2\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + eax]\r\n']}, {'input': '5\r\n', 'output': ['1\r\nlea ebx, [eax + 4*eax]\r\n']}, {'input': '14\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ecx + eax]\r\n']}, {'input': '15\r\n', 'output': ['2\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 2*ebx]\r\n']}, {'input': '17\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\n']}, {'input': '7\r\n', 'output': ['2\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 2*eax]\r\n']}, {'input': '3\r\n', 'output': ['1\r\nlea ebx, [eax + 2*eax]\r\n']}, {'input': '16\r\n', 'output': ['2\r\nlea ebx, [eax + eax]\r\nlea ecx, [8*ebx]\r\n']}, {'input': '58\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + ebx]\r\nlea eex, [edx + 4*eax]\r\n']}, {'input': '1\r\n', 'output': ['0\r\n']}, {'input': '8\r\n', 'output': ['1\r\nlea ebx, [8*eax]\r\n']}, {'input': '9\r\n', 'output': ['1\r\nlea ebx, [eax + 8*eax]\r\n']}, {'input': '10\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\n']}, {'input': '11\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*eax]\r\n']}, {'input': '12\r\n', 'output': ['2\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [4*ebx]\r\n']}, {'input': '13\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\n']}, {'input': '254\r\n', 'output': ['5\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + ebx]\r\nlea efx, [eex + 2*eax]\r\n']}, {'input': '197\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [eax + 4*edx]\r\n']}, {'input': '210\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [eax + 8*ecx]\r\nlea eex, [edx + edx]\r\n']}, {'input': '109\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [eax + 4*ecx]\r\n']}, {'input': '233\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*ecx]\r\nlea eex, [edx + 8*eax]\r\n']}, {'input': '220\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [eax + 2*ecx]\r\nlea eex, [4*edx]\r\n']}, {'input': '167\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*eax]\r\nlea eex, [eax + 2*edx]\r\n']}, {'input': '63\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*ebx]\r\n']}, {'input': '171\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ebx + 2*ecx]\r\n']}, {'input': '126\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 4*ebx]\r\nlea eex, [edx + ebx]\r\n']}, {'input': '223\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [eax + 8*ecx]\r\nlea eex, [ecx + 2*edx]\r\n']}, {'input': '46\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + eax]\r\n']}, {'input': '207\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ebx]\r\nlea eex, [ebx + 2*edx]\r\n']}, {'input': '202\r\n', 'output': ['4\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [eax + 8*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '216\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [8*ecx]\r\n']}, {'input': '138\r\n', 'output': ['3\r\nlea ebx, [eax + eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '106\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [edx + edx]\r\n']}, {'input': '74\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + eax]\r\n']}, {'input': '129\r\n', 'output': ['3\r\nlea ebx, [eax + eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [eax + 8*ecx]\r\n']}, {'input': '191\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ebx + 4*ecx]\r\nlea eex, [edx + 2*eax]\r\n']}, {'input': '67\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [8*eax]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '42\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + eax]\r\n']}, {'input': '104\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [8*ecx]\r\n']}, {'input': '235\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 4*ebx]\r\nlea eex, [eax + 2*edx]\r\n']}, {'input': '240\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [8*edx]\r\n']}, {'input': '116\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + 2*eax]\r\nlea eex, [4*edx]\r\n']}, {'input': '57\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 2*ebx]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '200\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [8*ecx]\r\n']}, {'input': '28\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + eax]\r\n']}, {'input': '54\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + ebx]\r\n']}, {'input': '51\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '44\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*eax]\r\nlea edx, [4*ecx]\r\n']}, {'input': '147\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [eax + 2*ecx]\r\n']}, {'input': '82\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + eax]\r\n']}, {'input': '113\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '176\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [8*edx]\r\n']}, {'input': '66\r\n', 'output': ['3\r\nlea ebx, [eax + eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '118\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 4*ebx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '158\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [eax + 4*ebx]\r\nlea eex, [ecx + 4*edx]\r\n']}, {'input': '184\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + eax]\r\nlea eex, [4*edx]\r\n']}, {'input': '172\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ebx + 2*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '94\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ebx]\r\nlea eex, [edx + 4*eax]\r\n']}, {'input': '221\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [ebx + 4*edx]\r\n']}, {'input': '100\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '139\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + 4*eax]\r\n']}, {'input': '187\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [ebx + 2*edx]\r\n']}, {'input': '192\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [8*ecx]\r\n']}, {'input': '130\r\n', 'output': ['3\r\nlea ebx, [eax + eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '244\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '115\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [ebx + 2*edx]\r\n']}, {'input': '59\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '183\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [eax + 4*ecx]\r\nlea eex, [edx + 2*eax]\r\n']}, {'input': '120\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [8*ecx]\r\n']}, {'input': '251\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + 8*eax]\r\n']}, {'input': '189\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '47\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*eax]\r\n']}, {'input': '204\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [4*edx]\r\n']}, {'input': '194\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [ecx + 8*edx]\r\n']}, {'input': '135\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '70\r\n', 'output': ['3\r\nlea ebx, [eax + eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '69\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [eax + 4*ecx]\r\n']}, {'input': '144\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [8*ecx]\r\n']}, {'input': '141\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*eax]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '159\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '149\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [eax + 4*ecx]\r\n']}, {'input': '173\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '90\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ebx]\r\n']}, {'input': '253\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*ebx]\r\nlea eex, [eax + 4*edx]\r\n']}, {'input': '125\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*ecx]\r\n']}, {'input': '174\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ecx + 8*ebx]\r\nlea eex, [ecx + 2*edx]\r\n']}, {'input': '26\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 8*eax]\r\n']}, {'input': '157\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '179\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [eax + 2*edx]\r\n']}, {'input': '84\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '188\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*eax]\r\nlea eex, [4*edx]\r\n']}, {'input': '24\r\n', 'output': ['2\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [8*ebx]\r\n']}, {'input': '205\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '49\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*eax]\r\n']}, {'input': '136\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [8*ecx]\r\n']}, {'input': '225\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*ecx]\r\n']}, {'input': '215\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [ebx + 2*ecx]\r\nlea eex, [edx + 4*edx]\r\n']}, {'input': '153\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 8*ebx]\r\n']}, {'input': '143\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + 8*eax]\r\n']}, {'input': '248\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [8*edx]\r\n']}, {'input': '219\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '226\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '80\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [8*ecx]\r\n']}, {'input': '255\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '25\r\n', 'output': ['2\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 4*ebx]\r\n']}, {'input': '228\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + ebx]\r\n']}, {'input': '148\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '134\r\n', 'output': ['4\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ecx + 2*ebx]\r\nlea eex, [ecx + 8*edx]\r\n']}, {'input': '98\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ebx]\r\nlea eex, [edx + 8*eax]\r\n']}, {'input': '114\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ebx + 8*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '91\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [eax + 2*ecx]\r\n']}, {'input': '218\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [eax + 8*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '55\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [eax + 2*ecx]\r\n']}, {'input': '214\r\n', 'output': ['4\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ecx + 4*ebx]\r\nlea eex, [ecx + 8*edx]\r\n']}, {'input': '237\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + 2*ebx]\r\n']}, {'input': '152\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 2*ebx]\r\nlea edx, [8*ecx]\r\n']}, {'input': '155\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ebx + 2*ecx]\r\n']}, {'input': '166\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ecx]\r\nlea eex, [edx + 4*eax]\r\n']}, {'input': '201\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [eax + 8*ecx]\r\n']}, {'input': '193\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [eax + 8*ecx]\r\n']}, {'input': '36\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [4*ebx]\r\n']}, {'input': '185\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [ecx + 4*ecx]\r\n']}, {'input': '86\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [edx + eax]\r\n']}, {'input': '230\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + eax]\r\nlea eex, [edx + 4*edx]\r\n']}, {'input': '208\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [8*edx]\r\n']}, {'input': '145\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [eax + 8*ecx]\r\n']}, {'input': '209\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [eax + 8*edx]\r\n']}, {'input': '83\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*eax]\r\n']}, {'input': '40\r\n', 'output': ['2\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [8*ebx]\r\n']}, {'input': '76\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 2*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '31\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + 4*eax]\r\n']}, {'input': '87\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ebx + 2*ecx]\r\n']}, {'input': '50\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ecx + 4*ecx]\r\n']}, {'input': '79\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [ebx + 2*edx]\r\n']}, {'input': '92\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ebx]\r\nlea eex, [edx + 2*eax]\r\n']}, {'input': '236\r\n', 'output': ['4\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ebx + 8*ecx]\r\nlea eex, [4*edx]\r\n']}, {'input': '30\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '96\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '56\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 2*eax]\r\nlea edx, [8*ecx]\r\n']}, {'input': '45\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\n']}, {'input': '60\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '127\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*ebx]\r\nlea eex, [eax + 2*edx]\r\n']}, {'input': '48\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [8*ecx]\r\n']}, {'input': '65\r\n', 'output': ['2\r\nlea ebx, [8*eax]\r\nlea ecx, [eax + 8*ebx]\r\n']}, {'input': '112\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + eax]\r\nlea eex, [4*edx]\r\n']}, {'input': '61\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '75\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + 2*eax]\r\n']}, {'input': '101\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [eax + 4*ecx]\r\n']}, {'input': '232\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + 2*eax]\r\nlea eex, [8*edx]\r\n']}, {'input': '224\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + eax]\r\nlea eex, [8*edx]\r\n']}, {'input': '213\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [eax + 4*edx]\r\n']}, {'input': '131\r\n', 'output': ['3\r\nlea ebx, [8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [eax + 2*ecx]\r\n']}, {'input': '119\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 4*ebx]\r\nlea eex, [edx + 2*eax]\r\n']}, {'input': '107\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '62\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + ebx]\r\nlea eex, [edx + 8*eax]\r\n']}, {'input': '128\r\n', 'output': ['3\r\nlea ebx, [eax + eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [8*ecx]\r\n']}, {'input': '196\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [4*edx]\r\n']}, {'input': '234\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ecx]\r\nlea eex, [edx + 8*ebx]\r\n']}, {'input': '18\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\n']}, {'input': '217\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [eax + 8*ecx]\r\n']}, {'input': '32\r\n', 'output': ['2\r\nlea ebx, [8*eax]\r\nlea ecx, [4*ebx]\r\n']}, {'input': '175\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*eax]\r\nlea eex, [ebx + 2*edx]\r\n']}, {'input': '198\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ecx]\r\nlea eex, [edx + 4*ebx]\r\n']}, {'input': '77\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '35\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + 8*eax]\r\n']}, {'input': '29\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + 2*eax]\r\n']}, {'input': '19\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 2*ebx]\r\n']}, {'input': '39\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '85\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 4*eax]\r\n']}, {'input': '111\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '247\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + 4*eax]\r\n']}, {'input': '161\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 2*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '68\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [4*ecx]\r\n']}, {'input': '117\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 4*ebx]\r\n']}, {'input': '239\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ebx + 8*ecx]\r\nlea eex, [ecx + 2*edx]\r\n']}, {'input': '156\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [4*edx]\r\n']}, {'input': '199\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ebx]\r\nlea eex, [eax + 2*edx]\r\n']}, {'input': '78\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '227\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*ecx]\r\nlea eex, [edx + 2*eax]\r\n']}, {'input': '160\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '180\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '142\r\n', 'output': ['4\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ebx + 2*ecx]\r\nlea eex, [ecx + 8*edx]\r\n']}, {'input': '181\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [eax + 4*ecx]\r\n']}, {'input': '103\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '95\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 2*ebx]\r\nlea edx, [ecx + 4*ecx]\r\n']}, {'input': '99\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ebx]\r\n']}, {'input': '34\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [ecx + ecx]\r\n']}, {'input': '250\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ecx + 4*ecx]\r\nlea eex, [edx + 4*edx]\r\n']}, {'input': '89\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 8*eax]\r\n']}, {'input': '137\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [eax + 8*ecx]\r\n']}, {'input': '252\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + ebx]\r\n']}, {'input': '168\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [8*ecx]\r\n']}, {'input': '110\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [eax + 4*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '52\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [4*ecx]\r\n']}, {'input': '246\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + eax]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '178\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [edx + edx]\r\n']}, {'input': '211\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [eax + 8*ecx]\r\nlea eex, [eax + 2*edx]\r\n']}, {'input': '27\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\n']}, {'input': '105\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*eax]\r\nlea edx, [eax + 8*ecx]\r\n']}, {'input': '43\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [ebx + 2*ecx]\r\n']}, {'input': '73\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\n']}, {'input': '124\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [4*edx]\r\n']}, {'input': '121\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [eax + 8*ecx]\r\n']}, {'input': '133\r\n', 'output': ['3\r\nlea ebx, [8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [eax + 4*ecx]\r\n']}, {'input': '162\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ecx]\r\n']}, {'input': '20\r\n', 'output': ['2\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [4*ebx]\r\n']}, {'input': '102\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [ecx + 4*ecx]\r\nlea eex, [edx + ecx]\r\n']}, {'input': '154\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 8*ebx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '165\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [eax + 4*ecx]\r\n']}, {'input': '72\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [8*ebx]\r\n']}, {'input': '33\r\n', 'output': ['2\r\nlea ebx, [8*eax]\r\nlea ecx, [eax + 4*ebx]\r\n']}, {'input': '238\r\n', 'output': ['4\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ebx + 4*ecx]\r\nlea eex, [ecx + 8*edx]\r\n']}, {'input': '182\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [eax + 4*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '140\r\n', 'output': ['3\r\nlea ebx, [8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '242\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ebx + 2*ecx]\r\nlea eex, [ecx + 8*edx]\r\n']}, {'input': '212\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [4*edx]\r\n']}, {'input': '245\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\nlea eex, [edx + 2*eax]\r\n']}, {'input': '164\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '195\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [8*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '241\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [ecx + 4*edx]\r\n']}, {'input': '108\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*ebx]\r\nlea edx, [4*ecx]\r\n']}, {'input': '81\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\n']}, {'input': '21\r\n', 'output': ['2\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 4*ebx]\r\n']}, {'input': '186\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [ecx + 4*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '243\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '22\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 4*eax]\r\n']}, {'input': '53\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 8*eax]\r\n']}, {'input': '151\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [ecx + 2*edx]\r\n']}, {'input': '122\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 8*eax]\r\nlea eex, [ecx + 4*edx]\r\n']}, {'input': '71\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 2*ebx]\r\nlea eex, [edx + 8*eax]\r\n']}, {'input': '222\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + eax]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '231\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*eax]\r\nlea edx, [ebx + 4*ecx]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '23\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*eax]\r\nlea edx, [eax + 2*ecx]\r\n']}, {'input': '37\r\n', 'output': ['2\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 4*ebx]\r\n']}, {'input': '206\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ebx + 4*ecx]\r\nlea eex, [ecx + 4*edx]\r\n']}, {'input': '163\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [eax + 2*ecx]\r\n']}, {'input': '229\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ecx + 4*ecx]\r\nlea eex, [edx + 4*eax]\r\n']}, {'input': '203\r\n', 'output': ['3\r\nlea ebx, [eax + 2*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '150\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + eax]\r\nlea edx, [ecx + 4*ecx]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '190\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 4*ebx]\r\nlea edx, [ebx + 4*ecx]\r\nlea eex, [edx + eax]\r\n']}, {'input': '64\r\n', 'output': ['2\r\nlea ebx, [8*eax]\r\nlea ecx, [8*ebx]\r\n']}, {'input': '93\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 2*ebx]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '123\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + 2*ecx]\r\n']}, {'input': '97\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*eax]\r\nlea edx, [ebx + 8*ecx]\r\n']}, {'input': '169\r\n', 'output': ['3\r\nlea ebx, [eax + 4*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ebx + 4*ecx]\r\n']}, {'input': '249\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + 2*eax]\r\nlea eex, [edx + 2*edx]\r\n']}, {'input': '38\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [ecx + eax]\r\n']}, {'input': '88\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 2*eax]\r\nlea edx, [8*ecx]\r\n']}, {'input': '146\r\n', 'output': ['3\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [eax + 8*ebx]\r\nlea edx, [ecx + ecx]\r\n']}, {'input': '170\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + 8*ebx]\r\nlea edx, [ecx + ecx]\r\nlea eex, [edx + 8*eax]\r\n']}, {'input': '177\r\n', 'output': ['4\r\nlea ebx, [eax + 8*eax]\r\nlea ecx, [ebx + ebx]\r\nlea edx, [ecx + 4*eax]\r\nlea eex, [eax + 8*edx]\r\n']}, {'input': '132\r\n', 'output': ['3\r\nlea ebx, [8*eax]\r\nlea ecx, [eax + 4*ebx]\r\nlea edx, [4*ecx]\r\n']}]


Igor K. very much likes a multiplayer role playing game WineAge II. Who knows, perhaps, that might be the reason for his poor performance at the university. As any person who plays the game, he is interested in equipping his hero with as good weapon and outfit as possible. One day, as he was reading the game's forum yet again, he discovered a very interesting fact. As it turns out, each weapon in the game is characterised with k different numbers: a1, ..., ak. They are called hit indicators and according to the game developers' plan they are pairwise coprime. The damage that is inflicted during a hit depends not only on the weapon's characteristics, but also on the hero's strength parameter. Thus, if the hero's strength equals n, than the inflicted damage will be calculated as the number of numbers on the segment , that aren't divisible by any hit indicator ai.Recently, having fulfilled another quest, Igor K. found a new Lostborn sword. He wants to know how much damage he will inflict upon his enemies if he uses it.

The first line contains two integers: n and k (1 ≤ n ≤ 1013, 1 ≤ k ≤ 100). They are the indicator of Igor K's hero's strength and the number of hit indicators. The next line contains space-separated k integers ai (1 ≤ ai ≤ 1000). They are Lostborn sword's hit indicators. The given k numbers are pairwise coprime.

Print the single number — the damage that will be inflicted by Igor K.'s hero when he uses his new weapon.  Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator.

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>

#define LL long long
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define size(S) S.size()
#define PII pair<int, int>
#define PID pair<int, double>

using namespace std;

const int MAX = 300000;
LL n, ans;
int k, a[110];
LL f[100][MAX];

LL dfs(int x, LL n){
	if (x == k) return n;
	if (n < MAX && f[x][n] >= 0) return f[x][n];
	LL ret = dfs(x + 1, n) - dfs(x + 1, n / a[x]);
	if (n < MAX) f[x][n] = ret;
	return ret;
}

int main(){
	cin >> n >> k;
	for (int i = 0; i < k; i++) cin >> a[i];
	memset(f, 255, sizeof(f));
	sort(a, a + k, greater<int>());
	ans = dfs(0, n);
	cout << ans << endl;
}


At a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform the following operations with vector А: Turn the vector by 90 degrees clockwise. Add to the vector a certain vector C.Operations could be performed in any order any number of times.Can Gerald cope with the task?

The first line contains integers x1 и y1 — the coordinates of the vector A ( - 108 ≤ x1, y1 ≤ 108). The second and the third line contain in the similar manner vectors B and C (their coordinates are integers; their absolute value does not exceed 108).

Print "YES" (without the quotes) if it is possible to get vector B using the given operations. Otherwise print "NO" (without the quotes).

#include <bits/stdc++.h>

using namespace std;

#define pb push_back

#define eb emplace_back

#define f first

#define s second

#define deb(a) cerr << #a << " = " << a << "\n";

#define all(x) (x).begin(), (x).end()

#define file() { ifstream cin("input.txt"); ofstream cout("output.txt"); }

#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))

#define y1 y1212312

#define int long long

typedef long long ll;

typedef long double ld;

typedef pair <int, int> pii;

const ll INF = 2e18;

const ll mod = 1e9 + 7;

const int inf = 1e9;

const ld EPS = 1e-12;

const ld Pi = acosl(-1);

const int P = 31;

const int dx[2] = {0, 1};

const int dy[2] = {1, 0};

int qqq = 1;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int x1, y1, x2, y2, x3, y3;

void solve() {

    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    int leng = x3 * x3 + y3 * y3;

    for (int i = 0; i < 4; i++) {

        int x = x2 - x1;

        int y = y2 - y1;

        int dp = x * x3 + y * y3;

        int cp = x * y3 - y * x3;

        if (x == 0 && y == 0) {

            cout << "YES\n";

            return;

        }

        if (leng && dp % leng == 0 && cp % leng == 0) {

            cout << "YES\n";

            return;

        }

        x1 = -x1;

        swap(x1, y1);

    }

    cout << "NO\n";

}

signed main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0); cout.tie(0);

    clock_t tStart = clock();

    //cin >> qqq;

    while (qqq--) {

        solve();

    }

    cerr << "Runtime is:" << (long double) (clock() - tStart) / CLOCKS_PER_SEC << '\n';

    return 0;

}


Gerald is positioned in an old castle which consists of n halls connected with n - 1 corridors. It is exactly one way to go from any hall to any other one. Thus, the graph is a tree. Initially, at the moment of time 0, Gerald is positioned in hall 1. Besides, some other hall of the castle contains the treasure Gerald is looking for. The treasure's position is not known; it can equiprobably be in any of other n - 1 halls. Gerald can only find out where the treasure is when he enters the hall with the treasure. That very moment Gerald sees the treasure and the moment is regarded is the moment of achieving his goal. The corridors have different lengths. At that, the corridors are considered long and the halls are considered small and well lit. Thus, it is possible not to take the time Gerald spends in the halls into consideration. The castle is very old, that's why a corridor collapses at the moment when somebody visits it two times, no matter in which direction. Gerald can move around the castle using the corridors; he will go until he finds the treasure. Naturally, Gerald wants to find it as quickly as possible. In other words, he wants to act in a manner that would make the average time of finding the treasure as small as possible. Each corridor can be used no more than two times. That's why Gerald chooses the strategy in such a way, so he can visit every hall for sure.More formally, if the treasure is located in the second hall, then Gerald will find it the moment he enters the second hall for the first time — let it be moment t2. If the treasure is in the third hall, then Gerald will find it the moment he enters the third hall for the first time. Let it be the moment of time t3. And so on. Thus, the average time of finding the treasure will be equal to .

The first line contains the only integer n (2 ≤ n ≤ 105) — the number of halls in the castle. Next n - 1 lines each contain three integers. The i-th line contains numbers ai, bi and ti (1 ≤ ai, bi ≤ n, ai ≠ bi, 1 ≤ ti ≤ 1000) — the numbers of halls connected with the i-th corridor and the time needed to go along the corridor. Initially Gerald is in the hall number 1. It is guaranteed that one can get from any hall to any other one using corridors.

Print the only real number: the sought expectation of time needed to find the treasure. The answer should differ from the right one in no less than 10 - 6.

NoteIn the first test the castle only has two halls which means that the treasure is located in the second hall. Gerald will only need one minute to go to the second hall from the first one.In the second test Gerald can only go from the first hall to the third one. He can get from the third room to the first one or to the second one, but he has already visited the first hall and can get nowhere from there. Thus, he needs to go to the second hall. He should go to hall 4 from there, because all other halls have already been visited. If the treasure is located in the third hall, Gerald will find it in a minute, if the treasure is located in the second hall, Gerald finds it in two minutes, if the treasure is in the fourth hall, Gerald will find it in three minutes. The average time makes 2 minutes.In the third test Gerald needs to visit 4 halls: the second, third, fourth and fifth ones. All of them are only reachable from the first hall. Thus, he needs to go to those 4 halls one by one and return. Gerald will enter the first of those halls in a minute, in the second one — in three minutes, in the third one - in 5 minutes, in the fourth one - in 7 minutes. The average time is 4 minutes.

#include<bits/stdc++.h>
#define F first
#define S second
#define pii pair<int , int>
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e5 + 10;
ll dp[N] , sz[N] , t[N];
vector<pii> a[N];

bool cmp(pair<pair<ll , ll> , int> x , pair<pair<ll , ll >  , int> y){
    ll p1 = x.F.F , p2 = y.F.F , s1 = x.F.S , s2 = y.F.S;
    return p1 * s2 < p2 * s1;
}

void dfs(int v,int p=-1){
    sz[v]++;
    vector<pair<pair<ll , ll >  , int> > childs;
    for(auto X:a[v]){
        int u = X.F , w = X.S;
        if(u == p)continue;
        dfs(u , v);
        sz[v]+=sz[u];
        t[v]+=t[u] + w;
        dp[v]+=w * sz[u] + dp[u];
        childs.pb({{t[u] + w , sz[u]} , u});
    }
    sort(childs.begin() , childs.end() ,cmp);
    ll tim = 0;
    for(auto X:childs){
        ll p = X.F.F , sz = X.F.S , ind = X.S;
        dp[v]+=(ll)2 * tim * sz;
        tim+=p;
    }
    return ;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v,w; cin>>u>>v>>w;
        a[u].pb({v , w});
        a[v].pb({u , w});
    }
    dfs(1);
    cout<<fixed<<setprecision(12)<<(ld)(dp[1])/(n-1)<<'\n';
}


You are given a straight half-line divided into segments of unit length, which we will call positions. The positions are numbered by positive integers that start with 1 from the end of half-line, i. e. 1, 2, 3 and so on. The distance between the positions is the absolute difference between the respective numbers. Laharl, Etna and Flonne occupy some positions on the half-line and they want to get to the position with the largest possible number. They are originally placed in different positions. Each of the characters can perform each of the following actions no more than once:   Move a certain distance.  Grab another character and lift him above the head.  Throw the lifted character a certain distance.  Each character has a movement range parameter. They can only move to free positions, assuming that distance between those positions doesn't exceed the movement range. One character can lift another character if the distance between the two characters equals 1, and no one already holds that another character. We can assume that the lifted character moves to the same position as the person who has lifted him, and the position in which he stood before becomes free. A lifted character cannot perform any actions and the character that holds him cannot walk. Also, each character has a throwing range parameter. It is the distance at which this character can throw the one lifted above his head. He can only throw a character to a free position, and only when there is a lifted character. We accept the situation when one person grabs another one who in his turn has the third character in his hands. This forms a "column" of three characters. For example, Laharl can hold Etna while Etna holds Flonne. In this case, Etna and the Flonne cannot perform any actions, and Laharl can only throw Etna (together with Flonne) at some distance. Laharl, Etna and Flonne perform actions in any order. They perform actions in turns, that is no two of them can do actions at the same time.Determine the maximum number of position at least one of the characters can reach. That is, such maximal number x so that one of the characters can reach position x.

The first line contains three integers: Laharl's position, his movement range and throwing range. The second and the third lines describe Etna's and Flonne's parameters correspondingly in the similar form. It is guaranteed that the three characters occupy distinct positions. All numbers in the input are between 1 and 10, inclusive.

Print a single number — the maximum ordinal number of position which either Laharl, Etna or Flonne can reach.

NoteLet us explain how to reach position 15 in the sample.Initially Laharl occupies position 9, Etna — position 4 and Flonne — position 2.First Laharl moves to position 6.Then Flonne moves to position 5 and grabs Etna.Laharl grabs Flonne and throws to position 9.Flonne throws Etna to position 12.Etna moves to position 15.

#include<cstdio>

#include<cstring>

#include<cmath>

#define check(i) i-p[0] && i-p[1] && i-p[2]

int p[3],m[3],t[3],ans,dep;

bool f[48][48][48][8][8];

void dfs(int *p,int x,int y)

{

	bool &res=f[p[0]][p[1]][p[2]][x][y]; if (res) return; res=1;

	int far=0,near=50;

	for (int i=0;i<3;i++){

		if (p[i]<45 && p[i]>far) far=p[i];

		if (p[i]<near) near=p[i];

		}

	if (far>ans) ans=far;

	for (int j=0;j<3;j++) {

		int q[3]={p[0],p[1],p[2]},z=1<<j;

		if (p[j]>=45){

			int T=p[j]-45;

			for (int i=p[T]+t[T];p[T]<45 && i>=p[T]-t[T] && i>near-2 && i;i--)

				if (check(i)) q[j]=i,dfs(q,x,y);

			}

		else if (check(j+45)){

			if (y&z) for (int i=0;i<3;i++) if (fabs(p[i]-p[j])==1)

				q[i]=45+j,dfs(q,x,y^z),q[i]=p[i];

			if (x&z) for (int i=p[j]+m[j];i>=p[j]-m[j] && i>near-2 && i;i--)

				if (check(i)) q[j]=i,dfs(q,x^z,y);

			}

		}

}

int main()

{

	for (int i=0;i<3;i++) scanf("%d%d%d",p+i,m+i,t+i);

	dfs(p,7,7); printf("%d\n",ans);	return 0;

}


Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the examiner will be...To prepare for the exam, one has to study proofs of n theorems. It is known that there will be k examination cards on the exam and each card contains  distinct theorems. Besides, no theorem is mentioned in more than one card (that is,  theorems won't be mentioned in any card). During the exam several students may get the same card.We do not know the exact way theorems are distributed by cards, however the students that took the exam before Vasya told him what theorems their cards contained. Vasya evaluates his level of proficiency in the i-th theorem by some number ai. The level of proficiency in some card is the average of the levels of proficiency in the theorems that are included in the card. Now Vasya wants to know the minimally and maximally possible levels of his proficiency in the card he gets on the exam. Vasya wants to determine it by the data he has collected from other students. Unfortunately, Vasya has no time left to do the math and he asked you to help him.

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 100) — the number of theorems and the number of cards correspondingly. The second line contains n integers ai (0 ≤ ai ≤ 100), the i-th number (1 ≤ i ≤ n) corresponds to Vasya's proficiency in the i-th theorem. The third line contains number q (0 ≤ q ≤ 100) — the number of people that have taken the exam before Vasya. Each of the following q lines contains the description of a student's card:  integers from 1 to n inclusive. They are the numbers of theorems included in the card in the order in which they are enumerated in the input data. The numbers are given in an arbitrary order. It is guaranteed that the given cards are valid (that is, that all theorems in one card are different and that different people get cards that either don't contain the same theorems or coincide up to the theorems' permutation).

Print two real numbers, representing Vasya's minimum and maximum proficiency in the card he will get on the exam. The absolute or relative error should not exceed 10 - 6.

NoteLet's analyze the first sample. Vasya's proficiency in the cards whose content he already knows equals 6 and 15.5 correspondingly. The three theorems that are left are only enough to make one exam card. If we consider all possible variants of theorems included in the card we can see that in the best case scenario Vasya gets the card that contains theorems 4 and 7 (his proficiency would equal 15.5) and in the worst case scenario he gets theorems 3 and 5 (his proficiency would equal 5).The ⌊ x⌋ operation denotes taking integer part of real number x (rounding down).

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int soCard = 0;
    int n, k, q;
    int a[101];
    bool fr[101];
    int soCauHoi;

    cin >> n >> k;

    soCauHoi = n / k;

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        fr[i] = true;
    }

    cin >> q;

    double max = -1;
    double min = 1000000;

    int tam;
    double tong;
    double trungbinh;
    bool kiemtra;

    for (int i = 0; i < q; i++)
    {
        tong = 0;
        kiemtra = false;
        for (int j = 0; j < soCauHoi; j++)
        {
            cin >> tam;
            tong += a[tam];
            if (fr[tam] == true)
            {
                kiemtra = true;
            }
            fr[tam] = false;
        }
        if (kiemtra == true)
        {
            soCard++;
        }

        trungbinh = tong / soCauHoi;
        if (trungbinh < min)
        {
            min = trungbinh;
        }

        if (trungbinh > max)
        {
            max = trungbinh;
        }

    }

    bool ftam;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            if (a[i] > a[j])
            {
                tam = a[j];
                a[j] = a[i];
                a[i] = tam;

                ftam = fr[j];
                fr[j] = fr[i];
                fr[i] = ftam;
            }
        }
    }
    if (soCard == k)
    {

        cout << fixed;
        cout << setprecision(10) << min << " " << setprecision(10) << max;

        return 0;
    }

    int demMin = 0;
    double sumMin = 0;
    double avgMin = 1000000;
    int dungMin = 0;
    // tim min;
    for (int i = 1; i <= n; i++)
    {
        if (fr[i] == true)
        {
            demMin++;
            sumMin += a[i];
            dungMin = i;
            if (demMin == soCauHoi)
            {
                break;
            }

        }
    }
    if (dungMin > 0)
        avgMin = sumMin / soCauHoi;

    int demMax = 0;
    double sumMax = 0;
    double avgMax = -1;
    int dungMax = n + 1;

    for (int i = n; i > 0; i--)
    {
        if (fr[i] == true)
        {
            demMax++;
            sumMax += a[i];
            dungMax = i;

            if (demMax == soCauHoi)
            {
                break;
            }
        }
    }

    if (dungMax < n + 1)
        avgMax = sumMax / soCauHoi;

        if (avgMin < min)
        {
            min = avgMin;
        }
        if (avgMax > max)
        {
            max = avgMax;
        }

    cout << fixed;
    cout << setprecision(10) << min << " " << setprecision(10) << max;

    return 0;

}


The Fat Rat and his friend Сerealguy have had a bet whether at least a few oats are going to descend to them by some clever construction. The figure below shows the clever construction.  A more formal description of the clever construction is as follows. The clever construction consists of n rows with scales. The first row has n scales, the second row has (n - 1) scales, the i-th row has (n - i + 1) scales, the last row has exactly one scale. Let's number the scales in each row from the left to the right, starting from 1. Then the value of wi, k in kilograms (1 ≤ i ≤ n; 1 ≤ k ≤ n - i + 1) is the weight capacity parameter of the k-th scale in the i-th row. If a body whose mass is not less than wi, k falls on the scale with weight capacity wi, k, then the scale breaks. At that anything that the scale has on it, either falls one level down to the left (if possible) or one level down to the right (if possible). In other words, if the scale wi, k (i < n) breaks, then there are at most two possible variants in which the contents of the scale's pan can fall out: all contents of scale wi, k falls either on scale wi + 1, k - 1 (if it exists), or on scale wi + 1, k (if it exists). If scale wn, 1 breaks, then all its contents falls right in the Fat Rat's claws. Please note that the scales that are the first and the last in a row, have only one variant of dropping the contents.Initially, oats are simultaneously put on all scales of the first level. The i-th scale has ai kilograms of oats put on it. After that the scales start breaking and the oats start falling down in some way. You can consider everything to happen instantly. That is, the scale breaks instantly and the oats also fall instantly.The Fat Rat is sure that whatever happens, he will not get the oats from the first level. Cerealguy is sure that there is such a scenario, when the rat gets at least some number of the oats. Help the Fat Rat and the Cerealguy. Determine, which one is right.

The first line contains a single integer n (1 ≤ n ≤ 50) — the number of rows with scales. The next line contains n space-separated integers ai (1 ≤ ai ≤ 106) — the masses of the oats in kilograms. The next n lines contain descriptions of the scales: the i-th line contains (n - i + 1) space-separated integers wi, k (1 ≤ wi, k ≤ 106) — the weight capacity parameters for the scales that stand on the i-th row, in kilograms.

Print "Fat Rat" if the Fat Rat is right, otherwise print "Cerealguy".

NoteNotes to the examples:   The first example: the scale with weight capacity 2 gets 1. That means that the lower scale don't break.  The second sample: all scales in the top row obviously break. Then the oats fall on the lower row. Their total mass is 4,and that's exactly the weight that the lower scale can "nearly endure". So, as 4  ≥  4, the scale breaks.