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

Fixed submission:
from collections import deque
    
N,K=map(int,input().strip().split())
x=list(map(int,input().strip().split()))
inf=10**9
    
l=inf
dp=deque(x[N-K:N])
i=0
while True:
    if dp[0]>=0:
        tmp=dp[K-1]
    elif dp[K-1]<=0:
        tmp=-dp[0]
    else:
        if abs(dp[K-1])>=abs(dp[0]):
            tmp=abs(dp[0])*2+abs(dp[K-1])
        else:
            tmp=abs(dp[K-1])*2+abs(dp[0])
    l=min(l,tmp)
    i+=1
    if N-K-i<0:
        break
    else:
        dp.appendleft(x[N-K-i])
        dp.pop()
print(l)

Buggy submission (verdict: Runtime Error):
from collections import deque

N,K=map(int,input().strip().split())
x=list(map(int,input().strip().split()))
inf=10*8

l=inf
dp=x[N-K:N-1]
i=0
while N-K-i>=0:
    if dp[0]>=0:
        tmp=dp[K-1]
    elif dp[K-1]<=0:
        tmp=-dp[0]
    else:
        if dp[K-1]>=dp[0]:
            tmp=dp[0]*2+dp[K-1]
        else:
            tmp=dp[K-1]*2+dp[0]
    l=min(l,tmp)
    i+=1
    if N-K-i<0:
        break
    else:
        dp.appendleft(x[N-K-i])
        dp.pop()
print(l)
Problem p03282 (python)

Fixed submission:
from collections import deque
S=deque(list(map(int,list(input()))))
K=int(input())
i=0
while S:
    if S[0]==1:
        S.popleft()
        i+=1
    else:
        break
result=1 if K<=i else S[0]
print(result)

Buggy submission (verdict: Runtime Error):
from collections import deque
S=deque(list(map(int,list(input()))))
K=int(input())
i=0
while True:
    if S[0]==1:
        S.popleft()
        i+=1
    else:
        break
result=1 if K<=i else S[0]
print(result)
Problem p03353 (python)

Fixed submission:
def main2():
    S=list(input())
    K=int(input())
    N=len(S)

    P=sorted(S)
    l=[]
    a=[]
    k=0
    while len(l)<=5 and k<N:
        if P[k] not in a:
            a.append(P[k])
            for n in range(N):
                if S[n]==P[k]:
                    for i in range(1,6):
                        if n+i<=N:
                            tmp="".join(S[n:n+i])
                            if tmp not in l:
                                l.append(tmp)
        k+=1
    l.sort()
    print(l[K-1])

if __name__=="__main__":
    main2()

Buggy submission (verdict: Runtime Error):
def main2():
    S=list(input())
    K=int(input())
    N=len(S)

    P=sorted(S)
    l=[]
    k=0
    while len(l)<=5:
        for n in range(N):
            if S[n]==P[k]:
                for i in range(1,6):
                    if n+i<N-1:
                        tmp="".join(S[n:n+i])
                        if tmp not in l:
                            l.append(tmp)
        k+=1
    l.sort()
    print(l[K-1])

if __name__=="__main__":
    main2()
Problem p03495 (python)

Fixed submission:
N,K=map(int,input().strip().split())
A=list(map(int,input().strip().split()))

d={}

for n in range(N):
    if d.get(A[n])==None:
        d[A[n]]=1
    else:
        d[A[n]]+=1

dn=sorted(d.items(),key=lambda x:x[1])

if K>=len(d):
    print(0)
else:
    cnt=0
    ans=0
    for n in range(len(dn)):
        ans+=dn[n][1]
        cnt+=1
        if cnt==len(d)-K:
            break
    print(ans)

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

d={}

for n in range(N):
    if d.get(A[n])==None:
        d[A[n]]=1
    else:
        d[A[n]]+=1

dn=sorted(d.items(),key=lambda x:x[1])

if K>=len(d):
    print(0)
else:
    cnt=0
    ans=0
    for n in range(len(dn)):
        ans+=dn[n][1]
        cnt+=1
        if cnt==len(d)-K:
            break
print(ans)
Problem p03611 (python)

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

dp=[0 for n in range(max(a)+1)]
for n in range(N):
    dp[a[n]]+=1

ans=0
if len(dp)==1:
    ans=dp[0]
else:
    for n in range(1,len(dp)-1):
        ans=max(ans,dp[n-1]+dp[n]+dp[n+1])

print(ans)

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

dp=[0 for n in range(max(a)+1)]
for n in range(N):
    dp[a[n]]+=1

ans=0
for n in range(len(dp)):
    if n==0:
        ans=max(ans,a[0]+a[1])
    elif n==N-1:
        ans=max(ans,a[N-2]+a[N-1])
    else:
        ans=max(ans,dp[n-1]+dp[n]+dp[n+1])

print(ans)

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

dp=[0 for n in range(max(a))]
for n in range(N):
    dp[a[n]-1]+=1

ans=0
for n in range(1,len(dp)-1):
    ans=max(ans,dp[n-1]+dp[n]+dp[n+1])

print(ans)
Problem p03625 (python)

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

d={}

for n in range(N):
    if d.get(A[n])==None:
        d[A[n]]=1
    else:
        d[A[n]]+=1

d=sorted(d.items(),reverse=True)

cnt=0
ans=0
for i in range(len(d)):
    if cnt==0:
        if d[i][1]>=4:
            ans=d[i][0]**2
            break
        elif d[i][1]>=2:
            temp=d[i][0]
            cnt+=1
    else:
        if d[i][1]>=2:
            ans=temp*d[i][0]
            break
print(ans)

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

d={}

for n in range(N):
    if d.get(A[n])==None:
        d[A[n]]=1
    else:
        d[A[n]]+=1

d=sorted(d.items(),reverse=True)

cnt=0
for i in range(len(d)):
    if d[i][1]>=4:
        ans=d[i][0]**2
        break
    else:
        if cnt==0:
            if d[i][1]>=2:
                temp=d[i][0]
                cnt+=1
        else:
            if d[i][1]>=2:
                ans=temp*d[i][0]
                break
print(ans)
Problem p02576 (python)

Fixed submission:
import math as m

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

N=LIST[0]
X=LIST[1]
T=LIST[2]

s=N/X
s=m.ceil(s)
s=int(s)
i=s*T
print(i)

Buggy submission (verdict: Runtime Error):
import math as m

s=N/X
s=m.ceil(s)
s=int(s)
i=s*T
print(i)

Buggy submission (verdict: Runtime Error):
import math as m

N=input()
X=input()
T=input()

N=int(N)
X=int(X)
T=int(T)

s=N/X
s=m.ceil(s)
s=int(s)
i=s*T
print(i)

Buggy submission (verdict: Runtime Error):
import math as m

N=input()
X=input()
T=input()

N=int(N)
X=int(X)
T=int(T)

s=N/X
s=m.ceil(s)
s=int(s)
i=s*T
print(i)

Buggy submission (verdict: Runtime Error):
import math as m

s=N/X
s=m.ceil(s)
s=int(s)
i=s*T
print(i)

Buggy submission (verdict: Runtime Error):
import math as m

N=int(input())
X=int(input())
T=int(input())
s=N/X
s=m.ceil(s)
s=int(s)
i=s*T
print(i)
Problem p02632 (python)

Fixed submission:
P = 10**9 + 7

K = int(input())
S = input()
L = len(S)

d = [0]*(L+K+1)
d[0] = 1
for i in range(1, L+K+1):
    d[i] = (d[i-1]*i)%P

ans = 0
for i in range(K+1):
    temp = pow(26, i, P) * pow(25, K-i, P)
    temp %= P
    temp *= d[L-1+K-i]
    temp %= P
    temp *= pow(d[L-1], P-2, P)
    temp %= P
    temp *= pow(d[K-i], P-2, P)
    temp %= P
    ans += temp
    ans %= P

print(ans)

Buggy submission (verdict: Runtime Error):
37564
whydidyoudesertme
Problem p02647 (python)

Fixed submission:
import math
N, K = map(int, input().split())
S = list(map(int, input().split()))

K = min(K, 41)
dp = [[0]*N for _ in range(K)]

for i in range(N):
    temp = S[i]
    m = max(0, i-temp)
    dp[0][m] += 1
    if N > i+temp+1:
        dp[0][i+temp+1] -= 1

for i in range(K-1):
    temp = 0
    for j in range(N):
        temp += dp[i][j]
        m = max(0, j-temp)
        dp[i+1][m] += 1
        if N > j+temp+1:
            dp[i+1][j+temp+1] -= 1

ans = [0]*N
ans[0] = dp[K-1][0]

for i in range(1, N):
    ans[i] = ans[i-1] + dp[K-1][i]

print(" ".join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
S = list(map(int, input().split()))

K = min(K, math.log(2*10**5))
dp = [[0]*N for _ in range(K)]

for i in range(N):
    temp = S[i]
    m = max(0, i-temp)
    dp[0][m] += 1
    if N > i+temp+1:
        dp[0][i+temp+1] -= 1

for i in range(K-1):
    temp = 0
    for j in range(N):
        temp += dp[i][j]
        m = max(0, j-temp)
        dp[i+1][m] += 1
        if N > j+temp+1:
            dp[i+1][j+temp+1] -= 1

ans = [0]*N
ans[0] = dp[K-1][0]

for i in range(1, N):
    ans[i] = ans[i-1] + dp[K-1][i]

print(" ".join(map(str, ans)))
Problem p02664 (python)

Fixed submission:
T = input()
ans = ""
# i = 0
# while i < len(T)-1:
#     if T[i] == "D":
#         ans += "D"
#     elif T[i] == "P":
#         ans += "P"
#     else:
#         if ans == "":
#             ans += "D"
#         elif ans[-1] == "P":
#             ans += "D"
#         else:

#     i += 1
# if len(ans) != len(T):
#     if T[-1] == "P":
#         ans += "P"
#     else:
#         ans += "D"
for i in range(len(T)):
    if T[i] == "?":
        ans += "D"
    else:
        ans += T[i]
print(ans)

Buggy submission (verdict: Runtime Error):
T = input()
ans = ""
i = 0
while i < len(T)-1:
    if T[i] == "D":
        if T[i+1] != "D":
            ans += "DP"
        else:
            ans += "DD"
        i += 1
    elif T[i] == "P":
        if T[i+1] == "D":
            ans += "PD"
            i += 1
        elif T[i+1] == "?":
            ans += "PD"
            i += 1
        else:
            ans += "P"
    else:
        if T[i+1] == "D":
            ans += "PD"
            i += 1
        elif T[i+1] == "P":
            ans += "D"
        else:
            if ans[-1] == "D":
                ans += "P"
            else:
                ans += "D"
    i += 1
if len(ans) != len(T):
    if T[-1] == "P":
        ans += "P"
    else:
        ans += "D"
print(ans)
Problem p02696 (python)

Fixed submission:
A, B, N = map(int, input().split())

if B > N:
    print(int((A*N)/B)-A*int(N/B))
else:
    print(int((A*(B-1))/B)-A*int((B-1)/B))

# if B > N:
#     ans = floor(A*N/B)
#     print(ans)
# else:
#     ans = floor(A*N/B) - A*floor(N/B)
#     ans_2nd = 0
#     x = (N//B)*B - 1
#     temp = floor((A*x)/B) - A*floor(x/B)
#     # while ans <= temp and x >= 0:
#     #     ans = temp
#     #     temp = floor(A*x/B) - A*floor(x/B)
#     #     x -= B
#     # while ans_2nd <= temp and x >= 0:
#     #     ans_2nd = temp
#     #     temp = floor(A*x/B) - A*floor(x/B)
#     #     x -= B
#     # prfloor(max(ans, ans_2nd))
#     print(max(temp, ans))

Buggy submission (verdict: Runtime Error):
A, B, N = map(floor, input().split())
from math import floor

if B > N:
    ans = floor(A*N/B)
    print(ans)
else:
    ans = floor(A*N/B) - A*floor(N/B)
    ans_2nd = 0
    x = (N//B)*B - 1
    temp = floor((A*x)/B) - A*floor(x/B)
    # while ans <= temp and x >= 0:
    #     ans = temp
    #     temp = floor(A*x/B) - A*floor(x/B)
    #     x -= B
    # while ans_2nd <= temp and x >= 0:
    #     ans_2nd = temp
    #     temp = floor(A*x/B) - A*floor(x/B)
    #     x -= B
    # prfloor(max(ans, ans_2nd))
    print(max(temp, ans))

Buggy submission (verdict: Runtime Error):
A, B, N = map(floor, input().split())
from math import floor

if B > N:
    ans = floor(A*N/B)
    print(ans)
else:
    ans = floor(A*N/B) - A*floor(N/B)
    ans_2nd = 0
    x = (N//B)*B - 1
    temp = floor(A*x/B) - A*floor(x/B)
    # while ans <= temp and x >= 0:
    #     ans = temp
    #     temp = floor(A*x/B) - A*floor(x/B)
    #     x -= B
    # while ans_2nd <= temp and x >= 0:
    #     ans_2nd = temp
    #     temp = floor(A*x/B) - A*floor(x/B)
    #     x -= B
    # prfloor(max(ans, ans_2nd))
    print(max(temp, ans))

Buggy submission (verdict: Runtime Error):
A, B, N = map(floor, input().split())
from math import floor

if B > N:
    ans = floor(A*N/B)
    prfloor(ans)
else:
    ans = floor(A*N/B) - A*floor(N/B)
    ans_2nd = 0
    x = (N//B)*B - 1
    temp = floor(A*x/B) - A*floor(x/B)
    # while ans <= temp and x >= 0:
    #     ans = temp
    #     temp = floor(A*x/B) - A*floor(x/B)
    #     x -= B
    # while ans_2nd <= temp and x >= 0:
    #     ans_2nd = temp
    #     temp = floor(A*x/B) - A*floor(x/B)
    #     x -= B
    # prfloor(max(ans, ans_2nd))
    prfloor(max(temp, ans))
Problem p02702 (python)

Fixed submission:
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
from math import pow
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
from math import pow
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i))) % MOD
    dp[temp] += 1

for item in dp:
    if item != 0:
        ans += item*(item-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
from math import pow
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*pow(10, i)) % MOD
    dp[temp] += 1

for item in dp:
    ans += item*(item-1)//2

print(ans)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

i = 0
j = 0
k = 0
ans = 0
while  i+j+k < X+Y:
    if i == X:
        for n in range(Y-(j+k)):
            if k == C:
                ans += Q[j]
                j += 1
            elif Q[j] > R[k]:
                ans += Q[j]
                j += 1
            else:
                ans += R[k]
                k += 1
    elif j == Y:
        for n in range(X-(i+k)):
            if k == C:
                ans += P[i]
                i += 1
            elif P[i] > R[k]:
                ans += P[i]
                i += 1
            else:
                ans += R[k]
                k += 1
    elif k == C:
        if P[i] > Q[j]:
            ans += P[i]
            i += 1
        else:
            ans += Q[j]
            j += 1
    else:
        if P[i] >= max(Q[j], R[k]):
            ans += P[i]
            i += 1
        elif Q[j] >= max(P[i], R[k]):
            ans += Q[j]
            j += 1
        else:
            ans += R[k]
            k += 1

print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

i = 0
j = 0
k = 0
ans = 0
while  i+j+k < X+Y:
    if i == X:
        for n in range(Y-(j+k)):
            if Q[j] > R[k]:
                ans += Q[j]
                j += 1
            else:
                ans += R[k]
                k += 1
    elif j == Y:
        for n in range(X-(i+k)):
            if P[i] > R[k]:
                ans += P[i]
                i += 1
            else:
                ans += R[k]
                k += 1
    else:
        if P[i] >= max(Q[j], R[k]):
            ans += P[i]
            i += 1
        elif Q[j] >= max(P[i], R[k]):
            ans += Q[j]
            j += 1
        else:
            ans += R[k]
            k += 1

print(ans)
Problem p02734 (python)

Fixed submission:
P = 998244353

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

dp0 = [[0]*(S+1) for _ in range(N)]
dp1 = [[0]*(S+1) for _ in range(N)]
dp2 = [[0]*(S+1) for _ in range(N)]

dp0[0][0] = 1
dp1[0][0] = 1
if A[0] <= S:
    dp1[0][A[0]] = 1

for i in range(1, N):
    dp0[i][0] = 1
    dp1[i][0] = dp1[i-1][0] + 1
    dp2[i][S] = dp2[i-1][S] + dp1[i-1][S]
    if A[i] == S:
        dp2[i][S] += dp1[i-1][0] + 1
        dp1[i][S] += dp1[i-1][0] + 1
    elif A[i] < S:
        dp1[i][A[i]] += 1 + dp1[i-1][0]
    for j in range(1, S+1):
        dp1[i][j] += dp1[i-1][j]
        if j + A[i] < S:
            dp1[i][j+A[i]] += dp1[i-1][j]
        elif j + A[i] == S:
            dp2[i][S] += dp1[i-1][j]
            dp1[i][S] += dp1[i-1][j]
        dp0[i][j] %= P
        dp1[i][j] %= P
        dp2[i][j] %= P

print(dp2[N-1][S])

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

MOD = 998244353
# dp = [[0]*(3000+1) for _ in range(N)]
# ans = 0

# for i, num in enumerate(data):
#     dp[i][num] = 1
#     for j in range(i):
#         for k in range(S-num, 0, -1):
#             if dp[j][k] >= 1:
#                 dp[j][k+num] += dp[j][k]
#             if k == num:
#                 dp[j][num] += 1
#     for j in range(i+1):
#         ans += dp[j][S]
#     ans %= MOD

# print(ans)

ans = 0
dp = [[] for _ in range(21)]
dp[0] = [0]
for i, num in enumerate(data):
    for j in range(S-num, -1, -1):
        for item in dp[j]:
            dp[j+num] += [item+(1<<i)]

for item in dp[S]:
    for i in range(N+1):
        if item < (1<<i):
            a = N - i + 1
            break
    for i in range(N):
        if item & (1<<i) != 0:
            b = i + 1
            break
    ans = (a*b+ans)%MOD

print(ans)

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

MOD = 998244353
dp = [[0]*(S+1) for _ in range(N)]
ans = 0

for i, num in enumerate(data):
    dp[i][num] = 1
    for j in range(i):
        for k in range(S-num, 0, -1):
            if dp[j][k] >= 1:
                dp[j][k+num] += dp[j][k]
            if k == num:
                dp[j][num] += 1
    for j in range(i+1):
        ans += dp[j][S]
    ans %= MOD

print(ans)
Problem p02783 (python)

Fixed submission:
H, A = map(int, input().split())

if H % A == 0:
    print(H//A)
else:
    print(H // A + 1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, D, A = map(int, input().split())
S = [0]*N
for i in range(N):
    x, h = map(int, input().split())
    if h % A == 0:
        h //= A
    else:
        h = h//A + 1
    S[i] = [x, h]

S.sort()
print(S)
cnt = 0

for i in range(N):
    if S[i][1] <= 0:
        continue
    cnt += S[i][1]
    dmg = S[i][1]
    max_X = S[i][0] + D*2
    for j in range(i+1, N):
        if S[j][0] > max_X:
            break
        S[j][1] -= dmg

print(cnt)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
N, M = map(int, input().split())
S = list(map(int, input().split()))

temp = S[0]
cnt = 0
while temp%2 == 0:
    temp //= 2
    cnt += 1
temp = S[0]
for i in range(1, N):
    temp = temp*S[i]//gcd(temp, S[i])
    if S[i]%(2**cnt) == 1 or (S[i]//(2**cnt))%2 == 0:
        print(0)
        break
else:      
    if temp//2 > M:
        print(0)
    else:
        print((M-temp//2)//temp+1)

Buggy submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
S = list(map(int, input().split()))

temp = S[0]
for i in range(1, N):
    temp = temp*S[i]//gcd(temp, S[i])
if temp//2 > M:
    print(0)
else:
    print((M-temp//2)//temp+1)
Problem p02899 (python)

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

ans = [0]*N
for i in range(N):
    ans[S[i]-1] = i+1
print(" ".join(map(str, ans)))

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

ans = [0]*N
for i in range(Nh):
    ans[S[i]-1] = i+1
print(" ".join(map(str, ans)))
Problem p02973 (python)

Fixed submission:
N = int(input())
A = list(int(input()) for _ in range(N))

S = [A[0]]
for i in range(1, N):
    if A[i] <= S[0]:
        S.insert(0, A[i])
        continue
    ok = 0
    ng = len(S)
    tmp = (ok+ng)
    while ok+1 < ng:
        tmp = (ok+ng)//2
        if A[i] > S[tmp]:
            ok = tmp
        else:
            ng = tmp
    S[ok] = A[i]
print(len(S))

Buggy submission (verdict: Runtime Error):
import heapq
N = int(input())
A = list(int(input()) for _ in range(N))

S = [A[0]]
for i in range(1, N):
    if A[i] <= S[0]:
        S.insert(0, A[i])
        continue
    ok = 0
    ng = len(S)
    while ok+1 < ng:
        tmp = (ok+ng)//2
        if A[i] > S[tmp]:
            ok = tmp
        else:
            ng = tmp
    S[tmp] = A[i]
print(len(S))
Problem p03006 (python)

Fixed submission:
N = int(input())
S = list(tuple(map(int, input().split())) for _ in range(N))
A = []
if N == 1:
    print(1)
else:
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            a, b = S[i]
            c, d = S[j]
            for k in range(len(A)):
                e, f, g = A[k]
                if e == a-c and f == b-d:
                    A[k] = (e, f, g+1)
                    break
            else:
                A.append((a-c, b-d, 1))
    print(N-max(list(x[2] for x in A)))

Buggy submission (verdict: Runtime Error):
from itertools import combinations
N = int(input())
d = [list(map(int, input().split())) for _ in range(N)]

dd = dict()
t = 0

for n ,m in combinations(d, 2):
    if n[0] == m[0]:
        t += 1
    else:
        a = (m[1]-n[1])/(m[0]-n[0])
        if a in dd:
            dd[a] += 1
        else:
            dd.setdefault(a, 1)

M = max(t, *dd.values())
if M == 1:
    print(N-1)
else:
    for i in range(1, 51):
        if M == (i*(i+1))//2:
            M = i
            break
    print(N-M)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
N = int(input())
d = [list(map(int, input().split())) for _ in range(N)]

dd = dict()
t = 0

for n ,m in combinations(d, 2):
    if n[0] == m[0]:
        t += 1
    else:
        a = (m[1]-n[1])/(m[0]-n[0])
        if a in dd:
            dd[a] += 1
        else:
            dd.setdefault(a, 1)

M = max(t, *dd.values())
for i in range(1, 51):
    if M == (i*(i+1))//2:
        M = i
        break
print(N-M)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
N = int(input())
d = [list(map(int, input().split())) for _ in range(N)]

dd = dict()
t = 0

for n ,m in combinations(d, 2):
    if n[0] == m[0]:
        t += 1
    else:
        a = (m[1]-n[1])/(m[0]-n[0])
        if a in dd:
            dd[a] += 1
        else:
            dd.setdefault(a, 1)

print(N-max(t, *dd.values()))
Problem p03086 (python)

Fixed submission:
S = input()
T = "ACGT"
ans = 0

i = 0
while i < len(S):
    if S[i] in T:
        temp = 1
        for j in range(i+1, len(S)):
            if S[j] in T:
                temp += 1
            else:
                break
        ans = max(ans, temp)
        i += 1
    else:
        i += 1

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = "ACGT"
ans = 0

i = 0
while i < len(S):
    if S[i] in T:
        temp = 1
        for j in range(i+1, len(S)):
            if S[j] in T:
                temp += 1
            else:
                break
        ans = max(ans, temp)
        i = max(i+1, j+1)
    else:
        i += 1

print(ans)