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

Fixed submission:
N,M = map(int,input().split())
A = list(map(int, input().split())) 

if N - sum(A) >= 0:
    print(N - sum(A))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [int(x) * M for x in input().split()]

if N - sum(A) >= 0:
    print(N - A.sum())
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [0] * M
A = [int(x) for x in input().split()]

if N - sum(A) >= 0:
    print(N - A.sum())
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [int(x) for x in input().split()]

if N - sum(A) >= 0:
    print(N - A.sum())
else:
    print(-1)
Problem p02718 (python)

Fixed submission:

N, M= map(int, input().split())

C = map(int, input().split())

A = list(C)

#if N < M:
#    print('No')
#if M == 0:
#    print('No')

B = []
for i in range(len(A)):
    if A[i] >= sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) >= M:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**3)

N, M= map(int, input().split())

A = [int(input()) for i in range(N)]

B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) >= M:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**6)

N, M= map(int, input().split())

A = [int(input()) for i in range(N)]

B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) >= M:
    print('Yes')
else:
    print('No')

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

if M == 0:
    print('No')
if N < M:
    print('No')

A = [int(input()) for i in range(N)]


B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) >= M:
    print('Yes')
else:
    print('No')

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

if M == 0:
    print('No')
if N < M:
    print('No')

A = [int(input()) for i in range(N)]


B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) > M:
    print('Yes')
else:
    print('No')

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

if M == 0:
    print('No')
if N < M:
    print('No')

A = [int(input()) for i in range(N)]


B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(1)
    else:
        B.append(0)

if sum(B) > N - M + 1:
    print('Yes')
else:
    print('No')

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

if M == 0:
    print('No')
if N < M:
    print('No')

A = [int(input()) for i in range(M)]


B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(0)
    else:
        B.append(1)

if sum(B) > N - M + 1:
    print('No')
else:
    print('Yes')

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

if M == 0:
    print('No')
if N < M:
    print('No')

A = [int(input()) for i in range(N)]


B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(0)
    else:
        B.append(1)

if sum(B) > N - M + 1:
    print('No')
else:
    print('Yes')

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

A = [int(input()) for i in range(N)]


B = []
for i in range(len(A)):
    if A[i] > sum(A)/4/M:
        B.append(0)
    else:
        B.append(1)

if sum(B) > N - M + 1:
    print('No')
else:
    print('Yes')
Problem p03695 (python)

Fixed submission:
#C - Colorful Leaderboard 

N = int(input())
A = list(map(int, input().split()))

n = 399
a, b, c, d, e, f, g, h, z = 0,0,0,0,0,0,0,0,0

for i in A:
    if i >= 1 and i <= n:
        a = 1
    elif i >= 400 and i <= n + 400:
        b = 1
    elif i >= 2*400 and i <= 2*400 + n:
        c = 1
    elif i >= 3*400 and i <= 3*400 + n:
        d = 1
    elif i >= 4*400 and i <= 4*400 + n:
        e = 1
    elif i >= 5*400 and i <= 5*400 + n:
        f = 1
    elif i >= 6*400 and i <= 6*400 + n:
        g = 1
    elif i >= 7*400 and i <= 7*400 + n:
        h = 1
    else:
        z += 1

min_num, max_num = 0, 0
        
min_num = a+b+c+d+e+f+g+h


max_num = min_num + z
min_num = max(1, min_num)

print(min_num,max_num)

Buggy submission (verdict: Runtime Error):
#C - Colorful Leaderboard 

N = int(input())
A = list(map(int, input().split()))

n = 399
a, b, c, d, e, f, g, h, z = 0,0,0,0,0,0,0,0,0

for i in A:
    if i >= 1 and i <= n:
        a = 1
    elif i >= 400 and i <= n + 400:
        b = 1
    elif i >= 2*400 and i <= 2*400 + n:
        c = 1
    elif i >= 3*400 and i <= 3*400 + n:
        d = 1
    elif i >= 4*400 and i <= 4*400 + n:
        e = 1
    elif i >= 5*400 and i <= 5*400 + n:
        f = 1
    elif i >= 6*400 and i <= 6*400 + n:
        g = 1
    elif i >= 7*400 and i <= 7*400 + n:
        h = 1
    else:
        z += 1

min_num, max_num = 0, 0
        
min_num = a+b+c+d+e+f+g+h

max_num = min(min_num + z)
min_num = max(1, min_num)

print(min_num,max_num)
Problem p03836 (python)

Fixed submission:
#C - Back and Forth
sx, sy, tx, ty = map(int,input().split())

route = ''

updown_num = ty - sy # 0>なら goalは上方向
rightleft_num = tx - sx #0>ならgoalは右方向

#route1
for i in range(updown_num):
    route += 'U'
for i in range(rightleft_num):
    route += 'R'
#route2
for i in range(updown_num):
    route += 'D'
for i in range(rightleft_num):
    route += 'L'
#route3
route += 'L'
for i in range(updown_num + 1):
    route += 'U'
for i in range(rightleft_num + 1):
    route += 'R'
route += 'D'
#route4
route += 'R'
for i in range(updown_num + 1):
    route += 'D'
for i in range(rightleft_num + 1):
    route += 'L'
route += 'U'

print(route)

Buggy submission (verdict: Runtime Error):
sx, sy, tx, ty = map(int,input().split())

route = ''

updown_num = ty - sy # 0>なら goalは上方向
rightleft_num = tx - sx #0>ならgoalは右方向

#route1
for i in range(updown_num):
    route += 'U'
for i in range(rightleft_num):
    route += 'R'
route2
for i in range(updown_num):
    route += 'D'
for i in range(rightleft_num):
    route += 'L'
#route3
route += 'L'
for i in range(updown_num + 1):
    route += 'U'
for i in range(rightleft_num + 1):
    route += 'R'
route += 'D'
#route4
route += 'R'
for i in range(updown_num + 1):
    route += 'D'
for i in range(rightleft_num + 1):
    route += 'L'
route += 'U'

print(route)
Problem p03069 (python)

Fixed submission:
"""
python3 a.py < input.txt
"""
import math
import itertools as it
import heapq

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

T=[S[0]]
U=[1]
for si in S[1:]:
    if T[-1] == si:
        U[-1] = U[-1]+1
    else:
        T.append(si)
        U.append(1)
M=len(T)

B=[U[i] if T[i] == "#" else 0 for i in range(M)]
sumB=[B[0]]
for b in B[1:]:
    sumB.append(sumB[-1]+b)

W=[U[i] if T[i] == "." else 0 for i in range(M)]
sumW=[W[-1]]
for w in reversed(W[:-1]):
    sumW.append(sumW[-1]+w)
sumW=list(reversed(sumW))

l=[sum(B), sum(W)]
for i in range(M):
    if T[i] == "#":
        l.append(sumB[max(0, i-1)] + sumW[min(i+1, M-1)])

#print(S)
#print(T)
#print("U   ",U)
#print("B   ",B)
#print("sumB",sumB)
#print("W   ",W)
#print("sumW",sumW)
#print("l   ",l)
print(min(l))

Buggy submission (verdict: Runtime Error):
"""
python3 a.py < input.txt
"""
import math
import itertools as it
import heapq

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

T=[S[0]]
U=[1]
for si in S[1:]:
    if T[-1] == si:
        U[-1] = U[-1]+1
    else:
        T.append(si)
        U.append(1)

lb=None
for i in reversed(range(len(T))):
    if T[i] == "#":
        lb=i
rb=None
for i in range(len(T)):
    if T[i] == "#":
        rb=i
rw=None
for i in range(len(T)):
    if T[i] == ".":
        rw=i

if lb == None or rw == None:
    print(0)
    exit()

nb=0
for i in range(lb, len(T)):
    if T[i] == ".":
        nb = nb+U[i]
nw=0
for i in range(rw):
    if T[i] == "#":
        nw = nw+U[i]
nx=0
for i in range(lb, rb):
    if T[i] == "#":
        nx = nx+U[i]
for i in range(rw, len(T)):
    if T[i] ==x".":
        nx = nw+U[i]
print(S)
print(min([nb, nw, nx]))
Problem p03078 (python)

Fixed submission:
"""
python3 main.py < input.txt
"""
import math
import itertools as it
import heapq

X,Y,Z,K=map(int, input().split())
A=list(sorted(map(int, input().split()), reverse=True))
B=list(sorted(map(int, input().split()), reverse=True))
C=list(sorted(map(int, input().split()), reverse=True))

def evaluate(x,y,z): return (-A[x]-B[y]-C[z], x,y,z)

Q=[]
heapq.heappush(Q, evaluate(0,0,0))
for i in range(1,K+1):
    (e,x,y,z) = heapq.heappop(Q)
    print(-e)
    if x+1 < X and evaluate(x+1, y, z) not in Q:
        heapq.heappush(Q, evaluate(x+1, y, z))
    if y+1 < Y and evaluate(x, y+1, z) not in Q:
        heapq.heappush(Q, evaluate(x, y+1, z))
    if z+1 < Z and evaluate(x, y, z+1) not in Q:
        heapq.heappush(Q, evaluate(x, y, z+1))

Buggy submission (verdict: Runtime Error):
/*
g++ main.cpp --std=c++14; ./a.out < input.txt
*/
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<tuple>

using namespace std;

const auto mod = 1000000007L;

typedef long long ll;

template<typename T>
using V = vector<T>;

template<typename K, typename V>
using M = map<K,V>;

ll sum(tuple<ll,ll,ll> const & t, V<ll> const & A, V<ll> const & B, V<ll> const & C) {
        auto a = get<0>(t);
        auto b = get<1>(t);
        auto c = get<2>(t);
        return A[a]+B[b]+C[c];
}

int main() {
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    auto A=V<ll>(X);
    for(size_t i = 0; i < X; i++)cin>>A[i];
    sort(A.begin(), A.end(), [](auto a, auto b){return a>b;});
    auto B=V<ll>(Y);
    for(size_t i = 0; i < Y; i++)cin>>B[i];
    sort(B.begin(), B.end(), [](auto a, auto b){return a>b;});
    auto C=V<ll>(Z);
    for(size_t i = 0; i < Z; i++)cin>>C[i];
    sort(C.begin(), C.end(), [](auto a, auto b){return a>b;});
    auto Q=multimap<ll, tuple<ll, ll, ll>, greater<ll>>();
    Q.insert(decltype(Q)::value_type(sum(make_tuple(0,0,0), A, B, C), make_tuple(0,0,0)));
    for(size_t k = 0; k < K; k++)
    {
        auto t = Q.begin();
        cout << t->first << "\n";
        auto a = get<0>(t->second);
        auto b = get<1>(t->second);
        auto c = get<2>(t->second);
        Q.erase(t) ;
        auto d=make_tuple(a, b, c+1);
        if (c+1<X) Q.insert(decltype(Q)::value_type(sum(d, A, B, C), d));
        auto e=make_tuple(a, b+1, c);
        if (c+1<Y) Q.insert(decltype(Q)::value_type(sum(e, A, B, C), e));
        auto f=make_tuple(a+1, b, c);
        if (c+1<Z) Q.insert(decltype(Q)::value_type(sum(f, A, B, C), f));
    }
}
Problem p03125 (python)

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

Buggy submission (verdict: Runtime Error):

n, m = map(int, input().split(' '))
ai = list(sorted(map(int, input().split(' '))))
required_maches = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}

used_numbers = dict()

def evaluate(l):
    if l == None:
        return -9999999999999999999999999999999
    if l == []:
        return 0
    return int(''.join(reversed([str(i) for i in sorted(l)])))

min_maches = min([required_maches[x] for x in ai])
def find(matches_count_to_use):
    if matches_count_to_use not in used_numbers:
        if matches_count_to_use < 0:
            used_numbers[matches_count_to_use] = None
        elif matches_count_to_use == 0:
            used_numbers[matches_count_to_use] = []
        else:
            candidates = list(filter(
                lambda x: find(matches_count_to_use - required_maches[x]) != None, ai))
            if len(candidates) == 0:
                used_numbers[matches_count_to_use] = None
            else:
                number_to_use = max(candidates,
                    key=lambda x: evaluate(find(matches_count_to_use - required_maches[x]) + [x]))
                prev = find(matches_count_to_use - required_maches[number_to_use])
                used_numbers[matches_count_to_use] = prev + [number_to_use]
                
    return used_numbers[matches_count_to_use]
    
print(evaluate(find(n)))
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = list(map(int, input().split()))
for base in range(x+1):
    if p.count(x+base*-1) == 0:
        print(x+base*-1)
        break
    if p.count(x+base) == 0:
        print(x+base)
        break

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n <= 0:
    print(x)
else:
    tbl = [0 for i in range(101)]
    data_in = input().split()
    for num in data_in:
        tbl[int(num)] = 1
    for i in range(1, 101, 1):
        if (x-i >= 0) and (tbl[x-i] == 0):
            print(x-i)
            break
        if (x+i <= 101) and (tbl[x+i] == 0):
            print(x+i)
            break
Problem p02690 (python)

Fixed submission:
import numpy as np
X = int(input())

t = np.arange(0, 2000001, 1)
t = t**5
S = set(t)

for B in range(0,200001,1):
    if X+B**5 in S:
        print("%d %d"%((X+B**5)**0.2, B))
        break
    if X-B**5 in S:
        print("%d %d"%((X-B**5)**0.2, -B))
        break

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())

t = np.arange(-1000000, 1000001, 1)
t = t**5
S = set(t)

for B in range(-100000,100001,1):
    if X+B**5 in S:
        print("%d %d"%((X+B**5)**0.2, B))
        break

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())

t = np.arange(-1000000, 1000000, 1)
t = t**5
S = set(t)

for B in range(-1000000, 1000001, 1):
    if X+B**5 in S:
        print("%d %d"%((X+B**5)**0.2, B))
        break

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())

t = np.arange(-600000, 600000, 1)
t = t**5
S = set(t)

for B in range(-600000, 600001, 1):
    if X+B**5 in S:
        print("%d %d"%((X+B**5)**0.2, B))
        break

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())

t = np.arange(-100000, 100000, 1)
t = t**5
S = set(t)

for B in range(-100000, 100001, 1):
    if X+B**5 in S:
        print("%d %d"%((X+B**5)**0.2, B))
        break
Problem p02921 (python)

Fixed submission:
S=input()
T=input()
cnt=0
for i in range(3):
  if S[i]==T[i]:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
    S=input()
    T=input()
    cnt=0
    for i in range(3):
      if S[i]==T[i]:
        cnt+=1
    print(cnt)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
cnt=0
for i in range(3):
  if S[i]==T[i]:
    cnt++
print(cnt)
Problem p03419 (python)

Fixed submission:
H,W =[int(i) for i in input().split()]
if H*W==1:
    print(1)
elif H==1 and W!=1:
    print(max(0, W-2))
elif W==1 and H!=1:
    print(max(0, H-2))
else:
    print(max(H-2, 0)*max(W-2, 0))

Buggy submission (verdict: Runtime Error):
H,W =[int(i) for i in input().split()]
if H*W=1:
    print(1)
elif H==1 and W!=1:
    print(max(0, W-2))
elif W==1 and H!=1:
    print(max(0, H-2))
else:
    print(max(H-2, 0)*max(W-2, 0))

Buggy submission (verdict: Runtime Error):
H, W =[int(i) for i in input().split()]
if H*W=1:
     print(1)
elif H==1 and W!=1:
     print(max(0, W-2))
elif W==1 and H!=1:
     print(max(0, H-2))
else:
     print(max(H-2, 0)*max(W-2, 0))

Buggy submission (verdict: Runtime Error):
    H, W =[int(i) for i in input().split()]
    if H==1 and W!=1:
      print(max(0, W-2))
    elif W==1 and H!=1:
      print(max(0, H-2))
    else:
      print(max(H-2, 0)*max(W-2, 0))
Problem p03035 (python)

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

def main(_old, _fee):
    if int(_old) >= 13:
        return int(_fee)
    elif 6 <= int(_old) <= 12:
        return int(_fee) // 2
    else:
        return 0

if __name__ == '__main__':
    print(main(a, b))

Buggy submission (verdict: Runtime Error):
import sys

argvs = sys.argv

def main(_old, _fee):
  if int(_old) >= 13:
    return int(_fee)
  elif 6 <= int(_old) <= 12:
    return int(_fee) / 2
  else:
    return 0
  
if __name__ == '__main__':
  print(main(argvs[1], argvs[2]))
Problem p02993 (python)

Fixed submission:
S=input()

tmp=""
for i in range(len(S)):
	if tmp==S[i]:
		print("Bad")
		break
	else:
		tmp=S[i]
	if i==len(S)-1:
		print("Good")

Buggy submission (verdict: Runtime Error):
import math

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

if X<A:
	print(0)
else:
	print(10)
Problem p03001 (python)

Fixed submission:
W,H,x,y=map(int,input().split())

print(H*W/2,end=" ")
if x==W/2 and y==H/2:
	print(1)
else:
	print(0)

Buggy submission (verdict: Runtime Error):
W,H,x,y=map(int,input().split())

print(H*W/2,end=" ")
if x==W/2 and y==H/w:
	print(1)
else:
	print(0)
Problem p02952 (python)

Fixed submission:
N = int(input())
import math
count = 0
for i in range(1,N+1):
    if int(math.log10(i)) %2 ==0:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
N = input()
import math
count = 0
for i in range(1,N+1):
    if int(math.log10(i)) %2 ==1:
        count+= 1
print(count)
Problem p02958 (python)

Fixed submission:
N = int(input())
suuretsu_str = input().split()
suuretsu = [int(i) for i in suuretsu_str]
suuretsu_order = [i for i in range(1,N+1)]
count = 0
for i in range(N):
    if suuretsu[i] != suuretsu_order[i]:
        count += 1
if count == 2 or count == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
suuretsu_str = input().split()
suuretsu = [int(i) for i in suuretsu_str]
suuretsu_order = [i for i in range(1,N+1)]
count = 0
for i in range(N):
    if suuretsu[i] != suuretsu_order[i]
    count += 1
if count == 2:
    print("YES")
else:
    print("NO")
Problem p03455 (python)

Fixed submission:
S = input().split(" ")
a, b = [int(i) for i in S]
if (a*b)%2 == 1:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a, b = [int(i) for i in input().split("")]
if (a*b)%2 == 1:
    print("Odd")
else:
    print("Even")
Problem p03760 (python)

Fixed submission:
even = input()
odd = input()
if (len(even) - len(odd)) % 2 == 0:
    for i in range(len(even)):
        print(even[i], odd[i], sep="", end="")
else:
    for i in range(len(even)-1):
        print(even[i], odd[i], sep="", end="")
    print(even[-1])

Buggy submission (verdict: Runtime Error):
even = input()
odd = input()
if (even - odd) % 2 == 0:
    for i in range(len(even)):
        print(even[i], odd[i], sep="", end="")
else:
    for i in range(len(even)-1):
        print(even[i], odd[i], sep="", end="")
    print(even[-1])
Problem p02536 (python)

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

#素集合 無向グラフ
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return False

    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
    return True

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)
for i in range(m):
  x,y=map(int,input().split())
  uf.union(x-1,y-1)
print(uf.group_count()-1)

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

#素集合 無向グラフ
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return False

    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
    return True

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)
for i in range(m):
  x,y=map(int,input().split())
  uf.union(x,y)
print(uf.group_count()-1)
Problem p02780 (python)

Fixed submission:
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int, input().split()))
b = [0] + a
b = list(accumulate(b))

ans = []
for i in range(n-k+1):
    ans.append(b[i+k]-b[i])
index = ans.index(max(ans))
a=a[index:index+k]
total=0
for i in a:
  total+=(1+i)/2
print(total)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int, input().split()))
b = [0] + a
b = list(accumulate(b))

ans = []
for i in range(n-k):
    ans.append(b[i+k]-b[i])
index = ans.index(max(ans))

a=a[index:index+k]
total=0
for i in a:
  total+=sum(range(i+1))/i
print(total)
Problem p02817 (python)

Fixed submission:
str1,str2=input().split()
print(str2+str1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
point=0
l=[]
point_list=[r,s,p]
kind=['r','s','p','r']
for i in range(n):
  for j in range(len(kind)-1):
    if t[i]==kind[j]:
      if i-k>=0 and t[i]==kind[l[i-k]+1]:
        if i+k<n and t[i+k]==kind[j+1]:
          if j==2:j=-1
          l.append(j+1)
        else:
          l.append(j)
      else:
        point+=point_list[j-1]
        if j==0:j=3
        l.append(j-1)
      break
print(point)
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(500000)

n=int(input())
l=[[] for i in range(n)]
ans=[0]*(n-1)

def dfs(v,c,p):
  k=1
  for i in range(len(l[v])):
    u=l[v][i][0]
    id=l[v][i][1]
    if(u==p):continue
    if(k==c):k+=1
    ans[id]=k
    dfs(u,ans[id],v)
    k+=1
for i in range(n-1):
  a,b=map(int,input().split())
  l[a-1].append((b-1,i))
  l[b-1].append((a-1,i))
dfs(0,-1,-1)
print(max(ans))
for i in ans:
  print(i)

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
l=[[] for i in range(n)]
ans=[0]*(n-1)

def dfs(v,c,p):
  k=1
  for i in range(len(l[v])):
    u=l[v][i][0]
    id=l[v][i][1]
    if(u==p):continue
    if(k==c):k+=1
    ans[id]=k
    k+=1
    dfs(u,ans[id],v)
for i in range(n-1):
  a,b=map(int,input().split())
  l[a-1].append((b-1,i))
  l[b-1].append((a-1,i))
dfs(0,-1,-1)
print(max(ans))
for i in ans:
  print(i)
Problem p02882 (python)

Fixed submission:
import math
a,b,x=map(int,input().split())
if (a*a*b)>=2*x:
  h=x/(b*(a/2))
  print(90-math.degrees(math.atan(h/b)))
else:
  h=(((x/a)*2)/a)-b
  b-=h
  if b!=0:
    print(90-math.degrees(math.atan(a/b)))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
if (a*a*b)>=2*x:
  h=x/(b*(a/2))
  print(90-math.degrees(math.atan(h/b)))
else:
  h=(((x/a)*2)/a)-b
  b-=h
  print(90-math.degrees(math.atan(a/b)))