Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02754 (python)

Fixed submission:
import numpy as np

NAB=np.array(input().split(" "),dtype=np.int64)

N=NAB[0]
A=NAB[1]
B=NAB[2]

div=int(N//(A+B))
mod=N%(A+B)

blue=0
if(mod<=A):
    blue=mod
else:
    blue=A

print(A*div+blue)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
NAB=np.array(input().split(" "),dtype=np.int32)
 
N=NAB[0]
A=NAB[1]
B=NAB[2]
 
div=int(N/(A+B))
mod=N%(A+B)
 
blue=0
if(mod<=A):
    blue=mod
else:
    blue=A
 
print(A*div+blue)
import numpy as np

NAB=np.array(input().split(" "),dtype=np.int32)

N=NAB[0]
A=NAB[1]
B=NAB[2]

div=int(N/(A+B))
mod=N%(A+B)

blue=0
if(mod<A):
    blue=mod
else:
    blue=A

print(A*div+blue)
提出情報
提出日時	2020-03-07 21:19:42
問題
Problem p02729 (python)

Fixed submission:
import sys
import math
import collections
from collections import deque
#n = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
#x = list(map(int, sys.stdin.readline().split()))

if n <= 1:
    a = 0
else:
    a = math.factorial(n) // (math.factorial(n - 2) * 2)

if m <= 1:
    b = 0
else:
    b = math.factorial(m) // (math.factorial(m - 2) * 2)

print(a+b)

Buggy submission (verdict: Runtime Error):
import sys
import math
import collections
from collections import deque
#n = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
#x = list(map(int, sys.stdin.readline().split()))

a = math.factorial(n) // (math.factorial(n - 2) * 2)
b = math.factorial(m) // (math.factorial(m - 2) * 2)

print(a+b)
Problem p02793 (python)

Fixed submission:
import fractions
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
 
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
 
c = 0
for i in range(n):
    b = ans // a[i]
    c += b
 
print(c % mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
 
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
 
c = 0
for i in range(n):
    b = ans // a[i]
    c += b
 
print(c % mod)
Problem p02695 (python)

Fixed submission:
from itertools import combinations_with_replacement
from collections import defaultdict


def main():
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]

    ll = list(combinations_with_replacement(range(1, m+1), n))

    ans = 0
    for l in ll:
        tmp = 0
        for data in abcd:
            if l[data[1]-1] - l[data[0]-1] == data[2]:
                tmp += data[3]
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from itertools import product
from collections import defaultdict


def main():
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]

    m_list = defaultdict(list)

    for i in range(1, m+1):
        m_list[i].append(0)

    for data in abcd:
        for i in range(1, m+1):
            for j in range(i+1, m+1):
                if j - i == data[2]:
                    if m_list[data[0]][0] == 0:
                        m_list[data[0]] = [i]
                    else:
                        m_list[data[0]].append(i)
                    if m_list[data[1]][0] == 0:
                        m_list[data[1]] = [j]
                    else:
                        m_list[data[1]].append(j)

    ll = list(product(*m_list.values()))

    ans = 0
    for l in ll:
        tmp = 0
        for data in abcd:
            if l[data[1]-1] - l[data[0]-1] == data[2]:
                tmp += data[3]
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from itertools import product
from collections import defaultdict


def main():
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]

    m_list = defaultdict(list)

    for i in range(1,m+1):
        m_list[i].append(0)

    for data in abcd:
        for i in range(1, m+1):
            for j in range(i+1, m+1):
                if j - i == data[2]:
                    m_list[data[0]].append(i)
                    m_list[data[1]].append(j)

    ll = list(product(*m_list.values()))

    ans = 0
    for l in ll:
        tmp = 0
        for data in abcd:
            if l[data[1]-1] - l[data[0]-1] == data[2]:
                tmp += data[3]
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()
Problem p03208 (python)

Fixed submission:
if __name__ == "__main__":
    N, K = map(int, input().split())
    h = list()
    for i in range(N):
        h.append(int(input()))

    h = sorted(h)

    res = 10 ** 9 + 1
    for i in range(N-K+1):
        if res > h[i+K-1] - h[i]:
            res = h[i+K-1] - h[i]
    
    print(res)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    N, K = map(int, input().split())
    h = list()
    for i in range(N):
        h.append(int(input()))

    h = sorted(h)

    res = 10 ** 9 + 1
    for i in range(N-K + 1):
        if res > h[i] - h[i+K]:
            res = h[i] - h[i+K]
    
    print(res)
Problem p02859 (python)

Fixed submission:
N = int(input())
print(N**2)

Buggy submission (verdict: Runtime Error):
import numpy as np
def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 10**6
fact, invfact = make_fact(U,MOD)

MOD = 10**9 + 7
X, Y = [int(x) for x in input().split()]
if (X+Y) % 3 != 0:
    print(0)
    exit()
r = (X+Y) // 3
k = X - r
if (k < 0 or Y - r < 0):
    print(0)
else:
    print(fact[r] * invfact[r-k] % MOD * invfact[k] % MOD)
Problem p02862 (python)

Fixed submission:
import numpy as np
def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 10**6
MOD = 10**9 + 7
fact, invfact = make_fact(U,MOD)

X, Y = [int(x) for x in input().split()]
if (X+Y) % 3 != 0:
    print(0)
    exit()
r = (X+Y) // 3
k = X - r
if (k < 0 or Y - r < 0):
    print(0)
else:
    print(fact[r] * invfact[r-k] % MOD * invfact[k] % MOD)

Buggy submission (verdict: Runtime Error):
import numpy as np
def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

U = 10**6
fact, invfact = make_fact(U,MOD)

MOD = 10**9 + 7
X, Y = [int(x) for x in input().split()]
if (X+Y) % 3 != 0:
    print(0)
    exit()
r = (X+Y) // 3
k = X - r
if (k < 0 or Y - r < 0):
    print(0)
else:
    print(fact[r] * invfact[r-k] % MOD * invfact[k] % MOD)

Buggy submission (verdict: Runtime Error):
import math
MOD = 10**9 + 7
X, Y = [int(x) for x in input().split()]
if (X+Y) % 3 != 0:
    print(0)
    exit()
r = (X+Y) // 3
k = X - r
fact = [1] * (r+2)
print(math.factorial(r)//(math.factorial(r-k)*math.factorial(k)) %MOD)
Problem p03013 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10**7)
lst = dict({0: 1, 1: 1, 2: 2})
def calc(n):
    if (n in lst):
        return lst[n]
    else:
        lst[n] = calc(n-1) + calc(n-2)
        return lst[n]

N, M = [int(x) for x in input().split()]
if (M != 0):
    a_list = [int(input()) for _ in range(M)]
    span_list = [a_list[0]-1]
    for i, a in enumerate(a_list[:-1]):
        if (a_list[i+1] - a) == 1:
            print(0)
            exit()
        else:
            span_list.append(a_list[i+1] - 2 - a)
    span_list.append(N - a_list[-1] -1)
else:
    span_list = [N]
max_span = max(span_list)
for i in range(max_span+1):
    calc(i)
ans = 1
for span in span_list:
    ans = (ans * lst[span]) % (10**9+7)
print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
N, M = [int(x) for x in input().split()]
if (M != 0):
    a_list = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
dp[0] = 1
dp[1] = int(not (1 in a_list))
for i in range(2, N+1):
    if (i not in a_list):
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N])

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit
setrecursionlimit(10**7)
lst = dict({0: 1, 1: 1, 2: 2})
def calc(n):
    if (n in lst):
        return lst[n]
    else:
        lst[n] = calc(n-1) + calc(n-2)
        return lst[n]

N, M = [int(x) for x in input().split()]
a_list = [int(input()) for _ in range(M)]
span_list = [a_list[0]-1]
for i, a in enumerate(a_list[:-1]):
    if (a_list[i+1] - a) == 1:
        print(0)
        exit()
    else:
        span_list.append(a_list[i+1] - 2 - a)
span_list.append(N - a_list[-1] -1)
max_span = max(span_list)
for i in range(max_span+1):
    calc(i)
ans = 1
for span in span_list:
    ans = (ans * lst[span]) % (10**9+7)
print(ans)

Buggy submission (verdict: Runtime Error):
lst = dict({0: 1, 1: 1, 2: 2})
def calc(n):
    if (n in lst):
        return lst[n]
    else:
        lst[n] = calc(n-1) + calc(n-2)
        return lst[n]

N, M = [int(x) for x in input().split()]
a_list = [int(input()) for _ in range(M)]
span_list = [a_list[0]-1]
ans = -1
for i, a in enumerate(a_list[:-1]):
    if (a_list[i+1] - a) == 1:
        ans = 0
    else:
        span_list.append(a_list[i+1] - 2 - a)
if (ans == 0):
    print(ans)
else:
    span_list.append(N - a_list[-1] -1)
    max_span = max(span_list)
    for i in range(max_span+1):
        calc(i)
    ans = 1
    for span in span_list:
        ans = (ans * lst[span]) % (10**9+7)
    print(ans)

Buggy submission (verdict: Runtime Error):
lst = dict({0: 1, 1: 1, 2: 2})
def calc(n):
    if (n in lst):
        return lst[n]
    else:
        lst[n] = calc(n-1) + calc(n-2)
        return lst[n]

N, M = [int(x) for x in input().split()]
a_list = [int(input()) for _ in range(M)]
span_list = [a_list[0]-1]
for i, a in enumerate(a_list[:-1]):
    if (a_list[i+1] - a) == 1:
        print(0)
        exit()
    else:
        span_list.append(a_list[i+1] - 2 - a)
span_list.append(N - a_list[-1] -1)
max_span = max(span_list)
for i in range(max_span+1):
    calc(i)
ans = 1
for span in span_list:
    ans = (ans * lst[span]) % (10**9+7)
print(ans)
Problem p03017 (python)

Fixed submission:
N, A, B, C, D = [int(x) for x in input().split()]
# index変換
A -= 1; B -= 1
S = input()
if (C<D):
    if ("##" in S[A:D]):
        print("No")
    else:
        print("Yes")
else:
    if ("##" not in S[A:C]) and ("..." in S[B-1:D+1]):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N, A, B, C, D = reads()
# index変換
A -= 1; B -= 1
S = input()
if (C<D):
    if ("##" in S[A:D]):
        print("No")
    else:
        print("Yes")
else:
    if ("##" not in S[A:C]) and ("..." in S[A:C]):
        print("Yes")
    else:
        print("No")
Problem p03221 (python)

Fixed submission:
from bisect import bisect_left
N, M = [int(x) for x in input().split()]
PY_list = [[int(x)-1 for x in input().split()] for _ in range(M)]
lst = [[] for _ in range(N)] 
for P, Y in PY_list:
    lst[P].append(Y)
for l in lst:
    l.sort()
for p, y in PY_list:
    print('{:06}{:06}'.format(p+1, bisect_left(lst[p], y)+1))

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]
PY_list = [[int(x)-1 for x in input().split()] for _ in range(M)]
lst = [[] for _ in range(N)] 
for P, Y in PY_list:
    lst[P].append(Y)
for l in lst:
    l.sort()
for i in range(N):
    p, y = PY_list[i]
    print('{:06}{:06}'.format(p+1, lst[p].index(y)+1))
Problem p02701 (python)

Fixed submission:
N = int(input())
S = []
for i in range(N) :
    S.append(input())

print(len(set(S)))

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++) {
        cin >> S.at(i);
    }
    sort(S.begin(),S.end());
    S.erase(unique(S.begin(),S.end()),S.end());
    cout << (int)S.size() << endl;
}
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
print(6-a-b)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
print(6-a-b)
Problem p02753 (python)

Fixed submission:
s = input()
print('No' if (s == 'AAA' or s == 'BBB') else 'Yes')

Buggy submission (verdict: Runtime Error):
print('Yes' if all(input().count(c) > 0 for c in 'AB') else 'No')
Problem p02766 (python)

Fixed submission:
n, k = map(int,input().split())
ans = 0
while (n > 0):
    ans += 1
    n //= k
print(ans + n%k)

Buggy submission (verdict: Runtime Error):
import math
print(math.ceil(math.log(int(input()), int(input()))))
Problem p02835 (python)

Fixed submission:
print('win' if sum(map(int,input().split())) <= 21 else 'bust')

Buggy submission (verdict: Runtime Error):
print('win' if sum(map(int,input())) == 21 else 'bust')

Buggy submission (verdict: Runtime Error):
print('win' if sum(list(map(int,input())))) == 21 else 'bust')

Buggy submission (verdict: Runtime Error):
print "bust" if sum([int(x) for x in input().split()]) > 21 else "win"

Buggy submission (verdict: Runtime Error):
a, b, c = [int(x) for x in input().split()]
print(a+b+c > 21 ? 'bust' : 'win')

Buggy submission (verdict: Runtime Error):
print(sum([int(x) for x in input().split()]) > 21 ? "bust":"win")
Problem p02987 (python)

Fixed submission:
s = input()
a = list(set(s))
print('Yes' if len(a) == 2 and s.count(a[0]) == 2 and s.count(a[1]) == 2 else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
a = set(s)
print('Yes' if len(a) == 2 and s.count(a[0]) == 2 and s.count(a[1]) == 2 else 'No')
Problem p03041 (python)

Fixed submission:
n, k = map(int,input().split())
s = list(input())
s[k-1] = s[k-1].lower()
for c in s:
  print(c, end='')

Buggy submission (verdict: Runtime Error):
n, k = map(int,input())
s = input()
k -= 1
print(s[:k]+s[k].lower()+s[k+1:])
Problem p02623 (python)

Fixed submission:
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    import itertools
    sum_a = list(itertools.accumulate(a))
    sum_b = list(itertools.accumulate(b))
    if sum_a[-1] + sum_b[-1] <= k:
        print(n+m)
        return
    if a[0] > k and b[0] > k:
        print(0)
        return

    for i in range(n):
        if sum_a[i] > k:
            break

    s_a = i - 1
    if sum_a[-1] <= k:
        s_a = n-1
    now_sum = 0
    if s_a >= 0:
        now_sum = sum_a[s_a]
    for i in range(m):
        if now_sum + sum_b[i] > k:
            break
    s_b = i - 1
    ans = s_a + 1 + s_b + 1
    now_sum = 0
    for a_i in range(s_a-1, -2, -1):
        for b_i in range(s_b+1,m):
            if a_i < 0:
                now_sumtime = sum_b[b_i]
            else:
                now_sumtime = sum_a[a_i] + sum_b[b_i]

            if b_i == m-1 and now_sumtime <= k:
                now_sum = a_i + m + 1
                break
            if now_sumtime > k:
                now_sum = a_i + b_i + 1
                break
        s_b = b_i-1
        ans = max(ans, now_sum)
    print(ans)

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    import itertools
    zero = [0]
    sum_a = zero + list(itertools.accumulate(a))
    sum_b = zero + list(itertools.accumulate(b))

    if sum_a[-1] + sum_b[-1] <= k:
        print(n+m)
        return
    if a[1] > k and b[1] > k:
        print(0)
        return

    for i in range(n+1):
        if sum_a[i] > k:
            break
    start_a = i - 1

    for i in range(m+1):
        if sum_b[i] + sum_a[start_a] > k:
            break
    start_b = i - 1

    ans = start_a + start_b
    for a_i in range(start_a-1, -1, -1):
        for b_i in range(start_b, m+1):
            now_sum_time = sum_a[a_i] + sum_b[b_i]
            if now_sum_time > k:
                cnt_b = b_i - 1
                break
            if b_i == m:
                cnt_b = b_i
        ans = max(ans, a_i + cnt_b)
    print(ans)
if __name__=='__main__':
    main()
Problem p02695 (python)

Fixed submission:
import itertools
def main():
    N,M,Q = map(int,input().split())
    q = []
    for i in range(Q):
        a,b,c,d = map(int,input().split())
        q.append([a-1,b-1,c,d])
    A = [i for i in range(1,M+1)]
    # if N==10:
    #
    #     ans = 0
    #     for i, qq in enumerate(q):
    #         if A[qq[1]] - A[qq[0]] == qq[2]:
    #             ans += qq[3]
    #     print(ans)
    #
    # else:
    aa = list(itertools.combinations_with_replacement(A,N))
    ans = 0

    for i, cc in enumerate(aa):
        ans1 = 0
        for j, qq in enumerate(q):
            if cc[qq[1]] - cc[qq[0]] == qq[2]:
                ans1 += qq[3]
            # print(ans1,cc)
        ans = max(ans,ans1)
    print(ans)

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import itertools
def main():
    N,M,Q = map(int,input().split())
    q = []
    for i in range(Q):
        a,b,c,d = map(int,input().split())
        q.append([a-1,b-1,c,d])
    A = [i for i in range(1,M+1)]
    if N==10:

        ans = 0
        for i, qq in enumerate(q):
            if A[qq[1]] - A[qq[0]] == qq[2]:
                ans += qq[3]
        print(ans)

    else:
        aa = list(itertools.combinations(A,N))
        ans = 0

        for i, cc in enumerate(aa):
            ans1 = 0
            for j, qq in enumerate(q):
                if cc[qq[1]] - cc[qq[0]] == qq[2]:
                    ans1 += qq[3]
            # print(ans1,cc)
            ans = max(ans,ans1)
        print(ans)

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import itertools
def main():
    N,M,Q = map(int,input().split())
    q = []
    for i in range(Q):
        a,b,c,d = map(int,input().split())
        q.append([a-1,b-1,c,d])
    A = [i for i in range(1,M+1)]
    if N==10:

        ans = 0
        for i, qq in enumerate(q):
            if A[qq[1]] - A[qq[0]] == qq[2]:
                ans += qq[3]
        print(ans)

    else:
        aa = list(itertools.combinations(A,N))
        ans = 0
        
        for i, cc in enumerate(aa):
            ans1 = 0
            for j, qq in enumerate(q):
                if cc[qq[1]] - cc[qq[0]] == qq[2]:
                    ans1 += qq[3]
            print(ans1,cc)
            ans = max(ans,ans1)
        print(ans)

if __name__=='__main__':
    main()
Problem p02735 (python)

Fixed submission:
def main():
    h,w = map(int, input().split())
    s = []
    for i in range(h):
        ss = list(input())
        s.append(ss)

    now = [0,0]
    cnt = 0
    if s[0][0] == '#':
        cnt += 1
        # s[0][0] = '.'
    

    dp = [[-1] * w for i in range(h)]
    dp[0][0] = cnt

    for i in range(h):
        for j in range(w):
            tmp_up = 100000
            tmp_left = 100000
            change  = 0
            if s[i][j] == '#':
                change = 1
            if i == 0 and j == 0:
                continue
            if i != 0:
                if s[i-1][j] == '#' and s[i][j] == '#':
                    tmp_up = dp[i-1][j]
                else:
                    tmp_up = dp[i-1][j] + change
            if j != 0:
                if s[i][j-1] == '#' and s[i][j] == '#':
                    tmp_left = dp[i][j-1]
                else:

                    tmp_left = dp[i][j-1] + change

            dp[i][j] = min(tmp_up,tmp_left)


    print(dp[h-1][w-1])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    h,w = map(int, input().split())
    s = []
    for i in range(h):
        ss = list(input())
        s.append(ss)

    now = [0,0]
    cnt = 0
    if s[0][0] == '#':
        cnt += 1
        # s[0][0] = '.'
    if s[h-1][w-1] == '#':
        # cnt += 1
        # s[h-1][w-1] = '.'

    dp = [[-1] * w for i in range(h)]
    dp[0][0] = cnt

    for i in range(h):
        for j in range(w):
            tmp_up = 100000
            tmp_left = 100000
            change  = 0
            if s[i][j] == '#':
                change = 1
            if i == 0 and j == 0:
                continue
            if i != 0:
                if s[i-1][j] == '#' and s[i][j] == '#':
                    tmp_up = dp[i-1][j]
                else:
                    tmp_up = dp[i-1][j] + change
            if j != 0:
                if s[i][j-1] == '#' and s[i][j] == '#':
                    tmp_left = dp[i][j-1]
                else:

                    tmp_left = dp[i][j-1] + change

            dp[i][j] = min(tmp_up,tmp_left)


    print(dp[h-1][w-1])
    print(dp)

if __name__ == '__main__':
    main()