akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

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;}

int point(int base, int sub){
	int ans = base+sub;
	if(ans>255)return 255;
	else if(ans <0)return 0;
	else return ans;
}

int x2(int a, int b){
	return (a-b)*(a-b);
}

int main(){
	int N,M;
	ofstream outputfile("ans.txt");
	while(true){
		cin>>N>>M;
		if(!N && !M)break;
		vector<int> C(M);
		vector<int> Y(N);
		rep(i,M)cin>>C[i];
		rep(i,N)cin>>Y[i];
		vector<vector<int>> dp(N, vector<int>(256,inf));
		rep(i,M){
			int p = point(128, C[i]);
			dp[0][p] = x2(p, Y[0]);
		}
		for(int i = 0; i<N-1; ++i){
			rep(j,256){
				if(dp[i][j] == inf)continue;
				// printf("[%d] -> %d\n", j, dp[i][j]);
				// cout<<"----"<<j<<"----"<<endl;
				rep(k,M){
					int p = point(j, C[k]);
					// cout<<p<<endl;
					chmin(dp[i+1][p], dp[i][j] + x2(p,Y[i+1]));
				}
			}
		}
		int ans = inf;
		rep(i,256)chmin(ans, dp[N-1][i]);
		// cout<<"---------"<<endl;
		cout<<ans<<endl;
		// cout<<"---------"<<endl;
		outputfile<<ans<<'\n';
	}
	outputfile.close();
	return 0;
}



Measured memory_bytes: 23700
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  char b;
  cin>>b;
  if(b=='A')cout<<'T'<<endl;
  if(b=='T')cout<<'A'<<endl;
  if(b=='C')cout<<'G'<<endl;
  if(b=='G')cout<<'C'<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
typedef long long ll;
ll inf = 1e9;

class network_flow{
private:
	int N;
	struct edge{int to; ll cap; int rev;};
	vector<vector<edge>> G;
	vector<int> level,iter;
	void bfs(int s){
		for(int i=0;i<=N;i++) level[i] = -1;
		queue<int> Q;
		level[s] = 0;
		Q.push(s);
		while(!Q.empty()){
			int v = Q.front(); Q.pop();
			for(int i=0;i<G[v].size();i++){
				edge &e = G[v][i];
				if(e.cap > 0 && level[e.to]<0){
					level[e.to] = level[v]+1;
					Q.push(e.to);
				}
			}
		}
	}
	ll dfs(int v,int t,ll f){
		if(v==t) return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge &e = G[v][i];
			if(level[v]<level[e.to] && e.cap>0){
				ll d = dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
public:
	network_flow(int n){
		N = n;
		G = vector<vector<edge>>(N+1);
		level = iter = vector<int>(N+1);
	}
	void add_edge(int from, int to,ll cap){
		G[from].push_back((edge){to,cap,(int) G[to].size()});
		G[to].push_back((edge){from,0,(int) G[from].size()-1});
	}
	ll max_flow(int s,int t){
		ll flow = 0;
		for(;;){
			bfs(s);
			if(level[t]<0) return flow;
			for(int i=0;i<=N;i++) iter[i] = 0;
			ll f;
			while((f=dfs(s,t,inf))>0) flow += f;
		}
	}
};

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> S(H,vector<char>(W));
    vector<int> dx = {-1,1,0,0},dy = {0,0,-1,1};
    bool ok = true;
    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
        cin >> S[i][j];
        if(S[i][j]=='X'){
            if(i==0 || j==0 || i==H-1 || j==W-1) ok = false;
        }
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    network_flow flow(2*H*W+2);
    auto id = [&](int i,int j,int isout){
        return i*W+j+1+isout*H*W;
    };

    auto in = [&](int i,int j){
        return 0<=i && i<H && 0<=j && j<W;
    };

    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
        if(S[i][j]=='X'){
            flow.add_edge(0,id(i,j,0),inf);
            flow.add_edge(id(i,j,0),id(i,j,1),inf);
        }
        else flow.add_edge(id(i,j,0),id(i,j,1),1);
        for(int k=0;k<4;k++){
            int ni = i+dx[k],nj = j+dy[k];
            if(in(ni,nj)) flow.add_edge(id(i,j,1),id(ni,nj,0),inf);
            else flow.add_edge(id(i,j,1),2*H*W+1,inf);
        }
    }
    cout << flow.max_flow(0,2*H*W+1) << endl;
}

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

using namespace std;

int main() {

string S;
cin>>S;
int a=0;
int b=0;
vector<int>x(2,0);
for(int i=0;i<S.size();i++){
   if(S[i]=='0'){
      x[0]++;
   }
   else if(S[i]=='1'){
      x[1]++;
   }

}
int c=min(x[0],x[1]);

cout<<c*2<<endl;

   return 0;
}






Measured memory_bytes: 3708
X = int(input())

ans = 0
if 400 <=X <600:
  ans = 8
elif 600 <= X < 800:
  ans = 7
elif 800 <= X < 1000:
  ans = 6
elif 1000 <= X < 1200:
  ans = 5
elif 1200 <= X < 1400:
  ans = 4
elif 1400 <= X < 1600:
  ans = 3
elif 1600 <= X < 1800:
  ans = 2
else:
  ans = 1

print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define ll long long
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main()
{
	ll h,a,b=1,ans=1;
	cin>>h;
	if(h==1)
	{
		cout<<"1"<<endl;
		return 0;
	}
	a=h;
	while(a>=2)
	{
		a/=2;
		b++;
	}
	REP(i,b)
	{
		ans*=2;
	}
	cout<<ans-1<<endl;
	return 0;	
} 

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
T LCM(T a, T b) {
	return a / GCD(a, b) * b;
}
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	ll n, k;
	cin >> n >> k;
	
	vector<pair<ll, ll>> p(n);
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		p[i] = make_pair(a, b);
	}

	ll now = 0;
	sort(ASC(p));

	for (int i = 0; i < n; ++i) {
		if (k <= now + p[i].second) {
			cout << p[i].first << endl;
			return 0;
		}
		else {
			now += p[i].second;
		}
	}
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する


int main(){
    int64_t n,k;
    cin>>n>>k;
    n = n%k;
    cout<<min(n,k-n)<<endl;
}

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

int main(){
  int n;
  double x1, x2, x3, y1, y2, y3, px, py, r, a1, a2, b1, b2, c1, c2;

  cin >> n;

  for(int i = 0;i < n; i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    a1 = 2 * (x2 - x1);
    b1 = 2 * (y2 - y1);
    c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
    a2 = 2 * (x3 - x1);
    b2 = 2 * (y3 - y1);
    c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

    px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
    py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
    r = sqrt((px - x1) * (px - x1) + (py - y1) * (py - y1));

    printf("%.3f %.3f %.3f\n", px, py, r);
  }

  return 0;
}

Measured memory_bytes: 1244
if __name__ == '__main__':
    N = int(input())
    S1 = input()
    S2 = input()
    sum = 1
    mul = 1
    mod = 1000000007
    fg = 0
    i = 0

    while True:

        if i >= N:
            print(sum)
            exit()

        if S1[i] == S2[i] and fg == 0:
            sum = 3
            i += 1
            fg = 1
        elif S1[i] != S2[i] and fg == 0:
            sum = 6
            i += 2
            fg = 2
        elif S1[i] == S2[i] and fg == 1:
            mul = 2
            i += 1
            fg = 1
        elif S1[i] != S2[i] and fg == 1:
            mul = 2
            i += 2
            fg = 2
        elif S1[i] == S2[i] and fg == 2:
            mul = 1
            i += 1
            fg = 1
        elif S1[i] != S2[i] and fg == 2:
            mul = 3
            i += 2
            fg = 2
        sum = ((sum % mod) * (mul % mod)) % mod


Measured memory_bytes: 3064
h,w=map(int,input().split())
a=[]
for i in range(h):
    x = input()
    if "#" in x:
        a.append(x)
a=list(zip(*a))
b=[]
for y in a:
    if "#" in y:
        b.append(y)
b=list(zip(*b))
for c in b:
    print("".join(c))

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

int main(){
  long long int N ,ans = 0 ;
  string S ;
  cin >> N ;
  vector<int> d(N);
  for(int i = 0; i < N; i++) cin >> d[i];
  for(int i = 1; i < N; i++)
    for(int j = 0; j < i; j++)
      ans += d[i] * d[j];
  cout << ans << endl;
}


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

int main() {
  int N,M,sumt=0;
  cin >> N;
  vector<int> time(100100);
  for(int i=1;i<=N;i++) {
    cin >> time[i];
    sumt+=time[i];
  }
  cin >> M;

  int p,x;

  for(int i=0;i<M;i++) {
    cin >> p >> x;
    cout << sumt+x-time[p] << endl;
  }
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int N = 105;
typedef long long ll;
int tot = 0;
ll a[4];
ll b[4][N];
int n ;
ll W;
vector<ll> bag[4];
set<ll> s;
bool cmp(ll a, ll b){
    return a>b;
}
int main(){
    scanf("%d%lld",&n,&W);
    for(int i = 0; i < n; i++){
        ll w,v;
        int num = 0;
        scanf("%lld%lld",&w, &v);
        if(!s.count(w)){
            s.insert(w);
            num = tot;
            a[tot++] = w;
        }
        else{
            for(int j = 0; j < tot; j++)
            {
                if(w == a[j])
                {
                    num = j;
                    break;
                }
            }
        }
        bag[num].push_back(v);
    }
    for(int i = 0; i < 4; i++){
        sort(bag[i].begin(), bag[i].end(),cmp);
    }
    for(int i = 0; i < 4; i++)
    {
        b[i][0] = 0;
        int j;
        for(j = 1; j <= bag[i].size(); j++)
        {
            b[i][j] = bag[i][j-1]+b[i][j-1];
        }
    }
    ll maxans = 0;
    int len0 = bag[0].size();
    int len1 = bag[1].size();
    int len2 = bag[2].size();
    int len3 = bag[3].size();
    for(int i = 0; i <= len0; i++){
        for(int j = 0; j <= len1; j++){
            for (int k = 0; k <= len2; k++){
                for(int l = 0; l <= len3; l++){
                    
                    ll temp = i*a[0]+j*a[1]+k*a[2]+l*a[3];
                    if(temp <= W){
                        ll ans = b[0][i]+b[1][j]+b[2][k]+b[3][l];
                        if(ans > maxans) maxans = ans;
                    }
                    
                }
            }
        }
    }
    printf("%lld\n", maxans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			
			if(A == 5 && B == 5 && C == 7){
				System.out.println("YES");
			}
			else if(A == 7 && B == 5 && C == 5){
				System.out.println("YES");
			}
			else if(A == 5 && B == 7 && C == 5){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
}

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

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

      if(S=="Sunny")
        cout << "Cloudy" << endl;

      if(S=="Cloudy")
        cout << "Rainy" << endl;

      if(S=="Rainy")
        cout << "Sunny" << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int t[n+1],x[n+1],y[n+1];
	for(int i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(int i=0;i<n;i++){
		if(abs(x[i]-x[i+1])+abs(y[i]-y[i+1])>t[i+1]-t[i]||((t[i+1]-t[i])-abs(x[i]-x[i+1])+abs(y[i]-y[i+1]))%2==1){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


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

using namespace std;

int main() {
	int t[100001], a[100001];
	bool bt[100001], ba[100001];
	int n;
	long long count = 1;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		if (i == 0) {
			bt[i] = true;
		} else {
			bt[i] = (t[i] != t[i-1]);
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) {

		} else {
			ba[i-1] = (a[i-1] != a[i]);
		}
	}

	ba[n-1] = true;

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

	for (int i = 0; i < n; i++) {
		if (ba[i] && bt[i]) {
			if (a[i] != t[i]) {
				cout << 0 << endl;
				return 0;
			}
		} else if (ba[i]) {
			if (a[i] > t[i]) {
				cout << 0 << endl;
				return 0;
			}
		} else if (bt[i]) {
			if (a[i] < t[i]) {
				cout << 0 << endl;
				return 0;
			}
		}
		else {
			int min = a[i] < t[i] ? a[i] : t[i];
			count *= min;
			count = count % 1000000007;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 1280
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0] + K)
B = list()
i = 0

for i in range(0, len(A) - 1):
  B.append(A[i + 1] - A[i])
  i += 1

print(K - max(B))

Measured memory_bytes: 26444
#include <iostream>

int main()
{
	int N;
	long long D;
	std::cin >> N >> D;
	long long X, Y;
	int cnt = 0;
	for (int i=0; i<N; i++) {
		std::cin >> X >> Y;
		if (X*X + Y*Y <= D*D) cnt++;
	}
	std::cout << cnt << std::endl;
	return 0;
}


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

long long euclid(long long &A, long long &B){
    int r = B % A;
    while(r != 0){
        B = A;
        A = r;
        r = B % A;
    }
    return A;
}

int main() {
    long long A, B;
    cin >> A >> B;

    long long lcm, x;
    x = A * B;

    if(A > B){
        int temp = A;
        A = B;
        B = temp;
    }

    lcm = euclid(A, B);

    cout << x/lcm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  vi c(26,0);
  REP(i,s.size()) c[s[i]-'a']++;
  REP(i,26) if(c[i]&1){
    puts("No");
    return 0;
  }
  puts("Yes");
}


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

#define llint long long int


llint gcd(llint a, llint b){
  if(a>b) std::swap(a, b);

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

llint count(llint st, llint ed, llint d){
  llint a = (ed/d) - (st/d);
  llint b = (st%d) ? 0 : 1;
  return a+b;
}

int main(void){

  std::vector<std::pair<llint, llint> > v;
  int n;
  std::cin >> n;

  for(int i=0; i<n; i++){
    llint a, b;
    std::cin >> a >> b;
    v.push_back(std::make_pair(b,a));
  }
  std::sort(v.begin(), v.end());

  llint now = 0;
  for(int i=0; i<n; i++){
    now += v[i].second;
    if(now > v[i].first){
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}



Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f), TMPend = (n); (i) < TMPend; (i)++)
#define RFOR(i, f, n) for(int (i) = (f), TMPend = (n); (i) >= TMPend; (i)--)
#define REP(i, n) for(int (i) = 0, TMPend = (n); (i) < TMPend; (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0, TMPend = (n); (i) < TMPend; (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int input(n);
  long long list_input(a, n);
  vector<long long> edge;
  edge.push_back(a[0]);

  // vector<int> test = {1, 4, 5, 5, 10};
  // auto p = lower_bound(test.begin(), test.end(), 3);
  // out(distance(test.begin(), p));
  // out("ok")
  FOR(i, 1, n) {
    long long pos = distance(edge.begin(), lower_bound(edge.begin(), edge.end(), a[i]));
    if (pos == 0) {
      edge.insert(edge.begin(), a[i]);
    } else {
      edge[pos - 1] = a[i];
    }
  }
  out(edge.size());
}


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

int main()
{
	int H = 0, W = 0, count = 0, a[10000] = { 0 };
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		a[count] = H, a[++count] = W;
		count++;
	}
	int i = 0;
	while (i < count){
		for (int j = 0; j < a[i + 1]; j++) cout << "#";
		cout << endl;
		for (int j = 1; j < a[i] - 1; j++){
			for (int k = 0; k < a[i + 1]; k++){
				if (k == 0 || k == a[i + 1] - 1) cout << "#";
				else							 cout << ".";
			}
			cout << endl;
		}
		for (int j = 0; j < a[i + 1]; j++) cout << "#";
		cout << endl;
		cout << endl;
		i += 2;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>
#define MAX 100000
 
int A[MAX], n;
 
int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j] <= x ){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}
 
int main() {
  int i, q;
   
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
   
  q = partition(0, n - 1);
   
  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    if ( i == q ) printf("[");
    printf("%d", A[i]);
    if ( i == q ) printf("]");
  }
  printf("\n");
   
  return 0;
}

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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

//pyteyonさんのものを拝借
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    ll n, m; cin >> n >> m;
    vi a(m),b(m);
    rep(i,m) cin >> a[i] >> b[i];

    ll tmp = n*(n-1)/2;
    vector<ll> ans;
    UnionFind tree(n);
    rep(i,m-1){
        ans.emplace_back(tmp);
        if(!tree.issame(a[m-1-i]-1, b[m-1-i]-1))
            tmp -= (tree.size(a[m-1-i]-1))*(tree.size(b[m-1-i]-1));
        tree.merge(a[m-1-i]-1, b[m-1-i]-1);
    }
    ans.emplace_back(tmp);

    rep(i,ans.size()){
        cout << ans[(int)ans.size()-1-i] << "\n";
    }
    return 0;
}


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

using namespace std;
using ll = long long;

const ll md = 1e9 + 7;

int main()
{
  ios_base::sync_with_stdio (0);
  cin.tie (0);
  ll a, b, c;
  cin >> a >> b >> c;
  ll rem = c - min (c, a - b);
  cout << rem << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ll n; cin >> n;
    int root = (int)sqrt(n);
    int out;

    for (int i = root; i > 0; i--) {
        if (n % i == 0) {
            out = i;
            break;
        }
    }

    cout << (n / out) + out - 2 << endl;

    return 0;
}


Measured memory_bytes: 256
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    ll N;
    cin>>N;
    if(N%2==0)
    {
        cout<<N<<endl;

    }
    else

    {
        N*=2;
        cout<<N<<endl;
    }
    
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstdio>

using namespace std;

static const char DOWN = '\\';
static const char EVEN = '_';
static const char UP = '/';

struct AREA {
  int index;
  int area;
};

int main() {
  stack<int> input;
  vector<AREA> answer;

  int total = 0;
  string data;
  cin >> data;
  AREA current = {};
  int lastIndex = 0;
  for (int i = 0; i < data.length(); i++) {
    switch (data[i]) {
    case DOWN:
      input.push(i);
      break;
    case EVEN:
      break;
    case UP:
      if (input.empty()) {
        continue;
      }
      lastIndex = input.top();
      input.pop();
      current.area = i - lastIndex;
      current.index = lastIndex;
      total += current.area;
      while (answer.size() > 0 && answer.back().index > lastIndex) {
        current.area += answer.back().area;
        answer.pop_back();
      }
      answer.push_back(current);
      break;
    default:
      break;
    }
  }

  cout << total << endl;  
  cout << answer.size();
  for (AREA ans : answer) {
      cout << " " << ans.area;
  }  
  cout << endl;

  return 0;
}



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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll n,d; cin >> n >> d;
    int ans = 0;
    REP(i,n){
        ll x,y; cin >> x >> y;
         if(x*x+y*y<=d*d) ans++;

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

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		long[] X = new long[N];
		for (int i = 0; i < N; i++) {
			X[i] = in.nextLong();
		}
		long ans = Long.MAX_VALUE;
		for (int i = 0; i + K - 1 < N; i++) {
			long left = X[i];
			long right = X[i + K - 1];
			ans = Math.min(ans, Math.min(Math.abs(left), Math.abs(right)) + right - left);
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 50044
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

bool c(string s1 , string s2){
  int i = 0;  
  while(s1[i] == s2[i]){
    i++;
  }
  
  //cout << s1 << " " << s2 <<endl;
  //cout << i << " "<<(int)s1[i] << " " << (int)s2[i];
  if((int)s1[i] > (int)s2[i]){
    //P("done t");
    ret true;
  }
  else{
    //P("done f");
    ret false;
  }
}

int main(){
  int n , l;
  cin >> n >> l;
  
  vector<string> v;
  
  rep(i,0,n){
    string s;
    cin >> s;
    v.push_back(s);
  }
  
  rep(i,0,n){
    int k = i;
    rep(j,i+1,n){
      //printf("k:%d j:%d v[k]:%s v[j]:%s\n",k,j,v[k].c_str(),v[j].c_str());
      if(c(v[k],v[j])){
        k = j;
      }
    }
    
    string s = v[k];
    v[k] = v[i];
    v[i] = s;
  }
  
  rep(i,0,n){
    cout << v[i];
  }
  cout << endl;
  ret 0;
}

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

typedef long long ll;

const int MAXN = 1e5 + 5;

ll M;
int N, Q;
vector <pair <int, int>> v;
int dad[MAXN], rnk[MAXN];
 
int find(int x) {
	return dad[x] == x ? x : dad[x] = find(dad[x]);
}

void join(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)
		return;
	if (rnk[x] > rnk[y])
		swap(x, y);
	dad[x] = y;
	rnk[y] += rnk[x] == rnk[y];
}

void load() {
	scanf("%d%lld%d", &N, &M, &Q);
	for (int i = 0; i < N; i++) 
		dad[i] = i;
	while (Q--) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		if (c)
			v.push_back({a, b});
		else
			join(a, b);
	}
}

bool solve() {
	if (M == N - 1)
		return v.empty();
	
	for (auto it : v)
		if (find(it.first) == find(it.second))
			return false;
	
	int comps = 0;
	for (int i = 0; i < N; i++)
		comps += find(i) == i;
	
	return comps >= 3 && M <= N + (ll)comps * (comps - 3) / 2;
}

int main() {
	load();
	puts(solve() ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 1784
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int N;
    cin >> N;
    int h[N];
    for (int i=0; i<N; ++i)
    {
        cin >> h[i];
    }
    int dp[N+2];
    for (int i=0; i<N; ++i)
    {
        dp[i] = inf;
    }

    dp[0] = 0;
    for (int i=0; i<N; ++i)
    {
        if (dp[i+1] > (dp[i] + abs(h[i+1]-h[i])))
        {
            dp[i+1] = dp[i] + abs(h[i+1]-h[i]);
        }
        if (dp[i+2] > (dp[i] + abs(h[i+2]-h[i])))
        {
            dp[i+2] = dp[i] + abs(h[i+2]-h[i]);
        }
    }

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

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)


def read_matrix(H, W):
    '''return np.ndarray shape=(H,W) matrix'''
    lines = []
    for _ in range(H):
        lines.append(read())
    lines = ' '.join(lines)  # byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ', dtype=np.int64).reshape(H, W)


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b

# from numba import njit
# @njit('(i8,i8,i8[:])',cache=True)


N = a_int()
XY = read_matrix(N, 2)
X = XY[:, 0]
Y = XY[:, 1]
f0 = X - Y
f1 = X + Y

print(max(f0.max() - f0.min(), f1.max() - f1.min()))


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

bool check(string S){
	for(int i=0;i<S.size();i++){
		if(S[i]!='A'&&S[i]!='G'&&S[i]!='C'&&S[i]!='T')return false;
	}
	return true;
}


int main(){
	string S;
	cin>>S;
	int maxi = 0;
	for(int i=0;i<S.size();i++){
		for(int j=1;j<S.size()-i+1;j++){
			if(check(S.substr(i,j)))maxi=max(maxi,j);
		}
	}
	cout<<maxi<<endl;
		
	
	return 0;
}


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

int main(){
    int n,a,t,i,ans=1;
    float minval=100000,val=0;
    cin >> n >> t >> a;
    int x[n];
    for(i=0;i<n;i++){
        cin >> x[i];
        val =  abs(a-(t - x[i]*0.006));
        if(val<minval){ans = i;minval=val;}
    } 
    cout << ans+1;
    return 0;
}


Measured memory_bytes: 256
// AOJ 0572: Card Game is Fun
// 2017.10.29 bal4u@uu

#include <stdio.h>

int a[5003], b[5003];

char buf[25105], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int la, lb, i, j, k, ans;

	fgets(p=buf, 16, stdin), la = getint(), p++, lb = getint();
	fgets(p=buf, 25100, stdin);
	for (i = 0; i < la; i++) a[i] = getint(), p++;
	fgets(p=buf, 25100, stdin);
	for (i = 0; i < lb; i++) b[i] = getint(), p++;	
	for (ans = 0, i = 0; i < la; i++) {
		for (k = 0, j = i; j < lb; j++) {
			while (k < la && a[k] != b[j]) k++;
			if (k == la) break;
			k++;
		}
		if (j-i > ans) ans = j-i;
	}
	printf("%d\n", ans);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while (sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }

  void build()
  {
    for (int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) L = f(L, seg[a++]);
      if (b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};

void solve() {
  int N; cin >> N;
  SegmentTree<int> se(N, [](int a, int b) { return gcd(a, b); }, 0);
  rep(i, N) {
    int a; cin >> a;
    se.set(i, a);
  }
  se.build();
  int ans = 1;
  rep(i, N) {
    amax(ans, (int) gcd(se.query(0, i), se.query(i + 1, N)));
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1280
import numpy as np
from itertools import permutations

import math

def main():
    N = int(input())
    xs = np.zeros(N)
    ys = np.zeros(N)
    for i in range(N):
        x, y = list(map(int, input().split()))
        xs[i] = x
        ys[i] = y
    dist_mat = np.sqrt((xs[:, np.newaxis] - xs[np.newaxis, :])**2
                       + (ys[:, np.newaxis] - ys[np.newaxis, :])**2)
    # print(dist_mat)
    assert dist_mat.shape == (N, N)

    perm = permutations(list(range(N)))

    avg_path_length = 0
    n = 1
    for seq in perm:
        path_length = np.sum([dist_mat[seq[i], seq[i+1]] for i in range(N-1)])
        avg_path_length = avg_path_length / n * (n-1) + path_length / n
        n+= 1
    assert n == math.factorial(N)+1

    print(avg_path_length)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14464
#include<bits/stdc++.h>
#define int long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
inline int read()
{
	char s;
	int k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
	return k*base;
}
int find(int x,int y)
{
	if (y>=x) return y+1; else return y;
}
int q,x,y;
bool check(int s)
{
	int d=s/2;
	for (int i=d-200;i<=d+200;i++)
	{
		if (i>0&&i<=s)
		{
			if (find(x,i)*find(y,s-i+1)>=x*y) return 0;
		}
	} 
	return 1;
} 
signed main()
{
	q=read();
	while (q--)
	{
		x=read();y=read();
		int l=0,r=2e9,ans=0;
		while (l<r)
		{
			int mid=(l+r+1)/2;
			if (check(mid)) l=mid; else r=mid-1;
		}
		printf("%lld\n",l);
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include<unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int a[300010];
signed main(void)
{
	int n;
	cin >> n;
	REP(i, 3*n) cin >> a[i];
	sort(a, a+3*n);
	ll ret = 0;
	for(int i=3*n-2; i>=n; i-=2) ret += a[i];
	cout << ret << endl;
	
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
using namespace std;

int main(){
  int n; cin >> n;
  map<int, bool> mp;
  int a[n+1];
  for(int i=1; i<=n; i++) {
    cin >> a[i];
    mp[a[i]] = true;
  }

  sort(a+1, a+n+1);
  int c = a[n], d, e;
  d = *(lower_bound(a+1, a+n+1, c/2));
  e = *(lower_bound(a+1, a+n+1, c/2)-1);

  if(abs(c - 2*d) < abs(c - 2*e)){
    cout << c << " " << d << endl;
  }
  else{
    cout << c << " " << e << endl;
  }
  return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	unordered_map<int,int>cnt;
	char c;
	for(int i=0;i<n;++i){
		cin>>c;
		++cnt[c-'a'];
	}
	int ans=1,mod=1e9+7;
	for(auto&i:cnt)ans=(int64_t)ans*(i.second+1)%mod;
	cout<<ans-1<<"\n"s;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



VI visitedTime, allSearchedTime;
vector<VI> edge;
int n, t;

void dfs(int u){
    visitedTime[u] = ++t;
    for(auto v: edge[u]){
        if(!visitedTime[v]) dfs(v);
    }
    allSearchedTime[u] = ++t;
}

void solve(){
    t = 0;
    REP(u, n)
        if(!visitedTime[u]) dfs(u);
    
    REP(u, n)
        cout << u+1 << " " << visitedTime[u] << " " << allSearchedTime[u] << "\n";
}

int main(){
    cin >> n;
    visitedTime.resize(n, 0);
    allSearchedTime.resize(n, 0);
    edge.resize(n);
    REP(i, n){
        int u; cin >> u; --u;
        int k; cin >> k;
        REP(j, k){
            int v; cin >> v; --v;
            edge[u].PB(v);
        }
    }

    solve();
    return 0;
}



Measured memory_bytes: 3152
r,g,b,n = gets.chomp.split.map(&:to_i)

count = 0
for i in 0..3000
    for j in 0..3000
        tmp_sum = r*i + j * g
        tmp = n-tmp_sum
        if tmp%b == 0 && tmp >= 0
            count+=1
        end
    end
end
puts count

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	bool flag = true;
	for(auto e : a) {
		if(e%2 == 0) {
			if(e%3==0 || e%5==0) {

			} else {
				flag = false;
			}
		}
	}
	cout << ((flag) ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
 
using namespace std;
// {{{ Modint
// using mint = modint<1000000007>;
// mint x = 2;
// std::cout << x.a << std::endl;
template <std::int64_t M>
class modint {
public:
  int64_t a;
 
  explicit constexpr modint(const int64_t x = 0) noexcept :
    a((x % M + M) % M) {}
  constexpr int64_t &value() noexcept { return a; }
  constexpr const int64_t &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= M) {
      a -= M;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += M;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % M;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    int64_t exp = M - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  constexpr modint pow(ll t) const {
    if (!t) return modint(1);
    modint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};
// }}}
using mint = modint<1000000007>;
 
ll Y, X, N;
 
vector<pair<int, int>> b;
mint fact[200000];
mint invfact[200000];
mint dp2[4000][2];
 
// block j から block i への経路数
mint route(int j, int i){
  int dy = b[i].first - b[j].first;
  int dx = b[i].second - b[j].second;
  if (dy < 0 || dx < 0)
    return mint(0);
  return fact[dx+dy] * invfact[dx] * invfact[dy];
}
 
int main() {
  cin >> Y >> X >> N;
 
 b.emplace_back(0, 0);
  for (int i=1; i<=N; i++) {
    int y, x;
    cin >> y >> x;
    y--; x--;
    b.emplace_back(y, x);
  }
  b.emplace_back(Y-1, X-1);
  sort(begin(b), end(b));
 
  fact[0] = fact[1] = mint(1);
  invfact[0] = invfact[1] = mint(1);
  for (int i=2; i<200000; i++) {
    fact[i] = fact[i-1] * mint(i);
    invfact[i] = mint(1) / fact[i];
  }
 
  dp2[0][1] = mint(1);
 
  for (int i=1; i<=N+1; i++) for (int p=0; p<2; p++) {
    mint t(0);
    for (int j=0; j<i; j++) {
      t += dp2[j][1-p] * route(j, i);
    }
    dp2[i][p] = t;
  }
  auto ans = dp2[N+1][0] - dp2[N+1][1];
  cout << ans.value() << endl;
  return 0;
}



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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll X, Y; cin >> X >> Y;

  if (X % Y == 0) {
    cout << -1 << endl;
  }else {
    cout << X << endl;
  }

  return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
struct edge {
  ll s;
  ll t;
  ll cost;
};

const ll MAX_N = 100000;
const ll MAX_M = 200000;

ll d[MAX_N], l[MAX_M], r[MAX_M], c[MAX_M];
vector<edge> es[MAX_N];
queue<edge> que;
int arrived[MAX_N];

void debug(ll u, ll v) {
  cout << "no " << u << ": ";
  for (ll i = 0; i < v; i++) {
    cout << d[i] << " ";
  }
  cout << endl;
  cout << "arrived " << u << ": ";
  for (ll i = 0; i < v; i++) {
    cout << arrived[i] << " ";
  }
  cout << endl;
}

bool bfs(ll n, ll m) {
  fill(arrived, arrived+n, -1);
  for (ll i = 0; i < m; i++) {
    arrived[l[i]] = 0;
    arrived[r[i]] = 0;
  }
  for (ll i = 0; i < n; i++) {
    //debug(i, n);
    if (d[i] == -1 || d[i] == 1) {
      continue;
    }
    else {
      for (auto ex: es[i]) {
	que.push(ex);
      }
      while (!que.empty()) {
	edge e = que.front();
	que.pop();

	if (arrived[e.t] == 1 &&
	    d[e.t] != (d[e.s] + e.cost)) {
	  return true;
	}
	else if (!arrived[e.t]) {
	  d[e.t] = d[e.s] + e.cost;
	  arrived[e.t] = 1;
	  for (auto ex: es[e.t]) {
	    que.push(ex);
	  }
	}
      }
    }
  }
  return false;
}

int main() {
  ll n, m;
  cin >> n >> m;

  for (ll i = 0; i < m; i++) {
    int lx, rx, cx;
    cin >> lx >> rx >> cx;
    ll ln = lx - 1;
    ll rn = rx - 1;
    l[i] = ln;
    r[i] = rn;
    edge p = {ln, rn, cx};
    edge q = {rn, ln, -cx};
    es[ln].push_back(p);
    es[rn].push_back(q);
  }
  cout << (bfs(n, m) ? "No" : "Yes") << endl;
}

Measured memory_bytes: 29360