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

Fixed submission:
# -*- coding: utf-8 -*-
a,b = map(int, raw_input().split())
tmp = a

if b == 1:
	print 0
elif a >= b:
	print 1
else:
	count = 1
	while True:
		count +=1
		tmp += (a - 1)
		if tmp >= b:
			print count
			break

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def is_integer(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

a,b = map(int, raw_input().split())
sub = b - a

if a >= b:
	print 1
else:
	count = 1
	while True:
		count +=1
		if sub <= a-1:			
			break
		else:
			sub = sub - (a-1)
print count

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def is_integer(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

a,b = map(int, raw_input().split())

if a >= b:
	print 1
else:
	sub = b - a
if sub < a-1:
	print 2
else:
	div = sub/float(a-1)
  	print 1 + int(div)
Problem p02923 (python)

Fixed submission:
n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(raw_input())
li = map(int, raw_input().split())

ans = 0
tmp = 0

for i in xrange(N-1):
    if li[i] < li[i+1]
        tmp +=1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)
Problem p02945 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# 整数の入力
a, b = map(int, raw_input().split())

mylist = [a+b,a-b,a*b]
print max(mylist)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
a = int(raw_input())
# スペース区切りの整数の入力
a, b = map(int, raw_input().split())

mylist = [a+b,a-b,a*b]
print max(mylist)
Problem p02946 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from __future__ import print_function
 
k, x = map(int, raw_input().split())
 
for i in range(x-(k-1),x+k):
    print (str(i) + " " ,end="")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
x, k = map(int, raw_input().split())

for i in range(x-(k-1),x+k):
    print (str(i) + " " ,end="")
Problem p02947 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(raw_input())
cnt = 0
dic = {}

for _ in xrange(N):
	rs = ''.join(sorted(raw_input()))
	
	if rs in dic:
		cnt += dic[rs]
		dic[rs] += 1
	else:
		dic[rs] = 1
print cnt

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

N = int(raw_input())
li = list(map(int, input().split()))

for i in range(N):
    sl.append("".join(sorted(li[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(N):
    sl.append("".join(sorted(li[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(n):
    sl.append("".join(sorted(li[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(n):
    sl.append("".join(sorted(list[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
li = list(map(int, input().split()))

for i in range(N):
    sl.append("".join(sorted(list[i])))

sl.sort()

c = collections.Counter(sl)

print(N - (len(c)-1))
Problem p02969 (python)

Fixed submission:
r = input()
r = int(r)
print(3 * r * r)

Buggy submission (verdict: Runtime Error):
r = map(int, input())
print(3 * r * r)
Problem p03035 (python)

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

if a >= 13:
    print(b)
elif a >= 6:
    print(int(b/2))
else:
    print(0)

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

if a, b = map(int, input().split())

if a >= 13:
    print(b)
elif a >= 6:
    print(int(b/2))
else:
    print(0)
Problem p03110 (python)

Fixed submission:
n = int(input())
total = 0

for i in range(n):
  x_temp, u_temp = input().split()
  x_temp = float(x_temp)
  if u_temp == 'BTC':
    x_temp *= 380000.0
  total += x_temp
  
print(total)

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

for i in range(n):
  x_temp, u_temp = map(int, input())
  if u_temp = 'BTC':
    x_temp *= 380000.0
  total += x_temp
  
print(total)
Problem p03323 (python)

Fixed submission:
a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  prit(':(')
Problem p03407 (python)

Fixed submission:
a, b, c = map(int, input().split())
 
if a+b >= c:
  print('Yes')
else:
  print('No')

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

if a+b <= c:
  print('Yes')
else:
  priny('No')
Problem p03623 (python)

Fixed submission:
x, a, b = map(int, input().split())
ax = abs(a-x)
bx = abs(b-x)
if ax > bx:
  print('B')
else:
  print('A')

Buggy submission (verdict: Runtime Error):
x, a, b = map(int, input().split())
ax = abs(a-x)
bx = abs(b-x)
if ax > bx:
  print(B)
else:
  print(A)
Problem p03657 (python)

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

if a%3 == 0 or b%3 == 0 or s%3 == 0:
  print('Possible')
else:
  print('Impossible')

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

if a%3 == 0 or b%3 == 0 or s%3 == 0:
  print('Possible')
else:
  print('Impossible)
Problem p03693 (python)

Fixed submission:
r, g, b = input().split()
rgb = int(r+g+b)
if rgb % 4 == 0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
r, g, b = input()
rgb = int(r+g+b)
if rgb % 4 == 0:
  print('YES')
else:
  print('NO')
Problem p03844 (python)

Fixed submission:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == '+':
  print(a + b)
else:
  print(a - b)

Buggy submission (verdict: Runtime Error):
a, op, b = input().split()
a = int(a)
b = int(b)
if op = '+':
  print(a + b)
else:
  print(a - b)
Problem p02887 (python)

Fixed submission:
n = int(input())
s = str(input())
count = 0

for i in range(n - 1):
    if s[i] == s[i + 1]:
        count = count + 1

print(n - count)

Buggy submission (verdict: Runtime Error):
import sys

n = int(input())
s = str(input())

if n == 1:
    if s[0] == s[1]:
        print(2)
    else:
        print(1)
    sys.exit()

count = 0
i = 0
while i < n - 1:
    if s[i] == s[i + 1]:
        count = count + 1
    i = i + 1

ans = n - count
print(ans)
Problem p03076 (python)

Fixed submission:
a = [int(input()) for i in range(5)]
r = 10
last = 0
for i in range(5):
    if a[i] % 10 != 0 and a[i] % 10 < r:
        last = i
        r = int(a[i] % 10)


b = [int((a[i] + 9) / 10) * 10 for i in range(5)] 
time = 0
for i in range(5):
    if i != last:
        time = time + b[i]
    
time = time + a[last]
print(time)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
r = 10
last = 10000
for i in range(5):
    if a[i] % 10 != 0 and a[i] % 10 < r:
        last = i
        r = int(a[i] % 10)

if last == 10000:
    for i in range(5):
        time = time + a[i]

else:
    b = [int((a[i] + 9) / 10) * 10 for i in range(5)] 
    time = 0
    for i in range(5):
        if i != last:
            time = time + b[i]
    
    time = time + a[last]
    print(time)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
r = 10
last = 10000
for i in range(5):
    #if a[i] % 10 == 0:
    #    fix = i
    if a[i] % 10 != 0 and a[i] % 10 < r:
        last = i
        r = int(a[i] % 10)

if last == 10000:
    for i in range(5):
        time = time + a[i]

else:
    b = [int((a[i] + 9) / 10) * 10 for i in range(5)] 
    time = 0
    for i in range(5):
        if i != last:
            time = time + b[i]
    
    time = time + a[last]
    print(time)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
r = 10
last = 10000
for i in range(5):
    #if a[i] % 10 == 0:
    #    fix = i
    if a[i] % 10 != 0 and a[i] % 10 < r:
        last = i
        r = int(a[i] % 10)

if last == 10000:
    for i in range(5):
        time = time + a[i]
    print(time)

else:
    b = []
    for i in range(5):
        if i != last:
            b.append(a[i])
    
    b = [int((b[i] + 9) / 10) * 10 for i in range(4)] 

    time = 0
    for i in range(4):
        time = time + b[i]
    
    time = time + a[last]
    print(time)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
r = 10
fix = 10000
for i in range(5):
    if a[i] % 10 == 0:
        fix = i
    elif a[i] % 10 < r:
        last = i
        r = int(a[i] % 10)

if fix == 10000:
    b = []
    for i in range(5):
        if i != last:
            b.append(a[i])
    
    b = [int((b[i] + 9) / 10) * 10 for i in range(4)] 

    time = 0
    for i in range(4):
        time = time + b[i]
    
    time = time + a[last]


else:
    b = []
    for i in range(5):
        if i != fix and i != last:
            b.append(a[i])

    b = [int((b[i] + 9) / 10) * 10 for i in range(3)]

    time = 0
    for i in range(3):
        time = time + b[i]

    time = time + a[fix] + a[last]

print(time)
Problem p02900 (python)

Fixed submission:
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(max(A,B)))+1
g = G
ans = 1

for i in range(2, N+3):
    if(g % i == 0):
        ans += 1
        while(g % i == 0):
            g = g/i
            
if g != 1:
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = sqrt(G)+1
g = G
ans = 1


for i in range(2, N+1):
    if (g < i):
        break
    if(g % (i) == 0):
        ans += 1
        while(g % (i) == 0):
            g /= i

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

G = math.gcd(A, B)
ans = 1

for i in range(G-1):
    if (G < i):
        break
    if(G % (i+2) == 0):
        ans += 1
        j = 1
        while(G % ((i+2)**j) == 0):
            G /= i+2
            j += 1

print(ans)

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

import math
# import time

G = math.gcd(A, B)
ans = 1
# print("G:", G)



for i in range(G-1):
    if (G < i):
        break
    # print("G % (i+1) == 0:", G % (i+1) == 0)
    if(G % (i+2) == 0):
        ans += 1
        j = 1
        while(G % ((i+2)**j) == 0):
            G /= i+2
            j += 1
            # print("i:", i + 2, "j:", j)
            # time.sleep(1)

print(ans)
Problem p02995 (python)

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

# n_c = 0
# n_d = 0
# n_cd = 0
# for i in range(A,B+1):
#     if(i % C == 0):
#         n_c = i // C
#     n_d = i // D
#     n_cd = i//(C*D)

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

n_c = B//C - A//C
n_d = B//D - A//D
CD = lcm(C,D)
n_cd = B//(CD) - A//(CD)

if(A%C == 0):
    n_c += 1
if(A%D==0):
    n_d += 1
if(A%CD==0):
    n_cd += 1


if (max(C,D)%min(C,D) == 0):
    ans = (B-A+1) - max(n_c, n_d)
else:
    ans = (B-A + 1) - (n_c + n_d - n_cd)

# print(n_c)
# print(n_d)
# print(n_cd)

print(ans)

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

# n_c = 0
# n_d = 0
# n_cd = 0
# for i in range(A,B+1):
#     if(i % C == 0):
#         n_c = i // C
#     n_d = i // D
#     n_cd = i//(C*D)

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

n_c = B//C - A//C
n_d = B//D - A//D
CD = lcm(C,D)
n_cd = B//(CD) - A//(CD)

if(A%C == 0):
    n_c += 1
if(A%D==0):
    n_d += 1
if(A%CD==0):
    n_cd += 1


if (max(C,D)%min(C,D) == 0):
    ans = (B-A+1) - max(n_c, n_d)
else:
    ans = (B-A + 1) - (n_c + n_d - n_cd)

# print(n_c)
# print(n_d)
# print(n_cd)

print(ans)

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

n_c = 0
n_d = 0
n_cd = 0
# for i in range(A,B+1):
#     if(i % C == 0):
#         n_c = i // C
#     n_d = i // D
#     n_cd = i//(C*D)

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

n_c = B//C - A//C
n_d = B//D - A//D
CD = lcm(C,D)
n_cd = B//(CD) - A//(CD)

if(A%C == 0):
    n_c += 1
if(A%D==0):
    n_d += 1
if(A%CD==0):
    n_cd += 1


if (max(C,D)%min(C,D) == 0):
    ans = (B-A+1) - max(n_c, n_d)
else:
    ans = (B-A + 1) - (n_c + n_d - n_cd)

# print(n_c)
# print(n_d)
# print(n_cd)

print(ans)
Problem p02898 (python)

Fixed submission:
if __name__ == '__main__':
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))
    heights.sort()
    # n人、k CM必要
    index = 0
    while len(heights) > index and heights[index] < k:
        index += 1
        if n == 1:
            break
    print(n - index)

Buggy submission (verdict: Runtime Error):
import math

if __name__ == '__main__':
    n, k = map(int, input().split())
    heights = list(map(int, input().split()))
    heights.sort()
    # n人、k CM必要
    index = 0
    while heights[index] < k:
        index += 1
        if n == 1:
            break
    print(n - index)
Problem p02918 (python)

Fixed submission:
## 幸福度が変わるかどうかは操作Kによって変更されたl, r番目の人間だけなので、
## 左右l,r番目の人間が幸福であるかどうかを見てゆく
## for(n)回のループでまず「既に 1 + x, 任意の r が幸福であるかどうか」を確認して、
## 幸福度2, 1の順でそのl,rをK回覚える
n, k = map(int, input().split())
humans = list(input())
k_count = 0
last_r = n ## 最後に操作したr(番目)
dev_null = 0

## ポイントを計算
happy_point = 0
for x in range(n - 1):
  if humans[x] == humans[x+1]:
    happy_point += 1
print(min(n-1,happy_point+2*k))

Buggy submission (verdict: Runtime Error):
## 幸福度が変わるかどうかは操作Kによって変更されたl, r番目の人間だけなので、
## 左右l,r番目の人間が幸福であるかどうかを見てゆく
## for(n)回のループでまず「既に 1 + x, 任意の r が幸福であるかどうか」を確認して、
## 幸福度2, 1の順でそのl,rをK回覚える
n, k = map(int, input().split())
humans = list(input())
k_count = 0
last_r = n ## 最後に操作したr(番目)
dev_null = 0

for x in range(n - 1):
  if x == last_r:
    break ## すべての可能性を確認した
  if x == 0:
    continue
  l = r = "n"
  if k_count == k:
    break ## 既にK回試行したのでbreak
  if humans[x] == "L" and humans[x - 1] == "L":
    continue
  elif humans[x] == "R" and humans[x - 1] == "R" and humans[x + 1] == "R":
    continue
  else:
    ## 不幸なので、lを確定
    l = x + 1 ## 不幸な人
    if l == last_r - 1:
      break ## 前に操作したrとlが等しい
    ## rを探す(x + 1からlast_rまで)
    for y in reversed(range(l, last_r)): ## l, l+1, last_r - 1
      if y == n - 1 and humans[x] == "R":
        ## 不幸なので、rを確定
        r = y
        last_r = r
        k_count += 1
        break
      elif humans[y] == "L" and humans[y - 1] == "L":
        dev_null += 1 ## 既に同じ方向を向いてる
      elif humans[y] == "R" and humans[y + 1] == "R":
        dev_null += 1 ## 既に同じ方向を向いてる
      else:
        ## 不幸なので、rを確定
        r = y
        last_r = r
        k_count += 1
        break
    if l != "n" and r != "n":
      ## ともに値があるなら操作Kを実行
      for z in range(l, r + 1):
        if humans[z - 1] == "L":
          humans[z - 1] = "R"
        else:
          humans[z - 1] = "L"

## ポイントを計算
happy_point = 0
for x in range(n):
  if x == 0 and humans[x] == "L":
    ## do nothing
    dev_null += 1
  elif x == n - 1 and humans[x] == "R":
    ## do nothing
    dev_null += 1
  else:
    if humans[x] == "L" and humans[x - 1] == "L":
      happy_point += 1
    elif humans[x] == "R" and humans[x + 1] == "R":
      happy_point += 1
print(happy_point)
Problem p02921 (python)

Fixed submission:
forecasts = list(input())
actuals = list(input())
ex_count = 0
for x in range(3):
    if forecasts[x] == actuals[x]:
        ex_count = ex_count + 1
print("{}".format(ex_count))

Buggy submission (verdict: Runtime Error):
    forecasts = list(input())
    actuals = list(input())
    ex_count = 0
    for x in range(3):
        if forecasts[x] == actuals[x]:
            ex_count = ex_count + 1
    print("{}".format(ex_count))
Problem p02922 (python)

Fixed submission:
a, b = map(int, input().split())
tap_count = 1
a_count = 0
while tap_count < b:
  tap_count = tap_count + a - 1
  a_count = a_count + 1
print("{}".format(a_count))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
tap_count = 1
a_count = 0
while tap_count <= b:
  tap_count = tap_count + a - 1
  a_count = a_count + 1
print("{}".format(a_count))
Problem p02936 (python)

Fixed submission:

n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]
px = [list(map(int, input().split())) for _ in range(q)]
 
neigh = {}
 
scores = [0] * n
 
for i in range(q) :
    scores[px[i][0] - 1] += px[i][1]
#print(*scores) 
for i in range(n - 1) :
    neigh.setdefault(ab[i][0], []).append(ab[i][1])
#print(neigh)

sortKey = sorted(neigh.keys())
 
for k in sortKey :
    for e in neigh[k]:
        scores[e-1]+=scores[k-1]
 
print(*scores)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)

n,q=[int(x) for x in input().split()]
ab=[[int(x) for x in input().split()] for _ in range(n-1)]
px=[[int(x) for x in input().split()] for _ in range(q)]

s=[0,]*n

def calc(dd,i,num):
  global s
  if dd[i]==[]:
    s[i-1]+=num
    return(True)
  else:
    s[i-1]+=num
    for item in dd[i]:
      calc(dd,item,num)
    return(True)


dd=defaultdict(list)
for key in range(1,n):
  dd[ab[key-1][0]].append(ab[key-1][1])

for item in px:
  calc(dd,item[0],item[1])

print(*s)

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

n,q=[int(x) for x in input().split()]
ab=[[int(x) for x in input().split()] for _ in range(n-1)]
px=[[int(x) for x in input().split()] for _ in range(q)]

s=[0,]*n

def calc(dd,i,num):
  global s
  if dd[i]==[]:
    s[i-1]+=num
    return(True)
  else:
    s[i-1]+=num
    for item in dd[i]:
      calc(dd,item,num)
    return(True)


dd=defaultdict(list)
for key in range(1,n):
  dd[ab[key-1][0]].append(ab[key-1][1])

for item in px:
  calc(dd,item[0],item[1])

print(*s)
Problem p02937 (python)

Fixed submission:
S = input()
T = input()

if all([c in S for c in T])!=True:
	print(-1)
	exit()

str_repeat_num = 0
now_idx = 0
for t in T:
    if t in S[now_idx:]:
        now_idx += S[now_idx:].index(t) + 1
    else:
        str_repeat_num += 1
        now_idx = S[:now_idx].index(t) + 1
print(len(S) * str_repeat_num + now_idx)

Buggy submission (verdict: Runtime Error):
import collections

s=input()
t=input()

if all([c in s for c in t])!=True:
	print(-1)
	exit()

i=0
ss=s
while t!="":
    if i>len(s)-1:
        ss=ss+s
    if t[0]==ss[i]:
        t=t[1:]

    i+=1
print(i)
Problem p03029 (python)

Fixed submission:
l = list(map(int,input().split()
            )
        )
print(int((3*l[0]+l[1])/2
         )
     )

Buggy submission (verdict: Runtime Error):
[N,K]=list(map(int,input().split()))
V=list(map(int,input().split()))
have=[]
for n,k in enumerate(reversed(range(0,K+1))):
  tmp=[V[:ki]+V[-(k-ki):] for ki in range(k)
      ]+[V[:k],]
  tmp=[sorted(item) for item in tmp if sum(item)>0]
  #print(n,tmp)
  if n!=0:
    for num_remove in range(n):
      tmp2=[item[n:] for item in tmp 
            if all([g<0 for g in item[:n]])
           ]
      
      tmp.extend(tmp2)
      #print("tmp",tmp)
      #print("tmp2",tmp2)
      
  have.extend(tmp)
  #print(n,have[-1])

if have==[]:
  print(0)
else:
  print(max(list(map(sum,have))))
Problem p03037 (python)

Fixed submission:
import numpy as np
[n,m]=[int(x) for x in input().split()]
LR_T=np.array([[int(x)-1 for x in input().split()] for _ in range(m)]).T

print(max(np.min(LR_T[1])-np.max(LR_T[0])+1,0))

Buggy submission (verdict: Runtime Error):
import numpy as np
[n,m]=[int(x) for x in input().split()]
LR_T=np.array([[int(x)-1 for x in input().split()] for _ in range(m)]).T

print(np.min(LR_T[1])-np.max(LR_T[0])+1)
Problem p03069 (python)

Fixed submission:
import numpy as np
n=int(input())
s=input()
s_int=[0 if x=="." else 1 for x in s]
ruiseki=np.cumsum([0,]+s_int)
 
#print(s_int,ruiseki)
res=float("inf")
for i in range(n+1):
  #print("左黒",ruiseki[i],"右白",(n-i-(ruiseki[-1]-ruiseki[i])),"計",n-i-ruiseki[-1]+2*ruiseki[i])
  res=min(n-i-ruiseki[-1]+2*ruiseki[i],res)
print(res)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
s_int=[0 if x=="." else 1 for x in s]

res=float("inf")
kouho=[[0]*i+[1]*(n-i) for i in range(n+1)]

for item in kouho:
  res=min(res,sum([abs(item[i]-s_int)for i in range(n)]))

print(res)
Problem p03239 (python)

Fixed submission:
[n,t]=list(map(int,input().split()))
ntlist=[list(map(int,input().split())) for _ in range(n)]
 
anslist=[nt[0] for nt in ntlist if nt[1]<=t]
if anslist==[]:
  print("TLE")
else:
  print(min(anslist))

Buggy submission (verdict: Runtime Error):
[n,t]=list(map(int,input().split()))
ntlist=[list(map(int,input().split())) for _ in range(n)]

anslist=[nt[0] for nt in ntlist if nt[1]<=t]
if ans==[]:
  print("TLE")
else:
  print(min(ans))
Problem p03240 (python)

Fixed submission:
def calc_h(cx,cy,xyh_item):
  res=abs(cx-xyh_item[0])+abs(cy-xyh_item[1])+xyh_item[2]
  return res

n=int(input())
xyh=[[int(x) for x in input().split()] for _ in range(n)]
xyh.sort(key=lambda x:x[0],reverse=True)

#平地の情報(ピラミッドの根元を除く)は役にたたないので捨てる
xyh0=[]
xyh1=[]
for item in xyh:
  if item[2]==0:
    xyh0.append(item)
  else:
    xyh1.append(item)

xyh=xyh1

for item0 in xyh0:
  if any([calc_h(item1[0],item1[1],item0)==item1[2] for item1 in xyh1]):
    xyh.append(item0)

n=len(xyh)

anslist=[]

for x in range(101):
  for y in range(101):
    c=0
    tmp=calc_h(x,y,xyh[0])
    for i in range(1,n):
      if tmp!=calc_h(x,y,xyh[i]):
        break
      else:
        c+=1
    #if c==n-1:
    #  print(x,y,tmp)
    anslist.append([c,x,y,tmp])


anslist.sort(key=lambda x:x[0])
print(*anslist[-1][1:])

Buggy submission (verdict: Runtime Error):
def calc_h(cx,cy,xyh_item):
  return(abs(cx-xyh_item[0])+abs(cy-xyh_item[1])+xyh_item[2])

n=int(input())
xyh=[[int(x) for x in input().split()] for _ in range(n)]
xyh=[item for item in xyh if item[2]!=0]

anslist=[]

for x in range(101):
  for y in range(101):
    c=0
    tmp=calc_h(x,y,xyh[0])
    for i in range(1,n):
      if tmp!=calc_h(x,y,xyh[i]):
        break
      else:
        c+=1
    anslist.append([c,x,y,tmp])

anslist.sort(key=lambda x:x[0])
print(*anslist[-1][1:])
Problem p03264 (python)

Fixed submission:
K= int(input())
if K%2==0:
  print((K//2)**2)
else:
  print((K//2)*(K//2+1))

Buggy submission (verdict: Runtime Error):
K= int(input())
if K%2==0:
  print((K/2)**2)
else:
  print(K//2)*(K//2+1))
Problem p03379 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
x_sorted = sorted(x)
pin = x_sorted[n//2]
pre = x_sorted[n//2 - 1]
for i in range(n):
  if x[i] < pin:
    print(pin)
  else:
    print(pre)

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

n=int(input())
x=np.array([int(item) for item in input().split()])
x_sorted=np.sort(x)

for i in range(n):
  if i==0 and x[0]==x[1]:
    print(x_sorted[n//2-1])
  elif i==n-1 and x[n-1]==x[n-2]:
    print(x_sorted[n//2-1])
  elif x[i]==x[i-1] or x[i]==x[i+1]:
    print(x_sorted[n//2-1])
    
  else:
    ind=np.ones(n,dtype=bool)
    ind[np.searchsorted(x_sorted,x[i])]=False
    print(x_sorted[ind][n//2-1])
Problem p03543 (python)

Fixed submission:
s=input()
if s[1]==s[2] and (s[0]==s[1] or s[2]==s[3]):
  print("Yes") 
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import dijkstra
from collections import defaultdict

import sys
input = sys.stdin.readline

[H,W]= [int(x) for x in input().split()]
c=np.array([[int(x) for x in input().split()] for _ in range(10)])

A=[]
for _ in range(H):
  A+=[int(x) for x in input().split()] 

dd = defaultdict(int)
for key in A:
  if key!=1 and key!=-1:
    dd[key] += 1

res=0
for k, v in dd.items():
  res+= v*int(dijkstra(c,indices = k)[1])
print(res)