akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

vector<int> fac, finv, inv;

void comb_init(int n) {
  fac  = vector<int>(n);
  finv = vector<int>(n);
  inv  = vector<int>(n);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
 
int comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
  int N, K;
  cin >> N >> K;

  comb_init(400010);

  int ans = 0;
  REP(i, min(N-1, K)+1){
    ans += comb(N, i)*comb(N-1, N-i-1);
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  double l;cin>>l;
  cout<<fixed<<setprecision(12)<<(l/3.0)*(l/3.0)*(l/3.0)<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

struct prob {
	int bonus, num;
 };

int main() {

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

	int D, G;
	cin >> D >> G;

	vector<prob> p(D);
	prob ptmp;
	for (int i = 0; i < D; i++) {
		cin >> ptmp.num >> ptmp.bonus;
		ptmp.bonus += (i + 1) * ptmp.num * 100;
		p[i] = ptmp;
	}

	int ans = INF, sum, cnt, tmp;
	for (int bit = 0b0; bit < (1 << D); bit++) {
		
		sum = 0, cnt = 0;
		for (int i = 0; i < D; i++) {
			if (bit & (1 << i)) {
				sum += p[i].bonus;
				cnt += p[i].num;
			}
		}

		if (sum >= G) {
			ans = min(ans, cnt);
		}
		else {
			for (int i = D - 1; i >= 0; i--) {
				if (!(bit & (1 << i))) {
					tmp = (G - sum - 1) / ((i + 1) * 100) + 1;
					if (tmp < p[i].num) {
						ans = min(ans, cnt + tmp);
					}
					break;
				}
			}
		}

	}
	
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h> 
int main()
{
    int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a*100+b*10+c)%4==0)
		printf("YES\n");
	else
		printf("NO\n");	
	
	
    return 0;
 }

Measured memory_bytes: 128
#include <stdio.h>
int main(void) {
  int a, b = 0, c;
  scanf("%d", &a);
  for (int i = 1; i < 10; i++) {
    if (a % i != 0)
      ;
    else
      c = a / i;
    for (int j = 1; j < 10; j++) {
      if (a % j != 0)
        ;
      else {
        c = a / j;
        if (c < 10) {
          b = -1;
          // printf("%d,", i * j);
          break;
        }
      }
    }
  }
  if (b == -1)
    puts("Yes");
  else
    puts("No");
  return 0;
}


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

int eulerPhi (int n) {
  if (n == 0) {
    return 0;
  }
  int result = n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      result -= result / i;
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1) {
    result -= result / n;
  }
  return result;
}

int main() {

  long long n;
  cin >> n;

  cout << eulerPhi(n) << endl;

  return 0;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX=1001001;
const ll MOD=1000000007;
int main()
{
    ll n;
    cin >> n;
    ll r=0;
    ll l=n+1;
    cout<<r<<endl;
    string s;
    cin>>s;
    if (s=="Vacant") {
        return 0;
    }
    string a=s;
    ll q=19;
    while (q--) {
        ll m=(r+l)/2;
        cout<<m<<endl;
        cin>>s;
        if (s=="Vacant") {
            return 0;
        }
        if (s==a) {
            if ((m-r)%2) {
                l=m;
            }
            else {
                r=m;
                a=s;
            }
        }
        else {
            if ((m-r)%2) {
                r=m;
                a=s;
            }
            else {
                l=m;
            }
        }
    }
}


Measured memory_bytes: 3856
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	long double a, b;
	cin >> a >> b;
	cout << ll(a * b) << endl;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod || x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
    return 0;
}



Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n,k;
  	cin>>n>>k;
  	vector<int> v(n+1,0);
  	int a;
  	for(int i=0;i<k;i++){
    	cin>>a;
      for(int j=0;j<a;j++){
      	int x;
        cin>>x;
        v[x]++;
      }
    }
  int count=0;
  for(int i=1;i<=n;i++){
  	if(v[i]==0)
      	count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

const ll INF=LLONG_MAX/2;

int main(){
  int N;
  cin>>N;
  ll a[N][N];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++) cin>>a[i][j];
  }
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(a[i][j]>a[i][k]+a[k][j]){
          cout<<-1<<endl;
          return 0;
        }
      }
    }
  }
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(k==j||k==i) continue;
        if(a[i][j]==a[i][k]+a[k][j]) a[i][j]=INF;
      }
    }
  }
  ll ans=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++) ans+=(a[i][j]!=INF?a[i][j]:0);
  }
  cout<<ans/2<<endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(),a.end()), a.end());
    
    int d=0;
    for(int i=0; i<a.size()-1; i++){
        d += a[i+1]-a[i];
    }
    cout << d << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int h,w;cin >> h>> w;
    char a[h][w];
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    rep(i,w+2)cout <<"#";
    cout << endl;

    rep(i,h){
        cout << '#';
        rep(j,w){
            cout << a[i][j];
        }
        cout <<"#"<< endl;

    }

    rep(i,w+2)cout <<"#";
    cout << endl;
    


    return 0;
}

Measured memory_bytes: 256
#pragma GCC Optimize("Ofast")
#pragma GCC Optimize "trapv"
#define _GLIBCXX_DEBUG

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

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

const ll Inf=1e9+5;

ll a[100005],dp[100005],n,k;

ll ans(ll i){	
	if(i==n-1)
		return 0;
	if(i>=n)
		return Inf;
	ll ostep=Inf, tstep=Inf;
	if(dp[i]!=-1)	return dp[i];
	if(i+1<n){
		ostep=abs(a[i]-a[i+1])+ans(i+1);
	}
    if(i+2 < n){
		tstep=abs(a[i]-a[i+2])+ ans(i+2);
	}
	return dp[i]=min(ostep,tstep);
}

void solve(){
	memset(dp,-1,sizeof(dp));
	cin >> n;
	for(ll i=0;i<n;i++)
		cin >> a[i];
	cout << ans(0) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
	FAST
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	solve();
	ret 0;
}

Measured memory_bytes: 9720
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>
#include<time.h>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, K; cin >> N >> K;
	vector<vector<int>> dou(N + 1,vector<int>(64));
	for (int i = 1; i <= N; i++) {
		cin >> dou[i][0];
	}

	for (int i = 0; i < 63; i++) {
		for (int j = 1; j <= N; j++) {
			dou[j][i + 1] = dou[dou[j][i]][i];
		}
	}

	int now = 1;
	for(int i=0;i<64;i++){
		if (K % 2) {
			now = dou[now][i];
		}
		K /= 2;
		if (K == 0)break;
	}

	cout << now << endl;
}


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

int main(){
    int K=0;
    int S=0;
    cin >> K >> S;
    int c=0;
    for(int x=0;x<=K;x++){
        for(int y=0;y<=K;y++){
            int z=S-x-y;
            if(z>=0 && z<=K) c++;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int i, n, k, x;
	scanf("%d %d", &n, &k);
	char s[200000];
	scanf("%s", &s);
	x=0;
	for(i=0;i<n-1;i++){
		if(s[i]==s[i+1]){
			x=x+1;
		}
	}

	if(x+2*k<n-1){
		printf("%d", x+2*k);
	}
	else{
		printf("%d", n-1);
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back
#define md ((st + nd) >> 1)
#define lc (1 + (idx << 1))
#define rc (2 + (idx << 1))

const int N = 200005;
vector <int> v[N];
ll tree[4*N], lazy[4*N];

int len(int x, int y) {
    return y - x + 1;
}

void prop(int idx, int st, int nd) {
    int temp = lazy[idx];
    lazy[idx] = 0;
    lazy[lc] += temp;
    lazy[rc] += temp;
    int mid = md;
    tree[lc] += (ll)temp * len(st, mid);
    tree[rc] += (ll)temp * len(mid + 1, nd);
}

int l, r, val;
void upd(int idx, int st, int nd) {
    if (l <= st && nd <= r) {
        tree[idx] += (ll)val * len(st, nd);
        lazy[idx] += val;
    } else {
        prop(idx, st, nd);
        int mid = md;
        if (r <= mid) {
            upd(lc, st, mid);
        } else if (l > mid) {
            upd(rc, mid + 1, nd);
        } else {
            upd(lc, st, mid);
            upd(rc, mid + 1, nd);
        }
        tree[idx] = tree[lc] + tree[rc];
    }
}

ll get(int idx, int st, int nd) {
    if (l <= st && nd <= r) {
        return tree[idx];
    }
    prop(idx, st, nd);
    int mid = md;
    if (r <= mid) {
        return get(lc, st, mid);
    }
    if (l > mid) {
        return get(rc, mid + 1, nd);
    }
    return get(lc, st, mid) + get(rc, mid + 1, nd);
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        if (x < y) swap(x, y);
        v[x].pb(y);
    }
    for (int i = 1; i <= n; i++) {
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin(), v[i].end());
    }
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        int hold = 1;
        r = i;
        for (auto j : v[i]) {
            l = j + 1;
            val = hold;
            if (l <= r) {
                upd(0, 1, n);
                res += get(0, 1, n);
            }
            hold--;
            r = j;
        }
        l = 1;
        val = hold;
        if (l <= r) {
            upd(0, 1, n);
            res += get(0, 1, n);
        }
    }
    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 22800
#include<bits/stdc++.h>
#define int long long
#define all(x) begin(x), end(x)
#define SZ(x) ((int)(x).size())
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define de(x) if(x && x == MODE)
#define MODE 1

using namespace std;

typedef pair<int, int> pii;
const int INF = 1e18;
const int maxn = 3e5 + 7;

struct seg {
    int tree[maxn*4] = {};

    int LC(int i) {return i*2;}
    int RC(int i) {return i*2+1;}

    void pull(int l, int r, int i) {
        tree[i] = max(tree[LC(i)], tree[RC(i)]);
    }
    void build( int l, int r, int i=1) {
        if (l == r) {
            tree[i] = 0;
            return;
        }

        int m = (l+r) / 2;
        build(  l, m, LC(i));
        build(m+1, r, RC(i));
        pull(l,r,i);
    }

    void upd( int x, int d, int l, int r, int i=1) {
        if (l == r) {
            tree[i] = d;
            return;
        }

        int m = (l+r) / 2;
        if (x <= m)
            upd(x, d,   l, m, LC(i));
        if (m+1 <= x)
            upd(x, d, m+1, r, RC(i));
        pull(l,r,i);
    }

    int query(int x1, int x2, int l, int r, int i=1) {
        de(0) printf("query(%lld, %lld)\n", l, r);
        de(0) system("PAUSE");
        if (x1 <= l && r <= x2) {
            return tree[i];
        }

        int m = (l+r) / 2;
        int ret = 0;
        if (x1 <= m)
            ret = max(ret, query(x1, x2, l, m, LC(i)));
        if (m+1 <= x2)
            ret = max(ret, query(x1, x2, m+1, r, RC(i)));
        return ret;
    }
}seg;

int A[maxn] = {};

main() {
    int i,j;
    int N,K;

    cin >> N >> K;
    for (int i=1; i<=N; i++) {
        cin >> A[i];
    }

    int M = 300000;
    seg.build(0,M);
    for (int i=1; i<=N; i++) {
        int l = max(0LL, A[i]-K);
        int r = min(M, A[i]+K);
        de(0) printf("YEE\n");
        int q = seg.query(l, r, 0, M);
        seg.upd(A[i], q+1, 0, M);
    }
    int ans = seg.query(0, M, 0, M);
    printf("%lld\n", ans);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 14312
INF = 100000
n=int(input())
s=input()
ls = []
ls = [int(c) for c in s]
flag = [[INF for _ in range(10)]]

ls.reverse()

for i in range(n):
    flag[i][ls[i]] = n - i
    flag.append(flag[i][:])

flag.reverse()

res = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            keta1 = flag[0][k]
            if keta1 != INF and keta1 != n:
                keta2 = flag[keta1+1][j]
                if keta2 != INF and keta2 != n:
                    keta3 = flag[keta2+1][i]
                    if keta3 != INF:
                        res += 1

print(res)

Measured memory_bytes: 40976
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
    I am too dumb to realize that i am too dumb.
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    string s[3];
    lli i;
    rep(i,0,3)
    {
        cin>>s[i];
    }
    rep(i,0,3)
    {
        cout<<s[i][i];
    }
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
	int r=0,g=0,b=0;
	int num;
	scanf("%d %d %d",&r,&g,&b);
	num = 100*r + 10*g + b;
	if(num % 4 == 0)	printf("YES");
	else	printf("NO");
 
	return 0;
	}

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


int popcount(string s) {

	int M = s.size();
	int ret = 0;
	for (int i = 0; i < M; i++) {
		if (s[i] == '1') { ret++; }
	}
	return ret;
}

int f(string s, int pop_cnt) {

	//cout << "s= " << s <<" pop_cnt= "<<pop_cnt<< endl;
	int m = pop_cnt;

	int tmp = 0;

	int M = s.size();

	for (int i = 0; i < M; i++) {
		tmp *= 2;
		if (s[i] == '1') { tmp++; }
		tmp %= m;
	}

	return tmp;

	/*string t = "";

	int next_pop = 0;

	while (tmp> 0) {
		if ((tmp % 2) == 1) { t += "1"; next_pop++; }
		else { t += "0"; }
		tmp /= 2;
	}
	reverse(t.begin(), t.end());

	//cout << "t= " << t << endl;

	return make_pair(t,next_pop);*/
}

int N;
string X;

int c[200005];

int g(int t) {
	if (c[t] >= 0) { return c[t]; }

	int tmp = t;
	int pcnt = 0;
	while (tmp > 0) {
		if ((tmp % 2 )== 1) { pcnt++; }
		tmp /= 2;
	}

	c[t] = g(t%pcnt)+1;

	return c[t];
}

int ans[200005];

int main(void) {

	cin >> N >> X;


	for (int i = 1; i <= N; i++) { c[i] = -1; }

	string s = X;
	int cnt = 0;

	pair<string, int> p;

	int m = popcount(s);

	int tmp = 0;
	for (int i = 0; i < N; i++) {
		tmp *= 2;
		if (X[i] == '1') { tmp++; }
		tmp %= (m + 1);
	}

	

	int num = 1;
	for (int i = N-1; i >=0; i--) {
		num %= (m + 1);


		if (s[i] == '0') {
			//cout << "num= " << num << endl;
			//cout <<"i= " <<i<<" "<< (tmp + num) % (m + 1) << endl;
			ans[i] = g((tmp + num) % (m + 1)) + 1;
		}
		num *= 2;
	}
	//=============================
	num = 1;

	if (m - 1 > 0) {
		tmp = 0;
		for (int i = 0; i < N; i++) {
			tmp *= 2;
			if (X[i] == '1') { tmp++; }
			tmp %= (m - 1);
		}


		for (int i = N-1; i >=0; i--) {
			num %= (m - 1);

			if (s[i] == '1') {
				//
				ans[i] = g((tmp - (num)+(m - 1)) % (m - 1)) + 1;
			}
			num *= 2;
		}
	}

	for (int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
	
	/*for (int i = 0; i < N; i++) {
		int pop_cnt;
		s = X;
		if (s[i] == '0') { s[i] = '1'; pop_cnt = m + 1; }
		else { s[i] = '0'; pop_cnt = m - 1; }


		if (pop_cnt == 0) { cout << 0 << endl; continue; }

		int cnt = 0; 
		int ret= f(s, pop_cnt); cnt++;

		//cout << "ret=" << ret << endl;

		cout << g(ret) + 1 << endl;
		
	}*/

	return 0;
}

Measured memory_bytes: 5256
/*
uchiyan ni gallan
*/

#include<bits/stdc++.h>
#define mod 1000000007
#define pp pair<long long,long long>
#define ll long long
#define ff first
#define ss second
#define horse_power ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int n;
 vector<double> p(3001);
 double dp[3001][3001];
void solve(){
 cin>>n;
 for(int i=1;i<=n;i++){
    cin>>p[i];
 }
 memset(dp,0,sizeof(dp));
 dp[1][1]=p[1];
 dp[1][0]=1-p[1];
 for(int i=2;i<=n;i++){
    for(int head=0;head<=n;head++){
        dp[i][head]=dp[i-1][head]*(1-p[i]);
        if(head-1>=0)
        dp[i][head]=dp[i][head]+p[i]*dp[i-1][head-1];
    }
 }
 double ans=0;
 for(int i=n/2+1;i<=n;i++){
    ans=ans+dp[n][i];
 }
 cout<<fixed<<setprecision(9)<<ans<<"\n";


}

int main(){
horse_power
int t=1;
//cin>>t;
while(t--){
solve();
}


}


Measured memory_bytes: 70656
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();

		}

      	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];

			
			//答えの出力
			Console.WriteLine(3*N*N);


		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 28224
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,cnt=0,ans=0,x[1005]={},y[1005]={},z[1005]={};
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  for(int i=0; i<(1<<3); i++) {
    ll a[1005]={};
    for(int j=0; j<n; j++) {
      a[j]=x[j]*(i&1?1:-1)+y[j]*(i&2?1:-1)+z[j]*(i&4?1:-1);
    }
    sort(a,a+n,greater<ll>());
    cnt=0;
    for(int j=0; j<m; j++) {
      cnt+=a[j];
    }
    ans=max(ans,cnt);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()

    val M = 100000000L
    val xu = Array(n) { (sc.nextDouble() * M).toLong() to sc.next() }

    val sum = xu
        .map { if (it.second == "JPY") it.first else it.first * 380000 }
        .sum()
        .toDouble()
        .div(M)

    println(String.format("%.6f", sum))
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    ll n; cin >> n;
    vector<string> s(n);
    ll m=0,a=0,r=0,c=0,h=0;
    rep(i, n) {
        cin >> s[i];
        switch (s[i][0]) {
            case 'M':
                m++;
                break;
            case 'A':
                a++;
                break;
            case 'R':
                r++;
                break;
            case 'C':
                c++;
                break;
            case 'H':
                h++;
                break;
            default:
                break;
        }
    }


    ll ans = 0;
    ans += m*a*r;
    ans += m*a*c;
    ans += m*a*h;
    ans += m*r*c;
    ans += m*r*h;
    ans += m*c*h;
    ans += a*r*c;
    ans += a*r*h;
    ans += a*c*h;
    ans += r*c*h;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 6144
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.function.Predicate;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();
			int n = Integer.parseInt(data);

			List<String> list = new ArrayList<String>();
			for (int i = 0; i < n; i++) {
				String data2 = scanner.nextLine();
				list.add(data2);
			}

			System.out.println(String.format("AC x %d", count(list, "AC")));
			System.out.println(String.format("WA x %d", count(list, "WA")));
			System.out.println(String.format("TLE x %d", count(list, "TLE")));
			System.out.println(String.format("RE x %d", count(list, "RE")));
		}
	}

	private static long count(List<String> list, String str) {
		return list.stream().filter(new Predicate<String>() {
			@Override
			public boolean test(String t) {
				return t.equals(str);
			}
		}).count();
	}
}


Measured memory_bytes: 65976
from collections import deque
K = int(input())
q = deque([i for i in range(1, 10)])
cnt = 1
while q:
  n = q.popleft()
  if cnt == K:
    print(n)
    exit()
  if n % 10  != 0:
    q.append(10 * n + n % 10 - 1)
  q.append(10 * n + n % 10)
  if n % 10 != 9:
    q.append(10 * n + n % 10 + 1)
  cnt += 1

Measured memory_bytes: 11908
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define RPA(i,s,e) for(int i=s; i<=e; i++)
#define RPD(i,s,e) for(int i=s; i>=e; i--)
#define PB(a) push_back(a)
#define MP(i,s) make_pair(i,s)
#define ALL(a) (a).begin(), (a).end()
#define PRT(a) cout << (a) << endl

typedef pair<int,int> P;

const int INF = 1000000009;
const int MAX_V = 101;
struct edge { int to, cost; };
vector<edge> G[MAX_V];

int N,K,L;
int f,t,c;
int dist[MAX_V];

void add_edge(int from, int to, int cost) {
	edge e1 = { to, cost };
	edge e2 = { from, cost };
	G[from].PB(e1);
	G[to].PB(e2);
}

int dijkstra(int from, int to) {
	fill(dist, dist+MAX_V, INF);
	priority_queue<P, vector<P>, greater<P> > que;
	dist[from] = 0;
	que.push(MP(0, from));
	while(!que.empty()) {
		P p = que.top();
		que.pop();

		int v = p.second;
		if(dist[v] < p.first) continue;

		REP(i,G[v].size()) {
			edge& e = G[v][i];
			if(dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				que.push(MP(dist[e.to], e.to));
			}
		}
	}

	return dist[to] == INF ? -1 : dist[to];
}

void coding() {
	while(scanf("%d%d", &N, &K) != EOF) {
		REP(i,N) G[i].clear();
		REP(i,K) {
			scanf("%d", &L);
			if(L == 0) {
				scanf("%d%d", &f, &t);
				f--; t--;
				printf("%d\n", dijkstra(f, t));
			} else if(L == 1) {
				scanf("%d%d%d", &f, &t, &c);
				f--; t--;
				add_edge(f, t, c);
			} else {
				PRT("unknown");
			}
		}
	}
}

// #define _LOCAL_TEST

int main() {
#ifdef _LOCAL_TEST
	clock_t startTime = clock();
	freopen("a.in", "r", stdin);
#endif

	coding();

#ifdef _LOCAL_TEST
	clock_t elapsedTime = clock() - startTime;
	cout << endl;
	cout << (elapsedTime / 1000.0) << " sec elapsed." << endl;
	cout << "This is local test" << endl;
	cout << "Do not forget to comment out _LOCAL_TEST" << endl << endl;
#endif
}

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

int main(){
    ll n,k; cin >> n >> k;
    vector<pair<int,int>> a(n);
    for(int ix=0;ix<n;ix++){
        int x,y;
        cin >> x >> y;
        a.at(ix) = make_pair(x,y);
    }
    sort(a.begin(),a.end());
    ll cnt=0,ans = -1;
    int i=0;
    while(1){
        cnt += a.at(i).second;
        if(cnt >= k){
            ans = a.at(i).first;
            break;
        }
        i++;
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  for(int i=0;i<s.size();i++){
    s[i]=(s[i]-'A'+n)%26+'A';
    cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define inf (int)(1e9)
#define queue_valtype pos

typedef struct {
	int x;
	int y;
	int val;
}pos;

typedef struct q_node_sub{
	queue_valtype data;
	struct q_node_sub *next;
}q_node;

typedef struct {
	q_node *fst;
	q_node *last;
	int num;
}queue;

queue *make_queue(){
	queue *q = (queue *)malloc(sizeof(queue));
	q->fst = NULL;
	q->last = NULL;
	q->num = 0;
	return q;
}

int element_num_q(queue *q){
	return q->num;
}

void add_data_q(queue_valtype val, queue *q){
	q_node *last = (q_node *)malloc(sizeof(q_node));
	last->data = val;
	last->next = NULL;
	if(element_num_q(q) == 0){
		q->fst = last;
	}
	else{
		q->last->next = last;
	}
	q->last = last;
	q->num++;
}

queue_valtype take_data_q(queue *q){
	if(q->num == 0){
		printf("no data in the queue\n");
	}
	queue_valtype ans = q->fst->data;
	q_node *fst = q->fst;
	if(q->num == 1){
		q->fst = NULL;
		q->last = NULL;
	}
	else{
		q->fst = fst->next;
	}
	free(fst);
	q->num--;
	return ans;
}

queue_valtype look_data_q(queue *q){
	if(q->num == 0){
		printf("no data in the queue\n");
	}
	else{
		return q->fst->data;
	}
}

int main(){
	int H, W, i, j, k, val, W_num = 0;
	scanf("%d%d", &H, &W);
	char **s = (char **)malloc(sizeof(char *) * (H + 2));
	int **a = (int **)malloc(sizeof(int *) * (H + 2));
	for(i = 0; i <= H + 1; i++){
		s[i] = (char *)malloc(sizeof(char) * (W + 2));
		a[i] = (int *)malloc(sizeof(int) * (W + 2));
		if(0 < i && i <= H){
			s[i][0] = '#';
			scanf("%s", &s[i][1]);
			s[i][W + 1] = '#';
		}
		else{
			for(j = 0; j <= W + 1; j++){
				s[i][j] = '#';
			}
		}
		for(j = 0; j <= W + 1; j++){
			if(s[i][j] == '.'){
				W_num++;
			}
			a[i][j] = inf;
		}
	}
	pos p;
	p.x = 1;
	p.y = 1;
	p.val = 0;
	queue *q = make_queue();
	add_data_q(p, q);
	int bx[4] = {0, 1, 0, -1};
	int by[4] = {1, 0, -1, 0};
	while(element_num_q(q) > 0){
		p = take_data_q(q);
		i = p.x;
		j = p.y;
		val = p.val;
		if(s[i][j] == '.' && a[i][j] > val){
			a[i][j] = val;
			for(k = 0; k < 4; k++){
				p.x = i + bx[k];
				p.y = j + by[k];
				p.val = val + 1;
				add_data_q(p, q);
			}
		}
	}
	if(a[H][W] == inf){
		printf("-1\n");
	}
	else{
		printf("%d\n", W_num - a[H][W] - 1);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
 
        List<Limit> limitList = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            limitList.add(new Limit(sc.nextInt(), sc.nextInt()));
        }
        Collections.sort(limitList, Comparator.comparingInt(limit -> limit.upper));
 
        int numDestroyedBridges = 0;
        int lastDestroyedBridge = 0;
        for (Limit l : limitList) {
            if (l.lower > lastDestroyedBridge) {
                lastDestroyedBridge = l.upper - 1;
                numDestroyedBridges++;
                //System.out.println("lastDestroyedBridge" + lastDestroyedBridge);
            }
        }
        System.out.println(numDestroyedBridges);
    }
}
 
class Limit {
    int lower;
    int upper;
    Limit(int lower, int upper) {
        this.lower = lower;
        this.upper = upper;
    }
 
    @Override
    public String toString() {
        return "(" + lower + ", " + upper + ")";
    }
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

LL pow2(LL K){
  LL a = 1;
  REP(i, K)
  {
    a *= 2;
  }
  return a;
}

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

  LL M ,K;
  cin >> M >> K;

  if(K==0){
    REP(i,pow2(M)){
      if(i!=0){
        cout << " ";
      }
      cout << i SP i;
    }
    cout << endl;
  }else
  if(K<pow2(M)&&M%2==0){
    cout << 0 << " ";
    REP(i,pow2(M)){
      if(i!=0&&i!=K){
        cout << i << " ";
      }
    }
    cout << 0 << " ";
    cout << K << " ";
    REP(j,pow2(M)){
      LL i = pow2(M) - j-1;
      if (i != 0 && i != K)
      {
        cout << i << " ";
      }
    }
    cout << K << endl;
  }else
  if(K<pow2(M)&&M%2!=0&&(M!=1)){
    if((K==pow2(M)-1)){
      cout << 0 << " ";
      REP(i,pow2(M)){
        if(i!=0&&i!=K){
          cout << i << " ";
        }
      }
      cout << 0 << " ";
      cout << K << " ";
      REP(j,pow2(M)){
        LL i = pow2(M) - j-1;
        if (i != 0 && i != K)
        {
          cout << i << " ";
        }
      }
      cout << K << endl;
    }else{
      LL KK = pow2(M)-K-1;
      cout << 0 << " ";
      REP(i,pow2(M)-1){
        if(i!=0&&i!=KK){
          cout << i << " ";
        }
      }
      cout << 0 << " ";
      cout << pow2(M)-1<<" ";
      cout << KK << " ";
      REP(j,pow2(M)-1){
        LL i = pow2(M) - j-2;
        if (i != 0 && i != KK)
        {
          cout << i << " ";
        }
      }
      cout << KK<<" ";
      cout << pow2(M)-1<<endl;
    }
  }
  else
  {
    cout << -1 << endl;
  }
}

// ->001
//
// 000
// ~~
// 000
// k
// 110
// ~~
// 110
// l


// 000
// 001
// 010
// 011
// 100
// 101
// 110
// 000
// 111
// 000
// 001
// 010
// 011
// 100
// 101
// 110
// 111



Measured memory_bytes: 1792
from math import log10 as log2

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

mod = 10 ** 9 + 7

p = []
m = []
for a in A :
  if a > 0 :
    p.append(a)
  elif a < 0 :
    m.append(-a)
    
p.sort(reverse=True)
m.sort(reverse=True)
pl = [0]
ml = [0]

for i in range(len(p)) :
  pl.append(log2(p[i]))
for i in range(len(m)) :
  ml.append(log2(m[i]))
for i in range(1, len(pl)) :
  pl[i] += pl[i - 1]
for i in range(1, len(ml)) :
  ml[i] += ml[i - 1]

Mi = -1
Mv = 0
for i in range(0, len(ml), 2) :
  j = K - i
  if len(pl) <= j or j < 0 : continue
  if ml[i] + pl[j] > Mv :
    Mi, Mv = i, ml[i] + pl[j]

if Mi != -1 :
  ret = 1
  for i in range(K - Mi) :
    ret *= p[i]
    ret %= mod
  for i in range(Mi) :
    ret *= m[i]
    ret %= mod
else :
  x = [abs(a) for a in A]
  x.sort()
  ret = 1
  for i in range(K) :
    ret *= x[i]
    ret %= mod
  ret = -ret % mod
  
print(ret)

Measured memory_bytes: 132936
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S[3];
	in >> S[0] >> S[1] >> S[2];

	int turn = 0;
	char strs[] = { 'A','B','C' };
	while (true)
	{
		if (S[turn].length() == 0)
		{
			out << strs[turn] << std::endl;
			return 0;
		}
		int next;
		if (S[turn][0] == 'a') next = 0;
		if (S[turn][0] == 'b') next = 1;
		if (S[turn][0] == 'c') next = 2;
		S[turn].erase(S[turn].begin());
		turn = next;
	}
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

boxes = [0]*N
for i in range(N)[::-1]:
  s = sum(boxes[i::i+1])
  if s % 2 != A[i]:
    boxes[i] = 1

M = sum(boxes)
print(M)
if M != 0:
  print(*[i + 1 for i, j in enumerate(boxes) if j == 1])

Measured memory_bytes: 13108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,H; cin>>N>>H;
    priority_queue<int> A;
    vector<int> B(N);
    rep(n,0,N){
        int a,b; cin>>a>>b;
        A.push(a);
        B.at(n)=b;
    }

    sort(ToEnd(B));
    int64_t ans=0;
    _rep(i,N-1,0){
        if(B.at(i)>A.top()){
            H-=B.at(i);
            ans++;
            if(H<=0) break;
        }else{
            break;
        }
    }

    if(H>0) ans+=ceil((double)H/A.top());
    cout<<ans<<endl;
}

Measured memory_bytes: 1276
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 998244353
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N,K;
    cin >> N >> K;
    int ans=1;
    rep(i,N) ans=min(ans*2,ans+K);
    cout << ans << endl;
}


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

int minX[26], maxX[26], minY[26], maxY[26];
bool has[26];

int main() {
	ios::sync_with_stdio(false);
	int t, H, W;
	cin >> t;
	while (t--) {
		for (int i=0; i<26; ++i) {
			minX[i] = minY[i] = 51;
			maxX[i] = maxY[i] = -1;
			has[i] = false;
		}
		cin >> H >> W;
		vector<string> img(H, "");
		for (int i=0; i<H; ++i) {
			cin >> img[i];
			for (int j=0; j<W; ++j) {
				char c = img[i][j];
				if (c != '.') {
					minX[c - 'A'] = min(minX[c - 'A'], j);
					maxX[c - 'A'] = max(maxX[c - 'A'], j);
					minY[c - 'A'] = min(minY[c - 'A'], i);
					maxY[c - 'A'] = max(maxY[c - 'A'], i);
					has[c - 'A'] = true;
				}
			}
		}
		int k = 0;
		while (k <= 26) {
			if (has[k]) {
				bool ok = true;
				for (int i=minY[k]; i<=maxY[k] && ok; ++i) {
					for (int j=minX[k]; j<=maxX[k] && ok; ++j) {
						if (img[i][j] - 'A' != k && img[i][j] != '#') {
							ok = false;
						}
					}
				}
				if (ok) {
					for (int i=minY[k]; i<=maxY[k]; ++i) {
						for (int j=minX[k]; j<=maxX[k]; ++j) {
							img[i][j] = '#';
						}
					}
					has[k] = false;
					k = 0;
					continue;
				}
			}
			++ k;
		}
		bool safe = true;
		for (int i=0; i<26; ++i) {
			if (has[i]) {
				safe = false;
				break;
			}
		}
		cout << (safe ? "SAFE" : "SUSPICIOUS") << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

const int N = 100005, INF = 1E9 + 7;

int n, ans = 0;
multiset<int> le, ri;
pair<int, int> a[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].fi >> a[i].se;
        le.insert(a[i].fi);
        ri.insert(a[i].se);
    }
    for (int i = 1; i <= n; i++) {
        le.erase(le.find(a[i].fi));
        ri.erase(ri.find(a[i].se));
        ans = max(ans, a[i].se - a[i].fi + max(*ri.begin() - *prev(le.end()), -1) + 2);
        le.insert(a[i].fi);
        ri.insert(a[i].se);
    }
    sort(a + 1, a + n + 1);
    int l = 0, r = INF;
    for (int i = 1; i < n; i++) {
        l = max(l, a[i].fi); r = min(r, a[i].se);
        le.erase(le.find(a[i].fi));
        ri.erase(ri.find(a[i].se));
        ans = max(ans, max(r - l, -1) + max(*ri.begin() - *prev(le.end()), -1) + 2);
    }
    cout << ans;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, ans, cnt, t;
unordered_set<int> st;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        if (st.count(t)) {
            st.erase(t);
            --cnt;
        } else {
            st.insert(t);
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<sstream>
#include<iostream>
#define ll long long 
#define ld long double
#define rep(i,n) for(i=0;i<n;i++)
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL) 
using namespace std;
int main()
{
	fastio;
	int a,b;
    cin>>a>>b;
    if (b>=a)
        cout<<"0"<<endl;
    else
    {
        if (a-2*b>0)
            cout<<a-2*b<<endl;
        else 
            cout<<"0"<<endl;
    }	
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint N,K;
  cin>>N>>K;
  lint p[N];
  REP(i,N)cin>>p[i];
  lint temp=0;
  REP(i,K)temp+=p[i];
  lint ans=temp;
  REP(i,N-K){
    temp-=p[i];
    temp+=p[K+i];
    ans=max(ans,temp);
  }
  cout<<(ans+K)/(lint)2<<((ans+K)%2==1?".5":"")<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( true ) {
	    final int size = Integer.parseInt( stdin.nextLine() );

	    if ( size == 0 ) {
		break;
	    }

	    final char[][] map = new char[size][];
	    
	    for ( int i = 0; i < size; i++ ) {
		map[i] = stdin.nextLine().toCharArray(); 
	    }

	    final int[][] acCol = new int[size][size];
	    for ( int r = 0; r < size; r++ ) {
		acCol[0][r] = ( map[0][r] == '.' ) ? 1 : 0;
		for ( int c = 1; c < size; c++ ) {
		    if ( map[c][r] == '.' ) {
			acCol[c][r] = acCol[c - 1][r] + 1;
		    } else {
			acCol[c][r] = 0;	
		    }
		}
	    }

	    final int[][] acRow = new int[size][size];
	    for ( int c = 0; c < size; c++ ) {
		acRow[c][0] = ( map[c][0] == '.' ) ? 1 : 0;
		for ( int r = 1; r < size; r++ ) {
		    if ( map[c][r] == '.' ) {
			acRow[c][r] = acRow[c][r - 1] + 1;
		    } else {
			acRow[c][r] = 0;	
		    }
		}
	    }

	    final int[][] ans = new int[size][size];
	    for ( int i = 0; i < size; i++ ) {
		ans[i][0] = ( map[i][0] == '.' ? 1 : 0 );
		ans[0][i] = ( map[0][i] == '.' ? 1 : 0 );
	    }
	    
	    int maxSize = 0;
	    for ( int c = 1; c < size; c++ ) {
		for ( int r = 1; r < size; r++ ) {
		    if ( map[c][r] == '*' ) {
			ans[c][r] = 0;
		    } else {
			if ( acRow[c][r] > ans[c - 1][r - 1] + 1 && acCol[c][r] > ans[c - 1][r - 1] + 1 ) {
			    ans[c][r] = ans[c - 1][r - 1] + 1;
			} else {
			    ans[c][r] = Math.min( acRow[c][r], acCol[c][r] );
			}
			maxSize = Math.max( maxSize, ans[c][r] );
		    }
		}
	    }
	    System.out.println( maxSize );
	}
    }
}

Measured memory_bytes: 64868
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  long ans = 0;
  for(int i=0; i<n; i++){
    long tmp;  scanf("%ld", &tmp);
	ans += (tmp-1);
  }
  printf("%ld\n", ans);
  return 0;
}

Measured memory_bytes: 128