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

Fixed submission:
s = input()
r_cnt = 0
l_cnt = 0
lst = [0 for _ in range(len(s))]
s += 'R'
for i in range(len(s)):
  if s[i] == 'R' and l_cnt == 0:
    r_cnt += 1
  elif s[i] == 'L' and r_cnt > 0:
    l_cnt += 1
    if r_cnt % 2 == 0:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2
    else:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2 + 1
    r_cnt = 0
    ind = i
  elif s[i] == 'L' and r_cnt == 0:
    l_cnt += 1
  elif s[i] == 'R' and l_cnt > 0:
    r_cnt += 1
    if l_cnt % 2 == 0:
      lst[ind] += l_cnt // 2
      lst[ind-1] += l_cnt // 2
    else:
      lst[ind] += l_cnt // 2 + 1
      lst[ind-1] += l_cnt // 2
    l_cnt = 0
print(*lst)

Buggy submission (verdict: Runtime Error):
s = input()
r_cnt = 0
l_cnt = 0
lst = [0 for _ in range(len(s))]
  s += 'R'
for i in range(len(s)-1):
  if s[i] == 'R' and l_cnt == 0:
    r_cnt += 1
  elif s[i] == 'L' and r_cnt > 0:
    l_cnt += 1
    if r_cnt % 2 == 0:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2
    else:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2 + 1
    r_cnt = 0
  elif s[i] == 'L' and r_cnt == 0:
    l_cnt += 1
  elif s[i] == 'R' and l_cnt > 0:
    r_cnt += 1
    if l_cnt % 2 == 0:
      lst[i-1] += l_cnt // 2
      lst[i-2] += l_cnt // 2
    else:
      lst[i-1] += l_cnt // 2 + 1
      lst[i-2] += l_cnt // 2
    l_cnt = 0
print(*lst)

Buggy submission (verdict: Runtime Error):
s = input()
r_cnt = 0
l_cnt = 0
lst = [0 for _ in range(len(s))]
  s += 'R'
for i in range(len(s)):
  if s[i] == 'R' and l_cnt == 0:
    r_cnt += 1
  elif s[i] == 'L' and r_cnt > 0:
    l_cnt += 1
    if r_cnt % 2 == 0:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2
    else:
      lst[i] += r_cnt // 2
      lst[i-1] += r_cnt // 2 + 1
    r_cnt = 0
  elif s[i] == 'L' and r_cnt == 0:
    l_cnt += 1
  elif s[i] == 'R' and l_cnt > 0:
    r_cnt += 1
    if l_cnt % 2 == 0:
      lst[i-1] += l_cnt // 2
      lst[i-2] += l_cnt // 2
    else:
      lst[i-1] += l_cnt // 2 + 1
      lst[i-2] += l_cnt // 2
    l_cnt = 0
print(*lst)
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
A = [True] * (n+1)
for _ in range(m):
  a = int(input())
  A[a] = False

mod = 10**9 + 7
dp = [0] * (n+1)
dp[0] = 1
if A[1]:
  dp[1] = 1

for i in range(2, n+1):
  if A[i]:
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod

print(dp[n])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = [True] * n
for _ in range(m):
  a = int(input())
  A[a] = False

mod = 10**9 + 7
dp = [0] * (n + 1)
dp[0] = 1
if A[1]:
  dp[1] = 1

for i in range(2, n+1):
  if A[i]:
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod

print(dp[n])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = [True] * n
for _ in range(m):
  a = int(input())
  A[a] = False

mod = 10**9 + 7
dp = [0] * (n + 1)
dp[0] = 1
if 1 not in A:
  dp[1] = 1

for i in range(2, n+1):
  if A[i]:
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod

print(dp[n])
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S = input()
ans = ''
for i in range(N):
  if i + 1 == K:
    ans += S[i].lower()
  else:
    ans += S[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
for i in range(N):
  if i + 1 == K:
    S[i] = S[i].lower()
  else:
    S[i] = S[i]
print(S)
Problem p03272 (python)

Fixed submission:
N, i = map(int, input().split())
print(N - i + 1)

Buggy submission (verdict: Runtime Error):
N, i = map(input().split())
print(N - i + 1)
Problem p03821 (python)

Fixed submission:
n = int(input())
l = []
r = []
for _ in range(n):
  a, b = map(int, input().split())
  l.append(a)
  r.append(b)
before_sa = 0
for i in range(1, n+1):
  a, b = l[-i], r[-i]
  a += before_sa
  if a % b == 0:
    continue
  else:
    sa = (a//b + 1) * b - a
    before_sa += sa
print(before_sa)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
r = []
for _ in range(n):
  a, b = map(int, input())
  l.append(a)
  r.append(b)
before_sa = 0
for i in range(1, n+1):
  j = 0
  a, b = l[-i], r[-i]
  while True:
    if j == 0 and a % b == 0:
      sa = 0
    elif j == 0 and a % b != 0:
      sa = (a//b + 1) * b - a
    elif j > 0:
      sa = (a//b + j) * b - a
    if before_sa <= sa:
      before_sa = sa
      break
    j += 1
print(before_sa)
Problem p02572 (python)

Fixed submission:
n=input()
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
print((ans//2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n=input()
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
return (ans/2)%(10**9+7)

Buggy submission (verdict: Runtime Error):
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
return (ans/2)%(10**9+7)

Buggy submission (verdict: Runtime Error):
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
return ans%(10**9+7)

Buggy submission (verdict: Runtime Error):
a=(int)(input().split())
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=a
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
return ans%(10**9+7)

Buggy submission (verdict: Runtime Error):
a=input().split()
sum=0
for i in a:
  sum+=a
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
return ans%(10**9+7)

Buggy submission (verdict: Runtime Error):
a=map(int,input().split())
sum=0
for i in a:
  sum+=a
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
return ans%(10**9+7)
Problem p02570 (python)

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

if D <= T*S:
    print("Yes")
else:
    print("No")

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

if D <= T*S:
    print("Yes")
else:
    print("No")

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

if D <= T*S:
    print("Yes")
else:
    print("No")
Problem p02578 (python)

Fixed submission:
n = int(input())
A = [int(x) for x in input().split()]
maxv = 0
ans = 0
for a in A:
    if maxv > a:
        ans += maxv - a
    else:
        maxv = a
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
cnt = 0
for i in A:
    if i == 0:
        pass
    if A[i-1] > A[i]:
        cnt += 1
    else:
        pass
print(cnt)
Problem p03208 (python)

Fixed submission:
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = []
for i in range(n - k + 1):
    ans.append(h[i + k - 1] - h[i])
print(min(ans))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = []
for i in range(k):
    ans.append(h[i + k - 1] - h[i])
print(min(ans))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = []
for i in range(n):
    ans.append(h[i + k - 1] - h[i])
print(min(ans))
Problem p02679 (python)

Fixed submission:
from sys import stdin
input = stdin.buffer.readline
from collections import defaultdict

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

MOD = 10 ** 9 + 7

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

rest = N
zero = 0
zero_left, zero_right = 0, 0
tmp = []
for a, b in AB:
    if a == b == 0:
        zero += 1
        rest -= 1
    elif a == 0:
        zero_left += 1
    elif b == 0:
        zero_right += 1
    else:
        gcd_ab = gcd(abs(a), abs(b))
        a, b = a // gcd_ab,  b // gcd_ab
        if a < 0: a, b = -a, -b
        tmp.append([a, b])
AB = tmp

cnt = defaultdict(int)
for a, b in AB:
    cnt[(a, b)] += 1

answer = 1
answer *= pow(2, zero_left + zero_right, MOD) - (pow(2, zero_left, MOD) - 1) * (pow(2, zero_right, MOD) - 1)
answer %= MOD
rest -= zero_right + zero_left
#print("answer:", answer)

check = defaultdict(int)
for a, b in AB:
    if b > 0 and check[(a, b)] == 0:
        check[(a, b)] = 1
        answer *= pow(2, cnt[(a, b)] + cnt[(b, -a)], MOD) - (pow(2, cnt[(a, b)], MOD) - 1) * (pow(2, cnt[(b, -a)], MOD) - 1) 
        answer %= MOD
        rest -= cnt[(a, b)] + cnt[(b, -a)]

answer *= pow(2, rest, MOD)
answer += zero - 1
answer %= MOD
print(answer)

Buggy submission (verdict: Runtime Error):
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

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

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

cnt = defaultdict(int)
zero = 0

tmp = []
for a, b in AB:
    gcd_ab = gcd(abs(a), abs(b))
    if a < 0: a,  b = - a, - b 
    tmp.append([a // gcd_ab, b // gcd_ab])
AB = tmp
#print(AB)

cnt = defaultdict(int)
zero = 0
        
for a, b in AB:
    if a * b == 0:
        zero += 1
    else:
        cnt[(a, b)] += 1
#print(cnt)

answer = 1
rest = N

answer *= zero + 1
answer %= MOD
rest -= zero

check = defaultdict(int)
for a, b in AB:
    if a > 0 and b > 0 and check[(a, b)] == 0:
        check[(a, b)] = 1
        #print((a, b), cnt[(a, b)], cnt[(b, -a)])
        answer *= pow(2, cnt[(a, b)] + cnt[(b, -a)], MOD) - (pow(2, cnt[(a, b)], MOD) - 1) * (pow(2, cnt[(b, -a)], MOD) - 1) 
        answer %= MOD
        rest -= cnt[(a, b)] + cnt[(b, -a)]

answer *= pow(2, rest, MOD)
answer -= 1
answer %= MOD

print(answer)
Problem p02693 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
INF = 10 ** 18

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

for i in range(A, B + 1):
    if i % K == 0:
        print("OK")
        exit()
        
print("NG")

Buggy submission (verdict: Runtime Error):
SIZE = 10 ** 6 + 100
g1, g2, inv = [1, 1], [1, 1], [0, 1]
for i in range(2, SIZE + 1):
    g1.append((g1[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inv[-1]) % MOD)
def nPr(n, r):
    if r < 0 or r > n:
        return 0
    return g1[n] * g2[r] % MOD
def nCr(n, r):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % MOD
Problem p02759 (python)

Fixed submission:
N = int(input())

print(-(-N // 2))

Buggy submission (verdict: Runtime Error):
root = [i for i in range(N + 1)]
size = [1] * (N + 1)
 
def find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = find(y)
    root[x] = z
    return z

def union(x, y):
  rx = find(x)
  ry = find(y)
  sx = size[rx]
  sy = size[ry]
  if rx == ry:
    return 0
  else:
    if sx >= sy:
      root[ry] = rx
      size[rx] = sx + sy
    else:
      root[rx] = ry
      size[ry] = sx + sy
    return sx * sy
Problem p02771 (python)

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

if A[0] == A[1] and A[1] != A[2]:
    print("Yes")
elif A[0] != A[1] and A[1] == A[2]:
    print("Yes")
else:
    print("No")

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

if A[0] == A[1] and A[1] != A[2]:
    print("Yes")
elif A[0] != A[1] and A[1] == A[2]:
    print("Yes")
else
    print("No")
Problem p02781 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline

N = int(input())
K = int(input())

LN = len(str(N))

def keta1(n):
    s = str(n)
    return (len(s) - 1) * 9 + int(s[0])
#print(keta1(N))


def keta2(n):
    if n < 10:
        return 0
    cnt2 = [0] * 101
    for i in range(2, 101):
        cnt2[i] = 9 * 9 * (i - 1)
    tmp2 = 0
    for i in range(len(str(n))):
        tmp2 += cnt2[i]
    tmp2 += (int(str(n)[0]) - 1) * keta1((10 ** (len(str(n))  - 1)) - 1) + keta1(int(str(n)[1:]))
    return tmp2

def keta3(n):
    cnt3 = [0] * 101
    for i in range(3, 101):
        cnt3[i] = 9 * 9 * 9 * (i - 1) * (i - 2) // 2
    tmp3 = 0
    for i in range(len(str(n))):
        tmp3 += cnt3[i]
    tmp3 += (int(str(N)[0]) - 1) * keta2((10 ** (len(str(n))  - 1)) - 1) + keta2(int(str(n)[1:]))
    
    return tmp3

if K == 1:
    print(keta1(N))
elif K == 2:
    print(keta2(N))
elif K == 3:
    print(keta3(N))

Buggy submission (verdict: Runtime Error):
N = input()
K = int(input())
L = len(N)

dp = [[[0 for j in range(L + 1)] for i in range(L + 1)] for _ in range(2)]
dp[0][0][0] = 1

for i in range(L):
    Ni = int(N[i])
    for j in range(L):
        if Ni == 0:
            dp[0][i + 1][j + 0] += dp[0][i][j + 0] * 1
            dp[0][i + 1][j + 1] += dp[0][i][j + 0] * 0
            dp[1][i + 1][j + 0] += dp[0][i][j + 0] * 0 + dp[1][i][j + 0] * 1
            dp[1][i + 1][j + 1] += dp[0][i][j + 0] * 0 + dp[1][i][j + 0] * 9
        else:
            dp[0][i + 1][j + 0] += dp[0][i][j + 0] * 0
            dp[0][i + 1][j + 1] += dp[0][i][j + 0] * 1
            dp[1][i + 1][j + 0] += dp[0][i][j + 0] * 1 + dp[1][i][j + 0] * 1
            dp[1][i + 1][j + 1] += dp[0][i][j + 0] * (Ni - 1) + dp[1][i][j + 0] * 9
#print(dp[0])
#print(dp[1])

print(dp[0][L][K] + dp[1][L][K])

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

def keta1(n):
    s = str(n)
    return (len(s) - 1) * 9 + int(s[0])

def keta2(n):
    s = str(n)
    cnt = [0] * 101
    for i in range(2, 101):
        cnt[i] = 9 * 9 * (i - 1)
    res = 0
    for i in range(len(s)):
        res += cnt[i]
    res += (int(s[0]) - 1) * keta1(10 ** (len(s) - 1) - 1) + keta1(int(s[1:]))
    return res

def keta3(n):
    s = str(n)
    cnt = [0] * 101
    for i in range(3, 101):
        cnt[i] = 9 * 9 * 9 * (i - 1) * (i - 2) // 2
    res = 0
    for i in range(len(s)):
        res += cnt[i]
    res += (int(s[0]) - 1) * keta2(10 ** (len(s) - 1) - 1) + keta2(int(s[1:]))
    return res

if K == 1:
    print(keta1(N))
elif K == 2:
    print(keta2(N))
elif K == 3:
    print(keta3(N))
Problem p02815 (python)

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

MOD = 10 ** 9 + 7

C.sort()
C = C[::-1]

a0 = pow(2, N - 1, MOD)
d = pow(2, N - 2, MOD) if N - 2 >= 0 else 0
answer = 0
for i in range(N):
  answer = (answer + (a0 + d * i) * C[i]) % MOD
answer = (answer * pow(2, N, MOD)) % MOD
print(int(answer))

Buggy submission (verdict: Runtime Error):
N = int(input())
C = list(map(int, input().split()))
MOD = 10 ** 9 + 7

C.sort()
C = [0] + C

answer = 0
for i in range(1, N + 1):
  answer = (answer + C[i] * (pow(2, N - 1, MOD) + pow(2, N - 2, MOD) * (N - i))) % MOD
answer = (answer * pow(2, N, MOD)) % MOD

print(answer)
Problem p02863 (python)

Fixed submission:
N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
dp = [0] * T
#print("AB:", AB)

answer = 0
for a, b in AB:
  for t in range(T-1, -1, -1):
    if dp[t]:
      if  a + t < T:
        dp[a + t] = max(dp[a + t], dp[t] + b)
        answer = max(answer, dp[a + t])
      else:
        answer = max(answer, dp[t] + b)
  if a < T:
    dp[a] = max(dp[a], b)
  answer = max(answer, b)
  #print("dp:", dp)
print(answer)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
dp = [0] * T
#print("AB:", AB)

answer = 0
for a, b in AB:
  for t in range(T-1, -1, -1):
    if dp[t]:
      if  a + t < T:
        dp[a + t] = max(dp[a + t], dp[t] + b)
        answer = max(answer, dp[a + t])
      else:
        answer = max(answer, dp[t] + b)
  if a < T:
    dp[a] = max(dp[a], b)
  answer = max(answer, b)
  #print("dp:", dp)
print(answer)      N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
dp = [0] * T
#print("AB:", AB)

answer = 0
for a, b in AB:
  for t in range(T-1, -1, -1):
    if dp[t]:
      if  a + t < T:
        dp[a + t] = max(dp[a + t], dp[t] + b)
        answer = max(answer, dp[a + t])
      else:
        answer = max(answer, dp[t] + b)
  if a < T:
    dp[a] = max(dp[a], b)
  answer = max(answer, b)
  #print("dp:", dp)
print(answer)
Problem p02954 (python)

Fixed submission:
s=input()
#s="RRLLLLRLRRLL"
a = [0] * len(s)
l_first = 0
r_first = 0

for i in range(len(s)):
    ii =len(s)-i-1
    if s[ii] == "R":
        if r_first==0:
            d = len(s)-ii-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)
        else:
            d = -ii+r_first-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)    
for i in range(len(s)):
    if s[i] == "L":
        if l_first==0:
            d = i-l_first
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
        else:
            d = i-l_first-1
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
print(" ".join(list(map(str,a))))

Buggy submission (verdict: Runtime Error):
s=input()
#s="RRLLLLRLRRLL"
a = [0] * len(s)
l_first = 0
r_first = 0

for i in range(len(s)):
    ii =len(s)-i-1
    if s[ii] == "R":
        if r_first==0:
            d = len(s)-ii-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)
        else:
            d = -ii+r_first-1
            r_first=ii
            a[ii+1]+=int(d/2)+d%2
            a[ii]+=int(d/2)    
for i in range(len(s)):
    if s[i] == "L":
        if l_first==0:
            d = i-l_first
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
        else:
            d = i-l_first-1
            l_first=i
            a[i-1]+=int(d/2)+d%2
            a[i]+=int(d/2)
print(" ".join(a))
Problem p03012 (python)

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

res=0
s=sum(W)
ans=100000000000
for i in range(N):
  res+=W[i]
  ans=min(ans,abs(s-res*2))
print(ans)

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

res=0
s=sum(W)
ans=100000000000
for i in range(N):
  res+=W[i]
  ans=min(abs(s-res*2))
print(ans)

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

res=0
s=sum(W)
ans=100000000000
for i in range(N):
  res+=W[i]
  ans=min(abs(s-res*2)
Problem p03017 (python)

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

if "##" in S[A-1:C] or "##" in S[B-1:D]:
  print("No")
  exit()


# A B C D
# A C B D
if C < D:
  print("Yes")
  exit()

# A B D C  
else:
  if "..." in S[B-2:D+1]:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
S=input()

d=0
for i in range(min(A+1,N-1),min(C+1,N-1)):
  if S[i]=="#" and S[i+1]=="#":
    d=1
    break
for i in range(min(B+1,N-1),min(D+1,N-1)):
  if S[i]=="#" and S[i+1]=="#":
    d=1
    break

if C<D:
  t=1
else:
  for i in range(max(0,min(B-1,N-2)),min(C+1,N-2)):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      t=1
      break

if C==D:
  print("No")
else:
  if d==1:
    print("No")
  else:
    if t==0:
      print("No")
    else:
      print("Yes")
Problem p03053 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
A = [input() for _ in range(H)]

check = [[-1 for _ in range(W)] for _ in range(H)]
q = deque()
for i in range(H):
  for j in range(W):
    if  A[i][j] == "#":
      check[i][j] = 0
      q.append((i, j))

while q:
  i, j = q.popleft()
  
  if i - 1 >= 0 and check[i - 1][j] == -1:
      check[i - 1][j] = check[i][j] + 1
      q.append((i - 1, j))

  if i + 1 < H and check[i + 1][j] == -1:
      check[i + 1][j] = check[i][j] + 1
      q.append((i + 1, j))

  if j - 1 >= 0 and check[i][j - 1] == -1:
      check[i][j - 1] = check[i][j] + 1
      q.append((i, j - 1))

  if j + 1 < W and check[i][j + 1] == -1:
      check[i][j + 1] = check[i][j] + 1
      q.append((i, j + 1))

answer = -1
for i in range(H):
  answer = max(answer, max(check[i]))
print(answer)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
A = [input() for _ in range(H)]

INF = 10 ** 10
B = [[INF for _ in range(W)] for _ in range(W)]

for h in range(H):
  for w in range(W):
    if A[h][w] == "#":
      B[h][w] = 0

for h in range(H):
  for w in range(W):
    if B[h][w] == 0:
      stack = [(h, w)]
      while stack:
        hh, ww = stack.pop()
        if hh != 0:
          if B[hh][ww] + 1 < B[hh - 1][ww]:
            B[hh - 1][ww] = B[hh][ww] + 1
            stack.append((hh - 1, ww))

        if hh != H - 1:
          if B[hh][ww] + 1 < B[hh + 1][ww]:
            B[hh + 1][ww] = B[hh][ww] + 1
            stack.append((hh + 1, ww))


        if ww != 0:
          if B[hh][ww] + 1 < B[hh][ww - 1]:
            B[hh][ww - 1] = B[hh][ww] + 1
            stack.append((hh, ww - 1))

        if ww != W - 1:
          if B[hh][ww] + 1 < B[hh][ww + 1]:
            B[hh][ww + 1] = B[hh][ww] + 1
            stack.append((hh, ww + 1))
answer = 0
for h in range(H):
  for w in range(W):
    answer = max(answer, B[h][w])
print(answer)
Problem p03201 (python)

Fixed submission:
from math import log2, ceil
from collections import defaultdict

N = int(input())
A = sorted(list(map(int, input().split())))[::-1]

cnt = defaultdict(int)
for a in A:
  cnt[a] += 1

answer = 0
for a in A:
  if cnt[a]:
    if ceil(log2(a)) == log2(a):
      i = (1 << (ceil(log2(a)) + 1)) - a
    else:
      i = (1 << ceil(log2(a))) - a

    if i != a:
      if cnt[i]:
        cnt[a] -= 1
        cnt[i] -= 1
        answer += 1
    else:
      if cnt[i] > 1:
        cnt[a] -= 2
        answer += 1
        
print(answer)

Buggy submission (verdict: Runtime Error):
from math import log2, ceil
from collections import defaultdict

N = int(input())
A = sorted(list(map(int, input().split())))[::-1]

cnt = defaultdict(int)
for a in A:
  cnt[a] += 1

answer = 0
for a in A:
  if cnt[a]:
    i = (1 << ceil(log2(a))) - a
    if cnt[i]:
      cnt[a] -= 1
      cnt[i] -= 1
      answer += 1
      
print(answer)
Problem p03652 (python)

Fixed submission:
from collections import Counter

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

check = [0] * (M + 1)

answer = []
for _ in range(M):
  tmp = []
  for ai in A:
    for aij in ai:
      if check[aij] == 0:
        tmp.append(aij)
        break
  #print(tmp)
  counter = list(Counter(tmp).items())
  counter.sort(key = lambda x: -x[1])  
  answer.append(counter[0][1])
  check[counter[0][0]] = 1
  
print(min(answer))

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

check = [0] * (M + 1)

answer = []
for n in range(N):
  tmp = []
  for ai in A:
    for aij in ai:
      if check[aij] == 0:
        tmp.append(aij)
        break
  #print(tmp)
  counter = list(Counter(tmp).items())
  counter.sort(key = lambda x: -x[1])  
  answer.append(counter[0][1])
  check[counter[0][0]] = 1
  
print(min(answer))