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

Fixed submission:
s = input()
a = 0
n = len(s)

for i in range (n):
    if i % 2 == 1:
        if s[i] != "R":
            a=a+1
    if i % 2 == 0:
        if s[i] != "L":
            a=a+1
if a == len(s):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np

s = input()
int a = 0

for i in range len(s):
    if i % 2 == 0:
        if a[i] != "R":
            a++
    if i % 2 == 1:
        if a[i] != "L":
            a++
    if a == len(s):
        print('Yes')
    else:
        print('NO')
Problem p02910 (python)

Fixed submission:
s = input()

isOdd = True
for i in range(len(s)):
    if i % 2 == 1:
        if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
            isOdd = False

isEven = True
for i in range(len(s)):
    if i == 0 or i % 2 == 0:
        if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
            isEven = False

if isOdd == True and isEven == True:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input()

isOdd = True
for i in range(len(s)):
    if i % 2 == 1:
        if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
            isOdd = False

isEven = True
for i in range(len(s)):
    if i == 0 or i % 2 == 0:
        if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
            isEven = False

if isOdd == True or isEven == True:
    print("Yes")
else:
    print("No")
Problem p03160 (python)

Fixed submission:
import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n = int(input())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  if i - 1 >= 0:
    chmin(dp,i, abs(h[i]-h[i-1])+dp[i-1])

  if i - 2 >= 0:
    chmin(dp,i, abs(h[i]-h[i-2])+dp[i-2])
    
#print(dp)   
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
      dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
A = []
P = [0] * N
for _ in range(Q):
    A.append(int(input()))
    P[A[-1]-1] += 1

# 全員終了時はK - Q + （個人の正解数）とする
# K - Q + 正解数 > 0の人は勝ち残る
for i in range(N):
    if K - Q + P[i] > 0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = []
P = [0] * N
for _ in range(Q):
    A.append(int(input()))
    P[A[-1]-1] += 1

# 全員終了時はK - Q + （個人の正解数）とする
# K - Q + 正解数 > 0の人は勝ち残る
for i in range(Q):
    if K - Q + P[i] > 0:
        print("Yes")
    else:
        print("No")
Problem p02947 (python)

Fixed submission:
import numpy as np
N = input()
N = int(N)
Sdict = {}
n_anagram = 0
D = {"a":2, "b":3, "c":5, "d":7, "e":11, "f":13,"g":17, "h":19, "i":23, "j":29, "k":31, "l":37, "m":41, "n":43,
"o":47, "p":53, "q":59, "r":61, "s":67, "t":71, "u":73, "v":79, "w":83, "x":89, "y":97, "z":1}

S = [input() for _ in range(N)]

for s in S:
    s1 = [D[x] for x in s]
    s2 = np.prod(s1)

    if s2 in Sdict:
        n_anagram = n_anagram + Sdict[s2]
        Sdict[s2] += 1
    else:
        Sdict[s2] = 1
   
print(n_anagram)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = input()
N = int(N)
Sdict = {}
n_anagram = 0
D = {"a":2, "b":3, "c":5, "d":7, "e":11, "f":13,"g":17, "h":19, "i":23, "j":29, "k":31, "l":37, "m":41, "n":43,
"o":47, "p":53, "q":57, "r":59, "s":61, "t":67, "u":71, "v":73, "w":79, "x":83, "y":87, "z":1}

S = [input() for _ in range(N)]

for s in S:
    s = np.prod([D[x] for x in s])
    if s in S:
        n_anagram = n_anagram + S[s]
        S[s] += 1
    else:
        S[s] = 1
    
print(n_anagram)
Problem p03636 (python)

Fixed submission:
s=input()
print(s[0]+str(len(s[1:-1]))+s[-1])

Buggy submission (verdict: Runtime Error):
s=input()
return s[0]+str(len(s[1:-1]))+s[-1]
Problem p02924 (python)

Fixed submission:
# -*- coding: utf-8 -*-

# import itertools

num = int(input())

# イテレーションせずに求めます
rtn = num * (num-1) //2
print(int(rtn))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# import itertools

num = int(input())

# 実は[5,1,2,3,4]のようにずらしたのが一番でかくなるのでは？
tgt_list = list(range(num+1))[1:]
tgt_list.insert(0, tgt_list.pop(num-1)) # [1,2,3,4] -> [4,1,2,3]

rtn = 0
for i, v in enumerate(tgt_list):
  rtn += v % (i+1)
  
print(rtn)


# 下記は全通りを調べるが、処理が長すぎてエラーになるのでボツ。
# for v_list in itertools.permutations(range(num+1)[1:]):
#   tmp = 0
#   for i, v in enumerate(v_list):
#     tmp += v % (i+1)
#   rtn = max(rtn, tmp)
#   if (rtn == tmp):
#     print(v_list)
#     print(tmp)   
# print(rtn)
Problem p03830 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import math

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = [0]
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            if(num != 1):
                factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return n
    else:
        factor.append(n)
        return factor

def main():
    N = int(input())
    result = 1
    divisor = []

    for i in range(1, N+1):
        divisor.extend(trial_division(i))

    for i in range(2,N+1):
        result = result*(divisor.count(i)+1)

    print(result % (10 ** 9 + 7))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math

N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divorces = make_divisors(math.factorial(N))
print(len(divorces)%(10**9 + 7))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math

N = int(input())
result = 1

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divorces = make_divisors(math.factorial(N))

print(len(divorces)%(10**9 + 7))
Problem p03848 (python)

Fixed submission:
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False

for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*(i//2) +1):
            continue
        else:
            bool_false = False
            break

if(people_num == 1):
    print(1)
elif(bool_false):
    print((2**(people_num // 2) % (10**9 +7)))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False



for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*((i)//2) +1):
            continue
        else:
            bool_false = False
            break

if(len(people_num) == 1):
    print(1)
elif(bool_false):
    print((people_num//2) **2)
else:
    print(0)
Problem p03862 (python)

Fixed submission:


N,x = map(int, input().split())
candy_list = list(map(int, input().split()))

count_candy_eat = 0

for i in range(N):
    if(i == 0):
        if(candy_list[0] > x):
            count_candy_eat += candy_list[0] - x
            candy_list[0] = x
    else:
        if(candy_list[i-1] + candy_list[i] > x):
            if(x - candy_list[i-1] > 0):
                count_candy_eat += candy_list[i-1] + candy_list[i] - x
                candy_list[i] = x - candy_list[i-1]
            else:
                count_candy_eat += candy_list[i]
                candy_list[i] = 0


print(count_candy_eat)

Buggy submission (verdict: Runtime Error):


N,x = map(int, input().split())
candy_list = list(map(int, input().split()))

count_candy_eat = 0

if(candy_list[-1] == 0):
    for i in (reversed(N)):
        if (i == N):
            continue
        else:
            if (candy_list[i] + candy_list[i-1] > x):
                count_candy_eat += candy_list[i] + candy_list[i-1] - x
                candy_list[i-1] = x - candy_list[i]

print(candy_list)

for i in range(N):
    if(i == 0):
        continue
    else:
        if(candy_list[i-1] + candy_list[i] > x):
            count_candy_eat += candy_list[i-1] + candy_list[i] - x
            candy_list[i] = x - candy_list[i-1]

print(count_candy_eat)
Problem p02945 (python)

Fixed submission:
a, b = map(int, input().split())
calcu = [a+b, a-b, a*b]
print(max(calcu))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max[a+b, a-b, a*b])
Problem p03246 (python)

Fixed submission:
from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    even[0], odd[0] = 0, 0
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())

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

def solve(size=int(input()), ary=list(map(int, input().split()))):
    if len(set(ary)) < 2: return len(ary) // 2

    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())

Buggy submission (verdict: Runtime Error):
from collections import Counter
def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om
print(solve())

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

given1 = int(input())
given2 = [int(_) for _ in input().split()]

def solve(size=given1, ary=given2):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])

    emst, esec = even.most_common(2)
    eme, emf = emst
    ese, esf = esec

    omst, osec = odd.most_common(2)
    ome, omf = omst
    ose, osf = osec

    return size - max(emf + osf, omf + esf) if eme == ome else size - esf - osf


print(solve())
Problem p03086 (python)

Fixed submission:
import re

s = input()
ans = max(
    map(len, re.findall('[AGCT]+', s)),
    default=0
)

print(ans)

Buggy submission (verdict: Runtime Error):
import re

s = input()
ans = max(
    len(m.group()) for m in re.findall('[AGCT]+', s),
    default=0
)

print(ans)

Buggy submission (verdict: Runtime Error):
import re

s = input()
ans = max(
    len(m.group()) for m in re.findall('[AGCT]+'),
    default=0
)

print(ans)
Problem p03160 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

N = int(input())
A = list(map(int,input().split()))
dp = [-1]*(N+2)
dp[0] = 0
dp[1] = abs(A[1] - A[0])


def rec(i):
  if dp[i] != -1:
    return dp[i]
  dp[i] = min(rec(i-1) + abs(A[i-1] - A[i]), rec(i-2) + abs(A[i-2] - A[i]))
  return dp[i]

print(rec(N-1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100_000)

N = int(input())
A = list(map(int,input().split()))
dp = [-1]*(N+2)
dp[0] = 0
dp[1] = abs(A[1] - A[0])


def rec(i):
  if dp[i] != -1:
    return dp[i]
  dp[i] = min(rec(i-1) + abs(A[i-1] - A[i]), rec(i-2) + abs(A[i-2] - A[i]))
  return dp[i]

print(rec(N-1))
Problem p03999 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    s=input()
    n=len(s)
    ans=0
    from itertools import product
    for A in product(range(2),repeat=n-1):
        k=s[0]
        for i in range(n-1):
            k+='+' if A[i] else ''
            k+=s[i+1]
        ans+=eval(k)
    print(ans)
resolve()
Problem p03469 (python)

Fixed submission:
print "2018"+raw_input()[4:]

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
N=[]
for i in range(n):
	N.append(int(raw_input()))
N.sort()
ans=1
for i in range(1,n):
	if N[i]!=N[i-1]:
		ans+=1
print ans
Problem p03470 (python)

Fixed submission:
n=int(raw_input())
N=[]
for i in range(n):
	N.append(int(raw_input()))
N.sort()
ans=1
for i in range(1,n):
	if N[i]!=N[i-1]:
		ans+=1
print ans

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
N=map(int,raw_input().split())
N.sort()
ans=1
for i in range(1,n):
	if N[i]!=N[i-1]:
		ans+=1
print ans
Problem p03577 (python)

Fixed submission:
y=list(raw_input())
y.reverse()
foo=''
for i in range(len(y)):
    foo+=y[i]
    if foo=='LAVITSEF':
        j=i
        break
x=y[j+1:]
x.reverse()
print ''.join(x)

Buggy submission (verdict: Runtime Error):
foo={}
bar={}
n=int(raw_input())
for x in map(int,raw_input().split()):
    if x not in foo:
        foo[x]=0
    foo[x]+=1
n=int(raw_input())
for x in map(int,raw_input().split()):
    if x not in bar:
        bar[x]=0
    bar[x]+=1
for i in foo:
    if i not in bar:
        continue
    if foo[i]<bar[i]:
        print "NO"
        exit(0)
print "YES"

Buggy submission (verdict: Runtime Error):
foo=[0]*(300000)
bar=[0]*(300000)
n=int(raw_input())
for x in map(int,raw_input().split()):
    foo[x]+=1
n=int(raw_input())
for x in map(int,raw_input().split()):
    bar[x]+=1
for i in range(200001):
    if foo[i]<bar[i]:
        print "NO"
        exit(0)
print "YES"
Problem p03683 (python)

Fixed submission:
mod=10**9+7
n,m=map(int,raw_input().split())
mul1=mul2=1
if abs(n-m)>1:
    print 0
else:
    for i in range(1,n+1):
        mul1*=i
        mul1%=mod
    for i in range(1,m+1):
        mul2*=i
        mul2%=mod
    if n==m:
        print (2*mul1*mul2)%mod
    else:
        print (mul1*mul2)%mod

Buggy submission (verdict: Runtime Error):
n,m=map(int,raw_input())
mul1=mul2=1
if abs(n-m)>1:
    print 0
else:
    for i in range(1,n+1):
        mul1*=i
        mul1%=mod
    for i in range(1,m+1):
        mul2*=i
        mul2%=mod
    if n==m:
        print (2*mul1*mul2)%mod
    else:
        print (mul1*mul2)%mod
Problem p03975 (python)

Fixed submission:
n,a,b=map(int,raw_input().split())
count=0
for i in range(n):
	z=int(raw_input())
	if z/a>=1 and z/b<1:
		count+=1
print n-count

Buggy submission (verdict: Runtime Error):
n,k=map(int,raw_input().split())
a=[0]*25
b=[]
count=0
for i in range(n):
	b.append(raw_input())
b=list(set(b))
for i in b:
	a[ord(i[0])-65]+=1
for i in a:
	if i>0:
		count+=i
if len(set(a))==2:
	print 0
else:
    print count/k
Problem p03992 (python)

Fixed submission:
y=raw_input()
print y[:4]+' '+y[4:]

Buggy submission (verdict: Runtime Error):
y=list(raw_input())
k=int(raw_input())
for i in range(len(y)):
	if y[i]=='a':
		continue
	else:
		if 123-ord(y[i])<=k:
			k-=(123-ord(y[i]))
			y[i]='a'
y[len(y)-1]=chr(ord(y[len(y)-1])+k%26)
print ''.join(y)

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
N=map(int,raw_input().split())
count=0
for i in range(n):
	if i==N[N[i]-1]-1:
		count+=1
print count/2
Problem p04029 (python)

Fixed submission:
n=int(raw_input())
print n*(n+1)/2

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
N=map(int,raw_input().split())
add=0
if sum(N)%n==0:
    a=sum(N)/n
else:
    a=sum(N)/n +1
for i in N:
    add+=(a-i)**2
print add

Buggy submission (verdict: Runtime Error):
n=int(raw_input())
N=map(int,raw_input().split())
if len(set(N))==1:
    print 0
else:
    add=0
    if sum(N)%n==0:
        a=sum(N)/n
    else:
        a=sum(N)/n+1
    for i in N:
        add+=(a-i)**2
    print add
Problem p04043 (python)

Fixed submission:
a,b,c=map(int,raw_input().split())
p=[]
p.append(a)
p.append(b)
p.append(c)
p.sort()
if p==[5,5,7]:
    print "YES"
else:
    print "NO"

Buggy submission (verdict: Runtime Error):
n,l=map(int,raw_input().split())
a=[]
for i in range(n):
    a.append(raw_input())
a.sort()
print ''.join(a)
Problem p04047 (python)

Fixed submission:
n=int(raw_input())
N=map(int,raw_input().split())
N.sort()
count=0
for i in range(n):
    count+=N[2*i]
print count

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)


n,x=map(int,raw_input().split())
print 3*(n-gcd(n,x))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)


n,x=map(int,raw_input().split())
print 3*(n-gcd(n,x))
Problem p03298 (python)

Fixed submission:
from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  p = ['', '']
  for i in range(N):
    p[int(2**i & ptn > 0)] += str[i]
  return tuple(p)

for i in range(2**N):
  d[paint(first, i)] += 1
  
for i in range(2**N):
  ans += d[paint(last, i)]
  
print(ans)

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

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  return (red, blue)

for i in range(2**N):
  red = ''.join(s for j, s in enumerate(first) if 2**j & ptn)
  blue = ''.join(s for j, s in enumerate(first) if not 2**j & ptn)
  d[paint(red, blue)] += 1
  
for i in range(2**N):
  red = ''.join(s for j, s in enumerate(last) if 2**j & ptn)
  blue = ''.join(s for j, s in enumerate(last) if not 2**j & ptn)
  ans += d[paint(red, blue)]
  
print(ans)
Problem p04011 (python)

Fixed submission:
stay = int(input())
change_day = int(input())
first_cost = int(input())
change_cost = int(input())
total_cost = 0
 
for i in range(stay):
 if(i < change_day):
  total_cost += first_cost
 else:
  total_cost += change_cost
print(total_cost)

Buggy submission (verdict: Runtime Error):
stay = int(input())
change_day = int(input())
first_cost = int(input())
change_cost = int(input())
total_cost = 0

for i in range(stay):
 if(i < change_day):
 total_cost += first_cost
else:
 total_cost += change_cost

print(total_cost)
Problem p04029 (python)

Fixed submission:
number = int(input())
total = 0

for i in range(number+1):
 total += i

print(total)

Buggy submission (verdict: Runtime Error):
stay = int(input())
change_day = int(input())
first_cost = int(input())
change_cost = int(input())
total_cost = 0
 
for i in range(stay):
 if(i < change_day):
  total_cost += first_cost
 else:
  total_cost += change_cost
print(total_cost)
Problem p03006 (python)

Fixed submission:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    if n == 1:
        print(1)
        return
    X, Y = get_data(n, [int, int])
    vecs = Counter()
    for i in range(n):
        for j in range(i+1, n):
            if X[i] > X[j] or (X[i] == X[j] and Y[i] > Y[j]):
                vecs[(X[i]-X[j], Y[i]-Y[j])] += 1
            else:
                vecs[(X[j]-X[i], Y[j]-Y[i])] += 1
    print(n-vecs.most_common()[0][1])
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    X, Y = get_data(n, [int, int])
    vecs = Counter()
    for i in range(n):
        for j in range(i+1, n):
            if X[i] > X[j] or (X[i] == X[j] and Y[i] > Y[j]):
                vecs[(X[i]-X[j], Y[i]-Y[j])] += 1
            else:
                vecs[(X[j]-X[i], Y[j]-Y[i])] += 1
    print(n-vecs.most_common()[0][1])
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()
Problem p03151 (python)

Fixed submission:
from itertools import accumulate


def main():
  n = int(input())
  As = map(int, input().split())
  Bs = map(int, input().split())

  diffs = [a - b for a, b in zip(As, Bs)]
  pos_acc = list(accumulate(sorted(filter(lambda x: x>0, diffs), reverse=True)))
  negatives = list(filter(lambda x: x<0, diffs))
  neg_sum = abs(sum(negatives))
  num_negs = len(negatives)
  if num_negs == 0:
    print(0)
    return
  for i, pa in enumerate(pos_acc):
    if neg_sum <= pa:
      print(num_negs + i + 1)
      return
  print(-1)


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  n = int(input())
  As = map(int, input().split())
  Bs = map(int, input().split())

  diffs = [a - b for a, b in zip(As, Bs)]
  positives = list(sorted(filter(lambda x: x>0, diffs), reverse=True))
  negatives = list(sorted(filter(lambda x: x<0, diffs)))
  max_i = -1
  for neg in negatives:
    for i, pos in enumerate(positives):
      neg += pos
      max_i = max(i, max_i)
      if neg >= 0:
        positives[i] = neg
        break
      else:
        positives[i] = 0
  if negatives[-1] < 0:
    print(-1)
    return
  print(len(negatives) + max_i + 1)


if __name__ == '__main__':
  main()
Problem p03155 (python)

Fixed submission:
def main():
  n, h, w = int(input()), int(input()), int(input())
  print((n-h+1)*(n-w+1))


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  n, h, w = map(int, input().strip().split())
  print((n-h+1)*(n-w+1))


if __name__ == '__main__':
  main()