Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
if N % 500 <= A
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())
A = int(input())
if N % 500 <= A:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
a,b = int(input().split('-'))
if len(a) == A and len(b) == B:
  print('Yes')
else:
  print('No')

Fixed submission:
A,B = map(int, input().split())
a= input().split('-')
if len(a[0]) == A and len(a[1]) == B:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
weight = input().split(" ")
if weight[0] + weight[1] > weight[2] + weight[3]:
  print("Left")
elif weight[0] + weight[1] = weight[2] + weight[3]:
  print("Balanced")
else:
  print("Right")

Fixed submission:
weight = input().split(" ")
if int(weight[0]) + int(weight[1]) > int(weight[2]) + int(weight[3]):
  print("Left")
elif int(weight[0]) + int(weight[1]) == int(weight[2]) + int(weight[3]):
  print("Balanced")
else:
  print("Right")
Buggy python submission (verdict: Runtime Error):
a = list(int(input()))
count = 0
for i in range(len(a)):
  if a[i] == 1:
    count += 1
print(count)

Fixed submission:
a = list(input())
count = 0
for i in range(len(a)):
  if a[i] == "1":
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
nums = int(input().split())
count = 0
while all(num%2==0 for num in nums):
  for i in range(len(nums)):
    nums[i] = nums[i]/2
    count += 1
print(count)

Fixed submission:
N = input()
nums = input().split()
count = 0
while all(int(num) % 2 == 0 for num in nums):
  for i in range(len(nums)):
    nums[i] = int(nums[i]) // 2
  count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
N = list(n)
sum = 0
for i in range(len(N)):
  sum += N[i]
  
if n % sum == 0:
  print("Yes")
else:
  print("No")


Fixed submission:
n = input()
N = list(n)
sum = 0
for i in range(len(N)):
  sum += int(N[i])
  
if int(n) % sum == 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
N = list(int(input()))
sum = 0
for i in range(len(N)):
  sum += N[i]
  
if n % sum == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
n = input()
N = list(n)
sum = 0
for i in range(len(N)):
  sum += int(N[i])
  
if int(n) % sum == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = list(map(int, input().split()))
if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3]):
  print("Yes")
else:
  print("No")
         


Fixed submission:
N = list(input())
if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3]):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N = list(map(int, input().split()))
if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
  print("Yes")
else:
  print("No")
         

Fixed submission:
N = list(input())
if (N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = [2,1]
for i in range(2,N):
  a = ans[i-2] + ans[i-1]
  ans.append(a)
print(ans[len(ans)])
  

Fixed submission:
N = int(input())
ans = [2,1]
for i in range(2,N+1):
  a = ans[i-2] + ans[i-1]
  ans.append(a)
print(ans[len(ans)-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for i in range(1, N+1):
  if int(i**0.5)**2 == i:
    ans = i
print(ans)


Fixed submission:
N = int(input())
for i in range(N,0, -1):
  if int(i**0.5)**2 == i:
    print(i)
    break

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for i in range(1, N+1):
  if int(i**0.5)**2 == i:
    ans = i
print(ans)

Fixed submission:
N = int(input())
for i in range(N,0, -1):
  if int(i**0.5)**2 == i:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
A,B,C,D = map(int, input().split())
if C < B:
  if D < B:
    print(D-C)
  else:
	print(B-C)
else:
  print(0)


Fixed submission:
A,B,C,D = map(int, input().split())
print(max(min(B,D)-max(A,C), 0))
Buggy python submission (verdict: Runtime Error):
number = "".join(input())
if int(number) % 4 == 0:
  print("YES")
else:
  print("NO")



Fixed submission:
number = list(map(str, input().split(" ")))
N = "".join(number)
if int(N) % 4 == 0:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
number = "".join(int(input()))
if number % 4 == 0:
  print("YES")
else:
  print("NO")



Fixed submission:
number = list(map(str, input().split(" ")))
N = "".join(number)
if int(N) % 4 == 0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
a,b,c = map(str, input().split())
print(str(a[0].uppercase)+str(b[0].uppercase)+str(c[0].uppercase))

Fixed submission:
a,b,c = map(str, input().split())
print(str(a[0].upper())+str(b[0].upper())+str(c[0].upper()))
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
print(sum(A,B)%24)

Fixed submission:
A,B = map(int, input().split())
print((A+B) % 24)
Buggy python submission (verdict: Runtime Error):
W,a,b = map(int,input().split())
start = max(a, b)
end = min(a+W, b+W)
print(max(start-end), 0)


Fixed submission:
W,a,b = map(int,input().split())
start = max(a, b)
end = min(a+W, b+W)
print(max(start-end, 0))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 1
for i in range(1,N+1):
  ans *= i
print(ans%(10**9+7))  

Fixed submission:
N = int(input())
ans = 1
for i in range(1,N+1):
  ans = ans * i %(10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
if A != 1 and B != 1:
	if A > B:
  	  print("Alice")
	elif B > A:
  	  print("Bob")
	elif A == B:
      print("Draw")
else:
  if A == 1:
    print("Alice")
  else:
   	print("Bob")

Fixed submission:
A, B = map(int, input().split())
if A != 1 and B != 1 and A > B:
  	print("Alice")
elif  A != 1 and B != 1 and B > A:
    print("Bob")
elif A == B:
    print("Draw")
elif A == 1:
    print("Alice")
else:
    print("Bob")
Buggy python submission (verdict: Runtime Error):
A, op, B = map(str, inpit().split())
if op == "+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))

Fixed submission:
A, op, B = map(str, input().split())
if op == "+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
Buggy python submission (verdict: Runtime Error):
AtCoder, s, Contest = map(str, input().split())
print(A + str(s[0]) + C)


Fixed submission:
AtCoder, s, Contest = map(str, input().split())
print("A" + str(s[0]) + "C")
Buggy python submission (verdict: Runtime Error):
candy = input().split(" ")
if sum(candy)-max(candy) == max(candy):
  print("Yes")
else:
  print("No")

Fixed submission:
candy = list(map(int, input().split(" ")))
if sum(candy)-max(candy) == max(candy):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = list(input())
ans = []
for i in s:
  if i == '0':
    ans.append('0')
  elif i == '1':
    ans.append('1')
  else:
    ans.pop()
print("".join(ans))
  

Fixed submission:
s = list(input())
ans = []
for i in s:
  if i == '0':
    ans.append('0')
  elif i == '1':
    ans.append('1')
  else:
    if len(ans) == 0:
      pass
    else:
      ans.pop()
print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
for i in range(n):
    tmp=input()
    if not tmp in s:
        s.append(tmp)
print(len(s))

Fixed submission:
n=int(input())
s={}
for i in range(n):
    tmp=input()
    if tmp in s:
        s[tmp]+=1
    else:
        s[tmp]=1
print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s={}
ans=[]
max=0
for i in range(n):
    st=input()
    if st in s:
        s[st]+=1
    else:
        s[st]=1
    if max<s[st]:
        max=s[st]
        ans=[st]
    elif max==s[st]:
        if not st in ans:
            ans.append(st)
ans.sort()
for i in ans:
    print(i)

Fixed submission:
n=int(input())
s={}
ans=[]
max=0
for i in range(n):
    st=input()
    if st in s:
        s[st]+=1
    else:
        s[st]=1
    if max<s[st]:
        max=s[st]
        ans=[st]
    elif max==s[st]:
        ans.append(st)
ans.sort()
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s={}
for i in range(n):
    st=input()
    if st in s:
        s[st]+=1
    else:
        s[st]=1
ans=[kv[0] for kv in s.items() if kv[1] == max(s.values())]
ans.sort()
for i in ans:
    print(i)

Fixed submission:
n=int(input())
s={}
ans=[]
max=0
for i in range(n):
    st=input()
    if st in s:
        s[st]+=1
    else:
        s[st]=1
    if max<s[st]:
        max=s[st]
        ans=[st]
    elif max==s[st]:
        ans.append(st)
ans.sort()
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b=map(int,input().strip().split())
print(lcm(a, b))

Fixed submission:
import fractions
 
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
a,b=map(int,input().strip().split())
print(lcm(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(p) for p in input().split()]
Result = 1

for i in A:
    Result = Result*i

if(Result > 10**18):
    Result = -1
print(Result)


Fixed submission:
N = int(input())
A = [int(p) for p in input().split()]
Result = 1

if(0 in A):
    print("0")
    exit()

for i in A:
    Result = Result*i
    if(Result > 10**18):
        Result = -1
        break

print(Result)
Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())

if(S > W):
    print(safe)
else:
    print(unsafe)

Fixed submission:
S, W = map(int, input().split())

if(S > W):
    print("safe")
else:
    print("unsafe")
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import math

K = int(input())
sum = 0
kl = range(1, K+1)
combdict = {}

for i in kl:
    for j in kl:
        for k in kl:
            sum += math.gcd(i, math.gcd(j, k))
print(sum)

Fixed submission:
import math

K = int(input())
sum = 0
kl = range(1, K+1)

for i in kl:
    for j in kl:
        for k in kl:
            sum += math.gcd(i, math.gcd(j, k))
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def other(a, b):
    if(a!="R" and b!="R"):
        return "R"
    if(a!="G" and b!="G"):
        return "G"
    if(a!="B" and b!="B"):
        return "B"


N = int(input())
S = str(input())
counterList = []

for i in range(N):
    counterList.append(collections.Counter(S[i:]))

result = 0
for j in range(1, N-1):
    for i in range(j):
        if(S[i] != S[j]):
            key = other(S[i], S[j])
            result += counterList[j][key]
            if(2*j-i < N):
                if(S[2*j-i] == key):
                    result -= 1
print(result) 

Fixed submission:
import collections

def other(a, b):
    if(a!="R" and b!="R"):
        return "R"
    if(a!="G" and b!="G"):
        return "G"
    if(a!="B" and b!="B"):
        return "B"


N = int(input())
S = str(input())
counterList = []

for i in range(N):
    counterList.append(collections.Counter(S[i:]))

result = 0
for j in range(1, N-1):
    for i in range(j):
        if(S[i] != S[j]):
            key = other(S[i], S[j])
            result += counterList[j][key]
            if(2*j-i < N):
                if(S[2*j-i] == key):
                    result -= 1
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

S = deque(list(str(input())))
Q = int(input())
flag = False

for i in range(Q):
    Query =  [str(p) for p in input().split()]
    if(int(Query[0]) == 1):
        flag = not(flag)
    else:
        if(int(Query[1]) == 1):
            if(flag):
                S.reverse()
                flag = not(flag)
            S.appendleft(Query[2])
        else:
            if(flag):
                S.reverse()
                flag = not(flag)
            S.append(Query[2])

if(flag):
    S.reverse()

print("".join(list(S)))

Fixed submission:
from collections import deque

S = deque(list(str(input())))
Q = int(input())
flag = False

for i in range(Q):
    Query =  [str(p) for p in input().split()]
    if(int(Query[0]) == 1):
        flag = not(flag)
    else:
        if(int(Query[1]) == 1):
            if(flag):
                S.append(Query[2])
            else:
                S.appendleft(Query[2])
        else:
            if(flag):
                S.appendleft(Query[2])
            else:
                S.append(Query[2])

if(flag):
    S.reverse()

print("".join(list(S)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

S = deque(list(str(input())))
Q = int(input())

for i in range(Q):
    Query =  [str(p) for p in input().split()]
    if(int(Query[0]) == 1):
        S.reverse()
    else:
        if(int(Query[1]) == 1):
            S.appendleft(Query[2])
        else:
            S.append(Query[2])

print("".join(list(S)))

Fixed submission:
from collections import deque

S = deque(list(str(input())))
Q = int(input())
flag = False

for i in range(Q):
    Query =  [str(p) for p in input().split()]
    if(int(Query[0]) == 1):
        flag = not(flag)
    else:
        if(int(Query[1]) == 1):
            if(flag):
                S.append(Query[2])
            else:
                S.appendleft(Query[2])
        else:
            if(flag):
                S.appendleft(Query[2])
            else:
                S.append(Query[2])

if(flag):
    S.reverse()

print("".join(list(S)))
Buggy python submission (verdict: Time Limit Exceeded):
A = [int(a) for a in input().split()]
N = A[0]
K = A[1]

P = [int(p) for p in input().split()]

raw_max = 0
maxnum = 0

for i in range(N-K+1):
    tmp = sum(P[i:i+K])
    if(raw_max < tmp):
        raw_max = tmp
        maxnum = i

ev_max = [(n+1)/2 for n in P[maxnum:maxnum+K]]

print(sum(ev_max))

Fixed submission:
A = [int(a) for a in input().split()]
N = A[0]
K = A[1]

P = [int(p) for p in input().split()]

raw_max = sum(P[0:K])
maxnum = 0
sum_tmp = sum(P[0:K])

for i in range(1, N-K+1):
    sum_tmp = sum_tmp - P[i-1] + P[i+K-1]
    if(raw_max < sum_tmp):
        raw_max = sum_tmp
        maxnum = i

ev_max = [(n+1)/2 for n in P[maxnum:maxnum+K]]

print(sum(ev_max))
Buggy python submission (verdict: Runtime Error):
N = input()
s = list(str(input()))

count = 0

for i in range(len(s)-2):
    if(s[i]+s[i+1]+s[i+2]=="ABC"):
        count += 1

print(count)

Fixed submission:
S = input().split()
K = int(S[0])
X = int(S[1])

if(500*K >= X):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial

n = int(input())
strlist = []
for i in range(n):
    strlist.append(list(str(input())))

allcount = 0
while (len(strlist) > 1):
    i = 1
    count = 1
    while True:
        if(set(strlist[0]) == set(strlist[i])):
            count += 1
            strlist.pop(i)
        else:
            i += 1
        if(i==len(strlist)):
            if(count > 1):
                allcount += int(factorial(count) / factorial(2) / factorial(count-2))
            break
    strlist.pop(0)
print(allcount)


Fixed submission:
row = input().split()
a = int(row[0])
b = int(row[1])

print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())

for _ in range(3):
    if n % 10 == 7:
        print('Yes')
        sys.exit(1)
    n = n // 10
print('No')

Fixed submission:
import sys
n = int(input())

for _ in range(3):
    if n % 10 == 7:
        print('Yes')
        sys.exit(0)
    n = n // 10
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == "__main__":
    h, w, k = map(int, input().split())
    s = []

    for _ in range(h):
        si = input()
        s.append(si)
    
    h_split = [0] * (h - 1)
    part = 0
    ans = float('inf')
    for mask in range(1 << (h - 1)):
        g = 0
        g_id = [0] * h
        for i in range(h):
            g_id[i] = g
            if mask >> i & 1 == 1:
                g += 1
        g += 1

        c = []
        for _ in range(g):
            c.append([0] * w)
        
        for i in range(h):
            for j in range(w):
                if s[i][j] == "1":
                    c[g_id[i]][j] += 1
        num = g - 1
        now = [0] * g

        for j in range(w):
            for i in range(g):
                now[i] += c[i][j]
            ok = True
            for i in range(g):
                if now[i] > k:
                    ok = False

            if not ok:
                num += 1
                now = [0] * g
                for i in range(g):
                    now[i] += c[i][j]
                ok = True
                for i in range(g):
                    if now[i] > k:
                        ok = False
                if not ok:
                    num = float('inf')
                    break
        ans = min(ans, num)
    print(ans)

Fixed submission:
if __name__ == "__main__":
    h, w, k = map(int, input().split())
    s = []

    for _ in range(h):
        si = input()
        s.append(si)
    
    h_split = [0] * (h - 1)
    part = 0
    ans = float('inf')
    for mask in range(1 << (h - 1)):
        g = 0
        g_id = [0] * h
        for i in range(h):
            g_id[i] = g
            if mask >> i & 1 == 1:
                g += 1
        g += 1

        c = []
        for _ in range(g):
            c.append([0] * w)
        
        for i in range(h):
            for j in range(w):
                if s[i][j] == "1":
                    c[g_id[i]][j] += 1
        num = g - 1
        now = [0] * g

        for j in range(w):
            for i in range(g):
                now[i] += c[i][j]
            ok = True
            for i in range(g):
                if now[i] > k:
                    ok = False

            if not ok:
                num += 1
                now = [0] * g
                for i in range(g):
                    now[i] += c[i][j]
                ok = True
                for i in range(g):
                    if now[i] > k:
                        ok = False
                if not ok:
                    num = float('inf')
                    break
        ans = min(ans, num)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

if __name__ == "__main__":
    a, b = map(int,input().split())
    print(a * b // math.gcd(a,b))

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b


if __name__ == "__main__":
    a, b = map(int,input().split())
    print(a * b // gcd(a,b))
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    mod = 1000000007

    for i in range(60):
        x = 0
        for j in range(n):
            if a[j] >> i & 1:
                x += 1
        
        now = x * (n - x) % mod
        for j in range(i):
            now = now * 2 % mod
        ans += now
        ans %= mod
    print(ans)

Fixed submission:
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    mod = 1000000007

    for i in range(60):
        x = 0
        for j in range(n):
            if a[j] >> i & 1:
                x += 1
        
        now = x * (n - x) % mod
        for j in range(i):
            now = now * 2 % mod
        ans += now
        ans %= mod
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

spots = [int(input()) for _ in range(5)]
k = int(input())

for i in range(5):
    for j in range(i + 1, 5):
        distance = spots[j] - spots[i]
        if (distance > k):
            print(":(")
            sys.exit(1)

print("Yay!")        

Fixed submission:
import sys

spots = [int(input()) for _ in range(5)]
k = int(input())

for i in range(5):
    for j in range(i + 1, 5):
        distance = spots[j] - spots[i]
        if (distance > k):
            print(":(")
            sys.exit()

print("Yay!")
Buggy python submission (verdict: Runtime Error):
from collections import deque
if __name__ == "__main__":
    h, w = map(int, input().split())
    grid = []
    for _ in range(h):
        grid.append(input())
    
    white = 0
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                white += 1
    
    qu = deque()
    qu.append(((0, 0), 0))
    
    visited = [[False] * w for _ in range(h)]
    visited[0][0] = True
    ans = 0

    while True:
        now, dis = qu.pop()
        if now[0] == h-1 and now[1] == w-1:
            ans = white - dis - 1
            break

        if now[0] + 1 < h and grid[now[0] + 1][now[1]] != "#" and not visited[now[0] + 1][now[1]]:
            visited[now[0] + 1][now[1]] = True
            qu.appendleft(((now[0] + 1, now[1]), dis + 1))
        
        if now[0] - 1 >= 0 and grid[now[0] - 1][now[1]] != "#" and not visited[now[0] - 1][now[1]]:
            visited[now[0] - 1][now[1]] = True
            qu.appendleft(((now[0] - 1, now[1]), dis + 1))

        if now[1] + 1 < w and grid[now[0]][now[1] + 1] != "#" and not visited[now[0]][now[1] + 1]:
            visited[now[0]][now[1] + 1] = True
            qu.appendleft(((now[0], now[1] + 1), dis + 1))
        
        if now[1] - 1 >= 0 and grid[now[0]][now[1] - 1] != "#" and not visited[now[0]][now[1] - 1]:
            visited[now[0]][now[1] - 1] = True
            qu.appendleft(((now[0], now[1] - 1), dis + 1))
    print(ans)

Fixed submission:
from collections import deque
if __name__ == "__main__":
    h, w = map(int, input().split())
    grid = []
    for _ in range(h):
        grid.append(input())
    
    white = 0
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                white += 1
    
    qu = deque()
    qu.append(((0, 0), 0))
    
    visited = [[False] * w for _ in range(h)]
    visited[0][0] = True
    ans = -1

    while qu:
        now, dis = qu.pop()
        if now[0] == h-1 and now[1] == w-1:
            ans = white - dis - 1
            break

        if now[0] + 1 < h and grid[now[0] + 1][now[1]] != "#" and not visited[now[0] + 1][now[1]]:
            visited[now[0] + 1][now[1]] = True
            qu.appendleft(((now[0] + 1, now[1]), dis + 1))
        
        if now[0] - 1 >= 0 and grid[now[0] - 1][now[1]] != "#" and not visited[now[0] - 1][now[1]]:
            visited[now[0] - 1][now[1]] = True
            qu.appendleft(((now[0] - 1, now[1]), dis + 1))

        if now[1] + 1 < w and grid[now[0]][now[1] + 1] != "#" and not visited[now[0]][now[1] + 1]:
            visited[now[0]][now[1] + 1] = True
            qu.appendleft(((now[0], now[1] + 1), dis + 1))
        
        if now[1] - 1 >= 0 and grid[now[0]][now[1] - 1] != "#" and not visited[now[0]][now[1] - 1]:
            visited[now[0]][now[1] - 1] = True
            qu.appendleft(((now[0], now[1] - 1), dis + 1))
    print(ans)