akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

long long N;
long long mod = 1000000007;
long long zero_bit[60];
long long one_bit[60];

int main() {
    std::cin >> N;

    std::vector<long long> A(N);
    for (long long i = 0; i < N; i++) {
        std::cin >> A[i];
        //int tmp_zero = 0, tmp_one = 0;
        for (long long bit = 0; bit < 60; bit++) {
            /*
            if ((A[i] >> bit) & 1) {
                one_bit[bit]++;
                //tmp_one++;
                //std::cout << "1";
            } else {
                zero_bit[bit]++;
                //tmp_zero++;
                //std::cout << "0";
            }
            */
            ((A[i] >> bit) & 1) ? one_bit[bit]++ : zero_bit[bit]++;
        }
        //std::cout << std::endl;
        //std::cout << "tmp_one = " << tmp_one << std::endl;
        //std::cout << "tmp_zero = " << tmp_zero << std::endl;
    }

    long long result = 0;
    for (long long bit = 0; bit < 60; bit++) {
        long long tmp = 1;
        tmp *= (1LL << bit) % mod;
        tmp %= mod;
        tmp *= one_bit[bit] % mod;
        tmp %= mod;
        tmp *= zero_bit[bit] % mod;
        tmp %= mod;
        result = (result + tmp) % mod;
        //long long result = (result + ( tmp * (one_bit[bit] * zero_bit[bit] % mod) ) % mod) % mod;
        //result = (result + tmp2) % mod;
        //result %= mod;
        //std::cout << "zero_bit[" << bit << "] = " << zero_bit[bit] << std::endl;
        //std::cout << "one_bit[" << bit << "] = " << one_bit[bit] << std::endl;
    }
    //result = result % mod;

    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  ll M;
  cin >> N >> M;
  ll A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  map<int,int> mp;

  //累積和
  ll sum[N+1];
  sum[0] = 0LL;
  mp[0]++;
  for(int i=1;i<=N;i++){
    sum[i] = sum[i-1] + A[i-1];
    sum[i] = sum[i] % M;
    mp[sum[i]]++;
  }

  ll cnt = 0LL;
  for(auto it = mp.begin() ; it!=mp.end() ; it++){
    //cout << it->first << it->second << endl;
    if(it->second >= 2){
      ll tmp = it->second;
      cnt += tmp * (tmp-1) / 2;
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    int cnt[2] = {};
    FOR(i, 1, N + 1) {
        cnt[i % 2]++;
    }
    cout << fixed << setprecision(10) << 1.0 * cnt[1] / N << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define INF 1LL<<61
#define fi first
#define se second
using namespace std;
int main(){
    int n;
    cin >> n;
    ll a[100100];
    ll b[100100];
    vector<pair<ll,int> > c(n);
    rep(i,n){
        cin >> a[i] >> b[i];
        c[i].fi = a[i]+b[i];
        c[i].se = i;
    }
    sort(c.rbegin(),c.rend());
    ll ans = 0;
    rep(i,n){
        int d = c[i].se;
        if(i%2==0){
            ans += a[d];
        }else{
            ans -= b[d];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n, k, arr[nax];
	
int main(){
	IOS
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}	
	sort(arr, arr+n);
	ll mins=inf;
	for(int i=0;i+k<=n;i++){
		mins=min(mins, arr[i+k-1]-arr[i]);
	} 
	cout << mins << '\n';
}


Measured memory_bytes: 4368
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

ll dp[110][4][2];

int main() {
  string s; cin >> s;
  int K; cin >> K;
  int n=s.size();
  dp[0][0][0]=1ll;
  rep(i,n)rep(j,n+1)rep(k,2){
    rep(d,10){
      int ni=i+1,nj=j,nk=k;
      if(d!=0) nj++;
      if(nj>K) continue;
      if(k==0){
        if(d>s[i]-'0') continue;
        if(d<s[i]-'0') nk=1;
      }
      dp[ni][nj][nk]+=dp[i][j][k];
    }
  }
  cout << dp[n][K][0]+dp[n][K][1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;

int main(){
  ll x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z), ab, abc;
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  rep(i, x)rep(j, y) ab.push_back(a[i]+b[j]);
  sort(ab.rbegin(), ab.rend());
  sort(c.rbegin(), c.rend());
  int n = min(k, x*y);
  rep(i, n)rep(j, z) abc.push_back(ab[i]+c[j]);
  sort(abc.rbegin(), abc.rend());
  rep(i, k) cout << abc[i] << endl;
  
  return 0;
}

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

int main(){
    int k,ans = 0;
    cin >> k;
    for (int a = 1; a <= k;a++){
        for (int b = 1;b <= k;b++){
            for (int c = 1;c <= k;c++){
                ans += gcd(gcd(a,b),c);
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <queue>
using namespace std;
int h, w, cnt, b[55][55];
char a[55][55];
queue<int> qr, qc;

void f(int p, int q, int r) {
	if(a[p][q]=='.') {
		qr.push(p);
		qc.push(q);
		a[p][q] = 'x';
		b[p][q] = r;
	}
}

int main() {
	int i, j;
	scanf("%d%d", &h, &w);
	for(i=1; i<=h; i++) {
		scanf("%s", &a[i][1]);
		for(j=1; j<=w; j++) cnt += a[i][j]=='.';
	}
	f(1, 1, 1);
	while(!qr.empty()) {
		i = qr.front(), qr.pop();
		j = qc.front(), qc.pop();
		if(i==h && j==w) {printf("%d", cnt-b[h][w]); return 0;}
		f(i+1, j, b[i][j]+1);
		f(i-1, j, b[i][j]+1);
		f(i, j+1, b[i][j]+1);
		f(i, j-1, b[i][j]+1);
	}
	puts("-1");
	return 0;
}

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

#define     Boost               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define     all(cont)           cont.begin(),cont.end()
#define     rall(cont)          cont.rbegin(),cont.rend()
#define     foreach(cont)       for(auto &val: cont)
#define     dbg(args...)        do {   cerr << #args << "-> " ;  show(args); } while(0); cerr<< endl ;
#define     TS                  template < typename T >
#define     TP                  template < typename F, typename S >
#define     TM                  template<typename T1, typename... T2>
#define     flush               cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define     Case                cout<< "Case "<< ++cs <<": "
#define     PI                  3.1415926535897932384
#define     eps                 1e-9
#define     inf                 LLONG_MIN
#define     INF                 LLONG_MAX
#define     mp                  make_pair
#define     pb                  push_back
#define     ff                  first
#define     ss                  second

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

/** Debugging Tool **/
TS void show(const T& v) {    cerr << v << ' ' ;}
TM void show(const T1& first,const T2&... rest){show(first);show(rest...);}
TP ostream& operator<<(ostream& os,const pair<F,S>& p){return os<<"("<<p.ff<<", "<<p.ss<<")";}
TS 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<<"}";}
TS 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<<"]";}
TP 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->ff<<" = "<<it->ss;}return os<<"]";}
/** Ends **/


void solve(){
    string s,t ;
    cin>> s >> t ;
    int n = s.size(),cnt=0 ;
    for(int i=0; i<n; i++){
        if(s[i] != t[i]) cnt++ ;
    }

    cout<< cnt << endl ;

}


int main()
{
    Boost;

    #ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    freopen("input.txt","r",stdin);    // Read
    freopen("output.txt","w",stdout);  // Write
    #endif

    int t = 1,cs = 0 ;
    //cin>> t ;

    while(t--){
        //Case ;
        solve() ;
    }

    #ifndef ONLINE_JUDGE
    fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}



Measured memory_bytes: 3808
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define MOD 1000000007
template<class T> T in(){T x;cin>>x;return x;}

int main(){
	int H,W; cin>>H>>W;

	vector<string> A;
	for(int i=0; i<H; i++){
		A.push_back(in<string>());
	}

	vvi dp(H+1, vi(W+1));
	dp[H][W-1] = 1;
	for(int h=H-1; h>=0; h--){
		for(int w=W-1; w>=0; w--){
			if(A[h][w]=='.') dp[h][w] = (dp[h+1][w] + dp[h][w+1]) % MOD;
		}
	}
	cout<< dp[0][0] <<endl;
}

Measured memory_bytes: 5248
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	ll a,b,c,d;
	ll N;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	scanf("%lld",&N);
	ll o=min(4LL*a,min(2LL*b,c));
	ll o2=min(d,2LL*o);
	ll ret=(N/2)*o2+(N%2)*o;
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}

int main(){
	double x,y;
	VP v;
	while(scanf("%lf,%lf", &x, &y) != EOF){
		v.push_back(P(x,y));
	}
	printf("%.10f\n", abs(getarea(v)));
	return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>

int main(void)
{
  int a,b;
  scanf("%d %d",&a,&b);
  
  if(a == b){
    printf("%s\n","a == b");
  }
    else{ if(a < b){
      printf("%s\n","a < b");
      }
       else{ 
	 printf("%s\n","a > b");
      }
  }
  return 0;
}

Measured memory_bytes: 580
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Read, Write, BufWriter};
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let d = get();
    let g: i64 = get();
    let mut p = vec![0; d];
    let mut c = vec![0; d];
    for i in 0 .. d {
        p[i] = get();
        c[i] = get();
    }
    let mut mi = 1 << 28;
    for bits in 0 .. 1 << d {
        let mut tot = 0;
        let mut cnt = 0;
        for j in 0 .. d {
            if (bits & 1 << j) == 0 { continue; }
            tot += 100 * (j as i64 + 1) * p[j] + c[j];
            cnt += p[j];
        }
        if tot >= g {
            mi = min(mi, cnt);
            continue;
        }
        for i in 0 .. d {
            if (bits & 1 << i) != 0 { continue; }
            let sc = 100 * (i as i64 + 1);
            let need = (g - tot + sc - 1) / sc;
            if need >= p[i] { continue; }
            mi = min(mi, cnt + need);
        }
    }
    println!("{}", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;
 
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator
 
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 

int32_t main()
{
    fast;
    int n,a,b;cin>>n>>a>>b;
    cout<<min(n*a,b);
}

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

int main(){
   int N;
   cin >> N;

   double p;
   if (N%2 == 0)
      p = 1/2.0;
   else
      p = (N+1)/2.0/N;

   cout << setprecision(11) << p << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int W, H, x, y, r;
    -100 <= x, y <= 100;
    0 < W, H, r <= 100;
    scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);
    if(x-r >= 0 && y-r >= 0 && x+r <= W && y+r <= H)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n;
  cin >> n;
  vi a(n), b(n), c(n - 1);
  REP(i, 0, n)  cin >> a[i];
  REP(i, 0, n)  cin >> b[i];
  REP(i, 0, n - 1)  cin >> c[i];

  int ans = 0, last = a[0];
  REP(i, 0, n){
      ans += b[a[i] - 1];
      if(a[i] == last + 1){
        ans += c[last - 1];
        last++;
      }
      else
        last = a[i];
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
# include<iostream>
using namespace std;
static const int MAX = 100;

void output(int A[],int N){
    for(int i=0;i<N;i++){
        cout << A[i];
        if(i == N-1){
            cout << endl;
        }else{
            cout << " ";
        }
    }
}

int selectionSort(int A[],int N){
    int minj,sw;
    sw=0;
    for(int i=0;i<N;i++){
        minj = i;
        for(int j=i;j<N;j++){
            if(A[j]<A[minj]){
                minj = j;
            }
        }
        if(i != minj){
            swap(A[i],A[minj]);
            sw++;
        }
    }

    return sw;
}

int main(){
    int N,count;
    int A[MAX];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    count = selectionSort(A,N);
    output(A,N);
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3120
N = int(input())
h_list = list(map(int,input().split()))

INF = 100001001010000
dp = [INF]*N # dp[i]:足場iに行くまでの最小コスト
dp[0] = 0
dp[1] = abs(h_list[1] - h_list[0])

for i in range(2,N):
    s0 = dp[i-2] + abs(h_list[i]-h_list[i-2]) # 2つ前の足場から飛ぶ場合
    s1 = dp[i-1] + abs(h_list[i]-h_list[i-1]) # 1つ前の足場から飛ぶ場合
    dp[i] = min(s0,s1) # コストが少ない方を選ぶ

print(dp[N-1])    

Measured memory_bytes: 13976
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
    
    int n;
    cin>>n;
    ll ar[n];
    for(int i=0; i< n; i++) cin>>ar[i];
    
    double ans = 0;
    
    for(int i=0; i<n ;i++){
        ans = ans + (1.0/(double)ar[i]);
    }
    cout<<fixed<<setprecision(7)<<(double)1.0 / (double) ans<<endl;
    return 0;
}

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  if(A >= K){
    cout << K << endl;
  }else if((A + B) >= K){
    cout << A << endl;
  }else{
    int score = A - (K - A - B);
    cout << score << endl;
  }
}

Measured memory_bytes: 3676
import java.util.*;
import java.math.BigDecimal;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);    //scanner
        // 数値受付
        int n = sc.nextInt();   // 1<= n,l <=100
        int l = sc.nextInt();
        // 文字列受付
        String s;
        ArrayList<String> sl = new ArrayList<String>(); // 文字列リスト
        for(int i=0;i<n;i++){
            s = sc.next();
            sl.add(s);  // リストに文字列を追加
        }
        // ソート
        Collections.sort(sl);
        // 出力文字列作成
        String ans = "";
        for(String str : sl){
            ans += str;
        }
        // 出力
        System.out.println(ans);    // output
    }
}

Measured memory_bytes: 25168
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (a, b, c) = readIntegerList()
    for (i in 1..b) {
        if ((((a % b) * i) % b) == c) {
            out.println("YES")
            return
        }
    }
    out.println("NO")
}


fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36176
#include<cstdio>
#include<cassert>

//INSERT ABOVE HERE
template<typename T>
struct Treap{
  struct Node{
    Node *l,*r;
    T key,pri;
    Node(){}
    Node(T key,T pri):key(key),pri(pri){l=r=nullptr;}
  };
  
  inline Node* create(){
    return new Node();
  }
  
  inline Node* create(T key,T pri){
    return new Node(key,pri);
  }
  
  Node* rotR(Node* t){
    Node* s=t->l;
    t->l=s->r;
    s->r=t;
    return s;
  }
  
  Node* rotL(Node* t){
    Node* s=t->r;
    t->r=s->l;
    s->l=t;
    return s;
  }
  
  Node* insert(Node* t,T key,T pri){
    if(t==nullptr) return create(key,pri);
    if(key==t->key) return t;
    if(key < t->key){
      t->l=insert(t->l,key,pri);
      if(t->pri < t->l->pri) t=rotR(t);
    }else{
      t->r=insert(t->r,key,pri);
      if(t->pri < t->r->pri) t=rotL(t);
    }
    return t;
  }

  Node* erase(Node* t,T key){
    if(t==nullptr) return t;
    if(key < t->key) t->l=erase(t->l,key);
    else if(key > t->key) t->r=erase(t->r,key);
    else return del(t,key);
    return t;
  }

  Node* del(Node* t,T key){
    if(t->l==nullptr&&t->r==nullptr) return nullptr;
    if(t->l==nullptr) t=rotL(t);
    else if(t->r==nullptr) t=rotR(t);
    else if(t->l->pri < t->r->pri) t=rotL(t);
    else t=rotR(t);
    return erase(t,key);
  }

  Node* find(Node* t,T key){
    if(t==nullptr) return t;
    if(key < t->key) return find(t->l,key);
    if(key > t->key) return find(t->r,key);
    return t;
  }

  void print1(Node* t){
    if(t==nullptr) return;
    print1(t->l);
    printf(" %d",t->key);
    print1(t->r);
  }
  
  void print2(Node* t){
    if(t==nullptr) return;
    printf(" %d",t->key);
    print2(t->l);
    print2(t->r);
  }  
};

char s[10];
int main(){
  int q;  
  scanf("%d",&q);
  Treap<int> G;
  Treap<int>::Node* r=nullptr;
  
  for(int i=0;i<q;i++){    
    scanf("%s",s);
    if(s[0]=='i'){
      int key,pri;
      scanf("%d %d",&key,&pri);
      r=G.insert(r,key,pri);
    }
    if(s[0]=='d'){
      int key;
      scanf("%d",&key);
      r=G.erase(r,key);
    }
    if(s[0]=='f'){
      int key;
      scanf("%d",&key);
      puts((G.find(r,key)!=nullptr?"yes":"no"));
    }
    if(s[0]=='p'){
      G.print1(r);
      puts("");
      G.print2(r);
      puts("");
    }
  }
  return 0;
}



Measured memory_bytes: 8984
n = gets.to_i
l = gets.split(" ").map(&:to_i)

#最大長を取得
max_length = l.max
max_length_point = l.find_index(l.max)
#配列から最大長を消す
l.delete_at(max_length_point)
#最大長以外の長さを足し込む
sum_length = l.inject(&:+)

if sum_length > max_length
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p=0;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    p+=b[i]-a[i]+1;
  }
  cout<<p<<endl;
}

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

int main(){
    double n,ans;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n-1)cin >> c[i];
    rep(i,n){
        ans+=b[a[i]-1];
        if(i==0) continue;
        else if(a[i]==a[i-1]+1) ans+=c[a[i-1]-1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

#define PRIME 1000000007

ll add(ll a, ll b){
  return (a+b)%PRIME;
}
ll mul(ll a, ll b){
  return (a*b)%PRIME;
}

int main(){
  str s;
  cin >> s;
  ll x = 1, a = 0, b = 0, c = 0;
  REP(i,s.length()){
    switch(s[i]){
      case 'A' :
      a = add(a,x); break;
      case 'B' :
      b = add(b,a); break;
      case 'C' :
      c = add(c,b); break;
      case '?' :
      c = add(mul(c,3),b);
      b = add(mul(b,3),a);
      a = add(mul(a,3),x);
      x = mul(x,3);
      break;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}



int main(){
 
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n);
    vector<ll> c(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> c[i];
    rep(i,n) p[i]--;
    ll ans = -1e18;
    ll total = 0;
    rep(i,n){
        int t = i;   
        int times = 0;
        total = 0;
        vector<int> s;
        rep(j,n){
            t = p[t];
            s.push_back(c[t]);
            total += c[t];
            times++;
            if(t == i) break;
        }
        ll sum = 0;
        rep(j,s.size()){
            if(j+1 > k) break;
            sum += s[j];
            ll now = sum;
            if(total > 0){
                int e = (k-j-1)/times;
                now += total*e;
            }
            ans = max(ans,now);
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=1e6+7;
typedef long long ll;
const int mod=1e9+7;
void Smax(ll &a,ll b){if(a<b) a=b;}
void Smin(ll &a,ll b){if(a>b) a=b;}
///#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
///char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
#define IO cin.tie(0),ios::sync_with_stdio(false);
#define pi acos(-1)
#define PII pair<ll,ll>
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()
/** keep hungry and keep calm! **/

char s[maxn];


int Sheryang()
{

    scanf("%s",s+1);
    int n=strlen(s+1);

    stack<char>st;

    int ans=0;
    for(int i=1;i<=n;i++){
        if(st.empty() || s[i]==st.top()){
            st.push(s[i]);
        }else{
            st.pop();ans++;
        }
    }

    cout<<ans*2<<endl;
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  int n=0;
  if (a > b) {
    n = a;
    a= a-1;
  }
  else{
    n = b;
    b=b-1;
  }

  if (a > b) {
    n +=a;
  }
  else{
    n += b;
  }
  

  cout << n << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define each(i, c) for (auto& (i) : (c))

using namespace std;
typedef long long int ll;
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }

const ll mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    ll ans = 1;
    for (ll i = 1; i <= n; i++) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  double a, min = 1000000.0, max = 0.0;
  while(scanf("%lf", &a) != EOF) {
    if(min > a) min = a;
    if(max < a) max = a;
  }
  printf("%f\n", max - min);
  return 0;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = ((int64_t)2e18);
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;

  // cin >> t;
  t = 1;

  while (t--) {
    int n;
    cin >> n;
    int k;
    cin >> k;

    n %= k;

    cout << min(n, k - n) << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		for (int i = 0; i < 5; i++) {
			int x = sc.nextInt();
			if(x==0){
				System.out.println(i+1);
			}
		}

	}
}

Measured memory_bytes: 27020
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
    double w;
   cin>>n;
   int a[n];
   rep(i,0,n) a[i]=0;
   rep(i,1,n){
       cin>>p;
       a[p-1]++;
   }
   rep(i,0,n){
       cout<<a[i]<<endl;
   }
   
}


Measured memory_bytes: 5192
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll n;
	cin >> n;

	multiset<ll> a;
	for (ll i = 0; i < n; i++)
	{
		ll q, x;
		cin >> q;

		switch (q)
		{
			case 0:
				cin >> x;
				a.insert(x);
				println(a.size());
				break;

			case 1:
				cin >> x;
				if (a.count(x))
				{
					println(a.count(x));
				}
				else
				{
					println(0);
				}
				break;

			case 2:
				cin >> x;
				a.erase(x);
				break;

			case 3:
				ll l, r;
				cin >> l >> r;

				for (decltype(a)::iterator it = a.equal_range(l).first; it != a.equal_range(r).second; it++)
				{
					println(*it);
				}
				break;
		}
	}

}






Measured memory_bytes: 12364
if __name__=="__main__":
  num = int(input())
  if num < 400:
    pass
  elif num<600:
    print(8)
  elif num<800:
    print(7)
  elif num<1000:
    print(6)
  elif num<1200:
    print(5)
  elif num<1400:
    print(4)
  elif num<1600:
    print(3)
  elif num<1800:
    print(2)
  elif num<2000:
    print(1)

Measured memory_bytes: 9064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    int x, t;
    cin >> x >> t;
    if(x-t<0) out(0);
    else out(x-t);
}


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

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

	string s;
	cin >> s;
	int ans = lim;
	int n = s.length();
	int cur = (s[0] - '0')*100 + (s[1] - '0')*10 + (s[2] - '0');
	for(int i=3; i<n; i++){
		ans = min(ans, abs(753-cur));
		cur %= 100;
		cur *= 10;
		cur += s[i] - '0';
	}
	ans = min(ans, abs(753-cur));
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
ans = len(t)

for i in range(len(s) - len(t) + 1):
    score = 0
    a = s[i : i + len(t) + 1]
    for j in range(len(t)):
        score += a[j] != t[j]
    ans = min(ans, score)

print(ans)


Measured memory_bytes: 9100
# -*- coding: utf-8 -*-
"""
D - equeue
https://atcoder.jp/contests/abc128/tasks/abc128_d

"""
import sys


def dig_lr(n, q, lr='L'):
    # 左(もしくは右)側から最大でn回操作した時の結果の最大値を求める
    res = [0]
    for di in range(1, min(n, len(q))+1): #  diは最大で掘る回数
        bu = n - di             #  埋める方に使用する操作回数
        dig = list(q[:di]) if lr == 'L' else list(q[-di:])
        dig.sort()
        while bu and dig and dig[0] < 0: #  マイナスのアイテムが手元にあればマイナスが大きい方から埋める
            dig.pop(0)
            bu -= 1
        res.append(sum(dig))
    return max(res)


def solve(N, K, V):
    ans = [0]
    limit = sum([v for v in V if v > 0]) #  価値がプラスのアイテムだけ取り出せたときの合計(理論上ベストな結果)
    # K操作回の操作を左右で(左:0 右:K), (左:1 右:K-1), ...,  (左:K 右:0),のように割り振っていき、
    # 左・右からゲットできる値の合計値を計算する
    for left in range(K+1):
        right = K - left
        l_dig = dig_lr(left, V, 'L')
        r_dig = dig_lr(right, V, 'R')
        ans.append(min(limit, l_dig+r_dig))
    return max(ans)


def main(args):
    N, K = map(int, input().split())
    V = [int(v) for v in input().split()]
    ans = solve(N, K, V)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <functional>
#include <queue>

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i, n) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());

    ll answer = 0;
    ll p_number = 0;
    ll p_counter = 0;
    rep(i, n) {
        if (vec[i] != p_number) {
            if (p_number <= p_counter) {
                answer += p_counter - p_number;
            } else {
                answer += p_counter;
            }
            p_number = vec[i];
            p_counter = 1;
        } else {
            ++p_counter;
        }
    }
    if (p_number <= p_counter) {
        answer += p_counter - p_number;
    } else {
        answer += p_counter;
    }
    cout << answer << endl;
    return 0;

}


Measured memory_bytes: 1024
a= input().strip()
l = int(len(a) //2 )
if len(a) % 2 != 0:
  l += 1
l2 = int(len(a))
k1 = list(a[0:l])
k2 = list(a[l:l2])

k2.reverse()

ans = 0
idx = 0
for i in k2:
  if k1[idx] != k2[idx]:
    ans +=1
  idx +=1
print(ans)


    
  

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

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(A[i] - A[N / 2]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <map>
using namespace std;
int M,l;int main(){string s,t,u;map<string,int>m;for(;cin>>u;t=t.size()<u.size()?u:t)if(++m[u]>M)M=m[u],s=u;cout<<s<<' '<<t<<endl;}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define p(x) cout << x << endl;

#define MOD 1000000007
#define PI 3.14159265359

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

    int n;
    cin >> n;
    int x = n;

    int num = 0;
    while(x != 0){
        num += x % 10;
        x /= 10;
    }

    if(n % num == 0){
        p("Yes");
    }else{
        p("No");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
int32_t main()
{
    fast;
    int n;
    cin >> n;
    int fl = 0;
    while (n != 0)
    {
        if (n % 10 == 7)
        {
            fl = 1;
        }
        n /= 10;
    }
    if (fl == 1)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }




}

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

int main(){
  int N,M,K;
  cin >> N >> M >> K;
  vector<int> A(N);
  vector<int> B(M);
  rep(i,N) cin >> A[i];
  rep(i,M) cin >> B[i];

  ll T = 0;
  rep(i,M) T+=B[i];
  int C = M;
  int ans = 0;
  rep(i,N+1){
    while(T>K && !C==0){
      C--;
      T-=B[C];
    }
      if(T>K) break;
      ans = max(ans, i+C);
      if(i==N) break;
      T+=A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    vector<int> w(10), k(10);
    for(int i=0; i<10; ++i)
        cin >> w[i];
    for(int i=0; i<10; ++i)
        cin >> k[i];
    sort(w.rbegin(), w.rend());
    sort(k.rbegin(), k.rend());

    cout << accumulate(w.begin(), w.begin()+3, 0) << ' '
         << accumulate(k.begin(), k.begin()+3, 0) << endl;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int solve(int n, int k, string s) {
    vector<Pii> run_length; // {isR?, length}
    int cnt = 0;
    for(int i=0;i<n;++i) {
        if(s[i] == 'L') {
            if(cnt > 0) {
                run_length.emplace_back(1, cnt);
                cnt = 0;
            }
            --cnt;
        } else {
            if(cnt < 0) {
                run_length.emplace_back(0, -cnt);
                cnt = 0;
            }
            ++cnt;
        }
    }
    if(cnt > 0) {
        run_length.emplace_back(1, cnt);
    }else if(cnt < 0) {
        run_length.emplace_back(0, -cnt);
    }

    if(run_length.size() == 1) return n-1;

    // for(int i=0;i<run_length.size();++i) cerr << run_length[i].second << " ";
    // cerr << endl;

    int ans = 0;
    for(int i=0;i<run_length.size();++i) {
        ans += run_length[i].second - 1;
    }
    for(int i=1;i<run_length.size()-1;++i) {
        if(run_length[i].first && k) {
            ans += 2;
            --k;
        }
    }
    if(run_length[0].first && k) {
        ans += 1;
        --k;
    }
    if(run_length.back().first && k) {
        ans += 1;
        --k;
    }

    return ans;
}

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    string t = "";
    for(int i=0;i<n;++i) {
        t += (s[n-1-i] == 'L') ? 'R' : 'L';
    }

    cout << max(solve(n, k, s), solve(n, k, t)) << endl;
}


Measured memory_bytes: 2484
<?php
$N = trim(fgets(STDIN));
$S = trim(fgets(STDIN));
$x = 0;
$max = 0;

for ($i = 0; $i < $N; $i++) {
    $t = substr($S, $i, 1);
    $x += $t === 'I' ? 1 : -1;
    $max = $max > $x ? $max : $x;
}

echo $max . "\n";

?>


Measured memory_bytes: 4604
N = gets.to_i

M = []

if N.even?
  (1..N).each do |i|
    ((i+1)..N).each do |j|
      if i + j != N+1
        M << [i,j]
      end
    end
  end
else
  (1..(N-1)).each do |i|
    ((i+1)..N).each do |j|
      if i + j != N
        M << [i,j]
      end
    end
  end  
end

p M.length

M.each do |a, b|
  puts "#{a} #{b}"
end


Measured memory_bytes: 2172
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int D[] = new int[K];
		for(int i = 0; i < K; i++) {
			D[i] = sc.nextInt();
		}
		outside : for(int i = N; i < 100000; i++) {
			for(int j = 0; j < String.valueOf(i).length(); j++) {
				for(int k = 0; k < K; k++) {
					if(String.valueOf(i).substring(j, j + 1).equals(String.valueOf(D[k]))) {
						continue outside;
					}
				}
			}
			System.out.println(i);
			return;
		}
	}
}


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

int n,o = 0, e = 0;

int main(){
	
	cin >> n;
	for ( int i = 0; i < n; i++ ){
		int a;
		cin >> a;
		if ( a & 1 ) o++;
		else e++;
	}
	
	while ( true ){
		if ( e > 1 ){
			e -= 1;
		} else if ( o > 1 ){
			o -= 2;
			e += 1;
		} else break;
	}
	if (o + e == 1 ) cout <<"YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-14;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ld a, b, c; cin >> a >> b >> c;
    ld x = sqrtl(a), y = sqrtl(b), z = sqrtl(c);
    if (abs(z - (x + y)) <= eps)cout << "No\n";
    else if (x + y < z)cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define endl '\n'
#define LL long long int
using namespace std;
struct jamin{
	LL A,B;
};
bool cmp(struct jamin i,struct jamin j) {
	return (i.A<j.A);
}
int main()
{
	LL M,i,N,money=0;
	cin>>N>>M;
	struct jamin love[N];
	for(i=0;i<N;i++) {
		cin>>love[i].A>>love[i].B;
	}
	sort(love,love+N,cmp);
	for(i=0;i<N;i++) {
		if(M>0) {
			if(M>love[i].B) {
				M=M-love[i].B;
				money=money+love[i].B*love[i].A;
			}
			else {
				money=money+M*love[i].A;
				M=0;
			}
		}
		else {
			break;
		}
	}
	cout<<money<<endl;
	return 0;
}

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

int main()
{
    // input
    int N;

    cin >> N;
    int A[N];
    int B[N];

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        int tmp = A[i]-1;
        B[tmp] = i+1;
    }
    for (int b : B)
        cout << b << endl;
}

Measured memory_bytes: 1536
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#include <cmath>
using namespace std;

int main(){
  int X;
  cin >> X;
  if (X>=30){
    cout << "Yes"<< endl;
  }
  else{
    cout << "No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	string s;
	cin >>s;
	int ans;
	int n;
	n=s.size();
	ans=n;
	if(n==1){cout<<1<<endl;}else{
		for(int i=0;i<n-1;++i){
			if(s[i]!=s[i+1]){ans=min(ans,max(i+1,n-i-1));}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 512