Harryxun/stf_run huggingface dataset:
#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
import numpy as np
N,Q=[int(i) for i in input().split()]
S=list(input())
hani=[[int(i) for i in input().split()] for j in range(Q)]
ACindex=np.array([S[i]=="A" and S[i+1]=="C" for i in range(N)])
for j in hani:
    print(sum(ACindex[j[0]-1:j[1]-1]))

### FIXED CODE ###

#ACを検索して開始位置をインデックスにしておき、それを操作すれば多少はマシか
import numpy as np
N,Q=[int(_) for _ in input().split()]
S=list(input())
hani=[[int(a) for a in input().split()] for j in range(Q)]
ACindex=[0]
cur=0
for i in range(N-1):
    cur+=S[i]=="A" and S[i+1]=="C"
    ACindex.append(cur)
ACindex.append(cur)
for j in hani:
    print(ACindex[j[1]-1]-ACindex[j[0]-1])
n,k=map(int,input().split())
hashmap=dict()
for i in range(k):
  d=int(input())
  for i in range(d):
    key=int(input())
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(i)==None:
    count+=1
print(count)

### FIXED CODE ###

n,k=map(int,input().split())
hashmap=dict()
for _ in range(k):
  d=int(input())
  arr=[int(p) for p in input().split()]
  for key in arr:
    hashmap[key]=d
count=0
for i in range(1,n+1):
  if hashmap.get(i)==None:
    count+=1
print(count)
to = [[] for _ in range(200005)]
ans: list


def dfs(v, p=-1):
    global ans
    for u in to[v]:
        if u == p: continue
        ans[u] += ans[v]
        dfs(u, v)
    return


def main():
    N, Q = map(int, input().split())
    for _ in range(N-1):
        a, b = map(int, input().split())
        to[a-1].append(b-1)
        to[b-1].append(a-1)
    
    global ans
    ans = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        ans[p-1] += x
    dfs(0)
    print(*ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


sys.setrecursionlimit(300000)

to = [[] for _ in range(200005)]
ans: list


def dfs(v, p=-1):
    global ans
    for u in to[v]:
        if u == p: continue
        ans[u] += ans[v]
        dfs(u, v)
    return


def main():
    N, Q = map(int, input().split())
    for _ in range(N-1):
        a, b = map(int, input().split())
        to[a-1].append(b-1)
        to[b-1].append(a-1)
    global ans
    ans = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        ans[p-1] += x
    dfs(0)
    print(*ans)


if __name__ == "__main__":
    main()
n = int(input())
ans = [0 for _in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v=i*i+j*j+k*k+i*j+j*k+k*i;
            if v<10050:
            	ans[v]+=1
for i in range(n):
	print(ans[i+1])

### FIXED CODE ###

l, r, d = map(int, input().split())
print(r//d - (l-1)//d)
N = int(input())
H = list(map(int, input().split()))
key = 0
for i in range(N-1, 1, -1):
    if H[i]>H[i+1]:
      H[i]-=1
    if H[i]>H[i+1]:
      key += 1
      break
if key == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
 
for i in range(1, N):
    if H[i] < H[i - 1]:
        H[i] += 1
for i in range(1, N):
    if H[i] < H[i - 1]:
        print('No')
        exit(0)
print('Yes')
N=input();
N=int(N);
A=input().split();
print(A);
A = [int(s) for s in A];
sum =1;
if 0 in A:
  print(0);
  return
for i in range(N):
  if(A[i]==0):
    sum=0;
    break;
  sum=sum*A[i];
  #print(sum);
if sum> (10**18):
  sum=-1;
print(sum);

### FIXED CODE ###

A,B=input().split();
A=int(A);
B=int(B);
print(A*B);
n=input()
print("Yes" if n=n[::-1] else "No")

### FIXED CODE ###

n = input()
print("Yes" if n == n[::-1] else "No")
"""

問題文

すぬけ君は最初、ビスケットを 1 枚持っており、日本円は持っていません。 すぬけ君は、以下の操作を好きな順に合計ちょうど K 回行います。

    持っているビスケットを叩き、1 枚増やす
    ビスケット A 枚を 1 円に交換する
    1 円をビスケット B 枚に交換する

K 回の操作の後、すぬけ君が持っているビスケットの枚数の最大値を求めてください。
制約

    1≤K,A,B≤109
    K,A,B は整数である
"""

def func(K , A , B) : 
    if B >= A + 3 :
        #売って買ってで(B - A)枚手に入る(ただし2回消費する)
        #まずは手持ちをAまいに持っていく必要がある。
        #売って買ってをn回繰り返す
        #最後に１回余ったら1叩く
        # K - (A - 1) = 2 * n + r
        # K - (A - 1)を計算し、偶数であれば n*(B - A) + A (n = (K - A + 1) / 2)
        # 奇数であれば n = (K - A) / 2として n*(B - A) + A + 1
        if (K - A + 1) % 2 == 0 : 
            n = int((K - A + 1) / 2)
            return n * (B - A) + A 
        else : 
            n = int((K - A) / 2)
            return n*(B - A) + A + 1
    else : 
        #叩き続けたほうがいい
        return K + 1

if not func(4 , 2 , 6) == 7 : 
    print("test 1 fail")

if not func(7 , 3, 4) == 8 : 
    print("test 2 fail")

if not func(314159265 , 35897932 , 384626433) == 48518828981938099 : 
    print(f"{int(func(314159265 , 35897932 , 384626433)) } != 48518828981938099")
    print("test 3 fail")

s = input().split(" ")
print( int(func( int(s[0]) , int(s[1]) , int(s[2]) )) )

### FIXED CODE ###

def func(K , A , B) : 
    if B >= A + 3 :
        if (K - A + 1) % 2 == 0 : 
            n = int((K - A + 1) / 2)
            return n * (B - A) + A 
        else : 
            n = int((K - A) / 2)
            return n*(B - A) + A + 1
    else : 
        return K + 1


s = input().split(" ")
print( int(func( int(s[0]) , int(s[1]) , int(s[2]) )) )
def aaa(seat_list):
	return seat_list[len(seat_list)-1] - seat_list[0]+1

value = int(input())
people = 0
# while True:
# 	try:
# 		seat = input()
# 		if seat:
# 			string_seat = seat.split()
# 			seat_list = []
# 			seat_list = [int(x) for x in (string_seat)]
# 			people += aaa(seat_list)
# 	except EOFError:
# 		break
while True:
	seat = input()
	if seat:
		string_seat = seat.split()
		seat_list = []
		seat_list = [int(x) for x in (string_seat)]
		people += aaa(seat_list)
		print(people)
	else:
		break
print(people)


### FIXED CODE ###

value = int(input())
people = 0
while True:
	try:
		seat = input()
		if seat:
			string_seat = seat.split()
			seat_list = []
			seat_list = [int(x) for x in (string_seat)]
			people += seat_list[len(seat_list)-1] - seat_list[0]+1
	except EOFError:
		break
# while True:
# 	seat = input()
# 	if seat:
# 		string_seat = seat.split()
# 		seat_list = []
# 		seat_list = [int(x) for x in (string_seat)]
# 		people += aaa(seat_list)
# 	else:
# 		break
print(people)
n,k=map(int,input().split());print(sum(n//b*(b-k)+max(n%b-k+(k>0),0)for b in range(k,n+1)))

### FIXED CODE ###

n,k=map(int,input().split());print(sum(n//b*(b-k)+max(n%b-k+(k>0),0)for b in range(k+1,n+1)))
N, K = map(int, input().split())
S = list(input())

seq = []

flag = False
tmp = 0
for i in range(N-1):
    if S[i] != S[i+1]:
        tmp += 1
        seq.append(tmp)
        tmp = 0
            
    else:
        tmp += 1

res1 = []     
res2 = []

seq.append(tmp+1)

seq_sum = [0 for _ in range(len(seq)+1)]

for i in range(len(seq)):
    seq_sum[i+1] = seq_sum[i] + seq[i]

res = 1
if S[0] == '0':
    for i in range(len(seq_sum) - 2 * K - 1):
        if i%2 == 0:
            r = min(i + 2*K, len(seq_sum))
            res = max(res, seq_sum[r] - seq_sum[i]) 
        else:
            r = min(i + 2*K+1, len(seq_sum))
            res = max(res, seq_sum[r] - seq_sum[i])
        
else:
    for i in range(len(seq_sum) - 2 * K):
        if i%2 == 0:
            r = min(i + 2*K+1, len(seq_sum))
            res = max(res, seq_sum[r] - seq_sum[i])
        else:
            r = min(i + 2*K, len(seq_sum))
            res = max(res, seq_sum[r] - seq_sum[i]) 
 


print(res)

### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())

seq = []
tmp = 0
for i in range(N-1):
    if S[i] != S[i+1]:
        tmp += 1
        seq.append(tmp)
        tmp = 0
            
    else:
        tmp += 1

seq.append(tmp+1)

seq_sum = [0 for _ in range(len(seq)+1)]

for i in range(len(seq)):
    seq_sum[i+1] = seq_sum[i] + seq[i]

res = -1
if S[0] == '0':
    for i in range(len(seq_sum)):
        if i%2 == 0:
            r = min(i + 2*K, len(seq_sum)-1)
            res = max(res, seq_sum[r] - seq_sum[i]) 
        else:
            r = min(i + 2*K+1, len(seq_sum)-1)
            res = max(res, seq_sum[r] - seq_sum[i])
        
else:
    for i in range(len(seq_sum)):
        if i%2 == 0:
            r = min(i + 2*K+1, len(seq_sum)-1)
            res = max(res, seq_sum[r] - seq_sum[i])
        else:
            r = min(i + 2*K, len(seq_sum)-1)
            res = max(res, seq_sum[r] - seq_sum[i]) 

            
print(res)
n, a, b = [int(i) for i in input().split()]
X = [int(i) for i in input.split()]

ans = 0
for i in range(n-1):
  ans += min(a * X[i+1] - X[i], b)

print(ans)

### FIXED CODE ###

n, a, b = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

ans = 0
for i in range(n-1):
  ans += min(a * (X[i+1] - X[i]), b)

print(ans)
print(eval('(i*i)*i//2'.replace('i','int(input()')))

### FIXED CODE ###

a,b,c,d=eval('['+'int(input()),'*3+'0]');print((a+b)*c//2)
from itertools import combinations as c
n, *d = map(sorted, open(0).read().split())
print(sum(d[i[0]] == d[i[1]] for i in c(range(int(*n)), 2)))

### FIXED CODE ###

d = {}
c = 0
for i in open(0):
    i = str(sorted(i))
    t = d.get(i, 0)
    c += t
    d[i] = t + 1
print(c)
S = input()
N = len(S)
plus_flag = [0] * (N - 1)


def calc(flags):
    val = 0
    num_begin_index = 0
    num_end_index = None
    for flag_index in range(len(flags)):
        if flags[flag_index] == 0:
            continue
        num_end_index = flag_index + 1
        val += int(S[num_begin_index:num_end_index])
        num_begin_index = num_end_index
    num_end_index = len(flags) + 1
    val += int(S[num_begin_index:num_end_index])
    return val


def calc_sum(index, flag):
    plus_flag[index] = flag
    if index == len(plus_flag) - 1:
        return calc(plus_flag)
    return calc_sum(index + 1, 0) + calc_sum(index + 1, 1)


print(calc_sum(0, 0) + calc_sum(0, 1))

### FIXED CODE ###

S = input()
N = len(S)
plus_flag = [0] * (N - 1)


def calc(flags):
    val = 0
    num_begin_index = 0
    num_end_index = None
    for flag_index in range(len(flags)):
        if flags[flag_index] == 0:
            continue
        num_end_index = flag_index + 1
        val += int(S[num_begin_index:num_end_index])
        num_begin_index = num_end_index
    num_end_index = len(flags) + 1
    val += int(S[num_begin_index:num_end_index])
    return val


def calc_sum(index, flag):
    plus_flag[index] = flag
    if index == len(plus_flag) - 1:
        return calc(plus_flag)
    return calc_sum(index + 1, 0) + calc_sum(index + 1, 1)


if N == 1:
    print(S)
else:
    print(calc_sum(0, 0) + calc_sum(0, 1))
a,b=map(int,input().split())
if (b-1)¥(a-1)==0:
    c=int((b-1)/(a-1))
else:
    c=int((b-1)/(a-1))+1
print(c)

### FIXED CODE ###

a,b=map(int,input().split())
if (b-1)%(a-1)==0:
    c=int((b-1)/(a-1))
else:
    c=int((b-1)/(a-1))+1
print(c)
D=int(input("Enter a number in the range of 0 and 10000 10000: "))
T=int(input("Enter a number in the range of 0 and 10000: "))
S=int(input("Enter a number in the range of 0 and 10000: "))

if (D and T) and S <=10000 and D/S==T:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

D,T,S= [int(x) for x in input().split()]
if 1<=(D and T)<=10000 and (1<=S<=10000 and D/S<=T):
    print("Yes")
else:
    print("No")
# B - ATCoder
S = int(input())
ans = 0
tmp = 0
for i in range(len(S)):
    if S[i] in ['A','C','G','T']:
        tmp += 1
    else:
        ans = max(ans,tmp)
        tmp = 0
ans = max(ans,tmp)
print(ans)

### FIXED CODE ###

# B - ATCoder
S = input()
ans = 0
tmp = 0
for i in range(len(S)):
    if S[i] in ['A','C','G','T']:
        tmp += 1
    else:
        ans = max(ans,tmp)
        tmp = 0
ans = max(ans,tmp)
print(ans)
n = int(input())
if n%2 == 0:
  print(n):
else:
  print(2*n)

### FIXED CODE ###

n = int(input())
if n%2 == 0:
  print(n)
else:
  print(2*n)
N = int(input())

lis = []

lis = list(map(int,input().split()))

first = []

for i in range(N):
  first[lis[i]] = i + 1
  
for i in range(N):
  print(first[i],end=' ')

### FIXED CODE ###


N = int(input())
lis = []
lis = list(map(int,input().split()))
first = [0]*N

for i in range(N):
    num = lis[i] - 1
    first[num] = i

for i in range(N):
    print(first[i]+1,end=' ')
print()
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

count = 0
tmp = 1
for i in range(1, N):
    if A[i] == A[i - 1]:
        tmp += 1
    else:
        # 等しくなくなったら
        count += tmp // 2
        tmp = 1  # tmp のリセット

print(count)


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(i) for i in input().split()] + [0]

count = 0
tmp = 1
for i in range(1, N+1):
    if A[i] == A[i - 1]:
        tmp += 1
    else:
        # 等しくなくなったら
        count += tmp // 2
        tmp = 1  # tmp のリセット

print(count)
import sys
sys.setrecursionlimit(10 ** 6)

n, m = list(map(int, input().split()))
data = [[] for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    data[a-1].append(b-1)
    data[b-1].append(a-1)

ans = 0


def dfs(pos, cnt, his):
    global ans
    his[pos] = 1
    if cnt == n:
        if sum(his) == n:
            ans += 1
        return

    for next in data[pos]:
        dfs(next, cnt+1, his[:])
    return


dfs(0, 1, [0]*n)
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n, m = list(map(int, input().split()))
data = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    data[a-1].append(b-1)
    data[b-1].append(a-1)

ans = 0


def dfs(pos, cnt, his):
    global ans
    his[pos] = 1
    if cnt == n:
        if sum(his) == n:
            ans += 1
        return

    for next in data[pos]:
        dfs(next, cnt+1, his[:])


dfs(0, 1, [0]*n)
print(ans)
N=int(input())
S=input()

ans=0
for i in range(len(S)):
    a=set(S[:i])
    b=set(S[i:])
    if a&b>ans:
    	ans=a&b
print(ans)

### FIXED CODE ###

N=int(input())
S=input()

ans=0
for i in range(len(S)):
    a=set(S[:i])
    b=set(S[i:])
    if len(a&b)>ans:
    	ans=len(a&b)
print(ans)
n = int(input())
h = list(map(int,input().split()))
a = [0 for _ in range(n)]
a[1] = abs(h[1]-h[0])
for i in range(2,n):
  a[i] = min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[n])
  
  

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
a = [0 for _ in range(n)]
a[1] = abs(h[1]-h[0])
for i in range(2,n):
  a[i] = min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[n-1])
def prm(x):
  if x == 1 or x == 4:
    return False
  for i in range(1,int(x**0.5+1)):
    if x%i == 0:
      return False
  return True
for i in range(X,X**2):
  if prm(i):
    print(i)
    break

### FIXED CODE ###

def prm(x):
  if x == 1 or x == 4:
    return False
  for i in range(2,int(x**0.5+1)):
    if x%i == 0:
      return False
  return True
X=int(input())
for i in range(X,X**2):
  if prm(i):
    print(i)
    break
import numpy as np
N, M, V, P = map(int, input().strip().split())
A = sorted(list(map(int, input().strip().split())),reverse=True)
ans=0

for i in range(N):
    thre=A[i]+M
    if thre < A[P-1]:
        continue

    remain=V-(P-1)-(N-i)
    if remain <=0:
        ans+=1
    elif sum(A[P-1:i])+M*remain <= thre*(i-1-(P-1)+1):
        ans+=1
print(ans)

### FIXED CODE ###

n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = p
c = [0]
cnt = 0
for i in range(n):
  # 累積和
  cnt += a[i]
  c.append(cnt)
  
from bisect import bisect_right
for i in range(p,n):
  h = a[i]+m
  free = v - (p-1) - (n-i)
  if free >= 0 and h >= a[p-1]:
    d = h * (i-p+1) - (c[i]-c[p-1]) # 余裕
    if d >= free*m:
      ans += 1
  else:
    if h >= a[p-1]:
      ans += 1
print(ans)
from functools import lru_cache

#@lru_cache(maxsize=1000)
def fx(H,atk,MP):
  if H <= 0:
    return 0
  arr = []
  for i in range(len(atk)):
    b = fx(H - atk[i],atk,MP) + MP[i]
    arr.append(b)   
  return min(arr)
  
H,N = map(int,input().split())
atk=[]
MP=[]
for i in range(N):
  n,a=input().split()
  atk.append(int(n))
  MP.append(int(a))

a = fx(H,atk,MP)

print(a)

### FIXED CODE ###

def knapsack(N,W,weight,value):
  #初期化
  inf=float("inf")
  dp=[[inf for i in range(W+1)] for j in range(N+1)]
  dp[0][0]= 0
  #DP
  for i in range(N):
    for w in range(W+1):
      if 0 <= w-weight[i]: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある
        dp[i+1][w]=min(dp[i+1][w-weight[i]]+value[i], dp[i][w])
      else:
        dp[i+1][w]=dp[i][w]
  return dp
 
H,N = map(int,input().split())
 
weight=[]
value=[]
for i in range(N):
    n,a=input().split()
    weight.append(int(n))
    value.append(int(a))
MAX = max(weight)
dp = knapsack(N,H+MAX,weight,value)
 
print(min(dp[N][H:H+MAX]))
n,x=map(int,input().split())
L=list(map(int,input().split()))
c=0
s=0
while(s<=x):
    s+=L[c]
    c+=1
print(c)

### FIXED CODE ###

n,x=map(int,input().split())
L=list(map(int,input().split()))
c=0
s=0
while(s<=x):
    if c == n:
        c+=1
        break
    s+=L[c]
    c+=1

print(c)
s=str(input())
print(s.reprace("2017"."2018"))

### FIXED CODE ###

s=str(input())
print(s.replace("2017","2018"))
a,b=map(int(input().split()))
cnt = 1
b -= a
if b == 1:
  print('0')
while True:
  if b > 0:
  	b -= (a - 1)
    cnt += 1
  else:
    print(cnt)
    break


### FIXED CODE ###

a,b=map(int,input().split())

if b == 1:
  print('0')
else:
  cnt = 1
  b -= a
  while True:
    if b > 0:
      b -= (a - 1)
      cnt += 1
    else:
      print(cnt)
      break
n, k = map(int, input().split())
m = n
while m > 0:
  n = min(abs(n - k), m)
  if m > n:
      m = n
  else:
      print(n)
      break

### FIXED CODE ###

a, b, c = map(int, input().split())
print(c, a, b)
a=int(input().split(" "))
a1,a2,a3=int(a[0]),(a[1]),int(a[2])
ans="No"
if a1!=a2 and (a1==a3 or a2==a3):
  ans="Yes"
if a1!=a3 and (a1==a2 or a2==a3):
  ans="Yes"
if a2!=a3 and (a1==a2 or a1==a3):
  ans="Yes"
  
print(ans)

### FIXED CODE ###

a=input().split(" ")
a1,a2,a3=int(a[0]),int(a[1]),int(a[2])
ans="No"
if a1!=a2 and (a1==a3 or a2==a3):
  ans="Yes"
if a1!=a3 and (a1==a2 or a2==a3):
  ans="Yes"
if a2!=a3 and (a1==a2 or a1==a3):
  ans="Yes"
  
print(ans)
a,b,c,d=map(int,input().split())
x=int((a+d-1)/d)
y=int((c+b-1)/c)
 
if x>=y:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

s,w=map(int,input().split())
if s <= w:
    print("unsafe")
else:
    print("safe")
if (N%500==0):
  print Yes
  if(N%500<=A)
  print Yes

### FIXED CODE ###

N = int(input())
A = int(input())
if N % 500 <= A:
  print('Yes')
else:
  print('No')
\def LCS():
  x = raw_input()
  y = raw_input()
  X = len(x)
  Y = len(y)
  for i in range(X):
    c[i][0] = 0
  for j in range(Y):
    c[0][j] = 0
 
  for i in range(X):
    for j in range(Y):
      if X[i] == Y[i]: 
        c[i][j] = c[i - 1][j - 1] + 1
 
      else:
        c[i][j] = max(c[i - 1][j], c[i][j - 1])
         
 
  print max(c)
 
q = input()
 
for i in xrange(q):
  LCS

### FIXED CODE ###

def LCS():
    X = raw_input()
    Y = raw_input()
 
    a, b = len(X), len(Y)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = X[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == Y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i in range(n):
    print LCS()
def main():
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    h_s = sorted(h)
    if len(h_s) <= k:
        ans = 0
    else:
        for _ in range(k):
            h_s.pop()
        ans = sum(h_s)
    print(ans)

if __name__ == '__main__':
    main(

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    h_s = sorted(h)
    if len(h_s) <= k:
        ans = 0
    else:
        for _ in range(k):
            h_s.pop()
        ans = sum(h_s)
    print(ans)

if __name__ == '__main__':
    main()
#include <iostream>
using namespace std;

int main()
{
　　int x, y;
　　while(true) {
　　  cin >> x >> y;
　　  if(x == 0 && y == 0) {
　　    break;
　　  }
　　  if(x>y) {
　　    cout << y << " " << x << endl;
　　  }
　　  else {
　　    cout << x << " " << y << endl;
　　  }
　　}
}


### FIXED CODE ###

while True:
  x, y = map(int, input().split())
  if x == 0 and y == 0 :
    break
  if x>y:
    print(y, x)
  else:
    print(x,y)
def main():
  s=0
  S=input()
  N=len(S)
  for i in range(N//2);
    if S[i]!=S[N-1-i]:
      S[N-1-i]=S[i]
      s+=1
  print(s)
main()

### FIXED CODE ###

def main():
  S=input()
  s=0
  N=len(S)
  for i in range(N//2):
    if S[i]!=S[N-1-i]:
      s+=1
  print(s)
main()
#a,b,c = map(int,inpput().split(" "))
#n = int(input())
#print(a,b,c)
t=[]
for i in range(5):
    t.append(int(input()))
#n = int(input())
def dif(x):
    s = int(a/10)
    return (s+1)*10 -x

def comp(a,b):
    a1 = dif(a)
    b1 = dif(b)
    return a1 < b1
d = sorted(t, cmp=dif(a,b), reverse=True)

sum = 0
for i in range(4):
    if int(d[i]/10)*10 ==d[i]:
        sum = sum+d[i]
    else:
        sum += (int(d[i]/10)+1)*10
print(sum + d[4])

### FIXED CODE ###

#a,b,c = map(int,inpput().split(" "))
#n = int(input())
#print(a,b,c)
t=[]
for i in range(5):
    t.append(int(input()))
#n = int(input())
def dif(x):
    s = int(x/10)
    if s * 10 == x:
        return 0
    else:
        return (s+1)*10 -x

def comp(a,b):
    a1 = dif(a)
    b1 = dif(b)
    return a1 < b1
d = sorted(t, key=lambda x: dif(x))

sum = 0
for i in range(4):
    if int(d[i]/10)*10 ==d[i]:
        sum = sum+d[i]
    else:
        sum += (int(d[i]/10)+1)*10
print(sum + d[4])
N = int(input())
points = []
for _ in range(N):
    x, y = map(int, input().split())
    points.append((x, y))
diff = dict()
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = points[i]
        x2, y2 = points[j]
        pq = x1-x2, y1-y2
        diff[pq] = diff.get(pq, 0) + 1
val, key = max((v, k) for k, v in diff.items())
print(N-val)


### FIXED CODE ###

N = int(input())
if N == 1:
    print(1)
    quit()
points = []
for _ in range(N):
    x, y = map(int, input().split())
    points.append((x, y))
diff = dict()
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = points[i]
        x2, y2 = points[j]
        pq = x1-x2, y1-y2
        diff[pq] = diff.get(pq, 0) + 1
val, key = max((v, k) for k, v in diff.items())
print(N-val)
s=input()
ans=0
def dfs(v):#vはインデックス
    if 0<=v+1<=len(s)-1 and s[v+1]=='A':
        dfs(v+1)
    elif 0<=v+2<=len(s)-1 and s[v+1]=='B' and s[v+2]=='C':
        global ans
        ans+=1
        dfs(v+2)
    else:
        return
L=[]
for i,I in enumerate(s):
    if I=='A':
        L.append(i)
for l in L:
    dfs(l)
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
s=list(input())
ans=0
cA=1
L=[]
def dfs(v):#vはインデックス
    if 0<=v+1<=len(s)-1 and s[v+1]=='A':
        s[v+1]='#'
        global cA
        cA+=1
        dfs(v+1)
    elif 0<=v+2<=len(s)-1 and s[v+1]=='B' and s[v+2]=='C':
        global ans
        ans+=cA
        dfs(v+2)
    else:
        cA=1
        return

for i,I in enumerate(s):
    if I=='A':
        L.append(i)
for l in L:
    if (0<=l+1<=len(s)-1 and s[l]=='A'and s[l+1]=='A'):
        dfs(l)
    elif (0<=l+2<=len(s)-1 and s[l]=='A'and s[l+1]=='B'and s[l+2]=='C'):
        dfs(l)
    else:
        cA=1
print(ans)