Harryxun/stf_run huggingface dataset:
x = input()
list = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']

for i in range(len(list)):
    theday = list[i]
    if x == theday:
        answer = list[i + 1]
print(answer)


### FIXED CODE ###

x = input()
list = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
 
for i in range(len(list) - 1):
    theday = list[i]
    if x == theday:
        answer = list[i + 1]
print(answer)
[K, X] = [int(x) for x in input().split()]
if K * 500 >= X:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

[K, X] = [int(x) for x in input().split()]
if K * 500 >= X:
    print('Yes')
else:
    print('No')
print(char(ord(input()) + 1))

### FIXED CODE ###

print(chr(ord(input()) + 1))
import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = []

for(int i=min(x); i<max(x); i++):
  for j in range(len(x)):
    each = np.power((x[j]-i), 2)
  loss.append(each)
  
print(min(each))

### FIXED CODE ###

import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = 0
ll = []

for k in range(min(x), max(x)+1):
      for j in range(len(x)):
            each = np.power((x[j]-k), 2)
            loss += each
      ll.append(loss)
      loss = 0
  
print(min(ll))
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,k,ans = 0;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    rep(i,k) ans+=p[i];
    cout << ans << endl;
}

### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[:k]))
import sys
input = sys.stdin.readline
D, N = [int(x) for x in input().split()]
ans = []
for i in range(1, 1010000):
    if i % (100 ** D) == 0 and i % (100 ** (D + 1)) != 0:
        ans.append(i)
print(ans[N-1])


### FIXED CODE ###

import sys
input = sys.stdin.readline
D, N = [int(x) for x in input().split()]
ans = []
for i in range(1, 1010001):
    if i % (100 ** D) == 0 and i % (100 ** (D + 1)) != 0:
        ans.append(i)
print(ans[N-1])
input()
print(''.join([s+t for s,t in zip(input(),input())]))

### FIXED CODE ###

N=int(input())
S=input()
print(''.join([S[i]+S[i+N+1] for i in range(N)]))
a,b = map(int,input().split())
b*=100
print(int(a*b/100))

### FIXED CODE ###

a,b = map(float,input().split())
a=int(a)
b=int(100*(b+0.001))
print(a*b//100)
, S = map(int, input().split())

all = []
for x in range(0,K+1):
	if S-x < 0:
		break
	for y in range(0, min(K,S-x)+1):
		z = S-x-y
		if z>-1:
			if z < K+1:
				all.append(str(x)+str(y)+str(z))
		else:
			break

print(len(all))

### FIXED CODE ###

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

cnt = 0
for x in range(0,K+1):
	if S-x < 0:
		break
	for y in range(0, min(K,S-x)+1):
		z = S-x-y
		if z>-1:
			if z < K+1:
				cnt += 1
		else:
			break

print(cnt)
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

while max(x) > -1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(nma+" "+i)
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

mainus = [i for i in x if i < 0]
plus = [i for i in x if i >= 0]
for i in mainus:
  lst.append(str(nma)+" "+str(i))
  nma -= i
for i in plus:
  lst.append(str(nmi)+" "+str(i))
  nmi -= i
lst.append(str(nma)+" "+str(nmi))
print(nma-nmi)
for i in lst:
  print(i)
"""
while max(x) > -1 and len(x) > 1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(str(nma)+" "+str(i))
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)
"""
a, b, c, d = map(int, input().split())

t_hp = a
a_hp = c
while a_hp > 0 or t_hp > 0:
	a_hp -= b
	t_hp -= d
    if a_hp <= 0:
         print("Yes")
         exit()
    elif t_hp <= 0:
         print("No")
         exit()

### FIXED CODE ###

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

t_hp = a
a_hp = c
while a_hp > 0 or t_hp > 0:
    a_hp -= b
    t_hp -= d
    if a_hp <= 0:
         print("Yes")
         exit()
    elif t_hp <= 0:
         print("No")
         exit()
import math
x1, y1, x2, y2 = map(int, input().split())
x = x2 - x1
y = y2 - y1
result = x**2 + y**2
print(math.sqrt(result))

### FIXED CODE ###

import math
x1, y1, x2, y2 = map(float, input().split())
x = x2 - x1
y = y2 - y1

result = x**2 + y**2
print(math.sqrt(result))
import numpy as np


N,M=map(int,input().split())
A=np.array(list(map(int,input().split())))
# A=np.array(list(map(int,input().split())),dtype=np.int64)
A=np.sort(A)

for i in range(M):
    B,C=map(int,input().split())
    for j in range (B):
        count=np.count_nonzero(A<C)
        if count>0:
            m=min(B,count)
            A[:m]=C
        else:
            continue
    
    A=np.sort(A)

print(np.sum(A))

### FIXED CODE ###

import numpy as np


N,M=map(int,input().split())
# A=np.array(list(map(int,input().split())))
A=np.array(list(map(int,input().split())),dtype=np.int32)
A=np.sort(A)

EXC=[]

for i in range(M):
    exc=list(map(int,input().split()))
    EXC.append(exc)
excArry=np.array(EXC,dtype=np.int32)

col_num=1
Arr=excArry[np.argsort(excArry[:,col_num])[::-1]]
# print(A)
# print(Arr)

point=0


for j in range (M):
    change_Num=Arr[j][1]
    count=np.count_nonzero(A<change_Num)
    if count > 0:
        m=min(count,Arr[j][0])
        A[point:point+m]=change_Num
        point+=m
        # A=np.sort(A)
    else:
        break

print(np.sum(A))
    
#     for j in range (B):
#         count=np.count_nonzero(A<C)
#         if count>0:
#             m=min(B,count)
#             A[:m]=C
#         else:
#             continue
    
#     A=np.sort(A)

# print(np.sum(A))
n,a,b = map(int,input().split())
inf = 10**9 +7
ans = pow(2,n,inf)-1
def conbi(n,k):
  if n-k < k:
    k = n-k
  x = 1
  y = 1
  for i in range(k):
    x *= n-i
    x = x%inf
    y *= i+1
    y = y%inf
    ans = x* pow(y,inf-2,inf)%inf
  return ans
ans  -= conbi(n,a) + conbi(n,b)
ans = ans%inf
print(ans)  

### FIXED CODE ###

n,a,b = map(int,input().split())
inf = 10**9 +7
ans = pow(2,n,inf)-1
def conbi(n,k):
  if n-k < k:
    k = n-k
  x = 1
  y = 1
  for i in range(k):
    x *= n-i
    x = x%inf
    y *= i+1
    y = y%inf
  ans = x* pow(y,inf-2,inf)%inf
  return ans
ans  -= conbi(n,a) + conbi(n,b)
ans = ans%inf
print(ans)
import heapq
n=int(input())
d=[]
for i in range(n):
  heapq.heappush(d,int(input()))
for j in range(n):
  if d[j]==d[n-1]:
    print(x[n-2])
  else:
    print(x[n-1])

### FIXED CODE ###

n=int(input())
d=[]
for i in range(n):
  d.append(int(input()))
x=sorted(d)
for j in range(n):
  if d[j]==x[-1]:
    print(x[-2])
  else:
    print(x[-1])
s = int(input())

if s == 1 || s == 2:
    print(4)
elif:
    for i in range(1000000):
        if s == 4:
            print(i + 4)
            break

            
        if s % 2 == 0:
            s = s / 2
        else:
            s = 3 * s + 1
        
    







        



### FIXED CODE ###

s = int(input())

if s == 1 or s == 2:
    print(4)
else:
    for i in range(1000000):
        if s == 4:
            print(i + 4)
            break

            
        if s % 2 == 0:
            s = s / 2
        else:
            s = 3 * s + 1
N,K=input().split()
S=input()
S[K+1].swapcase()
print(S)

### FIXED CODE ###

N,K=map(int,input().split())
S=input()
S=S[:K-1]+S[K-1].swapcase()+S[K:]
print(S)
import sys
sys.setrecursionlimit(10000)

n, k = map(int,input().split())
nck = {}

def c(n,k):
    if k == 0 or n==k:
        return 1
    elif n<k:
        return 0
    elif k == 1:
        return n  
    elif (n,k) in nck:
        return nck[(n,k)]
    else:
        nck[n,k] = c(n-1,k-1)+c(n-1,k)
        return nck[n,k]

for j in range(1,k+1):
    if n == k:
        r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)

### FIXED CODE ###



import sys
sys.setrecursionlimit(10000)

n, k = map(int,input().split())
nck = {}

def c(n, r):
    
    if n<r: return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

for j in range(1,k+1):
    r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)
S = input()

if all(S == "A") or all(S == "B"):
    print("No")
else:
    print("Yes")

### FIXED CODE ###

S = input()

if all(i == "A" for i in S) or all(i == "B" for i in S):
    print("No")
else:
    print("Yes")
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
n=[]
if n>,:
  print(0)
  exit()
for i in range(1,len(x)):  
  for j in range(i,len(x)):
    n.append(abs(x[0]-x[i-1])+abs(x[i]-x[j-1])+abs(x[j]-x[-1]))
print(min(n))


### FIXED CODE ###

n,m=map(int,input().split())
x=list(map(int,input().split()))
l=[]
ans=0
if n<m:
  x.sort()
  for i in range(m-1):
    l.append(x[i+1]-x[i])
  l.sort()
  for j in range(m-n):
    ans+=l[j]
print(ans)
import sys
input = sys.stdin.readline

# 自分の解答
def myAnswer(N:int,dic:dict) -> int: # pythonはlist操作が重いので辞書で処理する
   ans = 0
   for a in dic.values():
      if(a % 2 == 1):
         ans += 1
   return ans
def modelAnswer(N:int,A:list) -> int:
   ans = []
   A.sort()
   for a in A:
      if(a in ans):
         ans.remove(a)
      else:
         ans.append(a)
   return len(ans)

def main():
   N = int(input())
   dic = {}
   for _ in range(N):
      a = int(input())
      if(a in dic.keys()):
         dic[a]+=1
      else:
         dic[a]=1
   print(modelAnswer(N,dic))
if __name__ ==

### FIXED CODE ###

import sys
input = sys.stdin.readline
N=int(input())
ans=dict()
cnt=0

for _ in range(N):
    A=int(input())
    if((A in ans)==False):
        ans[A]=1
    else:
        ans[A]+=1

for value in ans.values():
    if(value%2==1):
        cnt+=1

print(cnt)
# -*- coding: utf-8 -*-
test = input()
a, b, c = test.split()  # 変数a,b,cにそれぞれN、A、Bをint型にして入力する　
x = []
for i in range(1,a+1):  # list型の変数xに１からNまでの要素を入れる
    x.append(i)


len_x = len(x)  # リスト型の変数xの要素数を獲得

d = 0  # リストの各行の和を入れるための変数
f = []  # 各行の和がA以上B以下の要素を入れるための変数
x = map(str, x)  # リストxの書く要素をstr型に変換

for i in range(len_x):
    e = x[i]           # xのi番目の要素を抽出
    e = list(e)  # xのi番目の要素を一文字ずつのstr型としてリスト型の変数に入れる
    e = map(int, e)  # xのi番目の要素をint型に変換
    e_number = len(e)  # リスト型の変数eの要素数を取得
    d = 0              # 位の合計の判定用の変数
    for g in range(e_number):
        d += e[g]  # 位の合計
    if b <= d <= c:  # 位の合計がA以上B以下ならリストfに要素を追加
        f.append(x[i])
answer = 0  # 条件位合う要素の合計を入れる変数
f = map(int, f)
for h in f:  # 要素に合う要素の合計
    answer += h
print(answer)




### FIXED CODE ###

# coding: utf-8
# Your code here!
#-*- coding: utf-8 -*-#
test = input()
a, b, c = map(int, test.split())  # 変数a,b,cにそれぞれN、A、Bをint型にして入力する　
x = []
e = []
for i in range(1,a+1):  # list型の変数xに１からNまでの要素を入れる
    x.append(i)
len_x = len(x)  # リスト型の変数xの要素数を獲得
d = 0  # リストの各行の和を入れるための変数
f = []  # 各行がA以上B以下の要素を入れるための変数
x = map(str, x) # リストxの各要素をstr型に変換
x = list(x)
e_number = 0
for i in range(len_x):
    e = x[i]           # xのi番目の要素を抽出
    e = list(e)  # xのi番目の要素を一文字ずつのstr型としてリスト型の変数に入れる
    e = map(int, e)# xのi番目の要素をint型に変換
    e = list(e)
    e_number = len(e)   # リスト型の変数eの要素数を取得
    d = 0              # 位の合計の判定用の変数
    for g in range(e_number):
        d += e[g-1]  # 位の合計
    if b <= d <= c:  # 位の合計がA以上B以下ならリストfに要素を追加
        f.append(x[i])
answer = 0  # 条件位合う要素の合計を入れる変数
f = map(int, f)
for h in f:
    answer += h  # 要素に合う要素の合計
print(answer)
N, L = map(int, input().split())
S = [input() for i in range(L)]
print(*S, sep='')

### FIXED CODE ###

n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print(*s,sep="")
import numpy as np
N = int(input())
n = N % 2
if n == 1:
  ans = 0
else:
  AB = list(range(N, 1, -2))
  AB = [ab for ab in AB if ab % 10 == 0]
  AB = [np.log10(ab) for ab in AB]
  AB = [int(ab) for ab in AB]
  ans = np.sum(AB)
print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
n2 = N % 2
if n2 != 0:
  ans = 0
elif N <= 2:
  ans =0
else:
  a = int(np.log(N) // np.log(5))
  A = [N // (2 * (5 ** (i + 1))) for i in range(a)]
  ans = np.sum(A)
print(ans)
n = int(input())
a = [map(int, input().split()) for _ in range(n)]

ans = 1
for i in range(n):
  ans = a[i]
  
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr) 
ans=1
for val in arr:
 ans*=val 
 if ans>10**18:
   print(-1)
   break
else:
 print(ans)
import math
N,D = map(int,input().split())
print(math.cell(N/(2*D)))


### FIXED CODE ###

import math
N,D = map(int,input().split())
print(math.ceil(N/(2*D+1)))
import sys

while 1:
  a , b = map(int, sys.stdin.readline().split())

### FIXED CODE ###

import sys

while 1:
  a , b = sys.stdin.readline().split()
  if a == b == "0":
    break
  elif int(a) > int(b) :
    print(b,a)
  else :
    print(a,b)
N,X=map(int,input().split())
if N!=1:
  L=list(map(int,input().split()))
  tot=0
  count=0
  while X>=tot:
    tot+=L[count]
    count+=1
  print(count)
else:
  L=int(input())
  if X>=L:
    print(2)
  else:
    print(1)

### FIXED CODE ###

N,X=map(int,input().split())
if N!=1:
  L=list(map(int,input().split()))
  tot=0
  count=1
  for i in range(N):
    tot+=L[i]
    if X>=tot:
      count+=1
  print(count)
else:
  L=int(input())
  if X>=L:
    print(2)
  else:
    print(1)
H, W, h, w = map(int, input().split())

a = (10 ** 9 - 1) // (h * w - 1)
ret = [[a] * W for _ in range(H)]
for y in range(h - 1, H, h) :
  for x in range(w - 1, W, w) :
    ret[y][x] = - a * (h * w - 1) - 1

s = 0
for y in range(H) :
  s += sum(ret[y])
  
if s > 0 :
  print('Yes')
  for r in ret :
    print(*r)
else :
  print('No')

### FIXED CODE ###

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

if h == w == 1 :
  print('No')

else :
  a = (10 ** 9 - 1) // (h * w - 1)
  ret = [[a] * W for _ in range(H)]
  for y in range(h - 1, H, h) :
    for x in range(w - 1, W, w) :
      ret[y][x] = - a * (h * w - 1) - 1

  s = 0
  for y in range(H) :
    s += sum(ret[y])
    
  if s > 0 :
    print('Yes')
    for r in ret :
      print(*r)
  else :
    print('No')
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    XY=[tuple(map(int,input().split())) for _ in range(n)]
    parity=[0]*2
    for x,y in XY:
        parity[(x+y)%2]=1

    # 双方のparityがあれば不可能
    if(parity[0] and parity[1]):
        print(-1)
        return

    # for output
    m=31
    D=[2**i for i in range(m)]
    W=[None]*m
    # parityが偶数ならば、先に長さ1のRを入れることで、奇数の場合に帰着
    if(parity[0]):
        XY=[(x-1,y) for x,y in XY]
        D.insert(0,1)

    # 45 deg 回転
    U=[x-y for x,y in XY]
    V=[x+y for x,y in XY]

    for j in range(n): # 各 U[i],V[i]に対して方向を定める
        res=[0]*m
        u=(U[j]+pow(2,m)-1)//2
        v=(V[j]+pow(2,m)-1)//2
        for i in range(m):
            ub=u&1; vb=v&1
            if(ub and vb):
                res[i]='R'
            elif(ub and (not vb)):
                res[i]='D'
            elif((not ub) and vb):
                res[i]='U'
            else:
                res[i]='L'
            ub>>=1; vb>>=1
        W[j]=''.join(res)

    # output
    print(m+parity[0])
    print(*D)
    for j in range(n):
        print(W[j] if(parity[1]) else 'R'+W[j])
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    XY=[tuple(map(int,input().split())) for _ in range(n)]
    parity=[0]*2
    for x,y in XY:
        parity[(x+y)%2]=1

    # それぞれのパリティの点が存在すると不可能
    if(parity[0] and parity[1]):
        print(-1)
        return

    m=31
    D=[pow(2,i) for i in range(m)]
    # 偶数の場合は奇数に帰着させる
    if(parity[0]):
        XY=[(x-1,y) for x,y in XY]
        D=[1]+D

    U=[x-y for x,y in XY]
    V=[x+y for x,y in XY]

    W=[0]*n
    for j in range(n):
        res=[0]*m
        u=(U[j]+pow(2,m)-1)//2
        v=(V[j]+pow(2,m)-1)//2
        for i in range(m):
            ub=u&1; vb=v&1
            if(ub and vb):
                res[i]='R'
            elif(ub and (not vb)):
                res[i]='D'
            elif((not ub) and vb):
                res[i]='U'
            else:
                res[i]='L'
            u>>=1; v>>=1
        ans=''.join(res)
        W[j]=ans

    m=m+parity[0]
    print(m)
    print(*D)
    for j in range(n):
        ans=W[j] if(parity[1]) else 'R'+W[j]
        print(ans)
resolve()
def bfs(field,H,W,start_x,start_y,tmp_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * W for i in xrange(H)]
    min_path[start_y][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] != "X" and min_path[ny][nx] == INF:
                min_path[ny][nx] = min_path[current[1]][current[0]] + 1
                if field[ny][nx] == tmp_N:
                    return nx,ny,min_path[ny][nx]
                else:
                    que.append([nx,ny])

def getField():
    matrix = []
    first = raw_input().rstrip()
    H,W,N = map(int,first.split())
    for i in xrange(H):
        row = list(input().strip())
        for j in xrange(W):
            if row[j].isdigit():
                row[j] = int(row[j])
        matrix.append(row)
    return matrix,H,W,N

def getStart(field):
    for y in xrange(len(field)):
        for x in xrange(len(field[0])):
            if field[y][x] == "S":
                return x,y

def main():
    matrix,H,W,N = getField()
    sx,sy = getStart(matrix)
    distance = 0
    tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,sx,sy,1)
    distance += tmp_dist
    tmps = [tmp_x,tmp_y]
    for k in xrange(N-1):
        tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,tmps[0],tmps[1],k+2)
        distance += tmp_dist
        tmps = [tmp_x,tmp_y]
    print distance

if __name__=='__main__':
    main()

### FIXED CODE ###

def bfs(field,H,W,start_x,start_y,tmp_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * W for i in range(H)]
    min_path[start_y][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] != "X" and min_path[ny][nx] == INF:
                min_path[ny][nx] = min_path[current[1]][current[0]] + 1
                if field[ny][nx] == tmp_N:
                    return nx,ny,min_path[ny][nx]
                else:
                    que.append([nx,ny])

def getField():
    matrix = []
    first = input().strip()
    H,W,N = map(int,first.split())
    for i in range(H):
        row = list(input().strip())
        for j in range(W):
            if row[j].isdigit():
                row[j] = int(row[j])
        matrix.append(row)
    return matrix,H,W,N

def getStart(field):
    for y in range(len(field)):
        for x in range(len(field[0])):
            if field[y][x] == "S":
                return x,y

def main():
    matrix,H,W,N = getField()
    sx,sy = getStart(matrix)
    distance = 0
    tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,sx,sy,1)
    distance += tmp_dist
    tmps = [tmp_x,tmp_y]
    for k in range(N-1):
        tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,tmps[0],tmps[1],k+2)
        distance += tmp_dist
        tmps = [tmp_x,tmp_y]
    print(distance)

if __name__=='__main__':
    main()
S = input()
K = int(input())

c = 0
for s in S:
    if s == "1":
        c += 1
    else:
        break

print(S[c])

### FIXED CODE ###

S = input()
K = int(input())

c = 0
for s in S:
    if s == "1":
        c += 1
    else:
        break

print(1 if K <= c else S[c])
a = input()
if a%10 == 3:
  print('bon')
elif a&10 == 0 or 1 or 6 or 8:
  print('pon')
else:
  print('hon')

### FIXED CODE ###

a = int(input())
if a%10 == 3:
  print('bon')
elif a%10 == 0 or a%10 ==1 or a%10 ==6 or a%10 ==8:
  print('pon')
else:
  print('hon')
n = int(input())
a = list(map(int,input().split())
c = 0
for x in range(a[0]+1):
    for y in range(a[1]+1):
        for z in range(a[2]+1):
            t = 500*x + 100*y + 50*z
            if t == a[3]:
                c = c + 1
print(c)

### 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 i*500 + j*100 + k*50 == x:
                count+=1
print(count)
n = int(input())
nums = list(map(int,input().split()))
nums.sort()
ans = 0
cnt = {}
flag = [0]*1000000
for i in range(1,len(nums)):
  if nums[i] == nums[i-1]:
    flag[nums[i]] = 1
    
if flag[nums[0]] == 0:
  ans +=1
    
for i in range(1,len(nums)):
  if flag[nums[i]] == 0:
    ans += 1
  if nums[i] != nums[i-1]:
    n = nums[i]
    while n <1000000:
      flag[n] = 1
      n = n+ nums[i]

print(ans)

### FIXED CODE ###

n = int(input())
nums = list(map(int,input().split()))
nums.sort()
ans = 0
cnt = {}
flag = [0]*1000005
for i in nums:
  cnt[i] = cnt.get(i,0) + 1

for i in nums:
  if flag[i] == 0 and cnt[i] == 1:
    ans += 1
  if flag[i] == 1:
    continue
  for j in range(i,1000001,i):
    flag[j] = 1

print(ans)
from collections import defaultdict

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

dic = defaultdict(int)
for d in D:
    dic[d] += 1

for t in T:
    if dic[t]:
        dic[t] -= 1
    else:
        print ('No')
        exit()

print ('Yes')


### FIXED CODE ###

from collections import defaultdict

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

dic = defaultdict(int)
for d in D:
    dic[d] += 1

for t in T:
    if dic[t]:
        dic[t] -= 1
    else:
        print ('NO')
        exit()

print ('YES')
import numpy as  np
import copy
for i in range(N-K+1):
    
    diff = 0
    print("h[i] is {}".format(h[i]))
    for j in range(K-1):
        if(h[i] >= h[j]):
            target = [a for a in h if a <= h[i] and a >= h[j]]
            print("0")
            exit()
        else :
            target = [a for a in h if a > h[i] and a < h[j]]
        media = (a.pop(np.abs(np.asarray(a) - h[i]).argmin()))
        choose_h =[h[i],h[j],media]
        diff = max(choose_h)-min(choose_h)
        if(diff < candidate):
            candidate = diff
print(candidate)

### FIXED CODE ###

N,K = list(map(int, input().split()))
h = [int(input()) for i in range(N)]
candidate = None
h.sort()
for i in range(N-K+1):
    tmp = h[i+K-1] - h[i]
    if candidate == None or tmp < candidate:
        candidate = tmp
print(candidate)
n, t = list(map(int, input().split()))
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
minCost = 1001
for i in range(n):
    if data[i][1] <= t && minCost > data[i][0]:
        minCost = data[i][0]

if minCost == 1001:
    print("TLE")
else:
    print(minCost)

### FIXED CODE ###

n, t = list(map(int, input().split()))
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
minCost = 1001
for i in range(n):
    if data[i][1] <= t and minCost > data[i][0]:
        minCost = data[i][0]

if minCost == 1001:
    print("TLE")
else:
    print(minCost)
S = int(input())

check = S[2] == S[4] and S[3] == S[5]

print("Yes" if check else "No")

### FIXED CODE ###

S = input()

check = S[2] == S[3] and S[4] == S[5]

print("Yes" if check else "No")