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

Fixed submission:
import sys
sys.setrecursionlimit(15000)

n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

key = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
#k = [1, 7, 4, 5, 3, 2, 9, 6, 8]

dpi = [-1<<50] * 9 + [0]
def dp(i):
    '''i should be started from 1'''

    ans = []
    for j in a:
        ans.append(dpi[len(dpi) - key[j]] + 1)
    dpi.append(max(ans))

    if i == n:
        return dpi[len(dpi) - 1]
    else:
        return dp(i + 1)

i = dp(1)
a.sort()

s = ''
cur = -1
for j in range(i):
    for k in reversed(a):
        if dpi[cur-key[k]] == dpi[cur] - 1:
            s += str(k)
            cur -= key[k] 
            break
        else:
            continue

print(int(s))

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

n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

key = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
#k = [1, 7, 4, 5, 3, 2, 9, 6, 8]

dpi = [-1<<50] * 9 + [0]
def dp(i):
    '''i should be started from 1'''

    ans = []
    for j in a:
        ans.append(dpi[len(dpi) - key[j]] + 1)
    dpi.append(max(ans))

    if i == n:
        return dpi[len(dpi) - 1]
    else:
        return dp(i + 1)

i = dp(1)
a.sort()

s = ''
cur = -1
for j in range(i):
    for k in reversed(a):
        if dpi[cur-key[k]] == dpi[cur] - 1:
            s += str(k)
            cur -= key[k] 
            break
        else:
            continue

print(int(s))

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

key = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
#k = [1, 7, 4, 5, 3, 2, 9, 6, 8]

dpi = [-1<<50] * 9 + [0]
def dp(i):
    '''i should be started from 1'''

    ans = []
    for j in a:
        ans.append(dpi[len(dpi) - key[j]] + 1)
    dpi.append(max(ans))

    if i == n:
        return dpi[len(dpi) - 1]
    else:
        return dp(i + 1)

i = dp(1)
a.sort()

s = ''
cur = -1
for j in range(i):
    for k in reversed(a):
        if dpi[cur-key[k]] == dpi[cur] - 1:
            s += str(k)
            cur -= key[k] 
            break
        else:
            continue

print(int(s))

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

key = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
#k = [1, 7, 4, 5, 3, 2, 9, 6, 8]

dpi = [-1<<50] * 9 + [0]
def dp(i):
    '''i should be started from 1'''

    ans = []
    for j in a:
        ans.append(dpi[len(dpi) - key[j]] + 1)
    dpi.append(max(ans))

    if i == n:
        return dpi[len(dpi) - 1]
    else:
        return dp(i + 1)

i = dp(1)
a.sort()

s = ''
cur = -1
for j in range(i):
    for k in reversed(a):
        if dpi[cur-key[k]] == dpi[cur] - 1:
            s += str(k)
            cur -= key[k] 
            break
        else:
            continue

print(int(s))
Problem p03152 (python)

Fixed submission:
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

a = set(a); b = set(b)
#print(a, b)

def k(a, b, n, m):
    s = 1
    x, y = 0, 0
    if (n * m not in a) or (n * m not in b):
        return 0
    for i, j in enumerate(reversed(range(n * m))):

        if (j + 1 in a) and (j + 1 in b):
            x += 1; y += 1
            #continue
        elif j + 1 in a:
            y += 1
            s *= x
        elif j + 1 in b:
            x += 1
            s *= y
        else:
            if x * y - i > 0:
                s *= x * y - i
            else:
                s = 0
                break
        if s > 10 ** 9 + 7:
            s %= 10 ** 9 + 7
        #print(i, j + 1, 'x=', x, 'y=', y, 's=', s)
    return s

if len(a) != n or len(b) != m:
    print(0)
else:
    print(k(a, b, n, m))

# TimeLimitExceeded
# indexで一個ずつ見つけていくのは時間がかかるということ。

Buggy submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

a.sort(reverse=True); b.sort(reverse=True)
c, s = 0, 1

for i in reversed(range(n * m)):
    try:
        x = a.index(i + 1) + 1
        row = 1
    except ValueError:
        row = 0
    try:
        y = b.index(i + 1) + 1
        column = 1
    except ValueError:
        column = 0

    if row * column:
        s *= 1
    elif not row * column and row + column:
        s *= column * x + row * y
    else:
        if x * y - c > 0:
            s *= x * y - c
        else:
            s = 0
            break
    c += 1
    if s > 10 ** 9 + 7:
        s %= 10 ** 9 + 7

print(s)
Problem p03555 (python)

Fixed submission:
#!/usr/bin/env python3
from sys import stdin, stdout

def rint():
   return map(int, stdin.readline().split())
#lines = stdin.readlines()

a = input()
b = input()
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
   print("YES")
else:
   print("NO")

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

def rint():
   return map(int, stdin.readline().split())
lines = stdin.readlines()

a = input()
b = input()
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
   print("YES")
else:
   print("NO")
Problem p02866 (python)

Fixed submission:
import collections
import sys
def read_a_integer():
    return int(sys.stdin.readline())

def read_a_list(dtype):
    return list(map(dtype, sys.stdin.readline().split()))


def main():
    N = read_a_integer()
    D = read_a_list(int)
    if D[0] != 0:
        print(0)
        return
    counter = collections.Counter(D)
    if counter[0] != 1:
        print(0)
        return
    max_D = max(D)
    ans = 1
    for i in range(2, max_D + 1):
        if i not in counter:
            print(0)
            return
        ans = (ans * (counter[i-1] ** counter[i])) % 998244353
    print(ans)
    # brute_force(N, D)

        


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import collections
import sys
import itertools
from tqdm import tqdm
from pprint import pprint

def read_a_integer():
    return int(sys.stdin.readline())

def read_a_list(dtype):
    return list(map(dtype, sys.stdin.readline().split()))

def brute_force(N, D):
    def get_distance(G):
        queue = collections.deque()
        queue.append(1)
        distance = [-1] * N
        distance[0] = 0

        while queue:
            u = queue.popleft()
            for v in G[u]:
                if distance[v-1] == -1:
                    distance[v-1] = distance[u-1] + 1
                    queue.append(v)
        return distance

    ans = 0
    all_edges = [(u, v) for u in range(1, N+1) for v in range(1+u, N+1)]
    for graph in tqdm(itertools.combinations(all_edges, N - 1)):
        G = collections.defaultdict(list)
        # print(graph)
        # graph = [(1,4),(1,7),(3,4),(4,5),(4,6),(2,3)]
        for u, v in graph:
            G[u].append(v)
            G[v].append(u)
        # print(G)
        # exit(0)
        distance = get_distance(G)
        # print(distance)
        if distance == D:
            ans += 1
            print("-" * 50)
            pprint(G)
            print("-" * 50)
        # break
    print(ans)


def main():
    N = read_a_integer()
    D = read_a_list(int)
    if D[0] != 0:
        print(0)
        return
    counter = collections.Counter(D)
    if counter[0] != 1:
        print(0)
        return
    max_D = max(D)
    ans = 1
    for i in range(2, max_D + 1):
        if i not in counter:
            print(0)
            return
        ans = (ans * (counter[i-1] ** counter[i])) % 998244353
    print(ans)
    # brute_force(N, D)

        


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

Fixed submission:
import sys


def check(A, B):
    if A > 8 or B > 8:
        return False
    return True


ret = check(*tuple(map(int, sys.stdin.readline().split())))
if ret:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
import sys


def check(A, B):
    if A > 8 or B > 8:
        return False
    return True


ret = check(
    int(sys.stdin.readline()),
    int(sys.stdin.readline()))
if ret:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
import sys


def check(A, B):
    if A > 8 or B > 8:
        return False
    return True


ret = check(
    int(sys.stdin.readline()),
    int(sys.stdin.readline()))
if ret:
    print('Yay!')
else:
    print(':(')
Problem p03341 (python)

Fixed submission:
n = int(input())
s = input()
a = [0] * n
if s[0] == 'W': a[0] = 1
for i in range(1, n):
    c = s[i]
    if c == 'E':
        a[i] = a[i - 1]
    else:
        a[i] = a[i - 1] + 1
b = [0] * n
if s[n - 1] == 'E': b[n - 1] = 1
for i in range(n - 2, -1, -1):
    c = s[i]
    if c == 'W':
        b[i] = b[i + 1]
    else:
        b[i] = b[i + 1] + 1
m = n
for i in range(n):
    m = min(m, a[i] + b[i])
print(m - 1)

Buggy submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
a = [int(x) for x in input().split()]
m = None
for x in a:
    b = []
    c = []
    for y in a:
        if y < x:
            if len(c) >= k:
                c.sort()
                b.extend(c[:len(c) - k + 1])
            c = []
        else:
            c.append(y)
    if len(c) >= k:
        c.sort()
        b.extend(c[:len(c) - k + 1])
    if len(b) >= q:
        b.sort()
        if m is None or m > b[q - 1] - x: m = b[q - 1] - x
print(m)
Problem p03343 (python)

Fixed submission:
n, k, q = map(int, input().split())
a = [int(x) for x in input().split()]
m = None
for x in a:
    b = []
    c = []
    for y in a:
        if y < x:
            if len(c) >= k:
                c.sort()
                b.extend(c[:len(c) - k + 1])
            c = []
        else:
            c.append(y)
    if len(c) >= k:
        c.sort()
        b.extend(c[:len(c) - k + 1])
    if len(b) >= q:
        b.sort()
        if m is None or m > b[q - 1] - x: m = b[q - 1] - x
print(m)

Buggy submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
a = [(int(x), i) for i, x in enumerate(input().split())]
a.sort()
m = a[q - 1][0] - a[0][0]
v = []
for i in range(1, n - q + 1):
    mi = a[q - 1 + i][0] - a[i][0]
    bis = list(range(i))
    d = 0
    for ai in range(i, i + q):
        ok = True
        for bi in bis:
            if abs(a[bi][1] - a[ai][1]) < k:
                bis.append(ai)
                ok = False
                con = False
                d += 1
                if i + q + d - 1 < n:
                    mi = a[q + i + d - 1][0] - a[i][0]
                    if mi < m:
                        con = True
                break
        if con: continue
        break
    if ok:
        m = mi
print(m)

Buggy submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
a = [(int(x), i) for i, x in enumerate(input().split())]
a.sort()
m = a[q - 1][0] - a[0][0]
v = []
for i in range(1, n - q + 1):
    mi = a[q - 1 + i][0] - a[i][0]
    bis = list(range(i))
    for ai in range(i, i + q):
        ok = True
        for bi in bis:
            if abs(a[bi][1] - a[ai][1]) < k:
                bis.append(ai)
                ok = False
                con = False
                if i + q < n:
                    mi = a[q + i][0] - a[i][0]
                    if mi < m:
                        con = True
                break
        if con: continue
        break
    if ok:
        m = mi
print(m)
Problem p03355 (python)

Fixed submission:
s = input()
k = int(input())
t = set()
for i in range(1, min(len(s), k, 5) + 1):
  for j in range(len(s) - i + 1):
	  t.add(s[j:i + j])
print(sorted(list(t))[k - 1])

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

n, m = map(int, input().split())
p = [int(x) - 1 for x in input().split()]
g = [list() for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)
v = [False] * n
s = set()
def dfs(i):
    if v[i]: return
    s.add(i)
    v[i] = True
    for k in g[i]: dfs(k)

c = 0
for i in range(n):
    if v[i]: continue
    s = set()
    dfs(i)
    t = {p[k] for k in s}
    c += len(s.intersection(t))
print(c)
Problem p03381 (python)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
x = sorted(a)
m1 = x[n // 2]
m2 = x[n // 2 - 1]
for i in range(n):
    if a[i] < m1: print(m1)
    else: print(m2)

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

h, w = map(int, input().split())
s = [None] * h
ss = [None] * h
for i in range(h):
    s[i] = input()
    ss[i] = sorted(s[i])

def c(x, y):
    l = len(y)
    if l == w: return True
    if l % 2 == 0:
        for i in range(w):
            if i not in y:
                y.append(i)
                if c(x, y): return True
                y.pop()
    else:
        for i in range(w):
            if i not in y:
                ok = True
                for j in range(0, h, 2):
                    if j + 1 == h: k = j
                    else: k = j + 1
                    a, b = x[j], x[k]
                    d, e = y[-1], i
                    if s[a][d] == s[b][e] and s[a][e] == s[b][d]:
                        continue
                    ok = False
                if ok:
                    y.append(i)
                    if c(x, y): return True
                    y.pop()
    return False
    
def r(x):
    l = len(x)
    if l == h:
        for i in range(w):
            if c(x, [i]): return True
    if l % 2 == 0:
        for i in range(h):
            if i not in x:
                x.append(i)
                if r(x): return True
                x.pop()
    else:
        for i in range(h):
            if i not in x and ss[x[-1]] == ss[i]:
                x.append(i)
                if r(x): return True
                x.pop()
    return False
            

ok = True
for i in range(h):
    ok = r([i])
    if ok: break
if ok: print('YES')
else: print('NO')
Problem p03436 (python)

Fixed submission:
import sys
import Queue

sys.setrecursionlimit(1000000)

def s(m, h, w, d, q):
    if q.empty(): return d[h - 1][w - 1]
    k, i, j = q.get()
    if i > 0 and m[i - 1][j] == '.' and k + 1 < d[i - 1][j]:
        d[i - 1][j] = k + 1
        q.put((k + 1, i - 1, j))
    if i < h - 1 and m[i + 1][j] == '.' and k + 1 < d[i + 1][j]:
        d[i + 1][j] = k + 1
        q.put((k + 1, i + 1, j))
    if j > 0 and m[i][j - 1] == '.' and k + 1 < d[i][j - 1]:
        d[i][j - 1] = k + 1
        q.put((k + 1, i, j - 1))
    if j < w - 1 and m[i][j + 1] == '.' and k + 1 < d[i][j + 1]:
        d[i][j + 1] = k + 1
        q.put((k + 1, i, j + 1))
    return s(m, h, w, d, q)

h, w = map(int, raw_input().split())
m = [raw_input()[:w] for _ in range(h)]
q = Queue.PriorityQueue()
d = [None] * h
for i in range(h):
    d[i] = [1000000] * w
d[0][0] = 1
for i in range(h):
    for j in range(w):
        if m[i][j] == '.':
            q.put((d[i][j], i, j))
c = s(m, h, w, d, q)
if c == 1000000: print -1
else:
    a = 0
    for row in m:
        a += row.count('#')
    print h * w - c - a

Buggy submission (verdict: Runtime Error):
import Queue

def s(m, v, q):
    if q.empty(): return -1
    k, i, j = q.get()
    if i == len(m) - 1 and j == len(m[i]) - 1: return k
    if i > 1 and m[i - 1][j] == '.' and (i - 1, j) not in v:
        q.put((k + 1, i - 1, j))
        v.add((i - 1, j))
    if i < len(m) - 1 and m[i + 1][j] == '.' and (i + 1, j) not in v:
        q.put((k + 1, i + 1, j))
        v.add((i + 1, j))
    if j > 1 and m[i][j - 1] == '.' and (i, j - 1) not in v:
        q.put((k + 1, i, j - 1))
        v.add((i, j - 1))
    if j < len(m[i]) - 1 and m[i][j + 1] == '.' and (i, j + 1) not in v:
        q.put((k + 1, i, j + 1))
        v.add((i, j + 1))
    return s(m, v, q)

h, w = map(int, raw_input().split())
m = [raw_input() for _ in range(h)]
q = Queue.PriorityQueue()
q.put((1, 0, 0))
v = set((0, 0))
c = s(m, v, q)
if c == -1: print -1
else:
    a = 0
    for row in m:
        a += row.count('#')
    print h * w - c - a
Problem p03550 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10000)

cm = None
cM = None
def m(a, n, i, w):
    if w in cm[i]: return cm[i][w]
    m = abs(a[n - 1] - w)
    for k in range(i, n - 1):
        m = min(m, abs(M(a, n, k + 1, a[k])))
    cm[i][w] = m
    return m

def M(a, n, i, w):
    if w in cM[i]: return cM[i][w]
    M = abs(a[n - 1] - w)
    for k in range(i, n - 1):
        M = max(M, abs(m(a, n, k + 1, a[k])))
    cM[i][w] = M
    return M

n, z, w = map(int, raw_input().split())
a = map(int, raw_input().split())
cm = [dict() for _ in range(n)]
cM = [dict() for _ in range(n)]
print M(a, n, 0, w)

Buggy submission (verdict: Runtime Error):
cm = None
cM = None
def m(a, n, i, w):
    if w in cm[i]: return cm[i][w]
    m = abs(a[n - 1] - w)
    for k in range(i, n - 1):
        m = min(m, abs(M(a, n, k + 1, a[k])))
    cm[i][w] = m
    return m

def M(a, n, i, w):
    if w in cM[i]: return cM[i][w]
    M = abs(a[n - 1] - w)
    for k in range(i, n - 1):
        M = max(M, abs(m(a, n, k, a[k])))
    cM[i][w] = M
    return M

n, z, w = map(int, raw_input().split())
a = map(int, raw_input().split())
cm = [dict() for _ in range(n)]
cM = [dict() for _ in range(n)]
print M(a, n, 0, w)
Problem p03855 (python)

Fixed submission:
import sys
sys.setrecursionlimit(20000)

n, k, l = map(int, input().split())
a = [list() for _ in range(n)]
b = [list() for _ in range(n)]
for _ in range(k):
    p, q = [int(x) - 1 for x in input().split()]
    a[p].append(q)
    a[q].append(p)
for _ in range(l):
    r, s = [int(x) - 1 for x in input().split()]
    b[r].append(s)
    b[s].append(r)

def g(a, b, i, k):
    b[i] = k
    for e in a[i]:
        if b[e] is not None: continue
        g(a, b, e, k)

def f(a, b):
    k = 0
    for i in range(n):
        if b[i] is not None: continue
        g(a, b, i, k)
        k += 1

c = [None] * n
f(a, c)
d = [None] * n
f(b, d)
e = {}
for i in range(n):
    k = (c[i], d[i])
    e[k] = e.get(k, 0) + 1

print(' '.join([str(e[(c[i], d[i])]) for i in range(n)]))

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

n, k, l = map(int, input().split())
a = [list() for _ in range(n)]
b = [list() for _ in range(n)]
for _ in range(k):
    p, q = [int(x) - 1 for x in input().split()]
    a[p].append(q)
    a[q].append(p)
for _ in range(l):
    r, s = [int(x) - 1 for x in input().split()]
    b[r].append(s)
    b[s].append(r)

def g(a, b, i, k):
    b[i] = k
    for e in a[i]:
        if b[e] is not None: continue
        g(a, b, e, k)

def f(a, b):
    k = 0
    for i in range(n):
        if b[i] is not None: continue
        g(a, b, i, k)
        k += 1

c = [None] * n
f(a, c)
d = [None] * n
f(b, d)
e = {}
for i in range(n):
    k = (c[i], d[i])
    e[k] = e.get(k, 0) + 1

print(' '.join([str(e[(c[i], d[i])]) for i in range(n)]))

Buggy submission (verdict: Runtime Error):
n, k, l = map(int, input().split())
a = [list() for _ in range(n)]
b = [list() for _ in range(n)]
for _ in range(k):
    p, q = [int(x) - 1 for x in input().split()]
    a[p].append(q)
    a[q].append(p)
for _ in range(l):
    r, s = [int(x) - 1 for x in input().split()]
    b[r].append(s)
    b[s].append(r)

def g(a, b, i, k):
    b[i] = k
    for e in a[i]:
        if b[e] is not None: continue
        g(a, b, e, k)

def f(a, b):
    k = 0
    for i in range(n):
        if b[i] is not None: continue
        g(a, b, i, k)
        k += 1

c = [None] * n
f(a, c)
d = [None] * n
f(b, d)
e = {}
for i in range(n):
    k = (c[i], d[i])
    e[k] = e.get(k, 0) + 1

print(' '.join([str(e[(c[i], d[i])]) for i in range(n)]))
Problem p04014 (python)

Fixed submission:
import math

n = int(input())
s = int(input())
f = None
for i in range(2, math.ceil(math.sqrt(n))):
    c = 0
    k = n
    while k > 0:
        c += k % i
        k //= i
    if c == s:
        f = i
        break
if f is None:
    for i in range(int(math.sqrt(n)), 1, -1):
        b = n // i
        k = n
        c = 0
        while k > 0:
            c += k % b
            k //= b
        if s >= c and (s - c) % i == 0 and b - (s - c) // i > n // (i + 1):
            f = b - (s - c) // i
            break
if f is None:
    if s == n: f = n + 1
    elif s <= (n + 1) // 2: f = n - s + 1
    elif s == 1: f = n
if f is None: print(-1)
else: print(f)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = int(input())
f = None
for i in range(2, math.ceil(math.sqrt(n))):
    c = 0
    k = n
    while k > 0:
        c += k % i
        k //= i
    if c == s:
        f = i
        break
if f is None:
    for i in range(int(math.sqrt(n)), 1, -1):
        b = n // i
        k = b
        while k > 0:
            c += k % b
            k //= b
        if (s - c) % i == 0 and b + (s - c) // i < n // (i + 1):
            print(i, b, c, s - c)
            f = b + (s - c) // i
            break
if f is None and s <= n // 2:
    f = n - s + 1
if f is None: print(-1)
else: print(f)
Problem p02923 (python)

Fixed submission:
import numpy as np
N = input()
N = int(N)
H_ = input().split()
H = np.zeros(N)

for i in range(N):
  H[i] = int(H_[N-i-1])
out = [0]

num = 0
for i in range(N-1):
  if H[i] <= H[i+1]:
    num += 1
  else:
    out.append(num)
    num = 0
out.append(num)

print(np.array(out).max())

Buggy submission (verdict: Runtime Error):
import numpy as np
N = input()
N = int(N)
H_ = input().split()
H = np.zeros(N)

for i in range(N):
  H[i] = int(H_[N-i-1])
H = np.array(H)
out = []

num = 0
for i in range(N-1):
  if H[i] <= H[i+1]:
    num += 1
  else:
    out.append(num)
    num = 0

print(np.array(out).max())
Problem p03068 (python)

Fixed submission:
N=int(input())
S=str(input())
K=int(input())
target = S[K-1]
arr = ''
 
for i in range(N):
	if S[i]==target:
		arr+=target
	else:
		arr+=('*')
 
print(arr)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, S, K = map(int, input().split())

target = S[K-1]

for i in range(N):
	if S[i]==target:
		arr+=target
	else:
		arr+=('*')

print(arr)

Buggy submission (verdict: Runtime Error):
import numpy as np

N=int(input())
S=str(input())
K=int(input())
target = S[K]
arr = ''

for i in range(N):
	if S[i]==target:
		arr+=target
	else:
		arr+=('*')

print(arr)
Problem p03071 (python)

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B)
AA = A * 2 - 1
AB = A + B
BB = B * 2 - 1

print(max(AA, AB, BB))

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = list(map(int,input().split()))
num = 0
tmp = 0

for data in arr:
	if data >= tmp:
		num += 1
		tmp = data

print(num)
Problem p03523 (python)

Fixed submission:
import re

s = raw_input()


x = re.compile('A?KIHA?BA?RA?$')


#print x.match(s)

if x.match(s):
	print 'YES'
else:
	print 'NO'

Buggy submission (verdict: Runtime Error):
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))



char v[]="AKIHABARA@";

char s[100];

int main(void){
	scanf("%s",s);
	int ls=strlen(s);
	int t=0;
	
	rep(i,ls){
		if(v[t]==s[i])t++;
		else if(v[t]=='A' && s[i]==v[t+1]){
			t+=2;
		}
		else{
			puts("NO");
			return 0;
		}
	}
	
	//printf("%c\n",v[t]);
	puts((v[t]=='@' || t==8)?"YES":"NO");
	return 0;
}