text:
Swap, delete and repeat
Introduction
Let's observe the following string:
ABCDEFGHIJKLMNOP

If we swap the ends of the string, which are these:
ABCDEFGHIJKLMNOP
^^            ^^

We get the following result:
BACDEFGHIJKLMNPO

After that, we delete the ends of the string, which in this case are B and O. The result is:
ACDEFGHIJKLMNP

If we repeat the process, we get the following list:
N     Result

2     ADEFGHIJKLMP
3     AEFGHIJKLP
4     AFGHIJKP
5     AGHIJP
6     AHIP
7     AP

You can see that for N = 5, the result is AGHIJP. At N = 7, the length of the string is smaller than 3, so N > 7 is considered invalid in this case.
The Task
Given a string S with at least length 4 and the number of repetitions N > 0, output the final result. You can assume that N is always valid.
Test cases
Input                               >  Output

N = 3, S = ABCDEFGHIJKLMNOP         >  AEFGHIJKLP
N = 1, S = Hello                    >  Hlo
N = 2, S = 123321                   >  11

This is code-golf, so the submission with the least amount of bytes wins! For the simplicity, you can assume that the string will only contain alphanumeric characters.

Question: Is it okay to take N in unary with something like ' as the counting character? For example: ''123321?

@daavko Yes, unary is acceptable by default

@Adnan Unary format can be used for N, but can it be a string, with quotes? I mean, for N=3 take '111' (as opposed to 111)

@LuisMendo Yes, you may use that

It looks to me like we skip 1 and remove N - is this allowed as an answer or does the code need to swap delete and repeat?

@VisualBean Good observation :), that is also possible. I always try to make the challenges have multiple ways of solving it.

MATL, 8 9 12 13 bytes
th"P[]2(

Inputs are: first N as a unary string with quotes (allowed by the challenge); second S as a string with quotes (quotes in strings are allowed by default); separated by a linebreak.
This works by flipping the string, removing its second element, and repeating for a total of 2*N times.
Try it online!
th       % implicitly take first input (N) as a unary string. Concatenate horizontally
         % with itself: gives a string of 2*N ones
"        % for each (i.e., repeat 2*N times)
  P      %   flip string. Take S implicitly as input the first time
  []     %   empty array (used as new contents)
  2      %   2 (used as index)
  (      %   assign [] to position 2 of string; that is, remove second element
         % implicitly end for each
         % implicitly display

Explanation? :P

@VoteToClose Sure :-) I had to run. I've just added it

Retina, 44 20 bytes
Crossed out 44 is still regular 44 :(
+`'(\w).(.*).\B
$1$2

Assumes input in following format (in unary - counting character: '):
{number of repeats}{string}
For example: '''''''ABCDEFGHIJKLMNOP
There is no space between number of repeats and the string.
Thanks @MartinBüttner for shaving off 24 bytes!
Try it online!

Related.

@MartinBüttner Aha! So this was your psychological masterplan :p

@Adnan ¯\(ツ)/¯

Crossed out 44 looks like crossed out 11...

Python 2, 31 bytes
lambda s,n:s[0]+s[n+1:~n]+s[-1]

I think this works?

It's also valid python 3.

Labyrinth, 40 bytes
<
,,}:?
.
;("   {(={}{".
,",;=};} }) "{@

Input is N followed by the string, separated by any non-numeric character.
Try it online!
This was written in collaboration with Sp3000 (which means I couldn't be bothered to figure out an algorithm, so he started working on it, came up with 118 byte solution but couldn't be bothered golfing it, so I did the golfing... yay for teamwork).
Explanation
Sp's usual primer (as usual slightly modified):

Labyrinth is a stack-based 2D language with two stacks, main and auxiliary. Pretty much everything happens on the main stack, but you can shift values over to the other one, e.g. to reverse them or save them for later.
The stacks are bottomless and filled with zeroes, so popping from an empty stack is not an error.
Execution starts from the first valid character (here the top left). At each junction, where there are two or more possible paths for the instruction pointer (IP) to take, the top of the stack is checked to determine where to go next. Negative is turn left, zero is go forward and positive is turn right. While this was meant to make the code look like winding, twisty passages, there's nothing stopping you from making "rooms" where these conditions are checked in every cell. Those can yield quite unpredictable behaviour, but are great for golfing.
The source code (and therefore the layout of the labyrinth) can be modified at runtime using <>^v which cyclically shifts a row or column or the grid.
" are no-ops.

Here we go.
The code starts on the <, which is a golfing trick I've used a few times when starting with a long piece of linear code. It shifts the first row cyclically to the left, with the IP on it, so the source then looks like this:
              <
,,}:?
.
;("   {(={}{".
,",;=};} }) "{@

But now the IP can't move anywhere, so it executes the < again. This continues until we reach this state:
    <
,,}:?
.
;("   {(={}{".
,",;=};} }) "{@

At this point, the IP can leave the cell and begin executing the second line starting from the ?. So here's the linear code broken down:
?   # Read the first integer on STDIN, i.e. N.
:}  # Duplicate it and move one copy over to the auxiliary stack.
,   # Read the separator character.
,.  # Read the first character of the input string and directly print it.

The IP now enters this 3x2 room, which is actually two tightly-compressed (overlapping) 2x2 clockwise loops. The first loop reads and discards N-1 characters from STDIN.
;   # Discard the top of the stack. On the first iteration, this is the
    # separator we've already read. On subsequent iterations this will be
    # one of the N-1 characters from the input string.
(   # Decrement N. If this hits zero, we leave the loop, otherwise we continue.
,   # Read the next character from STDIN to be discarded.

Now we enter the second loop which reads the remainder of the input string. We can detect EOF because , will return -1 in that case, making the IP turn left.
,   # Read a character. Exit the loop if EOF.
(   # Decrement it.

That decrement isn't actually useful, but we can undo it later for free and here it allows us to overlap the two loops.
If we take the 5 ABCDEFGHIJKLMNOP input as an example, the stack looks like this:
Main [ ... 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' -1  |  5 ... ] Auxiliary

Note that these actually correspond to the input characters FGHIJKLMNOP (because we decremented them), and that we don't actually want to print the first of those (we've only discarded N-1 characters, but want to skip N).
Now there's a short linear bit that prepares the stack for the next loop:
;   # Discard the -1.
=   # Swap the tops of the stacks, i.e. N with the last character.
    # By putting the last character on the auxiliary stack, we ensure that
    # it doesn't get discarded in the next loop.
}   # Move N over to the auxiliary stack as well.

The stacks now look like:
Main [ ... 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N'  |  5 'O' ... ] Auxiliary

We enter another 2x2 clockwise loop. This discards the top N characters from the main stack:
;   # Discard the top of the main stack.
{   # Pull N over from the auxiliary stack.
(   # Decrement it. It it's 0 we leave the loop.
}   # Push N back to the auxiliary stack.

When we exit the loop = swaps that 0 and the last character of the input string again. Now the stacks look like this:
Main [ ... 'E' 'F' 'G' 'H' 'I' 'O'  |  ... ] Auxiliary

We want to print the contents of the main stack (except the bottom element and all incremented by 1), from the left. That means we need to get it over to the auxiliary stack. That's what the next 2x2 (clockwise) loop does:
{   # Pull an element over from the auxiliary stack. This is necessary so we
    # have a 0 on top of the stack when entering the loop, to prevent the IP
    # from turning right immediately.
}   # Move the top of the main stack back to the auxiliary stack. If this was the
    # bottom of the stack, exit the loop.
)   # Increment the current character.
}   # Move it over to the auxiliary stack.

Stacks now:
Main [ ...  |  'F' 'G' 'H' 'I' 'J' 'P] ... ] Auxiliary

We move the first of those (the one we don't want to print) back to the main stack with {. And now we enter final 2x2 (counterclockwise) loop, which prints the rest:
{   # Pull another character over from the auxiliary stack. Exit the loop
    # if that's the zero at the bottom of the stack.
.   # Print the character.

Finally we terminate the program with @.

Mathematica, 29 bytes
My first answer!
#~Delete~{{2},{-2}}&~Nest~##&

The crux of bracketless Mathematica!
Function inputs are a list (of characters, or whatever) and a number.

Welcome to PPCG! :D Nice first answer.

JavaScript (ES6), 39 bytes
(s,n)=>s[0]+s.slice(++n,-n)+s.slice(-1)

Turns out I just reinvented @Sp3000's answer.

Jelly, 8 bytes
Ḣ1¦UðḤ}¡

Try it online!
How it works
Ḣ1¦UðḤ}¡  Main link. Left input: S (string). Right input: N (deletions)

Ḣ         Pop the first element of S.
          This return the element and modifies S.
 1¦       Apply the result to the first index.
          This replaces the first character of the popped S with the popped char.
   U      Upend/reverse the resulting string.
    ð     Convert the preceding chain into a (dyadic) link.
     Ḥ}   Apply double to the right input.
          This yields 2N.
       ¡  Repeat the link 2N times.

Jelly, 10 bytes
Ḣ;ṪjḊṖ$Ɠ¡F

Input the number via STDIN, and the string via command line args. Thanks to @Dennis for a lot of hints/help getting this to work (Jelly still eludes me).
Try it online!
Ḣ;Ṫ               Pop first and last chars of string and concatenate
   j              Join by...
       Ɠ¡           Execute n times...
    ḊṖ$               Drop first, drop last of string ($ combines the two monadically)
         F        Flatten to filter out empty lists, since Jelly's j is weird

Honest question, how do the 10 bytes work? Isn't this in UTF-8 (and shouldn't it be at least 16 bytes because ḢṪḊṖƓ¡ are all using more than 1 byte) or do you use some kind of character code table for readability?

@AutomatedChaos The latter :) (click on the link where the word "bytes" is in the header). Jelly uses a custom code page, akin to languages like APL.

Pyth, 13 bytes
++hz:zhQ_hQez

Explanation:
              - autoassign z = input()
              - autoassign Q = eval(input())
    :zhQ_hQ   -  z[Q+1:-(Q+1)]
++hz       ez - z[0]+^+z[-1]

Try it here

Python 2, 49 48 bytes
g=lambda s,n:n and g(s[0]+s[2:-2]+s[-1],n-1)or s

Try it here with testcases!
Simple recursive solution. Removes the second and last second element from the input string and calls itself with this and n-1 until n=0.
edit: Feeling kinda stupid, looking at the other python solution. Guess I just like recursion too much...

Vitsy, 12 9 (code) + 1 (newline for function declaration) = 10 bytes
\o/
Expects input on the stack as the string followed by the number.
2*\[vXvr]
2*         Multiply by 2.
  \[    ]  Do the stuff in the brackets that many times. (input num * 2)
    v      Take the top item off the stack and save it as a local variable.
     X     Remove the top item of the stack.
      v    Push the temporary variable back onto the stack.
       r   Reverse the stack.
Which you can call with:
'String' r <number> 1m Z
2*\[vXvr]
This is a function that leaves the resultant string on the stack. I have provided it as a program in the TryItOnline link.
TryItOnline!

@Adnan Fixed - that places me in close proximity to Pyth. D:

But still one byte ahead :D

@Adnan Could I get away with saying that it expects items on the stack rather than input? Or is that a no-no?

I'm not sure what the policy is for that, but if you can find a meta post about items already on the stack, it's fine :)

@Adnan There's a meta post about items already being on the tape for languages like brainfuck. I'll ask about it in meta (because that's actually super important for Vitsy. :D)

Ruby, 29 bytes
->s,n{s[0]+s[n+1...~n]+s[-1]}

Very straightforward.
~ trick stolen from Sp's answer, which saves a byte over s[n+1..-2-n]. (It works because ~n is -1-n in two's-complement, and then ... is an exclusive range.)

Perl, 36 32 + 1 = 33 bytes
for$i(1..<>){s;\B.(.+).(.);$1$2;}

Requires -p flag and takes input on two lines, with numbers of iterations at the end:
$ perl -pe'for$i(1..<>){s;\B.(.+).(.);$1$2;}' <<< $'ABCDEFGHIJKLMNOP\n4'
AFGHIJKP

Ungolfed?
for $i ( 1..<> ) {
  s;
  \B.(.+).(.);$1$2;x
}

C, 96 bytes
i;main(c,v,p)char**v,*p;{i=atoi(v[2])+1;c=strlen(p=v[1]);printf("%c%.*s%s",*p,c-2*i,p+i,p+c-1);}

Ungolfed
i; /* Param 2, the number of chars to remove */

main(c,v,p)char**v,*p;
{
    i=atoi(v[2])+1; /* convert param 2 to integer */
    c=strlen(p=v[1]); /* Length of the input */
    printf("%c%.*s%s",*p, /* Print the first char... */
        c-2*i, /* a number of characters equal to the length minus twice the input... */
        p+i, /* skip the "removed" chars... */
        p+c-1); /* Print the last character of the string */
}

Rust, 135 bytes
Well, that's a pretty terrible length.
fn f(s:&str,n:usize)->String{let s=s.as_bytes();s[..1].iter().chain(&s[n+1..s.len()-n-1]).chain(s.last()).map(|d|*d as char).collect()}

Pretty-printed:
fn f(s: &str, n: usize) -> String {
    let s = s.as_bytes();
    s[..1].iter()
          .chain(&s[n+1..s.len()-n-1])
          .chain(s.last())
          .map(|d| *d as char)
          .collect()
}

You can get it down to 104 bytes if we allow bytestrings instead of proper strings.
fn f(s:&[u8],n:usize)->Vec<u8>{let mut r=vec![s[0]];r.extend(&s[n+1..s.len()-n-1]);r.extend(s.last());r}

Pretty-printed:
fn f(s: &[u8], n: usize) -> Vec<u8> {
    let mut r = vec![s[0]];
    r.extend(&s[n+1..s.len()-n-1]);
    r.extend(s.last());
    r
 }

Curious if anyone can do better.

CJam, 12 bytes
q~{VW@)t(t}*

Try it online!
How it works
q~            Read and evaluate all input. This pushes S (string) and N (integer).
  {       }*  Do the following N times:
   VW           Push 0 and -1.
     @          Rotate S on top of them.
      )         Pop the last character of S.
       t        Set the item at index -1 to that character.
        (       Pop the first character of S.
         t      Set the item at index 0 to that character.

Octave, 28 bytes
@(S,N)S([1,N+2:end-N-1,end])

Index the string, omitting S(2:N+1) and S(end-N:end-1).
Sample run on ideone.

Vim, 27 bytes
o0lxehx <ESC>"ay0ddA@a<ESC>B"bdWx@b

Input is expected to be in the form STRING N on the first line with no other characters.
Explanation:
#Write a macro to do one round of the swap and delete and save to register a
o0lxehx <ESC>"ay0dd

#Append register a to N and save in register B so it will run @a N times.
A@a<ESC>B"bdWx

# Actually run the macro
@b

mSL - 137 bytes
c {
%l = $len($1)
return $mid($+($mid($1,2,1),$left($1,1),$right($left($1,-2),-2),$right($1,1),$mid($1,$calc(%l -1),1)),2,$calc(%l -2))
}

Explanation:
%l = $len($1) will get the length of the input string and saves it in variable called l
$right(<input>,<length>) and $left(<input>,<length> can be used to return the left or right most part of the original string respectably. $left always return text starting from the very left side while $right always return text starting from the right side. If the length specified is a negative number, $left and $right return the entire text minus that many characters from their respective sides.
$mid(<string>,<start>,[length]) is used to get a substring from the middle of the string. Start is the start of the substring from the left. A negative value indicates a start from the right. In both case, an optional length can be specified. A negative length can be used to remove that many characters from the end. So I used it to retrieve the second character and the second last character by using the length of the input string.
$calc(<input>) is used to perform mathematical calculations

Welcome to PPCG! It's generally a good idea to add some annotations or an explanation of your code.

@ZachGates Thanks! Will remember this for the next time!

Brainfuck, 130 bytes
My first PPCG entry!
Obviously not gonna win but hey.
Takes input like: 4ABCDEFGHIJKL, with the first character being N.
,>+++++++[<------->-]<+>>+[>,]<[<]>-<<[>>>[<+>-]>[<+>-]<<[>>+<<-]>[>]<[>+<-]<[>+<-]>>[<<+>>-]<[-]<[<]>[-]>[[<+>-]>]<<[<]<<-]>>>[.>]

Test it on this wonderful site.
Limited to N less than or equal to 9, because two-digit numbers are a pain in the butt.
EDIT: I sucked it up and added support for two-digit numbers. Pad with a zero for single digits.
,>+++++++[<------->-]<+ [>++++++++++<-]>[<+>-],>+++++++[<------->-]<+ [<+>-]>+[>,]<[<]>-<<[>>>[<+>-]>[<+>-]<<[>>+<<-]>[>]<[>+<-]<[>+<-]>>[<<+>>-]<[-]<[<]>[-]>[[<+>-]>]<<[<]<<-]>>>[.>]

Welcome to PPCG! This is a very nice first answer! :)

@AandN thanks! I've been looking for a while for a challenge that could be reasonably easily solved in BF, which is one of my new favorite languages :D

As of yet untitled language (so new noncompetitive), 9 bytes
hD_RQ:Q|J

You can find the source code here, language is completely unstable (first test challenge for it) so don't expect it to work in the future (commit 7)
This is a stack based language with functions that add and remove objects from the stack. There are currently 2 stack manipulation commands: D(duplicate the top of the stack N times) and R(rotate the top N items on the stack)
Explanation:
          - autoassign Q = eval_or_not(input()) (string)
h         - imp_eval_input()+1
 D        - duplicate(^)
  _       - neg(^)
   R      - rotate(^)
    Q:    - Q[^:^]
      Q|  - Q[0], Q[-1]
        J - "".join(all)

CJam, 14 bytes
l(o)\l~_W*@<>o

Test it here.
Explanation
l   e# Read the input string.
(o  e# Pull off the first character and print it.
)\  e# Pull off the last character and swap with the rest of the string.
l~  e# Read the second line of the input and evaluate it (N).
_   e# Duplicate.
W*  e# Multiply by -1 to get -N.
@   e# Pull up the string.
<   e# Discard the last N characters.
>   e# Discard the first N characters.
o   e# Output what's left. The last character of the input is now still on the
    e# stack and is automatically printed at the end of the program.

Perl, 27 bytes
Include +1 for -p
Run as perl -p sdr.pl
Input given on STDIN, first line the string, second line the count
Assumes the string contains only "word" characters
sdr.pl:
eval's%\B.(.*).\B%$1%;'x<>

Vyxal Ṫ, 8 bytes
f÷?d($_^

Try it online!
Explanation:
f         # Get the list of characters
 ÷        # and push each one to the stack.
   d      # Double
  ?       # the input
    (     # times:
     $    #   swap the top two items
      _   #   pop the stack
       ^  #   then reverse the stack.
          # Sum the whole stack and print

Factor, 47 bytes
[ 1 cut pick tail 1 cut* swap roll head* glue ]

Try it online!
       ! 5 "ABCDEFGHIJKLMNOP"
1      ! 5 "ABCDEFGHIJKLMNOP" 1
cut    ! 5 "A" "BCDEFGHIJKLMNOP"
pick   ! 5 "A" "BCDEFGHIJKLMNOP" 5
tail   ! 5 "A" "GHIJKLMNOP"
1      ! 5 "A" "GHIJKLMNOP" 1
cut*   ! 5 "A" "GHIJKLMNO" "P"
swap   ! 5 "A" "P" "GHIJKLMNO"
roll   ! "A" "P" "GHIJKLMNO" 5
head*  ! "A" "P" "GHIJ"
glue   ! "AGHIJP"

CJam, 15 bytes
r(\)\{(;);}ri*\

I'm sure it's possible to golf this further...

PHP, 60 bytes
This solution iteratively sets characters from the input string to an empty string by index. I'm manipulating the input string directly to prevent a long return.
function(&$w,$i){for(;$i;)$w[$i--]=$w[strlen($w)-$i-2]="";};

Basically in memory $w looks like this when done:
Addr 0 1 2 3 4
     H   l   o
     ^   ^   ^
>Result: Hlo

Run like this:
php -r '$f = function(&$w,$i){for(;$i;)$w[$i--]=$w[strlen($w)-$i-2]="";}; $f($argv[1],$argv[2]);echo"$argv[1]\n";' Hello 1

PHP 4.1 (50 bytes): <?for(;$I;)$W[$I--]=$W[strlen($W)-$I-2]="";echo$W;. It expects the values on the keys W and I, over POST/GET/COOKIE... An example would be http://example.com/a.php?W=MyString&I=5

Yeah, I don't wanna do answers which require register globals anymore. Thx for the suggestion though :)

Pylons, 16 Bytes.
i:At,{\,v\,v,A}c

How it works:
i    # Get command line input.
:At  # Set A equal to the top of the stack.
,    # Pop the stack.
{    # Start a for loop.
 \   # Swap the top two elements of the stack.
  ,  # Pop the stack.
   v # Reverse the stack.
 \   # Swap the top two elements of the stack.
  ,  # Pop the stack.
   v # Reverse the stack.
 ,   # Switch to loop iterations.
 A   # Iterate A times.
}    # End the for loop.
c    # Print the stack as a string

Jolf, 13 bytes
ΆFi liγhj_γgi

A tranpilation of the JavaScript answer.
Explanation:
ΆFi liγhj_γgi
Ά             ternary add
 Fi            i[0],
   `li         i sliced
      γhj       γ = j + 1
         _γ     to -γ
           gi  and the last of i

Try it here!
A more interesting post-question version:
 ΆFi]ihjYgi

Seriously, 17 bytes
,#,`p@pXod@dXq`nΣ

Takes input as s \n n.
Try it online!
Explanation:
,#,`p@pXod@dXq`nΣ
,#                 push a list of characters in s
  ,`          `n   do the following n times:
    p@pXo          pop 2 characters off the front, discard the second, put the first back
         d@dXq     pop 2 characters off the back, discard the second, put the first back
                Σ  join

bash + GNU coreutils, 93 83 Bytes
s=$2
for i in `seq $1`;do
s=`sed 's/\(.\).\(.*\).\(.\)/\1\2\3/'<<<$s`
done
echo $s

I wanted to find an answer in pure sed, but I am not sure if counters are possible this way...
Invocation:
./testgolf.sh 3 ABCDEFGHIJKLMNOP

Explanation:
s=$2  # Store second parameter into variable
for i in `seq $1`;do   # loop number of first parameter times...
s=`sed 's/\(.\).\(.*\).\(.\)/\1\2\3/'<<<$s`
#         +-1-+ +-2--+ +-3-+
# sed splits the string into 3 placeholders
# to create the new string by use of substitution.
# s=$`...` stores the output into the variable.
# <<<$s sends the content of the variable to stdin of sed.
done
echo $s  # output content of the variable now.

Welcome to Programming Puzzles and Code Golf. This is a great first answer, however I think it could be improved by adding a code breakdown and explanation.

C#, 129 bytes
Since we basically skip 1 and remove N and the reversed scenario
string o(string i,int n){var s=i.ToList();int x=0;while(x<2){s.RemoveRange(1,n);s.Reverse();x++;}return new string(s.ToArray());}

ungolfed
string o(string i, int n)
{
    var s = i.ToList();
    int x = 0;
    while (x < 2) //Repeat the following twice
    {
        s.RemoveRange(1, n); //remove n at index 1
        s.Reverse(); //Reverse the list
        x++;
    }
    return new string(s.ToArray());
}

Wóuld it be possible to decrease the length of the script by using this for looping: for(int x=0xi<2;i++)

Java, 144 bytes
static String y(int i,String s){return i==0?s:y(i-1,new StringBuffer(s).replace(1,2,"").replace(s.length()-3,s.length()-2,"").toString());}

PHP 76 Bytes
while($n>=0){$s=substr($s,0,1).substr($s,2,-2).substr($s,-1,1);$n--;}echo$s;

Explanation is one word, substr!
I assumed $n and $s are inputs. Correct me if this is incorrect, or if <?php is required.
Long hand
<?php

$n = 3;
$s = 'ABCDEFGHIJKLMNOP';

while ($n >= 0) {
    $s = substr($s, 0, 1) . substr($s, 2, -2) . substr($s, -1, 1);
    $n--;
}
echo $s;

You should make it a function. Also, it might be shorter to remove the loop.

I tried my best at making it a recursive function just now, but I ended up with many more bytes.

Forth (gforth), 62 bytes
: f >r over 1 type i 1+ m+ i 1+ 2* - 2dup type + r> + 1 type ;

Try it online!
Code Explanation
: f            \ start a new word definition
  >r           \ store N on the return stack for easier access
  over 1 type  \ print the first character
  i 1+ m+      \ add N + 1 to the string starting address
  i 1+ 2* -    \ get the length of the middle section (strlen - 2*(N+1))
  2dup type    \ output the middle section
  + r> +       \ get the address of the last character in the string
  1 type       \ output the last character in the string
;              \ end word definition

Keg, 11 bytes
Finally, a challenge built for Keg!
?(¿2*|$_^)^

Try it online!
Explanation
?           Take a string input
 (¿         Repeat the following code block integer input
   2*       * 2 times:
     |$     Swap the ends of the string
       _    Discard the end
        ^   Repeat the process
         )^ Reverse the input back (because input is reversed)

Rust, 89 bytes
|s:&[_],n|(0..1).chain(n+1..s.len()-n-1).chain(s.len()-1..s.len()).map(|i|s[i]).collect()

Inputs as a &[u8] and outputs as a Vec<u8>. Or a &[char] to Vec<char>.
Playground Link
Rust may not be a very concise language but also a lot of rust answers in this site are sub-optimal. Including this one probably.

Vyxal, 6 bytes
(ÞẇḢṪj

Try it Online!
(      # N times...
 Þẇ    # Unwrap (push first+last and rest
   ḢṪ  # Remove first and last chars of rest
     j # Insert back into the first + last

Python, 78 59 bytes
Golfed
def s(t,n):return t if n==0 else s(t[0]+t[2:-2]+t[-1],n-1)

Try it here!
Ungolfed
def swapDeleteRepeat (text, n):
    if n == 0:
        return text
    else:
        return swapDeleteRepeat (text[0] + text[2:-2] + text[-1], n - 1)

This is exactly the same idea as in @DenkerAffe's answer, with a longer function declaration and conditional.

GolfScript, 16 bytes
Assuming that N goes after S.
~2*{.1<\2>+-1%}*

Try it online!
Explanation
~                # Take inputs in the form of S, N.
 2*{          }* # Repeat N*2 times:
    .1<\2>+      #    Remove the second character
           -1%   #    Reverse the string

Japt, 11 bytes
jUÊ-VÉV j1V

Try it
This would be a couple bytes shorter if j worked with negative indexes.
jUÊ-VÉV j1V #
j     V     # Remove N characters from S starting at index:
 UÊ         #  Length of S
   -V       #  Minus N
     É      #  Minus 1
        j V # Remove N characters from S starting at index:
         1  #  1


text:
Longest path on a 2d plane
You are provided a set of arbitary, unique, 2d, integer Cartesian coordinates:
e.g. [(0,0), (0,1), (1,0)]
Find the longest path possible from this set of coordinates, with the restriction that a coordinate can be "visited" only once. (And you don't "come back" to the coordinate you started at).
Important:
You cannot "pass over" a coordinate or around it. For instance, in the last note example (Rectangle), you cannot move from D to A without visiting C (which may be a revisit, invalidating the length thus found). This was pointed out by @FryAmTheEggman.
Function Input: Array of 2d Cartesian Coordinates
Function Output: Maximum length only
Winner: Shortest code wins, no holds barred (Not the most space-time efficient)

Examples

1: In this case shown above, the longest path with no coordinate "visited" twice is A -> B -> O (or O-B-A, or B-A-O), and the path length is sqrt(2) + 1 = 2.414

2: In this case shown above, the longest path with no coordinate "visited" twice is A-B-O-C (and obviously C-O-B-A, O-C-A-B etc.), and for the unit square shown, it calculates to sqrt(2) + sqrt(2) + 1 = 3.828.

Note: Here's an additional test case which isn't as trivial as the two previous examples. This is a rectangle formed from 6 coordinates:

Here, the longest path is: A -> E -> C -> O -> D -> B, which is 8.7147
(max possible diagonals walked and no edges traversed)

Here's a very similar question, albeit with different scoring.

@Geobits Agreed, but I'd not say "very", having gone through the problem description there. And for that matter, any min/max path problem is essentially some flavor of your usual graph suspects. I'm interested in a byte saving solution here.

@Fatalize Done. It's 8.7147.

By the way: Welcome to PPCG!

@Fatalize Thank you! (Actually I've been an observer here for a while, just got active and into the whole thing starting today). :)

Pyth, 105 103 100 92 86 bytes
V.pQK0FktlNJ.a[@Nk@Nhk)FdlNI&!qdk&!qdhkq+.a[@Nk@Nd).a[@Nd@Nhk)J=K.n5B)=K+KJ)IgKZ=ZK))Z

              Z = 0 - value of longest path
              Q = eval(input())

V.pQ         for N in permutations(Q):
  K0           K = 0 - value of current path
  FktlN        for k in len(N) - 1:
    J.a          set J = distance of
    [@Nk                 Q[k] and Q[k+1]
    @Nhk)
    FdlN         for d in len(N):
I&                 if d != k && d != (k + 1)
!qdk
&!qdhk
q+                and if sum of
.a                   distance Q[k] and Q[d]
 [@Nk
 @Nd)
.a                   distance Q[d] and Q[k+1]
 [@Nd
 @Nhk)
J                    are equal to J then
  =K.n5              set K to -Infinity
  B                  and break loop
                     ( it means that we passed over point )
  )                   end of two if statements
=K+KJ                  K+=J add distance to our length
)                      end of for
IgKZ                   if K >= Z - if we found same or better path
  =ZK                  Z = K       set it to out max variable
))                     end of two for statements
Z                      output value of longest path

Try it here!

Mathematica, 139 bytes
Max[Tr@BlockMap[If[1##&@@(Im[#/#2]&@@@Outer[#/Abs@#&[#-#2]&,l~Complement~#,#])==0,-∞,Abs[{1,-1}.#]]&,#,2,1]&/@Permutations[l=#+I#2&@@@#]]&

Test case
%[{{0,0},{0,1},{1,0},{1,1},{2,0},{2,1}}]
(* 3 Sqrt[2]+2 Sqrt[5] *)

%//N
(* 8.71478 *)

Perl, 341 322 318 bytes
sub f{@g=map{$_<10?"0$_":$_}0..$#_;$"=',';@l=grep{"@g"eq join$",sort/../g}glob"{@g}"x(@i=@_);map{@c=/../g;$s=0;$v=1;for$k(1..$#c){$s+=$D=d($k-1,$k);$_!=$k&&$_!=$k-1&&$D==d($_,$k)+d($_,$k-1)and$v=0 for 0..$#c}$m=$s if$m<$s&&$v}@l;$m}sub d{@a=@{$i[$c[$_[0]]]};@b=@{$i[$c[$_[1]]]};sqrt(($a[0]-$b[0])**2+($a[1]-$b[1])**2)}

The code supports up to a 100 points. Since it produces all possible point permutations,
100 points would require at least 3.7×10134 yottabytes of memory (12 points would use 1.8Gb).
Commented:
sub f {
    @g = map { $_<10 ? "0$_" : $_ } 0..$#_; # generate fixed-width path indices
    $" = ',';                               # set $LIST_SEPARATOR to comma for glob
    @l = grep {                             # only iterate paths with unique points
        "@g" eq join $", sort /../g         # compare sorted indices with unique indices
    } glob "{@g}" x (@i=@_);                # produce all permutations of path indices
                                            # and save @_ in @i for sub d
    map {
        @c = /../g;                         # unpack the path indices
        $s=0;                               # total path length
        $v=1;                               # validity flag
        for $k (1..$#c) {                   # iterate path
            $s +=                           # sum path length
                $D = d( $k-1, $k );         # line distance

              $_!=$k && $_!=$k-1            # except for the current line,
              && $D == d( $_, $k )          # if the point is on the line,
                     + d( $_, $k-1 )
              and $v = 0                    # then reset it's validity
            for 0 .. $#c                    # iterate path again to check all points
        }
        $m=$s if $m<$s && $v                # update maximum path length
    } @l;
    $m                                      # return the max
}

sub d {
    @a = @{ $i[$c[$_[0]]] };                # resolve the index $_[0] to the first coord
    @b = @{ $i[$c[$_[1]]] };                # idem for $_[1]
    sqrt( ($a[0] - $b[0])**2
        + ($a[1] - $b[1])**2 )
}

TestCases:
print f( [0,1], [0,0], [1,0] ), $/;        $m=0; # reset max for next call
print f( [0,0], [0,1], [1,0], [1,1] ), $/; $m=0;
print f( [0,0], [0,1], [0,2] ), $/;        $m=0;
print f( [0,0], [0,1], [0,2],
         [1,0], [1,1], [1,2]),$/;          $m=0;

322 bytes: save 19 by not resetting $", and some inlining
318 bytes: save 4 by reducing max nr of coords to 100.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Throwback Friday: Renumber my ZX spectrum BASIC listing
The first programming language I was exposed to was Sinclair BASIC.  Like many BASIC dialects, it requires all source code lines to be numbered.
As a result, use of the GO TO command was idiomatic and jumps execution to the given line number (no labels).
Also there is a related GO SUB command which can be used as a rudimentary function call.  Again, execution jumps to the given line number, but when a RETURN command is reached, execution jumps back to the next instruction after the GO SUB.
Similarly the RUN command will restart program execution at the given line.
Anyone who has spent any time in a line-numbered BASIC interpreter will have learned to use a numbering scheme with gaps in it.  This is so that it is easier to insert new lines of code.  However even then, you may still find yourself needing to insert new lines in between consecutively numbered lines.

Given a line-numbered BASIC listing as input, output the same program but renumbered such that the line numbers start at 10 and increment by steps of 10.  The input listing may have GO TO or GO SUB commands, so the numbers associated with these must also be adjusted.

GO TO and GO SUB commands are either on their own lines or at the end of IF THEN lines.  Its safe to say ^(\d+) .*GO (TO|SUB) (\d+)$ is sufficient to match such lines.  These commands in quotes should be ignored.
RUN commands will always be on their own lines.  In this case a line number is optional.  If it is missing, then the interpreter simply starts at the top of the program.
If a GO TO, GO SUB or RUN command references a non-existent line, then it will instead jump to the next defined line.  Your entry needs to deal with this and ensure any such line references are fixed so they point to the correct line.  Behaviour may be undefined if a line number after the end of the program is given in one of these commands.
Line numbers will always be positive integers 1 to 9999 (as per the manual).  This means that input programs will never have more than 999 lines.
Input lines will always be numbered in numerically ascending order.
For the purposes of this challenge, input listings will only contain printable ASCII.  You don't need to worry about the ZX character set.  Having said that, if your entry is actually written in ZX BASIC or appropriate z80 assembly/machine code (and there are emulators out there), then you may choose for your input to be encoded in the ZX character set instead.
You may not use any renumber libraries or utilities that are specifically tailored for this purpose.

Example Input:
1 REM "A rearranged guessing game"
2 INPUT A: CLS
3 INPUT "Guess the number ", B
10 IF A=B THEN PRINT "Correct": STOP
100 IF AB THEN GO SUB 122
121 GO TO 3
125 PRINT "Try again"
126 RETURN
127 REM "An example of GO TO 7 and GO SUB 13 in quotes"

Example Output:
10 REM "A rearranged guessing game"
20 INPUT A: CLS
30 INPUT "Guess the number ", B
40 IF A=B THEN PRINT "Correct": STOP
50 IF AB THEN GO SUB 80
70 GO TO 30
80 PRINT "Try again"
90 RETURN
100 REM "An example of GO TO 7 and GO SUB 13 in quotes"

I wanted to link to a ZX BASIC manual.  The best I could find seems to be http://www.worldofspectrum.org/ZXBasicManual/index.html but this seems to be a dead link.  The wayback machine has a copy though.

Also conrgats on asking the 5000th question!

Nostalgia time - my first PC was a Spectrum 48K and one of my first assembly programs was a renumberer

That was my first programming language as well!

@edc65 Do you still have your renumber assembly code?  If so you'd be very welcome to post it as an answer!

GO TO and GO SUB are actually single byte tokens in the original character set https://en.wikipedia.org/wiki/ZX_Spectrum_character_set I could have sworn they were without the space, but it seems from the link that they do indeed have a space in them.

@steve it appears to be somewhat inconsistent - on speccy and zx81 keyboards its clearly GOTO/GOSUB.  Who ever said anything about quality control and user experience? ;-)

The test case should include at least one goto/gosub in a string literal.

@PeterTaylor Done.

Do we need to handle computed gotos?

@TobySpeight as far as I can tell, zx basic only supports constant gotos, so no, you don't have to.

I found a mention: the ZX81 allows computed GOTOs and GOSUBs as in GOTO 100 + A*10, and Appendix C of the ZX Spectrum Manual lists GO TO as accepting a numerical expression (no restriction to constants).  Here's a discussion of the merits of computed GOTO on ZX80 and ZX81.  BTW, I've no idea why the space was added in the Spectrum version.

@TobySpeight Good find.  Still for this challenge, I'm not going to have computed gotos as a requirement, as apart from anything else, I think it would invalidate a bunch of the existing answers.

JavaScript (ES6) 177
Edit Added the (costly) scan for the next valid line number
l=>l.split`
`.map((x,i)=>([,n,t]=x.match(/(\d+)(.*)/),l[n]=10*-~i,t),l=[]).map((x,i)=>10*-~i+x.replace(/(UN |GO TO |UB )(\d+)$/,(a,b,c)=>(l.some((v,i)=>i<c?0:a=b+v),a))).join`
`

TEST

f=l=>
  l.split`\n`
  .map((x,i)=>([,n,t]=x.match(/(\d+)(.*)/),l[n]=10*-~i,t),l=[])
  .map((x,i)=>10*-~i+x.replace(/(UN |GO TO |UB )(\d+)$/,(a,b,c)=>(l.some((v,i)=>i<c?0:a=b+v),a)))
  .join`\n`

//TEST
console.log=x=>O.textContent+=x+'\n'

test=`1 REM "A rearranged guessing game"
2 INPUT A: CLS
3 INPUT "Guess the number ", B
10 IF A=B THEN PRINT "Correct": STOP
100 IF AB THEN GO SUB 122
121 GO TO 3
125 PRINT "Try again"
126 RETURN`
console.log(test+'\n\n'+f(test))

Looks good.  My +1 stands :)

Perl 6, 147 145 144 142 bytes
{my%a;.trans(/^^(\d+)/=>{%a{$0}=$+=10}).trans(/:s<!after \"\N*>(UN |GO TO |UB )(\d+)<!before \N*\">/=>{$0~%a{%a.keys».Num.grep(*>=$1).min}})}

This can probably be golfed down a bit more.
Expanded
my &f = -> $s {
    my %line-map; # This will map the old line numbers to the new ones

    $s.trans(/^^(\d+)/                    # This .trans creates the line number map
             => { %line-map{$0} = $+=10 } # as well as replaces the actual line numbers
            )\
      # This .trans replaces all the line numbers for each GO TO, GO SUB, RUN
      .trans(/:s<!after \"\N*>(UN |GO TO |UB )(\d+)<!before \N*\">/
             => {$0 ~ %line-map{%line-map.keys».Num.grep(*>=$1).min} }
            )
}

no reason to use the method .min. use {min %line-map.keys».Num.grep:*>=$1 instead

Visual Basic for Applications, 288 bytes
I couldn't resist giving a solution in a BASIC dialect. Probably works with Visual Basic 6/.NET or other modern variants with minor changes.
Sub n(t,a)
f=Chr(10)
u=Chr(0)
Open t For Input As 1
a=f &Input(LOF(1),1)&f
Close
j=10
For i=1 To 9999
q=f &j &u
g=" GO TO "
w=i &f
m=j &f
a=Replace(Replace(Replace(Replace(a,g &w,g &m),f &i &" ",q),"B "&w,"B "&m),"UN "&w,"UN "&m)
If InStr(1,a,q)Then j=j+10
Next
a=Replace(a,u," ")
End Sub

I used a lot of one-letter variables for conciseness. Also, I supressed all unnecessary whitespaces (VBE expands them automatically on import). Byte count is for final .BAS file, with CHR(10) as newline.
The subroutine, that can be invoked from VBE immediate window, opens a Sinclair BASIC program (first parameter is the path to an ASCII file - with CHR(10) as newline - containing the program), renumber lines and write results to a Variant variable (second parameter).
The idea is to iterate on all possible source line numbers, ascending order, and for each one, replace at once all matching line numbers as well as GO TO, GO SUB and RUN references with the next available target line number. Using this approach we do not need any kind of translation table. The target line number is incremented each time a match in source line number is found, so "wrong" line references are adjusted automatically to the next valid number. Newline characters are used as markers of start- and end-of-line, and a CHR(0) - never used in the program as it is not printable - is used as a temporary marker, to avoid renumbering the same line multiple times.
Some remarks:

For conciseness, we use the smaller possible string for a match with the jumping statements. Using the end-of-line on our search strings we do not run into the risk of including quoted occcurrences or user functions (that always use parenthesis in Sinclair). GO TO requires a larger string because of the FOR ... TO construct (e.g. compare 50 FOR X=AGO TO 100 and 50 GO TO 100)

The code does not support statements in the form GO TO200 (without whitespace), although the ZX manual implies that it is valid code on several examples (It would cost a dozen more bytes to deal with it).

The code adds a newline at the beginning and another at the end of the program. I could clean this up in the end (a dozen more bytes) but figure that the ZX would probably ignore blank lines.

Below, a more readable version:
Sub Renumber(ByVal ProgramPath As String, ByRef Program As Variant)

    Open ProgramPath For Input As #1
    Program = Chr(10) & Input(LOF(1), 1) & Chr(10)
    Close

    NewNumber = 10
    For OldNumber = 1 To 9999
        Program = Replace(Program, " GO TO" & OldNumber & Chr(10), " GO TO" & NewNumber & Chr(10)) 'self-explaining
        Program = Replace(Program, Chr(10) & OldNumber & " ", Chr(10) & NewNumber & Chr(0)) 'matches line number (and replaces whistespace with Chr(0) to avoid re-replacing
        Program = Replace(Program, "B " & OldNumber & Chr(10), "B " & NewNumber & Chr(10)) 'matches GO SUB
        Program = Replace(Program, "UN " & OldNumber & Chr(10), "UN " & NewNumber & Chr(10)) 'matches RUN
        If InStr(1, Program, Chr(10) & NewNumber & Chr(0)) Then NewNumber = NewNumber + 10 'if there is such a line, increment NewNumber
Next
Program = Replace(Program, Chr(0), " ") 'replace back Chr(0) with whitespace
End Sub

BTW, a QBasic solution would be much longer, as QBasic doesn't have a string-replacement function built in as far as I recall.

I think you're right... forgot about that

Pip -rn, 63 bytes
Ygn:#{_<aFIy}*t+tgR`(RUN|GO (SUB|TO)) (\d+)$`{b.s.(nd)}R`^\d+`n

Try it online!
Explanation
Setup
The -r flag reads all of stdin and stores it as a list of lines in the local variable g. The global variable t is preinitialized to 10, and the global variable s is preinitialized to " ".
Yg

Yanks the list of lines g into the global variable y, so that it's available inside the function we're about to define.
Line number translation function
We construct a function that maps from any line number in the original numbering scheme (including a non-existent one) to the corresponding line number in the new numbering scheme.
Suppose we have these lines:
1 INPUT A
4 PRINT A
9 IF A=1 THEN GO TO 3

We want to map 1 to 10, 2-4 to 20, and 5-9 to 30. If we have a list of the original line numbers ([1; 4; 9]), we can use a filter operation to find out how many of these numbers are less than the line number we're trying to convert. Multiply that result by 10 and add 10, and we have the desired answer.
For example, when converting 9, there are two line numbers (1 and 4) less than 9. 2*10+10 gives 30. When converting 3, there is one line number (1) less than 3. 1*10+10 gives 20.
Here's the code (slightly modified to be easier to read):
n:{#(_<aFIy)*t+t}
  {             }  Lambda function with parameter a:
        FIy         Filter y (the list of program lines) for
     _<a             lines that are numerically less than a
                    (In a numeric context, only the first run of digits on the line is considered)
   #(      )        Number of items in the filtered list
            *t+t    Times 10, plus 10
n:                 Assign that function to global variable n

First replacement: GO TO, GO SUB, and RUN
The rest of the program is a single expression that takes g and does a couple of regex replacements (which vectorize, applying to each line in g).
Here's the first replacement:
g R `(RUN|GO (SUB|TO)) (\d+)$` {b.s.(nd)}

The regex matches any of RUN, GO SUB and GO TO, followed by a number, followed by end of line. This ensures it doesn't match inside strings, nor does it match RUN without a line number.
The order of the capturing groups is important. The first group captures the command (one of RUN, GO SUB, or GO TO). The second group, if used, captures either SUB or TO. We don't need to capture this part, but a non-capturing group would require extra bytes. Then the third group captures the line number.
We use a callback function for the replacement. With callback functions in Pip, the whole match is the first argument a, and the capture groups in order are the subsequent arguments b, c, d, and e. So we have the command in the first group, which goes in b, and the line number in the third group, which goes in d. The only change we need to make is to pass the line number through our conversion function, which is called Lisp-style: (nd). Then we concatenate that together with b and a space and return it.
Second replacement: line numbers
All that's left to convert is the line numbers at the beginnings of lines.
(...) R `^\d+` n

The regex matches a run of digits at the beginning of a line. Again we use a callback function; this time, the conversion function n itself is sufficient, since the whole match (first argument, a) is the number we want converted.
Since this is the last expression in the program, Pip autoprints the result. The -n flag separates the result list with newlines.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How many letters in this word?
Inspired by Project Euler #17, this is your challenge. Write a full program or function that takes a number as input, then print or return how many letters it would take to count up to and including that number in English (starting at one). You do not include spaces, commas, or hyphens, but you should include the word and. For example. 342 is spelled: Three Hundred and Forty-Two. This is 23 letters long.
Your input will be a positive integer. You do not have to handle invalid inputs. Built-ins or libraries that convert numbers to English are not allowed.
Here are all of the rules for how to spell numbers. (Note: I realize that some people use a different set of rules for how to spell numbers. This will just be the official rules for the purpose of this challenge)
1 to 20

one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty

21 to 99
Join these:

Twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety

to these:

-one, -two, -three, -four, -five, -six, -seven, -eight, -nine,

Note that four has a u but forty does not!
Examples:
53: Fifty-three
60: sixty
72: seventy-two
99: ninety-nine

100 to 999
Write out how many hundreds (one hundred, two hundred, three hundred, etc.), an "and", and the rest of the number as above. The and does count towards your letter score.
Examples:
101: One hundred and one
116: One hundred and sixteen
144: One hundred and forty-four
212: Two hundred and twelve
621: Six Hundred and twenty-one

1,000 to 999,999
Write how many thousands (one thousand, two thousand, etc.), a comma, then the rest of the number as above. Note that if you have no hundreds, you still need the and.
Examples:
1,101: One thousand, one hundred and one
15,016: Fifteen thousand and sixteen
362,928: Three hundred and sixty-two thousand, nine hundred and twenty-eight

Millions
Write out how many millions, then the rest of the number as above. Note that "A million" is 6 zeroes "1,000,000".
Examples:
191,232,891: One hundred and ninety-one million, two hundred and thirty-two thousand, eight hundred and ninety-one
1,006,101: One million, six thousand, one hundred and one

The same rule applies to billions, trillions, quadrillions and above, but for the purpose of this challenge, you don't have to handle any number above 999,999,999 (Nine Hundred and ninety-nine million, nine-hundred and ninety-nine thousand, nine hundred and ninety-nine.)
Python solver
Here is a short python script to verify answers:
import en

def get_letter_num(s):
    count = 0
    for c in s:
        if c.isalpha():
            count += 1
    return count

number = input()
count = 0
for i in xrange(1, number + 1):
    count += get_letter_num(en.number.spoken(i))

print count

Note that this usesthe NodeBox linguistics library to convert numbers to English. (yes, I just broke my own rule, but this isn't a competing answer) This is freely available here.
Sample I/O
7: 27
19: 106
72: 583
108: 1000
1337: 31,131
1234567: 63,448,174

Why is it One hundred and one, but then One million, six thousand, one hundred one without the and?

@Geobits Typo. Also You do not include spaces, commas, or hyphens, but you should include the word "and".

Related and more related.

Shouldn't 15016 be fifteen thousand sixteen according to "the rest of the number as above"?

I can't find anything wrong with what I am doing, but I seem to get 31,128 for 1337. It seems odd to be off by exactly three, could you check that the rules are all correct and that that is the correct output? I get the same answer for 108.

@FryAmTheEggman I am definitely getting 31,131. How about post it as an answer with a disclaimer, and I'll look at it and see if I can spot the difference.

Invalid answers are Bad™ so here is a link

Oh, I didn't think of this before, I had a program that is too long to fit in a comment that englishifies the range of numbers for debugging. I made a paste of the results for 1337 if that helps.

@FryAmTheEggman 1100 -> one thousand and one hundred.

How does that scale to 1200 then? Or 10100? I don't see a rule that would indicate one hundred is a special case, I'm not sure how to handle it.

@FryAmTheEggman Using his python script, 1100 -> one thousand and one hundred; 1200 -> one thousand two hundred, 1000100 -> one million and one hundred, 1000200 -> one millian two hundred. I think either A) DJ McGoathem should address the 1100 and 1000100 special cases in his question, or B) correct his test cases

Why the "and"?  Proper names for numbers never use it: 123 = "one hundred twenty-three"

@ricdesi I agree. Related. People count "one thousand one, one thousand two, ...", without the ands.

Python 2, 266 259 236 229 228 bytes
This works for all inputs below one billion. This works for all test cases.
def l(n):b=[6,3,2][(n<1000)+(n<10**6)];c=10**b;return int("0335443554"[n%10])+int("0366555766"[n/10])+(n-10in[4,6,7,9])if n<100else l(n/c)+(l(n%c)or-3*(b<3))+7+(b<6)+2*(b<3)+3*(b>2)*(0<n%c<101)
print sum(map(l,range(input()+1)))

To modify it to fit the question as stated (e.g. don't treat numbers ending with 100 special) simply replace the number 101 at the end of the first line with 100.
Explanation:
def l(n):
    b=[6, 3, 2][(n < 1000) + (n < 10**6)] # b = 2 if n < 1000 else 3 if n < 1000000 else 6
    c=10**b
    return (                            # Parenthesis added for readability.
            int("0335443554"[n % 10]) + # Compute length of last digit. one -> 3, seven -> 5, etc.
            int("0366555766"[n / 10]) + # Compute length of second to last digit. ten -> 3, eighty -> 6, etc.
            (n - 10 in[4, 6, 7, 9])     # Add one to length if the number is 14, 16, 17, or 19.

            if n < 100 else             # Use above procedure if the number is under 100.
                                        # If otherwise, use below procedure.

            l(n / c) +                  # Compute length of the top portion of number.
                (l(n % c) or            # Compute length of bottom portion of number.
                -3 * (b < 3)) +         # If the number < 1000 and is a multiple of 100,
                                        # subtract 3 from the length because of missing and.
            7 +                         # Add 7 to the length for "million"
            (b < 6) +                   # Add 8 to the length for "thousand"
            2 * (b < 3) +               # Add 10 to the length for "hundred and"
                3 *                     # Add 3 to the length for another "and"
                (b > 2) *               # if the number >= 1000
                (0 < n % c < 101)       # and the bottom portion > 0 and <= 100
    )
print sum(map(l,range(input()+1)))      # For the reader to figure out.


text:
Leaving the Nest
Given a non-flat list of integers, output a list of lists containing the integers in each nesting level, starting with the least-nested level, with the values in their original order in the input list when read left-to-right. If two or more lists are at the same nesting level in the input list, they should be combined into a single list in the output. The output should not contain any empty lists - nesting levels that contain only lists should be skipped entirely.
You may assume that the integers are all in the (inclusive) range [-100, 100]. There is no maximum length or nesting depth for the lists. There will be no empty lists in the input - every nesting level will contain at least one integer or list.
The input and output must be in your language's native list/array/enumerable/iterable/etc. format, or in any reasonable, unambiguous format if your language lacks a sequence type.
Examples
[1, 2, [3, [4, 5], 6, [7, [8], 9]]] => [[1, 2], [3, 6], [4, 5, 7, 9], [8]]

[3, 1, [12, [14, [18], 2], 1], [[4]], 5] => [[3, 1, 5], [12, 1], [14, 2, 4], [18]]

[2, 1, [[5]], 6] => [[2, 1, 6], [5]]

[[54, [43, 76, [[[-19]]]], 20], 12] => [[12], [54, 20], [43, 76], [-19]]

[[[50]], [[50]]] => [[50, 50]]

Pyth, 17
 us-GeaYsI#GQ)S#Y

The leading space is important. This filters the list on whether the values are invariant on the s function, then removes these values from the list and flatten it one level. The values are also stored in Y and when we print we remove the empty values by filtering if the sorted value of the list is truthy.
Test Suite
Alternatively, a 15 byte answer with a dubious output format:
 us-GpWJsI#GJQ)

Test Suite
Expansion:
 us-GeaYsI#GQ)S#Y     ##   Q = eval(input)
 u          Q)        ##   reduce to fixed point, starting with G = Q
        sI#G          ##   get the values that are not lists from G
                      ##   this works because s<int> = <int> but s<list> = flatter list
      aY              ##   append the list of these values to Y
     e                ##   flatten the list
   -G                 ##   remove the values in the list from G
              S#Y     ##   remove empty lists from Y

Mathematica, 56 54 52 bytes
-2 bytes due to Alephalpha.
-2 bytes due to CatsAreFluffy.
Cases[#,_?AtomQ,{i}]~Table~{i,Depth@#}/.{}->Nothing&

Actually deletes empty levels.

Cases[#,_?AtomQ,{i}]~Table~{i,Depth@#}~DeleteCases~{}&

Cases[#,_?AtomQ,{i}]~Table~{i,Depth@#}/.{}->Nothing&, 2 bytes shorter

Python 2, 78 bytes
f=lambda l:l and zip(*[[x]for x in l if[]>x])+f(sum([x for x in l if[]<x],[]))

Mathematica 55 64 62 bytes
#~Select~AtomQ/.{}->Nothing&/@Table[Level[#,{k}],{k,Depth@#}]&

%&[{1, 2, {3, {4, 5}, 6, {7, {8}, 9}}}]

{{1, 2}, {3, 6}, {4, 5, 7, 9}, {8}}

Retina, 79
I know the Retina experts will golf this more, but here's a start:
{([^{}]+)}(,?)([^{}]*)
$3$2<$1>
)`[>}],?[<{]
,
(\d),+[<{]+
$1},{
<+
{
,*[>}]+
}

Try it online.

JavaScript, 112 80 bytes
F=(a,b=[],c=0)=>a.map(d=>d!==+d?F(d,b,c+1):b[c]=[...b[c]||[],d])&&b.filter(d=>d)

Thanks Neil for helping shave off 32 bytes.

Lots of opportunities for golfing here. Some easy ones are to remove the !=null as null is falsy anyway. The b= is also unnecessary. Having removed that you can then move the .filter(a=>x) to the &&b which then reduces the outer function to a call to the inner function which you can then inline. I'm left with this: f=(a,b=[],c=0)=>a.map(d=>d[0]?f(d,b,c+1):b[c]=[...b[c]||[],d])&&b.filter(d=>d).

@Neil d[0]? would evaluate false if it was equal to 0, which is within the range [-100,100]. And so would d=>d

@Neil Threw this one up in a rush, so I knew there were other opportunities to shrink it, but this is much better than I could have done even then. Thanks! Oh, and Patrick is right on the null check being necessary for that reason. I went with d===+d though, since it saves 2 bytes on the null check.

F=(a,b=[],c=0)=>(a.map(d=>d!==+d?F(d,b,c+1):b[c]=[...b[c]||[],d]),b) for -12 bytes.

@Dendrobium That won't handle the last case (or any cases with [...,[[...]]]) properly

@PatrickRoberts d=>d is OK since d is always an array or null at that point, but a fair point regarding d[0], although there's always d.map which will be truthy for an array but falsy for a number.

Jelly, 24 bytes
fFW®;©ṛ¹ḟF;/µŒḊ’$¡W®Tị¤;

Try it online!
If newline-separated lists were allowed, this could be golfed down to 14 bytes.
fFṄ¹¹?ḟ@¹;/µ¹¿

Try it online!

Jelly, 6 bytes
ŒJẈĠịF

Try it online!
Jelly has substantially improved in the past 5 years
How it works
ŒJẈĠịF - Main link. Takes a list L on the left
ŒJ     - Multi-dimensional indices
  Ẉ    - Get the length of each element
         This yields the depth (starting at 1 for flat elements) of each element
   Ġ   - Group the indices of this list by the values
     F - Flatten L
    ị  - Index into

Huh? The way that ŒJẈĠ works is kinda confusing without an example. Let's take L = [3, 1, [12, [14, [18], 2], 1], [[4]], 5] and work through it
ŒJ is one of a series of multi-dimensional commands that reflect the behaviour of their one-dimensional versions. Specifically, this is the "multi-dimensional indices" command, a multi-dimensional version of J, the "indices" command.
Picture L arranged like this:
3 1 12 14 18 2 1 4 5
    12 14 18 2 1 4
       14 18 2   4
          18

That is, each element is repeated down a number of times equal to it's depth. ŒJ doesn't quite leave the elements like this (it changes the specific values, not the shape), but it's enough. Ẉ then calculates the length of each i.e. how many rows each element goes down:
1 1 2 3 4 3 2 3 1

Ġ the takes this list as it's argument. First, it's generates this list's indices: [1, 2, 3, 4, 5, 6, 7, 8, 9]. We then group these indices by the values of the argument. So because the values at indices 3 and 7 are equal (they're both 2), [3, 7] is grouped. The final result of this is [[1, 2, 9], [3, 7], [4, 6, 8], [5]] as the groups are sorted by the values they're grouped by.
Finally, we index into the flattened L using this list of groups, which yields the intended output

Python, 108 99 bytes
This seems a bit long to me, but I couldn't make a one-liner shorter, and if I try using or instead of if, I get empty lists in the results.
def f(L):
    o=[];i=[];j=[]
    for x in L:[i,j][[]<x]+=[x]
    if i:o+=[i]
    if j:o+=f(sum(j,[]))
    return o

Try it online
Edit: Saved 9 bytes thanks to Stack Overflow

You should change your indents to single spaces, so they render properly in the code block. You can also use filter(None,o) to remove empty lists that are on the outermost nesting level of o.

I prefer to view my code with tabs. Spaces are evil.

SE Markdown converts tabs to 4 spaces, so there's no escaping them anyway :) Using a single space in the Markdown makes the byte count of the code block actually match the byte count of the code.

My code itself contains tabs if you look to edit it, though. It's whats on the inside that counts. ;)

MATL, 37 bytes
j']['!=dYsXKu"GK@=)'[\[\],]'32YXUn?1M

Try it online!
Works with current release (13.0.0) of the language/compiler.
This produces the output as lines of space-separated values, where each line corresponds to the same nesting level, and different nesting levels are separated by newlines.
j            % read input as string (row array of chars)
']['!        % 2x1 array containing ']'  and '['
=            % test for equality, all combinations
d            % row array obtained as first row minus second row
Ys           % cumulative sum. Each number is a nesting level
XK           % copy to clibdoard K
u            % unique values: all existing nesting levels
"            % for each nesting level
  G          %   push input
  K          %   push array that indicates nesting level of each input character
  @          %   push level corresponding to this iteration
  =          %   true for characters corresponding to that nesting level
  )          %   pick those characters
  '[\[\],]'  %   characters to be replaced
  32         %   space
  YX         %   regexp replacement
  U          %   only numbers and spaces remain: convert string to array of numbers
  n?         %   if non-empty
    1M       %     push that array of numbers again
             %   end if implicitly
             % end for each implicitly

Python 3, 109 bytes
As ever, stupid Python 2 features like comparing ints and lists mean that Python 3 comes out behind. Oh well...
def d(s):
 o=[]
 while s:
  l,*n=[],
  for i in s:
   try:n+=i
   except:l+=[i]
  if l:o+=[l]
  s=n
 return o

Perl, 63 bytes
{$o[$x++]=[@t]if@t=grep{!ref}@i;(@i=map{@$_}grep{ref}@i)&&redo}

Input is expected in @i, output produced in @o. (I hope this is acceptable).
Example:
@i=[[54, [43, 76, [[[-19]]]], 20], 12];                              # input

{$o[$x++]=[@t]if@t=grep{!ref}@i;(@i=map{@$_}grep{ref}@i)&&redo}      # the snippet

use Data::Dumper;                                                    # print output
$Data::Dumper::Indent=0;  # keep everything on one line
$Data::Dumper::Terse=1;   # don't print $VAR =
print Dumper(\@o);

Output:
[[12],[54,20],[43,76],[-19]]

Racket 259 bytes
(let((ol'())(m 0))(let p((l l)(n 0))(cond[(empty? l)][(list?(car l))(set! m(+ 1 n))
(p(car l)(+ 1 n))(p(cdr l)n)][(set! ol(cons(list n(car l))ol))(p(cdr l)n )]))
(for/list((i(+ 1 m)))(flatten(map(λ(x)(cdr x))(filter(λ(x)(= i(list-ref x 0)))(reverse ol))))))

Ungolfed:
(define (f l)
  (define ol '())
  (define maxn 0)
  (let loop ((l l)              ; in this loop each item is added with its level
             (n 0))
    (cond
      [(empty? l)]
      [(list? (first l))
       (set! maxn (add1 n))
       (loop (first l) (add1 n))
       (loop (rest l) n)]
      [else
       (set! ol (cons (list n (first l)) ol))
       (loop (rest l) n )]))

  ; now ol is '((0 1) (0 2) (1 3) (2 4) (2 5) (1 6) (2 7) (3 8) (2 9))

  (for/list ((i (add1 maxn)))   ; here similar levels are combined
    (flatten
     (map (λ (x) (rest x))      ; level numbers are removed
          (filter (λ (x) (= i(list-ref x 0)))
                  (reverse ol))))))

Testing:
(f '[1 2 [3 [4 5] 6 [7 [8] 9]]])

Output:
'((1 2) (3 6) (4 5 7 9) (8))

Clojure, 119 bytes
(116 with seq? and input as lists, a trivial modification)
(defn f([v](vals(apply merge-with concat(sorted-map)(flatten(f 0 v)))))([l v](map #(if(number? %){l[%]}(f(inc l)%))v)))

Better intended:
(defn f([v]  (vals(apply merge-with concat(sorted-map)(flatten(f 0 v)))))
       ([l v](map #(if(number? %){l[%]}(f(inc l)%))v)))

When called with two arguments (the current level and a collection) it either creates an one-element unordered-map like {level: value}, or calls f recursively if a non-number (presumambly a collection) is seen.
These mini-maps are then merged into a single sorted-map and key collisions are handled by concat function. vals returns map's values from first level to the last.
If a number is the only one at its level then it remains a vec, others are converted to lists by concat.
(f [[54, [43, 76, [[[-19]]]], 20], 12])
([12] (54 20) (43 76) [-19])

If input was a list instead of vec then number? could be replaced by seq?, oddly vector isn't seq? but it is sequential?. But I'm too lazy to implement that version, re-do examples etc.

Stax, 18 bytes
é╔óó)₧ú↔u.≤∟╦Ç╟·○`

Run and debug it
I rhought I'd be able to beat pyth, but ¯\_(○-○)_/¯


text:
Repair the ranges
Given an input of a list of positive integers with some replaced with 0,
output the list with the missing numbers that were changed to 0 replaced.
Characteristics of the input list:

The list will always have a length of at least 2.
Let us define the input list as a and the "original list" (that is, the
list before numbers were replaced with 0s) as b. For any n, a[n] is
either b[n] or 0.
For any n, b[n] is either b[n-1] + 1 or b[n-1] - 1. That is, the
numbers in b will always change by 1 at each index from its previous. The
first element is, of course, exempt from this rule.
For every run of zeroes in a (that is, consecutive elements replaced with
0), with x representing the index of the start of the run and y
representing the end, a[x-1] to a[y+1] will always be either solely
increasing or solely decreasing. Therefore, there will only be one possible
way to fill in the zeroes.

This also means that neither the first nor the last element of the array
can be zeroes.

In simpler terms, to fill in a run of zeroes, simply replace it with a range
from the number before to the number following it. For example, an input of
1 2 0 0 0 6 7

must output
1 2 3 4 5 6 7

Since this is code-golf, the shortest code in bytes will win.
Test cases:
In                      Out
-----------------------------------------------------
1 0 0 0 5 6 0 4 0 0 1 | 1 2 3 4 5 6 5 4 3 2 1
7 6 0 0 3 0 0 0 7 0 5 | 7 6 5 4 3 4 5 6 7 6 5
1 0 3 0 5 0 3 0 5 0 7 | 1 2 3 4 5 4 3 4 5 6 7
14 0 0 0 0 0 0 0 0 23 | 14 15 16 17 18 19 20 21 22 23

Instead of 0 can our program take another value such as null?

@Downgoat No, missing numbers must be given as 0.

JavaScript (ES6), 72 66 64 54 53 bytes
Saved 12 bytes thanks to @Neil!
Saved 1 byte thanks to @IsmaelMiguel
a=>a.map((l,i)=>l?b=l:b+=a.find((q,r)=>r>i&&q)>b||-1)

Pretty good for JavaScript.

Try it online (all browsers work)
Explanation
a=>  // Function with arg `a`
  a.map((l,i)=>  // Loop through input
    l?             // If nonzero
      b=l          // Set `b` to current number
    :a.find((q,r)=>r>i&q) // Otherwise look for the next nonzero number
     >b?           // If it's increased since nonzero last number
       ++b:--b)    // Increasing? increase `b` (the previous nonzero number)
                   // otherwise decrease `b`

I think that a.find((q,r)=>r>i&&q)>b?++b:--b is the same as b+=a.find((q,r)=>r>i&&q)>b||-1

@IsmaelMiguel that's smart, thanks!

You're welcome. I'm glad it worked out for you.

I think you can replace && with just &
(Just noticed you have one & in the explanation and two in the answer)

MATL, 11 12 bytes
fGXzGn:3$Yn

Works with current release (13.0.0) of the language/compiler.
Try it online!
f        % implicitly input array. Indices of nonzero elements (*)
GXz      % push input and get its nonzero elements (**)
Gn:      % vector [1,2,...,n], where n is input length (***)
3$Yn     % interpolate at positions (***) from data (**) defined at positions (*)

Haskell, 68 61 58 bytes
g(a:b:r)=[a..b-1]++[a,a-1..b+1]++g(b:r)
g x=x
g.filter(>0)

Usage example: g.filter(>0) $ [7,6,0,0,3,0,0,0,7,0,5]-> [7,6,5,4,3,4,5,6,7,6,5].
How it works: remove zeros from the input, then call g. Let a be the first and b then second element of the remaining list. Concatenate the lists from a upwards to b-1 and from a downwards to b+1 (one of them will be empty) and a recursive call with a dropped.
Edit: @Zgarb saved 3 bytes. Thanks!

Mathematica, 59 bytes
#//.{a___,x_,0..,y_,b___}:>{a,##&@@Range[x,y,Sign[y-x]],b}&

Test case
%[{1,0,3,0,5,0,3,0,5,0,7}]
(* {1,2,3,4,5,4,3,4,5,6,7} *)

Perl, 47 45 44 39 37 bytes
Includes +1 for -p
s%\S+%$p+=/\G(0 )+/?$'<=>$p:$&-$p%eg

Expects the list on stdin. Example: echo 1 0 3 0 1 | perl -p file.pl

I see some copy pasting here.. ;-) Nicely done btw.

Jelly, 12 11 bytes
ḢWW;ḟ0Ṫr¥\F

Try it online!
Alternative version, 8 bytes (non-competing)
Unfortunately, Jelly's pop did not cast to iterable, in the latest version that predates this challenge. This has been fixed, and the following works in the current version.
ḟ0Ṫr¥\FḊ

Try it online!
How it works
ḢWW;ḟ0Ṫr¥\F  Main link. Input: A (list)

Ḣ            Pop the first element of A. Let's call it a.
 WW          Yield [[a]].
   ;         Concatenate with the popped A.
             This wraps the first element of A in an array.
    ḟ0       Filter; remove all zeroes.
        ¥    Create a dyadic chain:
      Ṫ        Pop the last element of the left argument.
       r       Call range on the popped element and the right argument.
         \   Reduce the modified A by this chain.
          F  Flatten the resulting list of ranges.

In the alternate version, ḢWW; becomes unnecessary. However, since the first element is cast to iterable before popping, it is not actually modified. The final Ḋ removes the duplicate of the first element.

Retina, 39 34 31 bytes
3 bytes saved thanks to @Martin.
+`1(1*) (?= +((1)\1)?)
$0$1$3$3

Takes input and gives output in unary.
The code iteratively fills every empty place (0's) with previous_number - 1 + 2 * if_next_nonzero_number_bigger.
previous_number - 1 is $1 and if_next_nonzero_number_bigger is $3.
With decimal I/O the code is 51 bytes long as you can see in the online interpreter with all the test cases.

You can save another byte by omitting the first 1 in the lookahead.

@MartinBüttner Right, edited.

GNU Sed (with exec extension using bash), 61
Score includes +1 for -r option to sed.
:
s/( 0)+ /../
s/\w+..\w+/{&}/
s/.*/bash -c 'echo &'/e
/ 0/b

Find runs of 0s and replace them ..
Put braces around the endpoint numbers to create a bash brace expansion like {1..4} for the local endpoints.  The beauty of bash brace expansions here is that the generated sequence will always run in the right direction, regardless of whether the start or end is larger.
Use the e option to the s command to call out to bash to evaluate this brace expansion
If any more 0s are found, jump back to the start.

Ideone.

Python 2, 195 111 bytes (thanks Alex!)
t=input()
z=0
for i,e in enumerate(t):
 if e:
  while z:t[i-z]=e+z if l>e else e-z;z-=1
  l=e
 else:z+=1
print t

Input: must be a [list] of ints
Output: [list] of ints

Sorry about that! Fixed. Thanks for the heads up.

No worries. Nice solution. :) You can get it down to 112 bytes using this, which is your same approach, just golfed a bit more. We also have a collection of tips for golfing in Python here.

Jelly, 8 bytes
ḟ0rƝṖ€Fo

Try it online!

Perl, 85 82 bytes
includes +1 for -p
s/(\d+)(( 0)+) (\d+)/$s=$1;$e=$4;$_=$2;$c=$s;s!0!$c+=$e<=>$s!eg;"$s$_ $e"/e&&redo

Expects the list on stdin. Example: echo 1 0 3 0 1 | perl -p file.pl.
This uses a nested regexp. Somewhat readable:
s/(\d+)(( 0)+) (\d+)                  # match number, sequence of 0, number
 /
    $s=$1;                            # start number
    $e=$4;                            # end number
    $_=$2;                            # sequence of ' 0'
    $c=$s;                            # initialize counter with start number
    s!0! $c += $s <=> $e !eg          # replace all 0 with (in|de)cremented counter
    "$s$_ $e"                         # return replacement
 /e
&& redo                               # repeat until no more changes.

Python 2, 92 88 bytes
(Removed intermediate variable)
t=filter(bool,input())
print sum([range(o,p,cmp(p,o))for o,p in zip(t,t[1:])],[])+t[-1:]

Pyth, 17 bytes
u+G+treGHHfTtQ[hQ

The way it works:
u                 reduce
              [hQ     seed: the first element of input, in a list
                      iterable:
          tQ              all except the first element of input
        fT                remove if 0
                      lambda: G is the list to be returned, H is the current item
 +G                       append to return list
    reGH                  a range from the last element of the return list and the current item
   +                      concatenated with
        H                 the last item (this step forms a bidirectional inclusive list)

In other words: all zeroes are removed from input, then an exclusive range is inserted between every element. This range is zero length on elements only one apart.

05AB1E, 3 bytes
This was a feature added after the challenge. Code:
0KŸ

Explanation:
0K   # Remove all zeroes from the input list
  Ÿ  # Rangify, [1, 4, 1] would result into [1, 2, 3, 4, 3, 2, 1]

Try it online! or Verify all test cases!

Vim: 231 Key Commands
Note that any ^ preceding a character means you should hold control while typing that character
mbomayiwo^V^R"^V^V^V^X ^V^["sy0dd`a@f ^["bc0yiwo^V^V^V^X^V^R"^V^[0l@sa^V^V^V^A-^V^[0f-"ayhdd`a@i ^["dc0mbyiwo^V^R"Exe@b^V^[0fel"ty2ldd`b@t ^["ec0wmbyiwo@f @d^V^[@z ^["fc0"xyiwwmbyiwocw^V^V^V^Rx^V^V^V^[@a@i @e^V^[@z ^["ic0IB0 B^V^R" ^V^OWB0 ^V^OA B0^V^[0*w"tyiWdd`b@t ^["zd0dd`bAe^[0@e

Steps so you can run this too!

Copy the line into Vim
Type :s/\^V/<Ctrl-V><Ctrl-V>/g and press enter (the two s should give you a blue ^V)
Type :s/\^R/<Ctrl-V><Ctrl-R>/g and press enter (you should see blue ^Rs now)
Type :s/\^X/<Ctrl-V><Ctrl-X>/g and press enter (you should see blue ^Xs now)
Type :s/\^O/<Ctrl-V><Ctrl-O>/g and press enter
Type :s/\^A/<Ctrl-V><Ctrl-A>/g and press enter
Type :s/\^\[/<Ctrl-V><Ctrl-[>/g and press enter (this command is slightly different because I needed to escape the [)
Type 0"yy$. The command is now stored in the y register
Set up input on a line, and run with @y

If someone knows a better way to share the command, please let me know. I know this is lengthy, but it's the best I could come up with.
Input/Output
The input string should be alone on any line in the file.
    1 0 0 4 3 0 0 0 7
The output will simply overwrite the input string
    1 2 3 4 3 4 5 6 7
Explanation
Algorithm

Start at a non-zero number, make sure it's not the last number
Find the next non-zero number
Take their difference. If the answer is negative, you should decrement to repair the range, otherwise, increment to repair the range.
Go back to the first character and replace each zero by incrementing/decrementing the previous number.
Repeat until you get to the last character

Macros Used
@e - Check for end. The last number will have an e appended to it. If the number under the cursor has an e at the end, delete the e and stop execution. Otherwise, start an interpolation cycle with @b.
mbyiwo^R"Exe@b^[0fel"ty2ldd`b@t

@b - Begin interpolation cycle. Save the number under the cursor for a subtraction operation (@s) and then find the next non-zero term (@f)
mayiwo^R"^V^X ^["sy0dd`a@f

@s - Stores the subtraction command to use in @d. It is simply (val)^X where (val) is the number at the start of the interpolation step. This is set by the @b command.
@f - Find the next non-zero term. Write the current value to the unnamed register, then write @f @d on the next line, and then run @z. This will repeat this command if the number is a zero, and execute @d if it isn't.
wmbyiwo@f @d^[@z

@z - Conditional execute if unnamed register is 0. This command expects two commands on a new line in the format command1 command2. If the unnamed register is 0, command1 is executed, otherwise command2 is executed. Note that neither command can have any spaces in it.
 IB0 B^R" ^OWB0 ^OA B0^[0*w"tyiWdd`b@t`

@t - Temporary command register. Stores various commands for a short time before executing them. Used primarily in if statements.
@d - Determine interpolation direction. Subtracts the first number in the sequence from the number under the cursor (using @s). If the result is negative, the interpolation must decrement so ^X is saved to @a. Otherwise, we should increment so ^A is saved to @a. Once this is saved, move back to the beginning of this interpolate cycle and run @i to actually interpolate
yiwo^V^X^R"^[0l@sa^V^A-^[0f-"ayhdd`a@i

@a - Stores either ^A or ^X to increment or decrement during the interpolation step. This is set by the @d command.
@i - Interpolate. Copy the number at the current location to @x and move to the next number. If that number is zero, replace it with @x and run @a to properly modify it up or down, then repeat this command. If the number isn't a zero, we have reached the end of this interpolation cycle. A new one should be started with this number as the beginning, so run @e to check for the end and run again.
"xyiwwmbyiwocw^V^Rx^V^[@a@i @e^[@z

@x - Temporary storage register. Used in the interpolate command (@i)
Breaking Down the keystrokes
mbo :Set b mark to current position and open a new line below to write macros
mayiwo^V^R"^V^V^V^X ^V^["sy0dd`a@f ^["bc0 :Write to @b and reset line

yiwo^V^V^V^X^V^R"^V^[0l@sa^V^V^V^A-^V^[0f-"ayhdd`a@i ^["dc0 :Write to @d and reset line

mbyiwo^V^R"Exe@b^V^[0fel"ty2ldd`b@t ^["ec0 :Write to @e and reset line

wmbyiwo@f @d^V^[@z ^["fc0 :Write to @f and reset line

"xyiwwmbyiwocw^V^V^V^Rx^V^V^V^[@a@i @e^V^[@z ^["ic0 :Write to @i and reset line

IB0 B^V^R" ^V^OWB0 ^V^OA B0^V^[0*w"tyiWdd`b@t ^["zd0 :Write to @z and reset line

dd`b :Delete this line and move cursor back to original line

Ae^[ :Append an e to the last number

0@e  :Move to the beginning of the line and run

Python 3.5, 159 bytes
a recursive solution
def f(s):
 h=s[0]
 g=lambda s,h,v:h*(h[-1]==s[0])if len(s)==1else(g(s[1:],h+[h[-1]-v],-v)+g(s[1:],h+[h[-1]+v],+v))*(s[0]==0 or h[-1]==s[0])
 return g(s,[h],1)

Ungolfed
def f(s):
    h=s[0]
    def g(s,h,v):
        if len(s)==1:
            if h[-1]!=s[0]:
                r=[]
            else:
                r=h
        else:
            if s[0]==0:
                r=g(s[1:],h+[h[-1]+v],v)
            elif h[-1]!=s[0]:
                r=[]
            else:
                r=g(s[1:],h+[h[-1]-v],-v)+g(s[1:],h+[h[-1]+v],+v)
        return r
return g(s,[h],1)

In the golfed solution, I replace conditions by using the fact that h*True=h and h*False=[]
Result
>>> f([7, 6, 0, 0, 3, 0, 0, 0, 7, 0, 5])
[7, 6, 5, 4, 3, 4, 5, 6, 7, 6, 5]

Perl 6, 54 bytes
{$_=$^a;1 while s/:s(\d+) 0 + (\d+)/{+~$0...+~$1}/;$_}

MATLAB, 39 38 37 bytes
@(a)interp1(find(a),a(a>0),find(a/0))

Anonymous function that linearly interpolates between the points in a. find(a) is an array of indices of non-zero elements in a and a(a>0) are the positive values. Saved 1 byte thanks to a friend's suggestion of > rather than ~=.

J, 32 bytes
{:,~[:;2<@({.+(i.@|**)@-~/)\-.&0

Try it online!

-.&0 Remove zeroes.
2...\ For each infix of size 2...
@-~/ Subtract the left from the right and...
(i.@|**) Create integers 0..<size of difference>, multiplied by * the sign of the difference *.
<@ And box (technical necessity for ragged arrays in J).
[:; Raise the result to remove the boxes.
{:,~ And append the last element of the original array.

Husk, 3 bytes
…fI

Try it online!