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

Fixed submission:
k = int(input())
a,b=map(int,input().split())
count = 0
for i in range(a,b+1):
    if i%k == 0:
        count += 1
if count == 0:
    print("NG")
else:
    print("OK")

Buggy submission (verdict: Runtime Error):
k = int(input())
n = list(map(int,input().split()))
d = 0
for i in range(a,b+1):
    if i % k == 0:
        
        d = 1
        break
if d == 0:
    print("NG")
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input())
d = 0	
for i in range(a,b+1):
  if i%k == 0:
    d = 3
    break
  else:
    d=0
if d == 3:
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):

k = int(input())
a,b = map(int,input())
d = 0
for i in range(a,b+1):
  if i%k == 0:
    d += 1
    break
  else:
    d = 0
if d == 1:
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input())
d = 0
for i in range(a,b+1):
  if i%k == 0:
    d = 3
    break
  else:
    continue
if d == 3:
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int,input())
d = 0
for i in range(a,b+1):
  if i%k == 0:
    d = 3
    break
if d == 3:
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b =map(int,input().split())
m = []
if a != b:
    for x in range(a,b+1):
        if x%n == 0:
            i = m.append(x)
            break

else:
    i = a%n
    if i == 0:
        m.append()

if len(m) != 0:
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b = map(int,input().split())
if (b-a) >=n:
  print('OK)
else:
  print('NG')
Problem p02726 (python)

Fixed submission:
N, X, Y = map(int, input().split())

ans = [0] * (N)

for i in range(1, N):
    for j in range(i + 1, N + 1):
        d = min(j - i, abs(X - i) + abs(j - Y) + 1)
        ans[d] += 1

for a in ans[1:]:
    print(a)

Buggy submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())

from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

edge = [[-1] * N for _ in range(N)]
for i in range(N - 1):
    edge[i][i + 1] = 1
    edge[i + 1][i] = 1
edge[X - 1][Y - 1] = 1
edge[Y - 1][X - 1] = 1

# 隣接行列
G = csgraph_from_dense(edge, null_value=-1)
# 下準備 重みがnull_valueの辺は存在しないとうこと
# 別に隣接行列のままでいい,今回は存在しない辺があるため

d = floyd_warshall(G, directed=True)
# directed初期値True 逆走もできるか

# print(d)

ans = [0] * (N)

for i in range(N):
    for j in range(i, N):
        ans[int(d[i][j])] += 1

[print(i) for i in ans[1:]]
Problem p02729 (python)

Fixed submission:
N, M = map(int, input().split())

import numpy as np

A = np.asarray(range(max(1, N)))
B = np.asarray(range(max(1, M)))
A = A.cumsum()
B = B.cumsum()

print(A[-1] + B[-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

import numpy as np

A = np.asarray(range(N))
B = np.asarray(range(M))
A = A.cumsum()
B = B.cumsum()

print(A[-1] + B[-1])
Problem p02891 (python)

Fixed submission:
S = input()
K = int(input())
SS = S[::-1]

count = 0
l = len(S)
check = True
ff = 1
while ff < l:
    if S[ff] == S[0]:
        ff += 1
    else:
        break
ll = 1
while ll < l:
    if SS[ll] == SS[0]:
        ll += 1
    else:
        break

if S[0] != SS[0]:
    ff = 0
    ll = 0

if ff == l:
    print(l * K // 2)
    exit()

i = ff
c = 1
while i < l - ll - 1:
    if S[i] == S[i + 1]:
        c += 1
    else:
        count += c // 2
        c = 1
    i += 1
count += c // 2

# print(count, ff, ll)

print(K * count + (K - 1) * ((ff + ll) // 2) + ff // 2 + ll // 2)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

count = 0
l = len(S)
check = True
i = 0
while i < l - 1:
    if S[i] == S[i + 1]:
        count += 1
        i += 2
        if i + 1 == l:
            check = False
    else:
        i += 1

ff = 1
while S[ff] == S[0] and ff < l:
    ff += 1
ll = 1
while S[-ll] == S[-1] and ll < l:
    ll += 1

if S[0] == S[-1]:
    if not check:
        print(count * K)
    else:
        print(count + (K - 1) * (ff + ll) // 2)
else:
    print(count * K)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

count = 0
l = len(S)
check = True
i = 0
while i < l - 1:
    if S[i] == S[i + 1]:
        count += 1
        i += 2
        if i + 1 == l:
            check = False
    else:
        i += 1

ff = 1
while S[ff] == S[0] and ff < l:
    ff += 1
ll = 1
while S[-ll] == S[-1] and ll < l:
    ll += 1

if S[0] == S[-1]:
    if not check:
        print(count * K)
    else:
        print(count + (K - 1) * (ff + ll) // 2)
else:
    print(count * K)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

count = 0
l = len(S)
check = True
i = 0
while i < l - 1:
    if S[i] == S[i + 1]:
        count += 1
        i += 2
        if i + 1 == l:
            check = False
    else:
        i += 1

ff = 1
while S[ff] == S[0]:
    ff += 1
ll = 1
while S[-ll] == S[-1]:
    ll += 1

if S[0] == S[-1]:
    if not check:
        print(count * K)
    else:
        print(count + (K - 1) * (ff + ll) // 2)
else:
    print(count * K)
Problem p02990 (python)

Fixed submission:
N, K = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
P = 10**4
g1 = [1, 1] # 元テーブル 階乗
g2 = [1, 1] #逆元テーブル 逆元の階乗
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, P + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

#a = cmb(n,r,mod)

print(N - K + 1)

for i in range(2, K + 1):
    ans = cmb(K - 1, i - 1, mod) * cmb(N - K + 1, i, mod) % mod
    print(ans)

Buggy submission (verdict: Runtime Error):
a
Problem p03012 (python)

Fixed submission:
N = int(input())
W = list(map(int, input().split()))
l = sum(W)
r = 0
ans = l
for w in W:
    l -= w
    r += w
    ans = min(abs(r - l), ans)

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))
l = sum(W)
r = 0
ans = l
for w in W:
    l -= w
    r += w
    ans = min(abs(r - l))

print(ans)
Problem p03013 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
N, M = map(int, input().split())
#a = [0 for _ in range(N + 1)]
dp = [-1 for _ in range(N + 1)]
dp[0] = 1
for _ in range(M):
    a = int(input())
    dp[a] = 0
mod = 10**9 + 7

def f(n):
    if n < 0:
        return 0
    if dp[n] == -1:
        dp[n] = (f(n - 1) + f(n - 2)) % mod
    return dp[n]
print(f(N))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
#a = [0 for _ in range(N + 1)]
dp = [-1 for _ in range(N + 1)]
dp[0] = 1
for _ in range(M):
    a = int(input())
    dp[a] = 0
mod = 10**9 + 7

def f(n):
    if n < 0:
        return 0
    if dp[n] == -1:
        dp[n] = (f(n - 1) + f(n - 2)) % mod
    return dp[n]
print(f(N))
Problem p03127 (python)

Fixed submission:
""" AtCoder """

from fractions import gcd

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

ans = A[0]

for i in range(1, N):
    ans = gcd(ans, A[i])

print(ans)

Buggy submission (verdict: Runtime Error):
""" AtCoder """

import math

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

ans = A[0]

for i in range(1, N):
    ans = math.gcd(ans, A[i])

print(ans)
Problem p03745 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

B = []
tmp = -1
for a in A:
    if a != tmp:
        B.append(a)
        tmp = a

if len(B) == 1:
    print(1)
    exit()

def f(A):
    ans = 1
    n = len(A)
    if A[0] < A[1]:
        ff = 1
    else:
        ff = -1
    for i in range(1, n - 1):
        if ff == 0:
            if A[i] < A[i + 1]:
                ff = 1
            else:
                ff = -1
        elif ff == 1:
            if A[i] > A[i + 1]:
                ans += 1
                ff = 0
        else:
            if A[i] < A[i + 1]:
                ans += 1
                ff = 0
    return ans

print(f(B))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

B = []
tmp = -1
for a in A:
    if a != tmp:
        B.append(a)
        tmp = a

def f(A):
    ans = 1
    n = len(A)
    if A[0] < A[1]:
        ff = 1
    else:
        ff = -1
    for i in range(1, n - 1):
        if ff == 0:
            if A[i] < A[i + 1]:
                ff = 1
            else:
                ff = -1
        elif ff == 1:
            if A[i] > A[i + 1]:
                ans += 1
                ff = 0
        else:
            if A[i] < A[i + 1]:
                ans += 1
                ff = 0
    return ans

print(f(B))
Problem p03803 (python)

Fixed submission:
""" AtCoder """

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

if A == 1:
    A = 14
if B == 1:
    B = 14

if A > B:
    print("Alice")
elif A == B:
    print("Draw")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
""" AtCoder """

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

if A == 1:
    A = 14
if B == 1:
    B = 14:

if A > B:
    print("Alice")
elif A == B:
    print("Draw")
else:
    print("Bob")
Problem p03804 (python)

Fixed submission:
""" AtCoder """

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        count = 0
        for jj in range(M):
            if A[i + jj][j:j + M] != B[jj]:
                break
            count += 1
        if count == M:
            print("Yes")
            exit()

print("No")

Buggy submission (verdict: Runtime Error):
""" AtCoder """

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

check = True

for i in range(N - M + 1):
    check = True
    for j in range(M):
        count = 0
        for jj in range(N - M + 1):
            if A[i + jj][j:j + M] != B[jj]:
                check = False
                break
            count += 1
        if count == M:
            print("Yes")
            exit()
        if not check:
            break

print("No")
Problem p03805 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
edge = [[] for _ in range(N + 1)]
ab = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    a, b = ab[i][0] - 1, ab[i][1] - 1
    edge[a].append(b)
    edge[b].append(a)

ans = 0

def f(now, v):
    global ans
    v |= (1 << now)
    for to in edge[now]:
        if not (v & (1<<to)):
            f(to, v)
    if bin(v).count("1") == N:
        ans += 1

f(0, 0)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
edge = [[] for _ in range(N + 1)]
ab = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    a, b = ab[i][0], ab[i][1]
    edge[a].append(b)
    edge[b].append(a)


def f(now, v):
    v = v & (1 << now)
    for to in edge[now]:
        if v >> to == 0:
            f(to, v)
    if v == int('0b11111111', 0):
        ans += 1

ans = 0
f(1, 1)

print(ans)
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = map(int,input().split())
m = B // K
if m*K >= A:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = map(int,input().split())
n_A = A//K
n_B = B//K
if n_B - b_A >= 1:
  print("Yes"):
else:
  print("No")
Problem p02699 (python)

Fixed submission:
S, W = input().split()
if int(S) <= int(W):
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
S, W = input().split()
if int(S) =< int(W):
  print("safe")
else:
  print("unsafe")
Problem p02711 (python)

Fixed submission:
N = input()
if "7" in N:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
if "7" in N:
  print("Yes"):
else:
  print("No")
Problem p02701 (python)

Fixed submission:
import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
print(len(c))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
print(len(a))
Problem p02723 (python)

Fixed submission:
s = input()

if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())

red = sorted(list(map(int, input().split())), reverse=True)
gre = sorted(list(map(int, input().split())), reverse=True)
non = sorted(list(map(int, input().split())), reverse=True)

eat = []

for i in range(x):
    eat.append(red.pop(0))

for i in range(y):
    eat.append(gre.pop(0))

eat.sort()

for i in range(len(non)):
    n = non.pop(0)
    if eat[i] < n:
        eat[i] = n
    else:
        break

print(sum(eat))
Problem p02707 (python)

Fixed submission:
import collections
M = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
num = 1

while num <= M:
    print(B[num])
    num += 1

Buggy submission (verdict: Runtime Error):
M = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
#print(B)
#print(B[])
num = 1

while num <= M:
    print(B[num])
    num += 1
Problem p02951 (python)

Fixed submission:
A,B,C = map(int,input().split())

S = A - B

if C - S > 0:
    print(C - S)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
S = A - B

if C - S > 0:
    print(C - S)
else:
    print(0)
Problem p02685 (python)

Fixed submission:
n, m, k = map(int, input().split())
MOD = 998244353
ans = 0
c = 1

for i in range(k + 1):
    ans += (((m * pow(m - 1, n - i - 1, MOD)) % MOD) * c) % MOD
    ans %= MOD
    c = (c * (n - 1 - i) * pow(i + 1, MOD - 2, MOD)) % MOD
    
    
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
from math import factorial
n, m, k = map(int, input().split())
MOD = 998244353
ans = 0

def nck(q, r):
    a = (factorial(q)) / (factorial(r)) / (factorial(q - r))
    return a%MOD


for i in range(k+1):
    ans += (m * nck(n - 1, i) * ((m - 1)**(n - 1 - i)%MOD))
    
print(int(ans%MOD))
Problem p02792 (python)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1):
    head, tail = str(i)[0], str(i)[-1]
    if tail == "0":
        continue
    if head == tail:
        ans += 1
    if int(tail + head) <= N:
        ans += 1
    if len(str(N))-2 >= 1 or head == tail:
        num = len(str(N))-2
        if int(tail) <= int(str(N)[0]) and num > 0:
            if int(tail + "9"*(len(str(N))-2) + head) <= N:
                j = int("9"*(len(str(N))-2))
            else:
                if int(tail + str(N)[1:-1] + head) <= N:
                    j = int(str(N)[1:-1])
                else:
                    j = int(str(N)[1:-1]) - 1
            ans += int(j) + 1
        if num > 1:
            ans += int((num - 1) * "1") * 10
    # print(i, ans)
                    
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1, N+1):
    head, tail = str(i)[0], str(i)[-1]
    if tail == "0":
        continue
    if head == tail:
        ans += 1
    if int(tail + head) <= N:
        ans += 1
    if len(str(N))-2 >= 1 or head == tail:
        num = len(str(N))-2
        if int(tail + "9"*(len(str(N))-2) + head) <= N:
            j = int("9"*(len(str(N))-2))
        else:
            j = int(str(N)[1:-1])
        ans += int(j) + 1
        if num > 1:
            ans += int((num - 1) * "1") * 10
                    
print(ans)
Problem p02970 (python)

Fixed submission:
N, D = map(int, input().split())
x = N//((2*D)+1)
if(x*((2*D)+1)>= N):
	print(N//((2*D)+1))
else:
	print((N//((2*D)+1)+1))

Buggy submission (verdict: Runtime Error):
N, D = map(int, input())
x = N//((2*D)+1)
if(x*((2*D)+1)>= N):
	print(N//((2*D)+1))
else:
	print((N//((2*D)+1)+1))

Buggy submission (verdict: Runtime Error):
N, D = map(int, input())
x = N//((2*D)+1)
if(x*((2*D)+1)>= N):
	print(N//((2*D)+1))
else:
	print(N//((2*D)+1)+1)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input())
if(N%2*D+1==0):
	print(N//((2*D)+1))
else:
	print(N//((2*D)+1)+1)
Problem p02989 (python)

Fixed submission:
N = int(input())
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(N // 2) :
  cnt = len(list(filter(lambda x : x <= D[N // 2 - 1 + i], D)))
  if(cnt == N // 2) :
    ans += D[N // 2] - D[N // 2 - 1]
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = list(map(int, input().split()))
cnt = 0
for i in range(max(D)) :
  cnt = len(list(filter(lambda x : x <= i, D)))
  if(cnt == N // 2) :
    ans += 1
  else :
    pass
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = list(map(int, input().split()))
n = N // 2
_n = n - 1
n_ = n + 1
D.sort()
cnt = 0
for i in range(max(D)) :
  if(D[_n] < i and i < D[n_]) :
    if(D[_n] != D[n_]) :
      cnt += 1
    else :
      pass
  else :
    pass
print(cnt)
Problem p02693 (python)

Fixed submission:
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

a = listA[0][0]
b = listA[1][0]
c = listA[1][1]

if b % a == 0:
  print ('OK')

d = b // a

if b % a !=0:
  if a * (d+1) <= c:
    print ('OK')
  else:
    print ('NG')

Buggy submission (verdict: Runtime Error):
import math
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

a = listA[0][0]
b = listA[0][1]
n = listA[0][2]

old = 0
for x in range(1,n+1):
  if x == 1:
    c = math.floor((a*x)/b)
    d = math.floor(x/b)
    old = c-(a*d)
  else:
    c = math.floor((a*x)/b)
    d = math.floor(x/b)
    current = c-(a*d)
    if old <= current:
      old = current
  if x > 10000000:
    break
print (old)
Problem p02753 (python)

Fixed submission:
l = list(input())
if 'A'in l and 'B' in l:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N, b, r = map(int, input().split())
ans = N // (b + r) * b
N = N % (b + r)
if b > N:
    ans += N
else:
    ans += b
print(ans)
Problem p02759 (python)

Fixed submission:
import math
n = int(input())
n = math.ceil(n / 2)
print(n)

Buggy submission (verdict: Runtime Error):
import math
n = input()
n = math.ceil(n / 2)
print(n)
Problem p02847 (python)

Fixed submission:
# -*- coding: utf-8 -*-
S = input()
a = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
a.reverse()
ans = a.index(S) + 1
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = input()
a = ["SUN", "MUN", "TUE", "WED", "THU", "FRI", "SAT"]
a.reverse()
ans = a.index(S) + 1
print(ans)
Problem p03803 (python)

Fixed submission:
a = map(int, raw_input().split())

if a[0] == 1 :
    a[0] = 14
if a[1] == 1 :
    a[1] = 14

if a[0] == a[1] :
    print 'Draw'
elif a[0] > a[1] :
    print 'Alice'
else :
    print 'Bob'

Buggy submission (verdict: Runtime Error):
a = map(int, raw_input().split())

a[0] = (a[0] + 12) % 13
a[1] = (a[1] + 12) % 13

if a[0] == a[1]  :
Problem p02735 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    H,W = MAP()
    s = [input() for _ in range(H)]
    dp = [[0]*W for _ in range(H)]

    if s[0][0] == "#":
        dp[0][0] = 1

    for i in range(H):
        for j in range(W):
            if i == 0:
                if j == 0:
                    continue

                if s[i][j] == "#" and s[i][j-1] == ".":
                    dp[i][j] = dp[i][j-1]+1
                else:
                    dp[i][j] = dp[i][j-1] 
            else:
                if j == 0:
                    if s[i-1][j] == "." and s[i][j] == "#":
                        up = dp[i-1][j]+1
                    else:
                        up = dp[i-1][j]
                    dp[i][j] = up
                    continue
                else:
                    if s[i-1][j] == "." and s[i][j] == "#":
                        up = dp[i-1][j]+1
                    else:
                        up = dp[i-1][j]
                    
                    if s[i][j-1] == "." and s[i][j] == "#":
                        left = dp[i][j-1]+1
                    else:
                        left = dp[i][j-1]
                    
                    dp[i][j] = min(left,up)

    print(dp[H-1][W-1])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

def solve(H: int, W: int, s: "List[str]"):
    dp = [[0]*W for _ in range(H)]

    if s[0][0] == "#":
        dp[0][0] = 1

    for i in range(H):
        for j in range(W):
            if i == 0:
                if j == 0:
                    continue

                if s[i][j] == "#" and s[i][j-1] == ".":
                    dp[i][j] = dp[i][j-1]+1
                else:
                    dp[i][j] = dp[i][j-1] 
            else:
                if j == 0:
                    if s[i-1][j] == "." and s[i][j] == "#":
                        up = dp[i-1][j]+1
                    else:
                        up = dp[i-1][j]
                    dp[i][j] = up
                    continue
                else:
                    if s[i-1][j] == "." and s[i][j] == "#":
                        up = dp[i-1][j]+1
                    else:
                        up = dp[i-1][j]
                    
                    if s[i][j-1] == "." and s[i][j] == "#":
                        left = dp[i][j-1]+1
                    else:
                        left = dp[i][j-1]
                    
                    dp[i][j] = min(left,up)

    print(dp[H-1][W-1])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(W)]  # type: "List[str]"
    solve(H, W, s)

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

Fixed submission:
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    S,T = input().split()
    A,B = MAP()
    U = input()

    if S == U:
        print(A-1,B)
    else:
        print(A,B-1)

    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

import numpy as np
def main():
    S,T = input().split()
    A,B = MAP()
    U = INT()

    if S == U:
        print(A-1,B)
    else:
        print(A,B-1)

    return

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

Fixed submission:
import sys
s = list(input())
k = int(input())

if len(set(s))==1:
	print((len(s)*k)//2)
	sys.exit()
    
def counter(string):
    count = 0
    answer = 0
    prev = ""
    for index,sss in enumerate(string):
        if prev == "" or sss == prev:
            count+=1
            if count == 2: 
                answer+=1
                count=0
                string[index] = "1"
        else:
            count=1
        prev = sss
    return answer,string

answer, string = counter(s.copy())

if string[0] != string[-1]:
    print(answer*k)
else:
    count = 0
    l = len(s)
    for i in range(l):
        if s[i] == s[0]:
            count += 1
        else:
            break
    for i in range(l):
        if s[-1-i] == s[0]:
        	count += 1
        else:
        	break

    if count % 2 ==0:
        print(answer*k + k-1)
    else:
        print(answer*k)

Buggy submission (verdict: Runtime Error):
s = input()
k = input()

ss = ""
for _ in range(k):
    ss += s

ss_list = list(ss)
count = 0
answer = 0
prev = ""
for sss in ss_list:
    if prev == "" or sss == prev:
        count+=1
        if count == 2: 
            answer+=1
            count=0

    else:
        count=1
    prev = sss

print(answer)