Source code
#include <iostream>
#include<vector>
#include<string>
#include<math.h>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include <fstream>
#include<iterator>
#include<algorithm>
#include <iomanip> // std::setprecision
/* ==================================================
| |
| Author: *** S. M. Sabiul Hajjaj Sabit *** |
| Last Edit: May,14,2019 |
================================================== */
///***global declaration***///
#define all(arr) arr.begin(),arr.end()
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define sz(x) x.size()
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define lli long long int
#define prnt(x) cout<<x<<endl
using namespace std;
int j,n,m,sum=0,ans=0;
template <typename T>long long int power(T a, T b)
{
long long int pow=1;
for(int i=0; i<b; i++)
pow *= a;
return pow;
}
/**** ascending sort vector of pair basis fd 2nd element******/
//sort(arr.begin(), arr.end(),sortbysec);
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
return (a.second < b.second);
}
/////*********Write Code From Here*********///
int main()
{
int l,r,a;
cin>>l>>r>>a;
if(l==r)
{
prnt(l+r+(a-a%2));
}
else if(l<r)
{
int t = r-l;
if(t<=a)
{
l+=t;
a-=t;
}
else
{
l+=a;
a=0;
}
prnt((min(l,r)*2)+(a-a%2));
}
else
{
int t = l-r;
if(t<=a)
{
r+=t;
a-=t;
}
else
{
r+=a;
a=0;
}
prnt((min(l,r)*2)+(a-a%2));
}
}
Add your comment