AtCoder Beginner Contest 147 - Palindrome-philia

Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.
Given is a string S. Find the minimum number of hugs needed to make S palindromic.

-----Constraints-----
 - S is a string consisting of lowercase English letters.
 - The length of S is between 1 and 100 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
Print the minimum number of hugs needed to make S palindromic.

-----Sample Input-----
redcoder

-----Sample Output-----
1

For example, we can change the fourth character to o and get a palindrome redooder.

Source: atcoder | Difficulty: EASY


Solutions:
S = list(input())
d = 0
for i in range(len(S) // 2):
	if S[i] != S[len(S) - i - 1]:
		d += 1
print(d)


S = input()
c = 0
N = len(S)
for i in range(N // 2):
	c += S[i] != S[N - i - 1]
print(c)


def main():
	S = input()
	ans = 0
	for i in range(len(S)):
		if S[i] != S[-(i + 1)]:
			ans += 1
	print(ans // 2)

def __starting_point():
	main()
__starting_point()


S = input()
ans = 0
for i in range(len(S)):
	if S[i] != S[-1 * (i + 1)]:
		ans += 1
print(ans // 2)


s = input()
a = 0
for i in range(len(s) // 2):
	if s[i] != s[-(i + 1)]:
		a += 1
print(a)


s = input()
ans = 0
for i in range(len(s) // 2):
	ans += s[i] != s[len(s) - i - 1]
print(ans)


S = input()
print(sum((1 for (a, b) in zip(S[:len(S) // 2], S[::-1]) if a != b)))


a = input()
print(sum([a > b for (a, b) in zip(a, a[::-1])]))


A = input()
print(sum((i != j for (i, j) in zip(A, A[::-1]))) // 2)


import sys

def resolve(in_):
	S = next(in_).strip()
	ans = 0
	for (a, b) in zip(S[:len(S) // 2], reversed(S)):
		if a != b:
			ans += 1
	return ans

def main():
	answer = resolve(sys.stdin)
	print(answer)

def __starting_point():
	main()
__starting_point()


s = input()
r_s = s[::-1]
cnt = 0
for (a, b) in zip(s, r_s):
	if a != b:
		cnt += 1
print(cnt // 2)


s = input()
t = s[::-1]
c = 0
for x in range(len(s)):
	if s[x] != t[x]:
		c += 1
print(c // 2)


a = input()
b = a[::-1]
n = 0
for i in range(len(a) // 2):
	if a[i] != b[i]:
		n += 1
print(n)


s = input()
l = len(s)
print(sum((1 for i in range(int(l / 2)) if s[i] != s[-i - 1])))


S = input()
p = len(S)
t = 0
for n in range(p):
	if S[n] != S[p - n - 1]:
		t += 1
print(int(t / 2))


s = input()
i = 0
j = len(s) - 1
c = 0
while i < j:
	if s[i] != s[j]:
		c += 1
	i += 1
	j -= 1
print(c)


s = input()
print(sum([s[i] != s[-(i + 1)] for i in range(len(s) // 2)]))


s = input()
sr = s[::-1]
hugs = sum((1 for (c, cr) in zip(s, sr) if c != cr)) // 2
print(hugs)


s = input()
l = len(s)
c = 0
for i in range(int(l / 2)):
	if s[i] != s[l - i - 1]:
		c += 1
print(c)


s = list(input())
n = 0
for i in range(len(s) // 2):
	if s[i] != s[len(s) - 1 - i]:
		n += 1
print(n)


s = input()
(l, r) = (0, len(s) - 1)
a = 0
while l < r:
	if s[l] != s[r]:
		a += 1
	l += 1
	r -= 1
print(a)


S = input()
print(sum((S[i] != S[-i - 1] for i in range(len(S) // 2))))


s = input().strip()
n = len(s)
r = 0
for i in range(n // 2):
	r += s[i] != s[n - i - 1]
print(r)


S = input()
print(len([i for i in range((len(S) + 1) // 2) if S[i] != S[len(S) - i - 1]]))


s = input()
n = len(s)
cnt = 0
i = 0
j = -1
d = 0
while d != n // 2:
	if s[i] != s[j]:
		cnt += 1
	i += 1
	j -= 1
	d += 1
print(cnt)


S = list(input())
c = i = 0
while i < len(S):
	c += 1 * (S[i] != S[-i - 1])
	i += 1
print(c // 2)


s = input()
n = len(s)
c = 0
i = 0
while i < n - i - 1:
	if s[i] != s[n - i - 1]:
		c += 1
	i += 1
print(c)


S = str(input())
s = 0
for i in range(0, len(S) // 2):
	if S[i] != S[-(i + 1)]:
		s += 1
print(s)


S = input()
print(sum((a != b for (a, b) in zip(S, S[::-1]))) // 2)


s = list(input())
ans = 0
r = list(reversed(s))
for i in range(len(s) // 2):
	if s[i] != r[i]:
		ans += 1
print(ans)


S = input()
rS = reversed(S)
print(sum([s != rs for (s, rs) in zip(S, rS)]) // 2)


S = input()
N = len(S) - 1
i = 0
C = 0
while i < N - i:
	if S[i] != S[N - i]:
		C += 1
	i += 1
print(C)


S = input()
F = S[::-1]
N = len(S)
a = 0
for i in range(N):
	if S[i] != F[i]:
		a = a + 1
print(a // 2)


import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque, Counter
from decimal import Decimal
import functools

def v():
	return input()

def k():
	return int(input())

def S():
	return input().split()

def I():
	return map(int, input().split())

def X():
	return list(input())

def L():
	return list(input().split())

def l():
	return list(map(int, input().split()))

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 9)
mod = 10 ** 9 + 7
cnt = 0
ans = 1
inf = float('inf')
al = 'abcdefghijklmnopqrstuvwxyz'
S = v()
a = len(S)
if a % 2 == 0:
	ra = a // 2
else:
	ra = a // 2
for i in range(ra):
	if S[i] != S[-(i + 1)]:
		cnt += 1
print(cnt)


a = input()
l = len(a)
z = 0
for i in range(l):
	if a[i] != a[l - 1 - i]:
		z += 1
z //= 2
print(z)


S = input()
print(sum((i != j for (i, j) in zip(S, S[::-1]))) // 2)


L = input()
n = len(L)
c = 0
for i in range((n + 1) // 2):
	if L[i] != L[-1 - i]:
		c += 1
print(c)


s = input()
l = len(s)
x = 0
for i in range(l // 2):
	if s[i] != s[l - i - 1]:
		x += 1
print(x)


def answer(s: str) -> int:
	count = 0
	for i in range(len(s) // 2):
		if s[i] != s[-i - 1]:
			count += 1
	return count

def main():
	s = input()
	print(answer(s))

def __starting_point():
	main()
__starting_point()


a = input()
b = 0
for (i, j) in zip(a, a[::-1]):
	if i != j:
		b += 1
print(b // 2 + b % 2)


S = input()
ans = 0
for (f, l) in zip(S, S[::-1]):
	if f != l:
		ans += 1
print(ans // 2)


s = input()
print(sum((1 if s[i] != s[-(i + 1)] else 0 for i in range(len(s) // 2))))


s = list(input())
print(sum([int(s[i - 1] != s[-i]) for i in range(1, len(s) // 2 + 1)]))


S = input()
l = [s != r for (s, r) in zip(S, S[::-1])]
print(sum(l) // 2)


s = list(input())
Le = len(s) // 2
front = s[:Le + 1]
back = s[-Le:]
count = 0
for i in range(Le):
	if front[i] != back[-1 - i]:
		count += 1
print(count)


S = input()
print(sum((x != y for (x, y) in zip(S, S[::-1]))) // 2)


A = input()
print(sum([A[i] != A[::-1][i] for i in range(len(A))]) // 2)


c = input()
a = list(c)
a_r = reversed(a)
b = [x == y for (x, y) in zip(a, a_r)].count(False)
print(b // 2)


s = input()
n = len(s)
print(sum((t != u for (t, u) in zip(s[:n // 2], s[::-1]))))


s = input()
m = len(s)
cnt = 0
for i in range(m // 2):
	if s[i] != s[-1 - i]:
		cnt += 1
print(cnt)


list_s = list(input())
count = 0
for i in range(0, len(list_s) // 2):
	if list_s[i] == list_s[0 - (i + 1)]:
		continue
	else:
		count += 1
print(count)


S = input()

def ans147(S: str):
	def_count = 0
	for i in range(int(len(S) / 2)):
		if S[i] != S[-(i + 1)]:
			def_count += 1
	return def_count
print(ans147(S))


n = input()
num = len(n) // 2
ans = 0
for i in range(num):
	if n[i] != n[len(n) - 1 - i]:
		ans += 1
print(ans)


a = list(input())
c = 0
for x in range(int(len(a) / 2)):
	if a[x] != a[-x - 1]:
		c += 1
print(c)


moji = str(input())
N = len(moji)
FM = moji[:N // 2]
if N % 2 == 0:
	LM = moji[-1:N // 2 - 1:-1]
else:
	LM = moji[-1:N // 2:-1]
ct = 0
for i in range(N // 2):
	if FM[i] != LM[i]:
		ct += 1
print(ct)


s1 = input()
s2 = s1[::-1]
print(sum([1 for i in range(len(s1)) if s1[i] != s2[i]]) // 2)


s = input()
print(sum((1 for (a, b) in zip(s, reversed(s)) if a != b)) // 2)


s = input()
cnt = 0
for (i, j) in zip(s, s[::-1]):
	if i != j:
		cnt += 1
print(cnt // 2)


import math
s = input()
count = 0
for i in range(0, math.floor(len(s) / 2)):
	if s[i] != s[len(s) - i - 1]:
		count = count + 1
print(count)


def solve(S: str):
	return sum([a != b for (a, b) in zip(S, reversed(S))]) // 2

def main():
	S = input().strip()
	answer = solve(S)
	print(answer)

def __starting_point():
	main()
__starting_point()


S = input()
if len(S) % 2 == 0:
	S_left = list(S)[:int(len(S) / 2)]
	S_right = list(S)[int(len(S) / 2):][::-1]
else:
	S_left = list(S)[:int(len(S) // 2)]
	S_right = list(S)[int(len(S) / 2) + 1:][::-1]
ans = 0
for i in range(len(S_left)):
	if S_left[i] != S_right[i]:
		ans += 1
print(ans)


from operator import ne
S = input()
n = len(S)
print(sum(map(ne, S[:n // 2], S[n // 2:][::-1])))


s = input()
print(sum((x != y for (x, y) in zip(s, reversed(s)))) // 2)


s = input()
(l, r) = (0, len(s) - 1)
c = 0
while l < r:
	if s[l] != s[r]:
		c += 1
	l += 1
	r -= 1
print(c)


r = 0
s = input()
for n in range(len(s)):
	if s[n] != s[-n - 1]:
		r += 1
print(r // 2)


s = input()
n = len(s)
print(sum((1 for i in range(n // 2) if s[i] != s[n - 1 - i])))


s = str(input())
n = len(s)
cnt = 0
for i in range(n // 2):
	if s[i] != s[n - 1 - i]:
		cnt += 1
print(cnt)


s = input()
length = len(s) // 2
count = 0
for i in range(length):
	if s[i] != s[-(i + 1)]:
		count += 1
print(count)


s = str(input())
print(sum((i < j for (i, j) in zip(s, s[::-1]))))


S = input()
cnt = 0
for i in range(int(len(S) / 2)):
	if S[i] == S[len(S) - 1 - i]:
		continue
	else:
		cnt += 1
print(cnt)


S = input()
l = len(S) // 2
ans = sum((1 for i in range(l) if S[i] != S[-1 - i]))
print(ans)


s = input()
print(sum((i != j for (i, j) in zip(s, s[::-1]))) // 2)


s = input()
cau = 0
l = len(s)
for j in range(l // 2 + l % 2):
	if s[j] != s[-1 - j]:
		cau = cau + 1
print(cau)


S = input()
count = 0
for i in range(len(S) // 2):
	count += S[i] != S[-(i + 1)]
print(count)


A = input()
c = 0
B = A[::-1]
for i in range(len(A)):
	if A[i] != B[i]:
		c += 1
print(c // 2)


s = list(input())
t = s[::-1]
c = 0
for (x, y) in zip(s, t):
	if x != y:
		c += 1
print(c // 2)


S = input()
c = 0
for i in range(int(len(S) / 2)):
	if S[i] != S[-i - 1]:
		c += 1
print(c)


s = input()
ans = 0
for (f, b) in zip(s, s[::-1]):
	if f != b:
		ans += 1
print(ans // 2)


s = input()
n = len(s)
sm = 0
for i in range(n // 2):
	sm += s[i] != s[n - i - 1]
print(sm)


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float('inf')
(YES, Yes, yes, NO, No, no) = ('YES', 'Yes', 'yes', 'NO', 'No', 'no')
(dy4, dx4) = ([0, 1, 0, -1], [1, 0, -1, 0])
(dy8, dx8) = ([0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1])

def inside(y, x, H, W):
	return 0 <= y < H and 0 <= x < W

def ceil(a, b):
	return (a + b - 1) // b

def sum_of_arithmetic_progression(s, d, n):
	return n * (2 * s + (n - 1) * d) // 2

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	g = gcd(a, b)
	return a / g * b

def solve():
	S = input()
	num = 0
	for i in range(len(S) // 2):
		num += S[i] != S[-i - 1]
	print(num)

def main():
	solve()

def __starting_point():
	main()
__starting_point()


A = input()
import math
times = math.ceil(len(A) / 2)
count = 0
for i in range(times):
	if A[i] != A[len(A) - 1 - i]:
		count += 1
print(count)


def main():
	S = input()
	count = 0
	for i in range(int(len(S) // 2)):
		if S[i] != S[-i - 1]:
			count += 1
	print(count)

def __starting_point():
	main()
__starting_point()


S = input()
cnt = 0
for i in range(len(S) // 2):
	cnt += S[i] != S[-i - 1]
print(cnt)


S = input()
answer = 0
if S == S[::-1]:
	print(0)
	return
for i in range(len(S) // 2):
	if S[i] != S[-(i + 1)]:
		answer += 1
print(answer)


ss = input()
cnt = 0
for i in range(len(ss) // 2):
	if ss[i] != ss[-1 * (i + 1)]:
		cnt += 1
print(cnt)


s = list(input())
b = 0
for a in range(int(len(s) / 2)):
	if s[a] != s[len(s) - a - 1]:
		b = b + 1
print(b)


S = input()
s1 = S[:len(S) // 2]
s2 = S[len(S) // 2 + len(S) % 2:]
s2 = s2[::-1]
count = 0
for i in range(len(s1)):
	if s1[i] != s2[i]:
		count += 1
print(count)


s = input()
c = 0
for (n, r) in zip(s[:len(s) // 2], s[::-1]):
	if not n == r:
		c += 1
print(c)


def main():
	s = input()
	print(sum((s[i] != s[-1 - i] for i in range(len(s) // 2))))
main()


l = input()
n = len(l)
cnt = 0
for i in range(n // 2):
	if l[i] != l[-i - 1]:
		cnt += 1
print(cnt)


S = input()
print(sum((s != t for (s, t) in zip(S, S[::-1]))) // 2)


S = input()
N = len(S)
print(sum(map(lambda x: x[0] != x[1], zip(S[:N // 2], S[::-1]))))


s = input()
l = len(s)
c = 0
for k in range(l // 2):
	if s[k] != s[l - 1 - k]:
		c += 1
print(c)


S = input()
listS = list(S)
cnt = 0
if len(S) % 2 == 0:
	for i in range(len(S) // 2):
		if S[i] != S[-(i + 1)]:
			cnt += 1
else:
	for i in range(len(S) // 2):
		if S[i] != S[-(i + 1)]:
			cnt += 1
print(cnt)


def resolve():
	s = input()
	n = len(s)
	a = s[:n // 2]
	b = s[::-1][:n // 2]
	cnt = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			cnt += 1
	print(cnt)
resolve()


S = input()
num = len(S) // 2
if num % 2 == 0:
	for i in range(num):
		if S[i] == S[-i - 1]:
			num -= 1
else:
	for i in range(num):
		if S[i] == S[-i - 1]:
			num -= 1
print(num)


import math
import collections
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))
s = input()
cnt = 0
for i in range(len(s) // 2):
	if s[i] != s[-1 - i]:
		cnt += 1
print(cnt)


S = input()
length = len(S)
if length % 2 == 0:
	length = int(length / 2)
	S_half_1 = S[:length]
	S_half_2 = S[length:]
	S_half_2 = S_half_2[::-1]
else:
	length = int(length // 2)
	S_half_1 = S[:length]
	S_half_2 = S[length + 1:]
	S_half_2 = S_half_2[::-1]
ans = 0
for i in range(length):
	if S_half_1[i] != S_half_2[i]:
		ans += 1
print(ans)


s = input()
l = len(s)
ret = 0
for i in range(l):
	ret += s[i] != s[-i - 1]
print(ret // 2)


a = input()
b = a[::-1]
ans = [1 for i in range(len(a)) if a[i] != b[i]]
print(sum(ans) // 2)


s = input()
print(sum(map(lambda i: 1 if s[i] != s[-(i + 1)] else 0, range(len(s) // 2))))


s = input()
a = 0
i = 0
while i < len(s) / 2:
	if s[i] != s[-i - 1]:
		a += 1
	i += 1
print(a)


s = input()
l = sum((x != y for (x, y) in zip(s, s[::-1])))
print((l + 1) // 2)


a = list(input())
b = a[::-1]
count = 0
for i in range(len(a)):
	if a[i] != b[i]:
		count += 1
print(count // 2)


s = str(input())
print(sum((a < b for (a, b) in zip(s, s[::-1]))))


s = input()
if len(s) % 2 == 0:
	s1 = s[:len(s) // 2]
	s2 = s[:len(s) // 2 - 1:-1]
else:
	s1 = s[:len(s) // 2]
	s2 = s[:len(s) // 2:-1]
ans = 0
for i in range(len(s1)):
	if s1[i] != s2[i]:
		ans += 1
print(ans)


S = input()
a = 0
for i in range(len(S) // 2):
	a += S[i] != S[-1 - i]
print(a)


s = input()
print(sum([a != b for (a, b) in zip(s, s[::-1])]) // 2)


a = list(input())
num = len(a)
count = 0
for i in range(len(a) // 2):
	if a[i] == a[num - 1 - i]:
		pass
	else:
		count += 1
print(count)


s = input()
count = 0
for x in range(len(s) // 2):
	if s[x] != s[-x - 1]:
		count += 1
print(count)


s = input()
print(len([True for i in range(len(s) // 2) if s[i] != s[-1 - i]]))


s = input()
mid = len(s) // 2
q = s[:mid]
if len(s) % 2 == 0:
	t = list(s[mid:])
else:
	t = list(s[mid + 1:])
t.reverse()
cnt = 0
for i in range(mid):
	cnt += s[i] != t[i]
print(cnt)


S = input()

def kaibun():
	count = 0
	for i in range(int(len(S) / 2)):
		if S[i] != S[len(S) - 1 - i]:
			count += 1
	return count
print(kaibun())


s = input()
n = -int(-len(s) // 2)
print(sum((i != j for (i, j) in zip(s[:n], s[::-1]))))


S = input()
T = S[::-1]
a = 0
for (s, t) in zip(S, T):
	if s != t:
		a += 1
print(a // 2)


s = input()
print(sum((i != j for (i, j) in zip(s[:len(s) // 2], reversed(s[round(len(s) / 2):])))))


S = str(input())
N = len(S)
half = (N + 1) // 2
ans = 0
for i in range(half):
	if S[i] != S[N - 1 - i]:
		ans += 1
print(ans)


from sys import stdin, stdout

def solve():
	s = input()
	left = 0
	right = len(s) - 1
	count = 0
	while left < right:
		count += s[left] != s[right]
		left += 1
		right -= 1
	print(count)

def main():
	solve()

def __starting_point():
	main()
__starting_point()


s = list(input())
n = len(s) // 2
cnt = 0
L = s[:n]
R = s[-n:][::-1]
for (l, r) in zip(L, R):
	if l != r:
		cnt += 1
print(cnt)


l = list(input())
c = 0
n = len(l)
for i in range(n // 2):
	if l[i] != l[n - i - 1]:
		c += 1
print(c)


s = list(input())
m = len(s) // 2
cnt = 0
for num in range(m):
	if s[num] != s[-1 + -1 * num]:
		cnt += 1
print(cnt)