c programme de moyenne glissante
c 
      real delay,jj(65535),lp(65535),val(65535),nb(65535),box
      integer ndat,i,j
      open(unit=1,file='moyenne.in',status='old')
          read(1,*) box
          read(1,*) ndat
          do i=1,ndat
             read(1,*) jj(i),lp(i)
          enddo
      close(unit=1)
      do i=1,ndat
         val(i)=0.
         nb(i)=0.
         do j=1,ndat
            delay=abs(jj(j)-jj(i))
            if (delay.le.box/2.) then
               val(i)=val(i)+lp(j)
               nb(i)=nb(i)+1.
            endif
         enddo
         if (nb(i).gt.5) then
            val(i)=val(i)/nb(i)
         else
            val(i)=-1.
         endif
      enddo
      open(unit=1,file='moyenne.out',status='unknown')
          do i=1,ndat
             write(1,*) jj(i),val(i)
          enddo
      close(unit=1)
      stop
      end

