Problem:
Score : 100 points

Problem Statement

Takahashi is a user of a site that hosts programming contests.

When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:

Let the current rating of the user be a.

Suppose that the performance of the user in the contest is b.

Then, the new rating of the user will be the avarage of a and b.

For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.

Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.

Find the performance required to achieve it.

Constraints

0 \leq R, G \leq 4500

All input values are integers.

Input

Input is given from Standard Input in the following format:

R
G

Output

Print the performance required to achieve the objective.

Sample Input 1

2002
2017

Sample Output 1

2032

Takahashi's current rating is 2002.

If his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.

Sample Input 2

4500
0

Sample Output 2

-4500

Although the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>

using namespace std;

#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define LL                      long long
#define ULL                     unsigned long long
#define pb                      push_back
#define tcase                   cout<<"Case "<<C++<<": ";
#define all(a)                  a.begin(),a.end()
#define Unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end
#define ABS(x)                  ((x)<0?-(x):(x))
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define PI                      acos(-1.0)
#define ff                      first
#define ss                      second
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define FastRead                ios_base::sync_with_stdio(0);cin.tie(NULL);
#define FOR(x, l, r)            for (int x = l; x<=r; ++x)
#define REP(x,r)                for (int x = 0; x <r; ++x)
#define NN                      cout<<"\n";
#define NNN                     cout<<"\n------------------------------\n";
#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())
//***********************************************************************//
//                      SHAHED AHMED, CSE'15, IUT                        //
//***********************************************************************//


LL lim[200020];
LL fix[200020];
LL val[200020];


int main()
{
    LL n;

    cin>>n;

    vector<LL> t(n);
    vector<LL> v(n);

    for(LL i=0;i<n;i++) cin>>t[i];
    for(LL i=0;i<n;i++) cin>>v[i];


    LL pos = 0;

    for(LL i=0;i<t.size();i++)
    {
        lim[pos] = min(lim[pos],v[i]);
        while(t[i]--)
        {
            lim[++pos]= v[i];
        }

    }




    fix[0]=1;
    fix[pos]=1;



    LL increase = 111;

    while(increase--)
    {
        for(LL i=1;i<=pos;i++)
        {
            if(val[i]==lim[i]) fix[i]=1;
            if(val[i]==val[i-1]+1 && fix[i-1]==1) fix[i]=1;
        }

        for(LL i=pos;i>=1;i--)
        {
            if(val[i]==val[i+1]+1 && fix[i+1]==1) fix[i]=1;
        }

        for(LL i=1;i<=pos;i++)
        {
            if(fix[i]!=1)
            {
                val[i]++;
            }
        }
    }

    double tot=0;
    for(LL i=1;i<=pos;i++)
    {
        //cout<<val[i]<<" ";
        tot+=val[i];
    }

    for(LL i=1;i<=pos+1;i++)
    {
        if(val[i]==val[i-1] && (val[i]<max(lim[i],lim[i-1])))
        {
            tot+=0.25;
        }
    }
//
//    cout<<"\n";
//    for(LL i=1;i<=pos;i++)
//    {
//        cout<<val[i]<<" ";
//    }
//    cout<<"\n";

    cout<<SP(tot,10)<<"\n";


}