Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02684 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**9)

def dfs(num,lis,count,target):
    visited[num]=count
    n_city=A[num]
    if visited[n_city]!=-1:
        lis.append(num)
        if target<=count:
              print(lis[target]+1)
        else:
            rep=len(lis)-visited[n_city]
            target-=visited[n_city]
            amari=target%rep
            temp=lis[visited[n_city]:]
            print(temp[amari]+1)
        exit()
    else:
        lis.append(num)
        dfs(n_city,lis,count+1,target)
    

N,K=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x:x-1,A))

visited=[-1]*N

dfs(0,[],0,K)

Buggy submission (verdict: Runtime Error):
def dfs(num,lis,count,target):
    visited[num]=count
    n_city=A[num]
    if visited[n_city]!=-1:
        lis.append(num)
        if target<=count:
              print(lis[target]+1)
        else:
            rep=len(lis)-visited[n_city]
            target-=visited[n_city]
            amari=target%rep
            temp=lis[visited[n_city]:]
            print(temp[amari]+1)
        exit()
    else:
        dfs(n_city,lis+[num],count+1,target)
    

N,K=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x:x-1,A))

visited=[-1]*N

dfs(0,[],0,K)
Problem p02716 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())

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

if N==2:
    print(max(0,A[0],A[1]))
    exit()
if N==3:
    print(max(0,A[0],A[1],A[2]))
    exit()

dp=[[-10**18 for i in range(N)] for j in range(3)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]

for n in range(3):
    for index in range(N):
        if dp[n][index]!=-1:
            if n!=2 and index+3<N:
                dp[n+1][index+3]=max(dp[n+1][index+3],dp[n][index]+A[index+3])
            if n==0 and index+4<N:
                dp[n+2][index+4]=max(dp[n+2][index+4],dp[n][index]+A[index+4])
            if index+2<N:
                dp[n][index+2]=max(dp[n][index+2],dp[n][index]+A[index+2])

a=(dp[0][-1])
b=(dp[1][-1])
c=(dp[2][-1])

print(max(a,b,c))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N=int(input())

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

if N==2:
  print(max(0,A[0],A[1]))

dp=[[-10**18 for i in range(N)] for j in range(3)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]

for n in range(3):
    for index in range(N):
        if dp[n][index]!=-1:
            if n!=2 and index+3<N:
                dp[n+1][index+3]=max(dp[n+1][index+3],dp[n][index]+A[index+3])
            if n==0 and index+4<N:
                dp[n+2][index+4]=max(dp[n+2][index+4],dp[n][index]+A[index+4])
            if index+2<N:
                dp[n][index+2]=max(dp[n][index+2],dp[n][index]+A[index+2])

a=(dp[0][-1])
b=(dp[1][-1])
c=(dp[2][-1])

print(max(a,b,c))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N=int(input())

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

dp=[[-10**9 for i in range(N)] for j in range(3)]
dp[0][0]=A[0]
dp[1][1]=A[1]
dp[2][2]=A[2]

for n in range(3):
    for index in range(N):
        if dp[n][index]!=-1:
            if n!=2 and index+3<N:
                dp[n+1][index+3]=max(dp[n+1][index+3],dp[n][index]+A[index+3])
            if n==0 and index+4<N:
                dp[n+2][index+4]=max(dp[n+2][index+4],dp[n][index]+A[index+4])
            if index+2<N:
                dp[n][index+2]=max(dp[n][index+2],dp[n][index]+A[index+2])

a=(dp[0][-1])
b=(dp[1][-1])
c=(dp[2][-1])

print(max(a,b,c))
Problem p02717 (python)

Fixed submission:
# coding: utf-8
# Your code here!
X,Y,Z=map(int,input().split())

print(Z,X,Y)

Buggy submission (verdict: Runtime Error):
%%time
import scipy.stats
from sklearn.datasets import load_breast_cancer
from sklearn.svm import LinearSVC
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import RandomizedSearchCV
from sklearn.model_selection import train_test_split
from sklearn.metrics import f1_score

import pandas as pd

#乳癌データの読み込み
df=pd.read_csv("ダミーデータ.csv",index_col=0)
X=df.iloc[:, 1:].values.tolist()
y=df["y"].values

print(X)

#条件設定
max_score = 0
SearchMethod = 0
LSVC_grid = {LinearSVC(): {"C": [10 ** i for i in range(-5, 6)],
                           "multi_class": ["ovr", "crammer_singer"],
                           "class_weight": ["balanced"],
                           "random_state": [i for i in range(0, 101)]}}
LSVC_random = {LinearSVC(): {"C": scipy.stats.uniform(0.00001, 1000),
                             "multi_class": ["ovr", "crammer_singer"],
                             "class_weight": ["balanced"],
                             "random_state": scipy.stats.randint(0, 100)}}

#トレーニングデータ、テストデータの分離
train_X, test_X, train_y, test_y = train_test_split(X, y, test_size=0.2, random_state=0)

#グリッドサーチ
for model, param in LSVC_grid.items():
    clf = GridSearchCV(model, param)
    clf.fit(train_X, train_y)
    pred_y = clf.predict(test_X)
    score = f1_score(test_y, pred_y, average="micro")

    if max_score < score:
        max_score = score
        best_param = clf.best_params_
        best_model = model.__class__.__name__

#ランダムサーチ
for model, param in LSVC_random.items():
    clf =RandomizedSearchCV(model, param)
    clf.fit(train_X, train_y)
    pred_y = clf.predict(test_X)
    score = f1_score(test_y, pred_y, average="micro")

    if max_score < score:
        SearchMethod = 1
        max_score = score
        best_param = clf.best_params_
        best_model = model.__class__.__name__

if SearchMethod == 0:
    print("サーチ方法:グリッドサーチ")
else:
    print("サーチ方法:ランダムサーチ")
print("ベストスコア:{}".format(max_score))
print("モデル:{}".format(best_model))
print("パラメーター:{}".format(best_param))

#ハイパーパラメータを調整しない場合との比較
model = LinearSVC()
model.fit(train_X, train_y)
score = model.score(test_X, test_y)
print("")
print("デフォルトスコア:", score)
Problem p02814 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import fractions

N,M=map(int,input().split())
A=list(map(int,input().split()))

have2=[0]*len(A)

for index,item in enumerate(A):
    while item%2==0:
        item/=2
        have2[index]+=1

if len(list(set(have2)))!=1:
    print(0)
    exit()

f=0
f2=1
for item in A:
    f=fractions.gcd(f2,item)
    f2=f2*item//f
if M>=f2//2:
    M-=f2//2
    print(max(M//f2+1,0))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
from math import gcd
 
N,M=map(int,input().split())

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

if N==1:
    print(0)
    exit()

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//gcd(A[i],A[i+1])

#print(A[-1])
if A[-1]%2==1 or (A[-1]//2)%2==0:
    print(0)
else:
    print((M-A[-1]//2)//A[-1]+1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
from math import gcd
 
N,M=map(int,input().split())

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


for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//gcd(A[i],A[i+1])

#print(A[-1])
if A[-1]%2==1 or (A[-1]//2)%2==0:
    print(0)
else:
    print((M-A[-1]//2)//A[-1]+1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import fractions

N,M=map(int,input().split())

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

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//(fractions.gcd(A[i],A[i+1]))
    B=[A[-1]//2]


if M<B[-1]:
    print(0)
else:
    print((M-B[-1])//A[-1]+1)
Problem p02866 (python)

Fixed submission:
N=int(input())
D=list(map(int,input().split()))
layer=[0]*N

mx=0
for item in D:
    layer[item]+=1
    mx=max(mx,item)

if layer[0]!=1 or D[0]!=0:
    print(0)
    exit()

ans=1
for i in range(mx):
    ans*=(layer[i]**layer[i+1])

print(ans%998244353)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N=int(input())
l=list(map(int,input().split()))

if temp[0]==0:
    print(0)
    exit()

ans=1
for i in range(2,len(temp)):
    #print(ans)
    ans=ans*temp[i-1]**temp[i]
print(ans)
Problem p02882 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import math

a,b,x=map(int,input().split())

if x==a**2*b:
    print(0)
    exit()

if x<=(a**2)*b/2:
    t=a-(a-(2*x)/a/b)
    ans=math.atan(b/t)
    ans=math.degrees(ans)
    
    print(ans)
else:
    
    t=2*(b-x/(a**2))
    ans=math.atan(a/t)
    ans=math.degrees(ans)
    
    print(90-ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math

a,b,x=map(int,input().split())

if x<=(a**2)*b/2:
    t=a-(a-(2*x)/a/b)
    ans=math.atan(b/t)
    ans=math.degrees(ans)
    
    print(ans)
else:
    
    t=2*(b-x/(a**2))
    ans=math.atan(a/t)
    ans=math.degrees(ans)
    
    print(90-ans)
Problem p02900 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import fractions

A,B=map(int,input().split())

def yaku(num):
    temp=[]
    for i in range(2,-int(-num**0.5//1)+1):
        if num%i==0:
            temp.append(i)
            temp.append(num//i)
    temp=list(set(temp))
    if num!=2:
        temp.append(num)
    temp.sort()
    return temp

koyaku=fractions.gcd(A,B)

cand=yaku(min(A,B))
#print(cand)

if cand[0]==1:
    print(1)
    exit()

count=0

for i in cand:
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

if A*B==2:
    print(1)
    exit()

A,B=map(int,input().split())
s=[]
ans=[]
count=0
for i in range(1,-int(-A**0.5//1)+1):#因数分解
    if A%i==0:
        s.append(i)
        s.append(A//i)

for i in range(1,-int(-B**0.5//1)+1):#因数分解
    if B%i==0:
        if i in s:
            ans.append(i)
        elif B//i in s:   
            ans.append(B//i)        

ans.sort()

for i in range(1,len(ans)):
    for j in range(1,i):
        if ans[i]%ans[j]==0:
            count-=1
            break
    count+=1

print(count+1)
Problem p02901 (python)

Fixed submission:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

dp=[10**9]*2**N

dp[0]=0

for _ in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    cl=["0"]*N
    for item in c:
        cl[item-1]="1"
    plus=int(str("".join(cl)),2)
    for i in range(len(dp))[::-1]:
        if dp[i]!=10**9:
            #print(i,i|plus)
            dp[i|plus]=min(dp[i|plus],dp[i]+a)
if dp[-1]!=10**9:
    print(dp[-1])
else:
    print(-1)

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

def saiki(m,box,ans):
    if m==M:
        if sum(box)==len(box):
            return ans
        else:
            return 10**18
    else:
        open=box[:]
        for item in l[m][1]:
            open[item]=1
        return min(saiki(m+1,box,ans),saiki(m+1,open,ans+l[m][0]))


l=[]
for _ in range(M):
    a,b=map(int,input().split())
    temp=list(map(lambda x: int(x)-1,input().split()))
    l.append([a,temp])

ans=saiki(0,[0]*N,0)

print(ans if ans!=10**18 else -1)
Problem p02903 (python)

Fixed submission:
# coding: utf-8
# Your code here!
H,W,A,B=map(int,input().split())

ans=[]
for b in range(B):
    ans.append(["1"]*A+["0"]*(W-A))
for b in range(H-B):
    ans.append(["0"]*A+["1"]*(W-A))

for item in ans:
    print("".join(item))

Buggy submission (verdict: Runtime Error):
H,W,A,B=map(int,input().split())

if W/A==H/B or W/A==0 or H/B==0:
    for h in range(H):
        S=[0]*W
        for i in range(A):
            S[W*h//H-i]=1
        print(S)
else:
    print(-1)
Problem p02939 (python)

Fixed submission:
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1
#print(S[::-1])
if len(S)==3:
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if S[1]==S[0]:#aabbaが出来ればよい
        print(count+1)
    else:
        print(count+2)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1

if len(S)==3:
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if pre[-1]==S[1] or S[1]==S[0]:
        print(S[10])
        print(count+1)
    else:
        print(count+2)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1

if len(S)==3:
    print(S[10])
    if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
        print(count+2)
    else:
        print(count+3)
else:
    if pre[-1]==S[1] or S[1]==S[0]:
        print(count+1)
    else:
        print(count+2)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
S=list(input())[::-1]

count=0
temp=[]
pre=[]
while len(S)>3:
    temp.append(S.pop(-1))
    if temp==pre:
        temp.append(S.pop(-1))
    pre.clear()
    pre+=temp
    temp.clear()
    count+=1
if pre[-1]==S[2] or S[2]==S[1] or S[1]==S[0]:
    print(count+2)
else:
    print(count+3)
Problem p02953 (python)

Fixed submission:
# coding: utf-8
# Your code here!

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

high=l[0]
for i in range(N-1):
    if l[i+1]-l[i]<(-1):
        print("No")
        exit()
    high=max(high,l[i+1])
    if l[i+1]<(high-1):
        print("No")
        exit()
        
print("Yes")

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

if N==1:
    print("Yes")
    exit()

if N==2 and l[1]-l[0]<(-1):
    print("No")
    exit()
    

for i in range(N-2):
    if l[i+2]-l[i+1]<(0) and l[i+i]-l[i]<(0):
        print("No")
        exit()
    elif l[i+i]-l[i]<(-1):
        print("No")
        exit()

print("Yes")

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

if N==2 and l[1]-l[0]<(-1):
    print("No")
    exit()
    

for i in range(N-2):
    if l[i+2]-l[i+1]<(0) and l[i+i]-l[i]<(0):
        print("No")
        exit()
    elif l[i+i]-l[i]<(-1):
        print("No")
        exit()

print("Yes")
Problem p02960 (python)

Fixed submission:
S=list(input())
N=len(S)

dp=[[0 for i in range(13)] for j in range(N+1)]
dp[0][0]=1

for i in range(N):
    if S[i]=="?":
        temp=10**((N-i-1)%6)
        for j in range(10):
            for k in range(13):
                dp[i+1][(k+j*temp)%13]+=dp[i][k]
                dp[i+1][(k+j*temp)%13]%=10**9+7
                    
    else:
        temp=int(S[i])*10**((N-i-1)%6)
        for k in range(13):
            dp[i+1][(k+temp)%13]+=dp[i][k]
            dp[i+1][(k+temp)%13]%=10**9+7

print(dp[-1][5])

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def saiki(num,lis):
    if num==6:
        temp=0
        for i in range(6):
            temp+=lis[i]*10**(5-i)
        if (temp+amari)%13==5:
            cand.append(lis)
        return 0
    else:
        for i in range(10):
            saiki(num+1,lis+[i])
            

S=list(input())
N=len(S)

num=[0]*6#左から大きい
que=[0]*6

for i in range(N):
    if S[i]=="?":
        que[i%6]+=1
    else:
        num[i%6]+=int(S[i])

for i in range(6):
    num[i]%=10
amari=0
for i in range(6):
    amari+=(num[i]*10**(5-i))%13
amari%=13

cand=[]
saiki(0,[])

#print(amari)
#print(cand)
"""
ans=0
for item in cand:
    temp=1
    for i in range(6):
        if que[i]==0 and item[i]!=0:
            temp=0
            break
        else:
            for j in range(que[i]-1):
                temp*=(item[i]+que[i]-j-1)
    ans+=temp
    """
    """
    if temp!=0:
        print(item)
        print(ans)
    """
    """
print(ans%(10**9+7))
            
"""
Problem p02975 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
B=list(set(A))

if len(B)==3:
    if B[0]^B[1]==B[2]:
        if A.count(B[0])==A.count(B[1]) and A.count(B[1])==A.count(B[2]):
            print("Yes")
            exit()
elif len(B)==2:
    if 2*A.count(B[0])==A.count(B[1]):
        print("Yes")
        exit()
elif len(B)==1:
    if B[0]==0:
        print("Yes")
        exit()

print("No")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

N=int(input())

l=list(map(int,input().split()))
l.sort()

init=l.pop(-1)

left=init
center=0

ans=[left]

def find(left):
    if len(l)==1:
        ans.append(l.pop(0))
        pass
    elif len(l)==0:
        pass
        
    else:
        right=l.pop(-1)
        for i in range(len(l)):
            if l[i]==left^right:
                center=l.pop(i)
                ans.append(center)
                ans.append(right)
                find(right)
                break
            else:
                break
            
find(left)

if len(ans)==N:
    if ans[0]==ans[1]^ans[-1] and ans[-1]==ans[0]^ans[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

N=int(input())

l=list(map(int,input().split()))
l.sort()

init=l.pop(-1)

left=init
center=0
judge=False

ans=[left]

def find(left):
    if len(l)<2:
        if len(l)==1:
            ans.append(l.pop(0))
        else:
            pass
        
    else:
        right=l.pop(-1)
        for i in range(len(l)):
            if l[i]==left^right:
                center=l.pop(i)
                ans.append(center)
                ans.append(right)
                find(right)
            else:
                break
            
find(left)

if len(ans)==N:
    if ans[0]==ans[1]^ans[-1]:
        print("Yes")
else:
    print("No")
Problem p02983 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import heapq
 
L,R=map(int,input().split())
 
ans=2018*2017
if (R-L)>=2018:
    print("0")
else:
    l=list(range(L,R+1))
    for i in range(len(l)):
        for j in range(i+1,len(l)):
            #print(l[i],l[j],(l[i]*l[j])%2019)
            ans=min(ans,(l[i]*l[j])%2019)
            

    print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import heapq

L,R=map(int,input().split())

l=list(range(L,R+1))
q=[]

for item in l:
   heapq.heappush(q,item%2019)

print(heapq.heappop(q)*heapq.heappop(q))
Problem p02985 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**9)

def dfs(num):
    temp=K-len(way[num])
    
    for w in way[num]:
        if visited[w]==-1:
            visited[w]=temp
            temp+=1
            dfs(w)
    
    return 

N,K=map(int,input().split())

mod=10**9+7

visited=[-1]*N
way=[[] for i in range(N)]

for _ in range(N-1):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
    
color=[]
visited[0]=K
dfs(0)

#print(way)
#print(visited)
ans=1
for item in visited:
    ans*=item
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def dfs(num):
    temp=K-len(way[num])
    
    for w in way[num]:
        if visited[w]==0:
            visited[w]=temp
            temp+=1
            dfs(w)
    
    return 

N,K=map(int,input().split())

mod=10**9+7

visited=[0]*N
way=[[] for i in range(N)]

for _ in range(N-1):
    a,b=map(int,input().split())
    way[a-1].append(b-1)
    way[b-1].append(a-1)
    
color=[]
visited[0]=K
dfs(0)

#print(visited)
ans=1
for item in visited:
    ans*=item
    ans%=mod
print(ans)
Problem p02995 (python)

Fixed submission:
# coding: utf-8
# Your code here!
A,B,C,D=map(int,input().split())
A-=1

def gcd(a,b):
    ans=1
    for i in range(1,int(min(a,b)**0.5)+1):
        
        if a%i==0 and b%i==0:
            ans=max(ans,i)
        temp=min(a,b)//i
        if a%temp==0 and b%temp==0:
            ans=max(ans,temp)
    return ans

num1=A-A//C-A//D+(A//(C*D//gcd(C, D)))
num2=B-B//C-B//D+(B//(C*D//gcd(C, D)))

print(num2-num1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import math

A,B,C,D=map(int,input().split())
A-=1
print(A)
num1=A-A//C-A//D+(A//(C*D//math.gcd(C, D)))
num2=B-B//C-B//D+(B//(C*D//math.gcd(C, D)))

print(num1)
print(num2)

print(num2-num1)
Problem p03000 (python)

Fixed submission:
# coding: utf-8
# Your code here!
n,x=map(int,input().split())
A=list(map(int,input().split()))

for i in range(n):
    if x-A[i]<0:
        print(i+1)
        exit()
    else:
        x-=A[i]

print(n+1)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n,x=map(int,input().split())
A=list(map(int,input().split()))

count=0
sm=0
while sm<=x:
    count+=1
    sm+=A[count-1]

print(count)
Problem p03006 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N=int(input())

l=[]
for i in range(N):
    l.append(list(map(int,input().split())))

dis=[[0]*(N) for i in range(N-1)]
#print(dis)

for i in range(N-1):
    for j in range(i+1,N):
        if l[i][0]-l[j][0]>0:
            dis[i][j]=[(l[i][0]-l[j][0]),(l[i][1]-l[j][1])]
        elif l[i][0]-l[j][0]<0:
            dis[i][j]=[-(l[i][0]-l[j][0]),-(l[i][1]-l[j][1])]
        else:
            dis[i][j]=[(l[i][0]-l[j][0]),abs(l[i][1]-l[j][1])]

temp=0
for i in range(N-1):
    for item in dis[i]:
        if item!=0:
            temp=max(sum(x.count(item) for x in dis),temp)

#print(l)
#print(dis)
print(N-temp)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

for i in range(N):
    A[i]-=(i+1)

a=2*N
b=sum([A[i]*2 for i in range(N)])

x1=b//a
x2=-(-b//a)
x0=min(x1,x2)-1
x3=max(x1,x2)+1
X=[x0,x1,x2,x3]

ans=10**18
def count(num):
    temp=0
    for i in range(N):
        temp+=abs(A[i]-num)
    return temp

for x in X:
    ans=min(count(x),ans)

print(ans)
Problem p03014 (python)

Fixed submission:
# coding: utf-8
# Your code here!
H,W=map(int,input().split())
S=[]
ans=0

for _ in range(H):
    S.append(list(input()))

l=[[0]*W for _ in range(H)]

for h in range(H):
    count=0
    start=0
    for i in range(W):
        if S[h][i]=="#":
            count=0
            start=i+1
        else:
            count+=1
            l[h][i]+=count

for h in range(H):
    count=0
    start=W-1
    for i in range(W)[::-1]:
        if S[h][i]=="#":
            count=0
            start=i
        else:
            count+=1
            l[h][i]+=count

for w in range(W):
    count=0
    start=0
    for i in range(H):
        if S[i][w]=="#":
            count=0
            start=i+1
        else:
            count+=1
            l[i][w]+=count

for w in range(W):
    count=0
    start=H-1
    for i in range(H)[::-1]:
        if S[i][w]=="#":
            count=0
            start=i
        else:
            count+=1
            l[i][w]+=count
            ans=max(ans,l[i][w])

print(ans-3)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def up(w,h,count):
    if h==-1:
        return count-1
    elif S[h][w]=="#":
        return count-1
    else:
        count=up(w,h-1,count+1)
    return count

def down(w,h,count):
    if h==H:
        return count-1
    elif S[h][w]=="#":
        return count-1
    else:
        count=down(w,h+1,count+1)
    return count
        
def right(w,h,count):
    if w==W:
        return count-1
    elif S[h][w]=="#":
        return count-1
    else:
        count=right(w+1,h,count+1)
    return count

def left(w,h,count):
    if w==-1:
        return count-1
    elif S[h][w]=="#":
        return count-1
    else:
        count=left(w-1,h,count+1)
    return count

H,W=map(int,input().split())
S=[]

for _ in range(H):
    S.append(list(input()))

ans=0
for h in range(H):
    for w in range(W):
        if S[h][w]=="#":
            continue
        ans=max((up(w,h,0)+down(w,h,0)+right(w,h,0)+left(w,h,0)),ans)
        
        """
        if ans==(up(w,h,0)+down(w,h,0)+right(w,h,0)+left(w,h,0)):
            print(h,w)
            print(up(w,h,0),down(w,h,0),right(w,h,0),left(w,h,0))
        """
print(ans+1)