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

Fixed submission:
n, m = map(int, input().split())
d = {0: 1}
asum = 0
ans = 0
for a in map(int, input().split()):
    asum = (asum + a) % m
    if asum in d:
        ans += d[asum]
        d[asum] += 1
    else:
        d[asum] = 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = {0: 1}
asum = 0
ans = 0
for a in map(int, input().split()):
    asum = (asum + a) % m
    if asum in d:
        ans += d[asum]
        d[asum] += 1
    else:
        d[asum] = 1
print(ans
Problem p03433 (python)

Fixed submission:
a = int(input())
b = int(input())
if a%500 <= b:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
b = int(input())
if a%500 < b:
    print('Yes')
else:
    print('No')
Problem p03471 (python)

Fixed submission:
a,b = map(int,input().split())
f = 0
for i in range(a+1):
    if f == 1: break
    for j in range(a+1-i):
        if f == 1: break
        k = a-i-j
        if (i*10000 + j*5000 + k*1000) == b:
                f = 1
                print(i,j,k)
if f == 0: print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
f = 0
for i in range(a+1):
    if f == 1: break
    for j in range(a+1-i):
        if f == 1: break
        k = a+1-i-k
        if (i*10000 + j*5000 + k*1000) == b:
                f = 1
                print(i,j,k)
if f == 0: print(-1,-1,-1)
Problem p02755 (python)

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

list = []
if 100*a%8:
  x=int(a/0.08)+1
else:
  x=int(a/0.08)

if 100*(a+1)%8:
    y=int((a+1)/0.08)
else:
    y=int((a+1)/0.08)-1

    
for i in range(x, y+1):
    if b/0.1 <= i <(b+1)/0.1:
        list.append(i)

        
list = sorted(list)
if list:
    print(list[0])
else:
    print('-1')

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

list = []
if 100*a%8:
  x=int(a/0.08)+1
else:
  x=int(a/0.08)

for i in range(x, int((a+1)/0.08)+1):
    if b/0.1 <= i <(b+1)/0.1:
        list.append(i)

        
list = sorted(list)
if list[0]:
    print(list[0])
else:
    print('-1')
Problem p02783 (python)

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

ans =1
while h-a>0:
    h-=a
    ans+=1

print(ans)

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

if h-sum(list1)<=0:
    print('Yes')
else:
    print('No')
Problem p02789 (python)

Fixed submission:
n,m = map(int,input().split())
if n==m:
    print('Yes')
else:
    print('No')

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

ans = 0
for i in range(1,n+1):
    list = sorted(listn[:i])
    if listn[i-1]==list[0]:
        ans+=1

print(ans)
Problem p02801 (python)

Fixed submission:
c=input()
s='abcdefghijklmnopqrstuvwxyz'
list=list(s)

n=list.index(c)
print(list[n+1])

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

k = n*m-sum(list)
if 0<= k <=100:
    print(k)
elif k<0:
    print(0)
else:
    print(-1)
Problem p02732 (python)

Fixed submission:
import collections

# input
N = int(input())
A = input().split()
# calculatioin
cnt = collections.Counter(A)
full_cnt = int(sum(cnt[key]*(cnt[key]-1)/2 for key in cnt))
for i in range(N):
  print(full_cnt - cnt[A[i]]+1)

Buggy submission (verdict: Runtime Error):
import collections

# input
N = int(input())
A = map(int,input().split())
# calculatioin
cnt = collections.Counter(A)
full_cnt = int(sum(cnt[key]*(cnt[key]-1)/2 for key in cnt))
for i in range(N):
  print(full_cnt - cnt[A[i]]+1)
Problem p02756 (python)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
flip = False # False: left side is the head
for i in range(Q):
  Query_i = list(map(str, input().split()))
  if Query_i[0]=='1':
    flip = not flip
  elif Query_i[1] == '1' and not flip:
    S.appendleft(Query_i[2])
  elif Query_i[1] == '1' and flip:
    S.append(Query_i[2])
  elif Query_i[1] == '2' and not flip:
    S.append(Query_i[2])
  elif Query_i[1] == '2' and flip:
    S.appendleft(Query_i[2])
if flip:
  S.reverse()
print(''.join(S))

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

S = deque(input())
Q = int(input())
flip = False # True: left side is head
for i in range(Q):
  Query_i = list(map(str, input().split()))
  if Query_i[0]=='1':
    flip = not flip
  elif Query_i[1] == '1' and not flip:
    S.appendleft(Query_i[2])
  elif Query_i[1] == '1' and flip:
    S.append(Query_i[2])
  elif Query_i[1] == '2' and not flip:
    S.append(Query_i[2])
  elif Query_i[1] == '2' and flip:
    S.appendleft(Query_i[2])
if flip:
  S = S.reverse()
print(''.join(S))

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
head = True # True: left side is head
for i in range(Q):
  Query_i = list(map(str, input().split()))
  if Query_i[0]=='1':
    head = not head
  elif Query_i[1] == '1' and head:
    S = Query_i[2] + S
  elif Query_i[1] == '1' and not head:
    S = S + Query_i[2]
  elif Query_i[1] == '2' and head:
    S = S + Query_i[2]
  else Query_i[1] == '2' and not head:
    S = Query_i[2] + S
  if not head:
    S = S[::-1]
print(S)

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
for i in range(Q):
  Query_i = list(map(str, input().split()))
  if Query_i[0]=='1':
    S = S[::-1]
  elif Query_i[1] = '1':
    S = Query_i[2] + S
  else:
    S = S + Query_i[2]
print(S)

Buggy submission (verdict: Runtime Error):
S = input()
Q = int(input())
for i in range(Q):
  Query_i = list(map(str, input().split()))
  if Query_i[0]=='1':
    S = S[::-1]
  elif Query_i[1] = '1':
    S = Query_i[2] + S
  else:
    S = S + Query_i[2]
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
flag = True
ex = [-1]*N
for i in range(M):
  S,C = map(int, input().split())
  if ex[S-1]==-1 or ex[S-1]==C:
    ex[S-1] = C
  else:
    flag = False
    break
if N>1 and ex[0]==0:
  flag = False
if flag:
  for i in range(1,N):
    if ex[i]==-1:
      ex[i] = 0
  if ex[0]==-1 and N>1:
    ex[0] = 1
  elif ex[0]==-1:
    ex[0] = 0
  print(int("".join(map(str, ex))))
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
candidate = [-1]*N
flag = False
if N == 1:
  if M == 0:
    candidate = [0]
  else:
    s_temp,c_temp = map(int, input().split())
    candidate = [c_temp]
else:
  for i in range(M):
    s_temp,c_temp = map(int, input().split())
    s_temp = s_temp - 1
    if candidate[s_temp] == -1:
      candidate[s_temp] = c_temp
    elif candidate[s_temp] == c_temp:
      pass
    elif candidate[s_temp] != c_temp:
      flag = True
      break
if flag == True:
  print(-1)
else:
  print(int(''.join(map(str, candidate))))
Problem p02724 (python)

Fixed submission:
X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
else:
     sum = 0   
print(sum)

Buggy submission (verdict: Runtime Error):
X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
 else:
     sum = 0   
print(sum)

Buggy submission (verdict: Runtime Error):
x = int(input())
 if x >0:   
    num = x / 500
    w = x-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
 else:
     sum = 0   
print(sum)

Buggy submission (verdict: Runtime Error):
x = int(input())
 if x >0:   
    num = x / 500
    w = x-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
 else:
     sum = 0
Problem p02945 (python)

Fixed submission:
a, b = (int(i) for i in input().split())  
sum=a+b
dif=a-b
mul=a*b
 
 
if sum > dif:
    if mul>sum:
        print('{}'.format(mul))
    else:
        print('{}'.format(sum))
else:
    if mul>dif:
        print('{}'.format(mul))
    else:
        print('{}'.format(dif))

Buggy submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split())  
sum=a+b
dif=a-b
mul=a*b


if sum > dif:
	if mul>sum:
    	print("{}".format(mul))
	else:
    	print("{}"format(sum))
else:
	if mul>dif:
    	print("{}".format(mul))
	else:
    	print("{}"format(dif))

Buggy submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split())  

if a+b > a-b:
	if a*b>a+b:
    	print("{}".format(a*b))
	else:
    	print("{}"format(a+b))
else:
	if a*b>a-b:
    	print("{}".format(a*b))
	else:
    	print("{}"format(a-b))
Problem p02767 (python)

Fixed submission:
import numpy as np
from math import ceil, floor
 
n = int(input())
l = [int(x) for x in input().split()]
 
c = ceil(np.array(l).mean())
f = floor(np.array(l).mean())

print(min(sum([(x-c)**2 for x in l]), sum([(x-f)**2 for x in l])))

Buggy submission (verdict: Runtime Error):
import numpy as np
from math import ceil, floor

n = int(input())
l = [int(input()) for x in range(n)]

c = ceil(np.array(l).mean())
f = floor(np.array(l).mean())


print(min(sum([(x-c)**2 for x in l]), sum([(x-f)**2 for x in l])))
Problem p02946 (python)

Fixed submission:
k, x = map(int, input().split())
l =  [x-n for n in range(1,k)] + [x+n for n in range(k)]
l = [x for x in l if x <= 1000000]
l = [x for x in l if x >= 1000000 * -1]
l = sorted(l)
print(" ".join(map(str, l)))

Buggy submission (verdict: Runtime Error):
k, x = map(int, input().split())
l =  [x-n for n in range(1,k)] + [x+n for n in range(k)]
l = [x for x in l if x <= 1000000]
l = [x for x in l if x >= 1000000 * -1]
l = sorted(l)
print(" ".join(map(str, s_l)))
Problem p02947 (python)

Fixed submission:
from math import factorial
from collections import Counter
 
def conb(n):
    if n <= 1:
        return 0
    else:
        return factorial(n) // factorial(n-2) // factorial(2) 

n = int(input())
S = [''.join(sorted(list(input()))) for i in range(n)]

print(int(sum([conb(i) for i in Counter(S).values()])))

Buggy submission (verdict: Runtime Error):
from math import factorial
from collections import Counter
 
def conb(n):
    if n == 1:
        return 0
    else:
        return factorial(n) / factorial(2) / factorial(n - 2) 

n = int(input())
S = [''.join(sorted(list(input()))) for i in range(n)]

print(int(sum([conb(i) for i in Counter(S).values()])))

Buggy submission (verdict: Runtime Error):
from math import factorial
from collections import Counter
 
def conb(n):
    if n == 1:
        return 0
    else:
        return factorial(n) / factorial(2) / factorial(n - 2) 

n = int(input())
S = [''.join(sorted(list(input()))) for i in range(n)]

print(int(sum([conb(i) for i in Counter(S).values()])))

Buggy submission (verdict: Runtime Error):
from math import factorial
def conb(n):
    if n == 1:
        return 0
    else:
        return factorial(n) / factorial(2) / factorial(n - 2)


n = int(input())
l = [input() for _ in range(n)]
mst = set((list("".join(l))))
l = ["".join(map(str, [x.count(a) for a in mst])) for x in l]
l_s = set(l)
result = 0
for s in l_s:
    result += int(conb(l.count(s)))
print(result)

Buggy submission (verdict: Runtime Error):
mst_l = [chr(i) for i in range(97,97+26)]

n = int(input())
l = ["".join(map(str, [input().count(a) for a in mst_l])) for _ in range(n)]
result = 0
for i in range(n-1):
    result += l[i+1:].count(l[i])
print(result)
Problem p02958 (python)

Fixed submission:
n = int(input())
l = [int(x) for x in input().split()]
s_l = sorted(l)
print("YES" if sum([1 if l[i]!=s_l[i] else 0 for i in range(n)]) <= 2 else "NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
cnt = 0
for i in range(len(a)):
    if l == sorted(l):
        break
    for j in range(len(a)-1, i, -1):
        if a[j] < a[j-1]:
            a[j], a[j-1] = a[j-1], a[j]
        cnt += 1

print("YES" if cnt < 2 else "NO")
Problem p02982 (python)

Fixed submission:
n, d = map(int, input().split())
coodinates = [[int(x) for x in input().split()] for _ in range(n)]
result = 0
for left in range(n-1):
    for right in range(left+1,n):
        dist = 0
        for i in range(d):
            dist += (coodinates[left][i] - coodinates[right][i])**2
        dist = dist ** 0.5
        result += 1 if dist.is_integer() else 0
print(result)

Buggy submission (verdict: Runtime Error):
import sys
import re
import numpy as np
from itertools import combinations

def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))
    return sum(float.is_integer(i) for i in results)

rows = re.split('\n', sys.stdin.readline())
args = [list(map(int, row.split(' '))) for row in rows][1:]
print(answer(args))

Buggy submission (verdict: Runtime Error):
import sys
import re
import numpy as np
from itertools import combinations
 
 
def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))
    return sum(float.is_integer(i) for i in results)
 
rows = re.split('\n', sys.stdin.read())
args = [list(map(int, row.split(' '))) for row in rows][1:]
print(answer(args))

Buggy submission (verdict: Runtime Error):
import sys
import re
import numpy as np
from itertools import combinations


def answer(l):
    results = []
    for i, j in combinations(l, 2):
        v_a = np.array(i)
        v_b = np.array(j)
        results.append(np.linalg.norm(v_a - v_b))

    return sum(float.is_integer(i) for i in results)


if __name__ == '__main__':
    rows = re.split('\n', sys.stdin.read())
    args = [list(map(int, row.split(' '))) for row in rows][1:]
    print(answer(args))
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
l = [int(x) for x in input().split()]
bounds = 1
coodinate = 0
for i in l:
    coodinate += i
    if coodinate > x:
        break
    bounds += 1
print(bounds)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = [int(x) for x in input().split()]
bounds = 1
coodinate = 0
for i in range(n+1):
    coodinate += l[i]
    if coodinate > x:
        break
    bounds += 1
print(bounds)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())
S = W*H*0.5
cond = 1 if (W/2==x)&(H/2==y) else 0
print(S, cond)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
S = W*H*0.5
cond = 1 if (W//x==2)&(H//y==2) else 0
print(S, cond)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
S = max(min(x*H, (W-x)*H), min(W*y, W*(H-y)))
cond = 1 if W/H==x/y else 0
    
print(S, cond)
Problem p03030 (python)

Fixed submission:
n = int(input())
l = []
for i in range(n):
    d = {}
    d["index"] = i+1
    d["city"], d["score"] = input().split()
    d["score"] = int(d["score"])
    l.append(d)
results = []
citys = list(set([l[i]["city"] for i in range(n)]))
citys.sort()
for city in citys:
    sorted_scores = sorted([l[i]["score"] for i in range(n) if l[i]["city"] == city], reverse=True)
    for score in sorted_scores:
        candidate = [l[i]["index"] for i in range(n) if (l[i]["city"] == city)&(l[i]["score"] == score)][0]
        results.append(candidate)
print(*results, sep="\n")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(n):
    d = {}
    d["index"] = i+1
    d["city"], d["score"] = input().split()
    l.append(d)
results = []
for city in citys:
    sorted_scores = sorted([l[i]["score"] for i in range(n) if l[i]["city"] == city], reverse=True)
    for score in sorted_scores:
        candidate = [l[i]["index"] for i in range(n) if (l[i]["city"] == city)&(l[i]["score"] == score)][0]
        results.append(candidate)
print(*results, sep="\n")

Buggy submission (verdict: Runtime Error):
import pandas as pd
n = int(input())
dic = {}
for i in range(n):
    dic[i+1] = {}
    dic[i+1]["city"], dic[i+1]["score"] = input().split()
print(*list(pd.DataFrame().from_dict(dic, orient="index").sort_values(["city","score"], ascending=[True,False]).index), sep="\n")
Problem p03037 (python)

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

gate_cond = [[int(x) for x in input().split()] for _ in range(m)]
max_under_th = max([l[0] for l in gate_cond])
min_upper_th = min([l[1] for l in gate_cond])
if min_upper_th - max_under_th >= 0:
    print(min_upper_th - max_under_th + 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted([int(x) for x in  input().split()])
for _ in range(m):
    b, c = map(int, input().split())
    if a[0] < c:
        for i in range(b):
            if a[i] < c:
                a[i] = c
        a.sort()
print(sum(a))
Problem p03071 (python)

Fixed submission:
a,b = map(int, input().split())
gain1 = max([a, b])
print(max([gain1 *2 - 1, sum([a,b])]))

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
print(max([max([a,b]) * 2 -1, a+b])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = [int(x) for x in list(input())]

state = 1
cnt = 0
l = []
for i in s:
    if i == state:
        cnt += 1
    else:
        l.append(cnt)
        cnt = 1
        state = i
l = [x for x in l if x >0]
if len(l) % 2 == 1:
    l.append(0)

Add = 2 * k + 1
ruiseki = [0]

for i, e in enumerate(l):
    ruiseki.append(ruiseki[i] + l[i])

answer = 0
for i in range(0, len(l), 2):
    left = i
    right = min(i + Add, len(l))
    tmp = ruiseki[right] - ruiseki[left]
    answer = max(tmp, answer)
 
print(answer)
Problem p03076 (python)

Fixed submission:
from decimal import Decimal, ROUND_UP
 
l = [int(input()) for _ in range(5)]
if len([x%10 for x in l if x%10 > 0]) > 0:
    min_remainder = 10 - min([x%10 for x in l if x%10 > 0])
    print(sum([int(Decimal(x).quantize(Decimal("1E1"), rounding=ROUND_UP)) for x in l]) - min_remainder)
else:
    print(sum([int(Decimal(x).quantize(Decimal("1E1"), rounding=ROUND_UP)) for x in l]))

Buggy submission (verdict: Runtime Error):
from decimal import Decimal, ROUND_UP

l = [int(input()) for _ in range(5)]
min_remainder = 10 - min([x%10 for x in l if x%10 > 0])
print(sum([int(Decimal(x).quantize(Decimal("1E1"), rounding=ROUND_UP)) for x in l]) - min_remainder)
Problem p03136 (python)

Fixed submission:
n = input()
l = sorted(list(map(int, input().split())))
max_l = l[-1]
if sum(l[:-1]) > l[-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
l = sorted(list(map(int, input().split())))
max_l = l[-1]
if sum(max_l[:-1]) > l[-1]:
  print("Yes")
else:
  print("No")
Problem p03227 (python)

Fixed submission:
s = list(input())
if len(s) == 3:
    print("".join(s[::-1]))
else:
    print("".join(s))

Buggy submission (verdict: Runtime Error):
s = list(input())
if len(s) == 3:
    print(s[::-1].join())
else:
    print(s.join())
Problem p03971 (python)

Fixed submission:
n, a, b = map(int, input().split())
s = list(input())

result = []
cnt = 0
cnt_b = 0
limit = a + b

for student in s:
    if student == "c":
        result.append("No")
    elif (student == "a") & (cnt < limit):
        result.append("Yes")
        cnt += 1
    elif (student == "b") & (cnt < limit) & (cnt_b < b):
        result.append("Yes")
        cnt += 1
        cnt_b += 1
    else:
        result.append("No")
print("\n".join(result))

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

result = []
cnt = 0
cnt_b = 0
limit = a + b

for student in s:
    if student == c:
        result.append("No")
    elif (student == "a") & (cnt < limit):
        result.append("Yes")
        cnt += 1
    elif (student == "b") & (cnt < limit) & (cnt_b < b):
        result.append("Yes")
        cnt += 1
        cnt_b += 1
    else:
        result.append("No")
print("\n".join(result))
Problem p03067 (python)

Fixed submission:
s = [int(i) for i in input().split(' ')]
if s[2] > s[0] and s[2] < s[1]:
    print("Yes")
elif s[2] < s[0] and s[2] > s[1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = s.count('.')
tmp = ans
for i in s:
    if i == '.':
        tmp -= 1
    else:
        tmp += 1
    ans = min(ans,tmp)
print(ans)
Problem p03086 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 20:27:19 2019

@author: screamLab
"""

s = input()
s += 'H'
atcg = ['A','T','C','G']
ans = 0
long = 0
for i in range(len(s)):
    if s[i] in atcg:
        if i == len(s):
            break
        if s[i+1] in atcg:
            ans += 1
        else:
            ans += 1
            long = max(long,ans)
            ans = 0
long = max(long,ans)
print(long)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 20:27:19 2019

@author: screamLab
"""

s = input()
atcg = ['A','T','C','G']
ans = 0
long = 0
for i in range(len(s)):
    if s[i] in atcg:
        if s[i+1] in atcg:
            ans += 1
        else:
            ans += 1
    long = max(long,ans)
    ans = 0
long = max(long,ans)
print(long)
Problem p03304 (python)

Fixed submission:
def main():
	t = input().split(" ")
	n, m, d = int(t[0]), int(t[1]), int(t[2])
	if d == 0:
		r = (m-1) / n
	elif d > n:
		r = 0
	else:
		r = 2 * (n-d) * (m-1) / n / n
	print(r)
main()

Buggy submission (verdict: Runtime Error):
def main():
  	t = input().split(" ")
    n, m, d = int(t[0]), int(t[1]), int(t[2])
    if d == 0:
    	r = (m-1) / n
    elif d > n:
      	r = 0
    else:
      	r = 2 * (n-d) * (m-1) / n / n
    print(r)
main()
Problem p03341 (python)

Fixed submission:
def main():
	N = int(input())
	a = input()
    
	W = [0]*(N+1)
	E = [0]*(N+1)
	for i in range(N):
		if a[i] == 'W':
			W[i+1] = W[i] + 1
			E[i+1] = E[i]
		else:
			W[i+1] = W[i]
			E[i+1] = E[i] + 1
	E_max = E[-1]
	n_min = N
	for i in range(N):
		t = W[i] + E_max - E[i+1]
		if t < n_min:
			n_min = t
	print (n_min)
main()

Buggy submission (verdict: Runtime Error):
def main():
	N = int(input())
	a = input()
    
	W = [0]
	E = [0]
	for i in range(N):
		if a[i] == 'W':
			W[i+1] = W[i] + 1
			E[i+1] = E[i]
		else:
			W[i+1] = W[i]
			E[i+1] = E[i] + 1
	E_max = E[-1]
	n_min = N
	for i in range(N):
		t = W[i] + E_max - E[i+1]
		if t < n_min:
			n_min = t
	print (n_min)
main()
Problem p03361 (python)

Fixed submission:
def main():
  t = input().split(" ")
  H, W = int(t[0]), int(t[1])
  
  s = ["."*(W+2)]
  for i in range(H):
    t = input().strip()
    s.append("".join(['.', t, '.']))
  s.append("."*(W+2))
  flag = True
  for i in range(H):
    for j in range(W):
      if s[i+1][j+1] == '#':
        if s[i][j+1]=='.' and s[i+2][j+1]=='.' and s[i+1][j]=='.' and s[i+1][j+2]=='.':
          flag = False
  if flag:
    print("Yes")
  else:
    print("No")
main()

Buggy submission (verdict: Runtime Error):
def main():
  t = input().split(" ")
  H, W = int(t[0]), int(t[1])
  
  s = ["."*(W+2)]
  for i in range(H):
    t = input().strip()
    s.append("".join(['.', t, '.']))
  s.append("."*(W+2))
  flag == True
  for i in range(H):
    for j in range(W):
      if s[i+1][j+1] == '#':
        if s[i][j+1]=='.' and s[i+2][j+1]=='.' and s[i+1][j]=='.' and s[i+1][j+2]=='.':
          flag == False
  if flag:
    print("Yes")
  else:
    print("No")
main()
Problem p03379 (python)

Fixed submission:
def main():
  N = int(input())
  t = input().split(" ")
  a = [int(i) for i in t]
  b = sorted(a)
  sm = b[N//2-1]
  bm = b[N//2]
  
  for i in a:
    if i <= sm:
      print(bm)
    else:
      print(sm)
main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  t = input().split(" ")
  a = [int(i) for i in t]
  a.sort()
  
  for i in range(N):
    if i <= N//2:
      print(a[N//2+1])
    else:
      print(a[N//2])
main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  t = input().split(" ")
  a = [int(i) for i in t]
  a.sort()
  
  for i in range(N):
    if i <= N/2:
      print(a[N/2+1])
    else:
      print(a[N/2])
main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  t = input().split(" ")
  a = [int(i) for i in t]
  a.sort()
  
  for i in range(N):
  	if i <= N/2:
      print(a[N/2+1])
    else:
      print(a[N/2])
main()