PART 1  Stack: PUSH charged 2, POP and MULTIPOP charged 0.
op                     items  actual  charged  credit  (= items?)
PUSH 1                     1       1        2       1   yes
PUSH 2                     2       2        4       2   yes
PUSH 3                     3       3        6       3   yes
PUSH 4                     4       4        8       4   yes
POP                        3       5        8       3   yes
MULTIPOP 2                 1       7        8       1   yes
PUSH 9                     2       8       10       2   yes
MULTIPOP 100               0      10       10       0   yes

200000 random stack operations: lowest credit ever seen = 0; final credit = 9, final stack size = 9

PART 2  Counter: charge 2 for every bit set to 1, 0 for every reset.
  n   value  ones  actual  charged  credit  (= ones?)
   1       1     1       1        2       1     yes
   2       2     1       3        4       1     yes
   3       3     2       4        6       2     yes
   4       4     1       7        8       1     yes
   5       5     2       8       10       2     yes
   6       6     2      10       12       2     yes
   7       7     3      11       14       3     yes
   8       8     1      15       16       1     yes
   9       9     2      16       18       2     yes
  10      10     2      18       20       2     yes
  11      11     3      19       22       3     yes
  12      12     2      22       24       2     yes
  13      13     3      23       26       3     yes
  14      14     3      25       28       3     yes
  15      15     4      26       30       4     yes
  16      16     1      31       32       1     yes

1000000 increments: lowest credit ever seen = 0; final credit = 7, number of 1 bits = 7
actual cost = 1999993, charged = 2000000 (= 2n, the bound proved in the text)
