Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
#import numpy as np
#import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
def main():
  ans=1
  mod=1000000007
  n0=0
  na=nb=0
  n=int(input())
  d={}

  for i in range(n):
      a,b=map(int,input().split())
      if b==0 and a==0:
          n0+=1
      elif b==0:
          nb+=1
      elif a==0:
          na+=1
      else:
          if Fraction(a, b) not in d:
              d[Fraction(a, b)]=1
          else:
              d[Fraction(a, b)]+=1

  for i in d.keys():
      if Fraction(-1,i) in d:
          if i>0:
              ans*=pow(2,d[Fraction(-1, i)])-1+pow(2,d[i])-1+1
              ans=ans%mod
      else:
          ans*=pow(2,d[i])
          ans=ans%mod
  ans*=pow(2,na)-1+pow(2,nb)-1+1
  print((ans-1+n0)%mod)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
from math import gcd
#import numpy as np
#import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
def main():
  ans=1
  mod=1000000007
  n0=0
  na=nb=0
  n=int(input())
  d={}

  for i in range(n):
      a,b=map(int,input().split())
      if b==0 and a==0:
          n0+=1
      elif b==0:
          nb+=1
      elif a==0:
          na+=1
      else:
          g=gcd(a,b)
          if b<0:
            a*=-1
            b*=-1
          s=(a//g,b//g)
          if s not in d:
              d[s]=1
          else:
              d[s]+=1
  for k,v in d.items():
      a,b=k
      if a>0:
        if (-b,a) in d:
            if d[(a,b)]!=-1:
                ans*=pow(2,d[(-b, a)])-1+pow(2,d[(a,b)])-1+1
                ans=ans%mod
                d[(-b,a)]=-1
        else:
            ans*=pow(2,d[(a,b)])
            ans=ans%mod
            
      else:
        if (b,-a) in d:
            if d[(a,b)]!=-1:
                ans*=pow(2,d[(b, -a)])-1+pow(2,d[(a,b)])-1+1
                ans=ans%mod
                d[(b,-a)]=-1
        else:
            ans*=pow(2,d[(a,b)])
            ans=ans%mod
  ans*=pow(2,na)-1+pow(2,nb)-1+1
  print((ans-1+n0)%mod)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
ans=ansb=0
f=False
m=int(pow(x,0.2))
a=m
while True:
  b=0
  while pow(a,5)-pow(b,5)>=x:
      if pow(a,5)-pow(b,5)!=x:
          b+=1
      else:
          ans=a
          ansb=b
          f=True
          break
  a+=1
  if f:
    break
else:
    f=False
    for a in range(m//2+1):
        for b in range(a,m//2+2):
            if pow(a,5)+pow(b,5)!=x:
                continue
            else:
                ans=a
                ansb=-b
                f=True
                break
        if f:
            break

print(ans,ansb)

Fixed submission:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
x=int(input())
for a in range(-10**3,10**3):
    for b in range(-10**3,a):
        if pow(a,5)-pow(b,5)==x:
            print(a,b)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):

a,b,n=map(int,input().split())
i=0
while True:
    if b*i<=n:
        i+=1
    else:
        break
r=(a*n)//b-a*(n//b)
if i>1:
    x=b*(i+1)-1
    r1=(a*x)//b-a*(x//b)
else:
    r1=0
print(max(r,r1))

Fixed submission:

a,b,n=map(int,input().split())
i=(n//b)*b
r=(a*n)//b-a*(n//b)
if i>1:
    x=b*(i+1)-1
    r1=(a*x)//b-a*(x//b)
else:
    r1=0
print(max(r,r1))
Buggy python submission (verdict: Runtime Error):
import math

a=int(input().split())
print(2*math.pi*a)

Fixed submission:
import math

a=int(input())
print(2*math.pi*a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
r=[]
g=[]
b=[]
res=0
for i in range(n):
  if s[i]=="R":
    r.append(i)
  elif s[i]=="G":
    g.append(i)
  elif s[i]=="B":
    b.append(i)

res=len(g)*len(b)*len(r)

for i in r:
  for j in g:
    if (i+j)%2==0 and int((i+j)/2) in b:
      res-=1
    if abs(i-j)+max(i,j) in b:
      res-=1
    if min(i,j)-abs(i-j) in b:
      res-=1
print(res)

Fixed submission:
n=int(input())
s=input()
r=[]
g=[]
b=[]
res=0
for i in range(n):
  if s[i]=="R":
    r.append(i)
  elif s[i]=="G":
    g.append(i)
  elif s[i]=="B":
    b.append(i)

res=len(g)*len(b)*len(r)
r=set(r)
g=set(g)
b=set(b)
for i in r:
  for j in g:
    if (i+j)%2==0 and int((i+j)/2) in b:
      res-=1
    if abs(i-j)+max(i,j) in b:
      res-=1
    if min(i,j)-abs(i-j) in b:
      res-=1
print(res)
Buggy python submission (verdict: Runtime Error):
import headq

heap=[]
N = input()
for i in range(10):
  heapq.heappush(heap,i)
print(heap)


Fixed submission:
import heapq
 
heap=[]
N = int(input())
for i in range(1,10):
  heapq.heappush(heap,i)
for i in range(N):
  x = heapq.heappop(heap)
  if x%10!=0:
    heapq.heappush(heap,10*x+(x%10)-1)
  heapq.heappush(heap,10*x+(x%10))
  if x%10!=9:
    heapq.heappush(heap,10*x+(x%10)+1)
  
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
a_dic={}
for i in a:
  if i in a_dic:
    a_dic[i]+=1
  else:
    a_dic[i]=1
dic={}
for i in range(N):
  if a[i] not in dic:
    sum=0
    for j in a_dic:
      if j==a[i]:
        sum+=((a_dic[j]-1)*(a_dic[j]-2))/2
      else:
        sum +=(a_dic[j]*(a_dic[j]-1))/2
    dic[a[i]]=int(sum)
    print(int(sum))
  else:
    print(dic[a[i]])


Fixed submission:
N = int(input())
a = list(map(int,input().split()))
tot=0
dic={}
for i in a:
  if i not in dic:
    dic[i]=1
  else:
    dic[i]+=1
for i in dic:
  tot+=int((dic[i]*(dic[i]-1))/2)

for i in range(N):
  c=dic[a[i]]-1
  print(tot-c)
Buggy python submission (verdict: Runtime Error):
from collections import deque

d=deque()
s=input()
d.append(s)
q=int(input())
flag=1
t = [input().split() for l in range(q)]
for i in range(q):
  if t[i][0]=='1':
    flag=flag*(-1)
  else:
    if t[i][1]=='1' and flag==1:
      s=t[i][2]+s
    elif t[i][1]=='1' and flag==-1:
      s=s+t[i][2]
    elif t[i][1]=='2' and flag==1:
      s=s+t[i][2]
    elif t[i][1]=='2' and flag==-1:
      s=t[i][2]+s
if flag==-1:
  new_s = ''.join(list(reversed(s)))
print(new_s)

Fixed submission:
from collections import deque

d=deque()
s=input()
for i in s:
  d.append(i)
q=int(input())
flag=1
t = [input().split() for l in range(q)]
for i in range(q):
  if t[i][0]=='1':
    flag=flag*(-1)
  else:
    if t[i][1]=='1' and flag==1:
      d.appendleft(t[i][2])
    elif t[i][1]=='1' and flag==-1:
      d.append(t[i][2])
    elif t[i][1]=='2' and flag==1:
      d.append(t[i][2])
    elif t[i][1]=='2' and flag==-1:
      d.appendleft(t[i][2])
if flag==-1:
  d.reverse()
d="".join(list(d))
print(d)
Buggy python submission (verdict: Runtime Error):
a = [input().split() for l in range(3)]

n=int(input())
b = [(input()) for i in range(n)]
s=[]
for i in range(n):
  for j in range(3):
    if b[i] in a[j]:
      k=a[j].index(b[i])
      s.append([j,k])
      if [j,0] in s and [j,1] in s and [j,2] in s:
        print("Yes")
        break
      elif [0,k] in s and [1,k] in s and [2,k] in s:
        print("Yes")
        break
      elif j==k:
        if [0,0] in s and [1,1] in s and [2,2] in s:
          print("Yes")
          break
        elif [0,2] in s and [1,1] in s and [2,0] in s:
          print("Yes")
          break
  else:
    continue
  break
else:
  print("No")
    

Fixed submission:
a = int(input())
if a%2==0:
  print(int(a/2))
else:
  print(int((a+1)/2))

Buggy python submission (verdict: Runtime Error):
a = int(input())
if a%2=0:
  print(a/2)
else:
  print((a+1)/2)

Fixed submission:
a = int(input())
if a%2==0:
  print(int(a/2))
else:
  print(int((a+1)/2))
Buggy python submission (verdict: Time Limit Exceeded):
#xorの性質
#AxorA=0、交換法則、結合法則が成立、bitごとに独立して考える！

import numpy as np

n=int(input())
a=np.array(list(map(int,input().split())))
res=0
for j in range(60):
  s=0 #1の数
  for i in a:
    if (i>>j & 0b1)==0b1:
      s+=1
  r=2**j*(n-s)*s
  res=(res+r)%(10**9+7)
print(res)

Fixed submission:
#xorの性質
#AxorA=0、交換法則、結合法則が成立、bitごとに独立して考える！

import numpy as np

n=int(input())
a=np.array(list(map(int,input().split())))
res=0
for j in range(60):
  s=0 #1の数
  """
  for i in a:
    if (i>>j & 0b1)==0b1:
      s+=1
  """
  s=np.count_nonzero(a>>j&1)
  r=2**j*(n-s)*s
  res=(res+r)%(10**9+7)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
#xorの性質
#AxorA=0、交換法則、結合法則が成立、bitごとに独立して考える！
n=int(input())
a=list(map(int,input().split()))
res=0
for j in range(60):
  s=0 #1の数
  for i in a:
    if (i>>j & 0b1)==0b1:
      s+=1
  r=2**j*(n-s)*s
  res=(res+r)%(10**9+7)
print(res)

Fixed submission:
#xorの性質
#AxorA=0、交換法則、結合法則が成立、bitごとに独立して考える！

import numpy as np

n=int(input())
a=np.array(list(map(int,input().split())))
res=0
for j in range(60):
  s=0 #1の数
  """
  for i in a:
    if (i>>j & 0b1)==0b1:
      s+=1
  """
  s=np.count_nonzero(a>>j&1)
  r=2**j*(n-s)*s
  res=(res+r)%(10**9+7)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
#xorの性質
#AxorA=0、交換法則、結合法則が成立、bitごとに独立して考える！
n=int(input())
a=list(map(int,input().split()))
res=0
for j in range(60):
  s=0 #1の数
  for i in a:
    if (i>>j & 0b1)==0b1:
      s+=1
  res+=2**j*(n-s)*s
print(res%(10**9+7))

Fixed submission:
#xorの性質
#AxorA=0、交換法則、結合法則が成立、bitごとに独立して考える！

import numpy as np

n=int(input())
a=np.array(list(map(int,input().split())))
res=0
for j in range(60):
  s=0 #1の数
  """
  for i in a:
    if (i>>j & 0b1)==0b1:
      s+=1
  """
  s=np.count_nonzero(a>>j&1)
  r=2**j*(n-s)*s
  res=(res+r)%(10**9+7)
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
x,y=map(int,input().split())

if (2*x-y)%3!=0 or (2*x-y)<0:
  print(0)
  exit()
if (2*y-x)%3!=0 or (2*y-x)<0:
  print(0)
  exit()
p=int((2*x-y)/3)
q=int((2*y-x)/3)
M=2*(10**6)
Mod=10**9+7

fac=[0]*M
finv=[0]*M
inv=[0]*M

def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
print(COM(p+q,p))

Fixed submission:
x,y=map(int,input().split())

if (2*x-y)%3!=0 or (2*x-y)<0:
  print(0)
  exit()
if (2*y-x)%3!=0 or (2*y-x)<0:
  print(0)
  exit()
p=int((2*x-y)/3)
q=int((2*y-x)/3)
M=p+q+2
Mod=10**9+7

fac=[0]*M
finv=[0]*M
inv=[0]*M

def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
print(COM(p+q,p))
Buggy python submission (verdict: Runtime Error):
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1c
print(ans)

Fixed submission:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n=int(input())
l=np.array(list(map(int , input().split())))
#尺取り法
l.sort()
s=0
for i in range(n):
  if i+2<n:
    k=i+2
  else:
    break
  for j in range(i+1,n):
    while (k<n and l[k]<l[i]+l[j]):
      k+=1
    s+=k-(j+1)
print(s)

Fixed submission:

n=int(input())
l=list(map(int , input().split()))
#尺取り法
l.sort()
s=0
for i in range(n):
  if i+2<n:
    k=i+2
  else:
    break
  for j in range(i+1,n):
    while (k<n and l[k]<l[i]+l[j]):
      k+=1
    s+=k-(j+1)
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n=int(input())
l=np.array(list(map(int , input().split())))

l.sort()
s=0
for i in range(n):
  for j in range(i+1,n):
    k=np.searchsorted(l,l[i]+l[j],side="left")
    s+=k-(j+1)
    
print(s)

Fixed submission:

n=int(input())
l=list(map(int , input().split()))
#尺取り法
l.sort()
s=0
for i in range(n):
  if i+2<n:
    k=i+2
  else:
    break
  for j in range(i+1,n):
    while (k<n and l[k]<l[i]+l[j]):
      k+=1
    s+=k-(j+1)
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
p,q=map(int,input().split())
if q>p:
  p,q=q,p
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)
g=gcd(p,q)
d=int(g**0.5)
res=set()
for i in range(2,g+1):
  if g%i!=0:
    continue
  else:
    res.add(i)
    while g%i==0:
      g=int(g/i)
print(len(res)+1)

Fixed submission:
p,q=map(int,input().split())
if q>p:
  p,q=q,p
  
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)
  
def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a
  
g=gcd(p,q)
res=prime_factorize(g)
print(len(res)+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
pairs=list(tuple(map(lambda x:int(x)-1,input().split())) for _ in range(n-1))
point=list(tuple(map(lambda x:int(x)-1, input().split())) for _ in range(q))

node=[[] for _ in range(n)]
parent=[None for _ in range(n)]
parent[0]=0
res=[0 for _ in range(n)]

for p in pairs:
  node[p[0]].append(p[1])
  node[p[1]].append(p[0])
  
for s in point:
  res[s[0]]+=(s[1]+1)
    
for i in range(n):
  for c in node[i]:
    if parent[c]==None:
      parent[c]=i
      res[c]+=res[i]
      
print(*res)

Fixed submission:
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,q=map(int,input().split())
v=tuple(tuple(map(lambda x: int(x)-1,input().split())) for _ in range(n-1))

node=[[] for _ in range(n)]
d=deque()
d.append(0)
for pair in v:
    node[pair[0]].append(pair[1])
    node[pair[1]].append(pair[0])
ans=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x
seen=[0]*n
seen[0]=1
while True:
    if not d:
        break
    i=d.pop()
    for j in node[i]:
        if seen[j]==0:
            d.append(j)
            seen[j]=1
            ans[j]+=ans[i]
print(*ans)
Buggy python submission (verdict: Runtime Error):
import sys
import heapq
input = sys.stdin.readline

n,m=map(int,input().split())
p=tuple(tuple(map(int,input().split())) for _ in range(n))
p=sorted(p,key=lambda x:x[0])
q=[]
ans=0
count=0

for i in range(n-1):
  a,b=p[i]
  if a>m:
    break
  elif a==p[i+1][0]:
    heapq.heappush(q,-b)
  else:
    heapq.heappush(q,-b)
    ans-=heapq.heappop(q)
    count+=1
    
else:
  heapq.heappush(q,-p[n-1][1])
  for _ in range(m-count):
    ans-=heapq.heappop(q)

print(ans)

Fixed submission:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
d=[]
ab=sorted(ab,key=lambda x: x[0])
ans=0
j=0
for i in range(m):
    for k in range(j,n):
        if ab[k][0]>i+1:
            j=k
            break
        heapq.heappush(d,(-1)*ab[k][1])
    else:
      j=n
    if not d:
        continue
    res=heapq.heappop(d)*(-1)
    ans+=res
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
n=int(input())
a=[int(input()) for _ in range(n)]
print(max(a[1:]))
for i in range(1,n-1):
    print(max(max(a[:i]),max(a[i+1:])))
    
print(max(a[:n-1]))

Fixed submission:
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
n=int(input())
a=[int(input()) for _ in range(n)]
l=[0]*n
r=[0]*n
l[0]=a[0]
r[0]=a[-1]
for i in range(1,n):
    if a[i]>l[i-1]:
        l[i]=a[i]
    else:
        l[i]=l[i-1]
    if a[n-1-i]>r[i-1]:
        r[i]=a[n-1-i]
    else:
        r[i]=r[i-1]
print(r[n-2])
for i in range(1,n-1):
    print(max(l[i-1],r[n-i-2]))
print(l[n-2])
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
if n==1:
    b=a
elif n==2:
    b[1]=a[1]
    b[0]=(a[0]-b[1])%2
elif n==3:
    b[1]=a[1]
    b[2]=a[2]
    b[0]=(a[0]-b[1]-b[2])%2
i=2
while n/i>=2:
    for k in range(n//i,n//(i-1)):
        j=2
        b[k]=a[k]
        while j*(k+1)-1<n:
            b[k]=(b[k]-b[j*(k+1)-1])%2
            j+=1
    i+=1
j=1
b[1]=a[1]
b[0]=a[0]
while j*1<n:
    if 1+j*2<n:
        b[1]=(b[1]-b[1+j*2])%2
    b[0]=(b[0]-b[j*1])%2
    j+=1
num=0
for i in range(n):
    if b[i]==1:
        print(i+1)
        num+=1
if num==0:
  print(0)
    

Fixed submission:
import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
if n==1:
    b=a
elif n==2:
    b[1]=a[1]
    b[0]=(a[0]-b[1])%2
    
elif n==3:
    b[1]=a[1]
    b[2]=a[2]
    b[0]=(a[0]-b[1]-b[2])%2
else:
  i=2
  while n/i>=1:
      for k in range((n//i)+1,n//(i-1)+1):
          j=2
          b[k-1]=a[k-1]
          while j*k-1<n:
              b[k-1]=(b[k-1]-b[j*k-1])%2
              j+=1
      i+=1
  j=1
  b[0]=a[0]
  while j*1<n:
      b[0]=(b[0]-b[j*1])%2
      j+=1
num=sum(b)
print(num)
for i in range(n):
    if b[i]==1:
        print(i+1)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
Mod=10**9+7
M=n
fac=[0]*M
finv=[0]*M
inv=[0]*M

#finvに逆元、facに階乗のmod
def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
for i in range(1,k+1):
  print((COM(k-1,i-1)*COM(n-k+1,i))%Mod)


Fixed submission:
n,k=map(int,input().split())
Mod=10**9+7
M=n+10
fac=[0]*M
finv=[0]*M
inv=[0]*M

#finvに逆元、facに階乗のmod
def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
for i in range(1,k+1):
  print((COM(k-1,i-1)*COM(n-k+1,i))%Mod)
Buggy python submission (verdict: Runtime Error):
import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[i for i in range(n)]
xy=[list(map(int,input().split()))  for _ in range(n)]
comb=itertools.permutations(l,2)
dic={}
for c in comb:
    i,j=c
    xi,yi=xy[i]
    xj,yj=xy[j]
    p=xi-xj
    q=yi-yj
    if (p,q) not in dic:
        dic[(p,q)]=1
    else:
        dic[(p,q)]+=1
res=-1
ai=-1
for i in dic.keys():
    if res<dic[i]:
        ai=i
        res=dic[i]
print(n-dic[i])

Fixed submission:
import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[i for i in range(n)]
xy=[list(map(int,input().split()))  for _ in range(n)]
if n==1:
  print(1)
  exit()
comb=itertools.permutations(l,2)
dic={}
for c in comb:
    i,j=c
    xi,yi=xy[i]
    xj,yj=xy[j]
    p=xi-xj
    q=yi-yj
    if (p,q) not in dic:
        dic[(p,q)]=1
    else:
        dic[(p,q)]+=1
res=-1
ai=-1
for i in dic.keys():
    if res<dic[i]:
        ai=i
        res=dic[i]
print(n-dic[ai])

Buggy python submission (verdict: Runtime Error):
import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[i for i in range(n)]
xy=[list(map(int,input().split()))  for _ in range(n)]
comb=itertools.permutations(l,2)
dic={}
for c in comb:
    i,j=c
    xi,yi=xy[i]
    xj,yj=xy[j]
    p=xi-xj
    q=yi-yj
    if (p,q) not in dic:
        dic[(p,q)]=1
    else:
        dic[(p,q)]+=1
res=-1
ai=-1
for i in dic.keys():
    if res<dic[i]:
        ai=i
        res=dic[i]
print(dic[ai])

Fixed submission:
import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[i for i in range(n)]
xy=[list(map(int,input().split()))  for _ in range(n)]
if n==1:
  print(1)
  exit()
comb=itertools.permutations(l,2)
dic={}
for c in comb:
    i,j=c
    xi,yi=xy[i]
    xj,yj=xy[j]
    p=xi-xj
    q=yi-yj
    if (p,q) not in dic:
        dic[(p,q)]=1
    else:
        dic[(p,q)]+=1
res=-1
ai=-1
for i in dic.keys():
    if res<dic[i]:
        ai=i
        res=dic[i]
print(n-dic[ai])
Buggy python submission (verdict: Runtime Error):
import heapq

n,k=map(int,input().split())
v=list(map(int,input().split()))
s=-10**7-1
for l in range(k//2+1):
    for i in range(k+1-l):
        d=v[:i]
        d.extend(v[(n-k+l+i):])
        heap=heapq.heapify(d)
        res=sum(d)
        for j in range(l):
            t=heapq.heappop(d)
            if t<0:
                res-=t
        if s<res:
            s=res
if s<0:
    print(0)
else:
    print(s)
       

Fixed submission:
import heapq

n,k=map(int,input().split())
v=list(map(int,input().split()))
s=-10**7-1

if n>k:
    for l in range(k//2+1):
        for i in range(k+1-l):
            d=v[:i]
            d.extend(v[(n-k+l+i):])
            heap=heapq.heapify(d)
            res=sum(d)
            for j in range(l):
                t=heapq.heappop(d)
                if t<0:
                    res-=t
                else:
                    break
            if s<res:
                s=res
else:
    for l in range(n+1):
        for i in range(n-l+1):
            d=v[:i]
            d.extend(v[(l+i):])
            heap=heapq.heapify(d)
            res=sum(d)
            for j in range(k-(n-l)):
                if not d:
                    break
                t=heapq.heappop(d)
                if t<0:
                    res-=t
                else:
                    break
            if s<res:
                s=res

        
if s<0:
    print(0)
else:
    print(s)
Buggy python submission (verdict: Runtime Error):
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[0]*(x*y)
c.sort(reverse=True)
for i in range(x):
    for j in range(y):
        ab[y*i+j]=a[i]+b[j]
ab.sort(reverse=True)
d=ab[:k]
ans=[0]*(k*z)
for i in range(k):
    for j in range(z):
        ans[z*i+j]=d[i]+c[j]
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Fixed submission:
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[0]*(x*y)
c.sort(reverse=True)
for i in range(x):
    for j in range(y):
        ab[y*i+j]=a[i]+b[j]
ab.sort(reverse=True)
d=ab[:k]
ans=[0]*(k*z)
for i in range(len(d)):
    for j in range(z):
        ans[z*i+j]=d[i]+c[j]
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])