Harryxun/stf_run huggingface dataset:
import sys 

sys.setrecursionlimit(100000000)

def dfs(row, column, black):
    global S, H, W, X, Y, visited, ans
    if black:
        for dx, dy in zip(X, Y):
            n_row = row + dx
            n_column = column + dy
            if 0 <= n_row < H and 0 <= n_column < W:
                if visited[n_row][n_column] == False and S[n_row][n_column] == '.':
                    visited[n_row][n_column] = True
                    ans += 1
                    dfs(n_row, n_column, False)
    
    else:
        for dx, dy in zip(X, Y):
            n_row = row + dx
            n_column = column + dy
            if 0 <= n_row < H and 0 <= n_column < W:
                if visited[n_row][n_column] == False and S[n_row][n_column] == '#':
                    visited[n_row][n_column] = True
                    dfs(n_row, n_column, True)






if __name__ == "__main__":
    H, W = map(int, input().split())

    S = [None] * H
    X = [0, 0, 1, -1]
    Y = [1, -1, 0, 0]
    for i in range(H):
        S[i] = list(input())
    black_row = []
    black_column = []
    for row in range(H):
        for column in range(W):
            if S[row][column] == "#":
                black_row.append(row)
                black_column.append(column)
    ans = 0
    for row, column in zip(black_row, black_column):
        visited = [[False] * W for i in range(H)]
        dfs(row, column, True)
    print(ans)


### FIXED CODE ###

N = int(input())
H = int(input())
W = int(input())

print((N-H+1)*(N-W+1))
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
X,Y,A,B,C = LI()
p = LI()
q = LI()
r = LI()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pa =  [0] + list(itertools.accumulate(p))
qa =  [0] + list(itertools.accumulate(q))
p = [INF] + p
q = [INF] + q
red = X
green = Y
t = 0
pl = 0
while p[red] < r[t] or q[green] < r[t]:
    pl += r[t]
    t += 1
    elif p[red] < q[green] :
        red -= 1
    else:
        green -= 1
    if t >=C or (green ==0 and red ==0): break
print (pa[red] + qa[green] + pl)

### FIXED CODE ###

import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
X,Y,A,B,C = LI()
p = LI()
q = LI()
r = LI()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pa =  [0] + list(itertools.accumulate(p))
qa =  [0] + list(itertools.accumulate(q))
p = [INF] + p
q = [INF] + q
red = X
green = Y
t = 0
pl = 0
while p[red] < r[t] or q[green] < r[t]:
    pl += r[t]
    t += 1
    if red == 0:
        green -= 1
    elif green == 0:
        red -= 1

    elif p[red] < q[green] :
        red -= 1
    else:
        green -= 1
    if t >=C or (green ==0 and red ==0): break
print (pa[red] + qa[green] + pl)
a,b,c=input().split()
time = (c+0.5)/a
print (time*b)

### FIXED CODE ###

a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
time=int(c/a)

p=time*b
print(p)
N, Q = [int(item) for item in input().split()]

tree_list = [input().split() for _ in range(1,N)]

query_list = [input().split() for _ in range(Q)]
query_list_int = [[int(k) for k in i]  for i in query_list]

val_list = [0 for _ in range(N)]
linkde_node_list = [[] for _ in range(N)]

for a, b in tree_list:
    linkde_node_list[int(a) -1].append(int(b) - 1)
    linkde_node_list[int(b) -1].append(int(a) - 1)


for index, val in query_list_int:
    val_list[index-1] += val

def dfs(node_index, pairent_index):

    for child in linkde_node_list[node_index]:

        if child == pairent_index:
            continue

        val_list[child] += val_list[node_index]
        dfs(child, node_index)

    return val_list

res = dfs(0, -1) 

print(*res)

### FIXED CODE ###

N, Q = [int(item) for item in input().split()]

tree_list = [input().split() for j in range(1, N)]

query_list = [input().split() for k in range(Q)]
query_list_int = [[int(k) for k in i] for i in query_list]

val_list = [0 for _ in range(N)]

linked_node_list = [[] for _ in range(N)]

for a, b in tree_list:
    a, b = int(a)-1, int(b) -1
    linked_node_list[a].append(b)
    linked_node_list[b].append(a)


for index, val in query_list_int:
    val_list[index-1] += val

stack = [0]
parent = [0] * (N+1)

while True:
    v=stack.pop()
    for child in linked_node_list[v]:
        if child != parent[v]:
            parent[child] = v
            stack.append(child)
            val_list[child] += val_list[v]
    if not stack:
        break

print(*val_list)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev != 0 and != N:
    manzoku += C[prev-1]
  prev = a
print(manzoku)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
manzoku = 0
prev = 0
 
for a in A:
  manzoku += B[a-1]
  if prev+1 == a and prev != 0:
    manzoku += C[prev-1]
  prev = a
print(manzoku)
from collections import Counter
s = list(input())
x, y = map(int, input().split())
cs = Counter(s)

ss = []
idx = 0
cnt = 0
while idx < len(s):
    if s[idx] == 'F':
        cnt += 1
    else:
        if cnt != 0:
            ss += [cnt]
        ss += [0]
        cnt = 0

    idx += 1

    if idx == len(s):
        if cnt != 0:
            ss += [cnt]

p = [[], []]
now = 0

for i in ss:
    if i == 0:
        now = abs(1-now)
    else:
        p[now] += [i]

s1 = p[0]
s2 = p[1]

if len(s1) == 0 and len(s2) == 0:
    print('No')
    exit()

if len(s1) > 0:
    dp = [[0]*(2*max(2*x, sum(s1))+1) for _ in range(len(s1)+1)]
    zero = sum(s1)
    dp[0][zero] = 1
    sum_s1 = sum(s1)
    for i in range(len(s1)):
        m = s1[i]
        for j in range(sum_s1+1):
            if zero+j+m < 2*sum_s1 and zero+j-m > 0:
                dp[i+1][zero+j] = dp[i][zero+j-m] | dp[i][zero+j+m]
            elif zero+j+m < 2*sum_s1:
                dp[i+1][zero+j] = dp[i][zero+j+m]
            elif zero+j-m > 0:
                dp[i+1][zero+j] = dp[i][zero+j-m]

            if zero-j+m < 2*sum_s1 and zero-j-m > 0:
                dp[i+1][zero-j] = dp[i][zero-j-m] | dp[i][zero-j+m]
            elif zero-j+m < 2*sum_s1:
                dp[i+1][zero-j] = dp[i][zero-j+m]
            elif zero-j-m > 0:
                dp[i+1][zero-j] = dp[i][zero-j-m]

    if dp[-1][x+zero] == 0:
        print('No')
        exit()

if len(s2) > 0:
    dp = [[0]*(2*max(2*y, sum(s2))+1) for _ in range(len(s2)+1)]
    zero = sum(s2)
    dp[0][zero] = 1
    sum_s2 = sum(s2)
    for i in range(len(s2)):
        m = s2[i]
        for j in range(sum_s2+1):
            if zero+j+m < 2*sum_s2 and zero+j-m > 0:
                dp[i+1][zero+j] = dp[i][zero+j-m] | dp[i][zero+j+m]
            elif zero+j+m < 2*sum_s2:
                dp[i+1][zero+j] = dp[i][zero+j+m]
            elif zero+j-m > 0:
                dp[i+1][zero+j] = dp[i][zero+j-m]

            if zero-j+m < 2*sum_s2 and zero-j-m > 0:
                dp[i+1][zero-j] = dp[i][zero-j-m] | dp[i][zero-j+m]
            elif zero-j+m < 2*sum_s2:
                dp[i+1][zero-j] = dp[i][zero-j+m]
            elif zero-j-m > 0:
                dp[i+1][zero-j] = dp[i][zero-j-m]
    if dp[-1][y+zero] == 0:
        print('No')
        exit()

print('Yes')

### FIXED CODE ###

s = input()
x, y = map(int, input().split())
d = [len(i) for i in s.split('T')]
 
s1 = d[2::2]
s2 = d[1::2]
 
now_x = [0]
now_y = [0]

x -= d[0]

for i in s1:
    nx = set()
    for j in now_x:
        nx.add(j-i)
        nx.add(j+i)
    now_x = nx

for i in s2:
    ny = set()
    for j in now_y:
        ny.add(j-i)
        ny.add(j+i)
    now_y = ny

if x in now_x and y in now_y:
    print('Yes')
else:
    print('No')
import numpy as np

rotate = int(input()) 

x = 0
y = 1
heading = 0

count = 1

while x != 0 and y != 0:
  heading += rotate
  x += cos(np.deg2rad(heading))
  y += sin(np.deg2rad(heading))
  count++
  
print(count)

### FIXED CODE ###

import numpy as np
import math

rotate = int(input())

x = 0
y = 1
heading = 90

count = 1

while True:
    heading += rotate
    x += np.cos(np.deg2rad(heading))
    y += np.sin(np.deg2rad(heading))
    count += 1
    #print('heading', heading)
    #print('x : ', x)
    #print('y : ', y)

    if math.isclose(x, 0.0,abs_tol=0.000001) and math.isclose(y, 0.0,abs_tol=0.0000001):
        break

print(count)
import itertools

N, K = map(int,input().split())
D = list(map(int,input().split()))
N = str(N)
d = []
d_min = 10
for i in range(10):
    if i in D:
        continue
    else:
        if i != 0:
            d_min = min(d_min, i)
        d.append(str(i))
if '0' in d:
    ans = str(d_min) + '0' * len(N)
else:
    ans = str(d_min) * len(N+1)
ans = int(ans)
for s in itertools.product(d, repeat=len(N)):
    s = ''.join(s)
    s = int(s)
    if s >= int(N):
        ans = min(ans, s)
print(ans)


### FIXED CODE ###

import itertools

N, K = map(int,input().split())
D = list(map(int,input().split()))
N = str(N)
d = []
d_min = 10
for i in range(10):
    if i in D:
        continue
    else:
        if i != 0:
            d_min = min(d_min, i)
        d.append(str(i))
if '0' in d:
    ans = str(d_min) + '0' * len(N)
else:
    ans = str(d_min) * (len(N) + 1)
ans = int(ans)
for s in itertools.product(d, repeat=len(N)):
    s = ''.join(s)
    s = int(s)
    if s >= int(N):
        ans = min(ans, s)
print(ans)
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(N)]

PY = sorted(PY)

keyP = -1
for P, Y in PY:
  if keyP != P:
    keyP = P
    keyNo = 1

  print("{:0>6}{:0>6}", keyP, keyNo)
  keyNo += 1


### FIXED CODE ###

N, M = map(int, input().split())
PY = [list(map(int, input().split() +[x])) for x in range(M)]

PY = sorted(PY)

keyP = -1
for i, (P, Y, _) in enumerate(PY):
  if keyP != P:
    keyP = P
    keyNo = 1

  PY[i].append("{:0>6}{:0>6}".format(keyP, keyNo))
  keyNo += 1

for P, Y, _, s in sorted(PY, key=lambda x:x[2]):
  print(s)
S = input()
prvs = ''
si = None
for i, s in enumerate(S):
  if prvs == s:
    if si is None: si = i
    print(i,i+1)
    exit()
  else:
    if si is not None:
      print(si, i)
  prvs = s

for i range(len(S)-2):
  if set(S[i:i+3])>=3:
    print(i+1, i+4)
    exit()
  
print(-1, -1)
  

### FIXED CODE ###

S = input()
prvs = ''
si = None
for i, s in enumerate(S):
  if prvs == s:
    if si is None: si = i
    print(i,i+1)
    exit()
  else:
    if si is not None:
      print(si, i)
  prvs = s

for i in range(len(S)-2):
  if len(set(S[i:i+3]))<=2:
    print(i+1, i+3)
    exit()
  
print(-1, -1)
f=input.split(" ")
x=f[1]
y=f[2]
z=x+y/2
print(z)


### FIXED CODE ###

number=input().split(" ")
x=int(number[0])
y=int(number[1])
z=x+y/2
print(int(z))
while True:
    x, y = sorted(map(int, input().split()))
    if x==y and y==0:
    print(x, y)
    x,y = sorted(map(int, input().split()))


### FIXED CODE ###

while True :
    x, y = sorted(map(int, input().split()))
    if x == y and y == 0 : break
    print(x, y)
# import numpy as np
# A,B = map(int,input().split())
# print(np.lcm(A,B))
# numpyのlcm関数は新しく追加された関数であり、AtCoderでは使用不可
import math

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

def lcm(A,B):
    return A * B // math.gcd(A,B)

print(lcm(A,B))

### FIXED CODE ###

# import math
import fractions # Python 3.4ではこちらにgcdがある

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

def lcm(A,B):
    return A * B // fractions.gcd(A,B)

print(lcm(A,B))
import math
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [a//2 for a in A]

def lcm(a, b):
    return (a*b) // math.gcd(a, b)

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M % 2
if b == 1:
    print(((M / k)+1)/2)
else:
    print((M / k) / 2)
    

### FIXED CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline

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

def lcm(a, b):
    return (a*b) // gcd(a, b)

k = A[0]
for a in A[1:]:
    k = lcm(a, k)

M = M - (M % k)
b = M // k


if b % 2 == 0:
    r = int(b/2)
else:
    r = int((b + 1) / 2)

for a in A[1:]:
    if k // a % 2 == 0:
        r = 0
        break

print(r)
N = int(input())
N_list = [int(i) for i in input().split()]

counter = 0
for i in range(len(N_list)):
    if N_list[i] == min(N_list[:i+1]):
        couter += 1
print(counter)
print()

### FIXED CODE ###

N = int(input())
N_list = list(map(int, input().split()))

counter = 0
min = N_list[0]
for i in range(N):
    if N_list[i] <= min:
        min = N_list[i]
        counter += 1
print(counter)
print()
import sys
import time
import random
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(ans):
  res = 0
  LastDay = [0]*26
  for i in range(D):
    res += s[i][ans[i]]
    for j in range(26):
      if ans[i] == j:
        continue
      res -= (i+1 - LastDay[j]) * c[j]
    LastDay[ans[i]] = i+1
  return res

def nasu():
  res = []
  LastDay = [0]*26
  for d in range(1,D+1):
    tmp = ["", 0]
    for i in range(26):
      if tmp[1] < s[d-1][i] + (d - LastDay[i]) * c[i]:
        tmp = [i, s[d-1][i] + (d - LastDay[i]) * c[i]]
    res.append(tmp[0])
    LastDay[tmp[0]] = d
  return res

def nbo(ans, score, num):
  tmp_ans = ans[:]
  for _ in range(num):
    random_date = random.randint(0,D-1)
    random_val = random.randint(0,25)
    tmp_ans[random_date] = random_val
  scoscore = tami(tmp_ans)
  if scoscore > score:
    return (True, tmp_ans, scoscore)
  else:
    return (False, tmp_ans, scoscore)

start = time.time()
D = I()
c = IL()
s = [IL() for i in range(D)]

ans = nasu()
#print(ans)

score = tami(ans)
#print(score)

end = time.time()
num = 10
cnt = 0
while (time.time() - start) < 1.8:
  judge, anans, scoscore = nbo(ans, score, num)
  if judge == True:
    ans, score = anans, scoscore
    #print(ans)
    #print(tami(ans))
  cnt += 1
  if cnt == 1000:
    cnt = 0
    n = max(2, n-1)
for i in ans:
  print(i+1)

### FIXED CODE ###

import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(now, ContestType):
  res = c[ContestType] * (now - LastDay[ContestType])
  return res

D = I()
c = IL()
s = [IL() for i in range(D)]

LastDay = [0]*26
for i in range(1,D+1):
  tmp = ["", 0]
  for j in range(26):
    Dscore = tami(i, j)
    if Dscore > tmp[1]:
      tmp = [j, Dscore]
  print(tmp[0]+1)
  LastDay[tmp[0]] = i
N, A, B = map(int,input().split())
a = list()
a = ["blue"]*A + ["red"]*B
for i in range(N):
    a = a + a
del a[N:]
print(a.count("blue"))

### FIXED CODE ###

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

import math
n = math.ceil(N//(A+B))
mod = N % (A+B)
b = n*A
if mod <= A:
    b += mod
else:
    b += A

print(b)
x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = []
q_list = []
r_list = []

for value in input().split():
  value = int(value)
  if len(p_list) >= x:
    if p_list[-1*(x-1)-1] < value:
      insort(p_list,value)
      if len(p_list) % 50 == 0:
      	p_list = p_list[-1*(x+1)-1:]
  else:
    insort(p_list,value)

for value in input().split():
  value = int(value)
  if len(q_list) >= y:
    if q_list[-1*(y-1)-1] < value:
      insort(q_list,value)
      if len(q_list) % 50 == 0:
      	q_list = q_list[-1*(y+1)-1:]
  else:
    insort(q_list,value)
  
for value in input().split():
  value = int(value)
  if len(r_list) >= x+y:
    if r_list[-1*(x+y)-1] < value:
      insort(r_list.value)
      if len(r_list) % 50 == 0:
      	r_list = r_list[-1*(x+y+1)-1:]
  else:
    insort(r_list,value)
  
red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)

### FIXED CODE ###

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

from bisect import insort

p_list = list(map(int,input().split()))
q_list = list(map(int,input().split()))
r_list = list(map(int,input().split()))


p_list.sort()
q_list.sort()
r_list.sort()

red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)
n = int(input())
s = [int(i) for i in input().split()]
s = set(s)
for i in s:
	for j in s:
		if i == j or i%j == 0:
			s.remove(i)
			s.add(-i)
			break
l = [i for i in s if i >= 0]
print(len(l))

### FIXED CODE ###

x = [int(i) for i in input().split()]
print(x.index(0)+1)
n=int(input())
count=0
ren=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    if count<3:
      count+=1
      ren=1
  else if count<3:
    count=0
if count>=3:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=int(input())
count=0
ren=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    if count<3:
      count+=1
      ren=1
  elif count<3:
    count=0
if count>=3:
  print("Yes")
else:
  print("No")
min_b = max(-1000000, x - (k - 1) )
max_b = min(1000000, x + (k - 1) )
ans = []
for i in range(min_b, max_b + 1):
  ans.append(str(i))
print(" ".join(ans))

### FIXED CODE ###

k, x = [int(v) for v in input().split()]

min_b = max(-1000000, x - (k - 1) )
max_b = min(1000000, x + (k - 1) )
ans = []
for i in range(min_b, max_b + 1):
  ans.append(str(i))
print(" ".join(ans))
def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]//2
    while(True):
        m = mi + (MA - mi)//2 if (MA - mi)%2 == 0 else mi + (MA-mi)//2 + 1
        count = 0
        for i in a:
            count += i//m
        if(MA < mi):
            print(m)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m-1




if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    a = list(sorted(map(int,input().split())))
    mi = 0
    MA = a[n-1]
    if(k == 0):
        print(MA)
        return
    while(True):
        m = mi + (MA - mi)//2
        if(MA == 1):
            print(1)
            return
        count = 0
        for i in a:
            plus = i//m - 1 if i%m == 0 else i//m 
            count += plus
        if(MA - mi <= 0):
            if(k >= count):
                print(m)
            else:
                print(mi)
            break
        if(k < count):
            mi = m+1
        else:
            MA = m
        





if __name__ == "__main__":
    main()
a,b,c= input().list()

if b == "+":
    print(a+c)
else:
    print(a-c)



### FIXED CODE ###

a,b,c= input().split()

if b == "+":
    print(int(a)+int(c))
else:
    print(int(a)-int(c))
x500 = int(input())
x100 = int(input())
x50 = int(input())
xxx = int(input())

i = 0
j = 0
k = 0

count = 0
for i in range(x500):
    if total(i, j, k) == xxx:
        count += 1
    for j in range(x100):
        if total(i, j, k) == xxx:
            count += 1
        for k in range(x50):
            if total(i, j, k) == xxx:
                count += 1
print(count)


def total(i, j, k):
    return 500 * i + 100 * j + 50 * k


### FIXED CODE ###

A, B, C, x = [int(input()) for i in range(4)]
print(sum(500 * a + 100 * b + 50 * c == x for a in range(A+1) for b in range(B+1) for c in range(C+1)))
a , b , c = map(int,input().split())
print(min(abs(a-b)+abs(b-c),abs(b-a)+abs(a-c),abs(a-c)+abs(c-b))

### FIXED CODE ###

a , b , c = map(int,input().split())
print(min(abs(a-b)+abs(b-c),abs(b-a)+abs(a-c),abs(a-c)+abs(c-b)))
import itertools
import numpy as np
N,M,X=map(int,input().split())
CA=[]
for i in range(N):
  CA.append(list(map(int,input().split())))
money=100000000000
count=1
for i in range(1,N):
  test=itertools.combinations(CA,i)
  for j in test:#組み合わせごとに計算
    pre_ans=np.sum(j, axis=0)
    if pre_ans[0]<money and np.all(pre_ans[1:]>=X):
      money=pre_ans[0]
      count=0
if count==0:
  print(money)
else:
  print(-1)


### FIXED CODE ###

import itertools
import numpy as np
N,M,X=map(int,input().split())
CA=[]
for i in range(N):
  CA.append(list(map(int,input().split())))
money=9000000000
count=1
for i in range(1,N+1):
  test=itertools.combinations(CA,i)
  for j in test:#組み合わせごとに計算
    pre_ans=np.sum(j, axis=0)
    if pre_ans[0]<money and np.all(pre_ans[1:]>=X):
      money=pre_ans[0]
      count=0
if count==0:
  print(money)
else:
  print(-1)
TAX = 1.08
value = int(input())

row_cost = int(value / TAX)

flag = False
echo_cost = 0
if int(row_cost * TAX) == value:
    flag = True
    echo_cost = int(row_cost )
elif int((row_cost + 1) * TAX) == value:
    flag = True
    echo_cost = int(row_cost + 1)

else :
    flag = False

if flag:
    print(echo_cost)
else:
    print(":(")




### FIXED CODE ###

def fetch_int_input():
    return [int(s) for s in input().strip().split()]

pre_input = fetch_int_input()
nxt_input = fetch_int_input()

echo_str = ""
if pre_input[0] != nxt_input[0]:
  echo_str = 1
 
else:
  echo_str = 0
 
print(echo_str)
import sys

line_size, row_size = map(int, input().split())
mapmap = []#地図初期化

for i in range(line_size):
    mapmap.append(list(input()))

#探索
def Start_check(mapmap, px, py):
    start_flg = False
    move_x = [1, -1, 0, 0]
    move_y = [0, 0, 1, -1]
    for i in range(len(move_x)):#動ける範囲で探索
        nx = px + move_x[i]
        ny = py + move_y[i]
        if 0 <= nx and nx < line_size and 0 <= ny and ny < row_size:
            if mapmap[nx][ny] == '#':#もし黒塗りなら
                start_flg = True
    
    if start_flg == False:
        print('No')
        sys.exit()

#Main
count = 0#探索回数（塗り絵した回数）
for i in range(line_size):
    for j in range(row_size):
        if mapmap[i][j] == '#':
            Start_check(i, j)
            count += 1

#何もしなかった場合
if count == 0:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

import sys

line_size, row_size = map(int, input().split())
mapmap = []#地図初期化

for i in range(line_size):
    mapmap.append(list(input()))

#探索
def Start_check(mapmap, px, py):
    start_flg = False
    move_x = [1, -1, 0, 0]
    move_y = [0, 0, 1, -1]
    for i in range(4):#動ける範囲で探索
        nx = px + move_x[i]
        ny = py + move_y[i]
        if 0 <= nx and nx < line_size and 0 <= ny and ny < row_size:
            if mapmap[nx][ny] == '#':#もし黒塗りなら
                start_flg = True
    
    if start_flg == False:
        print('No')
        sys.exit()

#Main
count = 0#探索回数（塗り絵した回数）
for i in range(line_size):
    for j in range(row_size):
        if mapmap[i][j] == '#':
            Start_check(mapmap, i, j)
            count += 1

#何もしなかった場合
print('Yes')
A, B = int(input().split())
if A + B > 24:
  print(A + B -24)
else:
  print(A + B)

### FIXED CODE ###

A, B = map(int,input().split())
if A + B >= 24:
  print(A + B -24)
else:
  print(A + B)