akhauriyash/Code-Regression huggingface dataset:
// G++ MACro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int gcd(int m,int n){
  if(0==n)return m;
  return gcd(n,m%n);
}
 
int main(){
  CIN(n,k);V a(n);VECCIN(a);
  if(n==1){POSSIBLE(k==a[0]);return 0;}
  if(k>*max_element(ALL(a))){POSSIBLE(false);return 0;}
  int gc=gcd(a[0],a[1]);
  FOR(i,2,n){
    gc=gcd(gc,a[i]);
  }
  POSSIBLE(k%gc==0);
  return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        char[] scha = s.toCharArray();
        char[] tcha = t.toCharArray();
        Arrays.sort(scha);
        Arrays.sort(tcha);
        int scnt = scha.length;
        int tcnt = tcha.length;
        boolean minIsS = true;
        if (scnt > tcnt) {
            minIsS = false;
        }
        int ans = -1;
        for (int i = 0; i < Math.min(scnt, tcnt); i++) {
            if (scha[i] == tcha[tcnt - 1 - i])
                continue;
            if (scha[i] < tcha[tcnt - 1 - i]) {
                ans = 1;
                break;
            } else {
                ans = 0;
                break;
            }
        }
        if (ans == -1) {
            if (scnt == tcnt) {
                ans = 0;
            } else if (scnt < tcnt) {
                ans = 1;
            }
        }
        if (ans == 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 23252
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then Enum.empty ()
  else
    List.map (fun _ -> scan fmt f) (1 ++ n)
    |> List.enum

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (h, w)  = scan "%d %d" Tuple.Tuple2.make
let g = scan_matrix h w "." id
let m = Array.make_matrix h w (-1)
let ds = [(-1,0);(1,0);(0,-1);(0,1)]

let rec bfs visited queue =
  if Queue.is_empty queue then ()
  else
    let (i, j, n) = Queue.pop queue in
    if visited.(i).(j) then bfs visited queue;

    visited.(i).(j) <- true;
    m.(i).(j) <- n;
    ListL.iter ds ~f:(fun (di, dj) ->
        let x, y = i + di, j + dj in
        if between 0 x h && between 0 y w && not visited.(x).(y)
           && g.(x).(y) = "." then
          Queue.push (x,y, succ n) queue);
    bfs visited queue

let () =
  let visited = Array.make_matrix h w false in
  let q = Queue.create () in
  Queue.push (0,0,1) q;
  bfs visited q;
  let n = m.(h-1).(w-1) in
  (if n = -1 then -1
   else
     h*w -
     (ArrayL.map g
        ~f:(fun line ->
            ArrayL.filter line ~f:((=) "#")
            |> Array.length)
      |> Array.sum) - n)
  |> Printf.printf "%d\n"


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int x;
    cin >> x;
    cout << x*x*x << endl;
}



Measured memory_bytes: 3084
/**
 *	author: tanishq_code_c
**/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
// template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



void __print(int x) {cerr << x;}; void __print(long x) {cerr << x;}; void __print(long long x) {cerr << x;}; void __print(unsigned x) {cerr << x;}; void __print(unsigned long x) {cerr << x;}; void __print(unsigned long long x) {cerr << x;}; void __print(float x) {cerr << x;}; void __print(double x) {cerr << x;}; void __print(long double x) {cerr << x;}; void __print(char x) {cerr << '\'' << x << '\'';}; void __print(const char *x) {cerr << '\"' << x << '\"';}; void __print(const string &x) {cerr << '\"' << x << '\"';}; void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif


#define int             							long long
#define setbits(x)     							    __builtin_popcountll(x)
#define zerobits(x)     							__builtin_ctzll(x)
#define mod             							1000000007
#define inf            							    1e18
#define endl            							'\n'
#define pb              							push_back
#define all(x)          							x.begin(),x.end()
#define ff              							first
#define ss              							second
#define rep(i,n)                                  	for(int i = 0; i < n; i++)
#define set(n)                                      fixed << setprecision(n)

int powmod(int a, int b) {int res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
int fast_pow(int a, int b) {if (b == 1) return a; if (b == 0) return 1; int x = fast_pow(a, b / 2); x *= x; if (b & 1) x *= a; return x;}

void t_c_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("inp.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif*/
	int n; cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int pre[n];
	pre[0] = arr[0] % mod;
	for (int i = 1; i < n; i++) {
		pre[i] = (pre[i - 1] % mod + arr[i] % mod) % mod;
		pre[i] %= mod;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int elem = (((pre[n - 1] - pre[i]) % mod) + mod) % mod;
		ans += (arr[i] % mod * elem % mod) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

int32_t main()
{
	t_c_c();
	return 0;
}


Measured memory_bytes: 6764
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  vector<int> v;
  v.push_back(1);
  FOR(i, 1, 7) v.push_back((int)pow(6, i));
  FOR(i, 1, 6) v.push_back((int)pow(9, i));
  sort(v.begin(), v.end());
  int dp[n + 1];
  dp[0] = 0;
  dp[1] = 1;
  FOR(i, 2, n + 1) {
    int mi = dp[i-1] + 1;
    rep(j, v.size()) {
      if(i - v[j] >= 0) {
        mi = min(mi, dp[i - v[j]] + 1);
      }
    }
    dp[i] = mi;
  }
  cout << dp[n] << endl;
  

  return 0;
}


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

const int mod = 1000000007;

int main() {
  int n;
  cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  
  reverse(a.begin(),a.end());
  vector<long long> b(n);
  b.at(0)=a.at(0);
  for(int i=1;i<n;i++){
    b.at(i)=(b.at(i-1)+a.at(i))%mod;
  }
  reverse(b.begin(),b.end());
  reverse(a.begin(),a.end());
  
  long long ans=0;
  for(int i=0;i<n-1;i++){
    long long aa = a.at(i)*b.at(i+1) % mod;
    ans+=aa;
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6400
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, A, B = mi()

if not (A - B)%2:
    print((B-A)//2)
else:
    print(min(A+(B-A)//2, N-B+1+(B-A)//2))

Measured memory_bytes: 3064
//https://scrapbox.io/ganariya/AtCoderBeginnerContest077_C%E5%95%8F%E9%A1%8C300%E7%82%B9_%E3%80%8CSnuke_Festival%E3%80%8D_(copy)
//勉強させていただいた記事

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int N;
    cin>>N;
    vector<int> A(N),B(N),C(N);
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];
    rep(i,N)cin>>C[i];
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));

    ll ans=0;

    rep(i,N){
        ll pre=lower_bound(A.begin(),A.end(),B[i])-A.begin();//イテレータは足し算、引き算ができる...!結果も正しく出る
        ll over=C.end()-upper_bound(C.begin(),C.end(),B[i]);//B[i]よりも大きい配列数
        ans+=pre*over;
    }

    cout<<ans<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
			int m = 4280;
		while(w != -1){
			int r = 0;
			if(w <= 10){
				r = 1150;
			}else if(w <= 20){
				r = 1150+(w-10)*125;
			}else if(w <= 30){
				r = 1150+10*125+(w-20)*140;
			}else{
				r = 1150+10*125+10*140+(w-30)*160;
			}
			System.out.println(m-r);
			w = scan.nextInt();
		}
	}
}

Measured memory_bytes: 18580
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#define fo(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
const int N=1e5+10;
typedef pair<int,int> pr;
typedef multiset<int>::iterator it;

queue<pr> q;
map<pr,int> mp;
multiset<int> b[N];

int f[N];

int find(int x){return !f[x]?x:f[x]=find(f[x]);}

void link(int x,int y){b[x].insert(y),b[y].insert(x);}

pr mkpr(int x,int y){
    if(x>y) swap(x,y);
    return make_pair(x,y);
}

int main() {
    int n;
    scanf("%d",&n);
    fo(i,1,n*2-2){
        int x,y;
        scanf("%d %d",&x,&y);
        link(x,y);
        pr t=mkpr(x,y);
        ++mp[t];
        if(mp[t]==2) q.push(t);
    }
    fo(ch,2,n){
        if(q.empty()) return puts("NO"),0;
        int x=0,y=0;
        for(;x==y;x=find(q.front().first),y=find(q.front().second),q.pop());
        if(b[x].size()>b[y].size()) swap(x,y);
        f[x]=y;
        for(it i=b[x].begin();i!=b[x].end();i++){
            int v=find(*i);
            b[v].erase(b[v].find(x));
            if(v==y) continue;
            link(v,y);
            pr t=mkpr(v,y);
            ++mp[t];
            if(mp[t]==2) q.push(t);
        }
        b[x].clear();
    }
    puts("YES");
}


Measured memory_bytes: 38932
A,B,K = [int(x) for x in input().split()]
if(B-A+1>2*K):
  for i in range(A,A+K):
    print(i)
  for i in range(B-K+1,B+1):
    print(i)
else:
  for i in range(A,B+1):
    if(i<= A+K-1 or i>= B-K+1):
      print(i)
    

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

template <class Cost = int>
struct Edge {
    int from, to;
    Cost cost;
    Edge(int from = -1, int to = -1, Cost cost = 1)
        : from(from), to(to), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
class Graph {
public:
    int size;
    std::vector<std::vector<Edge<Cost>>> path;

    explicit Graph(int N = 0) : size(N), path(size) {}
    void span(int from, int to, Cost cost = 1) {
        path[from].push_back(Edge<Cost>(from, to, cost));
    }
    std::vector<Edge<Cost>>& operator[](int v) { return path[v]; }
};

template <class Cost = int>
class Lowlink {
private:
    Graph<Cost> graph;
    int cur;
    std::vector<int> order, low;

    void dfs(int v, int r) {
        order[v] = low[v] = cur++;
        int deg = 0;
        bool is_artic = false;

        for (auto e : graph[v]) {
            if (order[e.to] < 0) {
                ++deg;
                dfs(e.to, e.from);
                low[e.from] = std::min(low[e.from], low[e.to]);

                if (order[e.from] <= low[e.to]) is_artic = true;
                if (order[e.from] < low[e.to]) bridges.push_back(e);
            } else if (e.to != r) {
                // eは後退辺 1回だけ遡る
                low[e.from] = std::min(low[e.from], order[e.to]);
            }
        }

        if (r < 0) is_artic = (deg > 1);
        if (is_artic) artics.push_back(v);
    }

public:
    std::vector<int> artics;
    std::vector<Edge<Cost>> bridges;

    explicit Lowlink(const Graph<Cost>& graph)
        : graph(graph), order(graph.size, -1), low(graph.size, graph.size) {
        cur = 0;
        for (int v = 0; v < graph.size; ++v) {
            if (order[v] < 0) dfs(v, -1);
        }
    }
};

void fail() {
    std::cout << "No" << std::endl;
    exit(0);
}

void ok() {
    std::cout << "Yes" << std::endl;
    exit(0);
}

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

    Graph<> graph(N);
    for (int i = 0; i < M; ++i) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        graph.span(u, v);
        graph.span(v, u);
    }

    for (int v = 0; v < N; ++v) {
        if (graph[v].size() % 2 != 0) fail();
    }

    for (int v = 0; v < N; ++v) {
        if (graph[v].size() >= 6) ok();
    }

    int cnt = 0;
    for (int v = 0; v < N; ++v) {
        if (graph[v].size() >= 4) ++cnt;
    }

    if (cnt <= 1) fail();
    if (cnt >= 3) ok();

    Lowlink<> lowlink(graph);
    std::cout << (lowlink.artics.empty() ? "No" : "Yes") << std::endl;
    return 0;
}


Measured memory_bytes: 15744
#include<cstdio>
using namespace std;
int main(){
  int h,i,j;
  int n,m;
  while(scanf("%d%d",&n,&m),n||m){
    int s[100];
    for(i=0;i<m;++i)
      scanf("%d",s+i);
    h=1;
    for(i=0;i<n;++i){
      for(j=0;j<m;++j){
	int b;
	scanf("%d",&b);
	if(h){
	  s[j]-=b;
	  if(s[j]<0)
	    h=0;
	}
      }
    }
    if(h)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}

Measured memory_bytes: 732
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int a,b,s1,s2,s3;
    while(~scanf("%d %d",&a,&b))
    {
       s1=a+b;
       s2=a-b;
       s3=a*b;
       if(s1>=s2&&s1>=s3)
        printf("%d\n",s1);
       else if(s2>=s1&&s2>=s3)
        printf("%d\n",s2);
       else if(s3>=s1&&s3>=s2)
            printf("%d\n",s3);
    }
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(1, n + 1):
    b.append(a[i-1]-i)
b.sort()
c = b[(len(b) - 1)//2]
#print(c)
ans = 0
for i in range(n):
    ans += abs(b[i] - c)
print(ans)

Measured memory_bytes: 26836
#include <stdio.h>

#define Mod 1000000007

int main()
{
	char L[100002];
	scanf("%s", L);
	
	int i, l;
	long long ans = 1, pow[100001];
	for (l = 1, pow[0] = 1, pow[1] = 1; L[l] != 0; l++) pow[l+1] = pow[l] * 3 % Mod;
	for (i = l - 1; i >= 0; i--) {
		if (L[i] == '1') ans = (ans * 2 + pow[l-i]) % Mod;
	}
	
	printf("%lld\n", ans % Mod);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2576
#include<bits/stdc++.h>
namespace imzzy{
	#define endl '\n'
	#define ccf std::cout<<"f**k"<<endl
	// #define rgi register int
	#define rgi int
	#define ll long long
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL);
	#endif
}}using namespace imzzy;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=1000000007,inf=1201201201;

int a[maxn];
signed main()
{P_INIT();
	int n,ans=0; fin>>n;
	for(rgi i=1;i<=n*2;++i) fin>>a[i];
	std::sort(a+1,a+1+n*2);
	for(rgi i=2;i<=n*2;i+=2) ans+=std::min(a[i],a[i-1]);
	fout<<ans;
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 3648
(defun parse-int-ex (n)
  (cond ((upper-case-p n) (- (char-code n) 55))
        ((lower-case-p n) (- (char-code n) 87))
        (t (- (char-code n) 48))))
(let* ((n (read-line)))
  (if (= 0 (mod (reduce #'+ (map 'list #'parse-int-ex n)) 9)) (princ "Yes") (princ "No")))


Measured memory_bytes: 30108
import sys
import numpy as np
from itertools import accumulate


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    def make_prime(U):
        is_prime = np.zeros(U, np.bool)
        is_prime[2] = 1
        is_prime[3::2] = 1
        M = int(U ** 0.5) + 1
        for p in range(3, M, 2):
            if is_prime[p]:
                is_prime[p * p :: p + p] = 0
        return is_prime

    primes = make_prime(10 ** 5 + 1)
    check = np.where(primes == True, 1, 0)
    for i in range(1, 10 ** 5 + 1):
        if i % 2 == 1:
            if primes[i]:
                if not primes[(i + 1) // 2]:
                    check[i] = 0
        else:
            continue
    check[2] = 0
    check = list(accumulate(check))
    Q = int(input())
    for _ in range(Q):
        l, r = map(int, input().split())
        print(check[r] - check[l - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 17332
n = gets.to_i
pr = []
n.times do
  a = gets.to_i
  hs = Hash.new
  a.times do
    x, y = gets.chomp.split.map(&:to_i)
    hs[x - 1] = y
  end
  pr.push(hs)
end

res = 0
(2 ** n - 1).step(0, -1) do |b|
  ok = true
  0.step(n - 1) do |i|
    if b & (1 << i) == 0
      next
    end

    pr[i].each do |x, y|
      if b & (1 << x) != (y << x)
        ok = false
        break
      end
    end

    if !ok
      break
    end
  end
  
  if ok
    cnt = ("%b" % [b]).count("1")
    res = cnt if cnt > res
  end
end
puts res

Measured memory_bytes: 14216
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e9
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}


ll getFirstSetBitPos(ll n) 
{ 
    return log2(n & -n) + 1; 
} 

int main()
{
    int r;

    cin >> r;

    cout << r*r << "\n";	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;

int main() {
	string s;
	cin >> s;
	if ((int) s.size() & 1) {
		while (1) {
			s.erase(s.end() - 1);
			string left = s.substr(0, (int) s.size() / 2);
			string right = s.substr((int) s.size() / 2, (int) s.size() / 2);
			if (left == right) {
				return printf("%d\n", (int) s.size()), 0;
			}
		}
	} else {
		while (1) {
			s.erase(s.end() - 2, s.end());
			string left = s.substr(0, (int) s.size() / 2);
			string right = s.substr((int) s.size() / 2, (int) s.size() / 2);

			if (left == right) {
				return printf("%d\n", (int) s.size()), 0;
			}
		}
	}
}



Measured memory_bytes: 3732
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		int ans = 0;
		for (int i = 0; i < S.length(); i++) {
			for (int j = i + 1; j <= S.length(); j++) {
				String s = S.substring(i, j);
				boolean flag = true;
				for (int l = 0; l < s.length(); l++) {
					if (s.charAt(l) != 'A' && s.charAt(l) != 'T' && s.charAt(l) != 'C' && s.charAt(l) != 'G') {
						flag = false;
						break;
					}
				}
				if (flag && s.length() > ans)
					ans = s.length();
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23508
n, m = map(int, input().split())
ne = []
for i in range(n):
    ne.append(list(map(int, input().split())))
ne.sort(key=lambda x: x[0])
ans = 0
for i in range(n):
    if ne[i][1] >= m:
        ans += m * ne[i][0]
        break
    else:
        ans += ne[i][0] * ne[i][1]
        m -= ne[i][1]
print(ans)


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

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

	string ans = "";
	for (int i = 0; i < s.length(); i++) {
		if (s.at(i) == '0') {
			ans.insert(ans.end(), '0');
		} else if (s.at(i) == '1') {
			ans.insert(ans.end(), '1');
		} else {
			if (ans != "") {
				ans.erase(ans.end()-1);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N, T = ds_in()
cmin = 10**10

for _ in range(N):
    c, t = ds_in()
    if t <= T:
        cmin = min(cmin, c)

if cmin == 10**10:
    print('TLE')
else:
    print(cmin)


Measured memory_bytes: 3060
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b) = listOfInt()
    println(if (b % a == 0) a + b else b - a)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37772
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}


//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}


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

	vector<ll> c(S.size());
	rep(i, S.size()) {
		if (i == 0) {
			if (S[i] == 'B') c[i] = 1;
			else c[i] = 0;
		}
		else {
			if (S[i] == 'B') c[i] = c[i-1] + 1;
			else c[i] = c[i-1];
		}
	}

	ll ans = 0;
	rep(i, S.size()) {
		if (S[i] == 'W') ans += c[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 9988
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    vector<int> a;
    inputVector(a, n);

    sort(all(a));

    cout << a[n - 1] - a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

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

  if(((a==b) &&( a!=c))||((a==c) &&( a!=b))||((b==c) &&( a!=b))){
    printf("Yes");
  }else{
    printf("No");
  }
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	map<ll, ll> mp;
	ll sum = 0;
	rep(i,n){
		ll a;
		cin >> a;
		mp[a]++;
		sum +=a;
	}
	ll q;
	cin >> q;
	rep(i,q){
		ll b, c;
		cin >> b >> c;
		ll num = mp[b];
		// num個のcが増える
		// num個のcが減る
		sum -= num * b;
		sum += num * c;
		cout << sum << endl;
		mp[b] = 0;
		mp[c] += num;
	}
}


Measured memory_bytes: 9496
N, M, K = map(int, input().split())

ans = False
for n in range(N + 1):
    for m in range(M + 1):
        if n * (M - m) + m * (N - n) == K:
            ans = True
            break
    else:
        continue
    break
print('Yes' if ans else 'No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    rep(i, N)
    {
        cin >> B[i];
    }
    rep(i, N)
    {
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    ll ans = 0;
    for(auto b: B) {
        ll i = lower_bound(A.begin(), A.end(), b) - A.begin();
        ll j = C.end() - upper_bound(C.begin(), C.end(), b);
        ans += i * j;
    }
    cout << ans << endl;
    return 0;
}

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

const int MAX = 50;
const char FLOOR = '.';
const char WALL = '#';

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
	int H, W;
	char map[MAX][MAX];
	cin >> H >> W;
	for (int i = 0;i < H;i ++) {
		cin >> map[i];
	}
	
	int white = 0; // 白い床の数
	for (int i = 0;i < H;i ++) {
		for (int j = 0;j < W;j ++) {
			if (map[i][j] == FLOOR) white ++;
		}
	}
	
	int dist = 0;
	queue<pair<pair<int, int>, int> > que; // 現在探索している座標とその距離
	que.push(make_pair(make_pair(0, 0), 0));
	pair<pair<int, int>, int> tmp;
	while (!que.empty()) { // DFS
		tmp = que.front();
		que.pop();
		if (tmp.first.first < 0 || tmp.first.first >= W || tmp.first.second < 0 || tmp.first.second >= H) continue; // マップ外も除外
		if (map[tmp.first.second][tmp.first.first] == WALL) continue; // 黒マス見ても仕方がない
		map[tmp.first.second][tmp.first.first] = WALL; // 同じマスを2回チェックする無駄防止
		if (tmp.first.first == W - 1 && tmp.first.second == H - 1) { // ゴールに着いた
			cout << white - tmp.second - 1; // 最初のマスとゴールマスも塗れないからね
			return 0;
		}
		for (int i = 0;i < 4;i ++) {
			que.push(make_pair(make_pair(tmp.first.first + dx[i], tmp.first.second + dy[i]), tmp.second + 1)); // 次のマス
		}
		if (dist != tmp.second) { // デバッグ用
			dist = tmp.second;
			//cout << "現在の距離:" << dist << endl;
			for (int i = 0;i < H;i ++) {
				//cout << map[i] << endl;
			}
		}
	}
	cout << -1; // 辿り着けなかった
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

塗れる数を最大にするならば、通らない道全てを黒に変えたい
つまり、通らないマスを最大にしたい
つまり、すぬけ君は最短経路を通る
よって、まずすぬけ君に最短経路を通らせ、次に最短経路ではなかった場所を全て黒に塗れば良い訳だ
最短経路の長さはBFSを用いれば即座に出るので簡単に求められる
*/

Measured memory_bytes: 256
const main = (standardInput) => {
    const lengthList = standardInput.split(' ');
    lengthList[0] = Number.parseInt(lengthList[0])
    lengthList[1] = Number.parseInt(lengthList[1])
    lengthList[2] = Number.parseInt(lengthList[2])
    lengthList.sort((a, b) => {
      return a > b
    })
    console.log(lengthList[0] + " " + lengthList[1] + " " + lengthList[2])
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



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

public class Program
{
	static void Main(string[] args)
	{
		new Program();
	}

	private bool isDebug = false;
	private IReader reader;

	public Program()
	{
		reader = new ConsoleReader();
		if (isDebug) {
			reader = new FileReader("test.txt");
		}

		int[] v = reader.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		List<int> valueList = new List<int>();
		valueList.Add(v[0] + v[1]);
		valueList.Add(v[0] - v[1]);
		valueList.Add(v[0] * v[1]);
		int res = valueList.Max();
		Console.WriteLine(res);
	}
}

// ------------------------------------------------------------------
public interface IReader
{
	string ReadLine();
}

//
public class ConsoleReader : IReader
{
	string IReader.ReadLine()
	{
		return Console.ReadLine();
	}
}

//
public class FileReader : IReader
{
	private StreamReader streamReader;

	public FileReader(string path)
	{
		try {
			streamReader = new StreamReader(path, Encoding.UTF8);
		}
		catch (Exception ex) {
			Console.WriteLine(ex);
		}
	}

	string IReader.ReadLine()
	{
		return streamReader.ReadLine();
	}
}



Measured memory_bytes: 13396
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int N, K, A[100111];
VI G[100111];
int D[100111];


int main() {
    scanf("%d%d", &N, &K);
    REP (i, N) {
	scanf("%d", A+i);
	A[i]--;
    }

    int ans = 0;
    if (A[0] != 0) {
	ans++;
	A[0] = 0;
    }

    for (int i=1; i<N; i++) {
	G[A[i]].push_back(i);
    }

    VI ord; ord.reserve(N);
    ord.push_back(0);
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) {
	    ord.push_back(*e);
	}
    }

    for (int i_=N; i_--; ) {
	int v = ord[i_];
	if (v == 0) continue;;

	if (D[v] + 1 >= K) {
	    if (A[v] != 0) ans++;
	    A[v] = 0;
	} else {
	    amax(D[A[v]], D[v] + 1);
	}
    }

//    REP (i, N) eprintf("%d ", A[i] + 1); eprintf("\n");
    printf("%d\n", ans);

    return 0;
}



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

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

Node* Find(Node *u,int k)
{
    while(u!=NIL&&k!=u->key)
    {
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}

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(z->key<x->key)
        {
            x=x->left;
        }
        else
        {
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL)
    {
        root=z;
    }else
    {
        if(z->key<y->key)
        {
            y->left=z;
        }else
        {
            y->right=z;
        }
    }
}
void inorder(Node *u)
{
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n,i,x;
    string com;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        cin>>com;
        if(com[0]=='f')
        {
            scanf("%d",&x);
            Node *t=Find(root,x);
            if(t!=NIL)printf("yes\n");
            else printf("no\n");
        }
        else if(com=="insert")
        {
            scanf("%d",&x);
            Insert(x);
        }
        else if(com=="print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

 	return 0;
}



Measured memory_bytes: 22044
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int K,X;
	cin>>K>>X;

	for(int i=X-K+1; i<=X+K-1; i++)
	{
		cout<<i<<" ";
	}
	cout<<endl;
}

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


void solve(long long K, long long T, std::vector<long long> a){
    sort(a.begin(), a.end());
    ll left = 0, right = 0;
    for(ll i = T - 1; i >= 0; --i){
        if(left <= right){
            left += a.at(i);
        }else{
            right += a.at(i);
        }
    }
    cout << max(0LL, abs(left - right) - 1) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long K;
    scanf("%lld",&K);
    long long T;
    scanf("%lld",&T);
    std::vector<long long> a(T);
    for(int i = 0 ; i < T ; i++){
        scanf("%lld",&a[i]);
    }
    solve(K, T, std::move(a));
    return 0;
}


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

ll C[51][51];

void combination_table(int n) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 or j == i) {
        C[i][j] = 1ll;
      } else {
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      }
    }
  }
}

void solve(long long N, long long A, long long B, std::vector<long long> v) {
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  combination_table(N);
  double avg = 0.0;

  for (int i = 0; i < A; i++) {
    avg += v[i];
  }
  avg /= A;
  int totalCount = 0, localCount = 0;
  for (int i = 0; i < N; i++) {
    if (v[i] == v[A - 1]) {
      totalCount++;
      if (i < A) {
        localCount++;
      }
    }
  }
  ll res = 0;
  if (localCount == A) {
    for (int i = A; i <= B; i++) {
      res += C[totalCount][i];
    }
  } else {
    res += C[totalCount][localCount];
  }
  cout << setprecision(10) << avg << endl;
  cout << res << endl;
}

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

  long long N;
  scanf("%lld", &N);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  std::vector<long long> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &v[i]);
  }
  solve(N, A, B, std::move(v));
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    card.at(i) =a;
      }
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());
    int A=0,B=0;
    for(int i=0;i<N;i++){
      if(i%2==0){
        A += card.at(i);
      }
      else{
        B += card.at(i);
      }
    }
    cout << A-B << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int s,hour,minute,second;
	
	scanf("%d",&s);
	
	hour= s/3600;
	minute= (s-3600*hour)/60;
	second= s-3600*hour-60*minute;
	
	printf("%d:%d:%d\n",hour,minute,second);
	
	return 0;
}


Measured memory_bytes: 2076
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}   //fill table with 0
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();  //vertex
			int degree = in.nextInt();  //degree(undirected)
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;  //1/0 
				adjWeight[u][v] = in.nextInt();  //weight
			}	
		}
		in.close();
	}
	
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {  //start from 0 vertex
		int[]dist = new int[totalVertex];
		for(int i=1;i<totalVertex;i++) {
			dist[i]= Integer.MAX_VALUE;
		}
		dist[s]=0;
		for(int u=0;u<totalVertex;u++){
			int a = getUnsettledNearest(dist);
			LinkedList<Integer> nodes = getUnsettledNeighbors(a);  //get all unsettled neighbors
			Iterator<Integer> nodeList = nodes.iterator();
			while(nodeList.hasNext()) {
				int x = nodeList.next();
				dist[x]=Math.min(dist[x], dist[a]+getWeight(a,x));  //update every node's distance
			}
			ifSettled[a]=true;
		}
		return dist;
	}
}

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}



Measured memory_bytes: 40376
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll sum = 0;
	int K;
	cin>>K;
	for(int i=1; i<=K;i++)
	{
		for(int j=1; j<=K;j++)
		{
			for(int k=1; k<=K;k++)
			{
				sum += __gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<sum;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long int
#define f(i,s,e) for(i=s;i<e;++i)
#define fb(i,s,e) for(i=s;i>=e;i--)
#define ff(i,s,e,f) for(i=s;i<e && f;++i)
#define mem(arr,val) memset(arr, val, sizeof(arr))
#define mems(arr, val, n) memset(arr, val, n)
#define vec vector<int>
#define pr trip
#define vp vector<trip>
#define lim 1000000
#define mod 1000000007
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define READ freopen("/home/raghav/Downloads/a_example.txt","r",stdin);
using namespace std;
int i=0,j=0;

signed main()
{
    Arena
    int a,b,m;cin>>a>>b>>m;
    int arr1[a];
    int arr2[b];
    int m1=INT_MAX,m2=INT_MAX;
    f(i,0,a)
    {
        cin>>arr1[i];m1=min(m1,arr1[i]);
    }
    f(i,0,b)
    {
        cin>>arr2[i];m2=min(m2,arr2[i]);
    }
    int c,x,y;
    int ans=m1+m2;
    f(i,0,m)
    {
        cin>>x>>y>>c;
        ans=min(ans,arr1[x-1]+arr2[y-1]-c);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
// SPDX-License-Identifier: X11
// 2020-06-21

#include <stdio.h>

#define LIMIT 100005

int main(void) {
  long N;
  scanf("%ld", &N);

  long a[LIMIT];
  for(long i = 0; i < LIMIT; i++)
    a[i] = 0;

  long x;
  for(long i = 0; i < N; i++) {
    scanf("%ld", &x);
    a[x]++;
  }

  long sum = 0;
  for(long i = 0; i < LIMIT; i++) {
    if(a[i] == 0)
      continue;
    sum += a[i] * i;
  }

  long Q;
  scanf("%ld", &Q);

  long b,c;
  for(long i = 0; i < Q; i++) {
    scanf("%ld %ld", &b, &c);

    sum += a[b] * (c - b);
    a[c] += a[b];
    a[b] = 0;

    printf("%ld\n", sum);
  }

  return 0;
}


Measured memory_bytes: 2492
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a, count[100005];
	for (i = 0; i < 100005; i++)
		count[i] = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a);
		count[a]++;
	}
	int c = 0;
	for (i = 0; i < 100005; i++)
		if (count[i] > 1)
			c += count[i] - 1;
	printf("%d\n", n - c - (c % 2));
	return 0;
}

Measured memory_bytes: 512