text:
What day is it (on Flooptonia)?
You are a space tourist on your way to planet Flooptonia! The flight is going to take another 47,315 years, so to pass the time before you're cryogenically frozen you decide to write a program to help you understand the Flooptonian calendar.
Here is the 208-day long Flooptonian calendar:
Month       Days    Input Range
Qupu        22      [0-22)
Blinkorp    17      [22-39)
Paas        24      [39-63)
Karpasus    17      [63-80)
Floopdoor   1       [80]
Dumaflop    28      [81-109)
Lindilo     32      [109-141)
Fwup        67      [141-208)

Challenge
Your program, given an integer day in the year (range [0-208)) is to output the corresponding day of the month and name of the month (e.g. 13 Dumaflop).
There is an exception, however: Floopdoor a special time for Flooptonians that apparently deserves its own calendar page. For that reason, Floopdoor isn't written with a day (i.e. the output is Floopdoor, not 1 Floopdoor).
Test Cases
0   => 1 Qupu
32  => 11 Blinkorp
62  => 24 Paas
77  => 15 Karpasus
80  => Floopdoor
99  => 19 Dumaflop
128 => 20 Lindilo
207 => 67 Fwup

Rules

You must write a complete program.
You can assume that the input is always valid.
Your output may have a trailing newline but must otherwise be free of any extra characters. The case should also match the provided examples.
You may use date/time functions.
Code length is to be measured in bytes.

Does the output's case  matter?

Yes it does, I'll clarify in the post.

Is it "Floopdoor" or "Floopdor"?  The first chart has the extra o, but the other instances of the name don't.

Ah, forgive my typo! :) I've changed it to "Floopdoor" as the majority of the current answers use that already.

So... in 47k years, nothing will change?

@NotthatCharles furthermore, if the planet's that far away, won't it be outdated by the time you get it in the first place?

As if the Gregorian calendar wasn't bad enough.

@ArturoTorresSánchez Well at least there is no leap year. But are there any other stories about Flooptonia, or was the entire setting created solely for this specific puzzle? Is Fwup their word for winter? Or should I just get my tail back to Worldbuilding?

Pyth - 105 103 90 88 bytes
Uses base conversion. Two simple lookup tables, with one for the names and one for start dates, and a ternary at the end for Floopdoor.
KhfgQhTC,aCM"mQP?'"Zcs@LGjC"îºBüÏl}W\"p%åtml-¢pTÇÉ(°±`"23\c+?nQ80+-hQhKdkreK3

Compresses the string not as base 128, but as base 23. First, it translates it to indices of the alphabet. This required the separator to be c which doesn't appear in any of the month names. Then it encodes that to base ten from a base 23 number (the highest value that appeared was w), then converts to base 256.
The start dates are their unicode codepoints, no base conversion.
K                       K =
 hf                     First that matches the filter
  gQ                    >= Q
   hT                   First element of filter var
  C,                    Zip two sequences
   a       Z            Append 0 (I could save a byte here but don't want to mess with null bytes)
    CM"..."             Map the string to its codepoints
   c          \c        Split by "c"
    s                   Sum by string concatenation
     @LG                Map to location in alphabet
      j     23          Base 10 -> Base 23
      C"..."            Base 256 -> Base 10
+                       String concatenation
 ?nQ80                  Ternary if input != 80
  +-hQhK                Input - start date + 1
  k                     Else empty string
 r  3                   Capitalize first letter
  eK                    Of month name

Try it online here.
Test Suite.

I'm very new to Pyth, could you break it down? I'd be very grateful.

@Winny I will, just wanted to finish the obvious golfs first. All the weird symbols are because I compressed the base 26 symbols (the alphabet) into base 256 to save space.

@Winny is that enough? Feel free to ping me here/in chat if you have any questions.

Python 3, 159 156 152 151 150 148 bytes
n=int(input())+1
for c,x in zip(b" C","Qupu Blinkorp Paas Karpasus Floopdoor Dumaflop Lindilo Fwup".split()):c>=n>0and print(*[n,x][-c:]);n-=c

The bytes object in the zip contains unprintable characters:
for c,x in zip(b"\x16\x11\x18\x11\x01\x1c C", ...): ...

(Thanks to @xnor for suggesting a for/zip loop for -3 bytes)

That moment when a Python answer is ---going neck to neck to--- beating a Pyth answer

The use of a bytestring is ingenious!

I feel like it should be possible to iterate over b directly with for instead of while, with something like for c in b"...":i+=n>0;n-=c.

Oh, wait, you need the right value of n to stop going down too. Still should be possible with something like x=n>c;n-=c*x;i+=x but don't know if it's worth it.

Piet  2125 bytes
It's by no means the shortest, but it's pretty and colorful...
Each pixel is placed by myself by hand. To run it go here in FireFox (Chrome won't work) and load it with a codel width of 1 (it'll appear black, don't worry), enter the number and hit the run button!
Small Program:

Enlarged (Codel width of 10):

Doesn't dead chex add to the byte count?

@Beta To be fair the bye count is actually the size of the smaller image on disk, so regardless the byte count is fixed

Pyth 178 156 153 147 bytes
J?<Q22,_1"Qupu"?<Q39,21"Blinkorp"?<Q63,38"Paas"?<Q80,62"Karpasus"?<Q81,k"Floopdoor"?<Q109,80"Dumaflop"?<Q141,108"Lindilo",140"Fwup"?nhJkjd,-QhJeJeJ

Permalink
Second golf ever, any Pyth feedback will be very helpful.
Explanation
J                       (Auto)Assign J a tuple of the first day & month name
 ?<Q22,_1"Qupu"         Recall that Q auto-initialized to raw_input()
 ?<Q39,21"Blinkorp"     ? is ternary
 ?<Q63,38"Paas"         , is a two-pair tuple
 ?<Q80,62"Karpasus"
 ?<Q81,k"Floopdoor"     Special case handled by empty string as first day
 ?<Q109,80"Dumaflop"
 ?<Q141,108"Lindilo"
 ,140"Fwup"             Since input assumed valid, no need to test for Fwup
?nhJk                   Is day not an empty string?
jd,                     join on space
   -QhJ                 Q-(first day or -1 on first month) + 1
   eJ                   The month itself
eJ                      Else print only the month name on Floopdoor

You should be able to use inline assignment to put the entire J=... into the ternary condition.

CJam, 98 96 93 bytes
0000000: 72 69 63 22 00 16 27 3f 50 51 6d 8d d0 22 66 2d  ric"..'?PQm.."f-
0000010: 5f 7b 30 3c 7d 23 28 5f 40 3d 29 53 40 22 06 32  _{0<}#(_@=)S@".2
0000020: 88 b2 ce d2 87 2f 1e 79 62 1b 7a 11 53 a6 cc 02  ...../.yb.z.S...
0000030: 40 c5 c6 82 d0 dd b7 4b ed ee 1c dc 4f f5 ec 67  @......K....O..g
0000040: 22 32 35 35 62 32 33 62 27 61 66 2b 27 63 2f 3d  "255b23b'af+'c/=
0000050: 5f 2c 39 3d 7b 5c 3f 7d 26 28 65 75 5c           _,9={\?}&(eu\

The above is a reversible hexdump, since the source code contains unprintable characters.
Most unprintable characters are no problem for the online interpreter, but the null byte in the first string is a deal breaker.
At the cost of one byte, we can fix this by adding 1 to the input and 1 to each code point of the first string. You can try this version in the CJam interpreter.
If the permalink doesn't work in your browser, you can copy the code from this paste.
Test cases
$ LANG=en_US
$ xxd -ps -r > flooptonia.cjam <<< 726963220016273f50516d8dd022662d5f7b303c7d23285f403d29534022063288b2ced2872f1e79621b7a1153a6cc0240c5c682d0ddb74bedee1cdc4ff5ec6722323535623233622761662b27632f3d5f2c393d7b5c3f7d262865755c
$ wc -c flooptonia.cjam
96 flooptonia.cjam
$ for d in 0 32 62 77 80 99 128 207; do cjam flooptonia.cjam <<< $d; echo; done
1 Qupu
11 Blinkorp
24 Paas
15 Karpasus
Floopdoor
19 Dumaflop
20 Lindilo
67 Fwup

How it works
ric     e# Read a Long from STDIN and cast to Character.
"…"     e# Push the string that corresponds to [0 22 39 63 80 81 109 141 208].
f-      e# Subtract each character from the input char.
        e# Character Character - -> Long
_{0<}#  e# Find the index of the first negative integer.
(_      e# Subtract 1 from the index and push a copy.
@=)     e# Select the last non-negative integer from the array and add 1.
S@      e# Push a space and rotate the decremented index on top of it.
"…"     e# Push a string that encodes the months' names.
255b23b e# Convert from base 255 to 23.
'af+    e# Add the resulting digits to the character 'a'.
'c/     e# Split at occurrences of 'c' (used as separator).
=       e# Select the chunk that corresponds to the index.
_,9=    e# Check if its length is 9 (Floopdoor).
{\?}&   e# If so, swap and execute ternary if.
        e# Since the string " " is truthy, S Month Day ? -> Month.
(eu\    e# Shift out the first char, convert it to uppercase and swap.

SWI-Prolog, 237 232 213 bytes
a(X):-L=[22:"Qupu",39:"Blinkorp",63:"Paas",80:"Karpasus",81:"Floopdoor",109:"Dumaflop",141:"Lindilo",208:"Fwup"],nth1(I,L,A:B),X<A,J is I-1,(nth1(J,L,Z:_),Y=X-Z;Y=X),R is Y+1,(X=80,write(B);writef("%w %w",[R,B])).

Here we use Prolog's backtracking mechanism to repeatedly apply nth1/3 to the list L, to get the first element LastDay+1:MonthName of L for which X < LastDay+1 holds. We then look for the month immediately before this one in the list to evaluate the day of the month.

Q, 134 146 Bytes
second cut -- program (146 bytes)
v:bin[l:0 22 39 63 80 81 109 141 208;x:(*)"I"$.z.x];1(,/)($)$[v=4;`;(1+x-l v)," "],`Qupu`Blinkorp`Paas`Karpasus`Floopdoor`Dumaflop`Lindilo`Fwup v;

first cut -- function (134 bytes)
{v:bin[l:0 22 39 63 80 81 109 141 208;x];(,/)($)$[v=4;`;(1+x-l v)," "],`Qupu`Blinkorp`Paas`Karpasus`Floopdoor`Dumaflop`Lindilo`Fwup v}

testing
q){v:bin[l:0 22 39 63 80 81 109 141 208;x];(,/)($)$[v=4;`;(1+x-l v)," "],`Qupu`Blinkorp`Paas`Karpasus`Floopdoor`Dumaflop`Lindilo`Fwup v} each 0 32 62 77 80 99 128 207
"1 Qupu"
"11 Blinkorp"
"24 Paas"
"15 Karpasus"
"Floopdoor"
"19 Dumaflop"
"20 Lindilo"
"67 Fwup"

you're correct -- i edited the answer to make it a full program rather than a function and so that it prints to stdout w/o the quotation marks as per the question rules

Julia, 231 216 184 175 bytes
r=readline()|>int
l=[141,109,81,80,63,39,22,0]
m=split("Qupu Blinkorp Paas Karpasus Floopdoor Dumaflop Lindilo Fwup")
i=findfirst(j->r>=j,l)
print(i==4?"":r-l[i]+1," ",m[9-i])

This reads a line from STDIN and converts it to an integer, finds the first element of a reversed list of month start days where the input is greater than or equal to the start, then prints accordingly.

Swift 1.2, 256 bytes
var d=Process.arguments[1].toInt()!,f="Floopdoor",n=[("Qupu",22),("Blinkorp",17),("Paas",24),("Karpasus",17),(f,1),("Dumaflop",28),("Lindilo",32),("Fwup",67)]
for i in 0..<n.count{let m=n[i]
if d>=m.1{d-=m.1}else{println((m.0==f ?"":"\(d+1) ")+m.0)
break}}

To run put the code alone in a .swift file and run it using swift <filename> <inputNumber>

Java, 357 339 bytes
It's not the most efficient, but I do like how it works. It creates the entire Flooptonia calendar and then looks up what date the number is.
class X{public static void main(String[]q){String n[]={"Qupu","Blinkorp","Paas","Karpasus","Floopdoor","Dumaflop","Lindilo","Fwup"},l[]=new String[209];int m=0,d=0,i,b[]={0,22,39,63,80,81,109,141,208};for(i=0;i++<208;d++){l[i]=(m==4?"":d+" ")+n[m];if(i>b[m+1]){m++;d=0;}}System.out.print(l[new java.util.Scanner(System.in).nextInt()+2]);}}

Input/Output:
77 --> 15 Karpasus
 80 --> Floopdoor
Spaced and tabbed out:
class X {
    public static void main(String[] q) {
        String n[] = { "Qupu", "Blinkorp", "Paas", "Karpasus", "Floopdoor", "Dumaflop", "Lindilo", "Fwup" },
          l[]=new String[209];
        int m = 0,
          d = 0,
          i,
          b[] = { 0, 22, 39, 63, 80, 81, 109, 141, 208 };
        for(i = 0; i++ < 208; d++) {
            l[i]=(m == 4 ? "" : d + " ") + n[m];
            if(i > b[m+1]){
                m++;
                d = 0;
            }
        }
        System.out.print(l[ new java.util.Scanner(System.in).nextInt() + 2 ]);
    }
}

I challenge you! View my answer! =)

JavaScript using ES6 171 164 163 bytes
I'm not the best JavaScript programmer but I tried my best and ended up with the following code
f=(n)=>[0,22,39,63,80,81,109,141,208].some((e,j,a)=>n<a[j+1]&&(r=(j-4?n-e+1+' ':'')+"Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0)[j]))&&r;

To see the result you need to refer above code in a html file and use similar to the code below

In the above code fp.js is the file that contains the javascript code.
Combined HTML and JavaScript code with indent is

        f=(n)=>[0,22,39,63,80,81,109,141,208].some(
          (e,j,a)=>n<a[j+1]&&(r=(j-4?n-e+1+' ':'')+"Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0)[j]))
        &&r;

        t = [0, 32, 62, 77, 80, 99, 128, 207];
        for (i = 0; i < t.length; i++)
            document.getElementById('o').innerHTML += f(t[i]) + '
';

Edit:
I'd like to thank Vihan for helping me remove the return statement and reduce my code by 17bytes
@ipi, thanks for helping me save 7 bytes

Note: You can see the result only in browsers Firefox version 22+ and
  Google Chrome 45+ because of using ES6 arrow functions

@vihan1086, Thanks for your suggestion

I don't have access to a browser with arrow notation support right now (so I haven't tested this) but you should be able to replace your month array with "Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0) and save 7 bytes.

Thanks ipi, i was splitting by a space, but the zero saved me two bytes! You must write a complete program I think this has to run alone, you might have to use something like prompt().

@ipi, Thanks for your comment

@Vartan, Thanks to your answer, I saved 1 byte

glad it helped. I still think you need to add something like ;alert(f(prompt())) to meet the complete program requirement

@Vartan, JavaScript is never complete without HTML except in few cases like node.js. Both of our codes will not work without HTML. I thought about using it as an expression but for some reason I ended up using a function I don't know why.

Java, 275 269 266 257 256 252 246 244 243 bytes
class X{public static void main(String[]w){int x=new Short(w[0]),i=1,a[]={-1,21,38,62,79,80,108,140,207};w="Qupu,Blinkorp,Paas,Karpasus,Floopdoor,Dumaflop,Lindilo,Fwup".split(",");while(x>a[i++]);System.out.print((i==6?"":x-a[i-=2]+" ")+w[i]);}}

Formatted:
class X {
    public static void main(String[] w) {
        int x = new Short(w[0]),
            i = 1,
            a[] = { -1, 21, 38, 62, 79, 80, 108, 140, 207 };
            w = "Qupu,Blinkorp,Paas,Karpasus,,Dumaflop,Lindilo,Fwup".split(",");
        while (x > a[i++]);
        System.out.print(i == 6 ? "Floopdoor" : x - a[i-=2] + " " + w[i]);
    }
}

Interestingly, it's a few bytes shorter than this
class X {
    public static void main(String[] w) {
        int x = new Short(w[0]);
        System.out.print(x < 22 ? x + 1 + " Qupu" : x < 39 ? x - 21
                + " Blinkorp" : x < 63 ? x - 38 + " Paas" : x < 80 ? x - 62
                + " Karpasus" : x < 81 ? "Floopdoor" : x < 109 ? x - 80
                + " Dumaflop" : x < 141 ? x - 108 + " Lindilo" : x < 208 ? x
                - 140 + " Fwup" : "");
    }
}

Well played Luigi!

Save 6 bytes with "new Short(w[0])" instead of "Integer.valueOf(w[0])".

@AndrewTrewin great tip, thank you!

Python 2, 168 bytes
n=input();e=[-1,21,38,62,80,108,140,207];m=1
while n>e[m]:m+=1
print[`n-e[m-1]`+' '+'Qupu Blinkorp Paas Karpasus Dumaflop Lindilo Fwup'.split()[m-1],'Floopdoor'][n==80]

This treats day 80 internally as 18 Karpasus, but then ignores it when called to print.  Also, Python 2's input() function (as opposed to raw_input()) was convenient here.

Perl 5, 140
Requires running via perl -E:
$i=<>+1;$i-=$b=(22,17,24,17,1,28,32,67)[$c++]while$i>0;say$b>1&&$i+$b.$",(x,Qupu,Blinkorp,Paas,Karpasus,Floopdoor,Dumaflop,Lindilo,Fwup)[$c]

Test output (stolen test code from @Dennis):
$for d in 0 32 62 77 80 99 128 207; do perl -E '$i=<>+1;$i-=$b=(22,17,24,17,1,28,32,67)[$c++]while$i>0;say$b>1&&$i+$b.$",(x,Qupu,Blinkorp,Paas,Karpasus,Floopdoor,Dumaflop,Lindilo,Fwup)[$c]' <<< $d; echo; done
1 Qupu

11 Blinkorp

24 Paas

15 Karpasus

Floopdoor

19 Dumaflop

20 Lindilo

67 Fwup

Haskell, 171 167 bytes
main=interact$f.read
f 80="Floopdoor"
f n=(g=<<zip[22,17,24,18,28,32,67](words"Qupu Blinkorp Paas Karpasus Dumaflop Lindilo Fwup"))!!n
g(n,s)=map((++' ':s).show)[1..n]

The program reads it's input from stdin which must not end in NL. Terminate input with EOF/^D or use something like echo -n 80 | ./what-day-is-it. (Some echos don't understand the -n switch and omit the NL by default).
How it works: The main function reads the input, converts it to an Integer and calls f which returns a literal Floopdoor in case of an input of 80 or builds up a list of all possible dates, i.e. ["1 Qupu", "2 Qupu", ... "1 Blinkorp", ... "67 Fwup"] from which it picks the nth element. I make Karpasus is one day longer.  18 Karpasus is at position 80 and fixes the missing Floopdoor in the list.
Edit: @MtnViewMark had the idea of the 18 Karpasus trick and saved 4 bytes.

I think you can save 4 bytes by pretending Karpasus is 18 days long, removing ,1 and  x - since 80 will be caught by the pattern match for it.

@MtnViewMark: very clever. Thanks a lot.

Swift 2.0, 220 bytes
Nothing clever, just filters from a collection of tuples...
func d(n:Int)->String{return n==80 ?"Floopdoor":[("Qupu",21,0),("Blinkorp",38,22),("Paas",62,39),("Karpasus",79,63),("Dumaflop",108,81),("Lindilo",140,109),("Fwup",208,141)].filter{$0.1>=n}.map{"\($0.0) \(n-$0.2+1)"}[0]}

Edited to correct bug, removed a space

"You must write a complete program." So it can't be a function.

JavaScript (ES6 on Node.js), 196 bytes
Takes one command line argument:
a=+process.argv[2];for(d of['22Qupu','17Blinkorp','24Paas','17Karpasus','01Floopdoor','28Dumaflop','32Lindilo','67Fwup']){if(a<(z=parseInt(d)))return console.log((z>1?a+1+' ':'')+d.slice(2));a-=z}

Demo
As there is no command-line argument (process.argv) in the browser, the code in the snippet has been placed in a function that accepts an argument:

// Snippet stuff
console.log = function(x){O.innerHTML += x + '\n'};

// Flooptonia function
function flooptonia(a) {
  a = +a;
  for (d in y=['22Qupu', '17Blinkorp', '24Paas', '17Karpasus', '01Floopdoor', '28Dumaflop', '32Lindilo', '67Fwup']) {
    if (a < (z = parseInt(y[d]))) return console.log((z > 1 ? a + 1 + ' ' : '') + y[d].slice(2));
    a -= z
  }
}

// Test
['0', '32', '62', '77', '80', '99', '128', '207'].map(flooptonia);
Test values: [0, 32, 62, 77, 80, 99, 128, 207]

Swift 2.0, 215 204
let(n,t)=(Int(readLine()!)!,[(141,"Fwup"),(109,"Lindilo"),(81,"Dumaflop"),(63,"Karpasus"),(39,"Paas"),(22,"Blinkorp"),(0,"Qupu")])
print({(n==80 ?"Floopdoor":"\(n-$0.0+1) "+$0.1)}(t[t.indexOf{$0.0<=n}!]))

This is a full program which asks the user to input the number in STDIN.

Matlab, 187 bytes
d=input('');l=[141 109 81 80 63 39 22 0];t=find(d>=l,1);m=strsplit('Fwup Lindilo Dumaflop Floopdoor Karpasus Paas Blinkorp Qupu');f='%d %s';if t==4;f='%d\b%s';end;fprintf(f,d-l(t)+1,m{t})

Expanded version:
d=input('');
l=[141 109 81 80 63 39 22 0];
t=find(d>=l,1);
m=strsplit('Fwup Lindilo Dumaflop Floopdoor Karpasus Paas Blinkorp Qupu');
f='%d %s';
if t==4;
    f='%d\b%s';
end
fprintf(f,d-l(t)+1,m{t})

Reads a line from the console (stdin), finds the first element of a reversed list of month start days where the input is greater than or equal to the array element, then prints accordingly.
This is almost identical to the Julia answer, except for the display stage. (We can't beat their ternary operator, unavailable in Matlab). To make up having to explicit a full if statement, we use a little trick (a Backspace character in the print format) to "erase" the number 1 for the special day/month Floopdoor

In collaboration with the Matlab and Octave chat participants.

Javascript ES5 using 168 bytes
m=[-1,21,38,62,79,80,108,140];for(n=prompt(i=0);n>m[i+1]&&i++<8;);alert((i-4?n-m[i]+" ":"")+"Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0)[i])

Ungolfed:
m=[-1,21,38,62,79,80,108,140];   // create range of starting indexes - 1

for(                             // begin for loop
  n=prompt(i=0);                 // initialize i to zero and prompt user
  n>m[i+1] && i++ < 8;           // exit if n>0; increment i; exit if i was < 8
  );                             // end for loop

alert(
  (i-4 ? n-m[i]+" ":"") + // special floopdoor case
  "Qupu0Blinkorp0Paas0Karpasus0Floopdoor0Dumaflop0Lindilo0Fwup".split(0)[i]);

  //^  create an array of strings by splitting at zero. Then, select element i

C, 241 bytes
Nothing too exciting. Could have shaved 27 bytes had it require to be a complete program.
main(c,s)char**s;{c=atoi(s[1]);c-80?printf("%d ",c<22?c+1:c<39?c-21:c<63?c-38:c<80?c-62:c<109?c-80:c<141?c-108:c-140):0;puts(c<22?"Qupu":c<39?"Blinkorp":c<63?"Paas":c<80?"Karpasus":c<81?"Floopdoor":c<109?"Dumaflop":c<141?"Lindilo":"Fwup");}


text:
Creasing for Loot
Introduction
After a long battle, you have managed to defeat a Sphinx in a contest of riddles.  The Sphinx, impressed with your skill, wishes to give you a reward commensurate with your cleverness, and conjures into existence a strip of magical parchment divided into eight boxes, each containing a numeral.
"Crease the parchment," says the Sphinx, "such that the boxes overlap, and those boxes will merge either through addition or multiplication.  When one box remains, its value will be your reward in gold coins."
Task
You must write a program or function which takes as input a list/array/whatever of eight natural numbers, and returns/prints the maximum possible reward obtainable through a series of 'crease' operations.
Mechanics
The 'crease' operation is performed on some number of cells, and with either + or * as the operator.  The first n cells of the list are folded across and merged with their destination cells using the operator.  Any cells which are not consumed in the merge operation are left unmodified.
Here is an example of creasing using n=3 cells:

using either addition, which would result in this:

or multiplication, which would result in this:

Note:  For simplicity, creasing with fewer than 1 cell is disallowed, as is creasing with a number of cells greater than or equal to the length of the list.  However, a list can by creased by more than half its cell count.
A list of 8 cells can be creased by 5, resulting in a new list of length 5:
[0,1,2,3,4,5,6,7] creased by 5 cells using the + operator would give [9,9,9,1,0].
Scoring
Standard code golf rules - the code which produces correct output and has the fewest number of bytes wins.
Bonus:  If your code also returns/prints the sequence of crease operations which leads to the maximal reward, multiply your score by 0.8.  Example output might look like:
crease 5 +
crease 2 *
crease 2 +
crease 1 *

Examples
Test your code using these inputs and results, in the form of input - maximum reward:
[0, 1, 2, 3, 4, 5, 6, 7] - 7560
[0, 9, 0, 3, 2, 6, 1, 5] - 1944
[0, 1, 0, 3, 0, 2, 0, 4] - 36
[6, 0, 9, 1, 9, 0, 7, 3] - 11907
[0, 5, 2, 0, 1, 3, 8, 8] - 2560

The example output under the "Scoring" heading is invalid.  After creasing 5 and 2 there are only 3 cells left, so creasing 3 makes no sense.

Good point.  I'll change it.

Pyth, 31 bytes
Le+bSyMsm,sMJ.T,_<bd>bdm*FkJtUb

This defines a function, y, which computes the crease value.
Demonstration.
This uses the recusive method, taking the maximum of the score of every possible successor.
The base case of the recursion is implemented by concatenating the input to the sorted values of the possible successors, and then taking the end of the resultant list. If there is only 1 element in the input, there are no successors, and therefore the end of the list is the one element in the input.

It's hard to imagine this getting beaten.  Maybe CJam has a chance?

C#, 275 272 bytes
It's simply a recursive function that traverses every branch and returns the best score.
Indented for clarity:
using M=System.Math;
int F(int[]n){
    int b=0,g,h,i=0,j,k,l=n.Length;
    if(l<2)
        return n[0];
    for(;++i<l;){
        int[]m=new int[k=M.Max(i,l-i)],o=new int[k];
        for(j=0;j<k;j++){
            m[j]=((g=i-j-1)<0?0:n[g])+((h=i+j)<l?n[h]:0);
            o[j]=h<l&g>=0?n[g]*n[h]:m[j];
        }
        b=M.Max(b,M.Max(F(m),F(o)));
    }
    return b;
}

source: Stack Exchange

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

sort: votes


text:
Swap capitalization of two strings
your shift key is broken. wheNever you type two lines, the cApitaL
LetteRs in them get swappeD. you must write a program to fiX THIS!
Description
The input is two strings, s1 and s2, equal in length. They will each contain only printable ASCII and be at least one character in length. You may input these as two strings, an array of two strings, or a single string with s1 and s2 separated by either a tab or newline.
The output is the following:

For each character c in s1:

If the character is not a letter, output it unchanged.
Otherwise, if c is a letter:

Find the matching character (the one at the same index) in s2.

If it is a capital letter, output c capitalized.
If it is a lowercase letter, output c in lowercase.
Otherwise, output c unchanged.

Then do the same thing, except with s1 and s2 switched.

Essentially, all letters in s1 for which the matching character in s2 is capital should be capitalized, and all letters in s1 with a lowercase letter at the same index in s2 should become lowercase (and vice versa).
Test cases
Input:
ABCDEfghijKlMnOpqrstuvwxyz
aaaaaaaaaaaaaaaa----------

Output:
abcdefghijklmnopqrstuvwxyz
AAAAAaaaaaAaAaAa----------

Input:
PRogrammiNG puzZLes & CODe golf
SdlkhkfaladlKsdlalksdg7ldklDgsl

Output:
Programming Puzzles & Code Golf
SDlkhkfalADlksdLAlksdg7LDkldgsl

Input:
AAAbbb111
Cc2Dd3Ee4

Output:
AaABbb111
CC2dd3Ee4

I cannot for the life of me figure out how this could be caused by a broken shift key, but who am I to argue with the almighty Doorknob? :P

Does the input have to be on the same line? Or can I use some other character (a tab?) to separate them?

@Dennis No, the input must be provided as shown in the question.

@kirbyfan64sos You may take either two strings, an array of strings, or two strings separated by either a tab or a newline. I'll edit that into the question.

is a trailing newline allowed?

@vihan1086 Yes.

Is this limited to ANSI chars not Unicode, i.e. there is no concern about Turkish and German for instance?

@Jodrell "They will each contain only printable ASCII"

so swapping bit 6 would be sufficient?

@Jodrell Not if the input contains numbers.

You are not specific on the output format. I am in doubt whether you allow to return a list of items instead of two lines separated by a \n character, but I will change my answer from the second to the first, as I've already seen other's answers doing it!

Pyth, 19 18 bytes
LCmrW&@dG@drG1d2Cb

This defines a function y that accepts and return a list of strings.
Verify all test cases at once in the Pyth Compiler/Executor.
Thanks to @Jakube for golfing off 1 byte.
How it works
                   " (implicit) Initialize G to 'abcdefghijklmnopqrstuvwxyz'.

L                  " Define y(b):
                Cb "   Zip to turn the two strings into an array of char pairs.
  m                "   Map (implicit variable d):
      @dG          "     Intersect d with G.
         @drG1     "     Intersect d with G.upper().
    W&             "     If both are non-empty:
   r          d2   "       Apply swapcase() to d.
 C                 "   Zip to turn the character pairs back into two strings.

CJam, 25 bytes
{z{_el_eu&\__:^32&f^?}%z}

This is an anonymous function that pops an array of strings from the stack and leaves one in return.
In supported browsers, you can verify all test cases at once in the CJam interpreter.
Test cases
Code
qN/2/                     e# Read input and split into arrays of two strings.

{z{_el_eu&\__:^32&f^?}%z}

%                         e# Map the block over all string arrays.
:+N*                      e# Separate the strings by linefeeds.

Input
ABCDEfghijKlMnOpqrstuvwxyz
aaaaaaaaaaaaaaaa----------
PRogrammiNG puzZLes & CODe golf
SdlkhkfaladlKsdlalksdg7ldklDgsl
AAAbbb111
Cc2Dd3Ee4

Output
abcdefghijklmnopqrstuvwxyz
AAAAAaaaaaAaAaAa----------
Programming Puzzles & Code Golf
SDlkhkfalADlksdLAlksdg7LDkldgsl
AaABbb111
CC2dd3Ee4

How it works
z                       e# Zip to transform the array of strings into an array
                        e# of character pairs.
 {                  }%  e# For each character pair:
  _el                   e#   Push a copy and convert to lowercase.
     _eu                e#   Push a copy and convert to uppercase.
        &               e#   Intersect. The result will be an empty string if
                        e#   and only if both characters are letters.
         \              e#   Swap the character pair on top of the stack.
          __            e#   Push two copies.
            :^          e#   XOR both characters.
              32&       e#   Logical AND with 32. This pushes 32 for letters of
                        e#   different cases and 0 for letters of the same case.
                 f^     e#   XOR each character with the result.
                   ?    e#   Select the original copy for non-empty intersection
                        e#   and the modified one otherwise.
                      z e# Zip to turn the characters pairs back into two strings.

C, 126 bytes
This is my first attempt at a code golf, ever. Let me know if I did anything wrong.
I'm using bitwise operations to perform the switching
Golfed:

main(u,a,s,t)char**a,*s,*t;{for(s=a[1],t=a[2];*t;s++,t++)isalpha(*s)*isalpha(*t)?u=(*t^*s)&32,*t^=u,*s^=u:0;*s=10;puts(a[1]);}

Ungolfed:
main(u,a,s,t) char**a,*s,*t; {       // K&R style arguments
    for(s=a[1],t=a[2];*t;s++,t++)    // initialize loop.
        isalpha(*s) * isalpha(*t) ? // ensure both characters are letters (if)
            u = (*t^*s) & 0x20,      // check if characters have swapped case
            *t^=u,                   // if so, xor the bit which represents case
            *s^=u                    // for both characters in the string.
        :0;                          // end ternary statement (endif)
    *s=10;                           // replace null terminator in first string
    puts(a[1]);                      // with newline. This allows both output to
}                                    // be printed out all at once

edit: replaced && with *

SQL (PostGreSQL), 427 Bytes
Despite it's huge size, this ended up being quite a bit smaller than I expected.  I wasn't quite sure I was going to be able to do it to be honest.  I suspect there is a lot that still can be done:)
CREATE FUNCTION F(TEXT,TEXT)RETURNS TABLE(S TEXT) AS'SELECT unnest(array[string_agg(CASE WHEN T~''[A-Z]''THEN upper(S)WHEN T~''[a-z]''THEN lower(S)ELSE S END,''''),string_agg(CASE WHEN S~''[A-Z]''THEN upper(T)WHEN S~''[a-z]''THEN lower(T)ELSE T END,'''')])FROM(SELECT ROW_NUMBER()OVER()N,S FROM regexp_split_to_table($1,'''')X(S))A JOIN(SELECT ROW_NUMBER()OVER()M,T FROM regexp_split_to_table($2,'''')Y(T))B ON N=M'LANGUAGE SQL

Formatted and commented
-- Declare the function spec
CREATE FUNCTION F(TEXT,TEXT)RETURNS TABLE(S TEXT) AS
'SELECT unnest(   -- turns array into a table
    array[        -- build array of the column results
    string_agg( -- Aggregate the result into a string
        CASE
        WHEN T~''[A-Z]''THEN upper(S) -- uppercase it if corresponding char is uppercase
        WHEN T~''[a-z]''THEN lower(S) -- lowercase it if corresponding char is lowercase
        ELSE S END
        ,''''),
    string_agg( -- Same as the previous but swap strings
        CASE
        WHEN S~''[A-Z]''THEN upper(T)
        WHEN S~''[a-z]''THEN lower(T)
        ELSE T END
        ,'''')
    ])
FROM
    -- split the first string
   (SELECT ROW_NUMBER()OVER()N,S FROM regexp_split_to_table($1,'''')X(S))A
    JOIN
    -- split the second string
   (SELECT ROW_NUMBER()OVER()M,T FROM regexp_split_to_table($2,'''')Y(T))B
   ON N=M
'
LANGUAGE SQL

Test run
SELECT F(A,B) AS Result
FROM (VALUES
    ('AAAbbb111', 'Cc2Dd3Ee4'),
    ('ABCDEfghijKlMnOpqrstuvwxyz', 'aaaaaaaaaaaaaaaa----------'),
    ('PRogrammiNG puzZLes & CODe golf', 'SdlkhkfaladlKsdlalksdg7ldklDgsl')
    )A(A,B)

Result
-----------------------------
AaABbb111
CC2dd3Ee4
abcdefghijklmnopqrstuvwxyz
AAAAAaaaaaAaAaAa----------
Programming Puzzles & Code Golf
SDlkhkfalADlksdLAlksdg7LDkldgsl

Julia, 140 bytes
f(s,t)=(C(x,y)=(i=0;z="";for c=x i+=1;z*=string(isalpha(c)?isupper(y[i])?uppercase(c):islower(t[i])?lowercase(c):c:c)end;z);(C(s,t),C(t,s)))

This creates a function that accepts two strings and returns a tuple of strings. Nothing particularly clever is going on here; we simply define an inner function that directly implements the algorithm in the spec and call it twice.
Ungolfed:
function f(s, t)
    C(x, y) = begin
        i = 0
        z = ""
        for c in x
            i += 1
            if isalpha(c)
                if isupper(y[i])
                    z *= string(uppercase(c))
                elseif islower(y[i])
                    z *= string(lowercase(c))
                else
                    z *= string(c)
                end
            else
                z *= string(c)
            end
        end
        return z
    end

    return (C(s, t), C(t, s))
end

JavaScript ES6, 128 108 bytes
s=(a,b,t)=>[...a].map((l,i)=>/[^a-z]/.exec(b[i])?l.toUpperCase():l.toLowerCase()).join``+(t?'':`
`+s(b,a,1))

JavaScript's toUpperCase() and toLowerCase() take up a lot of bytes but String.fromCharCode() is even longer

This doesn't account for the condition where a character in s2 is not a letter and the corresponding character in s1 is uppercase. In this case, c in s1 must be returned unchanged.

@c.P.u1 I've addressed that :)

Mathematica, 173 169 155 bytes
f=0>1;t=!f;c=Characters;u=ToUpperCase;StringJoin/@MapThread[#@#2&,{Reverse[{LetterQ@#,#==(u@#)}&/@c@#/.{{f,_}->(#&),{t,t}->u,{t,f}->ToLowerCase}&/@#],c/@#},2]&

This is a function taking an array of two strings, e.g. {"Foo","bAR"} and outputting an array of two strings.  Un-spatially-compressing it, rewriting the scheme f@x as f[x] wherever it appears, expanding the notation abbreviations (f=0>1 a.k.a. False,t=!f a.k.a. True, c=Characters, and u=ToUpperCaseQ), and un-replacing UpperCaseQ[#] with #==u@# (this character equals its uppercased version), it is:
StringJoin /@ MapThread[#[#2] &, {
    Reverse[
        { LetterQ[#], UpperCaseQ[#] } & /@ Characters[#] /.
        { {False, _} -> (# &), {True, True} -> ToUpperCase,
          {True, False} -> ToLowerCase } & /@ #
    ],
    Characters /@ #
}, 2] &

Interfacing:  the trailing & makes this a function.  Its argument is inserted as the "#" at both instances of /@ #.  For instance f=0>1; ... & [{"AAAbbb111", "Cc2Dd3Ee4"}] produces the output {AaABbb111,CC2dd3Ee4}.
Processing:  Told in usual outside in order:

The output of the MapThread[...] is a list of two lists of characters.  StringJoin is applied to each of these two lists of characters to produce a list of two strings, the output.
MapThread[#[#2]&, ... , 2] acts on an array of two 2-by-n element lists.  The first list is a 2-by-n array of functions.  The second list is a 2-by-n array of characters, Characters /@ #, the lists of characters in the two input strings.  It works at depth 2, i.e., on the functions and individual characters.
Reverse[...] swaps the two sublists of functions so that MapThread will apply the second string's functions to the first string and vice versa.
{ ... } & is an anonymous function that is applied to each of the two input strings.
{LetterQ[#], UpperCaseQ[#]} & /@ Characters[#] splits a string into a list of characters, then replaces each character with two element lists.  In these two element lists, the first element is True if the character is a letter and False otherwise, similarly, the second element indicates whether the character is upper case.  UpperCaseQ[] cannot return true if it does not receive a letter.
/. {{False, _} -> (# &), {True, True} -> ToUpperCase, {True, False} -> ToLowerCase} replaces these two element lists with functions.  (Expansion of the abbreviations t and f occurs before any matching is attempted.)  If a two element list has False as its first element, it is replaced with the function (# &), the identity function.  (The parentheses are necessary, otherwise the arrow binds more tightly than the ampersand.)  Otherwise the two element list starts with True, the character was a letter, and we output the functions ToUpperCase and ToLowerCase corresponding to its case.  (Checking for this last False is unnecessary, in fact {_,_}->ToLowerCase would work, catching anything that hadn't been replaced yet, but this would be no shorter and more obscure.)

The only challenge was figuring out a succinct way to zip a two dimensional array of functions to an array of arguments.
Edit:  Thanks to @Martin Büttner for catching "helpful" cut/paste linebreak backslashes, the 1>0 and 1<0 abbreviations, and also for the guidance to count length in bytes not characters (whatever those are :-) )
Edit2:  Further thanks to @Martin Büttner for pointing out that polluting the global namespace is acceptable golf, reminding me of one character function application, and suggesting replacing the two uppercase functions with an abbreviation for one and using the one to emulate the other (saving four characters).  (I think he's done this before.  :-)  )

More golfitude: use f@g instead of f[g] (throughout your code). I'm also quite sure you don't need a block. Just do (f=0>1;t=!f;c=Characters;StringJoin/@...)&. This pollutes the global namespace, but we're totally fine with that when golfing. Also, I haven't counted, but you might be able to save bytes by storing ToUpperCase in a variable (u, say) and replacing UpperCaseQ@# with #==u@#.

Python 3, 131 bytes
def j(s,g):p=lambda s,g:''.join(i.upper()if j.istitle()else i.lower()if j.islower()else i for i,j in zip(s,g));return p(s,g),p(g,s)

Function returns strings in a tuple

@mbomb007 May I ask the point of editing my post? In my opinion strikethroughs are messy, that's why I never use them.

It's a standard format, and it gives a bit of credit to people that helped you golf it, by showing that this isn't what you originally came up with. Otherwise, in order to see that you changed it significantly at all, they have to view edit history. It's more user-friendly to show the byte-change, but I guess it's up to you whether or not to credit those who helped you.

See this meta post for further description of why it's helpful.

@mbomb007 The accepted answer to the meta post you link says there isn't and doesn't need to be a policy about this, even though it does give reasons one might like to include them, so I think it's up to each poster.

@xnor Thanks for summarizing what I said above. Very helpful.

Erlang, 157 bytes
f(A,B)->S=string,G=fun(A,B)->[if Q>64andalso Q<91->S:to_upper(P);Q>96andalso Q<123->S:to_lower(P);true->P end||{P,Q}<-lists:zip(A,B)]end,G(A,B)++"\n"++G(B,A).

Zips the two strings (actually, lists) into a two-character-tuple list and maps each character to the appropriate case using a list comprehension.

Python 2, 101 bytes
lambda*I:["".join([a.upper(),a.lower(),a][~-b.isalpha()or"Z"<b]for a,b in zip(*X))for X in I,I[::-1]]

An anonymous function which takes two strings and returns the output strings in a list. I've marked this as Python 2 because Python 3 doesn't allow I,I[::-1] to sit alone at the end like that.

Python, 126 bytes
t="".join;s="low","upp";y=lambda a,b:eval("a"+".%ser()"%s[b.isupper()]*b.isalpha());f=lambda a,b:(t(map(y,a,b)),t(map(y,b,a)))

Function f returns strings in a tuple

That is now fixed, it now works for all the test cases.

C, 181 bytes
char*x,*y;main(int a,char**_){a?x=_[2],y=_[1],main(0,0),putchar(10),x=_[1],y=_[2],main(0,0):(*x?putchar(!isupper(*x)?!islower(*x)?*y:tolower(*y):toupper(*y)),x++,y++,main(0,0):0);}

Had trouble shortening standard library names in a worthwhile way, (#define'ing them takes 11 characters of overhead). Uses main recursion and global variables x and y as arguments.
main(<non-zero>,argv) = call main(0,{argv[1],argv[2]}) then print newline then call main(0,{argv[2],argv[1]})
main(0,{x,y}) = if x is end of string return 0, else print correct case of first character of x and call main(0,{x+1,y+1}).
Run with the two strings as arguments.

Are you stealing my username? ;)

147 bytes

C - 164 153 Bytes - GCC
#define r z[_][w]
main(_,z,w)char**z;{while(--_)for(w=0;r;r+=r<25?97:r<91&&r>64?z[!(_-1)+1][w]-=32,_-1?z[_-1][w]-=97:0,32:0,w++);puts(z[1]),puts(z[2]);}

gcc prog.c
./a.out AfdgF a2dfsd
Will update if I can get wc -c down. Works very well actually

Could you post an ungolfed version? I'm curious how this works, but have a hard time reading through your symbols ;)

Sure thing. Give me a minute.

Ruby, 102
$><<gets.chars.zip(gets.chars).map{|i|/[a-z][A-Z]|[A-Z][a-z]/=~i*''?(i.map &:swapcase):i}.transpose*''

Takes the original strings, pairs off letters in arrays. If they are either lower/cap or cap/lower, then swapcase on both. Then transpose the arrays back into our ordered array.
This requires a trailing newline in input.

F#, 211 chars
let n x y=List.fold2(fun a i j->a@match j with|c when c>='A'&&c<='Z'->[Char.ToUpper i]|c when c>='a'&&c<='z'->[Char.ToLower i]|_->[i])[](x|>Seq.toList)(y|>Seq.toList)|>String.Concat
let m a b =n a b+"\n"+n b a

could be better ...

Matlab, 140
function [s,t]=f(s,t)
c=s>96&s<123;C=s>64&s<91;d=t>96&t<123;D=t>64&t<91;s(c&D)=s(c&D)-32;s(C&d)=s(C&d)+32;t(d&C)=t(d&C)-32;t(D&c)=t(D&c)+32;

Ungolfed:
function [s,t] = f(s,t)
c = s>96 & s<123;         % letters that are lowercase in 1st string
C = s>64 & s<91;          % letters that are uppercase in 1st string
d = t>96 & t<123;         % letters that are lowercase in 2nd string
D = t>64 & t<91;          % letters that are uppercase in 2nd string
s(c&D) = s(c&D) - 32;     % make uppercase in 1st string
s(C&d) = s(C&d) + 32;     % make lowercase in 1st string
t(d&C) = t(d&C) - 32;     % make uppercase in 2nd string
t(D&c) = t(D&c) + 32;     % make lowercase in 2nd string

Example:
>> [s,t]=f('PRogrammiNG puzZLes & CODe golf','SdlkhkfaladlKsdlalksdg7ldklDgsl')
s =
Programming Puzzles & Code Golf
t =
SDlkhkfalADlksdLAlksdg7LDkldgsl

C, 164 bytes
Pretty much implementing the algorithm as described in the problem. Takes 2 strings as input parameters.
char*a,*b;main(c,v)char**v;{for(a=v[1],b=v[2];*a&&*b;++a,++b)isupper(*a)&&islower(*b)?*a+=32,*b-=32:isupper(*b)&&islower(*a)?*b+=32,*a-=32:0;puts(v[1]);puts(v[2]);}

Ungolfed:
char *a, *b; /* Helpers */

main(c, v)
char **v;
{
    /* While strings not terminated... */
    for (a = v[1], b = v[2]; *a && *b; ++a, ++b)
        isupper(*a) && islower(*b)
            ? *a += 32, *b -= 32 /* Make first string lowercase, second uppercase */
            : isupper(*b) && islower(*a)
                ? *b += 32, *a -= 32; /* Make second string lowercase, first uppercase */

    puts(v[1]); /* print out first string */
    puts(v[2]); /* print out second string */
}

Perl 5.10+, 101 99 bytes
perl -p00e '/\n/;s/([a-z])(?=.{$-[0]}([a-z]))/$x=($1^$2)&" ";$s{$-[2]}=$2^$x;$1^$x/egis;s|.|$s{$-[0]}//$&|eg'

96 bytes + 3 bytes for the command line flags p00. Takes a single newline-delimited string as input:
$ echo -e "AAAbbb111\nCc2Dd3Ee4" | perl -p00e '...'

Or you can enter input on STDIN:
$ perl -p00e '...'
AAAbbb111 <Enter>
Cc2Dd3Ee4 <Ctrl+D>

Broken down:
perl -p00e'  # Slurp everything into $_, print $_ automatically at the end
    /\n/;    # Match first newline, setting $-[0] to length(s1)

    s/
        ([a-z])  # Match a single letter in s1
        (?=
            .{$-[0]}  # Match n chars where n is length(s1) (until corresponding char in s2)
            ([a-z])   # Corresponding letter in s2
        )
    /
        $x=($1^$2)&" ";   # Check whether bit 6 is the same for both chars.
                          # (Only difference between a lowercase and uppercase ASCII letter
                          # is bit 6; ASCII space is 100000 in binary)

        $s{$-[2]}=$2^$x;  # Swap case of corresponding char in s2 and store in %s,
                          # with position as the key

        $1^$x             # Swap case of current char
    /egis;

    s|.|$s{$-[0]}//$&|eg  # Do a second pass through $_. If there's a value stored in %s
                          # corresponding to this position, use it
'

First attempt in scala, 138 chars
def f(s:String,t:String)={val g=(a:Char,o:Char)=>if(o.isUpper)a.toUpper else a.toLower;s.zip(t).map(c=>(g.tupled(c),g(c._2, c._1))).unzip}

f is a function that take the two input strings and do the job, with a local function, used two times, for changing case of strings.
The same code, with indentation and just a litte more readable names :
def f_ungolfed(first : String, second : String) = {
  val aux = (c1: Char, c2: Char) => if (c2.isUpper) c1.toUpper else c1.toLower
    first.zip(second).map(
         c => (aux.tupled(c), aux.tupled(c.swap))
    ).unzip
}

Jelly, 13 bytes
=Œu=/ị"Ɱż"Œs$

A monadic Link accepting and returning lists of two "strings" (lists of characters in Jelly).
Try it online!

Python 2, 97 bytes
lambda a,b:''.join([x,chr(ord(x)&95|ord(y)&32)][(x+y).isalpha()]for x,y in zip(a+'\n'+b,b+' '+a))

Try it online!

Tcl, 194 bytes
proc C a\ b {proc L x\ y {expr [[set S string] is u $y]?"[$S tou $x]":"[$S is lo $y]"?"[$S tol $x]":"$x"}
lmap x [split $a ""] y [split $b ""] {append s [L $x $y]
append t [L $y $x]}
list $s $t}

Try it online!

Haskell, 109 91 bytes
import Data.Char
(!)=zipWith f
f c|isUpper c=toUpper|isAlpha c=toLower|1<3=id
a#b=[b!a,a!b]

Thanks to @Laikoni for 16 bytes!
Try it online!

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

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


text:
Knödel numbers - Find Kn
The Knödel numbers are a set of sequences. Specifically, the Knödel numbers for a positive integer \$n\$ are the set of composite numbers \$m\$, such that all \$i < m\$, coprime to \$m\$, satisfy \$i^{(m-n)} \equiv 1 \mod m\$. The set of Knödel numbers for a specific \$n\$ is denoted \$K_n\$. (Wikipedia).
For example, \$K_1\$ are the Carmichael numbers, and OEIS A002997. They go like: \$\{561, 1105, 1729, 2465, 2821, 6601, ... \}\$. \$K_2\$ is OEIS A050990 and goes like, \$\{4, 6, 8, 10, 12, 14, 22, 24, 26, ... \}\$.
Your task
Your task is to write a program/function/etc. that takes two numbers, \$n\$ and \$p\$. It should return the first \$p\$ numbers of the Knödel Sequence, \$K_n\$.
This is code-golf, so shortest code in bytes wins!
Examples
1, 6   ->   [561, 1105, 1729, 2465, 2821, 6601]
2, 3   ->   [4, 6, 8]
4, 9   ->   [6, 8, 12, 16, 20, 24, 28, 40, 44]
3, 1   ->   [9]
3, 0   ->   []
21, 21 ->   [45, 57, 63, 85, 105, 117, 147, 231, 273, 357, 399, 441, 483, 585, 609, 651, 741, 777, 861, 903, 987]

Why is 4 not in the sequence K_4? i^(4-4) = 1 mod 4 is always true.

@isaacg MathWorld has the additional condition that m > n.

Pyth, 29 28 bytes
.f&tPZ!f&q1iTZt%^T-ZQZSZvzhQ

1 byte saved thanks to Jakube and orlp.
Demonstration.
Input in the form
p
n

A fairly straightforward calculation. Relative primeness is checked via Pyth's gcd function. This code showcases .f, Pyth's "first n satisfying" function.
I have incorporated the implicit condition that m > n by starting the search for m values at n + 1.

Haskell, 89 bytes
Very straightforward implementation. Defines a binary operator n!p.
n!p=take p[m|m<-[n+1..],any((<1).mod m)[2..m-1],and[i^(m-n)`mod`m<2|i<-[1..m],gcd i m<2]]

Example:
Prelude> 4!9
[6,8,12,16,20,24,28,40,44]

What is m>n for?

I have no idea. I was getting negative exponent errors on 21!21, and adding that in solved the problem.

I installed Haskell to try and figure out how to get rid of the m>n&& bit, changing m<-[4..] to m<-[n+1..] seems to work. You also get a byte count of 91!

Neat! Thanks, @Vioz.

@Vioz- So you meddled with Haskell without knowing Haskell before? How did you do it?

also, a tip - you can use any and all instead of or and and. sometimes these are shorter, and sometimes these are shorter.

@proudhaskeller Well, it's a fairly simple language to understand, so I just began investigating changing different things in the ranges to help fix the issue. I figured since the raising to the negative power was an issue, then obviously m's size was an issue, so I found the range it was defined and figured as long as the range started at a value greater than n the exponent wouldn't be negative

@Vioz- first time hearing someone saying Haskell is a simple language to understand. I mostly just hear of people who think they don't understand monads or purity or how to do stuff without loops. If Haskell is easy for you, then good luck with learning more of it! (If you want to, of course)

@proudhaskeller: I thought I'd checked, but turns out any is a bit shorter after all. Thanks!

Haskell, 90
a#b=gcd a b>1
n!p=take p[m|m<-[n+1..],any(m#)[2..m-1],all(\i->m#i||mod(i^(m-n))m<2)[1..m]]

much the same as @Marius 's answer, though developed independently.

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


text:
The Will Rogers Phenomenon
The so-called Will Rogers phenomenon describes a way to tweak statistics by raising the average in two (multi)sets when one element is moved between the two sets. As a simple example, consider the two sets
A = {1, 2, 3}
B = {4, 5, 6}

Their arithmetic means are  2 and 5, respectively. If we move the 4 to A:
A = {1, 2, 3, 4}
B = {5, 6}

Now the averages are 2.5 and 5.5, respectively, so both averages have been raised through a simple regrouping.
As another example, consider
A = {3, 4, 5, 6} --> A = {3, 5, 6}
B = {2, 3, 4, 5} --> B = {2, 3, 4, 4, 5}

On the other hand, it's not possible to raise both averages for the sets
A = {1, 5, 9}
B = {4, 5, 7, 8}

The Challenge
Given two lists of non-negative integers, determine whether it is possible to raise both averages by moving a single integer from one list to the other.
The average of an empty list is not defined, so if one of the lists contains only one element, this element cannot be moved.
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
Input may be taken in any convenient string or list format.
You must not assume that the elements in each list are unique, nor that they are sorted. You may assume that both lists contain at least one element.
Output should be truthy if both averages can be raised by moving a single integer and falsy otherwise.
This is code golf, so the shortest answer (in bytes) wins.
Test Cases
Truthy:
[1], [2, 3]
[1, 2, 3], [4, 5, 6]
[3, 4, 5, 6], [2, 3, 4, 5]
[6, 5, 9, 5, 6, 0], [6, 2, 0, 9, 5, 2]
[0, 4], [9, 1, 0, 2, 8, 0, 5, 5, 4, 9]

Falsy:
[1], [2]
[2, 4], [5]
[1, 5], [2, 3, 4, 5]
[2, 1, 2, 3, 1, 3], [5, 1, 6]
[4, 4, 5, 2, 4, 0], [9, 2, 10, 1, 9, 0]

Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

As a mathematician and not a coder, I can't really address the challenge, but I am interested by the following question: If both averages can be raised by shifting some finite collection of integers (say five) from the one set to the other, does it always follow that both averages may be raised by shifting just one integer?  Thus showing that the challenge really covers all the cases.

@TrevorRichards I think the last falsy test case covers this. You could move a 1 and 9 over, which would raise both averages, but you can't do so by moving a single one.

@TrevorRichards In general, if the sets A & B have averages a & b with a < b then both averages can be raised if there is a subset C of B which has average c such that a < c < b.  On the other hand, if you require all elements moved from B to A to have values YyhT<YyeTeT.pQ

Prints an a non-empty list for truthy, and [] for falsey.
L                    Define y(b). Pyth has no builtin for mean
 c                   Float div
  sb                 Sum of b
  lb                 Length of b
f        .pQ         Filter all permutations of input
 f     eT            Filter the last element of the filter var
  &                  Logical and
   >Y                Inner filter var greater than
    y                Call the mean function we defined earlier
     hT              First element of outer filter var
   <Y                Inner filter var less than
    y                Mean of
     eT              Last element of outer filternvar

Try it online here.
Test Suite.

Haskell, 58 57
x%y=any(\n->(\g->g x<0&&g y>0)$sum.map(n-))x
x?y=x%y||y%x

we can check if we enlarge or lower the average by checking whether the element to remove or include is bigger or smaller than the average.
we can check that by checking if the average is smaller or bigger than an element by removing that element from the array, and checking whether the new array's average is negative or positive, which in turn is just as checking whether the sum is positive or negative.
checking that is put very simply as sum.map(-n+).

Python 3, 74
lambda*L:any(sum(C)/len(C)>x>sum(D)/len(D)for(C,D)in[L,L[::-1]]for x in C)

Takes two lists as input. Checks if the first list has an element that's bigger than it's average but smaller than the other one's. Then, does the same for the two inputs swapped. Having a two-layer list comprehension was shorter than defining a separate function to try the two orders (82):
f=lambda A,B:any(sum(A)/len(A)>x>sum(B)/len(B)for x in A)
lambda A,B:f(A,B)|f(B,A)

Mathematica, 49 47 bytes
m=Mean;MemberQ[#2,x_/;m@#<x<m@#2]&@@#~SortBy~m&

Evaluates to a pure function that expects input in the form {list1, list2}.

APL, 45 40 bytes
Saved 5 bytes thanks to Moris Zucca!
{U←∊⍺⍵[⊃⍒M←(+/÷≢)¨⍺⍵]⋄1∊(U<⌈/M)∧(U>⌊/M)}

This creates an unnamed dyadic function that accepts arrays on the left and right and returns 1 or 0.
{
  M←(+/÷≢)¨⍺⍵          ⍝ Compute the mean of each array
  U←∊⍺⍵[⊃⍒M]           ⍝ Get the array with the larger mean
  1∊(U<⌈/M)∧(U>⌊/M)    ⍝ Any smaller mean < U < larger mean
}

You can try it online.

you can write the mean as: (+/÷≢)

@MorisZucca Thanks! Edited to use your suggestion.

R, 66 52 Bytes
As an unnamed function, that accepts 2 vectors.  Got rid of some spurious whichs.
function(a,b)any(a<(m=mean)(a)&a>m(b),b<m(b)&b>m(a))

Tests
> f=
+ function(a,b)any(a<(m=mean)(a)&a>m(b),b<m(b)&b>m(a))
> f(c(1), c(2, 3))
[1] TRUE
> f(c(1, 2, 3), c(4, 5, 6))
[1] TRUE
> f(c(3, 4, 5, 6), c(2, 3, 4, 5))
[1] TRUE
> f(c(6, 5, 9, 5, 6, 0), c(6, 2, 0, 9, 5, 2))
[1] TRUE
> f(c(0, 4), c(9, 1, 0, 2, 8, 0, 5, 5, 4, 9))
[1] TRUE
>
> f(c(1), c(2))
[1] FALSE
> f(c(2, 4), c(5))
[1] FALSE
> f(c(1, 5), c(2, 3, 4, 5))
[1] FALSE
> f(c(2, 1, 2, 3, 1, 3), c(5, 1, 6))
[1] FALSE
> f(c(4, 4, 5, 2, 4, 0), c(9, 2, 10, 1, 9, 0))
[1] FALSE
>

SAS/IML, 67
start m(a,b);return((a>b[:]&&aa[:]&&b<b[:]))[<>];finish;

It uses subscript reduction operators to get the answer, returning 0 if no element is found that matches the requirements or 1 if one is found.
Non-golfed, here I return the actual value itself using matrix multiplication:
proc iml;
  b={1 2 3 4 5 6 7 8 9 };
  a={2 3 4 5 6};
  start m(a,b);
  return (a#(a>b[:] && a a[:] && b < b[:]))[<>];
  finish;

  z= m(a,b);
  print z;
quit;

Tests:
%macro test(a,b,n);
  z&n=m({&a},{&b});
  print z&n;
%mend test;

proc iml;
  b={1 2 3 4 5 };
  a={2 3 4 5 6 7};
start m(a,b);return((a>b[:]&&aa[:]&&b<b[:]))[<>];finish;

* True;
 %test(1,2 3,1);
 %test(1 2 3,4 5 6,2);
 %test(3 4 5 6, 2 3 4 5,3);
 %test(6 5 9 5 6 0,6 2 0 9 5 2,4);
 %test(0 4, 9 1 0 2 8 0 5 5 4 9,5);
* False;
 %test(1,2,6);
 %test(2 4, 5,7);
 %test(1 5, 2 3 4 5,8);
 %test(2 1 2 3 1 3, 5 1 6,9);
 %test(4 4 5 2 4 0, 9 2 10 1 9 0,10);

quit;

(Condensed for readability)

z1 1
z2 1
z3 1
z4 1
z5 1
z6 0
z7 0
z8 0
z9 0
z10 0

Python 2.7, 102 98 96
lambda p:any([1for i in 0,1for e in p[i]if g[i^1]<e<g[i]]for g in[[sum(l)*1./len(l)for l in p]])

Takes the input as array of the 2 inputs and returns boolean.
The logic is -find the avg of the 2 lists, then find an element such that it's less than the avg of its own list and but greater than the average of the other list.
Testing it for the given inputs is demo-ed here

You can do *1. instead of *1.0 to save a byte. Alternatively, if you do this in Python 3, division will return a float by default, so you wouldn't need that multiplication at all.  (I don't think you'd have to change your code at all to use Python 3.)

@mathmandan Saved me a byte. Thanks :)

You can make it an anonymous function by removing f= and change in[0,1]for to in 0,1for. Since you're actually at 101 bytes, this brings you down to 98.

@Vioz- Thanks, didn't know I could do that :)

CJam, 28 bytes
{{_:+1$,d/\+}%$~(m],@0=i)>&}

This is an anonymous function that pops a two-dimensional array from the stack and leaves an array of movable elements in return.
In supported browsers, you can verify all test cases at once in the CJam interpreter.
Test cases
Code
q~]{{_:+1$,d/\+}%$~(m],@0=i)>&}%:p

Input
[[1] [2 3]]
[[1 2 3] [4 5 6]]
[[3 4 5 6] [2 3 4 5]]
[[6 5 9 5 6 0] [6 2 0 9 5 2]]
[[0 4] [9 1 0 2 8 0 5 5 4 9]]
[[1] [2]]
[[2 4] [5]]
[[1 5] [2 3 4 5]]
[[2 1 2 3 1 3] [5 1 6]]
[[4 4 5 2 4 0] [9 2 10 1 9 0]]

Output
[2]
[4]
[4]
[5]
[4]
""
""
""
""
""

How it works
If A and B are the arrays and avg(A) ≤ avg(B) we simply check if B ∩ {⌊avg(A)⌋+1, …, ⌈avg(B)⌉-1} is non-empty. Any element in this intersection could be moved from B to A to increase both averages.
{          }%              e# For each of the arrays:
 _:+                       e#   Compute the sum of its elements.
    1$,                    e#   Compute its length.
       d/                  e#   Cast to Double and perform division.
         \+                e#   Prepend the computed average to the array.
             $             e# Sort the arrays (by the averages).
              ~            e# Dump both arrays on the stack.
               (           e# Shift out the higher average.
                m]         e# Round up to the nearest integer b.
                  ,        e# Push [0 ... b-1].
                   @0=     e# Replace the array with lower average by its average.
                      i)   e# Round down to the nearest integer a and add 1.
                        >  e# Skip the first a integer of the range.
                           e# This pushes [a+1 ... b-1].
                         & e# Intersect the result with the remaining array.

This pushes the array of all elements of the array with higher average that can be moved to increase both averages. This array is empty/falsy if and only if no elements can be moved to achieve this result.

Ruby, 86
A=->x{x.reduce(0.0,:+)/x.size}
F=->q{b,a=q.sort_by{|x|A[x]};a.any?{|x|xA[b]}}

Takes as input an array containing the two arrays.
Tries to find a sub average item from the group with the higher average that is greater than the average of the other group.
Test: http://ideone.com/444W4U

Started working on this without noticing there was already a Ruby solution, ended up with something very similar but it nets two fewer characters by having the function assume the first list is 'better', then call itself the other way around. f=->a,s=1{i,j=a.map{|x|x.inject(0.0,:+)/x.size};a[0].any?{|y|i>y&&j<y}||s&&f[b,a,p]}

@histocrat Nice approach! I get a NameError regarding the variable b though. I think the recursive call should be something like f[a.rotate,p].

Oops, so that's how I got a better score, by cheating.

Matlab, 54
Using an anonymous function:
f=@(A,B)any([B>mean(A)&B<mean(B) A>mean(B)&A<mean(A)])

Examples:
>> f=@(A,B)any([B>mean(A)&B<mean(B) A>mean(B)&A<mean(A)])
f =
    @(A,B)any([B>mean(A)&B<mean(B),A>mean(B)&A<mean(A)])

>> f([1 2 3],[4 5 6])
ans =
     1

>> f([3 4 5 6],[2 3 4 5])
ans =
     1

>> f([1 5 9],[4 5 7 8])
ans =
     0

C#, 104
bool f(int[]a,int[]b){double i=a.Average(),j=b.Average();return a.Any(x=>xj)||b.Any(x=>x<j&&x>i);}

Example Calls:
f(new []{1,2,3}, new []{4,5,6})
f(new []{1}, new []{2, 3})
f(new []{1, 2, 3}, new []{4, 5, 6})
f(new []{3, 4, 5, 6}, new []{2, 3, 4, 5})
f(new []{6, 5, 9, 5, 6, 0}, new []{6, 2, 0, 9, 5, 2})
f(new []{0, 4}, new []{9, 1, 0, 2, 8, 0, 5, 5, 4, 9})

f(new []{1}, new []{2})
f(new []{2, 4}, new []{5})
f(new []{1, 5}, new []{2, 3, 4, 5})
f(new []{2, 1, 2, 3, 1, 3}, new []{5, 1, 6})
f(new []{4, 4, 5, 2, 4, 0}, new []{9, 2, 10, 1, 9, 0})

C++14, 157 bytes
As unnamed lambda, returns by the last parameter r. Assumes A,B to be containers like vector<int> or array<int,>.
[](auto A,auto B,int&r){auto m=[](auto C){auto s=0.;for(auto x:C)s+=x;return s/C.size();};r=0;for(auto x:A)r+=x<m(A)&&x>m(B);for(auto x:B)r+=x<m(B)&&x>m(A);}

Ungolfed:
auto f=
[](auto A,auto B,int&r){
  auto m=[](auto C){
   auto s=0.;
   for(auto x:C) s+=x;
   return s/C.size();
  };
  r=0;
  for (auto x:A) r+=x<m(A)&&x>m(B);
  for (auto x:B) r+=x<m(B)&&x>m(A);
}
;

Usage:
int main() {
  std::vector<int>
    a={1,2,3}, b={4,5,6};
  //  a={1,5,9}, b={4,5,7,8};
  int r;
  f(a,b,r);
  std::cout << r << std::endl;
}