Pupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once.Tickets for group of x people are sold on the attraction, there should be at least one adult in each group (it is possible that the group consists of one adult). The ticket price for such group is c1 + c2·(x - 1)2 (in particular, if the group consists of one person, then the price is c1). All pupils who came to the park and their parents decided to split into groups in such a way that each visitor join exactly one group, and the total price of visiting the most extreme attraction is as low as possible. You are to determine this minimum possible total price. There should be at least one adult in each group.

The first line contains three integers n, c1 and c2 (1 ≤ n ≤ 200 000, 1 ≤ c1, c2 ≤ 107) — the number of visitors and parameters for determining the ticket prices for a group. The second line contains the string of length n, which consists of zeros and ones. If the i-th symbol of the string is zero, then the i-th visitor is a pupil, otherwise the i-th person is an adult. It is guaranteed that there is at least one adult. It is possible that there are no pupils.

Print the minimum price of visiting the most extreme attraction for all pupils and their parents. Each of them should roll on the attraction exactly once.

NoteIn the first test one group of three people should go to the attraction. Then they have to pay 4 + 1 * (3 - 1)2 = 8.In the second test it is better to go to the attraction in two groups. The first group should consist of two adults (for example, the first and the second person), the second should consist of one pupil and one adult (the third and the fourth person). Then each group will have a size of two and for each the price of ticket is 7 + 2 * (2 - 1)2 = 9. Thus, the total price for two groups is 18.

#include<stdio.h>
#define lli long long int

lli n,c1,c2,pr=0;

lli calc(lli gr)
{
    lli num=n/gr;
    lli r=n%gr;
    lli ret=gr*c1;
    ret+=r*(n/gr)*(n/gr)*c2;
    ret+=(gr-r)*(n/gr-1)*(n/gr-1)*c2;
    return ret;
}

int main() {
    scanf("%lld%",&n);
    scanf("%lld%",&c1);
    scanf("%lld%",&c2);
    char s[n+1];
    gets(s);
    int ch=0;
    int i;
    for(i=0;i<n;i++)
        if(s[i]=='1')
            pr++;
        else
            ch++;
    int l=1,h=pr;
    lli ans=calc(l);
    for(i=l+1;i<=h;i++)
    {
        lli cur=calc(i);
        if(cur<ans)
            ans=cur;
    }
    printf("%lld",ans);
    return 0;
}

#include<stdio.h>
#include<string.h>
char s[200005];
long long cnt,n,c1,c2,ans;
long long f(long long x) {
	return c2*x*x;
}
int main() {
	scanf("%lld%lld%lld",&n,&c1,&c2);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='1')
			cnt++;
//	printf("%lld\n",cnt);
	ans=1e18;
	for(long long i=1;i<=cnt;i++) {
		long long tmp=n%i,o=n/i,res=0;
//		printf("%lld %lld %lld\n",i,tmp,o);
		res=i*c1+tmp*f(o)+(i-tmp)*f(o-1);
		if(ans>res)
			ans=res;
	}
	printf("%lld\n",ans);
}

#include<stdio.h>
char s[200005];
long long X,XX;
long long cal(long long x,long long  all){
    long long t,tt;
    long long ANS;
    ANS=0;
    t=all/x;
    tt=all%x;
    ANS+=(x-tt)*(X+XX*(t-1)*(t-1));
    ANS+=tt*(X+XX*t*t);
    return ANS;
}
int main(void){
    long long i,j,n,m,P,A,L,R,M,MM;
    long long ANS,ANSS;
    scanf("%I64d %I64d %I64d",&n,&X,&XX);
    scanf("%s",s);
    P=A=0;
    for(i=0;i<n;i++){
        if(s[i]=='1') A++;
        else P++;
    }
    L=1;R=A;
    while(L<R){
        M=(L+R)/2;
        MM=(M+R)/2;
        if(MM==M) MM++;
        //cout<<M<<" "<<MM<<endl;
        ANS=cal(M,n);
        ANSS=cal(MM,n);
        //cout<<ANS<<" "<<ANSS<<endl;
        if(ANS<ANSS) R=MM-1;
        else L=M+1;
    }
    //cout<<L<<endl;
    ANS=cal(L,n);
    ANSS=cal(R,n);
    printf("%I64d\n",ANS<ANSS?ANS:ANSS);
}

#include <stdio.h>
typedef long long LL;
int n;
LL c1,c2,ans;
LL f(int x)
{
    int a=n%x,b=x-a;
    LL ans=c1*x;
    ans+=a*c2*(n/x)*(n/x);
    ans+=b*c2*(n/x-1)*(n/x-1);
    return ans;
}
LL min(LL a,LL b){return a<b?a:b;}
int main()
{
    scanf("%d%I64d%I64d ",&n,&c1,&c2);
    char c;
    ans=c1+c2*(n-1)*(n-1);
    int x=0,y=0,k,i;
    for(k=1;k<=n;++k)
    {
        c=getchar();
        if(c=='0')++x;
        else ++y;
    }
    for(i=1;i<=y;++i)
        ans=min(ans,f(i));
    printf("%I64d\n",ans);
    return 0;
}

#include <stdio.h>

char s[200100];
int main()
{
    int n;
    long long c1 , c2;
    scanf("%d%lld%lld" , &n , &c1 , &c2);
    scanf("%s" , s);
    long long sum1 = 0 , sum2  = 0;
    for(int i = 0 ; i<n ; i++)
    {
        sum1+= s[i]=='1';
        sum2+= s[i]=='0';
    }
    long long  x = sum1 , mini = 1e18;
    while(x>0)
    {
        long long z = sum2 / x;
        long long rem = sum2 % x;
        long long ans = rem * (c1 + (z+1)*(z+1)*c2) + (x-rem)*(c1 + (z)*(z)*c2);
        if(ans < mini) mini = ans;
        x--;
        sum2++;
    }
    printf("%lld\n" , mini);
    return 0;
}

#include <stdio.h>
#include <assert.h>

int N, C1, C2;
char seq[ ( int ) 2e5 ];
int adult, child;

long long sqr( int x ) {
  return 1LL * x * x;
}

long long calc( int g ) {
  int ln = N / g; // number of people in less group
  int lc = g - N % g; // number of groups of less people
  int gn = ln + 1;
  int gc = N % g;
  return ( sqr( ln - 1 ) * C2 + C1 ) * lc + ( sqr( gn - 1 ) * C2 + C1 ) * gc;
}

signed main() {
  scanf( "%d %d %d", &N, &C1, &C2 );
  scanf( "%s", seq );
  for( int i = 0; i < N; ++i ) {
    if( seq[ i ] == '1' ) {
      ++adult;
    } else {
      ++child;
    }
  }
  int lb = 1, ub = adult;
  while( ub - lb > 10 ) {
    int x = lb + ( ub - lb ) / 3;
    int y = lb + ( ub - lb ) * 2 / 3;
    long long a = calc( lb ), b = calc( x ), c = calc( y ), d = calc( ub );
    if( a <= b && b <= c && c <= d ) {
      ub = x;
    } else if( a >= b && b <= c && c <= d ) {
      ub = y;
    } else if( a >= b && b >= c && c <= d ) {
      lb = x;
    } else if( a >= b && b >= c && c >= d ) {
      lb = y;
    } else {
      assert( 0 );
    }
  }
  long long ans = 1LL << 60;
  for( int i = lb; i <= ub; ++i ) {
    long long t = calc( i );
    if( ans > t ) {
      ans = t;
    }
  }
  printf( "%lld\n", ans );
  return 0;
}

//created by missever

#include<stdio.h>
typedef long long LL;
char s[200005];

LL min(LL a,LL b)
{
    if(a > b) return b;
    else return a;
}

int main(){
    int n,c1,c2,i,b;
    LL ans;
    b = 0;
    scanf("%d%d%d",&n,&c1,&c2);
    scanf("%s",s);
    for(i = 0;i < n; i++)
    {
        if(s[i] == '1') b++;
    }
    ans = c1 + 1LL * c2 * (n - 1) * (n - 1);
    for(i = 2;i <= b; i++) ans = min(ans,(n % i) * (c1 + 1LL * c2 * (n / i) * (n / i)) +
                                    (i - n % i) * (c1 + 1LL * c2 * (n / i - 1) * (n / i - 1)));
    printf("%I64d\n",ans);
    return 0;
}

#include<stdio.h>

char s[200005];

int main() {
	long long n, c1, c2, i;
	scanf("%lld %lld %lld", &n, &c1, &c2);
	scanf("%s", s);

	int adult = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == '1') adult++;
	}

	long long res = 1e18;

	for (i = 1; i <= adult; i++) {
		long long g = (n - i) / i, rem = (n - i) % i;
		long long cur = i * c1;
		cur += rem * c2 * (g + 1) * (g + 1);
		cur += (i - rem) * c2 * g * g;
		if (res > cur) res = cur;
	}

	printf("%lld\n", res);

	return 0;
}

#include <stdio.h>
#include <string.h>
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%lld%lld%lld", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 1e18;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '1')
            s1++;
    }
    long long a, b;
    for(i = 1; i <= s1; i++) {
        long long tmp = i * c1;
        tmp += (n % i) * (n / i) * (n / i) * c2  + (i - n % i) * (n / i - 1) * (n / i - 1) * c2;
        if(sum > tmp)
            sum = tmp;
    }
    printf("%lld\n", sum);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
typedef long long LL;
int n, c1, c2;
char st[200010];
LL min(LL a, LL b){return a < b ? a : b;}

int main()
{
	int m, l, r, mid, i;
	LL ans, num, res;
	scanf("%d%d%d %s", &n, &c1, &c2, st);
	m = 0;
	for(i = 0; i < n; ++i)
		if(st[i] == '1')
			++m;
	ans = c1 + 1ll * c2 * (n - 1) * (n - 1);
	for(num = 2; num <= m; ++num) {
		res = num * c1;
		r = n  % num;
		l = n / num;
		res += 1ll * c2 * l * l * r + 1ll * c2 * (l - 1) * (l - 1) * (num - r);
		ans = min(ans, res);
	}
	printf("%I64d\n", ans);
	return 0;
}

#include <stdio.h>

char s[200005];

int main(){
    long long n, c1, c2;
    scanf("%I64d%I64d%I64d", &n, &c1, &c2);
    scanf("%s", s);
    long long adult=0;
    for(int i=0; s[i]; i++){
        if(s[i] == '1') adult++;
    }
    long long res = 1e18;
    for(int gr=1; gr<=adult; gr++){
        long long ppltoadd = n-gr;
        long long cur = 0;
        long long grsz = ppltoadd/gr;
        long long more = ppltoadd%gr;
        cur = ((grsz+1)*(grsz+1)*c2 + c1)*more;
        cur += (grsz*grsz*c2 + c1)*(gr-more);
        if(cur < res) res = cur;
    }
    printf("%I64d", res);
    return 0;
}

#include<stdio.h>
typedef long long ll;
char S[200010];
ll min(ll a,ll b){
        return a<b?a:b;
}
int main(){
	ll n,c1,c2,a=0,res=1e18;
	scanf("%lld%lld%lld",&n,&c1,&c2);
	scanf("%s",S);
	for(ll i=0;i<n;i++){
		if(S[i]=='1') a++;
	}
	for(ll i=1;i<=a;i++){
		res=min(res,  c1*i+c2*(  (n/i)*(n/i)*(n%i)  +  (n/i-1ll)*(n/i-1ll)*(i-n%i)  ) );
	}
	printf("%lld\n",res);
	return 0;
}

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

char st[(200000)+99];

int main()
{
	//freopen("a.in" , "r", stdin);
	//freopen("a.out", "w", stdout);
	long long n , c1 , c2 , mn = 1ll << 60 , cur;

	while(scanf("%I64d",&n) == 1)
    {
        mn = 1ll << 60;
        scanf("%I64d %I64d",&c1 , &c2);
        char ch;
        int big = 0;

        scanf("%s" ,st);
        for(int i = 0 ; i < n ; ++i){

            char ch = st[i];
            if(ch == '1') big++;
        }

        for(int i = 1 ; i <= big ; ++i){
            int sz1 = n;
            int rem = sz1 % i;
            int sz2 = sz1 / i;
            long long fn1 , fn2;
            fn1 = (i - rem) * (c1 + c2 * (sz2 - 1) * (sz2-1) );
            fn2 = rem * ( c1 + c2 * sz2 * sz2);

            if(mn > fn1 + fn2) mn = fn1 + fn2;

        }

        printf("%I64d\n",mn);

    }
	return 0;
}

#include<stdio.h>

#define ll long long

char s[200005];
ll n,c1,c2;
ll fr[2];

int main()
{
	int t,i,j,k;

	scanf("%I64d%I64d%I64d %s",&n,&c1,&c2,s);
	for(i=0;i<n;i++)
	{
		fr[ s[i]-'0' ]++;
	}

	ll rs=(1LL<<61);
	for(ll q=1;q<=fr[1];q++)
	{
		ll rem=fr[1]-q+fr[0];
		ll d=rem/q;
		ll rmx=rem%q;

		ll qx;

		qx=c1*q+c2*(d+1)*(d+1)*rmx+c2*d*d*(q-rmx);

		if(qx<rs)rs=qx;
	}
	printf("%I64d\n",rs);

	return 0;
}

#include <stdio.h>
#include <limits.h>

char S[500003];

int main() {
   long long int t,n;
   char str[101];
   long long int c1,c2;
   scanf("%lld%lld%lld",&n,&c1,&c2);
   scanf("%s",S);
   long long int i,a,b,c,d;
   a=b=0;
   for(i=0;i<n;i++){
    if(S[i]=='1') a++;
    else b++;
   }
   long long int z,ans = LLONG_MAX,orgA,orgB;
   orgA=a;
   orgB=b;
   for(i=1;i<=orgA;i++){
    a=i;
    b=orgB+(orgA-i);
    t=b/a;
    c=c1+c2*t*t;
    d=c1+c2*(t+1)*(t+1);
    z=d*(b%a)+c*(a-b%a);
    if(z<ans) ans=z;
   }
   printf("%lld\n",ans);
}

#include <limits.h>
#include <stdio.h>

long long solve(int n, int g, int c1, int c2) {
	long long a = n / g;
	long long r = n % g;
	long long p1 = r * (c1 + a * a * c2);
	long long p2 = (g - r) * (c1 + (a - 1) * (a - 1) * c2);

	return p1 + p2;
}

int main() {
	static char s[200001];
	long long min;
	int n, c1, c2, i, g;
	int k;

	scanf("%d%d%d", &n, &c1, &c2);
	scanf("%s", s);
	k = 0;
	for (i = 0; i < n; i++)
		if (s[i] == '1')
			k++;
	min = LLONG_MAX;
	for (g = 1; g <= k; g++) {
		long long cost = solve(n, g, c1, c2);

		if (min > cost)
			min = cost;
	}
	printf("%lld\n", min);
	return 0;
}

#include <stdio.h>
char s[200005];
int main() {
	int n, c1, c2;
	scanf("%d%d%d", &n, &c1, &c2);
	scanf("%s", s);
	int m = 0;
	for (int i = 0; i < n; ++ i) m += s[i] == '1';
	n -= m;
	long long ans = -1;
	for (int x = 1; x <= m; ++ x) {
		int r = n + m - x;
		long long cost = 1LL * c1 * x + 1LL * (r / x) * (r / x) * c2 * (x - r % x) + 1LL * (r / x + 1) * (r / x + 1) * c2 * (r % x);
		if (ans == -1 || cost < ans) ans = cost;
	}
	printf("%I64d\n", ans);
return 0;
}

#include "stdio.h"

const int N = 2e5 + 5;

int n;
long long a, b;
char s[200100];
int p, c, i, j;
long long ans, cur;

int main() {
  scanf("%d %I64d %I64d", &n, &a, &b);
  scanf("%s", s);
  p = c = 0;
  for (i = 0; i < n; i++) {
    p += s[i] == '1';
    c += s[i] == '0';
  }
  ans = -1;
  for (i = 1; i <= p; i++) {
    cur = a * i;
    long long x = (n-i)/i, z = (n-i) % i;
    cur += x * x * b * (i-z);
    x++;
    cur += x * x * b * z;
    if (ans == -1 || ans > cur)
      ans = cur;
  }
  printf("%I64d\n", ans);
  return 0;
}

#include<stdio.h>
#define lli long long int

lli n,c1,c2,pr=0;

lli calc(lli gr)
{
    if(gr==0 || gr>pr)
        return 1000000000000000;
    lli num=n/gr;
    lli r=n%gr;
    lli ret=gr*c1;
    ret+=r*(n/gr)*(n/gr)*c2;
    ret+=(gr-r)*(n/gr-1)*(n/gr-1)*c2;
    return ret;
}

int main() {
    scanf("%lld%",&n);
    scanf("%lld%",&c1);
    scanf("%lld%",&c2);
    char s[n+1];
    gets(s);
    int ch=0;
    int i;
    for(i=0;i<n;i++)
        if(s[i]=='1')
            pr++;
        else
            ch++;
    int l=1,h=pr;
    lli ans;
    while(l<=h)
    {
        int mid=(l+h)/2;
        lli n1=calc(mid-1);
        lli n2=calc(mid+1);
        lli nm=calc(mid);
        if(n1>nm && n2>nm)
            {ans=nm;
            break;}
        else if(n2<nm)
            l=mid+1;
        else
            h=mid-1;
    }
    printf("%lld",ans);
    return 0;
}

#include<stdio.h>
#define lli long long int

lli n,c1,c2,pr=0;

lli calc(lli gr)
{
    if(gr==0 || gr>pr)
        return 1000000000000000;
    lli num=n/gr;
    lli r=n%gr;
    lli ret=gr*c1;
    ret+=r*(n/gr)*(n/gr)*c2;
    ret+=(gr-r)*(n/gr-1)*(n/gr-1)*c2;
    return ret;
}

int main() {
    scanf("%lld%",&n);
    scanf("%lld%",&c1);
    scanf("%lld%",&c2);
    char s[n+1];
    gets(s);
    int ch=0;
    int i;
    for(i=0;i<n;i++)
        if(s[i]=='1')
            pr++;
        else
            ch++;
    int l=1,h=pr;
    lli ans;
    while(l<=h)
    {
        int mid=(l+h)/2;
        lli n1=calc(mid-1);
        lli n2=calc(mid+1);
        lli nm=calc(mid);
        if(n1>nm && n2>nm)
            {ans=nm;
            break;}
        else if(n1>nm)
            ans=nm,l=mid+1;
        else
            h=mid-1;
    }
    printf("%lld",ans);
    return 0;
}

#include <stdio.h>
typedef long long LL;
int n;
LL c1,c2,ans;
LL f(int x)
{
    int a=n%x,b=x-a;
    LL ans=c1*x;
    ans+=a*c2*(n/x)*(n/x);
    ans+=b*c2*(n/x-1)*(n/x-1);
    return ans;
}
LL min(int a,int b){return a<b?a:b;}
int main()
{
    scanf("%d%I64d%I64d ",&n,&c1,&c2);
    char c;
    ans=c1+c2*(n-1)*(n-1);
    int x=0,y=0,k,i;
    for(k=1;k<=n;++k)
    {
        c=getchar();
        if(c=='0')++x;
        else ++y;
    }
    for(i=1;i<=y;++i)
        ans=min(ans,f(i));
    printf("%I64d\n",ans);
    return 0;
}

#include<stdio.h>

char s[200005];

int main() {
    int n, c1, c2, i;
    scanf("%d %d %d", &n, &c1, &c2);
    scanf("%s", s);

    int adult = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == '1') adult++;
    }

    long long res = 1e18;
    for (i = 1; i <= adult; i++) {
        int extra = n - i;
        int x = 1 + extra / i;

        int a = extra % i;
        int b = i - a;

        long long cur = i * c1;

        if (a > 0) {
            cur += a *  1LL * c2 * x * x;
        }
        if (x > 0) {
            cur += b * 1LL * c2 * (x - 1) * (x - 1);
        }

        if (res > cur) res = cur;
    }

    printf("%lld\n", res);

    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 0x3f3f3f3f;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = 1; i <= s1; i++) {
        long long tmp = i * c1;
        tmp += (n % i) * ((n / i) * (n / i) * c2 ) + (i - n % i) * ( (n / i - 1) * (n / i - 1) * c2);
        sum = min(sum, tmp);
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 2147483647;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = s1; i >= 1; i--) {
        sum = min(sum, ((n % i) * (c1 + (n / i) * (n / i) * c2 )+ (i - n % i) *(c1 + (n / i - 1) * (n / i - 1) * c2)));
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 1000000000000000000;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = s1; i >= 1; i--) {
        sum = min(sum, ((n % i) * (c1 + (n / i) * (n / i) * c2 )+ (i - n % i) *(c1 + (n / i - 1) * (n / i - 1) * c2)));
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 0x3f3f3f3f;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = s1; i >= 1; i--) {
        sum = min(sum, ((n % i) * (c1 + (n / i) * (n / i) * c2 )+ (i - n % i) *(c1 + (n / i - 1) * (n / i - 1) * c2)));
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%lld%lld%lld", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 0x3f3f3f3f;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = s1; i >= 1; i--) {
        sum = min(sum, ((n % i) * (c1 + (n / i) * (n / i) * c2 )+ (i - n % i) *(c1 + (n / i - 1) * (n / i - 1) * c2)));
    }
    printf("%lld\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 200000010;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = s1; i >= 1; i--) {
        sum = min(sum, ((n % i) * (c1 + (n / i) * (n / i) * c2 )+ (i - n % i) *(c1 + (n / i - 1) * (n / i - 1) * c2)));
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 0x3f3f3f3f;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = 1; i <= s1; i++) {
        long long tmp = i * c1;
        tmp += (n % i) * ((n / i) * (n / i) * c2 ) + (i - n % i) * ( (n / i - 1) * (n / i - 1) * c2);
        if(sum > tmp)
            sum = tmp;
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 200010;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = s1; i >= 1; i--) {
        sum = min(sum, ((n % i) * (c1 + (n / i) * (n / i) * c2 )+ (i - n % i) *(c1 + (n / i - 1) * (n / i - 1) * c2)));
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 0xFFFFFFFF;
    long long s0 = 0;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    long long a, b;
    for(i = s1; i >= 1; i--) {
        sum = min(sum, ((n % i) * (c1 + (n / i) * (n / i) * c2 )+ (i - n % i) *(c1 + (n / i - 1) * (n / i - 1) * c2)));
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
int main() {
    long long n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    long long len = strlen(s);
    long long sum = 1e18;
    long long s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '1')
            s1++;
    }
    long long a, b;
    for(i = 1; i <= s1; i++) {
        long long tmp = i * c1;
        tmp += (n % i) * (n / i) * (n / i) * c2  + (i - n % i) * (n / i - 1) * (n / i - 1) * c2;
        if(sum > tmp)
            sum = tmp;
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main() {
    int n, c1, c2, i;
    char s[200010];
    scanf("%d%d%d", &n, &c1, &c2);
    scanf("%s", s);
    int len = strlen(s);
    int sum = 200010;
    int s0 = 0;
    int s1 = 0;
    for(i = 0; i < len; i++) {
        if(s[i] == '0')
            s0++;
        else
            s1++;
    }
    int a, b;
    for(i = s1; i >= 1; i--) {
        sum = min(sum, ((n % i) * (c1 + (n / i) * (n / i) * c2 )+ (i - n % i) *(c1 + (n / i - 1) * (n / i - 1) * c2)));
    }
    printf("%d\n", sum);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
typedef long long LL;
int n, c1, c2;
char st[200010];
LL solve(LL x)
{
	LL a = n / x, b = n % x;
	LL res = (c1 + 1ll * c2 * (a - 1) * (a - 1)) * (x - b);
	res += (c1 + 1ll * c2 * a * a) * b;
	return res;
}
LL min(LL a, LL b){return a < b ? a : b;}

int main()
{
	int m, l, r, mid, i;
	LL ans;
	scanf("%d%d%d %s", &n, &c1, &c2, st);
	m = 0;
	for(i = 0; i < n; ++i)
		if(st[i] == '1')
			++m;
	ans = 1ll * n * c1;
	l = 2, r = m, mid;
	while(l <= r) {
		mid = (l + r) >> 1;
		LL res1 = solve(mid);
		LL res2 = solve(mid - 1);
		if(res1 <= res2) {
			ans = min(ans, res1);
			r = mid - 1;
		}
		else {
			ans = min(ans, res2);
			l = mid + 1;
		}
	}
	printf("%I64d\n", ans);
	return 0;
}

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

char st[(200000)+99];

int main()
{
	//freopen("a.in" , "r", stdin);
	//freopen("a.out", "w", stdout);
	long long n , c1 , c2 , mn = 1ll << 60 , cur;

	while(scanf("%I64d",&n) == 1)
    {
        mn = 1ll << 60;
        scanf("%I64d %I64d",&c1 , &c2);
        char ch;
        int big = 0;

        scanf("%s" ,st);
        for(int i = 0 ; i < n ; ++i){

            char ch = st[i];
            if(ch == '1') big++;
        }

        for(int i = 1 ; i <= big ; ++i){

            int sz2 = n % i; // have size e i+1
            int sz1 = i - sz2; // have size e i

            int fn1 = n / i;
            int fn2 = fn1 + 1;

            cur = 0;
            if(sz1 > 0){
                long long t = (c1 + c2*(fn1 - 1)*(fn1 - 1 ));
                cur += t * sz1;
            }
            ;
            if(sz2 > 0){
                long long t = (c1 + c2*(fn2)*(fn2));
                cur += t * sz2;
            }

            if(mn > cur) mn = cur;

        }

        printf("%I64d\n",mn);

    }
	return 0;
}


You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand.The coach decided to form a team of even number of players, exactly half of the players should play with their right hand, and exactly half of the players should play with their left hand. One player should use only on of his hands.Ambidexters play as well with their right hand as with their left hand. In the team, an ambidexter can play with their left hand, or with their right hand.Please find the maximum possible size of the team, where equal number of players use their left and right hands, respectively.

The only line contains three integers l, r and a (0 ≤ l, r, a ≤ 100) — the number of left-handers, the number of right-handers and the number of ambidexters at the training.

Print a single even integer — the maximum number of players in the team. It is possible that the team can only have zero number of players.

NoteIn the first example you can form a team of 6 players. You should take the only left-hander and two ambidexters to play with left hand, and three right-handers to play with right hand. The only person left can't be taken into the team.In the second example you can form a team of 14 people. You have to take all five left-handers, all five right-handers, two ambidexters to play with left hand and two ambidexters to play with right hand.

#include <stdio.h>

int main() {
    int l, r, a;
    int ans;
    scanf ("%d %d %d", &l, &r, &a);
    if (l > r) {
        if (l - r >= a) {
            ans = (r + a) * 2;
        }
        else {
            ans = 2 * l + (a - (l - r)) / 2 * 2;
        }
    }
    else if (l == r) {
        ans = l + r + a / 2 * 2;
    }
    else {
        if (r - l >= a) {
            ans = (l + a) * 2;
        }
        else {
            ans = 2 * r + (a - (r - l)) / 2 * 2;
        }
    }

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

#include<stdio.h>
#include<stdlib.h>
int main ()
{
    int l,r,a,count;
    scanf("%d %d %d",&l,&r,&a);
    int difference= abs(l-r);

    if (l==r)
    {
        count=2*l+a;

        if (count &1!=0)
            --count;
    }
    else if ( l<r)
    {
            if (difference>=a)
                {
                    l=l+a;
                    count=l+l;
                }
            else
            {
                a=a-difference;
                if (a&1!=0)
                    --a;
                count =r+r+a;
            }

    }
        else if (r<l)
            {
                if (difference>=a)
                {
                    r=r+a;
                    count=r+r;
                }
            else
            {
            a=a-difference;
            if (a&1!=0)
                --a;

            count =l+l+a;
            }
            }

    printf("%d\n",count);
}

#include <stdio.h>

int main()
{
	int l, r, a, _max, _min;
	scanf("%d %d %d", &l, &r, &a);
	if (l > r)
	{
		_max = l;
		_min = r;
	} else if (l < r)
	{
		_min = l;
		_max = r;
	} else
	{
		printf("%d", l + r + (a % 2 > 0 ? a - 1 : a));
		return 0;
	}
	if (_min + a <= _max)
		printf("%d", (_min + a) << 1);
	else
	{
		int b = _min + a - _max;
		printf("%d", (_max << 1) + (b % 2 > 0 ? b - 1 : b));
	}
	return 0;
}

#include<stdio.h>
int main(){
	int l,r,am;
	int min=0,max=0;
	scanf("%d %d %d",&l,&r,&am);

	min=(l>r)?r:l;
	max=(r>l)?r:l;
	if((min+am)<=max)
        printf("%d\n",2*(min+am));
	else
	    printf("%d\n",2*(max+(am-max+min)/2));

	return 0;
}

#include<stdio.h>
int main()
{
    int l,r,a,count=0,flag;
    scanf("%d %d %d",&l,&r,&a);
    if(l<=r)
        {
            count=l*2;
            r=r-l;
            flag=0;
        }
    else
        {
            count=r*2;
            l=l-r;
            flag=1;
        }
    if(flag==0)
    {
        if(a<=r)
            count=count+(a*2);
        else
        {
            count=count+(r*2);
            a=a-r;
            if(a%2==0)
                count=count+a;
            else
                count=count+a-1;
        }
    }
    if(flag==1)
    {
        if(a<=l)
            count=count+(a*2);
        else
        {
            count=count+(l*2);
            a=a-l;
            if(a%2==0)
                count=count+a;
            else
                count=count+a-1;
        }
    }
    printf("%d",count);
    return 0;
}

#include<stdio.h>
//#include<conio.h>
//#include<string.h>
//#include<math.h>
//#include<stdlib.h>

int main()
{
    int l,r,a,i,j,k,s=0;
    scanf("%d%d%d",&l,&r,&a);
    if(l==0 && a==0) printf("0");
    else if(r==0 && a==0) printf("0");
    else if(l>r) {s+=r;l=l-r;
    if(l<=a) a=a+l;
    else a=a*2;
    k=a/2;
    s+=k;
    printf("%d",s*2);
    }
    else if(l==r) {s+=r;l=l-r;
    if(l<=a) a=a+l;
    else a=a*2;
    k=a/2;
    s+=k;
    printf("%d",s*2);
    }
    else {s+=l;r=r-l;
    if(r<=a) a=a+r;
    else a=a*2;
    k=a/2;
    s+=k;
    printf("%d",s*2);
    }

        return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main(){
		int i,j,r,l,a,cnt;
		while(scanf("%d %d %d ",&l,&r,&a)!=EOF){
				cnt=0;
				if(l>r){
						while(r!=0){
								r--;
								l--;
								cnt++;
						}
						while(l!=0){
								if(a==0)break;
								l--;
								a--;
								cnt++;
						}
						if(a>=2){
								cnt+=a/2;
						}
						printf("%d\n",2*cnt);

				}
				else if(r>l){
						while(l!=0){
								r--;
								l--;
								cnt++;
						}

						while(r!=0){
							if(a==0)break;
								r--;
								a--;
								cnt++;
						}
//	printf("cnt%d\n",cnt);
						if(a>=2){
								cnt+=a/2;
						}
						printf("%d\n",2*cnt);
				}
				else if(r==l){
						printf("%d\n",2*(l+a/2));
				}

		}

		return 0;
}

#include<stdio.h>

int main(){
    int l,r,a;
    int n = 0;
    scanf("%d",&l);
    scanf("%d",&r);
    scanf("%d",&a);
    if(l == r){
        n += l;
        int rem = a / 2;
        n += rem;
    }
    else{
        int rem;
        if(l > r){
            n = r;
            rem = l - r;
        }
        else{
            n = l;
            rem = r - l;
        }
        if(rem < a){
            n += rem;
            rem = a - rem;
            rem = rem / 2;
            n += rem;
        }
        else if(rem > a){
            n += a;
        }
        else{
            n += rem;
        }
    }
    printf("%d",n * 2);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main(l,r,a)
{scanf("%d%d%d",&l,&r,&a);
int t,s;
if(l<r)
{
t=l;
l=r;
r=t;
}
if(a<=(l-r))
s=2*(r+a);
else
s=2*(l+(a-l+r)/2);
printf("%d",s);
}

#include<stdio.h>

int main(){
	int left,right,both,total;
	while(~scanf("%d%d%d",&left,&right,&both)){
		//while(left!=right){
		total=0;
			int t=both;
			if(left<right){
				both-=right-left;
				if(both<=0){
					left+=t;
					total=left*2;
				}else{
					left+=both;
					total=right*2+both/2*2;
				}
			}
			else if(left>right){
				both-=left-right;
				if(both<=0){
					right+=t;
					total=right*2;
				}else{
					total=left*2+(both/2)*2;
				}
			}
			else{
				total=left*2+(t/2)*2;
			}
		//}
		printf("%d\n",total);
	}
	return 0;
}

#include<stdio.h>
int main ()
{
    int a,b,c,min,max,x,y;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b)
    {
        min=b;
        max=a;
        x=max-min;
        if(x<=c)
        {
        	y=c-x;
        	y=y/2;
        	printf("%d\n",(max+y)*2);
		}
		else
		{
			printf("%d\n",(min+c)*2);
		}
	}
	else
	{
		min=a;
		max=b;
		x=max-min;
        if(x<=c)
        {
        	y=c-x;
        	y=y/2;
        	printf("%d\n",(max+y)*2);
		}
		else
		{

			printf("%d\n",(min+c)*2);
		}
	}
	return 0;
 }

//left handers right handers and ambidexters
//Bismillahir Rahmanir Rahim
#include<stdio.h>
int main()
{
    int x,y,z,a,b,c;
    scanf("%d%d%d",&x,&y,&z);
    if(x<y)
    {
        a=x+z;
        if(a>y)
        {
            b=a-y;
            b=b/2;
            c=y*2+b*2;
        }
        else
        {
            c=a*2;
        }

    }
    else if(x>y)
    {
        a=y+z;
        if(a>x)
        {
            b=a-x;
            b=b/2;
            c=x*2+b*2;
        }
        else
        {
            c=a*2;
        }
    }
    else
    {
        b=z/2;
        c=x*2+b*2;
    }
    printf("%d\n",c);

    return 0;
}
/*

1 4 2
5 5 5
0 2 0

*/

#pragma warning(disable:4996)
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#define N 100
#define EPS 1E-5
//#define min(a,b) (a>b) ? b : a
/*int lol(const void *x1, const void *x2)
{
	return *(int*)x1 - *(int*)x2;
}
int gcd(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}*/
int Min(int a, int b)
{
	return (a > b) ? b : a;
}
int main(void)
{
	int l, r, a;
	int i = 0, max = 0;
	scanf("%i%i%i", &l, &r, &a);
	for (i = 0; i <= a; i++)
		if ((l + i == r - (a - i) && l + i > max) || Min(l + i, r + (a - i)) > max)
			max = Min(l + i, r + (a - i));
	printf("%i", max * 2);
	return 0;
}

#include<stdio.h>
int main()
{
    int l,r,a,x,z;
    scanf("%d%d%d",&l,&r,&a);
    if(l==r && r==a)
    {
        printf("%d",l+r+a/2+a/2);
    }
    else
    {

    if(l>r)
    {
        x=l-r;
        if(x<=a)
        {
            r=r+x;
            a=a-x;
        }
        else
        {
            r=r+a;
            x=x-a;
            l=l-x;
            a=0;
        }

    }
    else
    {
        x=r-l;
        if(x<=a)
        {
            l=l+x;
            a=a-x;

        }
        else
        {
            l=l+a;
            x=x-a;
            r=r-x;
            a=0;
        }

    }

       printf("%d",l+r+a/2+a/2);

}
}

#include<stdio.h>
int main(){
    int a,b,c,t,r;
    scanf("%d%d%d",&a,&b,&c);
    if(a+c==0||b+c==0){
        r=0;
    }
    else{
    if(b>a){
       t=a;
       a=b;
       b=t;
    }
    again:
    if(a==b){
        r=2*(a+c/2);
    }
    else if(b+c<=a){
        r=2*(b+c);
    }
    else{

        c=c-a+b;
        b=a;
        goto again;
    }
    }
    printf("%d",r);

    return 0;
}

#include <stdio.h>

int min(int a, int b){ 	if (a<b) return a; else return b;}
int max(int a, int b){  if (a>b) return a; else return b;}

int main(){

int l,r,a,s=0,t;//i,j,k;

scanf("%i %i %i",&l,&r,&a);

if (r==l){
	s = 2*l;
	s+= (a%2==0)? a: a-1;
	}
else{
	t = max(l,r) - min(l,r);
	s = 2*min(l,r) + 2*min(a,t);
	if ( t < a ){
		t = (a-t);
		s += (t % 2 == 0 ) ? t : t-1;
	}
}

printf("%i\n",s );
return 0;
}

///I am Groot |*|
#include <stdio.h>

int main()
{
    int l,r,a,s;
    scanf("%d%d%d",&l,&r,&a);
    if(l<r)
    {
        s=l;
        l=r;
        r=s;
    }
    if(a<l-r)
        {printf("%d\n",2*(r+a));}
    else
        {printf("%d\n",(l+r+a)/2*2);}
        return 0;
}

#include<stdio.h>
main()
{
    int l,r,a,range=0,x,y,t;
    scanf("%d%d%d",&l,&r,&a);

    if(l<=r)
    {
        x=r; y=l;
    }
    else
    {
        x=l; y=r;
    }

        if(y+a<=x)
        {
            range=(y+a)*2;
        }
        else
        {
            t=(a+y-x)/2;
            range=(2*x)+(2*t);
        }

    printf("\t%d",range);

    return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
 long long compare (const void * a, const void * b)
{
    return ( *(long long *)a - *(long long *)b );
}
int main(void){

long long int test,i,j,n,count,flag,flag2,b1,l,m,u,r,q,d,x,max,max2,min,f,sum,a,b;

scanf("%lld%lld%lld",&l,&r,&b);
if(l>r){
   d=abs(l-r);
  if(d>b){
      printf("%lld",(r+b)*2);
  }else{
       printf("%lld",(l+((b-d)/2))*2);
  }

}else{
    if(l<r){
         d=r-l;
  if(d>b){
      printf("%lld",(l+b)*2);
  }else{
       printf("%lld",(r+((b-d)/2))*2);
  }
    }else{
        printf("%lld",2*r+(b/2)*2);
    }
}

    return 0;
}

#include<stdio.h>
int main()
{
    int l,r,a,result,ans,r1,l1;
    scanf("%d%d%d",&l,&r,&a);
    if(l==r){
        l=l+(a/2*2)/2;
        l=l*2;
        printf("%d\n",l);
        return 0;
    }
    if(l>r){
        r1=r+a;
        l1=l;
            if(l1>r1){
        ans=r1*2;
    }
    else
        ans=(l+r+a)/2*2;
        }
    else{
     l1=l+a;
     r1=r;
    if(l1<r1){
        ans=l1*2;
    }
    else
        ans=(l+r+a)/2*2;}
    printf("%d\n",ans);
    return 0;
}

#include<stdio.h>
int main()
{
    int l,r,a;
    scanf("%d%d%d",&l,&r,&a);
    if(l>=r)
    {
        if(a<=l-r)
        {
            r=r+a;
            printf("%d",2*r);
        }
        else
        {
            a=a-(l-r);
            r=l;
            r=r+a/2;
            printf("%d",2*r);
        }
    }
    else
    {
        if(a<=r-l)
        {
            l=l+a;
            printf("%d",2*l);
        }
        else
        {
            a=a-(r-l);
            l=r;
            l=l+a/2;
            printf("%d",2*l);
        }
    }
    return 0;
}

#include <stdio.h>
int main(){int l,r,a;scanf("%d%d%d",&l,&r,&a);while(l<r){if(a>0){a--;l++;}else{r--;}}while(r<l){if(a>0){a--;r++;}else{l--;}}while(a>1){r++;l++;a-=2;}printf("%d",r+l);return 0;}

#include<stdio.h>
int main()
{
    int l,r,a,big,small,total,c,b,k,m;
    scanf("%d %d %d",&l,&r,&a);
    b=a%2;
    if(l==r)
        {total=l+r+((a-b));
        printf("%d",total);
        return 0;
        end(0);}
    else if(l>r)
        {big=l;
        small=r;}
    else
        {small=l;
        big=r;}

    c=small+a;
    if(big>=c)
        {total=2*c;
        printf("%d",total);
        return 0;
        end(0);}
    else
        {   k=big-small;
            m=a-k;
            {
                if(m%2==0)
                    m=m;
                else
                    m=m-1;
            }
            {
                if(m>0)
                    m=m;
                else
                    m=-m;
            }
            total=(2*big)+m;
            printf("%d",total);
            return 0;
            end(0);
        }
}

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

int main(){
    setvbuf(stdout, NULL, _IONBF,0);
    int left;
    int right;
    int ambx;
    scanf("%i",&left);
    scanf("%i",&right);
    scanf("%i",&ambx);
    if(left>=0 && left<=100 && right>=0 && right<=100 && ambx>=0 && ambx<=100){
        while(ambx!=0){
            if(left>right){
                right+=1;
            }
            else if(right>left){
                left+=1;
            }
            else{
                right+=1;
            }
            ambx--;
        }
        if(left>right){
            right = right*2;
            printf("%i\n",right);
        }
        else if(left<right){
            left = left*2;
            printf("%i\n",left);
        }
        else{
            left = left*2;
            printf("%i\n",left);
        }
    }

    else{
        printf("\nNo division in command\n");
    }

    return 0;

}

#include<stdio.h>

int main()
{
    int l,r,b;
    scanf("%d%d%d",&l,&r,&b);
    if(l<r)
    {
        while(l!=r)
        {
            if(b==0)
            {
                break;
            }
            l++;
            b--;
        }
        l=l+b/2;
        r=l;
    }
    else if(r<l)
    {
        while(r!=l)
        {
            if(b==0)
            {
                break;
            }
            r++;
            b--;
        }
        r=r+b/2;
        l=r;
    }
    else if(l==r)
    {
        l=l+b/2;
        r=l;
    }
    printf("%d",l+r);
}

#include<stdio.h>
int getResult(int l,int r,int a){
	int max,min;
	max=l>r?l:r;
	min=l<r?l:r;
	if(max-min==a)
		return max*2;
	if(max-min>a)
		return (min+a)*2;
	if(max-min<a)
		return max*2+(a-max+min)/2*2;
}
int main(){
	int l,r,a;
	scanf("%d %d %d",&l,&r,&a);
	printf("%d\n",getResult(l,r,a));
	return 0;
}

#include<stdio.h>
int main()
{
    int l,r,a,total,total1,total2,total3,total4,team;
    scanf("%d%d%d",&l,&r,&a);
    total1=l+a;
    total2=r;
    total3=r+a;
    total4=l;
    if(total1<total2)
    {
        total=total2-total1;
        total2-=total;
        team=total1+total2;
        printf("%d",team);
    }
    else if(total3<total4)
    {
        total=total4-total3;
        total4-=total;
        team=total3+total4;
        printf("%d",team);
    }
    else
    {
       total=total1+total2;
       total/=2;
       team=total*2;
       printf("%d",team);
    }
return 0;

}

#include <stdio.h>
int main() {
    int l, r, a, ans;
    scanf("%d%d%d", &l, &r, &a);
    int delta = (l > r) ? l - r : r - l;
    if (delta > a) {
        if (l > r) {
            ans = r + a;
        } else {
            ans = l + a;
        }
    } else {
        a -= delta;
        a /= 2;
        if (l > r) {
            ans = l + a;
        } else {
            ans = r + a;
        }
    }
    printf("%d\n", 2 * ans);

    return 0;
}

#include<stdio.h>
int main()
{
    int l,r,a,temp;
    scanf("%d %d %d",&l,&r,&a);
    while(1){
        y:if(a==0){
            if(l>=r){
                printf("%d",r*2);
            }
            else{
                printf("%d",l*2);
            }
            break;
        }
        else{
            x:if(l==r){
                a=a/2;
                l=r;
                l=l+a;
                l=2*l;
                printf("%d",l);
                break;
            }
            else if(l>r){
                temp=l-r;
                if(temp<=a){
                    r=r+temp;
                    a=a-temp;
                    if(a==0){
                        goto y;
                    }
                    else{
                        goto x;
                    }
                }
                else{
                    r=r+a;
                    r=r*2;
                    printf("%d",r);
                    break;
                }
            }
            else if(l<r){
                temp=r-l;
                if(temp<=a){
                    l=l+temp;
                    a=a-temp;
                    if(a==0){
                        goto y;
                    }
                    else{
                        goto x;
                    }
                }
                else{
                    l=l+a;
                    l=l*2;
                    printf("%d",l);
                    break;
                }
            }
        }
    }
    return 0;
}

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

int main()
{
    int l,r,a,n;
    scanf("%d %d %d",&l,&r,&a);
    n=a;
    for(int i=1;i<=n;i++)if(l<=r){l++;a--;}else{r++;a--;}
    if(l==0 || r==0)printf("0\n");else if(l==r)printf("%d\n",l+r);else if(l>r)printf("%d\n",r*2);else printf("%d\n",l*2);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    long long int sum,lft_hnd,rght_hnd,ambdxtr,small,big,total;

    scanf("%lld %lld %lld",&lft_hnd,&rght_hnd,&ambdxtr);
    total=lft_hnd+rght_hnd;
    small=(total-abs(lft_hnd-rght_hnd))/2;
    big=total-small;
    if(small+ambdxtr<big)
        sum=(small+ambdxtr)*2;
    else
    sum=(lft_hnd+rght_hnd+ambdxtr)-(lft_hnd+rght_hnd+ambdxtr)%2;

    printf("%lld\n",sum);
    return 0;
}

#include<stdio.h>
int main()
{
	int l,r,a,b,x,y,z;
	while(scanf("%d %d %d",&l,&r,&a)!=EOF)
    {
	if(l>r){
		b=r+a;
		x=l-b;
		y=l+r+a-x;
		if(x<0)
            y=l+r+a;
            if(y%2!=0)
                y=y-1;
		printf("%d\n",y);
	}
	else if (r>l)
	{
		b=l+a;
		x=r-b;

        y=l+r+a-x;
        if(x<0)
            y=l+r+a;
            if(y%2!=0)
                y=y-1;
            printf("%d\n",y);
	}
	else if (l==r)
	{
		b=l+r;
		if(a%2==0){
		x=b+a;
		}
		else {
		x=b+a-1;
		}

	printf("%d\n",x);
	}
    }
	return 0;
}

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

int main() {
    int l,r,a;
    scanf("%d%d%d",&l,&r,&a);
    if(a==0){
        if(l>r)
            printf("%d",r+r);
        else if(l==r)
            printf("%d",l+r);
        else
            printf("%d",l+l);
    }
  else if(l==r){

       if(a%2==0){
           printf("%d",l+r+a);
       }
       else
           printf("%d",l+r+a-1);
   }
    else if((l==0&&r==0)||(l==0&&a==0)||(r==0&&a==0)){
        printf("0");
    }
   else if(l>r){
        if((a+r)<l){
            l=r+a;
                printf("%d",l+r+a);

        }
        else if((a+r)==l)
            printf("%d",a+r+l);
        else{
            int s=(a+r)-l;
            if(s%2==0){
                printf("%d",a+l+r);
            }
            else
                printf("%d",a+l+r-1);

    }
    }
   else if(r>l){
        if((a+l)<r){
            r=l+a;
                printf("%d",l+r+a);

        }
        else if((a+l)==r)
            printf("%d",a+r+l);
        else{
            int s=(a+l)-r;
            if(s%2==0){
                printf("%d",a+l+r);
            }
            else
                printf("%d",a+l+r-1);

    }
    }

    return 0;
}

#include<stdio.h>

int main()
{
    int left,right,ambidexter;
    scanf("%d %d %d",&left,&right,&ambidexter);
    int max_team,difference;
    if (left==right)
    {
        ambidexter=ambidexter/2;
        max_team=left+right+(ambidexter*2);
        printf("%d\n",max_team);
    }
    else if (left > right)
    {
        difference=left-right;
        if (ambidexter>=difference)
        {
            ambidexter-=difference;
            ambidexter=ambidexter/2;
            max_team=left+left+(2*ambidexter);
            printf("%d\n",max_team);
        }
        else if (ambidexter<difference)
        {
            right+=ambidexter;
            max_team=right+right;
            printf("%d\n",max_team);
        }
    }
    else if (left < right)
    {
        difference=right-left;
        if (ambidexter>=difference)
        {
            ambidexter-=difference;
            ambidexter=ambidexter/2;
            max_team=right+right+(ambidexter*2);
            printf("%d\n",max_team);
        }
        else if (ambidexter<difference)
        {
            left+=ambidexter;
            max_team=left+left;
            printf("%d\n",max_team);
        }
    }
    return 0;
}

#include<stdio.h>
int main(){
    int a,b,c,t,r;
    scanf("%d%d%d",&a,&b,&c);
    if(a+c==0||b+c==0){
        r=0;
    }
    else{
    if(b>a){
       t=a;
       a=b;
       b=t;
    }
    again:
    if(a==b){
        r=2*(a+c/2);
    }
    else if(b+c<=a){
        r=2*(b+c);
    }
    else{

        c=c-a+b;
        b=a;
        goto again;
    }
    }
    printf("%d",r);

    return 0;
}

#include<stdio.h>

int main ()
{
	int a,b,c,tong;
	scanf("%d %d %d",&a,&b,&c);
	tong = a+b+c ;
	if(a!=0&&b!=0&&c!=0)
	{
		if(a<b)
		{
			if((a+c)<b) printf("%d",(a+c)*2);
			else {
				if(tong%2==0) printf("%d",tong);
				else printf("%d",tong - 1 ) ;
			}
		}
		if(a>b)
		{
			if((b+c)<a) printf("%d",(b+c)*2);
			else {
				if(tong%2==0) printf("%d",tong);
				else printf("%d",tong - 1 ) ;
			}
		}
		if(a==b)
		{
			if(tong%2==0) printf("%d",tong);
			else printf("%d",tong - 1 ) ;
		}
	}
	else if(c==0)
	{
		if(a!=0&&b!=0)
		{
			if(a<b) printf("%d",a*2);
			else printf("%d",b*2);
		}
		else if(a==0&&b!=0) printf("%d",0);
		else if(b==0&&a!=0) printf("%d",0);
		else if(a==0&&b==0) printf("%d",0);
	}
	else if(a==0||b==0&&c!=0)
	{
		if(tong%2==0) printf("%d",tong);
		else printf("%d",tong - 1 ) ;
	}
}

#include <stdio.h>

int main( )
{
	int l,r,a, team=0;

	//printf("Enter l, r, a:");
	scanf("%d%d%d", &l, &r, &a);
	//printf("left=%d, right=%d, ambi=%d\n", l,r,a);

	if (l ==r)
	{
		team += l + r;
		if(a%2 ==0)
			team += a;
		else
			team += (a-1);
	}
	else if ( l < r)
	{
		team += 2*l;
		r = r-l;
		if( a < r)
		{
			team += 2*a;

		}
		else
		{
			team += 2*r;
			a = a-r;
			if(a%2 ==0)
				team += a;
			else
				team += (a-1);
		}
	}
	else
	{
		team += 2*r;
		l = l-r;
		if( a < l)
		{
			team += 2*a;

		}
		else
		{
			team += 2*l;
			a = a-l;
			if(a%2 ==0)
				team += a;
			else
				team += (a-1);
		}
	}
 printf("%d", team);
}

#include <stdio.h>
int main()
{
	int l,r,a,max;
	scanf("%d %d %d",&l,&r,&a);
		if(l==r)
		{
		l=l+a/2;
		r=r+a/2;
		max=l+r;
		}
		if(l>r)
		{
			if(a>l-r)
			{
				a=a-(l-r);
				r=l;
				r=r+a/2;
				l=l+a/2;
				max=r+l;
			}
			else
		   {
				max=2*(r+a);
			}
		}
		if(r>l)
		{
			if(a>r-l)
			{

				a=a-(r-l);
				l=r;
				r=r+a/2;
				l=l+a/2;
				max=r+l;
			}
			else
			{
				max=2*(l+a);
			}
		}
		printf("%d",max);
	return 0;
	}

#include<stdio.h>
#include<string.h>
int main()
{
	int l,r,a,t;
	scanf("%d%d%d",&l,&r,&a);
	if(l>r)
	{
		t=l;
		l=r;
		r=t;
	}
	if(l+a<=r)printf("%d\n",2*(l+a));
	else printf("%d\n",2*r+(a-(r-l))/2*2);
	return 0;
}

#include <stdio.h>
int min(int l,int r);
int max(int l,int r);
int main()
{
	int l,r,a,mi,ma,mini=0,maxi=0;
	scanf("%d %d %d",&l,&r,&a);
	if(l==0 || r==0)
		printf(0);
	if(a==0){
		if(l==r){
		printf("%d",2*l);
		return 0;
		}
		else{
		printf("%d",min(l,r)*2);
		return 0;
		}
	}
	mi=min(l,r);
	ma=max(l,r);
	if(mi+a<=ma){
		printf("%d",2*(mi+a));
		return 0;
	}
	if(mi+a>ma){
		mini=min(l,r);
		maxi=max(l,r);
		if(l!=r){
			a=a-(maxi-mini);
			mini=maxi;
		}
		if(a%2==0){
			mini+=(a/2);
			maxi+=(a/2);
			printf("%d",mini*2);
			return 0;
		}
		else{
			while(a>1){
				mini+=1;
				a--;
				if(a==1){
					break;
				}
				maxi+=1;
				a--;
				if(a==1){
					break;
				}
			}
			printf("%d",mini+maxi);
		}
	}
}
int max(int l,int r){
	int maximum=0;
	if(l>=r){
		maximum=l;
	}
	if(r>=l){
		maximum=r;
	}
	return maximum;
}

int min(int l,int r){
	int minimum=0;
	if(l<=r){
		minimum=l;
	}
	if(r<=l){
		minimum=r;
	}
	return minimum;
}

#include <stdio.h>
int main()
{

     int l,r,a,t,sum=0;
     scanf("%d %d %d",&l,&r,&a);
     if(l>r)
     {
         t=l;
         l=r;
         r=t;
     }
     sum=sum+2*l;
     r=r-l;
     if(r<a)
     {
         a=a-r;
         sum=sum+2*r;
         if(a>0)
         {
             if(a%2==0)
             {
                 sum=sum+a;

             }
             else{
                sum=sum+a-1;
             }

         }
     }
     else
     {
         sum=sum+2*a;
     }

    printf("%d",sum);

}

#include <stdio.h>
int min(int a,int b)
{
    if(a<b) return a;
    else    return b;
}
int max(int a,int b)
{
    if(a>b) return a;
    else    return b;
}
int abs(int a)
{
    if(a<0) return -a;
    else    return a;
}
int main(void) {
	int f,s,t,l,r,a;
	scanf("%d%d%d",&l,&r,&a);

	f=min(l,r);
	s=min(abs(max(l,r)-f),a);
	t=a-s;

	if(t<0) t=0;

	printf("%d",(f+s+t/2)*2);
	return 0;
}

#include <stdio.h>
#define min(a,b) (a>b?b:a)

int main() {
	int l,r,a;
	scanf("%d %d %d",&l,&r,&a);

	if (l > r) {
	    int x = l - r;
		if (x > a) {
			r += a;
			a = 0;
		} else {
			r += x;
			a -= x;
		}
	} else if (l < r) {
	    int x = r - l;
		if (x > a) {
			l += a;
			a = 0;
		} else {
			l += x;
			a -= x;
		}
	}

	if (l == r) {
		l+=(a/2);
		r+=(a/2);
	}

	printf("%d\n", min(l,r)*2);
	return 0;
}

#include <stdio.h>
int main() {
    int l, r, a, ans;
    scanf("%d%d%d", &l, &r, &a);
    int delta = (l > r) ? l - r : r - l;
    if (delta > a) {
        ans = ((l > r) ? r : l) + a;
    } else {
        a -= delta;
        a /= 2;
        ans = ((l > r) ? l : r) + a;
    }
    printf("%d\n", 2 * ans);

    return 0;
}

#include<stdio.h>
int main(){
	int l,r,am;
	int min=0,max=0;
	scanf("%d %d %d",&l,&r,&am);

	min=(l>r)?r:l;
	max=(r>l)?r:l;
	if((min+am)<=max)
        printf("%d\n",2*(min+am));
	else
	    printf("%d\n",2*(max+(am-max+min)/2));

	return 0;
}

///I am Groot |*|
#include <stdio.h>

int main()
{
    int l,r,a,s;
    scanf("%d%d%d",&l,&r,&a);
    if(l<r)
    {
        s=l;
        l=r;
        r=s;
    }
    if(a<l-r)
        {printf("%d\n",2*(r+a));}
    else
        {printf("%d\n",(l+r+a)/2*2);}
        return 0;
}

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

int main()
{
    int l,r,a,count;
    scanf("%d%d%d",&l,&r,&a);
    count=0;
    while(count<a){
        if(l>(r+a)){
            r=r+a;
            goto x;
        }
        if(r>(l+a)){
            l=l+a;
            goto x;
        }
        if(l<r){
            l++;
            count++;
        }
        if(l==r){
            if((a-count)%2==0){
                l=l+(a-count)/2;
                r=r+(a-count)/2;
                goto x;
            }
            else{
                l=l+(a-count-1)/2;
                r=r+(a-count-1)/2;
                goto x;
            }
        }
        if(r<l){
            r++;
            count++;
        }
    }
    x:
        if(l<=r)
            printf("%d",2*l);
        else
            printf("%d",2*r);
    return 0;
}

#include<stdio.h>
int main(){
int n,m,a,c,min,max,k;
scanf("%d %d %d",&n,&m,&a);
if(n!=m){
if(n<m)
{
min=n;
max=m;
}
else{
min=m;
max=n;
}
min=min+a;

if(min<max)
printf("%d\n",min*2);
else{
k=min-max;
if(k%2==0)
printf("%d\n",(max*2)+k);
else
printf("%d\n",(max*2)+(k-1));

}
}
else{
min=n*2;
if(a%2==0)
printf("%d\n",min+a);
else
printf("%d\n",(min+(a-1)));

}

return 0;
}

#include <stdio.h>

int main()
{
    int l, r, a, b;

    scanf("%d %d %d", &l, &r, &a);

    if(l < r){
        b = r-l;
        if(b <= a){
            l += b;
            a -= b;

        }
        else{
            l += a;
            a = 0;
        }
    }
    else{
        b = l-r;
        if(b <= a){
            r += b;
            a -= b;
        }
        else{
            r += a;
            a = 0;
        }
    }

    a /= 2;
    r += a;
    l += a;

    if(r < l) printf("%d\n", r*2);
    else printf("%d\n", l*2);

    return 0;
}

#include<stdio.h>
int main()
{
   long long int rh,lh,ne,d,sum,div,i;
    scanf("%lld %lld %lld",&rh,&lh,&ne);

    d = ne;
    if(rh>lh){

        while(ne>0){
            if(lh == rh){
                break;
            }
            lh++;
            d--;
            ne--;
        }

        div = d/2;
        sum = (lh*2)  + (div*2);
        printf("%lld\n",sum);
    }
    else {

        while(ne>0){
            if(rh == lh){
                break;
            }
            rh++;
            d--;
            ne--;
        }

        div = d/2;
        sum = (rh*2)  + (div*2);
        printf("%lld\n",sum);
    }
    return 0;

}

#include<stdio.h>
int main()
{
    int n,i,j,a,b,c,x;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b)
    {
        i=c/2;
        a=a+i;
        b=b+i;
        x=a+b;
    }
    else if(a>b && a-b<=c)
    {
       while(b!=a)
       {
           b=b+1;
           c=c-1;
       }
       i=c/2;
       a=a+i;
       b=b+i;
        x=a+b;

    }
    else if(a<b && b-a<=c)
    {
        while(a!=b)
        {
            a=a+1;
            c=c-1;
        }
        i=c/2;
        a=a+i;
        b=b+i;
        x=a+b;
    }
    else if(a>b && a-b>c)
    {
        b=b+c;
        i=a-b;
        a=a-i;
        x=a+b;
    }
    else if(a<b && b-a>c)
    {
        a=a+c;
        i=b-a;
        b=b-i;
        x=a+b;
    }
    printf("%d",x);
    return 0;
}

#include<stdio.h>
int main()
{
	int l,r,a,i,j,x;
	scanf("%d%d%d",&l,&r,&a);
	for(i=a;i>=0;i--)
	{
		if(l-r>=0)
		{
			x=r+i;
			if(x==l)
			{      if((a-i)%2==0)
				{	printf("%d",2*l+a-i);}
				else{printf("%d",2*l+a-i-1);
				}
			break;
			}
			else if(l>x)
			{
				printf("%d",2*(r+a));
				break;
			}
		}
		else
		{
			x=l+i;
			if(x==r)
			{      if((a-i)%2==0)
				{	printf("%d",2*r+a-i);}
				else{printf("%d",2*r+a-i-1);
				}	break;
			}
			else if(r>x)
			{
				printf("%d",2*(l+a));
					break;
			}
		}
	}
	return 0;
}

#include<stdio.h>
int main()
{
    int l,r,a,t,x,k,max,min,ans;
  scanf("%d %d %d",&l,&r,&a);
  if((l==0||r==0)&&(a==0))
    ans=0;
   if((l==0||r==0)&&(a!=0))
   {
       if(l==0)
        k=r;
       else
        k=l;
     if(a<=k)
        ans=2*a;
     else
        ans=2*k;
   }
   min=(l<r)?l:r;
   max=(l>r)?l:r;
   x=max-min;
   if(x>=a)
   ans=2*(min+a);
   if(x<a)
   {
       min=min+x;
       t=a-x;
       ans=2*(min+t/2);
   }
   if(x==0)
   {
       ans=2*(min+a/2);
   }
   printf("%d",ans);
   return 0;
}

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

int main()
{
    int a,l,r,ans;
    scanf("%d%d%d",&l,&r,&a);
    if(a==0)
    {
        if(l<r)
            ans=2*l;
        else
            ans=2*r;
    }
    else if(l<r)
    {
        for(;a!=0;)
        {
            if(a>0&&l<r)
            {
                l++;
                a--;
            }
            else if(r==l&&a>1)
            {
                r++;
                l++;
                a-=2;
            }
            else if(r==l&&a==1)
                break;
        }
        if(l<r)
            ans=2*l;
        else
            ans=2*r;
    }
    else if(r<l)
    {
        for(;a!=0;)
        {
            if(a>0&&r<l)
            {
                r++;
                a--;
            }
            else if(r==l&&a>1)
            {
                r++;
                l++;
                a-=2;
            }
            else if(r==l&&a==1)
                break;
        }
        if(r<l)
            ans=2*r;
        else
            ans=2*l;
    }
    else
    {
        if(a%2==0)
            ans=r+l+a;
        else
            ans=r+l+a-1;
    }
    printf("%d",ans);
    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    int a,b,c,d,e;
    scanf("%d%d%d",&a,&b,&c);
    d=b-a;
    if (d<0)
        d=-d;
    e=c-d;
    if(e>=0)
        printf("%d",a+b+d+(e/2)*2);
    else
    {
        if(b>a)
        printf("%d",2*(a+c));
    else if (a>b)
        printf("%d",2*(b+c));

}
}

#include<stdio.h>
#include<conio.h>
main()
{
int l,r,a,temp,ans;
scanf("%d %d %d",&l,&r,&a);
if(l<r)
{  while(a>0)
  {
      l=l+1;
      a=a-1;
  }
  if(l<=r)
  ans=2*l;
  else
  {temp=l-r;
   if(temp%2==0)
   ans=l+r;
   else
   ans=l+r-1;
  }
}
else
{
  while(a>0)
  {
      r=r+1;
      a=a-1;
  }
   if(l>=r)
  ans=2*r;
  else
  {temp=r-l;
   if(temp%2==0)
   ans=l+r;
   else
   ans=l+r-1;
}}
printf("%d",ans);
}

#include<stdio.h>
int main()
{
    int r,l,a,s,min,n,max;
    scanf("%d%d%d",&r,&l,&a);
    if(r>l){ min=l;
    max=r;}
    else {min=r;
    max=l;}
    if(r!=0 || l!=0){
            if(r==l){n=(r+(a/2))*2;}
       else{ s=max-min;
        if(s<a){a=(a-s)/2;
                n=(min+s+a)*2;}
        else {n=(min+a)*2;}
    }}
    else {
if(a%2==0) n=a;
else n=a-1;}
    printf ("%d",n);
}

#include <stdio.h>
unsigned short absv(unsigned short, unsigned short);
unsigned short min(unsigned short, unsigned short);
int main()
{
    unsigned short l, r, a, n, k;
    scanf("%hu%hu%hu", &l, &r, &a);
     k = absv(l, r);
    if(a < k){
      n = (a + min(l, r)) * 2;

    }else{
        a -= k;
        n = k + l + r + (a - a % 2);

    }
    printf("%hu",  n);
    return 0;
}
unsigned short absv(unsigned short x, unsigned short y){
    return x > y ? x - y : y - x;
}
unsigned short min(unsigned short x, unsigned short y){
    return x < y ? x : y;
}

#include<stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	while(c){
		if(a>b) b++;
		else a++;
		c--;
	}
	printf("%d",a > b ? b*2 : a*2);
	return 0;
}

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

int main()
{
    int l,r,a,c;
    scanf("%d %d %d",&l,&r,&a);
    if(l<r){
        c=r-l;
        if(c>=a){
            l=l+a;
            r=l;
        }
        else {
            l=l+c;
            a=a-c;
            a=a/2;
            l=l+a;
            r=r+a;
        }
    }
    else if(r<l){
        c=l-r;
        if(c>=a){
            r=r+a;
            l=r;
        }
        else {
            r=r+c;
            a=a-c;
            a=a/2;
            l=l+a;
            r=r+a;
        }
    }
    else {
        a=a/2;
        l=l+a;
        r=r+a;
    }
    printf("%d",2*l);
    return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,i,j,x,y,z,ans;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
            x=a;
            y=b;
    }
    else{
        x=b;
        y=a;
    }
    if((y+c)>x){
        ans=2*x+2*((y+c-x)/2);
        printf("%d",ans);
    }
    else if((y+c)<x){
        ans=2*(y+c);
        printf("%d\n",ans);
    }
    else if(a==b){
        ans=a+b+2*(c/2);
        printf("%d\n",ans);
    }
    return 0;
}

#include <stdio.h>

int main()
{
    int l, r, a, s;
    scanf("%d%d%d",&l,&r,&a);
    printf("%d",(l+r+a)/2*2);
}

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

int main() {
    int l,u,a;
    scanf("%d %d %d",&l,&u,&a);
    int min,max;
    if(l<u){
        min=l;
        max=u;
    }

  else if(u<l){
        min=u;
        max=l;
    }

    int x=(a/2)*2;

     if(l==u)
    printf("%d",2*l+x);
   else if((min+a)<max)
            printf("%d",2*(min+a));
    else if((min+a)>max)
        printf("%d",2*max+(a-max)/2);

    }

#include<stdio.h>
#include<conio.h>
int main()
{
    int a,b,c,s;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b)
    {
        if((a+c)<=b)
        {
            s=2*(a+c);
        }
        else
        {
            c=c-b+a;
            c=c/2;
            s=s*(b+c);
        }
    }
    else if(a==b)
    {
        c=c/2;
        s=2*(b+c);
    }
    else
    {
        if((b+c)<=a)
        {
            s=2*(b+c);
        }
        else
        {
            c=c-a+b;
            c=c/2;
            s=s*(a+c);
        }
    }
    printf("%d\n",s);
    return 0;
}

#include<stdio.h>

int main()
{
	int l, r, a, tmp=0;
	scanf("%d %d %d", &l, &r, &a);

	int total=0;

	if((l==0 && a==0)|| (r==0 && a==0))
		total=0;

	else if(l==0)
	{
		if(r>=a)
			total=2*a;
		else
		{
			total=2*r;
			tmp=a-r;
			if(tmp%2==0)
				total=total+a;
			else
				total=total+a-1;
		}
	}

	else if(r==0)
	{
		if(l>=a)
			total=2*a;
		else
		{
			total=2*l;
			tmp=a-l;
			if(tmp%2==0)
				total=total+a;
			else
				total=total+a-1;
		}
	}

	else if(l>r)
	{
		if((r+a)<=l)
			total=2*(r+a);

		else if((r+a)>l)
		{
			tmp=l-r;
			total=(2*l);
			a=a-tmp;
			if(a%2==0)
				total=total+a;
			else
				total=total+a-1;
		}
	}

	else if(r>l)
	{
		if((l+a)<=r)
			total=2*(l+a);

		else if((l+a)>r)
		{
			tmp=r-l;
			total=(2*r);
			a=a-tmp;
			if(a%2==0)
				total=total+a;
			else
				total=total+a-1;
		}
	}

	else
	{
		total=2*r;
		if(a%2==0)
			total=total+a;
		else
			total=total+a-1;
	}
	printf("%d", total);
}

#include<stdio.h>
int smaller(int a, int b){
    if(a>b){
        a = b;
    }
    return a;
}
int larger(int a, int b){
    if(b>a){
        a = b;
    }
    return a;
}
int main()
{
    int x,y,z,temp1,temp2;
    scanf("%d%d%d",&x,&y,&z);
    temp1 = smaller(x,y);
    temp2 = larger(x,y);

    while(temp1 != temp2){
        temp1 = temp1 + 1;
    }
    if(z%2!=0){
        z = z - 1;
    }
    int total_player;
    total_player = temp1 + temp2 + z;
    if(y==0 || x==0){
        total_player = 0;
    }
    printf("%d",total_player);
    return 0;
}

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

int main()

{
    long long a,b,c,n,r;
    scanf("%I64d %I64d %I64d",&a,&b,&c);
    if(c==0)
    {
        if(a!=b){printf("No");}
        else{printf("Yes");}
    }

    else{
    n=(b-a+c)/c;
    if(n>0){

    r=a+(n-1)*c;
    if(r==b)
    {
        printf("Yes");
    }
    else{printf("No");}}
    else{printf("No");}

}}

#include <stdio.h>

int main( )
{
	int l,r,a, team=0;

	printf("Enter l, r, a:");
	scanf("%d%d%d", &l, &r, &a);
	printf("left=%d, right=%d, ambi=%d\n", l,r,a);

	if (l ==r)
	{
		team += l + r;
		if(a%2 ==0)
			team += a;
		else
			team += (a-1);
	}
	else if ( l < r)
	{
		team += 2*l;
		r = r-l;
		if( a < r)
		{
			team += 2*a;

		}
		else
		{
			team += 2*r;
			a = a-r;
			if(a%2 ==0)
				team += a;
			else
				team += (a-1);
		}
	}
	else
	{
		team += 2*r;
		l = l-r;
		if( a < l)
		{
			team += 2*a;

		}
		else
		{
			team += 2*l;
			a = a-l;
			if(a%2 ==0)
				team += a;
			else
				team += (a-1);
		}
	}
 printf("%d", team);
}

#include<stdio.h>
int main(){
	int a, b, c,l,r,sum;
	scanf("%d%d%d", &a, &b, &c);
	l=a+c;
	r=b+c;
	sum=l+r-c;
	if ((a==0 && c==0) || (b==0 && c==0)) printf("%d\n", 0);
	else if (sum%2==0) printf("%d\n",  sum);
	else printf("%d\n", sum-1);

	return 0;
}

#include<stdio.h>
int main()
{
	int l,x,m,r,a,n;
	scanf("%d%d%d",&l,&r,&a);
	if(l==r)
	{   start:
		if(a%2!=0 && a!=0)
	{	x=l+r+a-1;}
		else
	{	x=l+r+a; }
	printf("%d\n",x);
	}
	else if(l>r)
	{m=l-r;
	if(a-m>0)
	r=r+m;
	a=a-m;
	goto start;}

	else if(l<r)
	{
	m=r-l;
	if(a-m>0)
	l=l+m;
	a=a-m;
	goto start;
	}
	else
	printf("0\n");

}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int l,r,a;
    scanf("%d %d %d",&l,&r,&a);
    if(l>r)
    {
        r+=a;
        if(r>l)
        {
            printf("%d\n",l*2);
        }
        else printf("%d\n",r*2);
    }
    else if(r<l)
    {
        l+=a;
        if(l>r)
        {
            printf("%d\n",(l-r));
        }
        else
            printf("%d\n",(r-l));
    }
    else
    {
        if((l+r+a)%2 == 0)
        {
            printf("%d\n",l+r+a);
        }
        else
        {
            printf("%d\n",l+r+a-1);
        }
    }
    return 0;
}

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

int main(void) {

	setvbuf(stdout, NULL, _IONBF, 0);
	int l;
	int r;
	int a;

	printf("Enter a number of players in this way l r a \n");
	scanf("%i %i %i", &l, &r, &a);

	if(l == r) {
		if((a & 1) == 0) {
		printf("%i", l + r + a);
		} else {
			printf("%i", l + r + (a - 1));
		}
	}

		else if((l == 0 && a == 0)){
		printf("%i", l + a);
	}

	else if((r == 0 && a == 0)){
			printf("%i", r + a);
	}

	else if(l < r){
			if((a & 1) == 0) {
					printf("%i", l + r + (a - 1));
		} else {
			printf("%i", l + r + a);
		}
		}

	else{
		if((a & 1) == 0) {
				printf("%i", l + r + (a - 1));
	} else {
		printf("%i", l + r + a);
	}
	}

	return 0;

}

#include<stdio.h>

int main ()
{
	int a,b,c,tong;
	scanf("%d %d %d",&a,&b,&c);
	tong = a+b+c ;
	if(a!=0&&b!=0&&c!=0)
	{
		if(a<b)
		{
			if((a+c)<b) printf("%d",(a+c)*2);
			else {
				if(tong%2==0) printf("%d",tong);
				else printf("%d",tong - 1 ) ;
			}
		}
		if(a>b)
		{
			if((b+c)<a) printf("%d",(b+c)*2);
			else {
				if(tong%2==0) printf("%d",tong);
				else printf("%d",tong - 1 ) ;
			}
		}
		if(a==b)
		{
			if(tong%2==0) printf("%d",tong);
			else printf("%d",tong - 1 ) ;
		}
	}
	else if(c==0)
	{
		if(a!=0&&b!=0)
		{
			if(a<b) printf("%d",a*2);
			else printf("%d",b*2);
		}
		else if(a==0&&b!=0) printf("%d",0);
		else if(b==0&&a!=0) printf("%d",0);
		else if(a==0&&b==0) printf("%d",0);
	}
	if(a==0 || b==0)
	{
		if(tong%2==0) printf("%d",tong);
		else printf("%d",tong - 1 ) ;
	}
}
//dsfsdfsd

#include<stdio.h>

int main(){
	int l,r,a;
	scanf("%d%d%d",&l,&r,&a);
	int t;

	if(r>l){
		l=l+a;
		if(l>r){
			a=l-r;
			if(a>0){
				t=(r+a/2)*2;
				printf("%d",t);
			}
			else printf("%d",r*2);
		}
		else printf("%d",l*2);
		return 0;
	}
	if(l>r){
		r=r+a;
		if(r>l){
			a=r-l;
			if(a>0){
				t=(l+a/2)*2;
				printf("%d",t);
			}
			else printf("%d",l*2);
		}
		else printf("%d",r*2);
		return 0;
	}
	if(l==r){
		if(a==0) printf("%d",r);
		else printf("%d",(l+a/2)*2);
	}
	return 0;
}

#include<stdio.h>
int main()
{
	int l,r,a,i,j,x;
	scanf("%d%d%d",&l,&r,&a);
	for(i=a;i>=0;i--)
	{
		if(l-r>=0)
		{
			x=r+i;
			if(x==l)
			{      if((a-i)%2==0)
				{	printf("%d",2*l+a-i);}
				else{printf("%d",2*l+a-i-1);
				}
			break;
			}
			else if(l>x)
			{
				printf("%d",2*(r+a));
				break;
			}
		}
		else
		{
			x=l+i;
			if(x==r)
			{      if((a-i)%2==0)
				{	printf("%d",2*l+a-i);}
				else{printf("%d",2*l+a-i-1);
				}	break;
			}
			else if(r>x)
			{
				printf("%d",2*(l+a));
					break;
			}
		}
	}
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main(){
		int i,j,r,l,a,cnt;
		while(scanf("%d %d %d ",&l,&r,&a)!=EOF){
				cnt=0;
				if(l>r){
						while(r!=0){
								r--;
								l--;
								cnt++;
						}
						while(l!=0){
								if(a==0)break;
								r--;
								a--;
								cnt++;
						}
						if(a>=2){
								cnt+=a/2;
						}
						printf("%d\n",2*cnt);

				}
				else if(r>l){
						while(l!=0){
								r--;
								l--;
								cnt++;
						}

						while(r!=0){
							if(a==0)break;
								r--;
								a--;
								cnt++;
						}
//	printf("cnt%d\n",cnt);
						if(a>=2){
								cnt+=a/2;
						}
						printf("%d\n",2*cnt);
				}
				else if(r==l){
						printf("%d\n",2*(l+a/2));
				}

		}

		return 0;
}

#include<stdio.h>
int main(){
	int a, b, c,max, min,l;
	scanf("%d%d%d", &a, &b, &c);
	max=a;
	min=a;
	if (max<b) max=b;
	else if (max==b) max=min;
	else min=b;
	if (min+c==max) l=max*2;
	else if (min+c<max) l=(min+c)*2;
	else if (min+c>max && ((min+c)-max)%2==0)
	l=max*2+((min+c)-max);
	else if (min+c>max && ((min+max)-b)%2!=0)
	l=max*2+((min+c)-max-1);
	printf("%d", l);

	return 0;
}

#include<stdio.h>
int main()
{
	int l,r,a, fl=0,fr=0, fe=0,d;

	scanf("%d%d%d",&l,&r,&a);

	if(a+l>r || a+r>l)
	{
		d=l-r;
		if(l<r && a>l){l=l+d;a=a-d;}
		else if(l>r && a>r){r=r+d;a=a-d;}
	}

	if(l>r) fr=1;
	else if (r>l) fl=1;
	else fe=1;

	if(fr) r+=a;
	else if(fl) l+=a;
	else if (fe) {l+=(a/2);r+=(a/2);}

	if(fl||fr)
	{	if(l>r)
			l-=(l-r);
		else
			r-=(r-l);
	}
	printf("%d",l+r);

	return 0;

}

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

int main(int argc, char *argv[]) {
    int l, r, a;
    scanf("%d%d%d", &l, &r, &a);
    if (abs(l - r) >= a)  {
        if (l > r) printf("%d", 2 * (r + a));
        else printf("%d", 2 * (l + a));
    }
    else {
        if (l > r) printf("%d", 2 * l + a - abs(l - r));
        else printf("%d", 2 * r + a - abs(l - r));
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
    int l,r,a,s=0;
    scanf("%d %d %d",&l,&r,&a);
    s=l+r+a;
     if(l+a==0 || r+a==0 ){
        printf("0");
    }
    else if(l+r==a || r+a==l || l+a==r)
    {
        printf("%d",s);
    }
    else if(l>r)
    {
        if(l-r>=a)
        {
             printf("%d",s-(l-r)+a);
        }
        else if(l-r<a)
        {
              printf("%d",s-1);
        }
    }
    else if(r>l)
    {
        if(r-l>=a)
        {
             printf("%d",s-(r-l)+a);
        }
        else if(r-l<a)
        {
              printf("%d",s-1);
        }
    }
    else if(l==r && r==a && a==l)
    {
         printf("%d",s-1);
    }

}

#include<stdio.h>
#define min(a,b) a<b?a:b
int main()
{
    int m,n,a,s;
    scanf("%d%d%d",&m,&n,&a);
    if(a==0)
        printf("%d\n",min(m,n)*2);
    else
    {
        if(m<n)
        {
            m+=a;
            if(m<=n)
                s=min(m,n),printf("%d\n",2*s);
            else
                printf("%d\n",n*2+((m-n)/2)*2);
        }
        else
        {
            n+=a;
            if(n<=m)
                s=min(m,n),printf("%d\n",s*2);
            else
                printf("%d\n",m*2+((n-m)/2)*2);
        }
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int l,r,a,di,d;
	int re;
	scanf("%d%d%d",&l,&r,&a);
	di=0;
 if(r>l)
	{
		di=r-l;
		di=di>a?a:di;
		l=di+l;
		a=a-di;
		d=l;
	}

else if(l>r)
	{
		di=l-r;
		di=di>a?a:di;
		r=r+di;
		a=a-di;
		d=r;
	}
else
d=l;
printf("%d",d);
return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
    int l,r,a,s=0;
    scanf("%d %d %d",&l,&r,&a);
    s=l+r+a;
     if(l+a==0 || r+a==0 ){
        printf("0");
    }
    else if(l+r==a || r+a==l || l+a==r)
    {
        printf("%d",s);
    }
    else if(l>r)
    {
        if(l-r>=a)
        {
             printf("%d",s-(l-r)+a);
        }
    }
    else if(l<r)
    {
        if(l-r<a)
        {
             printf("%d",s-1);
        }
    }
    else if(l==r && r==a && a==l)
    {
         printf("%d",s-1);
    }

}

#include<stdio.h>
int main()
{
    int l,r,a,i,x;
    scanf("%d%d%d",&l,&r,&a);
    if(l>r)
        x=l;
    else
        x=r;
    for(i=l;i<=x;i++)
    {
    if(l==r)
    {
        if(l=r=a)
            printf("%d",l+r+(a/2)+(a/2));
        else
            printf("%d",l+r);
            break;
    }
    if(l<r)
    {
      l=l+a;
      if(l<r)
          r--;
      else
          l--;
    }
    else
    {
        r=r+a;
        if(r<l)
            l--;
        else
            r--;
        }
    }

}

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int n,j,b,l,r,a,sum;
    scanf("%d %d %d",&l,&r,&a);
    if(l==r)
    {
        l=l+a/2;
        r=r+a/2;
    }
    else if(r>l && r<=a)
    {
        a=a-(r-l);
        l=r+a/2;
        r=r+a/2;
    }
    else if(r>l && r>a)
    {
        l=l+a;
        r=l;
    }
    else if(l>r && l>a)
    {
        r=r+a;
        l=r;
    }
    else if(l>r && l<=a)
    {
        a=a-(l-r);
        r=l+a/2;
        l=l+a/2;
    }
    sum=l+r;
    printf("%d\n",sum);

    return 0;
}

#include<stdio.h>
main()
{
    int l,r,a,d, large,small;

    scanf("%d%d%d",&l,&r,&a);
    if(l==0 || r==0)
       {
           printf("0");
       }

    else
    {
         if(l>r)
    {
        large=l;
        small=r;
    }
    else
    {
        large=r;
        small=l;
    }
    if((small+a)<=large)
    {
        d=2*(small+a);
        printf("\n\n%d",d);

    }
    else
    {
        d=small+large+a;
        if(d%2==0)
        {
            printf("\n\n%d",d);
        }
        else
        {
            d=d-1;
            printf("\n\n%d",d);
        }
    }

    }
    return 0;
}

#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);
    if(a==b){
        printf("%d",a+b+(c/2)*2);
        return 0;
    }
    if(a>b){
        b=b+c;
        if(a>=b){
            printf("%d",2*b);
            return 0;
        }
        else{
            printf("%d",2*a+((b+c-a)/2)*2);
            return 0;
        }
    }
    else{
        a=a+c;
        if(a>=b){
            printf("%d",2*b+((a+c-b)/2)*2);
            return 0;
        }
        else{
            printf("%d",2*a);
            return 0;
        }
    }
}

#include<stdio.h>
#include<math.h>
int main()
{
    int l,r,a,x,y;
    scanf("%d%d%d",&l,&r,&a);

    x=abs(l-r);
    if(x!=0)
    {
    y=abs(x-a);
    printf("%d\n",a+l+r-y);
    }
    else
        printf("%d\n",((a+l+r)/2)*2);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main() {
int l,r,a,p,q,m,s = 0,k;
scanf("%d%d%d",&l,&r,&a);
if(l < r) {
	p = r - l;
if(p <= a) {
	s = a - p;
	l = l + p;
	} else {
		l = l + a;
	}

	if(l != r ) {
	  k = abs(r - l);
	  r = r - k;
	}
printf("%d\n",(l + r + s));
} else if(r < l) {
	p = l - r;
if(p <= a) {
	s = a - p;
	r = r + p;
	} else {
		r = r + a;
	}

	if(l != r ) {
	  k = abs(r - l);
	  l = l - k;
	}
printf("%d\n",(l + r + s));
} else {
	if(a % 2 == 0)
		printf("%d\n",(l + r + a));
	else
		printf("%d\n",(l + r + a -1 ));
}
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int n,j,b,l,r,a,sum;
    scanf("%d %d %d",&l,&r,&a);
    if(l==r)
    {
        l=l+a/2;
        r=r+a/2;
    }
    else if(r>l && r<=a)
    {
        a=r-l;
        l=r+a/2;
        r=r+a/2;
    }
    else if(r>l && r>a)
    {
        l=l+a;
        r=l;
    }
    else if(l>r && l>a)
    {
        r=r+a;
        l=r;
    }
    else if(l>r && l<=a)
    {
        a=l-r;
        r=l+a/2;
        l=l+a/2;
    }
    sum=l+r;
    printf("%d\n",sum);

    return 0;
}

#include<stdio.h>
int main(){
    int a,b,c,t,r;
    scanf("%d%d%d",&a,&b,&c);

    if(b>a){
       t=a;
       a=b;
       b=t;
    }
    again:
    if(a==b){
        r=2*(a+c/2);
    }
    else if(b+c<a){
        r=2*(b+c);
    }
    else{

        c=c-a+b;
        b=a;
        goto again;
    }
    if(a==0||b==0){
        r=0;
    }
    printf("%d",r);

    return 0;
}

#include<stdio.h>
int main()
{
         int l,r,a,ctr,min,min1,d,max;
         scanf("%d%d%d",&l,&r,&a);
         if(l==r)
         {
                   if(a%2!=0)a-=1;
                   ctr = l+r+a;
         }
         else
         {
                   min = l<r ? l:r;
                   max = l>r ? l:r;
                   d = max - min;
                   min1 = d<a ? d:a;
                   ctr = (min*2) + (min1*2);
         }
         printf("%d\n",ctr);
}

#include <stdio.h>
int main() {
    int l, r, a, ans;
    scanf("%d%d%d", &l, &r, &a);
    int delta = (l > r) ? l - r : r - l;
    if (delta > a) {
        ans = (l > r) ? r : l + a;
    } else {
        a -= delta;
        a /= 2;
        ans = (l > r) ? l : r + a;
    }
    printf("%d\n", 2 * ans);

    return 0;
}

#include <stdio.h>

int main()
{
   unsigned int l, r, a;
   scanf("%u%u%u", &l, &r, &a);

   unsigned delta = 0;
   if(r > l){
       delta = r - l;
       delta = delta > a ? a : delta;
       l += delta;
       a -= delta;
   }else
   if(l > r)
   {
       delta = l - r;
       delta = delta > a ? a : delta;
       r += delta;
       a -= delta;
   }
   unsigned max_team_size = (l + a/2) * 2;
   printf("%d", max_team_size);
   return 0;
}

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

int main()
{
    int r,l,a;

    scanf("%d%d%d", &r,&l,&a);

    int t = r+l+a;

    if(r !=0 || l!=0)
    {
        if(t%2==0)
            printf("%d", t);
        else{
            t--;
            printf("%d", t);
        }
    }
    else
        printf("%d", 0);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h>

int main(){

     int l, r, a;
     int count;
     scanf("%d %d %d", &l, &r, &a);

     if(l==0 && a==0){
            count=0;
            printf("%d", count);
            return 0;
     }
     if(r==0 && a==0){
            count=0;
            printf("%d", count);
            return 0;
     }
     if(r==0 && l==0){
            count=a;
            printf("%d", count);
            return 0;
     }

     while(1){
        if(a==0)
            break;

         if(l<r){
                l++;
                a--;
         }else if(l>=r){
                r++;
                a--;
         }
     }

    if(l>r){
      count=2*r;
    }else if(l<=r){
      count=2*l;
    }

    printf("%d",count);

     return 0;
}

#include<stdio.h>
int main()
{
    int n,i,j,a,b,c,x;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b)
    {
        i=c/2;
        a=a+i;
        b=b+i;
        x=a+b;
    }
    else if(a>b)
    {
        b=b+c;
        if(b>a)
        {
            while(a!=b)
            {
            b=b-1;
            a=a+1;
            }
        }
        else if(b<a)
        {
            while(a!=b)
            {
                a=a-1;
            }
        }
        x=a+b;

    }
    else
    {
        a=a+c;
        if(b>a)
        {
            while(b!=a)
            {
                b=b-1;
            }
        }
        else if(b<a)
        {
            while(a!=b)
            {
                a=a-1;
                b=b+1;
            }
        }
        x=a+b;
    }
    printf("%d",x);
    return 0;
}

#include<stdio.h>
int main()
{
    int l,r,a,big,small,total,c,b,k,m;
    scanf("%d %d %d",&l,&r,&a);
    b=a%2;
    if(l==r)
        {total=l+r+((a-b));
        printf("%d",total);
        return 0;
        end(0);}
    else if(l>r)
        {big=l;
        small=r;}
    else
        {small=l;
        big=r;}

    c=small+a;
    if(big>=c)
        {total=2*c;
        printf("%d",total);
        return 0;
        end(0);}
    else
        {   k=big-small;
            m=a-k;
            {
                if(m>0)
                    m=m;
                else
                    m=-m;
            }
            total=(2*big)+m;
            printf("%d",total);
            return 0;
            end(0);
        }
}

#include<stdio.h>

int main()
{
	int l, r, a, tmp=0;
	scanf("%d %d %d", &l, &r, &a);

	int total=0;

	if((l==0 && a==0)|| (r==0 && a==0))
		total=0;

	else if(l==0)
	{
		if(r>=a)
			total=2*a;
		else
		{
			total=2*r;
			tmp=a-r;
			if(tmp%2==0)
				total=total+a;
			else
				total=total+a-1;
		}
	}

	else if(r==0)
	{
		if(l>=a)
			total=2*a;
		else
		{
			total=2*l;
			tmp=a-l;
			if(tmp%2==0)
				total=total+a;
			else
				total=total+a-1;
		}
	}

	else if(l>r)
	{
		if((r+a)<l)
			total=2*(r+a);

		else if((r+a)>l)
		{
			tmp=l-r;
			total=(2*l);
			a=a-tmp;
			if(a%2==0)
				total=total+a;
			else
				total=total+a-1;
		}
	}

	else if(r>l)
	{
		if((l+a)<r)
			total=2*(l+a);

		else if((l+a)>r)
		{
			tmp=r-l;
			total=(2*r);
			a=a-tmp;
			if(a%2==0)
				total=total+a;
			else
				total=total+a-1;
		}
	}

	else
	{
		total=2*r;
		if(a%2==0)
			total=total+a;
		else
			total=total+a-1;
	}
	printf("%d", total);
}

#include <stdio.h>

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for((i) = 0; (i) < (n); (i)++)
#define REP1(i, n) for((i) = 1; (i) <= (n); (i)++)

static int min(int a, int b)
{
    if (a < b)
        return a;
    return b;
}

static int max(int a, int b)
{
    if (a > b)
        return a;
    return b;
}

int main(void)
{
    int l, r, a;

    scanf("%d %d %d", &l, &r, &a);
    if (l == r) {
        printf("%d", (l + a / 2) * 2);
    } else if (l < r) {
        printf("%d", (l + min(r - l, a) + max(0, (a - min(r - l, a)))) * 2);
    } else {
        printf("%d", (r + min(l - r, a) + max(0, (a - min(l - r, a)))) * 2);
    }

    return 0;
}

#include<stdio.h>
int main()
{
	int l,x,m,r,a,n;
	scanf("%d%d%d",&l,&r,&a);
	if(l==r)
	{   start:
		if(a%2!=0 && a!=0)
	{	x=l+r+a-1;}
		else
	{	x=l+r+a; }
	printf("%d\n",x);
	}
	else if(l>r)
	{m=l-r;
	if(a-m>0)
	r=r+m;
	a=a-m;
	goto start;}

	else if(l<r)
	{
	m=r-l;
	if(a-m>0)
	l=l+m;
	a=a-m;
	goto start;
	}

}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
 long long compare (const void * a, const void * b)
{
    return ( *(long long *)a - *(long long *)b );
}
int main(void){

long long int test,i,j,n,count,flag,flag2,b1,l,m,u,r,q,d,x,max,max2,min,f,sum,a,b;

scanf("%lld%lld%lld",&l,&r,&b);
if(l>r){
   b-=abs(l-r);
   if(b<=0){
       printf("%lld",2*(r+b));
   }else{
   printf("%lld",2*(b/2)+2*l);
   }
}else{
    if(l<r){
         b-=abs(l-r);
   if(b<=0){
       printf("%lld",2*(r+b));
   }else{
   printf("%lld",2*(b/2)+2*r);
   }
    }else{
        printf("%lld",2*r+(b/2)*2);
    }
}

    return 0;
}

#include<stdio.h>
main()
{
    int l,r,a,d, large,small;

    scanf("%d%d%d",&l,&r,&a);
    if(l==0 || r==0)
       {
           printf("0");
       }

    else
    {
         if(l>r)
    {
        large=l;
        small=r;
    }
    else
    {
        large=r;
        small=l;
    }
    if((small+a)<=large)
    {
        d=2*(small+a);
        printf("\n\n%d",d);

    }
    else
    {
        d=small+large+a;
        if(d%2==0)
        {
            printf("\n\n%d",d);
        }
        else
        {
            d=d-1;
            printf("\n\n%d",d);
        }
    }

    }
    return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,i,j,ans,p,q;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        p=b+c;
        q=p-a;
        if(q>0){
            ans=2*a+2*(q/2);
        }
        else{
            ans=2*b;
        }
    }
    else if(b>a){
        p=a+c;
        q=p-b;
        if(q>0){
            ans=2*b+2*(q/2);
        }
         else{
            ans=2*a;
        }
    }
    else if(a==b){
        ans=a+b+2*(c/2);
    }
    printf("%d\n",ans);
    return 0;
}

#include<stdio.h>

int main(){
	int l,r,x;
	scanf("%d %d %d",&l,&r,&x);
	int a = l+x;
	int result1 = a > r ? r : a;
	int b = r+x;
	int result2 = b > l ? l : b;
	int result3;
	if(x%2==1){
		int c = l+x/2+1, d = r+x/2;
		result3 = c > d ? d : c;
		c = l+x/2, d = r+x/2+1;
		int result4 = c > d ? d : c;
		result3 = result3 > result4 ? result3 : result4;
		// printf("%d %d\n",result3, result4);
	}
	else{
		int c = l+x/2, d = r+x/2;
		result3 = c > d ? d : c;
	}
	int max = result1 > result2 ? result1 : result2;
	max = result3 > max ? result3 : max;

	// printf("%d %d %d",result1,result2,result3);

	printf("%d",max*2);
	return 0;
}

#include<stdio.h>
int main()
{
	int l,r,a,ans;
	scanf("%d %d %d",&l,&r,&a);
	if(l==0&&a==0||r==0&&a==0)
	printf("0\n");
	else if(l+a<r)
	printf("%d\n",2*(l+a));
	else if(r+a<l)
	printf("%d\n",2*(r+a));
	else
	{
		a=a/2;
		ans=l+r+2*a;
		if(ans==1)
		printf("0\n");
		printf("%d\n",ans);
	}
	return 0;
}

#include <stdio.h>
#include <stdbool.h>
int main(void)
{
	int a=0,b=0,c=0,x;
	scanf("%d %d %d ",&a,&b,&c);
	//printf("%d %d %d ",a,b,c);
	if (a>b)
	{
		x=a;
		a=b;
		b=x;
	}
	if (a+c<=b) printf("%d",2*(a+c));
	else
	{
		printf("%d",2*b+2*((c-a)/2));
	}

	return 0;
}


John Doe has an n × m table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size n × n have exactly k points.John Doe wondered, how many distinct ways to fill the table with points are there, provided that the condition must hold. As this number can be rather large, John Doe asks to find its remainder after dividing by 1000000007 (109 + 7).You should assume that John always paints a point exactly in the center of some cell. Two ways to fill a table are considered distinct, if there exists a table cell, that has a point in one way and doesn't have it in the other.

A single line contains space-separated integers n, m, k (1 ≤ n ≤ 100; n ≤ m ≤ 1018; 0 ≤ k ≤ n2) — the number of rows of the table, the number of columns of the table and the number of points each square must contain. Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

In a single line print a single integer — the remainder from dividing the described number of ways by 1000000007 (109 + 7).

NoteLet's consider the first test case:      The gray area belongs to both 5 × 5 squares. So, if it has one point, then there shouldn't be points in any other place. If one of the white areas has a point, then the other one also must have a point. Thus, there are about 20 variants, where the point lies in the gray area and 25 variants, where each of the white areas contains a point. Overall there are 45 variants.

/* practice with Dukkha */
#include <stdio.h>

#define N	100
#define K	(N * N)
#define MD	1000000007

long long power(int a, long long k) {
	long long p;

	if (k == 0)
		return 1;
	p = power(a, k / 2);
	p = p * p % MD;
	if (k % 2)
		p = p * a % MD;
	return p;
}

int main() {
	static int ch[N + 1][N + 1], pp[N + 1][N + 1], dp[N + 1][K + 1];
	int n, k, h, i, j;
	long long m;

	scanf("%d%lld%d", &n, &m, &k);
	ch[0][0] = 1;
	for (i = 1; i <= n; i++) {
		ch[i][0] = 1;
		for (j = 1; j <= i; j++)
			ch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % MD;
	}
	for (i = 0; i <= n; i++)
		for (j = 0; j <= i; j++)
			pp[i][j] = power(ch[i][j], m / n);
	dp[0][0] = 1;
	for (i = 0; i < n; i++)
		for (j = 0; j <= k; j++) {
			int x = dp[i][j];

			if (x == 0)
				continue;
			for (h = 0; h <= n && j + h <= k; h++)
				dp[i + 1][j + h] = (dp[i + 1][j + h] + (long long) x * pp[n][h] % MD * (i < m % n ? ch[n][h] : 1)) % MD;
		}
	printf("%d\n", dp[n][k]);
	return 0;
}

#include <stdio.h>

#define maxn 111

const int mod = (int) 1e9 + 7;

long long choose[maxn][maxn];

long long f[maxn][10001];
long long g[maxn][maxn];

long long power( long long a, long long b ) {
	long long ret = 1;

	a %= mod;
	while( b > 0 ) {
		if( b % 2 ) {
			ret = (ret * a) % mod;
		}

		b /= 2;
		a = (a * a) % mod;
	}

	return ret;
}

int main( void ) {
	long long n, m, k;
	scanf("%lld %lld %lld", &n, &m, &k);

	for( int i = 0; i < maxn; i++ ) {
		choose[i][0] = choose[i][i] = 1;
		for( int j = 1; j < i; j++ ) {
			choose[i][j] = (choose[i-1][j] + choose[i-1][j-1]) % mod;
		}
	}

	for( int i = 1; i <= n; i++ ) {
		for( int c = 0; c <= n; c++ ) {
			long long count = (m / n) + (m % n >= i ? 1 : 0);
			g[i][c] = power(choose[n][c], count);
		}
	}

	f[1][0] = 1;
	for( int i = 1; i <= n; i++ ) {
		for( int j = 0; j <= k; j++ ) if( f[i][j] > 0 ) {
			for( int c = 0; c <= n; c++ ) {
				if( j + c > k ) break;
				long long nways = (g[i][c] * f[i][j]) % mod;
				f[i+1][j+c] = (f[i+1][j+c] + nways) % mod;
			}
		}
	}

	printf("%lld\n", f[n+1][k]);

	return 0;
}

#include <stdio.h>

long long pow(long long x, long long y, long long z)
{
    long long p = 1;

    while (y) {
        if (y & 1) p = p * x % z;

        x = x * x % z;
        y >>= 1;
    }

    return p;
}

int max(int a, int b)
{
    if (a > b) {
        return a;
    } else {
        return b;
    }
}

long long c[101][101];
long long a[101];
long long dp[101][10001];

int main()
{
    int n, k, mod = 1000000007, i, j, l;
    long long m;

    scanf("%d %I64d %d", &n, &m, &k);

    for (i = 0; i <= 100; i++) {
        c[i][0] = c[i][i] = 1;

        for (j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }

    for (i = 0; i <= n; i++) a[i] = pow(c[n][i], m / n, mod);

    dp[0][0] = 1;

    for (i = 0; i < n; i++) {
        for (j = max(0, k - (n - i) * n); j <= i * n && j <= k; j++) {
            if (dp[i][j] == 0) continue;

            for (l = 0; l <= n && j + l <= k; l++) {
                long long x = a[l];

                if (m % n > i) x = x * c[n][l] % mod;

                dp[i + 1][j + l] = (dp[i + 1][j + l] + dp[i][j] * x % mod) % mod;
            }
        }
    }

    printf("%I64d\n", dp[n][k]);

    return 0;
}

#include<stdio.h>
#define mod 1000000007
long long f[200][200],dp[101][10001];
long long calc_pow(long long base , long long power)
{
    if(power == 0) return 1;

    long long half = calc_pow(base , power/2);

    if(power % 2)
        return ((half * half) % mod * base) % mod;

    return (half * half) % mod;
}
main()
{
    long long n,m,i,j,k,s;
    scanf("%I64d%I64d%I64d",&n,&m,&s);

    for(i=0; i<=100; i++)
        f[i][0] = 1;

    for(i=1; i<=100; i++)
        for(j=1; j<=i; j++)
            f[i][j] = (f[i-1][j] + f[i-1][j-1]) % mod ;

    long long pow[200][200];

    for(i=1; i<=n; i++)
        for(j=0; j<=n; j++)
            pow[i][j] = calc_pow(f[n][j] , (m-i)/n+1);

    for(i=0; i<=n; i++)dp[n][i] = pow[n][i];

    for(i=n-1; i>=1; i--)
    {
        for(j=0; j<=(n-i+1)*n ; j++)
        {
          for(k=0; k<=n; k++)
          {
              if(j - k <= (n-i)*n)
                dp[i][j] = (dp[i][j] + (pow[i][k] * dp[i+1][j-k] ) % mod )% mod;
          }
        }
    }

    printf("%I64d",dp[1][s]);

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<memory.h>
#include<assert.h>
#include<ctype.h>

typedef long long ll;

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(k) (((k)>0)?(k):(-(k)))
#define sqr(k) ((k)*(k))
#define swap(a,b) a^=b^=a^=b
#define mod(a,b) (((a)%(b)+(b))%(b))
#define mode(a,b) a=mod(a,b)
#define mset(a) memset(a,0,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define inf 1000000000
#define linf 1000000000000000000LL
#define pi 3.14159265358979323846

void fileio_in_out()
{
     freopen(".in","r",stdin);
     freopen(".out","w",stdout);
}

void fileio_txt()
{
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
}

//==================================================

const ll md=1000000007LL;

int n=0;
int i,j,k,l;
ll m,t;
ll cnk[111][111],f[111][2],dp[111][11111];

ll pw(ll x,ll y)
{
   ll i,t=1;

   for(i=1LL<<62;i;i>>=1)
     {
       t=(t*t)%md;
       if(i&y)
         t=(t*x)%md;
     }

   return t;
}

int main()
{
    //fileio_in_out();
    //fileio_txt();

    scanf("%d%I64d%d",&n,&m,&k);

    for(i=0;i<=n;i++)
      {
        cnk[i][0]=cnk[i][i]=1;
        for(j=1;j<i;j++)
          cnk[i][j]=(cnk[i-1][j-1]+cnk[i-1][j])%md;
      }

    for(i=0;i<=n;i++)
      {
        f[i][0]=pw(cnk[n][i],m/n);
        f[i][1]=pw(cnk[n][i],m/n+1);
      }

    mset(dp);
    dp[0][0]=1;
    for(i=0;i<n;i++)
      for(j=0;j<=k;j++)
        for(l=0;l<=n;l++)
          {
            t=(i<m%n)?f[l][1]:f[l][0];
            dp[i+1][j+l]=(dp[i+1][j+l]+t*dp[i][j])%md;
          }

    printf("%I64d\n",dp[n][k]);

    //system("pause");
    return 0;
}

#include <stdio.h>
#define MOD (1000000007ULL)
#define min(a, b)  ( ((a) < (b)) ? (a) : (b) )

unsigned long long cnk[101][101], pows[101], pows2[101][101], dp[101][10001];

unsigned long long quick_pow(unsigned long long a, unsigned long long n)
{
    if (n == 0) {
        return 1;
    } else if ((n & 1ULL) == 0) {
        unsigned long long tmp = quick_pow(a, n / 2ULL);
        return (tmp * tmp) % MOD;
    } else {
        return (quick_pow(a, n - 1) * a) % MOD;
    }
}

void count_cnk(void)
{
    int i, j;
    cnk[0][0] = 1;
    for(i = 1; i < 101; ++i){
        cnk[i][0] = 1;
        for(j = 1; j < 101; ++j){
            cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;
        }
    }
}

int
main(void)
{
    int i, j, t;
    unsigned long long n, m, k;

    count_cnk();

    scanf("%I64u%I64u%I64u", &n, &m, &k);

    unsigned long long rem =  m % n;
    for (i = 1; i <= n; ++i) {
        if (rem) {
            pows[i] = m / n + 1;
            --rem;
        } else {
            pows[i] = m / n;
        }
        for (j = 0; j <= n; ++j) {
            pows2[i][j] = quick_pow(cnk[n][j], pows[i]);
        }
    }

    dp[0][0] = 1;
    for (i = 1; i <= n; ++i) {
        for (j = 0; j <= min(k, i * n); ++j) {
            for (t = 0; t <= min(n, j); ++t) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - t] * pows2[i][t]) % MOD;
            }
        }
    }

    printf("%I64u", dp[n][k]);
    return 0;
}

#include <stdio.h>

#define maxn 111

const int mod = (int) 1e9 + 7;

long long choose[maxn][maxn];

long long f[maxn][1001];
long long g[maxn][maxn];

long long power( long long a, long long b ) {
	long long ret = 1;

	a %= mod;
	while( b > 0 ) {
		if( b % 2 ) {
			ret = (ret * a) % mod;
		}

		b /= 2;
		a = (a * a) % mod;
	}

	return ret;
}

int main( void ) {
	long long n, m, k;
	scanf("%lld %lld %lld", &n, &m, &k);

	for( int i = 0; i < maxn; i++ ) {
		choose[i][0] = choose[i][i] = 1;
		for( int j = 1; j < i; j++ ) {
			choose[i][j] = (choose[i-1][j] + choose[i-1][j-1]) % mod;
		}
	}

	for( int i = 1; i <= n; i++ ) {
		for( int c = 0; c <= n; c++ ) {
			long long count = (m / n) + (m % n >= i ? 1 : 0);
			g[i][c] = power(choose[n][c], count);
		}
	}

	f[1][0] = 1;
	for( int i = 1; i <= n; i++ ) {
		for( int j = 0; j <= k; j++ ) if( f[i][j] > 0 ) {
			for( int c = 0; c <= n; c++ ) {
				if( j + c > k ) break;
				long long nways = (g[i][c] * f[i][j]) % mod;
				f[i+1][j+c] = (f[i+1][j+c] + nways) % mod;
			}
		}
	}

	printf("%lld\n", f[n+1][k]);

	return 0;
}

#include <stdio.h>
#define MOD 1000000007
#define min(a, b)  ( ((a) < (b)) ? (a) : (b) )

unsigned long long cnk[101][101], pows[101], pows2[101][101], dp[101][101];

unsigned long long quick_pow(unsigned long long a, unsigned long long n)
{
    if (n == 0) {
        return 1;
    } else if ((n & 1ULL) == 0) {
        unsigned long long tmp = quick_pow(a, n / 2ULL);
        return (tmp * tmp) % MOD;
    } else {
        return (quick_pow(a, n - 1) * a) % MOD;
    }
}

int
main(void)
{
    int n, k;
    unsigned long long m;
    scanf("%d%I64u%d", &n, &m, &k);
    cnk[0][0] = 1;

    int i, j, t;
    for(i = 1; i < 101; ++i){
        cnk[i][0] = 1;
        for(j = 1; j < 101; ++j){
            cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;
        }
    }

    unsigned long long rem =  m % n;
    for (i = 1; i <= n; ++i) {
        if (rem) {
            pows[i] = m / n + 1;
            --rem;
        } else {
            pows[i] = m / n;
        }
        for (j = 0; j <= n; ++j) {
            pows2[i][j] = quick_pow(cnk[n][j], pows[i]);
        }
    }

    //printf("OPPA!");

    dp[0][0] = 1;
    for (i = 1; i <= n; ++i) {
        for (j = 0; j <= min(k, i * n); ++j) {
            for (t = 0; t <= min(n, j); ++t) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - t] * pows2[i][t]) % MOD;
            }
        }
    }

    printf("%I64u", dp[n][k]);
    return 0;
}