Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import itertools
H,W= [int(x) for x in input().split()]
meiro=[list(input())for _ in range(H)]
#print(meiro)
ans=0
dx = [1,0,-1,0]
dy=[0,1,0,-1]
for i in range(H):
  for j in range(W):
    result=[[0]*W for _ in range(H)]
    cnt=0
    #print(i,j)
    if meiro[i][j]=="#":
      continue
    elif meiro[i][j]==".":
      stk =[[i,j]]
      result[i][j]=1
      while stk:
        x,y = stk.pop(0)
        
        for r in range(4):
          xx,yy=x+dx[r],y+dy[r]
          if yy<0 or xx<0 or W<=yy or H<=xx or meiro[xx][yy]=="#" or result[xx][yy]!=0:
            continue
          result[xx][yy]=result[x][y]+1
          stk.append([xx,yy])
      for l in range(H):
        for t in range(W):
          ans = max(ans,result[l][t])
print(ans-1)import itertools
H,W= [int(x) for x in input().split()]
meiro=[list(input())for _ in range(H)]
#print(meiro)
ans=0
dx = [1,0,-1,0]
dy=[0,1,0,-1]
for i in range(H):
  for j in range(W):
    result=[[0]*W for _ in range(H)]
    cnt=0
    #print(i,j)
    if meiro[i][j]=="#":
      continue
    elif meiro[i][j]==".":
      stk =[[i,j]]
      result[i][j]=1
      while stk:
        x,y = stk.pop(0)
        
        for r in range(4):
          xx,yy=x+dx[r],y+dy[r]
          if yy<0 or xx<0 or W<=yy or H<=xx or meiro[xx][yy]=="#" or result[xx][yy]!=0:
            continue
          result[xx][yy]=result[x][y]+1
          stk.append([xx,yy])
      for l in range(H):
        for t in range(W):
          ans = max(ans,result[l][t])
print(ans-1)

Fixed submission:
import itertools
H,W= [int(x) for x in input().split()]
meiro=[list(input())for _ in range(H)]
#print(meiro)
ans=0
dx = [1,0,-1,0]
dy=[0,1,0,-1]
for i in range(H):
  for j in range(W):
    result=[[0]*W for _ in range(H)]
    cnt=0
    #print(i,j)
    if meiro[i][j]=="#":
      continue
    elif meiro[i][j]==".":
      stk =[[i,j]]
      result[i][j]=1
      while stk:
        x,y = stk.pop(0)
        
        for r in range(4):
          xx,yy=x+dx[r],y+dy[r]
          if yy<0 or xx<0 or W<=yy or H<=xx or meiro[xx][yy]=="#" or result[xx][yy]!=0:
            continue
          result[xx][yy]=result[x][y]+1
          stk.append([xx,yy])
      for l in range(H):
        for t in range(W):
          ans = max(ans,result[l][t])
print(ans-1)
Buggy python submission (verdict: Runtime Error):
#import numpy as np
import sys
from scipy.sparse.csgraph import floyd_warshall,csgraph_from_dense
from scipy.sparse import csr_matrix
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
a,b =inputs()
M = int(input())
graph= [[10**9]*(N+1) for _ in range(N+1)]
E = {i:[] for i in range(N+1)}
for i in range(M):
  x,y = inputs()
  graph[x][y] = 1
  graph[y][x] = 1
  E[x].append(y)
  E[y].append(x)
G = csgraph_from_dense(graph, null_value=10**9)
dist_mat = floyd_warshall(graph,directed=False)
visited=[-1]*(N+1)
stk =[[a,-1,0]]
cnt=0
while stk:
  v,p,path =stk.pop()
  if v==b and path==dist_mat[a][b]:
    cnt+=1
    cnt%=(10**9+7)
  #visited[v]=1
  for i in E[v]:
    if i != p and path<dist_mat[a][b]:
      stk.append([i,v,path+1])
print(cnt%(10**9+7))


Fixed submission:
import numpy as np
import sys
from scipy.sparse.csgraph import floyd_warshall,csgraph_from_dense
from scipy.sparse import csr_matrix
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N,M,L = inputs()
ABC =[inputs() for _ in range(M)]
graph = [[10**13]*(N+1) for _ in range(N+1)]
for a,b,c in ABC:
    graph[a][b] = c
G = csgraph_from_dense(graph, null_value=10**13)
dist_mat = floyd_warshall(graph,directed=False)
graph2 = np.array([[10**13]*(N+1) for _ in range(N+1)])
np.fill_diagonal(graph2,0)
graph2[dist_mat<=L]=1
dist_mat2 = floyd_warshall(graph2,directed=False)
dist_mat2[dist_mat2==10**13]=0
Q = int(input())
for i in range(Q):
    s,t = inputs()
    print(int(dist_mat2[s,t])-1)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
S = list(input())
N = int(input())
ans = 0
flag=0
if S[0]==S[-2]:
  if S[-2]!=S[-3]:
    	flag = 1
  ans+=1
  S[-2]="aaaa"
for i in range(len(S)-2):
    if S[i]==S[i+1]:
        ans +=1
        S[i+1]="aa"
if flag==0:
	print(ans*N)
else:
  print(ans*N-1)

Fixed submission:
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
S = list(input())
N = int(input())
if len(S)==2:
  print(N//2)
  exit()
ans = 0
flag=0
if S[0]==S[-2]:
  cnt=1
  cntb=1
  for i in range(len(S)-2):
    if S[i]==S[i+1]:
      cnt+=1
    else:
      break
  for j in range(len(S)-2,0,-1):
    if S[j]==S[j-1]:
      cntb +=1
    else:
      break
  if cnt==cntb==len(S)-1 and cnt%2==1:
    S[0]="aaaaaa"
    ans+=1
    flag=2
  elif cntb%2!=0:
    if cnt%2==0:
      S[0]="aaa"
      ans+=1
    else:
      S[0]="aaa"
      ans+=1
      flag = 1
for i in range(len(S)-2):
    if S[i]==S[i+1]:
        ans +=1
        S[i+1]="aa"
if flag==0:
	print(ans*N)
elif flag==1:
  print(ans*(N-1)+ans-1)
else:
  print(ans*N-(N+2-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  join = ''.join
  def getCharNGram(n,s):
      charGram = (join(s[i:i+n]) for i in range(len(s)-n+1))
      return charGram
  N = int(input())
  S = input()
  ans = 0
  from collections import Counter
  for i in range(1,N//2+1):
      l = getCharNGram(i,S)
      am = Counter(l)
      for j in am.values():
        if j>1:
          ans =max(i,ans)
  print(ans)
main()

Fixed submission:
N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]
res = 0
for i in range(N-1,-1,-1):
  for j in range(N-1,i,-1):
    if S[i]==S[j]:
      dp[i][j]=max(dp[i+1][j+1]+1,dp[i][j])
    res = max(res,min(j-i,dp[i][j]))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  def getCharNGram(n,s):
      charGram = [''.join(s[i:i+n]) for i in range(len(s)-n+1)]
      return charGram
  N = int(input())
  S = input()
  ans = 0
  from collections import Counter
  for i in range(1,N//2+1):
      l = getCharNGram(i,S)
      am = Counter(l)
      for j in am.values():
        if j>1:
          ans =max(i,ans)
  print(ans)
main()

Fixed submission:
N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]
res = 0
for i in range(N-1,-1,-1):
  for j in range(N-1,i,-1):
    if S[i]==S[j]:
      dp[i][j]=max(dp[i+1][j+1]+1,dp[i][j])
    res = max(res,min(j-i,dp[i][j]))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]
res = 0
for i in range(N-1,-1,-1):
  for j in range(N-1,i,-1):
    if S[i]==S[j]:
      dp[i][j]=max(dp[i+1][j+1]+1,dp[i][j])
    res = max(res,min(j-1,dp[i][j]))
print(res)

Fixed submission:
N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]
res = 0
for i in range(N-1,-1,-1):
  for j in range(N-1,i,-1):
    if S[i]==S[j]:
      dp[i][j]=max(dp[i+1][j+1]+1,dp[i][j])
    res = max(res,min(j-i,dp[i][j]))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
def getCharNGram(n,s):
    charGram = [''.join(s[i:i+n]) for i in range(len(s)-n+1)]
    return charGram
N = int(input())
S = input()
ans = 0
from collections import Counter
for i in range(1,N//2+1):
    l = getCharNGram(i,S)
    am = Counter(l)
    for j in am.values():
      if j>1:
        ans = i
print(ans)

Fixed submission:
N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]
res = 0
for i in range(N-1,-1,-1):
  for j in range(N-1,i,-1):
    if S[i]==S[j]:
      dp[i][j]=max(dp[i+1][j+1]+1,dp[i][j])
    res = max(res,min(j-i,dp[i][j]))
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = [int(x) for x in input().split()]
ans = [0]*(N)
for i in range(1,N-2):
  ans[i] = min(B[i-1],B[i],B[i+1])
ans[0] = min(B[0],B[1])
ans[N-2] =  min(B[N-3],B[N-2])
ans[N-1] = B[N-2]
print(sum(ans))

Fixed submission:
N = int(input())
B = [int(x) for x in input().split()]
ans = [0]*(N)
if N==2:
  print(int(B[0])*2)
  exit()
for i in range(1,N-1):
  ans[i] = min(B[i-1],B[i])
ans[0] = B[0]
ans[N-1] = B[N-2]
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
A,B = list(map(int,input()))
print((A+B-1)//A)

Fixed submission:
A,B = list(map(int,input().split()))
ans = 1
i = 0
while ans < B:
  ans += A-1
  i +=1
print(i)
Buggy python submission (verdict: Runtime Error):
M, d = input().split()
d10 = int(d[0])
d1 = int(d[1])
M = int(M)
ans = 0
import sys
for j in range(2,d10+1):
  for i in range(2,10):
    if 10*j+i>d10*10+d1:
      print(ans)
      sys.exit()
    if M >=j*i:
      ans+=1

Fixed submission:
import sys
M, d = input().split()
if int(d)>=10:
  d10 = int(d[0])
  d1 = int(d[1])
else:
  print(0)
  sys.exit()
M = int(M)
ans = 0
for j in range(2,d10+1):
  for i in range(2,10):
    if 10*j+i>d10*10+d1:
      print(ans)
      sys.exit()
    if M >=j*i:
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int,input().split())
A= list((map(int, input().split())))
an = (K*(K+1))//2
a = ((K-1)*K)//2
au =0
al = 0
for i in range(N):
    for j in range(N):
        au += 1 if A[i]<A[j] and i>j else 0
        al += 1 if A[i]<A[j] and i<j else 0
print((au*an+al*a)%(10**9+7))

Fixed submission:

N, K = map(int,input().split())
A= list((map(int, input().split())))
an = (K*(K+1))//2
a = ((K-1)*K)//2
au =0
al = 0
for i in range(N):
  for j in range(N):
    au += 1 if A[i]<A[j] and i>j else 0
    al += 1 if A[i]<A[j] and i<j else 0
print((au*an+al*a)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
  s = list(input())
  s.sort()
  S.append(s)
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    ans += S[i]==S[j]
print(ans)

Fixed submission:
N = int(input())
S = []
for i in range(N):
  s = list(input())
  s.sort()
  S.append(s)
S.sort()
ans = 0
snt = 1
for i in range(N-1):
  if S[i]==S[i+1]:
    snt += 1
  else :
    ans += (snt*(snt-1))//2 if snt>1 else 0
    snt = 1
ans += (snt*(snt-1))//2 if snt>1 else 0
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C=list(mao(int,input().split()))
print(max(0,C-(A-B)))

Fixed submission:
A,B,C=list(map(int,input().split()))
print(max(0,C-(A-B)))
Buggy python submission (verdict: Runtime Error):
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13] += dp[i][k]
  else:
    a = int(S[i])
    for k in range(13):
      dp[i+1][(k*10+a)%13] += dp[i][k]
  for k in range(13):
    dp[i + 1][k] %= (10**9+7)
print(dp[len(S)][5])


Fixed submission:
A,B = list(map(int,input().split()))
if (A+B)%2==0:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13] += dp[i][k]
  else:
    a = int(S[i])
    for k in range(13):
      dp[i+1][(k*10+a)%13] += dp[i][k]
print(dp[len(S)][5]%(10**9+7))

Fixed submission:
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13] += dp[i][k]
  else:
    a = int(S[i])
    for k in range(13):
      dp[i+1][(k*10+a)%13] += dp[i][k]
  for k in range(13):
    dp[i + 1][k] %= (10**9+7)
print(dp[len(S)][5])

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    a = -1
  else:
    a = int(S[i])
  for j in range(10):
    if a!=-1 and a!=j:
      continue
    for k in range(13):
      dp[i+1][(k*10+j)%13] += dp[i][k]
print(dp[len(S)][5]%(10**9+7))

Fixed submission:
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13] += dp[i][k]
  else:
    a = int(S[i])
    for k in range(13):
      dp[i+1][(k*10+a)%13] += dp[i][k]
  for k in range(13):
    dp[i + 1][k] %= (10**9+7)
print(dp[len(S)][5])

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    a = -1
  else:
    a = int(S[i])
  for j in range(10):
    if a!=-1 and a!=j:
      continue
    for k in range(13):
      dp[i+1][(k*10+j)%13] += dp[i][k]
print(dp[len(S)][5]%(10**9+7))

Fixed submission:
S = list(input())
dp = [[0 for _ in range(13)] for _ in range(len(S)+1)]
dp[0][0]=1
#print(dp[15][5])
for i in range(len(S)):
  a = 0
  if S[i]=="?":
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13] += dp[i][k]
  else:
    a = int(S[i])
    for k in range(13):
      dp[i+1][(k*10+a)%13] += dp[i][k]
  for k in range(13):
    dp[i + 1][k] %= (10**9+7)
print(dp[len(S)][5])
Buggy python submission (verdict: Runtime Error):
#import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  c = sum(ans[s*i::i])
  if c%2!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")


Fixed submission:
#import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  b = [i*j for j in range(2,N//i+1)]
  for j in b:
    c +=ans[j]
  c = c%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = np.array([0]*(N+1))
an = []
for i in range(N,0,-1):
  b = [i*j for j in range(2,N//i+1)]
  #print(b)
  c = sum(ans[b])%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

Fixed submission:
#import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = [0]*(N+1)
an = []
for i in range(N,0,-1):
  c =0
  b = [i*j for j in range(2,N//i+1)]
  for j in b:
    c +=ans[j]
  c = c%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")
Buggy python submission (verdict: Runtime Error):
N,D = list(map(int,input().split()))
X = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    for d in range(D):
      a += (X[i][d]-X[j][d])**2
    for l in range(a):
      if l**2==a:
        ans+=1
print(ans)
    

Fixed submission:
N,D = list(map(int,input().split()))
X = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    a = 0
    for d in range(D):
      a += (X[i][d]-X[j][d])**2
    for l in range(a+1):
      if l**2==a:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
r = [0]*(N+1)
for i in range(N):
  r[i+1] = A[i]-r[i]
x = r[N]
r[1::2] = r[1::,2]-x
r[0::2] = r[1::,2]+x
r = list(map(str,r))
print(" ".join(r))


Fixed submission:
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
r = np.array([0]*(N+1))
for i in range(N):
  r[i+1] = A[i]-r[i]
x = r[N]
#print(r)
r[1::2] = r[1::2]*2-x
r[0::2] = r[0::2]*2+x
r = r[:N]
r = list(map(str,r))
print(" ".join(r))
Buggy python submission (verdict: Runtime Error):
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  a = math.factorial(N-K+1)
  b = math.factorial(i)
  c = math.factorial(N-K+1-i)
  a = a//b
  a = a//c%inf
  ans = kumi*a
  print(int(ans%inf))
  
  

Fixed submission:
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  a = math.factorial(N-K+1)
  b = math.factorial(i)
  if (N-K+1-i)<0:
    print(0)
    continue
  c = math.factorial(N-K+1-i)
  a = a//b
  a = a//c%inf
  ans = kumi*a
  print(int(ans%inf))

Buggy python submission (verdict: Runtime Error):
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  ans = kumi*math.factorial(N-K+1)//(math.factorial(i)*math.factorial(N-K+1-i))
  print(int(ans%inf))
  
  

Fixed submission:
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  a = math.factorial(N-K+1)
  b = math.factorial(i)
  if (N-K+1-i)<0:
    print(0)
    continue
  c = math.factorial(N-K+1-i)
  a = a//b
  a = a//c%inf
  ans = kumi*a
  print(int(ans%inf))

Buggy python submission (verdict: Runtime Error):
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))
  ans = kumi*math.factorial(N-K+1)//(math.factorial(i)*math.factorial(N-K+1-i))
  print(int(ans%inf))
  

Fixed submission:
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  a = math.factorial(N-K+1)
  b = math.factorial(i)
  if (N-K+1-i)<0:
    print(0)
    continue
  c = math.factorial(N-K+1-i)
  a = a//b
  a = a//c%inf
  ans = kumi*a
  print(int(ans%inf))
Buggy python submission (verdict: Runtime Error):
N,L = list(map(int,input().split()))
A = list(range(L,L+N))
ans = sum(A)
if abs(A[0])>abs(A[N]):
  print(ans-A[N])
else:
  print(ans-A[0])

Fixed submission:
N,L = list(map(int,input().split()))
A = list(range(L,L+N))
ans = sum(A)
mi = min(list(map(abs,A)))
if abs(A[0])==mi:
  print(ans-A[0])
elif abs(A[N-1])==mi:
  print(ans-A[N-1])
else:
  print(ans-mi)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n= int(input())
xy=[[int(x) for x in input().split()] for _ in range(n)]
gr = [[[0,0]for _ in range(n)]for _ in range(n)]
for i in range(n):
  a,b = xy[i]
  for j in range(n):
    gr[i][j] = [xy[j][0]-a,xy[j][1]-b]
gr1 = []
for i in gr:
  for j in i:
    gr1.append(tuple(j))
#print(gr1)
c = Counter(gr1)
l,f = c.most_common()[0]
if l!=(0,0):
  print(n-f)
else:
  l,f = c.most_common()[1]
  print(n-f)

Fixed submission:
from collections import Counter
n= int(input())
if n==1:
  print(1)
  exit()
xy=[[int(x) for x in input().split()] for _ in range(n)]
gr = [[[0,0]for _ in range(n)]for _ in range(n)]
for i in range(n):
  a,b = xy[i]
  for j in range(n):
    gr[i][j] = [xy[j][0]-a,xy[j][1]-b]
gr1 = []
for i in gr:
  for j in i:
    gr1.append(tuple(j))
#print(gr1)
c = Counter(gr1)
l,f = c.most_common()[0]
if l!=(0,0):
  print(n-f)
else:
  l,f = c.most_common()[1]
  print(n-f)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n= int(input())
xy=[[int(x) for x in input().split()] for _ in range(n)]
gr = [[[0,0]for _ in range(n)]for _ in range(n)]
for i in range(n):
  a,b = xy[i]
  for j in range(n):
    gr[i][j] = [abs(xy[j][0]-a),abs(xy[j][1]-b)]
gr1 = []
for i in gr:
  for j in i:
    gr1.append(tuple(j))
#print(gr1)
c = Counter(gr1)
l,f = c.most_common()[0]
if l!=(0,0):
  print(n-f//2)
else:
  l,f = c.most_common()[1]
  print(n-f//2)

Fixed submission:
from collections import Counter
n= int(input())
if n==1:
  print(1)
  exit()
xy=[[int(x) for x in input().split()] for _ in range(n)]
gr = [[[0,0]for _ in range(n)]for _ in range(n)]
for i in range(n):
  a,b = xy[i]
  for j in range(n):
    gr[i][j] = [xy[j][0]-a,xy[j][1]-b]
gr1 = []
for i in gr:
  for j in i:
    gr1.append(tuple(j))
#print(gr1)
c = Counter(gr1)
l,f = c.most_common()[0]
if l!=(0,0):
  print(n-f)
else:
  l,f = c.most_common()[1]
  print(n-f)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(int,input().split()))
S.sorted()
a = N//2
su = 0
um = 0
for i in range(N):
  if i<a:
    su +=S[i]
  else:
    um +=S[i]
print(abs(su-um))

Fixed submission:
N = int(input())
S = list(map(int,input().split()))
su = [0]*(N+1)
um = [0]*(N+1)
ans = 10000000
for i in range(N):
    su[i+1] = su[i]+S[i]
    um[i+1] = um[i]+S[N-1-i]

for i in range(N+1):
  ans = min(abs(su[N-i]-um[i]),ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
am = [int(input()) for i in range(M)]
dp = [0]*(N+1)
if not 1 in am:
	dp[1]=1
if not 2 in am:
	dp[2]=1
for i in range(1,N):
    if not (i+1) in am:
        dp[i+1] += dp[i]
    if not (i+2) in am:
        if i+2<=N:
            dp[i+2] += dp[i]
print(dp[N]%(10**9+7))

Fixed submission:
N, M = map(int, input().split())
am = [int(input()) for i in range(M)]
safe = [True]*(N+1)
for i in am:
    safe[i] = False
dp = [0]*(N+1)
dp[0]=1
for i in range(N):
    if safe[i+1]:
        dp[i+1] += dp[i]
    if i+2<=N:
        if safe[i+2]:
            dp[i+2] += dp[i]
print(dp[N]%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
from itertools import accumulate
def main():
    input = sys.stdin.readline
    def inputs():
        return [int(x) for x in input().split()]
    A1= tuple(input())
    dp = [[0]*2 for _ in range(len(A1)+1)]
    dp[0][0]=1
    for i in range(len(A1)):
        if A1[i]=="1":
            dp[i+1][0]=max(dp[i+1][0],dp[i][0]*2)
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]*3+dp[i][0])
        else:
            dp[i+1][0]=max(dp[i+1][0],dp[i][0])
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]*3)
    #print(dp[len(A1)][0]+dp[len(A1)][1]-len(A1)**2)
    print((dp[len(A1)-1][0]+dp[len(A1)-1][1])%(10**9+7))
main()

Fixed submission:
import sys
import itertools
from itertools import accumulate
def main():
    input = sys.stdin.readline
    def inputs():
        return [int(x) for x in input().split()]
    A1= tuple(input())
    dp = [[0]*2 for _ in range(len(A1)+1)]
    dp[0][0]=1
    for i in range(len(A1)):
        if A1[i]=="1":
            dp[i+1][0]=max(dp[i+1][0],dp[i][0]*2)%(10**9+7)
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]*3+dp[i][0])%(10**9+7)
        else:
            dp[i+1][0]=max(dp[i+1][0],dp[i][0])%(10**9+7)
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]*3)%(10**9+7)
    #print(dp[len(A1)][0]+dp[len(A1)][1]-len(A1)**2)
    print((dp[len(A1)-1][0]+dp[len(A1)-1][1])%(10**9+7))
main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
from itertools import accumulate
def main():
    input = sys.stdin.readline
    def inputs():
        return [int(x) for x in input().split()]
    A1= list(input())
    dp = [[0]*2 for _ in range(len(A1)+1)]
    dp[0][0]=1
    for i in range(len(A1)):
        if A1[i]=="1":
            dp[i+1][0]=max(dp[i+1][0],dp[i][0]*2)
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]*3+dp[i][0])
        else:
            dp[i+1][0]=max(dp[i+1][0],dp[i][0])
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]*3)
    #print(dp[len(A1)][0]+dp[len(A1)][1]-len(A1)**2)
    print((dp[len(A1)-1][0]+dp[len(A1)-1][1])%(10**9+7))
main()

Fixed submission:
import sys
import itertools
from itertools import accumulate
def main():
    input = sys.stdin.readline
    def inputs():
        return [int(x) for x in input().split()]
    A1= tuple(input())
    dp = [[0]*2 for _ in range(len(A1)+1)]
    dp[0][0]=1
    for i in range(len(A1)):
        if A1[i]=="1":
            dp[i+1][0]=max(dp[i+1][0],dp[i][0]*2)%(10**9+7)
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]*3+dp[i][0])%(10**9+7)
        else:
            dp[i+1][0]=max(dp[i+1][0],dp[i][0])%(10**9+7)
            dp[i+1][1]=max(dp[i+1][1],dp[i][1]*3)%(10**9+7)
    #print(dp[len(A1)][0]+dp[len(A1)][1]-len(A1)**2)
    print((dp[len(A1)-1][0]+dp[len(A1)-1][1])%(10**9+7))
main()