text:
Stay away from zero
Task
Given a non-negative integer n, output 1 if n is 0, and output the value of n otherwise.
Input
A non-negative integer.

If you would like to accept the string as input, the string would match the following regex: /^(0|[1-9][0-9]*)$/, i.e. it must not have any leading zeroes, except when it is 0.
If you accept a real integer as input, you may assume that the integer is within the handling capability of the language.

Output
A positive integer, specified above. Leading zeroes are not allowed. Your output should match the regex /^[1-9][0-9]*$/.
Testcases
input output
    0      1
    1      1
    2      2
    3      3
    4      4
    5      5
    6      6
    7      7

Scoring
This is code-golf, so shortest answer in bytes wins.
Standard loopholes apply.

You should probably put a link to the TNB CMC, since that's where this challenge came from.

Does the answer need to be a full function, or can it be the body?

@CalebKleveter The default rule in PPCG is that the answer is either a function or a full program, but not snippets.

Can we print the output with a leading zero?

@MDXF yes, you can.

@LeakyNun the question text says "leading zeros are not allowed" but your comment contradicts this

I don't know if that can be written this way but I did it anyway, legal or not: ∃E∃F∃f:E↦F,∀x∃y,x∈E∧y∈F→(x=0→y=S(x))∧(¬x=0→y=x).

C (gcc), 14 13 bytes
f(n){n=n?:1;}

Thanks to @betseg for reminding me of the n?:1 trick in the comments of the other C answer!
Try it online!
C, 17 bytes
f(n){return!n+n;}

Try it online!
C, 16 bytes
#define f(n)!n+n

Try it online!

https://tio.run/nexus/c-gcc#@6@ckpqWmZeqkKaRp6mYp533PzOvRCE3MTNPQ5OrmksBCAqKgEJpGkqqKUo6CsZaaRqmmprWXLX/AQ hmmm...

@betseg That's because it's a macro. The compiler sees it as 3*!n+n which equals 3*0+5.

I know, but I think you should be able to apply arithmetic operators to the "return" values directly, that's why it's common practice to put parentheses around macros. I just don't think that the macro is valid.

@betseg I don't think that's a requirement in code golf. I've never seen a code golf answer with C macros do that.

I wonder how is this code can even be compiled. Please explain.

@hucancode See the TIO links. You need to add a main from which the function/macro f is called. A solution doesn't need to be a full program by default. The gcc-specific version may or may not compile on another compiler, and it may or may not run correctly when compiled on another compiler.

@hucancode as for ?:, omitting middle term is allowed by some compilers. E.g. -std=gnu89 passed to GCC (which is its default mode) will compile this without errors.

Does f(n){n+=!n;}not work?

@l4m2 No, it doesn't. At least on TIO.

Japt, 2 bytes
ª1

Try it online!
Explanation
ª is a shortcut for JS's || operator. Japt has implicit input, so this program calculates input||1, and the result is implicitly sent to STDOUT.
w1 would work as well, taking the maximum of the input and 1.

JavaScript (ES6), 7 bytes
n=>n||1

Alternative: n=>n+!n (At least I think)

@SIGSEGV Yes, that would work indeed. (That could also be n|!n, although this one is limited to a 31-bit quantity.)

this can be simplified to n||1.  Only thing that evaluates to false is 0.

@ansiart If your point is that n=>n||1 could be simplified to n||1, then no. Acceptable answers are either full programs or functions. n=>do_something_with(n) is an arrow function in ES6 syntax.

Why not n|1...? It makes sure the 1s place is always 1, making it not possible for it to be 0

@StanStrum We're required to return the original value of n if it's not zero. A bitwise OR would modify n whenever the least significant bit is not set (e.g. (4|1) === 5).

Haskell, 5 bytes
max 1

Usage example: (max 1) 0 -> 1.
Nothing much to explain.

Pyth, 2 bytes
+!

Try it online
Explanation
+!
 !Q    1 if (implicit) input is 0, 0 otherwise.
+  Q   Add the (implicit) input.

Alice, 7 bytes
1/s
o@i

Try it online!
Explanation
1   Push 1. Irrelevant.
/   Reflect to SE. Switch to Ordinal.
i   Read all input as a string.
    Reflect off bottom right corner. Move back NW.
/   Reflect to W. Switch to Cardinal.
1   Push 1.
    IP wraps around to last column.
s   Sort swap: implicitly convert the input to an integer. Then, if the top stack
    element is less than the one below, the two are swapped. It basically computes
    min and max of two values at the same time, with max on top.
/   Reflect to NW. Switch to Ordinal.
    Immediately reflect off the top boundary. Move SW.
o   Implicitly convert the result to a string and print it.
    Reflect off bottom left corner. Move back NE.
/   Reflect to S. Switch to Cardinal.
@   Terminate the program.

V, 4 bytes
é0À

Try it online!
Abuses an non-preferred but expected behavior, so I can't really call it a bug. Explanation:
In Vim, commands accept a count. For example, <C-a> will increment a number, but 7<C-a> will increment a number by 7. However, you can't use 0 as a count, because

0 is already a command (go the first column), and
In the context of a text editor, it rarely makes sense to request that a command be run 0 times.

This is fine for a text editor, but usually obnoxious for a golfing language, so V overwrites some commands so that 0 is a valid count. For example, é, ñ, Ä, and some others. However, since <C-a> is a builtin vim command, it is not overwritten, so running this with a positive input gives:
N       " N times:
 <C-a>  "   Increment

But running with 0 as input gives:
0       " Go to column one
 <C-a>  " Increment

Full explanation:
é0          " Insert a 0
  À         " Arg1 or 1 times:
   <C-a>    " Increment

The one time that 0 not being a count is useful.  I didn't even consider it at first because I've avoided it so many times

J, 2 bytes
^*

Try it online!
^ [argument] raised to the power of
* the sign of the argument (0 if 0 else 1)
Because 1=0^0 in J.

Retina, 4 bytes
^0
1

Try it online!
If the input starts with a zero, replace that with a 1. (Works because the input is guaranteed to have no leading zeros for non-zero values.)

R, 13 bytes
max(1,scan())

reads n from stdin. With pmax, it can read in a list and return the appropriate value for each element in the list for +1 byte.
try it online!
I should note that there is another fine R solution in 13 bytes by Sven Hohenstein which allows for yet another 13 byte solution of
(n=scan())+!n

which makes me wonder if that's the lower limit for R.

Another 13 bytes solution using pryr: pryr::f(n+!n). Can't find anything smaller...

dc, 7
?d0r^+p

Relies on the fact that dc evaluates 00 to 1, but 0n to 0 for all other n.
Try it online.

brainfuck, 8 bytes
+>,[>]<.

Try it online!

The paths to the Brainfuck compiler have changed, here is a fixed TIO demo

Cubix, 6 bytes
OI!1L@

Somehow managed to fit it on a unit cube... Test it online!
Explanation
Before being run, the code is arranged as a cube net:
  O
I ! 1 L
  @

The IP (instruction pointer) is then placed on the far-left face (I), facing to the right. The instructions run from there are:
I  Input a number from STDIN and push it to the stack.
!  If the top number is non-zero, skip the next instruction.
1  Push a 1 (only if the input was zero).
L  Turn left. The IP is now on the top face facing the !.
O  Output the top item as a number.

The IP then hits ! again, skipping the @ on the bottom face. This is not helpful, as we need to hit the @ to end the program. The IP hits the L again and goes through the middle line in reverse (L1!I) before ending up on the L one more time, which finally turns the IP onto @.

V, 5 bytes
ç^0/<C-a>

Where <C-a> is 0x01.
Try it online!
Explanation
ç                   " On every line
 ^0/                " that begins with a zero do:
    <C-a>           " Increment the number on that line

A little competition :)

Oasis, 2 bytes
Uses the following formula: a(0) = 1, a(n) = n
n1

Try it online!

Nice. My approach was >V.

@LeakyNun Oh nice!

R 20 16 bytes
pryr::f(n+(n<1))

Welcome to PPCG!

Thanks @MartinEnder. I am already learn some tricks of the trade.

Brain-Flak, 22, 10 bytes
({{}}[]{})

Try it online!
Explanation:
If the input is non-zero, then {{}} will pop everything off the stack and evaluate to the input. If it is zero, nothing will be popped, and it will evaluate to zero. So running ({{}}) gives
Non-zero:
n

Zero:
0
0

At this point, we'll add the height of the stack (0 for non-zero, 1 for zero) and pop one more value off the stack. (since the stack is padded with an infinite number of 0's, this will pop either the top 0 or an extra 0)

Nice job, but not the shortest solution: https://codegolf.stackexchange.com/a/118520/31203

APL (Dyalog), 3 bytes
1∘⌈

Try it online!
This takes the ceil of the argument and 1.

Jelly, 2 bytes
+¬

Try it online!
Pretty much exactly my Pyth answer, but it's my first Jelly program.

Brachylog, 3 bytes
∅1|

Try it online!
Explanation
If we add the implicit ? (Input) and . (Output), we have:
?∅          Input is empty (that is, [] or "" or 0 or 0.0)
  1.        Output = 1
    |       Else
     ?.     Input = Output

Hexagony, 7 6 bytes
)?<@.!

Expanded:
 ) ?
< @ .
 ! .

Try it online!
Saved 1 byte thanks to Martin!
If the number is nonzero print it, otherwise add one to it and print that instead.

Python, 15 bytes
lambda n:n or 1

Why not just n or 1, 6 bytes?

Because that's just a snippet, while we usually answer with complete programs or functions. I'm not sure if this is stated explicitly in some rules somewhere, but at least that's the de facto standard.

Quoting trichoplax: The rules are not terribly clear. I think we have a consensus on meta that REPLs count, but as a separate language, which would allow snippets in many cases, but snippets are not permitted according to this meta post -> https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422

Alternative with the same 15-bytes byte-count: lambda n:n|1>>n

One more notable 15 byter is lambda n:1-2%~n, other than that there are some variations of Kevin's function (n+0**n, 1>>n^n, ...)

MarioLANG, 12 bytes
;
=[
:<+
 =:

Try it online!
How it works
Mario starts in the top left, initially walking right. He reads an int from input (;) and stores it in the current memory cell. Then he falls off the ground (=), hitting [, which makes him ignore the next command if the current cell is 0.
If the cell is not 0, he'll start walking left (<), output the current cell as an int (:), and fall to his death (end of program).
If the cell is 0, he ignores the command to turn left, and keeps walking right. He increments the current cell (+), outputs it, and falls to his death.

Mathematica, 9 8 bytes
Per Martin Ender:
#~Max~1&

First idea:
#/. 0->1&

Pure function with replaces 0 with 1. The space is necessary or it thinks we are dividing by .0.

TI-BASIC, 7 bytes
:Prompt X
:X+not(X

Alternatively,
TI-BASIC, 7 bytes
:Prompt X
:max(X,1

Java 8, 10 bytes
i->i<1?1:i

Thanks to @LeakyNun for saving -1 byte

Didn't notice it's a non-negative integer

i==0 can be replaced by i<1

dc, 11 bytes
[1]sf?d0=fp

[1]sf stores a macro in register f which pushes 1 to the top of the stack,
? reads input,
d0=f runs macro f if input was 0, p prints the top of the stack.
Test:
$ dc -e "[1]sf?d0=fp" <<< 0
1
$ dc -e "[1]sf?d0=fp" <<< 1
1
$ dc -e "[1]sf?d0=fp" <<< 42
42

Excel, 10 Bytes
=A1+(A1=0)

This saves 4 Bytes over the obvious 'IF' statement solution, =IF(A1=0,1,A1).

And 1 byte less than the less obvious =A1+NOT(A1)

Perl 5, 6 + 2 bytes for the -l and -p flags
$_||=1

Takes input on separate lines from stdin. Runs with the flags -lp.

Arnold C, 303 bytes
IT'S SHOWTIME
HEY CHRISTMAS TREE i
YOU SET US UP 1
GET YOUR ASS TO MARS i
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
BECAUSE I'M GOING TO SAY PLEASE i
TALK TO THE HAND i
BULLSHIT
TALK TO THE HAND 1
YOU HAVE NO RESPECT FOR LOGIC
YOU HAVE BEEN TERMINATED

Trying to explain it:
IT'S SHOWTIME //main()
HEY CHRISTMAS TREE i //int i
YOU SET US UP 1 //i = 1
GET YOUR ASS TO MARS i // ? compiler told me to add that
DO IT NOW // ? compiler told me to add that
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY // something related to reading from stdin
BECAUSE I'M GOING TO SAY PLEASE i // if(i)
TALK TO THE HAND i //print i
BULLSHIT //else
TALK TO THE HAND 1 //print 1
YOU HAVE NO RESPECT FOR LOGIC //endif
YOU HAVE BEEN TERMINATED //end main()

It even beats this answer!

R, 13 bytes
n=scan();n+!n

Here, scan is used to read the input value n. The negation of n (i.e., !n, 0 or 1) is added to n.

Braingolf, 8 bytes
!?_:1_;

Explanation:
 ?       If last element on stack > 0
!        Prevent if check from consuming last element on stack
  _      Pop last element on stack and print
   :     Else
    1    Add int literal 1 to end of stack
     _   Pop last element on stack and print
      ;  Prevent automatic pop of last element on stack

Is this your language?

Yup, literally got bored at work today and decided to make a language. As you can tell it's very WIP, this is one of the only challenges that it can do beyond simply printing a string

Congratulations on your new language!

GCC command line, 9 bytes
-Df(x)x?:

Try it online!
-D in GCC checks if the following content has an =; if not, it add the code
#define <followed_content> 1

which in this case turns into
#define f(x)x?: 1

On meta I gave a common solution but here I give a pointed one

Can the downvoter leave a comment? I find this very creative.

Sinclair ZX81/Timex TS1000/1500 BASIC ~19 tokenized BASIC bytes
 1 INPUT A
 2 PRINT A+NOT A

This is a more efficient solution than the one below; essentially it takes the NOT value of A (which would be zero in all cases but zero) and adds that to the value of A.
Old answer:
Sinclair ZX81/Timex TS1000/1500 BASIC, ~31 tokenized BASIC bytes
 1 INPUT A
 2 IF NOT A THEN LET A=NOT A
 3 PRINT A

This takes a numeric input from the user and will display 1 if zero is entered by making A NOT A; otherwise it does nothing and displays the numeric value.

Ruby, 11 bytes
->n{n|1>>n}

Forte, 25 bytes
9LET0=1:INPUT2:PRINT2:END

Try it online!
Explanation
Clearly, the best way to approach this challenge is to define 0 to be 1. Problem solved.
Seriously. That's exactly what this program does.
9          Line number (doesn't matter as long as it's not 0 or 2)
 LET 0=1   Redefine 0 to be 1; all future occurrences of 0 will evaluate as 1
 INPUT 2   Redefine 2 to be a number read from input; all future occurrences of 2 will
           evaluate as the input number, though of course if that number was 0 it
           actually evaluates as 1
 PRINT 2   Print that number
 END       End the program

Taxi, 517 bytes
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 1 l 2 r.Pickup a passenger going to Addition Alley.Pickup a passenger going to Knots Landing.Go to Knots Landing:n 2 r 2 r 1 l.Pickup a passenger going to Addition Alley.Go to Addition Alley:w 1 r 1 l 2 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:n 1 r 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.

Formatted for humans:
Go to Post Office:w 1 l 1 r 1 l.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery:s 1 l 1 r.
Pickup a passenger going to Cyclone.
Go to Cyclone:n 1 l 1 l 2 r.
Pickup a passenger going to Addition Alley.
Pickup a passenger going to Knots Landing.
Go to Knots Landing:n 2 r 2 r 1 l.
Pickup a passenger going to Addition Alley.
Go to Addition Alley:w 1 r 1 l 2 l.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery:n 1 r 1 r.
Pickup a passenger going to Post Office.
Go to Post Office:n 1 l 1 r.

The key location is Knots Landing which performs the NOT operation so 0 returns 1 and all other numbers return 0. Now, you can go to Addition Alley to add the result from Knots Landing to the original input.

x86-64 Assembly, 10 9 bytes
Following the standard System V AMD64 calling convention, this function accepts a 32-bit unsigned integer parameter via the EDI register, and returns the result via the EAX register:
89 F8  |     mov   eax, edi    ; move parameter from EDI to EAX
85 C0  |     test  eax, eax    ; test input and set flags
75 01  |     jnz   Finished    ; if input is non-zero, then jump to end
FF 40  |     inc   eax         ; otherwise, input is 0, so increment it to 1
       |  Finished:
C3     |     ret               ; return, leaving result in EAX

x86-32 Assembly, 8 bytes
We could also write this as 32-bit code, since we're only dealing with 32-bit values.
The nice thing about this is that the INC instruction becomes only 1 byte in length. (In 32-bit mode, inc eax can be encoded simply as 40. In 64-bit mode, 40 is interpreted as a REX prefix, so the leading FF is needed. See Intel's documentation for this instruction.)
The caveat is that most 32-bit calling conventions pass parameters on the stack, rather than in registers, and loading a value from the stack (memory) takes many more bytes. If we can be allowed a __fastcall-style calling convention that passes parameters in registers (supported by virtually all C compilers, so not really cheating, just a bit less standard), then the integer parameter is passed in ECX and we get the following code, for a total of 8 bytes:
89 C8  |     mov  eax, ecx
85 C0  |     test eax, eax
75 01  |     jnz  Finished
40     |     inc  eax
       |  Finished:
C3     |     ret

Welcome to PPCG!

xchg eax, edi is only 1 byte and is fine since you don't need to keep a copy of the value.  Or use a calling convention like GCC's regparm (-mregparm=3) that passes the first arg in EAX already.  Tips for golfing in x86/x64 machine code

Or following an ARM machine-code answer's idea, mov eax, edi / neg edi (setting CF for any non-zero input) / sbb eax, -1 to add 1 or 0 (-(CF + -1)).  Unfortunately no shorter unless we can use sbb al, -1 (2 bytes)

Thanks, @Peter, for the review. I wrote this answer back before I knew it was legitimate to adopt custom calling conventions in assembly answers. I probably won't update it myself at this point; feel free to do so without stepping on my toes. Or post a separate answer.

There's already a quite clever 5-byte x86 answer with the function entry point in the middle of a block, using jecxz to run an inc ecx, taking full advantage of fastcall and of 1-byte xchg

x86 opcode, 6 5 bytes
       41                         INC     ECX
entry: E3 FD                      JECXZ   SHORT $-1
       91                         XCHG    EAX,ECX
       C3                         RETN

ECX -> EAX

You'll need to add a length in bytes, so other users can tell how long it is. Generally assembly or byte/op-code languages are measured in the size of the instructions the source represents.

fixed. forgot.

Damn, I just came up with E3 01 49 41 C3.

@2x-1 yeah if returning in ECX it can be 1B shorter

Java 8, 9 bytes
n->n|1>>n

Try it online.
C# .NET, 9 bytes
n=>n|1>>n

Try it online.
Different approach (and 1 byte shorter) than the existing Java/C# .NET answers. (Also works with negative inputs.)
Explanation:
i->       // Method with integer as both parameter and return-type
  i|      //  Return the input bit-wise OR-ed with:
    1>>i  //  1 bit-wise right-shifted by the input

1>>i will be 1 when the input is 0, and 0 for every other input.
0|1 for input 0 will therefore result in 1, and n|0 for every other input will therefore result in n.

See? You're getting better at bitwise operations ;-)

These two are also polyglots with Kotlin, Scala, and a ton of other languages :)

Zsh, 13 bytes
<<<$[$1?$1:1]

Try it online!
Bash, 15 bytes
echo $[$1?$1:1]

Try it online!
Dash (or other POSIX-compliant shell), 17 bytes
echo $(($1?$1:1))

Try it online!

Binary Lambda Calculus, 2.125 Bytes
00010110 00110001 0

Translation into lambda calculus:
\n. n (\x. n) (\x. x)

Labyrinth, 6 bytes
?"1
@!

Try it online!
?   Take number input and push it
"   No-op, but a 3-way junction:
    If top is 0, go straight
1     Convert the 0 to 1 and bounce off the dead end
"     Enter the junction again, turn right (reflected to south)
!@    Pop and print as number, turn around the corner and halt

    Otherwise, top is positive; turn right
!@    Pop and print as number and halt

Vyxal, 2 bytes
¬+

Straightforward answer:
¬  # nots the input (x == 0 ? 1 : 0)
+  # adds it to the input

Try it Online!

Lolwho.Cares, 62 bytes
*2*+21*1*+21010,**>*2+00210`v
0 ^02210012+*1*<  ^<0210002<<
321

Old version:
*2*+210*1*+210101,**>*2+00210`v
0 ^ 102210012+*1*<  ^<0210002<<
253

The last line isn't code; it's the input number.
Online interpreter: https://valthe.scheffers.net/testing/lolwhocares

Welcome to Code Golf, and nice first answer! Thanks for linking to an interpreter too! Lolwho.cares looks like an interesting fungeoid (if it is a fungeoid).

I looked at the definition, it's probably a fungoid.

JavaScript (ES6), 8 bytes
Beaten to the shortest solution (as usual!), so here's an alternative.
n=>n?n:1

Try It

f=
n=>n?n:1
console.log(f(0))
console.log(f(1))
console.log(f(8888))

PHP, 11 Bytes
<?=$argn?:1;

Online Version

Binary-Encoded Golfical, 12 bytes
This binary encoding can be converted back to the standard graphical representation using the encoder provided in the Golfical github repo, or run directly using the interpreter by adding the -x flag.
Hexdump of binary encoding:
00 40 02 15 17 14 00 01 23 1D 17 14

Original image:

Magnified 120x, with color labels:

Jelly, 2 bytes
o1

Try it online!
An alternative to the other Jelly solution. o provides a default value for a zero/empty argument; in this case, we default it to 1.

And another alternative is »1

Now you're making me wonder if it's possible in 1 byte; I doubt it, but you have to wonder. The closest I've got is ḃ, which outputs the number itself for all nonzero numbers, and nothing if the input is 0.

Yeah, another close one is m which yields [0,0] for 0 and n for n.

Perl 5, 10 +1 byte for -p flag = 11 bytes
$_=$_*1||1

Run with -p flag.

$_=$_||1 and thus $_||=1 is sufficient

Also, the other answers don't include the costs of outputting the result, so no need to count -p.

You are mistaken. Zero is false, whether stored as a number or as a string. However, if you populate $_ using echo 0 | perl -pe'...', you actually have "0\n", which is true. -l would take care of that.

@ikegami we consider here that requiring the input to be supplied without trailing newline is valid. (using echo -n ...  for instance). Regarding the cost of outputting the result, the rules on PPCG say that the result need to be either printed, or returned by a function (which is what does the answer you linked), or returned some other way (I don't remember all valid options). (so counting -p flag is mandatory)

Whirl, 38 bytes
01100011100011110011111100001000111100

Try it online!
Explanation:
01100     op.ccw, op.intio    Mem1 = STDIN
011100    math.ccw, math.=    If (Mem1 = 0) Then (Math.Val = 1) Else (Math.Val = 0)
0111100   op.cw, op.one       Op.Val=1
11111100  math.add            Math.Val = Math.Val + Mem1
00        op.one              Op.Val=1 (Cheapest way to loop back to the Math wheel)
100       math.store          Mem1 = Math.Val
0111100   op.ccw, op.intio    STDOUT = Mem1

k, 2 bytes
1|

Finds the maximum of 1 and whatever number is given.
Try it online!

C (gcc), 11 bytes
f(n){n?:1;}

Try it online

I tried it online with the provided link, and it outputs 0, 6.

It seems they've changed the gcc behavior recently. If you switch to tcc it still works.

Desmos, 10 bytes
Improvement suggested by Aiden Chow.
f(x)=0^x+x

Previous 13-byte solution:
f(x)=max(1,x)

Try it here

Desmos tips: you can have lists of integers like this.

10 bytes: f(x)=0^x+x. This works because 0^0 equals 1 in Desmos.

@AidenChow That's wild. Thanks for letting me know!

Yea, this 0^x+x trick is actually used to avoid log(0) situations when trying to count the digits of a number. floor(logn)+1 (where n is the number we are trying to get the digits of) works if n is positive, but the shortest way to cover the n=0 case seems to be floor(log(0^n+n))+1.

Keg, -hr 4 bytes
:0=+

Try it online!
Explanation
:     # Take 2 inputs
  0=  # Check whether the input is 0
      # (Yields 1 if the input is 0)
      # (Yields 0 otherwise)
    + # Add the input with this result and print it rawly
      # i.e. 0->1, 5->5

4 bytes: :0=+

The "HighlyRadioactive" interpreter flag.

GolfScript, 4 3* bytes
~1|

Try it Online!
*thanks to user a'_'

Using a bitwise or would still work.

convey, 6 bytes
{+1
}.

Try it online!
Outputs the max of the input and 1. I think this is the optimal answer, since to use any binary function, there must be a second line with at least two characters.
You can also do the more traditional x+!x for 8 bytes.

Python 3, 16 bytes
lambda x:x+(x<1)

Try it online!
Thanks caird coinheringaahing for saving an extra byte!

Welcome to CGCC. I think you can test for x<1 to save a byte: Try it online!

AWK, 8 bytes
$0||$0=1

Try it online!
Slightly different approach to this answer, reducing 2 bytes.
$0||$0=1      Basically, an OR logic gate. Right part is not considered if the left one is true.
              $0 is the input, parsed as true if different from zero, printing the input.
              If input is zero, $0 is set to 1 (right part).
              As $0 becomes 1, it is parsed true, and then the input is printed.

RegEx, 3 Bytes
Match pattern (2 Bytes):
^0

Substitution pattern (1 Byte):
1

Takes input as string without any leading zeros and substitutes it for 1 if it is 0.
Try on Regex101

C, 27 Bytes
f(n){printf("%d\n",n?n:1);}

You don't have to output, you can return that too. Also in GCC, you can do n?:1.

@betseg thanks I like that n?:1 trick

In this particular case you can also use n||1 which is compiler-independent, or !n+n as seen in several other answers. :)

MATL, 3 bytes
t~+

Try it online!
Explanation
t   % Implicit inupt. Duplicate
~   % Logical negation. Converts zero to 1, and nonzero to 0
+   % Add. Implicit display

PowerShell, 24 22 17 Bytes
blatantly stolen from here
!($a=$args[0])+$a

Explanation
Invert the value, returning 0 for non-0 numbers, and 1 for 0, then add the intitial to it.

this makes it basically 1/0 + value, so for 0 the first value is 1, any other numbers it's 0.

examples:
# !0+0 = 1
# !1+1 = 1
# !9+9 = 9

Could you instead use !$a as your index check? You wouldn't be able to set $a in your current manner, but I think something like this would work? Try it online!

@Sinusoid that worked perfectly for -2, but turns out the C answer was a bit ahead of us both, didn't think of the method at all.

That is certainly interesting! I will need to keep this method in mind :P

///, 11 bytes
/#0/1//#//#

Try it online!
Since there is no other way to take input in ///, hard-code the input after the last #.
Works by replacing #0 with 1. Then it removes any remaining #. The # makes sure that an input of 10 would not output 11.
Version that takes input in Itflabtijtslwi:
GGaGGGGbGG/#0/1//#//#ab

Try it online!

For your second program, the input has to be less than 100. Maybe you should mention this?

@boboquack Yes.

Ohm, 11 6 bytes
ö?┼¿1;

Uses CP-437 character encoding. Run with -c flag
Explanation:
ö?┼¿1;
       ■print(                                            )
  ┼    ■      first_input()
 ?   ; ■                   if(                     )
ö      ■                      int(first_input())!=0
   ¿   ■                                            else
    1  ■                                                 1

Here's a list of things you could fix: (1) if you just say this is in CP437 (no need for the -c flag), you only need to count characters. (2) Ohm is written in Ruby, so 0 is a truthy value. However, there is a built-in x != 0 component (ö). (3) There is implicit printing, so , is not necessary. (4) Ohm is on TIO now, so it'd help if you added a link to it.

FYI, feel free to ping me in chat if you have any questions about/feature reqs for the language!

Again, there's no need for the -c flag. That's just for reading files; it's not necessary for PPCG submissions. Just say it's in CP437 and you're good.

AWK, 10 bytes
!$0{$0=1}1

Try it online!
Example Usage:
awk '!$0{$0=1}1' <<< 978

Clojure, 12 bytes
#(get[1]% %)

The get function takes an associative data structure, a key, and a default value. Vectors are associative using sequential position as the key. So, [1] is a vector with the value 1 at position 0. If get is called with parameter 0 it will return 1, otherwise no other keys exist in the vector so it returns the default value of the parameter.

Universal lambda, 3 bytes (17 bits)
00010110001100010

It is a function and not a complete program. I think it should work, but didn't actually test it because it doesn't seem easy to do so. It means λx.x(λy.x)(λy.y).
Lazy K, 10 bytes
S(SIK)(KI)

It is a function, untested, too.

05AB1E, 7 bytes
D0›i,}1

Try it online!
D           //push two inputs (implicit)
 0›         //push input greater than zero
   i        //if true
    ,}      //print input
      1     //push 1. printing is implicit if there is no previous output

I'm sure there is a much shorter way to do this...

Me too, but I can't actually work 05ab1e, so...

You could save 3 bytes with D_i1.

Or in two bytes: $M.

Brain-Flak, 14 bytes
((){{}[()]}{})

Try it online!
Just computes: 1 + (n ? n-1 : 0).

Challenge accepted :)

Java, 29 bytes
Try Online
int f(int n){return n<1?1:n;}

Starry, 14 bytes
, +'      +*`.

Try it online!
Explanation
Space shown as _ .
,           Read integer and push to stack
_+          Duplicate
'           If non-zero jump to branch label
______+     Push 1
*           Add
`           Mark branch label
.           Print as a number

My first Starry answer

Japt, 2 bytes
w1

Try it online!
Returns the larger of 1 and the input.

Clojure, 10  bytes
#(max 1%)

Not much to explain.

I think you can shorten this to #(max 1%) (9 bytes). https://tio.run/nexus/clojure#0@DKSS1RiM7Lr0otyv@vrJGbWKFgqKr5P5ZLo6AoM68kJ09BAyKpYKCpiSloiE3QCCio@R8A

Chip, 20 18 bytes
eaABb
*`\\-!
fcCDd

Try it online!
How?
 aABb
            Copy the low 4 bits from input to output
 cCDd

e
*           Set the higher bits of output, so that the values are ASCII digits
f

eaABb
*           Replicate any ASCII digits on input to output
fcCDd

            -
     !      Produce a high signal, but only during the first byte
            -

 aAB
 `\\-*      Set the lowest bit of output, if the four low bits of input are unset
  CD

 aAB        Set the lowest bit of output, if the four low bits
 `\\-!      of input are unset, and only on the first byte
  CD

Aceto, 9 8 bytes
rid0=`1p

read an integer and duplicate it, then push 0. Are they =? Then (`) push a 1. print the top element.

Julia, 13 12 bytes
f(n)=n<1?1:n

Unfortunately, Julia doesn't do implicit casting from int to bool, so I have to burn an entire 3 characters just to do a comparison to zero. Saved one byte by safely assuming the number isn't negative. Still too verbose for my taste, though.

You can post the answer as an anonymous function and save 2 bytes, n->n<1?1:n Try it online!

Python 21 Bytes
int(max('1',input()))

Takes input from REPL environment

C++, 22 bytes
[](int i){return!i+i;}

Try it online

Excel, 10 bytes
=MAX(A1,1)

Here's another 10-byte solution: link

C#, 11 bytes
n=>n<1?1:n;

This compiles to a Func<int, int>.

SpecBAS - 20 bytes
1 INPUT n: ?n OR n=0

? is shorthand for PRINT

Groovy, 7 bytes
{it?:1}

Elvis operator; if true, return self, else return 1. Only false integer value auto-unboxxed to false in Groovy is 0. Thusly, exactly the spec.

SNOBOL4 (CSNOBOL4), 49 47 36 bytes
	N =INPUT
	N =EQ(N) 1
	OUTPUT =N
END

Try it online!

Symbolic Python, 11 bytes
_+=_==(_>_)

Try it online!
_+=           # Output = Input +
   _==(_>_)                       Input == 0

Google Sheets, 9 Bytes
Anonymous worksheet function that takes input from range A1 and outputs to the calling cell
=Max(1,A1

This look very cool mate :)

Bash, 43 bytes
if [ $1 -eq 0 ];then echo 1;else echo $1;fi

Julia 0.6, 10 bytes
x->x<1?1:x

Try it online!

also 10 bytes: x->x+(x<1)

BitCycle -u, 8 7 4 bytes
-1 byte thanks to Jo King
?/1!

Try it here!
How it works
The -u flag converts decimal inputs to unary and unary outputs to decimal. Inputs emerge from the source ? moving east.

For positive numbers, the splitter / sends one bit northward, off the playfield, while the other bits continue straight through. The 1 bit that started on the playfield, plus all but one of the input bits, land in the sink !, which therefore outputs the same number that was input (or more specifically, n-1+1).
For zero, there are no input bits, the splitter does nothing, and the 1 bit that started on the playfield lands in the sink and outputs 1.

Acc!!, 75 72 41 bytes
N
_+48/_
Count i while _/48 {
Write _
N
}

Try it online!
Explanation
N reads a character and stores its ASCII code into the accumulator.
Since the first character will always be a digit, the accumulator's value is between 48 and 57. If the accumulator is exactly 48, 48/_ will be 1; otherwise, it will be 0. We add this value to the accumulator. In effect: if the first digit of the number was 0, we consider it as 1; otherwise, we leave it unchanged.
We then enter a loop that writes the accumulator out as a character, reads another character into the accumulator, and loops until the ASCII code we read is less than 48 (probably 10 for newline). Then we halt.

><>, 6 bytes
:?!1n;

Could have been 1 byte shorter if ? had the opposite conditional behaviour.
:?       check if nonzero, then either
  !      a) skip the next instruction or
   1     b) push 1 to the stack
    n    print
     ;   terminate

Take the input via the -v flag instead. It saves a byte, and it's less suspect than using the char code of a character

5 bytes

Terminating with an error wasn't legal when I used to be around.

JavaScript (Node.js), 10 bytes
n=>n&&n||1

Try it online!
here is one more
JavaScript (Node.js), 8 bytes
n=>n?n:1

Try it online!
and lastly
JavaScript (Node.js), 7 bytes
n=>n||1

Try it online!

From the BASIC answer n=>n+!n (also 7 bytes) should also work ;)

Sed, 7 bytes
Input in any number base, without any leading zeros.  (It doesn't even need to be a consistent base!)
s/^0/1/

0 is the only number that begins with 0; just change that to 1.

Triangular, 6 bytes
$,w%1<

Try it online!
Ungolfed:
  $
 , w
% 1 <
-----------------------
$              Read from input as an integer
 w,            Change directions if ToS != 0 (will go straight to print)
   <1          Push 1
     %         Print ToS as an integer

W, 2 bytes
1|

Explanation
a   # Take an input
 1| # Logical or with 1
    # If n is 0, this evaluates to 1
    # It evaluates to 0 otherwise

naz, 70 bytes
2a2x1v4a8m2x2v1x1f1r3x2v2e1o3f0x1x2f1a1o0x1x3f1r3x1v4e1o3f0x1x4f0a0x1f

Works for any input integer, provided it's passed as a file terminated with the control character STX (U+0002).
Explanation (with 0x commands removed)
2a2x1v           # Set variable 1 equal to 2
4a8m2x2v         # Set variable 2 equal to 48 ("0")
1x1f1r3x2v2e1o3f # Function 1
                 # Read a byte of input
                 # Jump to function 2 if it equals variable 2
                 # Otherwise, output it and jump to function 3
1x2f1a1o         # Function 2
                 # Add 1 to the register and output
1x3f1r3x1v4e1o3f # Function 3
                 # Read a byte of input
                 # Jump to function 4 if it equals variable 1
                 # Otherwise, output it and jump back to the start of function 3
1x4f0a           # Function 4
                 # Add 0 to the register
1f               # Call function 1

Flurry, 12 bytes
({})[(){}]{}

Run example
$ ./flurry -nin -c "({})[(){}]{}" 0
1
$ ./flurry -nin -c "({})[(){}]{}" 1
1
$ ./flurry -nin -c "({})[(){}]{}" 2
2
$ ./flurry -nin -c "({})[(){}]{}" 10
10

For single input n, computes n (K n) 1: apply "a constant function that returns n regardless of argument" n times to the number 1.
({})    Pop n and push n
[(){}]  Apply (K n); n is popped again from the stack
{}      Apply I (equivalent to number 1); popping from empty stack gives I

Reduction into SKI terms don't help much:
n (K n) 1
= I n (K n) 1
= S I K n 1
which translates into <>{{}}(){}{}

Rockstar, 24 bytes
listen to N
say N-0 or 1

Try it here (Code will need to be pasted in)

MathGolf, 2 bytes
┌+

Try it online.
Explanation:
┌   # Inverted boolean the (implicit) input-integer (1 if 0; 0 for any other integer)
 +  # Add this to the (implicit) input-integer
    # (after which the entire stack joined together is output implicitly as result)

ARM Thumb-2 machine code, 6 bytes
Machine code:
b900 3001 4770

Assembly:
        .syntax unified
        .arch armv6t2
        .thumb
        .globl no_zero
        .thumb_func
no_zero:
        // skip next insn if r0 != 0
        cbnz    r0, .Ldont_add_1
.Ladd_1:
        // increment r0
        adds    r0, #1
.Ldont_add_1:
        // Return
        bx      lr

It doesn't get much simpler than that.
Input is in r0, output is in r0, follows standard calling convention.
ARM Thumb-2 machine code, branch/IT-less, 8 bytes
Only works for non-negative numbers unlike the branching solution.
Machine code:
4241 f140 0000 4770

Assembly:
        .syntax unified
        .arch armv6t2
        .thumb
        .globl no_zero_branchless
        .thumb_func
no_zero_branchless:
        // Negate r0 into r1. We only care about
        // setting the flags here.
        negs    r1, r0
        // Add the carry flag to r0. (wide insn)
        adc     r0, r0, #0
        // Return
        bx      lr

Follows the same calling convention.
negs follows the same rules as subs for setting flags. So, if r0 was positive, the result would have a borrow, but if it was 0, it would not.
Then, we just add with carry against zero to add 1 if r0 was zero, or 0 if r0 was positive.
Yes, you read that correctly.
When subtracting, ARM clears the carry flag to indicate a borrow. It is counterintuitive and usually annoying when golfing.
But I decided to use this for a small challenge.
Unfortunately, adc doesn't have a narrow immediate form, so we either have to waste another register to set it to zero, or use a wide instruction.

BRASCA, 14 7 bytes
ig:0=+n

Try it online
-7 bytes by RezNesX
Explanation
<implicit input> - Push STDIN to stack
ig               - Convert numbers from ASCII to number, and concatenate the stack
  :0=            - If the number is zero (pushes 1)
     +n          - Add and print as number.

```

7 bytes: ig:0=+n

Pxem, 12 bytes (content).
Unprintable characters are escaped.
.c\001.y.s\001.d.a

Usage

Expects stack has only an item, as an argument.
Stack content: (n, xxx) to (n', xxx, n, xxx).

Usage example
Filename to be _.e.n, with your input from stdin.

Python 3, 19 bytes
lambda n:[n,1][n<1]

Try it online!

APOL, 8 bytes
¿(⧣ ⋔ 1)
Explanation
¿(   Returning if statement
  ⧣    Integer input (condition, 0 evaluates to false)
  ⋔    If item (returns the value of the condition, executed if true)
  1    A literal 1 (executed if false)
)
Implicit print

Vyxal, 3 bytes
¬[1

Try it Online!
Explanation:
# implict input
 ¬  # logical not
  [1  # 1 if truthy else the original input
# implict output

Aussie++, 60 bytes
THE HARD YAKKA FOR f IS(x)<YA RECKON x ==0?<BAIL 1;>BAIL x;>

All whitespace is mandatory. Tested in commit 9522366, where all numbers are truthy (see this issue), so I can't just say BAIL x ||1;.

Commodore BASIC (CBM/PET, VIC-20, Commodore C64, Commodore C16/+4) 19 BASIC tokens, 17 PETSCII characters with keyword abbreviations
0INPUTN:?N+-(N=.)

Very simple, in Commodore [early Microsoft] BASIC, if you do like PRINT X=Y it will return -1 if true, or 0 if false. A single equals is used for comparison and assignment, and the context is picked up by the interpreter.
We ask for a number with the INPUT keyword, which will enter a numeric value into the variable N. So we will then PRINT N plus a negative of the returned value of N=. with the . being a more performant replacement for 0 in this instance (a very trivial optimisation for such a short program). When N is 0, it adds --1, which just adds 1. When it is not zero, then we add -0 which is zero.

Thunno 2, 2 bytes
1|

Attempt This Online! Logical OR with 1.
Alternative:
1§

Attempt This Online! Maximum of input and 1.

Nekomata, 2 bytes
1M

Attempt This Online!
Max with 1.

R 4.1+, 8 bytes
\(n)n+!n

Attempt This Online!

CJam, 5 bytes
ri1e>

Try it online!
Explanation
ri   e# Read input as an integer
1    e# Push 1
e>   e# Maximum. Implictly display

Batch, 17 bytes
@cmd/cset/a%1+!%1

Math++, 3 bytes
?|1

("Body must be at least 30 characters")

https://chat.stackexchange.com/transcript/240?m=36422623#36422623

Microscript II, 4 bytes
1sN|

Rough translation:
x=1
push x
x=readnum()
x|=pop()

x is then printed implicitly at the end.

braingasm, 4 bytes
;z+:

; reads a number from stdin, z+ increments that number if it is 0, : prints.

QBIC, 11 8 bytes
?:-(a>1)

Thanks to @l4m2 for saving me some bytes!
Explanation:
?         PRINT
 :        an integer taken from the cmd line (and store it as 'a')
  -       minus
   (a<1)  -1 if 'a' is less than 1 (can only be 0) or 0 otherwise.
          This leaves any a to be a, but turns zeroes into 1 by double negative.

Old code, that didn't use the inline : yet:
:?(a>0)+a+1

Explanation
:       Get an int from the cmd line, a
?       PRINT
 (a>0)    if a is greater than 0, this is -1, else 0
 +a        yields 0 for 0 and a-1 for >0
 +1        makes 1's for 0 and a's for all other values

can it be a-(a<1)?

CJam, 5 bytes
ri1e|

Explanation:
ri    e# Read token and convert to integer
  1e| e# OR with 0

| is bitwise OR, so an input of 2 will result in an output of 3.

@Dennis That's true; edited.

Ruby, 12 bytes
->n{n<1?1:n}

Try it online!

Alternate version that reads directly from STDIN instead of being a function. Same number of bytes after counting the -p flag (11+1 = 12 bytes). Effectively a port of the Retina solution.
sub /^0/,?1

Try it online!

Nice, I wanted to post ->x{[x,1].max}, but your solution is 2 bytes shorter.

Tcl, 25
puts [expr $argv?$argv:1]

demo — How to use: In the green area, type
tclsh main.tcl $n

where $n is the input number. Do not press backspace, otherwise your browser can go back in history!

Beam, 40 bytes
This reads the input as a string as it doesn't have any other option.  Basically it checks if the first character is 0 by removing 48 from it.  If 0 increment and output as a number, otherwise output it as a number, then read the rest of the input outputting it as characters.
 r'''''>`----\
 :+n++(------/
/<:<
r@
\u

Try it online!

Befunge-98, 5 bytes
&:!+.

Try it Online! (Warning - will take 60 seconds per test because of how TIO treats &)
Explanation
&:       Push 2 copies of the input
  !      Logical not the 1st copy - i.e. push 1 if 0, push 0 otherwise
   +     Add them together - this results in +0 normally, but +1 in the case of 0
    .    Print that value
         Loops back around to the first command
&        Because there's no more input, the TIO interpreter stalls for a minute and ends.

Befunge-93 Variant, 6 bytes
It's trivial to implement Befunge-93 in a similar way, except we can't use the & to end the program this time. Thus, the code is 1 byte longer, for 6 bytes:
&:!+.@

Try it Online!

Clojure(Script), 10 bytes
#(max 1 %)

Silberjoder, 42 bytes

0+b1,-CB+b1:BC<. +iB-b1+CB-CA[+CA.,-CA]1

How it works:

0

The first three characters are all data and are not executed. They are a newline (10), a zero (48), and a DC3 (19).
+b1

Point b at the "0" character. Note that a is still pointing at the newline character.
,

Read the first character of input.
-CB

Subtract what b is pointing to (the "0") from the first digit.
+b1

Point b at the DC3 character, which has value 19
:BC

Jump to position 19+3=22 if the c is pointing to anything other than zero. This would happen if the first digit of the number was anything other than "0". Otherwise...
<.

Move c on top of the "1" at the end of the program and print it.
 +iB

b is still pointing at 19, so we add 19 to the instruction pointer, jumping to the "1" at the end of the program, causing the program to halt after one more cycle. (The extra space is ignored, but we need it there to position this instruction so that the instruction pointer jumps beyond the "]" at the end of the program. If we don't do this, we will enter the loop at the end, and print an extraneous semicolon whenever 0 is input.)
-b1

This is position 22, so we jump here whenever the number didn't start with "0". We move b back to point at the "0".
+CB

Add the 48 back to the first digit of the number, restoring it to its proper character value.
-CA

Subtract the newline from the digit.
[+CA.

If it's not zero, restore it to its original value and print it.
,-CA]

Repeat reading digits, comparing them with newline, and printing them until newline is seen.
1

Data. Ignored. Program halts.

Ruby, 13 bytes
->i{i==0?1:i}

Swift, 25 bytes
max(1, Int(readLine()!)!)

If you just have the body of a closure, then it is just 10 bytes:
max(1, $0)

Takes in standard input and then returns the max int, which would either be 1 or higher.

Charcoal, 4 bytes
Ｉ∨Ｎ¹

Try it online!
Explanation
Ｉ    Cast (number is casted to string)
 ∨Ｎ¹ input number logical-or 1

Groovy, 9 bytes
f={it?:1}

Inside a groovy script file you can run with "groovy -D n=0 ":
println System.properties.n?:1

As a closure:
f={it?:1}

1) "?:" is groovy's "elvis-operator"

One instance of where this is handy is for returning a 'sensible default' value if an expression resolves to false-ish

2) "it" refers to a single anonymous parameter the closure is called with
3) 0 evaluates to false in groovy-truth

JavaScript, 19 Bytes
(x)=>{return x?x:1}

Ungolefed, with example:
function f(n) {
  if(n)
    return n;
  else
    return 1;
}

f(0); // 1
f(1); // 1
f(2); // 2

I swear there's a golfier duplicate

Whoops :3 I'll search :D

T-SQL, 21 bytes
SELECT MAX(1,a)FROM t

SQL input is allowed via a pre-existing named table (table t with INT field a).

Excel VBA, 17 13 Bytes
Anonymous VBE Immediate function that takes input as expected type unsigned integer and then outputs to the VBE immediate window
?[Max(A1,1)]

Previous Version
?[If(A1,A1,1)]

Husk, 3 2 bytes
|1

Try it online!
Ungolfed/Explanation
    -- implicit input N
|   -- if N is truthy: N
 1  -- else (N==0): 1

Thanks @Zgarb for -1 byte!

Two bytes: |1

,,,, 2 bytes
1∨

Try it online!
,,, is on TIO now, so that's cool. Computes input or 1 (logical OR) and implicitly outputs the result.

Element, 8 bytes
_2:'!"+`

Try it online

Pushy, 4 bytes
&n+#

Try it online!
   #  \ print:
  +   \   input + ...
&n    \   not(input)

Rust, 27 bytes
|x:u64|if x==0{1}else{x};

Anonymous function, or lambda, taking input from x.
First time golfing with Rust, and i must say im quite impressed.

|x:u64|x.max(1)

Befunge, 6 Bytes
&:!+.@

Try it Online
& Gets input as number
  :! Duplicates and inverts
    +.@ Adds the inverted input to the original, prints and ends the program

Implicit, 7 bytes
$!{.

Try it online! Explanation:
$      read input
 !{    if falsy
   .   increment
       implicit output

J, 6 Bytes
(>.1:)

Standard solution: Return the max of 1 and the argument.
The parenthesis ensure it's evaluated as a monadic hook:
(>.1:) 0
0 >. (1: 0)    NB. Definition of a monadic hook.
0 >. 1         NB. 1: is a constant function, always returns 1.
1              NB. >. returns the max of its two arguments.

Clean, 9 bytes
?0=1
?n=n

Try it online!

tinylisp, 14 bytes
(q((n)(i n n 1

This is a lambda function. In order to be able to call it, you either need to give it a name using d or call it directly (which would require explicitly closing the parentheses before specifying the argument). Try it online!
The function takes one argument, n. If n is truthy (all positive integers), return n. Otherwise (zero), return 1.

Whitespace, 41 bytes
[S S S N
_Push_0][S N
S _Duplicate][T N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve][S N
S _Duplicate_input][N
T   S N
_If_0_jump_to_Label_0][T    N
S T _Print_as_integer][N
N
N
_Exit][N
S S N
_Create_Label_0][S S S T    N
_Push_1][T  N
S T Print_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Explanation in pseudo-code:
Integer i = STDIN as integer
If i == 0:
  Call function Label_0
Print i
Exit program

function Label_0:
  Print 1
  Exit implicitly with error: Exit not defined

Example runs:
Input: 0
Command    Explanation              Stack    Heap     STDIN    STDOUT    STDERR

SSSN       Push 0                   [0]
SNS        Duplicate top (0)        [0,0]
TNTT       Read STDIN as integer    [0]      {0:0}    0
TTT        Retrieve                 [0]      {0:0}
SNS        Duplicate top (0)        [0,0]    {0:0}
NTSN       If 0: Jump to Label_0    [0]      {0:0}
NSSN       Create Label_0           [0]      {0:0}
SSSTN      Push 1                   [0,1]    {0:0}
TNST       Print as integer         [0]      {0:0}             1
                                                                         error

Try it online (with raw spaces, tabs and new-lines only).
Stops with error: Exit not defined.
Example runs:
Input: 5
Command    Explanation              Stack    Heap     STDIN    STDOUT    STDERR

SSSN       Push 0                   [0]
SNS        Duplicate top (0)        [0,0]
TNTT       Read STDIN as integer    [0]      {0:5}    5
TTT        Retrieve                 [5]      {0:5}
SNS        Duplicate top (5)        [5,5]    {0:5}
NTSN       If 0: Jump to Label_0    [5]      {0:5}
TNST       Print as integer         []       {0:5}             5
NNN        Exit program             []       {0:5}

Try it online (with raw spaces, tabs and new-lines only).

Gol><>, 5 bytes
I:z+h

Try it online!
Given n, calculate n + !n, print as int and halt. Unfortunately Gol><> doesn't have implicit input option, so the bytes are the same as regular ><>.

05AB1E, 2 bytes
_+

Try it online or verify some more test cases.
2 bytes alternative by @Adnan:
$M

Try it online or verify some more test cases.
Explanation:
_   # Check if the (implicit) input is 0 (0 becomes 1; everything else becomes 0)
 +  # Add it to the (implicit) input (0 becomes 1; everything else stays the same)
    # (and output the result implicitly)

$   # Push both 1 and the input to the stack
 M  # Push the largest number of the stack (without changing the rest of the stack)
    # (and output the top of the stack implicitly as result)

@Makonede I'm afraid those don't work.. $~ and 1~ fail for even-numbered inputs (i.e. 4 results in 5; 6 results in 7; etc.) And the 1M will always result in 1, because it's the only value on the stack.

Gaia, 2 bytes
1Ṁ

Try it online!
Takes the Ṁax of 1 and the input.

MAWP,  4  20 bytes
%@_1A[1A~25WWM~]~?1:

Responds to numbers which have more than 1 digit.
Try it!

I tried the Keg solution, and it outputs nothing after 9.

You were right. The Keg solution has now been fixed.

@Razetime that's because it was trying to output it as a character. It needed a sneaky -hr interpreter flag.

nice! Happy to help.

Problem was that the poster (petStorm) had deleted that account long ago. So it needed someone else to fix it.

Opening issue about inadequate input for multi-digit numbers in MAWP

Javascript, 8 11 bytes
Probably a bad implementation, but here:
n=>n==0?1:n

Explanation:
n // The input
n == 0 // Checks whether n is zero
?1 // If so, return 1.
:n // However, if n isn't zero, then return n

Welcome to CGCC. Your approach works, but note that either a full program or function is required; hard-coded input is not allowed. Something like this would be acceptable.

Thanks for the help, I've solved the problems, and rectified the things that need fixing!

you can change n==0 to n<1 since input is non-negative for -1 byte

n||1 works fine

MMIX, 8 bytes (2 instrs)
(jxd)
00000000: 6300 0001 f801 0000                      c¡¡¢ẏ¢¡¡

(assembly)
foo CSZ $0,$0,1
    POP 1,0

Honestly, this function really should be inlined. It costs three instructions to call, but just one to inline.

Swift, 12 bytes
Types provided, 12 bytes
{$0==0?1:$0}

{
  $0 == 0 ? 1 : $0
}

Types not provided, 20 bytes
{(n:Int)in n==0?1:n}

```swift
{ (number: Int) -> Int in
  number == 0 ? 1 : number
}

orangebutton suggests the following golf to 11 bytes

C (clang), 63 42 bytes
main(i){scanf("%i",&i);printf("%i",i?:1);}

Try it online!
Much readable than C answers that already exists here. An if-else statement whether to output 1 or the other.
Thanks to ceilingcat for golfing 21 bytes.

If statement is an overkill for such task......

@Wasif It's pretty much the way for beginners. Using if statements always help with programs, and so here it is. Except ceilingcat has golfed it that it's not very visible.

brevity/creativity is the target of code golf, readability be dammed, an if statement is sooooo boring, after the golf it looks much better, you might want to check Tips for golfing in C

Thunno, \$ 2 \log_{256}(96) \approx \$ 1.65 bytes
1~

Attempt This Online!
Explanation: logical OR (~) with 1.

Pyt, 3 bytes
1←↑

Try it online!
1       push 1
 ←      get input
  ↑     get maximum value on the stack; implicit print

Desmoslang, 14 13 Bytes
IS+1-\sgn(DOT

Old:
ISE\{D=0,D\}OT

Lua, 24 bytes
print(0<0+...and...or 1)

Try it online!

Python, 15 Bytes
lambda x:x or 1

Thanks for choosing a falsey value to avoid!
Try it online!

Python 3, 21 bytes
lambda n:{n:n,0:1}[n]

Try it online!
Also note that {0:1,n:n} doesn't work because if n is 0 the n:n overrides 0:1

Gema, 5 characters
\A0=1

Sample run:
bash-5.2$ gema '\A0=1' <<< '0'
1

bash-5.2$ gema '\A0=1' <<< '10'
10

Try it online! / Try all test cases online!

Swift, 19 18 17 bytes
var f={max(1,$0)}

Taking advantage of the "non-negative" rule here.

Easyfuck, 5 bytes
Solution:
+$":'

Explanation:
+ increments the cell at the pointer
$ copies cell at the pointer into storage
" takes in an 8 bit integer
: puts max(current cell, storage) into the current cell
' outputs an 8 bit integer

Excel VBA 17 bytes
[a1]=IIF(n=0,1,n)

Simple if else statement you can run it from vba immediate window

Hey, just a note on convention with VBA and Excel VBA for PPCG - you must take input from either a cell or from a passed variable. You can output to the immediate window, msgbox, function value, to a cell or by modifying a passed variable. This means that your above solution is not valid as it does not take input from cell or a passed variable, but rather relies on the variable being passed to it.

Save two bytes and make it a valid answer with ?-([A1]=0)+[A1]

JS ES5, 26 bytes
function (n){return n?n:1}

Save one byte by removing the space after function.

n||1

I think you can also write this as function(n)n||1 (taking the n||1 idea from l4m2)


text:
'A' to Ä converter
I'm currently scanning a bunch of handwritten documents and converting them to .txt files. Since I have a terrible handwriting the .jpg->.txt converter converts some of my umlauts to the "normal" letter encased by '
Task
Write a program or a function that:

Is given a string

you can choose any I/O codepage as long as

it supports the characters AEIOUaeiouÄËÏÖÜäëïöü'.

combining diacriticals are prohibited

the Input and Output codepages are the same.

the input will (beside spaces) only contain printable characters from your codepage.

There will only be one solution, thus things like 'a'e' won't appear

Converts all characters in the following set AEIOUaeiou to ÄËÏÖÜäëïöü

If, and only if, they are surrounded by ' characters:

Example: 'a''e' -> äë

If the from string is a single letter.

for example 'AE' does not change at all, outputting as-is.

If the from character is not a character out of AEIOUaeiou that character won't change.

Note: The from character / from string is the one between '.
Testcases
Input
Output
<empty line>

'A'sthetik
Ästhetik

Meinung ist wichtig!
Meinung ist wichtig!

Ich sagte: "Er sagte: 'Ich habe Hunger'"
Ich sagte: "Er sagte: 'Ich habe Hunger'"

Ich sagte: "Er sagte: ''A'sthetik'"
Ich sagte: "Er sagte: 'Ästhetik'"

Hämisch rieb er sich die H'a'nde
Hämisch rieb er sich die Hände

H'a''a'slich isn't a German word
Hääslich isn't a German word

since it's really called h'a'sslich
since it's really called hässlich

The active ingredient in all of your testcases are either 'A' or 'a'... not what I consider good testcases.

Can you add a example with 'w' (as w is not one of AEIOUaeiou)?

Combining diacriticals had unknown status, then were allowed, then were disallowed.  This invalidated at least 4 answers.  Boo! Hiss! I've changed my upvote to a downvote :(

@DigitalTrauma I'm very sorry for that.

Add testcase: 'q'e'd'

What is with strings like 'a'u', this can result in äu, aü or äü, what of that is allowed what not?

Isn't it häßlich?

This says it is hässlich. In the first example the error(?) is intended.

JavaScript (ES6), 81 70 68 bytes
s=>s.replace(/'[aeiou]'/gi,c=>"ï   ÖÄöä ËÜëüÏ "[c.charCodeAt(1)%15])

Try It

f=
s=>s.replace(/'[aeiou]'/gi,c=>"ï   ÖÄöä ËÜëüÏ "[c.charCodeAt(1)%15])
i.addEventListener("input",_=>o.innerText=f(i.value))
console.log(f("'A'sthetik")) // Ästhetik
console.log(f("Meinung ist wichtig!")) // Meinung ist wichtig!
console.log(f(`Ich sagte: "Er sagte: 'Ich habe Hunger'"`)) // Ich sagte: "Er sagte: 'Ich habe Hunger'"
console.log(f(`Ich sagte: "Er sagte: ''A'sthetik'"`)) // Ich sagte: "Er sagte: 'Ästhetik'"
console.log(f("Hämisch rieb er sich die H'a'nde")) // Hämisch rieb er sich die Hände
console.log(f("H'a''a'slich isn't a German word")) // Hääslich isn't a German word
console.log(f("since it's really called h'a'sslich")) // since it's really called hässlich
<input id=i><pre id=o>

Explanation

s=> Anonymous function taking the input string as an argument via parameter "s".
s.replace(x,y) Returns the string with "x" replaced by "y".
/'[aeiou]'/gi Case insensitive regular expression that matches all occurrences of a vowel enclosed by single quotes.
c=> Passes each match of the regular expression to an anonymous function via parameter "c".
"ï   ÖÄöä ËÜëüÏ "[n] Returns the nth character (0 indexed) in the string "ï   ÖÄöä ËÜëüÏ ", similar to "ï   ÖÄöä ËÜëüÏ ".charAt(n).
c.charCodeAt(1)%15 Gets the remainder of the character code of the second character in "c" (i.e. the vowel character) when divided by 15.

Alternative, 40/52 36/48 bytes (35/47 characters)
The following was my answer before combining diacritics were disallowed (Boo-urns!) - better viewed in this Fiddle
s=>s.replace(/'([aeiou])'/gi,"$1̈")

However, ETHproductions suggests that with the addition of .normalize() for an additional 12 bytes that this would be valid.
s=>s.replace(/'([aeiou])'/gi,"$1̈").normalize()

OP still hasn't answered https://codegolf.stackexchange.com/users/59183/dzaima

No, if combining diacritics are allowed.

Combining diacritics are now prohibited.

I believe you can make this valid by adding .normalize() to the end of the function.

Are you sure, @ETHproductions? If combining diacritics are prohibited, are they not prohibited from appearing in an answer at all?

Perl 5, 25 bytes
s/'(\w)'/chr 1+ord$1/age

24 bytes, plus 1 for -pe instead of -e
This makes use of the rule that "you can choose any I/O codepage as long as it supports the characters AEIOUaeiouÄËÏÖÜäëïöü'". It also makes use of the /a flag on regexes, which causes \w to refer to precisely the characters in abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 no matter how they're encoded.
The chosen I/O codepage for my script is this:
 1  a
 2  ä
 3  e
 4  ë
 5  i
 6  ï
 7  o
 8  ö
 9  u
10  ü
11  A
12  Ä
13  E
14  Ë
15  I
16  Ï
17  O
18  Ö
19  U
20  Ü
21  '

(I can't test this script on the test cases in the question, as they include some really weird characters, like t.)

Thanks to Grimy for saving me three bytes. Earlier, I had s/'([a-z])'/chr 1+ord$1/gie, which made use of (the encoding and) the interesting fact that [a-z] is special-cased in Perl to match precisely abcdefghijklmnopqrstuvwxyz no matter the encoding. My earlier answer is, IMO, more interesting, but this one is shorter, so, what the heck, I'll take it.

I carefully checked the "loopholes that are forbidden by default" list before posting this, and inventing a codepage wasn't among them. That, plus especially the fact that the question invited use of "any I/O codepage", seem to allow this answer. And then the a-z trick makes the answer actually interesting instead of merely a cheat. (IMO, anyway.)

This is the kind of trick that’s only funny once, but I believe you’re the first one to use it, so it works (=

You could save 3 bytes by using \w instead of [a-z], as well as /a instead of /i. If the "/a" modifier is in effect, \w matches the characters [a-zA-Z0-9_], regardless of how they’re encoded.

@Grimy, thanks! I'll edit....

Vim, 33 bytes
:s/\c'\([aeiou]\)'/<C-v><C-k>\1:/g
ii<esc>D@"

Try it online! in the backwards compatible V interpreter.

Japt, 29 bytes
r"'%v'"@"ï   ÖÄöä ËÜëüÏ "gXc1

Try it online!
Explanation
r"'%v'"@"ï   ÖÄöä ËÜëüÏ "gXc1

r"'%v'"@                       // Replace each match X of /'<vowel>'/ in the input with
        "ï   ÖÄöä ËÜëüÏ "g     //   the character in this string at index
                          Xc1  //     X.charCodeAt(1).
                               //   Values larger than the length of the string wrap around,
                               //   so this is effectively equal to " ... "[n%15].
                               // Implicit: output result of last expression

Using combining diacritics is controversial.

Beat me to it. Your solution is much shorter than mine though... Well done.

@LeakyNun Controversial for this question or in general?

Controversial for this question because you raised it in the comments but it was never addressed.

@Adám Beat you by 38 seconds ;-)

@ETHproductions Ninja'ed :-D

@LeakyNun Fixed now.

Can you add an explanation please?

@Luke Added now, let me know if you have any questions.

It's not too different from what I expected. I started writing a solution which doesn't use the wrapping of string indexing (since I didn't know Japt had that), but that is much longer.

Javascript, 67 bytes
s=>s.replace(/'.'/g,c=>"äëïöüÄËÏÖÜ"['aeiouAEIOU'.indexOf(c[1])]||c)

Try it online!
Replace all characters between quotes with either the corresponding umlauted character, or the match itself if it's not in the group of characters that need changing.

Jelly, 36 bytes
œṣ⁹Ṫ¤j
“.ạẏụ’D196;+\Ọż⁾''jÐ€Øc¤;@Wç/

Try it online!
This seems pretty complicated for Jelly!
How?
Note: Since the characters are not on the code-page, but are within the range of a byte in Unicode I think they must be created from ordinals, so I have.
œṣ⁹Ṫ¤j - Link 1, Replace: char list S [...], list R [char T, char list F]
œṣ     - split S at sublists equal to:
    ¤  -   nilad followed by link(s) as a nilad:
  ⁹    -     link's right argument, R
   Ṫ   -     tail - yield char list F and modify R to become [T]
     j - join with R (now [T])
       - all in all split S at Rs and join back up with [T]s.

“.ạẏụ’D196;+\Ọż⁾''jÐ€Øc¤;@Wç/ - Main link: char list S
       196;                   - 196 concatenate with:
“.ạẏụ’                        -   base 250 literal 747687476
      D                       -   to decimal list [7,4,7,6,8,7,4,7,6]
           +\                 - cumulative reduce with addition: [196,203,207,214,220,228,235,239,246,252]
             Ọ                - cast to characters: ÄËÏÖÜäëïöü
                       ¤      - nilad followed by link(s) as a nilad:
               ⁾''            -   literal ["'", "'"]
                     Øc       -   vowel yield: AEIOUaeiou
                  jÐ€         -   join mapped:  ["'A'", "'E'", ...]
              ż               - zip together
                          W   - wrap S in a list
                        ;@    - concatenate (swap @rguments)
                           ç/ - reduce with last link (1) as a dyad
                              - implicit print

V, 24 bytes
Óã'¨[aeiou]©'/±:
éiD@"

Try it online!
Hexdump:
00000000: d3e3 27a8 5b61 6569 6f75 5da9 272f 160b  ..'.[aeiou].'/..
00000010: b13a 0ae9 6944 4022                      .:..iD@"

This is just a direct translation of my vim answer so that I can beat all of the golfing languages. :P

Ruby, 62+1 = 63 bytes
Uses the -p flag for +1 byte.
gsub(/'([aeiou])'/i){$1.tr"AEIOUaeiou","ÄËÏÖÜäëïöü"}

Try it online!

APL (Dyalog), 53 bytes
(v←'''[AEIOUaeiou]''')⎕R{'  ÄËÏÖÜäëïöü'[v⍳2⊃⍵.Match]}

Try it online!
Uses PCRE Replace (saving the RegEx as v) to apply the following function to quoted vowels:
{ anonymous function
 '  ÄËÏÖÜäëïöü'[…] index the string (note two spaces corresponding to '[) with:
  ⍵.Match the matched string
  2⊃ pick second letter (the vowel)
  v⍳ find index in v
}

///, 67 bytes
/~/'\///`/\/\/~/'A~Ä`E~Ë`I~Ï`O~Ö`U~Ü`a~ä`e~ë`i~ï`o~ö`u~ü/

Try it online!
This works by replacing non-dotted letters surrounded by single-quotes('A') with the same letter as a dotted, without the single quotes (Ä). A single replacement of this looks like this (before the golf): /'A'/Ä/.
The golf takes two common occurrences, // and '/, and uses them as replacements.

SOGL, 43 35 (UTF-8) bytes
L∫:ÆW ':h++;"äëïöü”:U+Wŗ

Explanation:
L∫                        repeat 10 times, pushing current iteration (0-based)
  :                       duplicate the iteration
   ÆW                     get the index (1-based) in "aeiouAEIOU"
      ':h++               quote it
           ;              put the copy (current iteration) ontop
            "äëïöü”       push "äëïöü"
                   :      duplicate it
                    U     uppercase it
                     +    join together, resulting in "äëïöüÄËÏÖÜ"
                      W   get the index (1-based) in it
                       ŗ  replace [in the input, current char from "aeiouAEIOU" with
                          the corresponding char in "äëïöüÄËÏÖÜ"

Heh, one could think that ̈+ is a function in SOGL.

Combining diacritics are now prohibited.

Swift - 201 bytes
import Foundation;func g(s:String){var e=s;var r="aeiouAEIOUäëïöüÄËÏÖÜ".characters.map{String($0)};for i in r[0...9]{e=e.replacingOccurrences(of:"'\(i)'",with:r[r.index(of:i)!+10])};print(e)}

Usage: g("'A'sthetik")      // => Ästhetik

characters.map{blah blah} and replacingOccurrences() really kill the fun :((

AWK, 99 bytes
{split("AEIOUaeiou",p,"")
for(i=1;i<=split("ÄËÏÖÜäëïöü",r,"");i++)gsub("'"p[i]"'",r[i])}1

Try it online!
I tried to come up with some clever regex within a gensub but failed :(

Python 3.6, 98 92 characters
import re;a=lambda i,p="'([AEIOUaeiou])'":re.sub(p,lambda x:'ÄËÏÖÜäëïöü'[p.index(x[1])-3],i)

It's a function, not a complete program.
Formatted for readability:
import re

a = lambda i, p="'([AEIOUaeiou])'":\
    re.sub(p, lambda x: 'ÄËÏÖÜäëïöü'[p.index(x[1]) - 3], i)

Thanks to @ValueInk for clever tips for further golfing.

Does not run for me. Stops with a TypeError.

@totallyhuman are you sure? It seems to be working for me. You need to call the a function with the string you want to replace.

Try it here.

@totallyhuman it works for me. Which Python version do you have?

Python docs reports that match.__getitem__(g) is new to Python 3.6 so it should probably be specified in your header. Also, if you change your regex to '([AEIOUaeiou])' you save a byte by changing x[0][1] to x[1] and use -3 instead of -2.

Actually, it's even shorter to go import re;a=lambda i,p="'([AEIOUaeiou])'":re.sub ... since you cut out quite a bit of overhead from no longer needing a return statement!

05AB1E, 30 29 24 bytes
-6 bytes thanks to Emigna
žMDu«S''«''ì"äëïöü"Du«S:

05AB1E conveniently has the characters äëïöü in its code page.
Try it online!
(old code)
žMDu«Svy''.ø})"äëïöü"Du«¹ŠS:

Explanation (outdated):
žM                             Push aeiou                    ['aeiou']
  D                            Duplicate                     ['aeiou', 'aeiou']
   u                           Uppercase                     ['aeiou', 'AEIOU']
    «                          Concatenate                   ['aeiouAEIOU']
     vy                        For each...
       ''                        Push '
         .ø                      Surround a with b (a -> bab)
           }                   End loop
            )                  Wrap stack to array           [["'a'", "'e'", "'i'", "'o'", "'u'", "'A'", "'E'", "'I'", "'O'", "'U'"]]
             "äëïöü"           String literal.               [["'a'", "'e'", "'i'", "'o'", "'u'", "'A'", "'E'", "'I'", "'O'", "'U'"], 'äëïöü']
                    Du«        Duplicate, uppercase, concat  [["'a'", "'e'", "'i'", "'o'", "'u'", "'A'", "'E'", "'I'", "'O'", "'U'"], 'äëïöüÄËÏÖÜ']
                       ¹       Push first input
                        Š      Push c, a, b                  ["'A'sthetik", ["'a'", "'e'", "'i'", "'o'", "'u'", "'A'", "'E'", "'I'", "'O'", "'U'"], 'äëïöüÄËÏÖÜ']
                          S    Convert to char list          ["'A'sthetik", ["'a'", "'e'", "'i'", "'o'", "'u'", "'A'", "'E'", "'I'", "'O'", "'U'"], ['ä', 'ë', 'ï', 'ö', 'ü', 'Ä', 'Ë', 'Ï', 'Ö', 'Ü']]
                           :   Replace all                   ['Ästhetik']
                               Implicit print

Try it online!

You could replace .Á with Š.

You could save a few more bytes with žMDu«S''«''ì"äëïöü"Du«S:

@Emigna Thanks again.

You also don't need the I at the beginning :)

Retina, 39 bytes
iT`A\EI\OUaei\ou'`ÄËÏÖÜäëïöü_`'[aeiou]'

Try it online!

source: Stack Exchange

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

sort: votes


text:
Unrestricted Languages
One of my favorite types of challenges on this site are restricted-source challenges.  These challenges impose a computer tractable restriction that the sources of potential answers must pass.  I like these challenges so much I have been working on a golfing language designed to win at these challenges for some time now.  Now I want to extend the challenge to you.  Your task is to design a language to solve a variety of restricted source tasks.  You will time to design and implement a language, at which point changes and new additions will be non-competing and all of the submissions will go head to head in a gauntlet of restricted-source challenges.
Scoring
Before the challenge is posted I will come up with a list of simple challenges to solve and a list of source restrictions to follow.  For each matching of challenge and source restrictions your language can earn between 0 and 2 points. (there will be 10 challenges and 10 restrictions leading to 100 total combinations) A language scores

1 point if it can complete the task with the restriction in under 150 bytes
2 points if the solution is the shortest solution of any language competing (both languages will score 2 points in the event of a tie)
0 points if they are unable to create a program that completes the task under the restriction in less than 150 bytes.

Your score will be the sum of all points earned in every possible match up. The goal is to get the highest score.  Other people may help you to golf your solutions to each challenge and improve your score.
I will reveal 4 items of each list at the time of posting and an additional 8 one week after the second answer. You will only be allowed to score 1 point (shortest submission does not count) in any matching that has both parts revealed before the the first week. This way you can get an idea of how well your language stacks up while you are working on it, but you can't design you language simply to build in all of the challenges and restrictions.
I will include a hash of the intended categories with the question so you can be sure I do not change them during the week to advantage any party.  In addition I will not tell anyone the hidden parameters until the week is up nor compete in the challenge myself.
Pre-existing languages
This challenge is open to all pre-existing languages however if you are not the author of the language, please make your answer a community wiki so that other members of our community can contribute to the score directly.  Command line flags need not obey any restrictions however every program should be run with the same command line arguments (i.e. you should pick one and stick with it).  These do not add to your byte count.
Challenges and restrictions
Restrictions are enforced on the ASCII encoding of your binaries regardless of the code-page you use.  Some of these link to an existing question on the site from which they inherit their io requirements for challenges and source restrictions for restrictions.  You can ignore anything "banning builtins" or overriding existing meta consensuses on any of the linked challenges.
As a word of warning: do not try to rule lawyer; I know it is a competition but because there are essentially 100 different sub-challenges challenges and I simply cannot guarantee that all of them will be entirely unproblematic.  Just try to have fun.
Challenges

Sort a list of integers
print Hello, world!
Determine if parentheses are balanced
Test Primality

Restrictions

Only odd bytes (every 8th bit must be odd)
Double bytes
Bytes are in ascending order (each byte is greater than the last)
Source code is a palindrome

The remaining criteria have a sha512 hash of:
4de5eca33c6270798606cf1412820c4ce112d8b927ef02877f36795b2b15ffacca51ea598fa89b8d6bc9f4cde53810e0e7ade30e536e52e28f40a6a13841dfc5  -

Let us continue this discussion in chat.

Came here to downvote, then read the spec. +1

Is the one week up?

@tuskiomi Yes.  I haven't gotten any answers so I have not revealed it yet.  I'll update the question to reflect this

What if I develop a language where the empty program sorts a list of integers, prints hello world, determines if parentheses are balanced or tests primality, depending on what's in the input? I suggest to keep these challenges only as examples, and to score submissions exclusively on other, undiscovered challenges

@Leo The already revealed categories are worth significantly less than the hidden ones.  That might be a good starting point but I don't think that strategy is going to do you much in the long run.

"every 8th bit must be odd" implies that only odd ASCII values are allowed.

Unicode allowed?

@tuskiomi All that matters is the bytes, you may have any encoding you wish.

How would double characters work for that then?

@tuskiomi That should be double bytes.

But \u\u isn't a valid character?

@tuskiomi The definition of character is unimportant.  The source's hexdump is the only thing relevant to the source restrictions.

So it would be better to create a really smart compiler rather than a really intricate language,  huh?

Let us continue this discussion in chat.

I an a little confused by the line "Command line flags need not obey [...]." So, is it okay to use a different command line flag for every program, or am I getting confused and a command line flag is the same thing as a command line argument? Basically, is it okay to use -x in the command line for one program and -y in another?

@ComradeSparklePony The command line flags need to be the same for all programs.

Is modifying existing languages acceptable? If so, how should credit be handled?

an additional 8 one week after the second answer -> the competition closes then, correct? Otherwise earlier answers are at a steep disadvantage.

@StepHen Yes that is the case.

Width
The interpreter is still a work in progress (I have several unused command slots still). The repo, with more documentation, can be found here.
Dennis added Width to TIO less than a minute ago: Try It Online!
Width is an esoteric stack-based language I developed recently based on ideas I first dumped in this question. It is based entirely on how wide, more or less, a letter is in a "regular" font. The only characters that do anything are letters, uppercase and lowercase. All other characters are ignored. I split letters up into 10 different width categories, which form the 10 different actions possible in Width:
0: i j l                     # do while counter > 0
1: f r t I                   # end
2: c k s v x y z J           # 0 in commands
3: a b d e g h n o p q u L   # separator (no-op)
4: F T Z                     # push base 10 number, using left side row titles (width numbers); terminated with original char
5: A B E K P S V X Y         # 1 in commands
6: w C D H N R U             # 2 in commands
7: G O Q                     # push string literal; sets of 2 width numbers equate to index in printable ASCII; terminated with original char
8: m M                       # if top of stack
9: W                         # else

2, 5, and 6 provide access to the commands, most of which interact with the stack. More information can be found at the info.txt page in the Github repo.
This is the Python code of the interpreter. I still have several commands to add, and I'm considering how to work with error-handling, but otherwise it should be complete. (I'm also going to add a flag at some point to allow testing with a more abstract syntax, because otherwise this language is a giant pain to work with)
import sys
import math
import numbers
import functools

try:
    file = sys.argv[1]
except IndexError:
    file = "source.wide"

with open(file) as f:
    source = f.read()

translation = ("ijl", "frtI", "cksvxyzJ", "abdeghnopquL", "FTZ", "ABEKPSVXY", "wCDHNRU", "GOQ", "mM", "W")
chars = "".join(sorted("".join(translation)))
strings = """ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\n\t"""

def trans(letter):
    for each in translation:
        if letter in each:
            return translation.index(each)

COMMAND = "COMMAND"
COMMANDS = (2, 5, 6)
NUMBER = "NUMBER"
STRING = "STRING"
DO = "DO"
IF = "IF"
ELSE = "ELSE"
END = "END"
SEPARATOR = "SEPARATOR"

class Token:
    def __init__(self, val, type_):
        self.val = val
        self.type = type_

class Lexer:
    def __init__(self, src):
        self.src = src
        self.pos = 0
        self.char = self.src[self.pos]

    def read(self):
        if self.char is None:
            return None

        command = trans(self.char)

        if command == 0:
            self.advance()
            return Token(0, DO)
        elif command == 1:
            self.advance()
            return Token(1, END)
        elif command == 3:
            self.advance()
            return Token(3, SEPARATOR)
        elif command == 4:
            return self.read_num()
        elif command == 7:
            return self.read_str()
        elif command == 8:
            self.advance()
            return Token(8, IF)
        elif command == 9:
            self.advance()
            return Token(9, ELSE)
        else:
            return self.read_cmd()

    def advance(self):
        self.pos += 1

        try:
            self.char = self.src[self.pos]
        except IndexError:
            self.char = None

    def read_num(self):
        delim = self.char
        self.advance()

        res = ""
        while self.char is not None and self.char != delim:
            res += str(trans(self.char))
            self.advance()

        self.advance()

        return Token(int(res), NUMBER)

    def read_str(self):
        def read_char():
            res_ = str(trans(self.char))
            self.advance()
            res_ += str(trans(self.char))
            self.advance()
            try:
                return strings[int(res_)]
            except IndexError:
                return " "

        delim = self.char
        self.advance()

        res = ""
        while self.char is not None and self.char != delim:
            res += read_char()

        self.advance()

        return Token(res, STRING)

    def read_cmd(self):
        command = ""
        while self.char is not None and trans(self.char) in COMMANDS and len(command) <= 4:
            command += str(COMMANDS.index(trans(self.char)))
            self.advance()

        return Token(command, COMMAND)

source = "".join(filter(lambda c: c in chars, source))

stack = []
backburner = []
counter = 0

def set_counter(val):
    global counter
    counter = int(val)

    if counter < 0:
        counter = 0

def set_stack(val):
    global stack
    stack = val

def num_input():
    inp = input()
    try:
        stack.append(int(inp))
    except ValueError:
        try:
            stack.append(float(inp))
        except ValueError:
            pass

def flip_ends():
    if len(stack) > 1:
        stack[0], stack[-1] = stack[-1], stack[0]

def clear_stack():
    global stack
    stack = []

def reload_stack(is_top):
    global backburner, stack

    if is_top:
        stack.extend(backburner)
    else:
        stack = backburner + stack

    backburner = []

# https://stackoverflow.com/a/15285588/7605753
def is_prime(n):
    if n == 2 or n == 3:
        return True
    if n < 2 or n % 2 == 0:
        return False
    if n < 9:
        return True
    if n % 3 == 0:
        return False
    r = int(math.sqrt(n))
    _f = 5
    while _f <= r:
        if n % _f == 0:
            return False
        if n % (_f + 2) == 0:
            return False
        _f += 6
    return True

def error():
    raise Exception

commands = {
    "0": lambda: stack.append(stack[-1]),
    "1": lambda: stack.append(stack.pop(-2)),
    "2": lambda: stack.pop(),
    "00": lambda: set_counter(stack[-1]),
    "01": lambda: stack.append(len(stack)),
    "02": lambda: stack.append(input()),
    "10": num_input,
    "11": lambda: stack.append(str(stack.pop())),
    "12": lambda: stack.append(int(stack.pop())),
    "20": lambda: set_counter(counter + 1),
    "21": lambda: set_counter(counter - 1),
    "22": lambda: print(stack.pop()),
    "000": lambda: stack.append(float(stack.pop())),
    "001": lambda: stack.append(-stack.pop()),
    "002": lambda: stack.append(not stack.pop()),
    "010": lambda: stack.append(stack.pop(-2) + stack.pop()),
    "011": lambda: stack.append(stack.pop(-2) - stack.pop()),
    "012": lambda: stack.append(stack.pop(-2) / stack.pop()),
    "020": lambda: stack.append(stack.pop(-2) // stack.pop()),
    "021": lambda: stack.append(stack.pop(-2) * stack.pop()),
    "022": lambda: stack.append(stack.pop(-2) % stack.pop()),
    "100": lambda: stack.append(math.factorial(stack.pop())),
    "101": lambda: stack.append(str(stack.pop(-2)) + str(stack.pop())),
    "102": lambda: stack.append(math.pow(stack.pop(-2), stack.pop())),
    "110": lambda: stack.append(math.sqrt(stack.pop())),
    "111": lambda: stack.append(math.log(stack.pop(-2), stack.pop())),
    "112": lambda: stack.append(~stack.pop()),
    "120": lambda: stack.append(stack.pop(-2) | stack.pop()),
    "121": lambda: stack.append(stack.pop(-2) & stack.pop()),
    "122": lambda: stack.append(stack.pop(-2) << stack.pop()),
    "200": lambda: stack.append(stack.pop(-2) >> stack.pop()),
    "201": lambda: stack.append(stack.pop(-2)[stack.pop()]),
    "202": lambda: stack.append(str(stack.pop(-2)) * stack.pop()),
    "210": lambda: stack.append(counter),
    "211": lambda: set_counter(stack.pop()),
    "212": lambda: stack.extend(list(str(stack.pop()))),
    "220": flip_ends,
    "221": lambda: stack.append(len(stack[-1])),
    "222": lambda: print(stack[-1]),
    "0000": lambda: stack.reverse(),
    "0001": lambda: stack.sort(),
    "0002": lambda: stack.append(stack[counter]),
    "0010": lambda: stack.append(stack[stack.pop()]),
    "0011": 0,
    "0012": 0,
    "0020": lambda: stack.append(sum(n for n in stack if isinstance(n, numbers.Number))),
    "0021": lambda: stack.append(functools.reduce(lambda x, y: x*y, [n for n in stack if isinstance(n, numbers.Number)], 1)),
    "0022": 0,
    "0100": lambda: (backburner.extend(stack), clear_stack()),
    "0101": lambda: reload_stack(True),
    "0102": lambda: reload_stack(False),
    "0110": lambda: backburner.append(stack.pop()),
    "0111": lambda: backburner.append(list(stack.pop())),
    "0112": lambda: stack.pop().split(stack.pop()),
    "0120": lambda: stack.append(backburner[-1]),
    "0121": lambda: (lambda depth=stack.pop(): (set_stack(stack[-depth:]), backburner.append(stack[:depth])))(),
    "0122": lambda: (lambda depth=stack.pop(): (set_stack(stack[:-depth]), backburner.append(stack[depth:])))(),
    "0200": lambda: set_stack([stack.pop().join(stack)]),
    "0201": lambda: set_stack(["".join(stack)]),
    "0202": lambda: (lambda depth=stack.pop(-2): set_stack(stack[-depth:] + [stack.pop().join(stack[:depth])]))(),
    "0210": lambda: (lambda depth=stack.pop(): set_stack(stack[-depth:] + ["".join(stack[:depth])]))(),
    "0211": 0,
    "0212": 0,
    "0220": lambda: stack.append(stack.pop().split(stack.pop())),
    "0221": lambda: stack.append(stack.pop().split(", ")),
    "0222": 0,
    "1000": lambda: stack.append(is_prime(stack[-1])),
    "1001": lambda: stack.append((lambda s=stack.pop(): s == s[::-1])()),
    "1002": lambda: stack.append(1 / stack.pop()),
    "1010": lambda: stack.append(stack.pop() - 1),
    "1011": lambda: stack.append(stack.pop() + 1),
    "1012": lambda: stack.append(stack.pop() * 2),
    "1020": lambda: stack.append(stack.pop() / 2),
    "1021": lambda: stack.append(stack.pop() ** 2),
    "1022": lambda: float("." + str(stack.pop())),
    "1100": lambda: stack.append(stack.pop() == stack.pop()),
    "1101": lambda: stack.append(stack.pop() != stack.pop()),
    "1102": lambda: stack.append(stack.pop() > stack.pop()),
    "1110": lambda: stack.append(stack.pop() < stack.pop()),
    "1111": lambda: stack.append(stack.pop() >= stack.pop()),
    "1112": lambda: stack.append(stack.pop() <= stack.pop()),
    "1120": lambda: stack.append(stack.pop() in stack),
    "1121": lambda: stack.append(stack.pop() in backburner),
    "1122": lambda: stack.append(stack.pop() == counter),
    "1200": lambda: stack.append(stack.pop() in stack.pop()),
    "1201": lambda: stack.append(stack.pop(-2).find(stack.pop())),
    "1202": 0,
    "1210": 0,
    "1211": 0,
    "1212": lambda: stack.append(stack.pop().lower()),
    "1220": lambda: stack.append(stack.pop().upper()),
    "1221": lambda: stack.append(ord(stack.pop())),
    "1222": lambda: stack.append(chr(stack.pop())),
    "2000": lambda: stack.append(math.floor(stack.pop())),
    "2001": lambda: stack.append(math.ceil(stack.pop())),
    "2002": lambda: stack.append(round(stack.pop())),
    "2010": lambda: stack.append(abs(stack.pop())),
    "2011": 0,
    "2012": 0,
    "2020": lambda: stack.append(len(stack.pop())),
    "2021": 0,
    "2022": 0,
    "2100": lambda: stack.append(min(stack)),
    "2101": lambda: stack.append(max(stack)),
    "2102": lambda: stack.append(stack.count(stack.pop())),
    "2110": lambda: stack.append(sum(stack) / len(stack)),
    "2111": 0,
    "2112": 0,
    "2120": 0,
    "2121": 0,
    "2122": 0,
    "2200": lambda: stack.append(stack.pop(-3).replace(stack.pop(-2), stack.pop())),
    "2201": lambda: stack.append(stack.pop(-3).replace(stack.pop(-2), stack.pop(), 1)),
    "2202": lambda: stack.append(stack.pop(-2).replace(stack.pop(), "")),
    "2210": lambda: stack.append(stack.pop(-2).replace(stack.pop(), "", 1)),
    "2211": 0,
    "2212": lambda: stack.append(eval(stack.pop())),
    "2220": lambda: stack.append(eval(input())),
    "2221": lambda: print(stack[-1]),
    "2222": lambda: error()
}

def run_cmd(name):
    global stack, counter, backburner

    state = {
        "stack": list(stack),
        "counter": counter,
        "backburner": list(backburner)
    }

    # TODO: unknown command

    try:
        commands[name]()
    except IndexError:
        stack = state["stack"]
        counter = state["counter"]
        backburner = state["backburner"]

class AST:
    pass

class Main(AST):
    def __init__(self):
        self.nodes = []

class Do(AST):
    def __init__(self, node):
        self.node = node

class If(AST):
    def __init__(self, first, second):
        self.first = first
        self.second = second

class Literal(AST):
    def __init__(self, val):
        self.val = val

class Command(AST):
    def __init__(self, val):
        self.val = val

class Parser:
    def __init__(self, lexer):
        self.lexer = lexer
        self.token = None

    def parse(self):
        pgm = Main()
        self.token = self.lexer.read()

        while self.token is not None and self.token.type != END and self.token.type != ELSE:
            if self.token.type == DO:
                pgm.nodes.append(Do(self.parse()))

            elif self.token.type == NUMBER or self.token.type == STRING:
                pgm.nodes.append(Literal(self.token.val))

            elif self.token.type == IF:
                first = self.parse()

                if self.token.type == ELSE:
                    second = self.parse()
                else:
                    second = None

                pgm.nodes.append(If(first, second))

            elif self.token.type == COMMAND:
                pgm.nodes.append(Command(self.token.val))

            self.token = self.lexer.read()

        return pgm

class Interpreter:
    def __init__(self, tree):
        self.tree = tree

    def visit(self, node):
        method_name = "visit_" + type(node).__name__
        visitor = getattr(self, method_name.lower())
        return visitor(node)

    def interpret(self):
        self.visit(self.tree)

    def visit_main(self, node):
        for each in node.nodes:
            self.visit(each)

    def visit_do(self, node):
        while counter:
            self.visit(node)

    def visit_if(self, node):
        if stack[-1]:
            self.visit(node.first)
        elif node.second:
            self.visit(node.second)

    def visit_literal(self, node):
        stack.append(node.val)

    def visit_command(self, node):
        run_cmd(node.val)

if source == "":
    with open("info.txt") as f:
        info = f.read()

    print(info)
else:
    main = Parser(Lexer(source)).parse()

    interpreter = Interpreter(main)
    interpreter.interpret()

    try:
        sys.exit(stack[-1])
    except IndexError:
        pass

After 4 years and this is the only unrestricted language? I have to improve upon this language.

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