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

s = deque(input())
reverse = 0
q = int(input())

for _ in range(q):
  query = input()
  if query == '1':
    reverse = 1 - reverse
  else:
    _,f,c = query.split()
    if f == '1':
      if reverse:
        s.appendleft(c)
      else:
        s.append(c)
    else:
      if reverse:
        s.append(c)
      else:
        s.appendleft(c)
if not  reverse:
  s.reverse()

print(''.join(s))

Fixed submission:
from collections import deque

s = deque(input())
reverse = 0
q = int(input())

for _ in range(q):
  query = input()
  if query == '1':
    reverse = 1 - reverse
  else:
    _,f,c = query.split()
    if f == '1':
      if reverse:
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if reverse:
        s.appendleft(c)
      else:
        s.append(c)
        
  
if reverse:
  s.reverse()

print(''.join(s))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
d = {}
for _ in range(m):
  s,c = map(int,input().split())
  if s > n:
    print(-1)
    exit()
  if s in d:
    if d[s] == c:
      continue
    else:
      print(-1)
      exit()
  else:
    d[s] = c

ans = ''
for i in range(n):
  if i+1 in d:
    ans += str(d[i+1])
  else:
    ans += '1'
print(ans)



Fixed submission:
import math
n = int(input())
print(int(math.ceil(n/2)))
Buggy python submission (verdict: Runtime Error):
n,k = input().split()
k = int(k)
ans = len(str(int(n,k)))
print(ans)



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

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
ans = len(str(Base_10_to_n(int(n),k)))
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k = input().split()
k = int(k)
ans = len(int(n,k))
print(ans)

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

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
ans = len(str(Base_10_to_n(int(n),k)))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n_s = input()
n_s = n_s[::-1]
#n = int(n_s)

pay = 0
back = 0
flag = 0

dp = [[0,0] for _ in range(len(n_s) + 1)]

dp[0][0] = int(n_s[0])
dp[0][1] = 10 - int(n_s[0])

for i in range(len(n_s)):
  i += 1
  if i == len(n_s):
    n = 0
  else:
    n = int(n_s[i])
  
  dp[i][0] = min(dp[i-1][0] + n, dp[i-1][1] + n+1)
  dp[i][1] = min(dp[i-1][0] + (10-n), dp[i-1][1] + (10-n-1))

print(min(dp[-1]))

Fixed submission:
n_s = input()
n_s = n_s[::-1]
#n = int(n_s)

pay = 0
back = 0
flag = 0

dp = [[0,0] for _ in range(len(n_s) + 1)]

dp[0][0] = int(n_s[0])
dp[0][1] = 10 - int(n_s[0])

for i in range(len(n_s)):
  i += 1
  if i == len(n_s):
    n = 0
  else:
    n = int(n_s[i])
  
  dp[i][0] = min(dp[i-1][0] + n, dp[i-1][1] + n+1)
  dp[i][1] = min(dp[i-1][0] + (10-n), dp[i-1][1] + (10-n-1))

print(min(dp[-1]))
Buggy python submission (verdict: Runtime Error):
n = input()
k = int(input())

import math

def func(n,k):
  if k==0:
    return 0
  digit = len(n)
  res = 0
  if digit == 1:
    if k ==1:
      res = int(n)
    return res
  if digit == 2:
    if k ==2:
      res = (int(n) - 9 - int(n) //10)
    elif k == 3:
      res = (0)
    else:
      res = (9+int(n)//10)
    return res

  base = 9**k * (math.factorial(digit-1)/ (math.factorial(k) * math.factorial(digit-1-k)) )

  for i in range(9):
    i+= 1
    if i < int(n[0]):
      base += func(n[1:],k-1)
  return base

print(int(func(n,k)))

Fixed submission:
import math
import sys
n=int(input())
k=int(input())
s=str(n)
l=len(s)
dp0=[[0 for j in range(k+1)] for i in range(l)]
dp1=[[0 for j in range(k+1)] for i in range(l)]

x=int(s[0])
dp0[0][1]=x-1
dp0[0][0]=1
dp1[0][1]=1
for i in range(1,l):
    x=int(s[i])
    dp0[i][0]=1

    for j in range(1,k+1):
        dp0[i][j]+=dp0[i-1][j-1]*9+dp0[i-1][j]
        if x>0:
            dp0[i][j]+=dp1[i-1][j-1]*(x-1)+dp1[i-1][j]
            dp1[i][j]=dp1[i-1][j-1]
        else:
            dp1[i][j]=dp1[i-1][j]

print(dp0[l-1][k]+dp1[l-1][k])
Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [float('inf') for _ in range(h+max(skills,key=lambda x:x[1])[1] + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==float('inf'):
    continue
  for damage,mp in skills:
    if i+damage >= len(dp):
      continue
    if dp[i+damage] > dp[i] + mp:
      dp[i+damage] = dp[i]+mp
ans = min(filter(lambda x :x>0,dp[h:]))
print(ans)
#print(dp)



Fixed submission:
h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [float('inf') for _ in range(h+max(skills,key=lambda x:x[1])[1] + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==float('inf'):
    continue
  for damage,mp in skills:
    if i+damage >= len(dp):
      continue
    if dp[i+damage] > dp[i] + mp:
      dp[i+damage] = dp[i]+mp
ans = min(filter(lambda x :x>0,dp[h:]))
print(ans)
#print(dp)

Buggy python submission (verdict: Runtime Error):
h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [-1 for _ in range(h+max(skills) + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==-1:
    continue
  for damage,mp in skill:
    if dp[i+mp] < dp[i] + damage:
      dp[i+mp] = dp[i]+damage
print(min(dp[h:]))

Fixed submission:
h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [float('inf') for _ in range(h+max(skills,key=lambda x:x[1])[1] + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==float('inf'):
    continue
  for damage,mp in skills:
    if i+damage >= len(dp):
      continue
    if dp[i+damage] > dp[i] + mp:
      dp[i+damage] = dp[i]+mp
ans = min(filter(lambda x :x>0,dp[h:]))
print(ans)
#print(dp)

Buggy python submission (verdict: Runtime Error):
h,n = map(int,input().split())
lst = []
for _ in range(n):
  a,b = map(int,input().split())
  lst.append((a/b,a,b))
lst.sort()

_,a,b = lst[-1]

mp  = (h//a) * b
h -= h//a * a
lst.sort(key = lambda x:x[2])
for i in lst:
  if lst[i][1] >=h:
    mp += lst[i][2]
    break
print(mp)
    

Fixed submission:
h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [float('inf') for _ in range(h+max(skills,key=lambda x:x[1])[1] + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==float('inf'):
    continue
  for damage,mp in skills:
    if i+damage >= len(dp):
      continue
    if dp[i+damage] > dp[i] + mp:
      dp[i+damage] = dp[i]+mp
ans = min(filter(lambda x :x>0,dp[h:]))
print(ans)
#print(dp)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
maze = []
pad = ' ' * (W+2)
maze.append(pad)
for i in range(H):
  m = input()
  maze.append(' ' + m + ' ')
maze.append(pad)
  
def bfs(maze, x,y, score):
    queue = [(x,y,0)]
    visited = {}
    while queue:
      x,y,s = queue.pop(0)
      if maze[x][y] != '.':
        continue
      visited[(x,y)] = s
      if (x+1,y) not in visited:
        queue.append((x+1,y,s+1))
      if (x-1,y) not in visited:
        queue.append((x-1,y,s+1))
      if (x,y+1) not in visited:
        queue.append((x,y+1,s+1))
      if (x,y-1) not in visited:
        queue.append((x,y-1,s+1))
    return max(visited.values())
  
ans = -1
for h in range(1,H+1):
  for w in range(1,W+1):
    now = maze[h][w]
    if now == '#':
      continue
    if maze[h-1][w] == maze[h+1][w] == maze[h][w-1] == maze[h][w+1] == '.':
      continue
    a = bfs(maze,h,w,0)
    if a > ans:
      ans = a
print(ans)

Fixed submission:
a = input()
print(chr(ord(a)+1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

from itertools import permutations

lst = permutations(range(1,n+1))
lst.sort()
print(abs(lst.index(P) - lst.index(Q)))

Fixed submission:
n = int(input())
p = ''.join(input().split())
q = ''.join(input().split())

from itertools import permutations

all = list(permutations(list(map(str,range(1,n+1))), n))
all = list(map(lambda x: ''.join(x), all))
all.sort()
print(abs(all.index(p) - all.index(q)))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
r,s,p = map(int,input().split())
T = int(input())

scores = {'r':p,'s':r,'p':s}


ans = 0
memo = []

for i in range(n):
  if i < k:
    ans += scores[T[i]]
    memo.append(T[i])
  else:
    if memo[i-k] == T[i]:
      memo.append('N')
    else:
      ans += scores[T[i]]
      memo.append(T[i])
print(ans)
      

Fixed submission:
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
score = {'r':p, 's':r ,'p':s}
from collections import deque
past = deque([])

ans = 0
for i in range(n):
  if i < k:
    ans += score[t[i]]
    past.append(t[i])
  else:
    if past.popleft() != t[i]:
      ans += score[t[i]]
      past.append(t[i])
    else:
      past.append('nn')
      
  
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

def func(x):
  res = []
  for i in range(n):
    res.append(x%2)
    x //= 2
  return res

test = {}
for i in range(n):
  A = int(input())
  test[i+1] = []
  for a in range(A):
    x,y = map(int,input().split())
    test[i].append((x,y))

ans = 0
for i in range(2**n):
  people = func(i)
  for i in range(n):
    if people[i]:
      for x,y in test[i+1]:
        if people[x-1] == y:
          continue
        else:
          break
      else:
        continue
      break
  else:
    ans = max(sum(people),ans)
print(ans)

Fixed submission:
n = int(input())

def func(x):
  res = []
  for i in range(n):
    res.append(x%2)
    x //= 2
  return res

test = {}
for i in range(n):
  A = int(input())
  test[i+1] = []
  for a in range(A):
    x,y = map(int,input().split())
    test[i+1].append((x,y))

ans = 0
for i in range(2**n):
  people = func(i)
  for i in range(n):
    if people[i]:
      for x,y in test[i+1]:
        if people[x-1] == y:
          continue
        else:
          break
      else:
        continue
      break
  else:
    ans = max(sum(people),ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

count = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      pas = (str(i),str(j),str(k))
      key = 0
      for c in S:
        if c == pas[key]:
          key += 1
          if key ==3:
            count +=1
            break
print(count)

Fixed submission:
N = int(input())
S = input()

count = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      pas = (str(i),str(j),str(k))
      key = 0
      for c in S:
        if c == pas[key]:
          key += 1
          if key ==3:
            count +=1
            break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

dict = {}

for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      key = S[i]+S[j]+S[k]
      dict[key] = 0
print(len(dict))

Fixed submission:
N = int(input())
S = input()

count = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      pas = (str(i),str(j),str(k))
      key = 0
      for c in S:
        if c == pas[key]:
          key += 1
          if key ==3:
            count +=1
            break
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
pos = []
for _ in range(n):
  x,y = map(int,input().split())
  pos.append((x,y))

import math
def distance(p1,p2):
  x1,y1 = p1
  x2,y2 = p2
  return math.sprt((x1-x2)**2 + (y1-y2)**2)
  
ans = 0
for i in range(n):
  for j in range(n):
    ans += distance(pos[i],pos[j])
print(ans/n)

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

def distance(p1,p2):
  ans = (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2
  return math.sqrt(ans)

amount = 0
for i in range(len(points)):
  for j in range(len(points)):
    if i == j:
      continue
    amount += distance(points[i],points[j])
print(amount/n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

ans = 0
for i in range(1,s):
  if s[i] != s[i-1]:
    ans += 1
    
print(ans)

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

ans = 0
for i in range(1,n):
  if s[i] != s[i-1]:
    ans += 1
    
print(ans+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(1,n-1):
  for j in range(i):
    if L[n-1] - L[i]-L[j] < 0:
      ans += (n-1) - (i+1) + 1
      continue
    elif L[i+1] - L[i]-L[j] >= 0:
      continue
    l = i+1
    r = n-1
    while abs(r-l) > 1:
      mid = (l+r)//2
      if L[i]+L[j] - L[mid]> 0:
        l = mid
      else:
        r= mid
    ans += l-(i+1)+ 1
print(ans)

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

ans = 0
for i in range(1,n-1):
  for j in range(i):
    if L[n-1] - L[i]-L[j] < 0:
      ans += (n-1) - (i+1) + 1
      continue
    elif L[i+1] - L[i]-L[j] >= 0:
      continue
    l = i+1
    r = n-1
    while abs(r-l) > 1:
      mid = (l+r)//2
      if L[i]+L[j] - L[mid]> 0:
        l = mid
      else:
        r= mid
    ans += l-(i+1)+ 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)
import fractions

a,b = map(int,input().split())
#c = Euclid(a,b) if a > b else Euclid(b,a)
c = fractions.gcd(a,b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
if c == 1:
  print(1)
else:
  print(len(factorization(c))+1)



Fixed submission:
n = int(input())
print((n- n//2)/n)
Buggy python submission (verdict: Time Limit Exceeded):
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)
import fractions

a,b = map(int,input().split())
#c = Euclid(a,b) if a > b else Euclid(b,a)
c = fractions.gcd(a,b)

def soinsu(a):
  for i in range(2,a+1):
    if a % i == 0:
      return i
    
ans = []
while 1:
  if c==1:
    break
  s = soinsu(c)
  c = int(c/s)
  ans.append(s)
  
print(len(set(ans)) + 1)

Fixed submission:
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)
import fractions

a,b = map(int,input().split())
#c = Euclid(a,b) if a > b else Euclid(b,a)
c = fractions.gcd(a,b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
if c == 1:
  print(1)
else:
  print(len(factorization(c))+1)

Buggy python submission (verdict: Runtime Error):
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)

a,b = map(int,input().split())
c = Euclid(a,b) if a > b else Euclid(b,a)

def soinsu(a):
  for i in range(2,a+1):
    if a % i == 0:
      return i
    
ans = []
while 1:
  s = soinsu(c)
  c = int(c/s)
  ans.append(s)
  if c==1:
    break
print(len(set(ans)) + 1)

Fixed submission:
def Euclid(a,b):
  r = a % b
  if r == 0:
    return b
  return Euclid(b,r)
import fractions

a,b = map(int,input().split())
#c = Euclid(a,b) if a > b else Euclid(b,a)
c = fractions.gcd(a,b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
if c == 1:
  print(1)
else:
  print(len(factorization(c))+1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()


for _ in range(m):
  a = A.pop() // 2
  A.insert(bisect.bisect_left(A,a),a)
print(sum(A))

Fixed submission:
import bisect
import heapq
n,m = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x: x*(-1), A))


heapq.heapify(A)


for _ in range(m):
  a = -heapq.heappop(A)//2
  heapq.heappush(A,-a)
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()


for _ in range(m):
  a = A.pop() // 2
  A.insert(bisect.bisect_left(A,a),a)
print(sum(A))

Fixed submission:
import bisect
import heapq
n,m = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x: x*(-1), A))


heapq.heapify(A)


for _ in range(m):
  a = -heapq.heappop(A)//2
  heapq.heappush(A,-a)
print(-sum(A))
Buggy python submission (verdict: Runtime Error):
n = int(input())[::-1]
H = list(map(int,input().split()))

ans = [0 for i in range(n)]

for i in range(1,n):
  if H[i] < H[i+1]:
    ans[i] = ans[i]+1
  else:
    ans[i] = 0
print(max(ans))
    

Fixed submission:
n = int(input())
H = list(map(int,input().split()))[::-1]

ans = [0 for i in range(n)]

for i in range(1,n):
  if H[i-1] <= H[i]:
    ans[i] = ans[i-1]+1
  else:
    ans[i] = 0
print(max(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input)
V = list(map(int,input().split()))

while len(V)> 1:
  a = min(V)
  V.pop(V.index(a))
  b = min(V)
  V.pop(V.index(b))
  V.append((a+b)/2)
print(V[0])

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

while len(V)> 1:
  a = min(V)
  V.pop(V.index(a))
  b = min(V)
  V.pop(V.index(b))
  V.append((a+b)/2)
print(V[0])
Buggy python submission (verdict: Runtime Error):
n = input()
ans = 0
for i in range(1,n+1):
  if len(str(i)) %2:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
  if len(str(i)) %2:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
r = int(input())
return 3 * r ** 2 

Fixed submission:
r = int(input())
print(3 * r ** 2 )
Buggy python submission (verdict: Runtime Error):
import math
n,d = map(int,input().split())
print(math.ceil(n / (2d+1)) )

Fixed submission:
import math
n,d = map(int,input().split())
print(math.ceil(n / (2*d+1)) )
Buggy python submission (verdict: Runtime Error):
n,d = map(int,input().split())
points = []
for _ in range(n):
  X = tuple(map(int,input().split()))
  points.append(X)
  
ans = 0

import math
def distance(x,y):
  dis = 0
  for i in range(d):
    dis += (x[i]-y[i])**2
  return math.sqrt(dis)

for i in range(n-1):
  for j in range(i+1,n):
    dis = distance(X[i],X[j])
    if dis == int(dis):
      ans += 1
print(ans)

Fixed submission:
n,d = map(int,input().split())
points = []
for _ in range(n):
  X = tuple(map(int,input().split()))
  points.append(X)
  
ans = 0

import math
def distance(x,y):
  dis = 0
  for i in range(d):
    dis += (x[i]-y[i])**2
  return math.sqrt(dis)

for i in range(n-1):
  for j in range(i+1,n):
    dis = distance(points[i],points[j])
    if dis == int(dis):
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
D = list(map(int,input().split()))

D.sort()
print(D[n//2] -D[n//2-1])



Fixed submission:
l,r = map(int,input().split())

cand = []
for i in range(l,r+1):
  cand.append(i%2019)
  if len(cand) == 2020*2:
    break
    
ans = float('inf')
for i in range(len(cand)):
  for j in range(len(cand)):
    if i==j:
      continue
    ans = min(ans, (cand[i]*cand[j])%2019)
    if ans ==0:
      break
  else:
    continue
  break
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
from fractions import gcd
cd_gcd = gcd(c,d)
lcm= c*d // ab_gcd
divs = lcm//c + lcm//d - 1

ans = 0
ans += int((b-a)/lcm)*divs
for i in range(a % lcm, b%lcm+lcm+1):
  if not i % c or not i % d:
    ans += 1
print(b-a - ans)
    

Fixed submission:
a,b,c,d = map(int,input().split())
a -= 1
import fractions

lcm = c*d//fractions.gcd(c,d)
ansa = a - a//c - a//d + a//lcm
ansb = b - b//c - b//d + b//lcm

print(ansb-ansa)
Buggy python submission (verdict: Runtime Error):
n = int(input())
pos = []
diff = []
for _ in range(n):
  x,y = map(int,input().split())
  for px,py in pos:
    diff.append((x-px, y-py))
    diff.append((px-x, py-y))
  pos.append((x,y))
from collections import Counter
diff = Counter(diff).most_common()
x,y = diff[0][0]
count = diff[0][1]
if x== y == 0:
  x,y = diff[1][0]
  count = diff[1][1]
print(n-count)



Fixed submission:
n = int(input())
if n== 1:
  print(1)
  exit()
pos = []
diff = []
for _ in range(n):
  x,y = map(int,input().split())
  for px,py in pos:
    diff.append((x-px, y-py))
    diff.append((px-x, py-y))
  pos.append((x,y))
from collections import Counter
diff = Counter(diff).most_common()
x,y = diff[0][0]
count = diff[0][1]
if x== y == 0:
  x,y = diff[1][0]
  count = diff[1][1]
print(n-count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ws = list(map(int,input().split()))
others = [0]
diff = 999999999999
for i in range(n):
  d= abs(sum(ws)-sum(other))
  if d < diff:
    diff = d
  others.add(ws.pop(0))
print(diff)

Fixed submission:
n = int(input())
ws = list(map(int,input().split()))
others = [0]
diff = 999999999999
for i in range(n):
  d= abs(sum(ws)-sum(others))
  if d < diff:
    diff = d
  others.append(ws.pop(0))
print(diff)
Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
maze = [input() for _ in range(h)]

dph = [[0 for _ in range(w)] for _ in range(h)]
dpw = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
  for j in range(w):
    if maze[i][j] == '#':
      continue
    if dpw[i][j] != 0:
      continue
    k = j
    count = 0
    while k< w:
      
      if maze[i][k] == '.':
        count += 1
        k += 1
      else:
        break
    for l in range(j,k):
      dpw[i][l] = count
      
for i in range(w):
  for j in range(h):
    if maze[j][i] == '#':
      continue
    if dph[j][i] != 0:
      continue
    k = j
    count = 0
    while k< h:
      
      if maze[k][i] == '.':
        count += 1
        k += 1
      else:
        break
    for l in range(j,k):
      dph[l][i] = count


ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, dpw[i][j] + dph[i][j])
print(ans-1)

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

dph = [[0 for _ in range(w)] for _ in range(h)]
dpw = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
  for j in range(w):
    if maze[i][j] == '#':
      continue
    if dpw[i][j] != 0:
      continue
    k = j
    count = 0
    while k< w:
      
      if maze[i][k] == '.':
        count += 1
        k += 1
      else:
        break
    for l in range(j,k):
      dpw[i][l] = count
      
for i in range(w):
  for j in range(h):
    if maze[j][i] == '#':
      continue
    if dph[j][i] != 0:
      continue
    k = j
    count = 0
    while k< h:
      
      if maze[k][i] == '.':
        count += 1
        k += 1
      else:
        break
    for l in range(j,k):
      dph[l][i] = count


ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, dpw[i][j] + dph[i][j])
print(ans-1)