akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int D;
vector<int> c(26);
vector<int> last(26, 0);
vector<vector<int>> s(365, vector<int>(26));
void input();
int score;
int next_num;
const int Way = 26;
const int Nest = 0;
/*void dfs(int nest, int d) {
	int M = 0, temp = score;
	int prev, n;
	vector<pair<int, int>> kouho(26);
	rep(j, 0, 26) {
		score = temp;
		score += s[d - 1][j];
		prev = last[j];
		last[j] = d;
		rep(k, 0, 26)score -= c[k] * (d - last[k]);
		kouho[j].first = score;
		kouho[j].second = j;
		last[j] = prev;
	}
	//sort(all(kouho), greater<pair<int, int>>());
	rep(j, 0, Way) {
		//prev = last[kouho[j].second];
		//last[kouho[j].second] = d;
		score = kouho[j].first;
		if (nest && d < D)dfs(nest - 1, d + 1);
		if (M < score)M = score, n = kouho[j].second;
		printf("j:%2d score:%d\n", j, score);
		//last[kouho[j].second] = prev;
	}
	score = M;
	next_num = n;
}*/
int main()
{
	input();
	/*rep(i, 1, D + 1) {
		//score = 0;
		dfs(Nest, i);
		printf("%d\n", next_num + 1);
		last[next_num] = i;
		printf("%d\n", score);
	}*/
	ll score = 0, M = 0, temp;
	int prev, p;
	rep(i, 1, D + 1) {
		M = 0;
		temp = score;
		rep(j, 0, 26) {
			score = temp + s[i - 1][j];
			prev = last[j];
			last[j] = i;
			rep(k, 0, 26)score -= c[k] * (i - last[k]);
			last[j] = prev;
			if (M < score)M = score, p = j;
		}
		last[p] = i;
		score = M;
		printf("%d\n", p + 1);
		//printf("%d\n", score);
	}
	return 0;
}
void input() {
	cin >> D;
	rep(i, 0, 26)cin >> c[i];
	rep(i, 0, D) {
		rep(i2, 0, 26)cin >> s[i][i2];
	}
}

Measured memory_bytes: 3776
def findSumOfDigit(n):
    
    sum_digit = 0

    while n > 0:  

        sum_digit += n % 10 
        n = int(n / 10)
        
    return sum_digit

N, A, B = map(int, input().split())

ans = 0

for i in range(N+1):
    
    sum_digit = findSumOfDigit(i)
    if A <= sum_digit and sum_digit <= B:
        ans += i
        
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX],n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>R[i];
	}
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1;i<n;i++){
		maxv = max(maxv,R[i]-minv);
		minv = min(minv,R[i]);
	}
	cout<< maxv<<endl;
	return 0;
} 

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

static const int MAX = 1e5;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
int n;
vector<int> G[MAX], d(MAX, INF), d2(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること
 
void bfs(int s, vector<int> &x) {
  queue<int> q;
  q.push(s);
  x[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
    if(x[G[u][v]] == INF){
        x[G[u][v]] = x[u] + 1;
        q.push(G[u][v]);
      }
    }
  }
}

int main() {
// 無向(有向)グラフの隣接リスト
  int u, v;
  cin >> n;
  
  for(int i = 0; i < n - 1; i++){
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  bfs(0, d);
  bfs(n - 1, d2);
  
  int f = 0, sn = 0;
  for(int i = 0; i < n; i++){
    if(d[i] > d2[i]) sn++;
    else f++;
  }
  
  if(f > sn) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}

Measured memory_bytes: 6656
// https://atcoder.jp/contests/agc027/tasks/agc027_a

#include <bits/stdc++.h>
using namespace std;

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

    vector<long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (x - a[i] >= 0)
        {
            ++ans;
            x -= a[i];
        }
        else
        {
            break;
        }
    }
    if (x - a[n - 1] == 0)
    {
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int X, Y;
    cin >> X >> Y;
    rep(i, X + 1) {
        if (2 * i + 4 * (X - i) == Y) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


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

void solve() {
  int N, D;
  cin >> N >> D;

  int point[20][20];
  for (int pi = 0; pi < N; ++pi) {
    for (int pj = 0; pj < D; ++pj) {
      cin >> point[pi][pj];
    }
  }

  int ans = 0;
  for (int pi = 0; pi < N; ++pi) {
    for (int pj = pi+1; pj < N; ++pj) {
      int bidist = 0;
      for (int di = 0; di < D; ++di) {
        int dist = abs(point[pi][di] - point[pj][di]);
        bidist += dist * dist;
      }
      bool check = false;
      for (int k = 0; k <= bidist; ++k) {
        if (k * k == bidist) {check = true;}
      }
      if (check) ++ans;
    }
  }
  cout << ans << endl;
}

int main(void) {
  solve();
  return 0;
}

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

using namespace std;

const int INF = 1<<28;
int c, n, m, s, d;
vector<pair<int, int> > g[100];
int dist[100][11];

typedef tuple<int, int, int> node;

int dijkstra() {
  priority_queue<node, vector<node>, greater<node> > Q;
  Q.push(make_tuple(0, s, c));
  dist[s][c] = 0;
  
  while (!Q.empty()) {
    int cost;
    int v;
    int t;
    tie(cost, v, t) = Q.top();
    Q.pop();

    if (cost > dist[v][t])
      continue;
    
    for (auto &edge: g[v]) {
      int w = edge.first;
      int weight = edge.second;
      if (cost + weight < dist[w][t]) {
        dist[w][t] = cost + weight;
        Q.push(make_tuple(dist[w][t], w, t));
      }
      if (t > 0 && cost + weight/2 < dist[w][t-1]) {
        dist[w][t-1] = cost + weight/2;
        Q.push(make_tuple(dist[w][t-1], w, t-1));
      }
    }
  }

  int ret = INF;
  for (int i = 0; i < 11; i++)
    ret = min(ret, dist[d][i]);
  return ret;
}

void init() {
  for (int i = 0; i < 100; i++)
    g[i].clear();
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 11; j++)
      dist[i][j] = INF;
}

int main(int argc, char *argv[])
{
  for (;;) {
    cin >> c >> n >> m >> s >> d;
    if (!c && !n && !m && !s && !d)
      break;
    --s, --d;
    init();
    for (int i = 0; i < m; i++) {
      int a, b, f;
      cin >> a >> b >> f;
      --a, --b;
      g[a].push_back(make_pair(b, f));
      g[b].push_back(make_pair(a, f));
    }
    int ret = dijkstra();
    printf("%d\n", ret);
  }
  
  return 0;
}

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

//region Template
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;

using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << "\t";
	print(args...);
	#endif
}
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 6;
const int INF = 2e9;

vector<string> v;

int occ[50];

int cur[50];

int main() {
	#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
	#endif


	int n;
	cin >> n;

	for(int i = 0; i < 30; i++){
		occ[i] = INF;
	}

	for(int i = 0; i < n; i++){
		string s;
		cin >> s;

		v.push_back(s);
	}

	for(auto x : v){
		memset(cur, 0, sizeof cur);
		for(auto c : x){
			cur[c - 'a']++;
		}

		for(int i = 0; i < 30; i++){
			occ[i] = min(occ[i], cur[i]);
		}
	}

	for(int i = 0; i < 26; i++){
		cout << string(occ[i], (char)('a' + i));
	}
}


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

int main(){
  int n;
  string s;
  cin>>n>>s;
  // for(int i=0;i<n;i++){
  //   char c=s[i];
  //   mp[c]=mp[c]+1;
  // }
  int mx=0;
  for(int i=0;i<n;i++){
    char* left=(char*)calloc(26,sizeof(char));
    char* right=(char*)calloc(26,sizeof(char));
    for(int j=0;j<i;j++){
      left[s[j]-'a']++;
    }
    for(int j=i;j<n;j++){
      right[s[j]-'a']++;
    }
    int cnt=0;
    for(int j=0;j<26;j++){
      if(left[j]>0&&right[j]>0)cnt++;
    }
    if(cnt>mx)mx=cnt;
  }
  cout<<mx<<endl;
  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n,k,x,y;
	cin >> n >> k >> x >> y;
	
	if(n < k)
		cout << x * n;
	else
		cout << (x*k) + (n-k) * y;

	return 0;
}


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

#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9

typedef   pair<int,int> P;

map<char,int>mp;

void init() {
	mp['G']=0;
	mp['W']=0;
	mp['Y']=0;
	mp['P']=0;
}

int main() {

	int n,ans=0;
	char ch;
	
	init();
	
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		getchar();
		scanf("%c",&ch);
		if(mp[ch]==0) {
			ans++;
			mp[ch]=1;
		}
	//	printf("%c %d\n",ch,mp[ch]);
	}
//	printf("%d\n",ans);
	if(ans==3) puts("Three");
	else puts("Four");
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[600][600];

int main(){
  cin >> s;
  char ans[100000];
  l = 0;
  rep(i,0,s.sz){
    if(s[i] == 'B'){
      if(0 < l)l--;
    }else{
      ans[l] = s[i];
      l++;
    }
  }
  rep(i,0,l){
    cout << ans[i];
    if(i == l-1)break;
    // cout << " ";
  }
  puts("");
  return 0;
}

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

int main(){
  while(1){
    int N,W,H,S,T;
    cin>>N;
    if(N==0) break;
    cin >>W>>H;
    int x,y, a[501][501]={};
    for(int i=0;i<N;i++){
      cin>>x>>y;
      a[y][x]=1;
    }
  
    cin>>S>>T;
  
    int max=0;
    int count=0;
  
    for(int i=0;i<=H;i++){
      for(int j=0;j<=W;j++){     
	count=0;
	for(int k=i;k<i+T;k++){
	  for(int h=j;h<j+S;h++){
	    if(a[k][h]==1) count++;
	  }
	}
	if(count>max) max=count;
      }
    }
    cout<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 2144
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>	//toupper()
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
int main(){
	ll a,b;
	scanf("%lld %lld",&a,&b);
	if( (a-b) <= 1 && (a-b) >= -1 ) printf("Brown\n");
	else printf("Alice\n");

}

Measured memory_bytes: 128
#include<cstdio>
#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if(T[u].left != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }
  else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}
int main(){
  int i, v, l, r, root = 0;
  scanf("%d", &n);

  for(i=0; i<n; i++) T[i].parent = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }

  for(i=0; i<n; i++){
    if(T[i].parent == NIL) root = i;
  }

  setDepth(root, 0);
  setHeight(root);

  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 2764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  vector<long double> a(n);rep(i,n)cin>>a[i];
  vector<vector<long double>> dp(n,vector<long double>(n+1,0));
  dp[0][0] = (1-a[0]);
  dp[0][1] = a[0];
  
  for(int i = 1;i < n;++i){
    rep(j,i+2){
      dp[i][j] = dp[i-1][j]*(1-a[i]);
      if(j)dp[i][j] += dp[i-1][j-1]*a[i];
    }
  }
  long double ans = 0;
  for(int i = (n+1)/2;i <= n;++i){
    ans += dp[n-1][i];
  }
  cout<<setprecision(12)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 143984
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
 
		int T = sc.nextInt();
		int X = sc.nextInt();
      
      	double t = (double)T / X;
 
		System.out.println(t);
 
	}
 
}

Measured memory_bytes: 23120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc134_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  cout << 3 * N * N << endl;
}

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

int main () {
	long S;
	cin >> S;
	long ra, rb, a, b;
	ra = rb = (long)sqrtl(S-1)+1;
	if (S < ra*(rb-1)) --rb;
//	long subS = ra*rb - S;
//	for (long bb=0; bb <= r; ++bb){
//		if (subS/bb*bb == subS)
//		b = (S-r*i)/(r-i);
//		if (S == r*(i+b)-i*b) {
//			a = i;
//			break;
//		}
//	}
//	cout << r << " " << a << " " << b << endl;
	b = rb - 1;
	a = (S-ra*b)/(rb-b);
	cout << ra << " " << rb << " ";
	cout << 0 << " " << b << " ";
	cout << a << " " << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m, a[(1LL << 20)], dp[(1LL << 20)][20][2], ans[(1LL << 20)];

void setv(ll x, ll y, ll at){
	if(a[at] > a[dp[x][y][0]]){
		dp[x][y][1] = dp[x][y][0];
		dp[x][y][0] = at;
	}
	else{
		if(at != dp[x][y][0] && a[at] > a[dp[x][y][1]]){
			dp[x][y][1] = at;
		}
	}
}

void setp(ll x, ll y, ll u, ll v){
	setv(x, y, dp[u][v][0]);
	setv(x, y, dp[u][v][1]);
}

ll aa(ll x, ll y){
	return a[dp[x][y][0]]+a[dp[x][y][1]];
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	m = (1LL << n);
	zep(i, 0, m){cin >> a[i];}
	a[(1LL << 19)] = -INF;
	
	zep(i, 0, m){
		zep(j, 0, 20){
			dp[i][j][0] = (1LL << 19);
			dp[i][j][1] = (1LL << 19);
		}
	}
	zep(j, 0, 20){
		dp[0][j][0] = 0;
	}
	ans[0] = -INF;
	
	ll k;
	zep(bit, 1, m){
		if(__builtin_popcount(bit) == 1){k = bit;}
		
		setv(bit, 0, bit);
		zep(i, 0, 20){
			if(bit & (1LL << i)){
				setp(bit, 0, (bit & ~(1LL << i)), 0);
			}
		}

		zep(i, 1, 20){
			setv((bit & ~((1LL << i)-1)), i, bit);
		}
		
		zep(i, 1, 20){
			if(bit & (1LL << i)){
				ll buf = bit & ~((1LL << i+1)-1);
				zep(j, 0, 20){
					setp(buf, i, (buf & ~(1LL << j)), i);
				}
			}
		}
		
		ans[bit] = max(ans[k-1], aa(bit, 0));
		zep(i, 1, 20){
			if((bit & (1LL << i)) && ((1LL << i) != k)){
				ans[bit] = max(aa((bit & ~((1LL << i+1)-1)), i), ans[bit]);
			}
		}
		//cout << bit << ans[k-1] << dp[bit][0][0]+dp[bit][0][1] << endl;
	}
	
	zep(bit, 1, m){print(ans[bit])}
	//ll tmp; zep(bit, 1, m){cin >> tmp; if(ans[bit] != tmp){cout << bit << " " << ans[bit] << " " << tmp << endl;}}
	return 0;
}

Measured memory_bytes: 97280
#include<stdio.h>
int main(void){
int A,B,C,D;

if(scanf("%d %d %d %d",&A,&B,&C,&D)!=0){
int x=(A+D-1)/D;
int y=(C+B-1)/B;
if(x>=y){
    printf("Yes\n");
}else{
    printf("No\n");
}
}else{
    printf("Failed to read integer.\n");
}
return 0;
}

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


int isprime(int x){
    
    if (x==2){
        return true;
    }
    if (x<2 || x%2==0){
        return false;
    }
    int i=3;
    double x2 =sqrt(x); 
    while (i<=x2){
        if(x%i==0){
            return false;
        }
        i += 2;
    }
    return true;
}


int main(){
    int n;
    cin >> n;
    int a[n] = {};
    int count = 0;
    for (int j=0;j<n;j++){
        cin >> a[j];
        if (isprime(a[j])){
            count += 1;
        }
        
        
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	while(1){
		int w, h;
		cin >> w >> h;
		if(w == 0) break;
		char c[21][21];
		vector<pair<int, int > > dirty;
		int sx, sy;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				// cout << i << j << endl;
				cin >> c[i][j];
				if(c[i][j] == '*') dirty.push_back(make_pair(i, j));
				if(c[i][j] == 'o'){
					sx = i;
					sy = j;
				}
			}
		}
		int kyori[21][21][21][21];
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				for(int k = 0; k < h; k++){
					for(int l = 0; l < w; l++){
						kyori[i][j][k][l] = -1;
					}
				}
			}
		}
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				queue<pair<int, int> > qu;
				kyori[i][j][i][j] = 0;
				qu.push(make_pair(i, j));
				while(!qu.empty()){
					int x = (qu.front()).first;
					int y = (qu.front()).second;
					qu.pop();
					int dx[4] = {1, 0, -1, 0};
					int dy[4] = {0, 1, 0, -1};
					for(int k = 0; k < 4; k++){
						if(x + dx[k] >= 0 && x + dx[k] < h && y + dy[k] >= 0 && y + dy[k] < w && c[x + dx[k]][y + dy[k]] != 'x' && kyori[i][j][x + dx[k]][y + dy[k]] < 0){
							kyori[i][j][x + dx[k]][y + dy[k]] = kyori[i][j][x][y] + 1;
							qu.push(make_pair(x + dx[k], y + dy[k]));
						}
					}
				}
			}
		}
		vector<vector<int> > result((1 << 10), vector<int>(10, mod));
		for(int i = 0; i < dirty.size(); i++){
			result[(1 << i)][i] = kyori[sx][sy][dirty[i].first][dirty[i].second];
		}
		for(int i = 1; i < (1 << dirty.size()); i++){
			for(int j = 0; j < dirty.size(); j++){
				if((i & (1 << j)) == 0) continue;
				for(int k = 0; k < dirty.size(); k++){
					if(j == k || (i & (1 << k)) > 0 || kyori[dirty[j].first][dirty[j].second][dirty[k].first][dirty[k].second] < 0) continue;
					result[i | (1 << k)][k] = min(result[i | (1 << k)][k], result[i][j] + kyori[dirty[j].first][dirty[j].second][dirty[k].first][dirty[k].second]);
					// cout << k << " " << kyori[dirty[j].first][dirty[j].second][dirty[k].first][dirty[k].second] << endl;
				}
				// cout << i << " " << j << " " << result[i][j] << endl;
			}
		}
		int ans = mod;
		for(int i = 0; i < dirty.size(); i++){
			ans = min(ans, result[(1 << dirty.size()) - 1][i]);
		}
		if(ans == mod) ans = -1;
		cout << ans << endl;
	}
}


Measured memory_bytes: 3872
import sys
readline = sys.stdin.readline

K, Q = map(int, readline().split())

D = list(map(int, readline().split()))

Ans = [None]*Q
for q in range(Q):
    n, x, mod = map(int, readline().split())
    x%= mod
    D2 = [d%mod for d in D]
    res = 0
    cnt = 0
    zero = 0
    for d2 in D2:
        res += d2
        if res > mod:
            cnt += 1
            res -= mod
        if not d2:
            zero += 1
    
    loop =  ((n-1)//K)
    minus = loop*cnt
    zero *= loop
    res2 = 0
    for i in range((n-1)%K):
        res2 += D2[i]
        if not D2[i]:
            zero += 1
        if res > mod:
            res -= mod
            minus += 1
    minus += (x%mod + loop*res + res2)//mod
    Ans[q] = n-1 - zero - minus
print('\n'.join(map(str, Ans)))

Measured memory_bytes: 68188
from collections import deque
H, W = map(int, input().split())
L = []
for _ in range(H):
    s = input()
    a = []
    for i in range(len(s)):
        a.append(s[i])
    L.append(a)

dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]


def bfs(x, y):
    dp = [[10000000] * W for _ in range(H)]
    dp[y][x] = 0
    if L[y][x] == '#':
        return dp
    else:
        d = deque()
        d.append([x, y])
        while len(d) > 0:
            s = d.popleft()
            for i in range(4):
                if (s[1] +
                    dy[i] >= 0 and s[1] +
                    dy[i] < H and s[0] +
                    dx[i] >= 0 and s[0] +
                        dx[i] < W):
                    if L[s[1] +
                         dy[i]][s[0] +
                                dx[i]] == '.' and dp[s[1] +
                                                     dy[i]][s[0] +
                                                            dx[i]] == 10000000:
                        d.append([s[0] + dx[i], s[1] + dy[i]])
                        dp[s[1] + dy[i]][s[0] + dx[i]] = dp[s[1]][s[0]] + 1

        return dp


max_num = 0
for i in range(H):
    for j in range(W):
        dp = bfs(j, i)
        for k in dp:
            for p in k:
                if (p == 10000000):
                    continue
                max_num = max(max_num, p)
print(max_num)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

bool isPrime(int x) {
    if (x == 1) return false;
    for (int i = 2; i * i <= x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    vector<int> L(Q), R(Q);
    rep(i, Q) cin >> L[i] >> R[i];

    int N = *max_element(R.begin(), R.end());

    vector<int> sum(N+1);
    for (int x = 1; x <= N; ++x) {
        if (isPrime(x) && (x+1) % 2 == 0 && isPrime((x+1)/2)) {
            sum[x] = sum[x-1] + 1;
        } else {
            sum[x] = sum[x-1];
        }
    }

    rep(i, Q) {
        L[i]--;
        cout << sum[R[i]] - sum[L[i]] << endl;
    }
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
c=1
g=0
for i in range(n-1):
  if (g==1 and a[i+1]<a[i]) or (g==-1 and a[i+1]>a[i]) :
    c+=1
    g=0
  elif g==0:
    if a[i+1]>a[i]:
      g=1
    elif a[i+1]<a[i]:
      g=-1
print(c)

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

// dp[i][j][k]: x[:i] から j 枚選んで k になる組み合わせの個数 
long long dp[51][51][2501] = {};

int main()
{
    int N, A;
    cin >> N >> A;
    vector<int> x(N+1);
    FOR(i, 1, N+1) cin >> x[i];

    dp[0][0][0] = 1;
    REP(i, N){
        // x[i+1] を選ばないとき
        REP(j, i+1){
            REP(k, 2501) dp[i+1][j][k] = dp[i][j][k];
        }
        // x[i+1] を選ぶとき
        REP(j, i+1){
            FOR(k, x[i+1], 2501) dp[i+1][j+1][k] += dp[i][j][k-x[i+1]];
        }
    }

    long long ans = 0;
    FOR(j, 1, N+1){
        REP(k, 2501){
            if(k == A*j) ans += dp[N][j][k];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 49152
N,M = (int(x) for x in input().split())
H = list(map(int, input().split()))
connected = [set() for _ in range(N)]
count = 0
for i in range(M):
    A,B = (int(x) for x in input().split())
    connected[A-1].add(B)
    connected[B-1].add(A)
for i in range(N):
    if len(connected[i]) == 0:
        count += 1
    else:
        comp = [H[x-1] for x in connected[i]]
        if max(comp) < H[i]:
            count += 1
print(count)

Measured memory_bytes: 45156
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, char>> sc;
  rep(i, M) {
    int s;
    char c;
    cin >> s >> c;
    sc.push_back(make_pair(s - 1, c));
  }

  int high = static_cast<int>(pow(10, N));
  int low = N == 1 ? 0 : (high / 10);
  for (const int n : boost::irange(low, high)) {
    string s = to_string(n);
    if (all_of(sc.begin(), sc.end(),
               [s](pair<int, char> p) { return s.at(p.first) == p.second; })) {
      cout << n << endl;
      return 0;
    }
  }

  cout << "-1" << endl;
  return 0;
}


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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a= b; a>=c; a-=1)
#define fi first
#define se second
#define pb push_back

const int N = 2e5 + 100;
const int Maxn = 3e3;
const int mod = 2019;

int n;
int a[N], pw10[N];
int cnt[Maxn];

signed main() {
    ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0);
    pw10[0] = 1;
    FOR(i, 1, N - 1) pw10[i] = pw10[i - 1] * 10 % mod;

    string s; cin >> s;
    int len = s.length();

    int ans = 0;
    cnt[0] = 1;
    FORW(i, len - 1, 0) {
        a[i] = ((s[i] - '0') * pw10[len - i - 1] % mod + a[i + 1]) % mod;
        ans += cnt[ a[i] ];
        cnt[ a[i] ] += 1;
    }
    cout << ans;
}


Measured memory_bytes: 5288
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	int M, N;
	int A[100];
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A, A + N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
	}
	if (A[N - M] * (4 * M) >= sum) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
flag = 0
count = 0

while(flag == 0):
    for j in range(0,n):
        if(a[j] % 2 != 0):
            flag = 1
            break
        else:
            a[j] = a[j] / 2
    if(flag == 1):
        break
    else:
        count = count + 1

print(count)
    
    
        


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

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

    double josu = (double)1/n;
    double ans = 0;

    int i;

    if(n >= k){
        for(int i=n;i>=k;i--){
            ans += josu;
        }
        i = k-1;
    }else{
        i = n;
    }
    
    double two = (double)1/2;

    while(i>0){
        if((double)i >= k*two){
            ans += josu*two;
            i--;
        }else{
            two *= (1/2.0);
        }
    }

    printf("%.12lf\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define WW 100000
#define INF 1000000000000000000

 //1e18
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({__}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
int32_t main()
{
    IOS;
    int s,w;cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";
    return 0;
}

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

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

  if (A.size() > B.size()) {
    cout << "GREATER";
  } else if (A.size() < B.size()) {
    cout << "LESS";
  } else {
    string ans = "EQUAL";
    for (int i=0; i<A.size(); i++) {
      if (A[i] > B[i]) {
        ans = "GREATER";
        break;
      } else if (A[i] < B[i]) {
        ans = "LESS";
        break;
      }
    }
    cout << ans;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque
n,k = map(int, input().split())
td = []

for _ in range(n):
    t,d = map(int, input().split())
    td.append((t,d))

td.sort(reverse=True, key=lambda x:x[1])

used = set()
q = []
res = 0
kind = 0
for i in range(k):
    t,d = td[i]
    if t not in used:
        kind += 1
        used.add(t)
    else:
        q.append((t,d))
    res += d
res += kind**2
q = deque(sorted(q, key=lambda x:x[1]))

tmp = res
for i in range(k,n):
    if len(q)==0:
        break
    t2,d2 = td[i]
    if t2 in used:
        continue
    used.add(t2)
    t,d = q.popleft()

    r = tmp - d + d2
    r -= kind**2
    kind += 1
    r += kind**2
    res = max(res, r)
    tmp = r

print(res)


Measured memory_bytes: 21892
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

    static class InputReader {

        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000");
        long maxi = Integer.MAX_VALUE;
        long mod = (long) (1e9 + 7);

        long pro(long a, long b) {
            return (a % mod * b % mod) % mod;
        }

        long add(long a, long b) {
            return (a + b) % mod;
        }

        void solve() {
            double l = sc.nd();
            double a = l / 3.0;
            out.println(df.format(a * a * a));
        }
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	int N,M;cin>>N>>M;
	int l1,r1,l2,r2;
	//part1
	l1=1;
	if(M&1)r1=M;
	else r1=M+1;

	l2=r1+1;
	while(l1!=r1){cout<<l1<<" "<<r1<<"\n";l1++;r1--;}
	//part2;
	r2=2*M+1;
	while(l2<r2){cout<<l2<<" "<<r2<<"\n";l2++;r2--;}
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3624
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryDifficulty = readInts().sorted()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    print(aryDifficulty[n / 2] - aryDifficulty[n / 2 - 1])
}
main()



Measured memory_bytes: 17832
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  map<int, bool> X;
  rep(i, N) {
    int a;
    cin >> a;
    X[a] ^= 1;
  }
  int s = 0;
  for (P p : X) s += p._2;
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 4992
N, K = map(int, input().split())
A = map(int, input().split())

A_list = list(A)
counter = 0
A_list.sort()
A_list.reverse()

if K >= N:
    print(0)
else:
    for val in range(N - K):
        counter += int(A_list[val+K])
    print(counter)

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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int x = 0, y = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            x += a.at(i);
        } else {
            y += a.at(i);
        }
    }

    cout << x - y << endl;

    return 0;
}


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

int main() {
    ll H, W;
    cin >> H >> W;
    if(H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
    }
    ll all = H * W;
    ll ans = all / 2;
    if(all % 2 != 0) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

//#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;

const int MOD = 1000000007; // 10^9 + 7
struct mint{int x;mint(int x=0):x((x%MOD+MOD)%MOD){}
mint operator-()const{return mint(-x);}
mint& operator+=(const mint a){if((x+=a.x)>=MOD)x-=MOD;return*this;}
mint& operator-=(const mint a){if((x+=MOD-a.x)>=MOD)x-=MOD;return*this;}
mint& operator*=(const mint a){(x*=a.x)%=MOD;return*this;}
mint operator+(const mint a)const{return mint(*this)+=a;}
mint operator-(const mint a)const{return mint(*this)-=a;}
mint operator*(const mint a)const{return mint(*this)*=a;}
mint pow(int t)const{if(!t)return 1;mint a=pow(t>>1);a*=a;if(t&1)a*=*this;return a;}
mint inv()const{return pow(MOD-2);}
mint& operator/=(const mint a){return*this*=a.inv();}
mint operator/(const mint a)const{return mint(*this)/=a;}};
ostream& operator<<(ostream& os, const mint& a) {return os << a.x;}
/****************************** START ******************************/
/*mint f(mint a, mint N){
  if (N == 0){
    return 1;
  } else {
    return a * f(a, N - 1);
  }
}*/

mint f(long long a, long long n, long long MOD) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

signed main(){
  int N;
  cin >> N;
  cout << (f(10,N,MOD) - f(9,N,MOD) - f(9,N,MOD) + f(8,N,MOD)); 
}

Measured memory_bytes: 3592
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  rep(_, 1000) {
    string s;
    cin >> s;
    bool ok = true;
    loop(i, 1, s.size()) ok &= (abs(s[i] - s[i - 1]) == 1 && (s[i] - 'A') / 3 == (s[i - 1] - 'A') / 3) || abs(s[i] - s[i - 1]) == 3;
    if (ok) cout << s << endl;
  }
}

Measured memory_bytes: 3180
#include <iostream>
#include <vector>
using i64 = unsigned long long;
using namespace std;

int main() {
  i64 n;
  cin >> n;
  int sagot = 0;
  for (int i = 2; i <= n / i; i++) {
    vector<i64> d;
    if (n % i == 0) {
      d.push_back(i);
      if (n / i > i) {
        d.push_back(n / i);
      }
    }
    for (int x : d) {
      i64 t;
      for (t = n; t % x == 0; t /= x); 
      if (t % x == 1) sagot++;
    }
  }
  for (int i = 2; i <= (n - 1) / i; i++) {
    if ((n - 1) % i == 0) {
      sagot++;
      if ((n - 1) / i > i) {
        sagot++;
      }
    }
  }
  printf("%d\n", sagot + (n > 2) + 1); // +1 for k = n - 1
}

Measured memory_bytes: 256