akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <iostream>
#include <numeric>
#include <limits>
#include <functional>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;

const int N = 200010;

int n;
map<int, int> mp;

int main() {
	ios::sync_with_stdio(false);
#ifdef CAI_WEI_HAN
	freopen("test.in", "r", stdin);
#endif

	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		++mp[a[i]];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		int x = a[i];
		if (mp[x]) {
			--mp[x];
			int t = 0;
			while ((1 << t) <= x)
				++t;
			int y = (1 << t) - x;
			if (mp[y]) {
				++ans;
				--mp[y];
			}
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 19840
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] xyz = sc.nextLine().split(" ");
        int x = Integer.parseInt(xyz[0]);
        int y = Integer.parseInt(xyz[1]);
        int z = Integer.parseInt(xyz[2]);
        System.out.println(problem161a(x, y, z));
    }

    private static String problem161a(int x, int y, int z) {
        int[] array = {x, y, z};
        swap(array, 0, 1);
        swap(array, 0, 2);
        return array[0] + " " + array[1] + " " + array[2];
    }

    private static void swap(int[] array, int idx1, int idx2) {
        int tmp = array[idx1];
        array[idx1] = array[idx2];
        array[idx2] = tmp;
    }
}

Measured memory_bytes: 23764
h,w,_=io.read("*n","*n","*l")
a,b={},{}
s={}
for i=1,h do
	s[i]=io.read("*l")
end
for i=1,h do
	a[i]=false
	for j=1,w do
		if s[i]:sub(j,j)=='#' then a[i]=true end
	end
end

for i=1,w do
	b[i]=false
	for j=1,h do
		if s[j]:sub(i,i)=='#' then b[i]=true end
	end
end

for i=1,h do
	for j=1,w do
		if a[i] and b[j] then
			io.write(s[i]:sub(j,j))
		end
	end
	if a[i] then io.write("\n")end
end

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

typedef long long ll;

// dp[j][k]
// j ????????£????????°?????¶?\?
// k ???????¨??????????
// ???????????????????????° mod 1e9+7
ll dp[2][310 * 310];

const ll M = 1e9+7;

int main() {
	int d;
	vector<int> l;
	int s;
	cin >> d;
	l.resize(d);
	for(int i = 0; i < l.size(); i++)
		cin >> l[i];
	cin >> s;

	dp[0][0] = 1;
	for(int i = 0; i < l.size(); i++) {
		for(int j = 310*310; j >= 0; j--) {
			if(j - l[i] < 0) continue;
			dp[0][j] = (dp[0][j] + dp[1][j-l[i]]) % M;
			dp[1][j] = (dp[1][j] + dp[0][j-l[i]]) % M;
		}
	}
	ll res = 0;
	for(int i = 0; i <= s; i++) {
		ll x = 1;
		for(int j = 0; j < d; j++) x = x * (s-i) % M;
		res = (res + (dp[0][i] - dp[1][i] + M) * x) % M;
	}
	cout << res << endl;
}

Measured memory_bytes: 2700
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int n,ls[30],mx1,mx2,x[370][30],c[30],ans[370],a,la,val;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=26;i++)scanf("%d",&c[i]),ls[i]=0;
    for(int i=1;i<=n;i++)
    {
        mx1=0,mx2=1;
        for(int j=1;j<=26;j++)
        {
            scanf("%d",&x[i][j]);
            int k=((i-ls[j])*c[j])+x[i][j];
            if(mx1<k)mx1=k,mx2=j;
            else if(mx1==k)if(ls[j]<ls[mx2])mx2=j;
        }
        //printf("[%d]",mx1);
        ls[mx2]=i;
        ans[i]=mx2;
    }
    for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define ll long long
using namespace std;
using lli = long long;
long long a, b, c, d;
void inp()
{
    cin >> a >> b >> c >> d;
}
void process()
{
    long long x = (a*c);
    x = max(x, a*d);
    x = max(x, b*c);
    x = max(x, b*d);
    cout << x;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("test.inp","r", stdin);
    inp();
    process();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <climits>
using namespace std;

int conv(char a) {
  if (a >= '0' && a <= '9') {
    return a - '0';
  } else {
    return a - 'a' + 10;
  }
}

int conv(char a, char b) {
  return conv(a)*16 + conv(b);
}

int main() {
  string str;
  int c[3], d, m, ans;
  int cc[8][3] = {{0, 0, 0}, {0, 0, 0xff}, {0, 0xff, 0}, {0, 0xff, 0xff},
                  {0xff, 0, 0}, {0xff, 0, 0xff}, {0xff, 0xff, 0}, {0xff, 0xff, 0xff}};
  const char *label[8] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};

  while (1) {
    cin >> str;
    if (str == "0") break;
    for (int i=0; i<3; i++) {
      c[i] = conv(str.at(2*i+1), str.at(2*i+2));
    }
    m = INT_MAX;
    ans = -1;
    for (int i=0; i<8; i++) {
      d = 0;
      for (int j=0; j<3; j++) {
        d += (c[j]-cc[i][j])*(c[j]-cc[i][j]);
      }
      if (m > d) {
        m = d;
        ans = i;
      }
    }
    cout << label[ans] << endl;
  }
  return 0;
}

Measured memory_bytes: 1180
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
c = Counter(s)
res = 1
for key in list(c):
    res *= c[key]+1
    res %= mod
print(res-1)

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

using namespace std;

int main(){
    long long n;

    scanf("%lld", &n);

    if(n & 1) printf("0\n");
    else{
        long long ans = 0;

        for(long long i = 10; i <= n; i *= 5){
            ans += n / i;
        }

        printf("%lld\n", ans);
    }
    
    return 0;
}

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

using namespace std;

std::vector<int> ys;
std::vector<int> floodAreas;

void floodArea(int begin, int end) {
  if ((end - begin) <= 2) {
    return;
  }

  int maxi = begin + 1;
  for (int i = begin + 1; i < end - 1; ++i) {
    if (ys[maxi] < ys[i]) {
      maxi = i;
    }
  }
  int maxy = ys[maxi];
  int level = min(ys[begin], ys[end - 1]);
  if (maxy < level) {
    int area = 0;
    for (int i = begin + 1; i < end; ++i) {
      int a = 2 * level - ys[i] - ys[i-1];
      if (a > 0) {
        area += a;
      }
    }
    floodAreas.push_back(area / 2);
    return;
  }
  floodArea(begin, maxi + 1);
  floodArea(maxi, end);
}

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

  string map;
  cin >> map;

  int level = 0;
  ys.push_back(0);

  for (char c : map) {
    if (c == '/') {
      ++level;
    } else if (c == '\\') {
      --level;
    }
    ys.push_back(level);
  }
  floodArea(0, ys.size());

  if (floodAreas.empty()) {
    cout << "0" << endl;
    cout << "0" << endl;
  } else {
    int areaSum = 0;
    for (int a : floodAreas) {
      areaSum += a;
    }
    cout << areaSum << endl;

    cout << floodAreas.size() << " ";
    for (int i = 0; i < floodAreas.size(); ++i) {
      if (i != 0) {
        cout << " ";
      }
      cout << floodAreas[i];
    }
    cout << endl;
  }
}



Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
 priority_queue<float, vector<float>, greater<float> > q; 
  for(int i=0;i<n;i++)
  { 
    float y;
    cin>>y;
   q.push(y);
  }
  while(q.size()!=1)
  {
    float x=q.top();
    q.pop();
    float y=q.top();
    q.pop();
    float z=(float)(x+y)/2;
    q.push(z);
  }
  cout<<q.top()<<endl;
  
  return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
H = []
for _ in range(n):
    h = int(input())
    H.append(h)

max_t = - (- max(H) // b)

def clear_or_not(a, b, t, H):
    count_t = 0
    for i in range(len(H)):
        need_t = -(-(H[i] - b*t) //(a-b))
        if need_t <= 0:
            need_t = 0
        count_t += need_t
    if count_t <= t:
        return True
    else:
        return False
\
def bisect(low=1, high=max_t):
    while high-low > 1:
        mid = low + (high-low)//2
        if clear_or_not(a,b,mid,H):
            high = mid
        else:
            low = mid
    return high
ans = bisect()

print(ans)


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

public class Main {


    public Main(FastScanner in, PrintWriter out, int test) {
        long N = in.nextLong();
        StringBuilder res = new StringBuilder();
        while (N > 0) {
            res.append((char)((N - 1) % 26 + 'a'));
            N = (N - 1) / 26;
        }
        res.reverse();
        out.println(res);
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        // int T = in.nextInt();
        for (int t = 1; t <= 1; t++) {
            Main sol = new Main(in, out, t);
        }

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

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

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

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

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 32584
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();

  if(s[0] == s[N-1]){
    if(N%2==0) cout << "First" << endl;
    else cout << "Second" << endl;
  }
  else{
    if(N%2==0) cout << "Second" << endl;
    else cout << "First" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main(){
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b,c,count = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(int i = a; i <= b; i++){
		if(c%i == 0) count++;
	}
	printf("%d\n",count);
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int >A(n),B(n);
	vector<int >C;
	for(int i=0;i<n;i++)cin>>A[i];
	for(int i=0;i<n;i++){cin>>B[i];
		if(A[i]>B[i])C.push_back(A[i]-B[i]);
	}

	long long needed = 0;
	int count=0;
	for(int i=0;i<n;i++){
		if(B[i]>A[i])count++;
		needed = needed + max(0,B[i]-A[i]);
	}
	sort(C.rbegin(),C.rend());
	int start=0;
	//cout<<count<<' '<<needed<<'\n';
	//cout<<C[0]<<'\n';
	while(needed!=0 && start!=C.size()){
		if(C[start]<=needed){
			needed -= C[start];
			start++;
		}
		else{
		    needed=0;
		    start++;break;
		}
	}
	if(needed!=0)cout<<-1<<'\n';
	else cout<<start+count<<'\n';
}

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

int main() {
  long long n;

  cin>>n;

  long long A[n],B[n],C[n];
  long long agendaDP[n][3];

  for(int i = 0; i < 3; i++){
    agendaDP[0][i] = 0;
  }

  for(int i = 0; i < n; i++){
      cin>>A[i]>>B[i]>>C[i];
  }

  for(int i = 0; i < n; i++){
      agendaDP[i+1][0] = max(agendaDP[i][1], agendaDP[i][2]) + A[i];
      agendaDP[i+1][1] = max(agendaDP[i][0], agendaDP[i][2]) + B[i];
      agendaDP[i+1][2] = max(agendaDP[i][0], agendaDP[i][1]) + C[i];
  }

  cout << max(agendaDP[n][0], max(agendaDP[n][1], agendaDP[n][2]))<<endl;

}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b>=c-1){
	cout<<b+c<<endl;
	return 0;
    }
    int ans=b+b+1;
    c-=(b+1);
    if(a>=c){
	ans+=c;
      cout<<ans<<endl;
	return 0;
    }
    ans+=a;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        h: [i64; n],
    }

    let mut ch = h[0];
    let mut c = 0;
    let mut max = 0;
    for &h in h.iter().skip(1) {
        if h <= ch {
            c += 1;
            ch = h;
        } else {
            if max < c {
                max = c;
            }
            c = 0;
            ch = h;
        }
    }
    if max < c {
        max = c;
    }
    println!("{}", max);
}


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



int main(){
  while(1){



  
  int n,q;

  int a[1000]={};
  cin>>n>>q;
    if(n==0 && q==0){break;}
  for(int i=0;i<n;i++){
    int m;
    cin>>m;
    for(int t=0;t<m;t++){
      int p;
      cin>>p;
      a[p]++;
    }
  }
  int ans=0;
  int t=q-1;
  for(int i=1;i<1000;i++){
    if(a[i]>t){
      ans=i;
      t=a[i];
    }
  }
  cout<<ans<<endl;
  
  }
  
  return 0;
}



Measured memory_bytes: 3004
#include <stdio.h>

#define BUILDING_NUM 4
#define FLOOR_NUM 3
#define ROOM_NUM 10

int main(void) {
	int tenant[BUILDING_NUM][FLOOR_NUM][ROOM_NUM] = {{{0}}};
	int yosinaga_sayuri, hayasibara_megumi, izyuuinn_hikaru;
	if (scanf("%d", &yosinaga_sayuri) != 1) return 1;
	for (hayasibara_megumi = 0; hayasibara_megumi < yosinaga_sayuri; hayasibara_megumi++) {
		int b, f, r, v;
		if (scanf("%d%d%d%d", &b, &f, &r, &v) != 4) return 1;
		tenant[b - 1][f - 1][r - 1] += v;
	}
	for (yosinaga_sayuri = 0; yosinaga_sayuri < BUILDING_NUM; yosinaga_sayuri++) {
		if (yosinaga_sayuri > 0) puts("####################");
		for (hayasibara_megumi = 0; hayasibara_megumi < FLOOR_NUM; hayasibara_megumi++) {
			for (izyuuinn_hikaru = 0; izyuuinn_hikaru < ROOM_NUM; izyuuinn_hikaru++) {
				printf(" %d", tenant[yosinaga_sayuri][hayasibara_megumi][izyuuinn_hikaru]);
			}
			putchar('\n');
		}
	}
	return 0;
}



Measured memory_bytes: 2064
#include <iostream>
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <numeric>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
     int k;
     cin >> k;
     long long sum = 0;

    for(int x=1; x<=k; x++) {
        for(int y=1; y<=k; y++){
            for(int z=1; z<=k; z++){
                sum+= std::__gcd(std::__gcd(x, y), z);
       }
    }
}







     cout << sum << endl;




}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<vector<int>> M(101, vector<int>(101));

    rep(i, n) {
        rep (j, h[i]) {
            M[j][i] = 1;
        }
    }

    
    int cnt = 0;
    rep (j, 101) {
        int prev = 0;
        rep(i, n) {
            if (prev == 0 && M[j][i] == 1) {
                // put(i)
                // put(j)
                // put("===")
                cnt++;
            }
            prev = M[j][i];
        }
    }

    put(cnt);

    return 0;
}

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

signed main() {
  string S, T; cin >> S >> T;
  int N = S.size(), M = T.size();
  if(N < M) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  priority_queue<string, vector<string>, greater<string>> ans;
  rep(i, N-M+1) {
    string s = S;
    int n = 0;
    rep(j, M) {
      if(s[i+j] == T[j] || s[i+j] == '?') n++;
    }
    if(n == M) {
      rep(j, M) s[i+j] = T[j];
      rep(j, N) if(s[j] == '?') s[j] = 'a';
      ans.push(s);
    }
  }
  
  
  
  cout << (ans.size() > 0 ? ans.top() : "UNRESTORABLE") << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;cin>>n;
	vector<ll> A;
	ll sum_f=0, sum_b=0;
	priority_queue<ll> qb;
	priority_queue<ll, vector<ll>, greater<ll>> qf;
	rep(i,3*n){
		ll a;
		cin>>a;
		A.push_back(a);
		if(i < n){
			sum_f += a;
			qf.push(a);
		}else if(i >= 2*n){
			sum_b += a;
			qb.push(a);
		}
	}
	vector<ll> front,back;
	front.push_back(sum_f);
	back.push_back(sum_b);
	rep(i,n){
		qf.push(A[i+n]);
		ll minf = qf.top(); qf.pop();
		front.push_back(front[i] + A[i+n] - minf);

		qb.push(A[2*n-1-i]);
		ll maxb = qb.top(); qb.pop();
		back.push_back(back[i] + A[2*n-1-i] - maxb);
	}
	ll ans = -LINF;
	rep(i,n+1){
		chmax(ans, front[i] - back[n-i]);
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;

template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
    mod = (i64)mod;
    i64 res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}

template <int mod>
struct ModInt {
    using i64 = int64_t;
    i64 x;
    ModInt() : x(0) {}
    ModInt(i64 y) : x(y >= 0 ? y % mod : ((mod + y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &rhs) {
        x = x * rhs.x % mod;
        return *this;
    }
    ModInt &operator/=(const ModInt &rhs) {
        *this *= rhs.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) {
        return os << rhs.x;
    }
    friend istream &operator>>(istream &is, ModInt &rhs) {
        i64 t;
        is >> t;
        rhs = ModInt<mod>(t);
        return (is);
    }

   private:
    ModInt inverse() const {
        i64 a = x, u = 1LL, v = 0LL, t, b = (i64)mod;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
};
using mint = ModInt<1000000007>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    i64 n, a, b;
    cin >> n >> a >> b;
    mint ans = (mod_pow(2, n, MOD) - 1) % MOD;
    mint nca = 1;
    rep(k, a) { nca *= (n - k); }
    rep(k, a) { nca /= (k + 1); }
    mint ncb = 1;
    rep(k, b) { ncb *= (n - k); }
    rep(k, b) { ncb /= (k + 1); }

    ans -= nca;
    ans -= ncb;

    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    ll x;
    cin >> x;
    printf("%s\n", (x >= 1200) ? "ARC" : "ABC");
    return 0;
}


Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    q = int(input())
    ans = set()
    for _ in range(q):
        q = [int(i) for i in input().split()]
        x = q[1]
        if q[0] == 0:
            ans.add(x)
            print(len(ans))
        else:
            if x in ans:
                print(1)
            else:
                print(0)


resolve()



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

int main() {
    ll x;
    std::cin >> x;
    if(x==1){
        std::cout << 0 << std::endl;
    }else{
        std::cout << 1 << std::endl;
    }
}


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

bool cmp(char a,char b){
	return a>b;
}

int main()
{
	string s,t;

    cin>>s;
    cin>>t;
    
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),cmp);
    
    if(s<t)
       cout<<"Yes"<<endl;
    else
       cout<<"No"<<endl;
       
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
Pe = [(i+1)/2 for i in P]

maxsum = -1
cur = sum(Pe[0:K])
maxsum = cur
for i in range(1, N-K+1):
    cur = cur - Pe[i-1] + Pe[i+K-1]
    if cur > maxsum:
        maxsum = cur

print(maxsum)

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

int main(){

  //initialization
  string s;

  //input
  cin >> s;
  
  //output
  for(int i=0; i < s.size(); i += 2){
    cout << s[i];
  }
  cout << "\n";
}


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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n = int(input().strip())
    ans = ''
    while n != 0:
        if n % 26 == 0:
            ans = 'z' + ans
            n -= 26
            n = n // 26
        else:
            ans = chr(n % 26 + ord('a') - 1) + ans
            n = n // 26
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
loop do
  n, x = gets.chomp.split(' ').map(&:to_i)
  break if [n, x] == [0, 0]

  cnt = 0
  ave1 = x / 3
  for i in 1 .. ave1 - 1
    ave2 = (x - i) / 2
    for j in i + 1 .. ave2
      k = x - i - j
      if j < k && k <= n
        cnt += 1
      end
    end
  end

  puts cnt
end

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
        for (auto &u : v) os << u << endl;
        return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
        for (auto &u : v) is >> u;
        return (is);
}

int main() {
    int N; cin >> N;
    vint A(N); cin >> A;
    vint B;
    sort(begin(A), end(A));
    int sa = A.back() - A.front();
    if (sa > 1) { cout << "No" << endl; return (0); }
    if (sa == 1) {
        int val = A.front();
        int cnt; for (cnt = 0; A[cnt] == val; cnt++);
        if (val < cnt) {
            cout << "No" << endl;
            return (0);
        }
        for (int i = cnt; i < N; i++) {
            A[i] -= cnt;
            B.push_back(A[i]);
        }
    } else B = A;

    if ((int)B.size() >= B[0] * 2 || sa == 0 && (int)B.size() == B[0] + 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return (0);
}

Measured memory_bytes: 1404
#include <stdio.h>
#include <stdlib.h>

int vartex[100010],ww[100010],indexkawaii[100010];

int count1(const void*p,const void*q){
	if((double)vartex[*(int*)p]/ww[*(int*)p]>(double)vartex[*(int*)q]/ww[*(int*)q]){
		return -1;
	}
	return 1;
}

int main(){
	int n,m;

	scanf("%d%d",&n,&m);
	for(int i = 0 ; i < n ; i++)scanf("%d%d",vartex+i,ww+i);
	for(int i = 0 ; i < n ; i++)indexkawaii[i]=i;

	qsort(indexkawaii,n,sizeof(int),count1);

	double answer=0;
	for(int i = 0 ; i < n ; i++){
		if(m<=ww[indexkawaii[i]]){
			answer+=(double)vartex[indexkawaii[i]]/ww[indexkawaii[i]]*m;
			break;
		}
		answer+=vartex[indexkawaii[i]];
		m-=ww[indexkawaii[i]];
	}

	printf("%f\n",answer);

	return 0;
}



Measured memory_bytes: 3144
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
A = sorted(A)
ma = A[-1]
mi = A[0]
for i in range(n-1):
    if abs(A[i] - ma/2) <= abs(mi - ma / 2):
        mi = A[i]
print(ma,mi)


Measured memory_bytes: 16520
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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

const ll MOD = 2019;


int main() {
	
	int l, r, d;
	cin >> l >> r >> d;

	int cnt = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) {
			cnt++;
		}
	}

	cout << cnt;
}

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

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

#define MOD 1000000007

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

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

int main(void) {
    ll N, M;
    string S, T;
    ll gcd;
    cin >> N >> M >> S >> T;
    gcd = __gcd(N, M);
    rep(i, gcd) {
        if(S[i * N / gcd] != T[i * M / gcd]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << N * M / gcd << endl;
    return 0;
}


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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

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

	int n;
	cin>>n;
	int amin=INF;
	int amax=EPS;
	REP(i,n){
		int a;
		cin>>a;
		amin=min(amin,a);
		amax=max(amax,a);
	}
	cout << amax-amin << endl;

	return 0;
}

Measured memory_bytes: 3636
from networkx import*
(N,),*t=[s.split()for s in open(0)]
G=Graph()
for a,b in t:G.add_edge(a,b)
s=shortest_path_length
x=s(G,'1')
y=s(G,N)
c=0
for k in y:c+=x[k]>y[k]
print('FSennunkeec'[c*2>=int(N)::2])

Measured memory_bytes: 188532
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n, a[N], b[N];

int main() {
	scanf("%d", &n);
	REP(i,1,n) a[i]=b[i]=rd();
	sort(b+1,b+1+n),*b=unique(b+1,b+1+n)-b-1;
	REP(i,1,n) a[i]=lower_bound(b+1,b+1+n,a[i])-b;
	REP(i,1,n) b[a[i]]=i;
	int ans = 0;
	REP(i,1,n) if ((b[i]-i)%2) ++ans;
	printf("%d\n", (ans+1)/2);
}


Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s= sc.next();
		String buff= "";
		//double n = sc.nextInt()/1000.0;
		int m = sc.nextInt();
		//int k = sc.nextInt();
		//String s=sc.next();
		int count=0,flag=0;
		double count1=0,count2=0;
		int count3=0;
		//int[][] array1 = new int[m][k];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		//Arrays.sort(array);

		for(int j=105;j<=m;j++) {
			for(int i=1;i<=j;i+=2) {
				if(j%i==0) {
					count3++;
				}
			}
			//System.out.println(count3);
			if(j%2!=0 && count3==8) {
				count++;
			}
			count3=0;
		}

		/*if(count==0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}*/

		System.out.println(count);
	}
}




Measured memory_bytes: 23124
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
for i in range(n):
    arr[i]-=i+1

arr.sort()

def med(x):
    h = int(n/2)
    if n%2==0:
        return (arr[h-1]+arr[h])//2
    else:
        return arr[int((n-1)/2)]

ans=10**100
if n%2 ==0:
    ans1=0
    ans2=0
    m=med(arr)
    for i in range(n):
        ans1+=abs(arr[i]-m)
        ans2+=abs(arr[i]-(m+1))
    ans=min(ans1,ans2)
else:
    m=med(arr)
    ans1=0
    for i in range(n):
        ans1+=abs(arr[i]-m)
    ans=ans1
print(ans)




Measured memory_bytes: 106860
def main():
    N = int(input())
    A = list(map(int,input().split()))

    A.sort()

    B = [A[i] for i in range(N)]
    for i in range(1,N):
        B[i] += B[i-1]

    ans = 1
    for i in reversed(range(N-1)):
        if 2*B[i] >= A[i+1]:
            ans += 1
        else:
            break

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14308
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int isOk(string s, int N){
    int ok = 1;
    char c = s[0];
    rep(i,0,N) if(s[i]!=c) ok=0;
    return ok;
}
int main(){
  int N;    cin>>N;
  string s,t;   cin>>s>>t;
  int k = 0;
  for(int i=0 ; i<N ; i++){
    int cnt = 0;
    int j = 0;
    while(i+j<N&&j<N&&s[i+j]==t[j]){
        j++;
    }
    chmax(k, j);
  }
  cout<<2*N-k<<endl;
  return 0;
}   

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, A[50];

bool ok(ll k) {
  ll sum = 0;
  REP(i, 0, N) if(A[i] + k >= N) sum += (A[i] + k - N) / (N + 1) + 1;
  return sum <= k;
}

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  bool f = true;
  REP(i, 0, N) f = f && (A[i] < N);
  if(!f) {
    ll l = 0, h = (1LL << 60);
    while(l + 100000 < h) {
      ll m = (l + h) / 2;
      if(ok(m)) h = m;
      else l = m;
    }
    ll ans;
    REP(i, l, h + 1) {
      if(ok(i)) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
}


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

def solve():
    N = int(input())
    D = list(map(int, input().split()))

    D.sort()

    i = N//2

    if D[i] != D[i-1]:
        print(D[i]-D[i-1])
        return
    print(0)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 14396
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws Exception{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int c = Integer.parseInt(line[2]);

		if(a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 24116
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

 int main(){
  ll n,k ;cin>>n>> k;
  vector<P> A(n) ;
  rep(i,n) cin>> A[i].first>>A[i].second ;
  sort(A.begin(),A.end()) ;
  ll ans=0 ;
  ll res= k ;
  for(ll i=0 ;i<n;i++){
     if(res<=0){
        break ;
     }
     res-=A[i].second ;
     ans=A[i].first ;
  }
   cout<<ans<<endl ;
   return 0;
  }

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

int main(){
  
  set<int>S; //ここにリストをつくり，S.countで判定する
  
  int X, N;
  cin >> X >> N;
  if(N == 0){
    cout << X << endl;
    return 0;
  }
  vector<int>A(110);
  for(int i = 0; i <N ; i++){
    cin >> A[i];
  }

  int ans = 0;
  for(int i = 0; i <= 100; i++){
    ans = X - i; //まずは小さいほうをみる
    bool flag = 1;
    for(int j = 0; j <N; j++){ //配列を見ていき，ansがあるか確認
      if(A[j] == ans)flag = 0; //フラグをfalseにする
    }
    if(flag){
      cout << ans << endl;
      return 0;
    }
    flag = 1;
    ans = X + i; //小さいほうがダメなら大きいほう
    for(int j = 0; j <N; j++){ //配列を見ていき，ansがあるか確認
      if(A[j] == ans)flag = 0; //フラグをfalseにする
    }
    if(flag){
      cout << ans << endl;
      return 0;
    }
    
    
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve(){
	int n, m;
	cin >> n >> m;
	map<pii, int> has;
	vector<int> v;
	for(int i = 0; i < m; ++i){
		int x, y;
		cin >> x >> y;
		has[{x, y}] = 1;
		has[{y, x}] = 1;
		
	}
	for(int i = 1; i <= n; ++i) v.pb(i);
	int cnt = 0;
	do{
		if(v[0] != 1) break;
		bool ok = 1;
		for(int i = 1; i < sz(v); ++i){
			if(!has[{v[i], v[i - 1]}]) ok = 0;
		}
		cnt += ok;
	}while(next_permutation(all(v)));
	cout << cnt;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-9
#define PI 2 * acos (0.0)
using namespace std;

const int mod = 1000000000 + 7;



// inverse mod of i%prime = bigmod(i,prime-2)
long long bigmod(long long a, long long n) {
    n %= mod - 1;
    long long res = 1;
    while (n) {
        if (n & 1ll) {
            res = res * a;
            if (res >= mod) {
                res %= mod;
            }
        }
        a = a * a;
        if (a >= mod) {
            a %= mod;
        }
        n >>= 1;
    }
    return res;
}

ll ncr[1001][1001];
ll fct[1001];
ll dp[1001];
bool bi[1001];

void computeNCR()
{
    fct[0] = fct[1] = 1;
    for(int i = 0; i <= 1000; i++)
    {
        ncr[i][1] = i;
    }
    for(int n = 2; n <= 1000; n++)
    {
        fct[n] = (fct[n - 1] * n) % mod;
        for(int r = 2; r <= n; r++)
        {
            ncr[n][r] = ( ncr[n - 1][r - 1] + ncr[n - 1][r] ) % mod;
        }
    }
}

ll computeNSK(int N, int S, int K)
{
    ll ans = 1;
    for(int i = 0; i < K; i++)
    {
        ans = (ans * ncr[N - i * S][S]) % mod;
    }
    ans = (ans * bigmod(fct[K], mod - 2) ) % mod;

    return ans;
}



int main()
{

   

    computeNCR();

    int a, b, c, d, e, x, y, z;

    int N, A, B, C, D;

    cin>>N>>A>>B>>C>>D;

    for(int i = A; i <= B; i++) // group size
    {
        for(int j = N - C * i; j >= 1; j--)
        {
            if(bi[j])
            {
                for(int k = C; k <= D; k++)
                {
                    if(j + i * k > N)
                    {
                        break;
                    }
                    bi[j + i * k] = true;
                    dp[j + i * k] = (dp[j + i * k] + (dp[j] * computeNSK(N - j, i, k)) %mod ) % mod;
                }
            }
        }
        for(int k = C; k <= D; k++)
        {
            if(i * k > N)
            {
                break;
            }
            bi[i * k] = true;
            dp[i * k] = (dp[i * k] + computeNSK(N, i, k)) % mod;
        }
    }

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


Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

bool ok[10];

bool check(int n){
  bool ret=true;
  while(n>0){
    if(!ok[n%10])ret=false;
    n/=10;
    }
  return ret;
  }

int main(){
  int n;cin>>n;
  int d;cin>>d;
  rep(i,10)ok[i]=true;
  rep(i,d){
    int x;cin>>x;
    ok[x]=false;
    }
  int ans=n;
  for(;;){
    if(check(ans))break;
    ans++;
    }
  cout<<ans<<endl;
  return 0;         
  }

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

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double s = x / a;
    double rad;
    if (s >= a * b / 2) {
        double h = (a * b - s) * 2 / a;
        rad = atan2(h, a);
    } else {
        double w = s * 2 / b;
        rad = atan2(b, w);
    }
    double PI = acos(-1);
    double deg = rad / (2 * PI) * 360;
    printf("%.10f\n", deg);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n, m;
	int a[31][31];
	int i, j, k, ans=0, cnt;

	scanf("%d %d", &n, &m);

	for(i=0; i<n; i++){
		scanf("%d", &a[i][0]);
		for(j=1; j<=a[i][0]; j++)
			scanf("%d", &a[i][j]);
	}

	for(i=1; i<=m; i++){
		cnt = 0;
		for(j=0; j<n; j++){
			 for(k=1; k<=a[j][0]; k++){
				 if(i == a[j][k])
				 	cnt++;
			 }
		}

		if(cnt == n)
			ans++;
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 128