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

Fixed submission:
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    a, b = reads()
    if a == 1:
        a = 14
    if b == 1:
        b = 14

    if a == b:
        print('Draw')
    elif a > b:
        print('Alice')
    else:
        print('Bob')
 
main()

Buggy submission (verdict: Runtime Error):
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    a, b = input()
    if a == 1:
        a = 14
    if b == 1:
        b = 14

    if a == b:
        print('Draw')
    elif a > b:
        print('Alice')
    else:
        print('Bob')
 
main()
Problem p03805 (python)

Fixed submission:
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    n, m = reads();
    g = [set() for _ in range(n+1)]
    for _ in range(m):
        a, b = reads()
        g[a - 1].add(b - 1)
        g[b - 1].add(a - 1)
    
    count = 0
    q = [(0, [])]
    while q:
        i, p = q.pop(0)
        if len(p) == (n-1):
            count += 1
        for e in g[i]:
            if e in p:
                continue
            pp = p[:]
            pp.append(i)
            q.append((e, pp))
    print(count)
 
main()

Buggy submission (verdict: Runtime Error):
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    n, m = reads();
    g = [set() for _ in range(m)]
    for _ in range(m):
        a, b = reads()
        g[a - 1].add(b - 1)
        g[b - 1].add(a - 1)
    
    count = 0
    q = [(0, [])]
    while q:
        i, p = q.pop(0)
        if len(p) == (n-1):
            count += 1
        for e in g[i]:
            if e in p:
                continue
            pp = p[:]
            pp.append(i)
            q.append((e, pp))
    print(count)
 
main()
Problem p03835 (python)

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

cnt = 0
for x in range(0,K+1):
	if S-x < 0:
		break
	for y in range(0, min(K,S-x)+1):
		z = S-x-y
		if z>-1:
			if z < K+1:
				cnt += 1
		else:
			break

print(cnt)

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

all = []
for x in range(0,K+1):
	if S-x < 0:
		break
	for y in range(0, min(K,S-x)+1):
		z = S-x-y
		if z>-1:
			if z < K+1:
				all.append(str(x)+str(y)+str(z))
		else:
			break

print(len(all))

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

all = []
for x in range(0,K+1):
	if S-x < 0:
		break
	for y in range(0, min(K,S-x)+1):
		z = S-x-y
		if z>-1:
			if z < K+1:
				all.append(str(x)+str(y)+str(z))
		else:
			break

print(len(set(all)))
Problem p03803 (python)

Fixed submission:
#!/usr/bin/env python3

Alice, Bob = map(int, input().split())
if Alice == 1:
    Alice = 14
if Bob == 1:
    Bob = 14

if Alice > Bob:
    print('Alice')
elif Bob > Alice:
    print('Bob')
else:
    print('Draw')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

Alice, Bob = map(int, input())
if Alice == 1:
    Alice = 14
if Bob == 1:
    Bob = 14

if Alice > Bob:
    print('Alice')
elif Bob > Alice:
    print('Bob')
else:
    print('Draw')
Problem p04049 (python)

Fixed submission:
ii=lambda:map(int,raw_input().split())
n,k=ii()
T,F=True,False
e=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=ii()
    e[a-1]+=[b-1];e[b-1]+=[a-1]
cost=[0]*n
ans=10**5
def dfs(x,f):
    if f>=0:vis[f]=T
    q=[(x,0)]
    while len(q):
        v,c=q.pop(0)
        if c>k/2:break
        cost[v]=c;vis[v]=T
        for w in e[v]:
            if not vis[w]:q+=[(w,c+1)]
    return n-vis.count(T)
if k%2:
    for i in range(n):
        for j in e[i]:
            if i<j:vis=[F]*n;dfs(i,j);ans=min(ans,dfs(j,i))
else:
    for i in range(n):vis=[F]*n;ans=min(ans,dfs(i,-1))
print ans

Buggy submission (verdict: Runtime Error):
o=lambda:map(int,raw_input().split());r=range(n);a=10**5
n,k=o()
e=[[]for _ in [0]*n]
for _ in [0]*(n-1):a,b=o();e[a-1]+=[b-1];e[b-1]+=[a-1]
def U(x,f):
 l[f]=1;q=[(x,0)]
 while len(q):
  v,c=q.pop(0)
  if c>k/2:break
  l[v]=1
  for w in e[v]:
   if not l[w]:q+=[(w,c+1)]
 return n-l.count(1)
if k%2:
 for i in r:
  for j in e[i]:
   if i<j:l=[0]*n;U(i,j);a=min(a,U(j,i))
else:
 for i in r:l=[0]*n;a=min(a,U(i,-1))
print a
Problem p03834 (python)

Fixed submission:
def main():
    s = input().split(',')
    s = ' '.join(s)
    print(s)

if __name__ == "__main__":
    main()

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

    root = ""

    # first
    for n in range(tx - sx):
        root += "R"
    for n in range(ty - sy):
        root += "U"

    # first back
    for n in range(tx - sx):
        root += "L"
    for n in range(ty - sy):
        root += "D"

    # first
    root += "D"
    for n in range(tx - sx + 1):
        root += "R"
    for n in range(ty - sy + 1):
        root += "U"
    root += "L"

    # first back
    root += "U"
    for n in range(tx - sx + 1):
        root += "L"
    for n in range(ty - sy + 1):
        root += "D"
    root += "R"

    print(root)

if __name__ == "__main__":
    main()
Problem p03834 (python)

Fixed submission:
s = str(input())
s = s[:5] + " " + s[6:13] + " " + s[14:]
print(s)

Buggy submission (verdict: Runtime Error):
[a, b] = map(int, input().split())
if a*3==b:
    print(1)
elif b%3==0:
    print(b*3+1)
else:
    print(b*3)
Problem p03835 (python)

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

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      answer.append(K + 1 - (s_z - K))
  else:
    answer.append(s_z + 1)

print(sum(answer))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.extend(2*K - s_z + 1)
  else:
    ans.extend(s_z + 1)
 
print(sum(ans))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = [None]*(K+1)
 
for i in z:
  s_z = S - i
  if s_z < 0:
    ans[i] = 0
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans[i] = 2*K - s_z + 1
  else:
    ans[i] = s_z + 1
 
print(sum(ans))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    ans[i] = 0
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans[i] = 2*K - s_z + 1
  else:
    ans[i] = s_z + 1
 
print(sum(ans))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

K,S=map(int,input().split())

z = list(range(K+1))
ans = []

for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans[i] = K + 1 - (s_z - K)
  else:
    ans[i] = s_z + 1

print(sum(ans))

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans=0

z = list(range(0,K+1))
answer = []

for i in z:
  s_z = S - i
  if K < s_z:
    for x in list(range(s_z - K,K+1)):
      y = s_z - x
      answer.append([x, y, z])

  else:
    for x in list(range(0,s_z+1)):
      y = s_z - x
      answer.append([x, y, z])

print(len(answer))
Problem p03834 (python)

Fixed submission:
s = input()
print(s.replace(',', ' '))

Buggy submission (verdict: Runtime Error):
k, s = list(map(int, input().split()))
num = 0

for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1

print(num)
Problem p03835 (python)

Fixed submission:
k, s = list(map(int, input().split()))
num = 0

for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1

print(num)

Buggy submission (verdict: Runtime Error):
k, s = list(map(input().split()))
num = 0

for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1
      
print(num)

Buggy submission (verdict: Runtime Error):
k, s = list(map(input().split()))

num = 0
for x in range(k+1):
  for y in range(k+1):
    if s-k <= x+y <= s:
      num += 1
      
print(num)
Problem p03834 (python)

Fixed submission:
print(input().replace(',', ' '))

Buggy submission (verdict: Runtime Error):
happy,newyear,enjoy
Problem p03835 (python)

Fixed submission:
vec = input().split(' ')
k = int(vec[0])
s = int(vec[1])
count = 0
for x in range(k + 1):
    if x <= s:
        for y in range(k + 1):
            if x + y <= s:
                z = s - x - y
                if z >= 0 and z <= k:
                    count += 1
            else: break
    else: break
print(count)

Buggy submission (verdict: Runtime Error):
vec = input().split(' ')
k = int(vec[0]) + 1
count = 0

for x in range(k):
  for y in range(k):
    z = int(vec[1]) - x - y
    if z >= 0 and z <= k:
	  count += 1

print(count)
Problem p03835 (python)

Fixed submission:
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 14

count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z <= k and 0 <= z:
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 15

count = 0
for x in range(k+1):
    if x = s:
        count = count + 1
        break
    for y in range(k+1):
        if s < x + y:
            break
        if x + y = s:
            count = count + 1
            break
        for z in range(k+1):
            if s - x - y < k:
                count = count + 1
                break
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 15

count = 0
for x in range(k+1):
    if x = s:
        count = count + 1
        break
    for y in range(k+1):
        if s < x + y:
            break
        if x + y = s:
            count = count + 1
            break
        for z in range(k+1):
            if s - x - y < k:
                count = count + 1
                break
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0]
s = x[1]

#k = 5
#s = 15

count = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                count = count + 1
                break
print(count)
Problem p03834 (python)

Fixed submission:
haiku = input()
print(haiku.replace("," , " "))

Buggy submission (verdict: Runtime Error):
list = ["haiku", "atcorder", "pytho"]
print(list.replace("," , " "))
Problem p03835 (python)

Fixed submission:
# coding: utf-8
 
K_MAX = 2500
k, s = list(map(int, input().split()))
 
smz = [False] * (2 * K_MAX + 1)
 
for i in range(k + 1):
    if 0 <= s - i <= 2 * k: smz[s - i] = True
 
cnt = 0
for i in range(k + 1):
    for j in range(k + 1):
        if smz[i + j]:
            cnt += 1
 
print(cnt)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

k, s = list(map(int, input().split()))

and = 0
for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - (i + j) <= k: ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

K_MAX = 2500
k, s = list(map(int, input().split()))

smz = [False] * (2 * K_MAX + 1)

for i in range(k + 1):
    if s - i >= 0: smz[s - i] = True

cnt = 0
for i in range(k + 1):
    for j in range(k + 1):
        if smz[i + j]:
            cnt += 1

print(cnt)
Problem p03834 (python)

Fixed submission:
import sys
s=sys.stdin.readline()
print(s[:5]+' '+s[6:13]+' '+s[14:])

Buggy submission (verdict: Runtime Error):
import sys
s=sys.stdin.readline()
print s[:5]+' '+s[6:13]+' '+s[14:]
Problem p03986 (python)

Fixed submission:
instring = raw_input()

finallen = len(instring)
num_open = 0
for char in instring:
    if (char == 'S'):
        num_open += 1
    elif(num_open > 0):
        num_open -= 1
        finallen -= 2
print finallen

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
a = [int(x) for x in raw_input().split(' ')]

sorteda = sorted(a)

maxlen = sorteda[-1]
numpathsoflen = {}
if(sorteda[0] < (maxlen+1)/2):
    print 'Impossible'
elif(maxlen % 2 == 0 
     and sorteda[0] == maxlen/2 
     and sorteda[0] == sorteda[1]):
    print 'Impossible'
else:
    numnodes = maxlen + 1
    for i in range(N):
        if a[i] in numpathsoflen.keys():
            if numpathsoflen[a[i]] >= 2:
                numnodes += 1
            numpathsoflen[a[i]] += 1            
        else:
            numpathsoflen[a[i]] = 1
    if(numnodes != N):
        print 'Impossible'
    else:
        out= 'Possible'
        starti = (maxlen+1)/2 
        if maxlen % 2 == 0:
            starti += 1
        for i in range(starti, maxlen+1):
            if((not i in numpathsoflen.keys()) or numpathsoflen[i] < 2):
                out = 'Impossible'                
        print out
Problem p04005 (python)

Fixed submission:
a,b,c = sorted(int(s) for s in input().split())

if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    print(a*b)

Buggy submission (verdict: Runtime Error):
def min_k_shift(k, a, N, x, range_min):
    cost = k*x
    for j in range(N):
        cost += range_min[(j-k)%N][j] #min(a[(j-sj)%N] for sj in range(k))
    return cost

N, x = [int(s) for s in raw_input().split()]

a = [int(s) for s in raw_input().split()]

range_min = [[0]*N for st in range(N)]
for st in range(N):
    range_min[st][st] = a[st]

for k in range(1,N):
    for st in range(N):
        range_min[st][(st+k)%N] = min(range_min[st][(st+k-1)%N],a[(st+k)%N])

print(min(min_k_shift(k,a,N,x,range_min) for k in range(N)))
Problem p04005 (python)

Fixed submission:
if __name__ == '__main__':
    x, y, z = (int(_) for _ in input().split(' '))
    a = max((x, y, z))
    if a == x:
        b, c = y, z
    elif a == y:
        b, c = x, z
    elif a == z:
        b, c = x, y
    print(abs(a // 2 * b * c - (a - a // 2) * b * c))

Buggy submission (verdict: Runtime Error):
def main():
    ints = (int(_) for _ in input().split(' '))
    if any(_ % 2 == 0 for _ in ints):
        print(0)
        return
    t = max(ints)
    x, y, z = ints
    if t == x:
        print(y * z)
    elif t == y:
        print(x * z)
    elif t == z:
        print(x * y)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    x, y, z = (int(_) for _ in input().split(' '))
    if x % 2 == 0 or y % 2 == 0 or z % 2 == 0:
        print(0)
        return
    t = max((x, y, z))
    if t == x:
        print(y * z)
    elif t == y:
        print(x * z)
    elif t == z:
        print(x * y)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

if __name__ == '__main__':
    N, x = (int(_) for _ in input().split(' '))
    As = [int(_) for _ in input().split(' ')]
    each = sum(As)
    change = (N - 1) * x + N
    print(min(each, change))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    x = int(input())
    y = int(input())
    z = int(input())
    lst = (x, y, z)

    a = max(lst)
    if a == x:
        b, c = y, z
    elif a == y:
        b, c = x, z
    elif a == z:
        b, c = x, y
    print(((a - (a // 2)) * b * c) - ((a // 2) * b * c))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    x = int(input())
    y = int(input())
    z = int(input())
    t = (x, y, z)

    a = max(t)
    b, c =  [_ for _ in t if _ != a]
    print(((a - (a // 2)) * b * c) - ((a // 2) * b * c))
Problem p02771 (python)

Fixed submission:
l = str(input()).split()
 
a = l[0]
b = l[1]
c = l[2]
 
if (a == b and a != c )or (c == b and a != c )or (a == c and b != c ):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
l = input().split

a = l[0]
b = l[1]
c = l[2]

if (a == b and a != c )or (c == b and a != c )or (a == c and b != c ):
    print("Yes")
else:
    print("No")
Problem p02773 (python)

Fixed submission:
N = int(input())


inin = []
for i in range(N):
    inin.append(str(input()))
    
dic = {}
for i in inin:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] = dic[i]+1

l = dic.items()
max = 0
for i in l:
    if i[1] > max:
        max = i[1]

result = []
for i in l:
    if i[1] == max:
        result.append(i[0])

result.sort()

for i in result:
    print(i)

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

dic = set()
for i in range(N):
    dic.add(str(input()))

dic.sort()

for i in list(dic):
    print(i)
Problem p02777 (python)

Fixed submission:
color = input().split()
number = list(map(int,input().split()))
choice = str(input())
 
for i in [0,1]:
  if choice == color[i]:
    number[i] -= 1
    
print(number[0],number[1])

Buggy submission (verdict: Runtime Error):
color = input().split()
number = input().split()
choice = str(input())

for i in [0,1]:
  if choice == color[i]:
    number[i] -= 1
    
print(number[0],number[1])
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r*r)

Buggy submission (verdict: Runtime Error):
print(int(int(input())*int(input())))

Buggy submission (verdict: Runtime Error):
print(int(input())*int(input()))
Problem p02881 (python)

Fixed submission:
N = int(input())

ans = 10000000000000000000
for i in range(1,1000001):
  if N%i == 0:
    ans = min(ans,i+N//i-2)
    
print(ans)

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

ans = INF
for i in range(1,1e6+1):
  if N%i == 0:
    ans = min(ans,i+N//i-2)
    
print(ans)
Problem p02598 (python)

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

l=0
r=max(A)+1
while r-l>1:
  m=(l+r)//2
  cut=0
  
  for i in range(n):
    cut+=((A[i]+m-1)//m)-1
  if cut>k:
    l=m
  else:
    r=m
print(r)

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

l=-1
r=max(A)+1
while r-l>1:
  m=(l+r)//2
  cut=0
  
  for i in range(n):
    cut+=((A[i]+m-1)//m)-1
  if cut>k:
    l=m
  else:
    r=m
print(r)
Problem p02711 (python)

Fixed submission:
n=input()
if n[0]=='7' or n[1]=='7' or n[2]=='7':
  print('Yes')
else:
   print('No')

Buggy submission (verdict: Runtime Error):
n=input()
if n[0]=='7' or n[1]=='7' or n[2]=='7':
  print(Yes)
else:
   print('No')
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
r = input()
print(r**2)

Buggy submission (verdict: Runtime Error):
print(r**2)
Problem p02860 (python)

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

if n%2:
  print('No')
else:
  if s[:n//2]==s[n//2:]:
    print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
int(input())=n
input()=s
if s[0;n//2-1] == s[n//2;n-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input)
s = input()
if s[0;n//2-1] ==s[n//2;n-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if n % 2 = 0 and s[0 , n//2 - 1] =s[n//2 , n - 1]:
  print('Yes')
 else:
  print('No')
Problem p02880 (python)

Fixed submission:
n=int(input())
s=[0]*100
for i in range(1,10):
  for j in range(1,10):
    s[10*i+j]=i*j
p=81
for k in range(0,100):
  if s[k]==n:
    p=p-1
if p==81:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[0]*100
for i in range(1,10):
  for j in range(1,10):
    s[10*i+j]=i*j
p=81
for k in range(1,101):
  if s[k]==n:
    p=p-1
if p==81:
  print('No')
else:
  print('Yes')
Problem p02881 (python)

Fixed submission:
N = int(input())
n = int((N**(1/2))//1)
s =[0]*(n+10)
for i in range(1,n+1):
  if N%i == 0:
    s[i] = i
maxs = s[0]
for j in range(1,n+1):
  if s[j] > maxs:
    maxs = s[j]
p = int(N/maxs)
walk = p + maxs - 2
print(walk)

Buggy submission (verdict: Runtime Error):
N = int(input())
n = int((N**(1/2))//1)
s =[0]*n
for i in range(1,n+1):
  if N//i == 0:
    s[i] = i
maxs = s[0]
for j in range(1,n+1):
  if s[j] > maxs:
    maxs = s[j]
p = int(N/maxs)
walk = p + maxs - 2
print(walk)
Problem p03104 (python)

Fixed submission:
A,B=map(int,input().split())
def f(X):
  if X%4==0:
    return X
  elif X%4==1:
    return 1
  elif X%4==2:
    return 1^X
  elif X%4==3:
    return 0
if A==0:
  ans=f(B)
else:
  ans=f(A-1)^f(B)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
a=int(math.log(A,2))+1
b=int(math.log(B,2))
if a>=b:
  ans=0
  for i in range(A,B+1):
    ans^=i
else:
  ans=0
  for i in range(A,2**a):
    ans^=i
  for j in range(2**b,B+1):
    ans^=j
print(ans)
Problem p03208 (python)

Fixed submission:
N,K=map(int,input().split())
H=[]
for i in range(N):
  H.append(int(input()))
H.sort()
print(min(H[i+K-1]-H[i] for i in range(N-K+1)))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
H=[]
for i in range(N):
  H.append(int(input()))
H.sort()
ans=H[K-1]-H[0]
for i in range(N-K+1):
  if H[K+i]-H[i]>0:
    ans=ans+H[K+i]-H[i]
print(ans)
Problem p03315 (python)

Fixed submission:
S = input()
l = len(S)
num = 0
for i in range(l):
  if S[i] == '+':
    num = num +1
  else :
    num = num -1
print(num)

Buggy submission (verdict: Runtime Error):
S = input()
l = len(S)
num = 0
for i in range(n):
  if S[i] == '+':
    num = num +1
  else :
    num = num -1
print(num)
Problem p03317 (python)

Fixed submission:
nk=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nk[0]
k=nk[1]
def min(A):
  min=1000000
  for x in range(len(A)):
    if A[x]<=min:
      min=A[x]
  return min
m=0
for i in range(n):
  if a[i]==1:
    m=i
l=[]
if n<=k:
  l.append(1)
else:
  for j in range(k):
    if j<k-1:
      l.append(100000)
    elif j>=k-1 and j%(k-1)==0 and (n-j-1)%(k-1)==0:
      l.append(j//(k-1)+(n-j-1)//(k-1))
    elif j>=k-1 and j%(k-1)!=0 and (n-j-1)%(k-1)!=0:
      l.append(j//(k-1)+1+(n-j-1)//(k-1)+1)
    elif j>=k-1 and j%(k-1)!=0 and (n-j-1)%(k-1)==0:
      l.append(j//(k-1)+1+(n-j-1)//(k-1))
    elif j>=k-1 and j%(k-1)==0 and (n-j-1)%(k-1)!=0:
      l.append(j//(k-1)+(n-j-1)//(k-1)+1)
print(min(l))

Buggy submission (verdict: Runtime Error):
n,k =int(x) for x in input().split()
s = list(int(y) for y in input().split())
def min(a):
  min = 1000000
  for i in range(len(a)):
    if min > a[i]:
      min = a[i]
      index = i
  return index
c = min(s)
num = (c-1)//k + (len(s)-c)//k +2
print(num)