Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#D
import itertools
N=int(input())
S=str(input())
S_list=list(S)
password_list=[]
for x in itertools.product(['0','1','2','3','4','5','6','7','8','9'],repeat=3):
  for i in range(N-2):
    if x[0]==S_list[i]:
      for j in range(i+1,N-1):
        if x[1]==S_list[j]:
          for k in range(j+1,N):
            if x[2]==S_list[k]:
              password_list +=[''.join(x)]
              break
answer=len(set(password_list))
print(answer)

Fixed submission:
#D
import itertools
N=int(input())
S=str(input())
count=0
for i,j,k in itertools.product(range(10),repeat=3):
  try:
    x = S.index(str(i))
    y = S.index(str(j),x+1)
    z = S.index(str(k),y+1)
    count +=1
  except:
    continue

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
#D
N=int(input())
S=str(input())
password_list=[]
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      password_list += [S[i]+S[j]+S[k]]
answer=len(list(set(password_list)))
print(answer)

Fixed submission:
#D
import itertools
N=int(input())
S=str(input())
count=0
for i,j,k in itertools.product(range(10),repeat=3):
  try:
    x = S.index(str(i))
    y = S.index(str(j),x+1)
    z = S.index(str(k),y+1)
    count +=1
  except:
    continue

print(count)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[int(x) for x in input().split()]
L=sum(A)
for i in range(N):#真ん中の棒を探す
  if sum(A[:i])>=L/2:
    p=i
    break
X=abs(sum(A[:p])-sum(A[p+1:]))#両サイドの差
Y=A[p]
result=abs(X-Y)
print(result)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np
 
N=int(input())
A = np.array([int(x) for x in input().split()])
if N==2:
  print(abs(A[0]-A[1]))
else:
  B = np.concatenate([[0],A.cumsum()])
  H = np.searchsorted(B,sum(A)//2)
  result=float('inf')
  for i in range(min(5,len(A)//2)):
    result=min(result,abs(sum(A[:H+i])-sum(A[H+i:])),abs(sum(A[:H-i])-sum(A[H-i:])))

  print(result)
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if a**2*b>x> (a**2)*b/2:
  tan=2*((a**2)*b-x)/(a**3)
elif x<a*a*b/2:
  tan=a*b*b/(2*x)
elif x=a*a*b:
  tan=0
  

print(math.degrees(math.atan(tan)))

Fixed submission:
import math
a,b,x = map(int,input().split())
if a**2*b>x> (a**2)*b/2:
  tan=2*((a**2)*b-x)/(a**3)
elif x<=a*a*b/2:
  tan=a*b*b/(2*x)
elif x==a*a*b:
  tan=0
  

print(math.degrees(math.atan(tan)))

Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if a**2*b>x>= (a**2)*b/2:
  tan=2*((a**2)*b-x)/(a**3)
elif x<a*a*b/2:
  tan=a*b*b/(2*x)
  

print(math.degrees(math.atan(tan)))

Fixed submission:
import math
a,b,x = map(int,input().split())
if a**2*b>x> (a**2)*b/2:
  tan=2*((a**2)*b-x)/(a**3)
elif x<=a*a*b/2:
  tan=a*b*b/(2*x)
elif x==a*a*b:
  tan=0
  

print(math.degrees(math.atan(tan)))

Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
if a**2*b>x>= (a**2)*b/2:
  tan=2*((a**2)*b-x)/(a**3)
elif a**2*b>x:
  tan=a*(b**2)/x
print(math.degrees(math.atan(tan)))

Fixed submission:
import math
a,b,x = map(int,input().split())
if a**2*b>x> (a**2)*b/2:
  tan=2*((a**2)*b-x)/(a**3)
elif x<=a*a*b/2:
  tan=a*b*b/(2*x)
elif x==a*a*b:
  tan=0
  

print(math.degrees(math.atan(tan)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

p = ''
result = 0
for i in range(N):
    if p != S[i]:
        result += 1
        p = S[i]
print(result)

Fixed submission:
A,B = map(int,input().split())
r=A-2*B
if r <=0:
  print(0)
else:
  print(r)
Buggy python submission (verdict: Runtime Error):
N=input()
List=list(map(int,input().split()))
i =0 
j =0
for i in range(N):
    for j in range(N):
        t = List[i]*List[j]
print(t)

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

r = 0
for i in range(N-1):
    for j in range(i+1,N):
        r +=d[i]*d[j]
print(r)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
L=[]#公約数のリスト
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    L +=[i]
#公約数の中の素数を数える。素数でないものを取り除く
for j in range(len(L)):
  for k in range(2,L[j]):
    if L[j]%k==0:
      del L[j]
      break
print(len(L))

Fixed submission:
def gcd(a,b):#最大公約数
  return a if b == 0 else gcd(b,a%b)

def prime_factorize(n):#素因数分解
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A,B = map(int,input().split())
X=gcd(A,B)
P=prime_factorize(X)

answer=len(set(P))+1
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
for i in range(M):
  A.sort()
  A[-1]=A[-1]/2
for i in range(N):
  A[i]=int(A[i])
print(sum(A))

Fixed submission:
import heapq
N,M =map(int,input().split())
A=[-int(x) for x in input().split()]#大きい順で扱う為にマイナスを付ける

heapq.heapify(A)#Aを優先度付キューへ変換

for i in range(M):
  saitakane = heapq.heappop(A)#最高値を取り出す
  heapq.heappush(A,-(-saitakane//2))#切り捨ての為に正の数にしてから半分にして戻す（追加）
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
for i in range(M):
  for j in range(N):
    if A[j]==max(A):
      A[j]=A[j]/2
      break
for i in range(N):
  A[i]=int(A[i])
print(sum(A))

Fixed submission:
import heapq
N,M =map(int,input().split())
A=[-int(x) for x in input().split()]#大きい順で扱う為にマイナスを付ける

heapq.heapify(A)#Aを優先度付キューへ変換

for i in range(M):
  saitakane = heapq.heappop(A)#最高値を取り出す
  heapq.heappush(A,-(-saitakane//2))#切り捨ての為に正の数にしてから半分にして戻す（追加）
print(-sum(A))
Buggy python submission (verdict: Runtime Error):
result = 0
for i in range(3):
  if T[i] == S[i]:
    result +=1
print(result)

Fixed submission:
S = input()
T = input()
c = 0
for i in range(3):
	if S[i]==T[i]: c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
H=[int(x) for x in input().split()]
A=''
for i in range(N-1):
  if H[i] >= H[i+1]:
    A += 'o'
  else:
    A +='x'
for j in range(1,N):
  if 'o'*(N-j) in A:
    print(N-j)
    exit()
print('0')

Fixed submission:
N=int(input())
H=[int(x) for x in input().split()]
answer = 0
count = 0
for i in range(N-1):
  if H[i]>=H[i+1]:
    count +=1
    answer = max(answer,count)
  else:
    count=0
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[]
count=0
for i in range(N):
  s="".join(sorted(input()))
  count +=S.count(s)
  S +=[s]
print(count)  


Fixed submission:
from collections import defaultdict
N=int(input())
S={}
S_counter = defaultdict(int)
count=0
for i in range(N):
  s="".join(sorted(input()))
  if s in S:
    count += S[s]
    S[s] += 1
  else:
    dict={s:1}
    S.update(dict)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[]
count=0
for i in range(N):
  s=str(input())
  s_list=sorted(list(s))
  s=''.join(s_list)
  count +=S.count(s)
  S +=[s]
print(count)  

Fixed submission:
from collections import defaultdict
N=int(input())
S={}
S_counter = defaultdict(int)
count=0
for i in range(N):
  s="".join(sorted(input()))
  if s in S:
    count += S[s]
    S[s] += 1
  else:
    dict={s:1}
    S.update(dict)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=[]
for i in range(N):
  s=str(input())
  s_list=sorted(list(s))
  S +=[s_list]

count=0
for i in range(N-1):
  for j in range(i+1,N):
    if S[i]==S[j]:
      count +=1
print(count)

Fixed submission:
from collections import defaultdict
N=int(input())
S={}
S_counter = defaultdict(int)
count=0
for i in range(N):
  s="".join(sorted(input()))
  if s in S:
    count += S[s]
    S[s] += 1
  else:
    dict={s:1}
    S.update(dict)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S=[]
for i in range(N):
  s=str(input())
  u=''
  t=list(s)
  t.sort()
  for j in range(len(list(t))):
    u +=t[j]
  S +=[u]
count=0
for i in range(N-1):
  for j in range(i+1,N):
    if S[i]==S[j]:
      count +=1
print(count)

Fixed submission:
from collections import defaultdict
N=int(input())
S={}
S_counter = defaultdict(int)
count=0
for i in range(N):
  s="".join(sorted(input()))
  if s in S:
    count += S[s]
    S[s] += 1
  else:
    dict={s:1}
    S.update(dict)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())
answer = float('inf')
for i in range(L,R):
  for j in range(i+1,R+1):
    m = (i*j)%2019
    answer = min(answer,m)
print(answer)

Fixed submission:
L,R = map(int,input().split())
if R-L>2019:
  R=L+2019
answer = float('inf')
for i in range(L,R):
  for j in range(i+1,R+1):
    m = (i*j)%2019
    answer = min(answer,m)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())#奇数
A=[int(x) for x in input().split()]
B=[0]*N
#B[0]はA[0]-A[1]+A[2]-  -A[N-1]+A[N]
A=A*2
for i in range(N):
  for j in range(i,i+N):
    B[i] +=A[j]*((-1)**(j-i))
print(*B)

Fixed submission:
N=int(input())#奇数
D=[int(x) for x in input().split()]#ダムの貯水量
Ame=[0]
for i in range(N):
  Ame[0] +=D[i]*((-1)**i)
for i in range(1,N):
  Ame +=[2*D[i-1]-Ame[i-1]]
print(*Ame)
Buggy python submission (verdict: Runtime Error):
N = int(input())
W =[int(x) for x in input().split()]
print(min(abs(sum(W[:i])-sum(W[i:])) for i in range(N))

Fixed submission:
N = int(input())
W = [int(x) for x in input().split()]
result = float('inf')
for i in range(N):
    W1= sum(W[0:i])
    W2= sum(W)-W1
    diff=abs(W1-W2)
    result=min(result,diff)
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
mod=10**9+7
A=[]
for i in range(M):
  A +=[int(input())]

B=[1]
if 1 in A:
  B +=[0]
else:
  B +=[1]
for i in range(2,N+1):
  if i in A:
    B +=[0]
  else:
    B +=[(B[i-1]+B[i-2])%mod]
print(B[-1]%mod)

Fixed submission:
N,M = map(int,input().split())
mod=10**9+7
A = {int(input()) for i in range(M)}

if 1 in A:
  x=0
else:
  x=1
B=[1,x]
for i in range(2,N+1):
  if i in A:
    B +=[0]
  else:
    B +=[(B[i-1]+B[i-2])%mod]
print(B[-1]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
mod=10**9+7
A=[]
for i in range(M):
  A +=[int(input())]

B=[1]
if 1 in A:
  B +=[0]
else:
  B +=[1]
for i in range(2,N+1):
  if i in A:
    B +=[0]
  else:
    B +=[B[i-1]%mod+B[i-2]%mod]
print(B[-1]%mod)

Fixed submission:
N,M = map(int,input().split())
mod=10**9+7
A = {int(input()) for i in range(M)}

if 1 in A:
  x=0
else:
  x=1
B=[1,x]
for i in range(2,N+1):
  if i in A:
    B +=[0]
  else:
    B +=[(B[i-1]+B[i-2])%mod]
print(B[-1]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
mod=10**9+7
A=[]
for i in range(M):
  A +=[int(input())]

B=[1]
if 1 in A:
  B +=[0]
else:
  B +=[1]
for i in range(2,N+1):
  if i in A:
    B +=[0]
  else:
    B +=[B[i-1]+B[i-2]]
print(B[-1]%mod)

Fixed submission:
N,M = map(int,input().split())
mod=10**9+7
A = {int(input()) for i in range(M)}

if 1 in A:
  x=0
else:
  x=1
B=[1,x]
for i in range(2,N+1):
  if i in A:
    B +=[0]
  else:
    B +=[(B[i-1]+B[i-2])%mod]
print(B[-1]%mod)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
A=[int(x) for x in readline().split()]
BC=[]
for i in range(M):
  BC +=[list(map(int,readline().split()))]
BC = sorted(BC, key=lambda x: x[1],reverse = True)
A=sorted(A)
for i in range(M):
  for j in range(BC[i][0]):
    A[j]=max(A[j],BC[i][1])
  A=sorted(A)
print(sum(A))

Fixed submission:
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
CB=[]
for i in range(M):
  B,C = map(int,input().split())
  CB +=[[C,B]]

for j in range(N):
  CB +=[[A[j],1]]

CB=sorted(CB,reverse = True)
count = 0
result =0

i=0
while count<N:
  count +=CB[i][1]
  result +=CB[i][0]*CB[i][1]
  i +=1

result -= (count-N)*(CB[i-1][0])
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A=[int(x) for x in input().split()]
BC=[]
for i in range(M):
  BC +=[list(map(int,input().split()))]
BC = sorted(BC, key=lambda x: x[1],reverse = True)
A=sorted(A)
for i in range(M):
  for j in range(BC[i][0]):
    A[j]=max(A[j],BC[i][1])
  A=sorted(A)
print(sum(A))

Fixed submission:
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
CB=[]
for i in range(M):
  B,C = map(int,input().split())
  CB +=[[C,B]]

for j in range(N):
  CB +=[[A[j],1]]

CB=sorted(CB,reverse = True)
count = 0
result =0

i=0
while count<N:
  count +=CB[i][1]
  result +=CB[i][0]*CB[i][1]
  i +=1

result -= (count-N)*(CB[i-1][0])
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
H=[]
for i in range(5):
  H += [int(input())]
X=[N,0,0,0,0,0]#移動前の人数
count=0
goal=0
while goal<N:#6番目の都市の人数がN人以下なら移動を続ける
  count +=1
  Y=[0]*6#移動後の人数
  for i in range(5):
    if X[i]>=H[i]:#一回で乗り切れないとき
      Y[i+1] += H[i]
      Y[i] += X[i]-H[i]
    elif X[i]<H[i]:#全員乗れる
      Y[i+1] +=X[i]
  goal +=Y[5]
  X=Y
print(count)

Fixed submission:
N=int(input())
H=[]
for i in range(5):
  H += [int(input())]
print(-(-N//min(H))+4)
Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K=map(int,input().split())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]
A.sort(reverse =True)
B.sort(reverse =True)
C.sort(reverse =True)
answer=[]
for p in range(min(X,K)):
  for q in range(min(Y,K)):
    for r in range(min(Z,K)):
      answer +=[A[p]+B[q]+C[r]]
answer.sort()
for i in range(K):
  print(answer[-i-1])

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=[int(x) for x in input().split()]
A.sort(reverse =True)
B.sort(reverse =True)
C.sort(reverse =True)
answer=[]
for p in range(min(X,K)):
  for q in range(min(Y,K)):
    if p*q>K:
      break
    for r in range(min(Z,K)):
      if p*q*r>K:
        break
      answer +=[A[p]+B[q]+C[r]]
answer.sort()
for i in range(K):
  print(answer[-i-1])
Buggy python submission (verdict: Runtime Error):
a,b,k =map(int,input().split())
p=[]
for i in range(int((a+b)//4)):
  if i>0:
    if a%i == 0 and b%i == 0:
      p +=[i]
print(p[-k])

Fixed submission:
a,b,k =map(int,input().split())
p=[]
for i in range(max(a,b)+1):
  if i>0:
    if a%i == 0 and b%i == 0:
      p +=[i]
print(p[-k])

Buggy python submission (verdict: Runtime Error):
a,b,k =map(int,input().split())
p=[]
for i in range(max(a,b)):
  if i>0:
    if a%i == 0 and b%i == 0:
      p +=[i]
print(p[-k+1])

Fixed submission:
a,b,k =map(int,input().split())
p=[]
for i in range(max(a,b)+1):
  if i>0:
    if a%i == 0 and b%i == 0:
      p +=[i]
print(p[-k])

Buggy python submission (verdict: Runtime Error):
a,b,k =map(int,input().split())
p=[]
for i in range(int((a+b)//4)):
  if i>0:
    if a%i == 0 and b%i == 0:
      p +=[i]
print(p[-k+1])

Fixed submission:
a,b,k =map(int,input().split())
p=[]
for i in range(max(a,b)+1):
  if i>0:
    if a%i == 0 and b%i == 0:
      p +=[i]
print(p[-k])
Buggy python submission (verdict: Time Limit Exceeded):
A,B,Q = map(int,input().split())
jinjya = [0]*(A+1)+[float('inf')]#範囲を絞るために両サイドに0と無限を挿入
tera =[0]*(B+1)+[float('inf')]
for i in range(A):
  jinjya[i+1] =int(input())
for i in range(B):
  tera[i+1] =int(input())

for i in range(Q):
  x=int(input())
#出発地点の前後の神社と寺の場所を知りたい。つまり出発点より前にある対象のインデックス
  L=0
  R=A+2
  while R-L>1:
    P=(L+R)//2
    if x<jinjya[P]:
      R=P
    else:
      L=P
  jinjya_L=L
  
  L=0
  R=B+2
  while R-L>1:
    P=(L+R)//2
    if x<tera[P]:
      R=P
    else:
      L=P
  tera_L=L

#xの左側の神社と寺のインデックスがわかったのでそれらに対して距離を測って最小を探す。
#両サイドのダミーに注意する。
  a=jinjya[jinjya_L]
  b=jinjya[jinjya_L+1]
  c=tera[tera_L]
  d=tera[tera_L+1]
  if jinjya_L==0:
    a=b
  if tera_L==0:
    c=d
  answer=min(abs(x-a)+abs(a-c),abs(x-c)+abs(c-a),abs(x-b)+abs(b-c),abs(x-c)+abs(c-b),abs(x-a)+abs(a-d),abs(x-d)+abs(d-a),abs(x-b)+abs(b-d),abs(x-d)+abs(d-b))
  print(answer)

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

A,B,Q = map(int,input().split())
jinjya = [-float('inf')]+[int(input()) for _ in range(A)]+[float('inf')]#範囲を絞るために両サイドに0と無限を挿入
tera =[-float('inf')]+[int(input()) for _ in range(B)]+[float('inf')]

for i in range(Q):
  x=int(input())
#出発地点の前後の神社と寺の場所を知りたい。つまり出発点より前にある対象のインデックス
  L=0
  R=A+2
  while R-L>1:
    P=(L+R)//2
    if x<jinjya[P]:
      R=P
    else:
      L=P
  jinjya_L=L
  
  L=0
  R=B+2
  while R-L>1:
    P=(L+R)//2
    if x<tera[P]:
      R=P
    else:
      L=P
  tera_L=L
#xの左側の神社と寺のインデックスがわかったのでそれらに対して距離を測って最小を探す。
  a=jinjya[jinjya_L]
  b=jinjya[jinjya_L+1]
  c=tera[tera_L]
  d=tera[tera_L+1]
  if jinjya_L==0:
    a=b
  if tera_L==0:
    c=d
  answer=min(abs(x-a)+abs(a-c),abs(x-c)+abs(c-a),abs(x-b)+abs(b-c),abs(x-c)+abs(c-b),abs(x-a)+abs(a-d),abs(x-d)+abs(d-a),abs(x-b)+abs(b-d),abs(x-d)+abs(d-b))
  print(answer)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
L=[0]*M
for i in range(N):
  A=[int(x) for x in input().split()]
  for j in range(A[0]):
    L[A[j]] +=1
print(L.count(N))

Fixed submission:
N,M =map(int,input().split())
se = set(range(M+1))
for i in range(N):
  A = [int(x) for x in input().split()]
  se &= set(A[1:])
print(len(se))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(x) for x in input().split()]
while len(A)>1:
  A.sort
  
  for i in range(1,len(A)):
    A[i]=A[i]%A[0]
  
  A.sort()
  
  while A[0]==0:
    A.sort()
    if A[0]==0:
      A.pop(0)
  
print(*A)
  

Fixed submission:
N=int(input())
A=[int(x) for x in input().split()]

def gcd(a,b):#最大公約数
  return a if b == 0 else gcd(b,a%b)
P=A[0]
for i in range(N):
  P=gcd(P,A[i])
print(P)
Buggy python submission (verdict: Runtime Error):
import sys
input= sys.stdin.readline

N,M = map(int,input().split())
g=max(M//N,M**0.5)#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()


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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input= sys.stdin.readline

N,M = map(int,input().split())
g=max(M//N,M**0.5)#最大公約数になる可能性のある最大値
for i in range(M-N+1):
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input= sys.stdin.readline

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(M-N+1):
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input= sys.stdin.readline

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()

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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()

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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()

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

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N,M = map(int,input().split())
A=[int(x) for x in input().split()]
B=[]
for i in range(N+1):
  B+=[sum(A[:i])]
C=[]
for i in range(N+1):
  C +=[B[i]%M]
answer=0
D = collections.Counter(C)
E = list(D.values())

for i in range(len(E)):
  answer += E[i]*(E[i]-1)//2
print(answer)

Fixed submission:
import collections
import numpy as np

N,M = map(int,input().split())
A=np.array([0]+[int(x) for x in input().split()])
B=np.mod(A.cumsum(),M)
answer=0
C = collections.Counter(B)

for x in C.values():
  answer += x*(x-1)//2
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A=[int(x) for x in input().split()]
count=0
for i in range(N):
  for j in range(i,N):
    if sum(A[i:j+1])%M==0:
      count +=1
print(count)

Fixed submission:
import collections
import numpy as np

N,M = map(int,input().split())
A=np.array([0]+[int(x) for x in input().split()])
B=np.mod(A.cumsum(),M)
answer=0
C = collections.Counter(B)

for x in C.values():
  answer += x*(x-1)//2
print(answer)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[int(X) for X in input().split()]
B=[]
for i in range(N):
  B +=[A[i]-1-i]
B = sorted(B)
p=N//2
answer=float('inf')
for i in range(B[p-1],B[p+2]):
  a=0
  for j in range(N):
    a+=abs(B[j]-i)
  answer=min(answer,a)
print(answer if answer!=float('inf') else 0)

Fixed submission:
import numpy as np
N=int(input())
A=[int(X) for X in input().split()]
B=[]
for i in range(N):
  B +=[A[i]-1-i]
B = np.array(sorted(B))
x = B[N//2]
answer = np.abs(B-x).sum()
print(answer)

Buggy python submission (verdict: Runtime Error):
import statistics
import math

N=int(input())
A=[int(x) for x in input().split()]
def ka(b):
  k=0
  for i in range(N):
    k += abs(A[i]-(b+i+1))
  return k

B=[]
for j in range(N):
  B +=[A[j]-j-1]
B=sorted(B)

result=float('inf')
for k in range(B[N//2],B[N//2+2]):
  result =min(result,ka(k))
print(result)


Fixed submission:
import numpy as np
N=int(input())
A=[int(X) for X in input().split()]
B=[]
for i in range(N):
  B +=[A[i]-1-i]
B = np.array(sorted(B))
x = B[N//2]
answer = np.abs(B-x).sum()
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(x) for x in input().split()]
def ka(b):
  k=0
  for i in range(N):
    k += abs(A[i]-(b+i+1))
  return k
answer = float('inf')
for j in range(-max(A)*2,max(A)*2):
  answer = min(answer,ka(j))
print(answer)

Fixed submission:
import numpy as np
N=int(input())
A=[int(X) for X in input().split()]
B=[]
for i in range(N):
  B +=[A[i]-1-i]
B = np.array(sorted(B))
x = B[N//2]
answer = np.abs(B-x).sum()
print(answer)