text:
No A, just CAPS LOCK
What happens when the CapsLock key on your keyboard doesn't have a notch in it?
"This hPPENS."
The goal of this program is to consistently emulate keyboard misses where each A press is replaced with CapsLock. Uppercase 'A's from the source should yield the same effect. When CapsLock is enabled, capitalization is reversed.
Test Cases
"The quick brown fox jumps over the lazy dog."
-> "The quick brown fox jumps over the lZY DOG."

"Compilation finished successfully."
-> "CompilTION FINISHED SUCCESSFULLY."

"What happens when the CapsLock key on your keyboard doesn't have a notch in it?"
-> "WhT Hppens when the CPSlOCK KEY ON YOUR KEYBOrd doesn't hVE  notch in it?"

"The end of the institution, maintenance, and administration of government, is to secure the existence of the body politic, to protect it, and to furnish the individuals who compose it with the power of enjoying in safety and tranquillity their natural rights, and the blessings of life: and whenever these great objects are not obtained, the people have a right to alter the government, and to take measures necessary for their safety, prosperity and happiness."
-> "The end of the institution, mINTENnce, ND dministrTION OF GOVERNMENT, IS TO SECURE THE EXISTENCE OF THE BODY POLITIC, TO PROTECT IT, nd to furnish the individuLS WHO COMPOSE IT WITH THE POWER OF ENJOYING IN Sfety ND TRnquillity their nTURl rights, ND THE BLESSINGS OF LIFE: nd whenever these greT OBJECTS re not obtINED, THE PEOPLE Hve  RIGHT TO lter the government, ND TO Tke meSURES NECESSry for their sFETY, PROSPERITY nd hPPINESS."

"aAaaaaAaaaAAaAa"
-> "" (Without the notch, no one can hear you scream)

"CapsLock locks cAPSlOCK"
-> "CPSlOCK LOCKS CPSlOCK"

"wHAT IF cAPSlOCK IS ALREADY ON?"
-> "wHt if CPSlOCK IS lreDY ON?"

The winning criterion is, as usual, the size of the submitted program's source code.

Welcome to the site! This is a nice first challenge, and unfortunately very relatable for me and my fT FINGERS.

What characters will be in the input ? a-zA-Z?

suggested test case : teSTateSTateSTateST

@Rod Look at the examples. Printable ASCII seems to be included.

@Rod -> teSTTEstteSTTEst.

@Rod All characters except 'a' or 'A' are allowed in the output. Non-letters do not get changed.

@Broadwell He said "input", not "output"

hey so in the future I would recommend using sandbox :P but very good challenge

@Christopher is referring to the Sandbox, which is where users typically post questions to ask for improvements.

If only the enter key also had a notch in it so this wouldn'

t happen.......

TIL that @DJMcMayhem was trying to create the nick DJMACMayhem...

Literally joined this site to upvote "Without the notch, no one can hear you scream"

Is the sixth example correct?

Why is the title of this question not “No A, just cPS LOCK”?

Wouldn't it be "No , JUST Cps lock"?

I LSO WISH THt my keyboRD Hd a bigger bCKSPce kwt==et=y

@12Me21 I was allowing for not missing the A key when also holding down the shift key at the same time, since shift + caps lock is actually more difficult than shift + A. Also that would make the title completely illegible. But yes, if we went for the purely programmatic approach, it would.

Related

Test case: correct horse bTTERY STple

AutoHotKey, 7 bytes
a::vk14

// Is this valid? This really do what OP want -- replace a by CapsLock (vk14).
Run this program, and type the input from keyboard..

"Is this valid?" OP did not specify input or output constraints so I´d consider this valid.

Don't see too many ahk answers!

"my code runs everywhere"

I would cLL THIS Vlid!

ThT'S GREt but how do I disBLE IT?

@RobbG just type "killLL utohotkey" ... oh wIT

@RobbG You could copy/pSTE THE  in the title.

No ide WHt you're LL Tlking BOUT... MY  ND Cps lock work fine... wait

V, 9 bytes
ò/ãa
xg~$

Try it online!
Hexdump:
00000000: f22f e361 0a78 677e 24                   ./.a.xg~$

Explanation:
ò       " Recursively:
 /ãa    "   Move forward to the next 'a' (upper or lowercase)
        "   This will break the loop when there are no more 'a's
x       "   Delete the 'a'
 g~$    "   Toggle the case of every character after the cursor's position.

Vim, 16 bytes
qq/\ca
xg~$@qq@q

Assumes the input is on a single line
Explanation
qq            Start a loop
 /\ca␊         Find the first occurence of an a, end the loop if there are none left
 xg~$          Remove it and invert the case of the rest of the file
@qq@q         End the loop

Is this case insensitive finding of 'a'?

@Gnudiff \c anywhere in a regex-search enables case-insensitivity

Do you need to set a specific flag for g~$ to work? Because for me it only inverts case until the end of the line, not the whole file, so this doesn't really work for multiline files for me.

@Cubic As I wrote in the answer, it "assumes the input is on a single line"

@Cubic If you wanted it to go the end of the file and support inputs on multiple lines, you could do g~vG or vG~.

@DJMcMayhem I think using 'n' instead of '$' would work also?

C, 72 bytes
Thanks to @Ton Hospel for helping to save 16 bytes!
t,c;f(char*s){for(t=0;c=*s++;6305%c?putchar(isalpha(c)?c^t:c):(t^=32));}

Try it online!

You can swap the case of letters using a xor with 32

You can probably save even more by having t be 0/32 instead of even/odd (xor t with 32 for each a)  and then xor letters directly with t

Nice way to detect a's

And why initialize t ? It starts as 0 anyways :-) (though you will have to set it back to 0 after each f call in the footer)

@TonHospel Functions have to be reusable, and I don't think it counts as reusable if you need external code to make it usable again after each call.

6305%c is 0 if c is 13.

Husk, 11 bytes
Γ·§?m\:€"Aa

Try it online!
Explanation
I'm using the somewhat obscure overloading of Γ called listNF, which constructs recursive functions that operate on lists.
It corresponds to the following Haskell pattern:
listNF f = g
  where g (x : xs) = f g x xs
        g [] = []

The idea is that listNF takes a helper function f and returns a new function g, which takes a list.
The function f takes a function, which will always be g, and the head x and tail xs of the list, and does something with them.
In our application, f calls g recursively on xs.
The program is interpreted like this:
Γ (· (§ (?m\) : (€"Aa")))
Γ (                     )  Create a function g that takes a list (x:xs) and applies a function on x and xs.
   · (                 )   Compose g with second argument of function in parentheses.
                           Instead of x and xs, the function is called on x and the result of a recursive call of g on xs.
                (€"Aa")    Check if x is 'A' or 'a'.
        (?m\)              If it is, then swap the case of every char in g(xs).
      §       :            Otherwise, prepend x to g(xs).

Wow, good thing I refreshed before I posted my 12 byte solution: Ḟ·+m\ṁx'Ax'a. Could we get an explanation? I can't find any information on what Γ does exactly and this seems like a good chance to learn.

@SophiaLechner Done. This version of Γ is a bit hard to explain, I hope you can make sense of it.

Wow this is slow. Is it just TIO?

@FrownyFrog It's Husk. Type inference of programs containing Γ seems to be slow in general. If you're not familiar with Husk, a program is interpreted by looping through all possible structures of the program (essentially the possible placements of parentheses) and all overloadings of each built-in, and choosing the first one where the result is well-typed. The interpreter is smart enough to reject some possibilities early, but it seems that the recursive version of Γ can mess with this step and force it to loop through a lot of choices.

@SophiaLechner I wrote a tip that explains Γ in some detail.

Retina, 33 21 17 bytes
i(Tv`lL`Ll`a.*
a

Try it online
Explanation:
i(              i is for case-insensitive, the paren makes it modify both stages
  Tv`           Transliteration, with simple overlaps (v) - 1 match at every start pos
     lL`Ll`     Replace lowercase with uppercase, and vice versa
           a.*  Every 'a' will match, overlapping to the end of the string
                This swaps the case on all letters after each 'a'
a               Replace all 'a's with nothing

-12 bytes thanks to Martin
-4 bytes thanks to Leo

Amazingly this is almost as short as the current Pyth solutions

I think iT`aAlL`__Ll`a[^a]*a? also works for 21 bytes.

4 bytes shorter using overlapping matches

I'm interested in how this works if you have time to add the explanation. Thanks!

JavaScript (ES6), 93 88 84 82 bytes
(saved 5 bytes thanks to @Shaggy, 4 bytes thanks to @user81655, and 2 bytes thanks to @l4m2.)
a=>a.replace(A=/./g,c=>c in{a,A}?(A=!A,''):A?c:c[`to${c<{}?'Low':'Upp'}erCase`]())

Test cases:

let f=

a=>a.replace(A=/./g,c=>c in{a,A}?(A=!A,''):A?c:c[`to${c<{}?'Low':'Upp'}erCase`]())

console.log(f("The quick brown fox jumps over the lazy dog."));
console.log(f("Compilation finished successfully."));
console.log(f("What happens when the CapsLock key on your keyboard doesn't have a notch in it?"));
console.log(f("The end of the institution, maintenance, and administration of government, is to secure the existence of the body politic, to protect it, and to furnish the individuals who compose it with the power of enjoying in safety and tranquillity their natural rights, and the blessings of life: and whenever these great objects are not obtained, the people have a right to alter the government, and to take measures necessary for their safety, prosperity and happiness."));
console.log(f("aAaaaaAaaaAAaAa"));
console.log(f("CapsLock locks cAPSlOCK"));
console.log(f("wHAT IF cAPSlOCK IS ALREADY ON?"));

['to${c<'a'?'Low':'Upp'}erCase'] should save you a few bytes, replacing single quotes with backticks.

Sure does, @Shaggy.  Thanks!

Using ^1 to have u be the parity can let you initialise it shorter: s=>s.replace(u=/./g,c=>/a/i.test(c)?(u^=1,''):+u?c[`to${c<'a'?'Low':'Upp'}erCase`]():c)

Also here's another tricky way to test for the letter a which is shorter: a=>a.replace(A=/./g,c=>c in{a,A}?(A^=1,''):+A?c[`to${c<'a'?'Low':'Upp'}erCase`]():c)

Brilliant, @user81655, especially using the in operator like that.  Always more to learn!

Use {} as "[object Object]" to distingish upper and lower

Very nice, @l4m2, thanks!

@RickHitchcock does a=>a.replace(A=/./g,c=>c in{a,A}?(A=!A,''):A?c:c[`to${c<{}?'Low':'Upp'}erCase`]()) work?

Ahh, that's what you meant by Use {}.  Sorry, yes, that's perfect, thanks again.

R, 92 bytes
cat(`[<-`(v<-el(strsplit(scan(,""),"a|A")),w<-c(F,T),chartr("a-zA-Z","A-Za-z",v)[w]),sep="")

Thank @Giuseppe for fixing the answer.
Explanation
# Write
cat(
  # Replace and return, this is the function that powers
  # the R store at index operations, a[i]<-b
  `[<-`(
    # First arg - what to replace = extract first list element
    # of a string input after splitting at a or A
    v<-el(strsplit(scan(,""),"a|A")),
    # Second arg - index to replace = abuse vector recycling
    # to create infinite F, T, F, T, F, etc series
    w<-c(F,T),
    # Third arg - replacement values = replace with case toggled letters
    chartr("a-zA-Z","A-Za-z",v)[w]),
  # Write without separation
  sep="")

Try it online!

Perhaps I didn't make it clear, but this answer does not reverse capitalization when CapsLock is enabled (it only performs toupper), which is a requirement.

ooohhhhhhh that's very clever with the c(F,T), although @Broadwell is right; looks like it'll be a chartr("a-zA-Z","A-Za-z",v)[w] rather than toupper

Java 8, 119 108 98 bytes
s->{int f=0,t;for(int c:s)if((t=c&95)==65)f^=1;else System.out.printf("%c",f<1|t<66|t>90?c:c^32);}

-11 bytes thanks to @OlivierGrégoire.
-10 bytes thanks to @Nevay.
Explanation:
Try it online.
s->{                           // Method with char-array parameter and no return-type
  int f=0,t;                   //  Flag-integer, starting at 0
  for(int c:s)                 //  Loop over the characters of the input as integers
    if((t=c&95)==65)           //   If the current character is an 'A' or 'a':
      f^=1;                    //    Toggle the flag (0→1 or 1→0)
    else                       //   Else:
      System.out.printf("%c",  //    Print integer as character
        f<1|                   //     If the flag-integer is 0,
        t<66|t>90?             //     or the current character isn't a letter:
         c                     //      Simply output the character as is
        :                      //     Else (the flag it 1 and it's a letter)
         c^32);}               //      Print it with its case reversed

Damn imperatives... they forbade me to post my answer before yours... Anyways, here's my answer, 11 bytes shorter: s->{int z=0,d;for(int c:s)if((d=c&95)==65)z^=1;else System.out.printf("%c",z<1|d<66|d>90?c:c<91?c|32:c&95);}

@OlivierGrégoire Nice answer! And what do you mean by forbade me to post? Is your work-network that strict?

My answer was ready for a while: I was just polishing the test cases before posting but then suddenly endless meetings happened.

@OlivierGrégoire Ah of course.. The meetings that always come at the wrong time.. I know the feeling sometimes. ;)

No, it's just that your answer was so similar to mine that it wouldn't have been correct to post mine ;)

@OlivierGrégoire If you want I can delete mine and you can post it as yours. You've got my upvote if you do. :)

No, it's ok, I only have to blame myself for not being quick enough before the meetings ;-) But thank you for suggesting this!

98 bytes: s->{int f=0,t;for(int c:s)if((t=c&95)==65)f^=1;else System.out.printf("%c",f<1|t<66|t>90?c:c^32);}

Python, 63 bytes
f=lambda s:s and[s[0]+f(s[1:]),f(s[1:]).swapcase()][s[0]in"aA"]

Another Python solution, works in Python 2 and 3.
Takes a very long time for all but small inputs.

Perl 5 -p, 31 30 29 bytes
-1 byte thanks to @nwellnhof
-1 byte thanks to @ikegami
#!/usr/bin/perl -p
s/a([^a]*)a?/$1^uc$1^lc$1/egi

Try it online!

Why not simply s/a(.*?)(a|$)/uc$1/egi (22 bytes)?

@nwellnhof Because the capslock when active toggles the case, it doesn't just uppercase

Ah, I see. Then s/a(.*?)(a|$)/$1^uc$1^lc$1/egi is one byte shorter.

@nwellnhof Thanks, that is very neat

a([^a]*)a? is shorter than a(.*?)(a|$)

PowerShell Core, 105 bytes
"$args"|% t*y|%{if($_-in97,65){$c=!$c}else{Write-Host -n($_,("$_"|%("*per","*wer")[$_-in65..90]))[!!$c]}}

Try it online!
What with no real ternary operator and no default alias for printing to screen, it's not that short.

% t*y expands to | ForEach-Object -Method ToCharArray equiv. of "$args".ToCharArray()
Write-Host -n is for the parameter -NoNewLine
"$_" turns the [char] type back to [string] (chars have no upper/lower case in .Net)
|% *per does the same method call shortcut as earlier, but for .ToUpper(), same with .ToLower()
($a,$b)[boolean test] abused as fake-ternary operator
!!$c force-casts to [bool] here it starts undefined $null so it gets forced it into existence as "caps lock: $false".

That |% t*y is a neat trick I'll need to remember. Shorter than [char[]], which I use a lot. I'd almost say that should go onto the Tips thread.

94 bytes: -join($args|% t*y|%{if($_-eq'a'){$c=!$c}else{(("$_"|%("*per","*wer")[$_-in65..90]),$_)[!$c]}}). thanks for a |% *ethod operator!

Ruby, 42 41 bytes
->s{s.sub!(/a(.*)/i){$1.swapcase}?redo:s}

Try it online!
A lambda accepting a string, mutating the string in place, and returning it. The trick here is that sub returns the string (a truthy value) if a substitution was made, and returns nil otherwise. The existence of swapcase is pretty handy, too.
-1 byte: Replace boolean logic with ternary operator, thanks to Asone Tuhid
->s{
  s.sub!(/a(.*)/i){     # Replace "a" followed by anything with
    $1.swapcase         #   the case-swapped capture group
  } ? redo              # If a match was found, restart the block
    : s                 # Otherwise, return the modified string
}

save 1 byte. The link was too long if I included all the test cases.

@AsoneTuhid Thanks... One of these days I'll remember to use the ternary operator straight away, so you won't have to remind me.

C, 167 168 158 131 bytes
Thanks for @Martin Ender for the code review: I've switched the stream processing for string processing to help with reusability. Also many thanks to @RiaD and @ceilingcat for their suggestions.
c,d;(*t[][2])()={{isupper,tolower},{islower,toupper}};f(char*s){for(d=1;c=*s++;)t[0][1](c)==97?d=!d:putchar(t[!t[d][0](c)][1](c));}

Try it online!
How does it work?
/* int c is the input character,
   int d is the Caps Lock flag (1=off, 0=on)  starting as "Off". */
int c, d;
/* array of comparison functions and transformation functions for each state */
(*t[][2])() = {{isupper, tolower}, {islower, toupper}};

f(char *s) {
  /* Loop if we haven't hit the terminator */
  for(d = 1; c = *s++;)
    t[0][1](c) == 97 ?
      /* If tolower(c)=='a' then flip the Caps Lock state */
      d=!d:
      /* Otherwise, convert character according to the following table:

                       Character case
         Caps Lock  UPPER       LOWER
                ON  tolower()   toupper()
               OFF  toupper()   tolower()
      */
      putchar(t[!t[d][0](c)][1](c));
  }
}

Notes

s[][] is where the magic happens: [][0] is the comparison function and [][1] is the related transformation function for each state.
! is applied to the comparison function to force it into the range [0,1].

Welcome to PPCG! Unfortunately, you can't rely on the initialisation of d like this because it means that your function is not reusable. A simple d=0; should fix it.

I wasn't sure if reusability or maintaining state was more important in this case. If reusability is more important, I would move the variable declarations inside the function so the beginning would read void f(){int c,d=0;[...]. In any case, the stream dies, so an edit is in order!

do you need s in your while loop? It can't became NULL unless you called with f(NULL)

d=!d for flipping

!! will be ! if you flip order of t, and start d with 1

you may also just remove first 2

Suggest 1[*t] instead of t[0][1]

Jelly, 14 bytes
Œu=”Aœp⁸ŒsJḤ$¦

Try it online!
Full program.
Explanation:
Œu=”Aœp⁸ŒsJḤ$¦ Arguments: x
Œu             Uppercase x
  =”A          ^ Equals 'A' (vectorizes)
     œp⁸       ^ Partition ⁸ [⁸=x]
             ¦ Apply link A, keep results at specific indices B
        Œs     A: Swap case
            $  B: Form a >=2-link monadic chain
          JḤ      Arguments: y
          J       Get list indices ([1, length(list)]) of y
           Ḥ      Double (vectorizes) ^
                  This way, we only "apply" link A to even indices, so every second
                  element, starting from the secondd one.

Explanation of the code?

@SK19 Added an explanation.

6502 machine code routine (C64), 51 bytes
A0 00 84 FE B1 FC F0 2A C9 41 F0 06 90 1A C9 C1 D0 08 A9 80 45 FE 85 FE B0 11
B0 06 C9 5B B0 08 90 04 C9 DB B0 02 45 FE 20 16 E7 C8 D0 D6 E6 FD D0 D2 60

Expects a pointer to a 0-terminated input string in $fc/$fd, outputs to the screen.
Commented disassembly
 .caps:
A0 00       LDY #$00
84 FE       STY $FE             ; init capslock state
 .loop:
B1 FC       LDA ($FC),Y         ; next char from string
F0 2A       BEQ .done           ; NUL -> we're done
C9 41       CMP #$41            ; compare to 'a'
F0 06       BEQ .isa            ; if equal, toggle capslock
90 1A       BCC .out            ; if smaller, direct output
C9 C1       CMP #$C1            ; compare to 'A'
D0 08       BNE .ctog           ; if not equal, check for letter
 .isa:
A9 80       LDA #$80            ; toggle bit 7 in caps lock state
45 FE       EOR $FE
85 FE       STA $FE
B0 11       BCS .next           ; and go on
 .ctog:
B0 06       BCS .cZ             ; if char larger 'A', check for 'Z'
C9 5B       CMP #$5B            ; compare with 'z'+1
B0 08       BCS .out            ; larger or equal -> direct output
90 04       BCC .tog            ; smaller -> apply capslock
 .cZ:
C9 DB       CMP #$DB            ; compare with 'Z'+1
B0 02       BCS .out            ; larger or equal -> direct output
 .tog:
45 FE       EOR $FE             ; toggle bit from capslock state
 .out:
20 16 E7    JSR $E716           ; output char
 .next:
C8          INY                 ; and loop to next char
D0 D6       BNE .loop
E6 FD       INC $FD
D0 D2       BNE .loop
.done:
60          RTS

Example assembler program using the routine:
Online demo

Code in ca65 syntax:
.import caps ; link with routine above

.segment "BHDR" ; BASIC header
                .word   $0801           ; load address
                .word   $080b           ; pointer next BASIC line
                .word   2018            ; line number
                .byte   $9e             ; BASIC token "SYS"
                .byte   "2061",$0,$0,$0 ; 2061 ($080d) and terminating 0 bytes

.bss
string:         .res    $800

.data
prompt:         .byte   $d, "input> ", $0

.code
                lda     #$17            ; set upper/lower mode
                sta     $d018

                lda     #<prompt        ; display prompt
                ldy     #>prompt
                jsr     $ab1e

                lda     #<string        ; read string into buffer
                sta     $fc
                lda     #>string
                sta     $fd
                jsr     readline

                lda     #>string        ; call our caps routine on buffer
                sta     $fd
                jmp     caps

; read a line of input from keyboard, terminate it with 0
; expects pointer to input buffer in $fc/$fd
; NO protection agains buffer overflows !!!
.proc readline
                ldy     #$0
                sty     $cc             ; enable cursor blinking
                sty     $fe             ; temporary for loop variable
                lda     $fd
                sta     $2              ; initial page of string buffer
getkey:         jsr     $f142           ; get character from keyboard
                beq     getkey
                sta     $fb             ; save to temporary
                and     #$7f
                cmp     #$20            ; check for control character
                bcs     prepout         ; no -> to normal flow
                cmp     #$d             ; was it enter/return?
                beq     prepout         ; -> normal flow
                cmp     #$14            ; was it backspace/delete?
                bne     getkey          ; if not, get next char
                lda     $fe             ; check current index
                bne     prepout         ; not zero -> ok
                lda     $2              ; otherwise check if we're in the
                cmp     $fd             ;    first page of the buffer
                beq     getkey          ; if yes, can't use backspace
prepout:        ldx     $cf             ; check cursor phase
                beq     output          ; invisible -> to output
                sei                     ; no interrupts
                ldy     $d3             ; get current screen column
                lda     ($d1),y         ; and clear
                and     #$7f            ;   cursor in
                sta     ($d1),y         ;   current row
                cli                     ; enable interrupts
output:         lda     $fb             ; load character
                jsr     $e716           ;   and output
                ldx     $cf             ; check cursor phase
                beq     store           ; invisible -> to store
                sei                     ; no interrupts
                ldy     $d3             ; get current screen column
                lda     ($d1),y         ; and show
                ora     #$80            ;   cursor in
                sta     ($d1),y         ;   current row
                cli                     ; enable interrupts
                lda     $fb             ; load character
store:          cmp     #$14            ; was it backspace/delete?
                beq     backspace       ; to backspace handling code
                ldy     $fe             ; load buffer index
                sta     ($fc),y         ; store character in buffer
                cmp     #$d             ; was it enter/return?
                beq     done            ; then we're done.
                iny                     ; advance buffer index
                sty     $fe
                bne     getkey          ; not zero -> ok
                inc     $fd             ; otherwise advance buffer page
                bne     getkey
done:           lda     #$0             ; terminate string in buffer with zero
                ldy     $fe             ; get buffer index
                iny
                bne     termidxok       ; and advance ...
                inc     $fd
termidxok:      sta     ($fc),y         ; store terminator in buffer
                inc     $cc             ; disable cursor blinking
                rts                     ; return
backspace:      ldy     $fe             ; load buffer index
                bne     bsidxok         ; if zero
                dec     $fd             ;   decrement current page
bsidxok:        dey                     ; decrement buffer index
                sty     $fe
                bcs     getkey          ; and get next key
.endproc

I just have to say I admire you went to the effort to write in assembly. I don’t think this has much to do with the fact I used to really enjoy asm but maybe having the experience makes me more aware of what it entails. Experience or ease is besides the point to me. It brightens my day just a bit to see such enthusiasm too.

@Pryftan thanks :) It's just a nice way to keep in practice, I'm working on some game and recently also demo code for this nice old machine :)

Well it's great to see! Keep it up; I remember enjoying asm but I don't think I'd enjoy it so much nowadays (unless maybe I had an old machine like you do, that is but possibly not even then) - C is my favourite all time and it's what I primarily use. Anyway, won't let this evolve into chat - just wanted to say I appreciated the answer!

05AB1E, 12 bytes
õ?„AaS¡Dvć?š

Try it online!
Explanation
õ?             # print an empty string (to account for the special case of only A's)
  „AaS¡        # split on occurrences of "A" or "a"
       D       # duplicate
        v      # for each element in the top copy
         ć?    # extract and print the head of the other copy
           š   # switch the case of the rest of the other copy

PHP 101 99 bytes
for($s=$argn;$i<strlen($s);$i++)lcfirst($s[$i])==a?$s=strtolower($s)^strtoupper($s)^$s:print$s[$i];

Run like this:
echo '[the input]' | php -nR '[the code]'

Ungolfed:
for ($s = $argn; $i < strlen($s); $i++) {
    if (lcfirst($s[$i]) == 'a') {
        $s = strtolower($s) ^ strtoupper($s) ^ $s; // Flip the whole string's case.
    } else {
        print $s[$i]; // Print the current letter.
    }
}

This just loops through the string with a for loop, and on each iteration it checks if the current letter is a, if so, then flip the case of the whole string (method from here), and if not, then print the current letter.

The convention for code golf is that all code must be included. That means you have to take input as function parameter and actually declare a function (via the function keyword in php) or have a complete script (e.g. using $argn, $argv, $_GET). So at the moment this is not a correct submission. Return must be echoed or returned (only allowed for functions ofc).

Thanks for that @Christoph, I'm kind of new to golfing :). I've updated my answer now, just let me know if there's anything else that's wrong.

@Christoph Wow! 75! Very nice! You have my +1 :)

Fortran (GFortran), 307 bytes
CHARACTER(999)F,G
G=' '
READ(*,'(A)')F
N=1
M=1
DO I=1,999
IF(F(I:I)=='a'.OR.F(I:I)=='A')THEN
M=-M
ELSEIF(M==1)THEN
G(N:N)=F(I:I)
N=N+1
ELSE
J=IACHAR(F(I:I))
SELECTCASE(J)
CASE(65:90)
G(N:N)=ACHAR(J+32)
CASE(97:122)
G(N:N)=ACHAR(J-32)
CASE DEFAULT
G(N:N)=F(I:I)
ENDSELECT
N=N+1
ENDIF
ENDDO
PRINT*,TRIM(G)
END

Try it online!
Since Fortran has not "advanced" tools for dealing with strings, I came up with this little monster.
Indented and commented:
CHARACTER(999)F,G	!Define input and output strings (up to 999 characters)
G=' '			!Fill output with spaces
READ(*,'(A)')F		!Take input
N=1			!Represent the position to be written in output string
M=1			!M=-1: Change case; M=1: Do not change case
DO I=1,999
	IF(F(I:I)=='a'.OR.F(I:I)=='A')THEN	!If the character is A...
		M=-M				!Ah-ha - you pressed cPS-LOCK!
	ELSEIF(M==1)THEN			!Case the character is not A, and do not need to change case...
		G(N:N)=F(I:I)			!...only copy the character
		N=N+1
	ELSE !Otherwise...
		J=IACHAR(F(I:I))			!...get ascii of current character
		SELECTCASE(J)
			CASE(65:90)			!If is upper case,
				G(N:N)=ACHAR(J+32)	!now is lower case
			CASE(97:122)			!If is lower case,
				G(N:N)=ACHAR(J-32)	!now is upper case
			CASE DEFAULT			!If do not belong to alphabet,
				G(N:N)=F(I:I)		!simply copy the character
		ENDSELECT
		N=N+1
	ENDIF
ENDDO
PRINT*,TRIM(G) !Trim out trailing spaces
END !That's all folks!

Wolfram Language (Mathematica), 70 bytes
#//.{x___,"a"|"A",y___}:>Join[{x},ToUpperCase@#+ToLowerCase@#-#&@{y}]&

Try it online!
Takes input and output as a list of characters. For convenience I've added code in the footer to convert this from and back to a string.
How it works
The #//.{x___,"a"|"A",y___}:>Join[{x},...{y}]& part is standard: we find the first A (uppercase or lowercase), reverse case of that comes after the A, and repeat until there are no more A's to be found.
The interesting part is how we reverse case: the function ToUpperCase@# + ToLowerCase@# - #&. We add together the upper-cased version of the input and the lower-cased version of the input, then subtract the actual input. For example, given the list {"I","n","P","u","T"} this computes
{"I","N","P","U","T"}+{"i","n","p","u","t"}-{"I","n","P","u","T"}

which threads over lists as
{"I"+"i"-"I","N"+"n"-"n","P"+"p"-"P","U"+"u"-"u","T"+"t"-"T"}

and although Mathematica doesn't have any particular way of adding two strings, it's smart enough to simplify a+b-a to b for any values of a and b, including string values, so this simplifies to {"i","N","p","U","t"}.

MATL, 23  20 bytes
'a A'Yb&Ybt2L)Yo2L(g

Try it online!
Explanation:
'a A'Yb   % form a cell array containing {'a', 'A'}
&Yb       % split input into substrings, with either of those ('a' or 'A') as delimiters
t2L)      % extract out the even positioned cells from that result
Yo        % switch the case of those substrings
2L(       % place the result back in even positioned cells of the original cell array
g         % convert cell array to matrix, concatenating all substrings in the process
          % implicit output

Older answer (23 bytes):
"H@'aA'm?~XHx}@w~?Yo]&h
Other methods I tried:
0w"@t'aA'm?x~}y?Yo]w]]xv!
t'aA'mXHYsot&y*XzcYowf([]H(
t'aA'mXHYsoy3Y2m*32*Z~c[]H(

Julia 1.0, 82 bytes
s->foldl((b,c)->c∈"aA" ? !b : (print(c+32isletter(c)sign('_'-c)b);b),s,init=1<0)

Explanation
De-golfed:
function f(s::String)::Bool
    foldl(s, init=false) do b, c
        if c ∈ "aA"
            return !b
        else
            print(c + 32 * (isletter(c) & b) * sign('_'-c))
            return b
        end
    end
end

foldl(f, s, init=false): takes a function f that maps a state and a Char c to a new state. Applys f repeatedly over each Char of the string s, always passing the state previously returned by f back to f. init is the initial state. Here the state represents whether caps-lock is on.
if c in "aA": If c is an upper- or lowercase 'a', just return the opposite state.
isletter(c) & b: Bool, returns true iff c is a letter and b indicates, that caps-lock is on.
sign('_'-c): -1 if c is lowercase, 1 if c is uppercase.
print(c + 32 * (isletter(c) & b) * sign('_'-c)): Bools act like 0/1 under simple arithmetic operations, so if caps-lock should have an effect, this either adds or substracts 32 from c, returning a Char with opposite case. Then just print that.
Try it online!

Vyxal s, 12 10 9 bytes
Saved 2 bytes by using ṡ to split the string with a regex.
Saved 1 byte by using ⁽ to define the function.
`a|A`ṡ⁽Nẇ

Try it Online!
Explanation:
           # Implicit input
`a|A`ṡ     # Split string every instance 'a' OR 'A'
      ⁽N   # Define a function that swaps the casing of strings
        ẇ  # Apply the function to every 2nd string
           # 's' flag: concatenate top of the stack and print

SNOBOL4 (CSNOBOL4), 141 92 bytes
	I =INPUT
S	I ANY("Aa") REM . R =REPLACE(R,&LCASE &UCASE,&UCASE &LCASE) :S(S)
	OUTPUT =I
END

Try it online!
Assumes a single line of input.
A whopping 49 bytes saved by @ninjalj!
Line S does all the work, explained below:
I                    # in the subject string I match the following PATTERN:
 ANY("Aa")           # match A or a and
 REM . R             # match the remainder of I, assigning this to R
 =REPLACE(           # replace the PATTERN above with
          R, ...)    # R with swapped cases.
   :S(S)             # and if there was a match, goto S, else goto next line

This gives the wrong answer (as you stated in your comment, case is swapped when CapsLock is on)

I've edited the post to require case-swapping (rather than simply uppercase) when CapsLock is enabled because I never realized that my machine does this.

@mbomb007 ah, I hadn't realized OP had changed it; I'm editing for an explanation now so I'll include that in the explanation.

I =INPUT;S I ANY("Aa") REM . R =REPLACE(R,&LCASE &UCASE,&UCASE &LCASE) :S(S); OUTPUT =I;END

@ninjalj are you also a SNOBOL golfer or am I just terrible at golfing it??

@Giuseppe: I used to golf occasionally in SNOBOL at golf.shinh.org

Haskell, 92 bytes
import Data.Char
g x|x<'['=toLower x|1>0=toUpper x
f(a:b)|elem a"aA"=f$g<$>b|1>0=a:f b
f x=x

Try it online!
Explanation
First we declare g to be the function that maps lowercase to upper case and uppercase to lowercase.  This is actually the majority of our bytecount.  Then we define the function f.  If the input to f is of the form a:b we do
f(a:b)
 |elem a"aA"=f$g<$>b
 |1>0=a:f b

a and A match the first pattern and thus we apply f to the input with it's case inverted.  Otherwise we move a out front and apply f to b.

Husk, 15 bytes
ω(F·+otm\↕·≠_'a

Try it online!
Explanation
ω(F·+(tm\)↕·≠_'a) -- example input: "Bar, baz and Foo."
ω(              ) -- apply the following, until fixpoint is reached:
          ↕       -- | split string with predicate
           · _    -- | | the lower-cased character
            ≠ 'a  -- | | is not 'a'
                  -- | : ("B","ar, baz and Foo.")
  F               -- | apply the following to the tuple
    +             -- | | join the elements with..
   · (   )        -- | | ..the second element: "ar, baz and Foo."
       m\         -- | | | swap case: "AR, BAZ AND fOO."
      t           -- | | | tail: "R, BAZ AND fOO."
                  -- | : "BR, BAZ AND fOO."
                  -- : "BR, Bz ND fOO."

Stax, 12 bytes
ìo'½`║â↨╪U?5

Run and debug it online
It splits on a regex, and then alternately toggles case.  Here's the same program, unpacked, ungolfed, and commented.
"a|A"|s split on regex /a|A/
rE  reverse and explode array to stack
W   repeat forever...
p   print top of stack with no newline
:~p print top of stack, case inverted, with no newline

Run this one

I somehow cannot relate your explanation to your code.

Try stepping through the commented one, and watching the internal state of the interpreter.  Does that help?

@SK19:  Oh, I think I see the problem.  I didn't mention that stax programs have two representations.  Ascii and packed.  There's a lossless conversion between the two.  Ascii is easy to type, but wasteful for golf, since there are only 95 symbols.  The golfed program is packed, so it looks different, but it's the same program.

Japt v2.0a0, 16 bytes
e/a.*/i_År\l_c^H

Try it

Explanation
e                   :Recursively replace
 /a.*/i             :RegEx /a.*/gi
       _            :Pass each match through a function
        Å           :  Slice off the first character
         r          :  Replace
          \l        :  RegEx /[A-Za-z]/g
            _       :  Pass each match though a function
             c^     :    Bitwise XOR the character code
               H    :    With 32

Rust, 330 bytes
fn main(){let mut i=String::new();std::io::stdin().read_line(&mut i);let mut o=vec![];let mut c=false;for l in i.trim().as_bytes(){if*l==65||*l==97{c=!c;}else if c{if l.is_ascii_uppercase(){o.push((*l).to_ascii_lowercase());}else{o.push((*l).to_ascii_uppercase());}}else{o.push(*l);}}println!("{}",String::from_utf8(o).unwrap());}

Ungolfed
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input);
    let mut output_chars = vec![];
    let mut capslock = false;
    for letter in input.trim().as_bytes() {
        if *letter == 65 || *letter == 97 {
            capslock = !capslock;
        } else if capslock {
            if letter.is_ascii_uppercase() {
                output_chars.push((*letter).to_ascii_lowercase());
            } else {
                output_chars.push((*letter).to_ascii_uppercase());
            }
        } else {
            output_chars.push(*letter);
        }
    }
    println!("{}", String::from_utf8(output_chars).unwrap());
}

Since this uses bytes instead of chars in the loop, 65 and 97 are the byte values for 'A' and 'a'.
I'm new to Rust, so this might be golfable further.

Welcome to PPCG!

PHP 4, 77 76 75
foreach(spliti(a,$argn)as$b)echo$a++&1?strtoupper($b)^strtolower($b)^$b:$b;

Split into substrings by A (case insensitive) then toogle every second case.
Try it out here.

Old version
for(;a&$c=$argn[$i++];)trim($c,aA)?print($c^chr($f*ctype_alpha($c))):$f^=32;

walks over the string and toogles a flag if the current char is a or A else the char gets toogled depending on the flag and echoed.

Javascript (ES6), 80 79 bytes
(Partly based off of this answer by Rick Hitchcock. Posting as a separate answer because I don't have sufficient reputation to comment.)
(Saved 1 byte thanks to @l4m2's post here.)
a=>a.replace(j=/a()|./gi,(c,o=c[`to${j^c>{}?'Low':'Upp'}erCase`]())=>(j^=!o,o))

Welcome to PPCG!

Python 3, 78 72 bytes
import re
lambda x:re.sub("[Aa](.*?)(a|A|$)",lambda m:m[1].swapcase(),x)

You can use m[1] in place of m.group(1) on Python 3.6+.

Why was this flagged as low quality…?

I have no idea ...

New posts are flagged automatically if they are short and contain no text. Adding a description usually prevents that.

And now I wonder how many "A"s there are supposed to be in "ppperry".

Um, why should there be any?

><>, 139 129 bytes
1vo   <
>>i:"z")?^:"A"^>~~>~1$-
^o+< >::"aA"@=?^=?^$v
^o-^?  ("^"$*48:v?@:<
^ vv? )"Z":v?(< >>o
  >  ^v  < >:0 )?^;
  :< ^v?( "a"

A language with no concept of "characters" is surely the right tool for the job :)

x86-64, 31 bytes
Conforms to the System-V calling convention, tested in Ubuntu 16.04. Takes input from a pointer to a null-terminated in rsi, and outputs the result as a null-terminated string in rdi. rdi is expected to pointer to a buffer that's already been allocated with sufficient size.
Disassembly for byte count:
   0:       31 d2                   xor    edx,edx
   2:       ac                      lods   al,BYTE PTR ds:[rsi]
   3:       88 c1                   mov    cl,al
   5:       24 df                   and    al,0xdf
   7:       3c 41                   cmp    al,0x41
   9:       75 05                   jne    10 <not_A>
   b:       80 f2 20                xor    dl,0x20
   e:       eb f2                   jmp    2 <loop>
  10:       2c 41                   sub    al,0x41
  12:       3c 19                   cmp    al,0x19
  14:       77 02                   ja     18 <not_ascii>
  16:       30 d1                   xor    cl,dl
  18:       91                      xchg   ecx,eax
  19:       aa                      stos   BYTE PTR es:[rdi],al
  1a:       84 c0                   test   al,al
  1c:       75 e4                   jne    2 <loop>
  1e:       c3                      ret

Commented Assembly (GAS):
.intel_syntax noprefix
.text
// rsi has the input char*, rdi has the output char*.
// Input char* is \0-terminated.
.global caps
caps:
    // Use this for xor mask.
    xor     edx, edx
// Loop is set up as a do-while loop.
loop:
    // al = *rdi++
    lodsb

    // Save the character we read into cl.
    // We use al because the instructions are shorter.
    mov     cl, al

    // Make upper case
    and     al, 0b11011111

    // 65 = 'A'
    cmp     al, 65
    jne     not_A
is_A:
    // Invert capitialization mask
    xor     dl,0x20
    // Continue
    jmp     loop

not_A:
    // Now we check if input character is ascii.
    // Basically, if (al-'A' > 'Z'-'A'), it's not ascii
    sub     al, 65
    cmp     al, 25

    ja      not_ascii
ascii:
    // Flip capitilization if necessary.
    xor     cl, dl

not_ascii:
    // Restore saved character that we read.
    // xchg is 1 byte, as opposed to mov, which is 2.
    xchg    ecx, eax

    // Write out the character to the output buffer.
    stosb

endloop:
    // If al == 0, break
    test    al, al
    jnz     loop

end:
    // Just return, we've already written out the null
    // character to the output string.
    ret

Testing code in C, takes the input string via the first command line argument, prints out the result string:
#include <stdio.h> //puts
#include <stdlib.h> //malloc, free
#include <string.h> //strlen

void caps(char* output, char* input);

int main(int argc, char** argv) {
    char* instr = argv[1];
    char* buf = malloc(strlen(instr) + 1);
    caps(buf, instr);

    // Print converted string.
    puts(buf);

    free(buf);
}

Forth, 225 bytes
: d DUP ; : x SWAP ; : w WITHIN ; : a d d 65 = x 97 = OR ; : y d d 65 91 w x 97 123 w OR ; : ~ INVERT ; x VALUE s 0 VALUE f : l 0 DO I s + C@ a IF f ~ TO f THEN y IF f IF 32 XOR d THEN a ~ IF EMIT THEN ELSE EMIT THEN LOOP ; l

What happening:
: d DUP ;                     \ shortcut for duplicating value on stack
: a d d 'A' = SWAP 'a' = OR ;             \ testing, if char is 'a' or 'A'
: y d d 'A' '[' WITHIN SWAP 'a' '{' WITHIN OR ;   \ testing, if char is within letters
: ~ INVERT ;                      \ shortcut for negation
SWAP                          \ swap addr and len of the string after s" command
VALUE s                       \ pop addr to s
0 VALUE f                     \ write 0 to f(lag)
: l 0 DO                      \ declaration of loop named 'l' from 0 to len (len is laying on top of the stack, remember)
I s + C@                      \ push iteration number on stack and load char from s + iteration

        \ this IF is searching for 'a' or 'A'
a IF
    f ~ TO f              \ if we found 'a' or 'A', then flip the f(lag)
    THEN
y IF                      \ if char is letter
    f IF                  \ and f is set
    32 XOR d THEN             \ change case of symbol

    a ~ IF                \ if it's not 'a' or 'A' then print char
        EMIT
        THEN
ELSE
    EMIT                  \ print char
THEN
LOOP ;

l

Try it online!
Actually code in tio is 285 bytes, but this is because Footer didn't work for defining string, so i had to include string definition in actual code.

SM83, 29 28 bytes; Z80, 30 29 bytes

SM83 version

06 00 2A 4F CB AF D6 41
28 0C FE 1A 79 30 01 A8
12 13 B7 20 ED C9 78 EE
20 47 18 E6

Z80 version (changes in stars)

06 00 *7D 23* 4F CB AF D6 41
28 *0E* FE 1A 79 30 *03* A8
12 13 B7 20 *EE* C9 78 EE
20 47 18 *E7*

Disassembly and explanation
fun:
    ld b,0      ; 06 00     we start out in non-swapping state
loop:
#ifdef SM83
    ld a,(hl+)  ; 2A        load character
#else
    ld a,(hl)   ; 7D
    inc hl      ; 23        Z80 doesn't have autoinc addressing
#endif
    ld c,a      ; 4F        save copy in c
    res 5,a     ; CB AF     Clear bit 5
    sub 65      ; D6 41     subtract 'A'
    jr z,is_a   ; 28 0C/0E  if 0, was 'A' or 'a'; handle that later
    cp 26       ; FE 1A     compare to 26
    ld a,c      ; 79        reload from copy
    jr nc,put   ; 30 01/03  skip next if was letter (<26)
    xor b       ; A8        xor in caps lock setting
put:
    ld (de),a   ; 12        store
    inc de      ; 13        and increment
    or a        ; B7        check if zero by self-or (cheap trick)
    jr nz,loop  ; 20 ED/EE  loop if wasn't 0
    ret         ; C9        and return otherwise
is_a:
    ld a,b      ; 78
    xor 32      ; EE 20
    ld b,a      ; 47        flip caps lock setting
    jr loop     ; 18 E6/E7  jump back to loop

Heavily based on corvus_192's answer.
The differences:

I counted bytes of machine code, not assembly
I changed jp (absolute jump, three bytes) to jr (relative jump, two bytes), saving five bytes
I moved the case-fold (res 5,a) to before the test for A, saving a compare-to-constant and a jump (four more bytes saved)
This produced the sequence cp 65; jr z,is_a; sub 65, which can be collapsed to sub 65; jr z,is_a, saving two more bytes.
It's cheaper to test if a is 0 by executing or a (and a also works) than cp 0; it doesn't tell you sign, but we didn't need that.

In total, these changes (well, not the counting difference) save twelve bytes from the original.

Swift, 110 bytes
import Darwin
var x=0,f={for c in($0+"").utf8{c&95==65 ?(x^=1,0).1:putchar(CInt(x>0&&66...90~=c&95 ?c^32:c))}}

f(_:) is the closure you want.
If you're on Linux instead of macOS, you can replace import Darwin with import Glibc to save a byte (and you have to do it anyway if you want it to compile). For platform independence, import Foundation can be used instead.
This is an almost direct port of @KevinCruijssen's Java answer to Swift, with:

some things shuffled around,
a call to ~=(lhs:rhs:) (the pattern matching operator) to condense the range check,
a tuple shenanigan to let us use the ternary conditional operator instead of if-else, and
a bit of C interop abuse because Swift names are long.

Notes

CInt is a typealias for Int32, the type expected by putchar(_:) (for reasons beyond my mortal comprehension; C is weird).

For reasons slightly closer to a realm I can grasp (i.e. exit codes), putchar(_:) also returns an Int32, meaning we can't directly put a call to it in a ternary conditional that expects Void (an alias for ()), which is the result type of x^=1 (because, in Swift, assignment operators rightfully don't return anything).
So, instead, I shoved x^=1 into a tuple and added 0 as the second element, and then accessed it with .1. This still evaluates x^=1, but returns an Int32 (the type the 0 literal is inferred as) rather than a Void, which calms down the type checker a bit.

The ~=(lhs:rhs:) operator is used internally for custom pattern matching (i.e. switch statements, if case, and the like). There's an overload defined on ClosedRange that checks if rhs is contained in lhs. We abuse that here.

Because Swift really doesn't want you to do things like this with an ordinary String, we have to access the utf8 property of the input to get a [UInt8] that we can iterate over.

We need to concatenate "" with $0 (the implicit closure parameter, aka the input) to help the type checker figure out that $0 is a String.

Python 3, 114, 101, 97 bytes
import re
print(''.join(i.swapcase()if j%2else i for j,i in enumerate(re.split('a|A',input()))))

Split on all a's and toggle the case on the odd parts
Thanks @ElPedro !

Can reduce to 96 by not assigning input() to the variable s. Try it online!

Good one @ElPedro I will edit!

CJam, 31 bytes
q{_eu'A={;T!:T;}{_el_eu+|T=}?}%

Explanation
Loops through searching for a and non-a
Try it online!

CJam, 47 bytes
Slightly more fun version
[q'a'Aer'A/_2%\2/z)\;{_[el_eu]z{\(@|1=\}%e_}%]z

Try it online!
Explanation
This code has two parts.
[
               Part 1
 q                          -> Read all input as a single string
 'a'Aer                     -> Replace 'a' in string with 'A'
 'A/                        -> Split by 'A' leaving empty sets
 _                          -> Duplicate
 2%                         -> Get all rows where i%2 is 0
 \                          -> Swap top two elements of stack
 2/                         -> Split into array with groups of length 2
 z                          -> Zip/Transpose
 )\;                        -> Right uncons, swap and pop.

               Part 2
 {
  _[el_eu]                  -> Create an array containing the lower case and upper case version
  z                         -> Zip/Transpose
  {
   \                        -> Swap top two
   (                        -> Uncons left
   @                        -> Rotate top three elements of stack
   |                        -> Set union
   1=                       -> Get element at array indice 1 (Wraps)
   \                        -> Swap top two
  }%                        -> Map onto every element of string
  e_                        -> Flatten
 }%                         -> Map onto every element of array
]z                          -> Zip/Transpose

The first part splits the string by 'A' leaving any empty sets behind. For the string "baacadE" that will give the following array.
["b", "", "c", "dE"]

That way, all normal case elements are at even indices and reverse case are odd. Which After executing the rest of the first part gives the following.
[["b", "c"], ["", "dE"]]

The second part will take the odd half and reverse the case of every string. This is done with the set union operator |. So for the element "dE" It will do the following. Since the set union operator preserves the order of the elements found in the first string/array we can always assume the reverse case element will be the second one in the string/array.
["dE", "dD"]
["dD", "dE"]
["dD", "E", "d"]
["E", "d", "dD"]
["E", "dD"]
["E", "D"]
...
["D", "E", "eE"]
["D", "Ee"]
["D", "e"]

All That is left to do is zip up the two halves.

Chip, 64 bytes
,Ava
>B#
>C#.,Bb
>D##>Cc
>E##>Dd
`~+L^Ee
G~+)~vS
g,\-zm.
f{-F`~'

Try it online!
How it works
This is where I wish I could color-code the source. However, all of the below are full programs, and may be run on their own.
First things first, write a (slightly mangled) cat program.
 A-a

     Bb
     Cc
     Dd
     Ee
G
g
f--F

Now invert capitalization of all characters A-Za-z.
This is determined by:

c & 0x1F != 0

Filter out anything whose low 5 bits are zero
This is done by the left most column and upper ~

((c & 0x1F) + 0x5) & ~0x1F == 0

Filter out anything, that when added to 5, carries into or beyond the 6th bit
This is done by the two # columns

c & 0x40 != 0

Filter out anything that is less than 64
This is done by the lower ~

The program assumes it will receive no characters above 127.
The results are aggregated and, the inversion is done by the { at the bottom.
,Ava
>B#
>C#. Bb
>D## Cc
>E## Dd
`~+' Ee
G~<
g,\*
f{-F

But attach that to a toggle (T flip-flop) that is initially off. Now, the toggle decides whether to invert the capitalization, and the filter from above decides which characters to apply it to. Put a * above the m to toggle on every cycle.
,Ava
>B#
>C#. Bb
>D## Cc
>E## Dd
`~+' Ee
G~<
g,\-zm.
f{-F`~'

Toggle the toggle when we see an Aa, and suppress that character too. We have an Aa if the filter above says we have A-Za-z, and the low five bits equal one (c & 0x1F == 1).
,Ava
>B#
>C#.,Bb
>D##>Cc
>E##>Dd
`~+L^Ee
G~+)~vS
g,\-zm.
f{-F`~'

Python 3, 100 bytes
def f(x):x=x.replace('A','a').split('a');return''.join(i.swapcase()if i in x[1::2]else i for i in x)

Try it online!

C (gcc), 66 bytes
u;f(char*s){for(u=0;*s;s++)u^=6305%*s?!putchar(*s&64?*s^u:*s):32;}

Similar to another solution but doesn't use ctype functions.
-1 byte thanks to [ceilingcat]!
Try it online!

65 bytes

Clojure, 256 bytes
Golfed
(require[clojure.string :refer :all])(def u upper-case)(defn f[x](if(=(u x)x)(lower-case x)(u x)))(defn i[a](="A"(u a)))(defn g[x](let[v(vec(map str x))](join""(filter(complement i)(reduce-kv(fn[c k e](if(i e)(concat(take k c)(map f(drop k c)))c))v v)))))
Ungolfed
(ns acapslock.core
  (:require [clojure.string :as str]))

(defn flip
  [x]
  (if (= (str/upper-case x) x) (str/lower-case x) (str/upper-case x)))

(defn isa
  [a]
  (or (= "a" a) (= "A" a)))

(defn foo
  [x]
  (str/join "" (filter (complement isa) (reduce-kv (fn [coll idx elem] (if (isa elem)(concat (take idx coll) (map flip (drop idx coll))) coll)) (vec (map str x)) (vec (map str x))))))

Explanation
The solution works in two steps:

First, we go through the input character by character. If we find an a or an A, we flip the case of the rest of the string.
Then we filter out all a's and A's.

Tests
(ns acapslock.core-test
  (:require [clojure.test :refer :all]
            [acapslock.core :refer :all]))

(deftest a-test
  (testing "test cases"
    (is (= "" (foo "")))
    (is (= "The quick brown fox jumps over the lZY DOG." (foo "The quick brown fox jumps over the lazy dog.")))
    (is (= "CompilTION FINISHED SUCCESSFULLY." (foo "Compilation finished successfully.")))
    (is (= "WhT Hppens when the CPSlOCK KEY ON YOUR KEYBOrd doesn't hVE  notch in it?" (foo "What happens when the CapsLock key on your keyboard doesn't have a notch in it?")))
    (is (= "The end of the institution, mINTENnce, ND dministrTION OF GOVERNMENT, IS TO SECURE THE EXISTENCE OF THE BODY POLITIC, TO PROTECT IT, nd to furnish the individuLS WHO COMPOSE IT WITH THE POWER OF ENJOYING IN Sfety ND TRnquillity their nTURl rights, ND THE BLESSINGS OF LIFE: nd whenever these greT OBJECTS re not obtINED, THE PEOPLE Hve  RIGHT TO lter the government, ND TO Tke meSURES NECESSry for their sFETY, PROSPERITY nd hPPINESS." (foo "The end of the institution, maintenance, and administration of government, is to secure the existence of the body politic, to protect it, and to furnish the individuals who compose it with the power of enjoying in safety and tranquillity their natural rights, and the blessings of life: and whenever these great objects are not obtained, the people have a right to alter the government, and to take measures necessary for their safety, prosperity and happiness.")))
    (is (= "" (foo "aAaaaaAaaaAAaAa")))
    (is (= "CPSlOCK LOCKS CPSlOCK" (foo "CapsLock locks cAPSlOCK")))
    (is (= "wHt if CPSlOCK IS lreDY ON?" (foo "wHAT IF cAPSlOCK IS ALREADY ON?")))

    ))

05AB1E (legacy), 11 bytes
„AaS¡εNFš]J

Try it online!

Julia, 107 bytes
let b=false;[c in"aA" ? b=!b : print(b&&isletter(c) ? c<'@' ? c+32 : c-32 : c) for c::Char=read(stdin)];end

Try it online!
The let block is unfortunate, but apperently julia's scope is broken and b is undefined otherwise.
Here's the same program but with loops instead of comprehension, and if instead of conditionals.
 let b=false # whether to invert charachters
# normally this would be "for c in read(stdin,String)",
# but reading a byte array and converting the bytes to chars saves one (byte).
for c::Char in read(stdin)
if c in "aA"
   b = !b
else
   print(if b && isletter(c)
            if c<'@' # capitalization check
               c+32  # ascii code shenanigans to change case
            else
               c-32
            end
         else
            c # c is not a letter or we aren't swapping
         end)
end
end
end

Welcome to the site, and nice first answer! I've edited it slightly to include a link to both the language and TryItOnline, the online interpreter most answers use. I don't know Julia, but is is possible to remove some of the whitespace to golf a little? Also, for more specific tips, be sure to check out our Tips for golfing in Julia page

@cairdcoinheringaahing whitespace is mandatory around ? and : in the conditional operator. I removed whitespace where I could.

Julia 1.0, 73 71 bytes
f(s,b=0)=[c∈"aA" ? b=32-b : print(c+isletter(c)sign('_'-c)b) for c=s]

Try it online!
Stolen and improved from Simeon Schaub's great answer
-2 bytes thanks to Czylabson Asa

a slight improvement: 71 bytes

Pyth, 21 bytes
ssm+Pdr2edcscR\AcQ\a2

Try it here
Explanation
ssm+Pdr2edcscR\AcQ\a2
           scR\AcQ\a   Split the input on 'a' and 'A'
          c         2  Split the blocks into pairs.
  m  d   d             For each pair...
   +P r2e              ... cAPSlOCK the second block.
ss                     Join the blocks together.

Pyth, 19 bytes
s.e?%k2rb2b:Q"a|A"3

Try it here.
Saved one byte thanks to mnemonic.

Charcoal, 21 bytes
ＦＳ¿⁼a↧ι≦¬κ¿κι¿№αι↧ι↥ι

Try it online! Link is to verbose version of code. Explanation:
ＦＳ

Loop through each character in the line of input.
¿⁼a↧ι

Test whether it equals a in lower case.
≦¬κ

If so then logically negate k. (Note that for some reason Charcoal considers k's default value None to be truthy.)
¿κ

Otherwise check whether k is currently truthy.
ι

If so then just print the character.
¿№αι

Otherwise check whether the current character is an upper case letter.
↧ι

If it is then print it in lower case.
↥ι

Otherwise print it in upper case.

Python 2, 103, 97 bytes
import re
def f(s):print"".join(j.swapcase()if i%2else j for i,j in enumerate(re.split('a|A',s)))

APL (Dyalog Classic), 46 41 40 bytes
'aA'~⍨⊢819⌶⍨¨2|(⊢≠819⌶¨)+≠\∘(∨⌿'aA'∘.=⊢)

Try it online!
How??

'aA'~⍨ - Remove all a's from ...
⊢819⌶⍨¨2|(⊢≠819⌶¨) - ... the alternating upper-and-lower-case of the argument ...
+≠\∘ ... based upon ...
(∨⌿'aA'∘.=⊢) ... the position of a and/or A.

Yabasic, 121 bytes
An anonymous function that takes input as a line of text from STDIN and outputs to STDOUT.
Line Input""s$
For i=1To Len(s$)
c$=Mid$(s$,i,1)
u$=Upper$(c$)
If u$="A"Then
d=!d
ElsIf d Then?u$;Else?Lower$(c$);Fi
Next

Try it online!

Excel VBA, 115 bytes
A declared subroutine that takes input, s of expected type variant/string and outputs to the range [A1].
Sub f(s)
For i=1To Len(s)
c=Mid(s,i,1)
u=UCase(c)
If u="A"Then d=Not d Else[A1]=[A1]+IIf(d,u,LCase(c))
Next
End Sub

pwsh, 109 bytes
$Input|%{$i=$_[0]-ceq'a';$r='';foreach($s in $_.split('a')){$r+=($s.ToUpper(),$s.ToLower())[$i];$i=!$i};$r}

Haskell, 199 133 bytes
import Data.Char
l c|isUpper c=toLower c|1<2=toUpper c
f _""=""
f b(c:cs)|toLower c=='a'=f(not b)cs|1<2=(if b then l else id)c:f b cs

Run using f False "<string>"
Ungolfed version:
import Data.Char

flipCase c
    | isUpper c = toLower c
    | otherwise = toUpper c

f "" _ = ""
f b (c:cs)
    | toLower c == 'a' = f cs $ not b
    | True = (if b then flipCase else id) c:f b cs

You can replace cs by a single letter variable name and define f as an infix function.

Also note that when requiring extra arguments for the function, those need to be counted too. In this case the default would be to add 8 bytes to the byte count for f False and a newline.

Instead of using a boolean it is shorter to use 0 and 1. not b then becomes 1-b, b in the conditional becomes b>0 and f False just f 0.

Haskell, 96 94 Bytes
(Unix Line Endings)
import Data.Char
t=toUpper
i c|c>'Z'=t c|0<1=toLower c
f(x:s)|t x=='A'=f$i<$>s|0<1=x:f s
f x=x

@Laikoni Unfortunate. I've fixed that now at the cost of 16 more bytes, but realised I was counting Windows line endings as 2 bytes, so I've clawed back 3 bytes by switching to Unix line endings.

Pip, 22 bytes
(The SC operator was added because of this challenge.)
{LCaQ'a?xX!:ii?SCaa}Mq

Try it online!
Explanation
                        i is 0, x is empty string (implicit)
                     q  Read a line of input
{                  }M   Map this function to its characters:
 LCa                     The character, lowercased
    Q'a                  Is it equal to lowercase a?
       ?                 If so:
          !:i             Logically negate i in place (0 -> 1, 1 -> 0)
        xX                Repeat the empty string that many times (thus, always return
                          empty string when the character is a/A)
                         Else:
             i?           Is i truthy (1)? If so, caps lock is on, so return:
               SCa         The character, swap-cased
                          Else return:
                  a        The character, unchanged

K4, 49 bytes
Solution:
{@[x;&.q.mod[;2]@&-':w;.q.upper]_/|w:&"a"=_x,"a"}

Examples:
q)k){@[x;&.q.mod[;2]@&-':w;.q.upper]_/|w:&"a"=_x,"a"}"The quick brown fox jumps over the lazy dog."
"The quick brown fox jumps over the lZY DOG."
q)k){@[x;&.q.mod[;2]@&-':w;.q.upper]_/|w:&"a"=_x,"a"}"Compilation finished successfully."
"CompilTION FINISHED SUCCESSFULLY."
q)k){@[x;&.q.mod[;2]@&-':w;.q.upper]_/|w:&"a"=_x,"a"}"What happens when the CapsLock key on your keyboard doesn't have a notch in it?"
"WhT Hppens when the CPSLOCK KEY ON YOUR KEYBOrd doesn't hVE  notch in it?"
q)k){@[x;&.q.mod[;2]@&-':w;.q.upper]_/|w:&"a"=_x,"a"}"aAaaaaAaaaAAaAa"
""

Explanation:
Fairly heavy, will look at other answers to see if I can golf this down:
{@[x;&.q.mod[;2]@&-':w;.q.upper]_/|w:&"a"=_x,"a"} / the solution
{                                               } / lambda with implicit input x
                                           x,"a"  / append "a" to input
                                          _       / lowercase
                                      "a"=        / boolean list where input is "a"
                                     &            / indices where true
                                   w:             / save as w
                                  |               / reverse
                                _/                / drop over (remove these indices from...)
 @[ ;                 ;        ]                  / apply [var;indices;function]
                       .q.upper                   / uppercase
                  -':w                            / deltas of w
                 &                                / where, builds list of ascending values
                @                                 / apply
      .q.mod[;2]                                  / mod 2 to generate boolean list
   x                                              / apply uppercase to input x at these locations

Notes:
Think I may have missed the point. I enabled/disable caps when an a is encountered. Passes the first test cases but not the ones where caps is apparently already enabled...

Lua, 152 151 bytes
p=io.read()a=0s=""for c in p:gmatch"."do l=c:lower()if c:find"[aA]"then a=(a+1)%2 else s=s..((c:find"%A"or a==0)and c or l==c and c:upper()or l)end end

Try it online!

Explanation
p = io.read() -- reads the input
a = 0
s = ""
for c in p:gmatch"." do -- loops through the string 'p' (the input) calling each character 'c'
  l = c:lower() -- stores the lowercase version of 'c'
  if c:find("[aA]") then -- if 'c' is a lowercase or uppercase 'A'
    a = (a+1)%2 -- flip the value of 'a' between 0 and 1, from what I've seen it uses less space
  else
    s = s..((c:find("%A") or a==0) and c or l==c and c:upper() or l)
    s = s..   -- append to the string 's'
            (c:find("%A") or a==0)   -- if this is not a letter or the "reversion" is off
                                   and c or   -- then append 'c' else
                                            l==c and c:upper() or l   -- if 'c' is lowercase then append it as uppercase else append it as lowercase
  end
end

If you have any questions, feel free to ask and i'll try to answer.

Lua 5.3, 137 bytes
a=0s=""io.read():gsub(".",function(c)if c:find"[aA]"then a=not a else l=c:lower()s=s..(a and c or l==c and c:upper()or l)end end)print(s)

Try it online!

Notes:
My result was very similar to @Visckmart above. But I included the print(s) in my byte count. Also the try it online test uses Lua 5.1, where my final result is in Lua 5.3. To make my final answer run on the website linked above I had to add a single space in between defining a and s: a=0 s="" which make it 138 bytes when using Lua 5.1

Python 3, 110 bytes
code_golf=lambda s:"".join([j.swapcase()if i&1else j for i,j in  enumerate(__import__('re').split(r"a|A",s))])

You should use codeblock formatting so that the underscores in __import__ don't get interpreted as bolding. As for actual golfing, you can remove the code_golf= part, as anonymous functions are acceptable. You can also use an online interpreter like TIO so that people can test your code and it can auto-format your CGCC submission. Try It Online

Some other golfing tips, the [] in the join is not needed and it is shorter to import the module outside of the lambda. Additionally, could you please add the score of your submission to the header?

Welcome! It is recommended to add an explanation for your code, because code-only answers are usually automatically flagged as low-quality.

... and there are two spaces between for i,j in and enumerate(

Gameboy Z80 Assembly, 186 bytes
f:
 ld b,0
l:
 ld a,[hli]
 ld c,a
 cp 65
 jp z,a
 cp 97
 jp z,a
 res 5,a
 sub 65
 cp 25
 ld a,c
 jp nc,o
 xor b
o:
 ld [de],a
 inc de
 cp 0
 jp nz,l
 ret
a:
 ld a,b
 xor 32
 ld b,a
 jp l

This answer was heavily influenced by Ian Chew's x86 assembly answer.
Commented version
; input in hl
; output in de
; b is used for the caps lock state, 00000000 = no capslock, 00100000 = capslock
; a and c are used for the character
f:
 ld b,0
loop:
; load a character from the input and advance the source pointer
 ld a,[hli]
;save character in c
 ld c,a
; check if character is 'a' or 'A'
 cp 65
 jp z,is_a
 cp 97
 jp z,is_a
; check if character is a letter by setting the 5th bit to zero and checking for the range 25..65
 res 5,a
 sub 65
 cp 25
; load the character back from c
 ld a,c
; if it is not a letter, simply output it
 jp nc,output
; if it is a letter, apply the current case swap
 xor b
; output the character and advance the destination pointer
output:
 ld [de],a
 inc de
; end of input?
 cp 0
 jp nz,loop
; return
 ret

is_a:
; change the case swap mask by xoring with 32
 ld a,b
 xor 32
 ld b,a
; continue the loop
 jp loop

It's only 35 bytes. I assume you got "186" from the byte count of the disassembled version, but the right bytecount is the object code, not the LR35902 assembly.

So your shortening of labels is a bad idea.

Correction: 35 bytes if you change JP to JR. JP costs three bytes, JR two.

You can also save a few bytes by changing the code from cp 65 to sub 65 to res 5,a; sub 65; jr z,is_a. That drops it to 29 bytes.

After that, you end up with the following machine code: 06 00 2A 4F CB AF D6 41 28 0D FE 19 79 30 01 A8 12 13 FE 00 20 EC C9 78 EE 20 47 18 E5.

MMIX, 60 bytes (15 instrs)
E3020000 83030000 E7000001
CBFF0320 25FFFF41 5AFF0003
C7020220 F1FFFFFA 33FFFF1A
48FF0002 C6030302 A3030100
E7010001 5B03FFF4 F8000000

Disassembly and explanation:
fun SETL  $2,0              // E3020000: mask = 0
0H  LDBU  $3,$0,0           // 83030000: loop: chr = *src (src, dst are both char *)
    INCL  $0,1              // E7000001: src++
    ANDN  $255,$3,32        // CBFF0320: tmp = chr & ~32
    SUB   $255,$255,'A'     // 25FFFF41: tmp -= 'A'
    PBNZ  $255,1F           // 5AFF0003: iflikely(!tmp) goto nota
    XOR   $2,$2,32          // C7020220: mask ^= 32
    JMP   0B                // F1FFFFFA: goto loop
1H  CMPU  $255,$255,26      // 33FFFF1A: nota: tmp = tmp <=> 26
    BNN   $255,1F           // 48FF0002: if(tmp > 0) goto notlet
    XOR   $3,$3,$2          // C6030302: chr ^= mask
1H  STBU  $3,$1,0           // A3030100: notlet: *dst = chr
    INCL  $1,1              // E7010001: dst++
    PBNZ  $3,0B             // 5B03FFF4: iflikely(chr) goto loop
    POP   0,0               // F8000000: return

This was heavily inspired by corvus_192's answer.
It's essentially the same algorithm, except with multiple simplifications due to MMIX's symmetric register architecture.

Zsh, 97 107 bytes
for c (${(s..)1})case $c {a|A)((j^=1));;[b-z])((j))&&c=$c:u;|[B-Z])((j))&&c=$c:l;|*)s+=$c;}
<<<$s

-10 thanks to @GammaFunction.
Try it Online!
  107bytes

Fails for strings containing %. Also, here's a few straightforward golfs (shortloops case, ((j)) is 0 by default, ((j^=1))): Try it online!

Here's a version which works with %.

Uiua, 18 17 bytes
/◇⊂⍜▽¯◿2⊛.⊜□≠@A⌵.

Try it
/◇⊂⍜▽¯◿2⊛.⊜□≠@A⌵.
               ⌵.  # Push an uppercase copy
            ≠@A    # Mask of those not equal to A
          ⊜□       # Partition, boxing each string
        ⊛.         # Copy, push the range 0 to its length
      ◿2           # Modulo 2 (alternating 0s and 1s)
   ⍜▽¯             # At positions with 1s, swapcase
/◇⊂                # Reduce by joining each unboxed string

Created with the help of Luminespire.
I don't like formatting Uiua explanations like this since it's hard to explain everything on one line (especially because I like to do pretty in-depth explanations). Particularly for Uiua it can feel awkward reading the code down and to the left while reading the explanation all the way to the right. But, there's a clear tradeoff, doing explanations this way takes much less time, and I don't have that much time right now so this'll do.

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


text:
Print the largest String with the shortest Code
As the title says, your task is to print the largest string using the shortest code without taking any input value.
Rules

The program must take no input and print the largest string to STDOUT
The string must contain only ASCII Characters. If you don't know the ASCII Characters, take a look at the table
No Loops are allowed
No multiplication, exponentiation or any kind of elevation is permitted.
The score is measured by subtracting the amount of bytes of your code to the amount of bytes of your string. Example. My code is 60 Bytes and it generates an string of 300 Bytes. My score will be 300-60=240
The highest score wins.

Example

try{a.b}catch(e){alert(e)}

The output of my program is ReferenceError: a is not defined = 32 bytes
My Score will be 32-26 = 6

Update
By Loops i mean any repetitive structure. For example for, while, do while, recursive functions etc..

Generating a 65535x65535 image and printing its content base64 encoded? Sounds allowed, but horribly boring.

while True:print(1) prints indefinitely so has score infinity. ez

Possible duplicate, though that one is closed for Too Broad.

@HyperNeutrino No Loops are allowed

Right, sorry, missed that. How do you define "loop" though?

is string replacing allowed? is recursion allowed? is decompressing allowed? are  eval  type things allowed?

By Loops i mean any repetitive structure. For example for, while, do while, recursive functions etc.. Let me add that into the question

That's still not an objectively observable requirement.

Might I suggest posting in the Sandbox to get feedback before posting challenges? This type of challenge is tough to specify, but it's possible it can be saved with some additional effort and requirements.

@Giuseppe I guess that's what i'm gonna do.

Because it's subtraction and not ratio of lengths, how do you prevent people from just repeating a function that gives positive score like 1000000 times?

The shell utility yes by definition has ∞ output, though is not explicitly a loop in the shell language.  Allowed?

println(arc+arc+...+arc);
The full code cannot fit here. the ... means the + arc goes forever.

If program P scores S, then you can construct a program that scores 2*S by repeating the source of P twice.

you can print some character arbitrary many times without loops like so

Related: Maximizing output from minimal input, related: Shortest code for longest output, related: Largest number in ten bytes of code.

If you're requiring unobservable behavior, you're doing somthing wrong 99% of the time, mostly "assume language features".

Oh I wish this was open!! WinDBG: d0 L?FFFFFFFF would get an absurdly high score! It'll dump the whole address space, as bytes and ASCII value, plus there's spaces, new lines, ticks, and hyphens for formatting, as well as the address offset every 0x10 bytes. If I did my math right, it'll score about 9.6845406e+19. The length of the program at this point is insignificant.

I like the python print(2**2**2**2**2**2**2). Users should take care to purchase sufficient system RAM

@Alpha3031 "No multiplication, exponentiation or any kind of elevation is permitted."

R, 541-9 = 532
When passing a built-in function name to R, the console describes it parameters.  I'm sure there are longer ones, but I went for the low-hanging fruit
Code:
.packages

Output:
function (all.available = FALSE, lib.loc = NULL)
{
if (is.null(lib.loc))
    lib.loc <- .libPaths()
if (all.available) {
    ans <- character()
    for (lib in lib.loc[file.exists(lib.loc)]) {
        a <- list.files(lib, all.files = FALSE, full.names = FALSE)
        pfile <- file.path(lib, a, "Meta", "package.rds")
        ans <- c(ans, a[file.exists(pfile)])
    }
    return(unique(ans))
}
s <- search()
invisible(.rmpkg(s[substr(s, 1L, 8L) == "package:"]))
}
<bytecode: 0x103fdf200>
<environment: namespace:base>

Edit:  Thanks Giuseppe for the link

@dzaima seems right

You can add a link to Try it online so we can verify your results! And welcome to R golfing, by the way :)

Python 3, 937
help()

Try it online!

Wouldn't help() or import this have better code/output ratio?

@manatwork oh yeah thanks

source: Stack Exchange

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

sort: votes


text:
Euler-Poincaré-Characteristic of Polyhedra
Given a triangulation of the surface of a polyhedron p, calculate its Euler-Poincaré-Characteristic χ(p) = V-E+F, where V is the number of vertices, E the number of edges and F the number of faces.
Details
The vertices are enumerated as 1,2,...,V. The triangulation is given as a list, where each entry is a list of the vertices of one face, given in clockwise or counterclockwise order.
Despite the name, the triangulation can also contain faces with more than 3 sides. The faces can assumed to be simply connected that means that the boundary of each faces can be drawn using one closed non-self-intersecting loop.
Examples
Tetrahedron: This tetrahedron is convex and has χ = 2. A possible triangulation is
[[1,2,3], [1,3,4], [1,2,4], [2,3,4]]

Cube: This cube is convex and has χ = 2. A possible triangulation is
[[1,2,3,4], [1,4,8,5], [1,2,6,5], [2,3,7,6], [4,3,7,8],  [5,6,7,8]]

Donut: This donut/toroid shape has χ = 0. A possible triangulation is
[[1,2,5,4], [2,5,6,3], [1,3,6,4], [1,2,7,9], [2,3,8,7], [1,9,8,3], [4,9,8,6], [4,5,7,9], [5,7,8,6]]

Double Donut: This double-donut should have χ = -2. It is constructed by using two copies of the donut above and identifying the sides [1,2,5,4] of the first one with the side [1,3,6,4] of the second one.
[[2,5,6,3], [1,3,6,4], [1,2,7,9], [2,3,8,7], [1,9,8,3], [4,9,8,6], [4,5,7,9], [5,7,8,6], [1,10,11,4], [10,11,5,2], [1,10,12,14], [10,2,13,12], [1,14,13,2], [4,14,13,5], [4,11,12,14], [11,12,13,5]]

(Examples verified using this Haskell program.)

Can different faces have different numbers of vertices?

Yes, they can have any number of vertices.

Haskell, 42 bytes
f m=maximum(id=<<m)-sum[0.5|_:_:l<-m,x<-l]

Try it online!
Combines the face and edge terms by subtracting 0.5 for every edge on a face beyond the first two.
Alt 42 bytes:
f m=maximum(id=<<m)-sum(0.5<$(drop 2=<<m))

Try it online!

This is very clever :)

Haskell, 49 46 bytes
u=length
f x|j<-x>>=id=maximum j+u x-u j`div`2

Try it online!
I get the number of vertices by concating the faces and finding the maximum.  I find the number of faces by taking the length.  I find the number of edges by summing the lengths of the faces and dividing by 2.

Jelly, 18 17 11 10 9 bytes
1 byte thanks to Erik the Outgolfer, and 1 more for telling me about Ɗ.
FṀ_FLHƊ+L

Try it online!
Uses the actually intelligent not-hacked-together solution everybody else is probably using. (Credit to @totallyhuman for the only other solution I could understand enough to reimplement it.)
Old solution (17 bytes)
ṙ€1FżFṢ€QL
;FQL_Ç

Try it online!
I hope I got everything right. Assumes that all faces contain at least 3 vertices and that no two faces have the same vertices; I'm not good enough in topology to come up with something that breaks the code.
Alternative 17 byte solution:
ṙ€1FżFṢ€,;F$QL$€I

Explanation
;FQL_Ç    Main link. Argument: faces
            e.g. [[1,2,3],[1,3,4],[1,2,4],[2,3,4]]
 F          Flatten the list. We now have a flat list of vertices.
            e.g. [1,2,3,1,3,4,1,2,4,2,3,4]
;           Append this to the original list.
            e.g. [[1,2,3],[1,3,4],[1,2,4],[2,3,4],1,2,3,1,3,4,1,2,4,2,3,4]
  Q         Remove duplicates. We now have a list of faces and vertices.
            e.g. [[1,2,3],[1,3,4],[1,2,4],[2,3,4],1,2,3,4]
   L        Get the length of this list. This is equal to V+F.
            e.g. 8
     Ç      Call the helper link on the faces to get E.
            e.g. 6
    _       Subtract the edges from the previous result to get V-E+F.
            e.g. 2

ṙ€1FżFṢ€QL    Helper link. Argument: faces
                e.g. [[1,2,3],[1,3,4],[1,2,4],[2,3,4]]
ṙ€1             Rotate each face 1 position to the left.
                e.g. [[2,3,1],[3,4,1],[2,4,1],[3,4,2]]
   F            Flatten this result.
                e.g. [2,3,1,3,4,1,2,4,1,3,4,2]
     F          Flatten the original faces.
                e.g. [1,2,3,1,3,4,1,2,4,2,3,4]
    ż           Pair the items of the two flattened lists.
                e.g. [[2,1],[3,2],[1,3],[3,1],[4,3],[1,4],[2,1],[4,2],[1,4],[3,2],[4,3],[2,4]]
      Ṣ€        Order each edge.
                e.g. [[1,2],[2,3],[1,3],[1,3],[3,4],[1,4],[1,2],[2,4],[1,4],[2,3],[3,4],[2,4]]
        Q       Remove duplicates. We now have a list of edges.
                e.g. [[1,2],[2,3],[1,3],[3,4],[1,4],[2,4]]
         L      Get the length of the list to get E.
                e.g. 6

Can't you replace ;/ with F? ;-)

@EriktheOutgolfer Lol, that was apparently left there as some kind of brainfart from a dev version

In fact, it made the code error in case of empty arrays.

Will there ever be empty arrays?

Oh, and 1) your TIO link has a different code and 2) there are new quicks!

APL (Dyalog Classic), 13 bytes
⌈/∘∊+≢-2÷⍨≢∘∊

Try it online!

Python 2, 47 bytes
-1 byte thanks to... user56656 (was Wheat Wizard originally).
lambda l:len(l)-len(sum(l,[]))/2+max(sum(l,[]))

Try it online!

I improved my original haskell answer by saving sum(l,[]) to be used twice.  I don't know if this could be used in Python as well.

@user56656 It indeed saves a byte, thanks!

Perl 5 -a, 29 bytes
This one is tailor made for the perl -a option which does almost all the work already
#!/usr/bin/perl -a
@V[@F]=$e+=@F}{say$#V+$.-$e/2

Try it online!

Wolfram Language (Mathematica), 24 bytes
-3 bytes thanks to @att.
Max@#-Tr[Tr/@(1^#)/2-1]&

Try it online!

24: Max@#-Tr[Tr/@(1^#)/2-1]&

Stax, 9 bytes
ÑF4╨Ω◙╜#├

Run and debug online
It's a straight-forward port of totallyhuman's python solution.
%   length of input (a)
x$Y flatten input and store in y
%h  half of flattened length (b)
-   subtract a - b (c)
y|M maximum value in y (d)
+   add c + d and output

Run this one

Pari/GP, 28 bytes
x->#x+#Set(y=concat(x))-#y/2

Try it online!

05AB1E, 10 9 bytes
ZsgI˜g;-+

Try it online!
Explanation
Z          # push number of vertices (V)
 sg        # push number of faces (F)
   I˜g;    # push number of edges (E)
       -   # subtract (F-E)
        +  # add (F-E+V)

Pyth, 12 bytes
+-eSsQ/lsQ2l

Try it here

Scala 3, 46 bytes
A port of @Wheat Wizard♦'s Haskell answer in Scala.

x=>{val j=x.flatten;j.max+x.length-j.length/2}

Attempt This Online!

K (ngn/k), 22 bytes
{(#x)+(|/y)--2!#y}/,/\

Try it online!

JavaScript (ES6), 60 bytes
a=>a.map(b=>(v=Math.max(v,...b),d+=b.length/2-1),d=v=0)&&v-d

Explanation: Loops over each face, keeping track of the largest vertex seen in v and tracking the number of edges minus the number of faces in d as per @xnor's answer.

Ruby, 35 bytes
->a{a.size+a.flatten!.max-a.size/2}

Try it online!

Proton, 35 bytes
l=>max(f=sum(l,[]))-len(f)/2+len(l)

Try it online!

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


text:
Shifting-Oriented Programming
A string can be shifted by a number n by getting the byte value c of each character in the string, calculating (c + n) mod 256, and converting the result back to a character.
As an example, shifting "ABC123" by 1 results in "BCD234", shifting by 10 in "KLM;<=", and shifting by 255 in "@AB012".
The Task
Pick as many numbers n with 0 < n < 256 as you dare and write a program or function that takes a string as input and

returns the string unchanged when the source code is unchanged, but
returns the string shifted by n when the source code is shifted by n.

Rules

The score of your submission is the number of supported n, with a higher score being better. The maximum score is thus 255.
Your submission must support at least one shift, so the minimal score is 1.
In case of a tie the shorter program wins.
All shifted programs need to be in the same language.

Related.

Related.

Is it acceptable to have output before the desired output that is cleared via ANSI escape sequences, or hidden via \r?

@DomHastings Since 0x0D and 0x1B are potentially part of the actual string output, I wouldn't think so.

Brainfuck, score: 31 (2208 bytes)
Base64-encoded program:
[encoded data, 5160 characters]
Works for shifts 0, 4, 8, 12, 32, 36, 40, 44, 64, 68, 72, 76, 96, 100, 104, 108, 128, 132, 136, 140, 160, 164, 168, 172, 192, 196, 200, 204, 224, 228, 232 and 236.
For every value between 0 and 255, there is exactly one of those shifts that sends that character to a valid brainfuck instruction.
The program relies on 8-bit cells with wrapping on overflows.
This could probably be golfed quite a bit, as the shift just consists of a repeated + or - (whichever is shorter).
Python code used to generate this:
l = [0, 4, 8, 12, 32, 36, 40, 44, 64, 68, 72, 76, 96, 100, 104, 108, 128, 132, 136, 140, 160, 164, 168, 172, 192, 196, 200, 204, 224, 228, 232, 236]
shift = lambda s,n:"".join(chr((ord(i)+n)%256) for i in s)
code = ""
for i in l:
    code += shift(",[{}.,]".format(i*"+" if i<=128 else (256-i)*"-"),-i)

Can you show some of the actual working code that was encoded and shift-proofed? (ie +[>,.<]?)

@StanStrum It's just shifted versions of ,[+.,], where + is the amount of +s or -s

lHaskell, Score 255 (27,026 bytes)
The program works but putting it in my clipboard seems to destroy it  so here is code that outputs my program.
Verification
So if copying things to a clipboard breaks it how do I verify that it works?
You can use this here.  You can adjust N and the string (currently Big ol' egg) to see that it works yourself.
This will test all N on a single input in succession but tends to time out.
Explanation
This abuses literate Haskell's comment notation.  In literate Haskell any line that does not start with > is a comment.  So to make our code work we make 255 copies of the program each shifting by n and then we shift each individual copy by -n.

C, score: 1 (73 bytes)
aZ0;/*0\:..*/f(s){puts(s);}//	e'bg`q)r(zenq':)r:**r(otsbg`q'')r*0($145(:|
Try it online!
Shifted by 1:
b[1<0+1];//+0g)t*|qvut)t*<~00
f(char*s){for(;*s;++s)putchar((*s+1)%256);}

Try it online!

05AB1E, Score: 3 (24 bytes)
¶Ä0(ä.g){n·Å0)åH*oHÆ0*æI

Try it online!
Explanation
¶Ä0(ä.g){n·Å0)åH*oHÆ0*æ  # Doesn't matter
                       I # Push the original input to the stack, implicit display

Shifted once:
·Å1)å/h*|o¸Æ1*æI+pIÇ1+çJ

Try it online!
Explanation
·Å1)å/h*|o¸Æ1*æI+p       # Doesn't matter
                  IÇ     # Push the ASCII values of the input
                    1+   # Increment by 1
                      çJ # Push the chars of the ASCII values, join, implicit display

Shifted twice:
¸Æ2*æ0i+}p¹Ç2+çJ,qJÈ2,èK

Try it online!
Explanation
Æ2*æ0i+}p         # Doesn't matter
         ¹Ç       # Push the ASCII values of the input
           2+     # Increment by 2
             çJ   # Push the chars of the ASCII values, join
               ,q # Print and terminate

Shifted thrice:
¹Ç3+ç1j,~qºÈ3,èK-rKÉ3-éL

Try it online!
Explanation
¹Ç        # Push the ASCII values of the input
  3+      # Increment by 3
    ç1j   # Push the chars of the ASCII values, join
       ,q # Print and terminate

Javascript, score: 1 4 (94 346 bytes)
Pretty straight-forward, has different sections commented out when rotated, the difficult bit was finding usable variable names and comment sections that don't break Javascript syntax.
Unrotated:
hc/*% *%nnS/0S eb^[fRR _SbS/0Efd[`Y Xda_5ZSd5aVWS UZSd5aVW3f"#&$'( \a[`RR!! %34hc/*$ifb_jVV$cWfW34Ijh_d]$\hec9^Wh9eZ[W$Y^Wh9eZ[7j&!'&(+,$`e_dVV%%%*89hc/)nkgdo[[)h\k#\89Nomdib)amjh>c\m>j_`###\)^c\m>j_`<o#+$&0$ -01$$$)ejdi[[***/=>/*ch*/hc//chhcchvw*/g¬©¥¢g¦©avw«¢§ g«¨¦|¡«|¨aaag¡«|¨zaibdjrrb^knobbbg£¨¢§

Rotated by 5:
mh4/*%$/*ssX45X%jgc`kWW%dXgX45Jki`e^%]ifd:_Xi:f[\X%Z_Xi:f[\8k' "(+ ),-   %af`eWW &&%*89mh4/)nkgdo[[)h\k#\89Nomdib)amjh>c\m>j_`###\)^c\m>j_`<o#+$&,+$ -01$$$)ejdi[[***/=>mh4.split``.map(a=>String.fromCharCode(((a.charCodeAt(0)+5)%256))).join``///4BC4/hm/4mh44hmmhhm{|/4l±®ª§²l«®f{|²°§¬¥l¤°«¦°¢£fffl¡¦°¢£²fngiowwgcpstgggl¨§¬

Rotated by 10:
rm94/*)4/xx$]9:]*olhep\\*i]l$]9:Opnejc*bnki?d]n?k`a$$$]*_d]n?k`a=p$,%'-0%!.12%%%*fkej\\%++*/=>rm94.split``.map(a=>String.fromCharCode(((a.charCodeAt(0)+10)%256))).join``///4BCrm93xuqnyee3rfu-fBCXywnsl3kwtrHmfwHtij---f3hmfwHtijFy-5.0:.*7:;...3otnsee4449GH94mr49rm99mrrmmr49q¶³¯¬·££q°¤³k¤·µ¬±ªq©µ²°«¤µ²§¨kkk¤q¦«¤µ²§¨·kslnt||lhuxylllq²¬±££

Rotated by 14: things finally got interesting here, got to abuse the Javascript type system.
vq=83.-83||(a=>a.split``.map(a=>String.fromCharCode(((a.charCodeAt(0)+14)%256))).join``)//.3ABvq=82wtpmxdd2qet,eABWxvmrk2jvsqGlevGshi,,,e2glevGshiEx,4-/54-)69:---2nsmrdd3338FGvq=7|yur}ii7vjy1jFG\}{rwp7o{xvLqj{Lxmn111j7lqj{LxmnJ}1924>2.;>?2227sxrwii888=KL=8qv8=vq==qvvqqv8=uº·³°»§§u´¨·o¨»¹°µ®u¹¶´¯¨¹¶«¬ooo¨uª¯¨¹¶«¬»owprxply|}pppu±¶°µ§§

Rotated by 199:
/*öñìçæñì55áö÷ç,)%"-ç&)áö÷-+"' ç+(&ü!+ü(áááç!+ü(ú-áéâäêíâÞëîïâââç#("'âèèçìúû/*öñë0-)&1ë*-åúû1/&+$ë#/,*%/,!"åååë %/,!"þ1åíæèîíæâïòóæææë',&+ìììñÿ/*öð52.+6""ð/#2ê#ÿ64+0)ð(41/*#41&'êêê#ð%*#41&'6êòëí÷ëçô÷øëëëð,1+0""ñññööñ*/ñö/*öö*//**/=>ñö.split``.map(a=>String.fromCharCode(((a.charCodeAt(0)+199)%256))).join``

To find the solutions, I built a small tool to show me different snippets when rotated by a variable amount, I then found certain patterns that I could use as useful building blocks.
The main gist of it is that a/**/=>a is still a valid function definition, which allows you to embed a reverse rotated function in the comment section. From there on, it can be repeated a few times, if done correctly.
Since most of the comment sections are nested, it might be possible to find another result, but making it work becomes increasingly difficult with each added answer due to collisions and control characters.

Replacing all usages of charCodeAt(0) with charCodeAt`` would shave 4 bytes off the whole solution, but it's too much work to do from scratch.

I tried the same approach with a different starting set-up, but it was also capped at 4 points, it seems likely that this approach doesn't yield a higher score.

Can you at least use charCodeAt() to save 2 bytes?

PHP with -d output_buffering=on -d short_open_tag=on, score: 255 (25,731 bytes)
<?die($argv[1]);?>
=@pc`dmfbo)*<ejf)qsfh`sfqmbdf`dbmmcbdl)#0/0#-gvodujpo)%n*|sfuvso!dis)pSe)%n\1^*.2*<~-%bshw\2^**<@?>Aqdaengcp*+=fkg*rtgiatgrncegaecnndcem*$101$.hwpevkqp*&o+}tgvwtp"ejt*qTf*&o]2_+/4+=.&ctix]3_++=A@?Brebfohdq+,>glh+suhjbuhsodfhbfdooedfn+%212%/ixqfwlrq+'p,~uhwxuq#fku+rUg+'p^3`,06,>?/'dujy^4`,,>BA
@Csfcgpier,-?hmi,tvikcvitpegicgeppfego,&323&0jyrgxmsr,(q-vixyvr$glv,sVh,(q_4a-18-??0(evkz_5a--?CBADtgdhqjfs-.@inj-uwjldwjuqfhjdhfqqgfhp-'434'1kzshynts-)r.?wjyzws%hmw-tWi-)r`5b.2:.@?1)fwl{`6b..@DCBEuheirkgt./Ajok.vxkmexkvrgikeigrrhgiq.(545(2l{tizout.*s/?xkz{xt&inx.uXj.*sa6c/3</A?2*gxm|a7c//AEDCFvifjslhu/0Bkpl/wylnfylwshjlfjhssihjr/)656)3m|uj{pvu/+t0?yl{|yu'joy/vYk/+tb7d04>0B?3+hyn}b8d00BFEDGwjgktmiv01Clqm0xzmogzmxtikmgkittjiks0*767*4n}vk|qwv0,u1?zm|}zv(kpz0wZl0,uc8e15@1C?4,izo~c9e11CGFEHxkhlunjw12Dmrn1y{nph{nyujlnhljuukjlt1+878+5o~wl}rxw1-v2?{n}~{w)lq{1x[m1-vd9f26B2D?5-j{pd:f22DHGFIylimvokx23Enso2z|oqi|ozvkmoimkvvlkmu2,989,6pxm~syx2.w3?|o~|x*mr|2y\n2.we:g37;:3E?6.k|q?e;g33EIHGJzmjnwply34Fotp3{}prj}p{wlnpjnlwwmlnv3-:9:-7q?yntzy3/x4?}p?}y+ns}3z]o3/xf;h48<<4F?7/l}r?f<h44FJIHK{nkoxqmz45Gpuq4|~qsk~q|xmoqkomxxnmow4.;:;.8r?zo?u{z40y5?~q??~z,ot~4{^p40yg<i59=>5G?80m~s?g=i55GKJIL|olpyrn{56Hqvr5}rtlr}ynprlpnyyonpx5/<;</9s?{p?v|{51z6?r??{-pu5|_q51zh=j6:>@6H?91nt?h>j66HLKJM}pmqzso|67Irws6~?sum?s~zoqsmqozzpoqy60=<=0:t?|q?w}|62{7??s???|.qv?6}`r62{i>k7;?A;?7I?:2o?u?i?k77IMLKN~qnr{tp}78Jsxt7?tvn?t{prtnrp{{qprz71>=>1;u?}r?x~}73|8??t???}/rw?7~as73|j?l8<@D8J?;3p?v?j@l88JNMLOros|uq~89Ktyu8??uwo?u?|qsuosq||rqs{82?>?2<v?~s?y~84}9??u???~0sx?8bt84}k@m9=AF9K?<4q?w?kAm99KONMP?spt}vr9:Luzv9??vxp?v?}rtvptr}}srt|93@?@3=w?t?z?95~:??v???1ty?9?cu95~lAn:>BH:L?=5r?x?lBn::LPO
...

Similar to the Haskell solution, copying and pasting this breaks, so I generated this using this Perl script.
Verification for shifted 1, 16, 32 and 255 times.
Explanation
Using PHP's <? delimiter made this fairly easy, but I had to avoid any strings that could end up as <? elsewhere in the code, this basically means 03, 14, 25, 36, 47, 58 and 69. Working around those was fairly easy using arithmetic. It might well be possible to reduce the byte count in the original program too.

Crane-Flak, Score 3 (252 bytes)
%&'()%&%X'Z&xx\()'()z%xz|%&'()%&'()%&'()9;=&'()9;=%XZ\&'z|%&'(9;=(9;=%&'XZ\(|xz|9;=%&'%&(%X'Z&\('()xxz%xz|9;=&'()9;=%XZ\&'z|9;=(9;=%&'XZ\(|9;=)))))))%&Y[]'()yy{}%&y{}%&'()%&'():<>'():<>%&Y[]'(){}y{}:<>%&Y[]'()yy{}::<><>:<>%&y{}:<>'():<>%&Y[]'(){}::<><>

Try it online!
(Doesn't quite work in Brain-Hack because only Crane-Flak mods by 256)
Shifted by 1
&'()*&'&Y(['yy])*()*{&y{}&'()*&'()*&'()*:<>'()*:<>&Y[]'({}&'():<>):<>&'(Y[])}y{}:<>&'(&')&Y(['])()*yy{&y{}:<>'()*:<>&Y[]'({}:<>):<>&'(Y[])}:<>*******&'Z\^()*zz|~&'z|~&'()*&'()*;=?()*;=?&'Z\^()*|~z|~;=?&'Z\^()*zz|~;;=?=?;=?&'z|~;=?()*;=?&'Z\^()*|~;;=?=?

Try it online!
Shifted by 2
'()*+'('Z)\(zz^*+)*+|'z|~'()*+'()*+'()*+;=?()*+;=?'Z\^()|~'()*;=?*;=?'()Z\^*~z|~;=?'()'(*'Z)\(^*)*+zz|'z|~;=?()*+;=?'Z\^()|~;=?*;=?'()Z\^*~;=?+++++++'([]_)*+{{}'({}'()*+'()*+<>@)*+<>@'([]_)*+}{}<>@'([]_)*+{{}<<>@>@<>@'({}<>@)*+<>@'([]_)*+}<<>@>@

Try it online!
Shifted by 3
()*+,()([*]){{_+,*+,}({}()*+,()*+,()*+,<>@)*+,<>@([]_)*}()*+<>@+<>@()*[]_+{}<>@()*()+([*])_+*+,{{}({}<>@)*+,<>@([]_)*}<>@+<>@()*[]_+<>@,,,,,,,()\^`*+,||~€()|~€()*+,()*+,=?A*+,=?A()\^`*+,~€|~€=?A()\^`*+,||~€==?A?A=?A()|~€=?A*+,=?A()\^`*+,~€==?A?A

Try it online!
Explanation
The main code at work here is
([]){{}({}n<>)<>([])}{}<>([]){{}({}<>)<>([])}<>

where n is an arbitrary number.  This moves everything to the offstack adding n to each item (modulo 256 is implicit upon output), and then moves them all back.
However for the first program (i.e. shifted by 0) we don't need to do any of this because shifting by zero is the cat program.  So we start with this code:
([]){{}({}()<>)<>([])}{}<>([]){{}({}<>)<>([])}<>

and shift it down by 1
'Z\(zz|'z|m;=(;='Z\(|z|;='Z\(zz|'z|;=(;='Z\(|;=

This is unbalanced so we have to fix it.  There are a number of ways we could do this by my choice method (for reasons that will become apparent) is the following:
'Z\(zz|'z|m;=(;='Z\(|z|;='Z\(zz|'z|;=(;='Z\(|;=)))))){}{}{}{}{}

Shifting this up by 2 we get
)\^*||~)|~o=?*=?)\^*~|~=?)\^*||~)|~=?*=?)\^*~=?++++++}}}}}

Since () is easier to deal with than {} we will use the }s to complete the program we desire.  That means that the ) can be balanced with pretty obvious means.  With some fiddling we can turn that into:
()\^*||~()|~()*=?*=?()\^*~|~=?()\^*||~()|~=?*=?()\^*~=?+++++++([]_)*+{{}({}()*+()*+<>@)*+<>@([]_)*+}{}<>@([]_)*+{{}<<>@>@<>@({}<>@)*+<>@([]_)*+}<<>@>@

Shifting that back down we get
&'Z\(zz|&'z|&'(;=(;=&'Z\(|z|;=&'Z\(zz|&'z|;=(;=&'Z\(|;=)))))))&Y[]'()yy{}&y{}&'()&'():<>'():<>&Y[]'(){}y{}:<>&Y[]'()yy{}::<><>:<>&y{}:<>'():<>&Y[]'(){}::<><>

The step up to 3 is so complex I don't really understand it any more.  I used the same technique and just fiddled around with it until I finally got all 4 of them to work at once.  The technique is pretty much the same there is just a lot more fiddling.

Python 3, Score 1, 76 bytes
Shift 0: no change
""!="";print(input());exit()#   oqhms'&&-inhm'bgq'nqc'i(*0(enq'i(hm'hmots'((((

Shift 1:
##">##<qsjou)joqvu)**<fyju)*$
print(''.join(chr(ord(j)+1)for(j)in(input())))

Started work on shift 2, but "" becomes $$ and you can't start a line with that.
When you save it to a file, make sure it doesn't end with a newline. (vim -b file.py + set noeol)

Jelly, score 1 2
8 15 bytes
Shift 0:
M««Ṃ¬ịị¶Ɓ|L(0Ḷṇ

Try it online!
Shift 2:
O‘‘Ọµḷḷ¹Ɗ~N*2Ṇṛ

Try 2 online!
Shift 3:
P’’Ṛ½ṃṃ²Ƒ¶O+3Ọṣ

Try 3 online!