akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
  int a,b,c,d;
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  
  long long int A[2];
  long long int B[2];
  
  A[0]=a;
  A[1]=b;
  
  B[0]=c;
  B[1]=d;
  
  long int max=A[0]*B[0];
  long int product;
  for(int i=0;i<2;i++)
  {
      for(int j=0;j<2;j++)
      {
          product=A[i]*B[j];
          if(product>max)
          {
          max=product;
          }
      }
  }
  cout<<max;
  return 0;
}

Measured memory_bytes: 3640
import java.io.*;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicLong;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        String s = in.next();
        AtomicLong ans = new AtomicLong();

        dfs(s, new boolean[s.length()-1], 0, ans);
        out.println(ans.get());
    }

    private static void dfs(String s, boolean[] plus, int current, AtomicLong ans) {
        if (current == plus.length) {
            ans.addAndGet(value(s, plus));
            return;
        }

        plus[current] = true;
        dfs(s, plus, current+1, ans);
        plus[current] = false;
        dfs(s, plus, current+1, ans);
    }

    private static long value(String s, boolean[] plus) {
        long ret = 0;
        int left = 0;
        for (int i = 0; i < plus.length; i++) {
            if (plus[i]) {
                ret += Long.parseLong(s.substring(left, i+1));
                left = i+1;
            }
        }
        ret += Long.parseLong(s.substring(left));
        return ret;
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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


Measured memory_bytes: 20564
#include<iostream>
#include<algorithm>
#include<vector>
int main() {
	std::vector<int>w;
	std::vector<int>k;
	for (int i = 0; i < 10; ++i) {
		int num;
		std::cin >> num;
		w.push_back(num);
	}
	for (int i = 0; i < 10; ++i) {
		int num;
		std::cin >> num;
		k.push_back(num);
	}
	std::sort(w.begin(), w.end());
	std::sort(k.begin(), k.end());
	std::cout << w[9] + w[8] + w[7] << " " << k[9] + k[8] + k[7] << std::endl;
	return 0;
}

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

long long INF=pow(10LL, 8LL);

int main(){
  long long H, N;
  cin >> H >> N;
  
  long long A[N], B[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  
  long long dp[N+1][H +1]; //i番目にjのダメージを与えるときの魔力の最小値
  
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= H; j++) {
      dp[i][j]= INF;
    }
  }
  dp[0][0] = 0LL;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < H; j++) {
      dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
      dp[i+1][min(j+A[i],H)] = min({dp[i][min(j+A[i],H)],dp[i+1][min(j+A[i],H)], dp[i+1][j]+B[i]});
    }
  }

  cout << dp[N][H] << endl;
  
  return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }


int main() {
  lint n,c,k; cin >> n >> c >> k;
  vector<lint> t(n); for(lint i=0;i<n;i++) { cin >> t[i]; }

  sort(t.begin(),t.end()); // ok

  lint ans=1,cnt=1,index=0;
  for(lint i=1;i<n;i++) {

    if(t[i] <= t[index]+k) {
      cnt++;

      if(cnt >= c) {
        cnt = 0;
        ans++;
        index = i;
      }

    } else {
      cnt = 0;
      ans++;
      index = i;
    }

  }

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

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

int main(){
  int N, M; cin >> N >> M;

  vector<int> ans(N, -1);
  rep(i, M) {
    int s, c; cin >> s >> c; s--;
    if (ans[s] == -1) ans[s] = c;
    else if (ans[s] != c) {
      cout << -1 << endl;
      return 0;
    }
  }

  rep(i, N) if(ans[i] == -1) {
    if (N != 1 && i == 0) ans[i] = 1;
    else ans[i] = 0;
  }

  if (N != 1 && ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  }

  rep(i, N) cout << ans[i];
}


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

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

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


int main()
{
	int k;
	cin >> k;
	ll d = 7;
	for (int i = 1; i <= 7; i++) {
		if (d % k == 0) {
			cout << i << endl;
			return 0;
		}
		d = d * 10 + 7;
	}

	ll m = 7777777 % k;
	Vb Is(k, false);
	ll cnt = 7;
	while (!Is[m]) {
		cnt++;
		Is[m] = true;
		//cout << m << endl;
		m = (m * 10 + 7) % k;
		if (m == 0) {
			cout << cnt << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3704
#include<stdio.h>

int main(void)
{
   int a,b,c,d;

   scanf("%d",&a);
   scanf("%d",&b);
   scanf("%d",&c);
   scanf("%d",&d);

   if(a>b)
     a = b;
   if(c>d)
     c = d;
   printf("%d\n",a+c);
   return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define NO_DATA -1
#define MAX_COUNT 50

int main(int argc, const char * argv[]) {
    int result[MAX_COUNT][2];
    int a,b;
    int scanResult;
    
    for (int i = 0; i < MAX_COUNT; i++ ) {
        result[i][0] = NO_DATA;
        result[i][1] = NO_DATA;
    }
    
    int count=0;
    scanResult = scanf("%d %d", &a, &b);
    
    while (scanResult!=EOF) {
        
        if(a<b){
           int tmp = a;
           a = b;
           b = tmp;
         }
        
        int r = a % b;
        int x,y=b;
        while(r!=0){
          x = y;
          y = r;
          r = x % y;
        }

        result[count][0] = y;
        result[count][1] = a/y*b;

        count++;
        scanResult = scanf("%d %d", &a, &b);
    }
    
    for (int i=0;i<count;i++) {
        printf("%d %d\n", result[i][0], result[i][1]);
    }
    return 0;
}



Measured memory_bytes: 1932
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;



int main()
{
    ll A, B, N;
    cin >> A >> B >> N;
    
    ll x = min(N, B-1);
    ll ans = (A*x)/B - A*(x/B);

    cout << ans << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include<cmath>
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main()
{

    int x;
	cin>>x;
	for(ll i=-3000;i<3001;i++){
		for(ll j=-3000;j<3001;j++){
			ll a=i*i*i*i*i;
			ll b=j*j*j*j*j;
			if(a-b==x){
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	}
}

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

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
	if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
	if(H==T) return -1;return *H++;
}
inline int read()
{
	int x=0;char c=Get();
	while(!isdigit(c)) c=Get();
	while(isdigit(c)) x=x*10+c-'0',c=Get();
	return x;
}

inline void upmax(int &x,const int &y){if(y>x) x=y;}
inline void upmin(int &x,const int &y){if(y<x) x=y;}

const int N=200010;
struct Edge{int to,next;} e[N];
int h[N],sum=0,n;
int fa[N],mex[N];
bool vis[N],loop[N];
bool have[N];

void add_edge(int u,int v)
{
	e[++sum].to=v;
	e[sum].next=h[u];
	h[u]=sum;
}

void dfs(int u)
{
	for(int t=h[u];t;t=e[t].next)
		if(!loop[e[t].to]) dfs(e[t].to);
	for(int t=h[u];t;t=e[t].next)
		if(!loop[e[t].to]) have[mex[e[t].to]]=1;
	while(have[mex[u]]) mex[u]++;
	for(int t=h[u];t;t=e[t].next)
		if(!loop[e[t].to]) have[mex[e[t].to]]=0;
}

int main()
{
	//freopen("C.in","r",stdin);
	int n,x=1;
	n=read();
	for(int i=1;i<=n;i++)
	{
		fa[i]=read();
		add_edge(fa[i],i);
	}
	while(!vis[x]) vis[x]=1,x=fa[x];
	while(!loop[x]) loop[x]=1,x=fa[x];
	int mx=-1,mn=n+1,cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(!loop[i]) continue;
		dfs(i);cnt++;
		upmax(mx,mex[i]);
		upmin(mn,mex[i]);
	}
	puts(mx==mn&&(cnt&1)?"IMPOSSIBLE":"POSSIBLE");
	return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=2e5+9;
	string a[N],b[N];
	map<string,int> m;
	int main(){
		int n=read<int>(),cnt=0,mx=0;
		for(int i=1;i<=n;i++) cin>>a[i],m[a[i]]++,mx=max(mx,m[a[i]]);
		for(int i=1;i<=n;i++) if(mx==m[a[i]]) b[++cnt]=a[i];
		sort(b+1,b+cnt+1);
		cnt=unique(b+1,b+cnt+1)-b-1;
		for(int i=1;i<=cnt;i++)
			cout<<b[i]<<endl;
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

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



int main(){
    string s;
    cin >> s;
    ll n=s.size();
    ll l=0;
    ll r=n-1;
    bool flag=true;
    ll res=0;
    while(r>=l){
        if(s[r]==s[l]){
            l++;
            r--;
        }
        else if(s[l]=='x'&&s[r]!='x'){
            l++;
            res++;
        }
        else if(s[l]!='x'&&s[r]=='x'){
            r--;
            res++;
        }
        else if(s[l]!='x'&&s[r]!='x'&&s[l]!=s[r]){
            flag=false;
            break;
        }
    }
    if(!flag) cout << -1 << endl;
    else cout << res << endl;
    return 0;
}  


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

namespace Aojx
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var data = Console.ReadLine().Split(' ');
            Dictionary<string, int> d = new Dictionary<string, int>();

            foreach (string w in data)
            {
                if (d.ContainsKey(w))
                {
                    d[w]++;
                }
                else
                {
                    d[w] = 1;
                }
            }

            var sd = d.OrderByDescending(e => e.Value);
            var longest = d.OrderByDescending(e => e.Key.Length).First().Key;

            Console.WriteLine("{0} {1}", sd.First().Key, longest);
        }
    }
}

Measured memory_bytes: 6276
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <algorithm>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k;
  ld tmp=0.0,result=0.0;
  int x[LIMIT2]={0},y[LIMIT1]={0};
  char s[LIMIT1];
  std::vector<ll> p;
  
  scanf("%lld",&n);
  rep(i,n) scanf("%d %d",&x[i],&y[i]);
  rep(i,n) p.push_back(i);
  do{
    j = p.size();
    tmp = 0.0;
    for(i=0;i<j-1;i++){
      tmp += hypotl(labs(x[p[i]]-x[p[i+1]]),labs(y[p[i]]-y[p[i+1]]));
    }
    result += tmp;
  }while(std::next_permutation(p.begin(),p.end()));
  printf("%.10Lf\n",result/nPr(n,n));
  return 0;
}



Measured memory_bytes: 2944
a,b,c,x = 4.times.map{gets.to_i}
ans = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      ans +=1 if  500*i + 100*j + 50*k ==x
    end
  end
end
puts ans
  

Measured memory_bytes: 1788
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"

using namespace std;
typedef long long ll;

int main()
{
  int a[4];
  for (int i = 0; i < 4; i++)
  {
    cin >> a[i];
  }
  sort(a, a + 4);
  if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)
  {
    cout << "YES" << "\n";
  }
  else
  {
    cout << "NO" << "\n";
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long p[1<<17],N,Q,A,R,sum,cnt;
int main() {
	cin>>N>>Q;for (int i=0;i<N;i++)cin>>p[i];
	while(Q--){
		sum=0,R=0;cin>>A;cnt=0;
		for(int i=0;i<N;i++){
			while(R<N&&sum+p[R]<=A)sum+=p[R++];
			if(sum>0)sum-=p[i];
			cnt+=R-i;if(R<i+1)R=i+1;
		}
		cout<<cnt<<endl;
	}
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll a,b,k; cin>>a>>b>>k;
	for (int i=0; i<k; i++) {
		if(i%2) swap(a,b);
		if(a%2) a--;
		a/=2;
		b+=a;
		if(i%2) swap(a,b);
	}
	cout<<a<<" "<<b<<"\n";
	return 0;
}

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

using namespace std;

int main()
{
    string s;
    int cnt;
    while (1)
    {
        cin>>s;
        if (s=="0") break;
        cnt=0;
        for (int i=0; i<s.size(); i++) cnt+=s[i]-'0';
        cout<<cnt<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3144
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
 
void main()
{
    string n;
    
    n = readln;
    
    if (
        n[0..1] == "7"
        || n[1..2] == "7"
        || n[2..3] == "7"
    ) {
        writeln("Yes");
    } else {
        writeln("No");
    }
}


Measured memory_bytes: 2652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes\n";
  else cout<<"No\n";
}

int main(){
    ios::sync_with_stdio(false);
  cin.tie(0);
    cout<<fixed<<setprecision(15);
  solve();
    return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val Array(x1, y1, x2, y2, _*) = io.StdIn.readLine().split(" ").map(_.toDouble)

    val dx = Math.abs(x2 - x1)
    val dy = Math.abs(y2 - y1)
    val d = Math.sqrt(dx * dx + dy * dy)
    println(f"$d%.8f")
  }
}

Measured memory_bytes: 44216
import sys
from collections import Counter

def solve():
    N, K = map(int, input().split())
    cntr = Counter()

    for i in range(N):
        ai, bi = map(int, sys.stdin.readline().split())
        cntr[ai] += bi

    cntr = sorted(cntr.items())
    # print(cntr)

    cnt = 0

    for a, b in cntr:
        cnt += b

        if cnt >= K:
            print(a)
            return


if __name__ == '__main__':
    solve()

Measured memory_bytes: 14940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int N;
int A[212345];
ll sum[212345]; // 1-indexed

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	
	REP(i, N) sum[i + 1] = sum[i] + A[i];
	
	ll ans = INFL;
	
	int l = 1, r = 3;
	
	FOR(i, 2, N - 1) { // AB:[0,i), CD:[i,N)
		// A: [0, l)
		// B: [l, i)
		// C: [i, r)
		// D: [r, N)
		
		chmax(r, i + 1);
		
		while (l + 1 < i && sum[l + 1] - sum[0] < sum[i] - sum[l + 1]) l++;
		while (r + 1 < N && sum[r + 1] - sum[i] < sum[N] - sum[r + 1]) r++;
		
		vector<pll> p[2];
		p[0].push_back(pll(sum[l] - sum[0], sum[i] - sum[l]));
		if (l + 1 < i) p[0].push_back(pll(sum[l + 1] - sum[0], sum[i] - sum[l + 1]));
		
		p[1].push_back(pll(sum[r] - sum[i], sum[N] - sum[r]));
		if (r + 1 < N) p[1].push_back(pll(sum[r + 1] - sum[i], sum[N] - sum[r + 1]));
		
		REP(j, p[0].size()) {
			if (p[0][j].fi > p[0][j].se) swap(p[0][j].fi, p[0][j].se);
			
			REP(k, p[1].size()) {
				if (p[1][k].fi > p[1][k].se) swap(p[1][k].fi, p[1][k].se);
				chmin(ans, max(p[0][j].se, p[1][k].se) - min(p[0][j].fi, p[1][k].fi));
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> num(n+1, 0);
    for (int i=1; i<=n; i++) {
        int cur = i;
        for (int j=2; j<=n; j++) {
            if (i < j) break;
            while (cur%j == 0) {
                num[j]++;
                cur /= j;
            }
        }
    }
    vector<int> ans(75, 0);
    rep(i, n+1) {
        if (num[i] >= 74) ans[74]++;
        if (num[i] >= 24) ans[24]++;
        if (num[i] >= 14) ans[14]++;
        if (num[i] >= 4) ans[4]++;
        if (num[i] >= 2) ans[2]++;
    }

    cout << ans[74] + ans[24]*(ans[2]-1) + ans[14]*(ans[4]-1) + ans[4]*(ans[4]-1)*(ans[2]-2)/2 << endl;
}


Measured memory_bytes: 256
n = int(input())
ls = {'M':0,'A':0,'R':0,'C':0,'H':0}
head = set(["M","A","R","C","H"])

for i in range(n):
    s = input()
    if s[0] in head:
        ls[s[0]] += 1

head = list(head)
ans = 0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += ls[head[i]]*ls[head[j]]*ls[head[k]]
print(ans)

Measured memory_bytes: 43496
### subroutines

def fit?(b, x1, y1, x2, y2, grnds)
  for y in (y1..y2)
    for x in (x1..x2)
      return false if grnds[y][x] > 0 && grnds[y][x] != b
    end
  end
  true
end

def divk(k)
  for i in (1..k)
    if k % i == 0
      yield k / i, i
    end
  end
end

def gen_rects(b, k, x, y, grnds, w, h)
  rects = []

  divk(k) do |w0, h0|
    next if w0 > w || h0 > h

    for y0 in (0...h0)
      y1 = y - y0
      y2 = y + h0 - 1 - y0
      next if y1 < 0 || y2 >= h

      for x0 in (0...w0)
        x1 = x - x0
        x2 = x + w0 - 1 - x0
        next if x1 < 0 || x2 >= w

        if fit?(b, x1, y1, x2, y2, grnds)
          rects << [x1, y1, x2, y2]
        end
      end
    end
  end

  rects
end

def fill_rect(b, x1, y1, x2, y2, grnds)
  for y in (y1..y2)
    for x in (x1..x2)
      grnds[y][x] = b
    end
  end
end

def place_rec(id, n, buyers, grnds)
  if id >= n
    return [1, grnds.map{|hl| hl.map{|b| b}}]
  end

  count = 0
  gans = nil

  bi = buyers[id]
  for r in bi[4]
    if fit?(bi[0], *r, grnds)
      fill_rect(bi[0], *r, grnds)
      count0, gans0 = place_rec(id + 1, n, buyers, grnds)
      fill_rect(0, *r, grnds)
      grnds[bi[3]][bi[2]] = bi[0]

      count += count0
      if count > 1
        return [count, nil]
      elsif count0 == 1
        gans = gans0
      end
    end
  end

  [count, gans]
end

### main

while true
  w, h, n = gets.strip.split(' ').map{|s| s.to_i}
  break if w + h + n == 0

  buyers = []
  ksum = 0

  n.times.each do
    b, k = gets.strip.split(' ').map{|s| s.to_i}
    buyers[b - 1] = [b, k]
    ksum += k
  end

  if ksum != w * h
    h.times.each{gets}
    puts 'NA'
    next
  end

  grnds = h.times.map{gets.strip.split(' ').map{|s| s.to_i}}

  for y in (0...h)
    for x in (0...w)
      b = grnds[y][x]
      if b > 0
        b0 = buyers[b - 1]
        b0[2] = x
        b0[3] = y
        b0[4] = gen_rects(b0[0], b0[1], x, y, grnds, w, h)
      end
    end
  end
  #p grnds
  #p buyers

  count, gans = place_rec(0, n, buyers, grnds)

  if count != 1
    puts 'NA'
  else
    for hl in gans
      puts hl.join(' ')
    end
  end
end

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

int main(){
    int n;
    cin>>n;
    map<int,int> s;
    int d[3];
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>d[j];
        }
        sort(d,d+3);
        s[d[0]*1000000+d[1]*10000+d[2]]=1;
    }
    cout<<n-s.size()<<endl;
    return 0;
}


Measured memory_bytes: 3192
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
p1,p2,p3=0,0,0
Dxy=[0]*(n+1)
for i in range(n):
    Dxy[i]=abs(x[i]-y[i])
    p1+=Dxy[i]
    p2+=Dxy[i]**2
    p3+=Dxy[i]**3
p2**=0.5
p3**=(1/3)
print(p1,p2,p3,max(Dxy),sep='\n')


Measured memory_bytes: 5652
/*
ex4_3
tomatokan
*/
#include<stdio.h>
int get_snow_depth(int,int);/*プロトタイプ宣言*/

int main(void){
    int height_west,height_east;
    scanf("%d",&height_west);
    scanf("%d",&height_east);
    printf("%d",get_snow_depth(height_west,height_east));/*関数の呼び出し*/
    return 0;
}

int get_snow_depth(int west,int east){
    return (east*east-2*east*west+west*west-east-west)/2;
}

Measured memory_bytes: 128
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int[] points=new int[s.nextInt()];
		int[] targets=new int[s.nextInt()];
		for(int i=0;i<targets.length;i++)
			targets[i]=s.nextInt();
		int c;
		for(int t:targets) {
			c=0;
			for(int j=0;j<points.length;++j) {
				if(t==s.nextInt())
					points[j]++;
				else
					c++;
			}
			points[t-1]+=c;
		}
		for(int i:points)
			System.out.println(i);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<ll>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define possible(n) cout<<((n)?"possible":"impossible")<<endl
#define Possible(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
	int n;
	cin>>n;
	REP(c,25){
		REP(d,15){
			if(c*4+d*7==n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  for_each(H.begin(), H.end(), [](int& e) { cin >> e; });

  vector<int> Hmax;
  auto pmax = [](int& acc, int& e) { return max(acc, e); };
  partial_sum(H.begin(), H.end(), back_inserter(Hmax), pmax);

  vector<int> diffv;
  auto sub = [](int& h, int& hm) { return h - hm; };
  transform(H.begin(), H.end(), Hmax.begin(), back_inserter(diffv), sub);

  auto noneNegativeP = [](int& x) { return x >= 0; };
  cout << count_if(diffv.begin(), diffv.end(), noneNegativeP) << endl;

  return 0;
}


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

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

bool isHarshad(int n) {
	int sum = 0;
	int m = n;
	while (m > 0) {
		sum += m % 10;
		m /= 10;
	}
	return n % sum == 0;
}

int main() {
	int n;
	cin >> n;
	if (isHarshad(n)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int r,c,k;
	cin >> r >> c >> k;
	vector <vector <int>> a(r,vector <int>(c));
	for(int i = 0;i < k;++i){
		int ri,ci,vi;
		cin >> ri >> ci >> vi;
		--ri,--ci;
		a[ri][ci] = vi;
	}	
	vector <vector <lli>> dp(4,vector <lli>(r * c));
	dp[3][(r - 1) * c + c - 1] = dp[2][(r - 1) * c + c - 1] = dp[1][(r - 1) * c + c - 1] = a[r - 1][c - 1];
	dp[0][(r - 1) * c + c - 1] = 0;
	for(int i = r - 2;i >= 0;--i){
		dp[3][i * c + c - 1] = dp[3][(i + 1) * c + c - 1] + a[i][c - 1];
		dp[2][i * c + c - 1] = dp[2][(i + 1) * c + c - 1] + a[i][c - 1];
		dp[1][i * c + c - 1] = dp[1][(i + 1) * c + c - 1] + a[i][c - 1];
		dp[0][i * c + c - 1] = 0;
	}
	for(int j = c - 2;j >= 0;--j){
		dp[3][(r - 1) * c + j] = max(dp[2][(r - 1) * c + j + 1] + a[r - 1][j], dp[3][(r - 1) * c + j + 1]);
		dp[2][(r - 1) * c + j] = max(dp[1][(r - 1) * c + j + 1] + a[r - 1][j], dp[2][(r - 1) * c + j + 1]);
		dp[1][(r - 1) * c + j] = max(dp[0][(r - 1) * c + j + 1] + a[r - 1][j], dp[1][(r - 1) * c + j + 1]);
		dp[0][(r - 1) * c + j] = 0;
	}
	for(int i = r - 2;i >= 0;--i){
		for(int j = c - 2;j >= 0;--j){
			dp[3][i * c + j] = max(max(dp[2][i * c + j + 1] + a[i][j],dp[3][(i + 1) * c + j] + a[i][j]),dp[3][i * c + j + 1]);
			dp[2][i * c + j] = max(max(dp[1][i * c + j + 1] + a[i][j],dp[3][(i + 1) * c + j] + a[i][j]),dp[2][i * c + j + 1]);
			dp[1][i * c + j] = max(max(dp[0][i * c + j + 1] + a[i][j],dp[3][(i + 1) * c + j] + a[i][j]),dp[1][i * c + j + 1]);
			dp[0][i * c + j] = dp[3][(i + 1) * c + j];
		}
	}
	cout << dp[3][0] << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 390152
#pragma GCC optimize("-O3")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<vector>
#include<bitset>
#define DB long double
#define LL long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
  
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int x){
    if(x>9) Out(x/10);
    putchar('0'+x%10);
}
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
LL qpow(LL x,LL y,LL P){
    LL re=1;
    while(y){
        if(y&1) re=re*x%P;
        x=x*x%P;y>>=1;
    }
    return re;
}
const DB eps=1e-8;
const LL P=10000019;
const DB PI=acos(-1);
const LL inf=1e9;
const int N=110;
int n;
bool vis[N];
vector<int> ve[110];
int tp=0;
int l[N*N],r[N*N];
bool check(int x,int y){
	for(int i=1;i<=n;++i){
		vis[i]=0;ve[i].clear();
	}
	int z;
	for(int i=1;i<=y;++i){
		z=x;
		for(int j=n;j>=1;--j){
			if(j>z) continue;
			if(!vis[j]){
				vis[j]=1;
				z-=j;
				ve[i].push_back(j);
			}
		}
		if(z!=0) return 0;
	}
	for(int i=1;i<=y;++i){
		for(int j=i+1;j<=y;++j){
			for(int it=0;it<ve[i].size();++it){
				for(int jt=0;jt<ve[j].size();++jt){
					++tp;
					l[tp]=ve[i][it];
					r[tp]=ve[j][jt];
				}
			}
		}
	}
	cout<<tp<<endl;
	for(int i=1;i<=tp;++i) printf("%d %d\n",l[i],r[i]);
	return 1;
}
int main(){
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;++i) sum+=i;
	for(int i=2;;++i){
		if(sum%i!=0) continue;
		if(check(sum/i,i)) return 0;
	}
}
/*
5 4 4 1
1 2 3
2 3 4
3 4 5
4 5 6
*/

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

int main(){
    int N;std::cin>>N;
    std::set<int> st;
    for(int i=0;i<N;++i){
        int a;std::cin>>a;
        if(st.count(a)){
            st.erase(a);
        }
        else{
            st.insert(a);
        }
    }
    std::cout<<st.size()<<std::endl;
}


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

namespace Atcorder_text
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long k = long.Parse(input[1]);

            long[] Enemy = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            Array.Sort(Enemy);

            if (k >= n)
            {
                Console.Write(0);
            }
            else
            {
                long[] hp = new long[n - k];
                Array.Copy(Enemy, 0, hp, 0, n - k);

                long sum = hp.Sum();

                Console.Write(sum);
            }
            Console.Read();
        }
    }
}


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

using ll = long long;

#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 pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

template <class T>
bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T>
bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll N; cin >> N;
	int ans = INT32_MAX;
	FOR(i,1, N) {
		string s1 = to_string(i);
		string s2 = to_string(N - i);
		int cnt = 0;
		REP(j, s1.size()) {
			cnt += s1[j] - '0';
		}
		REP(j, s2.size()) {
			cnt += s2[j] - '0';
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
  
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int n = 0;
    int sum = 0;
    scanf("%d", &n);
    int t[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &t[i]);
    }
    for (int j = 0; j < n; j++){
        //prinrf("%d ", t[j]);
        for (int k = j + 1; k < n; k++){
            sum = sum + t[j] * t[k];
        }
    }
    printf("%d", sum);
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD ((ll)1e9+7)
ll Ln;
char L[101010];
ll dp[101010];
ll i,j,k,ans;
int main(){
    scanf("%s", L);
    dp[0] = 1;
    for (i = 0; L[i];i++){
        dp[i + 1] = dp[i] * 3%MOD;
    }
    Ln = i;
    //printf("%lld\n", dp[1]);
    k = 1;
    for (--i; i >= 0;i--){
        if(L[Ln-1-i]=='1'){
            ans = (ans + dp[i]*k) % MOD;
            k = k * 2 % MOD;
        }
    }
    ans = (ans + k) % MOD;
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;

vector< int > v[26];

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    if(a > b) swap(a, b);
    if(a == 5 and b == 5 and c == 7) puts("YES");
    else puts("NO");
}

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

using namespace std;

//typeDef
typedef long long           lli;
typedef long                li;
typedef vector<int>         vi;
typedef vector<li>          vli;
typedef vector<lli>         vlli;
typedef map<int, int>       mii;
typedef set<int>            seti;
typedef queue<int>          qi;
typedef deque<int>          dqi;
typedef stack<int>          stacki;
typedef multiset<int>       mseti;

//loop
#define rep(i, n)         for(int i = 0; i < n; ++i)
#define fori(i, a, b)     for(int i = a; i <= b; ++i)
#define ifor(i, a, b)     for(int i = a; i >= b; --i)

//Pair
#define mp                  make_pair
#define iPair               pair<int, int>
#define lliPair             pair<lli, lli>

//Extras
#define mod1                    1e9 + 7
#define mod2                    1e9 + 9
#define inf                     int(1e9)
#define INF                     lli(1e18)
#define pi                      3.14159265358979
#define pb                      push_back
#define pf                      push_front
#define popb                    pop_back()
#define popf                    pop_front()
#define ff                      first
#define ss                      second
#define all(v)                  v.begin(), v.end()
#define iter(container, it)     for(auto it = container.begin(); it != container.end(); ++it)

//functions
lli gcd(lli a, lli b) { return (a == 0) ? b : gcd(b % a, a); }
lli lcm(lli a, lli b) { return a / gcd(a, b) * b; }


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

      int n;
      cin >> n;
      
      int a = 1;
      while (a * 2 < n){
            a *= 2;
      }
      
      if (a * 2 == n){
            a *= 2;
      }
      
      cout << a;
      
      return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


class BIT{
private:
    //[1,n]
    vector<int> bit;
    int n;

public:
    BIT(){}
    BIT(int size){
        n = size;
        bit = vector<int>(n+1,0);
    }
    //[0,i)のsum（内部実装は[1,i]）
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x){
        while(i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }
    void show(){
        for(int i = 1; i <= n; i++){
            cout << " " << bit[i];
        }
        cout << endl;
    }
};

signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    int l = 0, r = 1<<30;
    int geta = n+1;
    int tmp = (n+1)*n/2/2;
    while(r - l > 1) {
        int mid = (l + r) / 2;
        int num = 0;
        BIT bit(n*2+10);
        int sum = 0;
        bit.add(sum+geta, 1);
        rep(i,n){
            int t = a[i]<=mid?1:-1;
            sum += t;
            num += bit.sum(sum+geta-1);
            bit.add(sum+geta, 1);
        }
        if(num > tmp) r = mid;
        else l = mid;
    }
    cout << r << endl;
}


Measured memory_bytes: 2668
table = [[0]*3 for i in range(50)]

times = 0 
for i in range(50):
    
    score = input().split()
    
    if  score[0] == "-1" and score[1] == "-1" and score[2] == "-1":
        break
        
    for j in range(3):
         table[i][j] = int(score[j])
    
    times += 1

for a in range(times):
    
    total_score = table[a][0] + table[a][1]
    
    if table[a][0] == -1 or table[a][1] == -1:
        print("F")
    
    elif total_score >= 80:
        print("A")

    elif total_score >= 65:
        print("B")

    elif total_score >= 50:
        print("C")

    elif total_score >= 30:
        if table[a][2] >= 50:
             print("C")
        else:
             print("D")
    else:
        print("F")


Measured memory_bytes: 5612
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//


#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;


int A,B,C,X,Y;
int M;
int ans;

int main() {
    // insert code here...    return 0;
  //////
    // input from txt
    /*
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    std::ofstream out("output.txt");
    std::cout.rdbuf(out.rdbuf());
   ///////
     */
    cin >> A >> B >> C >> X >> Y;
    if(A+B>2*C){
        int mi = min(X,Y);
        int many = (X>Y)? (X - mi):(Y - mi);
        int plus = (X>Y)? A * (X - mi):B * (Y - mi);
        if(plus > many*2*C)
            plus = many*2*C;
        ans += mi*C*2;
        ans += plus;
    }
    else{
        ans += X*A + Y*B;
    }
    cout << ans << endl;
    return 0;
}


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

import static java.lang.Integer.parseInt;

/**
 * ACB069
 * C - 4-adjacent
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;


		int N = parseInt(br.readLine());
		int[] c = new int[3];

		StringTokenizer st = new StringTokenizer(br.readLine());

		for (int i = 0; i < N; i++) {
			int a = parseInt(st.nextToken());
			if (a % 4 == 0) {
				c[2]++;
			} else if (a % 2 == 0) {
				c[1]++;
			} else {
				c[0]++;
			}
		}

		boolean ans = false;

		if (c[1] > 0) {
			if (c[2] >= c[0]) ans = true;
		} else {
			if (c[2] >= c[0] - 1) ans = true;
		}

		System.out.println(ans ? "Yes" : "No");
	}
}

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

int main()
{
	int n;
	vector<int> d;
	int m;
	vector<int> t;

	int temp;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> temp;
		d.push_back(temp);
	}
	cin >> m;
	for (int i = 0; i < m; i++){
		cin >> temp;
		t.push_back(temp);
	}

	sort(d.begin(), d.end());
	sort(t.begin(), t.end());

	if(n<m){
		cout << "NO" << endl;
	}else{
		int j=0;
		
		for (int i = 0; i < m; i++){
			bool b = false; 

			while (j!=d.size()){
				if(t[i]==d[j]){
					b=true;
					j++;
					break;
				}else{
					j++;
				}
			}

			if(b){
				if(i==m-1){
					cout<<"YES"<<endl;
				}
			}else{
				cout << "NO" << endl;
				break;
			}
		}
	}


}

Measured memory_bytes: 2548
#include<stdio.h>
int main(void){
	int n,x,i,j,k,l;
	
	while(1){
		i=0;
		scanf("%d %d",&n,&x);
		if(n==0&&x==0)break;
		for(j=3;j<=x-3;j++){
			for(k=2;k<j;k++){
				if(j+k>x)break;
				for(l=1;l<k;l++){
					if(j+k+l>x)break;
					if(j+k+l==x&&j<=n)i++;
				}
			}
		}
		printf("%d\n",i);
	}
	
	

	
	return 0;
}


Measured memory_bytes: 2052
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main(){

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

    vector<int> x(N), y(N);

    REP(i, N){
      cin >> x[i] >> y[i];
    }

    ll res = LLONG_MAX;
    REP(i, N) {
        REP(j, N){
            REP(k, N){
                REP(l, N){

                    int c = 0;
                    REP(m, N){
                        if( x[i] <= x[m] and x[m] <= x[j] and y[k] <= y[m] and y[m] <= y[l] ) c++;
                    }
                    if (c >= K) {
                        res = min(res, (ll)(x[j]-x[i]) * (ll)(y[l]-y[k]));
                    }
                }
            }
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384