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

Fixed submission:
N = int(input())
A = [int(c) for c in input().split()]

A_plus, A_minus = [], []
for a in A:
    if a>0: A_plus.append(a)
    else: A_minus.append(a)

if len(A_minus)%2==0:
    print(sum(A_plus) - sum(A_minus))
elif len(A_plus)==0:
    print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)    
else:
    if min(A_plus) > -max(A_minus):
        print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)
    else:
        print(sum(A_plus) - sum(A_minus) - min(A_plus)*2)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(c) for c in input().split()]

A_plus, A_minus = [], []
for a in A:
    if a>0: A_plus.append(a)
    else: A_minus.append(a)

if len(A_minus)%2==0:
    print(sum(A_plus) - sum(A_minus))
else:
    if min(A_plus) > -max(A_minus):
        print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)
    else:
        print(sum(A_plus) - sum(A_minus) - min(A_plus)*2)
Problem p03071 (python)

Fixed submission:
A,B = [int(c) for c in input().split()]
if A>B:
    print(A*2-1)
elif A==B:
    print(A*2)
else:
    print(B*2-1)

Buggy submission (verdict: Runtime Error):
N, K = [int(c) for c in input().split()]
S = [int(c) for c in input()]

longest=0

for bgn_flip in range(len(S)):

    S_copy=S[:]
    zero=False
    icluster=-1
    for i,s in enumerate(S):
        if s==0 and zero==False:
            zero=True
            icluster+=1
        if s==1:
            zero=False

        if s==0 and icluster>=bgn_flip and icluster < bgn_flip+K:
       	    S_copy[i]=1

    seq=0
    for sc in S_copy:
        if sc==1: seq+=1
        if sc==0: seq=0
        if seq>longest:longest=seq

print(longest)
Problem p03074 (python)

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

n = 1
c = []
if S[0]=='0': c.append(0)
for i in range(1,N):
    if S[i]!=S[i-1]:
        c.append(n)
        n=1
    else:
        n+=1
c.append(n)
if S[-1]=='0': c.append(0)

t = sum(c[:2*K+1])
m = t
for i in range(2*K+1, len(c), 2):
    t += c[i] + c[i+1] - c[i-(2*K+1)] - c[i+1-(2*K+1)]
    m = max(m,t)

print(m)

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

n = 1
c = []
if S[0]=='0': c.append(0)
for i in range(1,N):
    if S[i]!=S[i-1]:
    c.append(n)
        n=1
    else:
        n+=1
c.append(n)
if S[-1]=='0': c.append(0)

t = sum(c[:2*K+1])
m = t
for i in range(2*K+1, len(c), 2):
    t += c[i] + c[i+1] - c[i-(2*K+1)] - c[i+1-(2*K+1)]
    m = max(m,t)

print(m)

Buggy submission (verdict: Runtime Error):
N, K = [int(c) for c in input().split()]
S = [int(c) for c in input()]

longest=0

for bgn_flip in range(len(S)):

    S_copy=S[:]
    zero=False
    icluster=-1
    for i,s in enumerate(S):
        if s==0 and zero==False:
            zero=True
            icluster+=1
        if s==1:
            zero=False

		if s==0 and icluster>=bgn_flip and icluster < bgn_flip+K:
       		S_copy[i]=1

    seq=0
    for sc in S_copy:
        if sc==1:
          seq+=1
        if sc==0:
          seq=0
        if seq>longest:
          longest=seq

print(longest)

Buggy submission (verdict: Runtime Error):
N, K = [int(c) for c in input().split()]
S = [int(c) for c in input()]

longest=0

for bgn_flip in range(len(S)):

    S_copy=S[:]
    zero=False
    icluster=-1
    for i,s in enumerate(S):
        if s==0 and zero==False:
            zero=True
            icluster+=1
        if s==1:
            zero=False

	if s==0 and icluster>=bgn_flip and icluster < bgn_flip+K:
       	    S_copy[i]=1

    seq=0
    for sc in S_copy:
        if sc==1: seq+=1
        if sc==0: seq=0
        if seq>longest:longest=seq

print(longest)
Problem p03086 (python)

Fixed submission:
S = input()
n = [0]
k=0
for c in S:
    if c in 'ACGT':
        k+=1
    elif k>0:
        n.append(k)
        k=0
if k>0: n.append(k)

print(max(n))

Buggy submission (verdict: Runtime Error):
S = input()
n = []
k=0
for c in S:
    if c in 'ACGT':
        k+=1
    elif k>0:
        n.append(k)
        k=0
if k>0: n.append(k)

print(max(n))
Problem p03128 (python)

Fixed submission:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
cost = [None,2,5,5,4,5,6,3,7,6]

Aset = {}
for a in A:
    c = cost[a]
    Aset[c] = max(Aset[c], a) if c in Aset else a
A = sorted([v for k,v in Aset.items()])

dp = [None]*(N+1)
dp[0] = (0,[0]*len(A))

for ia, a in enumerate(A):
    c = cost[a]
    for i in range(c, N+1):
        t = dp[i-c]
        if t and (dp[i]==None or t[0]+1>=dp[i][0]):
            dp[i] = (t[0]+1, t[1].copy())
            dp[i][1][ia] += 1
      	
l=[]
for i in range(len(A)):
    l += [A[len(A)-1-i]]*dp[N][1][len(A)-1-i]

print(*l, sep='')

Buggy submission (verdict: Runtime Error):
cost = [None,2,5,5,4,5,6,3,7,6]

Aset = {}
for a in A:
    c = cost[a]
    Aset[c] = max(Aset[c], a) if c in Aset else a
A = sorted([v for k,v in Aset.items()])

dp = [None]*(N+1)
dp[0] = (0,[0]*len(A))

for ia, a in enumerate(A):
    c = cost[a]
    for i in range(c, N+1):
        t = dp[i-c]
        if t and (dp[i]==None or t[0]+1>=dp[i][0]):
            dp[i] = (t[0]+1, t[1].copy())
            dp[i][1][ia] += 1
      	
l=[]
for i in range(len(A)):
    l += [A[len(A)-1-i]]*dp[N][1][len(A)-1-i]

print(*l, sep='')
Problem p03456 (python)

Fixed submission:
N = int(''.join(input().split()))
sq = False
for k in range(1, N):
  sq |= k*k==N
print('Yes' if sq else 'No')

Buggy submission (verdict: Runtime Error):
N = int(''.join(input().split()))
sq = False
for k in range(1, N):
  sq |= k*k==N:
print('Yes' if sq else 'No')
Problem p03480 (python)

Fixed submission:
S = input()
N = len(S)

if len(set(S))==1:
  print(N)
  exit()

K = (N+1)//2
X = set()
if N&1:
  X = {S[K-1]}
  l = K-2
  r = K
else:
  X = set()
  l = K-1
  r = K
  
while l:
  X.add(S[l])
  X.add(S[r])
  if len(X)>1: break
  K += 1
  l -= 1
  r += 1

print(K)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
K = (N+1)//2
X = set()
if N&1:
  X = {S[K-1]}
  l = K-2
  r = K
else:
  X = set()
  l = K-1
  r = K
  
while l:
  X.add(S[l])
  X.add(S[r])
  if len(X)>1: break
  K += 1
  l -= 1
  r += 1

print(K)
Problem p03488 (python)

Fixed submission:
s = input()
x, y = list(map(int, input().split()))
F = [len(fs) for fs in s.split('T')]
x -= F[0]
Fx = F[2::2]
Fy = F[1::2]

xt2 = sum(Fx)-x
yt2 = sum(Fy)-y
if xt2%2==1 or yt2%2==1 or xt2<0 or yt2<0:
    print('No')
    exit()

xt = xt2//2
yt = yt2//2

dpx = [False]*(xt+1)
dpx[0] = True
for f in Fx:
    for i in range(xt, f-1, -1): dpx[i] |= dpx[i-f]

dpy = [False]*(yt+1)
dpy[0] = True
for f in Fy:
    for i in range(yt, f-1, -1): dpy[i] |= dpy[i-f]

print('Yes' if dpx[xt] and dpy[yt] else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
x, y = list(map(int, input().split()))
F = [len(fs) for fs in s.split('T')]
Fx = F[0::2]
Fy = F[1::2]

xt2 = sum(Fx)-x
yt2 = sum(Fy)-y
if xt2%2==1 or yt2%2==1:
    print('No')
    exit()

xt = xt2//2
yt = yt2//2

dpx = [False]*(xt+1)
dpx[0] = True
for f in Fx:
    for i in range(xt, f-1, -1): dpx[i] |= dpx[i-f]

dpy = [False]*(yt+1)
dpy[0] = True
for f in Fy:
    for i in range(yt, f-1, -1): dpy[i] |= dpy[i-f]

print('Yes' if dpx[xt] and dpy[yt] else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
x, y = list(map(int, input().split()))
F = [len(fs) for fs in s.split('T')]
Fx = F[0::2]
Fy = F[1::2]

xt2 = (sum(Fx)-x)
yt2 = (sum(Fy)-y)
if xt2%2==1 or yt2%2==1:
    print('No')
    exit()

xt = xt2//2
yt = yt2//2

M = 8000
dpx = [False]*M
dpx[0] = True
for f in Fx:
    for i in range(M-1, f-1, -1):
        if dpx[i-f]: dpx[i]=True

dpy = [False]*M
dpy[0] = True
for f in Fy:
    for i in range(M-1, f-1, -1):
        if dpy[i-f]: dpy[i]=True

print('Yes' if dpx[xt] and dpy[yt] else 'No')
Problem p03556 (python)

Fixed submission:
N = int(input())
k = 1
while k*k<=N: k+=1
print((k-1)*(k-1))

Buggy submission (verdict: Runtime Error):
N = input(input())
k = 1
while k*k<=N: k+=1
print((k-1)*(k-1))
Problem p03609 (python)

Fixed submission:
X, t = list(map(int,input().split()))
print(max(X-t,0))

Buggy submission (verdict: Runtime Error):
X, t = list(map(int,input().split()))
print(max(X-t),0)
Problem p03611 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = [0]*(10**5+10)
for a in A:
    for i in range(3): M[a+i]+=1
print(max(M))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
M = [0]*(N+10)
for a in A:
    for i in range(3): M[a+i]+=1
print(max(M))
Problem p03612 (python)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if P[i]==i+1:
        P[i+1]=P[i]
        ans+=1
if P[N-1]==N: ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
    if P[i]==i+1:
        P[i+1]=P[i]
        ans+=1
print(ans)
Problem p03671 (python)

Fixed submission:
A = list(map(int, input().split()))
print(sum(A)-max(A))

Buggy submission (verdict: Runtime Error):
A = map(int, input().split())
print(sum(A)-max(A))
Problem p03672 (python)

Fixed submission:
s = input()
for k in range(len(s)//2-1, 0, -1):
  if s[:k] == s[k:2*k]: break
print(k*2)

Buggy submission (verdict: Runtime Error):
s = input()
for k in range(len(s)//2-1, 0, -1)
  if s[:k] == s[k:2*k]: break
print(k)
Problem p03853 (python)

Fixed submission:
H, W = list(map(int, input().split()))
for _ in range(H):
    S = input()
    print(S)
    print(S)

Buggy submission (verdict: Runtime Error):
H, W = list(map(int, input().split()))
for _ in H:
    S = input()
    print(S)
    print(S)
Problem p03854 (python)

Fixed submission:
S = [input()]
ans = 'NO'
while S:
    S_new = []
    for s in S:
        if s[:5]=='dream'  : S_new.append(s[5:])
        if s[:7]=='dreamer': S_new.append(s[7:])
        if s[:5]=='erase'  : S_new.append(s[5:])
        if s[:6]=='eraser' : S_new.append(s[6:])
    S = S_new
    if '' in S:
        ans = 'YES'
        break

print(ans)

Buggy submission (verdict: Runtime Error):
def dividable(S):
    return ((S[:5]=='dream'   and dividable(S[5:])) or
            (S[:7]=='dreamer' and dividable(S[7:])) or
            (S[:5]=='erase'   and dividable(S[5:])) or
            (S[:6]=='eraser'  and dividable(S[6:])) or
            (S==''))

print('YES' if dividable(input()) else 'NO')
Problem p03863 (python)

Fixed submission:
# 文字が2種類になるまで減る
# 2種類になったら終了
# 両端の文字が違うならその2種類が残る→偶数個残る
# 両端の文字が同じならその文字+1種→奇数個残る

s = input()
iseven = len(s)&1==0
issame = s[0]==s[-1]
print('Second' if iseven^issame else 'First')

Buggy submission (verdict: Runtime Error):
# 文字が2種類になるまで減る
# 2種類になったら終了
# 両端の文字が違うならその2種類が残る→偶数個残る
# 両端の文字が同じならその文字+1種→奇数個残る

s = input()
iseven = len(S)&1==0
issame = S[0]==S[-1]
print('First' if iseven^issame else 'Second')
Problem p04032 (python)

Fixed submission:
s = input()
for x in list(map(chr, range(ord('a'), ord('z')+1))):
    p = None
    for i, c in enumerate(s):
        if c!=x: continue
        if p is not None and i-p<=2:
            print(p+1, i+1)
            exit()
        p = i

print(-1, -1)

Buggy submission (verdict: Runtime Error):
s = input()
for x in map(chr, range(ord('a'), ord('z')+1)):
    p = None
    for i, c in enumerate(s):
        if c!=x: continue
        if p:
            print(p+1, i+1)
            exit()
	p = i

print(-1, -1)
Problem p02555 (python)

Fixed submission:
S = int(input())

if S < 3:
  print(0)
  import sys
  sys.exit()

DP = [0]*(S+1)
DP[0] = 0
DP[1] = 0
DP[2] = 0

for i in range(3, S + 1):
  DP[i] += 1
  for j in range(i - 3 + 1):
    DP[i] += DP[j]

print(DP[S] % (10 ** 9 + 7))

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

DP = [0]*(S+1)
DP[0] = 0
DP[1] = 0
DP[2] = 0

for i in range(3, S + 1):
  DP[i] += 1
  for j in range(i - 3 + 1):
    DP[i] += DP[j]

print(DP[S] % (10 ** 9 + 7))
Problem p02683 (python)

Fixed submission:
from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

CAS = [[int(i) for i in input().split()] for _ in range(N)]


ok = False
mi = [float('inf'), *[0]*(M)]

fs = '{:0' + str(N) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*(M+1)
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
from copy import deepcopy

N, M, X = [int(i) for i in input().split()]

CAS = [[int(i) for i in input().split()] for _ in range(N)]


ok = False
mi = [float('inf'), *[0]*(M-1)]

fs = '{:0' + str(M) + 'b}'

for i in range(2**N):
  s = fs.format(i)
  t = [0]*M
  for i, f in enumerate(s):
    if f == '1':
      t = [a+b for a, b in zip(CAS[i], t)]

  if all(a >= X for a in t[1:]) and mi[0] > t[0]:
    mi = t
    ok = True


if ok:
  print(mi[0])
else:
  print(-1)
Problem p03415 (python)

Fixed submission:
l = [input() for i in range(3)]

print(''.join([l[0][:1], l[1][1:2], l[2][2:3]]))

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

if N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif M == 1:
    print(N - 2)
else:
    print(N * M - ((N - 2) * 2 + (M - 2) * 2) - 4)
Problem p03050 (python)

Fixed submission:
N=int(input())

def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

ans=0
divisors=make_divisors(N)

for d in divisors:
    m=(d-1)
    if m and (N//m==N%m):
        ans+=m

print(ans)

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

def make_divisors(n):
    divisors=[]
    for i range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

ans=0
divisors=make_divisors(N)

for d in divisors:
    m=(d-1)
    if m and (N//m==N%m):
        ans+=m

print(ans)
Problem p02574 (python)

Fixed submission:
from math import gcd
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)
  
n = int(input())
a = list(map(int, input().split()))
dic = {}
g = a[0]
flg = True
for i in range(n):
  g = gcd(g, a[i])
  if flg:
    tmp = prime_factorize(a[i])
    for j in tmp:
      if j in dic:
        flg = False
      else:
        dic[j]=1
        
if flg:
  print("pairwise coprime")
elif g == 1:
  print("setwise coprime")
else:
  print("not coprime")

Buggy submission (verdict: Runtime Error):
from math import gcd

def seachPrimeNum(N):
  max = int(N**0.5)
  seachList = [i for i in range(2,N+1)]
  primeNum = list(range(N+1))
  while seachList[0] <= max:
    tmp = seachList[0]
    tmp2 = list(seachList)
    for i in tmp2:
      if i%tmp == 0:
          primeNum[i]=tmp
          seachList.remove(i)
  return primeNum

def prime_factorize(n, f):
    a = []
    while n % f == 0:
        a.append(f)
        n //= f
    
    if f == 2:
      f=3
    else:
      f+=2
      
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
n = int(input())
a = list(map(int, input().split()))
d = seachPrimeNum(max(a))
dic = {}
g = a[0]

Buggy submission (verdict: Runtime Error):
from math import gcd

def seachPrimeNum(N):
  max = int(N**0.5)
  seachList = [i for i in range(2,N+1)]
  primeNum = list(range(N+1))
  while seachList[0] <= max:
    tmp = seachList[0]
    tmp2 = list(seachList)
    for i in tmp2:
      if i%tmp == 0:
          primeNum[i]=tmp
          seachList.remove(i)
  return primeNum

def prime_factorize(n, f):
    a = []
    while n % f == 0:
        a.append(f)
        n //= f
    
    if f == 2:
      f=3
    else:
      f+=2
      
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
n = int(input())
a = list(map(int, input().split()))
d = seachPrimeNum(max(a))
dic = {}
g = a[0]
flg = True
for i in range(n):
  g = gcd(g, a[i])
  if flg:
    tmp = prime_factorize(a[i], d[a[i]])
    for j in set(tmp):
      if j in dic:
        flg = False
      else:
        dic[j]=1
        
if flg:
  print("pairwise coprime")
elif g == 1:
  print("setwise coprime")
else:
  print("not coprime")
Problem p02612 (python)

Fixed submission:
n = int(input())
satu = n//1000
if  n % 1000 == 0:
  print(0)
  quit()
ans = 1000*(satu+1)-n
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
satu = n//1000
if n n % 1000 == 0:
  print(0)
  quit()
ans = 1000*(satu+1)-n
print(ans)
Problem p02615 (python)

Fixed submission:
import heapq
from collections import deque
b=[]
heapq.heapify(b)

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = deque(a)

heapq.heappush(b,-1*a.popleft())
ans = 0

while len(a)>0:
  temp = a.popleft()
  point = -1*heapq.heappop(b)
  ans+=point
  heapq.heappush(b, -1*temp)
  heapq.heappush(b, -1*temp)
  
print(ans)

Buggy submission (verdict: Runtime Error):
heapq.heapify(b)

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
a = deque(a)

heapq.heappush(b,-1*a.popleft())
ans = 0

while len(a)>0:
  temp = a.popleft()
  point = -1*heapq.heappop(b)
  ans+=point
  heapq.heappush(b, -1*temp)
  heapq.heappush(b, -1*temp)
  
print(ans)
Problem p02621 (python)

Fixed submission:
n = int(input())   
print(int(n+n**2+n**3))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(int(a+a**2+a**3))
Problem p02639 (python)

Fixed submission:
a = list(map(int, input().split()))
for i in range(5):
  if a[i] == 0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0

while len(a) >= 1:
  ans += 1
  temp=a.pop(0)
  if len(a) >= 1:
    if a[0] == temp:
      ans -= 1
    a = list(filter(lambda x: x % temp != 0, a))
  
print(ans)
Problem p02690 (python)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
  
x = int(input())
lis = make_divisors(x)
flg = False

for i in range(0, len(lis)):

  for j in range(-1000,1000):
    if (j+lis[i])**5 -j**5 ==x:
      ans = str(j+lis[i])+' '+str(j)
      #flg = False
      break


if flg:
  for i in range(0, len(lis)):
    for j in range(-1000,1000):
      if (j+lis[i])**5 -j**5 ==x:
        ans = str(j+lis[i])+' '+str(j)
        break

  
print(ans)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
  
x = int(input())
lis = make_divisors(x)
for i in range(0, len(lis)):

  for j in range(-100,100):
    if (j+lis[i])**5 -j**5 ==x:
      ans = str(j+lis[i])+' '+str(j)
      break

print(ans)
Problem p02705 (python)

Fixed submission:
import math 
a = int(input())
ans = 2 * a * math.pi
print(ans)

Buggy submission (verdict: Runtime Error):
import math 
a = int(input)
print(math.pi * 2 * a)
Problem p02780 (python)

Fixed submission:
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = [s[K-1]]
for i in range(N-K):
  l.append(s[i+K]-s[i])

print(max(l))

Buggy submission (verdict: Runtime Error):
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = []
for i in range(N-K):
  l.append(s[i+K]-s[i])
  
print(max(l))

Buggy submission (verdict: Runtime Error):
import numpy as np
N ,K = list(map(int, input().split()))
p = list(map(lambda x: (1+int(x))/2, input().split()))
s = [0]*N
s[0]=p[0]
sum = 0
for i in range(1,N):
  s[i] = s[i-1]+p[i]

l = []
for i in range(N-K):
  l.append(s[i+K]-s[i])
  
print(max(l))
Problem p02855 (python)

Fixed submission:
import queue
h, w, k = map(int, input().split())
s=[input() for i in range(h)]
ans = [[0]*w for i in range(h)]

def BFS(i, j, count):
  ans[i][j]=str(count)
  movex = [0, 0]
  movey = [1, -1]
  q = queue.Queue()
  q.put([i, j])
  while not q.empty():
    y, x = q.get()
    for i in range(2):
      nx = x+movex[i]
      ny = y+movey[i]
      if 0<=ny<=h-1 and ans[ny][nx]==0 and s[ny][nx]==".":
        ans[ny][nx]=str(count)
        q.put([ny, nx])

def DFS(i, j): 
  movex = [1, -1]
  movey = [0, 0]
  x = j
  y = i
  #右を見る
  while x<=w-1:
    if ans[y][x]==0:
       x+=1
    else:
       return ans[y][x]
  x=j
  while x>=0:
    if ans[y][x]==0:
      x-=1
    else:
      return ans[y][x]

count = 1
for i in range(h):
  for j in range(w):
    if s[i][j]== "#":
      BFS(i, j, count)
      count+=1
  
for i in range(h):
  for j in range(w):
    if ans[i][j]==0:
      ans[i][j]=DFS(i, j)
      
for i in range(h):
  print(" ".join(ans[i]))

Buggy submission (verdict: Runtime Error):
import queue
h, w, k = map(int, input().split())
s=[input() for i in range(h)]
ans = [[0]*w for i in range(h)]

def BFS(i, j, count):
  ans[i][j]=str(count)
  movex = [0, 0]
  movey = [1, -1]
  q = queue.Queue()
  q.put([i, j])
  while not q.empty():
    y, x = q.get()
    for i in range(2):
      nx = x+movex[i]
      ny = y+movey[i]
      if 0<=ny<=h-1 and ans[ny][nx]==0 and s[ny][nx]==".":
        ans[ny][nx]=str(count)
        q.put([ny, nx])

def DFS(i, j): 
  movex = [1, -1]
  movey = [0, 0]
  x = j
  y = i
  for i in range(2):
    nx = x+movex[i]
    ny = y+movey[i]
    if 0<=nx<=w-1:
      if ans[ny][nx]==0:
          DFS(ny, nx)
      else:
        return ans[ny][nx]
        
    
  
  

count = 1
for i in range(h):
  for j in range(w):
    if s[i][j]== "#":
      BFS(i, j, count)
      count+=1
  
for i in range(h):
  for j in range(w):
    if ans[i][j]==0:
      ans[i][j]=DFS(i, j)
      
for i in range(h):
  print(" ".join(ans[i]))
Problem p02983 (python)

Fixed submission:
a, b = list(map(int, input().split()))
if b-a >= 2019:
  print(0)
  quit()

lis = list(range(a, b+1))
  
ans = 2019

for i in range(b-a+1):
  for j in range(i+1, b-a+1):
    #print("i: " + str(lis[i]) + "  j: "+ str(lis[j]))
    temp = ((lis[i]%2019)*(lis[j]%2019))%2019
    #print(temp)
    if temp < ans:
      ans = temp
print(ans)

Buggy submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
lis = list(range(a, b+1))
lis2 = list(map(lambda x: x%2019, lis))
lis2.sort()
#print(lis2)
min1 = lis2.pop(0)
min2 = lis2.pop(0)
#print(min1)
#print(min2)
print((min1*min2)%2019)
Problem p02995 (python)

Fixed submission:
def baisu(n, a):
  return n // a

def baisu2(n, m, a):
  return baisu(m, a)-baisu(n-1, a)

import fractions

def lcm(k):
    ans = k[0]
    for i in range(1, len(k)):
        ans = ans * k[i] // fractions.gcd(ans, k[i])
    return ans

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

cbaisu = baisu2(a, b, c)
dbaisu = baisu2(a, b, d)
cdbaisu = baisu2(a, b, lcm([c, d]))

print(b-a+1-cbaisu-dbaisu+cdbaisu)

Buggy submission (verdict: Runtime Error):

import fractions

def lcm(k):
    ans = k[0]
    for i in range(1, len(k)):
        ans = ans * k[i] // fractions.gcd(ans, k[i])
    return ans

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

cbaisu = baisu2(a, b, c)
dbaisu = baisu2(a, b, d)
cdbaisu = baisu2(a, b, lcm([c, d]))

print(b-a+1-cbaisu-dbaisu+cdbaisu)