[Question]
  [
### Your Programs:
You'll write two programs (both in the same language). The storage program takes a string from STDIN and stores it somewhere *persistent* (see below) and then exits without error. The retrieval program takes no input, retrieves the string that was stored, and prints it to STDOUT.
### Objective test of Persistence:
You should be able to run the storage program on your local machine, then power-cycle your local machine, then call the retrieval program on your local machine. You can stash the string however you want (even on the web) as long as you pass this reboot test.
### Test Cases:
Storage then retrieval:
```
echo foo | Store
Retrieve
foo
```
Repeated Stores should overwrite (like a set() method):
```
echo foo | Store
echo bar | Store
Retrieve
bar
```
Repeated Retrieval is non-destructive (like a get() method):
```
echo foo | Store
Retrieve
foo
Retrieve
foo
```
Retrieval before any invocation of Storage:
You don't need to worry about this. Your retrieval program can assume that the storage program has been run at some point in the past.
### Input/Output flexibility.
People have asked me to expand this from strict STDIN/STDOUT to the standard IO rules. I can't because it would introduce too many loopholes. Some standard IO options already have the input stored in a persistent way, eg "programs may take input from a file". I'd like to be more flexible than just strict STDIN and STDOUT, but without opening the floodgates. 
From the standard IO rules thread I'm cherry-picking the ones that don't break the challenge:
* [Programs may take input via GUI prompts](https://codegolf.meta.stackexchange.com/a/2459/69304) and command-line prompts if you want
* [Programs may output by displaying it on screen](https://codegolf.meta.stackexchange.com/a/7139/69304) This includes GUI dialogs
* [Programs may take input via command-line arguments](https://codegolf.meta.stackexchange.com/a/2449/69304)
* [Programs may output to STDERR](https://codegolf.meta.stackexchange.com/a/2451/69304) but still can't actually throw errors.
If you use an alternate it must be user-interactive. The user shouldn't have to do any other work besides piping their input to your program, typing it into a prompt your program provides, or typing input as a command-line-arg of your program. The user shouldn't have to do anything other than running your retrieve program to see the output displayed on screen or sent to STDOUT or STDERR.
### Allowed assumptions:
* Your two programs will be run in the same directory
* Your programs have read-write permissions for that directory
* Files you create will survive the reboot (not in a temp dir)
* One trailing newline that wasn't part of the string is allowed. No other trailing whitespace
### This is code-golf, and your score is the sum of bytes from both programs.
  
[Answer]
## zsh, 4 bytes
Store: `>f` (reads from STDIN and writes to a file called `f`)  
Retrieve: `<f` (writes the contents of `f` to STDOUT)
[Answer]
# TI-BASIC (Z80), 1 [byte](https://codegolf.meta.stackexchange.com/a/4764/43319 "TI-Basic is tokenized")?
Store:  (just enter the string)  
Retrieve: `Ans` (byte 27)
But if that isn't valid:
# TI-BASIC (Z80), ~~7~~ 6 [bytes](https://codegolf.meta.stackexchange.com/a/4764/43319 "TI-Basic is tokenized")
-1 thanks to Jakob.
Store: `Prompt Str0` (bytes DD AA 09)  
Retrieve: `disp Str0` (bytes ED AA 09)
[Answer]
# Browser JS, 44 bytes
**Store**:
```
localStorage.a=prompt()
```
**Retrieve**:
```
alert(localStorage.a)
```
[Answer]
# POSIX shell sh/bash/... 8 bytes
store:
```
dd>f
```
get:
```
dd<f
```
[Answer]
# [Python 3](https://docs.python.org/3/), 46 bytes
### store, 45 bytes:
```
open(*'fw').write('print(%r)'%open(0).read())
```
The retrieve program is built by the store command, a file named `f`. ([1 byte for the file name](http://codegolf.meta.stackexchange.com/questions/12819/what-assumptions-about-the-file-system-layout-can-be-made))
[Answer]
# Batch, 16 bytes
```
COPY CON A
TYPE A
```
[Answer]
# Powershell - 4 Bytes
Storage:
```
ac
```
(alternative also `sc`)
Retrieval
```
gc
```
Edit: I just noticed the output is not allowed any user input... so it jumps from 4 to either 6 or 8 bytes
Storage:
```
ac f
```
(alternative also `sc f`) for the 8 byte version
```
ac
```
(and specify `f` as path) for the 6 byte Version
Retrieval
```
gc f
```
[Answer]
# Rust, 136 bytes
## Store (84 bytes)
```
use std::{fs::*,io::*};
```
```
||{let mut v=vec![];stdin().read_to_end(&mut v);write("a",v)}
```
## Retrieve (52 bytes)
```
||print!("{}",std::fs::read_to_string("a").unwrap())
```
## Acknowledgments
* -1 byte thanks to [Esolanging Fruit](https://codegolf.stackexchange.com/users/61384)
[Answer]
# Bash, ~~12 11~~ 10 bytes
## store, ~~7 6~~ 5 bytes
~~`cat ->f`~~ # no need for `-`, stdin is default
~~`cat >f`~~ # no need for space, `>` separates as well
```
cat>f
```
## retrieve, 5 bytes
```
cat f
```
[Answer]
# HP 49G RPL, 48 bytes
To save: `:2: A DUP PURGE STO`, 26.5 bytes
To restore: `:2: A RCL`, 21.5 bytes
If we can leave in the backup battery, we get:
# HP 49G RPL, 0 bytes
To save: , 0 bytes
To restore: , 0 bytes, since the HP 49G leaves the stack untouched across reboots.
[Answer]
# [APL (APLX)](https://www.dyalog.com/aplx.htm), 5 [bytes](https://codegolf.meta.stackexchange.com/q/9428/43319)
Store: `⍞⍈1`  
Retrieve: `⍇1`
`⍞` get line from stdin  
`⍈1` write to next available component of file number 1
`⍇1` read the ~~first~~\* last component of file number 1
[![APLX Store session](https://i.stack.imgur.com/d8JTl.png)](https://i.stack.imgur.com/d8JTl.png)[![APLX Retrieve session](https://i.stack.imgur.com/VrBz0.png)](https://i.stack.imgur.com/VrBz0.png)
\* Documentation says *first* but experimentation shows *last*.
[Answer]
# bash, 10 bytes (non-competing)
```
touch $@
ls
```
Unix filenames [can contain](https://unix.stackexchange.com/a/230299/43499) any character except `NUL` and `/`, and their names can be [upto 255 bytes long](https://serverfault.com/a/9548/188067) so this will be able to store only strings up to that length (consider that a limitation of the storage medium), and that don't contain '/' in them. That's one reason this is non-competing, another is that this assumes the directory it's run on is empty (or that extraneous output from `ls` is allowed). I still wanted to post this because it just seemed a cool and non-obvious way to store information. 
Another on a similar vein, which wouldn't have the same length and character limitations would be:
## ~~35~~ 33 bytes
```
mkdir -p $@
find|sed '$!d;s/..//'
```
This allows the `/` character in the string, and supports many more characters (exactly how many depends on implementation). 
*(-2 bytes on this thanks to @Cows quack)*
[Answer]
# Python 3, 56 bytes
## Store (33 bytes)
```
open(*'aw').write(open(0).read())
```
## Retrieve (23 bytes)
```
print(open('a').read())
```
Prints with a trailing newline.
[Answer]
# Japt, ~~46~~ 30 bytes
*-16 bytes thanks to [Shaggy](https://codegolf.stackexchange.com/users/58974).*
One of the first times I've tried using Japt. The JS eval can be fidgety sometimes. Uses the browser's `window.localStorage`.
## Store (16 bytes)
```
Ox`lo¯lSÈSge.P=U
```
## Retrieve (14 bytes)
```
Ox`lo¯lSÈSge.P
```
[Answer]
## Haskell, 46 bytes
Store (26 bytes):
```
getContents>>=writeFile"t"
```
Retrieve (20 bytes):
```
readFile"t">>=putStr
```
[Answer]
# Ruby (26 Bytes)
## Set (16 Bytes)
```
IO.write'a',gets
```
## Get (10 Bytes)
```
IO.read'a'
```
[Answer]
# MATLAB (30 Bytes)
## Set (22 Bytes)
```
a=input('','s');save a
```
Can shave off 4 bytes by changing to `input('')`, but this will require input to be in single quotes: `'input string'`
## Get (8 Bytes)
```
load a;a
```
[Answer]
# C (GCC), 98 bytes
## Store (46 bytes)
Input is via first command line argument.
```
main(c,v)char**v;{fputs(v[1],fopen("a","w"));}
```
## Retrieve (52 bytes)
```
c,d;r(){for(d=open("a",0);read(d,&c,1);)putchar(c);}
```
## Unportability
* Requires that several pointer types fit in `int`.
## Acknowledgments
* -2 bytes thanks to [*ceilingcat*](https://codegolf.stackexchange.com/users/52904)
* -10 bytes thanks to [Peter Cordes](https://codegolf.stackexchange.com/users/30206)
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 18 bytes
Store: `⍞⎕NPUT⎕A 1` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKM9uCS/KPX/o955j/qm@gWEhgApRwVDkAwXEAellhRlppalcj3qagYpcHcFKwBJ/VcAA7B@rrT8fC5kflJiEZQPMwEA "APL (Dyalog Unicode) – Try It Online")  
Retrieve: `⊃⎕NGET⎕A` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKM9uCS/KJXrUe@8R31T/QJCQ4CUIxdQHISDUkuKMlPLUv8/6moGSbu7gqVB2v4rgAFEd1p@PheED9OBxgUA "APL (Dyalog Unicode) – Try It Online")
`⍞` get line from stdin  
`⎕NPUT` put it in a native file called  
`⎕A` the uppercase alphabet
`1` and overwrite if the file exists
`⊃` the first part (the data, the next parts are encoding and line ending type) of  
`⎕NGET` get the native file  
`⎕A` the uppercase alphabet
[Answer]
# R (27 bytes)
## store (21 bytes)
```
x=readLines('stdin')
```
## load (6 bytes)
```
cat(x)
```
For this to work, the first script needs to be invoked with the command line option `--save`, and the second one with `--restore` (though in interactive mode this isn’t necessary: these options are the default).
This could be shortened by 7 bytes were it not for the fact that a bug in R prevents the default argument of `readLine` from working in non-interactive mode. In interactive mode, it is *not* necessary, and the solution therefore only uses **20 bytes**.
[Answer]
# [Java (JDK 10)](http://jdk.java.net/), 204 Bytes
**Warning:** Overwrites any preferences that any java programs have stored for your username!
### Store, 94 Bytes:
```
interface S{static void main(String[]a){java.util.prefs.Preferences.userRoot().put("",a[0]);}}
```
[Try it online!](https://tio.run/##DcsxDoMwDADAr0RMidRa3fsJVEbE4AaDnLYxShwWxNtdltsu4Y73NH/MOCuVBSO54aiKytHtwrP7IWc/aOG8jhOGI10DmvIXtkJLhf6SCuVIFVql8hJRH2Br6rvuhuNjCs/zNLO3yB8 "Java (JDK 10) – Try It Online")
### Retrieve 110 Bytes:
```
interface R{static void main(String[]a){System.out.print(java.util.prefs.Preferences.userRoot().get("",""));}}
```
[Try it online!](https://tio.run/##DYxBCsMgEAC/Ip4U2v1APxGSY@lhazZhbeMWXQMl5O3Gy8DMYSLueI/zpzVOSnnBQGY8iqJyMLvwbDbk5CbNnNbnC/0x/YvSBlIVfj2qi30BVfnbnZYCQydlSoEK1EJ5FFHnYSV11t6s9f5xnq21t8gF "Java (JDK 10) – Try It Online")
```
java S foo
java R
foo
```
This works by taking input as an arg and storing it in the user preferences backing-store provided by [java.util.prefs](https://docs.oracle.com/javase/8/docs/technotes/guides/preferences/index.html). It overwrites the user's root node to save one byte on naming a node. If you want to test it non-deestructively, either run it from a throwaway username or change the key from "" to a node name.
[Answer]
# C#, 157 Bytes
**Set, 74 Bytes:**
```
class P{static void Main(string[]a){System.IO.File.WriteAllLines("a",a);}}
```
**Get, 83 Bytes:**
```
class P{static void Main(){System.Console.Write(System.IO.File.ReadAllText("a"));}}
```
-1 Bytes thanks to VisualMelon  
-2 Bytes thanks to LiefdeWen
[Answer]
# Perl 5, 48 26 23 bytes
### Write, 20+1(-n) bytes
*-3 bytes thanks to mob*
```
open f,">>f";print f
```
I'm actually not certain about this one points-wise, but it meets the criteria. For past entries, only the cli options were counted, so that's what I'm going with.
### Read, 0+2 bytes
```
perl -pe "" f
```
[Answer]
# Sed, 2+2 bytes:
Stores to file `f`:
```
wf
```
Reads from file `f`:
```
rf
```
[Try a demo online!](https://tio.run/##LctBCoAgEEDRfaf4EOS@A3QXUSdtoeBMuOnuRtDqrV70mudMITecR62XejoeNEWGLB9dZvCGcGw7rFy3GtbQ3AaW078YXikVmS8)
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/Attache), 23 + 16 = 39 bytes
Simply writes STDIN to file `A`, then reads file `A`.
`store.@`:
```
$A&FileWrite!AllInput[]
```
`retrieve.@`:
```
Echo!FileRead!$A
```
## Testing
```
C:\Users\conorob\Programming\attache (master -> origin)
λ echo testing | attache store.@
C:\Users\conorob\Programming\attache (master -> origin)
λ attache retrieve.@
testing
```
[Answer]
# Lua, 57 53 51 bytes
**Store, 27 bytes**
```
io.open("x","w"):write(...)
```
**Retrieve, 24 bytes**
```
print(io.open"x":read())
```
[Answer]
**RUBY**
**Store** *(24 bytes)*
```
File.write('a', ARGV[0])
```
**Retrieve** *(16 bytes)*
```
p File.read('a')
```
[Answer]
# C (Unix/GNU), 23+23 = 46 bytes
## Store, ~~27~~23 bytes
```
main(){system("dd>f");}
```
## Retrieve, ~~27~~23 bytes
```
main(){system("dd<f");}
```
This basically wraps [jofel's answer](https://codegolf.stackexchange.com/a/168074/63856) into a C program.
Note: The `dd` commands outputs some statistics to `stderr`, so you will see some additional output when you naively run it in the shell. However, since the challenge only says that the stored string must be presented on `stdout`, not `stderr`, I take it that it is allowed to have additional output on `stderr`... Anyway, suppressing `stderr` output is as easy as replacing `dd` with `cat`, increasing the byte counts of the two programs by one, each.
[Answer]
# PHP, 26+1 + 21 = 48 bytes
Store.php:
```
<?fputs(fopen(s,w),$argn);
```
Run with `echo <input> | php -nF Store.php`.
Retrieve.php:
```
<?=fgets(fopen(s,r));
```
Run with `php -n Retrieve.php`.
[Answer]
# [C (gcc)](https://gcc.gnu.org), ~~77~~ 67 + 25 = 92 bytes
Compiles with only a few warnings on my gcc.
**store.c**
```
#include<stdio.h>
main(int c,char**v){fputs(v[1],fopen("f","w"));}
```
Can probably golf out the include, but I couldn't figure out how.
Segfaults if you don't pass it anything, but whatever.
Peter Cordes: -1
**read.c**
```
main(){system("cat f");}
```
]