1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
#include <bits/stdc++.h>

#include "message.h"
#include "palindromy.h"



#define double long double
#define LL long long
#define MP make_pair
#define ST first
#define ND second
#define PII pair<LL,LL >
#define PPIII pair<PII,int>
#define PPIIPII pair<PII,PII>
#define PIB pair<int,bool>
#define PIS pair<int,string>
#define PB push_back
#define VI vector<LL>
#define VVI vector<VI>
#define VLL vector<long long>
#define VVLL vector<VLL>
#define VB vector<bool>
#define VPII vector<PII>
#define VPPIII vector<PPIII>
#define VPPIIPII vector<PPIIPII>
#define VPIB vector<PIB>
#define VPIS vector<PIS>
#define SI set<int>
#define SPII set<PPIII>
#define VS vector<string>
#define PB push_back
#define INF (LL) 1000000000000000000
#define MOD 2000007
#define ALL(c) c.begin(),c.end()
#define NWD __gcd
#define SIZE 1000000

using namespace std;

string slo;

VI mana(int k)
{
	VI tab;
	tab.PB(0);
	int i=1, j=0;
	while(i<slo.size())
	{
		while(slo[i-j-k]==slo[i+j+1])
			j++;
		tab.PB(j);
		int k=1;
		while(tab[i-k]!=tab[i]-k&&k<=j)
		{
			tab.PB(min(tab[i-k], tab[i]-k));
			k++;
		}
		j=max(j - k, 0); i += k;
	}
	return tab;
}
/*
int GetLength()
{
	return 6;
}

char GetLetter(int i)
{
	string a="aaaaaa";
	return a[i];
}
*/

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

	if(MyNodeId() != 0)
		return EXIT_SUCCESS;

	slo+='!';
	for(int i=0;i<GetLength();i++)
	{
		slo+=GetLetter(i);
	}

	slo+='@';

	LL wyn=0;


	auto t1 = mana(0);
	for(auto it:t1)
		wyn+=it;


	auto t2 = mana(1);
	for(auto it:t2)
		wyn+=it;


	cout<<wyn+GetLength()<<endl;



	return EXIT_SUCCESS;

}