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

Fixed submission:
N, M = map(int, input().split())
A = [list(map(int, input().split()))[1:] for _ in range(M)]
P = list(map(int, input().split()))

c = 0
for n in range(1 << N):
    for i, S in enumerate(A):
        #print(P[i] , sum(n >> s-1 & 1 for s in S))
        if P[i] ^ sum(n >> s-1 & 1 for s in S) & 1:
            break
    else:
        c += 1

print(c)

Buggy submission (verdict: Runtime Error):
import numpy as np
tl = np.array([0,1,2,1,1,])
tl = np.array([0,1,2,1,1,])
dp = np.zeros((10,10))
ans = 0
n,m = map(int,input().split())
for i in range(10):
    tl = list(map(int,input().split()))
    for j in tl[1:]:
        dp[i][j-1]+=1
l = list(map(int,input().split()))
import itertools
for i in range(1,n+1):
    bp=np.zeros(10)
    t = list(itertools.combinations(range(5), i))
    for j in t:
        bp=np.zeros(10)
        for J in j:
            bp[J]+=1

        s = 0
        for j in range(n):
            s += (np.dot(dp[j],bp))%2 == l[j]
        if s == n: ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
tl = np.array([0,1,2,1,1,])
tl = np.array([0,1,2,1,1,])
dp = np.zeros((10,10))
ans = 0
n,m = map(int,input().split())
for i in range(m):
    tl = list(map(int,input().split()))
    for j in tl[1:]:
        dp[i][j-1]+=1
l = list(map(int,input().split()))
import itertools
for i in range(1,n+1):
    bp=np.zeros(10)
    t = list(itertools.combinations(range(5), i))
    for j in t:
        bp=np.zeros(10)
        for J in j:
            bp[J]+=1

        s = 0
        for j in range(n):
            s += (np.dot(dp[j],bp))%2 == l[j]
        if s == n: ans +=1
print(ans)
Problem p03032 (python)

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

m=[]
for i in range(k+1):
 for j in range(min(k,n)-i+1):
  # print(i,j)
  t=sorted(v[:i]+v[:~j:-1])
  while t and(k-i-j)*t[0]<0:t.pop(0);j+=1
  m+=sum(t),
print(max(m))

Buggy submission (verdict: Runtime Error):
import heapq 
N,K = map(int,input().split())
A = list(map(int,input().split()))
m = min(N,K) #KがNより大きい場合を防ぐ
M = 0 
for i in range(m+1):
    for j in range(m-i+1):
        A1 = A[:i] #前から取る
        A3 = A[N-j:] #後ろから取る
        new_A = A1+A3
        new_A.sort()
        h = K - len(new_A)
        while h >0:
            if new_A[-1] > 0:
                break
            else:
                new_A.pop()
                h-=1
        M = max(M,sum(new_A))
print(M)
Problem p03043 (python)

Fixed submission:
n,k = map(int, input().split())
s = 0
for i in range(1000):
    if 2**i <= k < 2**(i+1):
        s = i+1
        break
t = 0
for i in range(n):
    if s == 0 and k<=n:
        t+=1
        
    elif k<=(i+1) *2**s and k> (i+1) *2**(s-1):
        t+=1/(2**s)
    else:
        s-=1
        t+=1/(2**s)
print(t/n)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
tmp = K/N
q = 1
p = 2 ** 100
while p/q >2:
    qp = q*2
    if qp > tmp:
        p = qp
    else:
        q = qp
for i in range(N,0,-1):
    ans = i*q
    if ans < K:
        q*=2
    res+= float(1)/q
print(res/N)
Problem p03050 (python)

Fixed submission:
a = int(input())
def d(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
s = 0
t = d(a)
#print(t)
res = 0
for k in t:
    if k==1:
        continue
    m=k-1
    if (a//m)==(a%m):
        res+=m
print(res)

Buggy submission (verdict: Runtime Error):
a = int(input())
def d(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
s = 0
t = d(a)
#print(t)
for i in range(len(t)):
    if t[i]>=math.sqrt(a):break
    #print(t[i])
    s+=(a-t[i])//(t[i])
print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
def d(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
s = 0
t = d(a)
#print(t)
for i in range(len(t)):
    if t[i]>=math.sqrt(a):break
    #print(t[i])
    s+=(a-t[i])//(t[i])
print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
def d(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
s = 0
t = d(a)
#print(t)
for i in range(len(t)):
    if t[i]>=math.sqrt(a):break
    #print(t[i])
    s+=(a-t[i])//(t[i])
print(s)
Problem p03059 (python)

Fixed submission:
s= 0
A,B,T=map(int,input().split())
for i in range(T//A):
  s+=B
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ma = []
pa = []
l =[]
t = 0
for i in a:
  if i < 0:
    ma.append(i)
    l.append(i*-1)
  elif i> 0:
    pa.append(i)
    l.append(i)
  else:
    t = 1
pa.sort()
ma.sort()
s = sum(l)
for i in [pa,ma]:
  if len(i)==0:i.append(0)
print(s  if t == 1 or len(b)%2==0 else s - 2*min(l))
Problem p03061 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
L=[0]
R=[0]
def gcd(x,y):
    if x==0:return y
    else:return gcd(y%x,x)
for i in range(n-1):
    L.append(gcd(L[i],a[i]))
    R.append(gcd(R[i],a[-1-i]))
MAX=0
for i in range(n):
    MAX=max(MAX,gcd(L[i],R[-1-i]))
print(MAX)

Buggy submission (verdict: Runtime Error):
from fractions import*
N＝int(input())
a  = list(map(int,input().split()))
B=[0]
a=range(N)
for x in a:B+=[gcd(B[-1],A[x])]
w=M=0
for x in a[::-1]:M=max(M,gcd(w,B[x]));w=gcd(w,A[x])
print(M)
Problem p03062 (python)

Fixed submission:

n = int(input())
a = list(map(int,input().split()))
ma = []
pa = []
l =[]
t = 0
k  = 0
for i in a:
  if i < 0:
    ma.append(i)
    l.append(i*-1)
    k+=1
  elif i> 0:
    pa.append(i)
    l.append(i)
  else:
    t = 1
s = sum(l)
print(s  if t == 1 or k%2==0 else s - 2*min(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ma = []
pa = []
l =[]
t = 0
for i in a:
  if i < 0:
    ma.append(i)
    l.append(i*-1)
  elif i> 0:
    pa.append(i)
    l.append(i)
  else:
    t = 1
s = sum(l)
print(s  if t == 1 or N%2==0 else s - 2*min(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ma = []
pa = []
l =[]
t = 0
for i in a:
  if i < 0:
    ma.append(i)
    l.append(i*-1)
  elif i> 0:
    pa.append(i)
    l.append(i)
  else:
    t = 1
s = sum(l)
print(s  if t == 1 or len(b)%2==0 else s - 2*min(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ma = []
pa = []
l =[]
t = 0
for i in a:
  if i < 0:
    ma.append(i)
    l.append(i*-1)
  elif i> 0:
    pa.append(i)
    l.append(i)
  else:
    t = 1
pa.sort()
ma.sort()
s = sum(l)
for i in [pa,ma]:
  if len(i)==0:i.append(0)
print(s  if t == 1 or len(b)%2==0 else s - 2*min(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ma = []
pa = []
l =[]
t = 0
for i in a:
  if i < 0:
    ma.append(i)
    l.append(i*-1)
  elif i> 0:
    pa.append(i)
    l.append(i)
  else:
    t = 1
pa.sort()
ma.sort()
s = sum(l)
print(s if len(ma)%2==0 or t==1 else max(s+ma[-1]*2,s-pa[0]*2))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ma = []
pa = []
l =[]
t = 0
for i in a:
  print(i)
  if i < 0:
    ma.append(i)
    l.append(i*-1)
  elif i> 0:
    pa.append(i)
    l.append(i)
  else:
    t = 1
pa.sort()
ma.sort()
s = sum(l)
print(s if len(ma)%2==0 or t==1 else max(s+ma[-1]*2,s-pa[0]*2))
Problem p03068 (python)

Fixed submission:

a = int(input())
s = input()
k = int(input())

t = ["*"]*a
aa = s[k-1]
for f,i in enumerate(s):
  if i == aa:
    t[f] = i
print("".join(t))

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

t = ["*"]*a
aa = s[k]
for f,i in enumerate(s):
  if i == aa:
    t[f] = i
print("".join(t))

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

t = ["*"]*a
aa = s[k]
for f,i in enumerate(s):
  if i == aa:
    t[f] = i
print("".join(t))

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

t = ["*"]*a
aa = s[k]
for f,i in enumerate(s):
  if i == aa:
    t[f] = i
print(" ".join(aa))
Problem p03069 (python)

Fixed submission:
input()
S=input()
dot=S.count(".")
ans=dot
count=0
for s in S:
    if s=="#":count+=1
    else:dot-=1
    ans=(min(ans,count+dot))
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
l = input()
s = 0 
r = 0
for i in l :
  if i == "#":
    t +=1
  if t >= 1 and i == ".":
    s+=1
    r+=t
    t = 0
  
print(min(s,t))

Buggy submission (verdict: Runtime Error):

a = int(input())
l = input()
s = 0 
for i in l :
  if i == "#":
    t = 1
  if t and i == ".":
    s+=1
  
print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
l = list(map(int,input().split()))
s = 0 
for i ,j in zip(l,l[1:]):
  if i + j == "#.":s+=1
print(s)
Problem p03081 (python)

Fixed submission:
N,M=map(int,input().split())
a = "a"+input()+"q"
k = []
for i in range(M):
  ta,tb=map(str,input().split())
  k.append([ta,tb])
k = k[::-1]
s = 1
t = N
c=0
for i, j in k:
  if j == "R" and i == a[t]:
    t-=1
    c+=1
  if j == "L" and i == a[s]:
    s+=1
  if j == "R" and i == a[s-1] and s!= 1:
    s-=1
  if j == "L" and i == a[t+1] and t!= N:
    t+=1
    c-=1
  if s+c-1==N and N!=0:break
if N>1:print(N-s-c-1+2)
else: 
  if s+c+1>1:print(1)
  else:print(0)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
a = input()
k = []
for i in range(M):
  ta,tb=map(str,input().split())
  k.append([ta,tb])
k = k[::-1]
s = 0
t = N-1
c=0
for i, j in k:
  if j == "R" and i == a[t]:
    t-=1
    c+=1
  elif j == "L" and i == a[s]:
    s+=1
  elif j == "R" and i == a[s]:
    s-=1
  elif j == "L" and i == a[t]:
    t+=1
    c-=1
  if s+c==N and N!=0:break
if N>1:print(N-s-c)
else: 
  if s+c>1:print(1)
  else:print(0)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
a = input()
k = []
for i in range(M):
  ta,tb=map(str,input().split())
  k.append([ta,tb])
k = k[::-1]
s = 0
t = N-1
c=0
for i, j in k:
  if j == "R" and i == a[t]:
    t-=1
    c+=1
  elif j == "L" and i == a[s]:
    s+=1
print(s+c)
Problem p03112 (python)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    #print(b,d)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_right 
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [sys.stdin.readline() for i in range(A)] + [INF]
t = [-INF] + [sys.stdin.readline() for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect_right(s, x), bisect_right(t, x)
    #print(b,d)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy submission (verdict: Runtime Error):
from bisect import bisect.bisect_right
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    #print(b,d)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect.bisect_right 
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [sys.stdin.readline() for i in range(A)] + [INF]
t = [-INF] + [sys.stdin.readline() for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    #print(b,d)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import bisect.bisect_right from bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    #print(b,d)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
Problem p03151 (python)

Fixed submission:
import sys
input=sys.stdin.readline
mii=lambda:map(int,input().split())

n=int(input())
a=list(mii())
b=list(mii())
k = []
j = 0
na= 0
c = 0
for i in range(n):
    if a[i]<b[i]:
        na +=b[i]-a[i]
        c+=1
    elif a[i] > b[i]:
        k.append(a[i]-b[i])
k.sort()
while na > 0 and k:
    na -=k[-1]
    k.pop(-1)
    c +=1
if na > 0:print(-1)
else:print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
k = []
j = 0
na= 0
c = 0
if sum(a)<sum(b):
    print(-1)
else:
    for i in range(n):
        if a[i]<b[i]:
            na +=b[i]-a[i]
            c+=1
        elif a[i] > b[i]:
            k.append(a[i]-b[i])
    k.sort()
        k = k[::-1]
    while na > 0:
        na -=k[j]
        c +=1
        j+=1
    print(c)
Problem p03160 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
dp = [0] + [10**10]*N
for i,h in enumerate(a):
    for j in range(i+1,min(i+3,N)):
        dp[j] = min(dp[j],dp[i]+abs(h-a[j]))
    #print(dp)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a = ai()
x = lma()
dp =[0]+[float("INF")]*(a-1)
def cal(i):
    res = float("INF")
    if dp[i]< float("INF"): return dp[i]
    if(i==0) :return 0
    res = min(res,cal(i-1)+abs(x[i]-x[i-1]))
    if i >1 :res = min(res,cal(i-2)+abs(x[i]-x[i-2])) # i=1の時の処理
    dp[i] = res
    return dp[i]
print(cal(a-1))
Problem p03161 (python)

Fixed submission:
N,K=map(int, input().split())
a = list(map(int, input().split()))
dp = [0]+[float("inf")]*N
for i,h1 in enumerate(a):
    for j in range(i+1,min(i+K+1,N)):
        dp[j] = min(dp[j],dp[i]+abs(h1-a[j]))
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
dp = [0]+ [float("INF")]*(100010)

h = list(map(int, input().split()))
for i in range(n):
    for j in range(1,k+1):
        dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
        #print(1,dp[i],dp[i-j]+abs(h[i]-h[i-j]))
        #print(dp)
print(dp[n-1])
Problem p03164 (python)

Fixed submission:
N, W = map(int, input().split())
a = []
for i in range(N):
    x,y = map(int,input().split())
    a.append([x,y])
max_v, inf = 10**5, float("inf")
dp = [0] + [inf]*max_v
 
for w, v in a:
    for i, j in zip(range(max_v-v, -1, -1), range(max_v, -1, -1)):
        if dp[i]+w <= W and dp[j] > dp[i]+w:
            dp[j] = dp[i]+w
 
for weight, value in zip(dp[::-1], range(max_v, -1, -1)):
    if weight != inf:
        print(value)
        break

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

dp = [0]*(W+1)
L = []
for i in range(N):
    w,v = map(int,input().split())
    L.append([v,w])

for i in range(N):
    for w in range(W+1):
        if w-L[i][1]>=0 :dp[w] = max(dp[w],dp[w-L[i][1]]+L[i][0])
print(dp[-1])

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

dp = [0]*(W+1)
L = []
for i in range(N):
    v,w = map(int,input().split())
    L.append([w,v])

for i in range(N):
    for w in range(W+1):
        if w-L[i][1]>=0 :dp[w] = max(dp[w],dp[w-L[i][1]]+L[i][0])
print(dp[-1])
Problem p03192 (python)

Fixed submission:
print(input().count("2"))

Buggy submission (verdict: Runtime Error):
print(input().count(2))
Problem p03200 (python)

Fixed submission:
a = input()
b = 0
bt = 0
w = 0
wt = 0
for i in range(len(a)):
    if a[i] == "B":bt = 1
    if bt == 1 and a[i] == "B":b+=1
    if a[i] =="W":
        w+=b
        wt +=1
print(w)

Buggy submission (verdict: Runtime Error):
s = input() + "lllllll"
n = len(s)
tt = 0
ts = 0
for i in range(n-3):
    #print(s[i])
    if s[i] == "B" and s[i+1] == "W":
        #print("Hello")
        tt+=1
        #if s[i+2] == "B" and s[i+3] == "W":tt+=1
        for j in range(1,n-i,2):
            if s[i+j+1] == "B" and s[i+j+2] == "W":tt+=1
        for k in range(1,i+1):
            #print(k,i)
            if i - k >= 0 and s[i-k] == "B":tt+=1
            else:break
        for j in range(1,n-i):
            #print(j,i)
            if i + j <= n-2 and s[i+j+1] == "W":tt+=1
            else:break
        i = i+j+1
print(tt)
Problem p03210 (python)

Fixed submission:
n = int(input()) 
if (n%5 == 0 or n%3 == 0 or n%7 ==0) and n%9!=0 and n%6 !=0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a = int(input())
x = [3,5,7]
if a in x:
  pritn("YES")
else:
  print("NO")
Problem p03211 (python)

Fixed submission:
s= input()
n = len(s)
min = 1000
for i in range(n-2):
    k = 100*int(s[i])+10*int(s[i+1])+int(s[i+2])
    if min > abs(753-k):
        min = abs(753-k)
    
print(min)

Buggy submission (verdict: Runtime Error):
s= input()
n = len(s)
for i in range(n-2):
    k = 100*int(s[i])+10*int(s[i+1])+int(s[i+2])
    if min > abs(753-k):
        min = abs(753-k)
    
print(min)
Problem p03219 (python)

Fixed submission:
a = list(map(int, input().split()))
 
print(int(a[0]+a[1]/2))

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

print(inya[0]+a[1]/2)
Problem p03262 (python)

Fixed submission:
import fractions
a,b =map(int, input().split())
x = list(map(int, input().split()))
m = abs(x[0]-b)
for i in range(a):
    m = fractions.gcd(m,abs(x[i]-b))
print(m)

Buggy submission (verdict: Runtime Error):
import math
a,b =map(int, input().split())
x = list(map(int, input().split()))
m = abs(x[0]-b)
for i in range(a):
    m = math.gcd(m,abs(x[i]-b))
print(m)

Buggy submission (verdict: Runtime Error):
a,b =map(int, input().split())
x = list(map(int, input().split()))
m = abs(x[0]-b)
for i in range(a):
    m = math.gcd(m,abs(x[i]-b))
print(m)

Buggy submission (verdict: Runtime Error):
a,b =map(int, input().split())
x = list(map(int, input().split()))
m = abs(x[0]-b)
for i in range(a):
    m = math.gcd(m,abs(x[i]-b))
print(m)
Problem p03266 (python)

Fixed submission:
n,k = map(int,input().split())
if k%2==1:print((n//k)**3)
elif k%2==0:print((n//k)**3 + (n//(k//2) - n//k)**3 )

Buggy submission (verdict: Runtime Error):
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a,b  = ma()
x = lma()
ans = 10 **18
for i in range(a-b+1):
    a0 = x[i]
    ab = x[i+b-1]
    if ab< 0 :
        ans = min(ans,ab)
    elif a0 <=0 and 0 <= ab:
        ans = min(ans, ab-2*a0, 2*ab-a0)
    else:
        ans = min(ans,ab)
print(ans)
Problem p03273 (python)

Fixed submission:
h, w = map(int, input().split())
a = [input() for w in range(h)]

for i in range(h)[::-1]:
    if "#" not in a[i]:
        del a[i]
        h -= 1

n = []
for j in range(w):
    m = ["".join(t[j] for t in a)]
    if "#" in m[0]:
        n += m

for k in range(h):
    print("".join(u[k] for u in n))

Buggy submission (verdict: Runtime Error):
input = get_input(INPUT)

h, w = map(int, input().split())
a = [input() for w in range(h)]

for i in range(h)[::-1]:
    if "#" not in a[i]:
        del a[i]
        h -= 1

n = []
for j in range(w):
    m = ["".join(t[j] for t in a)]
    if "#" in m[0]:
        n += m

for k in range(h):
    print("".join(u[k] for u in n))
Problem p03274 (python)

Fixed submission:
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a,b  = ma()
x = lma()
ans = 10 **18
for i in range(a-b+1):
    a0 = x[i]
    ab = x[i+b-1]
    if ab< 0 :
        ans = min(ans,abs(a0))
    elif a0 <=0 and 0 <= ab:
        ans = min(ans, ab-2*a0, 2*ab-a0)
    else:
        ans = min(ans,ab)
print(ans)

Buggy submission (verdict: Runtime Error):
a,b  = ma()
x = lma()
ans = 10 **18
for i in range(a-b+1):
    a0 = x[i]
    ab = x[i+b-1]
    if ab< 0 :
        ans = min(ans,ab)
    elif a0 <=0 and 0 <= ab:
        ans = min(ans, ab-2*a0, 2*ab-a0)
    else:
        ans = min(ans,ab)
print(ans)
Problem p03289 (python)

Fixed submission:
#B AcCepted
b = input()
a = list(b)
c=z = len(b)
d =""
if a[0] == "A":
    a[0] = "a"
    c = 10000
for i in range(2,z-1):
    if a[i] == "C":
        a[i]="c"
        c+=1
for i in a:
    d+=i
if d.islower() and c == 10001:
    print("AC")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
#B AcCepted
b = input()
a = list(b)
c=z = len(b)
d =""
if a[0] == "A":
    a[0] = "a"
    c = 10000
for i in range(2,c):
    if a[i] == "C":
        a[i]="c"
        c+=1
for i in a:
    d+=i
if d.islower() and c == 10001:
    print("AC")
else:
    print("WA")
Problem p03294 (python)

Fixed submission:
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a = ai()
x = lma()
print(sum(x)-a)

Buggy submission (verdict: Runtime Error):
a = ai()
x = lma()
print(sum(x)-a)
Problem p03296 (python)

Fixed submission:
n = int(input())
a=list(map(int, input().split()))
t=a[0]
s=1
Ans=0
for i in range(1,n):
  if t==a[i]:
    s+=1
  else:
    Ans+=s//2
    s=1
  t=a[i]
Ans+=s//2
print(Ans)

Buggy submission (verdict: Runtime Error):
n = input()
a=list(map(int, input().split()))
t=a[0]
s=0
Ans=0
for i in range(1,n):
  if t==a[i]:
    s+=1
  else:
    Ans+=s//2
    s=0
  t=a[i]
print(Ans)
Problem p03323 (python)

Fixed submission:
a = list(map(int, input().split()))
a.sort()
if a[1] < 9:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
a.sort()
if a < 9:
    print("Yay!")
else:
    print(":(")
Problem p03353 (python)

Fixed submission:
a=input()
p = int(input())
k = []
for i in range(len(a)):
    for j in range(i+1,min(i+6,len(a)+1)):
        k.append(a[i:j])
#(k)
k = set(k)
k = list(k)
k.sort()
#(k)
print(k[p-1])

Buggy submission (verdict: Runtime Error):
a=input()
p = int(input())
k = []
for i in range(len(a)):
    for j in range(i+1,min(i+6,len(a)-1)):
        k.append(a[i:j])
k = set(k)
k = list(k)
k.sort()
#print(k)
print(k[p-1])