Harryxun/stf_run huggingface dataset:
import sys 

readline = sys.stdin.readline 

N = int(input())
X_str= input()
X = list(X_str)
bit_count = X_str.count('1')

def popcount(number, bit_counter):
    num = number
    counter = 0
    while num != 0:
        bit_con = bit_counter if counter == 0 else bin(num)[2:].count('1')
        num = num % bit_con
        counter += 1

    return counter

x_copy = X.copy()
for i in range(N):
    # ビットの反転
    # x_copy = X.copy()
    bit_count_n = bit_count
    if x_copy[i] == '0':
        x_copy[i] = '1'
        bit_count_n += 1
    else:
        x_copy[i] = '0'
        bit_count_n -= 1

    bit_int = int("".join(x_copy), 2)

    print(popcount(bit_int, bit_count_n))






### FIXED CODE ###

def popcount(n):
    bit_count = bin(n).count('1')
    n = n % bit_count 
    return n

if __name__ == "__main__":
    import sys 

    readline = sys.stdin.readline 

    N = int(input())
    X = readline()
    bit_count = X.count('1')
    mod1 = int(X, 2) % (bit_count + 1)
    mod2 = int(X, 2) % (bit_count - 1) if (bit_count - 1) != 0 else 0

    for i in range(N):
        if X[i] == '0':
            X_rest = (mod1 + pow(2, N - 1 - i, bit_count + 1)) % (bit_count + 1)
        else:
            if bit_count - 1 != 0:
                X_rest = (mod2 - pow(2, N - 1 - i, bit_count - 1)) % (bit_count - 1)
            else:
                print(0)
                continue

        counter = 1
        while X_rest != 0:
            X_rest = popcount(X_rest)
            counter += 1
        print(counter)
s = input()
a=s.index('C')
print('AC' if s[0]=='A' and s.count('C')==1 and s[1:a]+s[a+1:]==(s[1:a]+s[a+1:]).lower() and 1<a<len(s)-1 else 'WA')

### FIXED CODE ###

s = input()
if s.count('C')==1:
    a=s.index('C')
else:
    a=0
print('AC' if s[0]=='A' and s.count('C')==1 and s[1:a]+s[a+1:]==(s[1:a]+s[a+1:]).lower() and 1<a<len(s)-1 else 'WA')
N, P = map(int, input().split())
def prime_factorize(n):
    a = []
    N = n
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= N:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

lis = prime_factorize(P)
#print(lis)
if N == 1:
    print(P)
    exit()

else:
    d = [0] * (10 ** 6 + 5)
    for i in lis:
        d[i] += 1
    #print(d[:24])
    #print(d[103])
    lis2 = []
    for i in reversed(range(10 ** 6 + 5)):
        if d[i] >= N:
            val = d[i] // N
            lis2.append(pow(i,val))
    ans = 1
    for i in lis2:
        ans *= i
    print(ans)


### FIXED CODE ###

from math import sqrt
N, P = map(int, input().split())
def prime_factorize(n):
    a = []
    N = n
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= N:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

lis = prime_factorize(P)
#print(lis)
if N == 1:
    print(P)
    exit()

else:
    d = [0] * (10 ** 7)
    sq = sqrt(P) + 1
    for i in lis:
        if i < sq:
            d[i] += 1
    #print(d[:24])
    #print(d[103])
    lis2 = []
    for i in reversed(range(10 ** 6 + 5)):
        if d[i] >= N:
            val = d[i] // N
            lis2.append(pow(i,val))
    ans = 1
    for i in lis2:
        ans *= i
    print(ans)
n,m=map(int,input().split())
a=int(input())
b=1
s=[1]*(n+1)
for i in range(1,n+1):
    if i!=a:
        if i-2>=0:
            s[i]=(s[i-1]+s[i-2])%1000000007
        else:
            s[i]=s[i-1]%1000000007
    elif b!=m:
        s[i]=0
        a=int(input())
        b+=1
    else:
        s[i]=0
print(s[n])
        


### FIXED CODE ###

n,m=map(int,input().split())
a=0
if m!=0:
    a=int(input())
    
b=1
s=[1]*(n+1)
for i in range(1,n+1):
    if i!=a:
        if i-2>=0:
            s[i]=(s[i-1]+s[i-2])%1000000007
        else:
            s[i]=s[i-1]%1000000007
    elif b!=m:
        s[i]=0
        a=int(input())
        b+=1
    else:
        s[i]=0
print(s[n])
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))
tmp = []
for i in range(M-1):
  tmp.append(X[i+1] - X[i])
if(tmp != []):
  for i in range(N-1):
    tmp.remove(max(tmp))
  print(sum(tmp))
else:
  print(0)

### FIXED CODE ###

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

tmp = sorted([X[i+1] - X[i] for i in range(M-1)])
if(tmp != []):
  if(len(tmp) == 1):
    print(*tmp)
  elif(N == 1):
    print(sum(tmp))
  else:
    print(sum(tmp[:-(N-1)]))
else:
  print(0)
a, b = map(int, raw_input().split())

if a > b:
  print "a > b"
else if a == b:
  print "a = b"
else:
  print "a < b"

### FIXED CODE ###

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

if a > b:
  print "a > b"
elif a == b:
  print "a == b"
else:
  print "a < b"
s = raw_input()
N = len(s)
if N == 1:
    print(1)
    exit()
dp = [[0] * 3 for _ in xrange(N)]
dp[0][1] = 1
dp[1][2] = 0
dp[1][1] = 0 if s[1] == s[0] else 2
for i in xrange(2, N):
    if dp[i-1][2]:
        dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1)
    if dp[i-1][1] and s[i] != s[i-1]:
        dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1)
    if dp[i-2][1]:
        dp[i][2] = dp[i-2][1]+1
    if i >= 3 and (s[i-2-1]!=s[i-1] or s[i-2]!=s[i]) and dp[i-2][2]:
        dp[i][2] = max(dp[i][2], dp[i-2][2]+1)
print(max(dp[N-1][1], dp[N-1][2]))

### FIXED CODE ###

s = raw_input()
N = len(s)
s = '0' + s
dp = [0] * (1+N)
# dp[0] = 1
for i in xrange(1, N+1):
    if s[i] == s[i-1]:  dp[i] = dp[i-3]+2 if i >= 3 else 1
    else:   dp[i] = dp[i-1] + 1
print(dp[N])
n=int(input())
s=[int(i) for i in input().split]
print(min(s),max(s),sum(s))

### FIXED CODE ###

input()
s=[int(i) for i in input().split()]
print(min(s),max(s),sum(s))
l = [1]
p = [1]
N, X = map(int, input().split())
for i in range(N):
    l.append(l[i] * 2 + 3)
    p.append(p[i] * 2 + 1)


def calc(n, x):
    if l[n] <= x:
        return p[n]
    if x == 0 or x == 1:
        return 0
    if x <= l[n] // 2:
        return calc(n - 1, x - 1)
    elif x == l[n] // 2 + 1:
        return p[n - 1] + 1
    else:
        return p[n - 1] + 1 + calc(n - 1, x - (l[n - 1] + 2))


print(calc(N, X))


### FIXED CODE ###

c='Christmas'
for i in range(25-int(input())):
	c+=' Eve'
print(c)
# coding: utf-8
# Your code here!
import math
from collections import Counter

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

def C(n, r):
    return P(n, r)//math.factorial(r)

N = int(input())
arr = [input() for i in range(N)]
mar_arr = [j for j in arr if j[0] == "M" or j[0] == "A" or j[0] == "R" or j[0] == "C" or j[0] == "H"]
ini_arr = [k[0] for k in mar_arr]
dic = Counter(ini_arr)
key_num = len(dic)
val_num = sum(v for v in dic.values())
if key_num < 3:
    print(0)
else:
    total = C(len(ini_arr), 3)
    for i in dic.values():
        if i == 2:
            total -= C(num - i, 1)
        elif i >= 3:
            total -= C(i, 2) * C(num - i, 1)  + C(i, 3)
    print(total)

### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

n = int(input())
t = [0] * n
for i in range(n):
    t[i] =input()[0]
t2 = [t.count(i) for i in ["M","A","R","C","H"]]
ans = 0
for i in range(5):
    for j in range(5):
        if j == i:
            break
        for k in range(5):
            if k == j:
                break
            ans += t2[i] * t2[j] * t2[k]
print(ans)
A, B, K = map(int, input().split())
for i in range(K):
    if i%2!=0:
        if A%2!=0;
            A-=1
        B+=A//2
        A=A//2
    else:
        if B%2!=0;
            B-=1
        A+=B//2
        B=B//2
print(A, B)


### FIXED CODE ###

# coding: utf-8
A, B, K = map(int, input().split())
for i in range(K):
    if i%2 ==0 :
        if A%2 != 0:
            A-=1
        B+=A//2
        A=A//2
    else:
        if B%2 !=0:
            B-=1
        A+=B//2
        B=B//2
print(A, B)
R = int(input())

if R < 1200:
  pritn("ABC")
  
elif R < 2800:
  print("ARC")
  
else:
  print("AGC")
  
  

### FIXED CODE ###

R = int(input())

if R < 1200:
  print("ABC")
  
elif R < 2800:
  print("ARC")
  
else:
  print("AGC")
import fractions
def lcm(a, b):
    return a // fractions.gcd(a, b) * b

N, M = map(int, input().split())
A = list(map(int, input().split()))

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

for i in A_half:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()
ans = (M // A_lcm + 1) // 2
print(int(ans))

### FIXED CODE ###

from fractions import gcd

N, M = map(int, input().split())
A = [int(i) // 2 for i in input().split()]  

A_lcm = 1
for i in range(N):
    A_lcm *= A[i] // gcd(A_lcm, A[i])
    
for i in A:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()

print((M // A_lcm + 1) // 2)
n = int(input())
k = int(input())
s = input()
l = s.count('L')
r = s.count('R')
now = 0
for i in range(len(s)-1):
  if s[i] == 'R' and s[i+1] == 'L':
    res += 1
print(min(now + K, min(l, r)))

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
grp = 0
now = ""
for c in s:
  if c != now:
    grp += 1
    now = c
hap = 0
for i in range(n):
  if (i>0 and s[i]=='L' and s[i-1]=='L') or (i<n-1 and s[i]=='R' and s[i+1]=='R'):
    hap += 1
p_2 = (grp - 1) // 2
p_1 = (grp + 1) % 2
print(hap + 2 * min(k, p_2) + int(k > p_2) * p_1)
def main():
    import sys
    from collections import deque
    input = sys.stdin.readline
    N = int(input())
    color = [-1] * N
    color[0] = 0
    uvw = []
    edge = [[]for _ in range(N)]
    # append=uvw.append
    for i in range(N-1):
        ui, vi, wi = map(int, input().split())
        ui -= 1
        vi -= 1
        edge[ui].append((vi, wi))
        edge[vi].append((ui, wi))
    stack = [0]
    for i in range(N):
        tmp = deque()
        while stack:
            i = stack.pop()
            for e, w in edge[i]:
                if color[e] == -1:
                    stack.append(e)
                    if color[i] == 0:
                        if w % 2 == 0:
                            color[e] = 0
                        else:
                            color[e] = 1
                    else:
                        if w % 2 == 0:
                            color[e] = 1
                        else:
                            color[e] = 0
                # ここを追加--------------------------------------
                # 矛盾判定
                else:
                    if (color[i] == color[e]) != (w % 2 == 0):
                        print(-1)
                        exit()
                # ^^^^^^^^--------------------------------------
        # print(color)
        stack = tmp
    print(*color, sep="\n")


if __name__ == '__main__':
    main()


### FIXED CODE ###

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.nodes = [-1] * n  # nodes[x]: 負なら、絶対値が木の要素数

    def get_root(self, x):
        # nodes[x]が負ならxが根
        if self.nodes[x] < 0:
            return x
        # 根に直接つなぎ直しつつ、親を再帰的に探す
        else:
            self.nodes[x] = self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x, y):
        root_x = self.get_root(x)
        root_y = self.get_root(y)
        # 根が同じなら変わらない
        # if root_x == root_y:
        # pass
        if root_x != root_y:
            # 大きい木の方につないだほうが計算量が減る
            if self.nodes[root_x] < self.nodes[root_y]:
                big_root = root_x
                small_root = root_y
            else:
                small_root = root_x
                big_root = root_y
            self.nodes[big_root] += self.nodes[small_root]
            self.nodes[small_root] = big_root


N, M = map(int, input().split())
uf = UnionFind(N)
get_root, unite, nodes = uf.get_root, uf.unite, uf.nodes

for _ in range(M):
    x, y, _ = map(int, input().split())
    x -= 1
    y -= 1
    unite(x, y)
ans = 0
for i in range(N):
    if nodes[i] < 0:
        ans += 1
print(ans)
a,b,c,d = map(int,input().split())
print(max[a*c,a*d,b*c,b*d])

### FIXED CODE ###

a,b,c,d = map(int,input().split())
print(max(a*c,a*d,b*c,b*d))
H,W = map(int,input().split())
grid = [["&"] * (W+2) for i in range(H+2)]
visited = [[False] * (W+2) for i in range(H+2)]
# debug: visited_count = [[0] * (W+2) for i in range(H+2)]
start = []
for i in range(H):
    s = input()
    for j in range(W):
        grid[i+1][j+1] = s[j]
        if s[j] == ".":
            start.append([i+1,j+1])

ans = 0
b = 0
w = 0
def dfs(p_i,p_j):
    if visited[p_i][p_j] is True:
        global ans
        return
    visited[p_i][p_j] = True
    if grid[p_i][p_j] == "#":
        # debug: visited_count[p_i][p_j] += 1
        global b
        b += 1
    elif grid[p_i][p_j] == ".":
        start.remove([p_i,p_j])
        # debug: visited_count[p_i][p_j] += 1
        global w
        w += 1
    around = [[p_i,p_j+1],[p_i+1,p_j],[p_i,p_j-1],[p_i-1,p_j]]
    for i,j in around:
        if grid[p_i][p_j] == "#" and grid[i][j] == ".":
            dfs(i,j)
        elif grid[p_i][p_j] == "." and grid[i][j] == "#":
            dfs(i,j)

while True:
    if start == []:
        break
    dfs(start[0][0],start[0][1])
    ans += b * w
    b = 0
    w = 0

print(ans)

""" debug
print(start)
for line in visited_count:
    print(line)
print("b = {}".format(b))
print("w = {}".format(w)) """

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

H,W = map(int,input().split())
grid = [["&"] * (W+2) for i in range(H+2)]
visited = [[False] * (W+2) for i in range(H+2)]
# debug: visited_count = [[0] * (W+2) for i in range(H+2)]
start = []
for i in range(H):
    s = input()
    for j in range(W):
        grid[i+1][j+1] = s[j]

ans = 0
b = 0
w = 0
def dfs(p_i,p_j):
    if visited[p_i][p_j] is True:
        global ans
        return
    visited[p_i][p_j] = True
    if grid[p_i][p_j] == "#":
        # debug: visited_count[p_i][p_j] += 1
        global b
        b += 1
    elif grid[p_i][p_j] == ".":
        # debug: visited_count[p_i][p_j] += 1
        global w
        w += 1
    around = [[p_i,p_j+1],[p_i+1,p_j],[p_i,p_j-1],[p_i-1,p_j]]
    for i,j in around:
        if grid[p_i][p_j] == "#" and grid[i][j] == ".":
            dfs(i,j)
        elif grid[p_i][p_j] == "." and grid[i][j] == "#":
            dfs(i,j)

for i in range(1,H+1):
    for j in range(1,W+1):
        if visited[i][j] is False:
            dfs(i,j)
            ans += b * w
            b = 0
            w = 0

print(ans)

""" debug
print(start)
for line in visited_count:
    print(line)
print("b = {}".format(b))
print("w = {}".format(w)) """
h,w,m=map(int,input().split())
s=[0]*m
st=[0]*m
t=[0]*m
tt=[0]*m
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  st[i]=sm
  t[i]=tm
  tt[i]=tm
  
import statistics
temp=statistics.mode(s)
ans1=s.count(temp)
for i in range(m):
  if s[i]==temp:
    tt[i]=999999999999999999
while 999999999999999999 in tt:tt.remove(999999999999999999)
temp=statistics.mode(tt)
ans1=ans1+tt.count(temp)

temp=statistics.mode(t)
ans2=t.count(temp)
for i in range(m):
  if t[i]==temp:
    st[i]=999999999999999999
while 999999999999999999 in st:st.remove(999999999999999999)
temp=statistics.mode(st)
ans2=ans2+st.count(temp)

print(max(ans1,ans2))

### FIXED CODE ###

h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)
from math import lcm
a,b=map(int,input().split())
print(lcm(a,b))

### FIXED CODE ###

from fractions import gcd 
a,b=map(int,input().split())
print(a*b//gcd(a,b))
import sys
from operator import itemgetter

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    change = [[int(i) for i in input().split()] for _ in range(M)]
    change.sort(key = itemgetter(1), reverse = True)
    ai = 0
    for i in range(M):
        cb, c = change[i]
        if c < A[ai] or ai >= N: break
        for _ in range(cb):
            if ai >= N: break
            if A[ai] <= c:
                A[ai] = c
                ai += 1
            else: break
    print(sum(A))
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys, math, collections, heapq, itertools

F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    N, M = map(int, line_input())
    A = [int(a) for a in line_input()]
    change = [None] * M
    for i in range(M):
        b, c = map(int, line_input())
        change[i] = [c, b]
    A.sort()
    change.sort(reverse = True)

    sum = 0
    index = 0
    for c, b in change:
        bleft = b
        while bleft > 0:
            if c > A[index]:
                sum += c
                index += 1
                bleft -= 1
                if index == N: break
            else: break
        if index == N: break
    if index < N:
        for i in range(index, N):
            sum += A[i]
    print(sum)

    return 0
  
if __name__ == "__main__":
    solve()
import sys
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
cnt = [[0 for _ in range(15)] for _ in range(15)]
ans = 0
for _ in range(n):
	a = input()
	x, y = 0, 0
	if "." in a:
		i = len(a)-1
		while a[i] != ".":
			i -= 1
			x, y = x-1, y-1
		b = int(a[:i] + a[i+1:])
	else:
		b = int(a)
	while b%2 == 0:
		x += 1
		b //= 2
	while b%5 == 0:
		y += 1
		b //= 5
	#print(x, y)
	x, y = x+9, y+9
	for i in range(18-x, 15):
		for j in range(18-y, 15):
			ans += cnt[i][j]
	cnt[x][y] += 1
print(ans)


### FIXED CODE ###

import sys
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
cnt = [[0 for _ in range(20)] for _ in range(20)]
ans = 0
for _ in range(n):
	a = input()
	x, y = 0, 0
	if "." in a:
		i = len(a)-1
		while a[i] != ".":
			i -= 1
			x, y = x-1, y-1
		b = int(a[:i] + a[i+1:])
	else:
		b = int(a)
	#print(b)
	while b%2 == 0 and x < 9:
		x += 1
		b //= 2
	while b%5 == 0 and y < 9:
		y += 1
		b //= 5
	#print(x, y)
	x, y = x+9, y+9
	for i in range(18-x, 20):
		for j in range(18-y, 20):
			ans += cnt[i][j]
	cnt[x][y] += 1
print(ans)
s = input()
t = input()

s_dash = ''.join(sorted(s))
t_dash = ''.join(sorted(t)[::-1])

test = [s_dash, t_dash]

if s_dash == t_dash:
    print("No")
else:
    if sorted(test)[0] != s_dash:
        print("No")
    else:
        print("Yes")


### FIXED CODE ###

import math

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

ans =math.ceil(((a + b) / 2))

print(ans)
N = int(input())
H = [int(input()) for i in range(N)]
count = 1
Max = H[0]
for i in range(1:N):
     if Max <=H[i]:
         Max = H[i]
         count += 1

print(count)
     


### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
count = 1
x = H[0]
for i in range(N-1):
     if x <=H[i+1]:
         x = H[i+1]
         count += 1

print(count)
n = input()
print(n ** 2)

### FIXED CODE ###

n = int(input())
a = pow(n,3)
print(a)
N,X = map(int,input().split())

PforL = [1]
HforL = [1]
for i in range(1,51):
    PforL.append(PforL[i-1]*2+1)
    HforL.append(HforL[i-1]*2+3)

def recursive(n,x):
    if x<=n:
        return 0
    if x<=HforL[n-1]+1:
        return recursive(n-1,x-1)
    if x<HforL[n]:
        return PforL[n-1]+1+recursive(n-1,x-HforL[n-1]-2)

print(recursive(N,X))


### FIXED CODE ###

N,X = map(int,input().split())

PforL = [1]
HforL = [1]
for i in range(1,51):
    PforL.append(PforL[i-1]*2+1)
    HforL.append(HforL[i-1]*2+3)

ans = 0
while 0<X:
    if(X<((HforL[N]-3)/2)+1):
        X -= 1
        N -= 1
        continue
    if(X==((HforL[N]-3)/2+1)):
        ans+=PforL[N-1]
        break
    if(X==((HforL[N]-3)/2+2)):
        ans+=PforL[N-1]+1
        break
    if(X<HforL[N]-1):
        ans += PforL[N-1]+1
        X -= 2+HforL[N-1]
        N -= 1
        continue
    if(X<=HforL[N]):
        ans += PforL[N]
        break
print(ans)
import sympy
N = int(input())
al = sympy.divisors(N)
L = len(al)
if L%2==1:
    a = al[L//2]
    print((a-1)*(a-1))
else :
    a = al[L//2-1]
    b = al[L//2]
    print(a+b-2)

### FIXED CODE ###

N = int(input())
import math 

start = int(math.sqrt(N))+1
for i in range(start,0,-1):
    if N%i==0:
        print(i+N//i-2)
        break
def solve(N, Q, S, L_R):
    answers = [None] * Q
    ac_index = [0] * len(S)
    for i in range(len(S)):
        s = S[i]
        if s == "A":
            a_flag = True
            continue
        elif s == "C":
            if a_flag:
                ac_index[i - 1] = 1
            a_flag = False
        else:
            a_flag = False
    q = 0
    for l, r in L_R:
        arr = ac_index[l - 1:r]
        ans = sum(arr)
        if arr[-1] == 1:
            ans -= 1
        answers[q] = ans
        q += 1
    return answers

def count_ac(pstr):
    count = 0
    a_flag = False
    for i in range(len(pstr)):
        s = pstr[i]
        if s == "A":
            a_flag = True
            continue
        elif s == "C":
            if a_flag:
                count += 1
            a_flag = False
        else:
            a_flag = False
    return count

N, Q = map(int, input().split())
S = input()
L_R = [tuple(map(int, input().split())) for _ in range(Q)]
for ans in solve(N, Q, S, L_R):
    print(ans)

### FIXED CODE ###

def solve(N, Q, S, L_R):
    memo = [None] * N
    cumsum = 0
    for i in range(len(S) - 1):
        memo[i] = cumsum
        if S[i] == "A" and S[i + 1] == "C":
            cumsum += 1
    memo[N - 1] = cumsum
    for l, r in L_R:
        print(memo[r - 1] - memo[l - 1])


N, Q = map(int, input().split())
S = input()
L_R = [tuple(map(int, input().split())) for _ in range(Q)]
solve(N, Q, S, L_R)
import itertools
n=int(input())
s = []
for _ in range(n):
    s.append(input())
#print(s)
#s = list(itertools.chain.from_iterable(s))
#print(s)
s_u = list(set(s))
box = []
box.append([s_u[0],s.count(s_u[0])])
for i in range(1,len(s_u)):
    if max(box) < s.count(s_u[i]):
        box.remove(max(box))
        box.append([s_u[i],s.count(s_u[i])])
    elif max(box) == s.count(s_u[i]):
        box.append([s_u[i],s.count(s_u[i])])
            
ans_box = sorted(box)
for i in range(len(ans_box)):
    print(ans_box[i])

### FIXED CODE ###

n=int(input())
dic = dict()

a = 0
for i in range(n):
    s = str(input())
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
    if dic[s] > a:
        a = dic[s]
box= []
for i in dic:
    if dic[i] == a:
        box.append(i)

ans = sorted(box)
for i in range(len(ans)):
    print(ans[i])