Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
l=list()
s = s.replace("10","1,0")
s = s.replace("01","0,1")

l = [len(i) for i in s.split(",")]
r = 0
ans = 0

if s[0] == "1":
    r = min(k, len(l) - 1)
else:
    r = k-1

t = l[r]

for j in range(1, k+1):
    #print(r,j,t,l[r-j],l[r+j])
    if r-j >= 0:
        #print("r-j >= 0:")
        t += l[r-j]
    if r+j < len(l):
        #print("r+j < len(l):")
        t += l[r+j]
ans = t
for i in range(r+2, len(l) ,2):
    for j in range(1, 3):
        if i-j-k >= 0:
            #print("l[i-j-k]", i-j-k, l[i-j-k])
            t -= l[i-j-k]
        if i+j+k-2 < len(l):
            #print("l[i+k+j]", i+j+k-2, l[i+j+k-2])
            t += l[i+j+k-2]
    ans = max(ans, t)
print(ans)

Fixed submission:
n, k = map(int, input().split())
s = input()
l=list()
s = s.replace("10","1,0")
s = s.replace("01","0,1")

l = [len(i) for i in s.split(",")]
r = 0
ans = 0

if s[0] == "1":
    r = min(k, len(l) - 1)
else:
    r = min(k-1, len(l) - 1)

t = l[r]

for j in range(1, k+1):
    #print(r,j,t,l[r-j],l[r+j])
    if r-j >= 0:
        #print("r-j >= 0:")
        t += l[r-j]
    if r+j < len(l):
        #print("r+j < len(l):")
        t += l[r+j]
ans = t
for i in range(r+2, len(l) ,2):
    for j in range(1, 3):
        if i-j-k >= 0:
            #print("l[i-j-k]", i-j-k, l[i-j-k])
            t -= l[i-j-k]
        if i+j+k-2 < len(l):
            #print("l[i+k+j]", i+j+k-2, l[i+j+k-2])
            t += l[i+j+k-2]
    ans = max(ans, t)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
for i in range(q):
  l, r = map(int, input().split())
  print(s[l-1:r].count("AC"))

Fixed submission:
import bisect
n, q = map(int, input().split())
s = input()
ac=[]
for i in range(n):
  if s[i:i+2] == "AC":
    ac.append(i)

for i in range(q):
  l, r = map(int, input().split())
  acl=bisect.bisect_left(ac,l-1)
  acr=bisect.bisect_left(ac,r-1)
  print(acr-acl)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
sl = len(s)
while True:
  so = s
  so=so.replace("10","")
  so=so.replace("01","")
  if len(s) == len(so):
    break
  s = so

print(sl - len(s))

Fixed submission:
s = input()

t = s[0]
for i in s[1:]:
  if not t:
    t=i
    continue
  if i != t[-1]:
    t=t[:-1]
  else:
    t+=i

print(len(s) - len(t))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
sl = len(s)
s = list(s)
while True:
  flag = False
  for i in range(len(s)-1):
    if i+1 > len(s)-1 : break
    if s[i] != s[i+1]:
      s.pop(i+1)
      s.pop(i)
      flag = True
  else:
    if not flag:
      break
print(sl - len(s))

Fixed submission:
s = input()

t = s[0]
for i in s[1:]:
  if not t:
    t=i
    continue
  if i != t[-1]:
    t=t[:-1]
  else:
    t+=i

print(len(s) - len(t))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
sl = len(s)
s = list(s)
while True:
  for i in range(len(s)-1):
    if s[i] != s[i+1]:
      s.pop(i+1)
      s.pop(i)
      break
  else:
    break
print(sl - len(s))
  

Fixed submission:
s = input()

t = s[0]
for i in s[1:]:
  if not t:
    t=i
    continue
  if i != t[-1]:
    t=t[:-1]
  else:
    t+=i

print(len(s) - len(t))
Buggy python submission (verdict: Runtime Error):
n = int(input())
pos=[]
for i in range(n):
  x,y,h = map(int, input().split())
  pos.append([x,y,h])

def solve():
  for cx in range(101):
    for cy in range(101):
      H = h+abs(x-cx)+abs(y-cy)
      if all(h == max(H-abs(x-cx)-abs(y-cy), 0) for x,y,h in pos):
        return(cx,cy,H)

cx,cy,H=solve()
print(cx,cy,H)

Fixed submission:
n = int(input())
pos=[]
for i in range(n):
  x,y,h = map(int, input().split())
  pos.append([x,y,h])

pos = sorted(pos, key=lambda x: x[2])
tx,ty,th = pos[-1]
def solve():
  for cx in range(101):
    for cy in range(101):
      H = th+abs(tx-cx)+abs(ty-cy)
      for x,y,h in pos:
        if h != max(H-abs(x-cx)-abs(y-cy), 0):
          break
      else:
        return(cx,cy,H)

cx,cy,H=solve()
print(cx,cy,H)

Buggy python submission (verdict: Runtime Error):
n = int(input())
pos=[]
for i in range(n):
  x,y,h = map(int, input().split())
  pos.append([x,y,h])

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      edge=[]
      for i in range(n):
        x=pos[i][0]
        y=pos[i][1]
        h=pos[i][2]
        H = h+abs(x-cx)+abs(y-cy)
        if h == 0:
          if x == cx+H or x == cx-H or y == cy+H or y == cy-H:
            res.append(H)
        else:
          res.append(H)
      if len(set(res)) ==1:
        return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)

Fixed submission:
n = int(input())
pos=[]
for i in range(n):
  x,y,h = map(int, input().split())
  pos.append([x,y,h])

pos = sorted(pos, key=lambda x: x[2])
tx,ty,th = pos[-1]
def solve():
  for cx in range(101):
    for cy in range(101):
      H = th+abs(tx-cx)+abs(ty-cy)
      for x,y,h in pos:
        if h != max(H-abs(x-cx)-abs(y-cy), 0):
          break
      else:
        return(cx,cy,H)

cx,cy,H=solve()
print(cx,cy,H)

Buggy python submission (verdict: Runtime Error):
n = int(input())
pos=[]
for i in range(n):
  x,y,h = map(int, input().split())
  pos.append([x,y,h])

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      edge=[]
      for i in range(n):
        x=pos[i][0]
        y=pos[i][1]
        h=pos[i][2]
        H = h+abs(x-cx)+abs(y-cy)
        if h == 0:
          if (x == cx+H or x == cx-H) or (y == cy+H or x == cy-H):
            res.append(H)
        else:
          res.append(H)
      if len(set(res)) ==1:
        return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)

Fixed submission:
n = int(input())
pos=[]
for i in range(n):
  x,y,h = map(int, input().split())
  pos.append([x,y,h])

pos = sorted(pos, key=lambda x: x[2])
tx,ty,th = pos[-1]
def solve():
  for cx in range(101):
    for cy in range(101):
      H = th+abs(tx-cx)+abs(ty-cy)
      for x,y,h in pos:
        if h != max(H-abs(x-cx)-abs(y-cy), 0):
          break
      else:
        return(cx,cy,H)

cx,cy,H=solve()
print(cx,cy,H)
Buggy python submission (verdict: Runtime Error):
import bisect
n,k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x,0)

ans=10**12
s=z-k+1
if s < 0:
  s=0
if z == 0:
  z+=1
for i in range(s,z):
  xl=x[i]
  xr=x[i+k-1]
  ans=min(ans,abs(xr)+abs(xr-xl),abs(xl)+abs(xr-xl))
print(ans)

Fixed submission:
import bisect
n,k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x,0)

ans=10**12
s=z-k
if s < 0:
  s=0
g=z+1
if g+k >= n:
  g=n-k+1
for i in range(s,g):

  xl=x[i]
  xr=x[i+k-1]
  ans=min(ans,abs(xr)+abs(xr-xl),abs(xl)+abs(xr-xl))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x,0)

ans=10**12
s=z-k+1
if s < 0:
  s=0
if z == 0:
  z+=1
for i in range(s,z):
  t=x[i:i+k]
  xl=min(t)
  xr=max(t)
  ans=min(ans,abs(xr)+abs(xr-xl),abs(xl)+abs(xr-xl))
print(ans)

Fixed submission:
import bisect
n,k = map(int, input().split())
x = list(map(int, input().split()))
z = bisect.bisect_left(x,0)

ans=10**12
s=z-k
if s < 0:
  s=0
g=z+1
if g+k >= n:
  g=n-k+1
for i in range(s,g):

  xl=x[i]
  xr=x[i+k-1]
  ans=min(ans,abs(xr)+abs(xr-xl),abs(xl)+abs(xr-xl))
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())

print(a * b - a - b + 1)

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

print(a * b - a - b + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import string
s = input()
k = int(input())
d=[]
for sp in string.ascii_lowercase:
  for i,sd in enumerate(s,start=0):
    if sp == sd:
      for l in range(1, len(s)+1):
        if i+l > len(s):
          break
        d.append(s[i:i+l])
  d=list(set(d))
  if len(d) >= k:
    break

d=list(set(d))
d=sorted(d)
print(d[k-1])

Fixed submission:
import string
s = input()
k = int(input())
d=set()
for sp in string.ascii_lowercase:
  for i,sd in enumerate(s,start=0):
    if sp == sd:
      e=set()
      for l in range(1, 6):
        if i+l > len(s):
          break
        e.add(s[i:i+l])
      d=d|e
  if len(d) >= k:
    break

d=list(d)
d=sorted(d)
print(d[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
d=[]
for l in range(1, len(s)+1):
  for j in range(len(s)):
    if j+l > len(s):
      break
    d.append(s[j:j+l])
d=list(set(d))
d=sorted(d)
print(d[k-1])

Fixed submission:
import string
s = input()
k = int(input())
d=set()
for sp in string.ascii_lowercase:
  for i,sd in enumerate(s,start=0):
    if sp == sd:
      e=set()
      for l in range(1, 6):
        if i+l > len(s):
          break
        e.add(s[i:i+l])
      d=d|e
  if len(d) >= k:
    break

d=list(d)
d=sorted(d)
print(d[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=[int(x)for x in input().split()]
B=[0]
count=0
for x in A:
  i=B[-1]+x
  B.append(i)
  c=B.count(i)
  if c >1:
    count+=c-1
print(count)

Fixed submission:
import collections
N=input()
A=[int(x)for x in input().split()]
B=[0]
count=0
for x in A:
  i=B[-1]+x
  B.append(i)

dic=collections.Counter(B)
for key,c in dic.items():
  count+=c*(c-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=[int(x)for x in input().split()]
B=[0]
C=[]
for x in A:
  i=B[-1]+x
  B.append(i)
  if i not in C:
    C.append(i)

count=0

for x in C:
  i=B.count(x)
  if i>1:
    count+=(i-1)*i//2
print(count)

Fixed submission:
import collections
N=input()
A=[int(x)for x in input().split()]
B=[0]
count=0
for x in A:
  i=B[-1]+x
  B.append(i)

dic=collections.Counter(B)
for key,c in dic.items():
  count+=c*(c-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=[int(x)for x in input().split()]
B=[0]
for x in A:
  B.append(B[-1]+x) 

count=0
C=list(set(B))

for x in C:
  i=B.count(x)
  if i>1:
    count+=(i-1)*i//2
print(count)

Fixed submission:
import collections
N=input()
A=[int(x)for x in input().split()]
B=[0]
count=0
for x in A:
  i=B[-1]+x
  B.append(i)

dic=collections.Counter(B)
for key,c in dic.items():
  count+=c*(c-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=[int(x)for x in input().split()]
B=[0]
for x in A:
	B.append(B[-1]+x) 
count=0
C=list(set(B))

for x in C:
  i=B.count(x)
  count+=(i-1)*i//2
print(count)

Fixed submission:
import collections
N=input()
A=[int(x)for x in input().split()]
B=[0]
count=0
for x in A:
  i=B[-1]+x
  B.append(i)

dic=collections.Counter(B)
for key,c in dic.items():
  count+=c*(c-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=input()
A=[int(x)for x in input().split()]
B=[0]
for x in A:
	B.append(B[-1]+x) 
count=0

for i in range(len(B)-1,-1,-1):
  for j in range(i-1,-1,-1):
    if B[i]==B[j]:
      count+=1
print(count)

Fixed submission:
import collections
N=input()
A=[int(x)for x in input().split()]
B=[0]
count=0
for x in A:
  i=B[-1]+x
  B.append(i)

dic=collections.Counter(B)
for key,c in dic.items():
  count+=c*(c-1)//2
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))

for i in range(n):
  t=x[:i]+x[i+1:]
  t.sort()
  print(t[(n-1)//2])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
t=sorted(x)
right=t[n//2]
left=t[n//2-1]

for i in x:
  if i <= left:
    print(right)
  elif i >= right:
    print(left)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
p = 10**9+7
f=[1]
for i in range(1,a[0]+1):
  f.append(f[-1] * i)

def nCk(n,k):
  return (f[n] * pow(f[n-k],p-2,p) * pow(f[k],p-2,p)) % p

start = 0
end = -1
ans = 0
for i in range(1,n):
  t = nCk(a[start], a[i])
  if ans < t:
    ans = t
    end = i
print(a[start], a[end])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

t2 = a[0]
x = a[0]//2
ans = 1
for i in range(1,n):
  t = abs(x - a[i])
  if t < t2:
    t2 = t
    ans = i
print(a[0],a[ans])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())
temp = 0
ans = [i for i in range(a, b + 1)]

for i in sorted(list(set(ans[:k]) | set(ans[-k:]))):
  print(i) 

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

cnt = 0
if b - a + 1>= 2 * k:
  for i in range(a, a + k):
    print(i)
  for i in range(b - k + 1, b + 1):
    print(i)
else:
  for i in range(a, b + 1):
    print(i)
Buggy python submission (verdict: Runtime Error):
from collections import deque

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if (0 <= new_y < h) and (0 <= new_x < w):
        if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
          visited[new_y][new_x] = visited[y][x] + 1
          queue.append([new_y, new_x])
          
h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  t=input()
  maze.append(t)
  w_space += t.count(".")

visited = [[-1]*w for _ in range(h)]

ans = bfs()
if ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)

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

if n % 500 <= a:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
from collections import deque

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if (0 <= new_y < h) and (0 <= new_x < w):
        if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
          visited[new_y][new_x] = visited[y][x] + 1
          queue.append([new_y, new_x])
          
h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  t=input()
  maze.append(t)
  w_space += t.count(".")

visited = [[-1]*w for _ in range(h)]

ans = bfs()
if ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)

Fixed submission:
from collections import deque

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]

    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if not (0 <= new_y < h) or not (0 <= new_x < w):
        continue

      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        visited[new_y][new_x] = visited[y][x] + 1
        queue.append([new_y, new_x])

h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  t=input()
  maze.append(t)
  w_space += t.count(".")
visited = [[-1]*w for _ in range(h)]

ans = bfs()
if ans and ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
from collections import deque
h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  maze.append(input())
  w_space += maze[-1].count(".")

visited = [[-1]*w for _ in range(h)]

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if 0 <= new_y <= h-1 and 0 <= new_x <= w-1:
        if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
          visited[new_y][new_x] = visited[y][x] + 1
          queue.append([new_y, new_x])

ans = bfs()
if ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)

Fixed submission:
from collections import deque

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]

    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if not (0 <= new_y < h) or not (0 <= new_x < w):
        continue

      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        visited[new_y][new_x] = visited[y][x] + 1
        queue.append([new_y, new_x])

h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  t=input()
  maze.append(t)
  w_space += t.count(".")
visited = [[-1]*w for _ in range(h)]

ans = bfs()
if ans and ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = input()
if s[a] != "-":
  print("No")
else:
  s1, s2 = s.split("-")
  if s1.isdigit() and s2.isdigit():
    print("Yes")
  else:
    print("No")

Fixed submission:
a, b = map(int, input().split())
s = input()
if s[a] != "-":
  print("No")
else:
  s1, s2 = s[:a], s[a+1:]
  if s1.isdigit() and s2.isdigit():
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 0
for t in set(a):
  cnt = a.count(t)
  if t > cnt:
    ans += cnt
  else:
    ans += (cnt -t)

print(ans)

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

from collections import defaultdict
d = defaultdict(int)

for i in a:
  d[i] += 1

ans = 0
for t in set(a):
  cnt = d[t]

  if t > cnt:
    ans += cnt
  else:
    ans += (cnt - t)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

for i in range(n, 1, -1):
  j = int(i ** 0.5)
  if int(j) ** 2 == i:
    break
print(i)


Fixed submission:
n = int(input())

for i in range(n, 0, -1):
  j = int(i ** 0.5)
  if int(j) ** 2 == i:
    break
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

ans = 0
for i in a:
  bi = bisect.bisect_right(b,i)
  for j in b[bi:]:
    ci = bisect.bisect_right(c,j)
    ans += (n-ci)
print(ans)

Fixed submission:
import bisect

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

ans = 0
for i in b:
  ai = bisect.bisect_left(a,i)
  ci = bisect.bisect_right(c,i)
  ans += ai*(n-ci)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())

dp=[-1]*(f + 1)
dp[0]=0
for i in range(f+1):
  if dp[i] == -1:
    continue
  for j in [a, b]:
    water = i + 100*j
    if water > f:
      continue
    dp[water] = 0
    salt_max = water * e / 100
    dd = int(salt_max - dp[i])
    dp_s = [0] * (dd + 1)
    dp_s[0] = 1
    for pp in range(dd + 1):
      if dp_s[pp] == 0:
        continue
      for k in [c, d]:
        if pp+k > dd:
          continue
        dp_s[pp+k] = 1
    sm = 0
    for index,dp_i in enumerate(dp_s):
      if dp_i != 0:
        sm = index
    if water + sm + dp[i] <= f:
      dp[water] = max(dp[water], sm + dp[i])

for i in range(f+1):
  if dp[i] > 0:
    ans = i
print(dp[ans] + ans, dp[ans])

Fixed submission:
a,b,c,d,e,f = map(int, input().split())

per = 0.0
ans = salt = w = s = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f + 1, 100 * b):
        w = i + j
        if w > f: break
        for k in range(0, f + 1, c):
            if w + k > f: break
            for l in range(0, f + 1, d):
                w = i + j
                s = k + l
                if w + s > f: break
                if s <= (w // 100) * e:
                    if 0 < s + w <= f:
                        if per < s / (s + w):
                            per = s / (s + w)
                            ans = w + s
                            salt = s
if ans == 0:
    print(100*a,0)
else:
    print(ans,salt)

Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())

dp=[-1]*(f + 1)
dp[0]=0
for i in range(f+1):
  if dp[i] == -1:
    continue
  for j in [a, b]:
    water = i + 100*j
    if water > f:
      continue
    dp[water] = 0
    salt_max = water * e / 100
    dd = int(salt_max - dp[i] + 1)
    dp_s = [0] * dd
    dp_s[0]=1
    for pp in range(dd):
      if dp_s[pp] == 0:
        continue
      for k in [c, d]:
        if pp+k >= dd:
          continue
        dp_s[pp+k] = 1
    sm = 0
    for index,dp_i in enumerate(dp_s):
      if dp_i != 0:
        sm = index
    if water + sm + dp[i] <= f:
      dp[water] = max(dp[water], sm + dp[i])

for i in range(f+1):
  if dp[i] > 0:
    ans = i
print(dp[ans] + ans, dp[ans])

Fixed submission:
a,b,c,d,e,f = map(int, input().split())

per = 0.0
ans = salt = w = s = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f + 1, 100 * b):
        w = i + j
        if w > f: break
        for k in range(0, f + 1, c):
            if w + k > f: break
            for l in range(0, f + 1, d):
                w = i + j
                s = k + l
                if w + s > f: break
                if s <= (w // 100) * e:
                    if 0 < s + w <= f:
                        if per < s / (s + w):
                            per = s / (s + w)
                            ans = w + s
                            salt = s
if ans == 0:
    print(100*a,0)
else:
    print(ans,salt)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = list(map(int, input().split()))

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  else:
    c[8] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = min(sum(c))
print(cmin, cmax)

Fixed submission:
n = int(input())

a = list(map(int, input().split()))

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  else:
    c[8] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = sum(c)
print(cmin, cmax)

Buggy python submission (verdict: Runtime Error):
n = int(input())

a = list(map(int, input().split()))

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  elif t >= 8:
    c[t] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = min(sum(c[:-1]) + c[8], 8)
print(cmin, cmax)

Fixed submission:
n = int(input())

a = list(map(int, input().split()))

c = [0]*9
for i in a:
  t = i // 400
  if t < 8:
    c[t] = 1
  else:
    c[8] += 1
cmin = max(sum(c[:-1]), min(c[8], 1))
cmax = sum(c)
print(cmin, cmax)
Buggy python submission (verdict: Runtime Error):
n = int(input())

input(x - 200 * (x//15))

Fixed submission:
x = int(input())

print(800 * x - 200 * (x//15))
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
ma = []
for i in range(n):
  ma.append(input())

t = []
for i in range(m):
  t.append(input())

ly = len(t[0])
lt = m
ans = False
for i in range(n):
  for j in range(n):
    for k in range(lt):
      if ma[i + k][j : j + ly + 1] != t[k]:
        break
    else:
      ans = True

if ans:
  print("Yes")
else:
  print("No")


Fixed submission:
n,m = map(int, input().split())
ma = []
for i in range(n):
  ma.append(input())

t = []
for i in range(m):
  t.append(input())

ans = False
for i in range(n - m + 1):
  for j in range(n - m + 1):
    for k in range(m):
      ll = ma[i + k][j : j + m]
      if ll != t[k]:
        break
    else:
      ans = True

if ans:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import queue 
n,m = map(int, input().split())

ma = [[] for i in range(n+1)]
for i in range(n):
  a,b = map(int, input().split())
  ma[a].append(b)
  ma[b].append(a)

ans = 0
def dfs(i):
  global ans
  if all(reach[1:]):
    ans += 1
  for j in ma[i]:
    if reach[j] == 1:
      continue
    reach[j] = 1
    dfs(j)
    reach[j] = 0

reach=[0]*(n+1)
reach[1] = 1
dfs(1)
print(ans)

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

ma = [[] for i in range(n+1)]
for i in range(m):
  a,b = map(int, input().split())
  ma[a].append(b)
  ma[b].append(a)

ans = 0
def dfs(i):
  global ans
  if all(reach[1:]):
    ans += 1
  for j in ma[i]:
    if reach[j] == 1:
      continue
    reach[j] = 1
    dfs(j)
    reach[j] = 0

reach=[0]*(n+1)
reach[1] = 1
dfs(1)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())

for i in range(m):
  s = input()
  print(s)
  print(s)

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

for i in range(n):
  s = input()
  print(s)
  print(s)