akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=1000003;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}
template<class T,class L>ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}

int main(){
  vector<ll> p(3);
  cin>>p[0]>>p[1]>>p[2];
  sort(range(p));
  ll a=p[0];
  p[0]=LINF;
  sort(range(p));
  a+=p[0];
  cout<<a;
}

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

int main() {
  int N, n;
  n = 0;
  string S;
  cin >> N >> S;
  for(int i = 0; i < N - 1; i++) {
    if(S.at(i) != S.at(i + 1)) n++;
  }
  cout << n + 1 << endl;
}

Measured memory_bytes: 512
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    A, B = map(int, input().split())
    logging.info("Hello!")

    if (abs(A) + abs(B)) % 2 == 0:
        print(int((A + B) / 2))
    else:
        print("IMPOSSIBLE")
        
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
ll factorial(int x){
  ll res = 1;
  while(x>0){
    res *= x;
    x--;
    res %= 1000000007;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  if(abs(n-m)>1) cout << 0 << endl;
  else{
    if((n+m)%2==0){
      cout << ((ll)factorial(n)*factorial(m)*2)%1000000007 << endl;
    }
    else cout << ((ll)factorial(n)*factorial(m))%1000000007 << endl;
  }
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<int > A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    bitset<24> B(0);
    long long sum = 0;
    long long ans = 0;

    int right = 0;
    for (int left = 0; left < N; left++) {
        if (right <= left) right = left;
        while (right < N && (sum + A[right]) == (B ^ (bitset<24>(A[right]))).to_ullong()) {
            sum += A[right];
            B ^= bitset<24>(A[right]);
            right++;
        }
        ans += (right - left);
        sum -= A[left];
        B ^= A[left];
    }

    cout << ans << endl;

    return 0;
}














































Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

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

    int N, K;
    
    cin >> N >> K;

    vector<long long> h(N);

    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    
    sort(h.begin(), h.end());

    vector<long long> sub_tree(N-K+1);

    for(int i = 0; i < (N-K+1); i++){
        sub_tree[i] = h[i+K-1] - h[i];
    }

    long long ans;

    ans = *min_element(sub_tree.begin(), sub_tree.end());

    cout << ans << endl;

    return 0;
}


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

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

const long long MOD = 1000000007;
vector<set<int>> tre(2*1e5);
vector<ll> pt(2*1e5,0);

void tr(int x,int y){
  if(x!=0) pt.at(x)+=pt.at(y);
  for(auto i:tre.at(x)){
    if(i!=y) tr(i,x);
  }
  return;
}
  

int main(){
  int n,q,a,b;
  cin >> n >> q;
  rep(i,n-1){
    cin >> a >> b;
    a--;b--;
    tre.at(a).insert(b);
    tre.at(b).insert(a);
  }
  int p;
  rep(i,q){
    cin >> a >> p;
    a--;
    pt.at(a) += p;
  }
  tr(0,0);
  rep(i,n)  cout << pt.at(i) << " ";
  cout << endl;
  
}


Measured memory_bytes: 41472
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <string>
#include <sstream>
//#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
/*struct shi
{
    int x;
    int T;
} s[100000];
int cmp(shi a,shi b)
{
    return a.x<b.x;
}
long long cmd(long long a, long long  b)
{
    return a > b;
}*/
/*typedef struct node {
    string name;
    int score;
    //struct node *next;

}student[1000000];
/*student * creatlist(int b){
    student *head = new student;
    student *pre = head;
    for(int i=1;i<=b;i++){
        student *p = new student ;
        p->num = i;
        pre->next = p;
        pre = p;
        p->next = NULL;
    }
    pre->next = head->next;//quan
    return head;

};*/
/*void kill(struct node *head){
    student *p ;
    p = head->next;
    do{
        for(int i=1;i<=4;i++){
            head = head->next;
            //sum++;
        }
            //return;
        p=head->next;
        head->next = head->next->next;
       // p=head;
        sum++;
        //cout<<p->num;
    }while(p->num!=1);
    //cout<<p->num<<endl;
    cout<<sum<<endl;
}*/

int main()
{
    int a,t,c,flag=0;
    cin>>a >>t ;
    vector<int> hh;
    for(int i=0;i<a;i++){
        int h;
        cin >>h;
        hh.push_back(h);
    }
    long long sum=0;
    for(int i=0;i<hh.size();i++){
        if(i!=hh.size()-1&&hh[i+1]-hh[i]>=t)
        sum+=t;
        else if(i!=hh.size()-1&&hh[i+1]-hh[i]<t)
            sum+=hh[i+1]-hh[i];
    }
    sum+=t;
    cout<<sum<<endl;

    return 0;

}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int a, b, c;
        cin >> a>> b>> c;
        cout << min(a + b, min(b + c, (a + c)));
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

ll dp[105][2][5];

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

    string s;
    int K;
    cin >> s >> K;
    int n = s.length();
    dp[0][0][0] = 1;
    for(int i = 0; i < n; ++i){
        int num = s[i] - '0';
        for(int j = 0; j < 2; ++j){
            for(int k = 0; k <= K; ++k){
                if(!dp[i][j][k])    continue;
                for(int x = 0; x <= (j ? 9 : num); ++x){
                    dp[i + 1][j | (x < num)][k + (x != 0)] += dp[i][j][k]; 
                }
            }
        }
    }
    int ans = dp[n][0][K] + dp[n][1][K];
    cout << ans << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
ng=0
ok=10**10
while ok-ng>1:
  m=(ok+ng)//2
  c=0
  for i in a:
    c+=(i//m-(i%m==0))
  if c<=k:
    ok=m
  else:
    ng=m
print(ok)

Measured memory_bytes: 30788
//Code by Enderturtle
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define repe(i,a) for(register int i=head[a];i;i=e[i].nxt)
#define il inline
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
typedef long long ll;
using namespace std;
il void filejudge(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
il int read(){
	int x=0;bool f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=0;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}
/*----- head end -----*/
const int N=100100;
int n,a[N<<1],ans;
il bool check(int mid){
	rep(i,0,n-2){
		if(((a[n+i]<=mid) && (a[n+i+1]<=mid)) || ((a[n-i]<=mid) && (a[n-i-1]<=mid))) return 1;
		if(((a[n+i]>mid) && (a[n+i+1]>mid)) || ((a[n-i]>mid) && (a[n-i-1]>mid))) return 0;
	}
	return (a[1]<=mid);
}
int main(){
	n=read();rep(i,1,2*n-1) a[i]=read();
	int l=1,r=2*n-1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int n,k,q;cin>>n>>k>>q;
  vector<int>p(n, k-q);
  int a;
  for(int i=0; i<q; i++){
    cin >> a;
    p[a-1]++;
  }
  int ans = 0;
  for(int i=0; i<n; i++){
    if(p[i]>0)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

int N, K;
vector<int>v;
int cum[101];
signed main() {
	cin >> N >> K;
	v.resize(N);
	cum[0] = 0;
	REP(i, N) {
		cin >> v[i];
		cum[i + 1] = cum[i] + v[i];
	}
	//詰める回数Xを固定
	int ans = -INF;
	REP(X, K / 2+1) {
		//とる回数cntを固定
		FOR(cnt,X, min(N+1,K - X + 1)) {
			//左からl個とる
			REP(l, cnt + 1) {
				int r = cnt - l;//右からr個取る
				int res = 0;
				vector<int>v2;
				REP(i, l) {
					res += v[i];
					v2.pb(v[i]);
				}
				REP(i, r) {
					res += v[N - 1 - i];
					v2.pb(v[N - 1 - i]);
				}
				VSORT(v2);
				REP(i, X) {
					res -= v2[i];
				}
				ans = max(ans, res);
			}
		}
	}
	print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Os")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll maxn=2e5+10, maxm=3e3+10, lg=7, mod=1e9+7, inf=1e18;

int n,m,a[maxn],x,y,cnt[maxn],line[maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>m;
	int emp=n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		int p=a[i]-cnt[a[i]]++;
		emp-=(p>0 && !line[p]++);
	}
	while(m--){
		cin>>x>>y;
		int p=a[x]-cnt[a[x]]--+1;
		emp+=(p>0 && !--line[p]);
		a[x]=y;
		int q=a[x]-cnt[a[x]]++;
		emp-=(q>0 && !line[q]++);
		cout<<emp<<'\n';
	}
	
	return 0;
}


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

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

bool f(ll a, ll b, ll c, ll d) {
  if (a < 0) {
    return false;
  }
  if (d < b) {
    return false;
  }
  ll k = gcd(b, d);
  ll x = a <= c ? a + ((c - a) / k + 1) * k : c + (a - c - 1) % k + 1;
  // cerr << "k = " << k << ", x = " << x << endl;
  return x - b >= 0;
}

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (f(a - b, b, c, d) ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;

namespace A_Fifty_Fifty
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
            {
                Console.WriteLine ("Yes");
            }
            else if (s[0] == s[2] && s[0] != s[1] && s[1] == s[3])
            {
                Console.WriteLine ("Yes");
            }
            else if (s[0] == s[3] && s[0] != s[1] && s[1] == s[2])
            {
                Console.WriteLine ("Yes");
            }
            else
            {
                Console.WriteLine ("No");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"

string s;

bool read() {
	if  (!getline(cin, s)) {
		return 0;
	}
	return 1;
}

vi a;
int n;

bool can(int k) {
	forn(i, k - 1) {
		if  (a[i] && i + k >= n) {
			return 0;
		}
	}
	return 1;
}

int solve() {
	n = sz(s);
	a.resize(n);
	forn(i, n - 1) {
		a[i] = s[i] != s[i + 1];
	}
	a[n - 1] = s[n - 1] != '0';

	int L = 1;
	int R = n + 1;
	while (L != R - 1) {
		int M = (L + R) >> 1;
		if  (can(M)) {
			L = M;
		} else {
			R = M;
		}
	}
	return L;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		printf("%d\n", solve());
	}

#ifdef LOCAL
	eprintf("Time: %.10f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
vector<int>g[110000];
int bfs[110000];
int pr[110000];
int lis[110000];
int o[110000];
int ans[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	for(int i=0;i<a;i++)bfs[i]=-1;
	bfs[0]=0;
	queue<int>Q;
	Q.push(0);
	while(Q.size()){
		int at=Q.front();Q.pop();
		for(int i=0;i<g[at].size();i++){
			if(bfs[g[at][i]]==-1){
				bfs[g[at][i]]=bfs[at]+1;
				Q.push(g[at][i]);
			}
		}
	}
	int at=0;
	for(int i=0;i<a;i++){
		if(bfs[at]<bfs[i])at=i;
	}
	for(int i=0;i<a;i++)bfs[i]=-1;
	bfs[at]=0;
	Q.push(at);
	while(Q.size()){
		int at=Q.front();Q.pop();
		for(int i=0;i<g[at].size();i++){
			if(bfs[g[at][i]]==-1){
				bfs[g[at][i]]=bfs[at]+1;
				pr[g[at][i]]=at;
				Q.push(g[at][i]);
			}
		}
	}
	int to=0;
	for(int i=0;i<a;i++){
		if(bfs[to]<bfs[i])to=i;
	}
	int sz=bfs[to];
	int now=to;
	lis[0]=now;
	for(int i=0;i<sz;i++){
		now=pr[now];
		lis[i+1]=now;
	}
	sz++;
	int cur=sz;
//	printf("%d\n",sz);
	for(int i=1;i<sz-1;i++){
		o[i]=g[lis[i]].size()-2;
		cur+=o[i];
	//	printf("%d\n",o[i]);
	}

	if(a!=cur){
		printf("-1\n");return 0;
	}
	bool ba=false;
	for(int i=0;i<sz;i++){
		if(o[i]!=o[sz-1-i]){
			if(o[i]>o[sz-1-i]){
				ba=true;
			}
			break;
		}
	}
	if(ba)reverse(o,o+sz);
	int ind=0;
	for(int i=0;i<sz;i++){
		ans[ind+o[i]]=ind;
		ind++;
		for(int j=0;j<o[i];j++){
			ans[ind-1]=ind;
			ind++;
		}
	}
	for(int i=0;i<a;i++){
		if(i)printf(" ");
		printf("%d",ans[i]+1);
	}printf("\n");
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> ab(n,{0,0});
  rep(i,n){
    int a,b;
    cin >> a >> b;
    ab[i].first = a;
    ab[i].second =b;
  }
  sort(all(ab));
  ll cash = 0;
  int dri = 0;
  for(int i=0;dri < m;i++){
    ll var = min(ab[i].second,m-dri);
    dri+=var;
    cash += var*ab[i].first; 
  }
  cout << cash << endl;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[2][1010];
ll a[2][1010],b[2][1010];
int main(){
	ll n,m,k;	cin>>n>>m>>k;
	vector<ll> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<m;j++){
			dp[i][j]=LLONG_MAX;
			a[i][j]=INT_MIN;	b[i][j]=INT_MAX;
		}
	}
	dp[0][0]=k;	a[0][0]=b[0][0]=v[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<m;j++){
			if(dp[0][j]==LLONG_MAX)	continue;
			//その箱に追加する場合
			if(j+1<m){
				dp[1][j+1]=dp[0][j];
				a[1][j+1]=max((ll)a[0][j],v[i]);
				b[1][j+1]=min((ll)b[0][j],v[i]);
			}
			//新しく箱を作る場合
			ll num=k+dp[0][j];
			num+=(a[0][j]-b[0][j])*(j+1);
			dp[1][0]=min(dp[1][0],num);
			a[1][0]=b[1][0]=v[i];
		}
		for(int j=0;j<m;j++){
			dp[0][j]=dp[1][j];	dp[1][j]=LLONG_MAX;
			a[0][j]=a[1][j];	a[1][j]=INT_MIN;
			b[0][j]=b[1][j];	b[1][j]=INT_MAX;
		}
	}
	ll ans=LLONG_MAX;
	for(int i=0;i<m;i++){
		ll num=dp[0][i];
		num+=(a[0][i]-b[0][i])*(i+1);
		ans=min(ans,num);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <set>
#include <queue>

using namespace std;

int main(){
	int n;
	string commond, word;
	set<string> dictionary;
	queue<string> result;

	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> commond;
		if(commond == "insert"){
			cin >> word;
			dictionary.insert(word);
		}
		else{
			cin >> word;
			if(dictionary.count(word)){
				result.push("yes");
			}
			else{
				result.push("no");
			}
		}
	}
	while(!result.empty()){
		cout << result.front() << endl;
		result.pop();
	}

    return 0;
}


Measured memory_bytes: 56192
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;

    vi v(n);
    for(int &x:v) cin>>x;
        sort(all(v));

    double curr = (double)(v[0] + v[1])/2;
    for(int i=2;i<n;i++){
        curr = (double)(curr + v[i])/2; 
    }

    cout<<setprecision(10)<<fixed<<curr;
} 

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

int weight[110];
int value[110];
// dp := i番目までから重さjを超えないように選んだ時の価値の最大値
int dp[110][10010];

int main(){
	int n, w;
	scanf("%d%d", &n, &w);
	for(int i=0; i < n; i++) {
		scanf("%d%d", value+i, weight+i);
	}

	// 貰うDP
	// for(int i=0; i < n; i++) {
	// 	for(int j=0; j + weight[i] <= w; j++) {
	// 		dp[i+1][j+weight[i]] = max(dp[i][j+weight[i]], dp[i][j] + value[i]);
	// 	}
	// }

	// 配るDP
	for(int i=0; i < n; i++) {
		for(int j=0; j <= w; j++) {
			if(j >= weight[i]) dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]] + value[i]);
			else dp[i+1][j] = dp[i][j];
		}
	}
	printf("%d\n", dp[n][w]);
}



Measured memory_bytes: 7116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string sa,sb,sc;cin >> sa >> sb >> sc;
	char turn='a';
	char ans;
	while(true){
		if(turn=='a'){
			if(sa.size()==0){
				ans='A';
				break;
			}
			turn=sa.at(0);
			sa=sa.substr(1,sa.size());
		}
		if(turn=='b'){
			if(sb.size()==0){
				ans='B';
				break;
			}
			turn=sb.at(0);
			sb=sb.substr(1,sb.size());
		}
		if(turn=='c'){
			if(sc.size()==0){
				ans='C';
				break;
			}
			turn=sc.at(0);
			sc=sc.substr(1,sc.size());
		}
	}
	cout << ans << endl;
}

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

int main(){
  int H,R;

  cin >> H >> R;

  if (H + R == 0) {
    cout << 0 << endl;
  }
  else if (H + R > 0) {
    cout << 1 << endl;
  }
  else {
      cout << -1 << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
/* imp functions
	sorting arrays - sort(array,array+n);
	sorting vectors - v.sort(v.begin(),v.end());
	erasing element of vector - v.erase(v.begin()+i);
	inserting element in vector - v.insert(v.begin()+i,element);
	reversing vector - v.reverse(v.begin(),v.end());
	finding size of string - str.length();
	finding size of vector - v.size();
*/
/* Properties of modulo:Fermat's little theorem
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
using namespace std;
#define ll long long 
#define pb push_back
#define gcd __gcd
// checking whether a number is prime or not
bool compare(ll x, ll y){
    return x>y;
}
// checking whether a number is prime or not
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
// returning vector containing all prime numbers less than a given number
vector<ll> get_prime_less(ll n){
    ll array[n];
    vector<ll> factor;
    for(ll i=1;i<=n;i++) array[i]=i;
    ll prime[n];
    for(ll i=0;i<n;i++) prime[i]=1;
    for(ll i=2;i<=sqrt(n);i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
//returning vector containing index refering to elements of normal array after sorting it
vector<ll> retain_index(ll arr[], ll n){ 
    vector<pair<ll, ll> > vp; 
    for (ll i = 0; i < n; ++i) { 
        vp.push_back(make_pair(arr[i], i)); 
    } 
    sort(vp.begin(), vp.end());
    vector<ll> retain;
    for (ll i = 0; i < vp.size(); i++) { 
        ll a = vp[i].second;
        retain.pb(a);
    }
    return retain;
}
//calculating power in order logn returns x^y
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
} 
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if((c-a-b>0) && (a*a + b*b + c*c - 2*a*c - 2*a*b -2*c*b > 0)) cout<<"Yes";
    else cout<<"No";
}


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

int main()
{
    ll n;
    cin >> n;
    ll a;
    ll k = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a;
        if (a % 2 == 0)
        {
            if (a % 3 != 0 && a % 5 != 0)
            {
                k++;
            }
        }
    }
    if (k != 0)
    {
        cout << "DENIED" << endl;
    }
    else
    {
        cout << "APPROVED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		double sum = 0;
		for(int i = 1; i <= n ; i++) {
			
			double x = 1.0/n;
			int ii = i ;
			
			while( ii < k) {
				ii *=2;
				x /= 2;
			}
			
			sum += x;
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    double n;
    cin >> n;

    double cnt = 0;
    for(Int i=0; i<n; i++){
        if((i+1)%2==1){
            cnt++;
        }
    }
    printf("%.10lf", cnt/n);

    return 0;
}

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

long long n, naik, turun, i, j, x, grup;
vector < long long > ans;

int main() {
  scanf("%lld%lld%lld", & n, & naik, & turun);
  if (naik > n || turun > n) {
    printf("-1\n");
    return 0;
  }
  grup = ((n + naik - 1) / naik);
  if (turun < grup) printf("-1\n");
  else {
    i = n;
    while (grup != turun && i >= 0) {
      ans.push_back(i);
      i--;
      if (i % naik != 0) grup++;
    }
    //printf("---\n");
    if (i < 0) {
      printf("-1\n");
      return 0;
    }
    x = (i / naik) * naik;
    while (x >= 0) {
      for (j = x + 1; j <= i; j++) ans.push_back(j);
      i = x;
      x -= naik;
    }
	  int z = ans.size();
	  z--;
	  //printf("%lld\n",ans.size());
	  if (ans[z] != naik) {
	
	    printf("-1\n");
	    return 0;
	  }
	  for (i = 0; i < z + 1; i++) {
	    printf("%lld", ans[i]);
	    if (i == z + 1) printf("\n");
	    else printf(" ");
	  }
  }
}

Measured memory_bytes: 6568
#include <iostream>
using namespace std;
int n,id,k;
typedef struct{
	int parent;//???
	int depth;//??±???
	int lch;//????????????id
	int rch;//????????????id
	int ch;//????????°
	int bro;//?????????id
	int height;//??????
}NODE;
NODE node[30];
int root=-1;//id

int h_check(int i){
	int a=0,b=0;
	if(node[i].lch!=-1)a=h_check(node[i].lch)+1;
	if(node[i].rch!=-1)b=h_check(node[i].rch)+1;
	node[i].height=max(a,b);
	return max(a,b);
}

void preordertreewalk(int id){
	cout << " "<< id;
	if(node[id].lch!=-1)preordertreewalk(node[id].lch);
	if(node[id].rch!=-1)preordertreewalk(node[id].rch);
	return;
}

void inordertreewalk(int id){
	if(node[id].lch!=-1)inordertreewalk(node[id].lch);
	cout << " "<< id;
	if(node[id].rch!=-1)inordertreewalk(node[id].rch);
	return;
}

void postordertreewalk(int id){
	if(node[id].lch!=-1)postordertreewalk(node[id].lch);
	if(node[id].rch!=-1)postordertreewalk(node[id].rch);
	cout << " "<< id;
	return;
}


int main(){
		cin >> n;
		for(int i=0;i<30;i++){
			node[i].parent=-1;
			node[i].depth=0;
			node[i].lch=-1;
			node[i].rch=-1;
			node[i].ch=0;
			node[i].bro=-1;
			node[i].height=0;
		}
		for(int i=0;i<n;i++){
			cin >>id;
			cin >>node[id].lch>>node[id].rch;
			if(root==-1)root=id;
			if(node[id].lch!=-1){
				node[id].ch++;
				node[node[id].lch].parent=id;
				node[node[id].lch].bro=node[id].rch;
				node[node[id].lch].depth=node[id].depth+1;
			}
			if(node[id].rch!=-1){
				node[id].ch++;
				node[node[id].rch].parent=id;
				node[node[id].rch].bro=node[id].lch;
				node[node[id].rch].depth=node[id].depth+1;
			}

		}
		int temp=root;
		while(temp!=-1){
			root=temp;
			temp=node[temp].parent;
		}
		h_check(root);
		//cout << root<<endl;
		cout <<"Preorder" <<endl;
		preordertreewalk(root);
		cout<<endl;
		cout << "Inorder"<<endl;
		inordertreewalk(root);
		cout<<endl;
		cout << "Postorder"<<endl;
		postordertreewalk(root);
		cout<<endl;
}

Measured memory_bytes: 3096
//Author:  Pranta
//Date:    2020-Aug-22
//Problem: C_Step
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    ll n;
    cin>>n;
    ll arr[n+5];
    for(int i=0;i<n;++i) cin>>arr[i];
    ll stool =0;
    for(int i=1;i<n;++i){
        if(arr[i]<arr[i-1]){
            ll x=(arr[i-1]-arr[i]);
            stool+=x;
            arr[i]=arr[i]+x;
        }
    }
    cout<<stool;
}
int main()
{
    fast;
    int t;
    //cin>>t;
    //while(t--)
    solve();
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll temp;
    cin >> N;
    temp = N % 10;
    switch(temp) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        cout << "hon" << endl;
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        cout << "pon" << endl;
        break;
        case 3:
        cout << "bon" << endl;
        break;
    }
    return 0;
}


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

struct BIT {
    long long n;
    vector<long long> dat;

    void initialize(long long n_input){
        n = n_input + 1;
        dat.resize(n+1);
        for(int i = 0; i<=n; i++) dat[i] = 0;
    }

    long long sum(long long i){
        long long s = 0;
        while(i >= 0){
            s += dat[i];
            i = (i & (i+1)) - 1;
        }
        return s;
    }

    void add(long long i, long long x){
        while(i <= n){
            dat[i] += x;
            i |= i+1;
        }
    }
};

int N, M;
int ls[300000], rs[300000];
vector<pair<int, int>> pairs;

int main(){
    cin >> N >> M;
    for(int i=0; i<N; i++){
        cin >> ls[i] >> rs[i];
        pairs.push_back(make_pair(rs[i]-ls[i], i));
    }
    sort(pairs.begin(), pairs.end());

    BIT bit;
    bit.initialize(M+2);

    int pt = 0;
    for(int m=1; m<=M; m++){
        while(pt<N){
            int i = pairs[pt].second;
            if(rs[i]-ls[i]+1 < m){
                pt += 1;
                bit.add(ls[i], 1);
                bit.add(rs[i]+1, -1);
            }else{
                break;
            }
        }
        int sum = N - pt;
        for(int k=1; k<=M/m; k++){
            sum += bit.sum(k*m);
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int main()
{
int n,m;
cin>>m>>n;
int arr[n+1];
rep(i,0,n)
cin>>arr[i];
int sum=0;
rep(i,0,n)
sum+=arr[i];
if(sum>=m)
cout<<"Yes";
else
cout<<"No";

}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(void){
 long x,y;
 int ans;
 cin >> x >> y;
 ans = 0;
 while(x<=y){
   x *= 2;
   ans++;
 }

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


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int w,n,i,a,b,swap,num[30];
    scanf("%d",&w);
    for(i=0;i<w;i++)
        num[i]=i+1;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        swap=num[a-1];
        num[a-1]=num[b-1];
        num[b-1]=swap;
    }
    for(i=0;i<w;i++)
        printf("%d\n",num[i]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod  1000000007
int N = 1000001; 
 
ll FACT[1000002],NUMINVERSE[1000002],fact[1000002]; 
 
void INV(ll p) 
{ 
	NUMINVERSE[0] = NUMINVERSE[1] = 1; 
	for (int i = 2; i <= N; i++) 
		NUMINVERSE[i] = NUMINVERSE[p % i] * (p - p / i) % p; 
} 
void INVF(ll p) 
{ 
	FACT[0] = FACT[1] = 1; 
 
	for (int i = 2; i <= N; i++) 
		FACT[i] = (NUMINVERSE[i] * FACT[i - 1]) % p; 
}
 void factorial(ll p) 
{ 
	fact[0] = 1; 
 
	for (int i = 1; i <= N; i++) { 
		fact[i] = (fact[i - 1] * i) % p; 
	} 
} 
 
ll NCR(ll N, ll R, ll p) 
{ 
 
    ll ans = ((fact[N] * FACT[R]) 
              % p * FACT[N - R]) 
             % p; 
    return ans; 
} 
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ll p = 1000000007; 
	INV(p); 
	INVF(p); 
	factorial(p);
    long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m,a,b,c,d;
      cin>>n;
      if(n<3)
      {
          cout<<0; return 0;
      }
      for(i=1;i<=n;i++)
      {
          count=n-3*i;
          if(count<0)
          break;
          ans=(ans+NCR(i+count-1,count,p))%mod;
      }
      cout<<ans;
    
	return 0;
}

Measured memory_bytes: 27040
#include<stdio.h>
int main(void)
{
	char s[100001];
	int count = 0;
	int i;

	scanf("%s",s);

	if(s[0] == '0'){
		for(i = 1;i < 100001;i++){
			if(i%2 == 0 && s[i] == '1')
				count++;
			if(i%2 == 1 && s[i] == '0')
				count++;
          	if(s[i] == '\0')
              	break;
		}
	}

	if(s[0] == '1'){
		for(i = 1;i < 100001;i++){
			if(i%2 == 0 && s[i] == '0')
				count++;
			if(i%2 == 1 && s[i] == '1')
				count++;
          	if(s[i] == '\0')
              	break;
		}
	}
		
	printf("%d\n",count);

	return 0;
}

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

// 同じ文字は同時に他の文字に代わる
// S内の同じ文字のある位置にあるT内の文字が異なる場合、
// T内のその位置にある文字は同じである必要がある。
// 逆も同様である。

string S, T;
vi cntS[26], cntT[26];

int main() {
  cin >> S >> T;
  for (int i = 0; i < S.length(); ++i) cntS[S[i] - 'a'].push_back(i);
  for (int i = 0; i < T.length(); ++i) cntT[T[i] - 'a'].push_back(i);
  
  // check S -> T
  for (int i = 0; i < 26; ++i) {
    if (cntS[i].size() >= 2) { // 同じ文字が2つ以上ある場合
      char s = 'a' + i; // 該当する文字
      char t = '0'; // S内のsがある位置におけるT内の文字

      // cout << "check: " << s << endl;
      bool check = true;
      vector<char> stack;
      for (int j = 0; j < cntS[i].size(); ++j) {
        if (T[cntS[i][j]] == s) continue;

        if (t == '0') t = T[cntS[i][j]];
        else {
          if (t != T[cntS[i][j]]) check = false;
        }
      }

      if (!check) {
        printf("No\n");
        return 0;
      }
    }
  }
  
  // check T -> S
  for (int i = 0; i < 26; ++i) {
    if (cntT[i].size() >= 2) { // 同じ文字が2つ以上ある場合
      char t = 'a' + i; // 該当する文字
      char s = '0'; // T内のtがある位置におけるS内の文字

      // cout << "check: " << t << endl;
      bool check = true;
      vector<char> stack;
      for (int j = 0; j < cntT[i].size(); ++j) {
        if (S[cntT[i][j]] == s) continue;

        if (s == '0') s = S[cntT[i][j]];
        else {
          if (s != S[cntT[i][j]]) check = false;
        }
      }

      if (!check) {
        printf("No\n");
        return 0;
      }
    }
  }

  printf("Yes\n");
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if(a >= 13){
    cout << b;
  }
  else if(a >= 6){
    cout << b / 2;
  }
  else{
    cout << 0;
  }
  return 0;
}

Measured memory_bytes: 256
def showList(A, N):
    for i in range(N-1):
        print(A[i],end=' ')
    print(A[N-1])

def selectionSort(A, N):
    """
    選択ソート
    O(n^2)のアルゴリズム
    """
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            t = A[minj]
            A[minj] = A[i]
            A[i] = t
            count += 1
    showList(A, N)
    print(count)
    

N = int(input())
A = [int(x) for x in input().split(' ')]
selectionSort(A, N)


Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long ans=1;
    long long a[100010]={};
    for(long long i=0;i<n;i++){
        long long x;
        cin >> x;
        a[x]++;
        if(a[x]>2){
            ans = 0;
            break;
        }
    }
    if(ans == 0||a[0]>1){
        cout << 0 << endl;
    }else{
        for(int i=0;i<n/2;i++){
            ans = ans*2;
            ans = ans%1000000007;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
from statistics import median, median_low, median_high

n=int(input())
l=list(map(int,input().split()))

m_l=median_low(l)
m_h=median_high(l)

for i in range(n):
    if l[i] <= m_l:
        print(m_h)
    elif l[i] >= m_h:
        print(m_l)

Measured memory_bytes: 27196
n, m, q = gets.strip.split.map(&:to_i)
lr = m.times.map { gets.strip.split.map(&:to_i)}
pq = q.times.map { gets.strip.split.map(&:to_i)}

field = Array.new(n+1) { [0]*(n+1) }

lr.each do |l, r|
  field[l][r]+=1
end

#(n+1).times do |i|
#  p field[i]
#end

(1..n).each do |i|
  (1..n).each do |j|
    field[i][j] = field[i][j] + field[i][j-1]
  end
end

(1..n).each do |i|
  (1..n).each do |j|
    field[i][j] = field[i][j] + field[i-1][j]
  end
end

#(n+1).times do |i|
#  p field[i]
#end

results = []
pq.each do |p, q|
  p field[q][q] - field[p-1][q] - field[q][p-1] + field[p-1][p-1]
end




Measured memory_bytes: 48052
A = int(input())
B = int(input())
C = int(input())
X = int(input())

re =0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                re += 1
                
print(re)

Measured memory_bytes: 3060
n = int(input())
list_a = list((map(int, input().split())))
count = 0
while True:
    for number in list_a:
        if number % 2 == 1:
            break
        else:
            continue
    else:
        for i in range(0,len(list_a)):
            list_a[i] /= 2
        count += 1
        continue
    break

print(count)


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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=2e5+5;
vector<int>lk[N];
int ans=1,dp[N];
void dfs(int x,int fr)
{
	dp[x]=1;
	for(auto y:lk[x])
	if(y!=fr)
	{
		dfs(y,x);
		chmax(ans,dp[x]+dp[y]);
		chmax(dp[x],dp[y]+1);
	}
}

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);
#endif
	int n;
	cin>>n;
	rep(i,1,n-1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		lk[x].push_back(y);
		lk[y].push_back(x);
	}
	dfs(1,0);
	puts(ans%3==2?"Second":"First");
}

Measured memory_bytes: 23936
# -*- coding:utf-8 -*-
n,m,c = map(int,input().split())
b_list = list(map(int,input().split()))
a_list =[]
for i in range(n):
    a_list.append(list(map(int,input().split())))

ret_num = 0
sum = 0

for N in range(n):
    sum = 0
    for M in range(m):
        sum += a_list[N][M] * b_list[M]
    if sum + c > 0:
        ret_num += 1

print(ret_num)

        


Measured memory_bytes: 9184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var ha = Sarray();
            var ans = ha[0] / ha[1];
            WriteLine(ha[0] % ha[1] == 0 ? ans : ans + 1);
        }
    }
}


Measured memory_bytes: 18828
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
//typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M,V,P;
ll A[100010];
bool Able_UnderL(vector<ll>& v,ll b,ll L){
    ll nowRemain=b*M;
    for(auto o:v){
      nowRemain -= max(0ll,L-o);
    }
    return nowRemain<=0 ;
}

bool Check(ll i){
  if(i>=N)return false;

  if(A[i]+M<A[P-1]){
    return false;
  }
  vector<ll> v;
  for(ll j=P-1;j<i;j++){
    v.push_back(A[j]);
  }
  return Able_UnderL(v,V-P-(N-1-i),A[i]+M);
}

ll binarySearch(function<bool(ll)> check, ll ok, ll ng) {
  while ((ok - ng > 1) || (ng - ok > 1)) {
    ll mid = (ok + ng) / 2;
    if (check(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}
int main(){
    cin>>N>>M>>V>>P;
    for(ll i=0;i<N;i++){
      cin>>A[i];
    }sort(A,A+N,greater<ll>());
    cout<<binarySearch(Check,0ll,N)+1<<endl;
    return 0;
}

Measured memory_bytes: 2880
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int k, n;
    cin >> k >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int ans = a[0] + k - (a[n-1]);
    REP(i,1,n) {
        chmax(ans, a[i] - a[i-1]);
    }
    cout << k - ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;
ll N;
vector<vector<char>> S(300, vector<char>(300, ' '));
vector<vector<int>> check(300, vector<int>(300, -1));

int F(ll A, ll B){
    if(A>0&&B>0&&check[A-1][B-1]!=-1)return check[A][B]=check[A-1][B-1];
    for(ll i=0;i<N;i++){
     for(ll j=i;j<N;j++){
         if(S[(i+A)%N][(j+B)%N]!=S[(j+A)%N][(i+B)%N])return check[A][B]=0;
     ;}
    ;}
    return check[A][B]=1;
}

int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
     for(ll j=0;j<N;j++){
         cin>>S[i][j];
     ;}
    ;}
    ll ans=0;
    for(ll i=0;i<N;i++){
     for(ll j=0;j<N;j++){
         if(F(i,j))ans++;
     ;}
    ;}
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 768