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

Fixed submission:
x, y, z = map(int, input().split())
n = (x-z)//(z+y)
print(n)

Buggy submission (verdict: Runtime Error):
package main

/*
	予め片方の一端を引いたぶんでかんがえればいいね
	(X-Z) // ((Y+Z)
*/

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	x, y, z := nextInt(), nextInt(), nextInt()
	fmt.Fprint(out, (x-z)/(y+z))
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}
Problem p03569 (python)

Fixed submission:
# x無視したやつが回文なってればいいんじゃね？
# 真ん中にしたい(x以外の)文字が決まれば、もとのsにインデックスを適応して、左右のxの数の差をとればいい
# と思ったけど差をとっただけだと駄目だな xaaxxxbxxcxxxxbxaxxaxx はこの考えだと3だけど実際は7だし
# もうしかたねぇから無理やりsplitした（アホか？）
# これでいけると思いきや駄目 abxxxbaとかでエラーになる
# 趣向を変えて、両脇から比較していくことにしてみる

s = input()
# めんどくさいけどここで確実になるときのやつと回文にならんときのやつを判定すっか
if len(s) == 1:
    print(0)
    exit()
t = ""
for sv in s:
    if sv != "x":
        t += sv
if t != t[::-1]:
    print(-1)
    exit()

l, r = 0, len(s) - 1
ls, rs = "", ""
ans = 0
x = False
while l < r:
    if s[l] == s[r]:
        ls += s[l]
        rs += s[r]
        l += 1
        r -= 1
    else:
        if s[l] == "x":
            while l < r and s[l] != s[r]:
                l += 1
                ans += 1
        else:
            while l < r and s[r] != s[l]:
                r -= 1
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
# x無視したやつが回文なってればいいんじゃね？
# 真ん中にしたい(x以外の)文字が決まれば、もとのsにインデックスを適応して、左右のxの数の差をとればいい
# と思ったけど差をとっただけだと駄目だな xaaxxxbxxcxxxxbxaxxaxx はこの考えだと3だけど実際は7だし
# もうしかたねぇから無理やりsplitした（アホか？）

import re

s = input()
if len(set(s)) == 1:
    # 1文字でのみ構成されている場合
    print(0)
    exit()
t = ""
for sv in s:
    if sv != "x":
        t += sv

if t != t[::-1]:
    # 回文にならない場合
    print(-1)
    exit()

mid_char = t[len(t) // 2]
mid_count = t.count(mid_char) // 2
mid_idx = -1
target_idx = 0
for i in range(len(s)):
    if s[i] == mid_char:
        mid_idx += 1
    if mid_idx == mid_count:
        target_idx = i
        break
ss, tt = s[:target_idx], s[target_idx + 1 :]
tt = tt[::-1]

ss = re.split("[abcdefghijklmnopqrstuvwyz]", ss)
tt = re.split("[abcdefghijklmnopqrstuvwyz]", tt)
ans = 0
for i in range(len(ss)):
    ans += abs(len(ss[i]) - len(tt[i]))

print(ans)

Buggy submission (verdict: Runtime Error):
# x無視したやつが回文なってればいいんじゃね？
# 真ん中にしたい(x以外の)文字が決まれば、もとのsにインデックスを適応して、左右のxの数の差をとればいい
s = input()

t = ""
for sv in s:
    if sv != "x":
        t += sv

if t != t[::-1]:
    print(-1)
    exit()

mid = t[len(t) // 2]
mid_c = t.count(mid) // 2
leftx, rightx = 0, 0
count = 0
for sv in s:
    if sv == "x" and count < mid_c:
        leftx += 1
    elif sv == "x" and mid_c <= count:
        rightx += 1
    elif sv == mid and count < mid_c:
        count += 1

print(abs(rightx - leftx))
Problem p03574 (python)

Fixed submission:
# いつもの探索でいいです 終了

h, w = map(int, input().split())
table = []
for _ in range(h):
  table.append(list(input()))

for i in range(h):
  for j in range(w):
    if table[i][j] != "#":
      sub_h = [0] if h==1 else [-1, 0, 1] if 0<i<h-1 else [0, 1] if i==0 else [-1, 0]
      sub_w = [0] if w==1 else [-1, 0, 1] if 0<j<w-1 else [0, 1] if j==0 else [-1, 0]
      count = 0
      for sh in sub_h:
        for sw in sub_w:
          if sh == sw == 0:
            continue
          if table[i+sh][j+sw] == "#":
            count += 1
      table[i][j] = str(count)

for i in range(h):
  print("".join(table[i]))

Buggy submission (verdict: Runtime Error):
# いつもの探索でいいです 終了

h, w = map(int, input().split())
table = []
for _ in range(h):
  table.append(list(input()))

for i in range(h):
  for j in range(w):
    if table[i][j] != "#":
      sub_h = [0] if h==0 else [-1, 0, 1] if 0<i<h-1 else [0, 1] if i==0 else [-1, 0]
      sub_w = [0] if w==0 else [-1, 0, 1] if 0<j<w-1 else [0, 1] if j==0 else [-1, 0]
      count = 0
      for sh in sub_h:
        for sw in sub_w:
          if sh == sw == 0:
            continue
          if table[i+sh][j+sw] == "#":
            count += 1
      table[i][j] = str(count)

for i in range(h):
  print("".join(table[i]))

Buggy submission (verdict: Runtime Error):
# いつもの探索でいいです 終了

h, w = map(int, input().split())
table = []
for _ in range(h):
  table.append(list(input()))

for i in range(h):
  for j in range(w):
    if table[i][j] != "#":
      sub_h = [-1, 0, 1] if 0<i<h-1 else [0, 1] if i==0 else [-1, 0]
      sub_w = [-1, 0, 1] if 0<j<w-1 else [0, 1] if j==0 else [-1, 0]
      count = 0
      for sh in sub_h:
        for sw in sub_w:
          if sh == sw == 0:
            continue
          if table[i+sh][j+sw] == "#":
            count += 1
      table[i][j] = str(count)

for i in range(h):
  print("".join(table[i]))
Problem p04030 (python)

Fixed submission:
s = input()
ans = []
for x in s:
    if x == "0" or x == "1":
        ans.append(x)
    else:
        if len(ans) > 0:
            ans.pop()
print("".join(ans))

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
for x in s:
    if x == "0" or x == "1":
        ans.append(x)
    else:
        ans.pop()
print("".join(ans))
Problem p02579 (python)

Fixed submission:
from collections import deque

h,w = map(int,input().split())
sh,sw = map(int,input().split())
gh,gw = map(int,input().split())
s = [input() for _ in range(h)]

sh-=1; sw-=1; gh-=1; gw-=1;

dist = [[-1]*w for _ in range(h)]
dist[sh][sw] = 0
q = deque([(0,sh,sw)])
warpq = deque([])

while q or warpq:
    while q:

        d,vsh,vsw = q.popleft()

        flag = 0
        
        for dh,dw in [(-1,0),(1,0),(0,-1),(0,1)]:
            newh = vsh+dh
            neww = vsw+dw
            if newh<0 or h<=newh or neww<0 or w<=neww: continue
            if s[newh][neww] == "#":
                if flag ==0:
                    warpq.append((d,vsh,vsw))
                    flag = 1
                continue

            if dist[newh][neww] == -1:
                dist[newh][neww] = d
                q.append((d,newh,neww))

    while warpq:

        d,vsh,vsw = warpq.popleft()
        for dh in range(-2,3):
            for dw in range(-2,3):
                newh = vsh+dh
                neww = vsw+dw
                if newh<0 or h<=newh or neww<0 or w<=neww: continue
                if abs(dh)+abs(dw)<=0: continue
                if s[newh][neww] == "#": continue

                if dist[newh][neww] == -1:
                    dist[newh][neww] = d+1
                    q.append((d+1,newh,neww))
            
print(dist[gh][gw])

Buggy submission (verdict: Runtime Error):
import heapq

h,w = map(int,input().split())
sh,sw = map(int,input().split())
gh,gw = map(int,input().split())
s = [input() for _ in range(h)]

sh-=1; sw-=1; gh-=1; gw-=1;

INF = 10**7
dist = [[INF]*w for _ in range(h)]
dist[sh][sw] = 0
q = [(0,sh,sw)]

while q:
    
    d,vsh,vsw = heapq.heappop(q)
    
    for dh in range(-2,3):
        for dw in range(-2,3):
            newh = vsh+dh
            neww = vsw+dw
            if newh<0 or h<=newh or neww<0 or w<=neww: continue
            if dh == 0 and dw==0: continue
            if s[newh][neww] == "#": continue
                
            if abs(dh)+abs(dw)==1:
                if dist[newh][neww] > d:
                    dist[newh][neww] = d
                    if newh == gh and neww = gw: break
                    heapq.heappush(q,(d,newh,neww))
            else:
                if dist[newh][neww] > d+1:
                    dist[newh][neww] = d+1
                    heapq.heappush(q,(d+1,newh,neww))
                    
if dist[gh][gw] == INF: print(-1)
else: print(dist[gh][gw])
Problem p02585 (python)

Fixed submission:
#出来るだけループして端数を全部みるだとうまくいかない（最初と最後に負のスコアが固まっている場合など）

from numba import njit,i8
import numpy as np


n,k = map(int,input().split())
p = np.array([int(i)-1 for i in input().split()],np.int64)
c = np.array(list(map(int,input().split())),np.int64)

@njit(i8(i8,i8[:],i8[:]), cache = True)
def calc_score(x,p,c):
    n = p.size
    score = 0
    score_list = np.zeros(n,np.int64)
    cnt = 0
    visit = [0]*n
    while not visit[p[x]]:
        x = p[x]
        visit[x] = 1
        cnt += 1
        if cnt<=k:
            score += c[x]
            score_list[cnt-1] = score
        else:
            return score_list[:k].max()
    
    if score>0:
        tmp = np.arange(cnt)
        return (score_list[tmp] + ((k-1-tmp)//cnt) * score).max()
    else:
        return score_list[:cnt].max()

ans = max(calc_score(i,p,c) for i in range(n))
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = [int(i)-1 for i in input().split()]
c = list(map(int,input().split()))

def calc_score(x):
    
    score = 0
    score_max = -10**10
    score_list = [-float("inf")]*n
    cnt = 0
    visit = [0]*n
    while not visit[p[x]]:
        x = p[x]
        visit[x] = 1
        cnt += 1
        if cnt<=k:
            score += c[x]
            score_max = max(score_max, score)
            score_list[cnt-1] = score
        else:
            return score_max
            
    if score>0:
        return max(score_list[:k%cnt]) + (k//cnt) * score
    else:
        return score_max

ans = max(calc_score(i) for i in range(n))
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = [int(i)-1 for i in input().split()]
c = list(map(int,input().split()))

def calc_score(x):
    
    score = [0]
    cnt = 0
    visit = set()
    while not p[x] in visit:
        x = p[x]
        visit.add(x)
        score.append(score[-1] + c[x])
        cnt += 1
    if k<=cnt:
        return max(score[1:k+1])
    else:
        if score[-1]>0:
            return max(score[1:(k%cnt+1)]) + (k//cnt) * score[-1]
        else:
            return max(score[1:])

ans = max(calc_score(i) for i in range(n))
print(ans)
Problem p02605 (python)

Fixed submission:
from bisect import bisect_left
from collections import defaultdict

n = int(input())

xysame, upright, downright = {},{},{}
u_list = ("U","R","D","L")
for u in u_list:
    xysame[u] = defaultdict(list)
    upright[u] = defaultdict(list)
    downright[u] = defaultdict(list)

for _ in range(n):
    x,y,u = input().split()
    x,y = int(x),int(y)
    if u == "U" or u == "D":
        xysame[u][x].append(y)
    else:
        xysame[u][y].append(x)
    upright[u][y-x].append(x)
    downright[u][y+x].append(x)
    
for u in u_list:
    for key in xysame[u].keys():
        xysame[u][key].sort()
    for key in upright[u].keys():
        upright[u][key].sort()
    for key in downright[u].keys():
        downright[u][key].sort()

INF = 10**6
ans = INF


def line(low,high,type_ = 1):
    ret = INF
    for k,v in low.items():
        if high[k] == []: continue

        for vi in v:
            index = bisect_left(high[k], vi)
            if index == len(high[k]): continue
            ret = min(ret,(high[k][index]-vi)/type_)
    return ret

ans = min(ans, line(xysame["U"],xysame["D"],2))
ans = min(ans, line(xysame["R"],xysame["L"],2))
ans = min(ans, line(upright["R"],upright["D"],1))
ans = min(ans, line(upright["U"],upright["L"],1))
ans = min(ans, line(downright["R"],downright["U"],1))
ans = min(ans, line(downright["D"],downright["L"],1))

ans = int(ans*10)
if ans ==INF*10: ans = "SAFE"
    
print(ans)

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

n = int(input())

xysame, upright, downright = {},{},{}
u_list = ("U","R","D","L")
for u in u_list:
    xysame[u] = defaultdict(list)
    upright[u] = defaultdict(list)
    downright[u] = defaultdict(list)

for _ in range(n):
    x,y,u = input().split()
    x,y = int(x),int(y)
    if u == "U" or "D":
        xysame[u][x].append(y)
    else:
        xysame[u][y].append(x)
    upright[u][y-x].append(x)
    downright[u][y+x].append(x)
    
for u in u_list:
    for key in xysame[u].keys():
        xysame[u][key].sort()
    for key in upright[u].keys():
        upright[u][key].sort()
    for key in downright[u].keys():
        downright[u][key].sort()

INF = 10**6
ans = INF


def line(low,high,type_ = 1):
    ret = INF
    for k,v in low.items():
        if high[k] == []: continue

        for vi in v:
            index = bisect_left(high[k], vi)
            if index == len(high[k]): conitnue
            ret = min(ret,(high[k][index]-vi)/type_)
    return ret

ans = min(ans, line(xysame["U"],xysame["D"],2))
ans = min(ans, line(xysame["R"],xysame["L"],2))
ans = min(ans, line(upright["R"],upright["D"],1))
ans = min(ans, line(upright["U"],upright["L"],1))
ans = min(ans, line(downright["R"],downright["U"],1))
ans = min(ans, line(downright["D"],downright["L"],1))

ans = int(ans*10)
if ans ==INF*10: ans = "SAFE"
    
print(ans)
Problem p02609 (python)

Fixed submission:
n = int(input())
x = input()
popcount_x = x.count("1")
popcount_x1 = popcount_x + 1
popcount_x2 = popcount_x - 1

if popcount_x2 == 0: popcount_x2 = -1

div1 = [0]*n
div2 = [0]*n
cur1 = 1
cur2 = 1
for i in range(n):
    cur1 %= popcount_x1
    cur2 %= popcount_x2
    div1[i] = cur1
    div2[i] = cur2
    cur1 *= 2
    cur2 *= 2


fn = [0]*n
for i in range(1,n):
    popcount = bin(i)[2:].count("1")
    fn[i] = fn[(i)%popcount] + 1

    
x_div1 = sum(int(x[i]) * div1[-i-1] for i in range(n)) % popcount_x1
x_div2 = sum(int(x[i]) * div2[-i-1] for i in range(n)) % popcount_x2

for i in range(n):
    if x[i] == "0": 
        xi_div = (x_div1 + div1[-i-1]) % popcount_x1
        print(fn[xi_div] + 1)
    else:
        if popcount_x2 == -1:
            print(0)
        else:
            xi_div = (x_div2 - div2[-i-1]) % popcount_x2
            print(fn[xi_div] + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
popcount_x = x.count("1")
popcount_x1 = popcount_x + 1
popcount_x2 = popcount_x - 1


div1 = [0]*n
div2 = [0]*n
cur1 = 1
cur2 = 1
for i in range(n):
    cur1 %= popcount_x1
    cur2 %= popcount_x2
    div1[i] = cur1
    div2[i] = cur2
    cur1 *= 2
    cur2 *= 2


fn = [0]*n
for i in range(1,n):
    popcount = bin(i)[2:].count("1")
    fn[i] = fn[(i)%popcount] + 1

    
x_div1 = sum(int(x[i]) * div1[-i-1] for i in range(n)) % popcount_x1
x_div2 = sum(int(x[i]) * div2[-i-1] for i in range(n)) % popcount_x2

for i in range(n):
    if x[i] == "0": 
        xi_div = (x_div1 + div1[-i-1]) % popcount_x1
        print(fn[xi_div] + 1)
    else:
        xi_div = (x_div2 - div2[-i-1]) % popcount_x2
        print(fn[xi_div] + 1)
Problem p02692 (python)

Fixed submission:
import sys

n,a,b,c = map(int,input().split())

abc = {"A":a,"B":b,"C":c}

s = [input() for _ in range(n)]

ans = [None]*n
i = 0
while i <n:
    x = s[i][0]
    y = s[i][1]
    if abc[x] == 0 and abc[y] ==0:
        print("No")
        sys.exit()
    elif abc[x] == 1 and abc[y] ==1 and i<n-1:
        if s[i] == s[i+1]:
            ans[i] = x
            ans[i+1] = y
            i += 1
        elif x in s[i+1]:
            ans[i] = x
            abc[x] += 1
            abc[y] -= 1
        else:
            ans[i] = y
            abc[x] -= 1
            abc[y] += 1
    else:
        if abc[x]<=abc[y]:
            ans[i] = x
            abc[x] += 1
            abc[y] -= 1
        else:
            ans[i] = y
            abc[x] -= 1
            abc[y] += 1
    i += 1
    
print("Yes")
print("\n".join(ans))

Buggy submission (verdict: Runtime Error):
import sys

n,a,b,c = map(int,input().split())

abc = {"A":a,"B":b,"C":c}

s = [input() for _ in range(n)]

ans = [None]*n
i = 0
while i <n:
    x = s[i][0]
    y = s[i][1]
    if abc[x] == 0 and abc[y] ==0:
        print("No")
        sys.exit()
    elif abc[x] == 1 and abc[y] ==1 and i<n-1:
        if s[i] == s[i+1]:
            ans[i] = x
            ans[i+1] = y
            i += 1
        elif x in s[i+1]:
            ans[i] = x
            abc[x] += 1
            abc[y] -= 1
        else:
            abc[i] = y
            abc[x] -= 1
            abc[y] += 1
    else:
        if abc[x]<=abc[y]:
            ans[i] = x
            abc[x] += 1
            abc[y] -= 1
        else:
            ans[i] = y
            abc[x] -= 1
            abc[y] += 1
    i += 1
    
print("Yes")
print("\n".join(ans))
Problem p02814 (python)

Fixed submission:
import sys

def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

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

lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm,i)
for i in a:
    if (lcm//i)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)

Buggy submission (verdict: Runtime Error):
import sys

def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

n,m=map(int,input().split())
a=tuple(map(int,input().split()))
a.sort()
lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm,i)
for i in a:
    if (lcm//i)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)

Buggy submission (verdict: Runtime Error):
import sys

def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

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

lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm,i)
for i in a:
    if (lcm/i)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)
Problem p02888 (python)

Fixed submission:
from bisect import bisect_left
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans = 0
for i  in range(n-2):
    a = l[i]
    for j in range(i+1,n-1):
        b = l[j]
        k = bisect_left(l,a+b)
        ans += k-j-1
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans = 0
b_c= [0]*n
for i  in range(n-2):
    a = l[i]
    pre_k = 2
    for j in range(i+1,n-1):
        b = l[j]
        max_c = a+b-1
        k = bisect(l[j+pre_k-1:],max_c)
        ans += (pre_k-2 + )
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans = 0
for i  in range(n-2):
    if l[i]==a:
        continue
    a = l[i]
    b = 0
    for j in range(i+1,n-1):
        if l[j]==b:
            continue
        b = l[j]
        c = 0 
        for k in range(j+1,n):
            if l[k]==c:
                continue
            c = l[k]
            if c-b < a:
                ans += 1
            else:
                break
print(ans)
Problem p02971 (python)

Fixed submission:
n,*a=map(int,open(0).read().split())
ma=max(a)
ma_index=a.index(ma)
for i in range(n):
    if i==ma_index:
        print(max(a[:i]+a[i+1:]))
    else:
        print(ma)

Buggy submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
ma=max(a)
ma_index=a.index(ma)
for i in range(n):
    if i==ma_index:
        print(*max(a[:i]+a[i+1:]))
    else:
        print(ma)
Problem p02975 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
set_a=set(a)
if len(set_a)==3:
    set_a = list(set_a)
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    num2 = a.count(set_a[2])
    if (set_a[0]^set_a[1]^set_a[2]==0) and (num0==num2) and (num1==num2):
        print('Yes')
    else:
        print('No')
elif len(set_a)==2:
    set_a = list(set_a)
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    if (set_a[0]==0 and num1 == num0*2)or(set_a[1]==0 and num0==num1*2):
        print('Yes')
    else:
        print('No')
elif len(set_a)==1:
    if 0 in set_a:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
set_a=set(a)
if len(set_a)==3:
    set_a = list(set_a)
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    num2 = a.count(set_a[2])
    if (set_a[0]^set_a[1]^set_a[2]==0) and (num0==num2) and (num1==num2):
        print('Yes')
    else:
        print('No')
elif len(set_a)==2:
    num0 = a.count(set_a[0])
    num1 = a.count(set_a[1])
    if (0 in set_a) and (num0==num1):
        print('Yes')
    else:
        print('No')
elif len(set_a)==1:
    if 0 in a:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Problem p03032 (python)

Fixed submission:
n,k=map(int,input().split())
v=[0]+list(map(int,input().split()))+[0]

ans=0

getl_sum=0
for lc in range(min(n,k)+1):
    getl_sum += v[lc]
    getr_sum =0
    for rc in range(min(n,k)-lc+1):
        getr_sum += v[-rc-1]
        get = v[:lc] + v[-rc-1:]
        get.sort()
        get_sum = getl_sum + getr_sum
        ans = max(ans,get_sum)
        for bc in range(min(lc+rc,k-lc-rc)):
            get_sum-=get[bc]
            ans = max(ans,get_sum)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
v=[0]+list(map(int,input().split()))+[0]

ans=0

getl_sum=0
for lc in range(min(51,k+1)):
    getl_sum += v[lc]
    getr_sum =0
    for rc in range(min(51-lc,k-lc+1)):
        getr_sum += v[-rc-1]
        get = v[:lc] + v[-rc-1:]
        get.sort()
        get_sum = getl_sum + getr_sum
        ans = max(ans,get_sum)
        for bc in range(min(lc+rc,k-lc-rc)):
            get_sum-=get[bc]
            ans = max(ans,get_sum)
print(ans)
Problem p03046 (python)

Fixed submission:
M,K = map(int,input().split())

num = 2**(M+1)

if K >= num//2 or (M==1 and K==1):
    ans = [-1]
elif M==1 and K==0:
    ans = [0,0,1,1]
else:
    ans = [0]*num
    for i in range(2**M):
        if i==K: continue
        ans[i-(i>K)] = i
        ans[num-2-i+(i>K)] = i
    ans[num//2-1] = K
    ans[-1] = K
    
print(*ans)

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

num = 2**(M+1)

if K >= num//2 or (M==1 and K==1):
    print(-1)
else:
    ans = [0]*num
    for i in range(2**M):
        if i==K: continue
        ans[i-(i>K)] = i
        ans[num-2-i+(i>K)] = i
    ans[num//2-1] = K
    ans[-1] = K
    
print(*ans)
Problem p03059 (python)

Fixed submission:
a,b,t=map(int,input().split())
print((t//a)*b)

Buggy submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
s = 0
for i in range(n):
    s += max(0,v[i]-c[i])
print(s)
Problem p03608 (python)

Fixed submission:
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
from itertools import permutations

n,m,r = map(int,input().split())
rr = np.array(list(map(int,input().split()))) - 1

L = np.zeros((n,n),int)
for _ in range(m):
    a,b,c = map(int,input().split())
    L[a-1,b-1] = c

shortest = floyd_warshall(L, directed = False)

ans = float('inf')

for route in permutations(rr,len(rr)):
    ans = min(ans, shortest[route[:-1],route[1:]].sum())
print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
from itertools import permutations

n,m,r = map(int,input().split())
rr = np.array(list(map(int,input().split()))) - 1

L = np.zeros((m,m),int)
for _ in range(m):
    a,b,c = map(int,input().split())
    L[a-1,b-1] = c

shortest = floyd_warshall(L, directed = False)

ans = float('inf')

for route in permutations(rr,len(rr)):
    ans = min(ans, shortest[route[:-1],route[1:]].sum())
print(int(ans))