Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,q = [int(i) for i in input().split()]
s = input()

for i in range(q):
    l,r = [int(i) for i in input().split()]
    p = s[l-1:r]
    print(p.count("AC"))


Fixed submission:
n,q = [int(i) for i in input().split()]
s = input()
cumsum = [0]*n
ans = 0
flag = False

for i in range(n):
    if flag:
        if s[i] == "C":
            ans += 1

    cumsum[i] = ans     

    flag = False

    if s[i] == "A":
        flag = True
    


for i in range(q):
    l,r = [int(i) for i in input().split()]
    ans = cumsum[r-1] - cumsum[l-1]
    print(ans)

Buggy python submission (verdict: Runtime Error):
n,q = [int(i) for i in input().split()]
s = input()

for i in range(q):
    l,r = [int(i) for i in input().split()]
    p = s[l-1:r]
    ans = re.findall("AC",p)
    print(len("AC"))


Fixed submission:
n,q = [int(i) for i in input().split()]
s = input()
cumsum = [0]*n
ans = 0
flag = False

for i in range(n):
    if flag:
        if s[i] == "C":
            ans += 1

    cumsum[i] = ans     

    flag = False

    if s[i] == "A":
        flag = True
    


for i in range(q):
    l,r = [int(i) for i in input().split()]
    ans = cumsum[r-1] - cumsum[l-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,q = [int(i) for i in input().split()]
s = input()

for i in range(q):
    l,r = [int(i) for i in input().split()]
    p = s[l-1:r]
    print(p.count("AC"))

Fixed submission:
n,q = [int(i) for i in input().split()]
s = input()
cumsum = [0]*n
ans = 0
flag = False

for i in range(n):
    if flag:
        if s[i] == "C":
            ans += 1

    cumsum[i] = ans     

    flag = False

    if s[i] == "A":
        flag = True
    


for i in range(q):
    l,r = [int(i) for i in input().split()]
    ans = cumsum[r-1] - cumsum[l-1]
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
card = []

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


 
def check(cx,cy):
    needH = -1
    for i in range(n):
        x,y,h = card[i]

        if h>0:
            global H = abs(x-cx)+abs(y-cy)+h
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    return False
    
    for i in range(n):
        x,y,h = card[i]

        if h==0:
            dist = abs(x-cx)+abs(y-cy)
            if H > dist:
                return False
    else:
        return True

    
for i in range(101):
    for j in range(101):
        if check(i,j):

            print("{} {} {}".format(i,j,H))


Fixed submission:
n = int(input())
card = []

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


 
def check(cx,cy):
    needH = -1
    for i in range(n):
        x,y,h = card[i]

        if h>0:
            global H
            H = abs(x-cx)+abs(y-cy)+h
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    return False
    
    for i in range(n):
        x,y,h = card[i]

        if h==0:
            dist = abs(x-cx)+abs(y-cy)
            if H > dist:
                return False
    else:
        return True

    
for i in range(101):
    for j in range(101):
        if check(i,j):

            print("{} {} {}".format(i,j,H))
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    

n,x = [int(i) for i in input().split()]

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))

Fixed submission:
from functools import reduce

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def gcd_list(numbers):
    return reduce(gcd, numbers)
    

n,x = [int(i) for i in input().split()]

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    

n,x = [int(i) for i in input().split()]

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))

Fixed submission:
from functools import reduce

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def gcd_list(numbers):
    return reduce(gcd, numbers)
    

n,x = [int(i) for i in input().split()]

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))
Buggy python submission (verdict: Runtime Error):
import numpy as np

x1,y1,x2,y2 = [int(i) for i in input().split()]

vx = x2-x1
vy = y2-y1

vx2,vy2 = np.array([[0,-1],[1,0]])@np.array([vx,vy])

x3 = x2+vx2
y3 = y2+vy2

vx3,vy3 = np.array([[0,-1],[1,0]])@np.array([vx2,vy2])

x4 = x3+vx3
y4 = y3+vy3

print(x3,y3,x4,y4)

Fixed submission:
x1, y1, x2, y2 = list(map(int, input().split()))

x = x2 - x1
y = y2 - y1

x3 = x2 - y
y3 = y2 + x

x4 = x1 - y
y4 = y1 + x

print(str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4))

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

x1,y1,x2,y2 = [int(i) for i in input().split()]

vx = x2-x1
vy = y2-y1

vx2,vy2 = np.array([[0,-1],[1,0]])@np.array([vx,vy])

x3 = x2+vx2
y3 = y2+vy2

vx3,vy3 = np.array([[0,-1],[1,0]])@np.array([vx2,vy2])

x4 = x3+vx3
y4 = y3+vy3

print(x3,y3,x4,y4)

Fixed submission:
x1, y1, x2, y2 = list(map(int, input().split()))

x = x2 - x1
y = y2 - y1

x3 = x2 - y
y3 = y2 + x

x4 = x1 - y
y4 = y1 + x

print(str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4))
Buggy python submission (verdict: Runtime Error):
a,b = int(input()).split()

if a % b == 0:
  print(0)
else:
  print(1)

Fixed submission:
a,b = [int(i) for i in input().split()]

if a % b == 0:
  print(0)
else:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = [int(i) for i in input().split()]
A = [i for i in range(a,b+1)]
n = len(A)
ans = []
if n <= 2*k:
    for a in A:
        print(a)

else:
    A = A[:k]+A[-k:]
    for a in A:
        print(a)

Fixed submission:
a,b,k = [int(i) for i in input().split()]
n = b-a+1

if n <= 2*k:
    for i in range(a,b+1):
        print(i)

else:
    for i in range(k):
        print(a+i)
    for i in range(b-k+1,b+1):
        print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = [int(i) for i in input().split()]
A = [i for i in range(a,b+1)]
n = len(A)
ans = []
for i in range(k):
    if i >= n:
        break
    else:
        ans.append(A[i])

for i in range(1,k+1):
    if i >= n or A[-i] in ans:
        break
    else:
        ans.append(A[-i])


ans.sort()

for a in ans:
    print(a)

Fixed submission:
a,b,k = [int(i) for i in input().split()]
n = b-a+1

if n <= 2*k:
    for i in range(a,b+1):
        print(i)

else:
    for i in range(k):
        print(a+i)
    for i in range(b-k+1,b+1):
        print(i)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = [int(i) for i in input().split()]
A = [i for i in range(a,b+1)]
n = len(A)
ans = []
A.sort()
for i in range(k):
    if i >= n:
        break
    else:
        ans.append(A[i])

A.sort(reverse=True)
for i in range(k):
    if i >= n:
        break
    else:
        ans.append(A[i])

ans = list(set(ans))

ans.sort()

for a in ans:
    print(a)

Fixed submission:
a,b,k = [int(i) for i in input().split()]
n = b-a+1

if n <= 2*k:
    for i in range(a,b+1):
        print(i)

else:
    for i in range(k):
        print(a+i)
    for i in range(b-k+1,b+1):
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
# Your code here!
h,w,d = map(int,input().split())

dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
for i in range(q):
    ans = 0
    l,r = map(int,input().split())
    current = l
    current_m = dic[l]
    while current < r:
        current += d
        next_m = dic[current]
        ans += abs(next_m[0]-current_m[0])+abs(next_m[1]-current_m[1])
        current_m = next_m
        
    
    print(ans)

Fixed submission:
h,w,d = map(int,input().split())
 
dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
c = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    pi,pj = dic[i]; qi,qj = dic[i-d]
    c[i] = c[i-d] + abs(pi-qi) + abs(pj-qj)
    
for i in range(q):
    l,r = map(int,input().split())
    print(c[r]-c[l])

Buggy python submission (verdict: Time Limit Exceeded):
h,w,d = map(int,input().split())
A = [[int(i) for i in input().split()] for j in range(h)]
q = int(input())
dic = {}


for i in range(h):
    for j in range(w):
        dic[A[i][j]] = (i+1,j+1)

for i in range(q):
    ans = 0
    l,r = map(int,input().split())
    current = l
    current_m = dic[l]
    while current != r:
        current += d
        next_m = dic[current]
        ans += abs(next_m[0]-current_m[0])+abs(next_m[1]-current_m[1])
        current_m = dic[current]
        
    
    print(ans)

Fixed submission:
h,w,d = map(int,input().split())
 
dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
c = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    pi,pj = dic[i]; qi,qj = dic[i-d]
    c[i] = c[i-d] + abs(pi-qi) + abs(pj-qj)
    
for i in range(q):
    l,r = map(int,input().split())
    print(c[r]-c[l])
Buggy python submission (verdict: Runtime Error):

h,w = (int(i) for i in input().split())
M = [input() for i in range(h)]
N = [[False]*w for i in range(h)]
print(M)
cnt = 0
for i in range(h):
    for j in range(w):
        if M[i][j] == "#":
            cnt += 1
print(cnt)
ans = 0
def dfs(x,y):
    global ans
    if M[x][y] == "#":
        return
    elif N[x][y]:
        return
    elif x == w-1 and y == h-1:
        print(h*w-(ans+1+cnt))
        exit()
    else:
        N[x][y] = True
        ans += 1
        A = [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]
        for a in A:
            if 0<=a[0]<=w-1 and 0<=a[1]<=h-1:
                dfs(a[0],a[1])

dfs(0,0)
print(-1)

Fixed submission:
from collections import deque
h,w = (int(i) for i in input().split())

M = [input() for i in range(h)]
N = [[False]*w for i in range(h)]

cnt = 0
for i in range(h):
    for j in range(w):
        if M[i][j] == "#":
            cnt += 1


que = deque([[0,0,1]])
while que:
    x,y,c = que.popleft()

    if M[y][x] == "#":
        continue
    elif N[y][x]:
        continue
    elif x == w-1 and y == h-1:
        
        print(h*w-(c+cnt))
        quit()

    else:
        N[y][x]=True
        A = [[x+1,y,c+1],[x-1,y,c+1],[x,y+1,c+1],[x,y-1,c+1]]
        for a in A:
            if 0<=a[0]<=w-1 and 0<=a[1]<=h-1:
                que.append(a)
                
print(-1)
Buggy python submission (verdict: Runtime Error):
def dfs(s):
	global x, G
	for t, d in G[s]:
		if x[t] is None:
			x[t] = x[s] + d
			if not dfs(t):
				return False
		else:
			if x[t] != x[s] + d:
				return False
	return True

N,M = map(int,input().split())
x = [None] * N
G = [[] for _ in range(N)]
for _ in range(M):
	L, R, D = map(int,input().split())
	G[L-1].append([R-1,D])
	G[R-1].append([L-1,-D])
print(G)
res = True
for i in range(N):
	if x[i] is None:
		x[i] = 0
		res &= dfs(i)

print("Yes" if res == True else "No")

Fixed submission:
import sys
sys.setrecursionlimit(200002)

def dfs(s):
	global x, G
	for t, d in G[s]:
		if x[t] is None:
			x[t] = x[s] + d
			if not dfs(t):
				return False
		else:
			if x[t] != x[s] + d:
				return False
	return True

N,M = map(int,input().split())
x = [None] * N
G = [[] for _ in range(N)]
for _ in range(M):
	L, R, D = map(int,input().split())
	G[L-1].append([R-1,D])
	G[R-1].append([L-1,-D])

res = True
for i in range(N):
	if x[i] is None:
		x[i] = 0
		res &= dfs(i)

print("Yes" if res == True else "No")

Buggy python submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())

A = [0]*2*100000

for i in range(m):
    xr,xl,d = [int(i) for i in input().split()]
    if xr in A and xl in A:
        if A.index(xr) + d != A.index(xl):
            print("No")
            break
    elif xr in A:
        A[A.index(xr)+d] = xl
    elif xl in A:
        A[A.index(xl)-d] = xr
    else:
        A[xr+n-1] = xr
        A[xr+n-1+d] = xl
else:
    print("Yes")

Fixed submission:
import sys
sys.setrecursionlimit(200002)

def dfs(s):
	global x, G
	for t, d in G[s]:
		if x[t] is None:
			x[t] = x[s] + d
			if not dfs(t):
				return False
		else:
			if x[t] != x[s] + d:
				return False
	return True

N,M = map(int,input().split())
x = [None] * N
G = [[] for _ in range(N)]
for _ in range(M):
	L, R, D = map(int,input().split())
	G[L-1].append([R-1,D])
	G[R-1].append([L-1,-D])

res = True
for i in range(N):
	if x[i] is None:
		x[i] = 0
		res &= dfs(i)

print("Yes" if res == True else "No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
t = 0
st = 0
cn = []
sn = []
fn = []

for i in range(n-1):
  c,s,f = map(int,input().split())
  cn.append(c)
  sn.append(s)
  fn.append(f)

for j in range(n-1):
    t = 0
    for i in range(j,n-1):
      st = sn[i]
      if t <= sn[i]:
        t = sn[i]
      if t%fn[i] != 0:
          t += fn[i]-t%fn[i]
      t += cn[i]
    print(t)


print(0)

Fixed submission:
t = int(input())

print(24+24-t)
Buggy python submission (verdict: Runtime Error):
n = int(input())
t = 0
st = 0
cn = []
sn = []
fn = []

for i in range(n-1):
  c,s,f = map(int,input().split())
  cn.append(c)
  sn.append(s)
  fn.append(f)

for j in range(n-1):
    for i in range(j,n-1):
      st = sn[i]
      if t <= sn[i]:
        t = sn[i]
      else:
        while t <= st :
          st += fn[i]
      t += cn[i]
    print(t)
    t = 0
        
 print(0)
  
  

Fixed submission:
n = int(input())
t = 0
st = 0
cn = []
sn = []
fn = []

for i in range(n-1):
  c,s,f = map(int,input().split())
  cn.append(c)
  sn.append(s)
  fn.append(f)

for j in range(n-1):
    t = 0
    for i in range(j,n-1):
      st = sn[i]
      if t <= sn[i]:
        t = sn[i]
      if t%fn[i] != 0:
          t += fn[i]-t%fn[i]
      t += cn[i]
    print(t)


print(0)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map[int,input().split()]
right = a + b
left = c + d
 
if right < left:
  print('Right')
elif left < right:
  print('Left')
else:
  print('Balanced')

Fixed submission:
a,b,c,d = map(int,input().split())
right = a + b
left = c + d
 
if right < left:
  print('Right')
elif left < right:
  print('Left')
else:
  print('Balanced')

Buggy python submission (verdict: Runtime Error):
a,b,c,d = map[int,input().split()]
right = a + b
left = c + d

if right > left:
  print('Right')
elif left > right:
  print('Left')
else:
  print('Balanced')

Fixed submission:
a,b,c,d = map(int,input().split())
right = a + b
left = c + d
 
if right < left:
  print('Right')
elif left < right:
  print('Left')
else:
  print('Balanced')
Buggy python submission (verdict: Time Limit Exceeded):
x,y = map(int,input().split())
count = 1
counts = []
an = 0

for i in range(x,y+1):
  an = i
  for j in range(i+1,y+1):
    
    if j % an == 0:
      count += 1
      an = j
  counts.append(count)
  count = 0
  
print(max(counts))

Fixed submission:
x,y = map(int,input().split())
an = x
count = 0
while an <= y:
    an *= 2
    count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input().rstrip())
numbers =[ int(i) for i in input().rstrip().split()]
  

n_dic = {str(i):0 for i in set(numbers)}


for i in numbers:
    n_dic[str(i)] += 1
   
count = 0

for i,j in n_dic.items():
    if int(i) < j:
        count += j - int(i)
    
    elif int(i) > j:
        count += j
        
print(count)

Fixed submission:
import math
numbers = input().rstrip().split()
number1 = int(numbers[0])
number2 = int(numbers[1])
 
mean = (number1+number2) / 2
 
print(math.ceil(mean))

Buggy python submission (verdict: Runtime Error):
import string

alphabet = {}
n  = 0
for i in string.ascii_lowercase:
    alphabet[i] = n
    n += 1
    
s = list(input().rstrip())
t = list(input().rstrip())



for i in range(len(s)):
    s[i] = alphabet[s[i]]
    
for i in range(len(t)):
    t[i] = alphabet[t[i]]
    

s.sort()
t.sort(reverse=True)

if s < t:
    print('Yes')
else:
    print('No')
    

Fixed submission:
import math
numbers = input().rstrip().split()
number1 = int(numbers[0])
number2 = int(numbers[1])
 
mean = (number1+number2) / 2
 
print(math.ceil(mean))

Buggy python submission (verdict: Runtime Error):
import math
numbers = input().rstrip().split()
number1 = numbers[0]
number2 = numbers[1]

mean = (number1+number2) / 2

print(math.ceil(mean))

Fixed submission:
import math
numbers = input().rstrip().split()
number1 = int(numbers[0])
number2 = int(numbers[1])
 
mean = (number1+number2) / 2
 
print(math.ceil(mean))
Buggy python submission (verdict: Runtime Error):
import math as m
n = int(input())
numbers = map(int,input().split())
order = []
 
for i in range(n):
  if numbers[i] == 0:
    a = 0
  else:
    a = m.floor(m.log(numbers[i],2))
  order.append(a)
print(min(order))

Fixed submission:
N = int(input())
numbers =map(int,input().split())
ans = 10000
for i in numbers:
  count = 0
  while i % 2 == 0:
    i /= 2
    count += 1
  ans = min(ans,count)

print(ans)

Buggy python submission (verdict: Runtime Error):
import math as m
n = int(input())
numbers = map(int,input().split())
order = []

for i in range(6):
  if numbers[i] == 0:
    a = 0
  else:
    a = m.floor(m.log(numbers[i],2))
  order.append(a)
print(min(order))

  

Fixed submission:
N = int(input())
numbers =map(int,input().split())
ans = 10000
for i in numbers:
  count = 0
  while i % 2 == 0:
    i /= 2
    count += 1
  ans = min(ans,count)

print(ans)
Buggy python submission (verdict: Runtime Error):
x,y = [input().split()]
if x == y:
  print('=')
elif x > y:
  print('>')
else:
  print('<')

Fixed submission:
x,y = input().split()
if x == y:
  print('=')
elif x > y:
  print('>')
else:
  print('<')
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

count = 0


for c in C:
    for b in B:
        if b >= c:
            continue
        else:
            saidan = filter(lambda x: x<b ,A)
            count+=len(list(saidan))
                
print(count)

Fixed submission:
a = input()
b = input()
c = a[::-1]
d = b[::-1]

if a == d and b == c:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

count = 0


for c in C:
    for b in filter(lambda x: x<c ,B):
        saidan = filter(lambda x: x<b ,A)
        count+=len(list(saidan))
                
print(count)

Fixed submission:
import bisect
 
def main():
    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 y in b:
        i = bisect.bisect_left(a, y)
        j = bisect.bisect_right(c, y)
        if i > 0 and j != len(c):
            ans += i * (n - j)
 
    print(ans)
 
main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

count = 0


for c in C:
    for b in B:
        if b >= c:
            continue
        else:
            saidan = filter(lambda x: x<b ,A)
            count+=len(list(saidan))
                
print(count)

Fixed submission:
import bisect
 
def main():
    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 y in b:
        i = bisect.bisect_left(a, y)
        j = bisect.bisect_right(c, y)
        if i > 0 and j != len(c):
            ans += i * (n - j)
 
    print(ans)
 
main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

count = 0


for c in C:
    for b in B:
        if b >= c:
            continue
        for a in A:
            if a >= b:
                continue
            else:
                
                count+=1
                
print(count)

Fixed submission:
import bisect
 
def main():
    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 y in b:
        i = bisect.bisect_left(a, y)
        j = bisect.bisect_right(c, y)
        if i > 0 and j != len(c):
            ans += i * (n - j)
 
    print(ans)
 
main()
Buggy python submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())
c_max = 0
sw_max = 0
s_max = 0

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D
                
                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if water + sugar <= F and sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max = 0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)

Fixed submission:
A,B,C,D,E,F = map(int,input().split())
c_max = 0
sw_max = 0
s_max = 0

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D
                
                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if water + sugar <= F and sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max ==0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted([int(i) for i in input().split()])

def count(n,a):
    count = 0
    cmax = 0
    if n == 1:
        return 1
    else:
        for i in range(n):
            j = i
            while j <= n-1  and a[j]-a[i] <= 2:
                count += 1
                j += 1
            if count > cmax:
                cmax = count
            count = 0
        return cmax
        
print(count(n,a))

Fixed submission:
from collections import Counter
n = int(input())
a = sorted([int(i) for i in input().split()])
c = Counter(a)
d =[]
for k,v in c.items():
    d.append([k,v])

    

def count(a):
    na = len(a)
    count = 0
    cmax = 0
    if n == 1:
        return 1
    else:
        for i in range(na):
            j = i
            while j <= na-1  and a[j][0]-a[i][0] <= 2:
                count += a[j][1]
                j += 1
            if count > cmax:
                cmax = count
            count = 0
        return cmax

print(count(d))
Buggy python submission (verdict: Time Limit Exceeded):

n,m = map(int,input().split())
A = [[int(i) for i in input().split()] for j in range(m)]
B = []
C = []
for i in A:
    if 1 in i:
        B += i

for i in A:
    a,b = i
    if a in B:
        C.append(b)
    elif b in B:
        C.append(a)
        


if n in C or n in B:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
    

Fixed submission:
n,m = map(int,input().split())
A = [[int(i) for i in input().split()] for j in range(m)]
B = []
C = []
for i in A:
    if 1 in i:
        B += i
B = set(B)
for i in A:
    a,b = i
    if a in B:
        C.append(b)
    elif b in B:
        C.append(a)
        
C = set(C)

if n in C or n in B:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')