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

Fixed submission:
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (W+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (H+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (H+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (H+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
                break
    if flag == False:
        break
if flag:
    print('Yes')
else:
    print('No')
Problem p03425 (python)

Fixed submission:
from itertools import combinations
N = int(input())
names = {}
for _ in range(N):
    S = input()
    if S[0] in 'MARCH':
        if S[0] not in names:
            names[S[0]] = 1
        else:
            names[S[0]] += 1
comb = len(names)
if comb <= 2:
    print(0)
elif comb == 3:
    ret = 1
    for v in names.values():
        ret *= v
    print(ret)
elif comb == 4:
    tmp = 1
    for v in names.values():
        tmp *= v
    ret = 0
    for v in names.values():
        ret += tmp // v
    print(ret)
else:
    ret = 0
    for comb in combinations('MARCH', 3):
        tmp = 1
        for c in comb:
            tmp *= names[c]
        ret += tmp
    print(ret)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
N = int(input())
names = {}
for _ in range(N):
    S = input()
    if S[0] in 'MARCH':
        if S[0] not in names:
            names[S[0]] = 1
        else:
            names[S[0]] += 1
comb = len(names)
if comb <= 2:
    print(0)
elif comb == 3:
    ret = 1
    for v in names.values():
        ret *= v
    print(ret)
elif comb == 4:
    tmp = 1
    for v in names.values():
        tmp *= v
    ret = 0
    for v in names.values():
        ret += tmp // v
    print(ret)
else:
    ret = 0
    for comb in combinations('MARCH', 3):
        tmp = 1
        for c in comb:
            tmp *= names[c]
        ret += comb
    print(ret)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
N = int(input())
names = {}
for _ in range(N):
    S = input()
    if S[0] in 'MARCH':
        if S[0] not in names:
            names[S[0]] = 1
        else:
            names[S[0]] += 1
comb = len(names)
if comb <= 2:
    print(0)
elif comb == 3:
    ret = 1
    for v in names.values():
        ret *= v
    print(ret)
elif comb == 4:
    tmp = 1
    for v in names.values():
        tmp *= v
    ret = 0
    for v in names.values():
        ret += tmp // v
    print(ret)
else:
    ret = 0
    for comb in combinations('MARCH', 3):
        tmp = 1
        for c in comb:
            tmp *= c
        ret += comb
    print(ret)
Problem p03471 (python)

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

def main(Y):
    for i in range(Y//5000+1):
        b = i
        c = Y//1000 - 5*i
        if b//2 + b%2 + c <= N <= b + c:
            for j in range(b//2+1):
                if j + (b - 2*j) + c == N:
                    return (j, b - 2*j, c)
    return (-1, -1, -1)

result = main(Y)
print(' '.join(map(str, result)))

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

def res(a, b, c, A, memo):
    if memo[a][b]:
        return None
    else:
        memo[a][b] = True
    if c < 0:
        return None
    if a+b+c == N:
        A.append([a, b, c])
        return None
    if a+b+c < N:
        return None
    res(a+1, b, c-10, A, memo)
    res(a, b+1, c-5, A, memo)
    return A

has_visit = [[False for i in range(Y//5000+2)] for j in range(Y//10000+2)]
A = res(0, 0, Y//1000, [], has_visit)
result = A[0] if A else [-1, -1, -1]
print(' '.join(map(str, result)))

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

def res(a, b, c, A, memo):
    if memo[a][b]:
        return None
    else:
        memo[a][b] = True
    if c < 0:
        return None
    if a+b+c == N:
        A.append([a, b, c])
        return None
    if a+b+c < N:
        return None
    res(a+1, b, c-10, A, memo)
    res(a, b+1, c-5, A, memo)
    return A

has_visit = [[False for i in range(Y//5000+2)] for j in range(Y//10000+2)]
A = res(0, 0, Y//1000, [], has_visit)
result = A[0] if A else [-1, -1, -1]
print(' '.join(map(str, result)))
Problem p03625 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
x1, x2, x3 = 0, 0, 0
for k, v in c.items():
    if v >= 4:
        if k > x1:
            x1 = k
    if v >= 2:
        if k > x2:
            x2, x3 = k, x2
        elif k > x3:
            x3 = k
print(max(x1*x1, x2*x3))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
x1, x2, x3 = 0, 0, 0
for k, v in c.items():
    if v >= 4:
        if k > maxval1:
            x1 = k
    if v >= 2:
        if k > maxval1:
            x1, x2 = k, x1
        elif k > maxval2:
            x2 = k
        else:
            pass
print(max(x1*x1, x2*x3))
Problem p03645 (python)

Fixed submission:
N, M = map(int, input().split())
d = {}
for _ in range(M):
    a, b = map(int, input().split())
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)
if 1 not in d:
    print('IMPOSSIBLE')
else:
    for i in d[1]:
        if i in d:
            if N in d[i]:
                print('POSSIBLE')
                break
    else:
        print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
d = {}
for _ in range(M):
    a, b = map(int, input().split())
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)
for i in d[1]:
    if N in d[i]:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')
Problem p03695 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
color = [False] * 8
over3200 = 0
for a in A:
    for i in range(8):
        if a < 400*(i+1):
            color[i] = True
            break
    else:
        over3200 += 1
if sum(color):
    print(sum(color), end=' ')
    print(sum(color) + over3200)
else:
    print(1, end=' ')
    print(over3200)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
color = [False] * 8
over3200 = 0
for a in A:
    for i in range(8):
        if 400*i =< a < 400*(i+1):
            color[i] = True
            break
    else:
        over3200 += 1
if sum(color):
    print(sum(color), end=' ')
    print(sum(color) + over3200)
else:
    print(1, end=' ')
    print(over3200)
Problem p03699 (python)

Fixed submission:
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))
sums = sum(S)
if sums % 10 != 0:
    print(sums)
else:
    S.sort()
    for s in S:
        if s % 10 != 0:
            print(sums - s)
            break
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
p1, p2, p5 = 1, 1, 1
for _ in range(N):
    s = int(input())
    if s%10 == 0:
        pass
    elif s%5 == 0:
        p5 *= s
    elif s%2 == 0:
        p2 *= s
    else:
        p1 *= s
print(p1 * (max(p2, p3)))
Problem p03999 (python)

Fixed submission:
from sys import setrecursionlimit; setrecursionlimit(10**9)
S = input()

def res(S, A, B):
    if not S:
        B.append(sum(list(map(int, A))))
        return None
    A += [S[0]]
    res(S[1:], A, B)
    A.pop()
    A[-1] += S[0]
    res(S[1:], A, B)
    return B

if len(S) == 1:
    print(int(S))
else:
    B = res(S[1:], [S[0]], [])
    print(sum(B))

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit; setrecursionlimit(10**9)
S = input()

def res(S, A, B):
    if not S:
        B.append(sum(list(map(int, A))))
        return None
    A += [S[0]]
    res(S[1:], A, B)
    A.pop()
    A[-1] += S[0]
    res(S[1:], A, B)
    return B

B = res(S[1:], [S[0]], [])
print(sum(B))

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

def res(S, A, B):
    if not S:
        B.append(sum(list(map(int, A))))
        return None
    A += [S[0]]
    res(S[1:], A, B)
    A.pop()
    A[-1] += S[0]
    res(S[1:], A, B)
    return B

B = res(S[1:], [S[0]], [])
print(sum(B))
Problem p03662 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
def search(prev, start, stop):
    global nodes, edges
    for neigh in nodes[start]:
        if neigh==prev:
            continue
        if neigh==stop:
            return [stop,start]
        res=search(start,neigh,stop)
        if res!=False:
            res.append(start)
            return res
    return False

def size(prev, curr):
    su=1
    global nodes, edges
    for neigh in nodes[curr]:
        if neigh==prev:
            continue
        su+=size(curr,neigh)
    return su

n=int(input())
nodes=[[] for i in range (n)]
edges=[]
for i in range(n-1):
    line=input().split()
    a=int(line[0])-1
    b=int(line[1])-1
    edges.append([a,b])
    nodes[b].append(a)
    nodes[a].append(b)

res=search(-1,n-1,0)

fennec=(len(res)-1)//2
snuke=fennec+1
snuke=res[snuke]
fennec=res[fennec]
fennecsize=size(snuke,fennec)
snukesize=size(fennec,snuke)

if fennecsize>snukesize:
    print ("Fennec")
else:
    print("Snuke")

Buggy submission (verdict: Runtime Error):
def search(prev, start, stop):
    global nodes, edges
    for neigh in nodes[start]:
        if neigh==prev:
            continue
        if neigh==stop:
            return [stop,start]
        res=search(start,neigh,stop)
        if res!=False:
            res.append(start)
            return res
    return False

def size(prev, curr):
    su=1
    global nodes, edges
    for neigh in nodes[curr]:
        if neigh==prev:
            continue
        su+=size(curr,neigh)
    return su

n=int(input())
nodes=[[] for i in range (n)]
edges=[]
for i in range(n-1):
    line=input().split()
    a=int(line[0])-1
    b=int(line[1])-1
    edges.append([a,b])
    nodes[b].append(a)
    nodes[a].append(b)

res=search(-1,n-1,0)

fennec=(len(res)-1)//2
snuke=fennec+1
snuke=res[snuke]
fennec=res[fennec]
fennecsize=size(snuke,fennec)
snukesize=size(fennec,snuke)

if fennecsize>snukesize:
    print ("Fennec")
else:
    print("Snuke")
Problem p04015 (python)

Fixed submission:

line1=input().split()
n=int(line1[0])
a=int(line1[1])
nums=input().split()
for i in range(n):
    nums[i]=int(nums[i])-a

works={}

works[0]=1
s=0
for x in nums:

    if x>=0:
        for i in range(50*(n+1),-50*(n+1), -1):
            try:
                works[i]+=works[i-x]
            except:
                try:
                    works[i]=works[i-x]
                except:
                    pass
    else:
        for i in range (-50*(n+1),50*(n+1)):
            try:
                works[i+x]+=works[i]
            except:
                try:
                    works[i+x]=works[i]
                except:
                    pass

print (works[0]-1)

Buggy submission (verdict: Runtime Error):

line1=input().split()
n=int(line1[0])
a=int(line1[1])
nums=input().split()
for i in range(n):
    nums[i]=int(nums[i])-a

works={}

print (works)
s=0
for x in nums:

    if x>=0:
        for i in range(50*n,-50*n, -1):
            try:
                works[i]+=works[i-x]
            except:
                try:
                    works[i]=works[i-x]
                except:
                    pass
    else:
        for i in range (-50*n,50*n):
            try:
                works[i+x]+=works[i]
            except:
                try:
                    works[i+x]=works[i]
                except:
                    pass

print (works[0]-1)
Problem p03633 (python)

Fixed submission:
import math as m
from functools import reduce
n,T= int(input()),[]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
for i in range(n):
    T.append(int(input()))
tmp = max(T)
for i in range(n):
    if tmp % T[i] != 0:
        tmp = T[i]//gcd(tmp, T[i])*tmp

print(tmp)

Buggy submission (verdict: Runtime Error):
import math as m
from functools import reduce
n,T= int(input()),[]
def f(a, b):
    return int(a * b // m.gcd(a, b))
for i in range(n):
    T.append(int(input()))
tmp = max(T)
for i in range(n):
    if tmp % T[i] != 0:
        tmp = T[i]//m.gcd(tmp, T[i])*tmp

print(tmp)

Buggy submission (verdict: Runtime Error):
import math as m
from functools import reduce
n,l= int(input()),[]
def f(a, b):
    return int(a * b // m.gcd(a, b))
for i in range(n):
    l.append(int(input()))
print(reduce( lambda x,y: y//m.gcd(x,y)*x, l))

Buggy submission (verdict: Runtime Error):
import math as m
from functools import reduce

n = int(input())
l = []


def f(a, b):
    return int(a * b // m.gcd(a, b))


for i in range(n):
    l.append(int(input()))
print(reduce(f, l))

Buggy submission (verdict: Runtime Error):
import math as m
from functools import reduce

n = int(input())
l = []


def f(a, b):
    return int(a * b / m.gcd(a, b))


for i in range(n):
    l.append(int(input()))
print(reduce(f, l))

Buggy submission (verdict: Runtime Error):
import math as m
from functools import reduce

n=int(input())
l=set([])
def gcd(a,b):
    while a != 0:
        c = a
        a = b % a
        b = c
    return b
def f(a,b):
    return int(a*b/gcd(a,b))
for i in range(n):
    l.add(int(input()))
print(reduce(f,l))

Buggy submission (verdict: Runtime Error):
import math as m
from functools import reduce

n=int(input())
l=set([])
def f(a,b):
    return int(a*b/m.gcd(a,b))
for i in range(n):
    l.add(int(input()))
print(reduce(f,l))
Problem p03068 (python)

Fixed submission:
N = int(input())
S = input()
K = int(input())

compare_str = S[K - 1]
result_str = ''
for s in list(S):
  if compare_str == s:
    result_str += s
  else:
    result_str += '*'
print(result_str)

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

compare_str = S[K - 1]
result_str = ''
for s in list(S):
    if compare_str == s:
	result_str += s
    else:
	result_str += '*'
print(result_str)
Problem p03069 (python)

Fixed submission:
N = int(input())
S = input()

num_of_white = 0
num_of_black = 0

for i in range(1, N):
  if S[i] == '.':
    num_of_white += 1

result = num_of_white

for i in range(1, N):
  if S[i-1] == '#':
    num_of_black += 1
  if S[i] == '.':
    num_of_white -= 1
  
  if result > (num_of_black + num_of_white):
    result = num_of_black + num_of_white

print(result)

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

num_of_white = 0
num_of_black = 0

for i in range(1, N):
  if S[idx] == '.':
    num_of_white += 1

result = num_of_white

for i in range(1, N):
  if S[i-1] == '#':
    num_of_black += 1
  if S[i] == '.':
    num_of_white -= 1
  
  if result > (num_of_black + num_of_white):
    result = num_of_black + num_of_white

print(result)
Problem p03068 (python)

Fixed submission:
import re
# イテレーションのため
input()
S = input()
K = int(input())

print(re.sub(r'[^%s]' %S[K - 1] , '*', S))

Buggy submission (verdict: Runtime Error):
import re
# イテレーションのため
input()
S = input()
K = int(input())

print(re.sub(r'[^%s]' %S[K] , '*', S))
Problem p03101 (python)

Fixed submission:
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

total = H * W
black = h * W + H * w - h * w
white = total - black
print(white)

Buggy submission (verdict: Runtime Error):
H, W = list(map(int, input()))
h, w = list(map(int, input()))

total = H * W
black = h * W + H * w - h * w
white = total - black
print(white)
Problem p03102 (python)

Fixed submission:
import numpy as np
N, M, C = list(map(int, input().split()))
Bs = list(map(int, input().split()))

def is_correct(As):
  return np.inner(As, Bs) + C > 0

As = list(map(int, input().split()))
n = 0
while As:
  if is_correct(As):
    n += 1
  try:
    As = list(map(int, input().split()))
  except:
    break
  
print(n)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M, C = list(map(int, input().split()))
Bs = list(map(int, input().split()))

def is_correct(As):
  return np.inner(As, Bs) + C > 0

As = list(map(int, input().split()))
n = 0
while As:
  if is_correct(As):
    n += 1
  try:
	As = list(map(int, input().split()))
  except:
    break
  
print(n)
Problem p03852 (python)

Fixed submission:
C = ["a","e","i","o","u"]
print("vowel" if input() in C else "consonant")

Buggy submission (verdict: Runtime Error):
c = str(inout())
if c = 'a' or 'e' or 'i' or 'o' or 'u' :
  print('vowel')
else :
  print('consonant')
Problem p03997 (python)

Fixed submission:
a,b,h=map(int,open(0))
 
print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a, b, h = map(int(input).sprit())

print((a + b) * h / 2)
Problem p04011 (python)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
 
if n <= k :
  print(n * x)
else :
  print(k * x + (n - k) * y)

Buggy submission (verdict: Runtime Error):
n, k, x, y = int(input())

if n > k :
  print(k*x+(n-k)*y)
else:
  print(n*x)
Problem p04043 (python)

Fixed submission:
if input() in ('5 5 7', '5 7 5', '7 5 5') :
  print('YES')
else :
  print('NO')

Buggy submission (verdict: Runtime Error):
a = int(input())
if a == 17 :
  print('YES')
else :
  print('NO')
Problem p03067 (python)

Fixed submission:
a,b,c = map(int, input().split())

if a < b :
  ans = 'Yes' if a < c and c < b else 'No'

if a > b :
  ans =  'Yes' if b < c and c < a else 'No'

print(ans)

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

if (a < b):
  return True if a < c and c < b else False

if (a > b):
  return True if b < c and c < a else False
Problem p03080 (python)

Fixed submission:
n = int(input())
s = input()

r = s.count('R')
b = len(s) - r

if (r > b):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

r = s.count('R')

if (r > s // 2):
  print('Yes')
else:
  print('No')
Problem p03086 (python)

Fixed submission:
str = list(input())

tmp = ''
ans = ''
for s in str:
  if (s in ['A', 'T', 'G', 'C']):
    tmp += s
    if (len(tmp) > len(ans)):
      ans = tmp
  else:
    tmp = ''

print(len(ans))

Buggy submission (verdict: Runtime Error):
str = input()
ans = ''
tmp = ''
for s in str:
  if (s in ['A', 'T', 'G', 'C']):
    tmp += s
    if (len(tmp) > len(ans):
        ans = tmp
  else:
    tmp = ''

print(ans)
Problem p03087 (python)

Fixed submission:
n,q = map(int,input().split())
str = input()
q = int(q)
dic = {}

for j in range(len(str)):
  if (j > 0):
    if (str[j-1] == 'A' and str[j] == 'C'):
      dic[j] = dic[j-1] + 1
    else:
      dic[j] = dic[j-1]
  else:
    dic[j] = 0

for i in range(q):
  s,e = map(int,input().split())
  ans = dic[e-1] - dic[s-1]
  print(ans)

Buggy submission (verdict: Runtime Error):
n,q = int(input().split(' '))
str = input()
for i in range(q):
  s,e = int(input().split(' '))
  tmp = s[s-1:e]
  ans = tmp.count('AC')
  print(ans)
Problem p03494 (python)

Fixed submission:
n = input()
nums = list(map(int, input().split()))

if (nums[0] % 2 == 1):
  print('0')
else:
  tmp = nums[0] / 2
  tmp_ans = 1
  while(tmp % 2 == 0 and tmp > 1):
    tmp_ans += 1
    tmp = tmp / 2

  min_ans = tmp_ans
  
  for num in nums[1:]:
    if (num % 2 == 1):
      min_ans = 0
      break
    tmp = num / 2
    tmp_ans = 1
    while (tmp % 2 == 0 and tmp_ans <= min_ans):
      tmp_ans += 1
      tmp = tmp / 2

    if (tmp_ans < min_ans):
      min_ans = tmp_ans
      
  print(min_ans)

Buggy submission (verdict: Runtime Error):
n = input()
nums = map(int, input().split)

min_ans = 0
for num in nums:
  ans = 0
  tmp = num % 2
  if (tmp == 1):
    break
  ans += 1
  while (tmp % 2 == 0 and ans <= min_ans):
    ans += 1
    tmp = tmp % 2

  if (ans < min_ans):
    min_ans = ans

print(min_ans)
Problem p03067 (python)

Fixed submission:
x = list(map(int, input().split()))
if x[0]<x[2]<x[1]:
    print("Yes")
elif x[1]<x[2]<x[0]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = int(input().split())
if x[0]<x[2]<x[1]:
    print("Yes")
else:
    print("No")
Problem p03068 (python)

Fixed submission:
n = int(input())
s = input()
k = int(input())
w = s[k-1]
ss = ""
for i in range(n):
    if(s[i] == w):
        ss += w
    else:
        ss += "*"
print(ss)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
w = s[k]
ss = ""
for i in range(n):
    if(s[i] == w):
        ss += w
    else:
        ss += "*"
print(ss)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
ss = []
for i in range(n):
    if(s[k] != s[i]):
        ss[i] = "*"
    else:
        ss[i] = s[k]
print(''.join(ss))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
ss = []
for i in range(n):
    if(s[k] != s[i]):
        ss[i] = "*"
    else:
        ss[i] = s[k]
print(.join(ss))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
ss = ""
for i in range(n):
    if(s[k] != s[i]):
        ss = ss + "*"
    else:
        ss = ss + s[k]
print(ss)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
ss = ""
for i in range(n):
    if(s[k] != s[i]):
        ss[i] = "*"
    else:
        ss[i] = s[k]
print(ss)

Buggy submission (verdict: Runtime Error):
import re

n = int(input())
s = input()
k = int(input())
print(re.sub(^s[k],"*",s))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
w = s[k]
ss = s.replace(w,"*")
print(ss)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
w = s[k]
for i in range(n):
    if(s[i] != w):
        s[i] = "*"
print(s)
Problem p03086 (python)

Fixed submission:
S = input()
N = len(S)
max_n = 0
for n in range(N):
    for m in range(n, N):
        s = S[n:m+1]
        if all("ATCG".count(ss) == 1 for ss in s):
            max_n = max(max_n, len(s))
print(max_n)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
atcg_lst = []
for n in range(N):
    for m in range(n, N):
        s = S[n:m+1]
        atcg = ["ATCG".count(ss) for ss in s]
        if all(atcg):
            atcg_lst.append(sum(atcg))
print(max(atcg_lst))
Problem p03069 (python)

Fixed submission:
# coding: utf-8

N = int(input())
S = input()

# .......####### という形を目指す

#累積和を計算
sum_black = [0]
sum_white = [0]
for n in range(0,N):
    if S[n] == '#': #black
        sum_black.append(sum_black[n] + 1)
        sum_white.append(sum_white[n] + 0)
    else:
        sum_black.append(sum_black[n] + 0)
        sum_white.append(sum_white[n] + 1)

num_min = N
for n in range(0,N+1):
    num = sum_black[n] + (sum_white[-1] - sum_white[n]) 
    if num < num_min:
        num_min = num

print(num_min)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

N = int(input())
S = input()

data = []

def split_data(data, i):
    return (S[:i+1].count('#'),S[i+1:].count('.'))

# .......####### という形を目指す

#累積和を計算
sum_black = [0]
sum_white = [0]
for n in range(0,N+1):
    if S[n] == '#': #black
        sum_black.append(sum_black[n] + 1)
        sum_white.append(sum_white[n] + 0)
    else:
        sum_black.append(sum_black[n] + 0)
        sum_white.append(sum_white[n] + 1)

num_min = N
for n in range(0,N):
    num = sum_black[n] + (sum_white[n] - sum_white[-1]) 
    if num < num_min:
        num_min = num

print(num_min)