Harryxun/stf_run huggingface dataset:
H,W = map(int,input().split())
# dir: 0 -> start
# dir: 1 -> right
# dir: 2 -> down
# dir: 3 -> left
# dir: 4 -> up

grid = [list(input()) for _ in range(H)]


def dfs(grid,y,x,dir):
    global num_l
    if not (0 <= x < W and 0 <= y < H):
        return
    if grid[y][x] == '#':
        return
    num_l += 1
    if dir == 0:
        dfs(grid, y, x+1, 1)
        dfs(grid, y+1, x, 2)
        dfs(grid, y, x-1, 3)
        dfs(grid, y-1, x, 4)
    elif dir == 1:
        dfs(grid, y, x + 1, 1)
    elif dir == 2:
        dfs(grid, y+1, x, 2)
    elif dir == 3:
        dfs(grid, y, x-1, 3)
    elif dir == 4:
        dfs(grid, y-1, x, 4)

ans = 0
for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            num_l = 0
            dfs(grid, h, w, 0)
            ans = max(ans,num_l)
print(ans)

### FIXED CODE ###

import numpy as np
h, w = map(int, input().split())
table = np.array([list(input())for _ in range(h)]) == '.'
 
d = np.zeros((h, w), dtype = int)
u = np.zeros((h, w), dtype = int)
r = np.zeros((h, w), dtype = int)
l = np.zeros((h, w), dtype = int)

for i in range(h):
    d[i] = (d[i-1]+1) * table[i]
    u[-i-1] = (u[-i]+1) * table[-i-1]

for i in range(w):
    r[:, i] = (r[:, i-1]+1) * table[:, i]
    l[:, -i-1] = (l[:, -i]+1) * table[:, -i-1]
print(np.max(d+u+r+l)-3)
N, M = map(int, input().strip().split())

i=1
while i*i < M and i <= M//N:
  if M % i == 0:
    maxg = i
  i += 1

print(maxg)

### FIXED CODE ###

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

i=1
while i <= M//N: 
  if M % i == 0:
    maxg = i
    if M//i <= M//N:
      maxg = M // i
      break
  i += 1

print(maxg)
#import decimal
#decimal.getcontext().prec==500 Floatの桁数を500まで増やす
#Decimal(c).sqrt() それで平方根を求める
#Decimal(1) / Decimal(7) 1/7

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd
import sys
#input = sys.stdin.readline

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

data=[]
for i,a in enumerate([2,5,5,4,5,6,3,7,6]):
    if i+1 in A:
        data.append([a,i+1])

data=sorted(data,key=lambda x:x[0])
data.append([0,0])
tempcount=M//data[0][0]
M%=data[0][0]
itelst=list(combinations_with_replacement(range(1,len(data)),len(data)-1))
lst2=[]
if M==0:
    lst2.append([data[0][1]]*tempcount)
for i in range(20):
    if tempcount<0:
        break
    for lst in itelst:
        K=M
        for i in lst:
            K-=data[i][0]
        if K==0:
            lst2.append([data[i][1] for i in lst if data[i][0]]+[data[0][1]]*tempcount)
    M+=data[0][0]
    tempcount-=1
lst2=sorted(lst2,key=lambda x:len(x))
lst2=[sorted(i,reverse=True) for i in lst2 if len(i)==len(lst2[-1])][0]
print("".join([str(i) for i in lst2]))


### FIXED CODE ###

#import decimal
#decimal.getcontext().prec==500 Floatの桁数を500まで増やす
#Decimal(c).sqrt() それで平方根を求める
#Decimal(1) / Decimal(7) 1/7

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd
import sys
#input = sys.stdin.readline

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

data=[]
for i,a in enumerate([2,5,5,4,5,6,3,7,6]):
    if i+1 in A:
        data.append([a,i+1])

dic={}
for a,i in reversed(data):
    dic[i]=0
dp=[copy.copy(dic) for i in range(N+1)]

def main(dic1,dic2):
    dic1=sorted([[str(i),dic1[i]] for i in dic],key=lambda x:x[0],reverse=True)
    dic2=sorted([[str(i),dic2[i]] for i in dic],key=lambda x:x[0],reverse=True)
    for a,b in zip(dic1,dic2):
        if a[1]>b[1]:
            return(0)
        if a[1]<b[1]:
            return(1)
    return(0)

def _sum(dic):
    count=0
    for i in dic:
        count+=dic[i]
    return(count)


for a,n in data:
    tempdic=copy.copy(dic)
    tempdic[n]+=1
    if len(dp)-1>=a:
        flag=main(dp[a],tempdic)
        if flag:
            dp[a]=tempdic
    for i in range(len(dp)):
        if i>=a and _sum(dp[i-a]):
            if _sum(dp[i])<_sum(dp[i-a])+1:

                tempdic=copy.copy(dp[i-a])
                tempdic[n]+=1
                dp[i]=tempdic
            elif _sum(dp[i])==_sum(dp[i-a])+1:
                dp[i-a][n]+=1
                flag=main(dp[i],dp[i-a])
                dp[i-a][n]-=1
                if flag:
                    tempdic=copy.copy(dp[i-a])
                    tempdic[n]+=1
                    dp[i]=tempdic
dic=dp[N]
a=""
dic=sorted([[str(i),dic[i]] for i in dic],key=lambda x:x[0],reverse=True)
for i,z in dic:
    for m in range(z):
        a+=i
print(a)
import math
a,b,x = map(int, input().split())
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))

### FIXED CODE ###

import math
a,b,x = map(int, input().split())
if a * a * b == x:
  print(0)
  exit()
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))
import sys

d = {'A': 1, 'B': 0, 'C': 0}

for line in sys.stdin:
    a, t = line.split(',')
    d[a], d[t] = d[t], d[a]

for k, v in d.items():
    if v:
        print(k)

### FIXED CODE ###

d = {'A': True, 'B': False, 'C': False}

while True:
    try:
        a, t = input().split(',')
        d[a], d[t] = d[t], d[a]
    except:
        for k, v in d.items():
            if v:
                print(k)
        break
H,W,K = map(int,input().split())
import numpy as np
from collections import deque
ans = 10000
S = np.array([list(map(int,list(input()))) for _ in range(H)])
cum = [[0]*W for _ in range(H+1)]
for j in range(W):
  for i in range(1,H+1):
    cum[i][j] = cum[i-1][j]+S[i-1][j]
    
cum = np.array(cum)
for i in range(2**(H-1)):
  q = deque([0])
  for h in range(H):
    if (i>>h)&1:
      q.append(h+1)
  q.append(H)
  q = list(q)
  p = deque()
  judge = False
  for a in range(len(q)-1):
    x = list(cum[q[a+1]]-cum[q[a]])
    if (x>K).any():
      judge = True
      break
    else:
      p.append(x)

  if judge:
    continue
  p = list(p)
  t_a = len(q)-2
  n = len(p)
  l = [0]*n
  for w in range(W):
    for x,a in enumerate(p):
      y = l[x]+a[w]
      if y>K:
        t_a+=1
        l = [0]*n
        for z,b in enumerate(p):
          l[z] = b[w]
        break
      else:
        l[x]=y
  ans = min(ans,t_a)
    
print(ans)

### FIXED CODE ###

def main():
  H,W,K = map(int,input().split())
  import numpy as np
  from collections import deque
  ans = 10000
  S = np.array([list(map(int,list(input()))) for _ in range(H)])
  cum = [[0]*W for _ in range(H+1)]
  for j in range(W):
    for i in range(1,H+1):
      cum[i][j] = cum[i-1][j]+S[i-1][j]

  cum = np.array(cum)
  for i in range(2**(H-1)):
    j = 0
    q = deque([0])
    for h in range(H):
      if (i>>h)&1:
        q.append(h+1)
    q.append(H)
    t_a = len(q)-2
    if t_a>=ans:
      continue
    p = deque()
    judge = False
    for a in range(len(q)-1):
      x = cum[q[a+1]]-cum[q[a]]
      if (x>K).any():
        judge = True
        break
      else:
        p.append(list(x))

    if judge:
      continue
    n = len(p)
    l = [0]*n
    for w in range(W):
      y = [l[j]+p[j][w] for j in range(n)]
      if max(y)>K:
        t_a+=1
        l = [p[j][w] for j in range(n)]
        if t_a>=ans:
          judge = True
          break
      else:
        l = y
    if judge:
      continue
    ans = min(ans,t_a)

  print(ans)
  
main()
n, m = map(int, input().split())
s_li_ = []
c_li_ = []

for _ in range(m):
  s, c = map(int, input().split())
  s_li_.append(s)
  c_li_.append(c)

def func(n, m, s_li, c_li):
  if m==0:
    if (n==1) & (s_li[0]==1) & (c_li[0]==0):
      return 0
    else:
      return 10**(n-1)
  
  if n==1:
    if (s_li[0]==1) & (c_li[0]==0):
      return 0
  
  for i in range(10**(n-1), 10**n):
    cnt = 0
    for s, c in zip(s_li, c_li):
      if str(i)[s-1] == str(c):
        cnt+=1
    if cnt==m:
      return i
    
  return -1

print(func(n, m, s_li_, c_li_))


### FIXED CODE ###

n, m = map(int, input().split())
s_li_ = []
c_li_ = []

for _ in range(m):
  s, c = map(int, input().split())
  s_li_.append(s)
  c_li_.append(c)

def func(n, m, s_li, c_li):
  if m==0:
    if n==1:
      return 0
    else:
      return 10**(n-1)
  
  if n==1:
    if (s_li[0]==1) & (c_li[0]==0):
      return 0
  
  for i in range(10**(n-1), 10**n):
    cnt = 0
    for s, c in zip(s_li, c_li):
      if str(i)[s-1] == str(c):
        cnt+=1
    if cnt==m:
      return i
    
  return -1

print(func(n, m, s_li_, c_li_))
N=int(input())
A=list(map(str,input().split()))
if P in A and W in A and Y in A and G in A:
  print("Four")
else:
  print("Three")

### FIXED CODE ###

input()
A=map(str,input().split())
if len(set(A))==4:
  print("Four")
else:
  print("Three")
from operator import mul
from functools import reduce
n,k=map(int,input().split())

def comb(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

blue,red=k,n-k
if red==0:
  print(0)
else:
  mod=10**9+7
  for i in range(1,k+1):
    print((comb(red+1,i)*comb(blue-1,i-1))%mod)

### FIXED CODE ###

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

mod=10**9+7
ans=n-k+1
print(ans)
for i in range(2,k+1):
  ans=(ans*(n-k-i+2)*(k-i+1)*pow(i*(i-1),mod-2,mod))%mod
  print(ans)
# coding: utf-8

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

p.sort()

sep = []
for i in range(0,n):
    if(p[i] > a):
        sep.append(i)
        break
for i in range(sep[0],n):
    if(p[i] > b):
        sep.append(i)
        break

q1 = len(p[0:sep[0]])
q2 = len(p[sep[0]:sep[1]])
q3 = len(p[sep[1]:n])


#print("{}, {}, {}".format(q1,q2,q3))
print(min(q1,q2,q3))

### FIXED CODE ###

# coding: utf-8

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

p.sort()

cnt = [0,0,0]

for i in range(0,n):
    if(p[i] <= a):
        cnt[0]+=1
    elif(a < p[i] <= b):
        cnt[1]+=1
    else:
        cnt[2]+=1

#print(cnt)
print(min(cnt))
H, W = map(int, input().split())
maze = [input() for _ in range(H)]
p_flg = [[0]*W for _ in range(H)]
dyx = [(-1,0),(1,0),(0,-1),(0,1)]

def bfn(y,x,cnt):
    stack = [(y,x,cnt)]
    p_flg[y][x] = cnt
    while stack:
        sy, sx, cnt= stack.pop(0)
        cnt += 1
        for dy, dx in dyx:
            ny, nx = sy+dy, sx+dx
            if ny == H-1 and nx == W-1:
                return cnt
            if 0<=ny<H and 0<=nx<W:
                if maze[ny][nx] !="#" and not p_flg[ny][nx]:
                    p_flg[ny][nx] = cnt
                    stack.append((ny,nx,cnt))

def main():
    n_obs = 0
    for h in range(H):
        for w in range(W):
            if maze[h][w] == "#":
                n_obs += 1
    n_path = bfn(0,0,1) -1
    ans = H*W - n_obs - n_path -1
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

H, W = map(int, input().split())
maze = [input() for _ in range(H)]
p_flg = [[0]*W for _ in range(H)]
dyx = [(-1,0),(1,0),(0,-1),(0,1)]

def bfn(y,x,cnt):
    stack = [(y,x,cnt)]
    p_flg[y][x] = cnt
    while stack:
        sy, sx, cnt= stack.pop(0)
        cnt += 1
        for dy, dx in dyx:
            ny, nx = sy+dy, sx+dx
            if ny == H-1 and nx == W-1:
                return cnt
            elif 0<=ny<H and 0<=nx<W:
                if maze[ny][nx] !="#" and not p_flg[ny][nx]:
                    p_flg[ny][nx] = cnt
                    stack.append((ny,nx,cnt))
    return 0

def main():
    n_obs = 0
    for h in range(H):
        for w in range(W):
            if maze[h][w] == "#":
                n_obs += 1
    n_path = bfn(0,0,1) -1
    if n_path == -1:
        print(-1)
        return
    else:
        ans = H*W - n_obs - n_path -1
        print(ans)

if __name__ == "__main__":
    main()
N = int(input())
abcList = [list(map(int, input().split())) for i in range(N)]
dp = [abcList[0]]

if len(abcList) == 1:
    print(max(abcList[0][0], abcList[0][1], abcList[0][2]))
    return

# dp=1
dp.append(abc(abcList[1], dp[0]))

for i in range(2, N):
    dp.append(abc(abcList[i], dp[i-1]))
print(max(dp[-1]))


### FIXED CODE ###

N = int(input())
abcList = [list(map(int, input().split())) for i in range(N)]
dp = [abcList[0]]

if len(abcList) == 1:
    print(max(abcList[0][0], abcList[0][1], abcList[0][2]))
else:
    for i in range(1, N):
        dp.append([abcList[i][0] + max(dp[i - 1][1], dp[i - 1][2]),
                   abcList[i][1] + max(dp[i - 1][0], dp[i - 1][2]),
                   abcList[i][2] + max(dp[i - 1][0], dp[i - 1][1])])
    print(max(dp[-1]))
X=int(input())
l=[]
for i in range(300):
    a=i**5
    l.append(a)
    l.append(-a)
for j in l:
    for s in l:
        if j-s==X and j!=s:
            ans=[]
            for i in [j,s]:
                aaa=abs(i)**(1/5)
                if i>=0:
                    ans.append(int(aaa)
                else:
                    ans.append(-aaa)
            print(*ans)
        

### FIXED CODE ###

X=int(input())
l=[]
for i in range(300):
    a=i**5
    l.append(a)
    l.append(-a)
for j in l:
    for s in l:
        if j-s==X and j!=s:
            ans=[]
            for i in [j,s]:
                aaa=abs(i)**(1/5)
                if i>=0:
                    ans.append(int(aaa))
                else:
                    ans.append(int(-aaa))
            print(*ans)
            exit()
S = list(input())
def rec(list1,t):
    for i in range(len(list1)-1):
        if list1[i] == "B" and list1[i+1] == "W":
            list1[i] = "W"
            list1[i+1] = "B"
            return rec(list1,t+1)
    return t
result = rec(S,0)
print(result)

### FIXED CODE ###

S = list(input())
count_B = 0
ans = 0
for i in range(len(S)):
    if S[i] == "B":
        count_B += 1
    elif S[i] == "W":
        ans += count_B
print(ans)
import re
s = input()
match = re.findall(r"[ACGT]+",s)
print(max([len(i) for i in match]))


### FIXED CODE ###

import re
s = input()
match = re.findall(r"[ACGT]+",s)
if len(match)==0:
    print(0)
else:
    print(max([len(i) for i in match]))
X = int(input())
if X => 30:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

X = int(input())
if X >= 30:
    print("Yes")
else:
    print("No")
n = int(input())
A = list(map(int, input().split()))

dp = [[0 for i in range((n//2)+1)] for j in range(n)]

M = - float('inf')
for i in range(4):
    M = max(M, A[i])
    dp[i][0] = M
dp[2][1] = dp[0][0] + A[2]
dp[3][1] = max(dp[1][0] + A[3], dp[2][1])


# for i in range(len(dp)):
#     print(dp[i])

for i in range(4, n):
    for j in range(max(0, i // 2 - 1), (i + 2) // 2):
        # print(i, j)
        if i % 2 == 0 and j == (i + 2) // 2 - 1 :
            dp[i][j] = dp[i-2][j-1] + A[i]
        else:
            dp[i][j] = max(dp[i-2][j-1] + A[i], dp[i-1][j])

# for i in range(len(dp)):
#     print(dp[i])

print(dp[n-1][-2])

### FIXED CODE ###

import sys

n = int(input())
A = [int(_) for _ in input().split()]

# dp = [[0 for i in range((n//2)+1)] for j in range(n)]

if n == 1 or n == 2 or n == 3:
    print(max(A))
    sys.exit()

dp = [[0, 0] for j in range(n)]
M = - float('inf')
for i in range(4):
    M = max(M, A[i])
    dp[i][0] = M
dp[2][1] = dp[0][0] + A[2]
dp[3][1] = max(dp[1][0] + A[3], dp[2][1])


# for i in range(len(dp)):
#     print(dp[i])

# for i in range(4, n):
#     for j in range(max(0, i // 2 - 1), (i + 2) // 2):
#         # print(i, j)
#         if i % 2 == 0 and j == (i + 2) // 2 - 1 :
#             dp[i][j] = dp[i-2][j-1] + A[i]
#         else:
            # dp[i][j] = max(dp[i-2][j-1] + A[i], dp[i-1][j])

for i in range(4, n):
    for j in range(2):
        # print(i, j)
        if i % 2 == 0 and j == 1:
            dp[i][j] = dp[i-2][1] + A[i]
        elif i % 2 == 0 and j == 0:
            dp[i][j] = max(dp[i-2][0] + A[i], dp[i-1][1])
        elif i % 2 == 1 and j == 1:
            dp[i][j] = max(dp[i-2][1] + A[i], dp[i-1][1])
        else:
            dp[i][j] = max(dp[i-2][0] + A[i], dp[i-1][0])

# for i in range(len(dp)):
#     print(dp[i])

print(dp[n-1][(n+1)%2])
a, b, c = (int(i) for i in input().split())

if a = b and a = c :
    print('Yes')
else:
    print('No')



### FIXED CODE ###

a, b, c = (int(i) for i in input().split())

if a == b and a == c:
    print('Yes')
else:
    print('No')
x = input()
print(x ** 3)


### FIXED CODE ###


x = int(input())
print(x*x*x)
#abc125b

n=int(raw_input())
v=map(int,raw_input().split())
c=map(int,raw_input().split())
res=0
for i in xrange(n):
 if v[i]-c[i]>0:
  res+=v[i]-c[i]
print res


### FIXED CODE ###

#abc125a

a,b,t=map(int,raw_input().split())
res=t/a*b
print res
N = int(input())
A = map(int, input.split())
alice, bob = 0, 0

for i in range(N):
    m = max(A)
    A.remove(m)
    if i % 2 == 0:
        alice += m
    else:
        bob += m
print(alice - bob)



### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
alice, bob = 0, 0

for i in range(N):
    m = max(A)
    A.remove(m)
    if i % 2 == 0:
        alice += m
    else:
        bob += m
print(alice - bob)
from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
shrine = [int(input()) for _ in range(a)]
temple = [int(input()) for _ in range(b)]

inf = 10**18
for _ in range(q):
    ans = inf
    x = int(input())
    index_s = bisect_left(shrine, x)
    index_t = bisect_right(temple, x)
    for i in range(index_s-1, index_s+1):
        if i == a:
            continue
        s = shrine[i]
        i_t = bisect_left(temple, s)

        if i_t == 0:
            t0 = inf
        else:
            t0 = temple[i_t - 1]
        if i_t <= b:
            t1 = temple[i_t]
        else:
            t1 = inf

        ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        )
    for i in range(index_t-1, index_t+1):
        if i == b or i < 0:
            continue
        t = temple[i]
        i_s = bisect_left(shrine, t)
        if i_s == 0:
            s0 = inf
        else:
            s0 = shrine[i_s - 1]

        if i_s <= a-1:
            s1 = shrine[i_s]
        else:
            s1 = inf
        ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        )

    print(ans)





### FIXED CODE ###

from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
inf = 10**18
shrine = [-inf] + [int(input()) for _ in range(a)] + [inf]
temple = [-inf] + [int(input()) for _ in range(b)] + [inf]

for _ in range(q):
    ans = inf
    x = int(input())
    index_s = bisect_left(shrine, x)
    index_t = bisect_right(temple, x)
    for i in range(index_s-1, index_s+1):
        s = shrine[i]
        i_t = index_t
        t0, t1 = temple[i_t-1], temple[i_t]
        ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        )

    for i in range(index_t-1, index_t+1):
        t = temple[i]
        i_s = index_s
        s0 = shrine[i_s - 1]
        s1 = shrine[i_s]
        ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        )

    print(ans)
n,m=[int(i) for i in input().split()]
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if check[p]==0:
            check[p]=1
    else:
        if check[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(check),wa)

### FIXED CODE ###

n,m=[int(i) for i in input().split()]
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if ac[p]==0:
            ac[p]=1
    else:
        if ac[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(ac),sum(wa))
inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
if inp[0]/inp[2]<inp[1]:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

inp = list(map(int, input().split()))
if inp[0]/inp[2]<=inp[1]:
  print('Yes')
else:
  print('No')
import numpy as np
N,M,C = map(int,input().split())
B = [int(k) for k in input().split()]
A = [[int(j) for j in input().split()] for i in range(1,N)] 
b = np.array(B)
a = np.array(A)
cnt = 0
for i in range(1,N):
    if (np.dot(a[i],b) + C >0):
        cnt += 1
    else:
        cnt = cnt
        
print(cnt)




### FIXED CODE ###

import numpy as np
N,M,C = map(int,input().split())
B = [int(k) for k in input().split()]
A = [[int(j) for j in input().split()] for i in range(N)] 
b = np.array(B)
cnt = 0
for i in range(N):
    if (np.dot(np.array(A[i]),b) + C >0):
        cnt += 1
    else:
        cnt = cnt
        
print(cnt)
#たてなが
def ABC_49_B():
    H,W = map(int, input().split())
    C = [0 for _ in range(W)]

    for i in range(H):
        C[i] = input()

    for i in range(H):
        print(C[i])
        print(C[i])


if __name__ == '__main__':

    ABC_49_B()

### FIXED CODE ###

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

for i in range(H):
	C[i] = input()

for i in range(H):
	print(C[i])
	print(C[i])
N = [int(i) for i in input().split()][0]

ls = []
for i in range(N):
  a,b = [i for i in input().split()]
  tmp = [str(a),int(b)]
  ls.append(tmp)

new_ls = sorted(ls, key=lambda x:x[1], reverse=True)
new_ls = sorted(new_ls, key=lambda x:x[0])

for next,l in enumerate(new_ls):
  for i,tmp in enumerate(ls):
    if l[0]==tmp[0] and l[1]==tmp[1]:
      print(i+1)
      continue

### FIXED CODE ###

A,P = [int(i) for i in input().split()]

print((A*3+P)//2)
a,b,c,x=map(int, [input()　for i in range(4)])

count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if k*50+j*100+i*500==x:
                count+=1
                
print(count)

### FIXED CODE ###

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

count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if k*50+j*100+i*500==x:
                count+=1
                
print(count)
# 21
import sympy
x = int(input())

#エラトステネスの篩
n = [i for i in range(2,int(sympy.sqrt(x))+1)]

for i in n:
    for j in n:
        if j % i == 0 and j/i !=1:
            n.remove(j)
            
while x > 0:
    x +=1
    for i in n:
        if x % i == 0:
            break
    else:
        print(x)
        break


### FIXED CODE ###

# 21   import sympyが最速だが、Atcoderには無い
import math
x = int(input())

#エラトステネスの篩
n = [i for i in range(2,int(math.sqrt(x))+1)]

for i in n:
    for j in n:
        if j % i == 0 and j/i !=1:
            n.remove(j)
            
while x > 0:
    for i in n:
        if x % i == 0:
            break
    else:
        print(x)
        break
    x+=1
numbers = input()
numbers = string(numbers)
count = 0
if numbers[0]=='1':
  count += 1
if numbers[1]=='1':
  count += 1
if numbers[2]=='1':
  count += 1
print(count)

### FIXED CODE ###

number = int(input())
count = 0
if number >= 50:
  count += 1
if number%100 >= 5:
  count += 1
if number%10 >= 0.5:
  count += 1
print(count)
N = int(input())
A = input()
B = input()
 
r = ""
for i in range(N):
  r+= A[i]
  r+= B[i]
print(r)

### FIXED CODE ###

N = int(input())
A, B = input().split()
 
r = ""
for i in range(N):
  r+= A[i]
  r+= B[i]
print(r)
import sys
K=10**10
N,L=map(int,input().split())
T=list(map(int,input().split()))
for i in range(N-1):
  if T[i]+T[i+1]>=L:
    K=i
    print("Possible")
    break
if K==10**10:
  print("Impossible")
K=K+1
R=list(range(1,K))
R.extend(list(range(K+1,N)))
R.append(K)
R=list(map(str,R))
for i in range(N-1):
  print(R[i])

### FIXED CODE ###

K=10**10
import sys
N,L=map(int,input().split())
T=list(map(int,input().split()))
for i in range(N-1):
  if T[i]+T[i+1]>=L:
    K=i
    print("Possible")
    break
if K==10**10:
  print("Impossible")
  sys.exit()
K=K+1
R=list(range(1,K))
M=list(range(K+1,N))
M.reverse()
R.extend(M)
R.append(K)
for i in range(N-1):
  print(R[i])
n=int(input())
l=list(map(int,input().split()))
if(0 in l)::
    print(0)
    exit()
p=1
for i in l:
    p*=i
    if(p>1000000000000000000):
        print(-1)
        exit()
print(p)


### FIXED CODE ###

x,y=map(int,input().split())
print(x*y)