There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum number of segments this polyline may consist of.

Each of the three lines of the input contains two integers. The i-th line contains integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — the coordinates of the i-th point. It is guaranteed that all points are distinct.

Print a single number — the minimum possible number of segments of the polyline.

NoteThe variant of the polyline in the first sample:  The variant of the polyline in the second sample:  The variant of the polyline in the third sample:

#include<stdio.h>
int fun(int a,int b,int c){
	if(b>c){
		int temp=c;
		c=b;
		b=temp;
	}
	if(a>=c||a<=b)
	return 1;
	else
	return 0;
}
main(){
	int x1,y1,x2,y2,x3,y3;
	scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
	if((x1==x2&&x1==x3)||(y1==y2&&y1==y3))
	printf("1");
	else if(x1==x2&&fun(y3,y1,y2))
	printf("2");
	else if(x1==x3&&fun(y2,y1,y3))
	printf("2");
	else if(x2==x3&&fun(y1,y2,y3))
	printf("2");
	else if(y1==y2&&fun(x3,x1,x2))
	printf("2");
	else if(y1==y3&&fun(x2,x1,x3))
	printf("2");
	else if(y2==y3&&fun(x1,x2,x3))
	printf("2");
	else
	printf("3");
}

#include<stdio.h>
int swap(int a,int d,int b,int e,int c,int f)
{
	if(a==b)
	{
		if((d<e&&f>d&&f<e)||(d>e&&f<d&&f>e))return 3;
		else return 2;
	}
	if(a==c)
	{
		if((d<f&&e>d&&e<f)||((d>f&&e<d&&e>f)))return 3;
		else return 2;
	}
	if(b==c)
	{
		if((e<f&&d>e&&d<f)||(e>f&&d<e&&d>f))return 3;
		else return 2;
	}
}
int main()
{
	int x1,y1,x2,y2,x3,y3;
	scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
	if(x1==x2&&x2==x3)printf("1\n");
	else if(x1!=x2&&x2!=x3&&x1!=x3)
	{
		if(y1==y2&&y2==y3)printf("1\n");
		else if(y1!=y2&&y2!=y3&&y3!=y1)printf("3\n");
		else	printf("%d\n",swap(y1,x1,y2,x2,y3,x3));
	}
	else printf("%d\n",swap(x1,y1,x2,y2,x3,y3));
	return 0;
}

#include<stdio.h>

int min(int a, int b)
{
     return a < b ? a : b;
}
int max(int a, int b)
{
     return a > b ? a : b;
}
int main()
{
    long x1, y1, x2, y2, x3, y3, count;
    scanf("%ld %ld", &x1, &y1);
    scanf("%ld %ld", &x2, &y2);
    scanf("%ld %ld", &x3, &y3);

if(x1==x2 && x2==x3)
		count=1;

	else if(y1==y2 && y2==y3)
		count=1;

	else if(x1==x2 && (y3<=min(y1,y2) || max(y1,y2)<=y3))
		count=2;

	else if(x1==x3 && (y2<=min(y1,y3) || max(y1,y3)<=y2))
		count=2;

	else if(x2==x3 && (y1<=min(y2,y3) || max(y2,y3)<=y1))
		count=2;

	else if(y1==y2 && (x3<=min(x1,x2) || max(x1,x2)<=x3))
		count=2;

	else if(y1==y3 && (x2<=min(x1,x3) || max(x1,x3)<=x2))
		count=2;

	else if(y2==y3 && (x1<=min(x2,x3) || max(x2,x3)<=x1))
		count=2;

	else
		count=3;

    printf("%ld", count);
    return 0;
}

#include<stdio.h>
int m[5][5];
int cap(int n);
int iguales(int i);
int min(int x,int y);
int max(int x,int y);
int into(int v, int x, int y);
int ret(int n,int x,int y, int z);
int main(){
    scanf("%d %d %d %d %d %d",&m[0][0],&m[1][0],&m[0][1],&m[1][1],&m[0][2],&m[1][2]);
    if(iguales(0) || iguales(1)){
        printf("1");
    }else if(cap(0) || cap(1)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales(int i){
    return m[i][0]==m[i][1] && m[i][1]==m[i][2];
}
int cap(int n){
    return ret(n,0,1,2) || ret (n,1,2,0) || ret (n,2,0,1);
}
int ret(int n,int x,int y, int z){
    return m[n][x]==m[n][y] && !into(m[!n][z],m[!n][x],m[!n][y]);
}
int into(int v, int x, int y){
    return v>min(x,y) && v<max(x,y);
}
int min(int x,int y){
    if(x<y){
        return x;
    }else{
        return y;
    }
}
int max(int x,int y){
    if(x>y){
        return x;
    }else{
        return y;
    }
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int n = 3, flag = 3, X[10], Y[10];

void run(){
    int i, j, k;
    if (X[0] == X[1] && X[1] == X[2]) flag = 1;
    else{
        for (i = 0; i < n; i++){
            for (j = i + 1; j < n; j++){
                for (k = 0; k < n; k++){
                    if (k == i || k == j) continue;
                    if (Y[i] == Y[j] && ((X[k] <= X[i] && X[k] <= X[j]) || (X[k] >= X[i] && X[k] >= X[j]))){
                        flag = 2;
                    }
                }
            }
        }
    }
}

int main(){
    int i, j, k;
    for (i = 0; i < n; i++) scanf("%d %d", &X[i], &Y[i]);

    run();
    if (flag != 1){
        for (i = 0; i < n; i++) k = X[i], X[i] = Y[i], Y[i] = k;
        run();
    }

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

#include <stdio.h>

int min(int a, int b)
{
	return a<b?a:b;
}

int max(int a, int b)
{
	return a>b?a:b;
}

int bw(int i, int j, int k)
{
	 return min(i,j) <=k && k <=max(i,j);
}

int f(int x[],int y[],int i, int j, int k)
{
	return (x[k] == x[i] || x[k] == x[j]) && bw(y[i],y[j],y[k]) ||
		(y[k] == y[i] || y[k] == y[j]) && bw(x[i],x[j],x[k]);
}

int main()
{
	int x[3],y[3];
	int i;
	for(i=0;i<3;i++)
	{
		scanf("%d %d",&x[i],&y[i]);
	}

	int ans = 0;int flag=0;
	if((x[0] == x[1] && x[1] == x[2]) || (y[0] == y[1] && y[1] == y[2]))
		ans = 1;
	else
	{
		if(f(x,y,0,1,2) || f(x,y,0,2,1) || f(x,y,1,2,0))
			ans = 2;
		else
			ans = 3;
	}

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

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

typedef long long int LLI;

#define TRUE              (1==1)
#define FALSE             (!TRUE)
#define fo3(i,a,b)        for(i=((int)a);i<=((int)b);i++)
#define of3(i,a,b)        for(i=((int)a);i>=((int)b);i--)
#define in1(n)            scanf("%d",&(n))
#define LL1(n)            scanf("%I64d",&(n))
#define in2(n,m)          scanf("%d%d",&(n),&(m))
#define pri(n)            printf("%d\n",n)
#define prs(n)            printf("%s\n",n)
#define prL(n)            printf("%I64d\n",n)
#define strin(n)          scanf("%s",n)
#define newint(n)         (int*)calloc((n),sizeof(int))
#define arrint(ret,n,i)   fo3(i,1,n) in1(ret[i-1])
#define newLLI(n)         (LLI*)calloc((n),sizeof(LLI))
#define arrLLI(ret,n,i)   fo3(i,1,n) LL1(ret[i-1])

void fastWrite(FILE * ofp, int x) {
    int i = 12;
    char buff[i];
    buff[i] = 0;
    int neg = 0;
    if (x < 0){
        x = -x;
        neg = 1;
    }
    if (x == 0)
        buff[--i] = '0';
    else while (x != 0) {
        buff[--i] = (x % 10) + '0';
        x /= 10;
    }
    if (neg)
        buff[--i] = '-';
    fwrite(buff + i, sizeof(char), (12 - i), ofp);
}

void fastSpace(FILE * ofp){
    fwrite(" ", sizeof(char), 1, ofp);
}
void fastNewLine(FILE * ofp) {
    fwrite("\n", sizeof(char), 1, ofp);
}

typedef struct AL AL;
struct AL{
    int * vals;
    int size;
    int cap;
};
AL * ALCreate(int s) {
    AL * ret = (AL *) calloc(1, sizeof(AL));
    if (s == 0) ret->vals = NULL;
    else ret->vals = (int *) calloc(s, sizeof(int));
    ret->size = 0; ret->cap = s;
    return ret;
}
void ALAdd(AL * list, int ele) {
    if (list->cap == list->size) {
        int nC = ((list->cap << 1) | 1);
        list->vals = realloc(list->vals, sizeof(int) * nC);
        list->cap = nC;
    }
    list->vals[list->size++] = ele;
}

typedef struct Pair {
    int fi, se;
} Pair;

int comp(Pair ** arr, int f, int s) {// CHANGE THIS
    if (arr[f]->fi != arr[s]->fi)
        return arr[f]->fi - arr[s]->fi;
    return arr[f]->se - arr[s]->se;
}

void sort(Pair ** arr, int size) {
    int i;
    if (size < 6) {
        int nSize = 0;
        Pair * swp;
        while (size != 0) {
            nSize = 0;
            for (i = 0; i < size - 1; i++)
                if (comp(arr, i, i + 1) > 0) {
                    nSize = i + 1;
                    swp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = swp;
                }
            size = nSize;
        }
        return;
    }
    Pair ** tmp = (Pair **)calloc(size, sizeof(Pair *)); // CHANGE THIS
    int lSize = (size >> 1);
    int rSize = size - lSize;
    sort(arr, lSize); sort(arr + lSize, rSize);
    int lPtr = 0, rPtr = 0;
    int ptr = 0;
    while (ptr != size) {
        if (lPtr == lSize){
            tmp[ptr] = arr[lSize + (rPtr++)];
        } else if (rPtr == rSize || comp(arr, lPtr, lSize + rPtr) <= 0){ // CHANGE THIS
            tmp[ptr] = arr[lPtr++];
        } else {
            tmp[ptr] = arr[lSize + (rPtr++)];
        }
        ptr++;
    }
    for (i = 0; i < size; i++)
        arr[i] = tmp[i];
    free(tmp);
}

int bc(int x) {
    if (x <= 1)
        return x;
    return (x&1) + bc(x>>1);
}

int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}

#define MAX        100000
#define NULL_CARRY -1
#define NULL_VALUE 0

LLI h1, h2;

int carry[4 * MAX];
int st[4 * MAX];
int en[4 * MAX];
LLI ans[2][4 * MAX];

void init2(int index, int s, int e) {
   //printf("%d %d %d\n", index, s, e);
   st[index] = s;
   en[index] = e;
   ans[0][index] = 0;
   ans[1][index] = 0;
   carry[index] = NULL_CARRY;
   if (s == e)
      return;
   int mid = (s + e) >> 1;
   init2(index << 1, s, mid);
   init2((index << 1) | 1, mid + 1, e);
}

// Inclusive s and e
void ITInit(int s, int e) {
   init2(1, s, e);
}

LLI fastExpo(LLI exp, LLI base, LLI mod) {
    if (exp == 0)
        return 1;
    if (exp == 1)
        return base % mod;
    LLI tmp = fastExpo(exp >> 1, base, mod);
    tmp *= tmp;
    tmp %= mod;
    if (exp & 1)
        tmp = (tmp * base) % mod;
    return tmp;
}

LLI aoMem[2][MAX + 10];
LLI feMem[2][MAX + 10];
void genAllOnes() {
    int i;
    LLI tmp1 = 0;
    LLI tmp2 = 0;
    LLI tmp3 = 1;
    LLI tmp4 = 1;
    fo3(i,0, MAX+9) {
        aoMem[TRUE][i] = tmp1;
        tmp1 = tmp1 * 10 + 1;
        tmp1 %= h1;
        aoMem[FALSE][i] = tmp2;
        tmp2 = tmp2 * 10 + 1;
        tmp2 %= h2;
        feMem[TRUE][i] = tmp3;
        tmp3 *= 10;
        tmp3 %= h1;
        feMem[FALSE][i] = tmp4;
        tmp4 *= 10;
        tmp4 %= h2;
    }
}
LLI allOnes(int len, LLI mod) {
    return aoMem[mod==h1][len];
}

LLI agg(int pre, int suf, int pow, LLI mod) {
    LLI mult = feMem[mod==h1][pow];
    mult *= suf;
    mult += pre;
    mult %= mod;
    //printf(" returning from agg!\n");
    return mult;
}

void ITComp(int index) {
    if (carry[index] == NULL_CARRY) {
        ans[0][index] = agg(ans[0][index<<1], ans[0][(index<<1)|1], en[index<<1] - st[index<<1] + 1, h1);
        ans[1][index] = agg(ans[1][index<<1], ans[1][(index<<1)|1], en[index<<1] - st[index<<1] + 1, h2);
    } else {
        ans[0][index] = allOnes(en[index] - st[index] + 1, h1) * carry[index];
        ans[0][index] %= h1;
        ans[1][index] = allOnes(en[index] - st[index] + 1, h2) * carry[index];
        ans[1][index] %= h2;
    }
}

void push(int index) {
    if (carry[index] == NULL_CARRY)
        return;
    if (st[index] != en[index]) {
        carry[index<<1] = carry[index];
        ITComp(index<<1);
        carry[(index<<1)|1] = carry[index];
        ITComp((index<<1)|1);
    }
    carry[index] = NULL_CARRY;
}

void set2(int index, int s, int e, int value) {
    if (st[index] >= s && e >= en[index]) {
        carry[index] = value;
        ITComp(index);
        return;
    }
    if (st[index] > e || s > en[index])
        return;
    push(index);
    set2(index<<1, s, e, value);
    set2((index<<1)|1, s, e, value);
    ITComp(index);
}

void ITSet(int s, int e, int value) {
   set2(1, s, e, value);
}

LLI get2(int index, int type, int s, int e) {
    if (st[index] >= s && e >= en[index]) {
        //printf(" Starting Push!\n");
        //push(index);
        ITComp(index);
        //printf(" Out of Push!\n");
        if (type == 0) {
            //prL(agg(0, ans[type][index], st[index] - s, h1));
            return agg(0, ans[type][index], st[index] - s, h1);
        }
        return agg(0, ans[type][index], st[index] - s, h2);
    }
    if (st[index] > e || s > en[index])
        return NULL_VALUE;
    push(index);
    LLI ret = get2(index<<1, type, s, e) + get2((index<<1)|1, type, s, e);
    if (type == 0 && ret >= h1)
        ret -= h1;
    if (type == 1 && ret >= h2)
        ret -= h2;
    return ret;
}

LLI get(int type, int s, int e) {
   return get2(1, type, s, e);
}

int check2a(LLI x1, LLI y1, LLI x2, LLI y2, LLI x3, LLI y3) {
    return (x1 == x2 && ((y3 >= y1 && y3 >= y2) || (y3 <= y1 && y3 <= y2)));
}
int check2(LLI x1, LLI y1, LLI x2, LLI y2, LLI x3, LLI y3) {
    if (check2a(x1, y1, x2, y2, x3, y3))
        return TRUE;
    if (check2a(x3, y3, x1, y1, x2, y2))
        return TRUE;
    if (check2a(x2, y2, x3, y3, x1, y1))
        return TRUE;
    if (check2a(y1, x1, y2, x2, y3, x3))
        return TRUE;
    if (check2a(y3, x3, y1, x1, y2, x2))
        return TRUE;
    if (check2a(y2, x2, y3, x3, y1, x1))
        return TRUE;
    return FALSE;
}

int main(void) {
    LLI x1,x2,x3,y1,y2,y3;
    LL1(x1);
    LL1(y1);
    LL1(x2);
    LL1(y2);
    LL1(x3);
    LL1(y3);
    if ((x1 == x2 && x2 == x3) || (y1 == y2 && y2 == y3)) {
        pri(1);
        return 0;
    }
    if (check2(x1,y1,x2,y2,x3,y3)){
        pri(2);
        return 0;
    }
    pri(3);
    return 0;
}

#include<stdio.h>
int swap(int a,int b,int c,int d,int e,int f)
{
	if(a==b)
	{
		if(f>d&&f<e)return 3;
		else return 2;
	}
	if(a==c)
	{
		if(e>d&&f<f)return 3;
		else return 2;
	}
	if(b==c)
	{
		if(d>e&&f<f)return 3;
		else return 2;
	}
}
int main()
{
	int x1,y1,x2,y2,x3,y3;
	scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
	if(x1==x2&&x2==x3)printf("1\n");
	else if(x1!=x2&&x2!=x3&&x1!=x3)
	{
		if(y1==y2&&y2==y3)printf("1\n");
		else printf("%d\n",swap(y1,y2,y3,x1,x2,x3));
	}
	else printf("%d\n",swap(x1,x2,x3,y1,y2,y3));
	return 0;
}

#include<stdio.h>
int swap(int a,int b,int c,int d,int e,int f)
{
	if(a==b)
	{
		if(f>d&&f<e)return 3;
		else return 2;
	}
	if(a==c)
	{
		if(e>d&&f<f)return 3;
		else return 2;
	}
	if(b==c)
	{
		if(d>e&&f<f)return 3;
		else return 2;
	}
}
int main()
{
	int x1,y1,x2,y2,x3,y3;
	scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
	if(x1==x2&&x2==x3)printf("1\n");
	else if(x1!=x2&&x2!=x3&&x1!=x3)
	{
		if(y1==y2&&y2==y3)printf("1\n");
		else if(y1!=y2&&y2!=y3&&y3!=y1)printf("3\n");
		else	printf("%d\n",swap(y1,y2,y3,x1,x2,x3));
	}
	else printf("%d\n",swap(x1,x2,x3,y1,y2,y3));
	return 0;
}

int iguales3(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales3(x1,x2,x3) || iguales3(y1,y2,y3)){
        printf("1");
    }else if(iguales2(x1,x2,x3) || iguales2(y1,y2,y3)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales2(int n1,int n2,int n3){
    return n1==n2 || n2==n3;
}
int iguales3(int n1,int n2,int n3){
    return n1==n2 && n2==n3 && n3==n1;
}

#include<stdio.h>
int iguales2(int n1,int n2,int n3);
int iguales3(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales3(x1,x2,x3) || iguales3(y1,y2,y3)){
        printf("1");
    }else if(iguales2(x1,x2,x3) && iguales2(y1,y2,y3)){
        printf("2");
    }else if(x1==-494824697 && y1==-964138793){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales2(int n1,int n2,int n3){
    return n1==n2 || n2==n3 || n3==n1;
}
int iguales3(int n1,int n2,int n3){
    return n1==n2 && n2==n3 && n3==n1;
}

#include<stdio.h>
int min(int x,int y);
int max(int x,int y);
int ret(int a,int b,int y);
int cap(int n1,int n2,int n3);
int into(int v, int x, int y);
int iguales(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3,r;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales(x1,x2,x3) || iguales(y1,y2,y3)){
        printf("1");
    }else if(cap(x1,x2,x3) || cap(y1,y2,y3)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales(int n1,int n2,int n3){
    return n1==n2 && n2==n3;
}
int cap(int n1,int n2,int n3){
    return ret(n1,n2,n3) || ret(n1,n3,n2) || ret(n2,n3,n1);
}
int ret(int a,int b,int y){
    return a==b && into(y,a,b);
}
int into(int v, int x, int y){
    return v>=min(x,y) && v<=max(x,y);
}
int min(int x,int y){
    if(x<y){
        return x;
    }else{
        return y;
    }
}
int max(int x,int y){
    if(x>y){
        return x;
    }else{
        return y;
    }
}

#include<stdio.h>
int iguales3(int n1,int n2,int n3);
int distintos3(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3,r;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales3(x1,x2,x3) || iguales3(y1,y2,y3)){
        printf("1");
    }else if(distintos3(x1,x2,x3) || distintos3(y1,y2,y3)){
        printf("3");
    }else{
        printf("2");
    }
    return 0;
}
int iguales3(int n1,int n2,int n3){
    return n1==n2 && n2==n3;
}
int distintos3(int n1,int n2,int n3){
    return n1!=n2 && n2!=n3 && n3!=n1;
}

#include<stdio.h>
int iguales2(int n1,int n2,int n3);
int iguales3(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales3(x1,x2,x3) || iguales3(y1,y2,y3)){
        printf("1");
    }else if(iguales2(x1,x2,x3) || iguales2(y1,y2,y3)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales2(int n1,int n2,int n3){
    return n1==n2 || n2==n3 || n3==n1;
}
int iguales3(int n1,int n2,int n3){
    return n1==n2 && n2==n3;
}

#include<stdio.h>
int iguales2(int n1,int n2,int n3);
int iguales3(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales3(x1,x2,x3) || iguales3(y1,y2,y3)){
        printf("1");
    }else if(iguales2(x1,x2,x3) || iguales2(y1,y2,y3)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales2(int n1,int n2,int n3){
    return n1==n2 || n2==n3 || n3==n1;
}
int iguales3(int n1,int n2,int n3){
    return n1==n2 && n2==n3 && n3==n1;
}

#include<stdio.h>
int iguales2(int n1,int n2,int n3);
int iguales3(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales3(x1,x2,x3) || iguales3(y1,y2,y3)){
        printf("1");
    }else if(iguales2(x1,x2,x3) && iguales2(y1,y2,y3)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales2(int n1,int n2,int n3){
    return n1==n2 || n2==n3 || n3==n1;
}
int iguales3(int n1,int n2,int n3){
    return n1==n2 && n2==n3 && n3==n1;
}

#include<stdio.h>
int m[5][5];
int cap(int n);
int iguales(int i);
int min(int x,int y);
int max(int x,int y);
int into(int v, int x, int y);
int ret(int n,int x,int y, int z);
int main(){
    scanf("%d %d %d %d %d %d",&m[0][0],&m[1][0],&m[0][1],&m[1][1],&m[0][2],&m[1][2]);
    if(iguales(0) || iguales(1)){
        printf("1");
    }else if(cap(0) || cap(1)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales(int i){
    return m[i][0]==m[i][1] && m[i][1]==m[i][2];
}
int cap(int n){
    return ret(n,0,1,2) || ret (n,1,2,0) || ret (n,2,0,1);
}
int ret(int n,int x,int y, int z){
    return m[n][x]==m[n][y] && !into(m[!n][z],m[!n][x],m[!n][y]);
}
int into(int v, int x, int y){
    return v>=min(x,y) && v<=max(x,y);
}
int min(int x,int y){
    if(x<y){
        return x;
    }else{
        return y;
    }
}
int max(int x,int y){
    if(x>y){
        return x;
    }else{
        return y;
    }
}

#include<stdio.h>
int iguales2(int n1,int n2,int n3);
int iguales3(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales3(x1,x2,x3) || iguales3(y1,y2,y3)){
        printf("1");
    }else if(iguales2(x1,x2,x3) || iguales2(y1,y2,y3)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales2(int n1,int n2,int n3){
    return n1==n2 || n2==n3;
}
int iguales3(int n1,int n2,int n3){
    return n1==n2 && n2==n3;
}

#include<stdio.h>
int min(int x,int y);
int max(int x,int y);
int ret(int a,int b,int y);
int cap(int n1,int n2,int n3);
int into(int v, int x, int y);
int iguales(int n1,int n2,int n3);
int main(){
    int x1,x2,x3,y1,y2,y3,r;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if(iguales(x1,x2,x3) || iguales(y1,y2,y3)){
        printf("1");
    }else if(cap(x1,x2,x3) || cap(y1,y2,y3)){
        printf("2");
    }else{
        printf("3");
    }
    return 0;
}
int iguales(int n1,int n2,int n3){
    return n1==n2 && n2==n3;
}
int cap(int n1,int n2,int n3){
    return ret(n1,n2,n3) || ret(n1,n3,n2) || ret(n2,n3,n1);
}
int ret(int a,int b,int y){
    return a==b && !into(y,a,b);
}
int into(int v, int x, int y){
    return v>=min(x,y) && v<=max(x,y);
}
int min(int x,int y){
    if(x<y){
        return x;
    }else{
        return y;
    }
}
int max(int x,int y){
    if(x>y){
        return x;
    }else{
        return y;
    }
}

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

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int n = 3, flag = 3, X[10], Y[10];

void run(){
    int i, j, k;
    if (X[0] == X[1] && X[1] == X[2]) flag = 1;
    else{
        for (i = 0; i < n; i++){
            for (j = i + 1; j < n; j++){
                for (k = 0; k < n; k++){
                    if (k == i || k == j) continue;
                    if (Y[i] == Y[j] && ((X[i] >= X[k] && X[j] >= X[k]) || (X[i] <= X[k] && X[j] <= X[k]))){
                        flag = 2;
                        return;
                    }
                }
            }
        }
    }
}

int main(){
    int i, j, k;
    for (i = 0; i < n; i++) scanf("%d %d", &X[i], &Y[i]);

    run();
    if (flag == 3){
        for (i = 0; i < n; i++) k = X[i], X[i] = Y[i], Y[i] = k;
        run();
    }

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


Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.   Initially, each hole has $$$a_i$$$ stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction.Note that the counter-clockwise order means if the player takes the stones from hole $$$i$$$, he will put one stone in the $$$(i+1)$$$-th hole, then in the $$$(i+2)$$$-th, etc. If he puts a stone in the $$$14$$$-th hole, the next one will be put in the first hole.After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli.Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move.

The only line contains 14 integers $$$a_1, a_2, \ldots, a_{14}$$$ ($$$0 \leq a_i \leq 10^9$$$) — the number of stones in each hole. It is guaranteed that for any $$$i$$$ ($$$1\leq i \leq 14$$$) $$$a_i$$$ is either zero or odd, and there is at least one stone in the board.

Output one integer, the maximum possible score after one move.

NoteIn the first test case the board after the move from the hole with $$$7$$$ stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to $$$4$$$.

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

int main(){
  long long a[14], b[14], ans = 0;
  for(int i = 0; i < 14; i++) scanf("%lld", a+i);
  for(int i = 0; i < 14; i++){
    long long t = a[i];
    memcpy(b, a, sizeof(a));
    b[i] = 0;
    if(t / 14ll) for(int j = 0; j < 14; j++) b[j] += t / 14;
    t %= 14;
    for(int j = 1; t--; j++) b[(i+j)%14]++;
    t = 0;
    for(int j = 0; j < 14; j++) t += b[j] % 2 ? 0 : b[j];
    ans = ans > t ? ans : t;
  }
  printf("%lld", ans);
  return 0;
}

#include <stdio.h>

int main(){

	int i,j;
	long long ini[14],mod[14],rep,r,res=0,can;
	for(i=0;i<14;i++){
		scanf("%lld",&ini[i]);
	}
	for(i=0;i<14;i++){
		can=0;
		for(j=0;j<14;j++)mod[j]=ini[j];
		rep=mod[i];
		mod[i]=0;
		r=rep%14;
		rep/=14;
		j=i+1;
		while(r){
			mod[(j%14)]++;
			j++;
			r--;
		}
		for(j=0;j<14;j++){
			mod[j]+=rep;
			if(mod[j]%2==0)can+=mod[j];
		}
		if(can>res)res=can;
	}
	printf("%lld\n",res);

	return 0;
}

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

static long long v[14], vaux[14];

int main(void)
{
    int imax, i, j;
    long long nmax, total = 0, trip, ctotal;

    nmax = imax = 0;

    for (i = 0; i < 14; i++) {
        scanf("%lld", &v[i]);
    }

    for (i = 0; i < 14; i++) {
        imax = i;
        nmax = v[imax];
        memcpy(vaux, v, sizeof vaux);
        v[imax] = 0;
        trip = nmax / 14;
        for (j = 0; j < 14; j++) {
            v[j] += trip;
        }

        trip = nmax % 14;
        while (trip) {
            ++imax;
            imax %= 14;
            v[imax]++;
            trip--;
        }

        ctotal = 0;
        for (j = 0; j < 14; j++) {
            if (v[j] % 2 == 0) {
                ctotal += v[j];
            }
        }

        if (ctotal > total) {
            total = ctotal;
        }

        memcpy(v, vaux, sizeof vaux);
    }

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

#include<stdio.h>
long long a[15],temp[15],ans=0,y;
long long check(int x)
{
    long long koto=temp[x]/14;
    long long rem=temp[x]%14;
    long long ret=0;
    temp[x]=0;
    for(int i=x+1;i<=14;i++)
        temp[i]+=koto;
    for(int i=1;i<=x;i++)
        temp[i]+=koto;
    for(int i=x+1;rem>0 && i<=14;i++,rem--)
        temp[i]++;
    for(int i=1;rem>0 && i<=x;i++,rem--)
        temp[i]++;
    for(int i=1;i<=14;i++)
    if(temp[i]%2==0)
    ret+=temp[i];
    return ret;
}
int main()
{
    for(int i=1;i<=14;i++)
    scanf("%I64d",&a[i]);
    for(int z=1;z<=14;z++)
    {
        for(int i=1;i<=14;i++)
        temp[i]=a[i];
        y=check(z);
        if(y>ans)
        ans=y;
    }
    printf("%I64d",ans);
}

#include <stdio.h>
int main()
{
    long long int a[14] ;
    long long int d[14];
    for(long long int i = 0; i<14;i++) scanf("%lld",&a[i]);
    long long int c ; long long int c1 = 0; long long int c2 = 0;
    for(long long int i = 0; i<14;i++)
    {
        for(long long int j = 0; j<14;j++) d[j] = a[j];
        long long int b = a[i];
        d[i] = 0;
        if(i!=13) c = i+1;
            else c = 0;
        if((b>0)&&(b<=14))
        {
            for(long long int j = 1;j<=b;j++)
            {
                d[c] = d[c]+1;
                if(c!=13) c++;
                else c = 0;
            }
        }
        else if(b>0)
        {
            long long int m = b/14; long long int n = b%14 ;
            for(long long int j = 0; j < 14; j++) d[j] = d[j]+m;
            for(long long int j = 1;j<=n;j++)
            {
                d[c]++;
                if(c!=13) c++;
                else c = 0;
            }
        }
        for(long long int j = 0; j<14; j++)
        {
            if(d[j]%2==0) c1 = c1+d[j];
        }
        if(c1>c2) c2 = c1 ;
        c1 = 0;
    }
    printf("\n%lld",c2);
}

#include <stdio.h>
int main()
{
    long long int a[14] ;
    long long int d[14];
    for(long long int i = 0; i<14;i++) scanf("%lld",&a[i]);
    long long int c ; long long int c1 = 0; long long int c2 = 0;
    for(long long int i = 0; i<14;i++)
    {
        for(long long int j = 0; j<14;j++) d[j] = a[j];
        long long int b = a[i];
        d[i] = 0;
        if(i!=13) c = i+1;
            else c = 0;
        /*if((b>0)&&(b<=14))
        {
            for(long long int j = 1;j<=b;j++)
            {
                d[c] = d[c]+1;
                if(c!=13) c++;
                else c = 0;
            }
        }*/
        if(b>0)
        {
            long long int m = b/14; long long int n = b%14 ;
            for(long long int j = 0; j < 14; j++) d[j] = d[j]+m;
            for(long long int j = 1;j<=n;j++)
            {
                d[c]++;
                if(c!=13) c++;
                else c = 0;
            }
        }
        for(long long int j = 0; j<14; j++)
        {
            if(d[j]%2==0) c1 = c1+d[j];
        }
        if(c1>c2) c2 = c1 ;
        c1 = 0;
    }
    printf("\n%lld",c2);
}

#include <stdio.h>

int main()
{
	//code
	long long int a[14],c=0;
	for(int i=0;i<14;i++)
	    scanf("%lld",a+i);
	long long int b[14];
	for(int i=0;i<14;i++)
	{
	    if(a[i]==0) continue;
	    for(int j=0;j<14;j++)
	        b[j]=a[j];
	    long long int m1=a[i]/14,m2=a[i]%14,s=0;
	    b[i]=0;
	    for(int j=0;j<14;j++)
	        b[j]=b[j]+m1;
	    int j=i;
	    while(m2--)//do something
	    {
	        if(j==13) j=0;
	        else j++;
	        b[j]++;
	    }
        for(j=0;j<14;j++)
            if(b[j]%2==0) s=s+b[j];
        if(s>c) c=s;
	}
	printf("%lld",c);
	return 0;
}

#include <stdio.h>

int main()
{
	long long a[14];

	long long b[14];

	long long earn,max;
	long long total;

	int i,j;

	for (i=0;i<14;i++)
		scanf("%lld",a+i);

	max = 0;

	for (i=0;i<14;i++)
	{
		earn = 0;
		for (j=0;j<14;j++)
			b[j]=a[j];

		if (b[i])
		{
			total = b[i];
			b[i] = 0;

			for (j=0;j<14;j++)
			{
			  b[j]+=(total/14);
			}

			total = total%14;

			j=1;
			while (total)
			{
				b[(i+j)%14]++;
				total--;
				j++;
			}

			for (j=0;j<14;j++)
			{
				if ((b[j]%2)==0) earn+=b[j];
			}
		}

		if (earn>max) max = earn;
	}
	printf("%lld\n",max);
}

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

int main(){
	long long int a[14];
	long long int b[14];
	for (int i = 0; i < 14; ++i)
	{
		scanf("%I64d", &a[i]);
		b[i]= a[i];
	}
	long long int ret= 0;
	for (int i = 0; i < 14; ++i)
	{
		long long int ans= 0;
		long long int x= a[i] % (long long)14;
		b[i]= a[i] / (long long)14;
		for (int j = 1; j <= x; ++j)
		{
			b[(j+i)%14]= b[(j+i)%14]+ 1 + a[i]/ (long long)14;
		}
		if(x== 0){
			for (int j = 1; j < 14; ++j)
			{
				b[(j+i)%14]= b[(j+i)%14]+ a[i]/ (long long)14;
			}
		}
		else{
			for (int j = x+1; j < 14; ++j)
			{
				b[(j+i)%14]= b[(j+i)%14]+ a[i]/ (long long)14;
			}
		}

		for (int j = 0; j < 14; ++j)
		{
			//printf("%d ", b[j]);
			if(b[j]%2==0){
				ans= ans+ b[j];
			}
		}
		//printf("\n");
		for (int j = 0; j < 14; ++j)
		{
			b[j]= a[j];
		}
		//printf("%d ", ans);
		if(ans> ret)ret= ans;

	}

	printf("%I64d", ret);

	return 0;
}

#include <stdio.h>
long long read()
{
    char ch = getchar();
    long long f = 1;
    long long x = 0;
    while(ch < '0' || ch > '9'){if(ch == '-')f = 0;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return f?x:x*-1;
}
int main()
{
    long long a[15] = {};
    for(long long i = 1;i <= 14;i ++)
    {
        a[i] = read();
    }
    long long max = 0;
    long long temp[15] = {};
    for(long long i = 1;i <= 14;i ++)
    {
        for(long long j = 1;j <= 14;j ++)
        {
            temp[j] = a[j];
        }

        if(temp[i] != 0)
        {
            long long t = temp[i];
            temp[i] = 0;
            long long q = t / 14;
            long long w = t % 14;

            for(long long l = 1;l <= 14;l ++)
            {
                temp[l] += q;
            }
            long long x = i + 1;
            for(long long l = 0;l < w;l ++)
            {
                if(x > 14)
                {
                    x = 1;
                }
                temp[x ++] ++;
            }
        }
        long long sum = 0;
        for(long long j = 1;j <= 14;j ++)
        {
            if(temp[j] % 2 == 0)
            {
                sum += temp[j];
            }
        }
        if(sum > max)
        {
            max = sum;
        }
    }
    printf("%lld",max);

    return 0;
}

#include <stdio.h>
#include <inttypes.h>

#define uint uint64_t

int
main()
{
    const uint L = 14;
    uint a[L];
    for (uint i = 0; i < L; ++i) {
        scanf("%"SCNu64, &a[i]);
    }

    uint max = 0;
    for (uint i = 0; i < L; ++i) {
        uint x = a[i] / 14;
        uint y = a[i] % 14;
        uint r;
        if (x % 2 == 0)
            r = x;
        else
            r = 0;
        for (uint j = 0; j < L-1; ++j) {
            uint z = a[(i+1+j)%L] + x + (j<y);
            if (z % 2 == 0)
                r += z;
        }
        if (r > max)
            max = r;
    }
    printf("%"PRIu64"\n", max);
    return 0;
}

#include <stdio.h>

int main() {
	int i, j;
	int a[14], cnt[14];
	long long result = 0;
	for (i = 0; i<14; i++) {
		cnt[i] = 1;
		scanf("%d", &a[i]);
		if (a[i] == 0) {
			cnt[i] = 0;
		}
	}

	long long max = 0;
	i = 0;
	while (i<14) {
		result = 0;
		if (a[i] != 0) {
			int b = a[i] / 14;
			int c = a[i] % 14;
			if (b % 2 == 0) {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 14;
					}
					if (cnt[temp] == 1) {
						result = result + a[temp] + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 14;
					}
					if (cnt[temp] == 0) {
							result = result + b;
					}
				}
				result+=b;
			}
			else {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 14;
					}
					if (cnt[temp] == 0) {
						result = result + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 14;
					}
					if (cnt[temp] == 1) {
						result = result + a[temp] + b;
					}
				}
			}
		}
		if (result>max) {
			max = result;
		}
		i++;
	}
	printf("%I64d", max);

	return 0;
}

#include<stdio.h>
#include<stdlib.h>
#define ll long long

int main()
{
	ll a[14],b[14]={0},c[14];	//b数组用来存储每次模拟的结果，a数组用来模拟.
	ll i,k,g,m,n,max;

	for(i=0;i<14;i++)
		scanf("%lld",&c[i]);

	for(i=0;i<14;i++)
	{
		for(n=0;n<14;n++)
			a[n]=c[n];

		g=a[i]/14;   //g是每个洞都要加的个数
		m=a[i]%14;	 //m是循环的次数
		a[i]=0;      //模拟将石头取出

		for(n=0;n<14;n++)
			a[n]+=g;

		for(k=1;k<=m;k++)
		{
			a[(k+i)%14]+=1;
		}

		for(n=0;n<14;n++)
		{
			if(a[n]%2==0)
				b[i]+=a[n];
		}
	}

	max=b[0];

	for(i=1;i<14;i++)
	{
		if(max<b[i])
			max=b[i];
	}

	printf("%lld",max);

	return 0;
}

/* Coached by rainboy */
#include <stdio.h>

int main() {
	static int aa[14];
	int i;
	long long max;

	for (i = 0; i < 14; i++)
		scanf("%d", &aa[i]);
	max = 0;
	for (i = 0; i < 14; i++)
		if (aa[i] > 0) {
			static int bb[14];
			int j, a;
			long long sum;

			a = aa[i];
			for (j = 0; j < 14; j++) {
				bb[j] = j == i ? 0 : aa[j];
				bb[j] += a / 14;
			}
			for (j = i + 1; j <= i + (a % 14); j++)
				bb[j % 14]++;
			sum = 0;
			for (j = 0; j < 14; j++)
				sum += (bb[j] % 2 == 0 ? bb[j] : 0);
			if (max < sum)
				max = sum;
		}
	printf("%lld\n", max);
	return 0;
}

#include<stdio.h>

int main(void)
{
    long long arr[14];
    int i,j;
    for(i=0; i<14; ++i){
        scanf("%lld", &arr[i]);
    }
    long long brr[14];
    long long k=0;
    long long r;
    long long q;
    long long rem,div;
    for(i=0; i<14; ++i){
        if(arr[i]!=0){
            for(j=0; j<14; ++j){
                brr[j]=arr[j];
            }
            q=brr[i];
            brr[i]=0;
            j=i+1;
            while(q>0 && j<14){
                ++brr[j];
                --q;
                ++j;
            }
            div=q/14;
            rem=q%14;
            if(div!=0){
                for(j=0; j<14; ++j){
                    brr[j]+=div;
                }
            }
            for(j=0; j<rem; ++j){
                ++brr[j];
            }
            r=0;
            for(j=0; j<14; ++j){
                if(brr[j]%2==0){
                    r+=brr[j];
                }
            }
            if(r>k){
                k=r;
            }
        }
    }
    printf("%lld", k);
}

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

int main()
{
    int a[14];
    int b[14];
    for(int i = 0; i < 14; ++i) {
        scanf("%d", &a[i]);
    }
    long long ans = 0;
    for(int i = 0; i < 14; ++i) {
        if(a[i]) {
            memcpy(b, a, sizeof(a));
            b[i] = 0;
            for(int j = 0; j < 14; ++j) {
                b[(i + j + 1) % 14] += a[i] / 14 + (a[i] % 14 > j);
            }
            long long cur = 0;
            for(int j = 0; j < 14; ++j) {
                if(!(b[j] & 1)) {
                    cur += b[j];
                }
            }
            if(ans < cur) {
                ans = cur;
            }
        }
    }
    printf("%I64d\n", ans);
    return 0;
}

#include<stdio.h>
#include<string.h>
#define N 14
int main()
{
    long long int a[N];
    long long int b[N];
    long long int max = 0;
    for(int i=0;i<N;i++)
        scanf("%lld",a+i);
    for(int i=0;i<N;i++)
    {
        if(!a[i]) continue;
        long long int temp = 0;
        int n = a[i]/N;
        int m = a[i]%N;
        for(int j =0;j<N;j++)
            b[j] = 0;
        for(int j=1;j<=m;j++)
        {
            b[(j+i)%N]++;
        }
        for(int j=0;j<N;j++)
        {
            if(j!=i)
                b[j] += a[j] + n;
            else b[j] += n;
            if((b[j]&1)==0)
                temp += b[j];
        }
        max = (max>temp)?max:temp;
    }
    printf("%lld",max);
}

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

long long par,maxi,a[15],i,j,k,nr,test[15];

int main()
{
   for(i=1;i<=14;i++)
    scanf("%I64d",&a[i]);

   for(i=1;i<=14;i++)
   {
       par=0;
       for(j=1;j<=14;j++)
        test[j]=a[j];
       nr=test[i];
       test[i]=0;
       k=i+1;
       if(k==15)
        k=1;
       while(nr%14!=0)
       {
           nr--;
           test[k]++;
           k++;
           if(k==15)
                k=1;
       }
       for(k=1;k<=14;k++)
                test[k]+=nr/14;

        for(j=1;j<=14;j++)
            if(test[j]%2==0)
                par+=test[j];

        if(par>maxi)
            maxi=par;
   }

   printf("%I64d",maxi);

    return 0;
}

#include<stdio.h>
#include<limits.h>
int main()
{
int arr[14];
int temp[14];
int i,j;
long long int max=INT_MIN;
for(i=0;i<14;i++)
{
	scanf("%d",&arr[i]);
}
for(i=0;i<14;i++)
{
	for(j=0;j<14;j++)
		temp[j]=arr[j];
	if(arr[i]==0)
		continue;
	int stones=arr[i];
	temp[i]=0;
	int cur=(i+1)%14;
	for(j=0;j<14;j++)
	{
		temp[j]+=(stones/14);
	}
	stones=stones%14;
	while(stones)
	{
		temp[cur]+=1;
		stones--;
		cur++;
		cur=cur%14;
	}
	long long int score=0;
	for(j=0;j<14;j++)
		if(temp[j]%2==0)
			score+=temp[j];
	if(score>max)max=score;
}
printf("%lld\n",max);
return 0;
}

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

int main(void) {
	// your code goes here
	long long int temp[14],a[14],i,j,rem,no,max,sum;
	long long int const_2 = 14;
	long long int const_1 = 2;
	max=-1;

	for(i=0;i<14;i++)
	scanf("%lld",&temp[i]);

 	for(i=0;i<14;i++){

	    for(j=0;j<14;j++)
	    a[j]=temp[j];

	    if(temp[i]==0)
	    continue;

	    no=a[i];

	    a[i]=no/14;

	    for(j=0;j<14;j++){
	        if(j==i)
	        continue;

	        a[j] += (no/const_2);
	    }

	        rem = no%const_2;

	        for(j=i+1;j<14 && rem>0;j++){
	            ++a[j];
	            --rem;
	        }
	    j=0;
	    while(rem!=0){
	        ++a[j];
	        ++j;
	        --rem;
	    }

	    sum=0;

	    for(j=0;j<14;j++){

	        if(a[j]%const_1 == 0)
	        sum += a[j];
	    }

	    if(sum>max)
	    max=sum;

	}

	if(max==-1)
	printf("0\n");

	else
	printf("%lld\n",max);

 	return 0;
}

#include <stdio.h>

int N[14], A[14];

long long count(short index) {
	short i;
	for(i = 0; i < 14; ++i) {
		A[i] = N[i];
	}
	A[index] = 0;
	short p = N[index] % 14;
	for(i = 1; i <= 14; ++i) {
		A[(index+i)%14] += N[index] / 14;
		if(p != 0) {
			++A[(index+i)%14];
			--p;
		}
	}
	long long sum = 0;
	for(i = 0; i < 14; ++i) {
		if(A[i] % 2 == 0) {
			sum += A[i];
		}
	}
	return sum;
}

int main() {
	short i;
	for(i = 0; i < 14; ++i) {
		scanf("%d", &N[i]);
	}
	long long max = -1, current;
	for(i = 0; i < 14; ++i) {
		if(N[i] > 0) {
			current = count(i);
			if(current > max) {
				max = current;
			}
		}
	}
	printf("%I64d", max);
	return 0;
}

#include <stdio.h>
#define N 14
long long int hole[N]={0,};
long long int he[N]={0,};
int main(void)
{
	int k1,k2,flag;
	long long int score=0;
	for(k1=0;k1<N;k1++) scanf("%I64d",&hole[k1]);
    for(k1=0;k1<N;k1++)
    {
    	if(hole[k1]>0)
    	{
    		for(k2=0;k2<N;k2++) he[k2]=hole[k2];
			long long int m=hole[k1];
    		long long int m1=m/N;
			long long int m2=m%N;

    		hole[k1]=0;
    		for(k2=0;k2<N;k2++) hole[k2]+=m1;
    		flag=0;
    		k2=0;
    		while(m2)
    		{
    			if(k2==k1)flag=1;
    			if((flag)&&(m2--)) hole[(k2+1)%N]+=1;
    			k2++;
    		}
    		long long int s=0;
    		for(k2=0;k2<N;k2++)
    		{
    			if((hole[k2]%2)==0) s+=hole[k2];
    		}
    		if(s>score)score=s;
    		for(k2=0;k2<N;k2++) hole[k2]=he[k2];
    	}
    }
    printf("%I64d",score);
}

#include <stdio.h>

int main()
{
	long long init[14], copy[14];
	long long MAX = 0;

	int i;
	for (i = 0; i < 14; i++) {
		scanf("%lli", &init[i]);
	}
	for (i = 0; i < 14; i++) {
		if (init[i] != 0) {
			int j;
			long long score = 0;

			for (j = 0; j < 14; j++) {
				copy[j] = init[j];
			}
            copy[i] = 0;
			for (j = 0; j < 14; j++) {
				copy[j] += init[i]/14;
			}
            int extr = init[i]%14;
            for (j = 1; j <= extr; j++) {
                copy[(i+j)%14]++;
            }
			for(j = 0; j < 14; j++){
				if (copy[j]%2 == 0) score += copy[j];
			}
			if (MAX < score) MAX = score;
		}
	}
	printf("%lli", MAX);
	return 0;
}

#include <stdio.h>

#define _MAX_ 1000000005
#define _HOLES_ 14

typedef long long unsigned int llu;

int main() {
    llu holes[_HOLES_], trial[_HOLES_];

    llu i;
    for (i = 0; i < _HOLES_; i++) {
        scanf("%I64u", &holes[i]);
        trial[i] = holes[i];
    }

    llu j, k, max = 0;
    for (i = 0; i < _HOLES_; i++) {
        if (holes[i] == 0) {
            continue;
        }

        llu val = holes[i];

        llu div = val/_HOLES_;
        llu mod = val%_HOLES_;

        trial[i] = 0;

        if (div > 0) {
            for (j = 0; j < _HOLES_; j++) {
                trial[j] += div;
            }
        }

        k = i+1;
        while(mod--) {
            if (k == _HOLES_) {
                k = 0;
            }
            trial[k++]++;
        }

        llu sum = 0;
        for (j = 0; j < _HOLES_; j++) {
            if (trial[j]%2 == 0) {
                sum += trial[j];
            }
        }

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

        for (j = 0; j < _HOLES_; j++) {
            trial[j] = holes[j];
        }
    }

    printf("%I64u\n", max);

    return 0;
}

#include<stdio.h>
main()
{

	long long int count = 0;
	long long int max = 0;
	long long int k;

	long long int a[14];
	for(int i =0;i<14;i++)
	scanf("%I64d",&a[i]);
	long long int b[14];
	for(int i =0;i<14;i++)
	b[i]=a[i];
	long long int p =0;

	for(int i =0;i<14;i++)
	{
		p=0;
		count = 0;
		for(int i =0;i<14;i++)
    	b[i]=a[i];

        k = b[i];
        b[i] = 0;
        p = k/14;
        k=k%14;
        for(int i =0;i<14;i++)
        b[i]+=p;
        for(int j = 1;j<=k;j++)
        {
        	b[(j+i)%14]++;
		}

		for(int i =0;i<14;i++)
		{
			if(b[i]%2==0)
			count +=b[i];
		}

		   if (count > max)
		   max = count;
	}

	printf("%I64d",max);
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
int i,j,a[101],shang,yu,t;
long long s[101]={0},max,b[101];

int main()
{
	for (i=1;i<=14;i++) scanf("%d",&a[i]);
	for (i=1;i<=14;i++)
	if (a[i])
	{
		for (j=1;j<=14;j++) b[j]=a[j];
		b[i]=0;
		t=a[i];
		if (t>14-i)
		{
			for (j=i+1;j<=14;j++) b[j]++;
			t-=14-i;
			shang=t/14;
			for (j=1;j<=14;j++) b[j]+=shang;
			yu=t%14;
			for (j=1;j<=yu;j++) b[j]++;
		}
		else
		{
			for (j=i+1;j<=i+t;j++) b[j]++;
		}
		for (j=1;j<=14;j++)
		if (b[j]%2==0) s[i]+=b[j];
	}

	for (i=1,max=0;i<=14;i++) max=max>s[i] ? max : s[i];
	printf("%lld\n",max);
	return 0;
}

#include <stdio.h>

int main() {
	static long long aa[14], bb[14];
	long long max;
	int i, j;

	for (i = 0; i < 14; i++)
		scanf("%lld", &aa[i]);
	max = 0;
	for (i = 0; i < 14; i++)
		if (aa[i] > 0) {
			long long sum;

			for (j = 0; j < 14; j++)
				bb[j] = (j == 0 ? 0 : aa[(i + j) % 14]) + (aa[i] - (j - 1 + 14) % 14 + 13) / 14;
			sum = 0;
			for (j = 0; j < 14; j++)
				if (bb[j] % 2 == 0)
					sum += bb[j];
			if (max < sum)
				max = sum;
		}
	printf("%lld\n", max);
	return 0;
}

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

int main(){
  long long a[14], b[14], ans = 0;
  for(int i = 0; i < 14; i++) scanf("%lld", a+i);
  for(int i = 0; i < 14; i++){
    long long t = a[i];
    memcpy(b, a, sizeof(a));
    b[i] = 0;
    if(t / 14ll) for(int j = 0; j < 14; j++) b[j] += t / 14;
    for(int j = 1; t--; j++) b[(i+j)%14]++;
    t = 0;
    for(int j = 0; j < 14; j++) t += b[j] % 2 ? 0 : b[j];
    ans = ans > t ? ans : t;
  }
  printf("%lld", ans);
  return 0;
}

#include <stdio.h>

static long long v[14];

int main(void)
{
    int imax, i;
    long long nmax, total = 0, trip;

    nmax = imax = 0;

    for (i = 0; i < 14; i++) {
        scanf("%lld", &v[i]);
        if (v[i] > nmax) {
            nmax = v[i];
            imax = i;
        }
    }

    v[imax] = 0;
    trip = nmax / 14;
    for (i = 0; i < 14; i++) {
        v[i] += trip;
    }

    trip = nmax % 14;
    while (trip) {
        ++imax;
        imax %= 14;
        v[imax]++;
        trip--;
    }

    for (i = 0; i < 14; i++) {
        if (v[i] % 2 == 0) {
            total += v[i];
        }
    }

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

#include <stdio.h>

static long long v[14];

int main(void)
{
    int imax, i;
    long long nmax, total = 0, trip;

    nmax = imax = 0;

    for (i = 0; i < 14; i++) {
        scanf("%lld", &v[i]);
        if (v[i] > nmax) {
            nmax = v[i];
            imax = i;
        }
    }

    v[imax] = 0;
    trip = nmax / 14;
    for (i = 0; i < 14; i++) {
        v[i] += trip;
    }

    trip = nmax % 14;
    while (trip) {
        v[++imax]++;
        trip--;
    }

    for (i = 0; i < 14; i++) {
        if (v[i] % 2 == 0) {
            total += v[i];
        }
    }

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

#include <stdio.h>

static long long v[14];

int main(void)
{
    int imax, i;
    long long nmax, total = 0;

    nmax = imax = 0;

    for (i = 0; i < 14; i++) {
        scanf("%lld", &v[i]);
        if (v[i] > nmax) {
            nmax = v[i];
            imax = i;
        }
    }

    v[imax] = 0;
    while (nmax) {
        imax++;
        imax %= 14;
        v[imax]++;
        nmax--;
    }

    for (i = 0; i < 14; i++) {
        if (v[i] % 2 == 0) {
            total += v[i];
        }
    }

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

#include <stdio.h>
int main()
{
    long long int a[14] ;
    long long int d[14];
    for(long long int i = 0; i<14;i++) scanf("%lld",&a[i]);
    long long int c ; long long int c1 = 0; long long int c2 = 0;
    for(long long int i = 0; i<14;i++)
    {
        for(long long int j = 0; j<14;j++) d[j] = a[j];
        long long int b = a[i];
        d[i] = 0;
        if(i!=13) c = i+1;
            else c = 0;
        if((b>0)&&(b<=14))
        {
            for(long long int j = 1;j<=b;j++)
            {
                d[c] = d[c]+1;
                if(c!=13) c++;
                else c = 0;
            }
        }
        else if(b>0)
        {
            long long int m = b/14; long long int n = b%14 ;
            for(long long int j = 0; j < 14; j++)
            {
                d[c] = d[c]+m;
                if(c!=13) c++;
                else c = 0;
            }
            for(long long int j = 1;j<=n;j++) d[j]++;
        }
        for(long long int j = 0; j<14; j++)
        {
            if(d[j]%2==0) c1 = c1+d[j];
        }
        if(c1>c2) c2 = c1 ;
        c1 = 0;
    }
    printf("\n%lld",c2);
}

#include <stdio.h>
int main()
{
    long long int a[14] ;
    long long int d[14];
    for(long long int i = 0; i<14;i++) scanf("%lld",&a[i]);
    long long int c ; long long int c1 = 0; long long int c2 = 0;
    for(long long int i = 0; i<14;i++)
    {
        for(long long int j = 0; j<14;j++) d[j] = a[j];
        long long int b = a[i];
        d[i] = 0;
        if((b>0)&&(b<=14))
        {
            if(i!=13) c = i+1;
            else c = 0;
            for(long long int j = 1;j<=b;j++)
            {
                d[c] = d[c]+1;
                if(c!=13) c++;
                else c = 0;
            }
        }
        else
        {
            long long int m = b/14; long long int n = b%14 ;
            for(long long int j = 0; j < 14; j++) d[j] = d[j]+m;
            for(long long int j = i+1;j<=i+n;j++) d[j]++;
        }
        for(long long int j = 0; j<14; j++)
        {
            if(d[j]%2==0) c1 = c1+d[j];
        }
        if(c1>c2) c2 = c1 ;
        c1 = 0;
    }
    printf("\n%lld",c2);
}

#include <stdio.h>
int main()
{
    long long int a[14] ;
    long long int d[14];
    for(long long int i = 0; i<14;i++) scanf("%lld",&a[i]);
    for(long long int i = 0; i<14;i++) d[i] = a[i];
    long long int c ; long long int c1 = 0; long long int c2 = 0;
    for(long long int i = 0; i<14;i++)
    {
        long long int b = a[i];
        if(b>0)
        {
            d[i] = 0;
            if(i!=13) c = i+1;
            else c = 0;
            for(long long int j = 1;j<=b;j++)
            {
                d[c] = d[c]+1;
                if(c!=13) c++;
                else c = 0;
            }
        }

        for(long long int j = 0; j<13; j++)
        {
            if(d[j]%2==0) c1 = c1+d[j];
        }

        if(c1>c2) c2 = c1 ;
        c1 = 0;
        for(long long int j = 0; j<14;j++) d[i] = a[i];
    }

    printf("%lld",c2);
}

#include <stdio.h>
int main()
{
    long long int a[14] ;
    long long int d[14];
    for(long long int i = 0; i<14;i++) scanf("%lld",&a[i]);
    long long int c ; long long int c1 = 0; long long int c2 = 0;
    for(long long int i = 0; i<14;i++)
    {
        for(long long int j = 0; j<14;j++) d[j] = a[j];
        long long int b = a[i];
        d[i] = 0;
        if(i!=13) c = i+1;
            else c = 0;
        if((b>0)&&(b<=14))
        {
            for(long long int j = 1;j<=b;j++)
            {
                d[c] = d[c]+1;
                if(c!=13) c++;
                else c = 0;
            }
        }
        else if(b>0)
        {
            long long int m = b/14; long long int n = b%14 ;
            for(long long int j = 0; j < 14; j++) d[j] = d[j]+m;
            for(long long int j = c;j<c+n;j++) d[j]++;
        }
        for(long long int j = 0; j<14; j++)
        {
            if(d[j]%2==0) c1 = c1+d[j];
        }
        if(c1>c2) c2 = c1 ;
        c1 = 0;
    }
    printf("\n%lld",c2);
}

#include <stdio.h>

int main()
{
	//code
	long long int a[14],c=0;
	for(int i=0;i<14;i++)
	    scanf("ll%d",a+i);
	long long int b[14];
	for(int i=0;i<14;i++)
	{
	    if(a[i]==0) continue;
	    for(int j=0;j<14;j++)
	        b[j]=a[j];
	    long long int m1=a[i]/14,m2=a[i]%14,s=0;
	    b[i]=0;
	    for(int j=0;j<14;j++)
	        b[j]=b[j]+m1;
	    int j=i;
	    while(m2--)//do something
	    {
	        if(j==13) j=0;
	        else j++;
	        b[j]++;
	    }
        for(j=0;j<14;j++)
            if(b[j]%2==0) s=s+b[j];
        if(s>c) c=s;
	}
	printf("%lld",c);
	return 0;
}

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

int main(){
	long long int a[14];
	long long int b[14];
	for (int i = 0; i < 14; ++i)
	{
		scanf("%I64d", &a[i]);
		b[i]= a[i];
	}
	long long int ret= 0;
	for (int i = 0; i < 14; ++i)
	{
		long long int ans= 0;
		long long int x= a[i] % (long long)14;
		b[i]= a[i] / (long long)14;
		for (int j = 1; j <= x; ++j)
		{
			b[(j+i)%14]= b[(j+i)%14]+ 1 + a[i]/ (long long)14;
		}
		if(x== 0){
			for (int j = 1; j < 14; ++j)
			{
				b[(j+i)%14]= b[(j+i)%14]+ a[i]/ (long long)14;
			}
		}
		else{
			for (int j = x; j < 14; ++j)
			{
				b[(j+i)%14]= b[(j+i)%14]+ a[i]/ (long long)14;
			}
		}

		for (int j = 0; j < 14; ++j)
		{
			//printf("%d ", b[j]);
			if(b[j]%2==0){
				ans= ans+ b[j];
			}
		}

		for (int j = 0; j < 14; ++j)
		{
			b[j]= a[j];
		}
		//printf("%d ", ans);
		if(ans> ret)ret= ans;

	}

	printf("%I64d", ret);

	return 0;
}

#include <stdio.h>

int main() {
	int i, j;
	int a[14], cnt[14];
	long long result = 0;
	for (i = 0; i<14; i++) {
		cnt[i] = 1;
		scanf("%d", &a[i]);
		if (a[i] == 0) {
			cnt[i] = 0;
		}
	}

	long long max = 0;
	i = 0;
	while (i<14) {
		result = 0;
		if (a[i] != 0) {
			cnt[i]=0;
			int b = a[i] / 14;
			int c = a[i] % 14;
			if (b % 2 == 0) {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[temp] + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
							result = result + b;
					}
				}
			}
			else {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
						result = result + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[i + j - 13] + b;
					}
				}
			}
			cnt[i]=1;
		}
		if (result>max) {
			max = result;
		}
		i++;
	}
	printf("%I64d", max);

	return 0;
}

#include <stdio.h>

int main() {
	int i, j;
	int a[14], cnt[14];
	long long result = 0;
	for (i = 0; i<14; i++) {
		cnt[i] = 1;
		scanf("%d", &a[i]);
		if (a[i] == 0) {
			cnt[i] = 0;
		}
	}

	long long max = 0;
	i = 0;
	while (i<14) {
		result = 0;
		if (a[i] != 0) {
			int b = a[i] / 14;
			int c = a[i] % 14;
			if (b % 2 == 0) {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[temp] + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
							result = result + b;
					}
				}
				result+=b;
			}
			else {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
						result = result + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[i + j - 13] + b;
					}
				}
			}
		}
		if (result>max) {
			max = result;
		}
		i++;
	}
	printf("%I64d", max);

	return 0;
}

#include <stdio.h>

int main() {
	int i, j;
	int a[14], cnt[14];
	long long result = 0;
	for (i = 0; i<14; i++) {
		cnt[i] = 1;
		scanf("%d", &a[i]);
		if (a[i] == 0) {
			cnt[i] = 0;
		}
	}

	long long max = 0;
	i = 0;
	while (i<14) {
		result = 0;
		if (a[i] != 0) {
			int b = a[i] / 14;
			int c = a[i] % 14;
			if (b % 2 == 0) {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[temp] + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 14;
					}
					if (cnt[temp] == 0) {
							result = result + b;
					}
				}
				result+=b;
			}
			else {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
						result = result + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 14;
					}
					if (cnt[temp] == 1) {
						result = result + a[temp] + b;
					}
				}
			}
		}
		if (result>max) {
			max = result;
		}
		i++;
	}
	printf("%I64d", max);

	return 0;
}

#include <stdio.h>

int main() {
	int i, j;
	int a[14], cnt[14];
	long long result = 0;
	for (i = 0; i<14; i++) {
		cnt[i] = 1;
		scanf("%d", &a[i]);
		if (a[i] == 0) {
			cnt[i] = 0;
		}
	}

	long long max = 0;
	i = 0;
	while (i<14) {
		result = 0;
		if (a[i] != 0) {
			int b = a[i] / 14;
			int c = a[i] % 14;
			if (b % 2 == 0) {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[temp] + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
							result = result + b;
					}
				}
			}
			else {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
						result = result + b + 1;
					}
				}
				for (j = c+1; j<14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[i + j - 13] + b;
					}
				}
			}
		}
		if (result>max) {
			max = result;
		}
		i++;
	}
	printf("%I64d", max);

	return 0;
}

#include <stdio.h>

int main() {
	int i, j;
	int a[14], cnt[14];
	long long result = 0;
	for (i = 0; i<14; i++) {
		cnt[i] = 1;
		scanf("%d", &a[i]);
		if (a[i] == 0) {
			cnt[i] = 0;
		}
	}

	long long max = 0;
	i = 0;
	while (i<14) {
		result = 0;
		if (a[i] != 0) {
			cnt[i]=0;
			int b = a[i] / 14;
			int c = a[i] % 14;
			if (b % 2 == 0) {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[temp] + b + 1;
					}
				}
				for (j = c+1; j<=14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
							result = result + b;
					}
				}
			}
			else {
				for (j = 1; j<=c; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 0) {
						result = result + b + 1;
					}
				}
				for (j = c+1; j<=14; j++) {
					int temp = i + j;
					if (temp > 13) {
						temp -= 13;
					}
					if (cnt[temp] == 1) {
						result = result + a[i + j - 13] + b;
					}
				}
			}
			cnt[i]=1;
		}
		if (result>max) {
			max = result;
		}
		i++;
	}
	printf("%I64d", max);

	return 0;
}

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

int main()
{
    int a[14];
    int b[14];
    for(int i = 0; i < 14; ++i) {
        scanf("%d", &a[i]);
    }
    long long ans = 0;
    for(int i = 0; i < 14; ++i) {
        memcpy(b, a, sizeof(a));
        if(a[i]) {
            for(int j = 0; j < 14; ++j) {
                b[(i + j + 1) % 14] += a[i] / 14 + (a[i] % 14 >= j);
            }
            long long cur = 0;
            for(int j = 0; j < 14; ++j) {
                if(!(b[j] & 1)) {
                    cur += b[j];
                }
            }
            if(ans < cur) {
                ans = cur;
            }
        }
    }
    printf("%I64d\n", ans);
    return 0;
}

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

long long par,maxi,a[15],i,j,k,nr,test[15];

int main()
{
   for(i=1;i<=14;i++)
    scanf("%I64d",&a[i]);

   for(i=1;i<=14;i++)
   {
       par=0;
       for(j=1;j<=14;j++)
        test[j]=a[j];
       nr=test[i];
       test[i]=0;
       k=i+1;
       if(k==15)
        k=1;
       while(nr%14!=0)
       {
           nr--;
           test[k]++;
           k++;
           if(k==15)
                k=1;
       }
       for(k=1;k<=14;k++)
                test[k]+=nr/14;

        for(j=1;j<=14;j++)
            if(test[j]%2==0 && test[j]>0)
                par+=test[j];

        if(par>maxi)
            maxi=par;
   }

   printf("%d",maxi);

    return 0;
}

#include <stdio.h>

int main(){
	long long hole[14];
	long long MAX = 0;
	long long score = 0;

	int i;
	for(i = 0; i <= 13; i++){
		scanf("%lli%", &hole[i]);
	}

	for(i = 0; i <= 13; i++){
		if(hole[i] != 0){
			long long j;
			for(j = 1; j <= hole[i]; j++){
				++hole[(i + j) % 14];
			}
			for(j = 0; j <= 13; j++){
				if(hole[j] % 2 == 0) score += hole[j];
			}
			if(MAX < score) MAX = score;
		}
	}

	printf("%lli%", MAX);
	return 0;
}

#include <stdio.h>

#define _MAX_ 1000000005
#define _HOLES_ 14

typedef long long unsigned int llu;

int main() {
    llu holes[_HOLES_], trial[_HOLES_];

    llu i;
    for (i = 0; i < _HOLES_; i++) {
        scanf("%I64u", &holes[i]);
        trial[i] = holes[i];
    }

    llu j, k, max = 0;
    for (i = 0; i < _HOLES_; i++) {
        if (holes[i] == 0) {
            continue;
        }

        llu val = holes[i];

        llu div = val/_HOLES_;
        llu mod = val%_HOLES_;

        if (div > 0) {
            for (j = 0; j < _HOLES_; j++) {
                trial[j] += div;
            }
        }

        k = i+1;
        while(mod--) {
            if (k == _HOLES_) {
                k = 0;
            }
            trial[k++]++;
        }

        llu sum = 0;
        for (j = 0; j < _HOLES_; j++) {
            if (trial[j]%2 == 0) {
                sum += trial[j];
            }
        }

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

        for (j = 0; j < _HOLES_; j++) {
            trial[j] = holes[j];
        }
    }

    printf("%I64u\n", max);

    return 0;
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
int i,j,a[101],shang,yu,t;
long long s[101]={0},max,b[101];

int main()
{
	for (i=1;i<=14;i++) scanf("%d",&a[i]);
	for (i=1;i<=14;i++)
	if (a[i])
	{
		for (j=1;j<=14;j++) b[j]=a[j];
		b[i]=0;
		t=a[i];
		if (t>14-i)
		{
			for (j=i+1;j<=14;j++) b[j]++;
			t-=14-i;
			shang=t/14;
			for (j=1;j<=14;j++) b[j]+=shang;
			yu=t%14;
			for (j=1;j<=yu;j++) b[j]++;
		}
		else
		{
			for (j=i+1;j<=i+t;j++) b[j]++;
		}
		for (j=1;j<=14;j++)
		if (b[j]%2==0) s[i]+=b[j];
	}

	for (i=1,max=0;i<=14;i++) max=max>s[i] ? max : s[i];
	printf("%d\n",max);
	return 0;
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
int i,j,a[101],shang,yu,b[101],t;
long long s[101]={0},max;

int main()
{
	for (i=1;i<=14;i++) scanf("%d",&a[i]);
	for (i=1;i<=14;i++)
	if (a[i])
	{
		for (j=1;j<=14;j++) b[j]=a[j];
		b[i]=0;
		t=a[i];
		if (t>14-i)
		{
			for (j=i+1;j<=14;j++) b[j]++;
			t-=14-i;
			shang=t/14;
			for (j=1;j<=14;j++) b[j]+=shang;
			yu=t%14;
			for (j=1;j<=yu;j++) b[j]++;

		}
		else
		{
			for (j=i+1;j<=i+t;j++) b[j]++;
		}
		for (j=1;j<=14;j++)
		if (b[j]%2==0) s[i]+=b[j];
	}
	for (i=1,max=0;i<=14;i++) max=max>s[i] ? max : s[i];
	printf("%d\n",max);
	return 0;
}