akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    int k, s;
    cin >> k >> s;
    int cnt = 0;
    rep(a, k + 1) rep(b, k + 1) {
        int c = s - a - b;
        cnt += 0 <= c && c <= k;
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int s,w;
    cin >> s >> w;
    if(s>w){
        cout << "safe" ENDL;
    }else cout << "unsafe" ENDL;
    
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vll a(n);rep(i,n)cin>>a[i];
    sort(all(a));
    ll ans=1;bool tmp=true;
    if(a[0]==0)ans=0;
    else{
        rep(i,n){
            if(a[i]>INF/ans){
                ans=-1;
                break;
            }
            if(tmp)ans*=a[i];
            if(ans>INF){
                tmp=false;
                ans=-1;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<string>
#include<time.h>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;


std::vector<ull> prime;

void initprime(ull MAX) {
    std::vector<bool> is_prime(MAX + 1);
    for (int i = 0; i <= MAX; ++i) is_prime[i] = true;
    for (int i = 2; i <= MAX; ++i) {
        if (is_prime[i]) {
            int loop = (MAX / i);
            for (int j = 2; j <= loop; ++j) {
                is_prime[i * j] = false;
            }
            prime.emplace_back(i);
        }
    }
}

//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == (T)0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
ll gcd2(ll x, ll y) { return y ? gcd2(y, x % y) : x; }
//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

ull p_cnt(ull g) {
    if (g == 1) return 1;
    ull rootg = floor(sqrt((double)g));
    ull p_cnt = 1;
    for (int i = 0; i < prime.size(); ++i) {
        if (g % prime[i] == 0) {
            ++p_cnt;
        }
    }
    if (p_cnt == 1) ++p_cnt;
    return p_cnt;
}

int main() {
    initprime(1000000);
    ull a, b;
    cin >> a >> b;
    ull g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    int pc = p_cnt(g);
    if (pc == ans) {
        cout << pc << endl;
    }
    else {
        int shi = 1;
        if (((pc >> shi) & 1) == 1) {
            cout << ans << endl;
        }
        else {
            cout << pc << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1528
#include<iostream>
using namespace std;
bool is_sosu(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}

int main(){
	int a,d,n;
	while(cin>>a>>d>>n,a+d+n!=0){
		int cnt=0,now=a;
		while(true){
			
			if(is_sosu(now))cnt++;
			if(cnt==n)break;
			now+=d;
		}
		cout<<now<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 1160
let (p1, p2, p3) = (257, 251, 1000000007)

let pow x n =
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (acc*x mod p3) in
  doit 0 1

let solve a (h, w) b (r, c) =
  let make_hash v (y, x) =
    let h1 = Array.make_matrix y x 0 in
    let c1 = pow p1 c in
    let rec duduwa i =
      if i < y then begin
        let rec calc_z j acc =
          if j = c then acc
          else calc_z (j + 1) ((acc*p1 + Char.code v.(i).(j)) mod p3) in
        let rec aux j z =
          if j = x - c then h1.(i).(j) <- z
          else begin
            h1.(i).(j) <- z;
            let new_z = (z*p1 - (Char.code v.(i).(j))*c1 + Char.code v.(i).(j+c)) mod p3 in
            aux (j + 1) (if new_z < 0 then new_z + p3 else new_z)
          end in
        aux 0 (calc_z 0 0);
        duduwa (i + 1)
      end in
    duduwa 0;
    let h2 = Array.make_matrix y x 0 in
    let c2 = pow p2 r in
    let rec doit j =
      if j < x then begin
        let rec calc_z i acc =
          if i = r then acc
          else calc_z (i + 1) ((acc*p2 + h1.(i).(j)) mod p3) in
        let rec aux i z =
          if i = y - r then h2.(i).(j) <- z
          else begin
            h2.(i).(j) <- z;
            let new_z = (z*p2 - h1.(i).(j)*c2 + h1.(i+r).(j)) mod p3 in
            aux (i + 1) (if new_z < 0 then new_z + p3 else new_z)
          end in
        aux 0 (calc_z 0 0);
        doit (j + 1)
      end in
    doit 0;
    h2 in
  let s = make_hash a (h, w) in
  let t = make_hash b (r, c) in
  let rec doit = function
    | (i, _) when i > h - r -> ()
    | (i, j) when j > w - c -> doit (i + 1, 0)
    | (i, j) ->
      if s.(i).(j) = t.(0).(0) then Printf.printf "%d %d\n" i j;
      doit (i, j + 1) in
  doit (0, 0)

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let str_to_list str =
  let rec doit i acc =
    if i < 0 then acc
    else doit (i - 1) (String.get str i :: acc) in
  doit (String.length str - 1) []

let input_array y x =
  let a = Array.make_matrix y x '\000' in
  let rec doit i =
    if i = y then a
    else begin
      let rec aux j = function
        | [] -> ()
        | c :: cs -> a.(i).(j) <- c; aux (j + 1) cs in
      aux 0 (str_to_list (read_line ()));
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [h; w] ->
    begin
      let a = input_array h w in
      match List.map int_of_string (split (read_line ()) ' ') with
      | [r; c] when h < r || w < c -> exit 0
      | [r; c] ->
        let b = input_array r c in
        solve a (h, w) b (r, c)
      | _ -> exit 1
    end
  | _ -> exit 1

Measured memory_bytes: 46304
#include<stdio.h>
#define N 1001
static const int INFTY = (1<<21);

int n, M[N][N];
int color[N], d[N], f[N], tt;
int Q[N*2], head, tail;

void init(){
  head = tail = 1;
}

void enqueue(int x){
  Q[tail++] = x;
}

int empty(){
  return head == tail;
}

int dequeue(){
  int x = Q[head++];
  return x;
}

void bfs(int s){
  int i, u, v;
  init();
  enqueue(s);
  for ( i = 0; i < n; i++ )d[i] = INFTY;
  d[s] = 0;
  while(!empty()){
    u = dequeue();
    for ( v = 0; v < n; v++ ){
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i+1,((d[i]==INFTY)?(-1):d[i]));
  }
}

main(){
  int  u, k, v, i, j,a=0,b; 
  b=kansu(a);
  if(b == 0){
  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  bfs(0);

  return 0;
}}
int kansu(int a){
 int b=0,c=1;
 if(b == 0);
  if(c == 1);
   return a;
}


Measured memory_bytes: 2144
#include <cstdio>

int main() {
  int n;
  scanf("%d", &n);
  n %= 10;
  switch(n) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon\n");
      break;
    case 3:
      printf("bon\n");
      break;
    default:
      printf("pon\n");
  }
}

Measured memory_bytes: 1660
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int m, k; cin >> m >> k;
	if (k >= (1 << m)) cout << -1;
	else {
		if (m == 0) cout << "0 0";
		else if (m == 1) {
			if (k == 0) cout << "0 0 1 1";
			else cout << -1;
		}
		else {
			for (int i = 0; i <= ((1 << m) - 1); i++) if (i != k) cout << i << " ";
			cout << k << " ";
			for (int i = ((1 << m) - 1); i >= 0; i--) if (i != k) cout << i << " ";
			cout << k << " ";
		}
	}

	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(false);cin.tie(NULL);
const int N=2e3+5;
int a[N];
int main()
{
    ft
    int i,j,n,k,c=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=n-1;i>0;i--)
    {
        k=i-1;
        for(j=0;j<k; )
        {
            if(a[j]+a[k]>a[i])
            {
                c+=(k-j);
                k--;
            }
            else
            {
                j++;
            }
        }
    }
    cout<<c<<"\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std ;
using namespace  __gnu_pbds ;
using namespace __gnu_cxx ;

typedef long long ll ;
typedef long double ld ;

typedef pair<int, int> pii ;
typedef pair<ll,ll> pll ;

typedef vector<int> vi ;
typedef vector<ll> vll ;
typedef vector<pii> vpi ;
typedef vector<pll> vpl ;
typedef vector<vi> vvi ;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define fi first
#define se second

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD1 = 1000000007 ;
const int MOD2 = 998244353 ;
const ll INFL = 1e18 ;
const int INFI = 2e9 ;
const int MAXN = 205 ;
const int LOGN = 22 ;
const int MAXM = (1 << LOGN) ;
const int ALPHA = 30 ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

ll modpow(ll a, ll b, int MOD) {
    ll res = 1 ;
    while(b) {
        if(b&1) {
            res = res*a ;
            res %= MOD ;
        }
        a *= a ;
        a %= MOD ;
        b >>= 1 ;
    }
    return res%MOD ;
}
void upmin(int &a, int b) {
    if(a < b) {
        a = b ;
    }
}
void relax(int &a, int b) {
    if(a > b) {
        a = b ;
    }
}
ll add(ll a, ll b, int MOD) {
    a += b ;
    if(a >= MOD) {
        a -= MOD ;
    }
    return  a ;
}
ll subtract(ll a, ll b, int MOD) {
    a -= b ;
    if(a < 0) {
        a += MOD ;
    }
    return a ;
}
ll multiply(ll a, ll b, int MOD) {
    a *= b ;
    a %= MOD ;
    return a ;
}
int n ;
int graf[MAXN][MAXN] ;
int main() {
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> n ;
    rep(i,0,n-1) {
        rep(j,0,n-1) {
           char c ;
           cin >> c ;
           graf[i][j] = int(c- '0') ;
        }
    }
    int res = 0 ;
    rep(i,0,n-1) {
       int pres = 0 ;
       int b[n][n] ;
       int vis[n] ;
       bool judge = true ;
       rep(j,0,n-1) {
          vis[j] = 0 ;
       }
       rep(j,0,n-1) {
          rep(k,0,n-1) {
             b[j][k] = graf[j][k] ;
          }
       }
       queue<pair<int, int> > q ;
       q.push({i, 1}) ;
       vis[i] = 1 ;
       while(!q.empty()) {
          int v = q.front().fi ;
          int plevel = q.front().se ;
          pres = max(pres, plevel) ;
          q.pop() ;
          rep(j,0,n-1) {
              if(b[v][j] == 1) {
                  if(!(vis[j] == 0 || vis[j] == vis[v] + 1)) {
                      judge = false ;
                  }
                  int nlevel = plevel + 1 ;
                  q.push({j,nlevel}) ;
                  b[v][j] = 0 ;
                  b[j][v] = 0 ;
                  vis[j] = nlevel ;
              }
          }
       }
       if(judge) {
         res = max(res, pres) ;
       }
    }
    if(res == 0) {
        cout << "-1\n" ;
        return 0 ;
    }
    cout << res << endl ;
    return 0 ;
}


Measured memory_bytes: 816
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int ret = 0;
    for(int i = 1; i < N; ++i) {
        set<char> cleft;
        set<char> cright;
        int temp = 0;
        for(int j = 0; j < i; ++j) {
            cleft.insert(s[j]);
        }
        for(int j = i; j < N; ++j) {
            if(cleft.count(s[j]) != 0 && cright.count(s[j]) == 0) {
                temp++;
                cright.insert(s[j]);
            }
        }
        ret = max(ret, temp);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;
int cnt[100100];
set<int> si;

int main(){
	cin >> n;
	REP(i, n){
		ll a;
		cin >> a;
		cnt[a]++;
		si.insert(a);
	}
	ll ans = 0;
	REP(i, 100000 + 1){
		if (cnt[i] > 0)ans += cnt[i] - 1;
	}
	if (ans % 2)cout << si.size() - 1 << endl;
	else cout << si.size() << endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, m, a[N];
pii b[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n) cin >> a[i];
  sort(a, a+n);
  FOR(i, 0, m){
    int _b, _c;
    cin >> _b >> _c;
    b[i] = mp(_c, _b);
  }
  sort(b, b+m);
  int c = 0;
  FORR(i, m-1, 0){
    FOR(_, 0, b[i].se){
      maxs(a[c], b[i].fi);
      c++;
      if(c==n) goto here;
    }
  }
here: ;
  ll ans = 0;
  FOR(i, 0, n) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int w,h;
	cin>>w>>h;
	vector<pair<ll, int> > a;
	for (int i=0;i<w;i++){
		ll t;
		cin>>t;
		a.push_back({t, 1});
	}
	for (int i=0;i<h;i++){
		ll t;
		cin>>t;
		a.push_back({t, 2});
	}
	sort(a.begin(), a.end());
	int wu=0;
	int hu=0;
	ll v=0;
	for (int i=0;i<(int)a.size();i++){
		if (a[i].S==1){
			v+=(ll)(h-hu+1)*a[i].F;
		}
		else{
			v+=(ll)(w-wu+1)*a[i].F;
		}
		
		
		if (a[i].S==1) wu++;
		if (a[i].S==2) hu++;
	}
	cout<<v<<endl;
}

Measured memory_bytes: 4464
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0;
    int bound = 0;
    char last = s[0];
    for(int i = 1; i < n; i++){
        if(last == s[i]) ans++;
        else bound++;
        last = s[i];
    }

    cout << ans + min(bound, 2*k) << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static int compute_maxprofit1(int[] R) {
        int max_profit = Integer.MIN_VALUE;
        for (int i = 1; i < R.length; i++)
            for (int j = 1; j < R.length; j++)
                if (R[j] - R[i] > max_profit)
                    max_profit = R[j] - R[i];
        return max_profit;
    }

    public static int compute_maxprofit2(int[] R) {
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < R.length; i++) {
            if (max < R[i] - min)
                max = R[i] - min;
            if (min > R[i])
                min = R[i]; 
        }
        return max;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] R = new int[n];
        for (int i = 0; i < n; i++)
            R[i] = in.nextInt();
        in.close();
        System.out.println(compute_maxprofit2(R));
    }
}



Measured memory_bytes: 98796
#include<bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
V A,B,C,D;
#define pb(v) push_back(v)
long long calu(int N,int M){
    return abs(A.at(N)-C.at(M))+abs(B.at(N)-D.at(M));
}
int main(){
    CIN(N);CIN(M);
    REP(a,N){
        CIN(b);CIN(c);
        A.pb(b);B.pb(c);
    }
    REP(a,M){
        CIN(b);CIN(c);
        C.pb(b);D.pb(c);
    }
    V ans;
    REP(a,N){
        long long K = 10000000000000;
        int w = 0;
        REP(b,M){
            if(K > calu(a,b)){
                K = calu(a,b);
                w = b+1;
            }
        }
        ans.pb(w);
    }
    REP(a,N){
        COUT(ans.at(a));
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    string S, T, U;
    int A, B;

    cin >> S >> T >> A >> B >> U;

    if(U == S) { A--; }
    else { B--; }

    printf("%lld %lld\n", A, B);

    return 0;
}


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

int main(){
	int n,a,b,c,d,comb;
	while(cin>>n){
		comb=0;
		for(a=0;a<10;a++)
			for(b=0;b<10;b++)
				for(c=0;c<10;c++)
					for(d=0;d<10;d++)
						if(a+b+c+d==n)comb++;
		cout<<comb<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>

# define FILE
using namespace std;

const int N = 1e5 + 100;
int n, H[N], ans = 0;

int main()
{
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif // FILE
    ios_base::sync_with_stdio( false );
    cin >> n;
    for( int i = 1; i <= n;  i++ ){
        cin >> H[i];
    }
    int r = n, l = n;
    while( l >= 1 ){
        if( H[l] < H[l+1] )r = l;
        ans = max( ans, r - l );
        l--;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
S=list(input())
T=list(input())
L=[]
if len(S)-len(T)<0:
    print('UNRESTORABLE')
    exit()
for i in range(len(S)-len(T)+1):
    if all(S[i:i+len(T)+1][j]==T[j] or S[i:i+len(T)+1][j]=='?' for j in range(len(T))):
        L.append(''.join((S[0:i]+T+S[i+len(T):])).replace('?','a'))
if L==[]:
    print('UNRESTORABLE')
    exit()
else:
    print(sorted(L)[0])

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, X, Y, x, y):
    mx = max(x)
    my = min(y)

    error_print(mx, my)
    if mx >= my:
        return 'War'

    for i in range(mx+1, my+1):
        if X < i <= Y:
            return 'No War'
    return 'War'


def main():
    N, M, X, Y = read_int_n()
    x = read_int_n()
    y = read_int_n()
    print(slv(N, M, X, Y, x, y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7740
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <ios>
#include <iomanip>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;


void solve() {
    ll n; cin >> n;
    cout << n << ":";
    vi factor;
    int a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            factor.pb(a);
            n /= a;
        } else {
            a++;
        }
    }
    factor.pb(n);

    for(int f:factor){
        cout << " " << f;
    }
    cout << endl;
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    // int q; cin >> q;
	// while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3204
from queue import Queue

n, q = map(int, input().split())
que = Queue()

for i in range(n):
    name, time = input().split()
    que.put((name, int(time)))
 
total = 0

while que.qsize() > 0:
    name, time = que.get()
    total += min(q, time)
    if q < time:
        que.put((name, time-q))
    else:
        print(name, total)


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

typedef long long int ll;

typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision(i) cout << fixed << setprecision(i)

const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;


int main() {

  string s;
  cin >> s;

  ll count = 0;
  ll answer = 0;
  REP(i,s.size()){
    if(s.at(i)=='A'||s.at(i)=='T'||
    s.at(i)=='G'||s.at(i)=='C'){
      count++;
    }else{
      answer = max(answer,count);
      count = 0;
    }
  }

  answer = max(answer,count);

  cout << answer << endl;
}

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

using namespace std;
int dp[1005][1005],t[1005][1005],T,a,m,n,o;
int dq(int x,int y)
{
    if (x==m && y==n)
        return 0;
    if (dp[x][y]!=o)
        return dp[x][y];

    vector<int> v;

    if (x<m)
        v.push_back(dq(x+1,y));
    if (y<n)
        v.push_back(dq(x,y+1)+t[x][y+1]-(t[m][y+1]-t[x][y+1]));

    int h=(x+y)%2,kq;
    if (h==0)
    {
        kq=-o;
        for (int i=0; i<v.size(); ++i)
            kq=max(kq,v[i]);
    }
    else
    {
        kq=o;
        for (int i=0; i<v.size(); ++i)
            kq=min(kq,v[i]);

    }
    return dp[x][y]=kq;

}
int main()
{
   ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for (int i=1; i<=m; ++i)
        for (int j=1; j<=n; ++j)
        {
            cin>>a;
            t[i][j]=t[i-1][j]+a;
            T+=a;
        }
    o=2000000000;
    for (int i=0; i<=m; ++i)
        for (int j=0; j<=n; ++j)
            dp[i][j]=o;
    a=(dq(0,0));
    if (a<0)a=-a;
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 11252
import std.stdio, std.string, std.conv, std.algorithm, std.array;

void main(){
	auto a = readln.split.map!(to!int);
	auto w = a[0];
	auto h = a[1];
	auto x = a[2];
	auto y = a[3];
	auto r = a[4];
	
	if(w>=x+r && 0<=x-r && h>=y+r && 0<=y-r)
		writeln("Yes");
	else
		writeln("No");
}

Measured memory_bytes: 2488
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define mp make_pair
#define MAXN 100005
using namespace std;
template<class T> void read(T &res) { res = 0;T f = 1;char c = getchar(); while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar(); } while(c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); } res *= f; }
template<class T> void out(T x) { if(x < 0){putchar('-');x = -x;} if(x >= 10) out(x / 10); putchar('0' + x % 10); }
int N,D[2]; struct node { int to,next; }E[10000005]; int head[400005],sumE,dx[] = {-1,-1,1,1},dy[] = {1,-1,-1,1}; int col[400005],cr[400005],cnt[5];
int to_int(pii p) { return p.fi * 2 * N + p.se; }
void add(int u,int v) { E[++sumE].to = v; E[sumE].next = head[u]; head[u] = sumE; }
void dfs(int u) { if(col[u] == -1) col[u] = 0; for(int i = head[u] ; i ; i = E[i].next) { int v = E[i].to; if(col[v] == -1) {col[v] = col[u] ^ 1;dfs(v);} } }
int main() {
    read(N);read(D[0]);read(D[1]);
    for(int t = 0 ; t <= 1 ; ++t) {
        memset(head,0,sizeof(head));sumE = 0;
        for(int x = 0 ; x < 2 * N ; ++x) {
            if(D[t] < x * x) break; int y = sqrt(D[t] - x * x); if(y * y != D[t] - x * x) continue;
            for(int i = 0 ; i < 2 * N ; ++i) { for(int j = 0 ; j < 2 * N ; ++j) { for(int k = 0 ; k < 4 ; ++k) { int tx = i + dx[k] * x,ty = j + dy[k] * y; if(tx >= 0 && tx < 2 * N && ty >= 0 && ty < 2 * N) { add(to_int(mp(i,j)),to_int(mp(tx,ty))); } } } }
        }
        memset(col,-1,sizeof(col)); for(int i = 0 ; i < 4 * N * N ; ++i) { if(col[i] == -1) dfs(i); cr[i] = cr[i] << 1 | col[i]; }
    }
    for(int i = 0 ; i < 4 * N * N ; ++i) ++cnt[cr[i]]; int t = 0; for(int i = 1 ; i < 4 ; ++i) { if(cnt[i] > cnt[t]) t = i; }
    int a = N * N; for(int i = 0 ; i < 4 * N * N ; ++i) { if(!a) break; if(cr[i] == t) { out(i / (2 * N));space;out(i % (2 * N));enter; --a; } }
}

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

#define ll long long

using namespace std;

ll x, a, b, c, res, ans, sz;

int main () {
    scanf ("%lld", &x);
    a = 1;
    while (a <= x) {
        ans += a;
        a *= 2;
    }
    printf("%lld", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define Ntw 3
#define N2tw 9

struct Puzzletw{
    int f[N2tw];
    int space;
    string path;

    bool operator < (const Puzzletw &p)const{
        for(int i=0;i<N2tw;i++){
            if(f[i]==p.f[i])continue;
            return f[i]>p.f[i];
        }
        return false;
    }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(Puzzletw p){
    for(int i=0;i<N2tw;i++)
    if(p.f[i] != (i+1))return false;
    return true;
}

string bfs(Puzzletw s){
    queue<Puzzletw> Q;
    map<Puzzletw,bool>V;
    Puzzletw u, v;
    s.path="";
    Q.push(s);
    V[s]=true;

    while(!Q.empty()){
        u=Q.front();Q.pop();
        if(isTarget(u))return u.path;
        int sx = u.space/Ntw;
        int sy = u.space%Ntw;
        for(int r=0;r<4;r++){
            int tx=sx+dx[r];
            int ty=sy+dy[r];
            if(tx<0||ty<0||tx>=Ntw||ty>=Ntw)continue;
            v=u;
            swap(v.f[u.space],v.f[tx*Ntw+ty]);
            v.space=tx*Ntw+ty;
            if(!V[v]){
                V[v]=true;
                v.path+=dir[r];
                Q.push(v);
            }
        }
    }

    return "unsolvable";
}

int main(){
    Puzzletw in;

    for(int i=0;i<N2tw;i++){
        cin >> in.f[i];
        if(in.f[i]==0){
            in.f[i]=N2tw;
            in.space=i;
        }
    }
    string ans = bfs(in);
    cout << ans.size()<<endl;

    return 0;
}



Measured memory_bytes: 30612
#pragma optimize("unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <ext/pb_ds/assoc_container.hpp>
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define sorts(v) sort(v.begin(),v.end())
#define sortg(v) sort(v.begin(),v.end(),greater<ll>())
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1e18)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define mem(x,y) memset(x,y,sizeof(x))
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)
string s;
ll d;
const ll N=1e4+5,M=105;
ll dp[N][M][2];

ll fun(ll pos , ll rem , bool flag)
{
    if(pos==s.size())
    {
       if(rem==0)return 1;
       return 0;
    }
    if(dp[pos][rem][flag]!=-1)return dp[pos][rem][flag];
    ll ans=0;
    ll temp=0;
    if(flag==0)temp=s[pos]-'0';
    else temp=9;
    rep(i,temp+1)
    {
        ll nf=flag;
        if(flag==0&&i<temp)nf=1;
        ll trem=((rem)%d+i%d)%d;
        ans=(ans%mod+fun(pos+1,trem,nf)%mod)%mod;
    }
    return dp[pos][rem][flag]=ans%mod;
}

void solve()
{
   cin>>s>>d;
   mem(dp,-1);
   cout<<(fun(0,0,0)%mod-1%mod+mod)%mod<<"\n";
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


Measured memory_bytes: 20840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> pi;
const int MAX_N = 500005;
const int MAX_Q = 101;
vector<pi> S,T;
vector<int> ans;
int n,q;

int main() {
  cin >> n;
  rep (i,n) {
    int x, y;
    cin >> x >> y;
    S.push_back(pi(P(x,y),i));
    T.push_back(pi(P(y,x),i));
  }
  sort(S.begin(),S.end());
  sort(T.begin(),T.end());
  cin >> q;
  rep (i,q) {
    int sx, tx, sy, ty;
    cin >> sx >> tx >> sy >> ty;
    int lx = lower_bound(S.begin(),S.end(),pi(P(sx,sy),0))-S.begin();
    int hx = upper_bound(S.begin(),S.end(),pi(P(tx,ty),n))-S.begin();
    int ly = lower_bound(T.begin(),T.end(),pi(P(sy,sx),0))-T.begin();
    int hy = upper_bound(T.begin(),T.end(),pi(P(ty,tx),n))-T.begin();
    int wx = hx-lx;
    int wy = hy-ly;
    if (wx<wy) { 
      for (int i=lx; i<hx; i++) {
        int y = S[i].first.second;
        if (sy<=y && y<=ty) {
          ans.push_back(S[i].second);
        }
      }
    } else {
      for (int i=ly; i<hy; i++) {
        int x = T[i].first.second;
        if (sx<=x && x<=tx) {
          ans.push_back(T[i].second);
        }
      }
    }
    sort(ans.begin(),ans.end());
    rep (i,ans.size()) {
      printf("%d\n", ans[i]);
    }
    printf("\n");
    ans.clear();
  }
  return 0;
}

Measured memory_bytes: 14680
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
struct BinaryIndexedTree{
    vector<int> bit;
    BinaryIndexedTree(int siz){
        bit.assign(++siz,0);
    }
    void add(int k,int x){
        for(++k;k<bit.size();k+=k&-k){
            bit[k]+=x;
        }
    }
    int sum(int k){
        int res=0;
        for(++k;k>0;k-=k&-k){
            res+=bit[k];
        }
        return res;
    }
};
int main(){
    int n;cin>>n;
    ll k;cin>>k;
    ll a[200010],b[200010];
    ll sum=0;
    map<ll,ll> mp;
    b[0]=0;
    vector<ll>v;
    v.push_back(0);
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
        b[i]=sum-i*k;
        v.push_back(b[i]);
    }
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    for(int i=1;i<=v.size();i++){
        mp[v[i-1]]=i;
    }
    BinaryIndexedTree bit(2*n);
    ll ans=0;
    for(int i=0;i<=n;i++){
        ans+=(ll)bit.sum(mp[b[i]]);
        bit.add(mp[b[i]],1);
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<int,int>

const int N=1e5+10;
const ll maxN=1e18+10;
const double pi=3.14159265359;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    double n;
    cin >> n;
    cout << n*2*pi;
}
    

Measured memory_bytes: 3800
#include <iostream>
#include <math.h>

int main (){
	char aho[10];
	scanf("%s", aho);
	if (strcmp(aho, "Sunny")==0){
		printf("Cloudy\n");
	} else if (strcmp(aho, "Cloudy")==0){
		printf("Rainy\n");
	} else if (strcmp(aho, "Rainy")==0){
		printf("Sunny\n");
	}

	return 0;
}

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

// 1-indexed BIT
class BIT{
    public:
    vector<ll>bit;
    int N;
    void init(int n){
        N = n;
        bit = vector<ll>(N, 0);
    }
    // [1, n] = {}
    BIT(int n = 0){
        init(n);
    }
    // sum [1, i]
    ll sum(int i){
        ll s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    void add(int i, ll x){
        if(i == 0)return;
        while(i <= N){
            bit[i] += x;
            i += i & -i;
        }
    }
};

int main(){
    ll N;
    cin >> N;
    vector<ll>A(N), B(N + 1, 0);
    for(ll i = 0; i < N; i++){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(), B.end());
    ll ng = 0, ok = N;
    while(ng + 1 < ok){
        ll p = (ng + ok) / 2;
        ll x = B[p];
        ll cnt = 0;
        ll sum = N + 5;
        BIT bit(N * 2 + 20);
        bit.add(sum, 1);
        for(ll i = 0; i < N; i++){
            if(A[i] <= x)sum++;
            else sum--;
            cnt += bit.sum(sum - 1);
            bit.add(sum, 1);
        }
        if(cnt > N * (N + 1) / 4)ok = p;
        else ng = p;
    }
    cout << B[ok] << endl;

    return 0;
}


Measured memory_bytes: 3428
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def iif(n): return [int(input()) for _ in range(n)]
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    a, b, c = mi()
    k = ii()

    while a >= b:
        b *= 2
        k -= 1
    
    while b >= c:
        c *= 2
        k -= 1

    if k < 0:
        print("No")
    else:
        print("Yes")


    return

main()


Measured memory_bytes: 9096
#include <bits/stdc++.h>
typedef long long ll;
const ll LINF = 1e18;
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<ll> A(N, 0);
    vector<ll> B(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        A[i] = A[i] * 100000 + B[i] - 1;
    }

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

    int iter = 0;
    int cnt = 0;
    ll sum = 0;
    while (cnt < M) {
        ll a = A[iter] / 100000;
        ll b = A[iter] % 100000 + 1;
        for (int i = 1; i <= b; i++) {
            cnt++;
            sum += a;
            if (cnt >= M) break;
        }
        iter++;
    }

    cout << sum << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  for (int i = 0; i < 3; i++){
    
    if (s.at(i) == s.at(i + 1)){
      cout << "Bad" << endl;
      return 0;
    }
  }
  
  cout << "Good" << endl;
}


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

vector<int> v;

int main(){
  int n;
  while(true){
    cin>>n;
    if(n==0)break;
    v.clear();
    for(int i=0; i<n; i++){
      int tmp;
      cin>>tmp;
      v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    ll sum=0;
    for(int i=0; i<n-1; i++)
      sum+=v[i]*(v.size()-i-1);
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) f(i,0,n)
#define rrep(i,n) rf(i,n-1,0)
#define w(t) ll t; cin>>t; while(t--)
#define vi vector<ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mii map<ll,ll>
#define mci map<char,ll>
using namespace std;

void fast_IO_file()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main()
{
	fast_IO_file();
	ll n, k;
	cin >> n >> k;
	ll p[n];
	rep(i,n)
	{
		cin>>p[i];
	}
	ll ans=0;
	sort(p,p+n);
	rep(i,k)
	{
		ans+=p[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3664