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

Fixed submission:
from itertools import accumulate

def main():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))
    
    nonzeros = [1]
    for a in As:
        ndp = nonzeros[-1]
        if a <= K:
            ndp |= (nonzeros[-1] % (1 << (K-a))) << a
        nonzeros.append(ndp)
    dp = [0] * (K+1)
    dp[0] = 1
    acc = list(accumulate(dp)) + [0]
    ans = 0
    for i in range(N, 0, -1):
        a = As[i-1]
        ndp = []
        for j in range(K+1):
            t = dp[j] if j < a else dp[j] + dp[j-a]
            ndp.append(0 if t == 0 else 1)
        dp = ndp
        if a < K:
            nonzero = nonzeros[i-1]
            for y in range(K+1):
                if nonzero & 1:
                    t = K-y-a-1
                    if acc[K-y-1] > acc[t if t >= 0 else -1]:
                        break
                nonzero >>= 1
            else:
                ans += 1
        acc = list(accumulate(dp)) + [0]
    
    print(ans)

main()

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

def main():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))
    
    dp = np.array([0] * (K+1))
    dp[0] = 1
    nonzeros = [np.array([0])]
    for a in As:
        ndp = np.array([0] * (K+1))
        nonzero = []
        for i in range(K+1):
            t = dp[i] if i < a else dp[i] + dp[i-a]
            if t > 0:
                nonzero.append(i)
                ndp[i] = 1
        nonzeros.append(np.array(nonzero))
        dp = ndp
    
    dp = np.array([0] * (K+1))
    dp[0] = 1
    acc = list(accumulate(dp)) + [0]
    ans = 0
    for i in range(N, 0, -1):
        a = As[i-1]
        ndp = np.array([0] * (K+1))
        for j in range(K+1):
            t = dp[j] if j < a else dp[j] + dp[j-a]
            if t > 0:
                ndp[i] = 1
        dp = ndp
        if a < K:
            nonzero = nonzeros[i-1]
            for y in nonzero:
                t = K-y-a-1
                if acc[K-y-1] > acc[t if t >= 0 else -1]:
                    break
            else:
                ans += 1
        acc = list(accumulate(dp)) + [0]
    
    print(ans)

main()
Problem p03967 (python)

Fixed submission:
s=input()
print((s.count("g")-s.count("p"))//2)

Buggy submission (verdict: Runtime Error):
 s=input()
 print((s.count("g")-s.count("p"))//2)
Problem p02755 (python)

Fixed submission:
import math
a, b = [ int(v) for v in input().split() ]
ans = -1
for i in range(1, 10001):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        ans = i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = [ int(v) for v in input().split() ]
ans = -1
for i in range(1, 101):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        ans = i
        break
print(ans)
Problem p02813 (python)

Fixed submission:
import itertools
n = int(input())
a = tuple([ int(v)-1 for v in input().split() ])
b = tuple([ int(v)-1 for v in input().split() ])
t = 0
for i in itertools.permutations(range(n)):
    if a == i:
        xa = t
    if b == i:
        xb = t
    t += 1
print(abs(xa-xb))

Buggy submission (verdict: Runtime Error):
import itertools
n = int(input())
a = tuple([ int(v)-1 for v in input().split() ])
b = tuple([ int(v)-1 for v in input().split() ])
t = 0
for i in itertools.permutations(range(n)):
    if a == i:
        xa = t
    elif b == i:
        xb = t
    t += 1
print(abs(xa-xb))
Problem p02814 (python)

Fixed submission:
n, m = [ int(v) for v in input().split() ]
a_list = [ int(v) for v in input().split() ]

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcm(a,b):
	return a * b // gcd(a,b)

def p2(x):
    ans = 0
    while x % 2 == 0:
        ans += 1
        x //= 2
    return ans

n = len(a_list)

p2_list = [p2(i) for i in a_list]

p2_set = set(p2_list)
if len(p2_set) != 1:
    print(0)
else:
    p = 1
    for i in a_list:
        p = lcm(p, i//2)
        if p > m:
            print(0)
            break
    if p <= m:
        m -= p
        print(m//(p*2)+1)

Buggy submission (verdict: Runtime Error):
n, m = [ int(v) for v in input().split() ]
a_list = list(set([ int(v)//2 for v in input().split() ]))

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcm(a,b):
	return a * b // gcd(a,b)

n = len(a_list)
if n == 1:
    p = a_list[0]
    if p > m:
      print(0)
      else:
        m -= p
        print(m//(p*2)+1)
    
else:
    if all([i % 2 == 1 for i in a_list]):
        p = 1
        for j in a_list:
            p = lcm(p, j)
        if p > m:
            print(0)
        else:
            m -= p
            print(m//(p*2)+1)

    else:
        print(0)
Problem p02830 (python)

Fixed submission:
n = int(input())
s, t = [ v for v in input().split() ]


ans = ""
for i in range(n):
    ans += s[i]
    ans += t[i]

print(ans)

Buggy submission (verdict: Runtime Error):

ans = ""
for i in range(n):
    ans += s[i]
    ans += t[i]

print(ans)
Problem p02882 (python)

Fixed submission:
import math
a, b, x = [ int(v) for v in input().split() ]
v = a*a*b

if x < v/2:
    print(math.atan(b*b*a/(2*x))*(180/math.pi))
else:
    print(math.atan(2*(v-x)/(a**3))*(180/math.pi))

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

if x < v/2:
    print(math.atan(b*b*a/(2*x))*(180/math.pi))
else:
    print(math.atan(2*(v-x)/(a**3))*(180/math.pi))
Problem p02911 (python)

Fixed submission:
n, k, q = [ int(v) for v in input().split() ]
collect_list = [k-q for i in range(n)]

for i in range(q):
    a = int(input()) - 1
    collect_list[a] += 1


for i in range(n):
    print( "Yes" if collect_list[i] > 0 else "No" )

Buggy submission (verdict: Runtime Error):
f = open('input.txt', 'r')
sys.stdin = f

n, k, q = [ int(v) for v in input().split() ]
collect_list = [k-q for i in range(n)]

for i in range(q):
    a = int(input()) - 1
    collect_list[a] += 1


for i in range(n):
    print( "Yes" if collect_list[i] > 0 else "No" )
Problem p02923 (python)

Fixed submission:
n = int(input())
if n == 1:
    print(0)
else:
    h_list = [ int(v) for v in input().split() ]

    dh_list = []

    t = 0
    for i in range(n-1):
        if h_list[i] >= h_list[i+1]:
            t += 1
        else:
            t = 0
        dh_list.append(t)
    print(max(dh_list))

Buggy submission (verdict: Runtime Error):
n = int(input())
h_list = [ int(v) for v in input().split() ]

dh_list = []

t = 0
for i in range(n-1):
    if h_list[i] >= h_list[i+1]:
        t += 1
    else:
        t = 0
    dh_list.append(t)
print(max(dh_list))
Problem p02983 (python)

Fixed submission:
l, r = [ int(v) for v in input().split() ]

if l % 2019 == 0:
    ans = 0
elif r % 2019 == 0:
    ans = 0
elif l // 2019 == r // 2019:
    ans = 10**6
    l, r = l % 2019, r % 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min( ans, (i*j) % 2019 )


elif l // 2019 != r // 2019:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
if l % 2019 == 0:
    ans = 0
elif r % 2019 == 0:
    ans = 0
elif l // 2019 == r // 2019:
    ans = 10**6
    l, r = l % 2019, r % 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min( ans, (i*j) % 2019 )


elif l // 2019 != r // 2019:
    ans = 0
print(ans)
Problem p03032 (python)

Fixed submission:
n, k = [ int(v) for v in input().split() ]
jewel_list = [ int(v) for v in input().split() ]

ans = 0

for i in range(k+1):
    l = min(i,n)
    for j in range(l+1):
        left_gain = jewel_list[:j]
        if l-j != 0:
            right_gain = jewel_list[-l+j:]
        else:
            right_gain = []
        
        gabage = sorted(left_gain+right_gain)[:k-i]

        total = sum(left_gain+right_gain)
        for p in gabage:
            if p < 0:
                total -= p
            else:
                break
        ans = max(ans,total)

print(ans)

Buggy submission (verdict: Runtime Error):
ans = 0

for i in range(k+1):
    l = min(i,n)
    for j in range(l+1):
        left_gain = jewel_list[:j]
        if l-j != 0:
            right_gain = jewel_list[-l+j:]
        else:
            right_gain = []
        
        gabage = sorted(left_gain+right_gain)[:k-i]

        total = sum(left_gain+right_gain)
        for p in gabage:
            if p < 0:
                total -= p
            else:
                break
        ans = max(ans,total)

print(ans)
Problem p03068 (python)

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

ans_list = []
t = s[k-1]
for i in s:
  if i == t:
    ans_list.append(t)
  else:
    ans_list.append("*")
print("".join(ans_list))

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

ans = ""
for i in s:
	if i == s[k]:
    	ans += s[k]
	else:
    	ans += "*"
print(ans)

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

ans = ""
for i in s:
	if i == s[k]:
    	ans += s[k]
	else:
    	ans += "*"
print(ans)
Problem p03071 (python)

Fixed submission:
a, b = [ int(v) for v in input().split() ]
print(max(a+b,a*2-1,b*2-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
num_list = [ int(v) for v in input().split() ]
s = 0
for i in range(n):
	if max(num_list[:i+1]) <= num_list[i]:
		s += 1
print(s)
Problem p03074 (python)

Fixed submission:
n, k = [ int(v) for v in input().split() ]
s = input()

a_list = []
b_list = []

if s[0] == "0":
    a_list.append(0)
p = 0
for i in s:
    if i == "1" and p < 0:
        b_list.append(-p)
        p = 1
    elif  i == "1" and p >= 0:
        p += 1
    elif  i == "0" and p > 0:
        a_list.append(p)
        p = -1
    elif  i == "0" and p <= 0:
        p -= 1
if p < 0:
    b_list.append(-p)
    a_list.append(0)
else:
    a_list.append(p)


if len(b_list) <= k:
    ans = n
else:
    m = len(b_list) - k
    sequence = sum(a_list[:k+1]) + sum(b_list[:k])
    ans = sequence
    for i in range(m):
        sequence += a_list[i+k+1] - a_list[i]
        sequence += b_list[i+k] - b_list[i]
        ans = max(sequence, ans)
print(ans)

Buggy submission (verdict: Runtime Error):

n, k = [ int(v) for v in input().split() ]
s = list(map(int,list(input())))
binary_list = [0]
b = 0
for i in range(n):
	if s[i] == 1:
		b += 1
	else:
		b -= 1
	if i < n-1 and s[i] != s[i+1]:
		binary_list.append(b)
		b = 0
binary_list.append(b)
binary_list.append(0)

k = 2 * k + 1
ans = 0
for i in range(len(binary_list)-k+1):
	sumpart = collect(binary_list[i:i+k])
	ans = max(ans,sumpart)

print(ans)
Problem p03076 (python)

Fixed submission:

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish_list = [a,b,c,d,e]
count = 0
modmin = [10, -1]
for i in range(5):
    if dish_list[i] % 10 != 0:
        count += 1
        if  dish_list[i] % 10 < modmin[0]:
            modmin[0] = dish_list[i] % 10
            modmin[1] = i

if modmin[1] == -1:
    ans = sum(dish_list)
else:
    ans = 0
    for i in range(5):
        if dish_list[i] % 10 != 0 and i != modmin[1]:
            b = dish_list[i] + (10- (dish_list[i] % 10))
        else:
            b = dish_list[i] 
        ans += b

print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish_list = [a,b,c,d,e]

modmin = [10, -1]
for i in range(5):
    if dish_list[i] % 10 != 0:
        count += 1
        if  dish_list[i] % 10 < modmin[0]:
            modmin[0] = dish_list[i] % 10
            modmin[1] = i

if modmin[1] == -1:
    ans = sum(dish_list)
else:
    ans = 0
    for i in range(5):
        if dish_list[i] % 10 != 0 and i != modmin[1]:
            b = dish_list[i] + (10- (dish_list[i] % 10))
        else:
            b = dish_list[i] 
        ans += b

print(ans)
Problem p03078 (python)

Fixed submission:

import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)

cake_list = []
num_set = set([0])

def hash2(a,b,c):
    return 10**8*a+10**4*b+c


def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)

for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            num_set.add(hash2(1,0,0))
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            num_set.add(hash2(0,1,0))
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            num_set.add(hash2(0,0,1))
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if hash2(ai+1,bi,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                num_set.add(hash2(ai+1,bi,ci))
        if bi < y - 1:
            if hash2(ai,bi+1,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                num_set.add(hash2(ai,bi+1,ci))
        if ci < z - 1:
            if hash2(ai,bi,ci+1) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                num_set.add(hash2(ai,bi,ci+1))
        print(-di)

Buggy submission (verdict: Runtime Error):
x, y, z, k = [ int(v) for v in input().split() ]
a_list = sorted([ -int(v) for v in input().split() ], reverse = True )
b_list = sorted([ -int(v) for v in input().split() ], reverse = True )
c_list = sorted([ -int(v) for v in input().split() ], reverse = True )


def most_dericious(a,b,c):
	return a_list[a] + b_list[b] + c_list[c]
out_cakes_list= []
for i in range(k):
	if i == 0:
		dericious_heap = [ (most_dericious(x-1,y-1,z-1),(x-1,y-1,z-1)) ]
		heapq.heapify(dericious_heap)
	out_cakes = (heapq.heappop(dericious_heap))
	p, q, r = out_cakes[1][0], out_cakes[1][1], out_cakes[1][2]

	if p-1 >= 0 and (most_dericious(p-1,q,r),(p-1,q,r)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p-1,q,r),(p-1,q,r)))
	if q-1 >= 0 and (most_dericious(p,q-1,r),(p,q-1,r)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p,q-1,r),(p,q-1,r)))
	if r-1 >= 0 and (most_dericious(p,q,r-1),(p,q,r-1)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p,q,r-1),(p,q,r-1)))
	out_cakes_list.append(out_cakes)

out_cakes_list = sorted(out_cakes_list)
for i in range(k):
	print(-out_cakes_list[i][0])
Problem p03085 (python)

Fixed submission:
s = input()

if s == "A":
  print("T")
elif s == "T":
  print("A")
elif s == "G":
  print("C")
else:
  print("G")

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

if s == "A":
  print("T")
elif s == "T":
  print("A")
elif  == "G":
  print("C")
else:
  print("G")
Problem p03086 (python)

Fixed submission:

s = input()
ls = len(s)
part_s = set( [s[i:j+1] for i in range(ls) for j in range(ls)  ])
part_s = [ i for i in part_s if set(list(i)) | set(["A","T","C","G"]) == set(["A","T","C","G"])]
if part_s == []:
    print(0)
else:
    print(max(map(len,part_s)))

Buggy submission (verdict: Runtime Error):

s = input()
ls = len(s)
part_s = set( [s[i:j+1] for i in range(ls) for j in range(ls)  ])
part_s = [ i for i in part_s if set(list(i)) | set(["A","T","C","G"]) == set(["A","T","C","G"])]
print(max(map(len,part_s)))
Problem p03096 (python)

Fixed submission:

n = int(input())
ans_list = [ 1 for i in range(n) ]

color_list = [ -1 for i in range(2*(10**5))] 
for i in range(n):
    color = int(input()) - 1

    if color_list[color] not in [-1,i-1]:
        ans_list[i] = ans_list[i-1] + ans_list[color_list[color]]
    else:
        ans_list[i] = ans_list[i-1]
    ans_list[i] %= 10**9+7

    color_list[color] = i
print(ans_list[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans_list = [ 1 for i in range(n) ]

color_list = [ -1 for i in range(10**5)] 
for i in range(n):
    color = int(input()) - 1

    if color_list[color] not in [-1,i-1]:
        ans_list[i] = ans_list[i-1] + ans_list[color_list[color]]
    else:
        ans_list[i] = ans_list[i-1]
    ans_list[i] %= 10**9+7

    color_list[color] = i
print(ans_list[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans_list = [ 1 for i in range(n) ]

color_list = [ [0,-1] for i in range(10**5)] 
for i in range(n):
    color = int(input()) - 1

    if color_list[color][0] > 0 and color_list[color][1] not in [i-1,-1]:
        ans_list[i] = ans_list[i-1] + ans_list[color_list[color][1]]
    else:
        ans_list[i] = ans_list[i-1]
    ans_list[i] %= 10**9+7
    
    color_list[color][0] += 1
    color_list[color][1] = i
print(ans_list[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ans_list = [ 1 for i in range(n) ]

color_list = [ [0,-1] for i in range(10**5)] 
for i in range(n):
    color = int(input()) - 1
    color_list[color][0] += 1
    if color_list[color][0] > 0 and color_list[color][1] not in [i-1,-1]:
        ans_list[i] = ans_list[i-1] + ans_list[color_list[color][1]]
    else:
        ans_list[i] = ans_list[i-1]
    ans_list[i] %= 10**9+7
    color_list[color][1] = i
print(ans_list[-1])
Problem p03146 (python)

Fixed submission:
n = int(input())
stop = 0
num_list = []
while stop == 0:
	if n in num_list:
		stop = 1
		print(num_list.index(n)+4)
	else:
		num_list.append(n)
		if n % 2 == 0:
			n //= 2
		else:
			n = 3 * n + 1

Buggy submission (verdict: Runtime Error):
n = int(input())
stpo = 0
num_list = []
while stop == 0:
  if n in num_list:
    stop = 1
    print(num_list.index(n)+1)
  else:
    num_list.append(n)
    if n % 2 == 0:
      n //= 2
    else:
      n = 3 * n + 1
Problem p03165 (python)

Fixed submission:
s = input()
t = input()
ls, lt = len(s), len(t)

dp_list = [ [ 0 for i in range(ls+1) ] for j in range(lt+1) ]
index_list = [ [ None for i in range(ls) ] for j in range(lt) ]

for i in range(lt):
    for j in range(ls):
        if t[i] == s[j]:
            a = dp_list[i+1][j]
            b = dp_list[i][j+1]
            c = dp_list[i][j] + 1 
            p = [a,b,c].index(max(a,b,c))
            dp_list[i+1][j+1] = [a,b,c][p]
            index_list[i][j] = (1,p)

        else:
            a = dp_list[i+1][j]
            b = dp_list[i][j+1]
            p = [a,b].index(max(a,b))
            dp_list[i+1][j+1] = [a,b][p]
            index_list[i][j] = (0,p)

q = dp_list[-1][-1]
r = t   

a = 10**5

ans = ""
y, x = lt-1, ls-1
while y != -1 and x != -1:
    if index_list[y][x][1] == 2:
        x -= 1
        y -= 1
        ans += s[x+1]
    elif index_list[y][x][1] == 1:
        y -= 1
    elif index_list[y][x][1] == 0:
        x -= 1

print(ans[::-1])

Buggy submission (verdict: Runtime Error):

s, t = input(), input()
ls, lt = map(len,[s,t])

cls_list = [ [ 0 for j in range(lt+1) ] for i in range(ls+1) ]

    

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            cls_list[i+1][j+1] = max(cls_list[i+1][j], cls_list[i][j+1], cls_list[i][j] + 1)
        else:
            cls_list[i+1][j+1] = max(cls_list[i+1][j], cls_list[i][j+1])


ans = []
k = ls - cls_list[-1][-1]

for i in range(lt):
    if cls_list[k][i] != cls_list[k+1][i+1]:
        k += 1
        ans.append(t[i])


print("".join(ans))
Problem p03214 (python)

Fixed submission:
n = int(input())
flame_list = [ int(v) for v in input().split() ]

mean = sum(flame_list)/n

flame_list_2 = [ abs(mean - i) for i in flame_list ]


print(flame_list_2.index(min(flame_list_2)))

Buggy submission (verdict: Runtime Error):
n = int(input())
flame_list = [ int(v) for v in input().split() ]

mean = sum(flame_list)

if mean % 2 == 0:
  print(flame_list.index(mean//2))
else:
  print(min(flame_list.index((mean-1)//2),flame_list.index((mean+1)//2)))
Problem p03220 (python)

Fixed submission:
n = int(input())
t, a = [ int(v) for v in input().split() ]
height_list = [ abs(t-a-int(v)*0.006) for v in input().split() ]
print(height_list.index(min(height_list))+1)

Buggy submission (verdict: Runtime Error):
    n = int(input())
    t, a = [ int(v) for v in input().split() ]
    height_list = [ abs(t-a-int(V)*0.006) for v in input().split() ]
    print(height_list.index(min(height_list))+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
t, a = [ int(v) for v in input().split() ]
height_list = [ abs(t-a-int(V)*0.006) forfor v in input().split() ]
print(height_list.index(min(height_list))+1)
Problem p03228 (python)

Fixed submission:

a, b, k = [ int(v) for v in input().split() ]
	
for i in range(k):
	if i % 2 == 0:
		b += a // 2
		a = a // 2
		
	else:
		a += b // 2
		b = b // 2
print(a,b)

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

for i in range(k):
  if i % 2 == 0:
  	a = a // 2
    b += a // 2
  else:
    a += b // 2
    b = b // 2
print(a,b)
Problem p03251 (python)

Fixed submission:
n, m, x, y = [ int(v) for v in input().split() ]
xmax = max(sorted([ int(v) for v in input().split() ] + [x]))
ymin = min(sorted([ int(v) for v in input().split() ] + [y]))
ans = "War"
if xmax < ymin:
  ans = "No War"
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, x, y = [ int(v) for v in input().split() ]
xmax = sorted([ int(v) for v in input().split() ] + [x])
ymin = sorted([ int(v) for v in input().split() ] + [y])
ans = "War
if xmax < ymin:
  ans = "No War"
print(ans)
Problem p03254 (python)

Fixed submission:
def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist

n, x = [ int(v) for v in input().split() ]
candy_list = sorted([ int(v) for v in input().split() ])
candy_list_2 = cumsum(candy_list)

ans = 0
for i in range(n):
    if i != n-1 and candy_list_2[i] <= x:
        ans += 1
    elif i == n-1 and candy_list_2[i] == x:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, x = [ int(v) for v in input().split() ]
candy_list = sorted([ int(v) for v in input().split() ])
candy_list_2 = cumsum(candy_list)

if sum(candy_list) <= x:
    print(n)
else:
    for i in range(n):
        if candy_list_2[i] > x:
            print(i)
            break
Problem p03280 (python)

Fixed submission:

a, b = [ int(v) for v in input().split() ]
print((a-1)*(b-1))

Buggy submission (verdict: Runtime Error):
print((int(input())-1)*(int(input())-1))
Problem p03282 (python)

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

for i in range(len(s)):
	f = i+1
	if s[i] != "1":
		break

if k < f:
	print(1)
else:
	print(s[i])

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

for i in range(len(s)):
	if s[i] != "1":
		f = i+1
		break

if k < f:
	print(1)
else:
	print(s[i])

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

for i in range(len(s)):
	if s[i] != "1":
		f = i+1
		break

if k < f:
	print(1)
else:
	print(s[i])
Problem p03289 (python)

Fixed submission:

ans = "WA"
s = list(input())
if s[0] == "A":
  if s[2:-1].count("C") == 1:
    c = s[2:-1].index("C")+2

    if all([ s[i].islower() for i in range(1,len(s)) if i != c]):
      ans = "AC"

print(ans)

Buggy submission (verdict: Runtime Error):
ans = "WA"
s = list(input())
if s[0] == "A":
  if s[2:-1].count("C") == 1:
    c = s[2:-1].index("C")
    if all([ list[i].islower() for i in range(1,len(s)) if i != c]):
      ans = "AC"
print(ans)
Problem p03311 (python)

Fixed submission:
def total(inlist,k):
    print(sum([ abs(i-k) for i in inlist ]))
    return
n = int(input())
a_list = [ int(v) for v in input().split() ]
a_list = [ v-i for i, v in enumerate(a_list,1) ]
a_list.sort()

total(a_list,a_list[n//2])

Buggy submission (verdict: Runtime Error):
def total(inlist,k):
    print(sum([ abs(i-k) for i in inlist ]))
    return
n = int(input())
a_list = [ int(v) for v in input().split() ]
a_list = [ v-i for i, v in enumerate(a_list,1) ]
a_list.sort()

total(a_list,a_list[n//2])ｖ

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

num_list = [ int(v) for v in input().split() ]
num_list = [ num_list[i] - (i+1) for i in range(n) ]
median_u = num_list[(n//2)+1]
median_d = num_list[n//2]

d_list = [i-median_u for i in num_list]
u_list = [i-median_d for i in num_list]

print(min(sum(map(abs,d_list)),sum(map(abs,u_list))))