akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: chars
    }
    for &c in &n {
        if c == '1' {
            print!("9");
        } else {
            print!("1");
        }
    }
    println!("");
}


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Lqueue L;
    ll n;
    cin>>n;
    map<ll,ll> m;
    rep(i,n){
        ll a;
        cin>>a;
        m[a]++;
    }
    rbf(p,m){
        if(p.second>1){
            rep(i,p.second/2){
                L.push(p.first);
            }
        }
    }
    if(Size(L)<2){
        cout<<0<<endl;
        return 0;
    }
    ll a=L.top();
    L.pop();
    a*=L.top();
    cout<<a<<endl;
}

Measured memory_bytes: 9748
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T>
T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T>
T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
    cin >> n;
    vp vx(n), vy(n);
    REP(i, n)
    {
        cin >> vx[i].first >> vx[i].second;
    }
    REP(i, n)
    {
        cin >> vy[i].first >> vy[i].second;
    }
    sort(ALL(vx));
    sort(ALL(vy));
    set<P> st;
    REP(j, n) {
        vp v;
        REP(i, n) {
            if (vx[i].first < vy[j].first&&st.count(P(vx[i].second, vx[i].first)) == 0) {
                v.push_back({ vx[i].first,vx[i].second });
            }
        }
        vp vv;
        REP(i, v.size()) {
            if (v[i].second < vy[j].second) {
                vv.push_back({ v[i].second ,v[i].first });
            }
        }
        sort(RALL(vv));

        if (vv.size() == 0) {
            continue;
        }

        if (st.count(P(vv[0].first, vv[0].second)) == 0) {
            ans++;
            st.insert(P(vv[0].first, vv[0].second));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
int GCD(int x, int y) {
    return x ? GCD(y % x, x) : y;
}
int main()
{
    int n;
    cin >> n;
    vi v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    vi l(n); //i-1番目までの最大公約数
    vi r(n); //i+1番目以降の最大公約数
    l[0] = 0;
    r[n - 1] = 0;
    rep(i, n - 1)
    {
        l[i + 1] = GCD(v[i], l[i]);
    }
    for (int i = n - 1; i > 0; i--)
    {
        r[i - 1] = GCD(v[i], r[i]);
    }
    int ans = 0;
    rep(i, n)
    {
        int m = GCD(l[i], r[i]);
        ans = max(ans, m);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	string r, g, b;
	cin >> r >> g >> b;
	ll a = stoi(r + g + b);
	if (a % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
local n=io.read("n")
local p={}
for i=1,n do
    p[i]=io.read("n")
end

local dp={}
for i=1,n+1 do
    dp[i]={}
    for j=0,i do
        dp[i][j]=0
    end
end
dp[1][0]=1

for i=1,n do
    for j=0,i do
        dp[i+1][j+1]=dp[i+1][j+1]+dp[i][j]*p[i]
        dp[i+1][j]=dp[i+1][j]+dp[i][j]*(1-p[i])
    end
end

local total=0
for i=n//2+1,n do
    total=total+dp[n+1][i]
end
print(total)

Measured memory_bytes: 107856
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end(), greater<int>());
  int sum = 1;
  sum = 10 * a[0];
  sum += a[1];
  sum += a[2];
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

bool IsPrime(long num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (long i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    
    long n;
    cin >> n;
    long ans = 0;
    for (long i=0;i<n;i++){
        long p;
        cin >> p;
        if(IsPrime(p)){
            ans += 1;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
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; }

#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
void func(){
  string S;
  string T;
  cin >> S;
  cin >> T;
      
  vector<string> X;    
  REP(i,S.length()-T.length()+1){
    //cout << i << endl;
    bool is_match = true;
    REP(j,T.length()){
      if(S[i+j]=='?' or T[j]==S[i+j] ){

      } 
      else{
        is_match=false;
        break;
      }
    }
    if(is_match){
      string B = S;
      REP(j,T.length()){
        B[i+j]=T[j];
      }
      REP(j,B.length()){
        if(B[j]=='?'){
          B[j]='a';
        }
      }
      X.push_back(B);
      //cout << B<<endl;    
    }
  }
  if(X.size()<=0){
    cout << "UNRESTORABLE";
  }
  else{
    sort(ALL(X));
    cout << X[0];
  }

  EACH(x,X){
    //cout << x << endl;
  }

} 
int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
  int n, k, c, x, sum=0;
  int a[200001]={0};
  int i;
  cin >> n >> k;

  for(i=0; i<n; i++){
    cin >> c;
    a[c-1]++;
  }

  sort(a, a+n, greater<int>());

  for(i=0; i<k; i++){
    sum += a[i];
  }

  cout << n - sum << endl;


  return 0;
}

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

int main(void){
    ll a;
    cin >> a;
    if(a < 1200){
        cout << "ABC" << endl;
    }else if(a < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)

#define ll long long

const int MOD = 1e9 + 7;

int main() {

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

    // freopen("input.in", "r", stdin);

    int n;
    cin>>n;
    std::vector<int> a(n);
    int i;

    ll baza = 0ll;

    for (i=0;i<n;i++) {
        cin>>a[i];
        if (i>0) baza+=a[i];
        baza %= MOD;
    }

    ll vk = (baza * a[0]) % MOD;

    // cout<<vk<<"\n";

    int j;
    for (j=1;j<n;j++) {
        baza -= a[j];
        baza += MOD;
        baza %= MOD;

        vk+= (a[j] * baza) % MOD;
        vk%=MOD;
    }

    cout<<vk%MOD<<"\n";

    return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n;
    cin >> n;
    cout << n * n * n << endl;
}


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


int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  vector<vector<int>> roads(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    roads[a - 1].push_back(b - 1);
    roads[b - 1].push_back(a - 1);
  }
  vector<int> good(N, -1);
  for (int i = 0; i < N; i++) {
    if (good[i] == 0) continue;
    good[i] = 1;
    for (int j : roads[i]) {
      if (H[i] < H[j]) {
        good[i] = 0;
      } else if (H[i] == H[j]) {
        good[j] = 0;
        good[i] = 0;
      } else {
        good[j] = 0;
      }
    }
  }
  int n_goods = accumulate(good.begin(), good.end(), 0);
  cout << n_goods << endl;
  return 0;
}

Measured memory_bytes: 8980
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	
	vector<ll> an(N);
	rep(i, N) {
		ll a;
		cin >> a;
		an.at(a-1) = i + 1;
	}
	rep(i, N) {
		cout << an.at(i) << " ";
	}

}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)
const long long INF = 1LL << 60;

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int left=0;
    int right=1e9;
    while(right-left > 1){
      int c = (left+right)/2;
      ll sum=0;
      rep(i,N){
        sum+=((A[i]-1)/c);
      }
      if(sum<=K) right=c;
      else left=c;
    }
    cout << right << endl;

    return 0;
}


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

int main(){
    char c; cin >> c;
    
    if(c == 'a' || c == 'e' || c == 'i' || c =='u'||c=='e'||c=='o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};

using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     int n;
     cin>>n;
     int num=-1;
     for(int i=0;i<=50000;i++)
        {
            int k=i*(1.08);
            if(k==n)
                num=i;
        }
    if(num==-1)
        cout<<":(\n";
    else
    cout<<num<<endl;
     
     
}


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

#define ll long long

int main(){

    int N,M;
    int i,j,k,l;
    int a,b,c,d;
    int count=0,count_n=0,count_m=0;
    bool flag = false;
    int ans=0;
    string S;
    int A,B;

    cin >> A >> B;

    if(A + B >= A - B && A + B >= A * B)cout << A+B << endl; 

    if(A + B < A - B && A - B > A * B)cout << A-B << endl; 

    if(A - B < A * B && A + B < A * B)cout << A*B << endl; 

    return 0;

}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int dp[111111];
int h[111111];

main(){
	int n;cin>>n;
	rep(i,n)cin>>h[i];
	rep(i,111111)dp[i]=MOD;
	dp[0]=0;
	rep(i,n){
		chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	dump(dp[n-1]);
}






Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
	int X, Y;
	cin >> X >> Y;
	for(int i=0;i<=100;i++)
		for(int j=0;j<=100;j++)
			if (i + j == X && 2 * i + 4 * j == Y)
			{
				cout << "Yes";
				return 0;
			}
	cout << "No";
}

Measured memory_bytes: 3636
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
from fractions import Fraction

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def inv(x, MOD):
    return pow(x, MOD-2, MOD)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n,k,*A = get_all_int()
    A = list(A)

    # 答えが負である条件
    # ・Aが全て負で、Kが奇数
    # ・Aの負数が奇数個かつ0が存在せず、K=N

    # 答えが0である条件
    # ・N-(Aの0の個数) < K

    positives = 0
    zeros = 0
    negatives = 0

    for a in A:
        if a > 0:
            positives += 1
        elif a == 0:
            zeros += 1
        else:
            negatives += 1
    

    if k == 1:
        # 1個だけの場合はたんに最大値を出力する
        A.sort(reverse=True)
        print(A[0])
        exit()

    if (n-zeros) < k:
        # 答えが0
        print(0)
        exit()
    
    elif (k==n and negatives%2==1  or  n==negatives+zeros and k%2==1):
        # 答えが負
        # 絶対値小さい順にK個掛ける
        A.sort(key=lambda a: abs(a))
        # log(A)
        ans = 1
        for i in range(k):
            ans =  (ans * A[i]) % MOD
        print(ans%MOD)
        exit()

    else:
        # 答えが正
        # 絶対値大きい順にK個掛ける
        A.sort(reverse=True, key=lambda a: abs(a))
        # log(A)
        ans = 1
        n_count = 0
        last_n = 0
        last_p = 0
        for i in range(k):
            a = A[i]
            ans =  (ans * a) % MOD
            if a < 0:
                n_count += 1
                last_n = a
            elif a > 0:
                last_p = a
                # log(i, last_n)

        # log(ans, n_count, last_n)
        
        # 負数を奇数個選んでいる場合は調整する
        if n_count%2 == 1:
            first_p = None
            first_n = None
            for i in range(k,n):
                a = A[i]
                if a > 0 :
                    ans_a = ans*inv(last_n, MOD) * a
                    first_p = a
                    break
            if last_p != 0:
                for i in range(k,n):
                    a = A[i]
                    if a < 0:
                        ans_b = ans*inv(last_p, MOD) * a
                        first_n = a
                        break
                if first_n is not None:
                    if first_p is not None:
                        xx = Fraction(abs(first_p), abs(last_n))
                        yy = Fraction(abs(first_n), abs(last_p))
                        # xx = abs(first_p) / abs(last_n)
                        # yy = abs(first_n) / abs(last_p)
                        if yy > xx:
                            ans_a = ans_b
                    else:
                        ans_a = ans_b
            if first_n is None and first_p is None:
                ans_a = 0
            ans = ans_a
        
        print(ans%MOD)
        exit()

main()

Measured memory_bytes: 118380
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int a = getInt();
  const int b = getInt();

  puts(a % 2 == 0 || b % 2 == 0 ? "No" : "Yes");

  return 0;
}

Measured memory_bytes: 128
/*
Author: Hrujul Thumar
*/
#include <bits/stdc++.h>
#define int         long long
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define whilet()    int t; scanf("%d",&t); while(t--)
#define vp          vector<pair<int,int>,int>
#define pb          push_back
#define mii         map<int,int>
#define pii         pair<int,int>
#define msi         map<string,int>
#define psi         pair<string,int>
#define mpi         map<pair<int,int>,int>
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define ef          else if
#define MOD         1000000007
#define endl        '\n'
#define fastio       ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define pi          3.141592653589793238
const long long MAX_SIZE = 1000000000;
using namespace std;

signed main()
{
    fastio
    string s;
    cin>>s;
    int cnt=0;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')cnt++;
        else{
            ans=max(cnt,ans);
            cnt=0;
        }
    }
    ans=max(cnt,ans);
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
 
int main() {
  ll a, b;
  cin >> a >> b;
  ll d = gcd(a, b);
  vector<pair<ll, int>> f;
  for (ll i = 2; i * i <= d; i++) {
    if (d % i) continue;
    f.emplace_back(i, 0);
    while (d % i == 0) {
      d /= i;
      f.back().second++;
    }
  }
  if (d != 1) f.emplace_back(d, 1);
  // rep(i, f.size()) cerr << f[i].first << endl;
  cout << f.size() + 1 << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        int ans = (int) (a + Math.pow(a, 2) + Math.pow(a, 3));
        System.out.println(ans);
    }
}

Measured memory_bytes: 35552
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int switches[12][12];
int ks[12];
int ps[12];

int main(void){
  int N,M; cin >> N >> M;
  rep(i,M){
    int k; cin >> k; ks[i] = k;
    rep(j,k){
      int x; cin >> x; x--;
      switches[i][j] = x;
    }
  }
  rep(i,M) cin >> ps[i];
  
  int res = 0;
  rep(bits,1<<N){
    bool flag = true;
    rep(i,M){
      int num_on = 0;
      rep(j,ks[i]){
        if ((bits>>switches[i][j])&1){
           num_on++;
        }
      }
      if (num_on%2 != ps[i]) flag = false;
    }
    if (flag) res++;
  }
  
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
int n,m; 
vector<vector<char>> v;
vector<vector<bool>> used;
void solve(){
    int n ; cin>>n;
    cout<<n*n*n;


}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

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

#define ll long long
#define ar array

const int mxN=2e5;
int n, m;
ll k, a[mxN+1], b[mxN+1];

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

    cin >> n >> m >> k;
    for(int i=0; i<n; ++i)
        {
            cin >> a[i+1];
            a[i+1]+=a[i];
        }
    for(int i=0; i<m; ++i)
        {
            cin >> b[i+1];
            b[i+1]+=b[i];
        }
    int ans=0;
    for(int i=0, j=m; i<=n; ++i)
        {
            if(a[i]>k)
                break;
            while(a[i]+b[j]>k)
                --j;
            ans=max(i+j, ans);
        }
    cout << ans;
}


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

int main(){
  int X;
  cin>>X;
  for(long long int A=0;A<10000;A++){
    for(long long int B=0;B<10000;B++){
      long long int A5=A*A*A*A*A;
      long long int B5=B*B*B*B*B;
      if(-A5-B5==X){
        cout<<-A<<" "<<B<<endl;
        return 0;
      }
      if(-A5+B5==X){
        cout<<-A<<" "<<-B<<endl;
        return 0;
      }
      if(A5-B5==X){
        cout<<A<<" "<<B<<endl;
        return 0;
      }
      if(A5+B5==X){
        cout<<A<<" "<<-B<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3636
import java.io.*;

public class Main {

    final static int MENU_PRICE = 800;
    final static int PAID_PRICE = 200;
    final static int PAID_PER_COUNT = 15;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        int x = n * MENU_PRICE;
        int y = n / PAID_PER_COUNT * PAID_PRICE;
        System.out.println(x - y);
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
    int N;
    cin >> N;
    double ans = (double)((N+1)/2)/N;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    Set<String> set = new HashSet<>();
    while (n-- > 0) {
      set.add(sc.next());
    }
    System.out.println(set.size());
  }
}

Measured memory_bytes: 71816
#include<stdio.h>
int main()
{
    long long n,h,N,sum=0;
    double w;
    while(scanf("%lld",&N)!=EOF)
    {
        sum=0;
        for(h=1 ; h<=3500 ; h++)
        {
            for(n=1 ; n<=3500 ; n++)
            {
                if(4*h*n-N*n-N*h<=0)
                    continue;
                w=1.0*(N*h*n)/(4*h*n-N*n-N*h);
                if(w-(long long )w==0&&w>0)
                {
                    printf("%lld %lld %lld\n",h,n,(long long)w);
                    sum++;
                }
                if(sum==1)
                    break;
            }
            if(sum==1)
                break;
        }
    }
    return 0;

}

Measured memory_bytes: 504
if __name__ == "__main__":
    # 入力パターン．
    # 先に要素数Nが与えられて，その数読み込むパターン
    ### N
    ### x_1, y_1
    ### ...
    ### x_N, y_N
    N, K = map(int, input().split())
    s = set()
    for k in range(K):
        d = int(input())
        line = list(map(int, input().rstrip().split(' ')))
        for l in line:
            s.add(l)
    print(N-len(s))


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
ll a[N];
ll n, k;
ll get(ll a, ll nd) {
    if(a == nd)
        return 0;
    return a / nd;
}
void solve(){
    cin >> n >> k;
    ll f = -1;
    for(int i = 1; i <= n; ++i)
        cin >> a[i],
        f = max(f, a[i]);

    ll l = 1, r = INF;
    while(l <= r){
        ll md = l + r >> 1;
        
        ll t = 0;
        for(int i = 1; i <= n; ++i) {
            t += get(a[i], md);
        }
        if(t <= k){
            r = md - 1;
            f = md;
        }else{
            l = md + 1;
        }
    }
    cout << f << '\n';
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 5100
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;int main(){int n,m,p,q,r,x,y;vector<int>::iterator u,v,z;for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){vector<int>s,t;s.push_back(0);for(s.push_back(r);m--;t.clear()){cin>>x>>y;u=upper_bound(s.begin(),s.end(),x);v=upper_bound(s.begin(),s.end(),y);if(v-s.begin()+1&1)t.push_back(0);t.push_back(0);for(z=v;z!=s.end();++z)t.push_back(*z-y);if(s.end()-u&1)t.push_back(n-y);for(z=u;z!=v;++z)t.push_back(*z-x+n-y);z=s.begin();if(v-s.begin()&1)++z;if(!z[1])z+=2;if(*z+n-x==t.back()){++z;t.pop_back();}for(;z!=u;++z)t.push_back(*z+n-x);s.swap(t);}s.insert(upper_bound(s.begin(),s.end(),p-1),2,p-1);s.insert(lower_bound(s.begin(),s.end(),q),q);s.push_back(n);z=upper_bound(s.begin(),s.end(),p-1);if(z-s.begin()&1)--z;for(x=0;*z<q;++z)m=*z++,x+=*z-m;}}

Measured memory_bytes: 0
#k,x=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(input())
#r=[int(input()) for _ in range(n)]
a=list(map(int,input().split()))
#b=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#a=[list(map(int,input().split()))for _ in range(n)]
#m=[list(input().split())for _ in range(n)]
total=0
for i in range(n):
    total+=1/a[i]
print(1/total)


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

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> A(N+1);
    A[0] = 0;
    for (int i=1; i<=N; ++i) {
        cin >> A[i];
        A[i] += A[i-1];
    }
    sort(A.begin(), A.end());
    long long sum = 0;
    long long count = 0;
    int before = 1;
    for (const int a: A) {
        if (a != before) {
            sum += count * (count-1) / 2;
            before = a;
            count = 0;
        }
        ++count;
    }
    sum += count * (count-1) / 2;
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    int h, w, d; cin >> h >> w >> d;
    int a[h][w];
    P atoij[h*w];
    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
            atoij[a[i][j]] = {i, j};
        }
    }


    int q; cin >> q;
    int l[q], r[q];
    rep(i, q){
        cin >> l[i] >> r[i];
    }

    ll dist[h*w+1];
    reps(i, 1, h*w+1){
        if(i <= d){
            dist[i] = 0;
        }
        else{
            ll xp = atoij[i-d].first;
            ll yp = atoij[i-d].second;
            ll xn = atoij[i].first;
            ll yn = atoij[i].second;

            dist[i] = dist[i-d] + abs(xn-xp) + abs(yn-yp);
        }
    }

    rep(i, q){
        cout << dist[r[i]] - dist[l[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
struct node
{
	int x ;
	int y;
	int z;
};
int cmp(node a , node b)
{
	if(a.x == b.x)
	{
		return a.y < b.y;
	}
	else
	{
		return a.x < b.x;
	}
}
int main()
{
	int n , m ;
	node r[100008];
	
	int book[100008]={0};
	node a[100008] , b[100008];
	cin >> n >> m;
	for(int i = 0 ; i < m ; i++)
	{
		cin >> a[i].x >> a[i].y;
		a[i].z = i;
		book[a[i].x]++;
	}
	sort(a , a+m , cmp);
	int num = 1;
	for(int i = 0 ; i < m ; i++)
	{
		r[a[i].z].x = a[i].x;
		r[a[i].z].y = num;
		num++;
		if(a[i].x != a[i+1].x)
		num = 1;
	}
	for(int i = 0 ; i < m ; i++)
	{
		printf("%06d" , r[i].x);
		printf("%06d\n" , r[i].y);
	}
	return 0;
}

Measured memory_bytes: 3840
n = input()
k = int(input())
l = len(n)

dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(l)]

dp[0][1][0] = int(n[0])-1
dp[0][1][1] = 1

for i in range(1, l):

    dp[i][1][0] = dp[i-1][1][0] + 9
    dp[i][2][0] = dp[i-1][2][0] + 9 * dp[i-1][1][0]
    dp[i][3][0] = dp[i-1][3][0] + 9 * dp[i-1][2][0]

    if int(n[i]) == 0:
        dp[i][1][1] = dp[i-1][1][1]

    elif dp[i-1][1][1] == 1:
        dp[i][2][1] = 1
        dp[i][2][0] += int(n[i])-1
        dp[i][1][0] += 1

    elif dp[i-1][2][1] == 1:
        dp[i][3][1] = 1
        dp[i][3][0] += int(n[i])-1
        dp[i][2][0] += 1

    elif dp[i-1][3][1] == 1:
        dp[i][3][0] += 1

print(sum(dp[-1][k]))

Measured memory_bytes: 3192
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-22-20.10.15 Sunday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

double l;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> l;
    l /= 3.0;
    double ans = l*l*l;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

// ベルマン–フォード法
// sから到達可能な負閉路を持たないこと。
// 負閉路の検出にも使用できる。

//#define UNDIRECTED // 無向グラフ

constexpr int MAX_V = 1000;
constexpr int MAX_E = 2000;
constexpr int INF = 1 << 30;

struct Edge { int from, to, cost; };

int V, E;
Edge es[MAX_E];
int d[MAX_V];

bool bellman_ford(int s) {
  fill_n(d, MAX_V, INF);
  d[s] = 0;

  int loop_count{};
  while (true) {
    bool update = false;
    for (int i{}; i < E; ++i) {
      Edge e = es[i];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
#ifdef UNDIRECTED
      if (d[e.to] != INF && d[e.from] > d[e.to] + e.cost) {
        d[e.from] = d[e.to] + e.cost;
        update = true;
      }
#endif
    }
    if (!update) {
      break;
    }
    if (++loop_count >= V) {
      return false;
    }
  }

  return true;
}

int main() {
  int r;
  cin >> V >> E >> r;
  for (int i{}; i < E; ++i) {
    cin >> es[i].from >> es[i].to >> es[i].cost;
  }

  if (!bellman_ford(r)) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }

  for (int i{}; i < V; ++i)
    cout << (d[i] < INF ? to_string(d[i]) : "INF") << endl;

  return 0;
}



Measured memory_bytes: 3296
// AOJ 2236 Rabbit Plays Games!
// 2018.2.10 bal4u

#include <stdio.h>
#include <stdlib.h>

typedef struct { long long a; int d; } T;
T tbl[40002];
int h[40002], a[40002], d[40002], s[40002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(T *a, T *b) { return a->a * b->d > b->a * a->d; }

int main()
{
	int n, i, k, sz;
	long long turn, ans;

	n = in();
	for (i = 0; i <= n; i++) h[i] = in(), a[i] = in(), d[i] = in(), s[i] = in();
	
	sz = 0, ans = turn = 0;
	for (i = 1; i <= n; i++) {
		k = a[i] - d[0];
		if (k <= 0) continue;
		if (a[0] <= d[i]) { puts("-1"); return 0; }

		turn += k; if (s[i] > s[0]) ans += k;
		tbl[sz].d = k;
		tbl[sz++].a = ((long long)h[i]-d[i]+a[0]-1)/(a[0]-d[i]);
	}
	qsort(tbl, sz, sizeof(T), cmp);

	for (i = 0; i < sz; i++) {
		ans += turn*tbl[i].a - tbl[i].d;
		if (h[0] <= ans) { puts("-1"); return 0; }
		turn -= tbl[i].d;
	}
	printf("%lld\n", ans);
	return 0;
}


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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

const int MAX=2e5+9;
int n, a[MAX];
multiset<pi, greater<pi>> ms;

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

    cin >> n;
    for (int i=1; i<=n; ++i) {
        cin >> a[i];
    }

    sort(a+1, a+n+1, greater<int>());
    ms.insert({a[2], a[1]});
    ms.insert({a[2], a[1]});

    ll ans=a[1];
    for (int i=3; i<=n; ++i) {
        auto it=ms.begin();
        ans+=it->F;

        ms.insert({a[i], it->F});
        ms.insert({a[i], it->S});
        ms.erase(it);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 13812
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = r[0];
            var B = r[1];
            var K = r[2];
            if (K > A)
            {
                var t = (B - (K - A)) < 0 ? 0 : (B - (K - A));
                Console.WriteLine("0 " + t.ToString());
            }
            else
            {
                Console.WriteLine((A - K).ToString() + " " + B);
            }
        }

    }
}

Measured memory_bytes: 13268
#include<stdio.h>
#include <string.h>

int main(){
	double a, b = 0;
	int i;
	while(scanf("%lf", &a) != EOF){
		b += a;
		for(i = 1; i < 10; i++){
			if(i % 2 == 0) a /= 3;
			else a *= 2;
			b += a;
		}
		printf("%.8f\n", b);
		b = 0;
	}
	return 0;
}

Measured memory_bytes: 648
#include <stdio.h>
#include <string.h>

int bind[128];
char *i;

int rdp(void)
{
    int a, b;
    char c, op;

    switch (c = *i++) {
        case '0':
        case '1':
        case '2':
            return c - '0';
        case 'P':
        case 'Q':
        case 'R':
            return bind[c];
        case '-':
            return -(rdp() - 1) + 1;
        case '(':
            a = rdp();
            switch (op = *i++) {
                case '*':
                    a = (a * rdp() + 1) / 2;
                    break;
                case '+':
                    b = rdp();
                    a = (a == 1 && b == 1) ? 1 : (a + b >= 2 ? 2 : a + b);
                    break;
            }
            ++i;    // skip ')'
            return a;
    }
    return a;
}

int main(void)
{
    for (;;) {
        char s[81];
        int p, q, r, c = 0;

        scanf("%s", s);
        if (strcmp(s, ".") == 0)
            break;

        for (p = 0; p < 3; ++p) {
            bind['P'] = p;
            for (q = 0; q < 3; ++q) {
                bind['Q'] = q;
                for (r = 0; r < 3; ++r) {
                    bind['R'] = r;
                    i = s;
                    if (rdp() == 2)
                        ++c;
                }
            }
        }

        printf("%d\n", c);
    }

    return 0;
}

Measured memory_bytes: 536