Harryxun/stf_run huggingface dataset:
import numpy as np
h, w = map(int, input().split())
s = np.array([list(input()) for _ in range(h)])
w1, w2 = np.array(["."]*w), np.array(["."]*(h+2))
s = np.hstack((w1.reshape(len(w1),1), s))
s = np.hstack((s, w1.reshape(len(w1),1)))
s = np.vstack((w2, s))
s = np.vstack((s, w2))
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]
for i in range(1, h+1, 1):
    for j in range(1, w+1, 1):
        now = s[i][j]
        c = 0
        if now == ".":
            continue
        for d in range(4):
            x = j + dx[d]
            y = i + dy[d]
            if now == s[y][x]:
                c += 1
        if c == 0:
            print("No")
            exit()
print("Yes")

### FIXED CODE ###

import numpy as np
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
s = np.array(s)
out = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        if i == 0 and j == 0:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif i == 0 and j == w-1:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j]
        elif i == h-1 and j == 0:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif i == h-1 and j == w-1:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j - 1]
            right = s[i][j]
        elif i == 0 and j != 0 and j != w-1:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j + 1]
        elif i == h-1 and j != 0 and j != w-1:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j - 1]
            right = s[i][j + 1]
        elif j == 0 and i !=  0 and i != h-1:
            up = s[i - 1][j]
            down = s[i + 1][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif j == w-1 and i != 0 and i!= h-1:
            up = s[i - 1][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j]
        else:
            up = s[i-1][j]
            down = s[i+1][j]
            left = s[i][j-1]
            right = s[i][j+1]
        if s[i][j] != up and s[i][j] != down and s[i][j] != left and s[i][j] != right:
            out = "No"
print(out)
from collections import defaultdict
def main():
    def f(n):
        if n == 0:
            return 0
        if d[n] != 0:
            return d[n]
        d[n] = f(n % sum(list(map(int, bin(n)[2:])))) + 1


    n = int(input())
    X = list(input())
    rev = lambda x: '1' if x == '0' else '0'
    d = defaultdict(int)
    d[0] = 0
    for i in range(1, n):
        f(i)
    X[0] = rev(X[0])
    print(d[int(''.join(X), 2) % sum(list(map(int, X)))] + 1)
    for i in range(n - 1):
        X[i] = rev(X[i])
        X[i + 1] = rev(X[i + 1])
        print(d[int(''.join(X), 2) % sum(list(map(int, X)))] + 1)




if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    def f(n):
        if n == 0: return 0
        return f(n % bin(n).count('1')) + 1
    n = int(input())
    X = list(input())
    c = sum(list(map(int, X)))
    m = int(''.join(X), 2)
    mp, mm = m % (c + 1), m % (c - 1) if c - 1 != 0 else 0
    jp, jm = 1, 1
    ans = [0] * n
    for i in range(n - 1, -1, -1):
        if X[i] == '0':
            mod = c + 1
            ans[i] = f((mp + jp) % mod) + 1
        else:
            ans[i] = f((mm - jm + mod) % mod) + 1 if (mod := c - 1) != 0 else 0
        jp, jm = (jp << 1) % (c + 1), (jm << 1) % (c - 1) if c - 1 != 0 else 0
    [print(a) for a in ans]
if __name__ == '__main__':
    main()
di = {'Sunny':'Cloudy', 'Cloudy':'Rainy', 'Sunny'}
x = input()
print(di[x])



### FIXED CODE ###

di = {'Sunny':'Cloudy', 'Cloudy':'Rainy', 'Rainy':'Sunny'}
x = input()
print(di[x])
import math
n = int(input())
lis = [int(input()) for i in range(n)]
print(5 + math.ceil(n/min(lis))-1)

### FIXED CODE ###

n = int(input())
lis = [int(input()) for i in range(5)]
key = 0
if n % min(lis) == 0:key = 1
print(5 + n//min(lis)-key)
a,b,c,d=map(int,input().split())
print("balanced" if a+b=c+d else "left" if a+b>c+d else "right")

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print("Balanced" if a+b==c+d else "Left" if a+b>c+d else "Right")
n=int(input())
for i in range(math.inf):
  if n%2==0:
    print(n)
    break
  else:
    n=n/2

### FIXED CODE ###

n=int(input())
for i in range(99):
  if 2**i <= n:
    continue
  else:
    print(2**(i-1))
    break
input()
lst = list(map(int,input().split()))
for i in range(len(lst)):
    j = min(0, i-1)
    while (j >= 0) * (lst[j] > lst[i]):
        j -= 1
    lst[j+1:i+1] = lst[i] , *lst[j+1:i]
    print(*lst)

### FIXED CODE ###

n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
    li = lst[i]
    j = i-1
    while j >= 0 and lst[j] > li:
        lst[j:j+2] = lst[j+1], lst[j]
        j -= 1
    print(*lst)
N = int(input())

sum_list = []

def findSumOfDigit(n):
    s = 0
    while(n > 0):
        s += n % 10
        n = int(n / 10)
    return s

for a in range(2, N):
    b = N - a
    sum_list.append(findSumOfDigit(a) + findSumOfDigit(b))

print(min(sum_list))


### FIXED CODE ###

N = int(input())

sum_list = []

def findSumOfDigit(n):
    s = 0
    while(n > 0):
        s += n % 10
        n = int(n / 10)
    return s

for a in range(1, N):
    b = N - a
    sum_list.append(findSumOfDigit(a) + findSumOfDigit(b))

print(min(sum_list))
import math

def count(n, A, B):
    n_upper = int(B/n)
    n_lower = int(A/n + 1)
    n_count = n_upper - n_lower + 1
    return n_count

def main():
    A, B, C ,D  = list(map(int, input().split(" ")))
    C_count = count(C, A, B)
    D_count = count(D, A, B)
    s = (C / math.gcd(C, D)) * D
    CD_count = count(s, A ,B)
    fcount = (B - A + 1) - (C_count + D_count - CD_count)
    print(fcount)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
from fractions import gcd

def count(n, A, B):
    n_upper = B // n
    n_lower = (A-1) // n
    n_count = n_upper - n_lower
    return n_count

def main():
    A, B, C ,D  = list(map(int, input().split(" ")))
    C_count = count(C, A, B)
    D_count = count(D, A, B)
    s = (C * D) // gcd(C, D)
    CD_count = count(s, A ,B)
    fcount = (B - A + 1) - (C_count + D_count - CD_count)
    print(fcount)

if __name__ == '__main__':
    main()
a,b = map(int,input().split())
if a<9 || b<9:
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

a,b = map(int,input().split())
if a<9 and b<9:
  print("Yay!")
else:
  print(":(")
import random
a = int(input('<< '))
k=0
for i in range(1,a):
  if i%2 == 1:
    k += 1
  v = k/a

print v
   
    


### FIXED CODE ###

a = int(input())
if a%2 == 0:
  print(1/2)
else:
  print((a//2+1)/a)
S = input()
Q = int(input())


def formation():
    global S, Q

    ls = list(S)
    do_rev = False
    for _ in range(Q):
        t_str = input()

        if t_str[0] == '1':
            do_rev = not do_rev
        else:
            splited = t_str.split(' ')
            f = splited[1]
            c = splited[2]
            if f == '1':
                if do_rev:
                    ls.append(c)
                else:
                    ls.insert(0, c)
            else:
                if do_rev:
                    ls.insert(0, c)
                else:
                    ls.append(c)
        print(ls)

    if do_rev:
        ls.reverse()

    return ''.join(ls)


print(formation())


### FIXED CODE ###

S = input()
Q = int(input())


class Node:
    def __init__(self, value=None, prev=None, next=None):
        self.value = value
        self.prev = prev
        self.next = next

    def __str__(self):
        return str(self.value)


class LinkedList:
    def __init__(self, initial_string=None):
        self.first = Node()
        self.last = Node()
        self.first.next = self.last
        self.last.prev = self.first
        self.should_reverse = False
        for s in initial_string:
            self.insert_last(s)

    def _insert_first(self, value=None):
        prev_next = self.first.next
        self.first.next = Node(value, self.first, prev_next)
        prev_next.prev = self.first.next

    def _insert_last(self, value=None):
        prev_prev = self.last.prev
        self.last.prev = Node(value, prev_prev, self.last)
        prev_prev.next = self.last.prev

    def insert_first(self, value=None):
        if self.should_reverse:
            self._insert_last(value)
        else:
            self._insert_first(value)

    def insert_last(self, value=None):
        if self.should_reverse:
            self._insert_first(value)
        else:
            self._insert_last(value)

    def set_reverse(self):
        self.should_reverse = not self.should_reverse

    def _print(self):
        node = self.first.next
        while node is not None:
            if node.value is not None:
                print(node, end="")
            node = node.next
        print("")

    def _print_reverse(self):
        node = self.last.prev
        while node is not None:
            if node.value is not None:
                print(node, end="")
            node = node.prev
        print("")

    def print_list(self):
        if self.should_reverse:
            self._print_reverse()
        else:
            self._print()


def formation():
    global S, Q

    linked_list = LinkedList(S)

    for _ in range(Q):
        t_str = input()

        if t_str[0] == '1':
            linked_list.set_reverse()
        else:
            split = t_str.split(' ')
            f = split[1]
            c = split[2]
            if f == '1':
                linked_list.insert_first(c)
            else:
                linked_list.insert_last(c)

    linked_list.print_list()


formation()
N, K = list(map(int, input().split()))
S = str(input())
m = chr(ord(S[K-1]) - 32)
print(N[:m] + m + N[m+1:])




### FIXED CODE ###

N, K = list(map(int, input().split()))
S = str(input())
m = chr(ord(S[K-1]) + 32)
print(S[:K-1] + m + S[K:])
h,w = map(int,input().split())

def isvalid(r,c):
    return 0 <= r < h and 0 <= c < w

g = [input() for _ in range(h)]
d = [1,0,-1,0]
queue = [(0,0)]
dist = [[1000000]* h for _ in range(w)]
dist[0][0] = 0
if g[0][0] == '#':
    dist[0][0] = 1
while len(queue) > 0:
    next_queue = []
    for r,c in queue:
        for i in range(4):
            cos = dist[r][c]
            nr = r + d[i]
            nc = c + d[1^i]
            if not isvalid(nr,nc):
                continue
            if  g[r][c] != g[nr][nc]:
                cos += 1
            if cos < dist[nr][nc]:
                dist[nr][nc] = cos
                next_queue.append((nr,nc))
    queue = next_queue
print((dist[h-1][w-1] + 1)//2)

### FIXED CODE ###


h,w = map(int,input().split())

def isvalid(r,c):
    return 0 <= r < h and 0 <= c < w

g = [input() for _ in range(h)]
d = [1,0]
queue = [(0,0)]
dist = [[1000000]* w for _ in range(h)]
dist[0][0] = 0
if g[0][0] == '#':
    dist[0][0] = 1
while len(queue) > 0:
    next_queue = []
    for r,c in queue:
        for i in range(2):
            cos = dist[r][c]
            nr = r + d[i]
            nc = c + d[1^i]
            if not isvalid(nr,nc):
                continue
            if  g[r][c] != g[nr][nc]:
                cos += 1
            if cos < dist[nr][nc]:
                dist[nr][nc] = cos
                next_queue.append((nr,nc))
    queue = next_queue
print((dist[h-1][w-1] + 1)//2)
N, X = map(int, input().split())
L = list(map(int, input().split()))

D = 0
count = 0
for i in range(N+1):
  D = D + L[i]
  count += 1
  if D > X :
    print(count)
    break
  

### FIXED CODE ###

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

D = 0
count = 0
for i in range(N):
  D = D + L[i]
  count += 1
  if D > X :
    print(count)
    exit()
print(count+1)
N,A=int(input().split())
if A >= (N%500):
  print('Yes')
else:
  print('no')


### FIXED CODE ###

N=int(input())
A=int(input())
if A >= (N%500):
  print('Yes')
else:
  print('No')
input_num = input()
split = input_num.split(' ')
h = int(split[0])
w = int(split[1])
odd_row = w // 2 +1
even_row = odd_row - 1
total = 0
for i in range(h, start=1):
    if i%2 = 0:
        total += even_row
    else:
        total += odd_row
print(total)


### FIXED CODE ###

h, w = (int(x) for x in input().split())
if h == 1 or w == 1:
    odd_row = 0
    even_row = 0
    total = 1
elif w%2 == 0:
    odd_row = w // 2
    even_row = odd_row
    total = (h//2)*even_row + (h-h//2)*odd_row
else:
    odd_row = w // 2 + 1
    even_row = odd_row - 1
    total = (h//2)*even_row + (h-h//2)*odd_row
print(total)
from collections import Counter

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

L=[]
for i in range(N):
    A=list(map(int,input().split()))
    L.append(A)
    
OUTD=dict()
S=[0 for i in range(M)]

ANS=1000
for i in range(M):
    B=[0 for _ in range(N)]
    for j in range(N):
        for k in range(S[j],M):
            if L[j][k] in OUTD:
                S[j]+=1
            else:
                B[j]=L[j][k]
                break
    X=Counter(B).most_common()[0]
    if X[1]<ANS:
        ANS=X[1]
    OUTD[X[0]]=1
    #print(ANS,B,OUTD)
print(ANS)

### FIXED CODE ###

from collections import Counter

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

L=[]
for i in range(N):
    A=list(map(int,input().split()))
    L.append(A)
    
OUTD=dict()
S=[0 for i in range(N)]

ANS=1000
for i in range(M):
    B=[0 for _ in range(N)]
    for j in range(N):
        for k in range(S[j],M):
            if L[j][k] in OUTD:
                S[j]+=1
            else:
                B[j]=L[j][k]
                break
    X=Counter(B).most_common()[0]
    if X[1]<ANS:
        ANS=X[1]
    OUTD[X[0]]=1
    #print(ANS,B,OUTD)
print(ANS)
import copy
import sys
H, W, M= map(int,input().split())
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max
c = 0
p = len(cand_h)*len(cand_w)
if M >= p
for i in range(len(object)):
   if object[i][0] in cand_h and object[i][1] in cand_w:
      c += 1
print(ans - (c == p))

### FIXED CODE ###

import copy
import sys
H, W, M= map(int,input().split())
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max
c = 0
p = len(cand_h)*len(cand_w)
cand_h = set(cand_h)
cand_w = set(cand_w)
if M >= p:
   for i in range(len(object)):
      if object[i][0] in cand_h and object[i][1] in cand_w:
         c += 1
print(ans - (c == p))
def run(infile,outfile):
	for line in infile.readline():
		x, y = map(int,line.sprit())
		print >> outfile, x + y

if __name__ == "__main__":
	import sys
	run(sys.stdin, sys.stdout)

### FIXED CODE ###

def run(infile,outfile):
	for line in infile.readlines():
		print >> outfile,sum(map(int,line.rstrip().split()))

if __name__ == "__main__":
	import sys
	run(sys.stdin, sys.stdout)
from collections import*
import sys
input = sys.stdin.readline


class UnionFind(object):
    def __init__(self, n):
        # 親の番号を格納する。親だった場合は-(その集合のサイズ)
        # 作るときはParentsの値を全て-1にする
        # こうすると全てバラバラになる
        self.parents = [-1 for i in range(n)]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return


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

ro_cl = UnionFind(n)
ra_cl = UnionFind(n)
d = defaultdict(int)

# =================================================================

w = [list(map(int, input().split())) for i in range(k+l)]
ro = w[:k]
ra = w[l:]
for p, q in ro:
    ro_cl.union(p-1, q-1)
for p, q in ra:
    ra_cl.union(p-1, q-1)

# =================================================================

# for i in range(k):
#     p, q = map(int, input().split())
#     ro_cl.union(p-1, q-1)
# for i in range(l):
#     p, q = map(int, input().split())
#     ra_cl.union(p-1, q-1)

# =================================================================

for i in range(n):
    d[(ro_cl.find(i), ra_cl.find(i))] += 1
print(*[d[(ro_cl.find(i), ra_cl.find(i))]for i in range(n)])


### FIXED CODE ###

c = input()
p = "aeiou"
if c in p:
    print("vowel")
else:
    print("consonant")
def resolve():
    import math
    n = int(input())
    a = list(map(int, input().split()))
    a = list(set(a))
    a = sorted(a)
    for i in range(1, len(a)):
        ggcd = math.gcd(ggcd, a[i])
        if ggcd == 1:
            break
    if ggcd != 1:
        print("not coprime")
    else:
      print("test")
resolve()

### FIXED CODE ###

def resolve():
    import math
    n = int(input())
    a = list(set(map(int, input().split())))
    maxa = max(a)

    ggcd = a[0]
    for i in range(1, len(a)):
        ggcd = math.gcd(ggcd, a[i])
        if ggcd == 1:
            break

    pair = False

    c = [0] * (10**6+ 1)
    for i in a:
        c[i] += 1

    for i in range(2, maxa+1):
        cnt = 0
        for j in range(i, maxa+1, i):

            cnt += c[j]
        if cnt > 1:
            pair = True

    if ggcd != 1:
        print("not coprime")
    else:
        if pair:
            print("setwise coprime")
        else:
            print("pairwise coprime")
resolve()
a, b = map(int, input().split)
if (a*b) % 2:
    print("Odd")
else:
    print("Even")

### FIXED CODE ###

a, b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')
n=input()
import math
a = []
for i in range(0,math.ceil(len(n)/2),2):
  a.append(str(a[i]))
print(*a)

### FIXED CODE ###

n=input()
a = []
a.append(str(n[:len(n):2]))
print(*a)
input = int(input().strip())

hour = input // 3600
min = (input - 3600*hour) // 60
sec = input - 3600 * hour - 60 * min 

print (":".join(hour, min, sec))

### FIXED CODE ###

input = int(input().strip())

hour = input // 3600
min = (input - 3600*hour) // 60
sec = input - 3600 * hour - 60 * min 

print (":".join([str(hour), str(min), str(sec)]))
s = input()
s.sort()
if s[0] == s[1] and s[2] == s[3]:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s = list(input())
s.sort()
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
else:
    print('No')
r1 = input()
r2 = reverse(input())
print("YES" if r1 == r2 else "NO")

### FIXED CODE ###

r1 = input()
r2 = input()[::-1]

print("YES" if r1 == r2 else "NO")
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
time_ans = 0
A_sort = sorted(A)
before = -1
b = -1
for i in range(N):
        a_sorti = A_sort[i]
        if a_sorti == before:
                time_ans += b
                continue
        b = A_sort.index(a_sorti)
        time_ans += b
        before = a_sorti

for i in range(N):
        for j in range(i + 1,N):
                if A[i] > A[j]:
                        ans += 1
ans1 = int((time_ans * K * (K - 1)) / 2) - K * (time_ans - ans)
print(ans1 % (10 ** 9 + 7))


### FIXED CODE ###

N,M = map(int,input().split())
ans = 0
for n in range(1,N + 1):
        for m in range(1,M + 1):
                m = str(m)
                if len(m) == 1:
                        continue
                if int(m[1]) < 2 or int(m[0]) < 2:
                        continue
                if n == int(m[0]) * int(m[1]):
                        ans += 1
print(ans)
W,H,N = map(int,input().split())

CoordinateList = []
for i in range(N):
    x,y,a = map(int, input().split())
    CoordinateList.append([x,y,a])

# raw White & Black
AllArea = []
for numline in range(H):
    rawWhite = []
    rawBlack = []
    for numraw in range(W):
        rawWhite.append("W")
        rawBlack.append("B")
    AllArea.append(rawWhite)

# coloring from white to Black
for n in range(N):
    if CoordinateList[n][2] == 1:
        if CoordinateList[n][0] == 0:
            pass
        else:
            for i in range(H):
                del AllArea[i][:(CoordinateList[n][0])]
                for numX in range(CoordinateList[n][0]):
                    AllArea[i].insert(0,"B")

    elif CoordinateList[n][2] == 2:
        if CoordinateList[n][0] == 0:
            print(0)
            exit()
        else:
            for i in range(H):
                del AllArea[i][(CoordinateList[n][0]):]
                for numX in range(CoordinateList[n][0]):
                    AllArea[i].append("B")

    elif CoordinateList[n][2] == 3:
        changeY = H - int(CoordinateList[n][1])
        if changeY == 0:
            print(0)
            exit()
        else:
            del AllArea[changeY:]
            for changeRaw in range(changeY):
                AllArea.append(rawBlack)

    elif CoordinateList[n][2] == 4:
        changeY = H - int(CoordinateList[n][1]) 
        if changeY == 0:
            pass
        else:
            del AllArea[:changeY]
            for changeRaw in range(changeY):
                AllArea.insert(0,rawBlack)
            
            
# counting 
AreaWhite = 0
for i in range(H):
    AreaWhite += AllArea[i].count("W")

print(AreaWhite)

### FIXED CODE ###

w, h, n = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
x = [x_i for x_i in range(w + 1)]
y = [y_i for y_i in range(h + 1)]
for l_e in l:
    if l_e[2] == 1:
        x = [i for i in x if i > l_e[0] - 1]
    elif l_e[2] == 2:
        x = [i for i in x if i < l_e[0] + 1]
    elif l_e[2] == 3:
        y = [i for i in y if i > l_e[1] - 1]
    else:
        y = [i for i in y if i < l_e[1] + 1]
print(0 if len(x) == 0 or len(y) == 0 else (x[-1] - x[0]) * (y[-1] - y[0]))