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

Fixed submission:
import math
from collections import Counter

mod = 10**9+7
n = int(input())
c = Counter()
cc = Counter()

for _ in range(n):
    a, b = map(int, input().split())
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b == 0:
        c[-1] += 1
        continue
    elif a != 0 and b == 0:
        a, b = 1, 0
    elif a == 0 and b != 0:
        a, b = 0, 1
    else:
        a, b = a//math.gcd(a, b), b//math.gcd(a, b)

    c[(a, b)] += 1
    cc[(a, b)] += 1

l = []

for r in cc.keys():
    if r == -1:
        continue
    ra = c[r]

    a, b = r
    if a == 0:
        r_inv = (1, 0)
    elif b == 0:
        r_inv = (0, 1)
    elif a > 0:
        r_inv = (-b, a)
    else:
        r_inv = (b, -a)
    rb = c[r_inv]

    if ra >= 0 and rb >= 0:
        l.append([ra, rb])
        c[r] -= 10**9
        c[r_inv] -= 10**9

ans = 1
for a, b in l:
    ans *= pow(2, a, mod)-1 + pow(2, b, mod)-1 + 1
    ans %= mod

ans = (ans-1) + c[-1]
ans %= mod

print(ans)

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

mod = 10**9+7
n = int(input())
c = Counter()
cc = Counter()

for _ in range(n):
    a, b = map(int, input().split())
    a, b = a//math.gcd(a, b), b//math.gcd(a, b)
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b == 0:
        c[-1] += 1
        continue

    key = a*(10**19)+b
    c[key] += 1
    cc[key] += 1

l = []

for r in cc.keys():
    if r == -1:
        continue
    ra = c[r]
    
    a, b = r//(10**19), r % (10**19)
    if a >= 0:
        r_inv = (-b)*10**19 + a
    else:
        r_inv = b*(10**19) - a
    rb = c[r_inv]

    if ra >= 0 and rb >= 0:
        l.append([ra, rb])
        c[r] -= 10**9
        c[r_inv] -= 10**9

ans = 1
for a, b in l:
    ans *= pow(2, a, mod)-1 + pow(2, b, mod)-1 + 1
    ans %= mod

ans = (ans-1) + c[-1]
ans %= mod

print(ans)
Problem p02763 (python)

Fixed submission:
from bisect import bisect_right
from bisect import bisect_left

n = int(input())
s = list(input())
q = int(input())

ind_list = [[] for _ in range(26)]

for i, x in enumerate(s):
    ind_list[ord(x)-97].append(i)

for _ in range(q):
    _type, val1, val2 = input().split()
    if _type == '1':
        i = int(val1)-1
        c = val2
        if s[i] == c:
            continue
        ind_list[ord(s[i])-97].remove(i)
        p = bisect_right(ind_list[ord(c)-97], i)
        ind_list[ord(c)-97].insert(p, i)
        s[i] = c
    elif _type == '2':
        l = int(val1)-1
        r = int(val2)-1
        ans = 0
        for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
        print(ans)
    else:
        print('Exception caught!')
        exit()

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
from bisect import bisect_right

n = int(input())
s = input()
q = int(input())

ind_list = [[] for _ in range(26)]

for i, x in enumerate(s):
    ind_list[ord(x)-97].append(i)

for _ in range(q):
    _type, val1, val2 = input().split()
    if _type == '1':
        i = int(val1)-1
        c = val2
        ind_list[ord(s[i])-97].remove(i)
        ind_list[ord(c)-97].append(i)
        ind_list[ord(c)-97].sort()
    elif _type == '2':
        l = int(val1)-1
        r = int(val2)-1
        ans = 0
        for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
        print(ans)
    else:
        print('Exception caught!')
        exit()
Problem p02781 (python)

Fixed submission:

def solve(n,k):
    for i in range(len(n)):
        if n[i] != 0:
            break
    n = n[i:]
    if n == []:
        return 0
    l = len(n)
    ans = 0
    # n-1桁からKこ取る
    tmp = 1
    for i in range(1, k+1):
        tmp = tmp*9*(l-i)
    for i in range(1, k+1):
        tmp = tmp // i
    ans += tmp

    # 最上位から1つ（最上位の数以外）とる。
    tmp = n[0]-1
    for i in range(1, k):
        tmp = tmp*9*(l-i)
    for i in range(1, k):
        tmp = tmp // i
    ans += tmp

    # 最上位からその数をとる。
    tmp = 0
    if k == 3:
        tmp += solve(n[1:],k-1)

    elif k == 2:
        for i in range(1, l):
            if n[i] != 0:
                tmp += n[i] + 9*(l-i-1)
                break
    else:
        tmp += 1
    ans += tmp
    return ans

n = list(map(int, input()))
k = int(input())

print(solve(n,k))

Buggy submission (verdict: Runtime Error):

def solve(n,k):
    if k == 0:
        return 1
    for i in range(len(n)):
        if n[i] != 0:
            break
    n = n[i:]
    if n == []:
        return 0
    l = len(n)
    ans = 0

    # n-1桁からKこ取る
    tmp1 = 1
    for i in range(1, k+1):
        tmp1 = tmp1*9*(l-i)
    for i in range(1, k+1):
        tmp1 = tmp1 // i

    # 最上位から1つ（最上位の数以外）とる。
    tmp2 = n[0]-1
    for i in range(1, k):
        tmp2 = tmp2*9*(l-i)
    for i in range(1, k):
        tmp2 = tmp2 // i

    # 最上位からその数をとる。
    tmp3 = solve(n[1:],k-1)

    ans = tmp1 + tmp2 + tmp3
    return ans

n = list(map(int, input()))
k = int(input())

print(solve(n,k))
Problem p02987 (python)

Fixed submission:
w = input()
a = w[0]
b = w[1]
c = w[2]
d = w[3]
 
if a == b and b != c and c == d:
  print('Yes')
elif a == c and b != c and b == d:
  print('Yes')
elif a == d and a != b and b == c:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c,d = input().split()

if a == b and b != c and c == d:
  print('Yes')
elif a == c and b != c and b == d:
  print('Yes')
elif a == d and a != b and b == c:
  print('Yes')
else:
  print('No')
Problem p02998 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
xy = [[[] for _ in range(10**5+1)] for __ in range(2)]

for _ in range(n):
    x,y = map(int,input().split())
    xy[0][x].append(y)
    xy[1][y].append(x)

ans = 0
used = [[False for _ in range(10**5+1)] for __ in range(2)]

def dfs(i,flag):
    for v in xy[flag][i]:
        if not used[1-flag][v]:
            used[1-flag][v] = True
            dfs(v,1-flag)
            count[1-flag] += 1

for i in range(10**5+1):
    if xy[0][i] and not used[0][i]:
        used[0][i] = True
        count = [1,0]
        dfs(i,0)
        ans += count[0]*count[1]

ans -= n
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
xy = [[[] for _ in range(10**5+1)] for __ in range(2)]

for _ in range(n):
    x,y = map(int,input().split())
    xy[0][x].append(y)
    xy[1][y].append(x)

ans = 0
used = [[False for _ in range(10**5+1)] for __ in range(2)]

def dfs(i,flag):
    for v in xy[flag][i]:
        if not used[1-flag][v]:
            used[1-flag][v] = True
            dfs(v,1-flag)
            count[1-flag] += 1

for i in range(10**5+1):
    if xy[0][i] and not used[0][i]:
        used[0][i] = True
        count = [1,0]
        dfs(i,0)
        ans += count[0]*count[1]

ans -= n
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
xy = [[[] for _ in range(10**5+1)] for __ in range(2)]

for _ in range(n):
    x,y = map(int,input().split())
    xy[0][x].append(y)
    xy[1][y].append(x)

ans = 0
used = [[False for _ in range(10**5+1)] for __ in range(2)]

def dfs(i,flag):
    for v in xy[flag][i]:
        if not used[1-flag][v]:
            used[1-flag][v] = True
            dfs(v,1-flag)
            count[1-flag] += 1

for i in range(10**5+1):
    if xy[0][i] and not used[0][i]:
        used[0][i] = True
        count = [1,0]
        dfs(i,0)
        ans += count[0]*count[1]

ans -= n
print(ans)
Problem p03013 (python)

Fixed submission:
def howmany(n):
    if n <= 1:
        return n
    result = [1, 0, 0, 1]
    matrix = [1, 1, 1, 0]
    while n > 0:
        if n % 2:
            result = mul(matrix, result)
        matrix = mul(matrix, matrix)
        n //= 2
    return result[2]

def mul(a, b):
    return [a[0]*b[0] + a[1]*b[2],
            a[0]*b[1] + a[1]*b[3],
            a[2]*b[0] + a[3]*b[2],
            a[2]*b[1] + a[3]*b[3]]


n,m = map(int,input().split())

x = 1
a = [0]*(m+2)
a[0] = -1
a[m+1] = n

if m == 0:
    print(howmany(n+1) % 1000000007)
else:
    for i in range(1,m+1):
        a[i] = int(input())

    if all(a[i+1]-a[i] != 1 for i in range(1,m)):
        for i in range(1,m+1):
            if a[i] - a[i-1] > 1:
                x *= howmany(a[i] - a[i-1] -1)
        if a[m] + 1 == n:
            print(x % 1000000007)
        else:
            x *= howmany(a[m+1]-a[m])
            print(x % 1000000007)
    else: print(0)

Buggy submission (verdict: Runtime Error):
def howmany(z):
    if z == -1 or z == 0 or z == 1:
        return(1)
    elif z == 2:
        return(2)
    else:
        return howmany(z-1) + howmany(z-2)

n,m = map(int,input().split())

x = 1
a = [0]*(m+2)
a[0] = -1
a[m+1] = n

for i in range(1,m+1):
    a[i] = int(input())

if m == 0:
    print(howmany(n))

elif all(a[i+1]-a[i] != 1 for i in range(1,m+1)):
    for i in range(1,m+1):
        x *= howmany(a[i] - a[i-1] -2)
    x *= howmany(a[m+1]-a[m]-1)
    print(x % 1000000007)

else: print(0)

Buggy submission (verdict: Runtime Error):
def howmany(z):
    if z == -1 or z == 0 or z == 1:
        return(1)
    elif z == 2:
        return(2)
    else:
        return howmany(z-1) + howmany(z-2)

n,m = map(int,input().split())

x = 1
a = [0]*(m+2)
a[m+1] = n

a[1] = int(input())
x *= howmany(a[1]-1)

for i in range(2,m+1):
    a[i] = int(input())
    x *= howmany(a[i] - a[i-1] -2)

x *= howmany(a[m+1]-a[m] -1)

if  all(a[i+1]-a[i] != 1 for i in range(1,m+1)):
    print(x % 1000000007)
else: print(0)
Problem p03107 (python)

Fixed submission:
a = input()

print(2* min(a.count('1'),a.count('0') ))

Buggy submission (verdict: Runtime Error):
a = input()

print(2* min(a.count('1'),a.count('0') )
Problem p03725 (python)

Fixed submission:
from collections import deque

h,w,K = map(int,input().split())

maze = [[x for x in input()] for _ in range(h)]

sx = 0
sy = 0

for i in range(h):
    for j in range(w):
        if maze[i][j] == 'S':
            sx = j
            sy = i

d = [[float('inf')]*w for _ in range(h)]
d[sy][sx] = 0

q = deque([[sy,sx]])
c = 0

visited = [[False]*w for _ in range(h)]
visited[sy][sx] = True

while q:
    y,x = q.popleft()
    for j,k in [[1,0],[-1,0],[0,1],[0,-1]]:
        ny,nx = y+j,x+k
        if maze[ny][nx] == '.' and not visited[ny][nx]:
            d[ny][nx] = d[y][x] + 1
            if ny in {0,h-1} or nx in {0,w-1}:
                if d[ny][nx] <= K:
                    print(1)
                    exit()
                else:
                    continue
            else:
                visited[ny][nx] = True
                if d[ny][nx] == K:
                    continue
                else:
                    q.append([ny,nx])
    

def BFS(sy,sx):
    visited = [[-1]*w for _ in range(h)]
    q = deque([[sy,sx]])
    visited[sy][sx] = 0
    while q:
        y,x = q.popleft()
        if y == 0 or y == h-1 or x == 0 or x == w-1:
            return visited[y][x]
        for l,k in [[1,0],[-1,0],[0,1],[0,-1]]:
            new_y,new_x = y+l,x+k
            if visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                q.append([new_y,new_x])

ans = float('inf')

for i in range(h):
    for j in range(w):
        if d[i][j] <= K:
            ans = min(ans,min(i,h-1-i,j,w-1-j))

print((ans-1) // K +2)

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

h,w,K = map(int,input().split())

maze = [[x for x in input()] for _ in range(h)]

sx = 0
sy = 0

for i in range(h):
    for j in range(w):
        if maze[i][j] == 'S':
            sx = j
            sy = i

d = [[float('inf')]*w for _ in range(h)]
d[sy][sx] = 0

q = deque([[sy,sx]])
c = 0

while q:
    y,x = q.popleft()
    for j,k in [[1,0],[-1,0],[0,1],[0,-1]]:
        ny,nx = y+j,x+k
        if maze[ny][nx] == '.':
            d[ny][nx] = d[y][x] + 1
            if ny in {0,h-1} or nx in {0,w-1}:
                if d[ny][nx] <= k:
                    print(1)
                    exit()
                else:
                    continue
            else:
                q.append([ny,nx])
                c += 1
    if c >= 4*K**2:
        break
    
visited = [[-1]*w for _ in range(h)]

def BFS(sy,sx):
    q = deque([[sy,sx]])
    visited[sy][sx] = 0
    while q:
        y,x = q.popleft()
        if y == 0 or y == h-1 or x == 0 or x == w-1:
            return visited[y][x]
        for j,k in [[1,0],[-1,0],[0,1],[0,-1]]:
            new_y,new_x = y+j,x+k
            if visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                q.append([new_y,new_x])

ans = float('inf')

for i in range(h):
    for j in range(w):
        if d[i][j] <= K:
            ans = min(ans,BFS(i,j))

print((ans-1) // K +2)
Problem p02831 (python)

Fixed submission:
import numpy as np
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z
        
def lcm(m, n):
    return int(m*n/gcd(m,n))

A, B = list(map(int,input().split()))
ans = lcm(A, B)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B = list(map(int,input().split()))
ans = np.lcm(A, B)
print(ans)
Problem p02912 (python)

Fixed submission:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    from collections import deque


    n, m = map(int, input().split())

    aa = list(map(int, input().split()))
    aa.sort(reverse=True)
    aa = deque(aa)

    if n == 1:
        a = aa.popleft()
        for _ in range(m):
            a = a // 2
        print(a)
        exit()

    top = aa.popleft()

    deque_list = [aa, deque()]
    top_list = [deque_list[0].popleft(), top//2]


    for _ in range(m-1):
        max_num = max(top_list)
        max_index = top_list.index(max_num)
        try:
            deque_list[max_index+1].append(max_num//2)
        except IndexError:
            deque_list.append(deque())
            top_list.append(max_num//2)
        if top_list[max_index+1] == -1:
            top_list[max_index+1] = deque_list[max_index+1].popleft()
        try:
            top_list[max_index] = deque_list[max_index].popleft()
        except IndexError:
            top_list[max_index] = -1

    ans = 0
    for num in top_list:
        ans += max(0, num)
    for one_deque in deque_list:
        ans += sum(one_deque)
    print(ans)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    from collections import deque


    n, m = map(int, input().split())

    aa = list(map(int, input().split()))
    aa.sort(reverse=True)
    aa = deque(aa)

    if n == 1:
        a = aa.popleft()
        for _ in range(m):
            a = a // 2
        print(a)
        exit()

    top = aa.popleft()

    deque_list = [aa, deque()]
    top_list = [deque_list[0].popleft(), top//2]


    for _ in range(m-1):
        max_num = max(top_list)
        max_index = top_list.index(max_num)
        try:
            deque_list[max_index+1].append(max_num//2)
        except IndexError:
            deque_list.append(deque())
            top_list.append(max_num//2)
        if top_list[max_index+1] == 0:
            top_list[max_index+1] = deque_list[max_index+1].popleft()
        try:
            top_list[max_index] = deque_list[max_index].popleft()
        except IndexError:
            top_list[max_index] = 0

    ans = sum(top_list)
    for one_deque in deque_list:
        ans += sum(one_deque)
    print(ans)
Problem p02623 (python)

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

count = 0
ar = [0] * (N + 1)
br = [0] * (M + 1)

for i, v in enumerate(A):
    ar[i+1] = ar[i] + v

for i, v in enumerate(B):
    br[i+1] = br[i] + v

max_read = 0
j = M
for i in range(N+1):
    if ar[i] > K:
        break
    while br[j] > K - ar[i]:
        j -= 1
    max_read = max(max_read, i+j)

print(max_read)

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

count = 0
ar = [0] * (N)
br = [0] * (M)

ar[0] = A[0]
for i, v in enumerate(A):
    ar[i+1] = ar[i] + v

br[0] = B[0]
for i, v in enumerate(B):
    br[i+1] = br[i] + v

max_read = 0
j = M
for i in range(N+1):
    rest = K - ar[i]
    if rest <= 0:
        break
    while br[j] > K - ar[i]:
        j -= 1

    max_read = max(max_read, i+j)

print(max_read)
Problem p02779 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = {}

distinct = True
for i in a:
    if i in m:
        distinct = False
        break
    m[i] = 1
    
if distinct:
    print("YES")
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split(' ')))
bucket = [0]*1000000001

distinct = True
for i in a:
    if bucket[i] != 0:
        distinct = False
        break
    bucket[i] += 1
    
if distinct:
    print("Yes")
else:
    print('No')
Problem p02793 (python)

Fixed submission:
from fractions import gcd

def calc_lcm(x, y):
    return (x * y) // gcd(x, y)

n = int(input())
a = list(map(int, input().split(' ')))

lcm = a[0]
for i in range(1, n):
    lcm = calc_lcm(lcm, a[i])

s = 0
for i in range(n):
    s += lcm // a[i]

ans = s % 1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy

n = int(input())
a = list(map(int, input().split(' ')))

lcm = numpy.lcm.reduce(a)

s = 0
for i in range(n):
    s += lcm // a[i]

ans = s % 1000000007
print(ans)
Problem p03127 (python)

Fixed submission:
import fractions

def monsters_battle_royal(n, a):
    gcd = a[0]
    for i in range(1, n):
        gcd = fractions.gcd(gcd, a[i])
    return gcd

n = int(input())
a = list(map(int, input().split()))

ans = monsters_battle_royal(n, a)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

def monsters_battle_royal(n, a):
    gcd = a[0]
    for i in range(1, n):
        gcd = fractions.gcd(gcd, a[i])
    return gcd

n = int(input())
a = list(map(int, input()))

ans = monsters_battle_royal(n, a)
print(ans)
Problem p02699 (python)

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

if int(W)>=int(S):
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
N=int(input())
S=[input() for i in range(N)]
print(len(set(S)))
Problem p02779 (python)

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

B=set(A)
if len(A)==len(B):
    print("YES")
else:
    print("NO")

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

B=set(A)
if len(A)=len(B):
    print("YES")
else:
    print("NO")
Problem p02831 (python)

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

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

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())

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

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())

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

print(lcm(A,B))
Problem p03017 (python)

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

if A<B<C<D:
    a=True
    for i in range(A-1,D-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        print("Yes")
elif A<C<B<D:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-1,D-2):
            if S[i]==S[i+1]=="#":
                print("No")
                a=False
                break
    if a==True:
        print("Yes")
elif A<B<D<C:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            b=True
            a=False
            break
    if a==True:
        b=True
        for i in range(B-2,D-2+1):
            if S[i]==S[i+1]==S[i+2]:
                b=False
                break
    if b==False:
        print("Yes")
    elif b==True:
        print("No")

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

if A<B<C<D:
    a=True
    for i in range(A-1,D-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        print("Yes")
elif A<C<B<D:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-1,D-2):
            if S[i]==S[i+1]=="#":
                print("No")
                a=False
                break
    if a==True:
        print("Yes")
elif A<B<D<C:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        b=True
        for i in range(B-2,D-2+1):
            if S[i]==S[i+1]==S[i+2]:
                b=False
                break
    if b==False:
        print("Yes")
    elif b==True:
        print("No")

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

if A<B<C<D:
    a=True
    for i in range(A-1,D-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        print("Yes")
elif A<C<B<D:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-1,D-2):
            if S[i]==S[i+1]=="#":
                print("No")
                a=False
                break
    if a==True:
        print("Yes")
elif A<B<D<C:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-2,D-2+1):
            if S[i]==S[i+1]==S[i+2]:
                b=False
                break
    if b==False:
        print("Yes")
    elif b==True:
        print("No")
Problem p02627 (python)

Fixed submission:
IN = input()
if IN.isupper():
  print("A")
else:
  print("a")

Buggy submission (verdict: Runtime Error):
IN = input()
if IN.isupper():
  return "A"
else:
  return "a"
Problem p02693 (python)

Fixed submission:
K = int(input())

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

flag = False
for x in range(A, B+1):
  if x % K == 0:
    flag = True


if flag:
  print("OK")
else: 
  print("NG")

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

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

flag = false
for x in range(A, B+1):
  if x % K == 0:
    flag = True


if flag:
  print("OK")
else: 
  print("NG")
Problem p02726 (python)

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

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

print(*ans[1:], sep='\n')

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

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

print(*ans([1:], sep='\n'))
Problem p02954 (python)

Fixed submission:
S = input()
N = len(S)
left_R = [0] * N
right_L = [N-1] * N

for i, s in enumerate(S[1:], 1):
  left_R[i] = i if s == 'R' else left_R[i-1]

for i, s in enumerate(S[N-2::-1], 1):
  i = N-1-i
  right_L[i] = i if s == 'L' else right_L[i+1]

answer = [0] * N
for i, (s, R, L) in enumerate(zip(S, left_R, right_L)):
  if s == 'L':
    j = left_R[i]
    if (i+j) & 1:
      j += 1
  else:
    j = right_L[i]
    if (i+j) & 1:
      j -= 1
  answer[j] += 1
print(' '.join(map(str, answer)))

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
left_R = [0] * N
right_L = [N-1] * N

for i, s in enumerate(S[1:], 1):
  left_R[i] = i if s == 'R' else left_R[i-1]

for i, s in enumerate(S[N-2::-1], 1):
  i = N-1-i
  right_L[i] = i if s == 'L' else right_L[i+1]

anser = [0] * N
for i, (s, R, L) in enumerate(zip(S, left_R, right_L)):
  if s == 'L':
    j = left_R[i]
    if (i+j) & 1:
      j += 1
  else:
    j = right_L[i]
    if (i+j) & 1:
      j -= 1
  answer[j] += 1
print(' '.join(map(str, answer)))