akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  vector<int64_t> A(n);
  for(int i=0;i<n;++i)cin>>A[i];
  sort(A.rbegin(),A.rend());
  int64_t res=0,j=0,use=1;
  for(int i=1;i<n;++i){
    res+=A[j];
    use++;
    if(use==2)++j,use=0;
  }
  cout<<res<<'\n';
  
  return 0;
}
//2020.07.05 20:18:01


Measured memory_bytes: 4776
#include <cstdio>
#include <algorithm>

using namespace std;
const int Max_N(2050);

void gi(int &Ret)
{
	Ret = 0;
	char ch;
	while (ch = getchar(), ch > '9' || ch < '0')
		;
	do
	{
		(Ret *= 10) += ch - '0';
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
}

int N, Head[Max_N], Total, To[Max_N << 1], Next[Max_N << 1], Sum[Max_N], Size[Max_N], Ans = 0X3F3F3F3F, F[Max_N];
char S[Max_N];

inline void Add_Edge(int s, int t)
{
	++Total, To[Total] = t, Next[Total] = Head[s], Head[s] = Total;
}

void dfs(int u, int fa)
{
	Sum[u] = 0, Size[u] = S[u] - '0';
	for (int i = Head[u], v;i;i = Next[i])
		if ((v = To[i]) != fa)
			dfs(v, u), Sum[u] += Sum[v] + Size[v], Size[u] += Size[v];
}

void dp(int u, int fa)
{
	int Max(0), Son = 0;
	for (int i = Head[u], v;i;i = Next[i])
		if ((v = To[i]) != fa)
		{
			dp(v, u);
			Max = max(Max, Sum[v] + Size[v]);
			if (Sum[v] + Size[v] > Sum[Son] + Size[Son])
				Son = v;
		}
	if (Son == 0)
	{
		F[u] = 0;
		return;
	}
	if (Sum[u] - Max >= Max)
		F[u] = Sum[u] / 2;
	else
	{
		F[u] = Sum[u] - Max;
		int cnt = Max - (Sum[u] - Max);
		F[u] += min(F[Son], cnt >> 1);
	}
}

int main()
{
	gi(N);
	scanf("%s", S + 1);
	for (int i = 1, u, v;i != N;++i)
		gi(u), gi(v), Add_Edge(u, v), Add_Edge(v, u);
	for (int root = 1;root <= N;++root)
	{
		dfs(root, -1);
		if ((Sum[root] & 1) == 0 && (dp(root, -1), F[root] == (Sum[root] >> 1)))
			Ans = min(Ans, F[root]);
	}
	if (Ans == 0X3F3F3F3F)
		printf("-1");
	else
		printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdouble;


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

  for(int i = 0; i< s.size(); i++){
    cout << "x";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define L_T_S_k  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
using namespace std;
const int N = 1e6;
const int mod = 1e9 + 7;

int32_t main() {    
 L_T_S_k;
 string s;
 cin >> s;
 int cnt = 0;
 int i = 0 , j = s.size() - 1;
 while(i < j){
  if(s[i] != s[j])cnt++;
  i++ , j--;
 }
 cout << cnt << "\n";
 return 0;
}

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

const int MAXN = 101;
const int MAXK = 1e5+1;
int N, K, A[MAXN];
int dp[MAXK];

int canWin(int s) {
    // printf("s : %d\n", s);
    if (~dp[s]) return dp[s];

    for (int i=0;i<N;i++)  // try all possible moves
        if (s>=A[i]&&!canWin(s-A[i])) 
            return dp[s] = true;
    
    return dp[s] = false;
}

int main() {
    cin>>N>>K;
    for (int i=0;i<N;i++) cin>>A[i];
    memset(dp, -1, sizeof(dp));

    cout<<(canWin(K)? "First\n" : "Second\n");

}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[100100];
int K;

ll amin = INT_MAX;
ll amax = -1;

int main(){
    cin >> K;
    REP(i,K){
        ll a;
        cin >> a;
        A[i] = a;
    }

    ll small, large;
    small = large = 2;
    bool fail = false;
    for(int i = K-1; i >= 0; i--){
        ll a = A[i];
        if(a > large || (small % a != 0 && large - small + 1 + (small%a) < a)){
            fail = true;
            break;
        }
        small += (small % a != 0) ? a - small%a : 0; 
        large = large - large%a + (a - 1);
    }

    if(fail){
        cout << -1 << endl;
    }
    else{
        printf("%lld %lld\n", small, large);
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <bitset>

using namespace std;
int main (){
    int n;
    cin >> n;
    int a[n]={};
    int tmp1;
    int tmp2;
    int mark[n][n]={};
    for (int i = 0; i < n; i++){
        cin >> a[i];
        for (int j = 0; j < a[i]; j++){
            cin >> tmp1 >> tmp2;
            mark[tmp1-1][i]=tmp2+1;
        }
    }

    int hcount;
    bool ref;
    int jud;


//    cout << "\n";
//    for (int i = 0; i < n; i++){
//        for (int j = 0; j < n; j++){
//            cout << mark[i][j] << " ";
//        }
//        cout << "\n";
//    }
//    cout << "\n";


    int honest=0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        jud=true;
        hcount=__builtin_popcount(bit);

        for (int i = 0; i < n; i++){
            ref=(bit & (1<<i));
            for (int j = 0; j < n; j++){
                if(bit & (1<<j)){
                    if(!((mark[i][j]==(int)ref+1)||(mark[i][j]==0))) jud=false;
                }
            }
        }
        if(jud) honest=max(honest,hcount);
    }
    cout << honest << "\n";
}

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

#define ll long long

ll calc(ll val) {
  return val * 1.01;
}

int main(void) {

  ll X;
  cin >> X;

  ll value = 100;
  ll res = 1;
  while(1) {
    value *= 1.01;
    if (value >= X) break;
    res++;
  }

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu long long unsigned
int main()
{
    int t,a,b,x,y,z,n,mx,k,mn,tmp;
    scanf("%d %d",&k,&x);
    //for(int i=0;i<t;i++){
        int cnt=0,ans=0;
        string s="";
        vector<int>vc;
        map<int,int>mp;
        map<char,int>mc;
        //scanf("%d",&x);
        char ch,ch2;
        for(int j=x;j<x+k;j++){
            if(j>1000000) break;
            vc.push_back(j);
        }
        for(int j=x-1;j>x-k;j--){
            if(j<(-1000000)) break;
            vc.push_back(j);
        }
        sort(vc.begin(),vc.end());
        for(int j=0;j<vc.size();j++){
            printf("%d",vc[j]);
            if(j+1==vc.size()) puts("");
            else printf(" ");
        }



    //}

    return 0;
}






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

int main() {
  int N, a;
  vector<int> d;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    d.push_back(a);
  }
  sort(d.begin(), d.end());

  if (d[N / 2 - 1] == d[N / 2]) {
    cout << 0 << endl;
  } else {
    cout << d[N / 2] - d[N / 2 - 1]  << endl;
  }

  return 0;
}

Measured memory_bytes: 1020
#include<iostream>
using namespace std;
string s;
int a[10][10];
main()
{
    while(cin>>s)
    {
        for(int i=0;i<10;i++)a[0][i]=s[i]-'0';
        for(int i=0;i<9;i++)
        {
            for(int j=0;j<9-i;j++)a[i+1][j]=(a[i][j]+a[i][j+1])%10;
        }
        cout<<a[9][0]<<endl;
    }
}


Measured memory_bytes: 3096
#include <stdio.h>



int main(void){
    int A,B;
    scanf("%d %d",&A,&B);
    int ans[100][100];
    for(int i=0;i<100;i++)for(int j=0;j<100;j++){
        if(j>=50)ans[i][j]=1;
        else ans[i][j]=0;
    }
    for(int i=0;i<B-1;i++){
        int po1=i%50;
        int po2=i/50;
        ans[2*po1+1][2*po2+1]=1;
    }
    for(int i=0;i<A-1;i++){
        int po1=i%50;
        int po2=i/50;
        ans[2*po1+1][99-2*po2]=0;
    }
    printf("100 100\n");
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            if(ans[i][j]==1)printf("#");
            else printf(".");
        }
        printf("\n");
    }
    return 0;
}


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

#define coor(i,j) ((i)+(j)*m)
#define in(i,j) (0<=(i)&&(i)<m&&0<=(j)&&(j)<n)
using namespace std;
vector<bitset<626> > M(625);

main(){
	int m,n,d;
	int i,j,k;
	int success,ans;
	for(;cin>>m>>n>>d,d;cout<<ans<<endl){
		//create M
		for(j=0;j<n;j++)
			for(i=0;i<m;i++){
				M[coor(i,j)].reset();
				M[coor(i,j)][coor(i,j)]=1;
				cin>>k;M[coor(i,j)][m*n]=k;

				for(k=0;k<=d;k++){
					if(in(i-k,j-(d-k)))M[coor(i,j)][coor(i-k,j-(d-k))]=1;
					if(in(i+k,j-(d-k)))M[coor(i,j)][coor(i+k,j-(d-k))]=1;
					if(in(i-k,j+(d-k)))M[coor(i,j)][coor(i-k,j+(d-k))]=1;
					if(in(i+k,j+(d-k)))M[coor(i,j)][coor(i+k,j+(d-k))]=1;
				}
			}

		//solve
		k=0;
		for(i=0;i<m*n;i++){
			for(j=k;j<m*n&&!M[j][i];j++);
			if(j==m*n)continue;
			swap(M[k],M[j]);
			for(j=k+1;j<m*n;j++)if(M[j][i])M[j]^=M[k];
			k++;
		}

		//finalize
		ans=1;
		for(j=k;j<m*n;j++)if(M[j][m*n])ans=0;
	}
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 1000000007
#define pb push_back
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int> >PQG;
#define fi first
#define sf second.first
#define ss second.second

int n, m, ans, res;
pair<int, pair<int, int> > a[1010];

int fanc(int x, int y)
{
    if((x >> y) & 1){
        return -1;
    }
    else{
        return 1;
    }
}

signed main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i].fi >> a[i].sf >> a[i].ss;
    }
    sort(a, a + n, greater<pair<int, pair<int, int> > >() );
    for(int bit = 0; bit < 8; bit++){
        PQ que;
        for(int i = 0; i < n; i++){
            que.push(a[i].fi * fanc(bit, 0) + a[i].sf * fanc(bit, 1) + a[i].ss * fanc(bit, 2));
        }
        for(int j = 0; j < m; j++){
            res += que.top();
            que.pop();
        }
        ans = max(ans, res);
        res = 0;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n, m;
  cin >> n >> m;

  int u_1, v_1, u_2, v_2;
  cin >> u_1 >> v_1 >> u_2 >> v_2;
  --u_1;
  --v_1;
  --u_2;
  --v_2;

  vector<string> g(n);
  for(auto& row : g)
    cin >> row;

  int const INF = INT_MAX;
  vector<vector<int>> dist(n, vector<int>(m, INF));

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

  int jx[] = {
    -2, -2, -2, -2, -2,
    -1, -1,     -1, -1,
     0,              0,
     1,  1,       1, 1,
     2,  2,  2,  2,  2,
  };

  int jy[] = {
    -2, -1,  0,  1,  2,
    -2, -1,       1, 2,
    -2,              2,
    -2,  -1,      1, 2,
    -2, -1,  0,  1,  2,
  };

  set<tuple<int, int, int>> pq;
  pq.emplace(0, u_1, v_1);

  auto is_valid = [&] (int x1, int y1, int x2, int y2) {
    return
      0 <= x2 and x2 < n
      and
      0 <= y2 and y2 < m
      and
      g[x1][y1] == '.' and '.' == g[x2][y2];
  };

  while(pq.size()) {
    auto [d, x, y] = *pq.begin();
    pq.erase(pq.begin());

    if(x == u_2 && v_2 == y) {
      cout << d;
      return 0;
    }

    for(int i = 0; i < 4; ++i) {
      int u = x + dx[i];
      int v = y + dy[i];

      if(is_valid(x, y, u, v)) {
        int cost = 0;
        if(d + cost < dist[u][v]) {
          if(dist[u][v] != INF) {
            pq.erase({dist[u][v], u, v});
          }
          dist[u][v] = d + cost;
          pq.emplace(d + cost, u, v);
        }
      }
    }

    for(int i = 0; i < 20; ++i) {
      int u = x + jx[i];
      int v = y + jy[i];

      if(is_valid(x, y, u, v)) {
        int cost = 1;
        if(d + cost < dist[u][v]) {
          if(dist[u][v] != INF) {
            pq.erase({dist[u][v], u, v});
          }
          dist[u][v] = d + cost;
          pq.emplace(d + cost, u, v);
        }
      }
    }
  }

  cout << -1;
}


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

int main() {

	int n; cin >> n;
	string s; cin >> s;
	const int p = 26;
	int ans = 0;
	for (int i = 1; i <= n - 1; i++) {
		string s_left = s.substr(0, i);
		string s_right = s.substr(i);
		vector<int> leftNum(p, 0);
		vector<int> rightNum(p, 0);
		for (int i = 0; i < s_left.size(); i++) {
			leftNum[s_left[i] - 'a'] = 1;
		}
		for (int i = 0; i < s_right.size(); i++) {
			rightNum[s_right[i] - 'a'] = 1;
		}
		int tmp = 0;
		for (int i = 0; i < p; i++) {
			if (leftNum[i] == 1 && rightNum[i] == 1) tmp++;
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

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

    int n; cin >> n;
    vector<ll> t(n);
    for (int i = 0; i < n; ++i) cin >> t[i];

    ll res = lcm(1, t[0]);
    for (int i = 1; i < n; ++i) res = lcm(t[i], res);

    cout << res << endl;

    return 0;
}

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

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

    vector<pair<int, int>> ball(N);
    int x, y;
    for (int i = 0; i < N; i++)
    {
        cin >> x >> y;
        ball[i] = make_pair(x, y);
    }
    sort(ball.begin(), ball.end());

    map<pair<int, int>, int> count;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            int diff_x = ball[i].first - ball[j].first;
            int diff_y = ball[i].second - ball[j].second;
            count[make_pair(diff_x, diff_y)]++;
        }
    }
    if (N == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    int ans = INT_MAX;
    for (auto itr = count.begin(); itr != count.end(); itr++)
    {
        ans = min(ans, N - itr->second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while((x->left) != NIL)
    x = x->left;
  return x;

}

Node treeMaximum(Node x){
  while((x->right) != NIL)
    x = x->right;
  return x;
  
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == (u->key))
    return u;
  if(k < (u->key))
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  
  if((x->right) != NIL)
    return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == (y->right)){
    x = y;
    y = y->parent;
  }

  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if((z->left) == NIL || (z->right) == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if((y->left) != NIL)
    x = y->left;
  else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if((y->parent) == NIL)
    root = x;
  else if(y == ((y->parent)->left))
    (y->parent)->left = x;
  else
    (y->parent)->right = x;
    
  if(y != z)
    z->key = y->key;


}

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

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

}

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20448
import sys
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
i = 0
while i < N:
    if A[i] <= x:
        x -= A[i]
        i += 1
    else:
        print(i)
        sys.exit()
if x > 0:
    print(i - 1)
else:
    print(i)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	vector<string> all;
	vector<string> cur;
	rep(i,1,10) cur.push_back(to_string(i));
	all.insert(all.end(),cur.begin(),cur.end());

	auto lun=[](string &x) {
		rep(i,1,sz(x)) if (abs(x[i]-x[i-1])>1) return false;
		return true;
	};

	rep(i,1,10) {
		vector<string> next;
		fore(cur,x) {
			rep(y,0,10) {
				string z=x+(char)(y+'0');
				if (lun(z)) {
					next.push_back(z);
				}
			}
		}
		cur=next;
		all.insert(all.end(),cur.begin(),cur.end());
	}

	int N;
	cin>>N;
	cout<<all[N-1]<<endl;
}


Measured memory_bytes: 13704
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N;
    cin>>N;
    vector<int> v(N),p(N),q(N);
    rep(n,0,N){int a;cin>>a;v.at(n)=p.at(n)=a;}
    rep(n,0,N) cin>>q.at(n);
    sort(ToEnd(v));

    int i=0,ans=0;;
    do{
        if(v==p) ans=abs(ans-i);
        if(v==q) ans=abs(ans-i);
        i++;
    }while(next_permutation(ToEnd(v)));

    cout<<ans<<endl;
}

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

int main(void)
{
    ll n, ans=0, sum=0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    rep(i,n){
        sum -= a[i];
        ans += sum%mod*a[i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4756
#!/usr/bin/ruby
#encoding: utf-8

def isEvenArray(*ary)
  flag = true
  (0..ary.size-1).each do |i|
    if ary[i].odd?
      flag = false
      break
    end
  end

  return flag
end

n = gets.to_i
a = gets.split.map(&:to_i)

cnt = 0

while isEvenArray(*a) == true
  cnt += 1
  (0..a.size-1).each do |i|
    a[i] /= 2
  end
end

puts cnt

Measured memory_bytes: 3836
use std::io;
use std::collections::HashMap;

fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}
fn dist(aa: &Vec<i64>, bb: &Vec<i64>) -> f64
{
    let mut ret = 0.0;
    let n = aa.len();
    for i in 0..n {
        let index = i as usize;
        let a = aa[index];
        let b = bb[index];
        let d = (a-b)*(a-b);
        ret += d as f64;
    }
    ret = ret.sqrt();
    return ret;
}

fn main() {
    //println!("start");
    let nd = read_nums();
    let n = nd[0];
    let d = nd[1];
   
    let mut vv: Vec<Vec<i64>> = Vec::new();
    for i in 0..n {
        let v = read_nums();
        vv.push(v);
    }
    let mut count = 0;
    for i in 0..n {
        for j in i+1..n {
            let d = dist(&vv[i as usize], &vv[j as usize]);
            let d2 = d.floor();
            if d2 == d {
                count += 1;
            }
        }
    }
    //println!("{}",n);
    let ret = count;
 
    print!("{}", ret);
    
    
}   

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int k; cin>>k; --k;
	queue<int64_t>q;
	for(int i=1;i<10;++i){
		q.push(i);
	}
	for(;k;--k){
		int64_t top=q.front(); q.pop();
		string t=to_string(top);
		for(char c=t.back()-1;c<=t.back()+1;++c){
			if(c<'0'||c>'9')continue;
			string tt=t+c;
			q.push(stol(tt));
		}
	}
	cout<<q.front()<<"\n"s;
}

Measured memory_bytes: 4844
N,A,B=list(map(int, input().split()))
S=input()
a=0
b=0

for i in range(N):
  s=S[i]
  if s=='a':
    if a+b<A+B:
      print('Yes')
      a+=1
    else:
      print('No')
  elif s=='b':
    if a+b<A+B and b<B:
      print('Yes')
      b+=1
    else:
      print('No')
  else:
    print('No')



Measured memory_bytes: 75876
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 10000000

typedef long long ll;

bool f[100];
string s, t;
vector<string> vs;
vector< vector<int> > vvi;

map<string, int> msi;

int n, m, d;

int main(){
	while (cin >> n){
		if (!n)break;
		REP(i, n){
			cin >> s >> m;
			vs.push_back(s);
			vector<int> vi;
			REP(j, m){
				cin >> d;
				vi.push_back(d);
			}
			vvi.push_back(vi);
		}
		REP(i, 30){
			int c = -1;
			REP(j, n){
				vector<int>::iterator it = find(ALL(vvi[j]), i);
				if (it != vvi[j].end()){
					msi[vs[j]] += n;
					f[j] = 1;
					c++;
				}
			}
			REP(j, n){
				if (f[j]){
					msi[vs[j]] -= c;
				}
				f[j] = 0;
			}
		}
		int mi = INF;
		REP(i, n){
			if (mi == msi[vs[i]]){
				if (t > vs[i]){
					t = vs[i];
				}
				continue;
			}
			if (mi != min(mi, msi[vs[i]])){
				t = vs[i];
				mi = min(mi, msi[vs[i]]);
			}
		}
		cout << mi << " " << t << endl;
		vs.clear();
		vvi.clear();
		msi.clear();
	}
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)


// 2 * (N + 1 - K)!
int main(){
	int N,K;
	vector<ll> arr;
	vector<ll>sum_arr;
	cin>>N>>K;
	
	REP(i,N){
		ll a;
		cin>>a;
		arr.push_back(a);
	}
	sum_arr.push_back(0);
	for(int i = 1;i <= N;i++){
		ll n_sum = (arr[i-1] > 0 ? arr[i-1] : 0) + sum_arr[i-1];
		sum_arr.push_back(n_sum);
	}

	ll max_s = -INT_MAX;
	
	for(int i = 0; i < (N + 1 - K); i++){
		ll sum = 0;
		for(int j = 0; j < K; j++){
			sum += arr[j+i];
		}
		if(sum < 0)sum = 0;
		sum += sum_arr[N] + sum_arr[i] - sum_arr[i+K];
		if(max_s < sum ){
			max_s = sum;
		}
	}
	
	cout<<max_s<<endl;

	return 0;
}


Measured memory_bytes: 2548
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

const mod = 1000000007

var dp []int

func rec(i, N int, m []int) int {
	if dp[i] != -1 {
		return dp[i]
	}
	if i == N {
		return 1
	}
	var r0, r1 int
	if i < N && m[i+1] != 1 {
		r0 = rec(i+1, N, m)
	}

	if i < N-1 && m[i+2] != 1 {
		r1 = rec(i+2, N, m)
	}

	dp[i] = (r0 + r1) % mod
	return dp[i]
}

func solve(N int, m []int) int {
	dp = make([]int, N+1)
	dp[0] = 1
	for i := 1; i <= N; i++ {
		if m[i-1] != 1 {
			dp[i] += dp[i-1]
			dp[i] %= mod
		}
		if i > 1 && m[i-2] != 1 {
			dp[i] += dp[i-2]
			dp[i] %= mod
		}
	}

	return dp[N]
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()
	m := make([]int, N+1)
	dp = make([]int, N+1)

	for i := 0; i <= N; i++ {
		dp[i] = -1
	}

	for i := 0; i < M; i++ {
		a := getInt()
		m[a] = 1
	}

	//out(rec(0, N, m))
	out(solve(N, m))
}


Measured memory_bytes: 3328
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	inpa(a,n)
	int ans=1;
	int ct[n+2]={0};
	ct[0]=3;
	fo(i,n)
	{
		ans=(ans*ct[a[i]])%mod;
		ct[a[i]]--;
		ct[a[i]+1]++;
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll first=a+(n-1)*b;
	ll last=a+b+(n-2)*a;
	if(first-last+1<0) cout<<0;
	else	cout<<first-last+1;
	
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	if(k>(n-1)*(n-2)/2){
		cout << -1 << endl;
		return 0;
	}

	bool b[n][n];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i==0) b[i][j]=true;
			else b[i][j]=false;
		}
	}
	int cnt=0, t=(n-1)*(n-2)/2-k;
	for(int u=1; u<n; u++){
		for(int v=1; v<n; v++){
			if(u==v) continue;
			if(!b[u][v] && cnt<t){
				b[u][v]=true;
				b[v][u]=true;
				cnt++;
			}
		}
	}
	cout << n-1+t << endl;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if(b[i][j]){
				cout << i+1 << " " << j+1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int a[3];
		for(i=0;i<3;i++)
			cin>>a[i];
		sort(a,a+3);
		cout<<a[0]+a[1]<<endl;
	
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
  int n,m;
  cin>>n>>m;
  int s=0;
  vi a(n);
  rep(i,n){
    int tmp;
    cin>>tmp;
    a[i]=tmp;
    s+=tmp;
    }


  sort(rall(a));
  int ans=0;
  rep(i,m){
    if(a[i]>=s*1.0/4/m)ans++;
  }
  if(ans==m){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
int main (){
     
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    while( true ){
        int N;
        cin >> N;
        if( N == 0 ){ return 0; }
        multimap<int, int> mp;
        REP( i, N )
        {
            int a, b;
            cin >> a >> b;
            mp.insert( make_pair( b, a ) );
        }
        int total{0};
        bool flag = true;
        for( auto& x : mp )
        {
            total += x.second;
            if( total > x.first )
            {
                flag = false;
            }
        }
        cout << ( flag ? "Yes" : "No" ) << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String y = sc.next();
        if(x.compareTo(y) < 0){
            System.out.println("<");
        }else if(x.compareTo(y) > 0){
            System.out.println(">");
        }else{
            System.out.println("=");
        }
        sc.close();
    }
}

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

int Count;

void BubbleSort(int A[],int N){
	bool flag=true;
	
	while(flag){
		flag=false;
		
		for(int j=N-1;j>=1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				Count++;
				flag=true;
			}
		}
	}
}

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

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

	Count =0;
	
	BubbleSort(A,N);

	for(int i=0;i<N;i++){
		cout<<A[i];
	
		if(i<N-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
	cout<<Count<<endl;

	return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000

int parent(int i){ return i/2;}
int left(int i){return 2 * i;}
int right(int i){return 2 * i + 1;}

int main(){
  int H,i,A[MAX+1];
  scanf("%d",&H);
  for(i=1;i<=H;i++){scanf("%d",&A[i]);}

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>= 1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H)printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



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

const long long INF = 1LL << 60;
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; }

typedef long long ll;
#define vl vector<ll>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)

int main() {

    int N, K; cin >> N >> K;
    vl h(N);
    rep(i, N) cin >> h[i];

    vl dp(N, INF);
    dp[0] = 0;

    rep1(i, N) {

        rep1(j, min(i, K)+1) {
            chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }

    }

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

}


Measured memory_bytes: 1792
#
import sys
import math
import numpy as np
import itertools

# ひとつ入力
n = int(input())

# いくつか入力
a, b = (int(i) for i in input().split())

for i in range(a,b+1,1):
    if i % n == 0:
        print("OK")
        exit()
print("NG")



Measured memory_bytes: 27136
use std::cmp::max;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let mut ret = 0f64;
    let n: usize = parse!(it);
    let p: Vec<(f64, f64)> = (0..n).map(|_| parse!(it, 2)).collect();
    let cos = |a: f64, b: f64, c: f64| (b.powi(2) + c.powi(2) - a.powi(2)) / 2f64 / b / c;
    let l = |p: (f64, f64), q: (f64, f64)| ((p.0 - q.0).powi(2) + (p.1 - q.1).powi(2)).sqrt();
    for i in 0..n {
        for j in (i + 1)..n {
            for k in (j + 1)..n {
                let a = l(p[i], p[j]);
                let b = l(p[j], p[k]);
                let c = l(p[k], p[i]);
                let cosa = cos(a, b, c);
                let cosb = cos(b, c, a);
                let cosc = cos(c, a, b);
                if cosa < 0. || cosb < 0. || cosc < 0. {
                    ret = if ret < a / 2. { a / 2. } else { ret };
                    ret = if ret < b / 2. { b / 2. } else { ret };
                    ret = if ret < c / 2. { c / 2. } else { ret };
                } else {
                    let r =
                        a * b * c / ((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c)).sqrt();
                    ret = if ret < r { r } else { ret };
                }
            }
        }
    }
    if n == 2 {
        ret = l(p[0], p[1]) / 2.;
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  int A,B;
  cin >> A >> B;
  
  if(A < 9 && B < 9) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort(reverse=True)
    if l.pop(0) < sum(l):
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
	fio();
	ll n, k;
	cin >> n >> k;
	vl a(n);
	rep (i, n) cin >> a[i];
	sort(all(a));
	//DEBUG_VEC(a);

	ll ok = INF, ng = -INF;

	while (ng + 1 < ok) {
		ll x = (ng + ok) / 2;
		ll sum = 0;
		rep (i, n) {
			ll y = a[i];
			if (y == 0) {
				if (x >= 0) sum += n - 1;
				continue;
			}
			int num;
			if (y > 0) {
				ll w;
				if (x >= 0) w = x / y;
				else {
					if (x % y == 0) w = x / y;
					else w = x / y - 1;
				}
				num = upper_bound(all(a), w) - a.begin();
			}
			else {
				ll w;
				if (x >= 0) w = x / y;
				else {
					if (x % y == 0) w = x / y;
					else w = x / y + 1;
				}
				num = a.end() - lower_bound(all(a), w);
			}
			if (y * y <= x) num--;
			sum += num;
		}
		assert(sum % 2 == 0);
		sum /= 2;
		if (sum >= k) {
			ok = x;
		}
		else {
			ng = x;
		}
	}
	cout << ok << endl;
}

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

int a, b;
int main() {
	cin >> a;
	for(int i = 1; i <= 9; i++) 
		if (a % i == 0 && (a / i) >= 1 && (a / i) <= 9) return puts("Yes"), 0;
	puts("No");
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  vector<int> h(n); rep(i,n) cin>>h.at(i);
  reverse(h.begin(),h.end());
  bool j=true;
  rep(i,n-1){
    int H=h.at(i);
    if(h.at(i+1)-h.at(i)==1) h.at(i+1)--;
    if(h.at(i+1)-h.at(i)>1) j=false;
  }
  (j)?cout<<"Yes"<<endl:cout<<"No"<<endl;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func cmpStrNum(a, b string) bool {
	if a == "---" {
		return true
	}
	if len(a) < len(b) {
		return true
	} else if len(a) > len(b) {
		return false
	}
	return a < b
}

func main() {
	line := nextLine()

	spl := intSprit(line)

	N := spl[0]

	a := intSprit(nextLine())
	tb := []int{2, 5, 5, 4, 5, 6, 3, 7, 6}

	dp := make([]string, 100000)
	for i := 1; i < len(dp); i++ {
		dp[i] = "---"
	}
	dp[0] = ""

	for i := 0; i <= N; i++ {
		if dp[i] == "---" {
			continue
		}
		for _, v := range a {
			if cmpStrNum(dp[i+tb[v-1]], dp[i]+strconv.Itoa(v)) {
				dp[i+tb[v-1]] = dp[i] + fmt.Sprint(v)
			}
		}
	}
	fmt.Println(dp[N])
}


Measured memory_bytes: 130880
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;

 int main() {
   ll N, x;
   cin >> N >> x;

   vector<ll> a(N);
   rep(i, 0, N) cin >> a.at(i);

   ll ans = 0;
   rep(i, 0, N - 1) {
     if (a.at(i) + a.at(i + 1) <= x) continue;
     else {
       ll res = a.at(i) + a.at(i + 1) - x;
       ans += res;
       if (a.at(i + 1) <= res) a.at(i + 1) = 0;
       else a.at(i + 1) -= res;
     }
   }
   cout << ans << endl;
 }


Measured memory_bytes: 1152
import java.util.Scanner;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Arrays;
import java.util.Stack;

public class Main {
	static Scanner scn = new Scanner(System.in);
	static int count = 0, min = Integer.MAX_VALUE;

	public static void main(String[] args) 
	{
		int n =scn.nextInt();
		String str=scn.next();
		if(n%2!=0)
		{
			System.out.println("No");
			return;
		}
		boolean bl=true;
		int j=n/2;
		for(int i=0;j<n&&i<n/2;i++,j++)
		{
			if(str.charAt(i)!=str.charAt(j))
			{
				bl=false;
				break;
			}
			
		}
		if(bl)
		{
			System.out.println("Yes");
		}
		else
			System.out.println("No");
		
	}
	public  static void subset(int arr[], int k, int sum, String ans, int prev) {
		if (sum == k) {
			System.out.print(ans + " ");
			return;
		}
		if (sum > k)
			return;

		for (int i = prev; i < arr.length; i++) {
			subset(arr, k, sum + arr[i], ans + arr[i], i);
		}
	}

	public static int gcd(int a, int b) {
		if (a == 0)
			return b;
		int l = gcd(b % a, a);
		return l;
	}

	public static void grid(int arr[][], int h, int v, int sum, int n, int m) {
		if (h == n - 1 && v == m - 1) {
			sum = sum + arr[h][v];
			if (sum <= min)
				min = sum;
			return;
		}
		if (h >= n)
			return;
		if (v >= m)
			return;
		grid(arr, h + 1, v, sum + arr[h][v], n, m);
		grid(arr, h, v + 1, sum + arr[h][v], n, m);
		grid(arr, h + 1, v + 1, sum + arr[h][v], n, m);
	}

	public static int  last(int arr[],int m,int i)
	{	
		if(i==arr.length)
		{	
			return -1;	
		}
		int s=last(arr, m, i+1);
		if(arr[i]==m && s==-1)
		{	
			return i;
		}
		return s;
		
	}
}


Measured memory_bytes: 21972
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  long a, b, c;
  readf("%s %s %s\n", &a, &b, &c);
  auto x = c - a - b;
  if (x >= 0 && 4 * a * b < x*x) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
N=int(input())
A=sorted(int(input()) for _ in [0]*N)

if N%2:
    a = A[:N//2]
    b = A[N//2+1:][::-1]
    m = A[N//2]
    if abs(m-a[-1])>abs(m-b[-1]):
        a,b = b,a
    B = [m]*N
    for i in range(N//2):
        B[2*i+1] = b[i]
        B[2*i+2] = a[i]
else:
    a = A[:N//2][::-1]
    b = A[N//2:][::-1]
    B = [0]*N
    for i in range(N//2):
        B[i*2] = a[i]
        B[i*2+1] = b[i]
ans = sum(abs(B[i]-B[i+1]) for i in range(N-1))
print(ans)

Measured memory_bytes: 8864
import java.util.*;

public class Main {

    static int INF = 1_000_000_000;
    static int[][] removed;
    static int N;
    static int[][] H;
    static ArrayList<int[]> diff;

    public static void dfs(int y, int x) {
        int val = H[y][x] + 1-removed[y][x];
        for (int i=0;i<4;i++) {
            if (0 <= y+diff.get(i)[0] && y+diff.get(i)[0] < N && 0 <= x+diff.get(i)[1] && x+diff.get(i)[1] < N) {
                int tmp = H[y+diff.get(i)[0]][x+diff.get(i)[1]];
                if (tmp > val) {
                    H[y+diff.get(i)[0]][x+diff.get(i)[1]] = val;
                    dfs(y+diff.get(i)[0], x+diff.get(i)[1]);
                }
            }
        }
    }

    public static void init_diff() {
        diff = new ArrayList<int[]>();
        int[] add_1 = {1, 0};int[] add_2 = {-1, 0};int[] add_3 = {0, 1};int[] add_4 = {0, -1};
        diff.add(add_1);diff.add(add_2);diff.add(add_3);diff.add(add_4);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        H = new int[N][N];
        removed = new int[N][N];
        init_diff();
        for (int i=0;i<N;i++) {
            for (int j=0;j<N;j++) {
                H[i][j] = INF;
            }
        }
        for (int i=0;i<N;i++) {
            for (int j=0;j<N;j++) {
                H[i][j] = Math.min(H[i][j], Math.min(i, j)+1);
                H[i][j] = Math.min(H[i][j], Math.min(N-1-i, N-1-j)+1);
            }
        }
        int ans = 0;
        for (int i=0;i<N*N;i++) {
            int P = Integer.parseInt(sc.next())-1;
            int y = P/N;
            int x = P%N;
            ans += H[y][x]-1;
            removed[y][x] = 1;
            dfs(y, x);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 70740
s=sorted(set(input()))
test="abcdefghijklmnopqrstuvwxyz"
for i in range(len(test)):
    if (s[i]!=test[i]):
        print(test[i])
        break
    if (s[i]==test[i] and i==len(s)-1 and i!=len(test)-1):
        print(test[i+1])
        break
else:
    print("None")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e6+10, mod=1e9+7;


int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	string s;
	cin>>s;
	int i,n=s.length();
	int nxt[n],prev[n];
	nxt[n-1]=n;
	for(i=n-2;i>=0;i--){
		if( s[i]==s[i+1] ) nxt[i]=nxt[i+1];
		else nxt[i]=i+1;
	}
	prev[0]=-1;
	for(i=1;i<n;i++){
		if(s[i]==s[i-1])prev[i]=prev[i-1];
		else prev[i]=i-1;
	}
	
	int mx=0;
	for(i=0;i<n;i++){
		if(s[i]=='R')mx=max(mx,nxt[i]-i);
		else mx=max(mx,i-prev[i]);
	}
	vector<int> v(n);
	
	for(i=0;i<n;i++){
		if(s[i]=='L'){
			
			if(prev[i]==-1){
				v[0]++;
				continue;
			}
			
			int x=i-prev[i];
			if(x%2==0) v[ prev[i] ]++;
			else v[prev[i]+1]++;
			
		}else{
			if(nxt[i]==n){
				v[n-1]++;
			}
			
			int x=nxt[i]-i;
			if(x%2==0)v[ nxt[i] ]++;
			else v[ nxt[i]-1 ]++;
			
		}
	}
	for(auto x:v)cout<<x<<" ";
}
// check for any potential overflow before submitting



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

int main(){
    int N;

    cin >> N;

    int W[N];
    int sumSmaller = 0;
    int sumLarger = 0;
    int ans;

    for(int i = 0; i < N; i++){
        cin >> W[i];
        sumSmaller += W[i];
    }

    int i = N - 1;
    while(sumSmaller > sumLarger){
        sumSmaller -= W[i];
        sumLarger += W[i];
        i--;
    }

    if(sumLarger - sumSmaller < sumSmaller - sumLarger + 2 * W[i + 1]){
        ans = sumLarger - sumSmaller;
    }else{
        ans = sumSmaller - sumLarger + 2 * W[i + 1];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
input = sys.stdin.readline

N = int(input())

arr = np.array([input().split() + [0] for _ in range(N)], dtype='int64')
for i in range(N):
    arr[i, 2] = arr[i, 0] + arr[i, 1]

arr = arr[np.argsort(arr[:, 2])][::-1]

print(np.sum(arr[::2, 0]) - np.sum(arr[1::2, 1]))

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

int main() {
	int X;
	cin>>X;
	if(X<=599)cout<<"8";
	else if(X<=799)cout<<"7";
	else if(X<=999)cout<<"6";
	else if(X<=1199)cout<<"5";
	else if(X<=1399)cout<<"4";
	else if(X<=1599)cout<<"3";
	else if(X<=1799)cout<<"2";
	else cout<<"1";
	return 0;
}


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

int check(int start, int end) {
  int i = 0;
  if(start >= end)return 0;
  else{
    while(true) {
     i++;
     start *= 2;
     if(start >= end) {
       return i;
       break;
      }
    }
  }
}
int main() {
  cout << fixed << setprecision(15);
  double n, k, ans=0;
  cin >> n >> k;
  for(int i = 1; i <= n; i++) {
     ans += 1 / (n * pow(2, check(i, k)));
  }
  cout << ans;
}



Measured memory_bytes: 256