akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
int main(){
  vi in(5); rep(i,5) cin >> in[i];
  sort(ALL(in));
  int ans = INF;
  do{
    int tans = 0;
    rep(i,5){
      if(i == 4){tans += in[i];}
      else if(in[i] % 10 == 0) tans += in[i];
      else tans += in[i] +(10-(in[i]%10));
    }
    ans = min(ans, tans);
  }while(next_permutation(ALL(in)));
  cout << ans << endl;
}

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

void solve() 
{
    ll n;cin>>n;
    ll ans=0;
    map<ll,ll>m;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            m[i]++;
            n/=i;
        }
    }
    if(n!=1)m[n]=1;
    for(auto it:m){
        ans+=(sqrt(it.second*8+1)-1)/2;
    }
    cout<<ans<<endl;
}

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

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

#define ll long long
#define ld long double
#define ii pair<int ,int >
#define S second
#define F first
#define PI 3.1415926535897932384626
#define SPEED std::ios_base::sync_with_stdio(false);
const int N = 1e5+7;
int n,a[N],mem[N];

int dp(int i){
    if(i==n-1)return 0;
    if(i>=n)return 1e9;
    int &ret = mem[i];
    if(ret!=-1)return ret;
    int p1=1e9,p2=1e9;
    p2 = abs(a[i+2]-a[i])+dp(i+2);
    p1 = abs(a[i+1]-a[i])+dp(i+1);

    return ret = min(p1,p2);
}

int main(){
    SPEED
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    memset(mem,-1,sizeof mem);
    cout<<dp(0);

}


Measured memory_bytes: 2560
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x){ostringstream sout; sout<<x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

struct state {
	string s;
	int t;

	state(){};
	state(string s, int t) : s(s), t(t){};
};

int main(){
	int n;
	while(cin>>n,n){
		vs a(n),b(n);
		REP(i,n){
			cin>>a[i]>>b[i];
		}
		string start,goal;
		cin>>start>>goal;

		queue<state> S;
		S.push(state(start, 0));

		int ans = -1;
		while(!S.empty()) {
			state st = S.front();
			S.pop();
			string s = st.s;

			if(s == goal) {
				ans = st.t;
				goto show;
			}

			REP(i, n) {
				string curs(s);
				int pos=0;
				bool flag=false;
				while(pos = curs.find(a[i],pos), pos != string::npos) {
					flag=true;
					curs.replace(curs.begin()+pos,curs.begin()+pos+a[i].size(),b[i]);
					pos+=b[i].size();
					if(curs.size()>10){
						flag=false;
						break;
					}
				}
				if(flag){
					S.push(state(curs, st.t+1));
				}
			}
		}

show:
			cout << ans << endl;
	}
}

Measured memory_bytes: 1512
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("aca");
            WillReturn.Add("accc");
            WillReturn.Add("ca");
            //A
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("abcb");
            WillReturn.Add("aacb");
            WillReturn.Add("bccc");
            //C
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        List<char> AList = InputList[0].ToList();
        List<char> BList = InputList[1].ToList();
        List<char> CList = InputList[2].ToList();

        char Curr = 'a';
        while (true) {
            List<char> pList = null;
            if (Curr == 'a') pList = AList;
            if (Curr == 'b') pList = BList;
            if (Curr == 'c') pList = CList;

            if (pList.Count == 0) break;

            Curr = pList[0];
            pList.RemoveAt(0);
        }

        if (Curr == 'a') Console.WriteLine('A');
        if (Curr == 'b') Console.WriteLine('B');
        if (Curr == 'c') Console.WriteLine('C');
    }
}


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

int main(){
	int n;
	cin >> n;
	vector<int> vec(n);
	for (int i=0;i<n;i++){
		cin >> vec.at(i);
	}
	int ans = 0;
	for (int i=1;i<n-1;i++){
		if ((vec.at(i-1)<vec.at(i)&&vec.at(i)<vec.at(i+1))
		||  (vec.at(i+1)<vec.at(i)&&vec.at(i)<vec.at(i-1))){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 234567
using namespace std;
typedef long long ll;
ll ans,n,a[maxn];

int main()
{
    cin >> n; a[0]=-1;
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++) if (a[i]-a[i-1]>1) {cout << -1 << endl;return 0;}
    for (int i=1;i<=n;i++) if (a[i]>=a[i+1]) ans+=a[i];
    cout << ans << endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;

string s;
int d, dp1[10009][100], dp2[10009][100];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> d;
	int n = s.length();
	s = s + "0";
	reverse(s.begin(), s.end());
	dp2[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < d; j++) {
			for (int k = 0; k < 10; k++) {
				dp2[i][(k + j) % d] += dp2[i - 1][j];
				dp2[i][(k + j) % d] = dp2[i][(k + j) % d] % MOD;
			}
		}
	}
	dp1[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int k = 0; k < s[i] - '0'; k++) {
			for (int j = 0; j < d; j++) {
				dp1[i][(k + j) % d] += dp2[i - 1][j];
				dp1[i][(k + j) % d] = dp1[i][(k + j) % d] % MOD;
			}
		}
		for (int j = 0; j < d; j++) {
			dp1[i][(s[i] - '0' + j) % d] += dp1[i - 1][j];
			dp1[i][(s[i] - '0' + j) % d] = dp1[i][(s[i] - '0' + j) % d] % MOD;
		}
	}
	cout << (dp1[n][0] - 1 + MOD)%MOD << "\n";
	//system("pause");
	return 0;
}

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

#define N 250

int parent(int);
int right(int);
int left(int);


int main(){
  int i, n, A[N], key;

  scanf("%d", &n);

  for(i = 1; i <= n; i++)
    scanf("%d", &A[i]);

  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, A[i]);

    if(i > 1)
      printf("parent key = %d, ", A[parent(i)]);

    if(i * 2 <= n)
      printf("left key = %d, ", A[left(i)]);

    if((i * 2) + 1 <= n)
      printf("right key = %d, ", A[right(i)]);

    printf("\n");
  }

  return 0;
}

int parent(int i){
  return i / 2;
}

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

int left(int i){
  return i * 2;
}
    



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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n, a, b;
	cin >> n >> a >> b;
	if (a%2 == b%2)
		cout << "Alice\n";
	else
		cout << "Borys\n";
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n; R(n);
    VI a(n+1),b(n+1);
    FOR(i,1,n){
        R(a[i]);
        b[i]=abs(i-1-(n-i));
    }
    sort(ALL(a));
    sort(ALL(b));
    LL an=1;
    FOR(i,1,n){
        if(a[i]!=b[i]){
            W(0);
            return 0;
        }
        if(i>1&&a[i]==a[i-1])an=an*2%MOD;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>

using ll = long long;
using namespace std;

int main(void) {

    int N;
    cin >> N;

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

    vector<vector<ll>> dp(N+1, vector<ll>(2, 0));
    dp[0][0] = 0;
    dp[0][1] = -1e15;

    for (int i = 0; i < N; ++i) {
        dp[i+1][0] = max({dp[i][0]+A[i], dp[i][1]-A[i]});
        dp[i+1][1] = max({dp[i][0]-A[i], dp[i][1]+A[i]});
    }

    cout << dp[N][0] << endl;
    return 0;
}

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

int main(){

    string s;
    cin >> s;
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << "-1" << endl;
        return 0;
    }
    s += '`';
    for(int i = s.size() - 1; i >= 0; i--){
        for(s[i]++; s[i] <= 'z'; s[i]++){
            int f = 0;
            vector<int>cnt(256, 0);
            for(int j = 0; j <= i; j++){
                cnt[s[j]]++;
                if(cnt[s[j]] == 2)f = 1;
            }
            if(f)continue;
            for(int j = 0; j <= i; j++){
                cout << s[j];
            }
            cout << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b;
  cin >> a >> b;
  if(a+b>=10) cout <<"error\n";
  else cout <<a+b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	ll d, a;
	cin >> d >> a;
	pair<ll, ll> p[n];
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	vector<ll> x(n), cnt(n + 1);
	rep(i, n) x[i] = p[i].first;
	ll ans = 0;
	rep(i, n) {
		cnt[i + 1] += cnt[i];
		p[i].second -= a * cnt[i + 1];
		if (p[i].second > 0) {
			ll now = (p[i].second + a - 1) / a;
			ans += now;
			cnt[i + 1] += now;
			int it = upper_bound(all(x), p[i].first + d * 2) - x.begin();
			if (it == n + 1)
				continue;
			else
				cnt[it + 1] -= now;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 2e5 + 5;

ll n, a[nax], b[nax];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	for(ll i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	if(n & 1){
		ll mid = n / 2;
		cout << b[mid] - a[mid] + 1 << '\n';
	}
	else{
		ll mid = n / 2;
		ll mid2 = n / 2 - 1;
		cout << (b[mid] + b[mid2]) - (a[mid] + a[mid2]) + 1 << '\n';
	}
}


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

int comp1(const void * a,const void * b)
{
  if(*(const int *)a > *(const int *)b)
    return(-1);
  if(*(const int *)a < *(const int *)b)
    return(1);
  
  return(0);
}
int comp2(const void * a,const void * b)
{
  if(*(const int *)a < *(const int *)b)
    return(-1);
  if(*(const int *)a > *(const int *)b)
    return(1);
  
  return(0);
}

int main(void)
{
  int n, m, X, Y, x[100], y[100];
  int i;
  
  scanf("%d %d %d %d",&n, &m, &X, &Y);
  for(i = 0; i < n; i++)
    scanf("%d", &x[i]);
  for(i = 0; i < m; i++)
    scanf("%d", &y[i]);
  
  qsort(x, (size_t)n, sizeof(int), comp1);
  qsort(y, (size_t)m, sizeof(int), comp2);
  
  if(x[0] < y[0] && x[0] < Y && y[0] > X)
    printf("No War\n");
  else
    printf("War\n");
  
  
  
  return 0;
}

Measured memory_bytes: 128
#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 == 1) {
        a = 14;
    }
    if (b == 1) {
        b = 14;
    }
    if (a < b) {
        cout << "Bob" << endl;
    } else if (a > b) {
        cout << "Alice" << endl;
    } else {
        cout << "Draw" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define PQ priority_queue<vector<ll>,vector<vector<ll>>,greater<vector<ll>>>
using ll = long long;
const ll INF=1e18;
const ll maxS = 3000;
 
map<int, ll> dij(int f,ll s, ll n, vector<vector<vector<ll>>>& edge){
  map<int, ll> mintime;
  vector<vector<ll>> mincost(maxS+5, vector<ll>(n, INF));
  s = min(s,maxS);
  mincost[s][f] = 0;
  
  PQ pq;
  pq.push({mincost[s][f], s, f});
  
  while(!pq.empty()){
    vector<ll> now=pq.top(); pq.pop();
	if(!mintime.count(now[2])) mintime[now[2]] = now[0];
    if((ll)mintime.size()==n) return mintime;
    
    vector<vector<ll>>& v = edge[now[2]];
    ll l = v.size();
    
    rep(i, l){
      ll nextS=min(now[1]+v[i][1], maxS);
      if(nextS < 0) continue;
 
      if(mincost[nextS][v[i][0]] <= now[0] + v[i][2]) continue;
      mincost[nextS][v[i][0]] = now[0] + v[i][2];
	  pq.push({mincost[nextS][v[i][0]], nextS, v[i][0]});
    }
  }
}
 
int main(){
  int n, m; cin >> n >> m;
  ll s; cin >> s;
 
  vector<vector<vector<ll>>> edge(n);  
  rep(i, m){
    int u, v; cin >> u >> v; 
    ll a, b;  cin >> a >> b;
    u--, v--;
    edge[u].push_back({v, -a, b});
    edge[v].push_back({u, -a, b});
    }
  rep(i, n){
    ll c, d; cin >> c >> d;
    edge[i].push_back({i, c, d});
  }
 
map<int, ll> mintime =  dij(0, s, n, edge);
  for(auto p : mintime){
    if(p.first == 0) continue;
    cout << p.second << endl;
  }
  return 0;
}

Measured memory_bytes: 9636
#include<stdio.h>

int main()
{
	int x,y,size;
	int a[14][14]={0};
	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF)
	{
		if(x>=10||x<0||y>=10||y<0||size>3||size<=0)
		{
		}
		else
		{
			x+=2;
			y+=2;
			if(size==1)
			{
				a[x][y]++;
				a[x][y+1]++;
				a[x][y-1]++;
				a[x+1][y]++;
				a[x-1][y]++;
			}
			else if(size==2)
			{
				int n,m;
				n=x-1;
				for(n;n<=x+1;n++)
				{
					m=y-1;
					for(m;m<=y+1;m++)
					{
						a[n][m]++;
					}
				}
			}
			else if(size==3)
			{
				int n,m;

				a[x][y+2]++;
				a[x][y-2]++;
				a[x+2][y]++;
				a[x-2][y]++;

				n=x-1;
				for(n;n<=x+1;n++)
				{
					m=y-1;
					for(m;m<=y+1;m++)
					{
						a[n][m]++;
					}
				}
			}
		}
	}

	int zero=0,max=0;
	for(x=2;x<12;x++)
	{
		for(y=2;y<12;y++)
		{
			if(a[x][y]==0)
			{
				zero++;
			}
			if(a[x][y]>max)
			{
				max=a[x][y];
			}
		}
	}
	printf("%d\n%d\n",zero,max);
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<int> arr;
    int cur;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        arr.push_back(cur);
    }

    int ans = 1;
    int prev = arr[0];
    for (int j = 1; j < N; j++) {
        bool ok(true);
        for (int k = 0; k < j; k++) {
            if (j != k && arr[j] >= arr[k]) {
            } else {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

    int n, h, w;
    cin >> n >> h >> w;

    int cnt = 0;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if(a >= h && b >= w){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i, b, n) for(int i=b;i<(int)n;i++)
#define rep(i, n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it, o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;

//ハマったらチェックリスト見ろ!!

int main() {
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i, N)cin >> V[i];
    int cnt  =0;
    REP(i, 1, N){
        if(V[i-1] == V[i]){
            cnt++;
            V[i] = -1;
        }
    }
    cout << cnt <<endl;
    return 0;
}

Measured memory_bytes: 888
(* エラトステネスのふるい *)
let sieve :
  (* 素数かどうかを判定する自然数の上界 *)
  int ->
  (* 素数ならtrueを返す関数 *)
  (int -> bool)
  = fun n ->
    let a = Array.make n true in
    a.(0) <- false;
    a.(1) <- false;
    for p = 2 to int_of_float @@ ceil @@ sqrt @@ float_of_int n do
      if a.(p) then
        for i = p to (n - 1) / p do
          a.(p * i) <- false
        done
    done;
    Array.get a
 
let rec take n = function
  | [] -> []
  | x :: xs ->
      if n = 0 then []
      else x :: take (n - 1) xs
 
let () = Scanf.scanf "%d\n" @@ fun n ->
  let p = sieve 55555 in
  Array.init 55555 (fun i -> i)
  |> Array.to_list
  (*
   * (5i + 1) + (5j + 1) + (5k + 1) + (5l + 1) + (5m + 1) 
   * = 5 (i + j + k + l + m + 1)
   *)
  |> List.filter (fun n -> n mod 5 = 1 && p n)
  |> take n
  |> List.iter (Printf.printf "%d ")

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  set<int> st;
  int a;
  rep(i, 3) cin >> a, st.insert(a);
  cout << st.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    string s,t;cin>>s>>t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    reverse(t.begin(),t.end());

    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    cout << (sum - n) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	unsigned int A,B,C,D;
	int area1=0;
	int area2=0;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	area1=A*B;
	area2=C*D;
	if(area1>area2)
	printf("%d",area1);
	else if(area1<area2)
	printf("%d",area2);
	else
	printf("%d",area2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n - 1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n, int k) {
	//nのk桁目
	rep(i, k - 1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int binary(int n) {
	//10進数→2進数
	int ans = 0;
	for (int i = 0; n > 0; i++) {
		ans += n % 2 * intpow(10, i);
		n /= 2;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int N,ans=0;
	cin >> N;
	ans += (N / 500) * 1000;
	N %= 500;
	ans += (N / 5) * 5;
	cout << ans;
}

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if (e - a > k){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!";
  }
    
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
 
using namespace std;
 
bool ok(string s) {
  if (s[0] != 'A') return false;
  if (count(s.begin() + 2, s.end() - 1, 'C') != 1) return false;
  for (char c : s) {
    if (c != 'A' && c != 'C' && isupper(c)) return false;
  }
  return true;
}
 
int main() {
  string s;
  cin >> s;
  cout << (ok(s) ? "AC" : "WA") << endl;
}

Measured memory_bytes: 256
s = gets.chomp
n = s.size


if s == s.reverse
  n_1_helf = (n-1)/2-1
  txt = s[0..n_1_helf]
  if txt == txt.reverse
    n_3_half = (n+3)/2-1
    foo_txt = s[n_3_half..-1]
    if foo_txt == foo_txt.reverse
      puts 'Yes'
    else
      puts 'No'
    end
  else
    puts 'No'
  end
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int infint = 1e9;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e3 + 7;
ll n, m;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	ll ans = 0;
	for (int i = m + 1; i <= n; i++)
	{
		//[m, i - 1], [m + i, 2 * i - 1], [m + 2 * i, 3 * i - 1], ...
		ll T = (n + 1) / i, D = 0;
		D += T * (i - m);
		if((n + 1) % i)
			D += max(0LL, n - (m + T * i) + 1);
		ans += D;
	}
	if(m == 0)
		ans -= n;
	cout << ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

def f(num):
    global count
    while num%2==0:
        num=num//2
        count+=1


n=int(input())
A=list(map(int,input().split()))
count=0
for a in A:
    f(a)
print(count)


Measured memory_bytes: 42092
<?php
  list($n, $q) = explode(" ", trim(fgets(STDIN)));

  $tree = [];
  $pointTree = [];

  for ($i=0; $i<$n-1; $i++) {
    $pointTree[$i+1] = 0;
    list($a, $b) = explode(" ", trim(fgets(STDIN)));
    $tree[$a][$b] = $b;
    $tree[$b][$a] = $a;
  }
  $pointTree[$n] = 0;
  for ($i=0; $i<$q; $i++) {
    list($p, $x) = explode(" ", trim(fgets(STDIN)));
    $pointTree[$p] += $x;
  }

  f($tree, $pointTree, 1, 0);

  echo implode(" ", $pointTree);

  function f($tree, &$pointTree, $node, $parentNode){
    $pointTree[$node] += $pointTree[$parentNode];
    $parts_tree = $tree[$node];
    foreach($parts_tree as $node2){
      if($node2 == $parentNode){
        continue;
      }
      f($tree, $pointTree, $node2, $node);
    }
  }



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

int main () {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i=1; i<100; i++) {
		if (a*i%b==c) {
			cout << "YES"; return 0;
		}
	}
	cout << "NO";
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n,a,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		sum+=a;
	}
	if(sum%2==0) cout<<"YES";
	else cout<<"NO";
	cout<<endl;
	return 0;
}



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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

ll n,a,b,c,m;


ll moddiv(ll a,ll b,ll c){
	ll x0=c;
	ll x1=b;
  ll x2;
	ll n0=0LL;
	ll n1=1LL;
  ll n2;
	ll t=a%b;
  ll m;
  ll ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=n0-m*n1;
      n2%=c;
      if (x2==1){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;
      x1=x2;
      n0=n1;
      n1=n2;
    }
	ans=a+((t*ans)%c)*b-t;
	return ans/b;
}
//剰余の割ざん

ll expmod(ll a,ll n,ll c){
  ll ans=1LL;
  ll aa=a;
  ll beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1){
      ans=(ans*aa)%c;
    }
    aa=(aa*aa)%c;
    beki/=2;
    if (beki==0)break;
  }

  return ans;
}

int main(){
  cin>>n>>a>>b>>c;
  m=1000000007LL;
  ll ans_A=1LL;
  ll ans_B=1LL;
  ll bunsi=0LL;
  ll bunbo=0LL;
  ll aa=a;
  ll bb=b;
  a=moddiv(aa,aa+bb,m);
  b=moddiv(bb,aa+bb,m);

  REP(i,n-1){
    bunsi=((n+(n-1-i))*ans_A)%m;
    bunsi=(bunsi*b)%m;
    bunbo=((n-1-i))%m;
    ans_A=moddiv(bunsi,bunbo,m)+1;
  }
  ans_A=ans_A*n%m;
  ll an=expmod(a,n,m);
  ans_A=ans_A*an%m;
  //ans_A=moddiv(ans_A,expmod(100LL,n,m),m);


  REP(i,n-1){
    bunsi=((n+(n-1-i))*ans_B)%m;
    bunsi=(bunsi*a)%m;
    bunbo=((n-1-i))%m;
    ans_B=moddiv(bunsi,bunbo,m)+1;
  }
  ans_B=ans_B*n%m;
  ll bn=expmod(b,n,m);
  ans_B=ans_B*bn%m;
  //ans_B=moddiv(ans_B,expmod(100LL,n,m),m);

  ll ans=(ans_A+ans_B)%m;
  ans=ans*100LL%m;
  ans=moddiv(ans,aa+bb,m);
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {// Main
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int cap = sc.nextInt();
		int max_val = 100000;
		int []w = new int[n];
		int[] v = new int[n];
		
		for(int i= 0 ;i < n;i++) {
			w[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		
		int[][]dp  = new int[n+1][max_val+1];
		for(int [] k : dp)
		Arrays.fill(k, -1);
		dp[0][0]=0;
		for(int j = 1 ;j <= n;j++) {
			int val = v[j-1];
			int wei = w[j-1];
			for(int i =0  ;i <= max_val ; i++) {
				if(i==0) {dp[j][i]=0;continue;}
				int temp = Integer.MAX_VALUE;
				if(i >=val && dp[j-1][i-val]!=-1 && (long)dp[j-1][i-val] + (long)wei <=cap )
					temp = (int) (dp[j-1][i-val]+wei);
				
				if(dp[j-1][i]!=-1)temp = Math.min(dp[j-1][i], temp);
				if(temp!= Integer.MAX_VALUE)
				dp[j][i] = temp ; 
			}
		}
		
		int ans = 0 ;
		for(int i = max_val ; i>=0 ;i--)if(dp[n][i]!=-1) {ans=i;break;} 
  System.out.println(ans);
	}

}

Measured memory_bytes: 85764
//Your limitation—it’s only your imagination
#include <bits/stdc++.h>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) x.size()

//Dream it. Wish it. Do it

// 1/b%mod=b^(m-2)%mod

typedef double db;
typedef long long ll;

//Never forget health

const ll ary=1e5+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
ll a,b;
map<ll,ll> mp;
vector<ll> q;
int main(){
	cin>>a>>b;
	for(int i=1;i<=sqrt(a);i++){
		if(a%i==0){
			mp[i]=1;
			if(i*i!=a){
				mp[a/i]=1;
			}
		}
	}
	for(int i=1;i<=sqrt(b);i++){
		if(b%i==0){
			if(mp[i]){
				q.putb(i);
			}
			if(i*i!=b){
				if(mp[b/i]){
					q.putb(b/i);
				}
			}
		}
	}
	sort(full(q));
	ll lcm=1,ans=1;	
	for(int i=1;i<len(q);i++){
		if(__gcd(lcm,q[i])==1){
			ans++;
			lcm=lcm*q[i]/__gcd(q[i],lcm);
		}		
	}
	cout<<ans;
}
//Push yourself, because no one else is going to do it for you


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int p = a.back();
    if (p % 2){
        int ok = n;
        int ng = - 1;
        while (abs(ok - ng) > 1){
            int mid = (ok + ng) / 2;
            if (a[mid] >= p / 2) ok = mid;
            else ng = mid;
        }
        if (ok + 1 == n) ok--;
        int ok2 = n;
        int ng2 = - 1;
        while (abs(ok2 - ng2) > 1){
            int mid2 = (ok2 + ng2) / 2;
            if (a[mid2] >= p / 2 + 1) ok2 = mid2;
            else ng2 = mid2;
        }
        if (ok2 + 1 == n) ok2--;
        int x, y;
        if (ok - 1 >= 0 && a[ok] - p / 2 > p / 2 - a[ok - 1]) x = a[ok - 1];
        else x = a[ok];
        if (ok2 - 1 >= 0 && a[ok2] - p / 2 - 1 > p / 2 + 1 - a[ok2 - 1]) y = a[ok2 - 1];
        else y = a[ok2];
        if (abs(x - p / 2) > abs(y - p / 2 - 1)) cout << p << " " << y << endl;
        else cout << p << " " << x << endl;
    }
    else{
        int ok = n;
        int ng = - 1;
        while (abs(ok - ng) > 1){
            int mid = (ok + ng) / 2;
            if (a[mid] >= p / 2) ok = mid;
            else ng = mid;
        }
        if (ok + 1 == n) ok--;
        if (ok - 1 >= 0 && a[ok] - p / 2 > p / 2 - a[ok - 1]) cout << p << " " << a[ok - 1] << endl;
        else cout << p << " " << a[ok] << endl;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;

using Edge = pair<ll,ll>;  //　1つ目は結んでいるノード、2つ目はその辺の重みを指す
using Graph = vector<vector<Edge> >;  //隣接リスト

bool bellman(const Graph &G, vl &dist, ll s){
  ll V = (ll)G.size();
  rep(i,V) dist[i] = INF;
  dist[s] = 0;
  rep(c,V){
    bool update = false;
    rep(i,V){
      for(auto e : G[i]){
        if(dist[i] != INF && dist[e.first] > dist[i] + e.second){
          dist[e.first] = dist[i] + e.second;
          update = true;
          if(c == V-1) return true;
        }
      }
    }
    if(!update) break;
  }
  return false;
}

  
int main() {
  ll n,m;
  cin >> n >> m;
  Graph G(n),G_dual(n);
  rep(i,m){
    ll a,b,c;
    cin >> a >> b >> c;
    G[a-1].push_back(Edge(b-1,-c));
    G_dual[b-1].push_back(Edge(a-1,-c));
  }
  bool x,y;
  vl dist(n), dist_dual(n);
  x = bellman(G,dist,0);
  y = bellman(G_dual,dist_dual,n-1);
  if(x && y){
    cout << "inf";
    return 0;
  }
  
  cout << -dist[n-1];
 return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>

typedef long long ll;

const int N = 2e5;

std::vector<int> g[N];
ll ans[N];

void dfs(int v, int p)
{
    for (int u : g[v])
    {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main()
{
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i < n; ++i)
    {
        static int u, v;
        scanf("%d%d", &u, &v);
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    while(q--)
    {
        static int v, x;
        scanf("%d%d", &v, &x);
        --v;
        ans[v] += x;
    }

    dfs(0, -1);

    for (int i = 0; i < n; ++i)
        printf("%lld ", ans[i]);
}


Measured memory_bytes: 24192
def merge_count(left, right)
    return 0 if left+1 >= right
    
    mid = (left + right)/2
    return right - left + merge_count(left, mid) + merge_count(mid, right)
end

N=gets.to_i
puts gets.chomp.split(" ").map(&:to_i).sort.join(" ")
puts merge_count(0, N)


Measured memory_bytes: 58248
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int a = in.ni(), b = in.ni(), c = in.ni(), d = in.ni(), e = in.ni(), f = in.ni();
        int max_sum = 0, max_sugar = 0;
        for (int i = 0; i <= f/(100*a); i++) {
            int water = i*100*a;
            int sugar_limit = water/100*e;
            while(water<=f){
                for (int j = 0; j*c<=sugar_limit&&(water+j*c)<=f; j++) {
                    int sugar = j*c + Math.min((sugar_limit-j*c)/d*d,(f-water-j*c)/d*d);
                    if(sugar*max_sum >= max_sugar*(water+sugar)){
                        max_sum = water + sugar;
                        max_sugar = sugar;
                    }
                }
                water += 100*b;
            }
        }
        out.printf("%d %d", max_sum, max_sugar);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21460
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		long x=nextLong();
		long ans=(x/11)*2;
		x=x%11;
		if(x>0)
			ans+=x<=6?1:2;
		out.println(ans);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  int64_t cnt = X / D;
  if(cnt >= K){
    cout << X - K*D << endl;
    return 0;
  }
  else{
    K -= cnt;
    X -= D*cnt;
    if(K %2 == 0){
      cout << X << endl;
    }
    else{
      cout << abs(X - D) << endl;
    }
  }
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N; string S;

int main() {
  io();
  cin >> N >> S;
  bool is = true;
  fori(i, N/2-1) {
    if(S[i] != S[i+(N/2)]) {
      is = false;
    }
  }
  if(N%2==1) cout << "No";
  elif(N == 2 && S[0] == S[1]) cout << "Yes";
  elif(N == 2 && S[0] != S[2]) cout << "No";
  elif(is) cout << "Yes";
  else cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 5000001
#define NIL -2000000001

int key[MAX],n;

int parent(int p){
  return p/2;
}

int right(int p){
  return 2*p+1;
}

int left(int p){
  return 2*p;
}

void maxHeapify(int key[],int p){
  int l,r,largest=NIL,temp;
  l = left(p);
  r = right(p);
 
  if(l <= n && key[l]>key[p]) largest = l;
  else largest = p;
  if(r<= n && key[r]>key[largest]) largest = r;
  if(largest != p){
    temp = key[p];
    key[p] = key[largest];
    key[largest] = temp;
    maxHeapify(key,largest);
  }
  
}

void buildMaxHeap(int key[]){
  int i;
  for(i = n/2; i > 0; i--){
    maxHeapify(key,i);
  }
}

int main(){
  int i,v;

  scanf("%d",&n);

  for ( i = 0; i < MAX; i++ ){
    key[i] = NIL;
  }

  for ( i = 1; i <= n; i++ ){
    scanf("%d", &v);
    key[i] = v;
    }


    buildMaxHeap(key);

    for(i = 1; i <= n; i++ ){   
    printf(" %d",key[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 20128
#include <iostream>

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

  for (int i = 0; i < s.size(); i += 2) {
    if (s.substr(i, 2) != "hi") {
      std::cout << "No" << std::endl;
      return 0;
    }
  }

  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 888
def main():
    h, w = map(int, input().split())
    l = [input() for i in range(h)]
    
    row = [False]*h
    col = [False]*w

    for i in range(h):
        for j in range(w):
            if l[i][j] == '#':
                row[i] = True;
                col[j] = True;

    for i in range(h):
        if row[i]:
            for j in range(w):
                if col[j]:
                    print(l[i][j], end='')
            print()
      
   

    

if __name__=='__main__':
    main()

Measured memory_bytes: 4468
using System;

class B{
  public static void Main(){
    string[] Ar = Console.ReadLine().Split(' ');
    bool ans = false;
    for (int i = int.Parse(Ar[0]);i >= 0 ;i--){
      int j = int.Parse(Ar[0]) - i;
        int TuAsi = i * 2;
        int KaAsi = j * 4;
        int Ashi = TuAsi + KaAsi;
        if (Ashi == int.Parse(Ar[1])){
          ans = true;
        }
      
    }
    if (ans == true) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}


Measured memory_bytes: 17876
from collections import deque
INF = 10**6
n = int(input())
path = {}
for i in range(n-1):
    a, b = list(map(int, input().split()))
    if not a in path.keys():
        path[a] = [b]
    else:
        path[a].append(b)
    if not b in path.keys():
        path[b] = [a]
    else:
        path[b].append(a)
# print(path)

dist_f = [INF]*(n+1)
dist_f[1] = 0
que_f = deque([1])
while len(que_f) > 0:
    st_f = que_f.popleft()
    for en_f in path[st_f]:
        if dist_f[en_f] == INF:
            dist_f[en_f] = dist_f[st_f]+1
            que_f.append(en_f)

dist_s = [INF]*(n+1)
dist_s[n] = 0
que_s = deque([n])
while len(que_s) > 0:
    st_s = que_s.popleft()
    for en_s in path[st_s]:
        if dist_s[en_s] == INF:
            dist_s[en_s] = dist_s[st_s]+1
            que_s.append(en_s)
# print(dist_f, dist_s)

count_f, count_s = 0, 0
for d_f, d_s in zip(dist_f[1:], dist_s[1:]):
    if d_f <= d_s:
        count_f += 1
    else:
        count_s += 1
if count_f > count_s:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 42556
N=int(input())
l=list(map(int,input().split()))
l2=sorted([num for num in l if num<0])
l3=sorted([num for num in l if num>=0])
if len(l2)%2==0:
  ans=sum([abs(n) for n in l])

elif l3!=[]:
  if abs(l2[-1]) < l3[0]:
    x=l2.pop()
  else:
    x=l3.pop(0)
  ans=sum([abs(n) for n in l2])+sum(l3)-abs(x)
else:
  x=l2.pop()
  ans=sum([abs(n) for n in l2])-abs(x)
print(ans)

Measured memory_bytes: 14496