Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
from operator import itemgetter
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
tds = [tuple(map(int, input().split())) for _ in range(N)]

tds.sort(key = itemgetter(1), reverse = True)

ate = {t:False for t, _ in tds}
variety = 0
deliciousness = 0
will_be_replaced = []
for t, d in tds[:K]:
    if ate[t] == False:
        ate[t] = True
        variety += 1
    else:
        will_be_replaced.append((t, d))
    deliciousness += d

max_point = deliciousness + variety ** 2

i = K
while will_be_replaced:
    t, d = will_be_replaced.pop()
    while i < N and ate[tds[i][0]]:
        i += 1
    deliciousness -= d
    deliciousness += tds[i][1]
    variety += 1
    point = deliciousness + variety ** 2
    max_point = max(max_point, point)

print(max_point)
    

Fixed submission:
import sys
from operator import itemgetter
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
tds = [tuple(map(int, input().split())) for _ in range(N)]

tds.sort(key = itemgetter(1), reverse = True)

ate = {t:False for t, _ in tds}
variety = 0
deliciousness = 0
will_be_replaced = []
for t, d in tds[:K]:
    if ate[t] == False:
        ate[t] = True
        variety += 1
    else:
        will_be_replaced.append((t, d))
    deliciousness += d

max_point = deliciousness + variety ** 2

i = K
while will_be_replaced:
    t, d = will_be_replaced.pop()
    while i < N:
        if ate[tds[i][0]]:
            i += 1
        else:
            ate[tds[i][0]] = True
            deliciousness -= d
            deliciousness += tds[i][1]
            variety += 1
            point = deliciousness + variety ** 2
            max_point = max(max_point, point)
            break

print(max_point)
Buggy python submission (verdict: Runtime Error):
N = int(input())
hs = list(map(int, input().split()))

costs_1 = 0
costs_2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = min(costs1 + abs(hs[i] - hs[i - 2]), costs2 + abs(hs[i] - hs[i - 1])), costs1
  
print(costs2)


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

costs1 = 0
costs2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = costs2, min(costs1 + abs(hs[i] - hs[i - 2]), costs2 + abs(hs[i] - hs[i - 1])),
  
print(costs2)

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

costs_1 = 0
costs_2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = min(costs1 + abs(h[i] - h[i - 2]), costs2 + abs(h[i] - h[i - 2])), costs1
  
print(costs2)

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

costs1 = 0
costs2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = costs2, min(costs1 + abs(hs[i] - hs[i - 2]), costs2 + abs(hs[i] - hs[i - 1])),
  
print(costs2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
As = sorted(map(int, input().split()))

used = [False] * N

ans = 0
for i in range(31, 0, -1):
    power_of_two = 1 << i
    l = 0
    r = N - 1
    while True:
        while l < N and used[l]:
            l += 1
        while r >= 0 and used[r]:
            r -= 1
        if l >= r:
            break

        if As[l] + As[r] == power_of_two:
            used[l] = True
            used[r] = True
            l += 1
            r -= 1
            ans += 1
        elif As[l] + As[r] < power_of_two:
            l += 1
        else:
            r -= 1

print(ans)



Fixed submission:
N = int(input())
As = sorted(map(int, input().split()))

used = [False] * N

ans = 0
for i in range(31, 0, -1):
    power_of_two = 1 << i
    l = 0
    r = N - 1
    while True:
        while l < N and used[l]:
            l += 1
        while r >= 0 and used[r]:
            r -= 1
        if l >= r:
            break

        if As[l] + As[r] == power_of_two:
            used[l] = True
            used[r] = True
            l += 1
            r -= 1
            ans += 1
        elif As[l] + As[r] < power_of_two:
            l += 1
        else:
            r -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

N = int(input())
As = list(map(int, input().split()))

csum = list(accumulate(As, initial=0))

P_end = 1
R_end = 3
ans = 1001001001
for Q_end in range(2, N - 1):
    former_half = csum[Q_end] // 2
    latter_half = (csum[-1] - csum[Q_end]) // 2
    while P_end + 1 <= Q_end and csum[P_end + 1] < former_half:
        P_end += 1
    while R_end + 1 < N and csum[R_end + 1] - csum[Q_end] < latter_half:
        R_end += 1
    
    if abs(csum[P_end] - former_half) > abs(csum[P_end + 1] - former_half):
        P = csum[P_end + 1]
    else:
        P = csum[P_end]
    Q = csum[Q_end] - P

    if abs(csum[R_end] - csum[Q_end] - latter_half) > abs(csum[R_end + 1] - csum[Q_end] - latter_half):
        R = csum[R_end + 1] - csum[Q_end]
        S = csum[-1] - csum[R_end + 1]
    else:
        R = csum[R_end] - csum[Q_end]
        S = csum[-1] - csum[R_end]

    # print(P, Q, R, S)
    diff = max(P, Q, R, S) - min(P, Q, R, S)
    ans = min(diff, ans)
    

print(ans)

Fixed submission:
from itertools import accumulate

N = int(input())
As = list(map(int, input().split()))

csum = list(accumulate(As, initial=0))

P_end = 1
R_end = 3
ans = 10 ** 18
for Q_end in range(2, N - 1):
    former_half = csum[Q_end] / 2
    latter_half = (csum[-1] - csum[Q_end]) / 2
    while P_end + 1 <= Q_end and csum[P_end + 1] < former_half:
        P_end += 1
    while R_end + 1 < N and csum[R_end + 1] - csum[Q_end] < latter_half:
        R_end += 1
    
    if abs(csum[P_end] - former_half) > abs(csum[P_end + 1] - former_half):
        P = csum[P_end + 1]
    else:
        P = csum[P_end]
    Q = csum[Q_end] - P

    if abs(csum[R_end] - csum[Q_end] - latter_half) > abs(csum[R_end + 1] - csum[Q_end] - latter_half):
        R = csum[R_end + 1] - csum[Q_end]
        S = csum[-1] - csum[R_end + 1]
    else:
        R = csum[R_end] - csum[Q_end]
        S = csum[-1] - csum[R_end]

    # print(P, Q, R, S)
    diff = max(P, Q, R, S) - min(P, Q, R, S)
    ans = min(diff, ans)
    

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, x, y = map(int, input().split())
possible_minimum_sum1 = a * x + b * y
possible_minimum_sum2 = c * max(a, b) * 2
possible_minimum_sum3 = c * a * 2 + max(b-a, 0) * b
possible_minimum_sum4 = c * b * 2 + max(a-b, 0) * a

print(min(tuple(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3, possible_minimum_sum4)))


Fixed submission:
a, b, c, x, y = map(int, input().split())
possible_minimum_sum1 = a * x + b * y
possible_minimum_sum2 = c * x * 2 + max(y-x, 0) * b
possible_minimum_sum3 = c * y * 2 + max(x-y, 0) * a

print(min(possible_minimum_sum1, possible_minimum_sum2, possible_minimum_sum3))
Buggy python submission (verdict: Runtime Error):
N = int(input())
As = list(map(int, input()))

A_sorted = sorted(As)
med1 = A_sorted[N//2]
med2 = A_sorted[N//2+1]

for A in As:
  if A <= med1:
    print(med2)
  else:
    print(med1)

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

A_sorted = sorted(As)
med1 = A_sorted[N//2-1]
med2 = A_sorted[N//2]

for A in As:
  if A <= med1:
    print(med2)
  else:
    print(med1)
Buggy python submission (verdict: Runtime Error):
import networkx as nx

N = int(input())
ABs = [tuple(map(int, input().split())) for _ in range(N)]
CDs = [tuple(map(int, input().split())) for _ in range(N)]

# 0 <= i <   N  -> i: ABs[i]
# N <= i < 2*N  -> i: CDs[i-N]
# i == 2*N+1    -> start
# i == 2*N+2    -> goal

DG = nx.DiGraph()
DG.add_nodes_from(range(2 * N + 3))
for i in range(N):
    for j in range(N):
        if ABs[i][0] < CDs[j][0] and ABs[i][1] < CDs[j][1]:
            DG.add_edge(i, j + N, capacity = 1)

DG.add_edges_from([(2 * N + 1, i, {"capacity":1}) for i in range(N)])
DG.add_edges_from([(i, 2 * N + 2, {"capacity":1}) for i in range(N, 2*N)])

print(nx.maximum_flow_value(DG, 2 * N + 1, 2 * N + 2))


Fixed submission:
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(N)]

AB.sort(key = max, reverse = True)
CD.sort(key = min)

counter = 0
for a, b in AB:
    for c, d in CD:
        if a < c and b < d:
            CD.remove( (c, d) )
            counter += 1
            break

print(counter)
Buggy python submission (verdict: Runtime Error):
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())
 
counter = 0
for i in range(numof500 + 1):
  for j in range(numof100 + 1):
  	for k in range(numof50 + 1):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1
 
print(counter)

Fixed submission:
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())
 
counter = 0
for i in range(numof500 + 1):
  for j in range(numof100 + 1):
    for k in range(numof50 + 1):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1
 
print(counter)

Buggy python submission (verdict: Runtime Error):
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())

counter = 0
for i in range(numof500):
  for j in range(numof100):
  	for k in range(numof50):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1

print(counter)

Fixed submission:
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())
 
counter = 0
for i in range(numof500 + 1):
  for j in range(numof100 + 1):
    for k in range(numof50 + 1):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1
 
print(counter)
Buggy python submission (verdict: Runtime Error):
n, a, b = input().split()
 
s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(s)

Fixed submission:
n, a, b = map(int, input().split())
 
s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(s)

Buggy python submission (verdict: Runtime Error):
n, a, b = input().split()

s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(i)

Fixed submission:
n, a, b = map(int, input().split())
 
s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(s)
Buggy python submission (verdict: Runtime Error):
import numpy as np

s = input()
x_goal, y_goal = map(int, input().split())

directed_x = None
steps = 0
xs = [0]
ys = [0]
for c in (s+'T'):   #sentinel
    if c == 'F':
        steps += 1
    else:
        if directed_x is None:
            x_goal -= steps
            directed_x = True
        elif steps != 0:
            if directed_x:
                xs.append(steps)
            else:
                ys.append(steps)
        steps = 0
        directed_x = not directed_x

dx_2 = sum(xs) - x_goal
if dx_2 % 2 == 1:
    ans = False
else:
    dx = dx_2 // 2
    possible_x = np.full(dx + 1, False)
    possible_x[0] = True
    for x in xs:
        possible_x[x:] = np.logical_or(possible_x[:len(possible_x)-x], possible_x[x:])
        if possible_x[dx]:
            ans = True
            break
    else:
        ans = False

if ans:
    dy_2 = sum(ys) - y_goal
    if dy_2 % 2 == 1:
        ans = False
    else:
        dy = dy_2 // 2
        possible_y = np.full(dy + 1, False)
        possible_y[0] = True
        for y in ys:
            possible_y[y:] = np.logical_or(possible_y[:len(possible_y)-y], possible_y[y:])
            if possible_y[dy]:
                ans = True
                break
        else:
            ans = False

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

Fixed submission:
import numpy as np

s = input()
x_goal, y_goal = map(int, input().split())

directed_x = None
steps = 0
xs = [0]
ys = [0]
for c in (s+'T'):   #sentinel
    if c == 'F':
        steps += 1
    else:
        if directed_x is None:
            x_goal -= steps
            directed_x = True
        elif steps != 0:
            if directed_x:
                xs.append(steps)
            else:
                ys.append(steps)
        steps = 0
        directed_x = not directed_x

dx_2 = sum(xs) - x_goal
if dx_2 % 2 == 1 or dx_2 < 0:
    ans = False
else:
    dx = dx_2 // 2
    possible_x = np.full(dx + 1, False)
    possible_x[0] = True
    for x in xs:
        possible_x[x:] = np.logical_or(possible_x[:len(possible_x)-x], possible_x[x:])
        if possible_x[dx]:
            ans = True
            break
    else:
        ans = False

if ans:
    dy_2 = sum(ys) - y_goal
    if dy_2 % 2 == 1 or dy_2 < 0:
        ans = False
    else:
        dy = dy_2 // 2
        possible_y = np.full(dy + 1, False)
        possible_y[0] = True
        for y in ys:
            possible_y[y:] = np.logical_or(possible_y[:len(possible_y)-y], possible_y[y:])
            if possible_y[dy]:
                ans = True
                break
        else:
            ans = False

if ans:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
def how_many_times_divisible(n):
    counter = 0
	
    while n % 2 == 0:
    	n //= 2
        counter +=1
    
    return counter
  
_ = input()
return min(map(lambda x: how_many_times_divisible(int(x)), input().split())



Fixed submission:
def how_many_times_divisible(n):
  counter = 0
  while n % 2 == 0:
    n //= 2
    counter += 1
  return counter
  

_ = input()
print(min(map(lambda x: how_many_times_divisible(int(x)), input().split())))
Buggy python submission (verdict: Runtime Error):
from colletions import Counter

N = int(input())
d = Counter(map(int, input().split()))

sticks_len = []
for k, v in d:
  if v >= 2:
    sticks.append(k)
  if v >= 4:
    sticks.append(k)
    
sticks.sort()

if len(sticks) >= 2:
  print(sticks[-1] * sticks[-2])
else:
  print(0)

  


Fixed submission:
from collections import Counter
 
N = int(input())
d = Counter(map(int, input().split()))
 
sticks_len = []
for k, v in d.items():
  if v >= 2:
    sticks_len.append(k)
  if v >= 4:
    sticks_len.append(k)
    
sticks_len.sort()
 
if len(sticks_len) >= 2:
  print(sticks_len[-1] * sticks_len[-2])
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
from colletions import Counter

N = int(input())
d = Counter(map(int, input().split()))

sticks_len = []
for k, v in d:
  if v >= 2:
    sticks.append(k)
  if v >= 4:
    sticks.append(k)
    
sticks.sort()

if len(sticks) >= 2:
  print(sticks[-1] * sticks[-2]
else:
  print(0)

  

Fixed submission:
from collections import Counter
 
N = int(input())
d = Counter(map(int, input().split()))
 
sticks_len = []
for k, v in d.items():
  if v >= 2:
    sticks_len.append(k)
  if v >= 4:
    sticks_len.append(k)
    
sticks_len.sort()
 
if len(sticks_len) >= 2:
  print(sticks_len[-1] * sticks_len[-2])
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

N, K = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    possible = (As[0] == K)
else:
    g = As[1] - As[0]
    for A in As[2:]:
        g = gcd(g, A - As[0])

    possible = ((K-As[0]) % g == 0) and (min(As) <= K <= max(As))

if possible:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
from fractions import gcd

N, K = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    possible = (As[0] == K)
else:
    g = max(abs(As[1] - As[0]), 1)
    for A in As[2:]:
        g = gcd(g, A - As[0])

    possible = ((K-As[0]) % g == 0) and (min(As) <= K <= max(As))

if possible:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
N, K = map(int, input().split())
As = list(map(int, input().split()))

csum = list(accumulate(As, initial = 0))
csum_of_positives = list(accumulate([max(A, 0) for A in As], initial = 0))

#[i, i+K) will be all white/black.
max_score = 0
for i in range(N-K+1):
    score = 0
    all_black = csum[i+K] - csum[i]
    if all_black > 0: # if [i, i+K) is worth painting with black 
        score += all_black
    score += csum_of_positives[i] #[0, i)
    score += csum_of_positives[N] - csum_of_positives[i+K] #[i+K, N)    
    max_score = max(max_score, score)

print(max_score)


Fixed submission:
from itertools import accumulate
N, K = map(int, input().split())
As = list(map(int, input().split()))

csum = list(accumulate(As, initial = 0))
csum_of_positives = list(accumulate([max(A, 0) for A in As], initial = 0))

#[i, i+K) will be all white/black.
max_score = 0
for i in range(N-K+1):
    score = 0
    all_black = csum[i+K] - csum[i]
    if all_black > 0: # if [i, i+K) is worth painting with black 
        score += all_black
    score += csum_of_positives[i] #[0, i)
    score += csum_of_positives[N] - csum_of_positives[i+K] #[i+K, N)    
    max_score = max(max_score, score)

print(max_score)
Buggy python submission (verdict: Runtime Error):
from functools import lru_cache

@lru_cache
def grundy(s):
    if len(s) == 2:
        return 0
    gs = set()
    for i in range(1, len(s) - 1):
        if s[i - 1] == s[i + 1]:
            continue
        gs.add(grundy(s[:i] + s[i + 1:]))
    for i in range(100):
        if i not in gs:
            return not (i == 0)

def win_first(s):
    return ((s[0] == s[-1]) + len(s)) % 2

def test():
    for i in range(1000000):
        s = str(i)
        for c1, c2 in zip(s[:-1], s[1:]):
            if c1 == c2:
                break
        else:
            assert win_first(s) == grundy(s)

def main():
    print("First" if win_first(input()) else "Second")

main()

Fixed submission:
# from functools import lru_cache

# @lru_cache
# def grundy(s):
#     if len(s) == 2:
#         return 0
#     gs = set()
#     for i in range(1, len(s) - 1):
#         if s[i - 1] == s[i + 1]:
#             continue
#         gs.add(grundy(s[:i] + s[i + 1:]))
#     for i in range(100):
#         if i not in gs:
#             return not (i == 0)

def win_first(s):
    return ((s[0] == s[-1]) + len(s)) % 2

# def test():
#     for i in range(1000000):
#         s = str(i)
#         for c1, c2 in zip(s[:-1], s[1:]):
#             if c1 == c2:
#                 break
#         else:
#             assert win_first(s) == grundy(s)

def main():
    print("First" if win_first(input()) else "Second")

main()
Buggy python submission (verdict: Time Limit Exceeded):
class BIT:
	"0-indexed apparently"
	
	def __init__(self, n):
		self.n = n
		self.data = [0] * (n+1)
		
	def point_add(self, index, value):
		index += 1
		while index <= self.n:
			self.data[index] += value
			index += index & -index
		
	def folded(self, r):
		"[0, r)"
		ret = 0
		while r > 0:
			ret += self.data[r]
			r -= r & -r
		return ret
		
	def bisect_left(self, value):
		index = 0
		k = 1 << ((self.n + 1).bit_length() - 1)
		while k > 0:
			if index + k <= self.n and self.data[index + k] < value:
				value -= self.data[index + k]
				index += k
			k >>= 1
		return index + 1
		
N = int(input())
As = list(map(int, input().split()))

A_inv = [0] * N
for i, A in enumerate(As):
	A_inv[A-1] = i
	
bit = BIT(N + 2)
bit.point_add(0, 1)
bit.point_add(N+1, 1)
ans = 0
for A, index in enumerate(A_inv):
	A += 1
	index += 1
	v = bit.folded(index)
	ans += A * (bit.bisect_left(v+1) - index - 1) * (index - bit.bisect_left(v) + 1)
	#print(A, ans)
	bit.point_add(index, 1)
	
print(ans)

Fixed submission:
class BIT:
	"0-indexed apparently"
	
	def __init__(self, n):
		self.n = n
		self.data = [0] * (n+1)
		
	def point_add(self, index, value):
		index += 1
		while index <= self.n:
			self.data[index] += value
			index += index & -index
		
	def folded(self, r):
		"[0, r)"
		ret = 0
		while r > 0:
			ret += self.data[r]
			r -= r & -r
		return ret
		
	def bisect_left(self, value):
		index = 0
		k = 1 << ((self.n + 1).bit_length() - 1)
		while k > 0:
			if index + k <= self.n and self.data[index + k] < value:
				value -= self.data[index + k]
				index += k
			k >>= 1
		return index + 1
		
N = int(input())
As = list(map(int, input().split()))

A_inv = [0] * N
for i, A in enumerate(As):
	A_inv[A-1] = i
	
bit = BIT(N + 2)
bit.point_add(0, 1)
bit.point_add(N+1, 1)
ans = 0
for A, index in enumerate(A_inv):
	A += 1
	index += 1
	v = bit.folded(index)
	ans += A * (bit.bisect_left(v+1) - index - 1) * (index - bit.bisect_left(v) + 1)
	#print(A, ans)
	bit.point_add(index, 1)
	
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools

def f(a, b, c):
    return a+b > c


input()
l = tuple(map(int, input().split()))

a=0
for t in itertools.combinations(l, 3):
    if f(t):
        a += 1

print(a)


Fixed submission:
import itertools

n, *l = map(int, open(0).read().split())

def f(a,b,c):
    return a+b>c and b+c>a and a+c>b


a=0
for t in itertools.combinations(range(n), 3):
    s=[l[i] for i in t]
    if len(s) != len(set(s)):
        continue
    if f(*s):
        a+=1

print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [input() for _ in [0]*n]
ll = list(l)
for x in l:
    if ll.count(x) != 1:
        ll.remove(x)
print(len(ll))


Fixed submission:
n = int(input())
l = []
l_a = l.append
for _ in range(n):
    l_a(input())
print(len(set(l)))
Buggy python submission (verdict: Runtime Error):
from math import pi
i = input()
print(i * pi)

Fixed submission:
from math import pi
i = input()
print(float(i) * pi * 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = []
for _ in range(N):
    l.append(input())
from collections import Countor as C
l = dict(C(l))
for x in range(1,N+1):
    print(l.get(x))

Fixed submission:
N = int(input())
from collections import Counter as C
l = dict(C((int(x) for x in input().split())))
for x in range(1,N+1):
    print(l.get(x,0))

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    mn = int(input())
    j = [int(x) for x in input().split()]
    [print(j.count(x)) for x in range(1, mn + 1)]


if __name__ == '__main__':
    main()

Fixed submission:
N = int(input())
from collections import Counter as C
l = dict(C((int(x) for x in input().split())))
for x in range(1,N+1):
    print(l.get(x,0))

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    mn = int(input())
    j = [int(x) for x in input().split()]
    for x in range(1, mn+1):
        print(j.count(x))


main()

Fixed submission:
N = int(input())
from collections import Counter as C
l = dict(C((int(x) for x in input().split())))
for x in range(1,N+1):
    print(l.get(x,0))
Buggy python submission (verdict: Runtime Error):
def gcd(a, b,c):
    while b:
        a, b = b, a % b
    while c:
        b,c = c, b % c
    return b

""" 
l = []
for a in range(1,int(input())+1):
    for b in range(1, int(input())+1):
        for c in range(1,int(input())+1):
            l.append(gcd(a,b,c))
"""
l = (gcd(a,b,c) for a in range(1,int(input())+1) for b in range(1,int(input())+1) for c in range(1,int(input())+1))

print(sum(l))

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
'''
l = []
for a in range(1,int(input())+1):
    for b in range(1, int(input())+1):
        for c in range(1,int(input())+1):
            l.append(gcd(a,b,c))
'''
N = input() 
N = int(N)+1
l = (gcd(a,b,c) for a in range(1,N) for b in range(1,N) for c in range(1,N))
print(sum(l))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = (int(x) for x in input().split())
l = []
while 1:
    if not N % K:
        l.append(0)
        break
    N = abs(N - K)
    if N < K:
        if N in l:
            break
        l.append(N)
print(min(l))

Fixed submission:
N,K = (int(x) for x in input().split())
a = N % K
print(min((a, K-a)))
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
S1 = S[:(N-1)//2]
S2 = S[(N+3)//2]
print("Yes" if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1] else "No")

Fixed submission:
iss = lambda x:x == x[::-1]
S = input()
N = len(S)
S1 = S[:(N-1)//2]
S2 = S[(N+3)//2-1:]
print("Yes" if iss(S) and iss(S1) and iss(S2) else "No")