Harryxun/stf_run huggingface dataset:
import collections

a = list(map(int,input().split()))
c = []
d = []
for i in range(a[2]):
    b = list(map(int,input().split()))
    c.append(b[0])
    d.append(b[1])

ans1 = 0
ans2 = 0

e = collections.Counter(c)
f = collections.Counter(d)
g = e.most_common()[0][0]
gc = e.most_common()[0][1]
h = f.most_common()[0][0]
hc = f.most_common()[0][1]

ans1 += gc
ans2 += hc

for i in range(a[0]):
    if g[i] == g:
        h[i] = -1
    if h[i] == h:
        g[i] = -1    

e = collections.Counter(c)
f = collections.Counter(d)
g = e.most_common()[0][0]
gc = e.most_common()[0][1]
h = f.most_common()[0][0]
hc = f.most_common()[0][1]

if g == '-1':
    g = e.most_common()[1][0]
    gc = e.most_common()[1][1]
if h == '-1':
    h = f.most_common()[1][0]
    hc = f.most_common()[1][1]

ans1 += gc
ans2 += hc

if ans1 > ans2:
    print(str(ans1))
else:
    print(str(ans2))

### FIXED CODE ###

import collections
import copy

a = list(map(int,input().split()))
c = []
d = []
for i in range(a[2]):
    b = list(map(int,input().split()))
    c.append(b[0])
    d.append(b[1])

ans1 = 0
ans2 = 0

cp = copy.copy(c)
dp = copy.copy(d)

e = collections.Counter(c)
f = collections.Counter(d)
g = e.most_common()[0][0]
gc = e.most_common()[0][1]
h = f.most_common()[0][0]
hc = f.most_common()[0][1]
ans1 += gc
ans2 += hc
for i in range(a[2]):
    if cp[i] == g:
        d[i] = -1
    if dp[i] == h:
        c[i] = -1
e = collections.Counter(c)
f = collections.Counter(d)
g = e.most_common()[0][0]
gc = e.most_common()[0][1]
h = f.most_common()[0][0]
hc = f.most_common()[0][1]

if g == -1:
    if gc == a[2]:
        gc = 0
    else:
        g = e.most_common()[1][0]
        gc = e.most_common()[1][1]
if h == -1:
    if hc == a[2]:
        hc = 0
    else:
        h = f.most_common()[1][0]
        hc = f.most_common()[1][1]

ans1 += hc
ans2 += gc
if ans1 > ans2:
    print(str(ans1))
else:
    print(str(ans2))
N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
for i in range(N-1):
  a[i],b[i]=map(int,input().split())
for i in range(Q):
  p[i],x[i]=map(int,input().split())
v=[0]*N
 
for i in range(Q):
  box=[]
  box.append(p[i])
  for k in range(N-1):
    if a[k] in box :
      box.append(b[k])
  for l in range(len(box)):
    num=box[l]-1
    v[num]+=x[i]
 
for h in range(N):
  print(v[h], end=" ")

### FIXED CODE ###

a=int(input())
s=input()

if a<3200 :
  s='red'

print(s)
from collections import deque

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

nei_L = [[] for _ in range(M)]
for i in range(M):
    a, b = map(int, input().split())
    nei_L[a - 1].append(b - 1)
    nei_L[b - 1].append(a - 1)

ans = [-1] * N
visited = [0] * N
queue = deque()

def bfs():
    queue.append(0)
    while len(queue) > 0:
        #if all(visited):
            #break
        now = queue.popleft()

        for c in nei_L[now]:

            if not visited[c]:
                ans[c] = now
                queue.append(c)
                visited[c] = 1


bfs()

if -1 in visited[1:]:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)

### FIXED CODE ###

from collections import deque

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

nei_L = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    nei_L[a - 1].append(b - 1)
    nei_L[b - 1].append(a - 1)

ans = [-1] * N
queue = deque()


def bfs():
    queue.append(0)
    while queue:
        now = queue.popleft()

        for c in nei_L[now]:
            if ans[c] == -1:
                ans[c] = now
                queue.append(c)


bfs()

if -1 in ans[1:]:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)
N,K = map(int, input().split())
p=list(map(int,input().split()))


ans=[]
for j in  range(1,N-K+1):
    temp=0
    temp+=(0.5*(sum(p[j:j+K])+K))
    ans.append(temp)
    

print(max(ans))

### FIXED CODE ###

from itertools import accumulate

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

q=[0]+p
q=list(accumulate(q)) 

ans=[]
for i in range(N-K+1):
    ans.append(((q[i+K]-q[i])+K)*0.5)

print(max(ans))
or i in range(N) :
    if (S[i] == 'a') and (c < A + B) :
        print('Yes')
        c += 1
    elif S[i] == 'b' and (c < A + B) and b < B:
        print('Yes')
        b += 1
        c += 1
    else :
        print('No')

### FIXED CODE ###

N, A, B = map(int,input().split())
S = list(input())
b = 0
c = 0

for i in range(N) :
    if (S[i] == 'a') and (c < A + B) :
        print('Yes')
        c += 1
    elif S[i] == 'b' and (c < A + B) and b < B:
        print('Yes')
        b += 1
        c += 1
    else :
        print('No')
import numpy as np

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

listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

count = 0
for i in range(n):
    for j in range(n):
        if(i < j):
            dis = 0
            for k in range(d):
                dis += (listA[i][k]-listA[j][k]) ** 2
            dis = np.sqrt(dis)
            if(dis.is_integer()):
                count += 1


print(count)


### FIXED CODE ###

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

if( a*n < b ):
    print(a*n)
else:
    print(b)
input()
a = input().split()
a.reverse()
print(' '/join(a))

### FIXED CODE ###

input()
number = input().split()
number.reverse()
print(' '.join(number))
c=[[]]
c[0].append(input())
c[1].append(input())
for i in range(3):
  if c[0][i]!=c[1][2-i]:
    print('NO')
    exit()
print('YES')

### FIXED CODE ###

c=[]
c.append(input())
c.append(input())
for i in range(3):
  if c[0][i]!=c[1][2-i]:
    print('NO')
    exit()
print('YES')
#他の人の回答
import collections

N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]　#sortedでリストになった文字列をjoinでもう一度文字列に
c = collections.Counter(s)　　#cは辞書の形をとる
ans = 0
for si in set(s):　# sから重複を無くす
    n = c[si]
    ans += n * (n - 1) // 2   # n C 2を計算
print(ans)

### FIXED CODE ###

import itertools,math
n = int(input())
word = [input() for _ in range(n)]
count = 0

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

for i in range(n):
    word[i] = sorted(word[i])

new_word = list(sorted(word))

x = 1

for i in range(n-1):
    if new_word[i] == new_word[i+1]:
        x += 1
    elif x >= 2:
        count += combinations_count(x,2)
        x = 1
if x >= 2:
    count +=  combinations_count(x,2)

print(count)
import sys
sys.setrecursionlimit(10**5)
def main():
    n = int(input())
    h = [int(x) for x in input().split()]
    memo = [None for i in range(n)]

    # def rec(n):
    #     if memo[n-1] == None:
    #         if n <= 1:
    #             memo[n-1] = 0
    #         elif n == 2:
    #             memo[n-1] = abs(h[1]-h[0])
    #         else:
    #             d1 = rec(n-2)+abs(h[n-1]-h[n-3])
    #             d2 = rec(n-1)+abs(h[n-1]-h[n-2])
    #             memo[n-1] = min(d1,d2)
    #     return memo[n-1]
        
    # print(rec(n))

    def f(n):
        if memo[n-1] == None:
          if n <= 1:
              memo[0] = 0
          elif n == 2:
              memo[1] = abs(h[1]-h[0])
          else:
              d1 = f(n-1) + abs(h[n-1]-h[n-2])
              d2 = f(n-2) + abs(h[n-1]-h[n-3])
              memo[n-1] = min(d1,d2)
        return memo[n-1]

    print(f(n))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
def main():
    n = int(input())
    h = [int(x) for x in input().split()]
    memo = [None for i in range(n)]

    def rec(n):
        if memo[n-1] == None:
            if n <= 1:
                memo[n-1] = 0
            elif n == 2:
                memo[n-1] = abs(h[1]-h[0])
            else:
                d1 = rec(n-2)+abs(h[n-1]-h[n-3])
                d2 = rec(n-1)+abs(h[n-1]-h[n-2])
                memo[n-1] = min(d1,d2)
        return memo[n-1]
        
    print(rec(n))

if __name__ == "__main__":
    main()
s = input()
t = input()

s_list = list(s)
t_list = list(t)

s_list.sort()
t_list.sort()
    
for i in range(min(len(s_list), len(t_list))):
  if s_list[i] < t_list[i]:
    print('Yes')
    break
  elif s_list[i] > t_list[i]
    print('No')
    break
  else:
    if i == min(len(s_list), len(t_list)):
      if len(s_list) < len(t_list):
        print('Yes')
      else
        print('No')
    else
      continue
      

### FIXED CODE ###

s = input()
t = input()

s_list = list(s)
t_list = list(t)

s_list.sort()
t_list.sort(reverse=True)

s = "".join(s_list)
t = "".join(t_list)

if s < t:
  print("Yes")
else:
  print("No")
# atCoder Beginner Contest 147 a

import sys


def main():
    l = list(sys.stdin.readline().split())
    if sum(l) <= 21:
        print('win')
    else:
        print('bust')


main()


### FIXED CODE ###

# atCoder Beginner Contest 147 a

import sys


def main():
    l = list(sys.stdin.readline().split())
    l = [int(e) for e in l]
    if sum(l) <= 21:
        print('win')
    else:
        print('bust')


main()
print(input()[0:3]+'8'+input()[5:])

### FIXED CODE ###

print('2018'+input()[4:])
from itertools import product
t=[]
ans=0
n,m=map(int,input().split())
s=list(product([1,-1],repeat=3))
for i in range(n):
    li=[]
    p,q,r=map(int,input().split())
    for a,b,c in s:
        li.append(a*p+b*q+c*r)
    t+=[li]
for j in list(zip((*t))):
    p=sum(sorted(j)[n-m:])
    ans=max(ans,p)
print(ans)


### FIXED CODE ###

from itertools import product
t=[]
ans=0
n,m=map(int,input().split())
s=list(product([1,-1],repeat=3))
for i in range(n):
    li=[]
    p,q,r=map(int,input().split())
    for a,b,c in s:
        li.append(a*p+b*q+c*r)
    t+=[li]
for j in list(zip(*t)):
    p=sum(sorted(j)[n-m:])
    ans=max(ans,p)
print(ans)
x = int(a b)
print a * b 2 * (a + b)

### FIXED CODE ###

a, b = map(int, raw_input(). split())
print a * b, 2 * (a + b)
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N=int(input())
if N % 2 == 0:
    print(N//2)
else
    print(N//2 + 1)

### FIXED CODE ###

#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N=int(input())
if N % 2 == 0:
    print(N//2)
else:
    print(N//2 + 1)
p=[]
q=[]
n,m = map(int,input().split())
for _ in [0]*m:
  a,b = map(int,input().split())
  if a == 1:
    p += [b]
  elif b == n:
    q += [a]
p.sort()
q.sort()
i,j = 0,0
while i<len(p) or j<len(q):
    if p[i]<q[j]:
      i += 1
    elif p[i]>q[j]:
      j += 1
    else:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

### FIXED CODE ###

p=[]
q=[]
n,m = map(int,input().split())
for _ in [0]*m:
  a,b = map(int,input().split())
  if a == 1:
    p += [b]
  elif b == n:
    q += [a]
p.sort()
q.sort()
i,j = 0,0
while i<len(p) and j<len(q):
    if p[i]<q[j]:
      i += 1
    elif p[i]>q[j]:
      j += 1
    else:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")
r= map(int,raw_input().split())
s=float(r)*r*pi
l=float(r)*2*pi

print "%f %f" %(s,l)

### FIXED CODE ###

import math

r= input()
s=math.pi*float(r)**2
l=2*math.pi*float(r)

print "%f %f" %(s,l)
k=int(input())
a,b=map(input().split())
for i in range(a<b):
	if range(a<b)%k==0:
		print('OK')
    else:
    	print('NG')


### FIXED CODE ###

k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i % k == 0:
    print('OK')
    break
else:
  print('NG')
h, w, n = [int(i) for i in input().split()]
a, b = zip(*
  [[int(i) for i in input().split()] for j in range(n)])

board = [[0]*(w+1) for i in range(h+1)]

ans = [0] * 9
ans[0] = (h-2) * (w-2)

for a, b in zip(a, b):
  for i in range(max(2, a-1), min(h, a+2)):
    for j in range(max(2, b-1), min(w, b+2)):
      try:
        ans[board[i][j]] -= 1
        board[i][j] += 1
        ans[board[i][j]] += 1
      except:
        pass

for i in range(0, 9):
  print(ans[i])

### FIXED CODE ###

h, w, n = [int(i) for i in input().split()]
if n == 0:
  a = b = [0] 
else:
  a, b = zip(*
  [[int(i) for i in input().split()] for j in range(n)])

board = { }

ans = [0] * 10
ans[0] = max(0, (h-2)) * max(0, (w-2))

for a, b in zip(a, b):
  for i in range(max(2, a-1), min(h, a+2)):
    for j in range(max(2, b-1), min(w, b+2)):
      try:
        ans[board.get((i, j), 0)] -= 1
        board[(i, j)] = board.get((i, j), 0) + 1
        ans[board[(i, j)]] += 1
      except:
        pass

for i in range(10):
  print(ans[i])
n = int(Input())
p = list(map(int,input().split()))
count = 0
for x in range(len(p)):
  if p[x] == min(p[:x+1]):
    count += 1

print(count)
    

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
count = 0
a = p[0]
for x in range(len(p)):
  if p[x] <= a:
    count += 1
    a = p[x]
  
print(count)
n=int(input())
l=list(map(int,input().split()))
max_value=-999
cnt=0
for i in range(n):
  if max_balue<l[i]:
    cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
cnt=1
max_h=-1
for i in range(n-1):
  max_h=max(l[i],max_h)
  if l[i+1]>=max_h:
    cnt+=1
print(cnt)
# coding:utf-8

import sys
from bisect import bisect_left, bisect_right
INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()
    A.sort()

    res = 0
    used = [0] * n
    for p in range(1, max(A).bit_length() + 1)[::-1]:
        t = 2 ** p
        for i in range(n)[::-1]:
            a = A[i]
            if used[i]:
                continue
            if a >= t:
                break
            bi = bisect_left(A, t - a)
            if A[bi] == t - a:
                if i != bi and not used[bi]:
                    res += 1
                    used[i] = 1
                    used[bi] = 1

    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# coding:utf-8

import sys
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    MA = defaultdict(int)
    # 目標値をO(1)で見つけるために辞書に格納
    for a in A:
        MA[a] += 1

    key_n = list(MA.keys())
    key_n.sort()
    key_n.reverse()

    res = 0
    p = 30
    for x in key_n:
        # すでにペアを作るために使用してしまっている時はパス
        if not MA[x]:
            continue

        # 残っているボールの中で一番大きな値xを選ぶと，そのボールを使って表せる2べきの値x + yは1つに定まる
        # x + 1 <= x + y < 2x
        # 2べきの比は2であるのに対して，x + 1と2xの比は2未満だから
        while 2 * x < 2 ** p:
            p -= 1

        if x + 1 <= 2 ** p:
            y = 2 ** p - x
            if not MA[y]:
                continue

            if x == y:
                _add = MA[x] // 2
            else:
                _add = min(MA[x], MA[y])

            res += _add
            MA[x] -= _add
            MA[y] -= _add

    print(res)


if __name__ == '__main__':
    main()
n,a,b=map(int,input().split())
if n*a<b:
    print(n*a)
else:
    print(B)

### FIXED CODE ###

n,a,b=map(int,input().split())
if n*a<b:
    print(n*a)
else:
    print(b)
# TLEするはず
def main():
    N = int(input())
    X = input()
    t = X.count("1")
    d1 = []
    d2 = []
    d11 = 1
    d22 = 1
    for i in range(1, N+1):
        d1.append(d11)
        d11 *= 2
        d11 %= t-1
        d2.append(d22)
        d22 *= 2
        d22 %= t+1
    V = int(X, 2)
    for i in range(N):
        x = 0
        cur_bits = 0
        if t != 1 and X[i] == "1":
            cur_bits = t - 1
            x = V ^ d1[N-i-1]
        elif t != 1:
            cur_bits = t + 1
            x = V ^ d2[N-i-1]
        else:
            x = 0
        ans = 0
        while x > 0:
            x = x % cur_bits
            ans += 1
            cur_bits = "{:0b}".format(x).count("1")
        print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# わからんわからんわからんわからんわからん
# なんで1500人も解いてんの？この界隈天才しかおらん
table = [0 for i in range(2*10**5+5)]
for i in range(2*10**5+5):
    table[i] = "{:0b}".format(i).count("1")


def main():
    N = int(input())
    X = input()
    t = X.count("1")
    x1, x2 = int(X, 2) % (t+1), int(X, 2) % (t-1) if t != 1 else 0
    for i in range(N):
        ans = 1
        x = 0
        if X[i] == "0":
            # 反転してt+1
            p = pow(2, N-i-1, t+1)
            x = x1 + p
            x %= t+1
        elif t != 1:
            p = pow(2, N-i-1, t-1)
            x = x2 - p
            x %= (t-1)
        else:
            ans = 0
        while x > 0:
            x %= table[x]
            ans += 1
        print(ans)


if __name__ == '__main__':
    main()
s=input()
t=input()
count=0
for i in range(3):
    if s(i)==t(i):
      count+=1
print(count)


### FIXED CODE ###

s=input()
t=input()
count=0
for i in range(3):
    if s[i]==t[i]:
      count+=1
print(count)
from collections import deque

n, q = map(int, input().split( ))
Edg=[[] for i in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split( ))
    Edg[a].append(b)
Ans=[0 for i in range(n+1)]
P = [0 for i in range(n+1)]
for i in range(q):
    p, x = map(int, input().split( ))
    P[p]+=x
#print(*P)
Chld=[[] for i in range(n+1)]
for p in range(n+1):
    Task=deque()
    Task.append(p)
    while True:
        try:
            p_=Task.popleft()
            for child in Edg[p_]:
                Chld[p].append(child)
                Task.append(child)
        except:
            break
#print(Chld)
for p in range(n+1):
    tmp = P[p]
    Ans[p]+=tmp
    for c in Chld[p]:
            Ans[c]+=tmp

print(*Ans[1:])


### FIXED CODE ###

a=int(input())
s=input()
if a>=3200:
    print(s)
else:
    print("red")
n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
cheby = []
for i in range(n):
    l = [xy[i][0]-xy[i][1],xy[i][0]+xy[i][1]]
    cheby.append(l)

xmax = 1
xmin = 10**9
ymax = 1
ymin = 10**9
for i in range(n):
    if cheby[i][0] > xmax :
        xmax = cheby[i][0]
        xa = i
    if cheby[i][0] < xmin :
        xmin = cheby[i][0]
        xi = i
    if cheby[i][1] > ymax :
        ymax = cheby[i][1]
        ya = i
    if cheby[i][1] < ymin :
        ymin = cheby[i][1]
        yi = i

if abs(xmax-xmin) > abs(ymax-ymin):
    print(abs(xy[xa][0]-xy[xi][0])+abs(xy[xa][1]-xy[xi][1]))
else :
    print(abs(xy[ya][0]-xy[yi][0])+abs(xy[ya][1]-xy[yi][1]))


### FIXED CODE ###

n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
cheby = []
for i in range(n):
    l = [xy[i][0]-xy[i][1],xy[i][0]+xy[i][1]]
    cheby.append(l)

xmax = -10**10
xmin = 10**10
ymax = -10**10
ymin = 10**10
for i in range(n):
    if cheby[i][0] > xmax :
        xmax = cheby[i][0]
        xa = i
    if cheby[i][0] < xmin :
        xmin = cheby[i][0]
        xi = i
    if cheby[i][1] > ymax :
        ymax = cheby[i][1]
        ya = i
    if cheby[i][1] < ymin :
        ymin = cheby[i][1]
        yi = i

if abs(xmax-xmin) > abs(ymax-ymin):
    print(abs(xy[xa][0]-xy[xi][0])+abs(xy[xa][1]-xy[xi][1]))
else :
    print(abs(xy[ya][0]-xy[yi][0])+abs(xy[ya][1]-xy[yi][1]))
from itertools import permutations
inputs = open(0).readlines()
n = int(inputs[0])
S = inputs[1].strip()

R = [i for i, c in enumerate(S) if c == 'R']
G = [i for i, c in enumerate(S) if c == 'G']
B = [i for i, c in enumerate(S) if c == 'B']

def f(Z, i, x, y):
    for z in Z[i:]:
        if z == 2*y-x:
            return 1
        if z > 2*y-x:
            return 0
    return 0

ans = 0
for X, Y, Z in list(permutations([R, G, B])):
    for x in X:
        for y in Y:
            if x < y:
                idx = 0
                for i, z in enumerate(Z):
                    if y < z:
                        break
                if y < z:
                    ans += len(Z) - i - f(Z, i, x, y)
print(ans)

### FIXED CODE ###

n = int(input())
S = input().strip()
r, g, b = map(S.count, 'RGB')
t = 0
for i in range(n-2):
    for w in range(1, (n-i+1) // 2):
        t += len({S[i], S[i+w], S[i+2*w]}) == 3
print(r*g*b - t)
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 10:29:00 2020

@author: azikausy
"""

from collections import deque
S = list(input())
Q = int(input())
#Query = {}
#TFC = []
perm = 0
d = deque(S)
for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        #Query[i] = [l[0], 0, 0]
        #S.reverse()
        perm += 1
    else:
        #Query[i] = l
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.insert(0, l[2])

#print(d)
S0 = list(d)
#print(S0)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)

### FIXED CODE ###

from collections import deque
S = list(input())
Q = int(input())
perm = 0
d = deque(S)

for i in range(0, Q):
    l = input().split()
    if len(l) == 1:
        perm += 1
    else:
        if (int(l[1])+perm) % 2 == 0:
            d.append(l[2])
        else:
            d.appendleft(l[2])
 
S0 = list(d)
if perm % 2 != 0:
    S0.reverse()
ans = ""
for i in range(0, len(S0)):
    ans = ans + S0[i]
print(ans)
from marh import sqrt
a,b=input().split()
c=sqrt(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

from math import sqrt
a,b=input().split()
c=sqrt(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")
total, index = map(int, input().split())
string = list(map(str, input().split()))
string[index-1] = string[index-1].lower()
print(string)

### FIXED CODE ###

n, k = map(int, input().split())
string = str(input())
arr = list(string)
arr[k-1] = arr[k-1].lower()
print(*arr, sep="")
#D
N=int(input())
X=str(input())
   
CNT=0
for i in range(N):
    if X[i]=="1":
        CNT+=1
NUM=int(X,2)

to0_cnt=[0 for i in range(N)]
for i in range(1,N):
    ans=0
    num=i
    while True:
        cnt=0
        for j in bin(num)[2:]:
            if j=="1":
                cnt+=1
        if cnt==0:
            break
        r=num%cnt
        ans+=1
        if r==0:
            break
        num=r
    to0_cnt[i]=ans
                

R=[NUM%(CNT+1),NUM%(CNT-1)]
for i in range(N):
    if X[i]=="0":
        cnt=CNT+1
        r=(R[0]+2**(N-i-1))%cnt
    else:
        cnt=CNT-1
        r=(R[1]-2**(N-i-1))%cnt
    
    ans=1+to0_cnt[r]
    print(ans)

### FIXED CODE ###

#D
N=int(input())
X=str(input())
   
CNT=0
for i in range(N):
    if X[i]=="1":
        CNT+=1
NUM=int(X,2)

to0_cnt=[0 for i in range(N)]
for i in range(1,N):
    ans=0
    num=i
    while True:
        cnt=0
        for j in bin(num)[2:]:
            if j=="1":
                cnt+=1
        if cnt==0:
            break
        r=num%cnt
        ans+=1
        if r==0:
            break
        num=r
    to0_cnt[i]=ans
                
R=[NUM%(CNT+1),NUM%(CNT-1) if CNT!=1 else 0]
for i in range(N):
    if X[i]=="0":
        cnt=CNT+1
        r=(R[0]+pow(2,N-i-1,cnt))%cnt
    else:
        cnt=CNT-1
        if NUM-pow(2,N-i-1)==0:
            print(0)
            continue
        r=(R[1]-pow(2,N-i-1,cnt))%cnt
    
    ans=1+to0_cnt[r]
    print(ans)
p, q, r = map(int, input().split())

print(p + q + r - map(p, q, r))

### FIXED CODE ###

p, q, r = map(int, input().split())

print(p + q + r - max(p, q, r))
.replace('1','9')


### FIXED CODE ###

n = input()
print(n.replace("1", "x").replace("9", "1").replace("x", "9"))
from collections import Counter
n = int(input())
A = Counter(list(input()))
B = Counter(list(input()))
C = Counter(list(input()))
ans = ""
for key,value in A.items():
  ans.append(str(key)*min(value,B[key],C[key]))
print(sorted(ans))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=Counter(input())
for i in range(n-1):
    s&=Counter(input())
print("".join(sorted(s.elements())))