Harryxun/stf_run huggingface dataset:
def resolve():
  N, M, X = map(int, input().split(" "))

  books = []
  for i in range(N):
    CA = [int(x) for x in input().split(" ")]
    books.append(CA)

  books = np.array(books)

  books_index_pattarns = [list(x) for i in range(1, N) for x in combinations(range(0, N), i)]
  books_result = np.array([np.sum(books[x], axis=0) for x in books_index_pattarns])
  # books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)]
  books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)][:,:1]
  if len(books_result) == 0:
    print("-1")
    return True
  else:
    print(books_result.min())
    return True

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

from itertools import product
from itertools import combinations
import numpy as np

def resolve():
  N, M, X = map(int, input().split(" "))

  books = []
  for i in range(N):
    CA = [int(x) for x in input().split(" ")]
    books.append(CA)

  books = np.array(books)


  if N == 1:
    if np.all(books[:, 1:] >= X):
      print(books[0][0])
    else:
      print(-1)
    return True
  books_index_pattarns = [list(x) for i in range(1, N+1) for x in combinations(range(0, N), i)]
  books_result = np.array([np.sum(books[x], axis=0) for x in books_index_pattarns])
  books_result = books_result[np.all(books_result[:,1:] >= X, axis=1)]

  if len(books_result) == 0:
    print(-1)
    return True
  elif len(books_result) == 1:
    print(books_result[0][0])
    return True
  else:
    # print(books_result)
    print(books_result[:,:1].min())
    return True

if __name__ == "__main__":
    resolve()
import fractions
n,m = map(int,input().split())
s = input()
t = input()

lcm = n*m // fractions.gcd(n,m)
i = lcm
cnt = 0
while True:
    ans = [''] * i
    ai = 0
    for si in range(0,n):

        ans[ai] = s[si]
        ai += lcm//n
    ai = 0
    flg = True
    for ti in range(m):
        if ans[ai] == '' or t[ti] == ans[ai]:
            ans[ai] = t[ti]
        else:
            flg = False
            break
        ai += lcm//m
    if flg :
        print(i)
        break
    i += lcm
    cnt += 1
    if cnt == 10000:
        print(-1)
        break


### FIXED CODE ###

import fractions
n,m = map(int,input().split())
s = input()
t = input()

lcm = n*m // fractions.gcd(n,m)
ans = -1
ss = lcm // m
ts = lcm // n
j = 0
flg = True
for i in range(0,n,ss):
    if s[i] == t[j] :
        j += ts
        continue
    else:
        flg = False
        break

if flg :
    ans = lcm
print(ans)
# https://atcoder.jp/contests/abc103/tasks/abc103_d

# ToDo not yet

# biについて昇順にソートする
# それぞれのbiについて、
# 1: すでに分断されているなら何もしない
# 2: 分断されていないならbi - 1番目の橋を切断する
from typing import List, Any

N, M = map(int, input().split())
demand_list = []
for _ in range(M):
    ai, bi = map(int, input().split())
    demand_list.append([ai, bi])

# ソート
demands = sorted(demand_list, key=lambda d: d[1])

# 分断開始 切断されている橋は1で表現される
cut_bilagge_list = [0 for _ in range(N)]

for demand in demands:
    # すでに分断されているのかをチェックする
    if len([1 for i in cut_bilagge_list[demand[0] - 1:demand[1] - 1] if i == 1]) > 0:
        continue

    # 分断されていないので bi - 2の橋を切断する
    cut_bilagge_list[demand[1] - 2] = 1


print(sum(1 for bilagge in cut_bilagge_list if bilagge == 1))


### FIXED CODE ###

# https://atcoder.jp/contests/abc103/tasks/abc103_d

# ToDo not yet

# biについて昇順にソートする
# それぞれのbiについて、
# 1: すでに分断されているなら何もしない
# 2: 分断されていないならbi - 1番目の橋を切断する

N, M = map(int, input().split())
demand_list = []
for _ in range(M):
    ai, bi = map(int, input().split())
    demand_list.append([ai, bi])

# ソート
demands = sorted(demand_list, key=lambda d: d[1])

# 分断開始 切断されている橋は1で表現される
# cut_bilagge_list = [0 for _ in range(N)]
cnt = 0
cut_max_len = -1

for demand in demands:
    a, b = demand
    # すでに分断されているのかをチェックする
    if a < cut_max_len:
        continue
    # if len([1 for i in cut_bilagge_list[demand[0] - 1:demand[1] - 1] if i == 1]) > 0:
    #     continue

    # 分断されていないので bi - 2の橋を切断する
    # cut_bilagge_list[demand[1] - 2] = 1
    cut_max_len = b
    cnt += 1

# print(sum(1 for bilagge in cut_bilagge_list if bilagge == 1))
print(cnt)
k = input()
w= input()
l = len(w)
if l <= k:
	print(w)
else:
	print(w[:k])


### FIXED CODE ###

k = int(input())
s = input()
if int(len(s)) <= k:
  	print(str(s))
else:
  	print(((str(s))[0:k]) + "...")
import sys
import math
from functools import reduce

N, M = map(int, input().split(" "))

a = list(set(map(int, input().split(" "))))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

s = lcm(*a)

if s > M:
    print(0)

else:
    m = s // 2
    print((M-m)//s + 1)

### FIXED CODE ###

N, M = map(int, input().split(" "))

a = list(set(map(int, input().split(" "))))
g = a.copy()

while not any(x%2 for x in g): g = [i //2 for i in g]

if not all(x%2 for x in g): print(0); exit(0)

def gcd(a, b):

    while b:

        a, b = b, a % b
    return a

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


tot = 1

for x in a: tot = lcm(tot, x//2)
print((M//tot+1)//2)
X = input()
x = int(X[-2] + X[-1])
X = (int(X)-x)//100
if x > 5*X:
    print(0)
else:
    print(1)


### FIXED CODE ###

X = input()
if int(X) < 100:
    print(0)
    exit()
x = int(X[-2] + X[-1])
X = (int(X)-x)//100
if x > 5*X:
    print(0)
else:
    print(1)
n = int(input())
a = input().split()
s = ''
iList = [[ 0 for i in range(n)] for i in range(n)]


MIN = 100
#iの時にa[i]人いた
#a[i]が小さい順に並べてその時のiを順番に出力
for i in range(n):
	a[i] = int(a[i])
	iList[i][0] = a[i]
	iList[i][1] = i+1

for i in range(n):
	for j in range(n):
		if iList[i][0] < iList[j][0]:
			t = iList[i]
			iList[i] = iList[j]
			iList[j] = t

s += str(iList[0][1])
for i in range(1,n):
	s += ' '
	s += str(iList[i][1])
	


print(s)


### FIXED CODE ###

n = int(input())
ans = []
A = list(map(int,input().split()))
A2 = [[0,i+1] for i in range(n)]

for i in range(n):
	A2[i][0] = A[i]
#print(A2)
A2 = sorted(A2,key = lambda x:x[0])

for i in range(n):
	ans.append(A2[i][1])
print(*ans)
s=list(input())
if len(set(s))==2 and list(s).count(s[0])==2:
  print("Yes")
else:
  print("No)


### FIXED CODE ###

s=input()
if len(set(s))==2 and list(s).count(s[0])==2:
  print("Yes")
else:
  print("No")
x = raw_input()

for a in list(str):
    if a.islower():
        print a.upper()
    elif a.isupper():
        print a.lower()
    else
        print a

### FIXED CODE ###

str = raw_input()
li = []
for a in list(str):
    if a.islower():
        li.append(a.upper())
    elif a.isupper():
        li.append(a.lower())
    else:
        li.append(a)
print "".join(li)
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10 ** 9 + 7
n, k, *ab = map(int, read().split())
m = iter(ab)
AB = zip(m, m)
graph = [[] for _ in range(n + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
ans = 1

kaidan = [0] * (k + 1)
kaidan[0] = 1
for i in range(1, k + 1):
    kaidan[i] = i * kaidan[i - 1]


def perm(k, i):
    if i > k:
        return 0
    return kaidan[k] // kaidan[k - i]


def dfs(v, p):
    global ans
    if p == -1:
        ans *= k * perm(k - 1, len(graph[v]))
        ans %= mod
    else:
        ans *= perm(k - 2, len(graph[v]) - 1)
        ans %= mod
    for u in graph[v]:
        if u == p:
            continue
        dfs(u, v)


dfs(1, -1)
print(ans)


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, k = map(int, readline().split())


graph = [[] for _ in range(n + 1)]
cnt = [0] * (n + 1)
for _ in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
    cnt[a] += 1
    cnt[b] += 1
ans = 1

mod = 10 ** 9 + 7
kaidan = [1] * (10 ** 5 + 1)
gyaku = [1] * (10 ** 5 + 1)

for i in range(1, 10 ** 5 + 1):
    kaidan[i] = i * kaidan[i - 1] % mod
    gyaku[i] = pow(kaidan[i], mod - 2, mod)


def perm(k, i):
    if i > k:
        return 0
    return kaidan[k] * gyaku[k - i]


# dfs

stack = [1]
used = [False] * (n + 1)
while stack:
    v = stack.pop()
    used[v] = True
    if v == 1:
        ans *= k * perm(k - 1, cnt[v])
        ans %= mod
    else:
        ans *= perm(k - 2, cnt[v] - 1)
        ans %= mod
    for u in graph[v]:
        if used[u] == True:
            continue
        stack.append(u)

print(ans)
import numpy as np
n = int(input())
a = [int(input()) for _ in range(n)]
t1 = max(a)
t1_idx = [i for i, v in enumerate(a) if v == t1]
a.sort()
t2 = a[-1*len(t1_idx)-1]
for i in range(n):
    if i in t1_idx:
        print(t2)
    else:
        print(t1)


### FIXED CODE ###

import numpy as np
n = int(input())
a = [int(input()) for _ in range(n)]
t1 = max(a)
t1_idx = [i for i, v in enumerate(a) if v == t1]
a.sort()

if len(t1_idx) < 2:
    try:
        t2 = a[-1*len(t1_idx)-1]
    except:
        for i in range(n):
            print(t1)

    for i in range(n):
        if i in t1_idx:
            print(t2)
        else:
            print(t1)
else:
    for i in range(n):
        print(t1)
A,B = mao (int, input ().split ())
if B%A == 0:
  print (A+B)
else:
  print (B-A)

### FIXED CODE ###

A,B = map (int, input ().split ())
if B%A == 0:
  print (A+B)
else:
  print (B-A)
from math import sqrt, ceil, factorial
def is_prime(num):
  for i in range(2, ceil(sqrt(num))+1):
    if num%i==0:
      return False
  return True

def permcnt(n, r):
  return factorial(n) // factorial(n-r)

def combcnt(n, r):
  return factorial(n) // (factorial(n-r)*factorial(r))

n = int(input())
pls = [2]
i=3
while i<=n:
  if is_prime(i):
    pls.append(i)
  i+=1

def factoring(num):
  return _factoring(num, dict())
  
def _factoring(num, p):
  for i in pls:
    if num % i == 0:
      if i in p:
        p[i] += 1
      else:
        p[i] = 1
      return _factoring(num//i, p)
  return p

factors = dict()
for i in range(1,n+1):
  for k, v in factoring(i).items():
    if k in factors:
      factors[k] += v
    else:
      factors[k] = v

      
maxe = max(factors.values())
cnt = 0

# 七五数がx^74の形となるケース
cnt += len(list(filter(lambda x:x[1]>=74, factors.items())))

# 七五数がx^2*y^24の形となるケース
xs = {k for k,v in factors.items() if 2<=v and v<24}
ys = {k for k,v in factors.items() if v>=24}
cnt += len(xs)*len(ys)
cnt += permcnt(len(ys), 2) if len(ys)>=2 else 0

# 七五数がx^4*y^14の形となるケース
xs = {k for k,v in factors.items() if 4<=v and v<14}
ys = {k for k,v in factors.items() if v>=14}
cnt += len(xs)*len(ys)
cnt += permcnt(len(ys), 2) if len(ys)>=2 else 0

# 七五数がx^2*y^5*z^5の形となるケース
xs = {k for k,v in factors.items() if 2<=v and v<4}
ys = {k for k,v in factors.items() if v>=4}
cnt += len(xs)*combcnt(len(ys),2) if len(ys)>=2 else 0
cnt += 3*combcnt(len(ys.keys()), 3) if len(ys)>=3 else 0

print(cnt)

### FIXED CODE ###

from math import sqrt, ceil, factorial
def is_prime(num):
  for i in range(2, ceil(sqrt(num))+1):
    if num%i==0:
      return False
  return True

def permcnt(n, r):
  return factorial(n) // factorial(n-r)

def combcnt(n, r):
  return factorial(n) // (factorial(n-r)*factorial(r))

n = int(input())
pls = [2]
i=3
while i<=n:
  if is_prime(i):
    pls.append(i)
  i+=1

def factoring(num):
  return _factoring(num, dict())
  
def _factoring(num, p):
  for i in pls:
    if num % i == 0:
      if i in p:
        p[i] += 1
      else:
        p[i] = 1
      return _factoring(num//i, p)
  return p

factors = dict()
for i in range(1,n+1):
  for k, v in factoring(i).items():
    if k in factors:
      factors[k] += v
    else:
      factors[k] = v

cnt = 0

# 七五数がx^74の形となるケース
cnt += len(list(filter(lambda x:x[1]>=74, factors.items())))

# 七五数がx^2*y^24の形となるケース
xs = {k for k,v in factors.items() if 2<=v and v<24}
ys = {k for k,v in factors.items() if v>=24}
cnt += len(xs)*len(ys)
cnt += permcnt(len(ys), 2) if len(ys)>=2 else 0

# 七五数がx^4*y^14の形となるケース
xs = {k for k,v in factors.items() if 4<=v and v<14}
ys = {k for k,v in factors.items() if v>=14}
cnt += len(xs)*len(ys)
cnt += permcnt(len(ys), 2) if len(ys)>=2 else 0

# 七五数がx^2*y^5*z^5の形となるケース
xs = {k for k,v in factors.items() if 2<=v and v<4}
ys = {k for k,v in factors.items() if v>=4}
cnt += len(xs)*combcnt(len(ys),2) if len(ys)>=2 else 0
cnt += 3*combcnt(len(ys), 3) if len(ys)>=3 else 0

print(cnt)
from collections import Counter
import itertools
n, k = map(int, input().split())
d = []
sunuke = []
for i in range(k * 2 - 2):
    d.append(int(input()))
    sunuke.append(list(map(int, input().split())))

new = list(itertools.chain.from_iterable(sunuke))

c = Counter(new)

print(n - len(c))

### FIXED CODE ###

from collections import Counter
import itertools
n, k = map(int, input().split())
d = []
sunuke = []
for i in range(k):
    d.append(int(input()))
    sunuke.append(list(map(int, input().split())))

new = list(itertools.chain.from_iterable(sunuke))

c = Counter(new)

print(n - len(c))
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
C = []

for i in range(50):
    C.append(["#"] * 100)
for i in range(50):
    C.append(["."] * 100)

h = 0
w = 0
for i in range(A-1):
    C[h][w] = "."
    w += 2
    if w >= 100:
        # 端まで行ったら最初っから
        w = 0
        # 一行開けて下に書く
        row += 2

# 下から．二次元でもできる．
h = -1
w = 0

for i in range(B-1):
    C[h][w] = "#"
    w += 2
    if w >= 100:
        # 端まで行ったら最初っから
        w = 0
        # 一行開けて下に書く
        h -= 2

print(100, 100)
for i in range(100):
    print(*C[i], sep="")

### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
C = []

for i in range(50):
    C.append(["#"] * 100)
for i in range(50):
    C.append(["."] * 100)

h = 0
w = 0
for i in range(A-1):
    C[h][w] = "."
    w += 2
    if w >= 100:
        # 端まで行ったら最初っから
        w = 0
        # 一行開けて下に書く
        h += 2

# 下から．二次元でもできる．
h = -1
w = 0

for i in range(B-1):
    C[h][w] = "#"
    w += 2
    if w >= 100:
        # 端まで行ったら最初っから
        w = 0
        # 一行開けて下に書く
        h -= 2

print(100, 100)
for i in range(100):
    print(*C[i], sep="")
def f(i,ans,l):
  if (i+1) == (len(l)-1):
    return max(ans,l[i+1]-l[i])
  else:
    return f(i+1,max(ans,l[i+1]-l[i]),l)
n = input("")
an = input("").split(" ")
ani = [int(a) for a in an]
print(str(f(0,0,ani)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000000)
def f(i,ans,l,t):
  if (i+1) == (len(l)-1):
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return t+ans
    else:
      return t
  else:
    if (ans+l[i]) > l[i+1]:
      ans = ans + l[i]-l[i+1]
      return f(i+1,ans,l,t+ans)
    else:
      return f(i+1,0,l,t)
n = input("")
an = input("").split(" ")
ani = [int(a) for a in an]
if len(ani) == 1:
  print("0")
else:
  print(str(f(0,0,ani,0)))
n,a,b = map(int, raw_input().split())
print(min(n*a, b))


### FIXED CODE ###

n,a,b = map(int, raw_input().split())
print(min(n*a, b))
A,B,C,D=map(int,input().split())
if (A+B)%2!=0:
  print((A+B)//2+1)
else:
  print((A+B)//2)

### FIXED CODE ###

A,B=map(int,input().split())
if (A+B)%2!=0:
  print((A+B)//2+1)
else:
  print((A+B)//2)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b = map(int, input().split())

print(lcm(a, b))

### FIXED CODE ###

from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
a, b = map(int, input().split())

print(lcm(a, b))
import random
for _ in range(365):
  print(random.randint(1:26))

### FIXED CODE ###

import random
import numpy as np

def scoring(t,d,c,s):
  for day in range(d):
    t[day]=t[day]-1
  last=[0 for _ in range(26)]
  score=0
  for day in range(d):
    score=score+s[day][t[day]]
    score=score+c[t[day]]*(day-last[t[day]])*(d-day)
    last[t[day]]=day
  return score

d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(d)]
t=[0 for _ in range(d)]
last=[-1 for _ in range(26)]
for day in range(d):
  s_d=s[day]
  for i in range(26):
    s_d[i]=s_d[i]+c[i]*(day-last[i])*(d-day)
#  print(s_d)
  max_value = max(s_d)
  max_index = s_d.index(max_value)
  t[day]=max_index+1
  last[max_index]=day
for i in range(d):
  print(t[i])
#print(scoring(t,d,c,s))
N = input()
a=list(map(int,raw_input().split()))
print(a)
for i in range(1,N):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(a)

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]
for i in range(N):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(*a)
import fractions
N,X = map(int,input().split())
l = list(map(lambda x: abs(int(x)-X),input().split()))
print(reduce(fractions.gcd,l))

### FIXED CODE ###

import fractions
from functools import reduce
N,X = map(int,input().split())
l = list(map(lambda x: abs(int(x)-X),input().split()))
print(reduce(fractions.gcd,l))
s = input()
t = input()

ans = len(s)

for i in range(len(s)):
  if i + len(t) - 1 >= len(s):break;
    dif=0
    for j in range(len(t)):
      if s[i+j] != t[j]:
        dif += 1
    ans = min(ans, dif)
print(ans)

### FIXED CODE ###

s = input()
t = input()

ans = len(s)

for i in range(len(s)):
  if i + len(t) - 1 >= len(s):break;
  dif=0
  for j in range(len(t)):
    if s[i+j] != t[j]:
      dif += 1
  ans = min(ans, dif)
print(ans)
N=int(input())
if N%2==0:
  print(N//2,N,N)
else:
  for i in range(1,3501):
    for j in range(1,3501):
      w=(N*i*j)/(4*i*j-N*i-N*j)
      if w>0 and w.is_integer():
        print(i,j,int(w))
        exit()


### FIXED CODE ###

N=int(input())
if N%2==0:
  print(N//2,N,N)
else:
  for i in range(1,3501):
    for j in range(1,3501):
      if 4*i*j-N*i-N*j!=0:
        w=(N*i*j)/(4*i*j-N*i-N*j)
        if w>0 and w.is_integer():
          print(i,j,int(w))
          exit()
N = input()
a = list(map(input().split())
i = 0
for x in a:
	if x%2!=0 and a[x]%2!=0:
    	i+==1
     
    print(i)


### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
i=0
for x,y in enumerate (a):
    b=x+1
    if b%2!=0 and y%2!=0:
        i+=1
print(i)
n,a, b = map(int, input().split())
    ans = n //(a+b) *a
    ans += min(n%(a+b),a)
    print(ans)


### FIXED CODE ###

S = input()

if S == "AAA" or S == "BBB":
    print("No")
else:
    print("Yes")
import itertools
n=int(input())
A=[0 for i in range(n)]
A=input().split()
for i in range(n):
    A[i]=int(A[i])
q=int(input())
B=[0 for i in range(q)]
B=input().split()
C=[]
for i in range(q):
    B[i]=int(B[i])
l=[0,1]
p=[]
k=0
D=[]
for v in itertools.product(l,repeat=n):
    sum=0
    for i in range(n):
        if v[i]==1:
            sum=sum+A[i]
    D.append(sum)
    k+=1
for i in range(q):
    c=0
    j=0
    while c==0 and j<k:
        if B[i]==D[j] and c==0:
            C.append("yes")
            c+=1
        j+=1
    if c==0:
        C.append("no")
for i in range(q):
    print(C[i])



### FIXED CODE ###

import itertools
n=int(input())
A=[0 for i in range(n)]
A=input().split()
for i in range(n):
    A[i]=int(A[i])
q=int(input())
B=[0 for i in range(q)]
B=input().split()
C=[]
for i in range(q):
    B[i]=int(B[i])
l=[0,1]
p=[]
k=0
D=[]
for v in itertools.product(l,repeat=n):
    sum=0
    for i in range(n):
        if v[i]==1:
            sum=sum+A[i]
    D.append(sum)
    k+=1
for i in range(q):
    if B[i] in D:
        C.append("yes")
    else:
        C.append("no")
for i in range(q):
    print(C[i])
def solve():
    S = input()
    N = len(S)

    left = 0
    right = N-1

    ans = 0
    while left != right:
        if S[left] == S[right]:
            left += 1
            right -= 1
        else: 
            if S[left] == 'x':
                left += 1
                ans += 1
            elif S[right] == 'x':
                right -= 1
                ans += 1
            else:
                print('-1')
                return
    
    print(ans)
                
if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    S = input()
    N = len(S)

    left = 0
    right = N-1

    ans = 0
    while right - left > 0:
        if S[left] == S[right]:
            left += 1
            right -= 1
        else: 
            if S[left] == 'x':
                left += 1
                ans += 1
            elif S[right] == 'x':
                right -= 1
                ans += 1
            else:
                print('-1')
                return
    
    print(ans)
                
if __name__ == '__main__':
    solve()
N=input()
a=list(map(int, input().split()))
b=a
c=1
if c<=N:
	d=a[c]
    b[d]=c
    c+=1
print(b)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
ans=[0]*N
for i in range(N):
	b=a[i]-1
	ans[b]=i+1
for i in range(N):
	print(ans[i])
s = raw_input()
k = int(raw_input())


s_l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

def s_i(st):
    for i in range(26):
        if st == s_l[i]:
            return i + 1
            break

j = 0
while k > 0:
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - s_i(s[j]) <= k:
        k = k - (27 - s_i(s[j]))
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (s_i(s[j])+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s


### FIXED CODE ###

s = raw_input()
k = int(raw_input())


s_l = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

def s_i(st):
    for i in range(26):
        if st == s_l[i]:
            return i + 1
            break

j = 0
while k > 0 and j <= len(s)-1:
    a = s_i(s[j])
    if s[j] == 'a' and j < len(s)-1:
        pass
    elif 27 - a <= k and j < len(s)-1:
        k = k - (27 - a)
        s = s[:j] + 'a' + s[j+1:]
    elif j == len(s) - 1:
        t = (a+k)%26 - 1
        if t >= 0:
            s = s[:j] + s_l[t]
        else:
            s = s[:j] + s_l[t + 26]
        break
    else:
        pass
    j += 1

print s
N = int(input())
a = map(int, raw_input().split())
x = a[0]
y = sum(a) - a[0]
min = abs(x - y)
for i in range (1,N-1):
    y -= a[i]
    x += a[i]
    dummy = abs(x - y)
    if min > dummy:
        min = dummy
print min


### FIXED CODE ###

A , B = map(int, input().split())
#print(A, B)
if (A%3==0 or B%3 == 0 or (A+B) % 3 == 0):
    print("Possible")
else:
    print("Impossible")
a, b = map(int, input().split())

difference = b - a
rtn = sum(range(1, difference + 1))
print(rtn - b)

### FIXED CODE ###

# -*- coding: utf-8 -*-
def margin0(n):
    if n < 10:
        return "00{}".format(n)
    elif n < 100:
        return "0{}".format(n)
    elif n < 1000:
        return "".format(n%1000)
    else:
        return "{}".format(n%1000 - 1)
n = int(input())
# print(n)
name = ""
if n < 1000:
    name = "ABC{}".format(margin0(n))
else:
    name = "ABD{}".format(margin0(n))
print(name[:3])