[Question]
  [
[Sandbox](https://codegolf.meta.stackexchange.com/a/18337/78850)
*A spin-off of a [rip-off](https://codegolf.stackexchange.com/questions/193315/i-reverse-the-source-code-you-reverse-the-input/193317#193317) of a [rip-off](https://codegolf.stackexchange.com/questions/193021/i-reverse-the-source-code-you-negate-the-input) of a [rip-off](https://codegolf.stackexchange.com/q/192979/43319) of a [rip-off](https://codegolf.stackexchange.com/q/132558/43319). Go upvote those!*
Your task, if you accept it, is to write a program/function that outputs/returns its input/argument. The tricky part is that if I left shift your source code, the output must be left shifted too. Likewise, if I right shift your source code, the output must be right shifted too.
Source code will only be shifted once in each direction (in other words, only one shift will be applied, meaning that there are only three possible programs that need to be run). Consequently, the minimum source length should be 3.
## Examples
Let's say your source code is `ABC` and the input is `xyz`. If I run `ABC`, the output must be `xyz`. But if I run `BCA` instead, the output must be `yzx`. And if I run `CAB`, the output must be `zyx`.
Let's say your source code is `EFG` and the input is `Hello`. If I run `EFG`, the output must be `Hello`. If I run `GEF`, the output must be `oHell`. And if I run `FGE`, the output must be `elloH`.
Let's say your source code is `abcde` and the input is `2019`. If I run `abcde`, the output must be `2019`. But if I run `eabcd` instead, the output must be `9201`. And if I run `bcdea`, the output must be `0192`.
# Rules
* The program must print the entire output shifted in the specified direction
* Input can be taken in any convenient format.
* Output can be in any convenient format as well.
* Standard Loopholes are forbidden.
* Source length should be at least 3 characters long, as to allow for unique shifted programs.
## Scoring
This is code-golf so the answer with the fewest amount of bytes wins.
## Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
```
# Language Name, N bytes
```
where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance:
```
# Ruby, <s>104</s> <s>101</s> 96 bytes
```
If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header:
```
# Perl, 43 + 2 (-p flag) = 45 bytes
```
You can also make the language name a link which will then show up in the leaderboard snippet:
```
# [><>](http://esolangs.org/wiki/Fish), 121 bytes
```
```
var QUESTION_ID=196864;
var OVERRIDE_USER=78850;
var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(d){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+d+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(d,e){return"https://api.stackexchange.com/2.2/answers/"+e.join(";")+"/comments?page="+d+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(d){answers.push.apply(answers,d.items),answers_hash=[],answer_ids=[],d.items.forEach(function(e){e.comments=[];var f=+e.share_link.match(/\d+/);answer_ids.push(f),answers_hash[f]=e}),d.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(d){d.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),d.has_more?getComments():more_answers?getAnswers():process()}})}getAnswers();var SCORE_REG=function(){var d=String.raw`h\d`,e=String.raw`\-?\d+\.?\d*`,f=String.raw`[^\n<>]*`,g=String.raw`<s>${f}</s>|<strike>${f}</strike>|<del>${f}</del>`,h=String.raw`[^\n\d<>]*`,j=String.raw`<[^\n<>]+>`;return new RegExp(String.raw`<${d}>`+String.raw`\s*([^\n,]*[^\s,]),.*?`+String.raw`(${e})`+String.raw`(?=`+String.raw`${h}`+String.raw`(?:(?:${g}|${j})${h})*`+String.raw`</${d}>`+String.raw`)`)}(),OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(d){return d.owner.display_name}function process(){var d=[];answers.forEach(function(n){var o=n.body;n.comments.forEach(function(q){OVERRIDE_REG.test(q.body)&&(o="<h1>"+q.body.replace(OVERRIDE_REG,"")+"</h1>")});var p=o.match(SCORE_REG);p&&d.push({user:getAuthorName(n),size:+p[2],language:p[1],link:n.share_link})}),d.sort(function(n,o){var p=n.size,q=o.size;return p-q});var e={},f=1,g=null,h=1;d.forEach(function(n){n.size!=g&&(h=f),g=n.size,++f;var o=jQuery("#answer-template").html();o=o.replace("{{PLACE}}",h+".").replace("{{NAME}}",n.user).replace("{{LANGUAGE}}",n.language).replace("{{SIZE}}",n.size).replace("{{LINK}}",n.link),o=jQuery(o),jQuery("#answers").append(o);var p=n.language;p=jQuery("<i>"+n.language+"</i>").text().toLowerCase(),e[p]=e[p]||{lang:n.language,user:n.user,size:n.size,link:n.link,uniq:p}});var j=[];for(var k in e)e.hasOwnProperty(k)&&j.push(e[k]);j.sort(function(n,o){return n.uniq>o.uniq?1:n.uniq<o.uniq?-1:0});for(var l=0;l<j.length;++l){var m=jQuery("#language-template").html(),k=j[l];m=m.replace("{{LANGUAGE}}",k.lang).replace("{{NAME}}",k.user).replace("{{SIZE}}",k.size).replace("{{LINK}}",k.link),m=jQuery(m),jQuery("#languages").append(m)}}
```
```
body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654"> <div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> 
```
  
[Answer]
# [Haskell](https://www.haskell.org/), 51 bytes
```
midm(a:b)=b++[a]
i=(:).last<*>init
main=interact id
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/PzczJVcj0SpJ0zZJWzs6MZYr01bDSlMvJ7G4xEbLLjMvs4QrNzEzzzYzryS1KDG5RCEz5f9/RydnAA "Haskell – Try It Online")
## Explanation
Our `main` function is just `interact` of a another function. By default it is `id` which just returns the input, but if we shift we either add an `m` to make `idm` or remove the `d` to make `i`. Both of which we have defined to be roll left and roll right.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
À\Á\
```
[Try it online](https://tio.run/##yy9OTMpM/f//cEPM4caY//89UnNy8gE)  
[ry it shifted towards the leftT](https://tio.run/##yy9OTMpM/f8/5nBjzOGG//89UnNy8gE)  
[tTry it shifted towards the righ](https://tio.run/##yy9OTMpM/f8/5nBDzOHG//89UnNy8gE)
**Explanation:**
```
À     # Shift the (implicit) input once towards the left
 \    # Discard it from the stack
  Á   # Shift the (implicit) input once towards the right
   \  # Discard it from the stack
      # (output the implicit input implicitly as result)
\     # Discard (no-op, since the stack is already empty)
 À    # Shift the (implicit) input once towards the left
  \   # Discard it from the stack
   Á  # Shift the (implicit) input once towards the right
      # (and output this right-shifted input at the top of the stack implicitly as result)
\     # Discard (no-op, since the stack is already empty)
 Á    # Shift the (implicit) input once towards the right
  \   # Discard it from the stack
   À  # Shift the (implicit) input once towards the left
      # (and output this left-shifted input at the top of the stack implicitly as result)
```
[Answer]
# [R](https://www.r-project.org/), ~~82~~ ~~75~~ ~~67~~ 62 bytes
-4 bytes thanks to Giuseppe.
```
!-1->i
c(tail(s<-el(strsplit(scan(,""),"")),1/i),head(s,-i))#!
```
[Try it online!](https://tio.run/##K/r/X1HXUNcu0zpZoyQxM0ej2EY3FUiWFBUX5GSWaBQnJ@Zp6CgpaYKwpo6hfqamTkZqYopGsY5upqamsuJ/j9ScnPz/AA "R – Try It Online")
[ry it online!T](https://tio.run/##K/r/X9dQ1y7TOlmjJDEzR6PYRjcVSJYUFRfkZJZoFCcn5mnoKClpgrCmjqF@pqZORmpiikaxjm6mpqayouJ/j9ScnPz/AA)
[!Try it online](https://tio.run/##K/r/X1FR11DXLtM6WaMkMTNHo9hGNxVIlhQVF@RklmgUJyfmaegoKWmCsKaOoX6mpk5GamKKRrGObqampvJ/j9ScnPz/AA)
Uses rightwards assignment `->` (this is [only the 2nd time](https://codegolf.stackexchange.com/a/191416/86301) I have ever used rightwards assignment). The value of `i` is either 0, 1 or -1 depending on the shift. This is used to give the correct output:
* when `i=1`, `tail(s, 1)` gives the last element and `head(s, -1)` gives all elements but the last
* when `i=-1`, `tail(s, -1)` gives all elements but the first and `head(s, 1)` gives the first element
* when `i=0`, `tail(s, Inf)` gives `s` and `head(s, 0)` gives the empty vector.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 18 bytes
```
?.<Q1 Q ;*.>Q1qk" 
```
[Try it online!](https://tio.run/##K6gsyfj/317PJtBQIVDBWkvPLtCwMFtJ4f9/pcy8gtISJQA "Pyth – Try It Online"), [Right-shift](https://tio.run/##K6gsyfj/X8FezybQUCFQQVNLzy7QsDBb6f9/pcy8gtISJQA "Pyth – Try It Online"), [Left-shift](https://tio.run/##K6gsyfj/X88m0FAhUEFTS88u0LAwW0nB/v9/pcy8gtISJQA "Pyth – Try It Online")
Pretty proud of this one. Has a trailing newline except on right shift. Makes use of the fact that a space before a pyth expression suppresses the output. Note the last byte is a space.
## How it works
```
?.<Q1 Q ;*.>Q1qk" - Unshifted
?.<Q1                - If the input left-shifted is truthy
      Q ;            - Print the input, end if statement
         *.>Q1       - Right shifted input, multiplied by...
              qk"    - whether k (an empty string) is equal to the string at the end.                   
                       Since there is a space at the end, y(Q) is multiplied by zero.
.<Q1 Q ;*.>Q1qk" ? - Left Shifted
.<Q1               - Left shift the input and print it.
     Q             - This input is preceded by a space and as such does not print
               " ? - Obviously is not equal to an empty string (Pyth 
                     closes strings implicitly)
 ?.<Q1 Q ;*.>Q1qk" - Right Shifted
 ?.<Q1 Q ;         - The space before the if statement suppresses the printing
                 " - Since the space has been removed from the end, the 
                     terminating string is now an empty string, and y(Q) is printed
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~15~~ 11 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
-4 thanks to inspiration from [Luis Mendo's solution](https://codegolf.stackexchange.com/a/196871/43319).
Full program, prompting for input via stdin.
---
```
1⊢⍞⌽⍨¯2+≢1⍬
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKO94L/ho65Fj3rnPerZ@6h3xaH1RtqPOhcZPupdA5L9rwAGBVwZqTk5@QA "APL (Dyalog Unicode) – Try It Online")
`1⍬` the list `[1,[]]`
`≢` tally the elements in that; `2`
`¯2+` add negative two to that; `0`
…`⌽⍨` cyclically rotate the following by that number of steps:
 `⍞` stdin
`1⊢` yield that, ignoring the `1`
---
```
⊢⍞⌽⍨¯2+≢1⍬1
```
[ry it online!T](https://tio.run/##SyzI0U2pTMzJT///qKO94P@jrkWPeuc96tn7qHfFofVG2o86Fxk@6l1jCJL9rwAGBVwZqTk5@QA "APL (Dyalog Unicode) – Try It Online")
`1⍬1` the list `[1,[],1]`
`≢` tally the elements in that; `3`
`¯2+` add negative two to that; `1`
…`⌽⍨` cyclically rotate the following by that number of steps:
 `⍞` stdin
`⊢` yield that
---
```
⍬1⊢⍞⌽⍨¯2+≢1
```
[!Try it online](https://tio.run/##SyzI0U2pTMzJT///qKO94P@j3jWGj7oWPeqd96hn76PeFYfWG2k/6lxkCJL9rwAGBVwZqTk5@QA "APL (Dyalog Unicode) – Try It Online")
`1` the number `1`
`≢` tally the elements in that; `1`
`¯2+` add negative two to that; `-1`
…`⌽⍨` cyclically rotate the following by that number of steps:
 `⍞` stdin
`⍬1⊢` yield that, ignoring the list `[[],1]`
[Answer]
# JavaScript (Browsers), ~~81~~ ~~68~~ 66 bytes
```
xx=1;var x,xxx;w=prompt();alert(w.slice(a=x|-xxx)+w.slice(0,a))//x
```
## Original solution (81 bytes)
```
tob=-1;try{ob;atob=1}catch(e){}w=prompt();alert(w.slice(atob)+w.slice(0,atob))//a
```
No TIO link because it works only in browsers ~~with `atob` function defined~~.
In order to show the output in a more friendly way, `prompt` and `alert` are overridden in the screenshot below.
[![enter image description here](https://i.stack.imgur.com/ANx5U.png)](https://i.stack.imgur.com/ANx5U.png)
## Explanation
The declarations of `x` and `xxx` are hoisted to the beginning automatically, so the declarations won't clear the values assigned beforehand.
### No rotation
```
xx=1;var x,xxx;w=prompt();alert(w.slice(a=x|-xxx)+w.slice(0,a))//x
// xx = 1, so a = 0, so we have alert(w.slice(0)+w.slice(0,0))
```
### Left rotation
```
x=1;var x,xxx;w=prompt();alert(w.slice(a=x|-xxx)+w.slice(0,a))//xx
// x = 1, so a = 1, so we have alert(w.slice(1)+w.slice(0,1))
```
### Right rotation
```
xxx=1;var x,xxx;w=prompt();alert(w.slice(a=x|-xxx)+w.slice(0,a))//
// xxx = 1, so a = -1, so we have alert(w.slice(-1)+w.slice(0,-1))
```
[Answer]
# [Python 2](https://docs.python.org/2/), 64 bytes
```
bc=k=input()
print[k,k[1:]+k[0],k,k[-1]+k[:-1]][len(dir()[5])]#a
```
[Try it online!](https://tio.run/##K6gsycjPM/r/PynZNts2M6@gtERDk6ugKDOvJDpbJzva0CpWOzvaIFYHxNE1BHGsgFRsdE5qnkZKZpGGZrRprGascuL//0oeqTk5@UoA "Python 2 – Try It Online"), [!Try it online](https://tio.run/##K6gsycjPM/r/PzEp2TbbNjOvoLREQ5OroCgzryQ6Wyc72tAqVjs72iBWB8TRNQRxrIBUbHROap5GSmaRhma0aaxmrPL//0oeqTk5@UoA "Python 2 – Try It Online") and [ry it online!T](https://tio.run/##K6gsycjPM/r/P9k22zYzr6C0REOTq6AoM68kOlsnO9rQKlY7O9ogVgfE0TUEcayAVGx0TmqeRkpmkYZmtGmsZqxyYtL//0oeqTk5@UoA "Python 2 – Try It Online")
`dir` is a builtin function that returns a list of all variable names. The length of the first variable name is used to choose the right output.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 4 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
ÉUé0
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=yVXpMA&input=ImFiY2RlZiI)
---
[0ÉUé](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=MMlV6Q&input=ImFiY2RlZiI)
[Ué0É](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=VekwyQ&input=ImFiY2RlZiI)
---
Works with arrays too.
[ÉUé0](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=yVXpMA&input=WzEsMiwzLDRd)
[Ué0É](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=VekwyQ&input=WzEsMiwzLDRd)
[0ÉUé](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=MMlV6Q&input=WzEsMiwzLDRd)
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~109~~ ~~86~~ 83 bytes
-20 bytes thanks to [xibu](https://codegolf.stackexchange.com/users/90181/xibu)
Takes the text to display is a command line argument. The active code is bookended by newlines, having the result of changing what `__LINE__` evaluates to when shifting the code. This means `2-__LINE__` will be +1 for shifting left, 0 for no shift, and -1 for shifting right.
## No shift
```
K;main(L,s)char**s;{for(L=strlen(s[1]);K<L;)putchar(s[1][(K+++2-__LINE__+L)%L]);}
```
[Try it online!](https://tio.run/##S9ZNT07@/5/L2zo3MTNPw0enWDM5I7FIS6vYujotv0jDx7a4pCgnNU@jONowVtPa28bHWrOgtASkBiwUreGtra1tpBsf7@Pp5xofr@2jqeoDVFjL9f///8Sk5BQA "C (gcc) – Try It Online")
## Left shift
```
K;main(L,s)char**s;{for(L=strlen(s[1]);K<L;)putchar(s[1][(K+++2-__LINE__+L)%L]);}
```
[Try it online!](https://tio.run/##S9ZNT07@/9/bOjcxM0/DR6dYMzkjsUhLq9i6Oi2/SMPHtrikKCc1T6M42jBW09rbxsdas6C0BKQGLBSt4a2trW2kGx/v4@nnGh@v7aOp6gNUWMvF9f///8Sk5BQA "C (gcc) – Try It Online")
## Right shift
```
K;main(L,s)char**s;{for(L=strlen(s[1]);K<L;)putchar(s[1][(K+++2-__LINE__+L)%L]);}
```
[Try it online!](https://tio.run/##S9ZNT07@/5@Ly9s6NzEzT8NHp1gzOSOxSEur2Lo6Lb9Iw8e2uKQoJzVPozjaMFbT2tvGx1qzoLQEpAYsFK3hra2tbaQbH@/j6ecaH6/to6nqA1RY@////8Sk5BQA "C (gcc) – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), ~~52~~ 48 bytes
## Base code:
```
"i=1#";i=0#';i=-1
a=input()
print(a[i:]+a[:i])#'
```
[Try it online!](https://tio.run/##K6gsycjPM/7/XynT1lBZyTrT1kBZHUjqGnIl2mbmFZSWaGhyFRRl5pVoJEZnWsVqJ0ZbZcZqKqv//@@RmpOTrxCeX5SToggA "Python 3 – Try It Online")
## Left shift:
```
i=1#";i=0#';i=-1
a=input()
print(a[i:]+a[:i])#'"
```
[ry it online!T](https://tio.run/##K6gsycjPM/7/P9PWUFnJOtPWQFkdSOoaciXaZuYVlJZoaHIVFGXmlWgkRmdaxWonRltlxmoqqyv9/@@RmpOTrxCeX5SToggA "Python 3 – Try It Online")
## Right shift:
```
'"i=1#";i=0#';i=-1
a=input()
print(a[i:]+a[:i])#
```
[!Try it online](https://tio.run/##K6gsycjPM/7/X10p09ZQWck609ZAWR1I6hpyJdpm5hWUlmhochUUZeaVaCRGZ1rFaidGW2XGair//@@RmpOTrxCeX5SToggA "Python 3 – Try It Online")
Comments in code are useful :)
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~9~~ 8 bytes
```
TFsqYS%T
```
[Try it online!](https://tio.run/##y00syfn/P8StuDAyWDXk/391j9ScnHx1AA) See also [right-shifted](https://tio.run/##y00syfn/PyTErbgwMlj1/391j9ScnHx1AA) and [left-shifted](https://tio.run/##y00syfn/3624MDJYNSTk/391j9ScnHx1AA) versions.
# How it works
**Normal version:**
```
TF    % Push array [true, false]
sq    % Sum; subtract 1. Gives 0
YS    % Implicit input. Circular shift by that amount. Implicit display
%T    % Comment. Ignore rest of line
```
**Right-shifted version:**
```
TTF   % Push array [true, true, false]
sq    % Sum; subtract 1. Gives 1
YS    % Implicit input. Circular shift by that amount. Implicit display
%     % Comment. Ignore rest of line
```
**Left-shifted version:**
```
F     % Push array [false]
sq    % Sum; subtract 1. Gives -1
YS    % Implicit input. Circular shift by that amount. Implicit display
%TT   % Comment. Ignore rest of line
```
[Answer]
# [Runic Enchantments](https://github.com/Draco18s/RunicEnchantments/tree/Console), 7 bytes
```
@{͍{͍
```
[Try it online!](https://tio.run/##KyrNy0z@b5dpYOh0tve/Q/XZXiD6/7@isgoA "Runic Enchantments – Try It Online")
Input is limited to a single string (spaces need to be escaped).
This is the best I can come up with. It is not a full program, but instead [a function](https://codegolf.stackexchange.com/a/187842/47990) (see the header on TIO for the entry, stdin handling, and `B`ranch).
This also relies on treating each *cell* of the function as a single object.
Alternatively [this](https://tio.run/##KyrNy0z@b2cQnZkTa6BpomVfZGDodLb3f3W1w///FQqVClUA) works on space separated inputs and doesn't require modifier characters, but outputs them all with no separator.
Without those concessions, the challenge would be impossible in Runic, due to having explicit input and output, as well as a termination command (eg. sample program `i@}`, if it was rotated two to the right to `@}i`, the program would terminate without reading or outputting anything; with an explicit entry point, the program could not distinguish its own rotation).
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~96~~ 94 bytes
-2 bytes thanks to gastropner
```
BC=1;C;ABC;S,K;main(N,c)char**c;{K=S=strlen(c[1]);for(N=C-ABC+S;K--;)putchar(c[1][N++%S]);}//A
```
[Try it online!](https://tio.run/##S9ZNT07@/9/J2dbQ2tna0cnZOljH2zo3MTNPw08nWTM5I7FISyvZutrbNti2uKQoJzVPIznaMFbTOi2/SMPP1lkXqEU72NpbV9das6C0BKQerCDaT1tbNRiorlZf3/H///@GRsYmpgA "C (gcc) – Try It Online")
explanation:
```
BC=1;       // declare and set variable ABC, BC or C (depending on shift)
C;ABC;      // declare possible variable names
            // existing variables are not changed, newly declared variables are set to 0
int main(int NumArgs,char** c)
{
    char* input = c[1];
    int S = strlen(input);      // string length used for modulo
    int K = S;                  // string length used to count characters
    int I = C - ABC + S;        // set start of output
    for(;K--;)                  // display K characters
        putchar(input[I++%S]);  // display character and move read position
}
//A                             // A used to create valid variable name in first line
```
[Answer]
# Javascript, ~~63~~ ~~40~~ 39 bytes
Thanks to @Shaggy and @l4m2, it's now 39 bytes.
`0;f=x=>x.slice(o)+x.slice(0,o);o=~-0b01`
**Explanation**
The last line of this snippet assigns the variable o to either `-1+0b0`, `-1+0b01`, or `-1+0b010`. The 0b prefix is used to define a binary literal, causing those to evaluate to -1, 0, or 1, which then gets used inside the function.
Here are try-it-now versions:
**Not Shifted**
```
<html>
  <body>
    <script>
      0;f=x=>x.slice(o)+x.slice(0,o);o=~-0b01
      console.log(f(prompt()))
    </script>
  </body>
</html>
```
**Left Shifted**
```
<html>
  <body>
    <script>
      ;f=x=>x.slice(o)+x.slice(0,o);o=~-0b010
      console.log(f(prompt()))
    </script>
  </body>
</html>
```
**Right Shifted**
```
<html>
  <body>
    <script>
      10;f=x=>x.slice(o)+x.slice(0,o);o=~-0b0
      console.log(f(prompt()))
    </script>
  </body>
</html>
```
## History
**Original version**
`0;x=prompt();onload=_=>alert(x.slice(o)+x.slice(0,o));o=-1+0b01`
A value gets assigned to o on the last line, but we need it in the middle of the code, so we called a function with a delay (by attaching it to the onload event) in order to do so.
**After @Shaggy suggestion to accept I/O from a function**
`0;f=x=>x.slice(o)+x.slice(0,o);o=-1+0b01`
**After @l4m2's suggestion to use `~-` to subtract 1, instead of `-1+` (the current solution).**
`0;f=x=>x.slice(o)+x.slice(0,o);o=~-0b01`
[Answer]
# [Ruby](https://www.ruby-lang.org/), 72 bytes
```
aa,a,aaa,g=0,-1,1,gets
f=->s,a{(g*3)[s+a..-s+a-1]}
puts f.call g.size,aa
```
[Try it online!](https://tio.run/##KypNqvz/PzFRBwiBZLqtgY6uoY6hTnpqSTFXmq2uXbFOYrVGupaxZnSxdqKeni6Q1DWMreUqKC0pVkjTS07MyVFI1yvOrEoFGvD/f0ZqTk4@AA "Ruby – Try It Online")
```
a,a,aaa,g=0,-1,1,gets
f=->s,a{(g*3)[s+a..-s+a-1]}
puts f.call g.size,aaa
```
[Try it online!](https://tio.run/##KypNqvz/P1EHCBMTddJtDXR0DXUMddJTS4q50mx17Yp1Eqs10rWMNaOLtRP19HSBpK5hbC1XQWlJsUKaXnJiTo5Cul5xZlUqyID//zNSc3LyAQ "Ruby – Try It Online")
```
aaa,a,aaa,g=0,-1,1,gets
f=->s,a{(g*3)[s+a..-s+a-1]}
puts f.call g.size,a
```
[Try it online!](https://tio.run/##KypNqvz/PzExUQcIgWS6rYGOrqGOoU56akkxV5qtrl2xTmK1RrqWsWZ0sXainp4ukNQ1jK3lKigtKVZI00tOzMlRSNcrzqxK1Un8/z8jNScnHwA "Ruby – Try It Online")
Triplicates the input then takes a middle substring, shifted according to whether the source code was shifted. Doesn't take kindly to empty input, unfortunately.
Ruby actually has a built-in `rotate` function, there might be a way to use this but it only works on arrays and not strings.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 8 bytes
```
←→Ｆθ§θⅈ←
```
[Try it online!](https://tio.run/##S85ILErOT8z5/983vyxVw8onNa1E05oLwgnKTM8A8dLyixQ0CjUVAooy80o0HEs881JSKzQKdRQiNDQ14aohWv//DymqVMgsUcjPy8nMS1Xk@q9blgMA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
←           Move cursor left (decrement X-position)
 →          Move cursor right (increment X-position)
  Ｆ         For each character of
   θ        Input string
    §       Implicitly print cyclically indexed character
     θ      Input string
      ⅈ     Current X-position
       ←    Move cursor left (no-op)
```
Rotating the code simply causes the X-position to start at `1` or `-1` appropriately thus causing the characters of string to be output cyclically offset, however Charcoal does not include the cursor movement in the output.
```
→Ｆθ§θⅈ←←
```
[ry it online!T](https://tio.run/##S85ILErOT8z5/983vyxVwyooMz2jRNOaKy2/SEGjUFMhoCgzr0TDscQzLyW1QqNQRyFCQ1MTKA9R7ZOaVoLG@f8/pKhSIbNEIT8vJzMvVZHrv25ZDgA "Charcoal – Try It Online") Link is to verbose version of code.
```
←←→Ｆθ§θⅈ
```
[!Try it online](https://tio.run/##S85ILErOT8z5/983vyxVw8onNa1E05oLCycoMz0DxEvLL1LQKNRUCCjKzCvRcCzxzEtJrdAo1FGI0NDU1LT@/z@kqFIhs0QhPy8nMy9Vkeu/blkOAA "Charcoal – Try It Online") Link is to verbose version of code.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 33 bytes
```
0+#~RotateLeft~Log10[.1$]&/.$->10
```
[Try it online!](https://tio.run/##VY8xa8MwFIR3/YqghNJQO7KHDB1stGQozVBc00VoUJMXSRBJRVIgISR/3ZVsQul0fHf3Dp4RUYERUe/E8C0CNHioXub3zkURYQuHeN86WVdsVS/4E1ktyrauBkzIZ/Tayt5rg46p1Uz8d0bzGPJaqv9Zl50ptMJAaK4I54EZLtusBcI5zJg14biRcFR0Qx9pLBI6Xk/A@MPslQexZ@9wCWws8LJNnjtJxZ57tzn/eAhBO0volzie4NFa0s1OOTrn6UeKZp2we2febAQJnr0W13WxvvHhFw "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Klein](https://github.com/Wheatwizard/Klein) 000, ~~[59](https://codegolf.stackexchange.com/revisions/215152/1)~~ 53 bytes
## Original
```
@>:?!\)>):?!\?@
\(  / \$
/(   \ /)  \
>$:?!/?>:?!/?@/
```
[Try it online!](https://tio.run/##y85Jzcz7/9/BzspeMUbTThNE2TtwxWgoKOgrxKhw6QMZCjEK@ppAkstOBSitb28HJh30////r5v838DA4H9icTYA "Klein – Try It Online")
## Left-Shifted
```
>:?!\)>):?!\?@
\(  / \$
/(   \ /)  \
>$:?!/?>:?!/?@/@
```
[Try it online!](https://tio.run/##y85Jzcz7/9/Oyl4xRtNOE0TZO3DFaCgo6CvEqHDpAxkKMQr6mkCSy04FKK1vbwcmHfQd/v//r5v838DA4H9icTYA "Klein – Try It Online")
## Right-Shifted
```
/@>:?!\)>):?!\?@
\(  / \$
/(   \ /)  \
>$:?!/?>:?!/?@
```
[Try it online!](https://tio.run/##y85Jzcz7/1/fwc7KXjFG004TRNk7cMVoKCjoK8SocOkDGQoxCvqaQJLLTgUorW9vByYd/v//r5v838DA4H9icTYA "Klein – Try It Online")
---
This requires topology 000 for some small byte saving measures. For a version that works on any topology see the 59 byte version in the history.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
10%3Cṙ@ḷ4
```
[Try it online!](https://tio.run/##y0rNyan8/9/QQNXY@eHOmQ4Pd2w3@f//f0VlVWJSMgA "Jelly – Try It Online")
A monadic link taking a Jelly string and returning the processed Jelly string.
[All three variations](https://tio.run/##y0rNyan8b6Bq7Pxw50yHhzu2mxj@N0Tm/jdB5nIZHdmvY3hk/8Odax2Mj@yP/P@/orIqMSkZAA)
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 37 bytes
```
's/(.)(.*)/\2\1/;';";s/(.*)(.)/\2\1/"
```
[Try it online!](https://tio.run/##K0gtyjH9/1@9WF9DT1NDT0tTP8YoxlDfWt1ayRokpgUUhIop/f@fmJSckvovv6AkMz@v@L9uAQA "Perl 5 – Try It Online")
### Left shift
```
s/(.)(.*)/\2\1/;';";s/(.*)(.)/\2\1/"'
```
[Try it online!](https://tio.run/##K0gtyjH9/79YX0NPU0NPS1M/xijGUN9a3VrJGiSmBRSEiimp//@fmJSckvovv6AkMz@v@L9uAQA "Perl 5 – Try It Online")
### Right shift
```
"'s/(.)(.*)/\2\1/;';";s/(.*)(.)/\2\1/
```
[Try it online!](https://tio.run/##K0gtyjH9/19JvVhfQ09TQ09LUz/GKMZQ31rdWskaJKYFFISK/f@fmJSckvovv6AkMz@v@L9uAQA "Perl 5 – Try It Online")
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/Attache), 12 bytes
```
0&~Rotate??~
```
[Try it online!](https://tio.run/##SywpSUzOSP2fZmX730CtLii/JLEk1d6@7n9AUWZeSXRatJKjk7OLq5tSbOx/AA "Attache – Try It Online")
Returns a function.
## Explanation
`Rotate` is a function which does string rotation. `~Rotate` reverses the argument order. `x&` binds the `x` to the left argument of the given function. `??~` is a comment (`??` marking the start of it). So, this returns a function which, given y, returns `Rotate[y, x]`—rotating `y` by `x` degree.
For the case of no rotation, this rotates the string by 0.
When rotated once right, this becomes:
```
~0&~Rotate??
```
Which is the same as the above, except this time it's `Rotate[y, -1]`, which performs the desired transformation.
If instead we rotate left once, it becomes:
```
&~Rotate??~0
```
`&`, when used in a unary context such as this, will, if given an array as input, apply the each element of the array as an argument for the function. However, the argument is a string, and this is effectively a no-op. Thus, `Rotate[y, x]` has no right argument; by default, it is `1`, so this performs the desired transformation.
[Answer]
# [Crystal](https://crystal-lang.org/), 52 bytes
**Unshifted**
```
25.tap{|n|puts gets.to_s.chars.rotate(n%3-1).join}#2
```
[Try it online!](https://tio.run/##Sy6qLC5JzPn/38hUrySxQKG6Jq@moLSkWCE9taRYryQ/vlgvOSOxqFivKL8ksSRVI0/VWNdQUy8rPzOvVtno//@M1JycfAA "Crystal – Try It Online")
**Left-Shifted**
```
5.tap{|n|puts gets.to_s.chars.rotate(n%3-1).join}#22
```
[Try it online!](https://tio.run/##Sy6qLC5JzPn/31SvJLFAobomr6agtKRYIT21pFivJD@@WC85I7GoWK8ovySxJFUjT9VY11BTLys/M69W2cjo//@M1JycfAA "Crystal – Try It Online")
**Right-Shifted**
```
225.tap{|n|puts gets.to_s.chars.rotate(n%3-1).join}#
```
[Try it online!](https://tio.run/##Sy6qLC5JzPn/38jIVK8ksUChuiavpqC0pFghPbWkWK8kP75YLzkjsahYryi/JLEkVSNP1VjXUFMvKz8zr1b5//@M1JycfAA "Crystal – Try It Online")
Crystal's `Object#tap` passes the object into the following block. Then we get the input, guarantee it's a string, get an array of that string's characters, and then rotate. We rotate by the number at the beginning, modded by three and then subtracted by 1 (with the number at the beginning "chosen" based on convenient modulo properties).
[Answer]
# [Pxem](https://esolangs.org/wiki/Pxem), Content: 0 bytes + Filename: 75 bytes.
* Filename (escaped): `X.c.Z.w.i.c\001.+.a.s.v.t.p.m.o.d.A.c.Z.w.o.i.c\001.+.a.d.A.w.i.c\001.+.a.s.t.v.m.pX`
[Try it online!](https://tio.run/##jVhtV9rKFv7eXzGkkUzI6yAqEqNS8FrOUarWuqyArpAEDYbAIUHRwPnrvXsmQSD0dt2u1TLz7GfP3rNfJjN9Dp9@ff5sW5a9a7vdvV5xv0gsq@duW3Z52@6VSFEn9k5Z33N3i73ip9CNkOJOjMnACp@RrheLhjsdDccROqs9VM/OzJqBo7eRix7dyB4GvXyezezhYGAFjnioOe6LFkx8HxUP8ySfT5UvqtdfTY7HKQ8po8UCTCTyMf2RKvNkoMy5hdkfzcbtw/frulnU9e0FePHte@P27OdD7dvV1Unt2iRGC3F8/KX6/evDzcnV98a3ZkV6m3PIRG@ok8@zXQ3RaBh602QmfUlU7v6HhjuY@FbkovCJ8YejCIavw7ETjnwvyuct37NCpDwigY@JxPHH3FwwBfor5PPNH2dntfO6WWE2MLXnGOGT14sMNkaUlwKu/TRE/GeRWibUcg4MFYe@c5iH0L9YPuJyqGf5ocvNZqsytjTTns5C10FCqE21N80I4Z93TWALvqMOVWIs4CxUbSziISShGiDlJZqQWTRGSi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ugUfDhWqkaugO3cM9yjvxQthGY4WCk2KddQ/9I/6W37F3@pX2FhjY8jRPDlhwTNT70A5wGMPs5OgBw8xdtRzM1vkhKVzPYjEGis9s7nZ5uPrD28vM/loJTcFuIjBR4y@gZVx8Exm9gRGjoAEpPSKi68bXGwucF6kj8AVd1xWzMlXM4bCZQX9LEmGJPUPMD2EadFCyJPw99MpDETj99ug23Vc34V3MuQZWiE9nqBBJKlxAOoSSVqCfWkabEWJQJ8kh76UzDtzwaBfKvofBHCVshH7T4QJ7ZDhgD6JARxvgMsYOiWkNEtrhNkMj@B5XoU3v@fIbuQNXHlkjybyS/huOPCwF1dzUPrzAxhFlufD9ba0EmB6xY7L9JrDLlPCzHp9hrWQZSpFUtorlbd3S2UkxJZk8vr8pFlPvxoW3Ay4T/93/tNV0@jQHw4SAB98jokEXoc7GvzhUJikB3NbQ07mdVGYTa3xI8SgMUVp5qbo06@iTvb/Cw)
## With comments
```
??.z
# number of X's, as literals branches
.a??X.z
# if not empty; then pop; else enter here
.a.c.Z??.z
  # push while EOF
  .a.w.i.c\001.+.a??.z
  # pop; reverse; pop to heap; pop all to print; push heap; pop to print; exit
  .as.v.t.p.m.o.d??.a
.a.A??.z
# if not empty; then pop; else enter here
.a.c.Z??.z
  # cat; as in my previous post
  .a.w.o.i.c\001.+.a.d??.z
.a.A??.z
# and finally
.a.w.i.c\001.+.a.s.t.v.m.pX
```
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), ~~112~~ 75 bytes
```
+<,[>[>+<-],]+>[-[<<.[-]<[<]>[.[-]>]]<[-<<[<]>[.>]]>]<[-<[<]>>[.>]<[<]>.<]+
```
[Try it online!](https://tio.run/##LchLCoAwDEXRreg4TVfwyNgdOAgZ@AWxWCi4/tgWZ/fctSzXc77b7U4IKioEtmAkygpEZYPCRFuJVTD@USXdjd29IozcpyOlPMy5pH38AA "brainfuck – Try It Online")
[!Try it online](https://tio.run/##LchLCoAwDEXRreg4TVfwyNgdOAgZ@AWxWCi4/tgWZ/fctSzXc77b7U6EoKJCYAtGoqxAVDYoTLSVWAXjH1XS3djdK8LcpyOlPMy5pH38AA "brainfuck – Try It Online")
[ry it online!T](https://tio.run/##LchLCoAwDEXRreg4TVfwyNgdOAgZ@AWxWCi4/tgWZ/fctSzXc77b7Y6gokJgC0airEBUNihMtJVYBeMfVdLd2N0rwojcpyOlPMy5pH38AA "brainfuck – Try It Online")
]