akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
#define PB push_back
#define MP make_pair
#define I insert
 
const LL N = 1e5+5, mod = 1000000007;
 
using namespace std;
 
LL n, m, i, j, k, l, r, t, ans, a[N];
vector < LL > v[N];

void go ( LL u, LL par = 0 ){
	for ( LL i = 0; i < v[u].size(); ++i ){
		if ( v[u][i] == par ) continue;
		go ( v[u][i], u );
		a[u] ^= (a[v[u][i]]+1);
	}
	//if ( u == 1 && v[u].size() == 1 || u != 1 && v[u].size() == 2 ) a[u]++;
}

int main(){
	cin >> n;
	for ( i = 1; i < n; ++i ){
		cin >> l >> r;
		v[l].PB(r);
		v[r].PB(l);
	}
	
	go(1);
	
	if ( a[1] ) cout << "Alice\n";
	else cout << "Bob\n";
	
	return 0;
}
 
/**/
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O        O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

ll N,ans; cin>>N;

set<ll> S;

S.insert(N);

for(int i=2;;i++){
  if(N%2==0) N/=2;

  else N=3*N+1;

  if(S.count(N)){
    ans=i; break;
  }

  S.insert(N);
}
  
cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
<?php
$countList = array();
for ($i = 0; $i <= 100; $i++) {
    $countList[$i] = 0;
}

for ($i = 0; $i <= 100; $i++) {
    $line = trim(fgets(STDIN));
    if ($line != ""){
        $countList[(int)$line]++;
    }
}

$maxNum = max($countList);
foreach ($countList as $num => $count) {
    if ($maxNum == $count){
        echo $num.PHP_EOL;
    }
}


Measured memory_bytes: 9276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		long x = Long.parseLong(tmpArray[0]);
		long y = Long.parseLong(tmpArray[1]);
		
		if(x == y){
			System.out.println(1);
			return;
		}
		
		long result = 0;
		
		while(true){
			x *= 2;
			result ++;
			
			if(x > y){
				break;
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,i;
  cin>>n>>m;
  long int sum=0;
  int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  double limit=(double)sum/(4*m);
  int count=0;
  for(i=0;i<n;i++)
  {
    if(a[i]>=limit)
    {
      count++;
    }
  }
  if(count>=m)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int i,N,total=0,maxdayo,mindayo,box[1000];
  while(1){
  cin>>N;
  if(N==0) break;
  else{
  for(i=0;i<N;i++){
    cin>>box[i];
  }
  maxdayo=0;
  mindayo=1000;
  for(i=0;i<N;i++){
    total+=box[i];
    maxdayo=max(box[i],maxdayo);
    mindayo=min(box[i],mindayo);
  }
  total=total-maxdayo-mindayo;
  cout<<total/(N-2)<<endl;
  }
  total=0;
  }
  return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {

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

		if(a == 1){
			a = 14;
		}
		if(b == 1){
			b = 14;
		}

		System.out.println(a > b ? "Alice":
			a < b ? "Bob" : "Draw");
	}
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
    string s;cin>>s;
    string ans ="";
    fore(i,0,s.length()){
        char cur = s[i];
        if(cur=='0')ans+='0';
        else if(cur=='1')ans+='1';
        else{
            if(ans.length()!=0){
                ans.erase(ans.begin()+ans.length()-1);
            }
        }
    }cout<<ans<<"\n";
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

#define INF 2000000000
#define MAX_V 10

const ll MAX = 510000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}

struct Info{
    Info(ll arg_to,ll arg_cost){
        to = arg_to;
        cost = arg_cost;
    }
    bool operator<(const struct Info &arg) const{
            return cost > arg.cost;
    };
    ll to,cost;
};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double n,k,sum=0;
    cin>>n>>k;
    
    rrep(i,n){
        if(i>=k) sum+=1.0;
        else{
            double a=1,b=1;
            while(a<k/i){
                a*=2;
                b*=0.5;
            }
            sum+=b;
        }
    }
    cout<<fixed<<setprecision(10)<<sum/n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

double calcS(double a,double b,double c){
  double s=(a+b+c)/2.0;
  return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main(){

  int a,l,x;
  while(cin>>a>>l>>x){
    double res=calcS(a,l,l)+calcS(l,(l+x)/2.0,(l+x)/2.0)*2;
    printf("%.10f\n",res);
  }
  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    double a, b, C;
    cin >> a >> b >> C;
    
    double PI = acos(-1);
    double radC = C * PI / 180;
    double c = sqrt(pow(a, 2) + pow(b, 2) - (double) 2 * a * b * cos(radC)) ;
  
    double S = ((double) 1 / (double) 2) * a * b * sin(radC); 
    double L = a + b + c;
    double h = b * sin(radC);

    printf("%1f\n", S);
    printf("%1f\n", L);
    printf("%1f\n", h);

    return 0;
}


Measured memory_bytes: 3484
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
// constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,M;
  cin >> N >> M;
  map<int,int> two;
  map<int,int> rem;
  set<int> ex;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    if(ex.count(a)){
      ex.erase(a);
      two[a%M]++;
    }else{
      ex.emplace(a);
    }
    rem[a%M]++;
  }
  int ans = 0;
  for(auto m: rem){
    if(m.first == 0 || (M%2==0 && m.first == M/2)){
      // cout << m.first << " " << m.second/2 << "\n";
      ans += m.second/2;
      rem[m.first] = 0;
    }else{
      int mn = min(m.second,rem[M-m.first]);
      ans += mn;
      rem[m.first] -= mn;
      rem[M-m.first] -= mn;
    }
  }
  for(auto m: two){
    // cout << m.first << " ";
    // cout << m.second << " " << rem[m.first] << "\n";
    ans += min(m.second,rem[m.first]/2);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 12996
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int n, k;
  cin >> n >> k;
  int count[n + 1];
  fill(count, count + n + 1, 0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    count[a]++;
  }
  sort(count, count + n + 1);
  int ans = 0;
  for (int i = n - k; i >= 0; i--) {
    ans += count[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
"""
nCk := f[n] * g[n - k] * g[k](mod)
"""
def pre_c(n, mod):
    f = [0] * (n + 1)
    g = [0] * (n + 1)
    for i in range(n + 1):
        if i == 0:
            f[i] = 1
            g[i] = 1
        else:
            f[i] = (f[i - 1] * i) % mod
            g[i] = pow(f[i], mod - 2, mod)

    return f, g

n, m = map(int,input().split())
mod = 10 ** 9 + 7
f, g = pre_c(m, mod)
res = 0
for i in range(n + 1):
    C = f[n] * g[i] * g[n - i]
    P1 = f[m] * g[m - i]
    P2 = f[m - i] * g[m - n]
    temp = C * P1 * (P2 ** 2) * pow(-1, i)
    res = (res + temp%mod) %mod
print(res%mod)

Measured memory_bytes: 97128
#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;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N;
vector<ll> a;
ll dp[3010][3010];
bool f[3010][3010] = {false};

// turnが0なら先手、1なら後手
ll dfs(int l, int r, int turn) {
    if(f[l][r]) {
        return dp[l][r];
    }
    f[l][r] = true;
    if(l + 1 >= r) {
        return dp[l][r] = (turn ? -1 : 1) * a[l];
    }
    if(turn) {
        return dp[l][r] = min(dfs(l + 1, r, 1 - turn) - a[l],
                              dfs(l, r - 1, 1 - turn) - a[r - 1]);
    } else {
        return dp[l][r] = max(dfs(l + 1, r, 1 - turn) + a[l],
                              dfs(l, r - 1, 1 - turn) + a[r - 1]);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    a.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    cout << dfs(0, N, 0) << endl;
}

Measured memory_bytes: 58876
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
map<int,int> m;
vector<int> v;
int main() {
	int n,ans;
	cin>>n;
	for(register int i=1; i<=n; ++i) {
		int x;
		cin>>x;
		if(m[x]==0) v.push_back(x);
		++m[x];
	}
	for(register int i=0; i<v.size(); ++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i];
		else ans+=m[v[i]];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
import java.util.*;
public class Main{
  
 public static void main(String[] args){
  
   Scanner sc = new Scanner(System.in);
   
     /*K倍*/
     int k = sc.nextInt();
     int a = sc.nextInt();
     int b= sc.nextInt();
   
   int seisu;
   int count = 0;
   for(int i=a;i<=b;i++){
     
     if(i%k == 0){ 
       seisu = i/k;
      
         count++;    
         break;
       
     }
   }
     
   if(count>0){
     System.out.println("OK");
   }else{
      System.out.println("NG");     
    }
 }
 }
   

Measured memory_bytes: 35828
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main()
{
	cin >> a >> b;
	while(--a)
	{
		cin >> c;
		if(c>b)
		{
			e=max(e,d);
			d=0;
		}
		else
	        ++d;
	    b=c;
	}
	cout << max(e,d) << endl;
}

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

struct LowLink {
  int n, pos;
  vector<int> ord, low, par, blg;  
  vector<vector<int> > G, C, T;

  vector<int> ap;
  vector<pair<int, int> > bs;

  LowLink(int n) : n(n), pos(0), ord(n, -1), low(n), par(n, -1), blg(n, -1), G(n) {}  

  void add_edge(int u, int v) {
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  bool is_bridge(int u, int v) {
    if ( ord[u] > ord[v] ) swap(u, v);
    return ord[u] < low[v];    
  }

  void dfs(int v) {
    ord[v] = low[v] = pos++;
    for ( int u : G[v] ) {
      if ( u == par[v] ) continue;
      if ( ~ord[u] ) {
	low[v] = min(low[v], ord[u]);
	continue;
      }
      par[u] = v;
      dfs(u);
      low[v] = min(low[v], low[u]);
      if ( is_bridge(u, v) ) bs.emplace_back(u, v);      
    }
  }

  void fill_component(int v) {
    C[blg[v]].emplace_back(v);
    for ( int u : G[v] ) {
      if ( ~blg[u] ) continue;
      blg[u] = blg[v];
      fill_component(u);      
    }
  }

  void add_component(int v, int &k) {
    if ( ~blg[v] ) return;
    blg[v] = k++;
    C.emplace_back();
    fill_component(v);    
  }

  void build() {
    for ( int i = 0; i < n; i++ ) {
      if ( ord[i] < 0 ) dfs(i);
    } 
  }  
};

struct Edge {
  int u, v, c;
  Edge() {}
  Edge(int u, int v, int c) :
    u(u), v(v), c(c) {}
  bool operator < (const Edge& e) const {
    return c < e.c;    
  }
};

struct UnionFind {
  int n;
  vector<int> r, p;
  UnionFind() {}
  UnionFind(int sz) : n(sz), r(sz, 1), p(sz, 0) {
    iota(p.begin(), p.end(), 0);    
  }
  int find(int x) {
    return (x==p[x] ? x : p[x]=find(p[x]));    
  }
  bool same(int x, int y) {
    return find(x) == find(y);    
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if ( x == y ) return;
    if ( r[x] < r[y] ) swap(x, y);
    r[x] += r[y];
    p[y] = x;    
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<Edge> es(M);  
  for ( int i = 0; i < M; i++ ) {
    int u, v, c;
    cin >> u >> v >> c;
    u--; v--;
    es[i] = Edge{u, v, c};    
  }

  sort(es.begin(), es.end());  

  vector<int> use;
  int cost = 0;
  {
    UnionFind uf(N);
    int cnt = 0;
    for ( int i = 0; i < M; i++ ) {
      int u = es[i].u, v = es[i].v, c = es[i].c;
      if ( uf.same(u, v) ) continue;
      cost += c;
      uf.unite(u, v);
      use.emplace_back(i);
      cnt++;
      if ( cnt == N-1 ) continue;    
    }
  }

  int ans = 0, anscost = 0;  
  for ( int i = 0; i < N-1; i++ ) {
    UnionFind uf(N);
    int ncost = 0;
    int ncnt = 0;    
    for ( int j = 0; j < M; j++ ) {
      if ( use[i] == j ) continue;
      int u = es[j].u, v = es[j].v, c = es[j].c;
      if ( uf.same(u, v) ) continue;
      ncost += c;
      uf.unite(u, v);
      ncnt++;
      if ( ncnt == N-1 ) continue;      
    }

    if ( ncost > cost || ncnt < N-1 ) {
      ans++;
      anscost += es[use[i]].c;      
    }
  }

  cout << ans << " " << anscost << endl;
  
  return 0;
}



Measured memory_bytes: 3360
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
// #define MOD 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const ll B = 20, N = 300010, M = 2000000;
ll x, k, d, res = MAX;
int solve()
{
    cin >> x >> k >> d;
    if (x > 0)
    {
        ll high = k, low = 1, p, ans = 0;
        while (high >= low)
        {
            p = (high + low) / 2;
            // out(p)
            // out(x -  p * d )
            if (x/p >=  d)
            {
                ans = p;
                low = p + 1;
            }
            else 
                high = p - 1;
        }
        ll kk = k-ans;
        if (kk % 2)
        {
            res = min(x - (ans - 1) * d , x - (ans + 1) * d);
        }
        else res = x - ans * d ;
    }
    else
    {
        ll high = k, low = 1, p, ans = 0;
        while (high >= low)
        {
            p = (high + low) / 2;
            if (x/p<=(-d))
            {
                ans = p;
                low = p + 1;
            }
            else 
                high = p - 1;
        }
        ll kk = k-ans;
        if (kk % 2)
        {
            res = max(x + (ans - 1) * d , x + (ans + 1) * d);
        }
        else res = x + ans * d;
    }
    printf("%lld\n", abs(res));
    return 0;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    return solve();
}

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

using namespace std;
int k;
char a[100005];
int re;

int cal(char x)
{
    if(x=='a') return 0;
    return 'z'-x+1;
}

int main()
{
    cin>>a;
    int len=strlen(a);
    cin>>k;
    for(int i=0;i<len;i++)
    {  //cout<<cal(a[i])<<endl;

       if(k>=cal(a[i]))
       {
           k-=cal(a[i]);
           a[i]='a';

           //cout<<k<<endl;
       }
    }
    k%=26;
    while(k--)
    {
        a[len-1]+=1;
        if (a[len-1]==('z'+1))
            a[len-1]='a';
    }

    cout<<a<<endl;

    return 0;
}


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

using namespace std;

int main(){
    long long int n,x,y,min = 1000000000001;
    cin >> n;

    for(int i = 1;i <= (int)sqrt(n);i++){
        if(n % i == 0){
            if(min > i+(n/i)-2)
                min = i+(n/i)-2;
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<climits>
using namespace std;
  int n;

int m[101][101];
  int p[101];
void chain(){
  int n1;
  int j;
  int q;
  n1=n;
  //ok
  // cout <<"n1 "<<n1<<endl;
  for(int i=1;i<=n1;i++){
    m[i][i]=0;
  }
  for(int l=2;l<=n1;l++){
    for(int i=1;i<=n1-l+1;i++){
      j=i+l-1;
      m[i][j] = INT_MAX;
      for(int k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	//	cout<<"q "<<q<<endl;
	if(q<m[i][j]){
	  m[i][j]=q;
	  //	  cout<<s[i][j]<<endl;
	}
      }
    }
  }
}

int main(){

  int A[101][2];
  cin>>n;
  int i;
  for(i=0;i<n;i++){
    cin>>A[i][0]>>A[i][1];
    p[i]=A[i][0];
  }
  p[i]=A[i-1][1];

  //ok
  /*
 for(int i=0;i<=n;i++){
   cout<<"p "<<p[i]<<endl;
 }
  */
  chain();
  /*  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<m[i][j]<<endl;
    }
   }
*/
  cout<<m[1][n]<<endl;

  return 0;
}

Measured memory_bytes: 1200
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func solve() {
	n := getInt()
	as := getIntSlice(n)

	xs := make([]int, n)
	for i, a := range as {
		xs[i] = a - i + 1
	}
	sort.Ints(xs)

	b := xs[n/2]
	ans := 0
	for _, x := range xs {
		ans += abs(x - b)
	}
	fmt.Fprintln(wr, ans)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 6784
#include <iostream>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int k,s;	cin >> k >> s;
    int ans = 0;
    for(int x = 0; x <= k; x++){
	for(int y = 0; y <= k; y++){
	    int z = s - (x + y);
	    if(z >= 0 && z <= k)  ans++;
	}
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
s =  int(input()) # 整数
A = []
# print(s)
# print(A)

an = s
n=1
while(True):
    A.append(an)
    if an%2==0:
        # print(A)
        an=int(an/2)
    else:
        an=an*3+1
    n+=1

    if an in A:
        break

print(n)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define mii         map<pii, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
int mult(int a,int b, int p=MOD){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p=MOD){return (a + b + p)%p;}
int fpow(int n, int k, int p = MOD) {int r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve(){
    int n, k;
    cin>>n>>k;
    int a[n];
    rep(i, 0, n) {
        cin>>a[i];
    }
    sort(a, a + n);
    int ans = hell;
    rep(i, k-1, n) {
        ans = min(ans, a[i] - a[i-k+1]);
    }
    cout<<ans<<endl;

}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 4012
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N; cin >> N;
    int t[N], v[N]; REP(i,N) cin >> t[i]; REP(i,N) cin >> v[i];
    int T = 0; REP(i,N) T += t[i];
    vector<double> maxv; maxv.push_back(0);
    REP(i,N){
        maxv.back() = min(maxv.back(), (double)v[i]);
        REP(j,2*t[i]){
            maxv.push_back(v[i]);
        }
    }
    maxv.back() = 0;
    
    FOR(i,1,2*T+1){
        maxv[i] = min(maxv[i], maxv[i-1]+0.5);
    }
    for(int i=2*T-1; i>=0; i--){
        maxv[i] = min(maxv[i], maxv[i+1]+0.5);
    }
    double ans = 0;
    FOR(i,1,2*T+1){
        ans += (maxv[i-1]+maxv[i])/4;
    }
    cout << fixed;
    cout << setprecision(5) << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
 
using namespace std;

struct S
{
    ll x, y, h;
    bool operator<(const S &another) const
    {
        return h < another.h; 
    }
    bool operator>(const S &another) const
    {
        return h > another.h;
    }
};
 
int main()
{
    int n;
    cin >> n;
    vector<S> v(n);
    rep(i, n){
        cin >> v[i].x >> v[i].y >> v[i].h;
    }
    sort(all(v));
    reverse(all(v));

    ll cx, cy, ch;
    for(ll x=0; x<=100; x++){
        for(ll y=0; y<=100; y++){
            ll H;
            ll flag = 1;
            rep(i, n){
                if(i==0){
                    H = abs(x-v[i].x)+abs(y-v[i].y) + v[i].h;
                }else{
                    if(H-abs(x-v[i].x)-abs(y-v[i].y)>0){
                        if(H-abs(x-v[i].x)-abs(y-v[i].y) == v[i].h) flag++;
                    }else if(v[i].h==0) flag++;
                }
            }
            if(flag == n){
                cx = x;
                cy = y;
                ch = H;
                break;
            }
        }
    }
    cout << cx << " " << cy << " " << ch << endl;

    
}

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

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

using namespace std;
using lint = long long;

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N, vector<int>(N, 0));
    vector<vector<int>> y(N, vector<int>(N, 0));

    rep(i, N){
        cin >> A[i];
        rep(j, A[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }    

    lint bin = 1;
    rep(i, N) bin *= 2;

    int max = 0;
    for(int i = 0; i < bin; i++){
        //cout << "ok" << endl;
        int num = 0;
        int mask = 1;
        bool isOK = true;
        vector<int> person(N, 0);
        for(int k = 0; k < N; k++){
            if((mask & i) == mask){
                num++;
                person[k] = 1;
            }
            mask = mask << 1;
        }
        mask = 1;
        for(int k = 0; k < N; k++){
            if((mask & i) == mask){
                for(int j = 0; j < A[k]; j++){
                    if(person[x[k][j]] != y[k][j]){
                        isOK = false;
                        //cout << i << " " << k << " " << j << " " << person[x[k][j]] << endl;
                    }
                }
            }
             mask = mask << 1;
        }
        if(isOK && max < num){
            max = num;
            //cout << i << " " << num << endl;
        }
        

    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

fn power_set(n: usize) -> Vec<Vec<usize>> {
    return (1..(1 << n))
        .map(|i| (0..n).filter(|j| i & (1 << j) > 0).collect())
        .collect();
}

#[fastout]
fn main() {
    input! {
        n: usize, m: usize, x: usize,
        mut ca: [(usize, [usize; m]); n]
    }
    let mut ans:isize = -1;

    ca.sort();

    let power_set = power_set(n);
    let mut ca_power_set = Vec::new();
    for i in 0..power_set.len() {
        let mut sum = 0;
        for j in 0..power_set[i].len() {
            sum += ca[power_set[i][j]].0;
        }
        ca_power_set.push((sum, power_set[i].clone()));
    }
    ca_power_set.sort();

    for i in 0..ca_power_set.len() {
        let mut dp = vec![0; m];
        for j in 0..ca_power_set[i].1.len() {
            for l in 0..m {
                dp[l] += ca[ca_power_set[i].1[j]].1[l];
            }
        }
        if dp.iter().filter(|&&d| d < x).count() == 0 {
            ans = ca_power_set[i].0 as isize;
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2912
from itertools import accumulate
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    INF = 10**10

    N = int(input())
    As = list(map(int, input().split())) + [INF]
    Bs = list(map(int, input().split())) + [INF]

    def f(As):
        sts = [-1] * (N+1)
        ens = [-1] * (N+1)
        i = 0
        for v in range(1, N+1):
            if As[i] == v:
                sts[v] = i
            else:
                continue
            while As[i] == v:
                i += 1
            ens[v] = i-1
        return (sts, ens)

    stAs, enAs = f(As)
    stBs, enBs = f(Bs)

    imoss = [0] * (2*N+1)
    for v in range(1, N+1):
        if stAs[v] == -1 or stBs[v] == -1: continue
        L = stAs[v] - enBs[v] + N
        R = enAs[v] - stBs[v] + N
        imoss[L] += 1
        imoss[R+1] -= 1

    imoss = list(accumulate(imoss))

    Cs = [imoss[i] + imoss[i+N] for i in range(N)]

    numShift = -1
    for i in range(N):
        if Cs[i] == 0:
            numShift = i
            break

    if numShift == -1:
        print('No')
    else:
        print('Yes')
        anss = [Bs[(i-numShift)%N] for i in range(N)]
        print(' '.join(map(str, anss)))


solve()


Measured memory_bytes: 79328
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string.h>
#include <sstream>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(ll i = 0;i < n;i++)
#define rep1(i,n) for(ll i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<ll>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){

	char c;
	cin >> c;
	cout << ++c << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


//3
int gcd(int a,int b){return b?gcd(b,a%b):a;}


vector<pair<int,int>> fai;

map<pair<int,int> , int> cou;

pair<int,int> f(int n){



int b=n%10;
int a=n;
int res=0;
while(a>=10){
res=a;
a/=10;
}
if(n<10)res=n*10;
return make_pair(res/10,b);
}

int main(){

ios::sync_with_stdio(false);
cin.tie(0);
long long int n;
cin>>n;

for(int i=1;i<=n;i++){
pair<int,int> tem=f(i);
//cout <<tem.first<<" "<<tem.second<<endl;
cou[tem]++;
}
long long int re=0;
for(int i=1;i<=n;i++){
pair<int,int> tem=f(i);
pair<int,int> te=make_pair(tem.second,tem.first);

re+=cou[te];
}


cout<<re<<endl;
}



//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



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

typedef long long ll;
ll MOD = 1e9+7;

int main()
{
	int a,b,t;
	int ans=0;
	cin>>a>>b>>t;
	for(int i=1;i<=t;i++)
	{
		if(i%a==0)
			ans+=b;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region UnionFind
struct UnionFind
{
    vector<int> d;
    // d[x] is the index of the parent of x
    // d[x] is -size if x is a root

    UnionFind(int n) : d(vector<int>(n, -1)) {}
    int root(int x)
    {
        if (d[x] < 0)
        {
            return x;
        }
        return d[x] = root(d[x]);
    }

    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
        {
            return false;
        }
        if (d[x] > d[y])
            swap(x, y); // x always bigger tree

        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x) { return -d[root(x)]; }
};
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind uft(n);
    rep(i, m)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        uft.unite(x, y);
    }

    int ans = n;
    rep(i, n)
    {
        if (uft.root(i) == i)
        {
            ans -= uft.size(i) - 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin>>N;
    if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)
    {
        cout<<"hon";
    }
    if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
    {
        cout<<"pon";
    }
    if(N % 10 == 3)
    {
        cout<<"bon";
    }
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

typedef pair<int, int> P;

const int MOD = (int) 1e9 + 7;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	
	int cnt = 0;
	REP(i, n) {
		while (a[i] % 2 == 0) {
			cnt++;
			a[i] /= 2;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

int main() {
    ll N; cin >> N;
    vector<ll> A(N); for (ll i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end(), greater<>());
    ll ans = 0;
    ll j = 0, k = 0;
    for (int i = 0; i < N; ++i) {
        // cout << i << " " << A[j] << " " << j << " " << k << endl;
        if (i == 0) continue;
        if (i == 1) {
            ans += A[j];
            ++j;
            continue;
        }
        if (k == 2) {
            ++j;
            k = 0;
        }
        ans += A[j];
        ++k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4828
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
x, u = [''] * N, [''] * N
ans = 0.0

for i in range(N):
	x[i], u[i] = input().split()
	x[i] = float(x[i])
	if u[i] == 'JPY':
		ans += x[i]
	else:
		ans += x[i] * 380000.0
	
print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, c, k;
    cin >> n >> c >> k;
    VI tt(n);
    REP(i,n) scanf("%d", &tt[i]);
    sort(ALL(tt));
    int lim, s = 0, ans = 0;
    REP(i,n){
        int t = tt[i];
        if (i == 0 || s == c || t > lim){
            ans++;
            s = 1;
            lim = t + k;
        }else{
            s++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    ll s;
    cin >> s;
    ll x[3] = {}, y[3] = {};
    x[1] = 1e9;
    y[1] = 1;
    y[2] = (s - 1) / (x[1]) + 1;
    x[2] = -s + x[1] * y[2];

    cout << x[0] << " " << y[0] << " " << x[1] << " "  << y[1] << " " << x[2] << " " << y[2] << endl;
}
/*
g++ -std=c++14 agc036/a.cpp
 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repri(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;
typedef vector<int> VI;
typedef vector<ll> VL;

void Main() {
	string s;
	cin >> s;
	int n[3] = {};
	rep(i,s.size()) {
		if (s[i]=='a') n[0]++;
		else if (s[i]=='b') n[1]++;
		else if (s[i]=='c') n[2]++;
	}
	sort(n,n+3);
	if (n[2]-n[1]>1 || n[1]-n[0]>1 || n[2]-n[0]>1) cout << "NO\n";
	else cout << "YES\n";

	return;
}

int main(){
	FAST;
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            arr.add(a);
        }
        Collections.sort(arr);
        System.out.println(arr.get(n-1)-arr.get(0));

    }
}

Measured memory_bytes: 35932
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

template<typename T> class SQRTdecomposition{
public:
    vector<T> data, backet;
    int sz,backet_size,backet_cnt;
    SQRTdecomposition(vector<T>& v) : data(v){
        sz = (int)data.size();
        backet_size = (int)sqrt(sz);
        backet_cnt = (sz + backet_size - 1) / backet_size;
        backet.resize(backet_cnt);
        rep(i,sz){
            backet[i / backet_size] += data[i];   //例えば和を持たせる処理
        }
    }
    void update(int l, int k){
        data[l] += k;
        backet[l / backet_size] += k;
    }
    T query(int l, int r){    //[l.r)
        T res = 0;
        // 同じバケット内にある
        if(l / backet_size == (r-1) / backet_size){
            for(int i = l; i < r; i++){
                res += data[i];
            }
        }else{
            // 完全に被っているバケット
            for(int i = (l + backet_size - 1) / backet_size; i < r / backet_size; i++){
                res += backet[i];
            }
            // 中途半端な左側のバケット
            if(l % backet_size){
                for(int i = l; i < backet_size*(l / backet_size + 1); i++){
                    res += data[i];
                }
            }
            // 中途半端な右側のバケット
            if(r % backet_size){
                for(int i = r - r % backet_size; i < r; i++){
                    res += data[i];
                }
            }
        }
        return res;
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    vi a(n,0);
    SQRTdecomposition<int> sr(a);
    rep(i,q){
        int a,b,c;
        cin >> a >> b >> c;
        if(a == 0){
            sr.update(b-1,c);
        }else{
            cout << sr.query(b-1,c) << "\n";
        }
    }
    return 0;
}



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

using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN/2;

const double PI = 3.14159265358979311;
int32_t main() {
	FAST_IO;
	
	int n, m;
	cin >> n >> m;
	
	int a[m];
	for(int& x: a) cin >> x;
	
	int sum = 0;
	for (int x: a) sum += x;
	
	if (sum > n) cout << -1 << endl;
	else cout << n-sum << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3728