akhauriyash/Code-Regression huggingface dataset:
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]

import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = str(intinput())
K = intinput()
s = len(str(N))
dp = [[[0] * 2 for i in range(4)] for j in range(s+1)]
dp[0][0][0] = 1
for h in range(1,s+1):
    dp[h][0][1] = 1
    for i in range(1,4):
        for j in range(0,2):
            if j == 1:      
                for k in range(0,10):
                    if int(N[h-1]) == 0:
                        dp[h][i][j] += dp[h-1][i][1] + dp[h-1][i-1][1]*9
                        break
                    if int(N[h-1]) > k:
                        if k == 0:
                            dp[h][i][j] += dp[h-1][i][0] + dp[h-1][i][1]
                        if k != 0:
                            dp[h][i][j] += dp[h-1][i-1][0] + dp[h-1][i-1][1]
                    if int(N[h-1]) <= k:
                        dp[h][i][j] += dp[h-1][i-1][1]
            if j == 0:
                if int(N[h-1]) == 0:
                    dp[h][i][j] += dp[h-1][i][0]
                else:
                    dp[h][i][j] += dp[h-1][i-1][0]

print(dp[s][K][0]+dp[s][K][1])
            
                
                
 



Measured memory_bytes: 4088
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

struct UFTree {
    static const int MAX_N = 1e6;
    int p[MAX_N], r[MAX_N];

    UFTree(int n) : p(), r() {
        for(int i = 0; i < n; ++i) {
            p[i] = i;
            r[i] = 0;
        }
    }

    int root(int x) {
        return p[x] == x ? x : (p[x] = root(p[x]));
    }

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(r[x] < r[y]) {
            p[x] = y;
        } else {
            p[y] = x;
            if(r[x] == r[y]) r[x]++;
        }
    }
};

int n;
string s;

struct X {
    double x, y, z, r;
};

int main() {
    while (true) {
        cin >> n;
        if (n == 0) break;

        UFTree t = UFTree(n);
        V<X> xs(n);
        REP(i, n) {
            double x,y,z,r;
            cin >> x >> y >> z >> r;
            xs[i] = {x, y, z, r};
        }

        V<P<double, Pii>> edges(n*n-n);
        int cnt = 0;
        REP(i, n) REP(j, n) {
            if (i == j) continue;
            edges[cnt] = {
                max(0.0,
                    sqrt(
                        pow(xs[i].x - xs[j].x, 2) +
                        pow(xs[i].y - xs[j].y, 2) +
                        pow(xs[i].z - xs[j].z, 2)
                    ) - xs[i].r - xs[j].r
                ),
                {i, j}
            };
            cnt++;
        }

        sort(ALL(edges));
        double res = 0;
        FOR(i, edges) {
            double c = i->first;
            int x = i->second.first, y = i->second.second;
            if (t.same(x, y)) continue;
            t.unite(x, y);
            res += c;
        }
        printf("%.3lf\n", res);
    }

    return 0;
}



Measured memory_bytes: 11104
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 1 << 20;
const int mod = 998244353;
int n;
ll L, a[N], sum[N], ans;
int main() {
	cin >> L >> n;
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", a + i);
		sum[i] = sum[i - 1] + a[i];
	}
	for (int i = 1; i <= n; ++i) {
		ll tmp = -a[i];
		int k = min(i, n - i);
		tmp += 2 * (sum[i] - sum[i - k]);
		tmp += 2 * (k * L - (sum[i + k] - sum[i]));
		if (i > k) tmp += 2 * a[i - k];
		ans = max(ans, tmp);
		//
		tmp = -(L - a[i]);
		k = min(i - 1, n - i + 1);
		tmp += 2 * (sum[i - 1] - sum[i - k - 1]);
		tmp += 2 * (k * L - (sum[i + k - 1] - sum[i - 1]));
		if (n - i + 1 > k) tmp += 2 * (L - a[i + k]);
		ans = max(ans, tmp);
	}
	cout << ans;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

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

    REP(i, s.size()) {
        if(i == 3) cout << s[i] << " ";
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def bitcount(N):  # 立ってるbitの数
    bitcnt = [0]
    for _ in range(N):
        bitcnt += [i + 1 for i in bitcnt]
    return bitcnt


n, x = int(input()), input()

num, cnt = int(x, 2), x.count('1')
num0, num1 = num % (cnt + 1), num % max(cnt - 1, 1)
lbit = bitcount(18)
for i in range(n):
    ans = 1
    if x[i] == '0':
        ctmp = cnt + 1
        tmp = num0 + pow(2, n - (i + 1), ctmp)
    elif x[i] == '1':
        if cnt <= 1:
            print(0)
            continue
        ctmp = cnt - 1
        tmp = num1 - pow(2, n - (i + 1), ctmp)
    tmp %= ctmp
    ctmp = lbit[tmp]
    while tmp > 0:
        ans += 1
        tmp %= ctmp
        ctmp = lbit[tmp]
    print(ans)


Measured memory_bytes: 12952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,s=0,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            continue;
        else
            s+=i;
    }
    cout<<s;
}


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


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

int main() {
    long long int A, B, C, D;
    std::cin >> A >> B >> C >> D;

    long long int cs = B / C - (A - 1) / C;
    long long int ds = B / D - (A - 1) / D;

    long long int cd = C * D / gcd(C, D);
    long long int cds = B / cd - (A - 1) / cd;

    std::cout << (B - A + 1) - (cs + ds - cds) << std::endl;
}


Measured memory_bytes: 3660
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in =new Scanner(System.in);
		int a,b;
		a=in.nextInt();
		b=in.nextInt();
		if(a%2==0 || b%2==0 )
			System.out.println("No");
		else
			System.out.println("Yes");
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
class gauss_jordan {
  const int h, w;
  int rk;
  vector<int> stk;
  vector<int> p;
  vector<int> a;
  public:
    gauss_jordan (
        const vector<int> input_matrix,
        const int bit_max
      ) :
      h(bit_max), w(input_matrix.size()), rk(0),
      stk([&](){
          vector<int> ret(h);
          for (int i = 0; i < h; i++) ret[i] = i;
          return ret;
        }()),
      p([&](){
          vector<int> ret(h); 
          for (int i = 0, val = 1; i < h; i++, val <<= 1) ret[i] = val;
          return ret;
        }()),
      a(input_matrix)
      {
        for (int j = 0; j < w; j++) {
          for (auto it = stk.begin(); it != stk.end(); it++) {
            int pvt = *it;
            if ((a[j] >> pvt) & 1) {
              stk.erase(it); rk++;
              int spr = a[j] ^ (1 << pvt);
              for (int i = 0; i < h; i++) if ((p[i] >> pvt) & 1) p[i] ^= spr;
              for (int k = j; k < w; k++) if ((a[k] >> pvt) & 1) a[k] ^= spr;
              break;
            }
          }
          if (stk.empty()) break;
        }
      }
    inline int translate (int y) const {
      int z = 0;
      for (int i = 0; i < h; i++) if ((y >> i) & 1) {
        z ^= p[i];
      }
      return z;
    }
    inline int rank () const {return rk;}
    inline int kernel () const {return w - rk;}
    inline auto result () const {return a;}
    inline bool solvable (int y) const {
      if (y >> h) return false;
      int acm = accumulate(a.begin(), a.end(), 0, [](int x, int y){return x | y;});
      int z = translate(y);
      return !(~acm & z);
    }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  swap(n, m);
  vector<int> a(m);
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    while (k--) {
      int j; cin >> j; j--;
      a[j] |= 1 << i;
    }
  }
  gauss_jordan gj(
    a,
    n
  );
  int y = 0;
  for (int i = 0; i < n; i++) {
    int p; cin >> p;
    if (p) y |= 1 << i;
  }
  if (!gj.solvable(y)) {
    cout << 0 << endl;
    return 0;
  }
  int ret = 1;
  int p = gj.kernel();
  while (p--) {
    ret *= 2;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int k; cin >> k;
  string s; cin >> s;

  cout << s.substr(0,min(k,(int)s.size()));
  if(k<s.size()) cout << "...";
  cout << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vi ind;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'A' and s[i + 1] == 'C')
      ind.pb(i);
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    --l, --r;
    auto lb = lower_bound(all(ind), l) - ind.begin();
    auto ub = lower_bound(all(ind), r) - ind.begin();
    cout << ub - lb << endl;
  }
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 4068
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = s;
		String[] rep = new String[] {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        
		for (int i = 0; i < rep.length; i++) {
			String m = s.replace(rep[i], "");
			if (t.length() == m.length()) {
				System.out.println(rep[i]);
				return;
			} else {
				s = m;
				t = m;
			}
		}
		System.out.println("None");
	}
}

Measured memory_bytes: 40388
n = int(input())
h = [int(x) for x in input().split()]

ans = True
for i in range(n-1, 0, -1):
  dis = h[i] - h[i-1]
  if dis >= 0:
    continue
  elif dis == -1:
    h[i-1] -= 1
    continue
  else:
    ans = False
    break

if ans:
  print('Yes')
else:
  print('No')
  


Measured memory_bytes: 14396
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	char S[500010];
	scanf("%s", S);
	int N = strlen(S);
	if (S[N - 1] < 'a') N--;

	int Z[500000];
	Z[0] = N;
	int i = 1;
	int j = 0;
	while (i < N) {
		while (i + j < N && S[j] == S[i + j]) j++;
		Z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}
		int k = 1;
		while (i + k < N && k + Z[k] < j) {
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	if (N == 1) {
		printf("%d\n", N);
		printf("%d\n", 1);
		return 0;
	}
	if (Z[1] == N - 1) {
		printf("%d\n", N);
		printf("%d\n", 1);
		return 0;
	}
	bool mae[500000] = {};
	rep1(i, N / 2) {
		for (int j = i + i - 1; j < Z[i] + i; j += i) {
			//そうなの解説さん？
			if (mae[j]) break;
			mae[j] = 1;
		}
	}
	if (!mae[N - 1]) {
		printf("%d\n", 1);
		printf("%d\n", 1);
		return 0;
	}
	Z[0] = N;
	i = 1;
	j = 0;
	while (i < N) {
		while (i + j < N && S[N - 1 - j] == S[N - i - j - 1]) j++;
		Z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}
		int k = 1;
		while (i + k < N && k + Z[k] < j) {
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}

	bool ato[500000] = {};
	rep1(i, N / 2) {
		for (int j = i + i - 1; j < Z[i] + i; j += i) {
			if (ato[N - j - 1]) break;
			ato[N - j - 1] = 1;
		}
	}
	int kotae = 0;
	rep(i, N - 1) {
		kotae += (!mae[i] && !ato[i + 1]);
	}
	printf("%d\n", 2);
	printf("%d\n", kotae);


	Would you please return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

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

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    REP(i, S.size()) {
        printf("%c", (S[i] - 'A' + N) % 26 + 'A');
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '7') {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3608
open Batteries
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
 
  let rec aux sum sign cnt l =
    match l with
    | [] -> cnt
    | hd :: tl -> match sign with
      | `Plus -> 
        if sum + hd <= 0 then 
          let t = -(sum-1) in
          let c = t - hd in
          aux (sum+hd+c) `Minus (cnt+c) tl else 
          aux (sum+hd) `Minus cnt tl
      | `Minus -> 
        if sum + hd >= 0 then 
          let t = (sum+1) in
          let c = t + hd in
          aux (sum+hd-c) `Plus (cnt+c) tl else 
          aux (sum+hd) `Plus cnt tl
  in
  let ans1 = aux 0 `Plus 0 a_lst in
  let ans2 = aux 0 `Minus 0 a_lst in   
  Printf.printf "%d\n" @@
  if ans1 > ans2 then ans2 else ans1


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();

        int sum = 0;

        for (int i = 0; i < c; i++) {
            sum += sc.nextInt();
        }

        System.out.println((sum % (n + 1) == 0) ? sum / (n + 1) : sum / (n + 1) + 1);
    }
}


Measured memory_bytes: 26308
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
//#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long


using namespace std;

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


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

const int MOD = 1e9 + 7;

vector<char>c(4);
int dp[110][4][4][4];


signed main() {
	int N; cin >> N;
	c[0] = 'A', c[1] = 'G', c[2] = 'C', c[3] = 'T';
	REP(j, 4) {
		REP(k, 4) {
			REP(l, 4) {
				dp[3][j][k][l] = 1;
			}
		}
	}
	dp[3][0][1][2]--; dp[3][1][0][2]--; dp[3][0][2][1]--;
	FOR(i, 4, 101) {
		REP(k, 4) {
			REP(m, 4) {
				REP(j, 4) {
					int res = 0;
					REP(l, 4) {
						if (k == 2) {
							if (m == 0 && j == 1)continue;
							if (m == 1 && j == 0)continue;
							if (l == 0 && m == 1)continue;
							if (l == 0 && j == 1)continue;
						}
						if (k == 1) {
							if (m == 0 && j == 2)continue;
						}
						(res += dp[i - 1][l][m][j])%MOD;
					}
					/*if (k == 2) {
						REP(p, 4) {
							res -= dp[i - 1][p][0][1];
							res -= dp[i - 1][p][1][0];
							res -= dp[i - 1][0][1][p];
						}
						res += dp[i - 1][0][1][0];
					}
					if (k == 1) {
						REP(p, 4) {
							res -= dp[i - 1][p][0][2];
						}
					}*/
					dp[i][m][j][k] = res%MOD;
				}
			}
		}
	}

	ll ans = 0;
	REP(j, 4) {
		REP(k, 4) {
			REP(l, 4) {
				(ans += dp[N][j][k][l]) % MOD;
				//printf("%c %c %c:%lld\n", c[j], c[k], c[l], dp[N][j][k][l]);
			}
		}
	}
	print(ans%MOD);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

double const PI = acos(-1.0);

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  double a, b, x;
  read(a), read(b), read(x);
  if (x <= a * a * b / 2) {
    double xx = b, yy = x * 2 / b / a;
    double d = atan(yy / xx);
    printf("%.10lf\n", 90.0 - d * 180.0 / PI);
  }
  else {
    double xx = b, h = a, yy = 2.0 * x / a / a - b;
    double d = atan(h / (xx - yy));
    printf("%.10lf\n", 90.0 - d * 180.0 / PI);
  }

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int dp[50];
int num[maxn];
deque<int> q;
int main() {
	string s;
	int cnt = 0;
	int k;
	cin>>s;
	for(int i=0;i<s.length();i++){
		q.push_back(s[i]-'a');
	}
	cin>>k;
	for(int i=1;i<=k;i++){
		int t;
		cin>>t;
		if(t==1) cnt++;
		else {
			int a;
			char c;
			cin>>a>>c;
			if(a==1&&cnt%2==0) q.push_front(c-'a');
			if(a==2&&cnt%2==1) q.push_front(c-'a');
			if(a==1&&cnt%2==1) q.push_back(c-'a');
			if(a==2&&cnt%2==0) q.push_back(c-'a');
		}
	}
	if(cnt%2==1) {
		while(!q.empty()){
			cout<<(char)(q.back()+'a');
			q.pop_back();
		}
	}
	else {
		while(!q.empty()){
			cout<<(char)(q.front()+'a');
			q.pop_front();
		}
	}
	return 0;
}



Measured memory_bytes: 1920
import heapq
n = int(input())
a = list(map(int,input().split()))
count = 0
for i in a:
    if i < 0:
        count += 1
abs_a = list(map(abs,a))
if 0 in a or count % 2 == 0:
    print(sum(abs_a))
else:
    heapq.heapify(abs_a)
    min_a = heapq.heappop(abs_a)
    print(sum(abs_a)-min_a)

Measured memory_bytes: 71440
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n;
	int sum;
	int a;
	int MIN = 100000;
	int MAX = 0;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		MIN = 100000;
		MAX = 0;
		for (int j = 0; j < n; j++) {
			sum = 0;
			for (int i = 0; i < 5; i++) {
				cin >> a;
				sum += a;
			}
			MIN = min(MIN, sum);
			MAX = max(MAX, sum);
		}
		cout << MAX << " " << MIN << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf n,t,ans=0;
    cin >>n;
    vector<intf> a(n);
    rep(i,n) cin >> a[i];

    t = *std::min_element(a.begin(),a.end());

    while(1){
       rep(h,n){
           if(a[h]%2!=0){
                cout << ans<<endl;
                return 0;
           }
           a[h] /=2;
       }
        ans++;
    }


}

Measured memory_bytes: 256
from itertools import accumulate
N,W=map(int,input().split())
w1, w2, w3, w4 = [], [], [], []
w, v = map(int, input().split())
w1.append(v)
for _ in range(N-1):
    a, b = map(int, input().split())
    if a == w: w1.append(b)
    if a == w+1: w2.append(b)
    if a == w+2: w3.append(b)
    if a == w+3: w4.append(b)


for w_ in [w1, w2, w3, w4]:
    w_.sort(reverse= True)

w1=[0]+w1
w1=list(accumulate(w1))
w2=[0]+w2
w2=list(accumulate(w2))
w3=[0]+w3
w3=list(accumulate(w3))
w4=[0]+w4
w4=list(accumulate(w4))

#print(w1,w2,w3,w4)
#print(len(w1),len(w2),len(w3),len(w4))

ans=0
for a in range(len(w1)):
    for b in range(len(w2)):
        for c in range(len(w3)):
            for d in range(len(w4)):
                #print(a,b,c,d)
                wei=w*a+(w+1)*b+(w+2)*c+(w+3)*d
                val=w1[a]+w2[b]+w3[c]+w4[d]
                #print(wei,val)
                if wei<=W:
                    ans=max(val,ans)

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(){
	double N;
	double K;
	scanf("%lf",&N);
	scanf("%lf",&K);
	if(K<=N){
	double A=1;   
	double B=K;       
	while(K<=N){  
        K=pow(B,A);
        A++;
	}
    int a=A;
	printf("%d\n",a-1);
    }else{
    	int n=N;
    	printf("%d",n);
    }
	
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;

int main(void)
{
	int x,y;
	while(1)	{
		scanf("%d %d",&x,&y);
		if(x==0 && y==0)	break;
		if(x>y)	swap(x,y);
		printf("%d %d\n",x,y);
	}
	return 0;
}


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

int main(){
  int W, H;
  cin >> W >> H;
  while(W != 0 || H != 0){
      // cout << "print " << W << " * " << H << " #" << endl;
    for(int i = 0;i < W;i++){
      for(int j = 0;j < H;j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl ;
    cin >> W >> H;
  }
  return 0;
}


Measured memory_bytes: 3108
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD (1e9+7)
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
vector<int> tre[100010];

int T[100010];//1-indexed
int A[100010];//1-indexed
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int N,u,v;cin>>N>>u>>v;
  for(int i = 0; N-1 > i; i++){
    //uからvの直線距離を求める
    int a,b;cin>>a>>b;
    tre[a].push_back(b);
    tre[b].push_back(a);
  }
  queue<P> t;
  t.push({u,1});
  while(!t.empty()){
    P k = t.front();
    t.pop();
    if(T[k.first]){
      continue;
    }
    T[k.first] = k.second;
    k.second++;
    for(int i = 0; tre[k.first].size() > i; i++){
      t.push({tre[k.first][i],k.second});
    }
  }


  queue<P> a;
  a.push({v,1});
  while(!a.empty()){
    P k = a.front();
    a.pop();
    if(A[k.first]){
      continue;
    }
    A[k.first] = k.second;
    k.second++;
    for(int i = 0; tre[k.first].size() > i; i++){
      a.push({tre[k.first][i],k.second});
    }
  }
  int ans = 0;
  int nya = 0;
  for(int i = 1; N >= i; i++){
    if(T[i] < A[i]){
      if(A[i]%2 == T[i]%2){
        ans = max(ans,A[i]-2);
      }else{
        ans = max(ans,A[i]-1);
      }
      
    }
    //cout << i << ":" << T[i] << " " << A[i] << endl; 
  }
  //距離が偶数の場合
  if((T[v]%2)){
    ans++;
  }
  cout << ans-1 << endl;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  int ans = 0;
  while(1){
    if(N <= K + (K-1)*ans){
      cout << ans+1 << endl;
      break;
    }
    ans++;
  }
}

/*
int main() {
  ll N, K;
  cin >> N >> K;
  ll cnt=0;
  ll pos1;
  rep(i,N){
    cnt++;
    ll x;
    cin >> x;
    if(x==1) pos1 = cnt-1;
  }

  ll ans_1, ans_2;

  if(pos1 % (K-1) == 0) ans_1 = pos1 / (K-1);
  else ans_1 = pos1 / (K-1) + 1;

  ll pos2 = ans_1 * (K-1) + 1;

  if((N-pos2) % (K-1) == 0) ans_2 = (N-pos2) / (K-1);
  else ans_2 = (N-pos2) / (K-1) + 1;

  //cout << ans_1  << " " <<  ans_2 << endl;
  cout << ans_1 + ans_2 << endl;

}
*/


Measured memory_bytes: 3592
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)				(x).begin(),(x).end()
#define REP(i, n)			for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)		for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF					(ll)1e9
#define EPS					(double)1e-9
#define MOD					(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)			(((((x))+((n)-1))/(n)))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)			(((((x))+((n)-1))/(n))*(n))	/* Nの倍数に切り上げ */
#define FloorN(x, n)		((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)			(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)			(!IsOdd((x)))						
#define M_PI				3.14159265358979323846
typedef long long			ll;
typedef pair<ll, ll>		P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N, M;
	cin >> N >> M;

	string ans;
	if (N == M) {
		ans = "Yes";
	} else {
		ans = "No";
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
function vs(r,b){
	if(r == b)return r;
	else if(r > b)return r-b;
	else return b-r;
}

function Main(inputData) {
	init(inputData);
	
	var n = inI();
	n = Math.pow(2,n);
	var a = [];
	for(var i = 0; i < n; i++)a[i] = inI();

	var l = 0;
	while(n-l > 1){
		var r = a[l],b = a[l+1];
		l += 2;
		a[n++] = vs(r,b);
	}
	outln(a[n-1]);
}


////////////////////////////////////////////////////////////////////////////////////
var input,inputCnt;

// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
	Main(document.getElementById("input").value);
}

function init(inputData){
    //配列inputに順番に代入
	input = inputData.replace( /\n/g , " " );
	input = input.split(" ");
	inputCnt = 0;
}
//output
const out = (output) => { console.log(output) }
const outln = (output) => { console.log(output+"\n") }

//input
const inS = () => {return input[inputCnt++]};
const inI = () => {return parseInt(inS(), 10)};
const inF = () => {return parseFloat(inS())};

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  string s;
  cin >> s;
  int count = 0, now =0, out = 0;
  vector<int> v(s.size());
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') now++;
    else now = 0;
    out = max(now, out);
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;


int main() {
	int n; long long ans = 0;
	cin >> n;
	for (int i = 1;i < n; i++) {
		ans += i;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <functional>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>

int rmax, n;
int d[260];
std::vector<std::set<int> > edges, edges2;

/*
0: ????????????
1~n: ??????
n + 1: ?????????
*/

int check(int idx) {
    idx += d[idx];
    if(idx <= 0) {
        return 0;
    }

    if(idx >= n + 1) {
        return n + 1;
    }

    return idx;
}

int main() {
    while(std::cin >> rmax, rmax) {
        std::cin >> n;

        edges.clear();
        edges.resize(n + 2);
        edges2.clear();
        edges2.resize(n + 2);

        for(int i = 1; i <= n; ++i) {
            std::cin >> d[i];
        }
        for(int i = 0; i <= n; ++i) {
            for(int j = 1; j <= rmax; ++j) {
                int to = check(i + j);

                if(i == to) {
                    continue;
                }
                edges[to].insert(i);
                edges2[i].insert(to);
            }
        }

        /*for(int i = 0; i < edges.size(); ++i) {
            for(std::set<int>::iterator it = edges[i].begin(); it != edges[i].end(); ++it) {
                std::cout << i << " " <<  *it << std::endl;
            }
        }*/

        bool used[260] = {}, used2[260] = {};
        std::queue<int> que;
        {
            que.push(n + 1);
            used[n + 1] = true;
            while(!que.empty()) {
                int p = que.front(); que.pop();

                for(std::set<int>::iterator it = edges[p].begin(); it != edges[p].end(); ++it) {
                    if(!used[*it]) {
                        que.push(*it);
                        used[*it] = true;
                    }
                }
            }
        }

        {
            que.push(0);
            used2[0] = true;
            while(!que.empty()) {
                int p = que.front(); que.pop();

                for(std::set<int>::iterator it = edges2[p].begin(); it != edges2[p].end(); ++it) {
                    if(!used2[*it]) {
                        que.push(*it);
                        used2[*it] = true;
                    }
                }
            }
        }

        bool ok = true;
        for(int i = 0; i <= n + 1; ++i) {
            //std::cout << i << " " << used2[i] << " " << used[i] << std::endl;
            if(used2[i] && !used[i]) {
                ok = false;
                break;
            }
        }

        std::cout << (ok ? "OK" : "NG") << std::endl;
    }
}

Measured memory_bytes: 1328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

int64 dp[3000][3000][4];

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

  int r, c, k; cin >> r >> c >> k;
  int val[r][c];
  fill(val[0], val[r], 0);
  for (int i = 0; i < k; ++i) {
    int x, y, z; cin >> x >> y >> z;
    --x; --y;
    val[x][y] = z;
  }

  if (val[0][0] != 0) dp[0][0][1] = val[0][0];

  for (int i = 0; i < r; ++i) {
    for (int j = 0; j < c; ++j) {
      if (i == 0 && j == 0) continue;

      if (val[i][j] != 0) {
        if (i > 0) {
          for (int l = 0; l < 4; ++l) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][l]);
          for (int l = 0; l < 4; ++l) dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][l] + val[i][j]);
        }
        if (j > 0) {
          dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][0]);
          for (int l = 1; l < 4; ++l) {
            dp[i][j][l] = max({dp[i][j][l], dp[i][j - 1][l], dp[i][j - 1][l - 1] + val[i][j]});
          }
        }
      } else {
        if (i > 0) {
          for (int l = 0; l < 4; ++l) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][l]);
        }
        if (j > 0) {
          for (int l = 0; l < 4; ++l) dp[i][j][l] = max(dp[i][j][l], dp[i][j - 1][l]);
        }
      }
    }
  }

  int64 ans = 0;
  for (int i = 0; i < 4; ++i) ans = max(ans, dp[r - 1][c - 1][i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 319952
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>

#define MAX 20000
using namespace std;



int main(){
  int a,b,c;
  std::cin >> a>>b>>c;
  if(a<b&&b<c){
    std::cout << "Yes" << '\n';
  }else{
    std::cout << "No" << '\n';
  }

}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio  ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0)
#define all(v) (v).begin(), (v).end()
const ll mod = 10e9 + 7;
int main()
{
  fastio;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ma;
  // for (int i = a; i <= b; i++)
  // {
  //   for(int j=c;j<=d;j++)
  //   {
  //     if(i*j>ma)ma=i*j;
  //   }
  // }
  ll x=a*c;
  ll y=a*d;
  ll z=b*c;
  ll v=b*d;

  cout<<max({x,y,z,v})<<'\n';
  
  //cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  return 0;

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;
const int MAX_N=1000100;
int bit[MAX_N], n_, n;

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i -=i & -i;
    }
    return s;
}

void add(int i, int x){
    while( i<=n){
        bit[i] +=x;
        i += i & -i;
    }
}

int a[MAX_N], b[MAX_N];
P c[MAX_N];
int main(){
    ll ans=0;

    cin >> n;
//    n_=1;
//    while(n_ < n) n_ *=2;

    for(int j=0; j<n; j++){ cin >> b[j]; c[j]=P(b[j],j);}
    sort(c,c+n);
    for(int j=0; j<n; j++){
        c[j].first=j+1;
        swap (c[j].first, c[j].second);
    }
    sort(c,c+n);
    for(int j=0; j<n; j++){
        a[j]=c[j].second;
    }
    for(int j=0; j<n; j++){
        ans += j-sum(a[j]);
        add(a[j],1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6996
#include <bits/stdc++.h>
using namespace std;
int H,W,w,h;
int a[505][505];
const int INF =2333;
#define GG return printf("No"),0
int main()
{
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if (H%h==0&&W%w==0) GG;
	printf("Yes\n");
	for (int i=1;i<=H;++i)
		for (int j=1;j<=W;++j)
	      printf("%d%c",(i%h==0&&j%w==0?(1-h*w)*INF-1:INF),j==W?'\n':' ');
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
    int a, b, c;
    scanf ("%d %d %d", &a, &b, &c);
    
    if (b - a == c - b){
        printf ("YES");
    }
    else if (b - a != c - b){
        printf ("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int N, m, i=0,k;
  scanf("%d", &N);
  char SS[N+1];
  scanf("%s", SS);
  
  int count = N;
  
 while(m<N){
    for(m=i+1; m<N; m++){
      
      if(SS[i]==SS[m]){
        count -= 1;
      }else{
        i = m;
        break;
      }
      
    }
 }
  
  printf("%d\n", count);
  return 0;
}

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

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

	vector<int> b(n - 1), v(n);

	for (auto &t : b)cin >> t;

	v[0] = b[0];
	v[1] = b[0];
	
	for (int i = 2; i < n - 1; ++i) {
		if (v[i - 1] > b[i - 1]) {
			v[i - 1] = b[i - 1];
		}
			v[i] = b[i - 1];
	}

	if (v[n - 2] < b[n - 2]) {
		v[n - 1] = b[n - 2];
	}
	else {
		v[n - 1] = b[n - 2];
		v[n - 2] = b[n - 2];
	}

	int sum = 0;

	for (auto t : v) sum += t;

	cout << sum;

	return 0;
}

Measured memory_bytes: 256
#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;
  int a[3 * n];
  rep(i, 3 * n) cin>>a[i];
  sort(a, a + 3 * n);
  ll ans = 0;
  FOR(i, n, 3 * n) {
    if(i % 2 == n % 2) ans += a[i];
  }
  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(void){
    string s;
    int ans = 0,flg = 0;
    char tmps;
    cin >> s;
    for(int i = 0;i < s.size();i++){
        cin >> s[i];
        if(i == 0){
            tmps = s[i];
            ans++;
        }else if((i == s.size()-1) && flg == 0 && s[i] == tmps){
            break;
        }
        else if(i != 0 && s[i] == tmps && flg == 0){  // 2文字とる
            tmps = s[i+1];
            i++;
            flg = 1;
            ans++;
        }else if(i != 0 && s[i] != tmps && flg == 0){  // 1文字とる
            tmps = s[i];
            flg = 0;
            ans++;
        }else if(flg == 1){  // 1文字とる
            tmps = s[i];
            flg = 0;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      Map<Integer, Integer> map = new HashMap<>();
      long total = 0;
      for(int i = 0; i < N; i++){
        int A = sc.nextInt();
        if(map.containsKey(A)){
          int count = map.get(A);
          map.put(A,count+1);
        }else{
          map.put(A,1);
        }
        total += A;
      }
      int Q = sc.nextInt();
      
      // 操作
      for(int i = 0; i < Q; i++){
        int B = sc.nextInt();
        int C = sc.nextInt();
        total = operation(map, B, C, total);
        System.out.println(total);
      }
      
      
      // 出力
      //System.out.println(result);
    }
    
    // 【操作】マップを更新し総和を求める関数
    public static long operation(Map<Integer, Integer> map, int B, int C, long total){
      long newTotal = total;
      if(map.containsKey(B)){
        int bCount = map.get(B);
        int cCount = 0;
        if(map.containsKey(C)){
          cCount = map.get(C);
        }
        long dif = (long)(C - B) * bCount;
        newTotal = total + dif;
        map.put(C, bCount + cCount);
        map.remove(B);
      }
      
      return newTotal;
    }
    

}

Measured memory_bytes: 64984
#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define ull unsigned ll
#define pll pair<ll, ll>
#define itr(a) begin(a), end(a)
#define pb push_back
#define x first
#define y second
#define endl '\n'
#define FAST cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define FILES(namein, nameout) freopen(namein, "r", stdin); freopen(nameout, "w", stdout);
#define M 1000000007
#define N 200000
#define INF 101111111111111
using namespace std;
main(){
    FAST;
    ll n;
    scanf("%lld", &n);
    ll minres = INF;
    for(ll i = 1;i*i<=n;i++){
    	if(n%i == 0) minres = min(minres, i+n/i-2);
    }
    printf("%lld\n", minres);
}

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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  ll n, m, lv = 0, rv = 0, a[100001], ans[100001] = {};
  priority_queue <ll, vector<ll>, greater<ll> > pq1;
  priority_queue <ll> pq2;
  cin >> n;

  rep(i, 0, n) cin >> m, lv += m, pq1.push(m);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> m, rv += m, pq2.push(m);

  rep(i, 0, n) {
    ans[i] = lv;
    lv += a[i];
    pq1.push(a[i]);
    lv -= pq1.top();
    pq1.pop();
  }

  ans[n] = lv - rv;

  dep(i, n - 1, 0) {
    rv += a[i];
    pq2.push(a[i]);
    rv -= pq2.top();
    pq2.pop();
    ans[i] -= rv;
  }

  ll ma = -100000000000000;
  rep(i, 0, n + 1) {
    ma = max(ma, ans[i]);
  }
  cout << ma << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

const int INF = 1001001001;

int main()
{   
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n) cin >> h[i];

    vi dp(n, INF);
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k; j++) {
            if(i - j >= 0) chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}


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

namespace ABC_C
{
    class C100
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<long> a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();

            int counter = 0;
            foreach(long n in a)
            {
                long m = n;
                while(m % 2 == 0)
                {
                    m /= 2;
                    counter++;
                }
            }
            Console.WriteLine(counter);
        }

    }
}


Measured memory_bytes: 14176
#include<stdio.h>
#include<string.h>
int main(void){
    char s[11],t[11],u[11];
    int a,b;
    scanf("%s%s%d%d%s",s,t,&a,&b,u);
    if(strcmp(s,u)==0)
    printf("%d %d",a-1,b);
    else
    {
        printf("%d %d",a,b-1);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
 
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

int main(){
    int n;
    int a[100];
    int sum=0;
    cin>>n;
    REP(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    int ans;
    int x=1e9;
    REP(i,n){
        if(abs(a[i]*n-sum)<x){
            ans=i;
            x=abs(a[i]*n-sum);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	set<int>s;
	s.insert(1);
	s.insert(2);
	s.insert(3);
	int a,b;
	cin>>a>>b;
	s.erase(a);
	s.erase(b);
	auto it=s.begin();
	cout<<*it;
    return 0;
}







Measured memory_bytes: 256