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

Fixed submission:
N, M = (int(i) for i in input().split()) 

outs = [[] for i in range(N)]
ins = [0] * N


for _ in range(M):
    x, y = (int(i) for i in input().split())
    x -= 1
    y -= 1
    outs[x].append(y)
    ins[y] += 1

q = []
for i in range(N):
    if ins[i] == 0:
        q.append(i)

result = []
while q != []:
    qn = q.pop()
    result.append(qn)
    for v in outs[qn]:
        ins[v] -= 1
        if ins[v] == 0:
            q.append(v)


last = [0] * N
# last[i] = iが最後だったときに最長のパス
for sq in result:
    for v in outs[sq]:
        last[v] = max(last[v], last[sq] + 1)

print(max(last))

Buggy submission (verdict: Runtime Error):
N, M = (int(i) for i in input().split()) 
 
outs = [[] for i in range(N)]
ins = [0] * N
 
for _ in range(M):
    x, y = (int(i) for i in input().split())
    x -= 1
    y -= 1
    outs[x].append(y)
    ins[y] += 1
 
q = []
for i in range(N):
    if ins[i] == 0:
        q.append(i)
 
last = [0] * N
while q != []:
    qn = q.poplef()
    for v in outs[qn]:
        ins[v] -= 1
        last[v] = max(last[v], last[qn] + 1)
        if ins[v] == 0:
            q.append(v)
 
print(max(last))

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

outs = [[] for i in range(N)]
ins = [0] * N


for _ in range(M):
    x, y = (int(i) for i in input().split())
    x -= 1
    y -= 1
    outs[x].append(y)
    ins[y] += 1

q = []
for i in range(N):
    if ins[i] == 0:
        q.append(i)

result = []
while q != []:
    qn = q.pop(0)
    result.append(qn)
    for v in outs[qn]:
        ins[v] -= 1
        if ins[v] == 0:
            q.append(v)


last = [0] * N
# last[i] = iが最後だったときに最長のパス
for sq in result:
    for v in outs[sq]:
        last[v] = max(last[v], last[sq] + 1)

print(max(last)
Problem p03206 (python)

Fixed submission:
D = int(input())

if D == 22:
    print("Christmas Eve Eve Eve")
if D == 23:
    print("Christmas Eve Eve")
if D == 24:
    print("Christmas Eve")
if D == 25:
    print("Christmas")

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

h = [0] * N
for i in range(N):
    h[i] = int(input())

h.sort()

min = 1000000000

for i in range(N - K + 1):
    if min > h[i + K - 1] - h[i]:
        min = h[i + K - 1] - h[i]

print(min)
Problem p03219 (python)

Fixed submission:
x, y = (int(i) for i in input().split())

print(int(x+y/2))

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

clist = []
for _ in range(M):
    p, y = (int(i) for i in input().split())
    clist.append((p,y))

pp = []
for o in range(N):
    pp.append([])

for p, y in clist:
    pp[p-1].append(y)

spp = []
index = 0
for _ in range(N):
    spp.append(sorted(pp[index]))
    index = index + 1

for p, y in clist:
    num = spp[p-1].index(y) + 1
    print('%06d' % p + '%06d' % num)
Problem p03231 (python)

Fixed submission:
import fractions

N, M = (int(i) for i in input().split())  
S = input()
T = input()

L = fractions.gcd(N, M)
lcm = (N * M) // fractions.gcd(N, M)

flag = True
for i in range(L):
    if (S[N//L * i] != T[M//L * i]):
        flag = False

if flag:
    print(lcm)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
import fraction
N, M = (int(i) for i in input().split())  
S = input()
T = input()

L = fraction.gcd(N, M)
lcm = (N * M) // L

flag = True
for i in range(L):
    if (S[N//L * i] != T[M//L * i]):
        flag = False

if flag:
    print(lcm)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
import math
N, M = (int(i) for i in input().split())  
S = input()
T = input()

L = math.gcd(N, M)
lcm = (N * M) // math.gcd(N, M)

flag = True
for i in range(L):
    if (S[N//L * i] != T[M//L * i]):
        flag = False

if flag:
    print(lcm)
else:
    print("-1")
Problem p03206 (python)

Fixed submission:
a=int(input())
b="Christmas"
for i in range(25-a):
	b+=" Eve"
print(b)

Buggy submission (verdict: Runtime Error):
a=int(input())
b="Christmas"
for i in range(25-a)
	b+=" Eve"
print(b)

Buggy submission (verdict: Runtime Error):
a=int(input())
b="Christmas"
for i in range(25-a)
	b+=" Eve"
  print(b)
Problem p02683 (python)

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

A = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
  c_as = list(map(int, input().split()))
  c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
  
for s in range(0, 1 << n):
  skill = [0] * m
  money = 0
  for i in range(n):
    if(s >> i) % 2 == 0:continue
    money += c[i]
    for j in range(m):
      skill[j] += A[i][j]
  ok = True
  for j in range(m):
    if skill[j] < x:
      ok = False
  if ok:
    ans = min(ans, money)
    
if ans == INF:
  ans = -1
  
print(ans)

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

A = [[] for _ in range(n)]
c = [0] * n

INF = 10**9
ans = INF

for i in range(n):
  c_as = list(map(int, input().split()))
  c[i], A[i] = c_as[0], c_as[1:]
  
for s in range(0, 1 << n):
  skill = [0] * n
  money = 0
  for i in range(n):
    if(s >> i) % 2 == 0:continue
    money += c[i]
    for j in range(m):
      skill[j] += A[i][j]
  ok = True
  for j in range(m):
    if skill[j] < x:
      ok = False
  if ok:
    ans = min(ans, money)
    
if ans == INF:
  ans = -1
  
print(ans)

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

A = [[] for _ in range(n)]
c = [0] * n

INF = 10**9
ans = INF

for i in range(n):
  c_as = list(map(int, input().split()))
  c[i], A[i] = c_as[0], c_as[1:]
  
for s in range(0, 1 << n):
  money = 0
  skill = [0] * n
  for i in range(n):
    if(s >> i) % 2 == 0:continue
    money += c[i]
    for j in range(m):
      skill[j] += A[i][j]
  ok = True
  for j in range(m):
    if skill[j] < x:
      ok = False
  if ok:
    ans = min(ans, money)
    
if ans == INF:
  ans = -1
  
print(ans)
Problem p02584 (python)

Fixed submission:
x,k,d=map(int,input().split())
x1=abs(x)%d
x2=abs(abs(x1)-d)
num=abs(x)//d
if((k-num)>=0):
    if((k-num)%2==0):
        print(x1)
    else:
        print(x2)
else:
    print(abs(x)-k*d)

Buggy submission (verdict: Runtime Error):
x,k,d=map(int,input().split())
x1=abs(x)%d
x2=abs(abs(x1)-d)
num=abs(x)//d
if((k-num)>=0):
	if((k-num)%2==0):
    	print(x1)
	else:
    	print(x2)
else:
   print(abs(x)-k*d)

Buggy submission (verdict: Runtime Error):
x,k,d=map(int,input().split())
x1=abs(x)%d
x2=abs(abs(x1)-d)
num=abs(x)//d
if((k-num>=0):
	if((k-num)%2==0):
    	print(x1)
	else:
    	print(x2)
else:
   print(abs(x)-k*d)
Problem p02610 (python)

Fixed submission:
import heapq as hp
# heapq.heappush(heap,item)
# heapq.heppop(heap) 最小値　最初のやつの取り出し
t=int(input())
for i in range(t):
    n=int(input())
# 左からkまでなら、+x lef[k]=[3,4,5]
    lef=[[] for i in range(n+1)]
    rig=[[] for i in range(n+1)]
    a=[]
    hp.heapify(a)
    ans=0
    lefcnt=0

    for i in range(n):
        k,l,r=map(int,input().split())
        if(l>=r):
            ans+=r
            lefcnt+=1
            tmp=l-r
            lef[k].append(tmp)
        else:
            ans+=l
            tmp=r-l
            rig[n-k].append(tmp)
    for i in range(n,lefcnt,-1):
        for j in lef[i]:
            hp.heappush(a,-j)           
    for i in range(lefcnt,0,-1):
        for j in lef[i]:
            hp.heappush(a,-j)
        if(a):
            tmp=hp.heappop(a)*(-1)
            ans+=tmp

    a=[]
    hp.heapify(a)
    for i in range(n,n-lefcnt,-1):
        for j in rig[i]:
            hp.heappush(a,-j)    
    for i in range(n-lefcnt,0,-1):
        for j in rig[i]:
            hp.heappush(a,-j)
        if(a):
            tmp=hp.heappop(a)*(-1)
            ans+=tmp
    print(ans)

Buggy submission (verdict: Runtime Error):
import heapq as hp
# heapq.heappush(heap,item)
# heapq.heppop(heap) 最小値　最初のやつの取り出し
t=int(input())
for i in range(t):
    n=int(input())
# 左からkまでなら、+x lef[k]=[3,4,5]
    lef=[[] for i in range(n+1)]
    rig=[[] for i in range(n+1)]
    a=[]
    hp.heapify(a)
    ans=0
    lefcnt=0

    for i in range(n):
        k,l,r=map(int,input().split())
        if(l>=r):
            ans+=r
            lefcnt+=1
            tmp=l-r
            lef[k].append(tmp)
        else:
            ans+=l
            tmp=r-l
            rig[n-k].append(tmp)
    for i in range(lefcnt,0,-1):
        for j in lef[i]:
            hp.heappush(a,-j)
        if(a):
            tmp=hp.heappop(a)*(-1)
            ans+=tmp

    a=[]
    hp.heapify(a)
    for i in range(n-lencnt,0,-1):
        for j in rig[i]:
            hp.heappush(a,-j)
        if(a):
            tmp=hp.heappop(a)*(-1)
            ans+=tmp
    print(ans)
Problem p02683 (python)

Fixed submission:
n,m,x=map(int,input().split())
arr=[[0 for i in range(m+1)] for j in range(n)]
b=[0]*18
ans=-1
flag=1
for i in range(n):
    arr[i]=list(map(int,input().split()))
for i in range(2**n):
    b=[0]*18
    for j in range(n):
        flag=1
        if (1& i>>j):
            for s in range(m+1):
                b[s]= b[s]+arr[j][s]
        for y in range(1,m+1):
            if(b[y]<x):
                flag=0
                
        if flag :
            if ans==-1 or ans>b[0]:
                ans=b[0]
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
arr=[[0 for i in range(m+1)] for j in range(n)]
b=[0]*18

flag=1
for i in range(n):
    arr[i]=list(map(int,input().split()))
for i in range(2**n):
    b=[0]*18
    for j in range(n):
        flag=1
        if (1& i>>j):
            for s in range(m+1):
                b[s]= b[s]+arr[j][s]
        for y in range(1,m+1):
            if(b[y]<x):
                flag=0
                
        if flag :
            if ans==-1 or ans>b[0]:
                ans=b[0]
print(ans)
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=1
doubling=[[0 for i in range(n)] for j in range(60)]
for i in range(n):
    doubling[0][i]=a[i]
for i in range(59):
    for j in range(n):
        doubling[i+1][j]=doubling[i][doubling[i][j]]
v=0
for d in range(60):
    if(k>>d &1):
        v=doubling[d][v]

print(v+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
global s
for i in range(k):
    key
    if(i==0):
        key=0
    s=a[key-1]
    if(i==k-1):
        break
    key=a[s-1]
print(s)
Problem p02787 (python)

Fixed submission:
h,n=map(int,input().split())
a=[0]
b=[0]
width=2*10**4+7
dp=[[10**10 for i in range(width)] for j in range(n+1)]
dp[0][0]=0
dp[1][0]=0
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
for i in range(1,n+1):
    for j in range(width):
        dp[i][j]=min(dp[i][j],dp[i-1][j])
        if(j+a[i]<width):
            dp[i][j+a[i]]=min(dp[i][j+a[i]],dp[i][j]+b[i])
print(min(dp[n][h:]))

Buggy submission (verdict: Runtime Error):
h,n=map(int,input().split())dp=[10**10 for i in range(h+1)]
dp[0]=0
for i in range(n):
    x,y=map(int,input().split())
    for j in range(h+1):
        nj=min(h,j+x)
        dp[nj]=min(dp[nj],dp[j]+y)
print(dp[h])
Problem p03161 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(1,k+1):
        if((i-j)>=0):
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
            
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(1,k+1):
        if((i-j)>=0):
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
            print(dp)
print(dp[n-1])
Problem p03162 (python)

Fixed submission:
n=int(input())
#a=[0,a1,a2,a3,...,an]
a=[0]
b=[0]
c=[0]
#０日め　0,0,0
#1日目　a1,b1,c1
#2日目　a2=b1+a2 or c1+a2
dp=[[0 for i in range(3)] for j in range(n+1)]
for i in range(n):
    x,y,z=map(int,input().split())
    a.append(x)
    b.append(y)
    c.append(z)
for i in range(1,n+1):
    dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i])
    dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i])
    dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i])
print(max(dp[n]))

Buggy submission (verdict: Runtime Error):
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
Problem p03354 (python)

Fixed submission:
class uft():
    def __init__(self,n):
        self.p=[ -1 for i in range(n)]
        self.r=[ 1 for i in range(n)]
        
    def find(self,x):
        if(self.p[x]==-1):
            return x
        else:
            self.p[x]=self.find(self.p[x])
            return self.find(self.p[x])
        
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(self.r[x]>self.r[y]):
            tmp=x
            x=y
            y=tmp
            
        if(self.r[x]==self.r[y]):
            self.r[y]+=1
            
        if(x!=y):
            self.p[x]=y
        return
    
n,m=map(int,input().split())
p=list(map(int,input().split()))
for i in range(n):
  p[i]-=1
uf=uft(n)
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    uf.unite(x,y)
ans=0
for i in range(n):
    if(uf.find(i)==uf.find(p[i])):
        ans+=1
        
print(ans)

Buggy submission (verdict: Runtime Error):
class uft():
    def __init__(self,n):
        self.p=[ -1 for i in range(n)]
        self.r=[ 1 for i in range(n)]
        
    def find(self,x):
        if(self.p[x]==-1):
            return x
        else:
            self.p[x]=self.find(self.p[x])
            return self.find(self.p[x])
        
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(self.r[x]>self.r[y]):
            tmp=x
            x=y
            y=tmp
            
        if(self.r[x]==self.r[y]):
            self.r[y]+=1
            
        if(x!=y):
            self.p[x]=y
        return
    
n,m=map(int,input().split())
p=list(map(int,input().split()))
uf=uft(n)
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    uf.unite(x,y)
ans=0
for i in range(n):
    if(uf.find(i)==uf.find(p[i])):
        ans+=1
        
print(ans)
Problem p03363 (python)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
ans=0
accum = [0]*(n+1)
accum[0]=0
for i in range(n):
    accum[i+1]=a[i]+accum[i]

z=Counter(accum)
for k,v in z.items():
    ans+=v*(v-1)/2
    
print(int(ans))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
ans=0
accum = [0]*(n+1)
accum[0]=0
for i in range(n):
    accum[i+1]=a[i]+accum[i]

z=Counter(accum)
for k,v in z:
    ans+=n(n-1)/2
    
print(ans)
Problem p02582 (python)

Fixed submission:
S = input()
p = 0
q = 0
for i in range(len(S)):
    if S[i] != 'S':
        p += 1
        if p > q:
            q = p
    else:
      	p = 0
print(q)

Buggy submission (verdict: Runtime Error):
p = 0
q = 0
for i in range(len(S)):
    if S[i] != 'S':
        p += 1
        if p > q:
            q = p
    else:
      	p = 0
print(q)

Buggy submission (verdict: Runtime Error):
p = 0
for i in range(len(S)):
    if S[i] != 'S':
        p =+ 1
	else:
      	p == 0
print(p)

Buggy submission (verdict: Runtime Error):
p = 0
for i in range(len(S)):
    if S[i] != 'S':
        p =+ 1
print(p)
Problem p02716 (python)

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

DP_odd = [0, 0, A[0]]
DP_even = [0, max(A[0], A[1])]

if N >= 3:
    DP_odd = [DP_even[0], max(DP_odd[1] + A[2], DP_even[1]), DP_odd[2] + A[2]]

for i in range(3, N):
    if (i + 1) % 2 == 1:    
        DP_odd = [max(DP_odd[0] + A[i], DP_even[0]), max(DP_odd[1] + A[i], DP_even[1]), DP_odd[2] + A[i]]
    else:
        DP_even = [max(DP_even[0] + A[i], DP_odd[1]), max(DP_even[1] + A[i], DP_odd[2])]

if N % 2 == 1:
    ans = DP_odd[1]
else:
    ans = DP_even[1]

print(ans)

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

DP_odd = [0, 0, A[0]]
DP_even = [0, max(A[0], A[1])]

if N >= 3:
    DP_odd = [DP_even[0], max(DP_odd[1] + A[i], DP_even[1]), DP_odd[2] + A[2]]

for i in range(3, N):
    if (i + 1) % 2 == 1:    
        DP_odd = [max(DP_odd[0] + A[i], DP_even[0]), max(DP_odd[1] + A[i], DP_even[1]), DP_odd[2] + A[i]]
        print(DP_odd)
    else:
        DP_even = [max(DP_even[0] + A[i], DP_odd[1]), max(DP_even[1] + A[i], DP_odd[2])]
        print(DP_even)

if N % 2 == 1:
    ans = DP_odd[1]
else:
    ans = DP_even[1]

print(ans)
Problem p02727 (python)

Fixed submission:
from collections import deque

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

r = deque(r)
deque_p = deque(p[:X])
deque_q = deque(q[:Y])
deque_r = deque([])

if r:
    while min(deque_p[-1], deque_q[-1]) < r[0]:
        if deque_p[-1] <= deque_q[-1]:
            deque_p.pop()
            deque_r.append(r.popleft())
        else:
            deque_q.pop()
            deque_r.append(r.popleft())

        if (not r) or (not deque_p) or (not deque_q):
            break

if r and deque_p:
    while deque_p[-1] < r[0]:
        deque_p.pop()
        deque_r.append(r.popleft())

        if (not r) or (not deque_p):
            break

if r and deque_q:
    while deque_q[-1] < r[0]:
        deque_q.pop()
        deque_r.append(r.popleft())

        if (not r) or (not deque_q):
            break
    

ans = sum(deque_p) + sum(deque_q) + sum(deque_r)

print(ans)

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

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

r = deque(r)
deque_p = deque(p[:X])
deque_q = deque(q[:Y])
deque_r = deque([])

if r:
    while min(deque_p[-1], deque_q[-1]) < r[0]:
        if deque_p[-1] <= deque_q[-1]:
            deque_p.pop()
            deque_r.append(r.popleft())
        else:
            deque_q.pop()
            deque_r.append(r.popleft())

        if not r:
            break

ans = sum(deque_p) + sum(deque_q) + sum(deque_r)

print(ans)

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

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

r = deque(r)
deque_p = deque(p[:X])
deque_q = deque(q[:Y])
deque_r = deque([])

while min(deque_p[-1], deque_q[-1]) < r[0]:
    if deque_p[-1] <= deque_q[-1]:
        deque_p.pop()
        deque_r.append(r.popleft())
    else:
        deque_q.pop()
        deque_r.append(r.popleft())

    if not r:
        break

ans = sum(deque_p) + sum(deque_q) + sum(deque_r)

print(ans)
Problem p02755 (python)

Fixed submission:
import math

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

min_A = math.ceil(A * 100 / 8)
max_A = (A + 1) * 100 / 8
min_B = math.ceil(B * 100 / 10)
max_B = (B + 1) * 100 / 10

if (min_A <= min_B and min_B < max_A):
    ans = min_B
elif (min_B <= min_A and min_A < max_B):
    ans = min_A
else:
    ans = -1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

min_A = math.ceil(A * 100 / 8)
max_A = ((A + 1) * 100 / 8
min_B = math.ceil(B * 100 / 10)
max_B = (B + 1) * 100 / 10

if (min_A <= min_B and min_B < max_A):
    ans = min_B
elif (min_B <= min_A and min_A < max_B):
    ans = min_A
else:
    ans = -1

print(ans)
Problem p02768 (python)

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

def remainder_of_combination(n, r, p):
    X = 1
    Y = 1
    
    for i in range(n - r +1, n + 1):
        X = X * i % p
    for i in range(1, r + 1):
        Y = Y * i % p
        
    return X * pow(Y, p-2, p)

ans = -1 + pow(2, n, p) - remainder_of_combination(n, a, p) - remainder_of_combination(n, b, p)

print(ans % p)

Buggy submission (verdict: Runtime Error):
import math
n, a, b = map(int, input().split())
x = 1
my_list = [0] * n

for i in range(n):
    x = x * (n - i) // (i + 1)
    my_list[i] = x

my_list[a-1] = 0
my_list[b-1] = 0

print(my_list)
print(sum(my_list) %(10**9 + 7) )
Problem p02780 (python)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
S =[0] * (N - K + 1)
S[0] = sum(P[0:K])

for i in range(1, N - K + 1):
    S[i] = S[i-1] - P[i-1] + P[i+K-1]

print((max(S) + K) / 2)

Buggy submission (verdict: Runtime Error):
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
S =[0] * (NK[0] - NK[1])
S[0] = sum(P[0:(NK[1])])

for i in range(NK[0] - NK[1] - 1):
    S[i+1] = S[i] - P[i] + P[i+NK[1]]

print((max(S) + NK[1]) / 2)

Buggy submission (verdict: Runtime Error):
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
S =[0] * (NK[0] - NK[1])

for i in range(NK[0] - NK[1]):
    S[i] = sum(P[i:i+NK[1]])

print((max(S) + NK[1]) / 2)

Buggy submission (verdict: Runtime Error):
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
S =[0] * (NK[0] - NK[1])

for i in range(NK[0] - NK[1]):
    S[i] = (sum(P[i:i+NK[1]]) + NK[1]) / 2

print(max(S))
Problem p02817 (python)

Fixed submission:
print("".join(input().split()[::-1]))

Buggy submission (verdict: Runtime Error):
print("".join(input().split()[::-1])
Problem p02960 (python)

Fixed submission:
S = input()
g = 10 ** 9 + 7
x = 1
DP = [[0] * 13 for _ in range(2)]
DP[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        DP[1][j] = DP[0][j] % g
        DP[0][j] = 0
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
               DP[0][(j*10+k)%13] += DP[1][j]
        else:
            DP[0][(j*10+int(S[i]))%13] += DP[1][j]

print(DP[0][5] % g)

Buggy submission (verdict: Runtime Error):
S = input()
g = 10 ** 9 + 7
x = 1
DP = [None for _ in range(2)]
DP[0] = [0] * 13
DP[0][0] = 1
for i in range(len(S)):
    DP[1] = DP[0].copy()
    DP[0] = [0] * 13
    for j in range(13):
        if S[i] == "?":
                for k in range(10):
                    DP[0][(j*10+k)%13] += DP[1][j]
        else:
            DP[0][(j*10+int(S[i]))%13] += DP[1][j]

print(DP[0][5] % g)
Problem p02963 (python)

Fixed submission:
import math
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

S = int(input())
x = int(math.ceil(math.sqrt(S)))
Z = x * x - S

if Z == 0:
    z = 0
    oz = 0
else:
    fs = factorize(Z)
    z = 1
    oz = 1
    for k, c in fs:
        while c >= 2:
            z *= k
            oz *= k
            c -= 2
        if c > 0:
            if z < oz:
                z *= k
            else:
                oz *= k




print("0 0 {} {} {} {}".format(x, z, oz, x))

Buggy submission (verdict: Runtime Error):
import math
import sympy
S = int(input())
x = int(math.ceil(math.sqrt(S)))
Z = x * x - S

if Z == 0:
    z = 0
    oz = 0
else:
    fs = sympy.factorint(Z)
    z = 1
    oz = 1
    for k in fs:
        c = fs[k]
        while c >= 2:
            z *= k
            oz *= k
            c -= 2
        if c > 0:
            if z < oz:
                z *= k
            else:
                oz *= k




print("0 0 {} {} {} {}".format(x, z, oz, x))

Buggy submission (verdict: Runtime Error):
import math
import sympy
S = int(input())
x = int(math.ceil(math.sqrt(S)))
Z = x * x - S

if Z == 0:
    z = 0
    oz = 0
else:
    fs = sympy.factorint(Z)
    z = 1
    oz = 1
    for k in fs:
        c = fs[k]
        while c >= 2:
            z *= k
            oz *= k
            c -= 2
        if c > 0:
            if z < oz:
                z *= k
            else:
                oz *= k




print("0 0 {} {} {} {}".format(x, z, oz, x))