akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,ans=0;
  cin>>N>>K;
  int L[N];
  for(int i=0;i<N;i++) cin>>L[i];
  sort(L,L+N);
  for(int i=0;i<K;i++) ans+=L[N-1-i];
  cout<<ans<<endl;
}

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

int main(){
    int a, b, c, d;
    cin >>a >>b >>c >>d;
    while(true){
        c=c-b;
        if(c>0){
		}else{
            cout<<"Yes"<<endl;
            break;
        }
        a=a-d;
        if(a>0){            
        }else{
            cout<<"No"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 3604
import collections

N = int(input())
S = list(input())

c = collections.Counter(S)

ans = c['R'] * c['G'] * c['B']

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        if S[i] != S[j]:
            k = 2 * j - i
            if k < N and S[k] != S[i] and S[k] != S[j]:
                ans -= 1
print(ans)

Measured memory_bytes: 9472
n,k = map(int, input().split())
a =list(map(int, input().split()))
ans =1

if n == k:
   for i in a:
       ans *= i
       if abs(ans) >10**9+7:
           ans = ans%(10**9+7)

elif all(i <= 0 for i in a) and k%2 ==1:
    a.sort(reverse = True)
    for i in range(k):
        ans *= a[i]
        if abs(ans) > 10 ** 9 + 7:
            ans = ans % (10 ** 9 + 7)

else:
    am =[]
    ap =[]

    a.sort(key = abs,reverse = True)
    amax = a[:k]
    amin = a[k:]
    c=1
    if 0 in amax:
        ans = 0
    else:
        for i in amax:
            if i<0:
                am.append(i)
                c *=-1
            elif i>0:
                ap.append(i)
        if c ==1:
            for i in amax:
                ans *= i
                if abs(ans) > 10 ** 9 + 7:
                    ans = ans % (10 ** 9 + 7)
        else:
            if ap == []:
                amax.remove(max(am))
                amax.append(max(amin))

            elif max(am)*min(amin) < min(ap)*max(amin):
                amax.remove(max(am))
                amax.append(max(amin))
            else:
                amax.remove(min(ap))
                amax.append(min(amin))
            for i in amax:
                ans *= i
                if abs(ans) > 10 ** 9 + 7:
                    ans = ans % (10 ** 9 + 7)

print(ans % (10 ** 9 + 7))


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

using namespace std;

#define ll long long
#define ld long double

//#define TEST

static const ll MOD = (ll)1e9 + 7;

signed main() {
	int n; cin >> n;
	string s1, s2;
	cin >> s1 >> s2;

	// aa は1, aは0
	// bb      a
	vector<int> cnd;
	for (int i = 0; i < n; ++i) {
		if (s1[i] == s2[i])
			cnd.push_back(0);
		else {
			if (s1[i] == s1[i + 1] && s2[i] == s2[i + 1]) {
				cnd.push_back(1);
				++i;
			}
			else {
				exit(-1);
			}
		}
	}

#ifdef TEST
	cout << "----------cnd----------" << endl;
	for (auto ci : cnd)
		cout << ci;
	cout << endl;
#endif

	ll ans;
	if (cnd[0] == 1)
		ans = 6;
	else
		ans = 3;

	for (int i = 1; i < cnd.size(); ++i) {
		if (cnd[i - 1] == 0 && cnd[i] == 0) {
			ans *= 2;
			ans %= MOD;
		}
		else if (cnd[i - 1] == 0 && cnd[i] == 1) {
			ans *= 2;
			ans %= MOD;
		}
		else if (cnd[i - 1] == 1 && cnd[i] == 0) {
			continue;
		}
		else {
			ans *= 3;
			ans %= MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int top,S[1000];
 
void push(int x){
    S[++top] = x;
}
 
int pop(){
    top --;
     
    return S[top+1];
}
 
void AandBpop(int *a,int *b){
    *b = pop();
    *a = pop();
}
 
int main(){
    int a,b;
    char s[10];
    top = 0;
     
    while( scanf("%s",s) != EOF){
        if(s[0] == '+'){
            AandBpop(&a,&b);
            push(a+b);
        }else if(s[0] == '-'){
            AandBpop(&a,&b);
            push(a-b);
        }else if(s[0] == '*'){
            AandBpop(&a,&b);
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
     
    printf("%d\n",S[top]);
     
    return 0;
}



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


int main() {
    int n;
    cin >> n;
    vector<ll> h(n,0);
    rep(i,n)cin >> h.at(i);
    for(int i = n-1; i >= 0; i--){
        if(i != n-1){
            if(h[i] <= h[i+1]){
                continue;
            }else if(h[i] == h[i+1]+1){
                h[i]--;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 1024
n = int(input())
p = list(map(int, input().split()))
count = 0
for x in range(2, n):
    if(p[x-2] < p[x-1] and p[x] > p[x-1]):
        count += 1
    elif(p[x-2] > p[x-1] and p[x] < p[x-1]):
        count += 1
print(count)


Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long INF = 2_000_000_000_000_000_000L;
        int N = Integer.parseInt(sc.next());
        long C = Long.parseLong(sc.next());
        long[] x = new long[2*N];
        long[] v = new long[2*N];
        for (int i=0;i<N;i++) {
            x[i] = Long.parseLong(sc.next());
            x[i+N] = x[i]+C;
            v[i] = Long.parseLong(sc.next());
            v[i+N] = v[i];
        }
        long[] profit = new long[2*N];
        profit[N-1] = v[N-1]-(C-x[N-1]);
        profit[N] = v[N]-(x[N]-C);
        for (int i=N-2;i>=0;i--) {
            profit[i] = profit[i+1] + v[i]-(x[i+1]-x[i]);
        }
        for (int i=N+1;i<2*N;i++) {
            profit[i] = profit[i-1] + v[i]-(x[i]-x[i-1]);
        }
        // int l_index=-1;
        // long l_tmp=0;
        // int r_index=-1;
        // long r_tmp=0;
        // for (int i=0;i<N;i++) {
        //     if (profit[i]>=l_tmp) {
        //         l_index=i;
        //         l_tmp=profit[i];
        //     }
        // }
        // for (int i=2*N-1;i>=N;i--) {
        //     if (profit[i]>=r_tmp) {
        //         r_index=i;
        //         r_tmp=profit[i];
        //     }
        // }

        // serach index
        int[] max_index = new int[2*N];
        max_index[N]=N;
        max_index[N-1]=N-1;
        for (int i=N+1;i<2*N;i++) {
            if (profit[max_index[i-1]]<profit[i]) {
                max_index[i]=i;
            } else {
                max_index[i]=max_index[i-1];
            }
        }
        for (int i=N-2;i>=0;i--) {
            if (profit[max_index[i+1]]<profit[i]) {
                max_index[i]=i;
            } else {
                max_index[i]=max_index[i+1];
            }
        }

        long ans=0L;
        ans = Math.max(ans, profit[2*N-1]);
        ans = Math.max(ans, profit[0]);
        for (int i=N;i<2*N-1;i++) {
            long tmp = profit[i];
            ans = Math.max(ans, tmp);
            ans = Math.max(ans, tmp+profit[max_index[i-N+1]]-(x[i]-C));
            // System.out.println(profit[max_index[i-N+1]]);
        }
        for (int i=N-1;i>0;i--) {
            long tmp = profit[i];
            ans = Math.max(ans, tmp);
            ans = Math.max(ans, tmp+profit[max_index[i+N-1]]-(C-x[i]));
        }
        // System.out.println("profit: " + Arrays.toString(profit));
        // System.out.println("max_index: " + Arrays.toString(max_index));
        System.out.println(ans);
        // System.out.println("l_index: " + l_index + " r_index: " + r_index);
    }
}

Measured memory_bytes: 63924
n = gets.to_i

cands = [3,5,7]

$nums = []
def dfs(n, cands)
  return if n && n >= 10**9
  cands.each do |c|
    nn = "#{n}#{c}".to_i
    $nums << nn
    dfs(nn, cands)
  end
end

dfs(nil, cands)

nums = []
$nums.each do |num|
  flg = true
  ["3","5","7"].each do |c|
    flg = false unless num.to_s.chars.include?(c)
  end
  if flg
    nums << num
  end
end

nums.sort!

ans = 0
nums.each do |num|
  if num > n
    break
  else
    ans += 1
  end
end

puts ans


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

using namespace std;

#define PB push_back
#define MP make_pair
#define X first
#define Y second

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define read(a) freopen(a,"r",stdin)
#define write(a) freopen(a,"w",stdout)
#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for(typeof((c).begin())v=(c).begin();v!=(c).end();++v)

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

clock_t start;
void Time(bool timeIt) {
	if (!timeIt) return;
	clock_t end = clock();
	double elapsed_time = ((db)end - (db)start) / (db)CLOCKS_PER_SEC;
	printf("Time elapsed = %0.4lf\n", elapsed_time); 
}

#define LINF (long long)1e18
#define EPS 1e-9
#define INF 1000000007ll
#define SIZE 100010
#define MAX_A 1000010

int main() {
	start = clock();
	int a, b;
	cin >> a >> b;
	bool fl = (a < b);
	if (a < b) cout << a << endl;
	else {
		if (a % b == 0) cout << -1 << endl;
		else cout << a << endl;
	}

	Time(false);
	return 0;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
if k <= a:
    a1 = a - k
    b1 = b
elif a < k and k < a + b:
    a1 = 0
    b1 = b - (k-a)
else:
    a1 = 0
    b1 = 0

print(a1, b1)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
    public static void main(String[] Args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final int[] h = new int[n+1];
        final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
        for(int i = 1; i<=n; i++){
            h[i] = Integer.parseInt(st.nextToken());
        }
        final StringBuilder sb = new StringBuilder();
        for(int i = 1; i<=n; i++){
            sb.append("node ").append(i).append(": key = ").append(h[i]).append(", ");
            if(i>1) sb.append("parent key = ").append(h[i>>>1]).append(", ");;
            if(i+i<=n) sb.append("left key = ").append(h[i+i]).append(", ");
            if(i+i<n) sb.append("right key = ").append(h[i+i+1]).append(", ");
            sb.append('\n');
        }
        System.out.print(sb);
    }
}

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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
	lli n,p;
	lint2(n,p);
	
	if(n==1) {
		cout<<p;
		exit(0);
	}
	map<lli,lli> mpp;
	
	lli pp = sqrt(p);
	
	fors(i,2,pp+1){
		
		if(p==0 or p==1) break;
		
		while(p%i == 0){
			p /= i;
			mpp[i]++;
		}
	}
	lli sum = 1;
	for(auto  it=mpp.begin(); it!=mpp.end(); it++){
		sum *= pow(it->first, (it->second)/n);
	}
	cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int H,W;
  cin >> H >> W;
  vvi a(H,vi(W));
  rep(i,H) {
    rep(j,W) {
      cin >> a[i][j];
    }
  }
  int cnt = 0;
  vector<tuple<int,int,int,int>> ans;
  rep(i,H) {
    rep(j,W) {
      if(a[i][j] % 2 == 1) {
        if(i < H-1) {
          cnt++;
          ans.push_back(tuple<int,int,int,int>(i,j,i+1,j));
          a[i][j]--;
          a[i+1][j]++;
        } else {
          if(j < W-1) {
            cnt++;
            ans.push_back(tuple<int,int,int,int>(i,j,i,j+1));
            a[i][j]--;
            a[i][j+1]++;
          }
        }
      }
    }
  }
  cout << cnt << endl;
  rep(i,sz(ans)) {
    cout << get<0>(ans[i])+1 << " " <<  get<1>(ans[i])+1 << " " <<  get<2>(ans[i])+1 << " " << get<3>(ans[i])+1 << endl;
  }
  return 0;
}

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

bool is_comfortable(const string& s) {
  for (int i = 0; i < (int)s.size(); i++) {
    if (i % 2 == 0) {
      if (s.at(i) == 'L') {
        return false;
      }
    } else {
      if (s.at(i) == 'R') {
        return false;
      }
    }
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  if (is_comfortable(s)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


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

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
	x += y;
	if( x >= m )
		x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
	x -= y;
	if( x < 0 )
		x += m;
}

int main() 
{
	#ifdef gupta_samarth
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	fastio();

	int n,q;
	cin>>n>>q;

	dsu d(n);
	while(q--)
	{
		int t,u,v;
		cin>>t>>u>>v;

		if( t == 0 )
		{
			d.merge(u,v);
		}
		else
		{
			puts( d.same(u,v) ? "1" : "0" );
		}

	}

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 3912
N = int(input())
s = [list(input()) for _ in range(N)]

# in
cnt = [0] * N
for i, si in enumerate(s):
    tmp = 0
    for j in range(len(s[i]) - 1):
        if si[j] == 'A' and si[j + 1] == 'B':
            tmp += 1
    cnt[i] = tmp
# print("#", cnt)
    
# edge
As = 0
Bs = 0
ABs = 0
for i, si in enumerate(s):
    if si[-1] == 'A' and si[0] == 'B':
        ABs += 1
    elif si[-1] == 'A':
        As += 1
    elif si[0] == 'B':
        Bs += 1
# print("#", As, Bs, ABs)
        
ans = 0

# chain of B*A
if ABs > 0:
    ans += max(0, (ABs - 1))
    # edge
    if As > 0:
        ans += 1
        As -= 1
    if Bs > 0:
        ans += 1
        Bs -= 1
    
# left pairs
ans += min(As, Bs) 

print(sum(cnt) + ans)

Measured memory_bytes: 4724
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


bool used[114514];
vector<vector<pint> > edge;

int largest_edges(int v)
{
	int res, largest = -1;
	for (int i = v, prev = edge[v][0].first; ; )
	{
		used[i] = true;
		int next, cost;
		foreach (e, edge[i])
			if (e->first != prev)
				next = e->first, cost = e->second;

		if (largest == cost)
			++res;
		else if (cost > largest)
			largest = cost, res = 1;

		prev = i;
		i = next;
		if (next == v)
			break;
	}
	return res;
}
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		fill_n(used, n, false);
		edge = vector<vector<pint> >(n);
		rep (i, n)
		{
			rep (j, 2)
			{
				int a, b;
				scanf("%d%d", &a, &b);
				edge[i].push_back(pint(a, b));
			}
		}

		int res = 1;
		rep (i, n)
			if (!used[i])
				(res *= largest_edges(i)) %= 10007;
		printf("%d\n", res);
	}
}

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; ++i) {
        cin >> X[i];
    }
    auto Y = X;
    sort(begin(X), end(X));
    vector<int> ord(N);
    for(int i = 0; i < N; ++i) {
        ord[i] = lower_bound(begin(X), end(X), Y[i]) - begin(X);
    }
    for(int i = 0; i < N; ++i) {
        if(ord[i] < N / 2) {
            cout << X[N / 2] << endl;
        } else {
            cout << X[N / 2 - 1] << endl;
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x){
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main(){
    cin >> N;
    repi(i, 1, N+1) {
        cin >> A[i];
        repi(j, 1, A[i] + 1) { 
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    repi(bits, 1, (1 << N)) {
        bool ok = true;
        repi(i, 1, N+1) {
            if(!(bits & (1 << (i-1)))) continue;
            repi(j, 1, A[i]+1) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x, y,prize=0;
	cin >> x >> y;
	if (x == 1 && y == 1)prize += 4;
	if (x == 1)prize += 3;
	if (y == 1)prize += 3;
	if (x == 2)prize += 2;
	if (y == 2)prize += 2;
	if (x == 3)prize += 1;
	if (y == 3)prize += 1;
	cout << setprecision(10) << prize * pow(10,5) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m,l;
 	cin >> n>>m>>l;
 	for (int i = 0; i < 100; i++){
 		if((i*m+l)%n==0){
 			cout << "YES" << endl;
 			return 0;
 		}
 	}
 	cout << "NO" << endl;
 }

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

int n;
long long m;
int w[102], v[102];
int s = 0;
long long f[102][100002];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>n>>m;
    for (int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
        s+=v[i];
    }
    for (int i=0;i<=n;i++){
        for (int j=1;j<=s;j++)
            f[i][j] = 2e14;
    }

    for (int i=0;i<=n;i++) f[i][0] = 0;
    long long res = 0;

    for (int i=1;i<=n;i++){
        for (int j=1;j<=s;j++){
            if (j >= v[i]){
                f[i][j] = min(f[i-1][j], f[i-1][j-v[i]] + w[i]);
            }
            else f[i][j] = f[i-1][j];
        }
    }
    for (int i=1;i<=s;i++){
        if (f[n][i] <= m) res = i;
    }
    cout<<res;




}


Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {
    static int man[];
    static int ans;

    /**
     * @param args
     */
    public static void main(String[] args) throws java.io.IOException {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        while (true) {
            int q1 = sc.nextInt();
            if (q1 == 0)
                break;
            int b = sc.nextInt();
            int c1 = sc.nextInt();
            int c2 = sc.nextInt();
            int q2 = sc.nextInt();
            int buy_aizu = Math.min(q2, b / c1);
            b -= buy_aizu * c1;
            int buy_norm = b / c2;
            int total = buy_aizu + buy_norm;
            if (total < q1)
                for (int i = 1; i <= q2; i++) {
                    total = (int) ((buy_aizu - i) + (c1 * i / c2 + 1+buy_norm));

                    if (total >= q1) {
                        buy_aizu -= i ;
                        buy_norm += c1 * i/ c2 +1;
                        break;
                    }
                }
            if (total >= q1 && buy_aizu > 0)
                System.out.println(buy_aizu + " " + buy_norm);
            else
                System.out.println("NA");
        }
    }
}

Measured memory_bytes: 11000
import math


def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n // b) + n % b


n = int(input())
s = int(input())
bmax = math.floor(math.sqrt(n))

for b in range(2, bmax + 1):
    if f(b, n) == s:
        print(b)
        exit()
for k in range(bmax - 1, 0, -1):
    bb = n // k
    remaining = s - k - n % bb
    if remaining < 0 or remaining >= bb - remaining // k:
        continue
    if remaining % k == 0:
        print(bb - remaining // k)
        exit()
if n > 1 and s == 1:
    print(n)
    exit()
if s == n:
    print(n + 1)
    exit()
print(-1)

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

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

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  set<string> count;
  string S;
  REP(i, N) {
    cin >> S;
    count.insert(S);
  }

  cout << count.size() << endl;

  return 0;
}


Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
int a,c=1;
  cin>>a;
  int d=a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  rep(i,a){
  if(b[i]==c){
  c++;
    b[i]=0;
  }
  }
  rep(i,a){
  if(b[i]==0)
    d--;
  }
  if(d==a)
    cout<<-1;
  else
    cout<<d;
  
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	if(c-a-b<0||4*a*b>=c*c+a*a+b*b-2*a*c+2*a*b-2*b*c){
		cout << "No";
	}
	else{
		cout << "Yes";
	}
	// your code goes here
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int smallCount = 0;
    int bigCount = 0;
    for (int i=1; i<N; i++) {
        if (a[i] != a[i-1]) {
            smallCount = i;
            bigCount = N - i;
        }
    }

    if (a[0] == a[N-1]) {
        if (a[0] <= N / 2 || a[0] + 1 == N) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (a[0] + 1 == a[N-1]) {
        if (bigCount == 1) {
            cout << "No" << endl;
        } else if (smallCount < a[N-1] && smallCount + (bigCount / 2) >= a[N-1]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main()
{
    ll t=1;
    //cin>>t;
    while(t>0)
    {
        t--;
        ll n,k=0,max=LONG_MIN,min=LONG_MAX,flag=0,sum=0,cnt=0,ans=0,gcd=1;
        cin>>n>>k;
        cout<<n*k<<"\n";
        
        
    }
}

Measured memory_bytes: 3636
#include <stdio.h>

int binarySearch(int a[], int n, int key) {
    int left, right, mid;
    left = 0;
    right = n;
    
    while (left < right) {
        mid = (left + right) / 2;
        if (a[mid] == key){
            return 1;
        }
        else if (key < a[mid]){
            right = mid;
        }
        else {
            left = mid + 1;
        }
    }
    return 0;
}

int main() {
    
    int i, n, a[100000], q, key, sum = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    
    scanf("%d", &q);
    
    for (i = 0; i < q; ++i) {
        scanf("%d", &key);
        if (binarySearch(a, n, key)) sum = sum + 1;
    }
    
    printf("%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 2184
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
a1=(a-1)%10
b1=(b-1)%10
c1=(c-1)%10
d1=(d-1)%10
e1=(e-1)%10
ans=-((a//-10)+(b//-10)+(c//-10)+(d//-10)+(e//-10))*10
ans=ans-10+min(a1,b1,c1,d1,e1)+1
print(ans)


Measured memory_bytes: 3064
N = int(input())
S = input()
B = [0] * N
W = [0] * N
for i in range(N):
    B[i] = B[i - 1]
    W[i] = W[i - 1]
    if S[i] == '#':
        B[i] += 1
    else:
        W[i] += 1
ans = W[N - 1]
for i in range(N):
    ans = min(ans, B[i] + W[N - 1] - W[i])
print(ans)

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

string s;
vector<int> p(4);

bool isLetter(char x){
    return 'a'<=x && x<='d';
}

int calc(char op,int lhs,int rhs){
    if(op=='+'){
        return lhs|rhs;
    }
    if(op=='*'){
        return lhs&rhs;
    }
    if(op=='^'){
        return lhs^rhs;
    }
    assert(false);
}
int Hash(int &pos){
    if(isLetter(s[pos])){
        return p[s[pos++]-'a'];
    }
    else{
        assert(s[pos++]=='[');
        char op=s[pos++];
        int lhs=Hash(pos);
        int rhs=Hash(pos);
        assert(s[pos++]==']');
        return calc(op,lhs,rhs);
    }
}
int main(){
    while(cin>>s,s!="."){
        string pbuf;
        cin>>pbuf;
        for(int i=0;i<4;i++){
            p[i]=pbuf[i]-'0';
        }
        int pos=0;
        int h=Hash(pos);
        int res=0;
        for(int a=0;a<10;a++){
            for(int b=0;b<10;b++){
                for(int c=0;c<10;c++){
                    for(int d=0;d<10;d++){
                        p[0]=a,p[1]=b,p[2]=c,p[3]=d;
                        pos=0;
                        if(h==Hash(pos)){
                            res++;
                        }
                    }
                }
            }
        }
        cout<<h<<" "<<res<<endl;
    }
    return 0;
}




Measured memory_bytes: 3076
S = input()
T = input()

m = 0
for i in range(len(S) - len(T) + 1):
    res = 0
    for a, b in zip(T, S[i:i + len(T)]):
        if a == b:
            res += 1
    if res > m:
        m = res

print(len(T) - m)


Measured memory_bytes: 9116
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,a,b,c,d,l,r; cin>>n>>a>>b>>c>>d;
    rep(i,n){
        l=a+i*c-(n-1-i)*d;
        r=a+i*d-(n-1-i)*c;
        if(l<=b && b<=r){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define forn(i,n) for(ll i=0;i < ll (n); i++)
vector<ll>prime_factors[1000007];
ll vis[1000007];

void prime_factor_generator(ll n)
{
    forn(i,n+1)
    {
        if(i<=1) continue;
        if(vis[i]==0)
        {
            for(ll j=i; j<=n; j+=i)
            {
                vis[j]=1;
                prime_factors[j].push_back(i);
            }
        }
    }
    return;
}

int main()
{
    ll n;
    prime_factor_generator(1000000);
    //cout<<endl;
    cin>>n;
    ll ans=-1;
    ll a[n];
    forn(i,n) cin>>a[i];
    ll tem=a[0];
    forn(i,n) tem=__gcd(tem, a[i]);
    if(tem==1) ans=1;
    else ans=3;
    if(ans==1)
    {
        map<ll, ll>mp;
        bool flag=1;
        forn(i,n)
        {
            forn(j,prime_factors[a[i]].size())
            {
                ll t=prime_factors[a[i]][j];
                mp[t]++;
                //cout<<t<<" "<<mp[t]<<endl;
                if(mp[t]==2) {flag=0; break;}
            }
            if(flag==0) break;
        }
        if(flag) ans=2;
    }
    if(ans==1) cout<<"setwise coprime"<<endl;
    else if(ans==2) cout<<"pairwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
    return 0;
}


Measured memory_bytes: 89148
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;



int main(){
    int a;
    cin >> a;
    a %= 10;

    if (a == 3) {
        cout << "bon" << endl;
    } else if(a == 0 || a == 1 || a == 6 || a == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3128
def digit(n):
    res = 0
    while n != 0:
        n //= 10
        res += 1

    return res


n = int(input())
resa = 1
for i in range(int(n**(1/2)),1,-1):
    if n/i-n//i == 0:
        resa = i
        break

resb = n // resa

print(max(digit(resa), digit(resb)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N), sum(N+1);
  rep(i, N) cin >> A[i];
  sort(all(A));
  rep(i, N) sum[i+1] = sum[i] + A[i];
  auto bsearch = [&]() {
    auto test = [&](int k) {
      ll i = 0;
      ll curSum = A[k];
      while(true) {
        int j = upper_bound(all(A), 2*curSum) - begin(A);
        if(i == j) return (i == N ? true : false);
        curSum = sum[j];
        i = j;
      }
    };
    int ok = N-1, ng = -1;
    while(ok-ng>1) {
      int mid = (ok+ng)/2;
      (test(mid)?ok:ng) = mid;
    }
    return N-ok;
  };
  cout << bsearch() << "\n";
  return 0;
}


Measured memory_bytes: 4652
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int main(){
    int n,l=1,ans=0;
    cin >> n;
    for (int i=n; i > 9;i/=10){
        l++;
    }
    //cout << l << endl;
    for (int i = 1; i < l;i++){
        if(i%2==1){
            int p = 1;
            for (int k = 0; k < i;k++){
                p *= 10;
            }
            ans += p-p/10;
        }
    }
    if(l%2==1){
        int p = 1;
        for (int s = 0; s < l - 1;s++){
            p *= 10;
        }
        ans =ans+ n-p + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>
 
#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")
 
#define mp make_pair
#define pb push_back
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
 mt19937 gen(34);

ll n;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
//	freopen("memory.in", "r", stdin);
//	freopen("memory.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	cout << n * (n - 1) / 2;
	return 0;
}

Measured memory_bytes: 256
a, b, c, d = list(map(int, input().split()))

if a > c:
    minx = a
elif a <= c:
    minx = c

if b <= d:
    maxy = b
elif b > d:
    maxy = d

if minx >= maxy:
    print(0)
elif minx < maxy:
    print(maxy - minx)

Measured memory_bytes: 2940
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

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

  vector<pair<int, int> > V;
  for (int i=0; i<n; i++) {
    int num;
    cin >> num;
    V.push_back(pair<int, int>(num-1, i));
  }
  sort(V.begin(), V.end());

  long long res = 0;

  set<pair<int, int> > S;
  S.insert(pair<int, int>(0, n-1));
  for (int i=0; i<n; i++) {
    auto p = S.lower_bound(pair<int, int>(V[i].second, 999999));
    p --;
    int tot = (*p).second - (*p).first + 1;
    int ll = V[i].second - (*p).first;
    int rr = tot - ll - 1;
    res += 1LL * (ll + 1) * (rr + 1) * (V[i].first + 1);
    S.insert(pair<int, int>((*p).first, V[i].second - 1));
    S.insert(pair<int ,int>(V[i].second + 1, (*p).second));
    S.erase(p);
  }

  cout << res << endl;
}



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

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

}


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

int main() {
    int a,b,x;
    cin >> a >> b >> x;
    if(a <= x && x <= a+b) cout << "YES" << endl;
    else cout << "NO" << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n, res = 0;
    cin>>n;
    int a[n+2];
    for(int i = 1; i <= n; i++)
    {
        cin>>a[i];
        if(i % 2 && a[i] % 2)res++;
    }
    cout<<res<<endl;
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n, m;

VI k;
VI s;
VI p;


bool isOK(int bit){
    REP(i, m){
        if (__builtin_popcount(bit & s[i]) % 2 != p[i]) return false;
    }
    return true;
}

signed main()
{
    cin >> n >> m;
    REP(i, m){
        int a;
        cin >> a;
        k.push_back(a);
        int mask = 0;
        REP(i, a){
            int b;
            cin >> b;
            mask |= (1<<(b-1));
        }
        s.push_back(mask);
    }
    REP(i, m){
        int a;
        cin >> a;
        p.push_back(a);
    }

    int cnt = 0;
    REP(bit, 1<<n){
        if (isOK(bit)) cnt++; 
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
int main() {
	int h=1, w=1;
	while (h != 0 && w != 0) {
		cin >> h;
		cin >> w;
		if (h == 0 && w == 0) continue;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include<stdio.h>
int main(){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		else if(x<y){
			printf("%d %d\n",x,y);
		}
		else{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}


Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		for (int i = 0; i < 10; i++) {
			x = r * x - d;
			System.out.println(x);
		}
		sc.close();
	}
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
	NodePointer cur = nil->next;
	while(cur != nil && cur->key !=key){
	cur = cur->next;
	}
	return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
	if(t == nil)return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
	deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
	deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* 
   your code 
  */
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 32988
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    for _ in 0..min(50, k) {
        let mut b = vec![0i64; n + 1];
        for j in 0..n {
            b[j.saturating_sub(a[j])] += 1;
            b[min(n - 1, j + a[j]) + 1] -= 1;
        }
        for j in 0..n {
            b[j + 1] += b[j];
            a[j] = b[j] as usize;
        }
    }
    let mut out = Vec::new();
    for i in 0..n {
        write!(out, "{}", a[i]).ok();
        if i == n - 1 {
            writeln!(out, "").ok();
        } else {
            write!(out, " ").ok();
        }
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 7228
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] v = nextIntArray(sc, N);

		sc.close();

		Arrays.sort(v);

		double ans = 0;

		ans = (v[0] + v[1]) / 2.0;

		for (int i = 2; i < N; i++) {
			ans = (ans + v[i]) / 2;
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 23892
#include <iostream>

int main()
{
	int s = 0;
	int a,b,s2;
	std::cin >> a;
	s2 = a;
	while (1)
	{
		b = a / 10;
		s += a - (b * 10);
		a = b;
		if (b == 0)
		{
			break;
		}
	}
	switch (s2 % s)
	{
	case 0:
		std::cout << "Yes" << std::endl;
		break;
	default:
		std::cout << "No" << std::endl;
		break;
	}
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c) 
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll n;
    str s[MAX_N];
    ll answer = 0;
    
    in1(n);
    rin1(i,n,s);
    rep(i,n) if (s[i][0] == 'Y') {prl("Four"); return 0;}

    prl("Three");
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i=(int)s;i<(int)n;i++)
int main(){
  int n,c=0; cin>>n;
  vector<int> l(n); rep(i,0,n) cin>>l[i];
  sort(l.begin(),l.end());
  rep(i,0,l.size()-2){
    rep(j,i+1,l.size()-1){
      rep(k,j+1,l.size()){
        if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
          if(l[i]+l[j]>l[k]) c++;
        }
      }
    }
  }
  cout<<c;
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int func(int num) {
	if (num == 1)return 1;
	return 2 * func(num/2) + 1;
}
signed main() {
	int H;
	cin >> H;
	cout << func(H);
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    var ary = Array<Long>(k){0}.toMutableList()
    var ans = 0L
    (1..n).forEach {i ->  ary[i%k] += 1}
    (0 until k).forEach { a ->
        var b = (k-a) % k
        var c = (k-a) % k
        if ((b+c) % k != 0) return@forEach
        ans += ary[a] * ary[b] * ary[c]
    }
    println(ans)
}

Measured memory_bytes: 40688
#include<stdio.h>
int main()
{
	int a,b,c,d,x=0;
	scanf("%d %d %d %d",&a,&b,&c,&d);
 if(a<b) x+=a;
 else x+=b;
 if(c<d) x+=c;
 else x+=d;
 printf("%d\n",x);
}

Measured memory_bytes: 1728