<commit_before># https://www.hackerrank.com/contests/w14/challenges/palindromic-border

def isPalindrome(num) :
  string = str(num)
  bottomHalf = len(string)/2
  topHalf = (len(string)-1)/2
  return string[:bottomHalf] == string[:topHalf:-1]

def getBorders(string) :
  biggest = 0
  limit = len(string)
  # print limit
  while biggest < limit and string[biggest] == string[-1-biggest] :
    # print "%s = %s" % (string[biggest], string[-1-biggest])
    biggest += 1;
  # print biggest
  # print string[:biggest]
  return 0 if biggest == 0 else sum(1 for i in range(1,min(limit,biggest+1)) if isPalindrome(string[:i]))

# getBorders("abca") # 1
# getBorders("ababa") # 2
# getBorders("lololol") # 3


def substrings(string) :
  for i in range(len(string)) :
    for j in range(i+1, len(string)+1) :
      yield string[i:j]

# tuple(substrings("abcacb"))


def palindromicBorders(string) :
  return sum(map(getBorders, substrings(string)))

# palindromicBorders("abcacb") # 3
# palindromicBorders("ababa") # 5


string = raw_input()

print palindromicBorders(string)<commit_msg>As optimized as it gets. Need to pivot to solve<commit_after># https://www.hackerrank.com/contests/w14/challenges/palindromic-border

modVal = 10**9+7

def isPalindrome(num) :
  string = str(num)
  bottomHalf = len(string)/2
  topHalf = (len(string)-1)/2
  return string[:bottomHalf] == string[:topHalf:-1]


def countPalindromesBad(string) :
  return sum(1 for i in range(1,len(string)+1) if isPalindrome(string[:i])) % modVal

# countPalindromesBad("a") # 1
# countPalindromesBad("abab") # 3
# countPalindromesBad("lololo") # 3


def countPalindromes(string) :
  longest = len(string)
  while not isPalindrome(string[:longest]) :
    longest -= 1
  return sum(1 for i in range(0,len(string)) if string[i] == string[0] and isPalindrome(string[:i+1])) # 24s

# countPalindromes("a") # 1
# countPalindromes("abab") # 2
# countPalindromes("lololo") # 3


def getBorders(string) :
  biggest = 0
  limit = len(string)
  # print limit
  while biggest < limit and string[biggest] == string[-1-biggest] :
    # print "%s = %s" % (string[biggest], string[-1-biggest])
    biggest += 1;
  # print biggest
  # print string[:biggest]
  return 0 if biggest == 0 else countPalindromes(string[:min(limit,biggest+1)-1]) % modVal # 12s

# getBorders("abca") # 1
# getBorders("ababa") # 2
# getBorders("lololol") # 3


def substrings(string) :
  for i in range(len(string)) :
    for j in range(len(string), i+1, -1) :
      if string[i] == string[j-1] : 
        yield string[i:j] # 11 sec if we limit to 8 chars

# tuple(substrings("abcacb"))


def palindromicBordersBad(string) :
  return sum(map(getBorders, substrings(string))) % modVal

# start = time()
# palindromicBordersBad("abcacb") # 3
# palindromicBordersBad("ababa") # 5
# palindromicBordersBad("".join(["abcdefgh"[randint(0,7)] for i in range(10**3)])) # ~0.4 sec
# palindromicBordersBad("".join(["abcdefgh"[randint(0,7)] for i in range(10**4)])) # ~40 sec
# time() - start


def palindromicBorders(string) :
  return sum(map(getBorders, substrings(string))) % modVal

start = time()
# palindromicBorders("abcacb") # 3
# palindromicBorders("ababa") # 5
# palindromicBorders("".join(["abcdefgh"[randint(0,7)] for i in range(10**3)])) # ~0.4 sec
palindromicBorders("".join(["abcdefgh"[randint(0,7)] for i in range(10**4)])) # ~40 sec
# palindromicBorders("".join(["abcdefgh"[randint(0,7)] for i in range(10**5)])) # ~40 sec
time() - start


string = raw_input()

print palindromicBorders(string)
{'fraction_non_alphanumeric': 0.16879795396419436, 'fraction_numerical': 0.030122193805058255, 'mean_word_length': 4.906040268456376, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1179689', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1330, 'n_words': 284}