akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),v,u;
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    deque<ll> que;
    rep(i,N){
        que.push_back(A[i]);
    }
    ll M = que.back();
    que.pop_back();
    ll m = que.front();
    que.pop_front();
    rep(i,N-2){
        ll t = que.back();
        que.pop_back();
        if(t<=0){
            v.push_back(M);
            u.push_back(t);
            M -= t;
        }else{
            v.push_back(m);
            u.push_back(t);
            m -= t;
        }
        /*
        if(!(i%2)){
            ans += que.back();
            que.pop_back();
        }else{
            ans -= que.front();
            que.pop_front();
        }*/
    }
    v.push_back(M);
    u.push_back(m);
    cout << M-m << endl;
    rep(i,N-1){
        cout << v[i] << " " << u[i] << endl;
    }
}

Measured memory_bytes: 5060
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int N;
int A[85];

void solve() {
  long long ans = 1000;
  for (int i = 0; i < N-1; i++) {
    if (A[i] < A[i+1]) {
      long long c = ans / A[i];
      ans += ((long long)(A[i+1] - A[i])) * c;
    }
  }
  printf("%lld\n", ans);
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", A+i);
  }
  solve();
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int main () {
  int N, M, s, t;
  cin >> N >> M >> s >> t;
  s --;
  t --;
  vector<vector<int>>tow(N);
  vector<vector<ll>>yen(N);
  vector<vector<ll>>snu(N);
  for (int i = 0; i < M; i ++) {
    int u, v;
    ll a, b;
    cin >> u >> v >> a >> b;
    u --;
    v --;
    tow[u].push_back(v);
    tow[v].push_back(u);
    yen[u].push_back(a);
    yen[v].push_back(a);
    snu[u].push_back(b);
    snu[v].push_back(b);
  }
  priority_queue<P, vector<P>, greater<P>>Y;
  priority_queue<P, vector<P>, greater<P>>S;
  Y.push(P(0ll, s));
  S.push(P(0ll, t));
  ll inf = 1e15;
  vector<ll>ay(N, inf);
  vector<ll>sy(N, inf);
  ay[s] = 0ll;
  sy[t] = 0ll;
  while (!Y.empty()) {
    int u;
    ll d;
    tie(d, u) = Y.top();
    Y.pop();
    if (d > ay[u]) continue;
    for (int i = 0; i < (int)tow[u].size(); i ++) {
      int v = tow[u][i];
      if (ay[v] > d + yen[u][i]) {
        ay[v] = d + yen[u][i];
        Y.push(P(ay[v], v));
      }
    }
  }
  while (!S.empty()) {
    int u;
    ll d;
    tie(d, u) = S.top();
    S.pop();
    if (d > sy[u]) continue;
    for (int i = 0; i < (int)tow[u].size(); i ++) {
      int v = tow[u][i];
      if (sy[v] > d + snu[u][i]) {
        sy[v] = d + snu[u][i];
        S.push(P(sy[v], v));
      }
    }
  }
  vector<ll>ans(N);
  for (int i = N - 1; i >= 0; i --) {
    if (i == N - 1) ans[i] = inf - ay[i] - sy[i];
    else {
      ans[i] = max(ans[i + 1], inf - ay[i] - sy[i]);
    }
  }
  for (int i = 0; i < N; i ++) cout << ans[i] << endl;
}



Measured memory_bytes: 22772
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll a,as,b,bs,t;
	cin>>a>>as>>b>>bs>>t;
	if(bs>=as){
		cout<<"NO"<<endl;
	}
	else{
		if(abs(b-a)<=t*(as-bs)){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[100100];
li b[100100];

li diff[100100];

int main() {
    cin >> n;

    li sum_a = 0;
    li sum_b = 0;
    rin{
        cin >> a[i];
        sum_a += a[i];
    }
    rin{
        cin >> b[i];
        sum_b += b[i];
    }
    if (sum_a < sum_b) {
        puts("-1");
        return 0;
    }

    li sum_ng = 0;
    li res = 0;
    rin{
        diff[i] = a[i] - b[i];
        if (a[i] < b[i]) {
            sum_ng += b[i] - a[i];
            res++;
        }
    }
    sort(diff, diff + n);

    li now = n - 1;
    while (sum_ng > 0) {
        //p3(sum_ng, diff[now], res);
        sum_ng -= diff[now];
        now--;
        res++;
    }
    cout << res << endl;
    //dump(diff, n);


    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <typeinfo>
using namespace std;

//絶対値を返す関数
double abs(double a){
	if(a < 0){       //aが負の数
		return -a;
	}else{           //aが負の数
		return a;
	}
}

int main()
{
    int n;
    double t,a;
    scanf("%d",&n);
    scanf("%lf %lf",&t,&a);

    double h[n];

    double height;
    double min = 100000;
    int minPoint = 0;

    for(int i = 0; i < n; i++){

    	scanf("%lf",&h[i]);

    	height = abs(a - (t - h[i]*0.006));
    	if(min > height){
    		min = height;   //低いので更新
    		minPoint = i+1;
    	}
    }

    printf("%d\n",minPoint);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void){

    int n;
    int k = 0;
    string a, b, c;

    cin >> n;
    cin >> a >> b >> c;

    for (int i = 0; i < n; i++){
        int t = 0;
        if(a[i] == b[i]){
            t++;
        }
        if(a[i] == c[i]){
            t++;
        }
        if(c[i] == b[i]){
            t++;
        }

        if(t == 1){
            k += 1;
        }else if(t == 0){
            k += 2;
        }
    }

    cout << k << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x1 = scanner.nextInt();
		int y1 = scanner.nextInt();
		int x2 = scanner.nextInt();
		int y2 = scanner.nextInt();
		scanner.close();

		int xd = x2 - x1;
		int yd = y2 - y1;

		int x3 = x2 - yd;
		int y3 = y2 + xd;

		int x4 = x3 - xd;
		int y4 = y3 - yd;

		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int tms[30], a[30];
char str[100005];
bool cmp(int a, int b)
{
    return a > b;
}
signed main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", str);
        tms[str[0] - 'A' + 1]++;
    }
    int ans = 0;
    while (1)
    {
        int ts = 0;
        sort(tms + 1, tms + 27, cmp);
        for (int i = 1; i <= 26; i++)
        {
            if (tms[i])
            {
                tms[i]--;
                ts++;
                if (ts == k)
                    break;
            }
        }
        if (ts == k)
            ans++;
        else
            break;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
count=[0]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        count[a[j]-1]+=1
ans=0
for i in range(n):
    if count[i]==0:
        ans+=1
print(ans)

Measured memory_bytes: 67408
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(10);
		   //正→負　とその逆の二通り前から計算していけばok
           ll n;
           cin>>n;
           vll a(n);
           rep(i,0,n)cin>>a[i];
           //正→負
           ll sum=0;
           ll ans=0;
           rep(i,0,n){
             sum+=a[i];
             if(i%2==0){
              if(sum<=0){
               ans+=1-sum;
               sum=1; 
              }
             }
             else{
              if(sum>=0){
               ans+=1+sum;
                sum=-1;
              }
             }
           }
           //負->正
            sum=0;
          ll  ans2=0;
           rep(i,0,n){
             sum+=a[i];
             if(i%2==1){
              if(sum<=0){
               ans2+=1-sum;
               sum=1; 
              }
             }
             else{
              if(sum>=0){
               ans2+=1+sum;
                sum=-1;
              }
             }
           }
           cout<<min(ans,ans2)<<endl;
           
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;

signed main() {
	cin >> n;
	if (n % 10 == 7 || (n / 10) % 10 == 7 || (n / 100) % 10 == 7)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

const int INF = 1<<28;
int w, h;
int bd[32][32];
int cost[4];
int dist[32][32][4];

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

struct node {
  int y, x, dir, d;
  node(int y, int x, int dir, int d) : y(y), x(x), dir(dir), d(d) {}
  bool operator>(const node &n) const { return this->d > n.d; }
};

int solve() {
  for (int i = 0; i < 32; i++)
    for (int j = 0; j < 32; j++)
      for (int k = 0; k < 4; k++)
        dist[i][j][k] = INF;

  priority_queue<node, vector<node>, greater<node> > Q;
  Q.push(node(0, 0, 0, 0));
  dist[0][0][0] = 0;

  while (!Q.empty()) {
    int y = Q.top().y;
    int x = Q.top().x;
    int dir = Q.top().dir;
    int d = Q.top().d;
    Q.pop();

    if (d > dist[y][x][dir])
      continue;

    for (int i = 0; i < 4; i++) {
      int c = bd[y][x] == i ? 0 : cost[i];
      int k = (dir + i) % 4;
      int xt = x + dx[k];
      int yt = y + dy[k];
      int dt = d + c;

      if (yt < 0 || yt >= h || xt < 0 || xt >= w)
        continue;
      if (dist[yt][xt][k] > dt) {
        dist[yt][xt][k] = dt;
        Q.push(node(yt, xt, k, dt));
      }
    }
  }

  int ret = INF;
  for (int i = 0; i < 4; i++)
    ret = min(ret, dist[h-1][w-1][i]);
  return ret;
}

int main(int argc, char *argv[])
{
  while (~scanf(" %d %d", &w, &h)) {
    if (!w && !h)
      break;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        scanf(" %d", bd[i] + j);
      }
    }
    for (int i = 0; i < 4; i++)
      scanf(" %d", cost + i);
    int ret = solve();
    printf("%d\n", ret);
  }
  
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int a1, a2, a3, b1, b2, b3;
    bool ans = 0;
    vector<vector<int>> c(4, vector<int>(4, 0));
    for(int i = 1; i <= 3; i++){
        for(int j = 1; j <= 3; j++){
            cin >> c[i][j];
        }
    }
    
    for(int i = -200; i <= 200; i++){
        for(int j = -200; j <= 200; j++){
            bool l = 1;
            a1 = i, b1 = j;
            if(a1 + b1 != c[1][1]) continue;
            a2 = c[2][1] - b1;
            a3 = c[3][1] - b1;
            b2 = c[1][2] - a1;
            b3 = c[1][3] - a1;
            if(c[2][2] != a2 + b2) l = 0;
            if(c[2][3] != a2 + b3) l = 0;
            if(c[3][2] != a3 + b2) l = 0;
            if(c[3][3] != a3 + b3) l = 0;
            if(l) ans = 1;
        }
    }
    if(ans){
      cout << "Yes" << endl;  
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e16)
#define PI (acos(-1))

int main() {
    //cout.precision(11);
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A+1), t(B+1), x(Q);
    s[0] = -INF;
    t[0] = -INF;
    for(int i = 0; i < A; ++i) cin >> s[i+1];
    for(int i = 0; i < B; ++i) cin >> t[i+1];
    for(int i = 0; i < Q; ++i) cin >> x[i];

    
    for(int k = 0; k < Q; k++){
        ll sp[2], tp[2];
        auto sit = lower_bound(s.begin(), s.end(), x[k]);
        auto tit = lower_bound(t.begin(), t.end(), x[k]);
        sp[0] = *(sit-1);
        sp[1] = *sit;
        tp[0] = *(tit-1);
        tp[1] = *tit;

        ll ans = INF;
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j++){
                ans = min(ans, abs(sp[i]-tp[j]) + min(abs(sp[i]-x[k]), abs(tp[j]-x[k])));
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int i = 0;i <= k;i++){
    for (int j = i;j <= k;j++){
      int l = s - i - j;
      if (j <= l && l <=k){
        if (i == j && j==l){
          count++;
        } else if (i == j||j==l||l==i){
          count+=3;
        } else{
          count += 6;
        }
       }
    }
  }
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, T, A;
  cin >> N >> T >> A;
  int res = 0;
  int cc = 1 << 30;
  for (int i = 1; i <= N; i++)
  {
    int X;
    cin >> X;
    int d = abs((T * 1000 - X * 6) - A * 1000);
    if (cc > d)
    {
      cc = d, res = i;
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc046/tasks/arc062_b
# 300点なのに水色diff
# AtCodeerくんの最善手はgpgpgpと交互に手を出すことである。任意のタイミングでpをgに変更したとき、負けることはあっても勝つことはない.
# (相手が何を出そうともpは負けることはない(悪化しない))

s = input()
ans = 0
for i, ss in enumerate(s):
    if i & 1:
        # Aはpである
        ans += ss == 'g'  # 相手がgだったら得点
    else:
        # Aはgである
        ans -= ss == 'p'  # 相手がpだったら減点
print(ans)


Measured memory_bytes: 39792
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
	
	static DecimalFormat df = new DecimalFormat("0.0000000000000000000");
	
	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			min = Math.min(min, a);
			max = Math.max(max, a);
			sum += a;
		}
		
		System.out.println(min + " " + max + " " + sum);
		
		sc.close();
	}

}

Measured memory_bytes: 40988
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int w,h;
int sx,sy,gx,gy;
int field[104][104];

class Info{
public:
	int x,y;
};

bool bfd(void){
	int search = field[sy-1][sx-1];
	int dx[4] = {1,-1,0,0};
	int dy[4] = {0,0,1,-1};

	queue<Info> q;
	Info tmp = {sx-1,sy-1};

	if(search == 0){return false;}

	q.push(tmp);
	while(!q.empty()){
		tmp = q.front(); q.pop();

		if(tmp.x + 1 == gx && tmp.y + 1 == gy){
			return true;
		}

		field[tmp.y][tmp.x] = 0;
		for(int k=0;k<4;k++){
			int nx = tmp.x + dx[k];
			int ny = tmp.y + dy[k];

			if(nx>=0 && ny>=0 && nx<w && ny<h && field[ny][nx]==search){
				Info tmp2 = {nx,ny};
				q.push(tmp2);
			}
		}
	}

	return false;
}

void put_block(int c,int d,int x,int y){
	int i,j;
	int to_i=2,to_j=4;

	if(d == 1){to_i=4,to_j=2;}

	for(i=0;i<to_i;i++){
		for(j=0;j<to_j;j++){
			field[y+i-1][x+j-1] = c;
		}
	}
}

int main(void){
	int n,c,d,x,y;

	while(cin>>w>>h && w){
		cin>>sx>>sy>>gx>>gy>>n;

		memset(field,0,sizeof(field));
		while(n--){
			cin>>c>>d>>x>>y;
			put_block(c,d,x,y);
		}

		if(bfd()){
			cout<<"OK\n";
		}
		else{
			cout<<"NG\n";
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using R=double;

// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N){ 
	for(int i=0;i<=N;++i){
		for(int j=0;j<=i;++j){
			if(j==0 or j==i){
				C[i][j]=1LL;
			}else{
				C[i][j]=(C[i-1][j-1]+C[i-1][j]);
			}
		}
	}
}

int main(void){
	int N,A,B;
	cin >>  N >> A >> B;

	const int NMAX=50;
	ll v[NMAX];

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

	comb_table(N);
	sort(v,v+N);
	reverse(v,v+N);

	R max_average=0.0;
	for(int i=0;i<A;++i){	
		max_average+=v[i];
	}
	max_average/=A;
	
	int a_th_val_num=0,a_th_val_pos=0;
	for(int i=0;i<N;++i){
		if(v[i]==v[A-1]){
			a_th_val_num++;
			if(i<A){
				a_th_val_pos++;
			}
		}
	}
	
	ll cnt=0LL;
	if(a_th_val_pos==A){
		for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
			cnt+=C[a_th_val_num][a_th_val_pos];
		}
	}else{
		cnt+=C[a_th_val_num][a_th_val_pos];
	}

	cout.precision(20);
	cout << fixed << max_average << endl;
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=(int) 1e5;
static const int MOD=(int) 1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
int N,a,sum;

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> N;
    for(int i=0;i<N;i++) {
        cin >> a;
        sum += a-1;
    }
    cout << sum <<"\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = [int(i) for i in input().split()]
#L = list(set(L))
L.sort()
#print(L)
ans = 0

for i, l1 in enumerate(L):
    for j, l2 in enumerate(L[i+1:]):
        if l1 == l2:
            continue
        for l3 in L[i+j+2:]:
            #print(i,j,L[j+1:])
            #print(l1, l2, l3)
            if l2 == l3:
                continue
            elif l3 - l2 < l1 < l3 + l2:
                ans += 1
print(ans)

Measured memory_bytes: 67844
def main():
    s = int(input())

    def f(n):
        if n % 2 == 0:
            return n // 2
        else:
            return 3 * n + 1

    a = s
    max_a = a
    i = 1

    m = {}
    m[s] = 1

    while True:
        a = f(a)
        i += 1
        if not a in m:
            m[a] = i
        else:
            print(i)
            exit()


main()


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

#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2], R[MAX/2+2];
int cnt; 
void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main() {
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];

    mergeSort(A, n, 0, n);

    for (i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}


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


signed main() {
    int X, Y;
    cin >> X >> Y;

    if ((4 * X) < Y) {
        cout << "No" << endl;
        return 0;
    }
    if ((Y%2) != 0) {
        cout << "No" << endl;
        return 0;
    }

    int a = Y - (2 * X);
    if (a < 0) {
        cout << "No" << endl;
        return 0;
    }


    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3632
from collections import deque
K = int(input())
q = deque([0])

cnt = 0
while q:
  n = q.popleft()
  r = n % 10; n *= 10;
  for i in range(10):
    if abs(r - i) <= 1 or n == 0:
      if n + i != 0:
        q.append(n + i)
        cnt += 1
        if cnt == K:
          print(n+i)
          exit()

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

using namespace std;

#define ll long long
#define ar array

int n, k, tmp;
string s;


int AC = 0;
int WA = 0;
int TLE = 0;
int RE = 0;

void solve(){
    

    cin >> n;





    for (int i = 0; i < n; i++)
    {
        cin >> s;

        if(s == "AC") AC++;
        if(s == "WA") WA++;
        if(s == "TLE") TLE++;
        if(s == "RE") RE++;

    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int solve(int n, int k, int s, int m, const vi a) {
  if(n == 0) return (s == m) ? 1 : 0;
  int ans = 0;
  REP(i, k-1) {
    vi v = a;
    v.pb(i+1);
    ans += solve(n-1, i+1, s, m+i+1, v);
  }
  return ans;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n, k, s; cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    vi a;
    cout << solve(k, n+1, s, 0, a) << endl;
  }
}



Measured memory_bytes: 3092
#include <stdio.h>

int main () {
   int x, y, z, swap;

   z = 0;

   scanf ("%d %d", &x, &y);

   if (x < y) {
      swap = x;
      x = y;
      y = swap;
   }


   while(1) {
      z = x % y;

      if(z == 0){
         printf("%d\n", y);
         break;
      }
      
      x = y;
      y = z;
   }
   return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
vector<int> nei[2005],nei2[2005];
int num[2005];
bool lol[2005];
vector<int> ltks[2005];
int ans[2005];
inline void dfs(int now,int ltk){
	if(lol[now]){
		return;
	}
	lol[now]=1;
	ltks[ltk].pb(now);
	for(int i=0;i<nei[now].size();i++){
		if(!lol[nei[now][i]]){
			dfs(nei[now][i],ltk);
			nei2[now].pb(nei[now][i]);
		}	
	}
}
int n;
inline ll gcd(ll a,ll b){
	while(a&&b){
    	if(a>b){
    		a%=b;
		}
    	else{
    		b%=a;
		}
	}
	return a+b;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	sort(num,num+n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(gcd(num[i],num[j])!=1){
				nei[i].pb(j);
			}
		}
	}
	int cntltk=0;
	for(int i=0;i<n;i++){
		if(!lol[i]){
			dfs(i,cntltk++);
		}
	}
	priority_queue<pair<int,int> > pq;
	for(int i=0;i<cntltk;i++){
		pq.push(mp(num[ltks[i][0]],ltks[i][0]));
	}
	int nn=0;
	while(pq.size()){
		pair<int,int> nnaa=pq.top();
		pq.pop();
		int nnum=nnaa.first,x=nnaa.second;
		ans[nn++]=nnum;
		for(int i=0;i<nei2[x].size();i++){
			pq.push(mp(num[nei2[x][i]],nei2[x][i]));
		}
	}
	for(int i=0;i<nn;i++){
		cout<<ans[i]<<' ';
	}
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define LL long long
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main()
{
    FASTER;
    int N;
    cin >> N;
    int Max = 0, res = 1;
    for(int i = 1; i <= N; i++){
        int cnt = 0;
        int n = i;
        while(n != 1){
            if(n % 2 == 0){
                cnt++;
                n /= 2;
            }
            else break;
        }
        if(cnt > Max){
            Max = cnt;
            res = i;
        }
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7


def cmb(r):
    numerator = reduce(lambda x, y: x * y % mod, range(n, n - r, -1))
    denominator = reduce(lambda x, y: x * y % mod, range(1, r + 1))
    return numerator * pow(denominator, mod - 2, mod) % mod


ans = pow(2, n, mod) - 1 - cmb(a) - cmb(b)
print(ans % mod)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	cin>>a;
  if(a==25)
    cout<<"Christmas"<<endl;
  else if(a==24)
    cout<<"Christmas Eve"<<endl;
  else if(a==23)
    cout<<"Christmas Eve Eve"<<endl;
  else
    cout<<"Christmas Eve Eve Eve"<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    string S;
    getline(cin,S);
    int X,temp,d,minimum=642;
    for(int i=0;i<S.size()-2;i++)
    {
        X=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
        temp=X;
        int Y=753;
        X=max(X,Y);
        Y=min(temp,Y);
        d=X-Y;
        if(d<=minimum)
        {
            minimum=d;
        }
    }
    cout<<minimum<<endl;
}


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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    double r;
    cin>>r;
    r*=2;
    r*=3.14159265358979;

    cout<<r<<endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fl first
#define fr second
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;

const int N = 200000 + 5;

char s[N];

int main()
{
    scanf("%s", s + 1);
    int n = strlen(s + 1), ans = n;
    for (int i = 2; i <= n; i++)
        if (s[i] != s[i - 1]) ans = min(ans, max(i - 1, n - i + 1));
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());
        int p = Integer.parseInt(sc.next());
        String t = sc.next();
        StringBuilder win = new StringBuilder();
        int num = 0;
        for (int i = 0; i < t.length(); i++) {
            win.append(winChar(t.charAt(i)));
            num += point(r, s, p, winChar(t.charAt(i)));
        }
        for (int i = t.length() - 1 - k; i >= 0; i--) {
            if (win.charAt(i) == win.charAt(i + k)) {
                num -= point(r, s, p, win.charAt(i));
                int bb = i - k;
                if (bb >= 0) {
                    char before = win.charAt(bb);
                    if (before != win.charAt(i + k)) {
                        win.setCharAt(i, other(before, win.charAt(i + k)));
                    } else {
                        win.setCharAt(i, loseChar(before));
                    }
                } else {
                    win.setCharAt(i, loseChar(win.charAt(i)));
                }
            }
        }
        System.out.println(num);
    }

    private static int point(int r, int s, int p, char c) {
        if (c == 'r') {
            return r;
        } else if (c == 's') {
            return s;
        } else {
            return p;
        }
    }

    private static char other(char c1, char c2) {
        Set<Character> rsp = new HashSet<>(Arrays.asList('r', 's', 'p'));
        rsp.remove(c1);
        rsp.remove(c2);
        char ans = 'r';
        for (char c : rsp) {
            ans = c;
        }
        return ans;
    }

    private static char winChar(char c) {
        if (c == 'r') {
            return 'p';
        } else if (c == 's') {
            return 'r';
        } else {
            return 's';
        }
    }

    private static char loseChar(char c) {
        if (c == 'r') {
            return 's';
        } else if (c == 's') {
            return 'p';
        } else {
            return 'r';
        }
    }
}

Measured memory_bytes: 34200
#include<bits/stdc++.h>
#define mod 1000000007
#define modc 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << " " << x << " " <<  #y << " " << y << endl
#define deb3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " "  << z << endl;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define nl cout << "\n"
using namespace std;
template <class T>
string to_binary(T n)//returns string by converting n into its binary form
{
	string binaryNum;
	while (n > 0) {
		binaryNum.pb((n % 2)+'0');
		n = n / 2;
	}
	reverse(binaryNum.begin(),binaryNum.end());
	return binaryNum;
}
template <class T>
string to_string(T n)
{
	string str;
	while(n>0)
	{
		int r=n%10;
		n/=10;
		str.pb((r)+'0');
	}
	reverse(str.begin(),str.end());
	return str;
}
template<class T>
bool perfectSq(T n)   //Checks if n is a perfect square
{
	if(sqrt(n) == floor(sqrt(n)))
		return true;
	else
		false;
}
template<class T>
void print(T &v)
{
	for(auto x : v)
		cout << x << " " ;
	nl;
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s1,s2;
	cin>>s1>>s2;
	int i,j,k;
	if(s1.size()+1==s2.size())
	{
		int flag=0;
		for(i=0;i<s1.size();i++)
		{
			if(s1[i]!=s2[i])
			{
				cout<<"No";
				flag=1;
				break;
			}
			
		}
		if(!flag)
		   cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
 
  sort(s.begin(), s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(), t.end());
  
  if(s < t){
    cout << "Yes" << endl;
  }else{
   cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	int n, x, t;
	cin >> n >> x >> t;
	int nb;
	if (n % x == 0)
		nb = n / x;
	else
		nb = n / x + 1;
	cout << nb * t << endl;
	return (0);
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,x;
int accxor[200002],accadd[200002];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		accxor[i]=accxor[i-1]^x;
		accadd[i]=accadd[i-1]+x;
	}
	int l=1;
	long long res=0;
	for(int r=1;r<=n;r++){
		while((accxor[r]^accxor[l-1])!=(accadd[r]-accadd[l-1]))
			l++;
		res+=(long long)(r-l+1);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
//const int N=1e5;
#define INF 1e9
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double

void sol() {
	int n ;
	double d;
	cin >> n >> d;
	ld dis;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ld x, y;
		cin >> x >> y;
		dis = sqrt(x * x + y * y);
		if (dis <= d)
			ans++;
	}

	cout << ans;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		sol();
	}

	return 0;
}

Measured memory_bytes: 3860
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    string s[3];
    rep(i,3)cin>>s[i];
    int ans=0;
    rep(i,n){
        set<char> st;
        rep(j,3)st.insert(s[j][i]);
        ans+=st.size();
        --ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
r, c = map(int, input().split())
rc = [[int(i) for i in input().split()] for j in range(r)]

r_sum = [0] * (r+1)
c_sum = [0] * c


for i in range(r):
    for j in range(c):
        r_sum[i] += rc[i][j]
        c_sum[j] += rc[i][j]
        r_sum[r] += rc[i][j]

for i in range(r+1):
    for j in range(c):
        if i != r:
            print(rc[i][j], end=" ")
        else:
            print(c_sum[j], end=" ")
    print(r_sum[i])



Measured memory_bytes: 6248
# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int,input().split()))

sum = 0
L = []

for i in range(len(H)):
  if i == 0:
    sum = 0
    L.append(sum)
  elif i == N-1:
    if H[i] <= H[i-1]:
      sum += 1
      L.append(sum)
    else:
      L.append(sum)
  else:
    if H[i] <= H[i-1]:
      sum += 1
    else:
      L.append(sum)
      sum = 0
    
print(max(L))
      
  

Measured memory_bytes: 14252
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,n){e.exports=function(e){var n=e.split("\n")[0],t=Number(n.slice(0,2)),r=Number(n.slice(2,4)),o=!1,u=!1;1<=t&&t<=12&&(o=!0),1<=r&&r<=12&&(u=!0),u&&o?console.log("AMBIGUOUS"):o?console.log("MMYY"):u?console.log("YYMM"):console.log("NA")}},function(e,n){e.exports=require("fs")}]);

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int main(){
   int K,S,ans=0;
   cin>>K>>S;
  for(int i=0;i<=K;i++){
      for(int j=0;j<=K;j++){
          if(i+j<=S && S-i-j<=K){
                    ans++;   
          }
      }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

char s[100111];int n,a[100111];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);s[0]='0';
	for(int i=1;i<=n;i++)a[i]=(s[i]-'0')^(s[i-1]-'0');
//	for(int i=1;i<=n;i++)printf("%d ",a[i]);puts("");
	int ans=n;
	for(int i=1;i<=n;i++)
		if(a[i]==1)ans=min(ans,max(i-1,n-i+1));
	printendl(ans);
	return 0;
}

Measured memory_bytes: 768
n = gets.to_i
p = gets.split.map(&:to_i)
cnt = 0
(1..n-2).each do |i|
	if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i+1] < p[i] and p[i] < p[i-1])
		cnt += 1
	end
end
puts cnt


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

using namespace std;

int main()
{
    long long n,m,i,j,k,x=0,y,z;
    string s;
    cin>>n;
    cin>>s;
    if(n<3200)
    {
        cout<<"red"<<endl;
    }
    else
    {
        cout<<s<<endl;
    }
}


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

using namespace std;

int findMin(vector<int> &x, int a, vector<int>& h)
{
	if(x[a] != -1)
		return x[a];
	if(a == x.size()-1)
		x[a] = 0;
	else if(a==x.size()-2)
		x[a] = abs(h[a]-h[a+1]);
	else
	{
		int p = abs(h[a]-h[a+1]) + findMin(x,a+1,h);
		int q = abs(h[a]-h[a+2]) + findMin(x,a+2,h);
		x[a] = min(p,q);
	}
	return x[a];
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int i,n;
	cin>>n;
	vector<int> h(n),x(n,-1);
	for(i=0; i<n; i++)
		cin>>h[i];

	cout<<findMin(x,0,h)<<endl;
	return 0;
}


Measured memory_bytes: 7296
import math
n = int(input())

def f(x,y,z):
  return x**2 + y**2 + z**2 + z*x + x*y + y*z

current = [1,1,1]
ans = 0
p = [0 for _ in range(n+1)]
m = math.ceil(math.sqrt(n))+1
for i in range(1, m):
  f_ = f(i, 1, 1)
  if f_ > n:
    break
  for j in range(1, m):
    f_ = f(i,j,1)
    if f_ > n:
      break
    for k in range(1, m):
      f_ = f(i,j,k)
      if f_ > n:
        break
      p[f_] += 1
for i in range(1, n+1):
  print(p[i])

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

int main() {
  string A,B;
  cin>>A>>B;
  int a,b;
  int ans=1000;
  a=A.size();
  b=B.size();
  for(int i=0; i<a-b+1; i++){
    int d=0;
    for(int j=0; j<b;j++){
      if(A.at(j+i)!=B.at(j))
        d++; 
    }
    if(d<=ans)
      ans=d;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3616
use std::collections::*;
use std::io::*;
use std::*;
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    // iterator(splitted input-string) => iterator(output-type)
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:ty),+) => {
        ($(_get!($it; $t)),*)
    };
}

fn main() {
    let n = get!(i32);
    let mut a = get!([i64]);
    a.sort_by(|a, b| b.cmp(a));
    let mut ans: i64 = 0;
    ans += a[0];
    let mut left = n - 2;
    for i in 1..n {
        if left >= 2 {
            ans += a[i as usize] * 2;
            left -= 2;
        } else if left == 1 {
            ans += a[i as usize];
            println!("{}", ans);
            return;
        } else {
            println!("{}", ans);
            return;
        }
    }
}


Measured memory_bytes: 5900
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <sstream>
#include <climits>
#include <fstream>
#include <cmath>

using namespace std;

/// ********* debug template by Bidhan Roy *********

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const unordered_set< T > &v ) {
    os << "[";
    typename unordered_set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const unordered_map< F, S > &v ) {
    os << "[";
    typename unordered_map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << ": " << it -> second ;
    } 
    return os << "]";
}

#define debug(x) cerr << #x << " = " << x << endl;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<bool> VB;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<LL> VLL;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<VB> VVB;
typedef vector<VI> VVI;
typedef vector<VC> VVC;
typedef vector<VLL> VVLL;
typedef vector<VD> VVD;
typedef vector<VS> VVS;

// TEMPLATE DEFINITIONS END

int n;
string s;

void read_input(){
    cin >> n;
    cin >> s;
}

void solve(){

    for(int i=0;i<s.size();i++){
        s[i] = s[i] - 'A';
        s[i] = (s[i] + n) % 26;
        s[i] = s[i] + 'A';
    }

    cout << s << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    read_input();
    solve();
    return 0;
}


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

int main(){
    int N; cin >> N;
    for(size_t i = 0; i <= 25; i++)
    {
        for(size_t j = 0; j <= 15; j++)
        {
            int price = i*4 + j*7;
            if (price == N)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256