akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int read();

int N, x[200005], st[200005], a[200005];
int work() {
    int m = N / 2 + 1, res = a[m], l = m, r = m;
    a[0] = a[1], a[N + 1] = a[N];
    for (; l >= 1 && a[l] != a[l - 1] && a[r] != a[r + 1]; --l, ++r) res ^= 1;
    return res;
}

int main() {
    N = read() * 2 - 1;
    for (int i = 1; i <= N; ++i) st[i] = x[i] = read();
    sort(st + 1, st + 1 + N);
    int l = 1, r = N, res = r;
    while (l <= r) {
        int mid = l + r >> 1;
        for (int i = 1; i <= N; ++i) a[i] = x[i] > st[mid];
        if (!work())
            r = mid - 1, res = mid;
        else
            l = mid + 1;
    }
    printf("%d\n", st[res]);
    return 0;
}
int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    return x * f;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, m;
	cin >> n >> m;
	int ans = (n - 1)*(m - 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll divi[129];
ll vis[129];
map<long double,ll>mp1;
map<ll,ll>mp2;
vector<int>stp[29];
string str1;
string str2;
ll arra[100007];
deque<ll>save;
ll ans1[100005];
ll ans2[100005];
ll inp1[200009];
ll inp2[200009];
pair<ll,ll>sol;
//map<pair<ll, ll>, ll> mp3;
map<char,ll>mp3;
map<ll,ll>L;
map<ll,ll>R;
vector<ll>c_pg[1009];
ll x_p[1009];
ll y_p[1009];
ll x_last[1009];
ll y_last[1009];
ll p_m[200009];
int main()
{
  ll i,j,k,l,p=0,q=0,r=0,s=0,t,m,n,check=1,x=0,y=1,z=0,a=0,b=0,c=0,zero=0;
  cin>>n>>k;
  for(i=0;i<n;i++)
  {
     cin>>p_m[i];	
  }
  sort(p_m,p_m+n);
  if(k>=n)
  {
     cout<<"0";
     return 0;	
  }
  for(i=0;i<n-k;i++)
    a=a+p_m[i];
    cout<<a<<'\n';
  
 
     
  
   
  
    	
}

Measured memory_bytes: 1792
n, m = map(int, input().split())
ipy = []

for i in range(m):
    p, y = map(int, input().split())
    ipy.append([i, p, y])
    
city_count = {}
order = {}

for i, p, y in sorted(ipy, key = lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 0
    city_count[p] += 1
    order[i, p] = city_count[p]

for i, p, y in ipy:
    print('{:06}{:06}'.format(p, order[i, p]))

Measured memory_bytes: 44480
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC091_B();
        }

        static void ABC091_B()
        {
            var N = int.Parse(Console.ReadLine());
            var dict = new Dictionary<string, int>();
            for (var n = 0; n < N; n++)
            {
                var str = Console.ReadLine();
                if (!dict.ContainsKey(str))
                    dict.Add(str, 1);
                else
                    dict[str] += 1;
            }

            var M = int.Parse(Console.ReadLine());
            for (var m = 0; m < M; m++)
            {
                var str = Console.ReadLine();
                if (!dict.ContainsKey(str))
                    dict.Add(str, -1);
                else
                    dict[str] -= 1;
            }
            var ans = dict.Values.Max();
            Console.WriteLine(ans > 0 ? ans : 0);
        }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
int main()
{
	int n,i,r;
	int a,b,c,d,e;
	int min,max;
	while(1){
		min=500;
		max=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
			r=a+b+c+d+e;
			if(min>r){
				min=r;
			}
			if(max<r){
				max=r;
			}
		}
		printf("%d %d\n",max,min);
	}
	return 0;
}



Measured memory_bytes: 2688
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n,w;
    cin>>n>>w;
    ll weight[n+1],profit[n+1];
    ll dp[n+1][w+1];
    for(ll i = 1; i <=n; i++){
       cin>>weight[i]>>profit[i];
    }
    for(ll i = 0; i <=w;i++){
    	dp[0][i] = 0;
    }
    for(ll i = 0; i<=n;i++){
    	dp[i][0] = 0;
    }
    for(ll i = 1; i<=n; i++){
    	for(ll j = 1; j<=w;j++){
    		if(j<weight[i]){
    			dp[i][j] = dp[i-1][j];
    		}else{
    			dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i]] + profit[i]);
    		}
    	}
    }
    cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 79104
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
 
#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
 
using namespace std;

int s[2][1000][1000];


int main() {
    int n, k;
    cin >> n >> k;

    REP(i, n) {
        int xi, yi;
        string ci;
        cin >> xi >> yi >> ci;

        if (ci[0] == 'B')
            xi += k; // Do not use -= for %
        if (xi % (2 * k) >= k) {
            xi += k; // Do not use -= for %
            yi += k; // Do not use -= for %
        }

        if (yi % (2 * k) >= k)
            s[1][xi % k][yi % k]++;
        else
            s[0][xi % k][yi % k]++;
    }

    REP(p, 2) {
        for (int q = 1; q < k; q++) s[p][q][0] += s[p][q - 1][0];
        for (int r = 1; r < k; r++) s[p][0][r] += s[p][0][r - 1];
        for (int q = 1; q < k; q++) for (int r = 1; r < k; r++) s[p][q][r] += s[p][q - 1][r] + s[p][q][r - 1] - s[p][q - 1][r - 1];
    }

    int best = 0;

    REP(p, k) REP(q, k) {
        best = max(best,
                   max(s[0][k - 1][k - 1] - s[0][p][k - 1] - s[0][k - 1][q] + 2 * s[0][p][q] + s[1][p][k - 1] + s[1][k - 1][q] - 2 * s[1][p][q],
                       s[1][k - 1][k - 1] - s[1][p][k - 1] - s[1][k - 1][q] + 2 * s[1][p][q] + s[0][p][k - 1] + s[0][k - 1][q] - 2 * s[0][p][q]));
    }
    
    cout << best << endl;
    
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<string>

using namespace std;
int main(){
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
			return 0;
		} 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main(){
  int m1, d1; 
  cin >> m1 >> d1;
  int m2, d2; 
  cin >> m2 >> d2;
  if(d2 == 1) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll x; cin >> x;
    vector<vector<string>> l(10, vector<string>());
    vector<string> lm;
    rep(i, 9){
        l[0].push_back(string(1, (i+1)+'0'));
        lm.push_back(l[0][i]);
    }
    ll cnt = 9;
    for(ll i = 1; i < 10; ++i){
        for(auto v : l[i-1]){
            ll last = v[v.length()-1] - '0';
            for(ll j = -1; j < 2; ++j){
                string tmp = v;
                if(0 <= last+j && last+j <= 9){
                    tmp += (last+j) + '0';
                    l[i].push_back(tmp);
                    lm.push_back(tmp);
                    cnt++;
                }
            }
            if(cnt >= 100000) break;
        }
        if(cnt >= 100000) break;
    }

    cout << lm[x-1] << endl;
    return 0;
}

Measured memory_bytes: 11540
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << endl;
	}
	
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    private static long result;
    private const string march = "MARCH";
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var dic = new Dictionary<string, int>();
        for (var i = 0; i < 5; i++)
            dic[march.Substring(i, 1)] = 0;
        for (var i = 0; i < num; i++)
        {
            var str = ReadLine();
            var s = str.Substring(0, 1);
            if (dic.ContainsKey(s))
                dic[s]++;

        }
        for (var i = 0; i < 5; i++)
            dfs(dic, dic[march.Substring(i,1)],  0, i);
        WriteLine(result);
    }
    private static void dfs(Dictionary<string,int> dic,long res,int depth,int index)
    {
        if (depth == 2) { result += res; return; }
        for (var i = index+1; i < 5; i++)
        {
            var s = march.Substring(i, 1);
            dfs(dic, res * dic[s], depth+1, i);
        }

    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 15696
#include <stdio.h>
#include <math.h>
 
int main(){
  int N, D, i, j, ans = 0;
  scanf("%d %d", &N, &D);
  int X[N][D];
  for(i=0; i<N; i++){
    for(j=0; j<D; j++){
      scanf("%d", &X[i][j]);
    }
  }
  
  double tmp;
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      tmp = 0.0;
      if (i != j){
      	for(int k=0; k<D; k++){
          tmp += (double)((X[i][k] - X[j][k])*(X[i][k] - X[j][k]));
        }
		//printf("%f", tmp);
     	tmp = sqrt(tmp);
        if (tmp - (double)(int)tmp == 0){
          ans++;
        }
      }
    }
  }
  
  printf("%d", ans/2);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;

int n, m, ind[maxn];


int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n >> m;
    vector<vector<int> > g(n);

    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        
        ++ind[v];
        g[u].push_back(v);
    }

    queue<int> qu;

    for (int i = 0; i < n; ++i) {
        if (ind[i] == 0) {
            qu.push(i);
        }
    }

    int step = 0;
    while (!qu.empty()) {
        int sz = qu.size();
        while (sz) {
            --sz;

            int u = qu.front();
            qu.pop();

            for (int i = 0; i < g[u].size(); ++i) {
                int v = g[u][i];
                --ind[v];
                if (ind[v] == 0) {
                    qu.push(v);
                }
            }
        }

        if (!qu.empty())
            ++step;
    }

    cout << step << endl;
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int SZ=100005;
set<int> st[SZ];
pint id[SZ];
map<int,int> year_to_idx;

signed main()
{
    int N,M;
    cin>>N>>M;
    REP(i,M){
        int p,y; cin>>p>>y;
        year_to_idx[y]=i;
        st[p-1].insert(y);
    }

    REP(p,N){
        if(st[p].size()==0) continue;
        int cnt=1;
        for(auto y:st[p]){
            int idx=year_to_idx[y];
            id[idx].first=p+1;
            id[idx].second=cnt;
            cnt++;
        }
    }

    REP(i,M){
        printf("%06lld%06lld\n",id[i].first,id[i].second);
    }

}


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

#define _ cin.tie(0);ios::sync_with_stdio(false);
string s;
llong k;
int main(){ _;
  cin>>s>>k;
  int one=0;
  int ans=0;
  REP(i,s.length()){
    if(s[i]=='1'){
      ++one;
    }else{
      break;
    }
  }
  if(one>=k)
    cout<<'1'<<endl;
  else
    cout<<s[one]<<endl;

  return 0;
}


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

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 100000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;


#ifdef TESTING
#define DEBUG fprintf(stderr,"====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG 
#define VALUE(x)
#define debug(...)
#endif
/*
inline string IntToString(ll a) {
	char x[100];
	sprintf_s(x, "%lld", a); string s = x;
	return s;
}

inline ll StringToInt(string a) {
	char x[100]; ll res;
	strcpy_s(x, a.c_str()); sscanf_s(x, "%lld", &res);
	return res;
}
*/

inline string uppercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
	return s;
}

inline string lowercase(string s) {
	int n = SIZE(s);
	rep(i, n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
	return s;
}


int main()
{
	ll n,ans = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll t;
		cin >> t;
		ll y = __gcd(ans, t);
		ans /= y;
		ans *= t;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(n,c);
    out((n+c)/2);
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"YES\n"; else cout<<"NO\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    int n,m,x,q=0,w=0,a;
    cin>>n>>m>>x;
    rep(i,m){
        cin>>a;
        if(a<x)q++;
        if(a>x)w++;
    }
    cout<<min(q,w)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(void)
{
	std::string s;
	std::cin >> s;
	
	int answer = 0;
	if(s[0] == '1') ++answer;
	if(s[1] == '1') ++answer;
	if(s[2] == '1') ++answer;

	std::cout << answer << std::endl;

	return 0;
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    int aa = a, bb = b;
    while (b != 0) {
        int c = a % b;
        a = b; b = c;
    }
    cout << (long) aa / a * bb;

    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    int A, B;
    std::cin >> A >> B;
    
    std::string S;
    std::cin >> S;

    int L = A + B + 1;
    for(int i=0;i<L;++i){
        bool flag;
        if(i == A){
            flag = S[i] == '-';
        }else{
            flag = isdigit(S[i]);
        }

        if(!flag){
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

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

const int32_t MAX_N = 21;
const int32_t MOD = 1e9 + 7;

int32_t a[MAX_N + 5][MAX_N + 5], dp[MAX_N + 5][(1 << MAX_N) + 5];

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

    int32_t n;
    std::cin >> n;

    for(int32_t i = 0; i < n; i++) {
        for(int32_t j = 0; j < n; j++) {
			std::cin >> a[i][j];
		}
    }
	int32_t ans = 0;
	for(int32_t i = 0; i < n; i++) {
        if(a[0][i] == 1) {
			dp[0][(1 << i)] = 1;

			if(n == 1) {
				ans++;
			}
        }
	}

	if(n == 1) {
		std::cout << ans << '\n';
		return 0;
	}

    for(int32_t i = 1; i < n; i++) {
		for(int32_t j = 0; j < (1 << n); j++) {
			if(__builtin_popcount(j) != i + 1) {
				continue;
			}

			for(int32_t p = 0; p < n; p++) {
				if((j & (1 << p)) != 0 && a[i][p] == 1) {
					dp[i][j] = ((int64_t) dp[i][j] + dp[i - 1][(j ^ (1 << p))]) % MOD;
				}
			}

			if(i == n - 1) {
				ans = ((int64_t) ans + dp[i][j]) % MOD;
			}
		}
    }

    std::cout << ans << '\n';
}


Measured memory_bytes: 162048
#include<iostream>

using namespace std;

int main()
{
        double a,b;
        const double box = 3.305785;
        double c;
        double output;

        cin >> a >> b;
        c = a * b;
        output = c / box;
        printf("%f\n",output);
        //cout << output << endl;
}
      

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

int main() {

    string s;
    cin >> s;
    int ans = 0;

    rep(i, s.length())
    {
        if (s[i] != s[s.length()-1-i])
        {
            ans++;
        }
    }

    cout << ans / 2 << endl;

    return 0;
}

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

int main(){
    double L;
    cin>>L;

   cout << fixed << setprecision(8);

   cout<<(L/3)*(L/3)*(L/3)<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

        while(true){
            int H = stdIn.nextInt();
            int W = stdIn.nextInt();

            if(H==0 && W==0){
                break;
            }

            for(int i=1;i<=H;i++){
                for(int j=1;j<=W;j++){
                    System.out.print("#");
                }
                System.out.println();

            }
            System.out.println();
        }

        stdIn.close();

    }

}


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

int main() {
    string str;
    cin >> str;

    int n = str.size();
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            if (str[i] == 'p') --res;
        } else {
            if (str[i] == 'g') ++res;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    string s;
    cin >> n >> s;
    int r = 0 , w = 0;
    for(char c : s){
        if(c == 'R')
            ++r;
        else
            ++w;
    }
    int ans = min(r , w);
    int ans2 = 0;
    int i = 0 , j = n-1;
    while(i < j){
        if(s[i] == 'R'){
            ++i;
            continue;
        }
        if(s[j] == 'W'){
            --j;
            continue;
        }
        ++ans2;
        ++i;
        --j;
    }
    cout<<min(ans , ans2);
}



Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vp;

void dfs(vp e[], int x, int p, int dis[]) {
    for (pii y : e[x]) {
        if (y.first != p) {
            dis[y.first] = dis[x] + y.second;
            dis[y.first] %= 2;
            dfs(e, y.first, x, dis);
        }
    }
}

int main() {
    int n;
    cin >> n;
    vp e[n];
    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        e[u].push_back({v, w});
        e[v].push_back({u, w});
    }

    int dis[n];
    dis[0] = 0;
    dfs(e, 0, -1, dis);

    for (int i = 0; i < n; i++) {
        cout << dis[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9728
class Dice:
    #f[]はUSEWNDの順，添字はU:0,S:1,E:2,W:3,N:4,D:5
    def __init__(self,l):
        self.f=l
        
    def __str__(self):
        l=self.f
        s=f'[U:{l[0]},S:{l[1]},E:{l[2]},W:{l[3]},N:{l[4]},D:{l[5]}]'
        return(s)
       
    def roll(self,c):
        if c=='N':
            ni=[1,5,2,3,0,4]
        elif c=='S':
            ni=[4,0,2,3,5,1]
        elif c=='E':
            ni=[3,1,0,5,4,2]
        elif c=='W':
            ni=[2,1,5,0,4,3]
        self.f=[self.f[j] for j in ni]
    
    def rotate(self,r):
        if r==+1: #Uから見て反時計(西)回り
            ni=[0,3,1,4,2,5]
        elif r==-1: #Uから見て時計(東)周り
            ni=[0,2,4,1,3,5]
        self.f=[self.f[j] for j in ni]

d=Dice(list(map(int,input().split())))
for c in input():
    d.roll(c)
print(d.f[0])


Measured memory_bytes: 5624
n, k = map(int, input().split())
h_list = []
for i in range(n):
    h_list.append(int(input()))
h_list.sort()
min = h_list[-1]
for j in range(n-k+1):
    if min > h_list[j+k-1] - h_list[j]:
        min = h_list[j+k-1] - h_list[j]

print(min)

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    ll n, m;
    cin >> n >> m;
    ll a, b, ans;
    a = min(n, m);
    b = max(n, m);
    if(a == 1) {
        if(b == 1) ans = 1;
        else ans = b - 2;
    } 
    else if(a == 2) {
        ans = 0;
    } else { // a > 2
        ans = (a - 2) * (b - 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

K = int((2 * N) ** 0.5) + 1
if K * (K - 1) // 2 != N:
    print("No")
    quit()

print("Yes")
print(K)

A = [[] for _ in range(K - 1)]

cur = 1
for i in range(K - 1):
    for _ in range(i + 1):
        A[i].append(cur)
        cur += 1

for i in range(K - 1):
    T = A[i]
    cur = len(T) - 1
    for j in range(cur + 1, K - 1):
        T.append(A[j][cur])
    print(len(T), *T)

T = [A[i][i] for i in range(K - 1)]
print(len(T), *T)

Measured memory_bytes: 9220
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int count=0;
	string s1,s2;
	while(getline(cin,s2)){
		s1=s2;
		reverse(s2.begin(),s2.end());
		if(s1==s2)count++;
	}
	cout<<count<<endl;
	return 0;
}

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



int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  string ans="No";
  while(k>0 && a>=b){
    b *= 2;
    k--;
  }
  while(k>0 && b>=c){
    c *= 2;
    k--;
  }
  if(a<b && b<c && a<c) ans="Yes";
  
   
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
  	cin>>a>>b;
  	if(a>=b){
      for(int i=0;i<a;i++)cout<<b;
    }
  else {
    for(int i=0;i<b;i++)cout<<a;
  }
 }
     

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

int main() {
  int N, A, B, C, x;
  cin >> N;
  x = 10000;
  
  for (int i = 0; i < N; i++) {
    cin >> A;
    B = 0;
    
    for (int j = 0; j < 10000; j++) {
      C = A % 2;
      A /= 2;
      
      if (C != 0) {
        break;
      }
      
      else if (j + 1 > B) {
        B = j + 1;
      }
    }
    
    if (x > B) {
      x = B;
    }
  }
  
  cout << x << endl;
  
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    double sum = 0;
    double[] x = new double[n];
    double[] y = new double[n];
    for(int i = 0; i < n; i++) {
      x[i] = Double.parseDouble(sc.next());
      y[i] = Double.parseDouble(sc.next());
    }
    for(int i = 0; i < n - 1; i++) {
      for(int j = i + 1; j < n; j++) {
        sum += Math.sqrt(Math.pow(x[i] - x[j], 2) + Math.pow(y[i] - y[j], 2));
      }
    }
    double ans = sum * 2 / n;
    System.out.println(ans);
  }
}


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

int main() {
  int N, M;
  map<string, int> mp;
  cin >> N;
  rep(i,N) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> M;
  rep(i,M) {
    string s;
    cin >> s;
    mp[s]--;
  }
  int mx = 0;
    for(auto p : mp) mx = max(mx, p.second);
    cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N];
int main()
{
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	int id = 1;
	for(; id <= n; id ++)
		if(a[id] >= 0)
			break;
	ll ans = 1e13;
	for(int i = id - 1, cnt = k-1; i >= 1 && cnt; i --, cnt --)
	{
		if(i + k - 1 > n)
			continue;
		ll dm = abs(a[i])*2 + a[i + k - 1];
		umin(ans, dm);
	}
	if(id - k > 0)
		umin(ans, (ll)(abs(a[id- k])));
	for(int i = id, cnt = k-1; i <= n && cnt; i ++, cnt --)
	{
		if(i - k + 1 < 1)
			continue;
		ll dm = a[i] * 2 + abs(a[i - k + 1]);
		umin(ans, dm);
	}
	if(id + k - 1 <= n)
		umin(ans, (ll)(a[id + k - 1]));
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
         else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    vector<vector<int>>cnt(M);
    for(int i = 0; i < N; i++) {
        int K;cin >> K;
        for(int j = 0; j < K; j++) {
            int L;cin >> L;L--;
            cnt[L].push_back(i);
        }
    }
    for(int i = 0; i < M; i++) {
        for(int j = 0; j < (int)cnt[i].size()-1; j++) {
            uf.unite(cnt[i][j],cnt[i][j+1]);
        }
    }
    if(uf.consize(0) == N) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 8276
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
aN =LIST()

# Kがでかいのは論外
if max(aN) < K:
    print('IMPOSSIBLE')
    exit()

# aN全部の最大公約数を取る
base = aN[0]
for i in range(1, N):
    base = gcd(base, aN[i])
if K % base == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 16336
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

string s;

int main() {
	cin >> s;
	int l, r;
	int k = 0;
	if (s.size() % 2 == 0) {
		k = s.size() / 2;
		r = s.size() / 2;
		l = r - 1;
	}
	else {
		k = s.size() / 2;
		l = r = s.size() / 2;
	}
	char c = s[l];
	while (k < s.size() && s[l] == c && s[r] == c) {
		--l, ++r, ++k;
	}
	cout << k << "\n";
	return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

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


Measured memory_bytes: 4376
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
  a=list(map(int,input().split()))
  s=0
  for j in range(m):
    s+=a[j]*b[j]
  if s+c>0:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	int a=0,b=0,o=0,ab=0,tmp;
	char str[3];
	while(scanf("%d,%s",&tmp,str)!=EOF)
	{
		if(str[0]=='A'&&str[1]=='B')ab++;
		else if(str[0]=='B')b++;
		else if(str[0]=='O')o++;
		else if(str[0]=='A')a++;
	}
	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;
	return 0;
}

Measured memory_bytes: 1208
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
 
D = [0] * (N + 1)
 
temp = 0
for i in range(N):
    temp = (A[i] + temp) % M
    D[i] = temp
#print(D)
D.sort()
#print(D)
temp = 0
cc = 1
for i in range(N):
    if D[i] == D[i + 1]:
        cc += 1
    else:
        temp += cc * (cc - 1) // 2
        cc = 1
temp += cc * (cc - 1) // 2
 
print(temp)

Measured memory_bytes: 62576
from math import factorial as fact

N, P = map(int, input().split())
A = [int(_) for _ in input().split()]
oddcnt = 0
evencnt = 0
for i in A:
    if i % 2 == 1:
        oddcnt += 1
    else:
        evencnt += 1

even = 2**evencnt
odd = 0
if P == 0:
    for i in range(0, oddcnt+1, 2):
        odd += fact(oddcnt) // (fact(i)*fact(oddcnt-i))
else:
     for i in range(1, oddcnt+1, 2):
        odd += fact(oddcnt) // (fact(i)*fact(oddcnt-i))

print(even*odd)

Measured memory_bytes: 3064
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

void main() {
    int K, T;
    readf("%d %d\n", &K, &T);
    auto ary = readln.split.to!(long[]).enumerate.array.sort!((a, b) => a.value>b.value).array;
    int ans = 0;
    int pre = -1;
    foreach(i; 0..K) {
        ary.sort!((a, b) => a.value>b.value);
        auto a = ary.find!(a => a.index!=pre && a.value>0).array;
        if (a.length > 0) {
            foreach(j, e; ary) {
                if (e.index!=pre && e.value>0) {
                    ary[j].value -= 1;
                    pre = e.index.to!int;
                    break;
                }
            }
        } else {
            ans++;
            ary.front.value -= 1;
        }
    }
    ans.writeln;
}


Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using ll=long long;
int main(){
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    int cnt=0;
    if(a==0)cnt++;
    if(b==0)cnt++;
    if(c==0)cnt++;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    if(cnt==3){
        cout<<"No"<<endl;
    }else{
        vector<char> ret;
        for(int i=0;i<n;i++){
            if(s[i]=="AB"){
                if(a==0&&b==0){
                    cout<<"No"<<endl;
                    return 0;
                }
                if(a<b||(a<=b&&i<n-1&&s[i+1]=="AC")){
                    ret.push_back('A');
                    a++;
                    b--;
                }
                else {
                    ret.push_back('B');
                    b++;
                    a--;
                }
            }
            if(s[i]=="BC"){
                if(b==0&&c==0){
                    cout<<"No"<<endl;
                    return 0;
                }
                if(b<c||(b<=c&&i<n-1&&s[i+1]=="AB")){
                    ret.push_back('B');
                    b++;
                    c--;
                }
                else {
                    ret.push_back('C');
                    c++;
                    b--;
                }
            }
            if(s[i]=="AC"){
                if(a==0&&c==0){
                    cout<<"No"<<endl;
                    return 0;
                }
                if(a<c||(a<=c&&i<n-1&&s[i+1]=="AB")){
                    ret.push_back('A');
                    a++;
                    c--;
                }
                else {
                    ret.push_back('C');
                    c++;
                    a--;
                }
            }
        }
        cout<<"Yes"<<endl;
        for(int i=0;i<n;i++){
            cout<<ret[i]<<endl;
        }
    }
}

Measured memory_bytes: 6644
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=305;
int a[MAX][MAX];
int ans=0;
void wyjdz(){
	cout<<"-1";
	exit(0);
}
int32_t main()
{
  BOOST;
  int n;
  cin>>n;
  for (int i=1;i<=n;i++)
  	for (int j=1;j<=n;j++){
  		cin>>a[i][j];
  	}
  	
  for (int i=1;i<=n;i++){
  	for (int j=1;j<=n;j++){
  		bool czy=true;
  		for (int k=1;k<=n;k++){
  			if (a[i][j]+a[j][k]<a[i][k]  && i!=j && i!=k && j!=k)wyjdz();
  			if (a[i][j]==a[i][k]+a[k][j] && i!=j && j!=k && i!=k)czy=false;
  		}
  		if (czy)ans+=a[i][j];
  	}
  }
  ans>>=1;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  for(int i=0; i<N; i++){string S;
                         cin>>S;
  if(S=="Y"){
      cout<<"Four"<<endl;
    break;
    }
  if(i==N-1){
    cout<<"Three"<<endl;
    break;
}
                        }
}

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

int main() {
	int a[5];
	for(int i=0;i<5;i++)cin>>a[i];
	sort(a,a+5);
	for(int i=4;i>=0;i--)
	{
		if(i!=4)cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3028
#include <iostream>
using namespace std;
long long counter[100001];
int main()
{
  int N;
  long long K;
  cin >> N >> K;
  for (int i = 1; i <= 100000; i++) counter[i] = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    counter[a] += b;
  }
  long long order = 0;
  for (int i = 1; i <= 100000; i++) {
    order += counter[i];
    if (order >= K) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int maxn = 1e5 + 5;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    map<int, int> mp;
    int a, b;
    REP(i, n) {
        scanf("%d", &a);
        mp[a]++;
    }
    REP(i, m) {
        scanf("%d%d", &a, &b);
        mp[b] += a;
    }
    vector<pii> v;
    for (auto& p : mp) {
        v.push_back(p);
    }
    reverse(v.begin(), v.end());
    ll ans = 0, cnt = n;
    for (auto& p : v) {
        if (cnt > p.second) {
            ans += 1LL * p.first * p.second;
            cnt -= p.second;
        } else {
            ans += 1LL * p.first * cnt;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11768
#include<stdio.h>

int main(void){
  int i,j,m,f,r;
  char s;

  for(;;){
    scanf("%d%d%d",&m,&f,&r);
    if(m+f+r == -3) break;

    if(m == -1 || f == -1)
      s = 'F';
    else if(m+f >= 80)
      s = 'A';
    else if(m+f >= 65)
      s = 'B';
    else if(m+f >= 50)
      s = 'C';
    else if(m+f >= 30)
      if(r >= 50)
        s = 'C';
      else
        s = 'D';
    else
      s = 'F';

    printf("%c\n", s);
  }
  
  return 0;
}


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

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   int n, m, k;
   cin >> n >> m >> k;
   vector <string> s(n);
   for (auto &i : s)
      cin >> i;

   ll ans = 0;

   for (int i = 0; i < (1 << n); i++) {
      for (int j = 0; j < (1 << m); j++) {
         int cnt = 0;
         for (int r = 0; r < n; r++) {
            for (int c = 0; c < m; c++) {
               if (!((i & (1 << r)) || (j & (1 << c))))
                  cnt += bool(s[r][c] == '#');
            }
         }
         if (cnt == k)
            ans++;
      }
   }

   cout << ans << '\n';

   return 0;
}

Measured memory_bytes: 3604
n=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if n==1:
    print(0)
    exit()
a=factorization(n)
ans=0
for i in a:
    k=i[1]
    ans+=int((-1+(1+8*k)**(0.5))/2)
print(ans)

Measured memory_bytes: 63324
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int)1e5;
  // static Scanner sc = new Scanner(System.in);
   static List<Integer>[] edge;
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();
	int n = sc.nextInt();
	Double[] r = new Double[n];
	for(int i=0;i<n;++i) r[i] = sc.nextDouble();
	Arrays.sort(r);
	double ans = r[0];
	for(int i=1;i<n;++i) {
		ans = (ans+r[i])/2; 
	}
	out.print(ans);
		out.close();
	}
	
	
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 100005;
const int INF = (LL)1e9 + 5;

int deg[MAXN], ans, N, col[MAXN], dp1[MAXN], dp2[MAXN];
bool ok[MAXN];
vector<int> ch[MAXN], G[MAXN];

bool dfs(int v, int p) {
	ok[v] = col[v];
	for (int to : G[v]) {
		if (to == p) continue;
		ok[v] = dfs(to, v) || ok[v];
	}
	
	if (ok[v] && v != p) {
		ch[p].push_back(v);
		deg[v]++;
		deg[p]++;
		ans += 2;
	}
	
	return ok[v];
}

void dfs2(int v) {
//	cout << "DFS " << v << "\n";
	for (int to : ch[v]) {
		dfs2(to);
		dp1[v] = max(dp1[v], dp1[to] + (deg[to] % 2 == col[to] ? -1 : 1) + 1);
	}
}

void dfs3(int v, int p) {
	int h1 = 0, h2 = 0, who = -1;
	for (int to : ch[v]) {
		int h = dp1[to] + (deg[to] % 2 == col[to] ? -1 : 1) + 1;
		if (h > h1) h1 = h, who = to;
		else if (h > h2) h2 = h;
	}
	
	for (int to : ch[v]) {
		if (to != who) {
			dp2[to] = h1 + (deg[v] % 2 == col[v] ? -1 : 1) + 1;
		}
		else {
			dp2[to] = h2 + (deg[v] % 2 == col[v] ? -1 : 1) + 1;
		}
		
		if (v != p) dp2[to] = max(dp2[to], dp2[v] + (deg[v] % 2 == col[v] ? -1 : 1) + 1);
		
		dfs3(to, v);
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	int all = 0;
	for (int i = 1; i <= N; i++) {
		char ch;
		cin >> ch;
		col[i] = ch == 'W';
		all += col[i];
	}
	
	if (all == 0) {
		cout << "0\n";
		return 0;
	}
	
	int root;
	for (int i = 1; i <= N; i++) {
		if (col[i]) {
			root = i;
			dfs(i, i);
			break;
		}
	}
	
//	cout << "EULER = " << ans << "\n";
	dfs2(root);
	dfs3(root, root);
	
	int res = 0;
	for (int i = 1; i <= N; i++) {
		if (!ok[i]) continue;
		ans += deg[i] % 2 != col[i];
		res = max(res, max(dp1[i], dp2[i]));
//		cout << i << " -> " << dp1[i] << " " << dp2[i] << "\n";
	}
	
	ans -= res;
	
	cout << ans << "\n";
	
	return 0;
	
	/**** Note MAXN ****/
}


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

int main(void){
	int a[101];
  	int n;
  	cin >> n;
  for(int i=0;i<n;i++){
  	cin >> a[i];
  }
  int max=-1,hoge=0;
  for(int i=0;i<n;i++){
    if(a[i]==1)hoge++;
    else{
      if(max<hoge)max=hoge;
      hoge=0;
    }
  }
  if(max<hoge)max=hoge;
  max++;
  cout << max << endl;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
  int n,a,b,c,ans=0;
  vector<int> x,l;  
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    cin>>c;
    x.push_back(c);
  }
  for(int i=1;i<n;i++){
     ans+=min(abs(x[i]-x[i-1])*a,b);
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 4312