akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	ll n, a[100005], b[100005], i, ans = 0;

	cin >> n;
	for(i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}

	for(i = n - 1; i >= 0; i--){
		ans += ((a[i] + ans) % b[i] != 0)? b[i] - (a[i] + ans) % b[i] : 0;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	vector<int> v(n,0);
	int t;
	For(i,0,n-1){
		cin>>t;
		v[t-1]++;
	}
	v.emplace_back(INF);
	sort(all(v)); reverse(all(v));
	vector<int> ans;
	int k=0,nowmx=0,h=0,l=n;
	for(int i=n;i>=1;i--){
		//cerr<<i<<" "<<k<<" "<<nowmx<<" "<<h<<" "<<l<<"\n";
		while(k>=h){
			while(v[l]<=nowmx){
				l--;
			}
			h+=i-l; nowmx++;
		}
		ans.emplace_back(nowmx-1);
		//cerr<<"  "<<k<<" "<<nowmx<<" "<<h<<" "<<l<<"\n";
		k+=v[i];
		h-=nowmx-v[i];
	}
	reverse(all(ans));
	For(i,0,n-1) cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 13016
#include <stdio.h>

int main(void)
{
  int a,b,k,d;
  int c[100];
  
  c[0] = 1;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&k);
  
  int i;
  int count = 1;
  if(a >= b)
    d = a;
  else
    d = b;
  
  for(i = 2; i <= d; i++){
    if(a%i==0&&b%i==0){
      c[count] = i;
      count += 1;
    }
  }
  
  printf("%d",c[count - k]);
  
  return 0;
  
}


Measured memory_bytes: 128
while True:
    x = raw_input(); x = int(x);
    if x == 0: break
    sa = 0; sb = 0;
    for i in xrange(x):
        a,b = map(int, raw_input().split())
        if a < b: sb += a + b
        elif b < a: sa += a + b
        else: sa += a; sb += b;
    print sa, sb
        

Measured memory_bytes: 6252
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <queue>

using namespace std;
using ll = long long;

const int NS = 2 * 1e5 + 5;
ll h[NS];
ll a[NS];
ll dp[NS];

using getTwoNodeValueFunc = ll (*)(ll a, ll b);
using updateOneNodeValueFunc = ll (*)(ll a, ll b);
const ll NEG_INF = -1e12;

ll getMax(ll a, ll b) {
    return max(a, b);
}

ll update(ll a, ll b) {
    return max(a, b);
}

class SimpleSegmentTree {
    private:
        int numItems;
        vector<ll> tree;
        getTwoNodeValueFunc getFunc;
        updateOneNodeValueFunc updateFunc;
        int getNumberOfNodes() {
            int x = int(ceil(log2(numItems)));
            return ((1-pow(2, x+1))/(1-2)) + 1;
        };
        void buildTree() {
            vector<ll> t(getNumberOfNodes(), 0);
            tree = t;
        };
        void _update(ll value, int ind, int start, int end, int l, int r){
            // update value of 1 node in tree
            // [start, end] is an updating index interval of segment tree
            // print(start, end, l, r)
            if (start > r || end < l) {
                return;
            }

            if (start >= l && end <= r) {
                tree[ind] = updateFunc(tree[ind], value);
                return;
            }
                
            int mid = (start+end)/2;
            _update(value, 2*ind+1, start, mid, l, r);
            _update(value, 2*ind+2, mid+1, end, l, r);

            tree[ind] = getFunc(tree[2*ind+1], tree[2*ind+2]);
        };
        ll _query(int ind, int start, int end, int l, int r) {
            if (start > r || end < l) {
                return NEG_INF;
            }

            if (start >= l && end <= r) {
                return tree[ind];
            }

            int mid = (start + end)/2;
            ll a = _query(2*ind+1, start, mid, l, r);
            ll b = _query(2*ind+2, mid+1, end, l, r);
            if (a == NEG_INF) return b;
            if (b == NEG_INF) return a;
            return getFunc(a, b);
        };
    public:
        SimpleSegmentTree (int numItemsx, getTwoNodeValueFunc get, updateOneNodeValueFunc update) {
            numItems = numItemsx;
            getFunc = get;
            updateFunc = update;
            buildTree();
        };
        void update(ll value, int ind){
            return _update(value, 0, 0, numItems-1, ind, ind);
        };
        ll query(int l, int r) {
            return _query(0, 0, numItems-1, l, r);
        };
};


int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    SimpleSegmentTree tree(n+1, (getTwoNodeValueFunc)getMax, (updateOneNodeValueFunc)update);
    ll ans = a[0];
    dp[0] = a[0];
    tree.update(dp[0], h[0]);
    for (int i = 1; i < n; i++) {
        ll maxV = tree.query(1, h[i]-1);
        if (maxV == NEG_INF) maxV = 0;
        dp[i] = maxV + a[i];
        tree.update(dp[i], h[i]);
        if (ans < dp[i]) {
            ans = dp[i];
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 12544
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

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

using namespace std;
typedef long long ll;


// %% begin matrix %%

typedef vector<int> vec;
typedef vector<vec> mat;

void pretty_print(mat g) {
  rep (i, g.size()) {
    rep (j, g[0].size()-1) {
      cout << g[i][j] << ' ';
    }
    cout << g[i][g[0].size()-1] << endl;
  }
}


mat mul(mat A, mat B) {
  mat C(A.size(), vec(B.size()));
  rep (i, A.size()) {
    rep (k, B.size()) {
      rep (j, B[0].size()) {
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }
  return C;
}

// %% end matrix %%


int main() {

  ll a, b, c;
  cin >> a >> b >> c;

  ll ans = 1001001001;
  
  if (a % 2 == 0 or b % 2 == 0 or c % 2 == 0) {
    ans = 0;
  }
  else {
    // ans = min(ans, a*b);
    // ans = min(ans, b*c);
    // ans = min(ans, c*a);
    // ans = min({a*b,b*c,c*a});
    ans = min(a*b, min(b*c, c*a));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char s[20];
	int i;
	scanf("%s",s);
	for (i=0;i<4;i++)
	{
		printf("%c", s[i]);
	}
	printf(" ");
	for(;i<strlen(s);i++)
	{
		printf("%c", s[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct segment{
  point a,b;
};

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

double dist(point a,point b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

point intersection_ls(point a1, point a2, point b1, point b2) {
  point b = b2-b1;
  double d1 = abs(cross(b, a1-b1));
  double d2 = abs(cross(b, a2-b1));
  double t = d1 / (d1 + d2);

  return a1 + (a2-a1) * t;
}

int main(void){
  segment s[3];

  while(true){
    for(int i=0;i<3;i++){
      cin >> s[i].a.x >> s[i].a.y >> s[i].b.x >> s[i].b.y;
      if( s[i].a.x==0 && s[i].a.y==0 && s[i].b.x==0 && s[i].b.y==0)return 0;
      }
    
    int fg[3]={0};
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	if(i!=j)
	  fg[i]+=is_intersected_ls(s[i].a,s[i].b,s[j].a,s[j].b);
      }
    }

    if(fg[0]==2 && fg[1]==2 && fg[2]==2){
      point p[3];
      for(int i=0;i<2;i++)
	    p[i]=intersection_ls(s[i].a,s[i].b,s[i+1].a,s[i+1].b);
      p[2]=intersection_ls(s[2].a,s[2].b,s[0].a,s[0].b);

      double z=(dist(p[0],p[1])+dist(p[1],p[2])+dist(p[2],p[0]))/2;
      double res=sqrt(z*(z-dist(p[0],p[1]))*(z-dist(p[1],p[2]))*(z-dist(p[2],p[0])));

      if(res>1900000-EPS)cout <<"dai-kichi"<<endl;
      else if(res>1000000-EPS)cout <<"chu-kichi"<<endl;
      else if(res>100000-EPS)cout <<"kichi"<<endl;
      else if(res>0+EPS)cout << "syo-kichi"<<endl;
      else cout <<"kyo"<<endl;
    }
    else cout <<"kyo"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long A,B,C,d;
	cin>>A>>B>>C;
	d=A*B*C;
	if(d%2==0)
		printf("%d\n",0);
	else{
		long long a[3];
		a[0]=A;a[1]=B;a[2]=C;
		sort(a,a+3);
		printf("%lld\n",a[0]*a[1]);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll n, m;
    cin >> n >> m;
    ll count = 1LL<<m;
    ll each_time = 1900LL * m + 100LL * (n - m);
    cout <<  each_time * count << endl;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;

    print(min(c, b / a));

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    ll ans = (N / 11) * 2;
    N -= (N / 11) * 11;
    cout<<ans + (N == 0 ? 0 : N <= 6 ? 1 : 2)<<endl;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a;
  load(a, n);

  int count = 0;
  rep(i, n) {
    count += 1 + (d - 1) / a[i];
  }
  count += x;
  p(count);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	int num1 = H1 * 60 + M1;
	int num2 = H2 * 60 + M2;
	num2 -= K;
	cout << num2 - num1 << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long


using namespace std;

vector<int>mm[21];

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

    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    int ans=0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            ans+=a[i]*a[j];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
 
/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

const int xn = 5e3 + 10;
const int xm = - 20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 1e9 + 7;
const int TM = 3;
const int base = 257;

int n, dp[2][xn][xn], f[xn], sz[xn], ans, res[2][xn];
vector <int> adj[xn];

void DFS(int v, int par = - 1){
	dp[0][v][1] = 1;
	sz[v] = 1;
	for (int u : adj[v]){
		if (u == par) continue;
		DFS(u, v);
		for (int i = 0; i < 2; ++ i){
			for (int j = 0; j < xn; ++ j){
				res[i][j] = dp[i][v][j];
				dp[i][v][j] = 0;
			}
		}
		for (int i = 0; i < 2; ++ i){
			for (int j = 1; j <= sz[v]; ++ j){
				for (int k = 0; k <= sz[u]; ++ k){
					dp[i][v][j + k] = (dp[i][v][j + k] + ll(res[i][j]) * ll(dp[0][u][k]) % mod) % mod;
					dp[!i][v][j + k] = (dp[!i][v][j + k] + ll(res[i][j]) * ll(dp[1][u][k]) % mod) % mod;
				}
			}
		}
		sz[v] += sz[u];
	}
	for (int i = 0; i < 2; ++ i)
		for (int j = 1; j < xn; ++ j)
			dp[!i][v][0] = (dp[!i][v][0] + ll(dp[i][v][j]) * ll(f[j])) % mod;
}

int main(){
    InTheNameOfGod;
    
	cin >> n;
	for (int i = 0; i < n - 1; ++ i){
		int v, u;
		cin >> v >> u;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	f[0] = 1;
	for (int i = 2; i < xn; ++ i) f[i] = ll(f[i - 2]) * ll(i - 1) % mod;
	DFS(1);
	for (int i = 1; i < xn; ++ i){
		ans = (ans - ll(dp[1][1][i]) * ll(f[i])) % mod;
		ans = (ans + ll(dp[0][1][i]) * ll(f[i]) % mod + mod) % mod;
	}
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 200272
#include <iostream>
#include <map>
#include <utility>
#include <vector>
#define MAXN 300000

using namespace std;

int N, K, L;
int c[2][MAXN], color[2];
vector <int> adj[2][MAXN];
map <pair <int, int>, int> g;

void dfs(int l, int i, int cur) {
    if (c[l][i] != -1)
        return;
    c[l][i] = cur;
    for (int j : adj[l][i])
        dfs(l, j, cur);
}

int main() {
    cin >> N >> K >> L;
    for (int l = 0; l < 2; l++) {
        int num = (l == 0 ? K : L);
        for (int i = 0; i < num; i++) {
            int u, v;
            cin >> u >> v;
            u--, v--;
            adj[l][u].push_back(v);
            adj[l][v].push_back(u);
        }
        for (int i = 0; i < N; i++)
            c[l][i] = -1;
        for (int i = 0; i < N; i++)
            if (c[l][i] == -1)
                dfs(l, i, color[l]++);
    }
    for (int i = 0; i < N; i++) {
        g[make_pair(c[0][i], c[1][i])]++;
    }
    for (int i = 0; i < N; i++)
        cout << g[make_pair(c[0][i], c[1][i])] << " ";
    cout << endl;
}


Measured memory_bytes: 32640
#include<stdio.h>

int lcm(int n1,int n2)
{
	int min = (n1 > n2) ? n1 : n2;
    while (1) {
        if (min % n1 == 0 && min % n2 == 0)
        	return min;
        ++min;
    }
    return 0;
}

int main(){
	int x,y;
	scanf("%d",&x);
    y=lcm(x,360)/x;
    printf("%d",y);
}

Measured memory_bytes: 2120
import numpy as np


def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    sol_tot, sol_tracker = -1e10, []
    for p in range(2):
        c = a.copy()

        idx = np.arange(p, n, 2)
        if len(idx) == 0:
            continue

        pick = max(idx, key=lambda x: c[x])
        if c[pick] <= 0:
            chosen = {pick}
        else:
            chosen = {x for x in idx if c[x] > 0}

        is_chosen, tot, tracker = [False] * n, 0, []
        for i in chosen:
            is_chosen[i] = True
            tot += c[i]

        for i in reversed(range(n)):
            if not is_chosen[i]:
                if i == 0 or i + 1 == len(c):
                    tracker += [i]
                    del c[i], is_chosen[i]
                elif is_chosen[i - 1] == is_chosen[i + 1]:
                    tracker += [i]
                    c[i - 1] += c[i + 1]
                    del c[i + 1], c[i], is_chosen[i + 1], is_chosen[i]

        if len(c) > 1 and not is_chosen[0]:
            tracker += [0]
            del c[0], is_chosen[0]

        if tot > sol_tot:
            sol_tot, sol_tracker = tot, np.array(tracker) + 1

    print(sol_tot, len(sol_tracker), *sol_tracker, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 12576
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  ll N;
  int ans = 0, counter[50] = {};

  cin >> N;

  for (int i=0; N; i++) {
    counter[i] += N % 3;
    N /= 3;
  }

  for (int i=0; i<50; i++) {
    bool first = true;
    for (int j=48; j>=0; j--) {
      if(((!(first || j == 0) && counter[j] <= 1) ||
         ((first || j == 0) && counter[j] == 0)) && counter[j+1]) {
        counter[j+1]--;
        counter[j] += 3;
      }
      first &= counter[j] == 0;
    }
  }

  for (int i=0; i<50; i++) {
    debug(counter[i]);
    ans += counter[i];
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#endif
#define int long long
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long double ld;
typedef long long ll;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >>  c >> d;
	for (int i = 1; ; i++) {
		if (i & 1) {
			c -= b;
			if (c <= 0) return cout << "Yes\n", 0;
		} else {
			a -= d;
			if (a <= 0) return cout << "No\n", 0;
		}
	}
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, k;
  cin >> n >> k;
  int count = 0;
  while (n) {
    n /= k;
    count++;
  }
  cout << count << endl;
}


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

int main() {
	int h, w; cin >> h >> w;
	vector<string> a(h);
	for(int i = 0; i < h; i++) cin >> a[i];

	vector<bool> tate(h, false), yoko(w, false);

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(a[i][j] == '#') {
				tate[i] = true;
				yoko[j] = true;
			}	
		}
	}

	for(int i = 0; i < h; i++) {
		if(!tate[i]) continue;
		for(int j = 0; j < w; j++) {
			if(!yoko[j]) continue;
			cout << a[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
struct song {
	string title;
	int time;
};
int main()
{
	int num;
	cin >> num;
	vector<song> list;
	string strTemp;
	int nTemp;
	song temp;
	int i;
	string xTitle;
	int sum=0;
	for (i = 0; i < num; i++)
	{
		cin >> strTemp >> nTemp;
		list.push_back({strTemp, nTemp});
	}
	cin >> xTitle;
	for (i = 0; i < num; i++)
	{
		if (xTitle == list[i].title) break;
	}
	i++;
	for (i; i < num; i++)
	{
		sum += list[i].time;
	}
	cout << sum;
}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;
  set<long> S;

  for(int i=0;i<N;i++){
    long X;
    cin>>X;

    if(S.count(X)){
      S.erase(X);
    }else{
      S.insert(X);
    }
  }
  cout<<S.size()<<endl;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define LL long long
#define ffor(i,s,n) for(int i=(s);i<(n);i++)
#define efor(i,s,n) for(int i=(s);i<=(n);i++)
using namespace std;

LL n;
LL a[200000];

LL ev(LL ld){
	LL sum=0;

	ffor(i,0,n){
		sum+=abs(a[i]-(ld));
	}
	return sum;
}

int main(){
	cin>>n;
	double sum=0;
	ffor(i,0,n){
		cin>>a[i];
		a[i]-=(i+1);
	}
	sort(a,a+n);
	
	cout<<ev(a[n>>1])<<endl;
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

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

	int dp[100005];
	fill(dp,dp+n,100005);
	dp[0]=1;
	dp[5]=1;
	for(int i=6;i<=n;i*=6)
		dp[i-1]=1;
	dp[8]=1;
	for(int i=9;i<=n;i*=9)
		dp[i-1]=1;
	

	for(int i=2;i<=n;i++)
	{
		if(dp[i-1]==1)
			continue;
		int tmp=dp[i-1-1]+1;
		for(int j=6;j<i;j*=6)
		{
			if(tmp>dp[i-j-1]+1)
				tmp=dp[i-j-1]+1;
		}
		for(int j=9;j<i;j*=9)
		{
			if(tmp>dp[i-j-1]+1)
				tmp=dp[i-j-1]+1;
		}
		dp[i-1]=tmp;
	}
	cout << dp[n-1] << endl;
/*
	for(int i=1;i<=n;i++)
		cout << i << ":" << dp[i-1] << endl;
*/
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  
  int base = -1;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (base <= vec[i]) {
      cnt++;
      base = vec[i];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int x[6];

int main(){
	for(int i=1; i<=5; ++i)
	  cin >> x[i];
	for(int i=1; i<=5; ++i) 
	if(x[i] == 0) printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 3216
/*
	Powered by C++11.
	Author : Alex_Wei.
*/

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

//#pragma GCC optimize(3)
//#define int long long

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

// Templates start.

namespace IO{
	char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#ifdef __WIN64
		#define gc getchar()
	#else
		#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
	#endif
	#define pc(x) (*O++=x)
	#define flush() fwrite(obuf,O-obuf,1,stdout)

	inline int read(){
		int x=0,sign=0; char s=getchar();
		while(!isdigit(s))sign|=s=='-',s=getchar();
		while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=getchar();
		return sign?-x:x;
	}
	void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}
}

namespace math{
	const int mod=998244353;
	const int maxn=1e6+5;

	ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%mod; m=m*m%mod,b>>=1;} return s;}
	ll inv(ll x){return ksm(x,mod-2);}

	ll fc[maxn],ifc[maxn];
	void init_m(int n){
		fc[0]=1; for(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%mod;
		ifc[n]=inv(fc[n]); for(int i=n-1;i>=0;i--)ifc[i]=ifc[i+1]*(i+1)%mod;
	}
	ll C(ll n,ll m){return fc[n]*ifc[m]%mod*ifc[n-m]%mod;}
}

// Templates end. Please give me more points.

using namespace IO;
//using namespace math;

const int N=2e5+5;

int n,a[N]; ll ans;
map <int,int> mp;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)ans+=mp[i-a[i]],mp[a[i]+i]++;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 21252
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
LL n,c,x[N],val[N],bx[N],sv[N],bv[N],f[2][N],g[2][N],ans;
int main()
{
	n=read();c=read();
	for(int i=1;i<=n;i++)
	  x[i]=read(),val[i]=read();
	for(int i=1;i<=n;i++){
		sv[i]=sv[i-1]+val[i];
	}
	for(int i=n;i>=1;i--){
		bx[i]=c-x[i];
		bv[i]=bv[i+1]+val[i];
	}
	for(int i=1;i<=n;i++){
		f[1][i]=max(f[1][i-1],sv[i]-2*x[i]);
		g[1][i]=max(g[1][i-1],sv[i]-x[i]);
	}
	for(int i=n;i>=1;i--){
		f[0][i]=max(f[0][i+1],bv[i]-2*bx[i]);
		g[0][i]=max(g[0][i+1],bv[i]-bx[i]);
	}
	for(int i=0;i<=n;i++){
		ans=max(ans,g[0][i+1]+f[1][i]);
		ans=max(ans,g[1][i]+f[0][i+1]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
string S[10];
int main()
{
  int N,M,K;
  cin>>N>>M>>K;
  for(int i=0;i<N;i++)
    cin>>S[i];
  int Ans=0;
  for(int S1=0;S1<(1<<N);S1++)
    for(int S2=0;S2<(1<<M);S2++)
    {
      int Cnt=0;
      for(int i=0;i<N;i++)
        if(!((S1>>i)&1))
          for(int j=0;j<M;j++)
            if(!((S2>>j)&1))
              if(S[i][j]=='#')
                Cnt++;
      if(Cnt==K)
        Ans++;
    }
  cout<<Ans<<endl;
  return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>

using namespace std;

#define N (200000)

vector<pair<int,int>>g[N];

pair<int,int> a[N];
int b[N];

bool used[N];

vector<int>ans;

void dfs(int v) {
	used[v] = true;
	for (auto edge : g[v]) {
		int u = edge.first;
		if (used[u])continue;
		dfs(u);
		if (b[u] & 1) {
			b[u]++;
			b[v]++;
			ans.push_back(edge.second);
		}
	}
}

int inf = 1e9;

int main() {
	fill(a, a + N, make_pair(inf, inf));
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i].first, &a[i].second);
	}
	sort(a, a + n);
	for (int i = 0; i <= n; i++) {
		if (i == 0) {
			b[i] = (a[i].second != 0);
		}
		else {
			if (i == n) {
				b[i] = (a[i - 1].second != 0);
			}
			else {
				b[i] = (a[i].second != a[i - 1].second);
			}
		}
	}

	for (int i = 0; i < m; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		int ind1 = lower_bound(a, a + n, make_pair(l, -1)) - a;
		int ind2 = upper_bound(a, a + n, make_pair(r, 2)) - a;
		if (ind1 == ind2)continue;
		g[ind1].push_back({ ind2 ,i + 1 });
		g[ind2].push_back({ind1, i + 1});
	}
	for (int i = 0; i <= n; i++) {
		if (!used[i]) {
			dfs(i);
		}
	}
	for (int i = 0; i <= n; i++) {
		if (b[i] & 1) {
			puts("-1");
			return 0;
		}
	}
	printf("%d\n", ans.size());
	sort(ans.begin(), ans.end());
	for (auto x : ans) {
		printf("%d ", x);
	}
	return 0;
}

Measured memory_bytes: 18300
s = list(map(int, input()))
sod = [s[i] for i in range(len(s)) if i % 2 == 0]
sev = [s[i] for i in range(len(s)) if i % 2 == 1]
sodb = sod.count(0)
sodw = sod.count(1)
sevb = sev.count(0)
sevw = sev.count(1)
print(min([sodb+sevw, sodw+sevb]))

Measured memory_bytes: 4640
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    char x,y;
    cin>>x>>y;
    if(x=='H'){
        cout<<y<<endl;
    }
    else{
        if(y=='H')
            cout<<"D"<<endl;
        else
            cout<<"H"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
//#include "puzzle.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)
#pragma warning (disable:4244)

using namespace std;
typedef long long int lint;


//***** Main Program *****

int main() {
	int n;
	cin >> n;
	vector<int> R(n);
	Loop(i, n) cin >> R[i];
	int ret = R[1] - R[0];
	int a = INT_MAX;
	Loop(i, n) {
		ret = max(ret, R[i] - a);
		a = min(a, R[i]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n,greater<int>());
  long long int j=0,ans=0;
  for(int i=0;i<n;i++){
    if(i==0){
      ans+=a[i];
      j++;
      if(j==n-1)break;
    }
    else{
      ans+=a[i];
      j++;
      if(j==n-1)break;
      ans+=a[i];
      j++;
      if(j==n-1)break;
    }
  }
  printf("%lld",ans);
}


Measured memory_bytes: 4528
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	vector<int> nsew(4,0);
	string s;
	cin >> s;

	for(int i=0; i<s.length(); i++){
		if(s.at(i)=='N' ){
			nsew.at(0)=1;
		}else if(s.at(i)=='S'){	
			nsew.at(1)=1;
		}else if(s.at(i)=='E'){	
			nsew.at(2)=1;
		}else if(s.at(i)=='W'){	
			nsew.at(3)=1;
		}
	}

	if(nsew.at(0)==nsew.at(1) && nsew.at(2)==nsew.at(3)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
	char str[1000];
	char one_str[2] = {'0', '\0'};
	char *sp;
	int a, digit;
	cin>>str;
	a = atoi(str);
	while(a){
		digit=0;
		sp=str;
		while(1){
			if(*sp=='\0') break;
			one_str[0] = *sp;
			digit += atoi(one_str);
			sp++;
		}
		cout<<digit<<endl;
		cin>>str;
		a = atoi(str);
	}
	return 0;
}

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

int main(){
  int A, B, ans = 0;
  cin >> A >> B;
  
  for (int i = 0; A + i < B + 1; i++){
    int N = A + i;
    if (N/10000 == N%10 && N%10000/1000 == N%100/10){
      ans++;
    }
  }
    
    cout << ans << endl;
}

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

int main(void){

  int x,i=0;

  while(1){
    cin >> x;
    i = i++;
    if(x == 0) break;
    cout <<"Case" <<" " <<i <<":" <<" " <<x<<"\n";
    
  }
  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    s << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    s << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
	cin >> n;

	vector<ll> x(n), y(n), h(n);
	ll gx, gy, gh;
	rep(i, n) {
		cin >> x[i] >> y[i] >> h[i];
		if(h[i] > 0) {
			gx = x[i]; gy = y[i]; gh = h[i];
		}
	}

	for(int cx = 0; cx <= 100; ++cx){
		for(int cy = 0; cy <= 100; ++cy){
			bool ok = true;
			ll H = max(abs(gx-cx)+abs(gy-cy)+gh, 0ll);
			for(int i = 0; i < x.size(); ++i){
				ll tmp = max(H-abs(x[i]-cx)-abs(y[i]-cy), 0ll);
				if(h[i] != tmp) {
					ok = false;
					break;
				}
			}
			if(ok){
				cout << cx << sp << cy << sp << H << endl;
				return 0;
			}
		}
	}


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
long long n,s[10001],count;
int main(){
	while(true){
	cin>>n;
	if(n==0)
		break;
	count=0;
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<n-1;i++){
		for(int j=n-1;j>i;j--){
			if(s[j]<s[j-1]){
				int tmp=s[j];
				s[j]=s[j-1];
				s[j-1]=tmp;
			}
		}
	}
	for(int i=0;i<n;i++)
		count+=s[i]*(n-1-i);
	cout<<count<<endl;
	}
    return 0;
}
 

Measured memory_bytes: 1232
n, y = map(int, input().split())
a, b, c = 10000, 5000, 1000

#そもそも無理なやつは排除
if y > n * a:
    print("-1 -1 -1")
    
else:
    success = False
    for i in range(n+1):
        for j in range(n - i + 1):
            if y == a * i + b * j + c * (n - i - j):
                print(i, j, n-i-j)
                success = True
                break
        if success == True:
            break
    if success == False:
        print("-1 -1 -1")
        

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

    if(n%2 == 0)
       impare = n/2;
    else
       impare = n/2+1;

    float rezultat = (float)impare / n;

    cout << rezultat << endl;

     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char s;
  int cou=0;
  bool flag=true;
  while(cin>>s){
    cou++;
    if(cou%2){
      if(s=='L'){cout<<"No"<<endl;
      flag=false;
      break;
      }
    }
    else{
      if(s=='R'){cout<<"No"<<endl;
      flag=false;
      break;
      }
    }
  }
  if(flag){cout<<"Yes"<<endl;}
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = fastReadInts(n)
  val ys = fastReadInts(n)
  val xSum = xs.map { it.toLong() }.sum()
  val ySum = ys.map { it.toLong() }.sum()
  if (xSum < ySum) {
    println(-1)
    return
  }


  val lowCount = (0 until n).count { xs[it] < ys[it] }
  val lowSum = (0 until n).map {
    if (xs[it] < ys[it]) (ys[it] - xs[it]).toLong()
    else 0.toLong()
  }.sum()

  if (lowCount == 0) {
    println(0)
    return
  }

  val excessValues = (0 until n).map {
    if (xs[it] < ys[it]) 0
    else xs[it] - ys[it]
  }.toIntArray()
  excessValues.sortDescending()
  // println(excessValues)
  var usedExcessCount = 0
  var usedExcessSum = 0L
  for (i in 0 until n) {
    usedExcessSum += excessValues[i]
    usedExcessCount++
    if (usedExcessSum >= lowSum) break
  }

  println(lowCount + usedExcessCount)
}

// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}


Measured memory_bytes: 57192
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int Nmax = 50;

int n, m;
vector<vector<int>> G(Nmax, vector<int>(Nmax));
vector<int> visited(Nmax);

void dfs(int v) {

    visited[v] = 1;

    rep(u, n) {
        if(G[v][u] && !visited[u]) {
            dfs(u);
        }
    }

}   

int main() {

    cin >> n >> m;

    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }

    int ans = 0;
    rep(i, m) {

        G[a[i]][b[i]] = G[b[i]][a[i]] = 0;

        rep(i, n) {
            visited[i] = 0;
        }

        dfs(0);

        rep(i, n) {
            if(!visited[i]) {
                ans++;
                break;
            }
        }

        G[a[i]][b[i]] = G[b[i]][a[i]] = 1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
char op(int x)
{
  if(x > 0) return '+';
  else return '-';
}
int main(void)
{
  int n,a,b,c,d;
  std::cin >> n;
  a = n / 1000;
  b = n / 100 % 10;
  c = n / 10 % 10;
  d = n % 10;
  for(int op1 = -1; op1 <= 1; op1 += 2){
    for(int op2 = -1; op2 <= 1; op2 += 2){
      for(int op3 = -1; op3 <= 1; op3 += 2){
        if(a + op1 * b + op2 * c + op3 * d == 7){
          std::cout << a << op(op1) << b << op(op2) << c << op(op3) << d << "=7" << std::endl;
          goto end;
        }
      }
    }
  }
  end:
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
		ld l;cin >> l;
		ld b = l / 3;
		cout << fixed << setprecision(10) << pow(b,3) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void){
   int i,n,a,m,z;
   double total=0,tota=0,tot=0,b,c,max;
       scanf("%d",&n);
  int x[n],y[n];
  for(a=0;a<n;a++){
      scanf("%d",&x[a]);
  }
     for(a=0;a<n;a++){
      scanf("%d",&y[a]);
  }
          for(i=0; i<n; i++){
              m=x[i]-y[i];
              z=abs(m);
       total += z;
   }
      for(i=0;i<n;i++){
          m=x[i]-y[i];
              z=abs(m);
          tota+=(z*z);
          b=sqrt(tota);
  }
         for(i=0;i<n;i++){
             m=x[i]-y[i];
              z=abs(m);
          tot+=(z*z*z);
          c=pow(tot,1.0/3.0);
          
  }
    max=abs(x[0]-y[0]);
         for(i=0;i<n;i++){
          if(abs(x[i]-y[i])>=max)max=abs(x[i]-y[i]);
  }
  printf("%f\n%f\n%f\n%f\n",total,b,c,max);
   
}


Measured memory_bytes: 2104
#include<iostream>
using namespace std;
string s;int i;
bool f()
{
	if(s[i]!='m')return false;
	i++;
	if(s[i]!='e'&&!f())return false;
	if(s[i]!='e')return false;
	i++;
	if(s[i]!='w'&&!f())return false;
	if(s[i]!='w')return false;
	i++;
	return true;
}
main()
{
	cin>>s;cout<<(f()&&i==s.size()?"Cat":"Rabbit")<<endl;
}



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

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

using namespace std;

int main()
{
  int n,k;
  cin >> n >> k;
  int gz[100001] = {};
  int go[100001] = {};
  int zc = 0;
  int oc = 0;

  string s;
  cin >> s;

  bool zero = true;

  if(s[0] == '0') {
    zc++;
    gz[zc] = 1;
  } else {
    zero = false;
    oc++;
    go[oc] = 1;
  }

  FOR(i,1,n) {
    if(s[i] == '0') {
      if (s[i] == s[i-1]) {
        gz[zc]++;
      } else {
        zc++;
        gz[zc] = 1 + gz[zc-1];
      }
    } else {
      if (s[i] == s[i-1]) {
        go[oc]++;
      } else {
        oc++;
        go[oc] = 1 + go[oc-1];
      }
    }
  }

  if(zc <= k) {
    cout << n << endl;
    return 0;
  }

  int result = 0;

  FOR(i, k, zc + 1) {
    int tmp = (gz[i] - gz[i - k]);
    if (zero) {
      tmp += (go[min(oc, i)] - go[max(i - k - 1, 0)]);
    } else {
      tmp += (go[min(oc, i + 1)] - go[max(i - k, 0)]);
    }
    result = max(tmp, result);
  }

  cout << result << endl;


}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i=0; i<W+2; i++) {
    cout << "#";
  }
  cout << endl;
  
  for (int i=0; i<H; i++) {
    vector<string> vec(H);
    cin >> vec.at(i);
    cout << "#";
    cout << vec.at(i);
    cout << "#" << endl;
  }
  
  for (int i=0; i<W+2; i++) {
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
  int a[5];
  int k;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  cin >> k;
  if (a[4] - a[0] <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <queue>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ul;
typedef pair<int,int> P;
#define X first
#define Y second

const int mod = 998244353;

bool ok(string s,int k) {
	int n = s.length();
	for(int i = 0; i <= n-k; i++) {
		if(s[i]==1) {
			if(i+k<n) {
				s[i] = 0;
				s[i+k] = 1-s[i+k];
			} else {
				for(int j = 0; j < k; j++) {
					s[i+j] = 1 - s[i+j];
				}
			}
		}
	}
	for(int i = 0; i < k; i++) if(s[i]==1) return false;
	return true;
}

void go() {
	string s;
	cin >> s;
	for(char &c : s) c-='0';
	int l,r,m;
	l = 1; r = s.length();
	if(ok(s,r)) {
		cout << r << endl;
		return;
	}
	for(;l+1<r;) {
		m = (l+r)/2;
		if(ok(s,m)) {
			l = m;
		} else {
			r = m;
		}
	}
	cout << l << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	// int t; cin >> t; for(;t--;)
	go();
	return 0;
}




Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <stdint.h>
#include <vector>
using namespace std;

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

bool solve()
{
    int n;
    int64_t k;
    cin >> n >> k;
    vector<int64_t> as(n);
    for (auto& a : as)
        cin >> a;

    sort(as.begin(), as.end());

    int64_t g = 0;
    for (int i = 0; i + 1 < n; i++) {
        g = gcd(g, abs(as[i] - as[i + 1]));
    }

    if (g == 0) {
        return as[0] == k;
    }

    for (int i = 0; i < n; i++) {
        if (k > as[i])
            continue;
        if (abs(k - as[i]) % g == 0)
            return true;
    }
    return false;
}

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

    cout << (solve() ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n;
    cin >> n;

    li ans = 0;
    for (int i = 1; i < n; ++i) {
        li j = n - i;
        if (i != j && i < j) {
            ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  sample
//
//  Created by h3037178 on 2017/07/27.
//  Copyright ?? 2017??´ ?????£?????????. All rights reserved.
//

#include<iostream>
using namespace std;
int main(){
    int i;
    cin>>i;
    cout<<i*i*i<<endl;
}

Measured memory_bytes: 3072
# 一致している数の集合をSとする。
n, m = map(int, input().split())

mod = 10 ** 9 + 7
N = m + 5
bikkuri = [1 for i in range(N)]
for i in range(1, N):
    bikkuri[i] = (i * bikkuri[i - 1]) % mod

gyaku = [1 for i in range(N)]
gyaku[N - 1] = pow(bikkuri[N - 1], mod - 2, mod)
for i in range(N - 1, 0, -1):
    gyaku[i - 1] = (gyaku[i] * i) % mod


def perm(n, r):
    if r < 0:
        return 0
    if n == 0:
        return 1
    return (bikkuri[n] * gyaku[n - r]) % mod


def comb(n, r):
    if r < 0 or n - r < 0:
        return 0
    return (bikkuri[n] * gyaku[r] * gyaku[n - r]) % mod


ans = 0
# i個共通とする.共通じゃないのはmからn-i個
for i in range(n + 1):
    ans += (
        perm(m, i) * perm(m - i, n - i) * perm(m - i, n - i) * comb(n, i) * pow(-1, i)
    )
    ans %= mod

print(ans % mod)


Measured memory_bytes: 48560