Problem:
Score: 100 points

Problem Statement

The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...

Given is a string S representing the weather in the town today. Predict the weather tomorrow.

Constraints

S is Sunny, Cloudy, or Rainy.

Input

Input is given from Standard Input in the following format:

S

Output

Print a string representing the expected weather tomorrow, in the same format in which input is given.

Sample Input 1

Sunny

Sample Output 1

Cloudy

In Takahashi's town, a sunny day is followed by a cloudy day.

Sample Input 2

Rainy

Sample Output 2

Sunny

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<stdio.h>
#include<stdlib.h>
#include<string.h>


struct priority_queue{
	size_t __nmemb;
	size_t __size;
	int (*__compar) (const void*, const void*);
	size_t length;
	void *heap;
	void *temp;
	int (*push)(struct priority_queue*, int);
	int (*pop)(struct priority_queue*);
	void (*clear)(struct priority_queue*);
	void (*dispose)(struct priority_queue*);
};

int priority_queue_push(struct priority_queue *p, int value){
	if(p->length == p->__nmemb){
		return -1;
	}
	void *heap = p->heap - p->__size;
	p->length++;
	memcpy(heap+(p->length*p->__size), (void*)&value, p->__size);

	size_t node;
	for(node=p->length; p->__compar(heap+node*p->__size, heap+(node/2)*p->__size)<0 && node != 1; node/=2){
		memcpy(p->temp, heap+node*p->__size, p->__size);
		memcpy(heap+node*p->__size, heap+(node/2)*p->__size, p->__size);
		memcpy(heap+(node/2)*p->__size, p->temp, p->__size);
	}
	return 0;
}

int priority_queue_pop(struct priority_queue *p){
	if(p->length == 0){
		return 0;
	}
	int ret;
	size_t node, downto;
	size_t left, right;
	char f;
	void *heap = p->heap - p->__size;
	
	ret = *((int*)(heap+p->__size));
	
	memcpy(heap+p->__size, heap+(p->length*p->__size), p->__size);
	p->length--;
	node = 1;
	while(1) {
		downto = node;
		left = node<<1;
		right = left+1;
		if (left<=p->length && p->__compar(heap+downto*p->__size, heap+left*p->__size)>0){
			downto=left;
		}
		if (right<=p->length && p->__compar(heap+downto*p->__size, heap+right*p->__size)>0){
			downto = right;
		}
		if(downto==node){
			break;
		}
		memcpy(p->temp, heap+node*p->__size, p->__size);
		memcpy(heap+node*p->__size, heap+downto*p->__size, p->__size);
		memcpy(heap+downto*p->__size, p->temp, p->__size);
		node = downto;
	}
    return ret;
}

void priority_queue_clear(struct priority_queue *p){;
	p->length = 0;
}

void priority_queue_dispose(struct priority_queue *p){
	free(p->heap);
}

int create_priority_queue(struct priority_queue *p, size_t __nmemb, /*size_t __size, */int (*__compar) (const void*, const void*)){
	size_t __size = sizeof(int);
	if((p->heap = malloc(__nmemb * __size)) == NULL){
		return -1;
	}
	if((p->temp = malloc(__size)) == NULL){
		free(p->heap);
		return -1;
	}
	p->__nmemb = __nmemb;
	p->__size = __size;
	p->__compar = __compar;
	p->length = 0;
	p->push = priority_queue_push;
	p->pop = priority_queue_pop;
	p->clear = priority_queue_clear;
	p->dispose = priority_queue_dispose;
	return 0;
}

int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}

struct priority_queue A;
int N, M, a, i;
long sum;

int main(void){
	scanf("%d%d", &N, &M);
	create_priority_queue(&A, N, compare_int);
	for(i=0; i<N; i++){
		scanf("%d", &a);
		sum += a;
		A.push(&A, a);
	}
	for(i=0; i<M; i++){
		a = A.pop(&A);
		sum -= (a+1)>>1;
		A.push(&A, a>>1);
	}
	printf("%ld\n", sum);
}