Harryxun/stf_run huggingface dataset:
import numpy as np
H, W=map(int, input().split())
S=np.array([list(input()) for _ in range(H)])
S=np.where(S==".",1,0 )

left=np.zeros((H, W))
right=np.zeros((H, W))
top=np.zeros((H, W))
bottom=np.zeros((H, W))

for i in range(W):
  if i==0:
    left[:,i]=S[:,i]
    right[:,-i-1]=S[:,-i-1]
  else:
    left[:,i]=(left[:,i-1]+1)*S[:,i]
    right[:,-i-1]=(right[-i]+1)*S[:,-i-1]
    
for i in range(H):
  if i==0:
    top[i,:]=S[i,:]
    bottom[-1-i,:]=S[-i-1,:]
  else:
    top[i,:]=(top[i-1,:]-S[i,:])
    bottom[-1-i,:]=(bottom[-i]+1)*S[-i-1,:]
    
ans=left+top+right+bottom-3
    
    
print(ans.max())

### FIXED CODE ###

import numpy as np
H, W=map(int, input().split())
S=np.array([list(input()) for _ in range(H)])
S=np.where(S==".",1,0 )

left=np.zeros((H, W))
right=np.zeros((H, W))
top=np.zeros((H, W))
bottom=np.zeros((H, W))

for i in range(W):
  if i==0:
    left[:,i]=S[:,i]
    right[:,-i-1]=S[:,-i-1]
  else:
    left[:,i]=(left[:,i-1]+1)*S[:,i]
    right[:,-i-1]=(right[:,-i]+1)*S[:,-i-1]
    
for i in range(H):
  if i==0:
    top[i,:]=S[i,:]
    bottom[-1-i,:]=S[-i-1,:]
  else:
    top[i,:]=(top[i-1,:]+1)*S[i,:]
    bottom[-1-i,:]=(bottom[-i,:]+1)*S[-i-1,:]
    
ans=left+top+right+bottom-3
    

print(int(ans.max()))
N = int(input())
path = []
ans = 0
ap = path.append
Ap = path[-1].append
for i in range(N):
    A = int(input())
    ap([])
    for j in range(A):
        x, y = map(int,input().split())
        x -= 1
        Ap((x, y))
for i in range(1<<N):
    i |= (1<<N)
    judge = True
    for j in range(N):
        if (1<<j) & i:
            for k in range(len(path[j])):
                if path[j][k][1] != int(bin(i)[-path[j][k][0] - 1]):
                    judge = False
    if judge:
        if ans < bin(i).count("1") - 1:
            ans = bin(i).count("1") - 1
print(ans)

### FIXED CODE ###

N = int(input())
path = []
ans = 0
for i in range(N):
    A = int(input())
    path.append([])
    for j in range(A):
        x, y = map(int,input().split())
        x -= 1
        path[-1].append((x, y))
for i in range(1<<N):
    i |= (1<<N)
    judge = True
    for j in range(N):
        if not judge:
            break
        if (1<<j) & i:
            for k in range(len(path[j])):
                if path[j][k][1] != int(bin(i)[-path[j][k][0] - 1]):
                    judge = False
                    break
    if judge:
        if ans < bin(i).count("1") - 1:
            ans = bin(i).count("1") - 1
print(ans)
from collections import Counter
s = input()
n = len(s)
count = dict(Counter(s))
flag = False

if n ==1:
    flag = True
elif n <= 3:
    if max(count.values())!=2:
        flag = True
elif n==4:
    if max(count.values())<=2:
        flag = True
else:
    if count["a"]==count["b"] or count["b"]==count["c"] or count["c"]==count["a"]:
        if max(count.values())-min(count.values()) <= 1:
            flag = True
            
            
print('YES' if flag==True else 'NO')

### FIXED CODE ###

from collections import Counter
s = input()
n = len(s)
count = dict(Counter(s))
flag = False

if n ==1:
    flag = True
elif n <= 3:
    if max(count.values())!=2:
        flag = True
elif n==4:
    if max(count.values())<=2:
        flag = True
else:
    if "a" in count:
        if "b" in count:
            if "c" in count:
                if count["a"]==count["b"] or count["b"]==count["c"] or count["c"]==count["a"]:
                    dev = max(count.values())-min(count.values())
                    if dev <= 1:
                        flag = True
            
            
print('YES' if flag==True else 'NO')
while 1:
    list1=input().split('"')
    if len(list1)==1 and list1[0]==".":
        break
    list2=input().split('"')
     
    c1=0
    c2=0
    flag=0
     
    if len(list1)!=len(list2):
        print("DIFFERENT")
    else:
        i=0
        while i<len(list1):
            if list1[i]==list2[i]:
                c1+=1
            elif i%2==0:
                print("DIFFERENT")
                flag=1
                break
            else:
                c2+=1
                if c2>1:
                    print("DIFFERENT")
                    break
            i+=1
                 
        if flag==0 and t2==1:
            print("CLOSE")
        if c1==len(list1):
            print("IDENTICAL")


### FIXED CODE ###

while True:
    list1=input().split('"')
    if list1[0]==".":
        break
    list2=input().split('"')
     
    cnt1=0
    cnt2=0
    flag=0
     
    if len(list1)!=len(list2):
        print("DIFFERENT")
    else:
        i=0
        while i<len(list1):
            if list1[i]==list2[i]:
                cnt1+=1
            elif i%2==0:	#[ " ~~~~~ " ]in ""
                print("DIFFERENT")
                flag=1
                break
            else:
                cnt2+=1
                if cnt2>1:
                    print("DIFFERENT")
                    break
            i+=1
                 
        if flag==0 and cnt2==1:
            print("CLOSE")
        if cnt1==len(list1):
            print("IDENTICAL")
n=int(input)
s=input()
d=list(s)
cnt=0
for i in range(n-1):
  if s[i] != s[i+1]:
    cnt+=1
  else:
    continue
    
print(cnt+1)



### FIXED CODE ###

n=int(input())
s=input()
d=list(s)
cnt=0
for i in range(n-1):
  if s[i] != s[i+1]:
    cnt+=1
print(1+cnt)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
a, b = map(int,read().split())

def test(n):
    x = n * 8 // 100
    y = n * 10 // 100
    return (x==a) and (y==b)

answer = -1
for n in range(int(20000)):
    if test(n):
        ans = n
        break
print(ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
A,B = map(int,read().split())
 
def test(n):
    x = n * 8 // 100
    y = n * 10 // 100
    return (x == A) and (y == B)
 
answer = -1
for n in range(20000):
    if test(n):
        answer = n
        break
print(answer)
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline

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

if (y == 0):
  print(x)
  exit()

p = [list(map(int, input().split()))]
p_n = np.array(p)
p_n = p_n.reshape(-1)
pp = np.arange(1, 100)
for i in p_n:
    pp[i-1] += 10000
sa = min(abs(pp-x))
if (sa >= 101):
  print("0")
  exit()
if pp[x-sa-1] >= 10000:
    print(x+sa)
else:
    print(x-sa)

### FIXED CODE ###

import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
x, y = map(int, input().split())
if y == 0:
    print(x)
    exit()
p = [list(map(int, input().split()))]
p_n = np.array(p)
p_n = p_n.reshape(-1)
pp = np.arange(0, 102)
for i in p_n:
    pp[i] += 10000
sa = min(abs(pp-x))
if sa <= 101:
    if pp[x-sa] >= 10000:
        print(x+sa)
    else:
        print(x-sa)
else:
    print("0")
n = int(input())
ans = "No"
for i in range(n // 7 + 1):
  if (n - i*7) % 4 == 0:
    ans == "Yes"
print(ans)


### FIXED CODE ###

import math
n,k = map(int, input().split())
print(math.ceil(n/k)-n//k)
def pal(string):
    return True if string==string[::-1] else False

S = input()

if palindrome(S) and palindrome(S[0:int((len(S)-1)/2)]) and palindrome(S[int((len(S)+3)/2)-1:]):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

def pal(string):
    return True if string==string[::-1] else False

S = input()

if pal(S) and pal(S[0:int((len(S)-1)/2)]) and pal(S[int((len(S)+3)/2)-1:]):
    print('Yes')
else:
    print('No')
n = int(input())
a = list(map(int,input().split()))
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
mid = b[n//2]
sum = 0
for i in range(n):
    sum+=abs(a[i]-(mid+(i+1)))
print(sum)


### FIXED CODE ###

N = int(input())
if N%2==0:
    print(N)
else:
    print(N*2)
S=input()
list=[SUN,MON,TUE,WED,THU,FRI,SAT]
print(7-list.index(S))

### FIXED CODE ###

S=input()
list=["SUN","MON","TUE","WED","THU","FRI","SAT"]
print(7-list.index(S))
import sys
import math
import bisect

def main():
    a, b = map(int, input())
    A = []
    A.append(a + b)
    A.append(a - b)
    A.append(a * b)
    print(max(A))
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import math
import bisect

def main():
    a, b = map(int, input().split())
    A = [a + b, a - b, a * b]
    print(max(A))
    
if __name__ == "__main__":
    main()
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2)
        else:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2) +1
    else:
        if diff % 2 == 0:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2)
        else:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2) +1
    num = reach_loop_num
print(' '.join(map(str,count_list)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if reach_loop_num == char_list_num - 1:
        if char[num] == char[reach_loop_num]:
            diff += 1
        else:
            count_list[reach_loop_num] += 1
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2)
        else:
            count_list[reach_loop_num] += int(diff/2)
            count_list[reach_loop_num-1] += int(diff/2) +1
    else:
        if diff % 2 == 0:
            count_list[num] += int(diff/2)
            count_list[num-1] += int(diff/2)
        else:
            count_list[num] += int(diff/2) +1
            count_list[num-1] += int(diff/2)
    num = reach_loop_num
print(' '.join(map(str,count_list)))
n = int(input())

A = list(set(list(map(int, input().split()))))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

m = max(A)
if len(A) == 1:
    print(A[0])
else:
    for i in range(n-1):
        for j in range(i+1, n):
            m = min(m, gcd(A[i], A[j]))
    print(m)


### FIXED CODE ###

n = int(input())

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

t = max(A)

from fractions import gcd

for i in A:
    t = gcd(t, i)
print(t)
l = input()
L = l.split()
for i in range(len(L)):
	L[i] = int(L[i])
while True:
	if L[0] == 0:
		break
	a = [L[0]-number for number in range(L[0])]
	for j in range(L[1]):
		r = input()
		R = r.split()
		for k in range(len(R)):
			R[k] = int(R[k])
		b = []
		b += a[R[0]-1:R[0]+R[1]-1]
		b += a[:R[0]-1]
		b += a[R[0]+R[1]-1:]
		a.clear()
		a = b.copy()
	print(a[0])


### FIXED CODE ###

while True:
	l = input()
	L = l.split()
	for i in range(len(L)):
		L[i] = int(L[i])
	if L[0] == 0:
		break	
	a = [L[0]-number for number in range(L[0])]
	for j in range(L[1]):
		r = input()
		R = r.split()
		for k in range(len(R)):
			R[k] = int(R[k])
		b = []
		b += a[R[0]-1:R[0]+R[1]-1]
		b += a[:R[0]-1]
		b += a[R[0]+R[1]-1:]
		a.clear()
		a = b.copy()
	print(a[0])
S = input()
N = len(S) + 1

vA = [0,] * N
vZ = []
p = ">"
for i,s in enumerate(S):
    if p+s == "><":
        vZ.append(i)
    p = s
if S[-1] == ">":
    vZ.append(N-1)

# print(vZ)##
####
for z in vZ:
    if z == N-1:
        break
    t = z
    while t<N-1 and S[t] == "<":
        vA[t+1] = vA[t] + 1
        t += 1

# print(vA)##

for z in vZ:
    if z == 0:
        continue
    t = z
    while S[t-1] == ">":
        vA[t-1] = max(vA[t] + 1, vA[t-1])
        t -= 1

# print(vA)###
print(sum(vA))


### FIXED CODE ###

S = input()
N = len(S) + 1

vA = [0,] * N
vZ = []
p = ">"
for i,s in enumerate(S):
    if p+s == "><":
        vZ.append(i)
    p = s
if S[-1] == ">":
    vZ.append(N-1)

# print(vZ)##
####
for z in vZ:
    if z == N-1:
        break
    t = z
    while t<N-1 and S[t] == "<":
        vA[t+1] = vA[t] + 1
        t += 1

# print(vA)##

for z in vZ:
    if z == 0:
        continue
    t = z
    while t>0 and S[t-1] == ">":
        vA[t-1] = max(vA[t] + 1, vA[t-1])
        t -= 1

# print(vA)###
print(sum(vA))
S = input()
X, Y = map(int, input().split())

if S.find("F") < 0:
    if X != 0 or Y != 0:
        print("No")
        exit()

n = len(S)
d = list(map(len, S.split("T")))
xs = d[::2]
ys = d[1::2]

dpx = [[False] * (2 * n + 1) for _ in range(len(xs))]
for i in range(len(xs)):
    if i == 0:
        d = (-1) ** S.find("F")
        dpx[i][d * xs[i] + n] = True
        continue

    for j in range(2 * n + 1):
        if j + xs[i] <= 2 * n:
            dpx[i][j] |= dpx[i - 1][j + xs[i]]
        if 0 <= j - xs[i] <= 2 * n:
            dpx[i][j] |= dpx[i - 1][j - xs[i]]

dpy = [[False] * (2 * n + 1) for _ in range(len(ys) + 1)]
dpy[0][n] = True
for i in range(len(ys)):
    for j in range(2 * n + 1):
        if j + ys[i] <= 2 * n:
            dpy[i + 1][j] |= dpy[i][j + ys[i]]
        if 0 <= j - ys[i] <= 2 * n:
            dpy[i + 1][j] |= dpy[i][j - ys[i]]

ans = dpx[-1][X + n] & dpy[-1][Y + n]
print("Yes" if ans else "No")


### FIXED CODE ###

S = input()
X, Y = map(int, input().split())

if S.find("F") < 0:
    if X != 0 or Y != 0:
        print("No")
    else:
        print("Yes")
    exit()

n = len(S)
d = list(map(len, S.split("T")))
xs = d[::2]
ys = d[1::2]

dpx = [set() for _ in range(len(xs))]
for i in range(len(xs)):
    if i == 0:
        d = (-1) ** S.find("F")
        dpx[i].add(d * xs[i] + n)
        continue
    
    for j in dpx[i - 1]:
        dpx[i].add(j + xs[i])
        dpx[i].add(j - xs[i])

dpy = [set() for _ in range(len(ys) + 1)]
dpy[0].add(n)
for i in range(len(ys)):
    for j in dpy[i]:
        dpy[i + 1].add(j + ys[i])
        dpy[i + 1].add(j - ys[i])

ans = (X + n in dpx[-1]) & (Y + n in dpy[-1])
print("Yes" if ans else "No")
N= int(input())
s = []

for _ in range(N):
    s.append(input())

for i in range(N):
    s[i] = [*s[i]]
    s[i] = sorted(s[i])

counter = 0
for i in range(N):
    for j in range((i+1), N):
        if s[i] == s[j]:
            counter += 1

print(counter)   

### FIXED CODE ###

N= int(input())
s = []

for _ in range(N):
    s.append(input())

for i in range(N):
    s[i] = tuple(sorted(s[i]))

import collections
c = collections.Counter(s)
d = [i for i in c.values()]

counter = 0
from math import factorial
for i in d:
    if i > 1:
        counter += i*(i-1)/2

print(int(counter))
N = int(input())

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

### FIXED CODE ###

N = int(input())

if N%2==0:
  print(N//2)
else:
  print(N//2+1)
N, M = list(map(int, input().split()))
D = list(map(int, input().split()))
UB = [list(map(int, input().split())) for _ in range(M)]

R = {}
for i in range(M):
  a, b = UB[i]
  a -= 1
  b -= 1
  if a not in R: R[a] = [[b, i]]
  else: R[a].append([b, i])
  if b not in R: R[b] = [[a, i]]
  else: R[b].append([a, i])

DD = [[0] * 2 for _ in range(N)]
for i in range(N):
  DD[i][0] = D[i]
  DD[i][1] = i
DD.sort()
L = [0] * N
H = [0] * M
LL = [-1] * N
for i in range(N):
  h, x = DD[i]
  if x >= N: exit()
  if L[x] == 0:
    if LL[x] == -1:
      for n, m in R[x]:
        LL[n] = x
        if D[n] == D[x] or L[n] != 0:
          H[m] = h
          if L[n] == 1:
            L[n] = 1
            L[x] = 2
          else:
            L[n] = 2
            L[x] = 1
          break
      else:
        print(-1)
        exit()
    else:
      n, m = R[x][LL[x]]
      H[m] = h
      if L[n] == 1:
        L[n] = 1
        L[x] = 2
      else:
        L[n] = 2
        L[x] = 1

t = ""
for i in range(N):
  if L[i] == 1:
    t += "B"
  else:
    t += "W"
print(t)
for i in range(M):
  if H[i] == 0:
    print(10 ** 9)
  else:
    print(H[i])


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
D = list(map(int, input().split()))
UB = [list(map(int, input().split())) for _ in range(M)]

LL = [[-1] * 2 for _ in range(N)]
for i in range(M):
  a, b = UB[i]
  a -= 1
  b -= 1
  if D[a] < D[b]:
    LL[b] = [a, i]
  elif D[a] > D[b]:
    LL[a] = [b, i]
  else:
    LL[a] = [b, i]
    LL[b] = [a, i]

DD = [[0] * 2 for _ in range(N)]
for i in range(N):
  DD[i][0] = D[i]
  DD[i][1] = i
DD.sort()
L = [0] * N
H = [0] * M

for i in range(N):
  h, x = DD[i]
  if L[x] == 0:
    if LL[x][0] == -1:
      print(-1)
      exit()
    else:
      n, m = LL[x]
      H[m] = h
      if L[n] == 1:
        L[n] = 1
        L[x] = 2
      else:
        L[n] = 2
        L[x] = 1

for i in range(N):
  if L[i] == 1:
    L[i] = "B"
  else:
    L[i] = "W"
print("".join(list(map(str, L))))
for i in range(M):
  if H[i] == 0:
    print(10 ** 9)
  else:
    print(H[i])
from bisect import bisect

#Aのなかでlより大きな最小の値を得る.Aはソート済み

s = input()
t = input()
a = 'abcdefghijklmnopqrstuvwxyz'
d = {}
for ch in a:
  d[ch] = []
for ch,n in zip(s,range(len(s))):
  d[ch].append(n)

rep = 0
p = -1
for ch in t:
  if len(d[ch])==0:
    print("-1")
    exit()
  else:
    i = bisect(d[ch],p)
    if i!=len(d[ch]):p=d[ch][i]
    else:
      p = d[ch][0]
      rep+=1
for i in range(1,len(t)):
  if ret[i] < ret[i-1]:rep+=1

e = len(s) - ret[-1]

print(len(s)*rep - e + 1)

### FIXED CODE ###

from bisect import bisect

#Aのなかでlより大きな最小の値を得る.Aはソート済み

s = input()
t = input()
a = 'abcdefghijklmnopqrstuvwxyz'
d = {}
for ch in a:
  d[ch] = []
for ch,n in zip(s,range(len(s))):
  d[ch].append(n)

rep = 0
p = -1
for ch in t:
  if len(d[ch])==0:
    print("-1")
    exit()
  else:
    i = bisect(d[ch],p)
    if i!=len(d[ch]):p=d[ch][i]
    else:
      p = d[ch][0]
      rep+=1

print(len(s)*rep + p + 1)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]
N, M, C = IA()
B = IA()
A = IM(N)
print(((np.matmul(A, B) + C) > 0).sum())

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

import numpy as np

N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
ans = 0
for _ in range(N):
    A = np.array(list(map(int, input().split())))
    if sum(A * B) + C > 0:
        ans += 1
print(ans)
a, b, c = map(int, input().split(''))

if (a == b):
    print(c)
    exit()
if (b == c):
    print(a)
    exit()
if (a == c):
    print(b)
    exit()

### FIXED CODE ###

a, b, c = map(int, input().split(' '))

#A-B B-C C-A 同じもの以外を出力

if (a == b):
    print(c)
    exit()
if (b == c):
    print(a)
    exit()
if (a == c):
    print(b)
    exit()
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y)//gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

L = [-1] * N
D = [0] * K
D[A[0] % K] = 1
t = A[0] % K
L[0] = t
for i in range(1, min(K - 1, N)):
  t = (t + A[i] - 1) % K
  if t < 0:
    t += K
  D[t] += 1
  L[i] = t

n = 1
ans = D[n]
for i in range(N):
  if L[i] != -1:
    D[L[i]] -= 1
  if i + K - 1 < N:
    t = (t + A[i + K - 1] - 1) % K
    if t < 0:
      t += K
    D[t] += 1
    L[i + K - 1] = t
  n = (n - 1 + A[i]) % K
  #n -= 1
  if n < 0:
    n += K
  ans += D[n]
  
print(ans)

### FIXED CODE ###

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

if K == 1:
  print(0)
  exit()

L = [-1] * N
D = {}
D[A[0] % K] = 1
t = A[0] % K
L[0] = t
for i in range(1, min(K - 1, N)):
  t = (t + A[i] - 1) % K
  if t < 0:
    t += K
  if t in D:
    D[t] += 1
  else:
    D[t] = 1
  L[i] = t

n = 1
if n in D:
  ans = D[n]
else:
  ans = 0
for i in range(N):
  if L[i] != -1:
    D[L[i]] -= 1
  if i + K - 1 < N:
    t = (t + A[i + K - 1] - 1) % K
    if t < 0:
      t += K
    if t in D:
      D[t] += 1
    else:
      D[t] = 1
    L[i + K - 1] = t
  n = (n - 1 + A[i]) % K
  #n -= 1
  if n < 0:
    n += K
  if n in D:
    ans += D[n]
  
print(ans)
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
if m == 0:
return true
if i >= n and m > sum(A)
return false
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res

for m in M
   if res = solve(0,m):
      print 'yes'
   else:
      print 'no'

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
   if m == 0:
     return True
   if i >= n or m > sum(A):
     return False
   res = solve(i + 1, m) or solve(i + 1, m - A[i])
   return res

for m in M:
  if solve(0,m):
     print "yes"
  else:
     print "no"
from itertools import product

H, W = map(int, input().split())
S = [input() for _ in range(H)]
G = [[float("inf")]*W for _ in range(H)]
G[0][0] = 1

for _  i, j in product(range(H*W), range(H), range(W)) :
    if S[i][j] == "." :
        for x, y in [(1, 0), (0, 1), (-1, 0), (0, -1)] :
            try :
                G[i][j] = min(1+G[i+x][j+y], G[i][j])
            except : pass

d = sum(s.count(".") for s in S)
a = d-G[-1][-1]
print(-1 if a==-float("inf") else a)

### FIXED CODE ###

H,W=map(int,input().split());S=[input() for _ in range(H)];G=[[-1]*W for _ in range(H)];G[0][0]=1;q=[(0,0)]
while q:
 i,j=q[0];q=q[1:]
 for x,y in[(1,0),(0,1),(-1,0),(0,-1)]:
  t,u=i+x,j+y
  if 0<=t<H and 0<=u<W and G[t][u]<0 and S[t][u]==".":
   G[t][u]=1+G[i][j];q+=[(t,u)]
print(-1*(G[-1][-1]<0)or sum(s.count(".")for s in S)-G[-1][-1])
N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(S[0],S[N-1]):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

### FIXED CODE ###

N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(min(S)-100,max(S)+100):
    summ = 0
    for j in range(0,N):#実際にsumを求める
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))
S = input()
N = len(S)

l = [0] * 2019
for i in range(N):
    l[int(S[i:N])%2019] += 1

ans = l[0]

for i in range(1, 2019):
    ans += l[i] * (l[i]-1) // 2

print(ans)

### FIXED CODE ###

S, W = map(int, input().split())

if W >= S:
    print('unsafe')
else:
    print('safe')
a = map(int,input(),split())
print((a.sort())[0:2])

### FIXED CODE ###

a = map(int,input().split())
print(sum((sorted(a))[0:2]))