Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    N = i_input()
    A = i_list()
    ans = 0
    for i, a in enumerate(A):
        for ii, aa in enumerate(A):
            if i == ii:
                continue
            if a % aa == 0:
                break
        else:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())

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

def main():
    N = i_input()
    A = i_list()
    ans = 0
    max_a = max(A)
    p = [0] * (max_a + 1)
    for i in A:
        for j in range(i , max_a + 1, i):
            p[j] += 1
    for i in A:
        if p[i] < 2:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = n - 1
p = 1
for c in range(2, int(n / 2)):
    if p == 1 and c > (n ** 0.5):
        break
    if n % c == 0:
        p = c
        w = int(n / c)
        if (w + c - 2) < a:
            a = (w + c -2)
        else:
            continue
    else:
        continue
print(a)


Fixed submission:
n = int(input())
a = n - 1
p = 1
for c in range(2, int((n ** 0.5) * 2)):
    if p % 2 == 1 and c > (n ** 0.5):
        break
    if n % c == 0:
        p = c
        w = int(n / c)
        if (w + c - 2) < a:
            a = (w + c -2)
        else:
            continue
    else:
        continue
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
ans = 0
for c in range(N):
    for cc in range(c + 1, N):
        for ccc in range(cc + 1, N):
            ab = L[c]
            bb = L[cc]
            cb = L[ccc]
            if ab < (bb + cb) and bb < (ab + cb) and cb < (ab + bb):
                ans += 1
print(ans)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for a in range(N):
    for b in range(a):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L, ab)
        l = a + 1
        ans += max(r - l, 0)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
L = map(int, input().split())
ans = 0
for c in range(N):
    for cc in range(c + 1, N):
        for ccc in range(cc + 1, N):
            ab = L[c]
            bb = L[cc]
            cb = L[ccc]
            if ab < (bb + cb) and bb < (ab + cb) and cb < (ab + bb):
                ans += 1
print(ans)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for a in range(N):
    for b in range(a):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L, ab)
        l = a + 1
        ans += max(r - l, 0)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(n) for n in input().split()]
s = 0
for c in range(n):
    for cc in range(1, n):
        if cc <= c:
            continue
        else:
            for ccc in range(2, n):
                if ccc <= cc:
                    continue
                else:
                    ab = a[c]
                    bb = a[cc]
                    cb = a[ccc]
                    if ab < (bb + cb) and bb < (ab + cb) and cb < (ab + bb):
                        s += 1

print(s)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for a in range(N):
    for b in range(a):
        ab = L[a] + L[b]
        r = bisect.bisect_left(L, ab)
        l = a + 1
        ans += max(r - l, 0)
print(ans)
Buggy python submission (verdict: Runtime Error):
MAX=101010
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

a=[0]*MAX
for i in range(MAX):
  if i%2==0:
    continue
  if is_prime[i] and is_prime[(i+1)//2]:
    a[i]=1

s=[0]
for x in a:
  s.append(s[-1]+x)

Q=int(input())
for _ in range(Q):
  l,r=map(int,input().split())
  print(s[r+1]-s[l])


Fixed submission:
mod=10**9+7

N=int(input())
A=list(map(int,input().split()))
B=[0]
for x in A:
  B.append(B[-1]+x)

ans=0
for i in range(N):
  s=(B[N]-B[i+1])%mod
  ans+=A[i]*s
  ans%=mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  A=[C if i==B else i for i in A]
  a=collections.Counter(A)
  check=list(a.items())
  ans=0
  for j in range(len(check)):
    ans+=check[j][0]*check[j][1]
  print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=sum(A)
check=[0]*(10**5+1)
for key in A:
  check[key]+=1
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  if check[B]==0:
    print(ans)
  else:
    x=C-B
    ans+=check[B]*x
    print(ans)
    check[C]+=check[B]
    check[B]=0

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  A = [C if i==B else i for i in A]
  print(sum(A))


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=sum(A)
check=[0]*(10**5+1)
for key in A:
  check[key]+=1
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  if check[B]==0:
    print(ans)
  else:
    x=C-B
    ans+=check[B]*x
    print(ans)
    check[C]+=check[B]
    check[B]=0

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  for j in range(len(A)):
    if A[j]==B:
      A[j]=C
  print(sum(A))


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=sum(A)
check=[0]*(10**5+1)
for key in A:
  check[key]+=1
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  if check[B]==0:
    print(ans)
  else:
    x=C-B
    ans+=check[B]*x
    print(ans)
    check[C]+=check[B]
    check[B]=0
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int X,N; cin >>X >>N;
  if (N==0) {cout <<X <<endl; return 0;}
  vector<int> p(N);
  rep(i,0,N) cin >>p[i];
  sort(p.begin(),p.end());
  int ans=0;
  int check=INT_MAX;
  rep_eq(i,p[0],p[N-1]) {
    bool check_flag=true;
    rep(j,0,N) {
      if (i==p[j]) {check_flag=false; break;}
    }
    if (check_flag) {
      if (abs(X-i)<check) {check=abs(X-i); ans=i;}
    }
  }
  cout <<ans <<endl;
  return 0;
}


Fixed submission:
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
p=list(map(int,input().split()))
ans=0
check=100
for i in range(101+1):
  if i in p:
    continue
  if abs(X-i)<check:
    check=abs(X-i)
    ans=i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
teisuu1=10**6
N=int(input())
A=list(map(int,input().split()))
count_A=Counter(A)
dp=[True]*(teisuu1+1)
s=list(set(A))
for i in s:
  temp=i*2
  while temp<=max(s):
    dp[temp]=False
    temp+=i
ans=0
for i in A:
  if count_A[i]==1 and dp[i]==True:
    ans+=1
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
dp=[0]*(10**6+1)
ans=0
for i in A:
  if dp[i]==0:
    for j in range(i,10**6+1,i):
      dp[j]+=1
  else:
    dp[i]+=1
for i in A:
  if dp[i]==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
teisuu1=10**6
N=int(input())
A=list(map(int,input().split()))
count_A=Counter(A)
dp=[True]*(teisuu1+1)
s=list(set(A))
for i in s:
  temp=i*2
  while temp<=max(s):
    dp[temp]=False
    temp+=i
ans=0
for i in A:
  if count_A[i]==1 and dp[i]==True:
    ans+=1
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
dp=[0]*(10**6+1)
ans=0
for i in A:
  if dp[i]==0:
    for j in range(i,10**6+1,i):
      dp[j]+=1
  else:
    dp[i]+=1
for i in A:
  if dp[i]==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
dp=[0]*(10**6+1)
ans=0
for i in A:
  if dp[i]==0:
    for j in range(i,10**6+1,i):
      dp[j]+=1
  else:
    dp[i]+=1
for i in A:
  if dp[i]==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
  flag=True
  for j in range(N):
    if i!=j and A[i]%A[j]==0:
      flag=False
      break
  if flag:
    ans+=1
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
dp=[0]*(10**6+1)
ans=0
for i in A:
  if dp[i]==0:
    for j in range(i,10**6+1,i):
      dp[j]+=1
  else:
    dp[i]+=1
for i in A:
  if dp[i]==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
  flag=True
  for j in range(N):
    if i!=j and A[i]%A[j]==0:
      flag=False
      break
  if flag:
    ans+=1
print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
dp=[0]*(10**6+1)
ans=0
for i in A:
  if dp[i]==0:
    for j in range(i,10**6+1,i):
      dp[j]+=1
  else:
    dp[i]+=1
for i in A:
  if dp[i]==1:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k] and (j-i)!=(k-j):
        ans+=1

print(ans)


Fixed submission:
from collections import *

N=int(input())
S=input()
c=Counter(S)

ans=c['R']*c['G']*c['B']

for i in range(1,N//2+1):
  for j in range(i,N-i):
    if S[j-i]!=S[j] and S[j]!=S[j+i] and S[j+i]!=S[j-i]:
      ans-=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k] and (j-i)!=(k-j):
        ans+=1

print(ans)


Fixed submission:
from collections import *

N=int(input())
S=input()
c=Counter(S)

ans=c['R']*c['G']*c['B']

for i in range(1,N//2+1):
  for j in range(i,N-i):
    if S[j-i]!=S[j] and S[j]!=S[j+i] and S[j+i]!=S[j-i]:
      ans-=1

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x,y):
  return (x*y)//math.gcd(x,y)

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


Fixed submission:
import fractions

def lcm(x,y):
  return (x*y)//fractions.gcd(x,y)

A,B=map(int,input().split())
print(lcm(A,B))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
check=[]
for i in range(1,N+1):
  check.append(str(A.index(i)+1))
print(" ".join(check))


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
check=[0]*N
for i in range(N):
  check[A[i]-1]=i+1
[print(x,end=" ") for x in check]
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
check=[K]*N
for i in range(Q):
  A=int(input())-1
  for j in range(N):
    if j!=A:
      check[j]-=1
for i in range(N):
  print("Yes" if check[i]>0 else "No")


Fixed submission:
N,K,Q=map(int,input().split())
check=[K-Q]*N
for i in range(Q):
  A=int(input())-1
  check[A]+=1
for i in range(N):
  print("Yes" if check[i]>0 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy

N=int(input())
A=[int(input()) for i in range(N)]
for i in range(N):
  a=deepcopy(A)
  del a[i]
  print(max(a))


Fixed submission:
N=int(input())
A=[int(input()) for i in range(N)]
max_val1=sorted(A)[-1]
max_val2=sorted(A)[-2]
for x in A:
  print(max_val2 if x==max_val1 else max_val1)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())
ans=0
for r in range(3000+1):
  for g in range(3000+1):
    temp=r*R+g*G
    if N>=temp and (N-temp)%B==0:
      ans+=1
print(ans)


Fixed submission:
R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R+1):
  for j in range((N-i*R)//G+1):
    k=N-i*R-j*G
    if k%B==0 and k>=0:
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
print(N%(N//K))


Fixed submission:
N,K=map(int,input().split())
print(1 if N%K!=0 else 0)
Buggy python submission (verdict: Runtime Error):
N=int(input())
dp=[0]*100000
a=1
b=6
c=9
for i in range(1,N+1):
  if i>=b*6:
    b*=6
  if i>=c*9:
    c*=9
  if i<6:
    dp[i]=i
  elif i<9:
    dp[i]=min(dp[i-a]+1,dp[i-b]+1)
  else:
    dp[i]=min([dp[i-a]+1,dp[i-b]+1,dp[i-c]+1])
print(dp[N])


Fixed submission:
N=int(input())
ans=N
for i in range(N+1):
  cnt=0
  t=i
  while t>0:
    cnt+=t%6
    t//=6
  j=N-i
  while j>0:
    cnt+=j%9
    j//=9
  ans=min(ans,cnt)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
MAX=10**5+1
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

Q=int(input())
for _ in range(Q):
  ans=0
  l,r=map(int,input().split())
  for i in range(l,r+1,2):
    if is_prime[i] and is_prime[(i+1)//2]:
      ans+=1
  print(ans)


Fixed submission:
MAX=101010
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

a=[0]*MAX
for i in range(MAX):
  if i%2==0:
    continue
  if is_prime[i] and is_prime[(i+1)//2]:
    a[i]=1

s=[0]
for x in a:
  s.append(s[-1]+x)

Q=int(input())
for _ in range(Q):
  l,r=map(int,input().split())
  print(s[r+1]-s[l])

Buggy python submission (verdict: Time Limit Exceeded):
MAX=10**5+1
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

Q=int(input())
for _ in range(Q):
  ans=0
  l,r=map(int,input().split())
  for i in range(l,r+1,2):
    if is_prime[i] and is_prime[(i+1)//2]:
      ans+=1
  print(ans)


Fixed submission:
MAX=101010
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

a=[0]*MAX
for i in range(MAX):
  if i%2==0:
    continue
  if is_prime[i] and is_prime[(i+1)//2]:
    a[i]=1

s=[0]
for x in a:
  s.append(s[-1]+x)

Q=int(input())
for _ in range(Q):
  l,r=map(int,input().split())
  print(s[r+1]-s[l])
Buggy python submission (verdict: Runtime Error):
from math import *

def lcm(x,y):
  return (x*y)//gcd(x,y)

N=int(input())
T=[int(input()) for _ in range(N)]
a=T[0]
for i in range(1,N):
  ans=lcm(a,T[i])
  a=ans
print(ans)


Fixed submission:
from math import gcd

N=int(input())
T=list(int(input()) for _ in range(N))
ans=T[0]
for i in range(1,N):
  ans=ans*T[i]//gcd(ans,T[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

K,S=map(int,input().split())
li_=list(product(range(K+1),repeat=3))
ans=0
for x in li_:
  if sum(x)==S:
    ans+=1
print(ans)


Fixed submission:
K,S=map(int,input().split())
ans=0
for X in range(0,K+1):
  for Y in range(0,K+1):
    Z=S-X-Y
    if 0<=Z and Z<=K:
      ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product

K,S=map(int,input().split())
li_=list(product(range(K+1),repeat=3))
ans=0
for x in li_:
  if sum(x)==S:
    ans+=1
print(ans)


Fixed submission:
K,S=map(int,input().split())
ans=0
for X in range(0,K+1):
  for Y in range(0,K+1):
    Z=S-X-Y
    if 0<=Z and Z<=K:
      ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
ans=0
for X in range(0,K+1):
  for Y in range(0,K+1):
    for Z in range(0,K+1):
      if X+Y+Z==S:
        ans+=1
print(ans)


Fixed submission:
K,S=map(int,input().split())
ans=0
for X in range(0,K+1):
  for Y in range(0,K+1):
    Z=S-X-Y
    if 0<=Z and Z<=K:
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
print(math.factorial(N))


Fixed submission:
N=int(input())
ans=0
for i in range(1,N+1):
  ans+=i
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline

#エラトステネスの篩と素因数分解

from collections import Counter

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a
M = 10**6 + 8
prime = [0]*M
for i in range(2, M):
    if prime[i]:
        continue
    for j in range(i, M, i):
        if not prime[j]:
            prime[j] = i

def pd(x):
    C = Counter()
    while x > 1:
        C[prime[x]] += 1
        x //= prime[x]
    return C


N = int(readline())
A = list(map(int, readline().split()))

D = Counter()

for a in A:
    c = pd(a)
    for k in c.keys():
        D[k] += 1


res = A[0]
for a in A:
    res = gcd(res, a)
ans = None
if max(D.values()) == 1:
    ans = 'pairwise coprime'
elif res == 1:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'

print(ans)


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

#エラトステネスの篩と素因数分解

from collections import Counter

def gcd(a,b):
    while b:
        a, b = b, a%b
    return a
M = 10**6 + 8
prime = [0]*M
for i in range(2, M):
    if prime[i]:
        continue
    for j in range(i, M, i):
        if not prime[j]:
            prime[j] = i

def pd(x):
    C = Counter()
    while x > 1:
        C[prime[x]] += 1
        x //= prime[x]
    return C


N = int(readline())
A = list(map(int, readline().split()))

D = Counter()

for a in A:
    c = pd(a)
    for k in c.keys():
        D[k] += 1


res = A[0]
for a in A:
    res = gcd(res, a)
ans = None
if all(a == 1 for a in A) or max(D.values()) == 1:
    ans = 'pairwise coprime'
elif res == 1:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
from math import floor
from decimal import Decimal

N = int(readline())
A = [Decimal(readline()) for _ in range(N)]


G = 10**10
Aint = [int(a) for a in A if int(a) == a]
Afl = [int(a*G) for a in A if int(a) != a]


H = 200
geta = 100
Grid = [[0]*H for _ in range(H)]


i25 = []
for ai in Aint:
    i2 = 0
    i5 = 0
    while ai%2 == 0:
        ai //= 2
        i2 += 1
    while ai%5 == 0:
        ai //= 5
        i5 += 1
    i25.append((i2, i5)) 

for af in Afl:
    i2 = -10
    i5 = -10
    while af%2 == 0:
        af //= 2
        i2 += 1
    while af%5 == 0:
        af //= 5
        i5 += 1
    i25.append((i2, i5)) 


for i2, i5 in i25:
    Grid[geta+i2][geta+i5] += 1

for i in range(geta+90, geta-90, -1):
    for j in range(geta+90, geta-90, -1):
        Grid[i][j] += Grid[i][j+1]

for j in range(geta+90, geta-90, -1):
    for i in range(geta+90, geta-90, -1):
        Grid[i][j] += Grid[i+1][j]


lai = len(Aint)
ans = 0
for i2, i5 in i25:
    ans += Grid[geta-i2][geta-i5]
    #print(i2, i5, Grid[geta-i2][geta-i5])
print((ans-lai)//2)

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

G = 10**10
lai = 0
def Decimal(x):
    global lai
    a = x.strip().split('.')
    if len(a) == 1 or all([ai == '0' for ai in a[1]]):
        lai += 1
        return int(a[0])*G
        
    lf = len(a[1])
    i, f = map(int, a)
    return (i*10**(lf) + f)*10**(10-lf)
    
    
N = int(readline())
A = [Decimal(readline()) for _ in range(N)]

H = 200
geta = 100
Grid = [[0]*H for _ in range(H)]
i25 = []


for af in A:
    i2 = -10
    i5 = -10
    while af%2 == 0:
        af //= 2
        i2 += 1
    while af%5 == 0:
        af //= 5
        i5 += 1
    i25.append((i2, i5)) 


for i2, i5 in i25:
    Grid[geta+i2][geta+i5] += 1

for i in range(geta+90, geta-90, -1):
    for j in range(geta+90, geta-90, -1):
        Grid[i][j] += Grid[i][j+1]

for j in range(geta+90, geta-90, -1):
    for i in range(geta+90, geta-90, -1):
        Grid[i][j] += Grid[i+1][j]


ans = 0
for i2, i5 in i25:
    ans += Grid[geta-i2][geta-i5]
    #print(i2, i5, Grid[geta-i2][geta-i5])
print((ans-lai)//2)
Buggy python submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline

MOD = 10**9+7
N, K = map(int, readline().split())
A = list(map(int, readline().split()))
posi = [(a, 0) for a in A if a >= 0]
nega = [(-a, 1) for a in A if a < 0]
B = posi + nega
B.sort(reverse = True)

if N == len(nega):
    if K & 1:
        A.sort(reverse = True)
    else:
        A.sort()
    ans = 1
    
    for i in range(K):
        ans = (ans*A[i]) % MOD  
    print(ans)
else:
    cnt = 0
    for i in range(K):
        _, s = B[i]
        cnt ^= s
    
    res, _ = map(list, zip(*B[:K]))
    if cnt:
        pf, nf, ps, ns = 0, 0, 0, 0
        for i in range(K):
            b, s = B[i]
            if s:
                nf = b
            else:
                pf = b
        
        for i in range(K, N):
            b, s = B[i]
            if s:
                ns = b
                break
        for i in range(K, N):
            b, s = B[i]
            if not s:
                ps = b
                break
        
        if ns*nf >= pf*ps:
            res.remove(pf)
            res.append(ns)
        else:
            res.remove(nf)
            res.append(ps)
        
    ans = 1
    for r in res:
        ans = (ans*r)%MOD
        
    print(ans)
        
    

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

MOD = 10**9+7
N, K = map(int, readline().split())
A = list(map(int, readline().split()))
posi = [(a, 0) for a in A if a >= 0]
nega = [(-a, 1) for a in A if a < 0]
B = posi + nega
B.sort(reverse = True)

if N == K:
    ans = 1
    for i in range(K):
        ans = (ans*A[i]) % MOD  
    print(ans)
elif N == len(nega):
    if K & 1:
        A.sort(reverse = True)
    else:
        A.sort()
    ans = 1
    for i in range(K):
        ans = (ans*A[i]) % MOD  
    print(ans)
else:
    cnt = 0
    for i in range(K):
        _, s = B[i]
        cnt ^= s
    
    res, _ = map(list, zip(*B[:K]))
    if cnt:
        pf, nf, ps, ns = None, None, 0, 0
        for i in range(K):
            b, s = B[i]
            if s:
                nf = b
            else:
                pf = b
        
        for i in range(K, N):
            b, s = B[i]
            if s:
                ns = b
                break
        for i in range(K, N):
            b, s = B[i]
            if not s:
                ps = b
                break
        
        if pf is None:
            res.remove(nf)
            res.append(ps)
        elif nf is None:
            res.remove(pf)
            res.append(ns)
        elif ns*nf >= pf*ps:
            res.remove(pf)
            res.append(ns)
        else:
            res.remove(nf)
            res.append(ps)
        
    ans = 1
    for r in res:
        ans = (ans*r) % MOD
        
    print(ans)