akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const char NL = '\n';
const char SP = ' ';
#define loop(i, a, b) for (long long i = a; i < b; i++)

int main () {
  ios_base::sync_with_stdio(false);
  long long n, c = 0;
  cin >> n;
  long long a[n];
  loop (i, 0, n) {
    cin >> a[i];
  }
  long long min = a[0];
  loop (i, 1, n) {
    if (a[i] >= min) {
      min = a[i];
    }
    else {
      c += min - a[i];
    }
  }
  cout << c << NL;
  return 0;
}

Measured memory_bytes: 5228
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> R[i];
    
    int maxv = R[1] - R[0];
    int minv = R[0];
    
    for ( int i = 1; i < n; i++ ) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;

int sumDigits(int num){
    int sum = 0;
    while (num > 0)
    {
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

// main
int main(){
    int N; cin >> N;
    if( N % sumDigits(N) == 0 ){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] W = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToArray();

            int rightSum = W.Sum();

            int leftSum = 0;

            int index = 0;

            while (rightSum > leftSum)
            {
                leftSum += W[index];
                rightSum -= W[index];
                index++;
            }

            if (Math.Abs(leftSum - rightSum) > Math.Abs(leftSum - W[index - 1] - (rightSum + W[index - 1])))
            {
                Console.Write(Math.Abs(leftSum - W[index - 1] - (rightSum + W[index - 1])));
            }
            else
            {
                Console.Write(Math.Abs(leftSum - rightSum));
            }
        }
    }
}


Measured memory_bytes: 28152
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	int a[200020];
	int m=0;
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<n; i++){
		if(a[i]==m+1){
			m++;
		}
	}
	if(m==0){
		cout<<-1<<endl;
	}else{
		cout<<n-m<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
ans = 1
cnt = [0] * N
for i, a in enumerate(A):
    cnt[a] += 1
    if a == 0:
        ans *= 4 - cnt[a]
    else:
        ans *= max(0, cnt[a-1]-cnt[a]+1)
    ans %= MOD

print(ans)


Measured memory_bytes: 14780
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;



// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);


    bool ans=false;
    long long int p=1;
    while(true){
        if((p*K>=A)&&(p*K<=B)){
            ans=true;
            break;
        }else if(p*K>B){
            break;
        }
        p++;
    }
    if(ans){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, t, ans;
  cin >> x >> t;
  if (x - t <= 0) {
    ans = 0;
  } else {
    ans = x - t;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
ll r,s,p;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n,k;
  cin >> n >> k;

  cin >> r >> s >> p;
  string t;
  string res;
  cin >> t;
  ll ans=0;
  rep(i,n){
    if(i<k){
      if(t[i]=='s'){
	res.pb('r');
	ans+=r;
      }
      else if(t[i]=='r'){
	res.pb('p');
	ans+=p;
      }
      else if(t[i]=='p'){
	res.pb('s');
	ans+=s;
      }
    }
    else{
      if(t[i]=='s'){
	if(res[i-k]!='r'){
	  res.pb('r');ans+=r;
	}
	else {
	  if(i+k<n){
	    if(t[i+k]=='r') res.pb('s');
	    else res.pb('p');
	  }
	}
      }
      else if(t[i]=='r'){
	if(res[i-k]!='p'){
	  res.pb('p');ans+=p;
	}
	else{
	  if(i+k<n){
	    if(t[i+k]=='p') res.pb('r');
	    else res.pb('s');
	  }
	}
      }
      else if(t[i]=='p'){
	if(res[i-k]!='s'){
	  res.pb('s'); ans+=s;	  
	}
	else{
	  if(i+k<n){
	    if(t[i+k]=='s') res.pb('p');
	    else res.pb('r');
	  }
	}
      }
    }
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 640
#include <stdio.h>

int parent(int i) {
	return (i - 1) /4;
}

int childTab[256];

void initChildTab() {
	childTab['A'] = 1;
	childTab['C'] = 2;
	childTab['G'] = 3;
	childTab['T'] = 4;
}

inline int child(int i, int c) {
	return i*4 + childTab[c];
}

unsigned char H[2100000];

inline int index(int i) {
	return i / 8;
}

inline int offset(int i) {
	return i % 8;
}

void Set(int i) {
	int j = index(i);
	int off = offset(i);
	H[j] = H[j] | (1 << off);
}

int Get(int i) {
	int j = index(i);
	int off = offset(i);
	return H[j] & (1 << off);
}

int main(int argc, char **argv)
{
	int n, i, j, nd;
	char s[32];
	initChildTab();
	scanf("%d", &n);
	for (j = 0; j < n; j++) {
		scanf("%s", s);
		if (s[0] == 'i') {
			scanf("%s", s);
			nd = 0;
			for (i = 0; s[i] != '\0'; i++) {
				nd = child(nd, s[i]);
			}
			Set(nd);
		} else {
			scanf("%s", s);
			nd = 0;
			for (i = 0; s[i] != '\0'; i++) {
				nd = child(nd, s[i]);
			}
			if (Get(nd)) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1844
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i, a) for(int i = 0; i < (int) a; i++)
#define all(v) v.begin(), v.end()
#define f first
#define s second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;



int main(){
	ios::sync_with_stdio(false); cin.tie(0);

	int h, a; cin >> h >> a;
	int x = (h/a);
	if(h%a > 0) x++;

	cout << x << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node,int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert (int);
void inorder (Node);
void preorder(Node);

//void transplant(Node,Node);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
       inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
       scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }
  }

  
  
  return 0;
}


Node treeMinimum(Node x){
  
  while(x->left != NIL){
    x = x->left;
  }

  return x;

}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){

  if(u == NIL || k == u->key) return u;
  if(k < u->key) return treeSearch(u->left,k);
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right); //case1

  y = x->parent;

  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y; //case2

}

void treeDelete(Node z){
  Node a; // node to be deleted
  Node b; // child of y

  if(z->left == NIL || z->right == NIL) a = z;
  else a = treeSuccessor(z);

  if(a->left != NIL) b = a->left;
  else b = a->right;

  if( b != NIL ) b->parent = a->parent;
  if(a->parent == NIL) root = b;
  else if(a==a->parent->left) a->parent->left = b;
  else a->parent->right = b;

  if( a != z) z->key = a->key;

}


void insert(int k){
  Node y = NIL; // x parent
  Node x = root; 
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x; //parent set
    if( z->key < x->key) x = x->left;//左の子へ移動
    else x = x->right;//右の子へ移動
  }
  z->parent = y;

  //Tが空の場合
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z; //z を y の左の子にする
  else y->right = z; // z を yの右の子にする 

}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){
  if(u != NIL) {
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }

}




Measured memory_bytes: 20452
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        int s, w;
        cin >> s >> w;
        if (w >= s) {
                cout << "unsafe" << endl;
        } else {
                cout << "safe" << endl;
        }

        return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>  

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; -i)
#define INF (1 << 20)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int N, M;
int cost[101][101];
int mincost[101];
bool used[101];

int prim() {

	rep(i, N) {
		mincost[i] = INF;
		used[i] = false;
	}

	mincost[0] = 0;
	int res = 0;

	while(true) {
		int v = -1;
		rep(u, N) if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
		if(v == -1) break;
		used[v] = true;
		res += mincost[v];
		rep(u, N) mincost[u] = min(mincost[u], cost[v][u]);
	}
	return res;
}

int main() {
	while(scanf("%d %d", &N, &M), N || M) {
		rep(i, 101) rep(j, 101) cost[i][j] = INF;
		rep(i, M) {
			int a, b, Cost;
			scanf("%d %d %d", &a, &b, &Cost);
			cost[a][b] = cost[b][a] = Cost;
		}
		printf("%d\n", prim());
	}
	return 0;
}

Measured memory_bytes: 3180
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u64,
    }
    let divisor = 10_u64.pow(9) + 7;
    let ans = (1..=n).fold(1, |p, k| (p * k) % divisor);
    println!("{}", ans);
}


Measured memory_bytes: 2088
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=810;
const int ws_[4]={1,0,-1,0},ad_[4]={0,1,0,-1};
int N,M,K,sx,sy,ans;
char mp[maxn][maxn];
bool vis[maxn][maxn];
struct my{
	int x,y,v;
	my(int x=0,int y=0,int v=0){
		this->x=x,this->y=y,this->v=v;
	}
};
inline bool out(int x,int y){
	return x<1||y<1||x>N||y>M;
}
inline int dis(int x,int y){
	int d=min(min(x-1,y-1),min(N-x,M-y));
	return d/K+(d%K!=0);
}
queue<my>q;
void bfs(){
	q.push(my(sx,sy,0));
	vis[sx][sy]=1;
	ans=1<<30;
	while(!q.empty()){
		my tmp=q.front();
		q.pop();
		ans=min(ans,dis(tmp.x,tmp.y)+1);
		if(tmp.v<K)
			for(int i=0;i<4;i++){
				int tx=tmp.x+ws_[i],ty=tmp.y+ad_[i],tv=tmp.v+1;
				if(!out(tx,ty)&&mp[tx][ty]=='.'&&!vis[tx][ty]){
					vis[tx][ty]=1;
					q.push(my(tx,ty,tv));
				}
			}
	}
}
int main(){
	//freopen("in","r",stdin);
	N=read(),M=read(),K=read();
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++){
			mp[i][j]=one();
			if(mp[i][j]=='S')
				sx=i,sy=j;
		}
	bfs();
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var q = ToInt32(ReadLine());
        const int NUM = 100001;
        var bo = new bool[NUM];
        for (var i = 2; i < NUM; i++)
            if (!bo[i])
                for (var j = 2 * i; j < NUM; j += i)
                    bo[j] = true;
        var sum = new int[NUM];
        for (var i = 3; i < NUM; i += 2)
            if (!bo[i] && !bo[(i + 1) / 2]) sum[i] = sum[i - 2] + 1;
            else sum[i] = sum[i - 2];
        var s = new int[q];
        for(var i = 0; i < q; i++)
        {
            var lr = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            s[i] = lr[0]!=1?sum[lr[1]] - sum[lr[0]-2]:sum[lr[1]];
        }
        WriteLine(string.Join("\n", s));
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 18884
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100
#define NIL -1

struct Node
{
	int parent, left, right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d)
{
	if(u == NIL)
		return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u)
{
	int h1 = 0, h2 =0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

//返回兄弟结点

int getSibling(int u)
{
	if(T[u].parent == NIL)
		return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
		return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
		return T[T[u].parent].right;
	return NIL;
}

void print(int u)
{
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if(T[u].left != NIL)
		deg++;
	if(T[u].right != NIL)
		deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);
	if(T[u].parent == NIL)
		printf("root\n");
	else if(T[u].left == NIL && T[u].right == NIL)
		printf("leaf\n");
	else
		printf("internal node\n");
}
 
int main()
{
	int n, v, l, r, root;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		T[i].parent = NIL;
	for(int i = 0; i < n; i++)
	{
		scanf("%d%d%d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if(l != NIL)
			T[l].parent = v;
		if(r != NIL)
			T[r].parent = v;
	}
	
	for(int i = 0; i < n; i++)
		if(T[i].parent == NIL)
			root = i;
	setDepth(root, 0);
	setHeight(root);
	
	for(int i = 0; i < n; i++)
		print(i);
	
}



Measured memory_bytes: 3200
from collections import deque

n = int(input())
a = list(map(int, input().split()))

d = deque()
for i in range(n):
    if i % 2 != 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

if n % 2 == 0:
    print(*list(reversed(d)))
else:
    print(*d)


Measured memory_bytes: 25532
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;

using ll = long long;
using vl = vector<long long>;
using vi = vector<int>;
using vvl = vector<vl>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

int main()
{
    int n;
    cin >> n;
    vector<double> p(n + 1);
    for (int i = 1; i < n + 1; i++)
        cin >> p[i];
    vector<double> dp(n + 1, 0), dpt(n + 1, 0);
    dp[0] = 1 - p[1];
    dp[1] = p[1];
    for (int i = 2; i < n + 1; i++)
    {
        for (int j = 0; j <= i; j++)
            dpt[j] = dp[j - 1] * p[i] + dp[j] * (1 - p[i]);
        dp = vector<double>(dpt.begin(), dpt.end());
    }
    double res = 0;
    for (int i = 0; i < n + 1; i++)
        if (i > n / 2)
            res += dp[i];
    cout << setprecision(9) << res;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

#define N 100

int n, l, j, u, k, tmp;

int list[N][N];
int lengthlist[N];

void search(int , int );

int main(){
  
  scanf("%d", &n);
  
  for(l = 0 ; l < n ; l++){
    scanf("%d", &u);
    scanf("%d", &k);
    
    for( j = 0 ; j < k ; j++){
      scanf("%d", &tmp);
      list[u-1][tmp-1] = 1;
    }
  }
  
  for( l = 0 ; l < n ; l++){
    lengthlist[l] = -1;
  }
  
  search(0, -1);

  for(j = 0 ; j < n ; j++){
    printf("%d %d\n", j+1, lengthlist[j]);
  }

  return 0;
}

void search(int y, int length){
  int i;
  
  length++;
  lengthlist[y] = length;


  for( i = 0 ; i < n ; i++){
    if( list[y][i] == 1 ){
      if( lengthlist[i] <= length && lengthlist[i] >= 0 ){
        continue;
      }
      search(i, length);
    }
  }
}



Measured memory_bytes: 2096
var s:ansistring;
    a:array[0..100000]of string;
    i,j:longint;
    n,k:longint;
    num:longint;
    s1:string;
procedure qs(l,r:longint);
var i,j:longint;
    m,t:string;
begin
  i:=l;
  j:=r;
  m:=a[(l+r)>>1];
  repeat
    while a[i]<m do inc(i);
    while a[j]>m do dec(j);
    if i<=j then
    begin
      t:=a[i];a[i]:=a[j];a[j]:=t;
      inc(i);
      dec(j);
    end;
  until i>j;
  if l<j then qs(l,j);
  if i<r then qs(i,r);
end;
begin
  readln(s);
  n:=length(s);
  readln(k);
  for i:=1 to n do
  begin
    s1:='';
    for j:=0 to k-1 do
    if i+j<=n then
    begin
      s1:=s1+s[i+j];
      inc(num);
      a[num]:=s1;
    end;
  end;
  qs(1,num);
  for i:=1 to num do
  begin
    if a[i]<>a[i-1] then dec(k);
    if k=0 then
    begin
      writeln(a[i]);
      exit;
    end;
  end;
end.





Measured memory_bytes: 1152
#include<stdio.h>
#include <stdlib.h>
int flag[105];
int main()
{
    int x,n;
    scanf("%d %d",&x,&n);
    for(int i=1;i<=100;i++)
        flag[i]=0;
    for(int i=0;i<n;i++)
    {
        int j;
        scanf("%d",&j);
        flag[j]=1;
    }
    int min=x,mini=0;
    for(int i=1;i<=100;i++)
    {
            if(abs(x-i)>=min)
            {
                printf("%d",mini);
                return 0;
            }
            if(!flag[i])
            {
                if(abs(x-i)<min)
                {
                    min=abs(x-i);
                    mini=i;
                }
            }
    }
    printf("%d",((101-x)<min)?101:mini);
    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
// int vacation(vvi a, int n, int flag, vvi &dp) {
//     if(n == 0) {
//         return 0;
//     }
    
//     if(flag == 0) {
//         if(dp[n-1][0] == -1) {
//             dp[n-1][0] = a[n-1][0] + vacation(a, n-1, 1, dp);
//         }
//         if(dp[n-1][1] == -1) {
//             dp[n-1][1] = a[n-1][1] + vacation(a, n-1, 2, dp);
//         }
//         if(dp[n-1][2] != -1) {
//             dp[n-1][2] = a[n-1][2] + vacation(a, n-1, 3, dp);
//         }
//         return max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
//     }
//     if(flag == 1) {
//         if(dp[n-1][1] == -1) {
//             dp[n-1][1] = a[n-1][1] + vacation(a, n-1, 2, dp);
//         }
//         if(dp[n-1][2] == -1) {
//             dp[n-1][2] =  a[n-1][2] + vacation(a, n-1, 3, dp);
//         }
//         return  max(dp[n-1][1], dp[n-1][2]);
//     }
//     if(flag == 2) {
//         if(dp[n-1][0] == -1) {
//             dp[n-1][0] = a[n-1][0] + vacation(a, n-1,1, dp);
//         }
//         if(dp[n-1][2] == -1) {
//             dp[n-1][2] = a[n-1][2] + vacation(a, n-1, 3, dp);
//         }
//         return max(dp[n-1][0], dp[n-1][2]);
//     }
//     if(flag == 3) {
//         if(dp[n-1][0] == -1) {
//             dp[n-1][0] = a[n-1][0] + vacation(a, n-1,1, dp);
//         }
//         if(dp[n-1][1] == -1) {
//             dp[n-1][1] = a[n-1][1] + vacation(a, n-1, 2, dp);
//         }
//         return max(dp[n-1][0], dp[n-1][1]);
//     }
// }
int main() {
    IOS
    int n, ans;
    cin >> n;
    vvi a(n, vi(3));
    vvi dp(n, vi(3, -1));
    Fori(i, 0, n) {
        Fori(j, 0, 3) {
            cin >> a[i][j];
        }
    }
    Fori(i, 0, n) {
        Fori(j, 0, 3) {
            if(i == 0) {
                dp[i][j] = a[i][j];
            } else if(j == 0) {
                dp[i][j] = max(dp[i-1][1], dp[i-1][2]) + a[i][j];
            } else if(j == 1) {
                dp[i][j] = max(dp[i-1][0], dp[i-1][2]) + a[i][j];
            } else if(j == 2) {
                dp[i][j] = max(dp[i-1][0], dp[i-1][1]) + a[i][j];
            }
        }
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    return 0;
}

Measured memory_bytes: 14144
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
asum=[0]
bsum=[0]
current=0
for i in range(n):
  current+=a[i]
  asum.append(current)
current=0
for i in range(m):
  current+=b[i]
  bsum.append(current)
pointer=0
for i in range(n+1):
  if asum[i]>k:
    pointer=i-1
    break
  if i==n:
    pointer=n
ans=pointer
bpointer=0
for i in range(pointer,-1,-1):
  while bpointer<m and bsum[bpointer+1]+asum[i]<=k:
    bpointer+=1
  ans=max(ans,i+bpointer)
print(ans)


Measured memory_bytes: 132540
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int W, H, x, y, r; cin >> W >> H >> x >> y >> r;
	if (r <= x && x <= W-r && r <= y && y <= H-r) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1156
import java.io.InputStream;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    static Scanner scanner;
    static final int[] dx = {
            1, 0, -1, 0
    };
    static final int[] dy = {
            0, 1, 0, -1
    };
    static final HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

    static {
        map.put((int) 'E', 0);
        map.put((int) 'N', 1);
        map.put((int) 'W', 2);
        map.put((int) 'S', 3);
    }

    public static void main(String[] args) {
        InputStream in = System.in;
        scanner = new Scanner(in);
        while (true) {
            int n = scanner.nextInt();
            if (n == 0) {
                break;
            }
            int[] x = new int[n];
            int[] y = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = scanner.nextInt();
                y[i] = scanner.nextInt();
            }
            int m = scanner.nextInt();
            boolean[][] masu = new boolean[21][21];
            int nx = 10;
            int ny = 10;
            masu[nx][ny] = true;
            for (int i = 0; i < m; i++) {
                String D = scanner.next();
                int d = (int) D.charAt(0);
                int l = scanner.nextInt();
                for (int j = 0; j < l; j++) {
                    nx += dx[map.get(d)];
                    ny += dy[map.get(d)];
                    masu[nx][ny] = true;
                }
            }
            boolean flg = false;
            for (int i = 0; i < n; i++) {
                if (!masu[x[i]][y[i]]) {
                    flg = true;
                    break;
                }
            }
            if (flg) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }
    }
}

Measured memory_bytes: 39376
s = input()

if s == "SUN":
  ans = 7
elif s == "MON":
  ans = 6
elif s == "TUE":
  ans = 5
elif s == "WED":
  ans = 4
elif s == "THU":
  ans = 3
elif s == "FRI":
  ans = 2
elif s == "SAT":
  ans = 1

print(ans)



Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,j,n,u,mincost,*d,*pi,*color,**G;
  scanf("%d",&n);
  G = malloc(n * sizeof(int *));
  d = malloc(n * sizeof(int));
  pi = malloc(n * sizeof(int));
  color = malloc(n * sizeof(int));
  for(i=0;i<n;i++){
    G[i] = malloc(n * sizeof(int));
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&u);
      G[i][j] = u;
    }
  }
  for(i=0;i<n;i++){
    d[i] = 2001;
    pi[i] = -1;
    color[i] = 1;
  }
  d[0] = 0;
  while(1){
    mincost = 2001;
    for(i=0;i<n;i++){
      if(color[i] != -1 && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == 2001){
      break;
    }
    color[u] = -1;
    for(i=0;i < n;i++){
      if(G[u][i] != -1){
        if(color[i] != -1 && G[u][i]< d[i]){
          pi[i] = u;
          d[i] = G[u][i];
        }
      }
    }
  }
  for(i=1;i<n;i++){
    d[i] = d[i] + d[i-1];
  }
  printf("%d\n",d[n-1]);
  return 0;
}



Measured memory_bytes: 2108
n = int(input())
l = list(map(int,input().split()))
color = [0]*10
ans = 0
aans = 0
for i in range(n):
    if l[i] >= 3200:
        aans += 1
    else:
        color[int(l[i]/400)] += 1
for i in color:
    if i > 0:
        ans += 1
if aans == n:
    print(1,n)
else:
    print(ans,aans+ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        HashSet<Integer> s = new HashSet<>();
        s.add(1);
        s.add(2);
        s.add(3);
        s.remove(a);
        s.remove(b);
        for (Integer i : s) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int

using namespace std;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    ll N;
    ll sum=0;
    cin>>N;
    vector<ll> a(N);

    for(ll i=0;i<N;i++){
        cin>>a[i];

    }
    
    vector<ll> sw(N+1,0);


    for(ll i=N;i>=1;i--){
        sum=0;
        for(ll j=i;j<=N;j+=(i)){
            sum^=sw[j];
        }
        if(sum!=a[i-1]){
            sw[i]=1;

        }

    }

    vector<ll> r;
    for(ll i=1;i<=N;i++) if(sw[i]) r.push_back(i);

    cout<<r.size()<<endl;
    for(auto i:r) cout<<i<<endl;




    return 0;
}

Measured memory_bytes: 5108
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        long THREASHOLD=1000000000000000000L;
        int N = sc.nextInt();
        long[] A = new long[N];
        boolean zero = false;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            if (A[i] == 0) zero = true;
        }
        if (zero) {
            System.out.println("0");
            return;
        }

        long ans = 1;
        for (int i = 0; i < N; i++) {
            if (A[i] > THREASHOLD/ans) {
                ans = -1;
                break;
            }
            ans *= A[i];
        }

        System.out.println(ans);
        return;
    }

}

Measured memory_bytes: 61292
#include <iostream>
#include <cmath>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int count = 0;
  for(int i=1;i<=N;i++){
    int a;
    cin >> a;
    if(i%2 == 1 && a%2 == 1){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


int main() {
  int x;
  cin >> x;
  print((x+1)%2);
  return 0;
}

Measured memory_bytes: 3616
using System;
using System.Linq;
 
public class ABC135_B
{
    public static void Main()
    {
      	int count = int.Parse(Console.ReadLine());
        int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
 
      	int warn = 0;
      	for(int i = 0;i < count;i++)
        {
        	if(ints[i] != i + 1) warn++;
          	if(warn > 2) {
              	Console.WriteLine("NO");
              	return;
            }
        }
      	Console.WriteLine("YES");
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
const int MOD = INF+7;

int main(){
    int n;ll res = 0;
    cin>>n;
    REP(i,1,n){
        REP(j,1,n){
            REP(k,1,n){
                res += gcd(gcd(i,j),k);
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3632
// B - 1%
#include <bits/stdc++.h>
using namespace std;

int main(){
	long long X, yen = 100, ans = 0;
	cin>>X;
	while(yen < X){
		// yen *= 1.01;
		yen += yen/100;
		ans++;
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve()
{
    string s;cin>>s;
    const int n=s.size();
    vector<vector<ll>>dp(n+1,vector<ll>(13,0));dp[0][0]=1;
    REP(i,n)
    {
        int x;
        if(s[i]=='?')x=-1;
        else x=s[i]-'0';
        REP(j,10)
            if(x==-1||x==j)
                REP(k,13)
                    dp[i+1][(k*10+j)%13]+=dp[i][k];
    	REP(j,13)dp[i+1][j]%=mod;
    }
    cout<<dp[n][5]<<endl;
}

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 13648
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,k;cin>>n>>k;
  vector<int> a(n+2);
  a[0] = INF;
  a[n+1] = -INF;
  rep(i, 1, n+1) {
    cin>>a[i];
  }
  dump(a);
  vi R(n+2), L(n+2);

  {
    int cnt = 1;
    rrep(i, 1, n+1){
      if (a[i]<a[i+1]) cnt++;
      else cnt = 1;
      R[i] = cnt;
    }
    dump(R);
  }
  {
    int cnt = 1;
    rep(i, 1, n+1){
      if (a[i-1]<a[i]) cnt++;
      else cnt = 1;
      L[i] = cnt;
    }
    dump(L);
  }

  set<pii> ans;
  set<int> s;
  int nochange = 0;
  rep(i, k) s.insert(a[i]);

  rep(l, 1, n-k+2){
    s.erase(a[l-1]);
    s.insert(a[l+k-1]);
    if (k<=R[l]) chmax(nochange, 1LL);
    else{
      int ll = l;
      int rr = l+k-1;
      if (a[ll-1] < *s.begin()) ll -= L[ll-1];
      if (a[rr+1] > *s.rbegin()) rr += R[rr+1];
      dump(l, ll, rr);
      ans.insert(mp(ll, rr));
    }
  }
  dump(nochange);
  dump(ans);
  cout << sz(ans)+nochange << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;

int main() {
    char S;
    cin >> S;
    char S_U;
    S_U = toupper(S);
    if (S == S_U) {
        cout << "A" << endl;
    }
    else {
        cout << "a" << endl;
    }
}

Measured memory_bytes: 3564
<?php
# 数値の入力
fscanf(STDIN, "%d", $data1);
$data2 = trim(fgets(STDIN));
$a = explode(" ", $data2);
 
$anser = $a[0];
 
for($i=0; $i<$data1-2; $i++){
    if($a[$i]>$a[$i+1]){
        $anser += $a[$i+1];
    }else{
        $anser += $a[$i];
    }
}
$anser += $a[$data1-2];
 
echo $anser;
?>

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(ll i = a; i < b; i++)

int main(){
    ll N, K; cin >> N >> K;

    ll ans = 0;
    rep(b, K+1, N + 1){
        ll t = N / b;
        ans += (b - 1 - (K-1)) * t;
        ll t1 = N % b;
        if(t1 >= K) ans += t1 - (K - 1);
        if(K == 0) ans--;
        cerr << b << " " <<  ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main()
{
	int n;
	int p[50000] = {};

	for (int i = 2; i <= 50000; ++i)
	{
		if (p[i-2] == 0)
		{
			p[i-2] = 1;
			for (int j = i+i; j <= 50000; j += i) p[j-2] = -1;
		}
	}

	while (cin >> n && n)
	{
		int r = 0;
		for (int i = 2; i <= n/2; ++i) if (p[i-2] == 1 && p[n-i-2] == 1) ++r;
		cout << r << endl;
	}
	return 0;
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000003;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll dp[e3][e3];

bool is_p(ll p){
  for(ll x = 2;x*x <= p;x++){
    if(p%x == 0) return false;
  }
  return true;
}

int main(){
  for(ll i = 2;i <= 100;i++){
    if(i*(i-1)+1 < 1000) continue;
    ll p = i-1;
    if(is_p(p)){
      cout << i*(i-1)+1 << " " << i << endl;
      ll k = 1;
      for(ll i = 0;i < p;i++){
        for(ll j = 0;j <= p;j++){
          dp[i][j] = k;
          k++;
        }
      }
      for(ll j = 0;j <= p;j++){
        for(ll i = 0;i < p;i++){
          cout << dp[i][j] << " ";
        }
        cout << k << endl;
      }
      for(ll t = 0;t < p;t++){
        for(ll s = 0;s < p;s++){
          for(ll j = 0;j < p;j++){
            cout << dp[(s+(t*j))%p][j] << " ";
          }
          cout << dp[t][p] << endl;
        }
      }
      return 0;
    }
  }
}


Measured memory_bytes: 2688
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int r;
    cin >> r;

    ld res = 2. * acos(-1) * r;
    cout << fixed << setprecision(5) << res ;
}   

     
int32_t main()
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 3800
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int C[100][100];

void CombInit() {
  for (int i = 0; i <= 55; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i) {
        C[i][j] = 1LL;
      } else {
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      }
    }
  }
}

int N, A, B;
double v[100];

bool CC(double mid) {
  double x[100];
  for (int i = 0; i < A; i++) {
    x[i] = v[i] - mid;
  }

  double sum = 0;
  for (int i = 0; i < A; i++) {
    sum += x[i];
  }

  if (sum >= 0) {
    return true;
  }

  return false;
}

int Count(double m) {

  CombInit();

  int X = 0, Y = 0;
  if (v[0] != v[A - 1]) {
    for (int i = 0; i < N; i++) {
      if (v[i] == v[A - 1]) {
        X++;
        if (i < A) {
          Y++;
        }
      }
    }
    return C[X][Y];
  } else {

    for (int i = 0; i < N; i++) {
      if (v[i] == v[0]) {
        X++;
      }
    }
    int sum = 0LL;
    for (int i = A; i <= B; i++) {
      sum += C[X][i];
    }
    return sum;
  }
}

signed main() {
  cin >> N >> A >> B;
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }

  sort(v, v + N, greater<double>());

  double ok = 0, ng = 1e16;
  for (int i = 0; i < 100; i++) {
    double mid = (double)(ok + ng) / 2.0;
    if (CC(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  cout << fixed << setprecision(6) << ok << endl;
  cout << Count(ok) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; string s; cin >> n >> s;
  int cnt = 0;
  int mn = 0;
  rep(i, n) {
    if(s[i] == '(') cnt++;
    else cnt--;
    mn = min(cnt, mn);
  }
  cout << string(-mn, '(') + s + string(cnt-mn, ')') << "\n";
  return 0;
}


Measured memory_bytes: 3632
s=list(reversed(list(input())))
n=len(s)
for i in range(6):
    s.append("#")
d=0
f=0
while f==0 and s[d]!="#":
    if s[d]+s[d+1]+s[d+2]+s[d+3]+s[d+4]=="maerd":
        d+=5

    elif s[d]+s[d+1]+s[d+2]+s[d+3]+s[d+4]+s[d+5]+s[d+6]=="remaerd":
        d+=7

    elif s[d]+s[d+1]+s[d+2]+s[d+3]+s[d+4]=="esare":
        d+=5
    elif s[d]+s[d+1]+s[d+2]+s[d+3]+s[d+4]+s[d+5]=="resare":
        d+=6
    else:
        f=1
print("YES" if f==0 else "NO")




Measured memory_bytes: 79740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  string S;
  int Q;
  cin >> S;
  cin >> Q;
  deque<char> deq;
  bool flag = true;
  REP(i, S.size()) deq.push_back(S[i]);
  REP(i, Q) {
    int t;
    cin >> t;
    if (t == 1) {
      flag = !flag;
    } else if (t == 2) {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (flag) deq.push_front(c);
        else deq.push_back(c);
      } else if (f == 2) {
        if (flag) deq.push_back(c);
        else deq.push_front(c);
      }
    }
  }
  if (flag) {
    for (auto it = deq.begin(); it != deq.end(); it++) {
      cout << *it;
    }
  } else {
    for (auto it = deq.rbegin(); it != deq.rend(); it++) {
      cout << *it;
    }
  }
  cout << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 976
class Node
  attr_reader :value, :left, :right
  attr_accessor :parent

  def initialize(value)
    @value = value
  end

  def left=(node)
    @left = node
    node.parent = self
  end

  def right=(node)
    @right = node
    node.parent = self
  end
end

class Tree
  def initialize
    @map = {}
    @root = nil
  end

  def add(value, left, right)
    node(value)
    node(value).left = node(left) if left != -1
    node(value).right = node(right) if right != -1
  end

  def pre_order(node = @root, &block)
    yield node.value
    pre_order(node.left, &block) if node.left
    pre_order(node.right, &block) if node.right
  end

  def in_order(node = @root, &block)
    in_order(node.left, &block) if node.left
    yield node.value
    in_order(node.right, &block) if node.right
  end

  def post_order(node = @root, &block)
    post_order(node.left, &block) if node.left
    post_order(node.right, &block) if node.right
    yield node.value
  end

  def detect_root
    _, node = @map.first
    node = node.parent while node.parent
    @root = node
  end

  private

  def node(value)
    return @map[value] if @map.key?(value)
    @map[value] = Node.new(value)
  end
end


tree = Tree.new
gets.to_i.times { tree.add(*gets.split.map(&:to_i)) }
tree.detect_root

puts 'Preorder'
puts " " + [].tap { |arr| tree.pre_order { |v| arr << v } }.join("\s")

puts 'Inorder'
puts " " + [].tap { |arr| tree.in_order { |v| arr << v } }.join("\s")

puts 'Postorder'
puts " " + [].tap { |arr| tree.post_order { |v| arr << v } }.join("\s")



Measured memory_bytes: 6884
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    REP(i, 0, N - 1) cin >> C[i] >> S[i] >> F[i];

    REP(i, 0, N - 1) {
        int t = S[i] + C[i];
        REP(j, i + 1, N - 1) {
            if (t <= S[j]) {
                t += (S[j] - t) + C[j];
            } else if (t % F[j] == 0) {
                t += C[j];
            } else {
                t += ((t / F[j] + 1) * F[j] - t) + C[j];
            }
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000
#define N 110000

vector<vector<ll>> conn(N);
vector<ll> reached(N,0);

ll jud(ll x){
    reached[x]=1;
    REP(i,conn[x].size()) if (1-reached[conn[x][i]]) return conn[x][i];
    return -1;
}

int main(){
    ll n, m, a, b, edj; cin >> n >> m;
    REP(i,m){
        cin >> a >> b;a--;b--;
        conn[a].pb(b);
        conn[b].pb(a);
    }
    vector<ll> ansl, ansr;
    reached[a]=1; reached[b]=1;
    ansl.pb(a); ansr.pb(b); edj = a;
    while(true){
        if (jud(edj)==-1) break;
        else {
            edj = jud(edj);
            ansl.pb(edj);
        }
    }
    edj = b;
    while(true){
        if (jud(edj)==-1) break;
        else {
            edj = jud(edj);
            ansr.pb(edj);
        }
    }
    
    cout << ansl.size()+ansr.size() << endl;
    FORD(i,ansl.size()-1,0) cout << ansl[i]+1 << " ";
    REP(i,ansr.size()) cout << ansr[i]+1 << " ";
    cout << endl;
}

Measured memory_bytes: 8308