akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;

struct Node{
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(k < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(k < y->key) y->left = z;
    else y->right = z;
  }
}

bool find(int k){
  Node *x = root;
  while(x != NIL && x->key != k){
    if(k < x->key) x = x->left;
    else x = x->right;
  }
  if(x != NIL) return true;
  else return false;
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n; cin >> n;
  rep(i, n){
    string com; cin >> com;
    if(com == "insert"){
      int k; cin >> k;
      insert(k);
    }
    else if(com == "find"){
      int k; cin >> k;
      cout << (find(k) ? "yes" : "no") << endl;
    }
    else if(com == "print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }

  return 0;
}




Measured memory_bytes: 21888
#include <iostream>

int main() {
	long int N = 0;
	std::cin >> N;
	const int num = 1000;
	if (N % num == 0) {
		std::cout << 0 << std::endl;
	} else {
		int count = N / num + 1;
		std::cout << num * count - N << std::endl;
	}
}


Measured memory_bytes: 3156
#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

#define SUBMIT

ll N;

ll blute_force() {
    ll ret = 0;
    for(ll i = 1; i < N; ++i) {
        if(N / i == N % i) { ret += i; }
    }
    return ret;
}

ll solve() {
    if(N < 10) { return blute_force(); }

    ll ret = 0;

    ll s_point = 8;
    ll add_val = 7;
    ll div_cnt = 2;
    while(s_point <= N) {

        ll tmp_n = N - s_point;
        if(tmp_n % div_cnt == 0) {
            ll tmp_start = div_cnt + 1;
            ll tmp_val = (tmp_n / div_cnt) + tmp_start;
            ret += tmp_val;
            //printf(" +%lld -> %lld\n", tmp_val, ret);
        }

        div_cnt++;
        s_point += add_val;
        add_val += 2;
    }
    return ret + (N - 1);
}

signed main()
{
#ifdef SUBMIT
    cin >> N;
    ll ans = solve();
    //ll ans = blute_force();
    printf("%lld\n", ans);
    return 0;
#else
    const int limit = 1000;
    for(int i = 1; i <= limit; ++i) {

        N = i;
        ll ans = blute_force();
        ll cand = solve();
        if(ans != cand)
        {
            printf("N: %lld ans: %lld cand: %lld\n", N, ans, cand);
            return 0;
        }

#  if 0
        vector<int> fav;
        for(int j = 1; j < i; ++j) {
            if(i / j == i % j) { fav.push_back(j); }
        }
        printf("%lld: ", i);
        for(auto& f : fav) {
            printf("%lld ", f);
        }
        printf("\n");
#  endif
    }
#endif
    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  vector<int> va(3);
  cin >> va[0] >> va[1] >> va[2];
  sort(va.begin(), va.end(), greater<int>());
  cout << va[0] * 10 + va[1] + va[2] << '\n';
}


Measured memory_bytes: 3588
N = int(input())
s = []
for i in range(N):
	s.append(int(input()))
Sum = sum(s)
s.sort()
if(Sum % 10 == 0):
	for i in range(N):
		if  s[i]  % 10 != 0 and i !=  N-1:
			print(Sum-s[i])
			break
		if i == N-1:
			print(0)
else:
	print(Sum)

Measured memory_bytes: 3060
n = int(input())
max_t = 0
timing = []
for i in range(n):
    timing.append(int(input()))
    if timing[i] > max_t : max_t = timing[i]

divisor = []
for i in range(1,(max_t>>1)+1):
    if max_t%i == 0 : divisor.append(i)
divisor.append(max_t)
    
adj = 0
for t in timing :
    for d in divisor :
        if  d >= t :
            adj += d - t
            break
print(adj)
    



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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    vector<string> A;
    cin >> n >> m;
    A.resize(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    sort(A.begin(), A.end());
    string ans;
    for (auto &str: A) {
        ans.append(str);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N=int(input())
A=[int(i) for i in input().split()]

# A=[2,4,1,4,2]
dd=defaultdict(int)
ans=0
for a in A:
    dd[a]+=1

for k,v in dd.items():
    if k>v:
        ans+=v
    else:
        ans+=v-k
print(ans)




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

int main() {
	string S;
	string A = "abcdefghijklmnopqrstuvwxyz";
	cin >> S;
	bool flag = false;
	for (int i = 0; i < A.size(); i++) {
		for (int j = 0; j < S.size(); j++) {
			if (A[i] == S[j]) {
				break;
			}
			if (j == S.size() - 1) {
				flag = true;
				cout << S + A[i] << endl;
				return 0;
			}
		}
	}
	if (!flag) {
		if (S == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
		}
		else {
			int index = 0;
			for (int i = 1; i < S.size(); i++) {
				if (S[i-1] < S[i]) {
					index = i-1;
				}
			}
			char m = 'z';
			for (int i = index; i < S.size(); i++) {
				if (S[index] < S[i]) {
					m = min(m, S[i]);
				}
			}
			S[index] = m;
			string result = S.substr(0, index+1);
			cout << result << endl;
		}
		
	}


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 5000000000000;
typedef std::pair<int, int> P;
struct edge { int to;double cost; };
#define VMAX 1010
int N;
long double C[VMAX][VMAX];
long double d[VMAX];
bool F[VMAX];
ll X[VMAX], Y[VMAX], R[VMAX];


void Dijkstra(int s) {
	std::fill(F, F + N + 2, false);
	std::fill(d, d + N + 2, INF);
	d[s] = 0;
	while (true) {
		int v = -1;
		REP(i, N+2) {
			if (!F[i] && (v == -1 || d[i]<d[v]))v = i;
		}
		if (v == -1)break;
		F[v] = true;
		REP(i, N+2) {
			d[i] = std::min(d[i], d[v] + C[v][i]);
		}
	}
}

int main() {
	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy >> N;
	X[N] = sx, Y[N] = sy, X[N + 1] = gx, Y[N + 1] = gy;
	R[N] = R[N + 1] = 0;
	REP(i, 1002)REP(j, 1002)C[i][j] = INF;
	REP(i, N) {
		cin >> X[i] >> Y[i] >> R[i];
	}
    REP(i,2)REP(j,N){
      long double temp =
			sqrtl((X[N+i] - X[j])*(X[N+i] - X[j]) + (Y[N+i] - Y[j])*(Y[N+i] - Y[j]));
      if(temp<=R[j]){
        X[N+i]=X[j];
        Y[N+i]=Y[j];
        R[N+i]=R[j];
        break;
      }
    }
	REP(i, N + 2){REP(j, N + 2) {
		if (i == j) { continue; }
		long double temp =
			sqrtl((X[i] - X[j])*(X[i] - X[j]) + (Y[i] - Y[j])*(Y[i] - Y[j]));
        if(temp<=R[i]+R[j]){C[i][j]=0;}
	    else C[i][j] = temp- R[i] - R[j];
		/*DEB(X[i])DEB(X[j])DEB(Y[i])DEB(Y[j])*/DEB(C[i][j])
	}END}
    Dijkstra(N);
	printf("%.10llf\n", d[N + 1]);
	return 0;
}


Measured memory_bytes: 16128
N = int(input())
A = [int(input()) for _ in range(N)]
sort_A=sorted(A)

if(sort_A[N-1]==sort_A[N-2]):
    for i in range(N):
        print(sort_A[N-1])
else:
    for i in range(N):
        if(A[i]==sort_A[N-1]):
            print(sort_A[N-2])
        else:
            print(sort_A[N-1])



Measured memory_bytes: 18892
/**
 * Libraries
 */
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <iomanip>
#include <set>
#include <unordered_map>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
using lli = long long int;

const int INF = 1000000007;

struct order {
    int id, dstV;
    bool operator<(const order x) const {
        return this->dstV < x.dstV;
    }
};

int dist[400][400];
int nextPath[400][400]; // 経路復元用

signed main() {
    int V, E; cin >> V >> E;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            dist[i][j] = i == j ? 0 : INF;
            nextPath[i][j] = j;
        }
    }
    for (int i = 0; i < E; i++) {
        int u, v, d; cin >> u >> v >> d; u--; v--;
        dist[u][v] = d;
        dist[v][u] = d;
    }
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (dist[i][j] > dist[i][k] + dist[k][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                    nextPath[i][j] = nextPath[i][k];
                }
            }
        }
    }

    int T; cin >> T;
    int car = 0;
    int skipTo = 0;
    int dstV = 0, gotoV = 0;
    vector<int> cargoInStore(T, -1);
    priority_queue<int, vector<int>, greater<int>> dstQ;
    for (int t = 0; t < T; t++) {
        int N; cin >> N;
        vector<order> orders(N);
        for (order o: orders) {
            cin >> o.id >> o.dstV; o.id--; o.dstV--;
            cargoInStore[o.id] = o.dstV;
        }

        if (t < skipTo) {
            cout << gotoV + 1 << endl; // move w
            continue;
        } else if (skipTo == t) {
            skipTo = -1;
            car = gotoV;
        }

        if (car == 0) { // 積荷回収
            for(int i = 0; i < T; i++) {
                if (cargoInStore[i] != -1) {
                    dstQ.push(cargoInStore[i]);
                    cargoInStore[i] = -1;
                }
            }
            dstV = dstQ.empty() ? 0 : dstQ.top();
        } else { // 商品配達後、目的地更新
            while (car == dstV) {
                dstQ.pop();

                dstV = dstQ.empty() ? 0 : dstQ.top();
            }
        }

        // 短期目的地更新
        gotoV = nextPath[car][dstV];
        skipTo = t + dist[car][gotoV];

        if (gotoV == car) {
            cout << -1 << endl; // stay
        } else {
            cout << gotoV + 1 << endl; // move w
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factrial(int n){
  if(n == 0) return 1;
  return n*factrial(n-1);
}

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }


int x[110000];




int main(){
  int N,K;
  cin >> N >> K;
  rep(i,N){
    int num;
    cin >> x[i];
  }
      int temp;
  int ans = inf;
  for(int i = 0; i < N - K + 1; i++){
    int left = i;

    int right = i + K - 1;
    int temp = min(abs(x[i]) + abs(x[i]-x[right]),abs(x[right]) + abs(x[right]-x[i]));
    ans = min(temp,ans);
  }
  cout << ans << endl;
}
  




Measured memory_bytes: 640
def calc_l(px0,py0,px1,py1)
  ((px0-px1)**2+(py0-py1)**2)**0.5
end

def calc_s(px0,py0,px1,py1,px2,py2)
  a=calc_l(px0,py0,px1,py1)
  b=calc_l(px1,py1,px2,py2)
  c=calc_l(px2,py2,px0,py0)
  z=(a+b+c)/2
  (z*(z-a)*(z-b)*(z-c))**0.5
end

ps,s=[],0
while gets
  ps<<$_.split(",").map(&:to_f)
end
(ps.size-2).times do |i|
  s+=calc_s(ps[0][0],ps[0][1],ps[i+1][0],ps[i+1][1],ps[i+2][0],ps[i+2][1])
end
p s.round(6)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

  int X; 
  cin >> X;
  if(X>=30)cout << "Yes" << endl;
  else cout << "No" << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3596
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;

ll A,B,C,D;
map<ll,ll>memo;

ll solve(ll N){
	if(N==0) return 0;
	if(N==1) return D;
	if(memo.count(N)) return memo[N];//nが見つかったらmemoの値を返す
	ll l2 = (N/2)*2;
    ll r2 = ((N+1)/2)*2;
    ll l3 = (N/3)*3;
    ll r3 = ((N+2)/3)*3;
    ll l5 = (N/5)*5;
    ll r5 = ((N+4)/5)*5;

	ll res = 1e18;
    if (N < res/D) res = N*D;//+1だけの場合
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));//llabs-llのabs
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));
 
    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));
 
    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));
 
    memo[N] = res;//Nに到るまでのコイン数
 
    return res;
}

int main(){
	int t;
	cin >> t;
	rep(i,t){
		memo.clear();
		ll N;
		cin >> N>>A>>B>>C>>D;
		cout<<solve(N)<<endl;
	}
	return 0;
}

Measured memory_bytes: 4448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x);
  vector<ll> b(y);
  vector<ll> c(z);
  for(ll i=0;i<x;i++) {
    cin >> a[i];
  }
  for(ll i=0;i<y;i++) {
    cin >> b[i];
  }
  for(ll i=0;i<z;i++) {
    cin >> c[i];
  }
  sort(a.rbegin(),a.rend());
  sort(b.rbegin(),b.rend());
  sort(c.rbegin(),c.rend());
  priority_queue<tuple<ll,ll,ll,ll>> q;
  q.push(tuple<ll,ll,ll,ll>(a[0]+b[0]+c[0],0,0,0));
  set<ll> check;
  while(k--) {
    auto ans=q.top();
    q.pop();
    ll ta=get<1>(ans);
    ll tb=get<2>(ans);
    ll tc=get<3>(ans);
    if(!check.count(ta+1+tb*x+tc*x*y)&&ta<x-1) {
      q.push(tuple<ll,ll,ll,ll>(a[ta+1]+b[tb]+c[tc],ta+1,tb,tc));
      check.insert(ta+1+tb*x+tc*x*y);
    }
    if(!check.count(ta+(tb+1)*x+tc*x*y)&&tb<y-1) {
      q.push(tuple<ll,ll,ll,ll>(a[ta]+b[tb+1]+c[tc],ta,tb+1,tc));
      check.insert(ta+(tb+1)*x+tc*x*y);
    }
    if(!check.count(ta+tb*x+(tc+1)*x*y)&&tc<z-1) {
      q.push(tuple<ll,ll,ll,ll>(a[ta]+b[tb]+c[tc+1],ta,tb,tc+1));
      check.insert(ta+tb*x+(tc+1)*x*y);
    }
    cout << get<0>(ans) << endl;
  }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n , m;
    cin >> n >> m;
    vector <string> v(n);
    for (string &s : v)
        cin >> s;
    sort(v.begin(),v.end());
    for (string &s : v)
        cout << s;
    
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

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

int main(int argc, char* argv[]){
    int N, X, ans = 0, sum = 0, min = 10000;
    int m[1001];
    cin >> N >> X;
    rep(i, N){
        cin >> m[i];
        sum += m[i];
        min = std::min(min, m[i]);
    }
    X -= sum;
    ans += N;
    ans += (X / min);
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 100000


using namespace std;

using ll =long long;
using P = pair<int,int>;

string replaceAll(string &replacedStr, string from, string to) {
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();
 
    if (from.empty()) {
        return replacedStr;
    }
 
    while ((pos = replacedStr.find(from, pos)) != string::npos) {
        replacedStr.replace(pos, from.length(), to);
        pos += toLen;
    }
    return replacedStr;
}
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int gettt(long long int num){
    int digit=0;
if(num<10){
digit=0;
}else{
    while(num>1){
        num /= 10;
        digit++;
    }
}
    return digit;
}

int main() {

ios::sync_with_stdio(false);
cin.tie(0);
int x,n;
cin>>x>>n;
int p[n];
for(int i=0;i<n;i++){
cin>>p[i];
}
sort(p,p+n);

int kotae=0;
int temp=100000;

for(int i=x-100;i<x+100;i++){
bool fl=true;
for(int j=0;j<n;j++){
if(p[j]==i)fl=false;
}
if(fl && temp>abs(x-i)){
temp=abs(x-i);
kotae=i;
}


}

cout<<kotae<<endl;

}
//double res=10.11;
//printf("%.10f",ans);
//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;


Measured memory_bytes: 3616
#include<bits/stdc++.h>
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 repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  vector<vector<P>> tree(n);
  rep(i,n-1){
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    tree[u].push_back(make_pair(v,w));
    tree[v].push_back(make_pair(u,w));
  }
  vi col(n, -1);
  col[0] = 0;
  queue<int> que;
  que.push(0);
  while(!que.empty()){
    int now = que.front(); que.pop();
    for(P &next : tree[now]){
      if(col[next.first] != -1) continue;
      int w = next.second;
      col[next.first] = (col[now] + w) % 2;
      que.push(next.first);
    }
  }
  rep(i,n){
    cout << col[i] << endl;
  }
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

vll s()
{
	ll N=10000000;
	vll cnt(N,0);
	for(ll i=1;i<=N;i++)
		for(ll j=i;j<=N;j+=i)
			cnt[j]++;
	return cnt;
}

void solve()
{	
	ll a,b;
	cin>>a>>b;
	if(a<=5)
		cout<<0;
	else if(a<=12)
		cout<<b/2;
	else
		cout<<b;
	
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

using namespace std;

long long gcd(long long x, long long y) {
    if (x < y) {
        return gcd(y, x);
    }
    if (x % y == 0) {
        return y;
    }
    return gcd(y, x % y);
}

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

int main() {
    int n;
    cin >> n;
    unsigned long long hoge = 1;
    for (int i = 0; i < n; i++) {
        unsigned long long tmp;
        cin >> tmp;
        hoge = lcm(hoge, tmp);
    }
    cout << hoge << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n,x,t;
    cin >> n >> x >> t;
   
   cout << ((n + x-1)/x)*t;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back
#define fi first
#define se second

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;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,K;
signed main(){
	cin>>N>>K;
	if((N-1)*(N-2)/2<K){
		cout<<-1<<endl;return 0;
	}
	vector<P>v;
	for(int i=2;i<=N;i++)v.pb({1,i});
	int now=(N-1)*(N-2)/2;
	for(int i=2;i<N;i++){
		for(int j=i+1;j<=N;j++){
			if(now>K){
				v.pb({i,j});now--;
			}else goto ok;
		}
	}
	ok:;
	cout<<v.size()<<endl;
	for(auto p:v)cout<<p.first<<" "<<p.second<<endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n;
	cin >> n;
	vector<int> v(n);
	int Xor = 0;
	for (auto &it : v) {
		cin >> it;
		Xor ^= it;
	}
	for (int i = 0; i < n; i++)
		cout << (v[i] ^ Xor) << " \n"[i + 1 == n];
}


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

using namespace std;

set<string> S;
string s;
int k;
int main() {
	cin >> s >> k;
	for(int i = 0; i < s.size(); i++) {
		for(int j = 1; j <= 5; j++) {
			S.insert(s.substr(i, j));
		}
	}
	int cnt = 1;
	for(auto & x : S) {
		if(cnt == k) {
			cout << x << endl;
			break;
		}
		cnt++;
	}
}

Measured memory_bytes: 1664
n = int(input())
a = sorted(list(map(int, input().split())))
count = 0
while a[0]%2 == 0:
    for i, x in enumerate(a):
        if x%2 == 0:
            a[i] = x//2
        else:
            print(count)
            exit()
    count += 1
print(count)

Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int A, B;

int main() {
	cin >> A >> B;
	if (A + B == 3) {
		cout << 3 << endl;
	}
	else if (A + B == 4) {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 888
fun main(args: Array<String>) {
    var list = readLine()!!.split(" ").map { it.toInt() }
    while(list[0] != 0 || list[1] != 0) {
        val x = when {
            list[0] > list[1] -> "${list[1]} ${list[0]}"
            list[0] < list[1] -> "${list[0]} ${list[1]}"
            else -> "${list[0]} ${list[1]}"
        }
        println(x)
        list = readLine()!!.split(" ").map { it.toInt() }
    }
}


Measured memory_bytes: 32676
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int dx=tx-sx,dy=ty-sy;
  rep(i,dy) cout<<"U";
  rep(i,dx+1) cout<<"R";
  rep(i,dy+1) cout<<"D";
  rep(i,dx+1) cout<<"L";
  cout<<"UL";
  rep(i,dy+1) cout<<"U";
  rep(i,dx+1) cout<<"R";
  rep(i,dy+1) cout<<"D";
  rep(i,dx) cout<<"L";
  cout<<endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        long max = inpt[0];
        long div = inpt[1];

        long cnt = max / div;

        long ans = cnt * cnt * cnt;
        if(div % 2 ==0) {
            if(cnt * div + (div/2) > max) {
                cnt--;
            }
            cnt++;
            ans += cnt * cnt * cnt;
        }

        Console.WriteLine(ans);
    }





    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"

35897 932



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=1000010, inf=1e9+233, mod=1e9+7;
int n, m, x;
int row[maxn], col[maxn], cntr[maxn], cntc[maxn];

template<typename T>
inline void read(T &k)
{
    int f=1; k=0; char c=getchar();
    while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
    while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
    k*=f;
}

int main()
{
    read(n); read(m);
    for(int i=1;i<=n;i++) 
    {
        read(x); 
        if(row[x]) return puts("0"), 0;
        row[x]=i;
        cntr[i]=m;
    }
    for(int i=1;i<=m;i++) 
    {
        read(x); 
        if(col[x]) return puts("0"), 0;
        col[x]=i;
        cntc[i]=n;
    }

    int nowr=0, nowc=0, ans=1, now=0;
    for(int i=n*m;i;i--)
    {
        if(row[i] && col[i])
        {
            now+=nowr+nowc;
            nowr++; nowc++;
        }
        else if(row[i])
        {
            ans=1ll*ans*nowc%mod;
            now+=nowc-1;
            nowr++;
        }
        else if(col[i])
        {
            ans=1ll*ans*nowr%mod;
            // if(i==177) printf("i:%d cntc[i]:%d\n", i, cntc[i]);
            now+=nowr-1;
            nowc++;
        }
        else ans=1ll*ans*now%mod, now--;
        // printf("i:%d ans:%d\n", i, ans);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 6400
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin >> n;
    vi a, b, p(n), q(n);
    rep(i,n){
        a.push_back(i + 1);
        b.push_back(i + 1);
        cin >> p[i];
    }
    rep(i,n){
        cin >> q[i];
    }
    lli x=1, y=1;
    while(true){
        if(a==p){
            break;
        }
        else{
            x++;
            next_permutation(all(a));
        }
    }
    while (true)
    {
        if (b == q)
        {
            break;
        }
        else
        {
            y++;
            next_permutation(all(b));
        }
    }
    out(abs(x-y));
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  int mid = n / 2;
  int ans = d[mid] - d[mid - 1];
  cout << ans << endl;
  return 0;
}

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

int main(){
    string s;
    cin>>s;
    if(s[s.size()-1]=='s') s+="es";
    else s+='s';
    cout<<s<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<ll> A(N), S(N + 1, 0);

    map<ll, ll> cnt;
    cnt[0] = 1;
    rep(i, N) {
        cin >> A[i];
        S[i + 1] = S[i] + A[i];
        if (cnt.count(S[i + 1]) == 0) {
            cnt[S[i + 1]] = 1LL;
        }
        else {
            cnt[S[i + 1]]++;
        }
    }

    ll res = 0;
    for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
        res += (ll)(itr->second * (itr->second - 1LL)) / 2LL;
    }

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

Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int i, j;
        String level[] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
        double levelData500[] = {35.5d, 37.5d, 40.0d, 43.0d, 50.0d, 55.0d, 70.0d};
        double levelData1000[] = {71d, 77d, 83d, 89d, 105d, 116d, 148d};
        double inputDataSet1, inputDataSet2;
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            i = j = 0;
            inputDataSet1 = sc.nextDouble();
            inputDataSet2 = sc.nextDouble();
            while (i < 7) {
                if (inputDataSet1 < levelData500[i]) {
                    break;
                }
                i++;
            }

            while (j < 7) {
                if (inputDataSet2 < levelData1000[j]) {
                    break;
                }
                j++;
            }

            if (i <= j) {
                System.out.println(level[j]);
            } else {
                System.out.println(level[i]);
            }
        }
    }
}

Measured memory_bytes: 12000
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.ArrayList;

public class Main {
    public static Scanner sc;
    public static ArrayList<Integer> list;
    public static int number;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);
        number = 0;
        while (sc.hasNext()) {
            int n = sc.nextInt();
            
            if (n == 0) break;
            
            int[] ary = new int[n];
            int[] tmp = new int[n];

            for (int i = 0; i < n; i++) {
                ary[i] = sc.nextInt();
            }
            
            calc(ary, n);
        }
    }
    
    public static void calc(int[] a, int n) {
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            int num = a[i];
            int res = 0;
            for (int j = 0; j < n; j++) {
                if (num == a[j]) {
                    res++;
                }
            }
            b[i] = res;
        }
        
        boolean bn = true;
        for (int i = 0; i < n; i++) {
            if (a[i] != b[i]) {
                bn = false;
            }
        }
        
        if (bn) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < n; i++) {
                sb.append(a[i]).append(" ");
            }
            sb.deleteCharAt(sb.length()-1);
            System.out.println(number);
            System.out.println(sb.toString());
            number = 0;
        } else {
            number++;
            calc(b, n);
        }
        return;
    }
}

Measured memory_bytes: 31636
const big_root_priority_queue=true;
      small_root_priority_queue=false;
type priority_queue=object
                      private
                        main:array of longint;
                        size:longint;
                        mode:boolean;
                      public
                        procedure init(a:boolean);
                        procedure push(a:longint);
                        function pop:longint;
                        procedure top;
                        function empty:boolean;
                      end;
procedure priority_queue.init(a:boolean);
begin
  setlength(main,1);
  size:=0;mode:=a;
end;
procedure priority_queue.push(a:longint);
var x,t:longint;
begin
  inc(size);
  setlength(main,size+1);
  main[size]:=a;
  x:=size;
  while x<>1 do
    if (main[x]<main[x>>1]) xor mode then
    begin
      t:=main[x];
      main[x]:=main[x>>1];
      x:=x>>1;
      main[x]:=t;
    end
    else
      break;
end;
function priority_queue.pop:longint;
begin
  exit(main[1]);
end;
procedure priority_queue.top;
var t,x:longint;
begin
  t:=main[1];
  main[1]:=main[size];
  main[size]:=t;
  dec(size);
  setlength(main,size+1);
  x:=1;
  while x<<1<size do
    if ((main[x]<main[x<<1])xor mode)and((main[x]<main[x<<1+1])xor mode) then
      break
    else
    if (main[x<<1]<main[x<<1+1]) xor mode then
    begin
      t:=main[x];
      main[x]:=main[x<<1];
      x:=x<<1;
      main[x]:=t;
    end
    else
    begin
      t:=main[x];
      main[x]:=main[x<<1+1];
      x:=x<<1+1;
      main[x]:=t;
    end;
  if (x<<1=size) and ((main[x]>main[x<<1]) xor mode) then
  begin
    t:=main[x];main[x]:=main[x<<1];main[x<<1]:=t;
  end;
end;
function priority_queue.empty:boolean;
begin
  exit(size<>0);
end;
procedure sort(var a:array of longint;l,r:longint);
var i:longint;
    x:priority_queue;
begin
  x.init(small_root_priority_queue);
  for i:=l to r do
    x.push(a[i]);
  for i:=l to r do
  begin 
    a[i]:=x.pop;
    x.top;
  end;
end;
var n,x,i:longint;
    cnt:array[0..2]of longint;
    a:array[0..100000]of longint;
begin
  readln(n);
  for i:=1 to n do
    read(a[i]);
  sort(a,1,n);
  i:=n;
  while i>=1 do
    if a[i]=a[i-1] then
    begin
      inc(x);
      cnt[x]:=a[i];
      dec(i,2);
      if x=2 then
        break;
    end
    else
      dec(i,1);
  writeln(qword(cnt[1]*cnt[2]));
end.

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (st                                  derr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<pii, int> mpii;
typedef set<int> sti;
const int INF = 1e9, MOD = INF + 7 /* INF - 1755647 */;
int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }
int power(int a, int b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); }

/////////////////////////////////////////////////////////////////////

const int N = 1e5 + 20, M = 2e1 + 2;

int cnt[N];

int32_t main() {

    sync;
    
    int n; cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        ans = gcd(ans, x);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
	int n;
	vector<string> s;
	vector<int> p, idx;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		string tmp1;
		int tmp2;
		cin >> tmp1 >> tmp2;
		s.push_back(tmp1);
		p.push_back(tmp2);
		idx.push_back(i+1);
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n-i-1;j++){
			if(s[j] > s[j+1]){
				swap(s[j], s[j+1]);
				swap(p[j], p[j+1]);
				swap(idx[j], idx[j+1]);
			}
			else if(s[j] == s[j+1]){
				if(p[j] < p[j+1]){
					swap(s[j], s[j+1]);
					swap(p[j], p[j+1]);
					swap(idx[j], idx[j+1]);
				}
			}
		}
	}
	
	for(int i=0;i<n;i++){
		cout << idx[i] << endl;
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) if((i)) puts("YES");else puts("NO");
#define YesNo(i) if((i)) puts("Yes");else puts("No");
#define yesno(i) if((i)) puts("yes");else puts("no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  YesNo(s[0]=='7'||s[1]=='7'||s[2]=='7');
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n;
vector< vector< int > > arr( 1e5 + 5, vector< int >( 4 ) );
int dp[ 100005 ][ 4 ];

int solve( int j, int prev )
{
	if( j == n + 1 )
	{
		return 0;
	}
	if( dp[ j ][ prev ] != -1 )
	{
		return dp[ j ][ prev ];
	}
	dp[ j ][ prev ] = 0;
	for( int i = 1; i <= 3; ++i )
	{
		if( i != prev )
		{
			dp[ j ][ prev ] = max( dp[ j ][ prev ], arr[ j ][ i ] + solve( j + 1, i ) );
		}		
	}
	return dp[ j ][ prev ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	memset( dp, -1, sizeof( dp ) );
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ][ 1 ] >> arr[ i ][ 2 ] >> arr[ i ][ 3 ];		
	}
	cout << max( { arr[ 1 ][ 1 ] + solve( 2, 1 ), arr[ 1 ][ 2 ] + solve( 2, 2 ), arr[ 1 ][ 3 ] + solve( 2, 3 ) } ) << "\n";
	return 0;
}


Measured memory_bytes: 16640
// Comment
// delete all white sub tree node.  tree 순회 * 2 - tree dp value

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

int N;
vector<int> Ed[MAX_N];
vector<pi> G[MAX_N];
char S[MAX_N];
int Chk[MAX_N];
int AllBlack[MAX_N];
bool isAllBlack(int v, int p) {
	for(int w: Ed[v]) if(w != p) {
		Chk[v]++;
		if(isAllBlack(w, v)) Chk[v]--;
	}
	if(Chk[v] == 0 && S[v] == 'B') return AllBlack[v] = true;
	return AllBlack[v] = false;
}
vector<pi> Dy[MAX_N][2];
void getDy(int v, int p) {
	Dy[v][0] = vector<pi>(2, pi(0, -1));
	Dy[v][1] = vector<pi>(2, pi(0, -2));
	for(pi pp: G[v]) {
		int w, c; tie(w, c) = pp;
		if(w == p) continue;
		getDy(w, v);
		Dy[v][0].push_back(pi(Dy[w][0][0].one + c, w));
		sort(ALL(Dy[v][0]));
		reverse(ALL(Dy[v][0]));
		Dy[v][0].resize(2);
	}
	for(pi pp: G[v]) {
		int w, c; tie(w, c) = pp;
		if(w == p) {
			Dy[p][1].push_back(pi(Dy[v][1][0].one + c, v));
			sort(ALL(Dy[p][1]));
			reverse(ALL(Dy[p][1]));
			Dy[p][1].resize(2);
		}
	}
}
int main() {
	cin >> N;
	for(int i=1; i<N; i++) {
		int x, y; scanf("%d%d", &x, &y);
		Ed[x].push_back(y);
		Ed[y].push_back(x);
	}
	scanf("%s", S+1);
	int r = -1;
	for(int i=1; i<=N; i++) if(S[i] == 'W') {
		r = i;
		break;
	}
	if(r == -1) {
		puts("0");
		return 0;
	}
	isAllBlack(r, -1);

	for(int v=1; v<=N; v++) if(AllBlack[v] == false) {
		int cnt = 0;
		for(int w: Ed[v]) if(AllBlack[w] == false) cnt++;
		if(cnt % 2 == 1) S[v] = 'W' + 'B' - S[v];
	}
	for(int v=1; v<=N; v++) {
		for(int w: Ed[v]) if(AllBlack[w] == false) {
			G[v].emplace_back(w, (S[w] == 'W') * 2);
		}
	}

	int ans = 0;
	for(int v=1; v<=N; v++) if(AllBlack[v] == false) ans++;
	ans = max(0, (ans - 1)) * 2;
	for(int v=1; v<=N; v++) if(AllBlack[v] == false && S[v] == 'W') ans++;

	getDy(r, -1);

	int maxV = 0;
	for(int i=1; i<=N; i++) if(AllBlack[i] == false) {
		if(Dy[i][0][0].two != Dy[i][1][0].two) {
			maxV = max(maxV, Dy[i][0][0].one + Dy[i][1][0].one);
		}else{
			maxV = max(maxV, Dy[i][0][1].one + Dy[i][1][0].one);
			maxV = max(maxV, Dy[i][0][0].one + Dy[i][1][1].one);
		}
	}
	ans -= maxV;

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


Measured memory_bytes: 42024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;

string alpha="abcdefghijklmnopqrstuwvxyz";

int N;


int main(){
    cin>>N;
    if(N<=999){
        cout<<"ABC"<<endl;
    }
    else cout<<"ABD"<<endl;



    return 0;
}

Measured memory_bytes: 256