Harryxun/stf_run huggingface dataset:
# import sys
# sys.setrecursionlimit(2000)

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


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = []
        self.y = []
        
    def new_cor_n(self):
        if self.n <= 2:
            return 0
        s = len(self.x) * len(self.y) - self.n
        if s < 0:
            s = 0
        return s
        
def grouping(group, x, xcor, ycor):
    xcor[x][1] = True
    group.x.append(x)
    for y in xcor[x][0]:
        if ycor[y][1]:
            continue
        group.n += 1
        ycor[y][1] = True
        group.y.append(y)
        for x_ in ycor[y][0]:
            if xcor[x_][1]:
                continue
            group.n += 1
            grouping(group, x_, xcor, ycor)
            
if N <= 2:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for x, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        grouping(group, x, xcor, ycor)
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)

### FIXED CODE ###

# import sys
# sys.setrecursionlimit(20000)


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


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = 0
        self.y = 0
        self.xy = {}
        
    def new_cor_n(self):
        return self.x * self.y - self.n
        

def grouping(group, x, xcor, ycor):
    x_list = []
    group.x += 1
    for y in xcor[x][0]:
        if (x, y) not in group.xy:
            group.n += 1
            group.xy[(x, y)] = None
        if ycor[y][1]:
            continue
        ycor[y][1] = True
        group.y += 1
        for x_ in ycor[y][0]:
            if (x_, y) not in group.xy:
                group.n += 1
                group.xy[(x_, y)] = None
            if xcor[x_][1]:
                continue
            xcor[x_][1] = True
            x_list.append(x_)
    return x_list

if N <= 2:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for i, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        xcor[i][1] = True
        x_list = [i]
        while True:
            new_x_list = []
            for x in x_list:
                new_x_list += grouping(group, x, xcor, ycor)
            if new_x_list == []:
                break
            x_list = new_x_list
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)
s = input()
print(sorted(list(set([s[i:j+1] for i in range(len(s)) for j in range(i,len(s))])))[int(input())-1])

### FIXED CODE ###

s = input()
K = int(input())
ls = []

for i in range(1,K+1):
    for j in range(len(s)):
        ls.append(s[j:j+i])
print(sorted(set(ls))[K-1])
x = int(input())

500yen = x//500*1000
5yen = x%500//5*5

print(500yen + 5yen)


### FIXED CODE ###

x = int(input())

a = x//500*1000
b = x%500//5*5

print(a+b)
import sys
import itertools
import resource
xrange = lambda stop: iter(itertools.count().next, stop)
sys.setrecursionlimit(1000000)
ys.setrecursionlimit(10 ** 9)
resource.setrlimit(resource.RLIMIT_STACK, (-1, -1))
n = int(input())

chars ={1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g', 8: 'h', 9: 'i', 10: 'j', 11: 'k', 12: 'l', 13: 'm', 14: 'n', 15: 'o', 16: 'p', 17: 'q', 18: 'r', 19: 's', 20: 't', 21: 'u', 22: 'v', 23: 'w', 24: 'x', 25: 'y', 26: 'z'}

if n <= 26:
    print(chars[n])
    sys.exit()



def Base_10_to_26(X):
    if (X//26):
        return Base_10_to_26(int(X//26))+chars[int(X%26)]
    return chars[int(X%n)]

print(Base_10_to_26(n))


### FIXED CODE ###

import sys
import itertools
#import resource
#xrange = lambda stop: iter(itertools.count().next, stop)
#sys.setrecursionlimit(1000000)
#sys.setrecursionlimit(10 ** 13)
n = int(input())

chars ={1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g', 8: 'h', 9: 'i', 10: 'j', 11: 'k', 12: 'l', 13: 'm', 14: 'n', 15: 'o', 16: 'p', 17: 'q', 18: 'r', 19: 's', 20: 't', 21: 'u', 22: 'v', 23: 'w', 24: 'x', 25: 'y', 26: 'z'}

if n <= 26:
    print(chars[n])
    sys.exit()


ans = []
while True:
    n -= 1
    ans.append(chr(ord("a") + n % 26))
    n //= 26
    if n <= 0:
        break
for i in range(len(ans)):
    print(ans[-i-1], end="")
A,B,K=map(int,input().split())
for x in range(K):
    if A>=1:
        A-=1
    else:
        B-=1
print(A,B)

### FIXED CODE ###

S,T=map(str,input().split())
print(T+S)
a,b,c,d = map(int, input().split())

print(min(a,b) + min(c,d))


### FIXED CODE ###

a,b,c,d = [int(input()) for i in range(4)]

print(min(a,b) + min(c,d))
import sys
 
stdin=sys.stdin
 
input = sys.stdin.readline


n,q=input()
AB=[[int(x) for x in input().split()] for _ in range(n-1)]
PX=[[int(x) for x in input().split()] for _ in range(q)]

graph=[[] for _ in range(n+1)]
values=[0]*(n+1)

for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

for p,x in PX:
    values[p]+=x

#print(graph)

def dfs(x,parent,add):
    values[x]+=add
    for i in graph[x]:
        if i==parent:
            continue
        dfs(i,x,values[x])

dfs(1,0,0)

print(' '.join(map(str,values[1:])))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
n = int(input())
a = [int(input()) for i in range(n)]

r = [max([*a[0:i],*a[i+1:]]) for i in range(n)]

for answer in r:
     print(answer)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

a_max = max(a)
idx = [i for i, x in enumerate(a) if x==a_max]

if len(idx) > 1:
    for i in range(n):
        print(a_max)
else:
    for i in range(n):
        if a[i] == a_max:
            print(max(a[0:i]+a[i+1:]))
        else:
            print(a_max)
A = input()
B = input()
A = int(A)
B = int(B)
K = (A+B) / 2
K = int(K)

if K % 2 == 0:
    print(K)
else:
    print("IMPOSSIBLE")
    

### FIXED CODE ###

A, B = input().split()
A = int(A)
B = int(B)

if (A+B) % 2 == 0 and A != B:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")
A = input()
B = input()
C = input()
D = A + B + C
if(D<=12):
  if (A == 7):
    if(B == 5):
      print('YES')
  if (B == 7):
    if(A == 5):
      print('YES')
  if (C == 7):
    if(A == 5):
      print('YES')
else:
  print('NO')

### FIXED CODE ###

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

A = a[0] + a[1]
if(A==10 or A==12):
  if (a[0] == 7):
    if(a[2] == 5 and a[1] == 5):
      print('YES')
    else:
      print('NO')
  elif (a[1] == 7):
    if(a[2] == 5 and a[0] == 5):
      print('YES')
    else:
      print('NO')
  elif (a[2] == 7):
    if(a[0] == 5 and a[1] == 5):
      print('YES')
    else:
      print('NO')
  else:
    print('NO')
else:
  print('NO')
print((int(input())-1)*(int(input())-1))

### FIXED CODE ###

A,B=map(int,input().split())
print((A-1)*(B-1))
num = int(input())
al = input()

newal = ""
alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(len(al)):
  if(alp.index(al[i])+num>25):
    newal = newal + alp[(alp.index(al[i])+num)-25]
  else:
    newal = newal + alp[alp.index(al[i])+num]
  
print(newal)

### FIXED CODE ###

num = int(input())
al = input()

newal = ""
alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(len(al)):
  if(alp.index(al[i])+num>25):
    newal = newal + alp[(alp.index(al[i])+num)-26]
  else:
    newal = newal + alp[alp.index(al[i])+num]
  
print(newal)
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)
for i, (xi, yi, ci) in enumerate(xyc):
    ans = min(ans, a[xi - 1] + a[yi - 1] - ci)

print(ans)

### FIXED CODE ###

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)
for i, (xi, yi, ci) in enumerate(xyc):
    ans = min(ans, max(0, a[xi - 1] + b[yi - 1] - ci))

print(ans)
S = input()
  
if s <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")

### FIXED CODE ###

S = input()
  
if S <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")
T = list(input())
N = len(T)

for i in range(N):
  if T[i] == '?':
    if i == 0:
      if T[1] == 'D':
        T[0] = 'P'
      elif T[1] == 'P':
        T[0] = 'D'
      else:
        T[0] = 'P'
    elif i == N - 1:
      T[i] = 'D'
    else:
      if T[i-1] == 'P':
        T[i] = 'D'
      else:
        if T[i+1] == '?':
          T[i] = 'P'
        else:
          if T[i+1] == 'D':
            T[i] = 'P'
          else:
            T[i] = 'D'
          
print("".join(T))
      

### FIXED CODE ###

T = list(input())
N = len(T)

for i in range(N):
  if T[i] == '?':
    if T == ['?']:
      print('D')
      exit()
    if i == 0:
      if T[1] == 'D':
        T[0] = 'P'
      elif T[1] == 'P':
        T[0] = 'D'
      else:
        T[0] = 'P'
    elif i == N - 1:
      T[i] = 'D'
    else:
      if T[i-1] == 'P':
        T[i] = 'D'
      else:
        if T[i+1] == '?':
          T[i] = 'P'
        else:
          if T[i+1] == 'D':
            T[i] = 'P'
          else:
            T[i] = 'D'
          
print("".join(T))
inp_1 = int(input())
inp_2 = input().split(" ")
r = ""

for i in range(inp_1):
  r += inp_2[0][i]
  r += inp_2[1][i]

print(o)


### FIXED CODE ###

inp_1 = int(input())
inp_2 = input().split(" ")
r = ""

for i in range(inp_1):
  r += inp_2[0][i]
  r += inp_2[1][i]

print(r)
import sys
def I(): return int(sys.stdin.readline().rstrip())

K = I()

Graph = [0]*K
for i in range(K):
    if (i+1) % K != (10*i) % K:
        Graph[i] = [(1,(i+1) % K),(0,(10*i) % K)]  # 1を加える,10倍する
    else:
        Graph[i] = [(0,(10*i) % K)]

# dijkstra

from heapq import heappush,heappop

d = [100]*K
d[1] = 1
q = []
heappush(q,(1,1))
v = [False]*K
while q:
    a,n = heappop(q)
    if v[n]:
        continue
    v[a] = True
    for da,dn in Graph[n]:
        if v[dn]:
            continue
        if a+da < d[dn]:
            d[dn] = a+da
            heappush(q,(a+da,dn))

print(d[0])


### FIXED CODE ###

import sys
def I(): return int(sys.stdin.readline().rstrip())

K = I()

Graph = [0]*K
for i in range(K):
    if (i+1) % K != (10*i) % K:
        Graph[i] = [((i+1) % K,1),((10*i) % K,0)]  # 1を加える,10倍する
    else:
        Graph[i] = [((10*i) % K,0)]

from collections import deque

q = deque([1])
d = [100]*K
d[1] = 1
# 01-BFS
while q:
    n = q.pop()
    if n == 0:
        continue
    else:
        for a,b in Graph[n]:
            if d[a] > d[n]+b:
                d[a] = d[n]+b
                if b == 0:
                    q.append(a)
                else:
                    q.appendleft(a)

print(d[0])
import math

n, x = map(int, input().split())
l = list(map(int, input().split()))

if n == 1:
    print(abs(x-l[0]))
    exit()

diff = []
for i in range(len(l)-1):
    diff.append(abs(l[i] - l[i+1]))

for i in range(len(l)):
    diff.append(abs(l[i] - x))

gcd = math.gcd(diff[0], diff[1])
if n == 2:
    print(gcd)
    exit()

for i in range(2, len(diff)-1):
    gcd = math.gcd(gcd, diff[i])

print(gcd)

### FIXED CODE ###

from fractions import gcd

n, x = map(int, input().split())
l = list(map(int, input().split()))

if n == 1:
    print(abs(x-l[0]))
    exit()

diff = []
for i in range(len(l)-1):
    diff.append(abs(l[i] - l[i+1]))

for i in range(len(l)):
    diff.append(abs(l[i] - x))

gcd_1 = gcd(diff[0], diff[1])
if n == 2:
    print(gcd_1)
    exit()

for i in range(2, len(diff)-1):
    gcd_1 = gcd(gcd_1, diff[i])

print(gcd_1)
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
 
n = int(input())
a = list(map(int, input().split()))
a = deque(sorted(a))
ans = 0
for i in a:
    ans = math.gcd(ans, i)
print(ans)

### FIXED CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import fractions
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
 
n = int(input())
a = list(map(int, input().split()))
a = deque(sorted(a))
ans = 0
for i in a:
    ans = fractions.gcd(ans, i)
print(ans)
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
P = [0] + [abs(i) for i in A if i> 0 ]
M = [abs(i) for i in A if i< 0 ] +[0]
M = sorted(M,reverse =False)

PP = []
for i in range(len(P)-1):
    PP.append(P[i+1] - P[i])

MM = []
for i in range(len(M)-1):
    MM.append(M[i+1] - M[i])

cnt = 10000000
#正の部分、負の部分の長さが0の場合エラーが起こる
#正の方向でi個ろうそくを通って、負の方向にK-i個ろうそくを通る
for i in range(1,K):
    cnt =min(cnt,P[i]*2 + sum(MM[0:K-i]))
    #print(cnt)
#負の方向でi個ろうそくを通って、正の方向にK-i個ろうそくを通る
for i in range(1,K):
    cnt =min(cnt,M[i]*2 + sum(PP[0:K-i]))
    #print(cnt)

print(cnt)

### FIXED CODE ###

N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
P = [0] + [abs(i) for i in A if i> 0 ]
M = [abs(i) for i in A if i< 0 ] +[0]
M = sorted(M,reverse =False)


cnt = 10000000000

if len(P) == len(M) == 1:
    cnt = 0
elif len(P) == 1:
    cnt = M[K]
elif len(M) == 1:
    cnt = P[K]
else:
    #リストがK以下の場合不具合が起きる
    #for i in range(1,K):   
    #len(P)=4 len(M)=3 K=5の場合、IndexErrorとなる。rangeをうまく設定する必要があるが実装できない。
    #正の方向でi個ろうそくを通って、負の方向にK-i個ろうそくを通る
    s = max(0,K-len(M)+1)
    e = min(K+1, len(P))
    for i in range(s, e):
        cnt =min(cnt,P[i]*2 + M[K-i])
    #負の方向でi個ろうそくを通って、正の方向にK-i個ろうそくを通る
    s1 = max(0,K-len(P)+1)
    e1 = min(K+1, len(M))
    for i in range(s1, e1):
        cnt =min(cnt,M[i]*2 + P[K-i])

print(cnt)
import numpy as np


def main():
    n, k = map(int, input().split())
    ps = (np.array(list(map(int, input().split()))) + 1) / 2

    cumulative_sum = [0] * n
    for i in range(n):
        if i == 0:
            cumulative_sum[i] = ps[0]
        else:
            cumulative_sum[i] = ps[i] + cumulative_sum[i-1]

    ans = max([cumulative_sum[i+k] - cumulative_sum[i] for i in range(n-k)])
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    ps = list(map(int, input().split()))
    e = [(1+p)/2 for p in ps]

    s = [0]
    for i in range(n):
        s.append(s[i]+e[i])

    ans = max([s[i+k] - s[i] for i in range(n-k+1)])
    print(ans)


if __name__ == "__main__":
    main()
a,b,h=map(int,inpuut().split())
print((a+b)*2/2)

### FIXED CODE ###

a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

diff = [V[i] - C[i] for i in range(N)]
diff.sort(reverse=True)

i, ans = 0,0
while diff[i] > 0:
    ans += diff[i]
    i += 1
print(ans)

### FIXED CODE ###

input()
print(sum((v-c for v,c in zip(map(int,input().split()),map(int,input().split())) if v-c>0)))
n=int(input())

result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,len(str(n)):
            if k%(10**j)==3:
                result.append(i)
                break
            else:
                k=k//10**j
        else:
            continue

print(*result)

### FIXED CODE ###

n=int(input())
 
result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,5):
            if k%10==3:
                result.append(i)
                break
            else:
                k=k//10
        else:
            continue
 
print("",*result)
from bisect import bisect_left
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC,key= lambda x: x[1],reverse=True)
A.sort()
bisec = bisect_left
ex = A.extend
su =0
for i in range(M):
    if BC[i][1]<=A[0]:
        break
    B= BC[i][0]
    C = BC[i][1]
    b = bisec(A,C)
    if B>=b:
        su += C*b
        del A[:b]
    else:
        su += C*B
        del A[:B]
print(sum(A)+su)

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC,key= lambda x: x[1],reverse=True)
A.sort()
n = 0
i = 0
m = 0
while A[i]<BC[n][1]:
    A[i] = BC[n][1]
    m = m+1
    if m >=BC[n][0]:
        m = 0
        n = n+1
    i += 1
    if n==M:
      break
    if i == N:
      break
print(sum(A))
S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if sl[0] != 'A':
    ans = 'WA'
if sl[2:-1].count('C') != 1:
    ans = 'WA'
sl.pop(0)
sl.pop(sl.index('C'))
s = "".join(sl)

if s.islower() == False:
    ans = 'WA'
#print(sl)
print(ans)

### FIXED CODE ###

S = input()
sl = []
ans = 'AC'

for i in S:
    sl.append(i)
if S[0] != 'A':
    ans = 'WA'
if S[2:-1].count('C') != 1:
    ans = 'WA'

if S[1:].replace("C","c",1).islower() == False:
    ans = 'WA'
#print(sl)
print(ans)
N, K = map(int, input().split())
N = N%K
min_num = 0
while True:
  if (N==0):
    min_num = N
    break
  elif N in history:
    min_num = min(history)
    break 
  history.append(N)
  N = abs(N-K)

print(min_num)

      


### FIXED CODE ###

N, K = input().split()
N = int(N)
K = int(K)

middle = N % K
answer = middle
while True:
  if abs(answer-K) > N:
    answer = N
    break
  if abs(answer - K) < answer:
    answer = abs(answer-K)
  else:
    break
    
print(str(answer))
s=sys.stdin
if s[len(s)-1] =="s":
	print(s + "es")
else:
	print(s + "s")

### FIXED CODE ###

s=input()
if s[len(s)-1] =="s":
	print(s + "es")
else:
	print(s + "s")
c, r = map(int, input().split())
last_list = [0] * r
for _ in range(c):
    n = 0
    x = input()
    sum_list = list(map(int, x.split()))
    for i in range(r):
        last_list[i] += sum_list[i]
        n += sum_list[i]
    print(x, end = " ")
    print(n)

sum = 0   
for a in last_list:
    sum += a
print(*last_list, sum)

### FIXED CODE ###

r, c = map(int, input().split())
last_list = [0] * (c + 1)
for _ in range(r):
    n = 0
    x = input()
    sum_list = list(map(int, x.split()))
    for i in range(c):
        last_list[i] += sum_list[i]
        n += sum_list[i]
    print(x, n)

last_list[-1] = sum(last_list)
print(*last_list)
N,A,B,C,D = map(int,input().split())
S = list(input())

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    cnt = 0
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(B-2,D+1):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')
        
        
        


### FIXED CODE ###

N,A,B,C,D = map(int,input().split())
S = list(input())

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    cnt = 0
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(B-2,min(D+1,N)):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')
k=int(input())
if k==4 or k==6 or k==9 or k==10 or k==14 or k==21 or k==22 or k==25 or k==26:
  print(2)
elif k==8 or k==12 or k==18 or k==20 or k==27:
  print(5)
elif k==16:
  print(14)
elif k==24:
  print(15)
elif k==32:
  print(51):
else:
  print(1)

### FIXED CODE ###

k=int(input())
if k==4 or k==6 or k==9 or k==10 or k==14 or k==21 or k==22 or k==25 or k==26:
  print(2)
elif k==8 or k==12 or k==18 or k==20 or k==27:
  print(5)
elif k==16:
  print(14)
elif k==24:
  print(15)
elif k==32:
  print(51)
elif k==28 or k==30:
  print(4)
else:
  print(1)
s = str(input())
q = int(input())
state = True
front = ""
end = ""
for _ in range(q):
  qi = str(input())
  if qi[0] == "2":
    fi,ci = map(str,qi[2:].split())
    if state == True:
      if fi == "1":
        front += ci
      else:
        end += ci
    else:
      if fi == "1":
        end += ci
      else:
        front += ci
  else:
    state = not state
if state:
  first = front[::-1]
  last = end
else:
  first = end[::-1]
  last = front
  s = s[::-1]
for f in first:
  print(f,end="")
for si in s:
  print(s,end="")
for l in last:
  print(l,end="")





### FIXED CODE ###

s = str(input())
q = int(input())
state = True
front = ""
ending = ""
for _ in range(q):
  qi = str(input())
  if qi[0] == "2":
    fi,ci = map(str,qi[2:].split())
    if state == True:
      if fi == "1":
        front += ci
      else:
        ending += ci
    else:
      if fi == "1":
        ending += ci
      else:
        front += ci
  else:
    state = not state
if state:
  first = front[::-1]
  lastt = ending
else:
  first = ending[::-1]
  lastt = front
  s = s[::-1]
print(first+s+lastt)
o=998244353
f=[1]
for i in range(1,2500100):f.append(f[-1]*i%o)
c=lambda n,k: f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)%o
n,m=map(int,input().split())
w=3*m
u=n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u>m:
 for i in range(m+1,min(w,n)+1):
  a=(a-c(n,i)*c((w-i)//2+u,u))%o if w-i+1&1
print(a%o)

### FIXED CODE ###

mod = 998244353
rng = 2500100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
def inv(x):
  return pow(x,mod-2,mod)
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*inv(fctr[n-k])*inv(fctr[k])%mod

n,m = map(int,input().split())
ans = cmb(n+3*m-1,n-1)
ans = (ans-n*cmb(n+m-2,n-1))%mod
if n>m+1:
  for i in range(m+1,min(3*m,n)+1):
    if (3*m-i)%2 == 1:
      continue
    x = (3*m-i)//2
    ans = (ans-cmb(n,i)*cmb(x+n-1,n-1))%mod
print(ans)
N = int(input())
S =[input() for _ in range(N)]
A = [S.count(S[i]) for i in range (N)]
Max_A = max(A)
ans = []
for i in A:
    if i == Max_A:
        ans.append(S[i])
ans = set(ans)
ans = list(ans)
ans.sort()
print("\n".join(ans))
　　　　

### FIXED CODE ###

from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
ans = c.most_common()
ans = [i[0] for i in ans if i[1] == ans[0][1]]
for i in sorted(ans):
    print(i)