Harryxun/stf_run huggingface dataset:
def main():
    H, W, M = map(int, input().split())
    bombs = [list(map(int, input().split())) for i in range(M)]
    
    hw = [[0] * W for i in range(H)]
    
    for i in range(len(bombs)):
        [h, w] = bombs[i]
        hw[h - 1][w - 1] = 1
    
    wh = [list(x) for x in zip(*hw)]
    hw_tuple_list = []
    for i in range(len(hw)):
        hw_tuple_list.append((sum(hw[i]), i+1))
    
    wh_tuple_list = []
    for i in range(len(wh)):
        wh_tuple_list.append((sum(wh[i]), i+1))

    h_list = sorted(hw_tuple_list, reverse = True)
    w_list = sorted(wh_tuple_list, reverse = True)

    h_max = h_list[0][0]
    h_idx_list = []
    for i in range(len(h_list)):
        if h_max > h_list[i][0]:
            break
        h_idx_list.append(h_list[i][1])

    w_max = w_list[0][0]
    w_idx_list = []
    for i in range(len(w_list)):
        if w_max > w_list[i][0]:
            break
        w_idx_list.append(w_list[i][1])
    
    cnt = 1
    return w_max + h_max - cnt

if __name__ == '__main__':
    print(main())

### FIXED CODE ###

def main():
    H, W, M = map(int, input().split())
    bombs = [list(map(int, input().split())) for i in range(M)]
    
    if M == 1:
        return 1
    
    hw = [0] * H
    wh = [0] * W
    
    for i in range(len(bombs)):
        [h, w] = bombs[i]
        hw[h-1] += 1
        wh[w-1] += 1
    
    hw_tuple_list = []
    for i in range(len(hw)):
        hw_tuple_list.append((hw[i], i+1))
    
    wh_tuple_list = []
    for i in range(len(wh)):
        wh_tuple_list.append((wh[i], i+1))

    h_list = sorted(hw_tuple_list, reverse = True)
    w_list = sorted(wh_tuple_list, reverse = True)

    h_max = h_list[0][0]
    h_idx_list = []
    check_h = [0] * H
    for i in range(len(h_list)):
        if h_max > h_list[i][0]:
            break
        h_idx_list.append(h_list[i][1])
        check_h[h_list[i][1]-1] = 1

    w_max = w_list[0][0]
    w_idx_list = []
    check_w = [0] * W
    for i in range(len(w_list)):
        if w_max > w_list[i][0]:
            break
        w_idx_list.append(w_list[i][1])
        check_w[w_list[i][1]-1] = 1
    
    cnt = 0
    for [h, w] in bombs:
        if check_h[h-1] == 1 and check_w[w-1] == 1:
            cnt += 1
    return h_max + w_max if cnt != len(h_idx_list) * len(w_idx_list) else h_max + w_max - 1

if __name__ == '__main__':
    print(main())
n, t = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
x = []
for i in range(n):
     if a[i][1] <= t:
          x.append(a[i][0])
print(min(x))

### FIXED CODE ###

n, t = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
x = []
for i in range(n):
     if a[i][1] <= t:
          x.append(a[i][0])
if x != []:
     print(min(x))
else:
     print("TLE")
n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]==A and s[i]==C:
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])



### FIXED CODE ###


n,q=map(int,input().split())
s=list(input())
a=[0]*n

for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    a[i]=a[i-1]+1
  else:
    a[i]=a[i-1]
    
for i in range(q):
  sita,ue=map(int,input().split())
  if sita==1:
    print(a[ue-1])
  elif s[sita-2]=='A' and s[sita-1]=='C':
    print(a[ue-1]-a[sita-2]-1)
  else:
    print(a[ue-1]-a[sita-2])
N=int(input)
List = list(map(int, input().split()))
mid = -1
flag = True
for i in range(N):
  if List[i] == i+1:
    pass
  else:
    flag = False
    if mid == -1:
      mid = List[i]
    else:
      if mid == List[i]:
        print("YES")
      else:
        print("NO")
if flag:
  print("YES")

### FIXED CODE ###

N=int(input())
List = list(map(int, input().split()))
flag = 0
for i in range(N):
  if List[i] == i+1:
    pass
  else:
    flag += 1
if flag==2 or flag == 0:
  print("YES")
else:
  print("NO")
# coding: utf-8

# In[129]:


from collections import Counter


# In[130]:


n = int(input())
v = list(map(int, input().split()))


# In[134]:


v_even = Counter(v[::2]).most_common()
v_odd = Counter(v[1::2]).most_common()


# In[136]:


if len(v_even) == 1:
    v_even.append([0,0])
if len(v_odd) == 1:
    v_odd.append([0,0])


# In[ ]:


if v_even[0][0] == v_odd[0][0]:
    if v_even[1][1] > v_odd[1][1]:
        ret



### FIXED CODE ###


# coding: utf-8

# In[129]:


from collections import Counter


# In[141]:


n = int(input())
v = list(map(int, input().split()))


# In[142]:


v_even = Counter(v[::2]).most_common()
v_odd = Counter(v[1::2]).most_common()


# In[146]:


if len(v_even) == 1:
    v_even.append([0,0])
if len(v_odd) == 1:
    v_odd.append([0,0])
if v_even[0][0] == v_odd[0][0]:
    if v_even[1][1] > v_odd[1][1]:
        ret = n - v_even[1][1] - v_odd[0][1]
    else:
        ret = n - v_even[0][1] - v_odd[1][1]
else:
    ret = n - v_even[0][1] - v_odd[0][1]


# In[147]:


print(ret)
#input
N, M = map(int, input().split())
z = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    z[x-1].append(y-1)

#output
#便宜的にすべての点を-1しておく。
#dp[i]を頂点iから始まるpathで最長の長さとする。
#dp[i] = max(dp[v]+1)(vは頂点iから到達できる任意の頂点)

visited = [False] * N
memo = [0] * N

def dp(v):
    if visited[v]:
        return memo[v]
    else:
        res = 0
        for u in z[v]:
            res = max(res, dp(u)+1)
        memo[v] = res
        visited[v] = True
        return res
for i in range(N):
    dp(i)

print(max(memo))

### FIXED CODE ###

#input
import sys
sys.setrecursionlimit(10**7)
N, M = map(int, input().split())
z = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    z[x-1].append(y-1)

#output
#便宜的にすべての点を-1しておく。
#dp[i]を頂点iから始まるpathで最長の長さとする。
#dp[i] = max(dp[v]+1)(vは頂点iから到達できる任意の頂点)

visited = [False] * N
memo = [0] * N

def dp(v):
    if visited[v]:
        return memo[v]
    else:
        res = 0
        for u in z[v]:
            res = max(res, dp(u)+1)
        memo[v] = res
        visited[v] = True
        return res
for i in range(N):
    dp(i)

print(max(memo))
a,b = map(int,input().split())
ans = -1
for i in range():
  if a*i <= b:
    ans += 1
  else:
    break
print(ans)

### FIXED CODE ###

x,y = map(int, input().split())
cnt = 1
while x*2 ** cnt <= y:
    cnt += 1
print(cnt)
import math

n = int(input())
a = list(map(int, input().split()))

dp = [a[1], a[0], math.gcd(a[0], a[1])]
for i in range(2, n):
    for j in range(i+1):
        if j != i:
            dp[j] = math.gcd(a[i], dp[j])
    dp += [math.gcd(a[i], dp[i])]


print(max(dp))

### FIXED CODE ###

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

n = int(input())
a = list(map(int, input().split()))

l = [0 for i in range(n+1)]
r = [0 for i in range(n+1)]

for i in range(1, n+1):
    l[i] = gcd(l[i-1], a[i-1])

for i in range(n)[::-1]:
    r[i] = gcd(r[i+1], a[i])

m = [0 for i in range(n)]

for i in range(n):
    m[i] = gcd(l[i], r[i+1])

print(max(m))
from collections import Counter
import sys
sys.setrecursionlimit(1000000)

S = list(input())
L = len(S)
A = Counter(S)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

ans = cmb(L, 2) + 1
for v in A.values():
    if v == 1: continue
    ans -= cmb(v, 2)
print(ans)

### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(5000000)

S = list(input())
L = len(S)
A = Counter(S)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if L == 1:
    print(1)
else:
    ans = cmb(L, 2) + 1
    for v in A.values():
        if v == 1: continue
        ans -= cmb(v, 2)
    print(ans)
import bisect


def bisect_search(f, val=0, l=0, r=10**6):

    #is_increase=(f(r)-f(l))>=0

    eps = 10**(-5)
    while True:

        c = (l+r)//2
        print(l, c, r)
        input()
        if f(c) == val and f(c-1) != val:
            return c
        #if f(c)-val < eps:
        #    return c

        if f(c) > val:
            r = c

        else:
            l = c

        if l == r:
            return False



def next(ch,k):
    global N,dcs
    k_=k%N
    #print(ch,ch_,k)
    #print(dcs[ch][ch_]+1)
    #print(dcs[ch])
    #print(dcs[ch][ch_]+1)
    #print(N)
    val = dcs[ch][k_-1]+1
    if k_==0:
        val=1

    A=bisect.bisect_left(dcs[ch],val,k_,min(k_+N,2*N-1))
    B = N*((k//N))
    #print(A,B,k//N,k,N)

    return A+B#+A//N


import numpy as np

s=input()
t=input()

td=list(set(t))

N=len(s)
d={}

import sys

R = set(list(s))
L = set(list(t))

if not(L <= R):
    print(-1)
    sys.exit(2)

for std in td:
    d[std] =[0]*(2*N)



for i in range(len(s)*2):
    #nd[s[i]]

    for std in td:            
        if s[i%N]==std:
            d[std][i]=1



dcs={}
for std in td:
    dcs[std]=np.cumsum(d[std])


last=-1
for ts in t:
    #print(last)
    last=next(ts,last+1)


print(last+1)


#print(dcs)


### FIXED CODE ###

import bisect


def bisect_search(f, val=0, l=0, r=10**6):

    #is_increase=(f(r)-f(l))>=0

    eps = 10**(-5)
    while True:

        c = (l+r)//2
        print(l, c, r)
        input()
        if f(c) == val and f(c-1) != val:
            return c
        #if f(c)-val < eps:
        #    return c

        if f(c) > val:
            r = c

        else:
            l = c

        if l == r:
            return False



def next(ch,k):
    global N,dcs
    k_=k%N
    #print(ch,ch_,k)
    #print(dcs[ch][ch_]+1)
    #print(dcs[ch])
    #print(dcs[ch][ch_]+1)
    #print(N)
    val = dcs[ch][k_-1]+1
    if k_==0:
        val=1

    A=bisect.bisect_left(dcs[ch],val,k_,min(k_+N,2*N-1))
    B = N*((k//N))
    #print(A,B,k//N,k,N)

    return A+B#+A//N


import numpy as np

s=input()
t=input()

td=list(set(t))

N=len(s)
d={}

import sys

R = set(list(s))
L = set(list(t))

if not(L <= R):
    print(-1)
    sys.exit()

for std in td:
    d[std] =[0]*(2*N)



for i in range(len(s)*2):
    #nd[s[i]]

    for std in td:            
        if s[i%N]==std:
            d[std][i]=1



dcs={}
for std in td:
    dcs[std]=np.cumsum(d[std])


last=-1
for ts in t:
    #print(last)
    last=next(ts,last+1)


print(last+1)


#print(dcs)
if __name__ == '__main__':
    N, M = [int(x) for x in input().split()]
    arr = [int(x) for x in input().split()]
    res = N - sum(arr)
    if res < 0:
        print(-1)
    else:


### FIXED CODE ###

if __name__ == '__main__':
    N, M = [int(x) for x in input().split()]
    arr = [int(x) for x in input().split()]
    res = N - sum(arr)
    if res < 0:
        print(-1)
    else:
        print(res)
n=int(input())
s=input()

for i in s:
    print(chr((ord(i)-65+n)%26+65),end="")


### FIXED CODE ###

days=['SUN','MON','TUE','WED','THU','FRI','SAT']
in_day=input()
inx=days.index(in_day)
out_day=7-inx
print(out_day)
n = int(input())
v_list = list(map(int,input().split()))
while len(v_list) >= 3:
  v_list.sort()
  new_v = (V_list[0] + v_list[1]) /2
  v_list.pop(0)
  v_list.pop(0)
  v_list.append(new_v)
print((v_list[0] + v_list[1]) / 2)
  

### FIXED CODE ###

n = int(input())
v_list = list(map(int,input().split()))
while len(v_list) >= 3:
  v_list.sort()
  new_v = (v_list[0] + v_list[1]) /2
  v_list.pop(0)
  v_list.pop(0)
  v_list.append(new_v)
print((v_list[0] + v_list[1]) / 2)
from scipy.special import comb

n, k = map(int, input().split())

mod = 10 ** 9 + 7
curr_sum = 0

for i in range(1, k + 1):
    ans = (comb(n - k + i, n - k, exact=True) - curr_sum)
    ans *= comb(k - 1, i - 1, exact=True)
    ans %= mod
    print(ans)
    curr_sum += ans



### FIXED CODE ###

def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a


def comb_mod(n, k, mod):
    if k > n:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    fact_n_div_k = (fact_n * pow(fact_k, mod - 2, mod)) % mod
    return (fact_n_div_k * pow(fact_n_k, mod - 2, mod)) % mod


n, k = map(int, input().split())
mod = 10 ** 9 + 7

for i in range(1, k + 1):
    ans = comb_mod(n - k + 1, i, mod) * comb_mod(k - 1, i - 1, mod)
    ans %= mod
    print(ans)
１

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a=input()
if str.isupper(a):
    print("A")
else:
    print("a")
import itertools
import collections
from operator import mul
from functools import reduce

N,A,B = map(int,input().split())
V = sorted(list(map(int,input().split())),reverse = True)

total = 0
pattern = 0

if len(set(V)) == 1:
  for i in range(1,B):
    c = 1
    for j in range(B,B - i,-1):
      c *= j
    d = [t for t in range(1,i + 1)]
    d = reduce(mul,d)
    c /= d
    pattern += c
  a = A - 1
  print(float(V[0]))
  print(int(pattern) + 1)
else:
  a = A - 1
  sect = V[:A]
  total += sum(sect) / A
  print(total)
  con = V.count(V[a])
  ind = V.index(V[a])
  C = con - ind
  if con == ind:
    print(1)
  else:
    numer = reduce(mul,[k for k in range(C,con + 1)]) 
    denom = reduce(mul,[k for k in range(1,C + 1)])
    print(int(numer/denom))

### FIXED CODE ###

import collections
from operator import mul
from functools import reduce

N,A,B = map(int, input().split())
V = list(map(int, input().split()))
VV = sorted(V,reverse = True)
ave = 0
ml = []

for i in range(A,B + 1):
  avet = sum(VV[:i]) / i
  if avet >= ave:
    ml.append(i)
    ave = max(ave,avet)
  else:
    break

dic = collections.Counter(V)
#print(dic,ml)

def cmb(n,r):
  r = min(n - r,r)
  if r == 0:
    return 1
  over = reduce(mul,range(n, n - r, -1))
  under = reduce(mul,range(1,r + 1))
  return over // under

res = 0

for j in ml:
  r = dic[VV[j - 1]]
  rr = VV.index(VV[j - 1])
  res += cmb(r,j - rr)

print(ave)
print(res)
import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import lil_matrix

N = int(input())
edge = lil_matrix((N,N))

XY = [[i] + [int(x) for x in input().split()] for i in range(N)]
for key in [itemgetter(1), itemgetter(2)]:
  XY.sort(key = key)
  for i in range(N-1):
    i1,x1,y1 = XY[i]
    i2,x2,y2 = XY[i+1]
    d = min(abs(x1-x2),abs(y1-y2))
    edge[i1,i2] = d

edge = edge.tocsr()

# 最小全域木
from scipy.sparse.csgraph import minimum_spanning_tree
tree = minimum_spanning_tree(edge, overwrite = True).astype(int)
answer = tree.sum()
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import csr_matrix
import numpy as np

N = int(input())

XY = [[i] + [int(x) for x in input().split()] for i in range(N)]

edge = [set() for _ in range(N)]
for key in [itemgetter(1),itemgetter(2)]:
  XY.sort(key = key)
  for i in range(N-1):
    i1,x1,y1 = XY[i]
    i2,x2,y2 = XY[i+1]
    d = min(abs(x1-x2),abs(y1-y2))
    edge[i1].add((i2,d))
    
# csr形式に直す
indptr = []
indrow = []
value = []
ptr = 0
for i in range(N):
  indptr.append(ptr)
  for j,v in edge[i]:
    indrow.append(j)
    value.append(v)
    ptr += 1
indptr.append(ptr)
value = np.array(value,dtype=int)
graph = csr_matrix((value,indrow,indptr),shape=(N,N))

# 最小全域木
from scipy.sparse.csgraph import minimum_spanning_tree
tree = minimum_spanning_tree(graph, overwrite = True).astype(int)
answer = tree.sum()
print(answer)
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n, m = map(int, input().split())
sc = [input().split() for i in range(m)]
# print(sc)
# print(len(sc))
if len(sc) == 1:
    print(-1)
    exit()

for i in range(m):
    if (sc[0][0] == sc[i][0])and(sc[0][1] != sc[i][1]):
        print(-1)
        exit()

#print(sorted(set(list(map(tuple, sc)))))
x = sorted(set(list(map(tuple, sc))))
# print(len(x))
# print(x[0][0])
for i in range(len(x)):
    if int(x[i][0]) == 1:
        h = 100*int(x[i][1])
        print(h)
    elif int(x[i][0]) == 2:
        i = 10*int(x[i][1])
        print(i)
    elif int(x[i][0]) == 3:
        j = 1*int(x[i][1])
        print(j)
print(h+i+j-1)


### FIXED CODE ###

import math
import string


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


N, M = map(int, input().split())
cs = [None]*N
for i in range(M):
    s, c = map(int, input().split())
    #print(s, c)
    if cs[(s-1)] == None:
        cs[(s-1)] = c
    elif cs[s-1] != c:
        print(-1)
        exit()


def check(x):
    s = str(x)
    if not(len(s) == N):
        return False
    for i in range(N):
        if not(cs[i] == None or cs[i] == int(s[i])):
            return False
    return True


for i in range(10000):
    if check(i):
        print(i)
        exit()
print(-1)
H,W,K = map(int,input().split())
C = [input() for i in range(H)]

ans = 0
for i in 2**H:
    for j in 2**W:
        tmp = 0
        for ii in range(H):
            for jj in range(W):
                
                if C[ii][jj] == '#' and (i >> ii) == 0 and (j >> jj) == 0:
                    tmp += 1
        if tmp == K:
            ans += 1
            
print(ans)    

### FIXED CODE ###

H,W,K = map(int,input().split())
C = [input() for i in range(H)]

import itertools
h = list(itertools.product([0,1], repeat=H))
w = list(itertools.product([0,1], repeat=W))

ans = 0
for i in h:
    for j in w:
        tmp = 0
        for ii in range(H):
            for jj in range(W):
                if C[ii][jj] == '#' and i[ii] == 0 and j[jj] == 0:
                    tmp += 1
        if tmp == K:
            ans += 1
            
print(ans)
def get_depth(graph,tmp_depth,vertex_list,depth_list):
    new_vertex_list=[]
    for vertex in vertex_list:
        for j in range(len(depth_list)):
            if(graph[vertex][j]!=0 and depth_list[j]==-1):
                depth_list[j]=tmp_depth + 1
                new_vertex_list.append(j)
    get_depth(graph,tmp_depth+1,new_vertex_list,depth_list)


#グラフの作成
n=int(input())
graph=[[0]*n for loop in range(n)]
for loop in range(n):
    tmp_ope=list(map(int,input().split()))
    for j in range(tmp_ope[1]):
        graph[tmp_ope[0]-1][tmp_ope[j+2]-1]=1


depth_list=[-1]*n
depth_list[0]=0
vertex_list=[0]
get_depth(graph,0,vertex_list,depth_list)

for i in range(n):
    print(f"{i+1} {depth_list[i]}")


### FIXED CODE ###

def get_depth(graph,tmp_depth,vertex_list,depth_list):
    new_vertex_list=[]
    for vertex in vertex_list:
        for j in range(len(depth_list)):
            if(graph[vertex][j]!=0 and depth_list[j]==-1):
                depth_list[j]=tmp_depth + 1
                new_vertex_list.append(j)
    if(len(new_vertex_list)!=0):
        get_depth(graph,tmp_depth+1,new_vertex_list,depth_list)


#グラフの作成
n=int(input())
graph=[[0]*n for loop in range(n)]
for loop in range(n):
    tmp_ope=list(map(int,input().split()))
    for j in range(tmp_ope[1]):
        graph[tmp_ope[0]-1][tmp_ope[j+2]-1]=1


depth_list=[-1]*n
depth_list[0]=0
vertex_list=[0]
get_depth(graph,0,vertex_list,depth_list)

for i in range(n):
    print(f"{i+1} {depth_list[i]}")
n = int(input())

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

b = [0 for i in range(10**5)]

for i in range(n):
    b[a[i]] += 1
if n % 2 == 0:
    if sum(b[::2]) == 0 and all(list(map(lambda x:x==2),b[1::2])):
        print(2**(n//2))
    else:
        print(0)

else:
    print(b[1:n//2:2],list(map(lambda x:x == 2,b[:n//2:2])))
    if sum(b[1::2]) == 0 and all(list(map(lambda x:x == 2,b[::2]))) and b[0] == 1:
        print(2**(n//2))
    else:
        print(0)


### FIXED CODE ###

n = int(input())

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

b = [0 for i in range(10**5*1)]

for i in range(n):
    b[a[i]] += 1
if n % 2 == 0:
    if all(list(map(lambda x:x==2,b[1:n+1:2]))):
        print(2**(n//2)%(10**9+7))
    else:
        print(0)

else:
    if all(list(map(lambda x:x == 2,b[2:n+1:2]))) and b[0] == 1:
        print(2**(n//2)%(10**9+7))
    else:
        print(0)
s = input()
len_s = len(s)
l_index = 0
r_index = s - 1
counter = 0
while l_index < r_index:
    if s[l_index] == s[r_index]:
        l_index += 1
        r_index -= 1
    elif s[l_index] == "x":
        counter += 1
        l_index += 1
    elif s[r_index] == "x":
        counter += 1
        r_index -=1
    else:
        counter = -1
        break
print(counter)

### FIXED CODE ###

s = input()
len_s = len(s)
l_index = 0
r_index = len_s - 1
counter = 0
while l_index < r_index:
    if s[l_index] == s[r_index]:
        l_index += 1
        r_index -= 1
    elif s[l_index] == "x":
        counter += 1
        l_index += 1
    elif s[r_index] == "x":
        counter += 1
        r_index -=1
    else:
        counter = -1
        break
print(counter)
def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[int(k)])
main()


### FIXED CODE ###

def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[int(k) - 1])
main()
a,b=int(input())
print(":("if a>8 or b>8 else "Yay!")

### FIXED CODE ###

a,b=map(int,input().split(" "))
print(":("if a>8 or b>8 else "Yay!")
a, b, h, m = map(int,input().split())

hk = h * 30
mk = m * 6

kaku = mk - hk

print(((b ** 2)+(a ** 2)) - (2 * a * b * kaku))

### FIXED CODE ###

a = int(input())
z = input()

if len(z) > a: 
  print(z[0:a] + "...")
else:
  print(z)
n=int(input())
d=list(map(int,input().split()))
s=sum(d)
print(sum([x*(d-x) for x in d])//2)

### FIXED CODE ###

from itertools import combinations
_=input()
d=list(map(int,input().split()))
print(sum([i*j for (i,j) in combinations(d,2)]))
import collections
N, M = map(int, input().split())
X = list(map(int, input().split()))

table = collections.defaultdict(list)
for x in X:
    table[x % M].append(x)
Count = [None]*N
for i in range(M):
    table[i].sort(key=lambda x: table[x].count(x), reverse=True)
    Count[i] = collections.Counter(table[i]).values()
ans = 0
for i in range(M // 2 + 1):
    tmp = min(len(table[i]), len(table[(M-i) % M]))
    if i != (M-i) % M:
        ans += tmp
    else:
        ans += tmp // 2

    k = 0
    l = 0
    for x in Count[i]:
        k += x % 2
        l += x // 2
    if tmp <= k:
        ans += l
    else:
        ans += ((k + l*2) - tmp) // 2

    if i != (M-i) % M:
        k = 0
        l = 0
        for x in Count[(M-i) % M]:
            k += x % 2
            l += x // 2
        if tmp <= k:
            ans += l
        else:
            ans += ((k + l*2) - tmp) // 2
    # print(table[i])
    # print(table[(M-i) % M])
    # print(ans)
print(ans)


### FIXED CODE ###

import collections
N, M = map(int, input().split())
X = list(map(int, input().split()))

table = collections.defaultdict(list)
for x in X:
    table[x % M].append(x)
Count = [None]*M
for i in range(M):
    Count[i] = collections.Counter(table[i]).values()
ans = 0
for i in range(M // 2 + 1):
    tmp = min(len(table[i]), len(table[(M-i) % M]))
    if i != (M-i) % M:
        ans += tmp
    else:
        ans += tmp // 2

    k = 0
    l = 0
    for x in Count[i]:
        k += x % 2
        l += x // 2
    if tmp <= k:
        ans += l
    else:
        ans += ((k + l*2) - tmp) // 2

    if i != (M-i) % M:
        k = 0
        l = 0
        for x in Count[(M-i) % M]:
            k += x % 2
            l += x // 2
        if tmp <= k:
            ans += l
        else:
            ans += ((k + l*2) - tmp) // 2

print(ans)