akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    string s; cin >> s;
    vbool v(26, false);
    rep(i, s.size()){
        v[s[i] - 'a'] = true;
    }
    // prvec(v);

    string ans;
    if(s.size()<26){
        rep(i, 26){
            if(v[i]) continue;
            ans = s + char(i+'a');
            pr(ans);
            return 0;
        }
    }else{
        for(int i=25; i>=0; i--){
            FOR(j, s[i]-'a'+1, 26){
                if(!v[j]){
                    rep(k, i) cout << s[k];
                    cout << char(j+'a');
                    cout << endl;
                    return 0;
                }
            }
            v[s[i] - 'a'] = false;
        }
    }

    pr(-1);
    return 0;}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std ;

int num = 1000000007 ;

long long int num_paths(vector<vector <char> > a){
    int H = a.size(), W = a[0].size() ;
    
    vector<vector<long long int> > dp(H+1, vector<long long int>(W+1, 0)) ;
    
    for (int i=1 ; i<=H ; i++){
        for (int j=1 ; j<=W ; j++){
            if (a[i-1][j-1] == '#')
                dp[i][j] = 0 ;
            else if (i==1 && j==1){
                dp[i][j] = 1 ;
            }
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % num ;
        }
    }
    
    return dp[H][W] ;
}

int main(){
    int H, W ;
    cin >> H >> W ;
    
    vector<vector <char> > a (H, vector<char> (W, '.')) ;
    
    for (int i=0 ; i<H ; i++){
        for (int j=0 ; j<W ; j++)
            cin >> a[i][j] ;
    }
    
    cout << num_paths(a) << "\n" ;
    
    return 0 ;
}


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

int main() {
  int r[100];
  for (int i=0; i<100; i++) r[i] = 0;
  int n;
  while (cin >> n) {r[n-1]++; if(n==0)break;}
  int maxValue = -1;
  for (int i=0; i<100; i++) if (r[i] > maxValue) maxValue = r[i];
  for (int i=0; i<100; i++) if (r[i] == maxValue) cout << i+1 << endl;
  return 0;
}


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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int n; cin >> n;
	// you can't do t(n){}; 
	vector<int> t(n+1);t.at(0) = 0;
	vector<int> x(n+1);t.at(0) = 0;
	vector<int> y(n+1);t.at(0) = 0;
	for(int i = 0, i_len = n; i < i_len; ++i){
		cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
	}

	bool can = true;
	for(int i = 0, i_len = n; i < i_len; ++i){
		int dt = t[i+1] - t[i];
		int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
		if(dt < dist) can = false;
		if(dist % 2 != dt % 2) can = false;
	}

	if(can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#define LEN 100005


typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void initialize(){
  head = 0;
  tail = 0;
}

void enqueue(P x){
  Q[tail] = x;
  if(tail+1==LEN) tail = 0;
  else tail++; 
}

P dequeue(){
  P x;
  x = Q[head];
  if(head+1==LEN) head=0;
  else head++;
  return x;
}


int main(){
  int elaps = 0, c=0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  tail = n;
  while(head != tail){
    u = dequeue();
    if(u.t-q<=0){
      elaps +=u.t;
      u.t = 0; 
      printf("%s %d\n",u.name,elaps);
    }else if(u.t-q>0){
      elaps+=q;
      u.t-=q;
      enqueue(u);
    }
  }
  return 0;
}

Measured memory_bytes: 10756
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()
sl = []

for i in range(len(s)):
    sl.append(s[i])

for i in range(97, 123):
    if chr(i) not in sl:
        print(chr(i))
        exit()

print("None")


Measured memory_bytes: 73732
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<62);

using namespace std;
vi *g;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, m; cin >> n >> m;
	g = new vi[n+1];
	f(i, m){
		int a, b; cin >> a >> b;
		g[a].pb(b);
	}

	vi sc;
	fo(i, 1, n+1){
		vi p(n+1, 0);
		queue<int> q;
		q.push(i);
		p[i] = -1;
		vi c;
		while(!q.empty()){
			int t = q.front();
			q.pop();
			vi &adj = g[t];
			for(auto k : adj){
				if(p[k] == 0){
					p[k] = t;
					q.push(k);
				}else if(k == i){
					c.pb(k);
					while(t != i){
						c.pb(t);
						t = p[t];
					}
					if(sz(sc) == 0 || sz(c) < sz(sc)){
						sc = c;
					}
					c.clear();
					while(!q.empty()) q.pop();
					break;
				}
			}
		}
	}
	if(sz(sc)){
		cout << sz(sc) << endl;
		f(i, sz(sc)) cout << sc[i] << endl;
	}else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N;
	size_t A, B;

	size_t count[3] = { 0, 0, 0 };

	scanf("%zu\n%zu %zu\n", &N, &A, &B);
	for (size_t i = 0; i < N; i++) {
		size_t P;
		scanf("%zu", &P);
		if (i < N - 1) {
			scanf(" ");
		}

		if (P <= A) {
			count[0]++;
		}
		else if (P <= B) {
			count[1]++;
		}
		else {
			count[2]++;
		}
	}

	printf("%zu\n", MIN(count[0], MIN(count[1], count[2])));

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n % 2){
            res = (res * x) % MOD;
        }
        x = (x * x) % MOD;
        n = n / 2;
    }
    return res;
}

int main()
{
    ll n;
    cin >> n;
    ll a[100001];
    ll b[100001] {0};
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[a[i]]++;
    }
    if(n % 2){
        bool f = true;
        if(b[0] != 1){
            f = false;
        }
        for(int i = 2; i < n; i += 2){
            if(b[i] != 2){
                f = false;
            }
        }
        if(!(f)){
            cout << 0 << endl;
            return 0;
        }
    }
    else{
        bool f = true;
        for(int i = 1; i < n; i += 2){
            if(b[i] != 2){
                f = false;
            }
        }
        if(!(f)){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << modpow(2, n / 2) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
#define EPS 1e-6
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, m = 32;
    ifstream ifs("in.txt");
    while (cin >> n && n){
        int f[50][32] = {};
        REP(i,n){
            int a;
            cin >> a;
            while (a--){
                int x;
                cin >> x;
                f[i][x-1] = 1;
            }
        }
        bool imp = 1;
        VL dp(n);
        REP(i,n) dp[i] = 1LL<<i;
        REP(j,m){
            ll x = 0;
            REP(i,n){
                if (f[i][j]) x |= dp[i];
            }
            REP(i,n){
                if (f[i][j]) dp[i] = x;
            }

            if (x == (1LL<<n)-1){
                cout << j+1 << endl;
                imp = 0;
                break;
            }
        }
        if (imp) cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
from collections import Counter
N = int(input())
c = Counter()
for n in range(2, N + 1):
    i = 2
    while i**2 <= n:
        count = 0
        while n % i == 0:
            n //= i
            count += 1
        if count != 0:
            c[i] += count
        i += 1
    if n > 1:
        c[n] += 1

d = Counter()
for v in c.values():
    if 2 <= v:
        d["3"] += 1
    if 4 <= v:
        d["5"] += 1
    if 14 <= v:
        d["15"] += 1
    if 24 <= v:
        d["25"] += 1
    if 74 <= v:
        d["75"] += 1

ans = 0
ans += d["75"]
ans += (d["5"] - 1) * d["15"]
ans += (d["3"] - 1) * d["25"]
ans += (d["3"] - 2) * d["5"] * (d["5"] - 1) // 2
print(ans)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)
const int INF = 1001001001;
int n, u, k;
int D[100],F[100];
vector<int> edges[100];
int tim = 0;

void dfs(int cur) {
	if (D[cur] == INF) {
		tim += 1;
		D[cur] = tim;//タイムスタンプ押印
	}	
	for (int dst = 0; dst < n; dst++) {
		vector<int>::iterator result = find(edges[cur].begin(), edges[cur].end(), dst);
		if (result != edges[cur].end() && D[dst] == INF) dfs(dst);
	}
	tim += 1;
	F[cur] = tim;
		 //タイムスタンプ押印		
}

int main() {
	cin >> n; //n頂点


	for (int i = 0; i < n; i++)//iは頂点
	{
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			int l;
			cin >> l;
			edges[u - 1].push_back(l - 1);
		}//入力終わり
		D[i] = INF;
		F[i] = INF;		
	}
	for (int p = 0; p < n; p++) {
		if(D[p]==INF)dfs(p);//未訪問ならばッてこと
	}
	
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << D[i] <<" "<<F[i]<< endl;		
	}
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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


    int a; cin>>a;
    if (a<1200) out("ABC");
    if (a<2800) out("ARC");
    out("AGC");

    return 0;
}


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

const int INF = 1001001001;

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> war(m);
  for(int i=0;i<m;i++){
    int ab; cin >> ab;
    war.at(i).first = ab;
    cin >> ab;
    war.at(i).second = ab;
  }
  sort(war.begin(),war.end());
  int left = 0 ,right = 10e5;
  int count = 0;
  for(int i=0;i<m;i++){
    left = max(left,war.at(i).first);
    right = min(right,war.at(i).second);
    if(right - left <= 0){
      count++;
      left = war.at(i).first;
      right = war.at(i).second;
    }
  }
  cout << count+1 << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<char> S(N);
  vector<int> V(N);
  for (int i = 0; i < N; i++){
    cin >> S[i] >> V[i];
  }
  vector< vector<char> > O(9, vector<char>(4));
  vector<int> C(9, 0);
  for (int i = 0; i < N; i++){
    O[V[i] - 1][C[V[i] - 1]] = S[i];
    C[V[i] - 1]++;
  }
  vector<char> BS(N);
  vector<int> BV(N);
  for (int i = 0; i < N; i++){
    BS[i] = S[i];
    BV[i] = V[i];
  }
  for (int i = 0; i < N; i++){
    for (int j = N - 1; j > i; j--){
      if (BV[j] < BV[j - 1]){
        swap(BS[j], BS[j - 1]);
        swap(BV[j], BV[j - 1]);
      }
    }
  }
  for (int i = 0; i < N; i++){
    cout << BS[i] << BV[i];
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
  bool stable;
  stable = true;
  vector<int> BC(9, 0);
  for (int i = 0; i < N; i++){
    if (O[BV[i] - 1][BC[BV[i] - 1]] != BS[i]){
      stable = false;
    }
    BC[BV[i] - 1]++;
  }
  if (stable){
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  vector<char> SS(N);
  vector<int> SV(N);
  for (int i = 0; i < N; i++){
    SS[i] = S[i];
    SV[i] = V[i];
  }
  for (int i = 0; i < N; i++){
    int m = i;
    for (int j = i; j < N; j++){
      if (SV[j] < SV[m]){
        m = j;
      }
    }
    swap(SS[i], SS[m]);
    swap(SV[i], SV[m]);
  }
  for (int i = 0; i < N; i++){
    cout << SS[i] << SV[i];
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
  stable = true;
  vector<int> SC(9, 0);
  for (int i = 0; i < N; i++){
    if (O[SV[i] - 1][SC[SV[i] - 1]] != SS[i]){
      stable = false;
    }
    SC[SV[i] - 1]++;
  }
  if (stable){
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y;
    cin>>x>>y;
    if(y>4*x || y<2*x)
    {
        cout<<"No";
        return 0;
    }
    if(y%4==0 || y%4==2)
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";


    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
//author_name:kaban5 
//date:2018/11/18
//title:AGC 010 E Rearranging
//因为怯懦，所以逃避生命，以不抵抗在最黑暗的沉沦中生出骄傲，因为骄傲，所以不选择生，所以拒斥粗鄙的乐观主义。
//天才的悲剧地于被小而舒适的名望所束缚。
//It's human to lie. Most of the time we can't even be honest with ourselves.

bool used[2020];
vector<int> g[2020];
int a[2020];
int n;

inline vector<int> combine(vector<int> a,vector<int> b)
{
	vector<int> l=a,r=b;
	if(l.empty()||r.empty())
		return l.empty()?r:l;
	vector<int> ret(l.size()+r.size());
	merge(a.begin(),a.end(),b.begin(),b.end(),ret.begin(),greater<int> ());
	return ret;
}

vector<int> dfs(int u)
{
	used[u]=true;
	vector<int>ret;
	for(int i:g[u]) if(!used[i])
	{
		ret=combine(ret,dfs(i));
	}
	ret.insert(ret.begin(),u);
	return ret;
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	sort(a,a+n);
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			if(__gcd(a[i],a[j])>1)
			{
				g[i].push_back(j);
				g[j].push_back(i);
			}
	vector<int> ret;
	for(int i=0;i<n;i++) if(!used[i])
	{
		ret=combine(ret,dfs(i));
	}
	for(int i=0;i<n;i++)
		printf("%d ",a[ret[i]]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 17152
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    popcount_to_state = [[] for _ in range(n + 1)]
    for U in range(1 << n):
        popcount_to_state[bin(U).count('1')].append(U)

    dp = [0] * (1 << n)
    dp[0] = 1
    for i in range(n):
        A = tuple(map(int, input().split()))
        for j in range(n):
            if not A[j]:
                continue
            for U in popcount_to_state[i]:
                if (U >> j) & 1:
                    continue
                nU = U | 1 << j
                dp[nU] += dp[U]
                if dp[nU] >= MOD:
                    dp[nU] -= MOD
    print(dp[-1])
resolve()

Measured memory_bytes: 131012
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    a = sorted(LI(), reverse=True)
    alice = 0
    for i in range(0, n, 2):
        alice += a[i]
    print(2 * alice - sum(a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 69356
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)
#define read(x) scanf("%d", &x)
#define readv(x, n) vll x(n); forn(i,0,n) scanf("%lld", &x[i])

#define pb push_back
#define mp make_pair
const int MAXN = 100000;
vector<int> lst[MAXN];
int parent[MAXN];

void make_set (int v) {
    lst[v] = vector<int> (1, v);
    parent[v] = v;
}

int find_set (int v) {
    return parent[v];
}

void union_sets (int a, int b) {
    a = find_set (a);
    b = find_set (b);
    if (a != b) {
        if (lst[a].size() < lst[b].size())
            swap (a, b);
        while (!lst[b].empty()) {
            int v = lst[b].back();
            lst[b].pop_back();
            parent[v] = a;
            lst[a].push_back (v);
        }
        
    }
}

int main()
{
    int n,m;
    scanf("%d %d", &n, &m);
    readv(a,n);
    forn(i,0,n) make_set(i);
    forn(i,0,m) {
        int u,v;
        scanf("%d %d", &u, &v);
        union_sets(u, v);
    }
    ll ans = 0;
    vll x;
    int cnum = 0;
    forn(i,0,n) if(!lst[i].empty()) {
        cnum++;
        vll comp;
        for(auto ind : lst[i]) comp.pb(a[ind]);
        sort(all(comp));
        ans += comp[0];
        forn(j,1,comp.size()) x.pb(comp[j]);
    }
    if(cnum == 1) {
        cout<<0;
        return 0;
    }
    sort(all(x));
    if(x.size() < cnum-2) {
        cout<<"Impossible";
        return 0;
    }
    forn(i,0,cnum-2) ans+=x[i];
    cout<<ans;
    
}


Measured memory_bytes: 10100
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

def check_even(A, B):
    odd_flag=0
    while odd_flag!=1:
        for i, num in enumerate(A):
            if num%2 == 1:
                odd_flag=1
                break
            elif i==len(A)-1:
                A=A/2
                B+=1
    return B

def main():
    print(check_even(A, 0))

if __name__ == '__main__':
    main()

Measured memory_bytes: 12424
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}


int main() {
    ll n;cin>>n;
    
    ll L[90];
    L[0]=2;
    L[1]=1;
    for(auto i=2;i<=n;i++){
        L[i] = L[i-1]+L[i-2];
    }
    
    cout<<L[n]<<endl;
    
    return 0;
}







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

using namespace std;

int main(){
	
	int n;
	cin >> n;
	
	int js = 0;
	map<string , char> mp;
	while(n--){
		string s1;
		cin >> s1;
		
		
		if(!mp.count(s1)) js++, mp[s1]++;
	}
	cout << js << endl;
	return 0;
} 

Measured memory_bytes: 19124
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(n: str):
    res = []
    for c in n:
        res.append('9' if c == '1' else '1')
    return int(''.join(res))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = (next(tokens))  # type: int
    result = solve(n)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100;
int n,ans=0;
int l[maxn*2+1];
int main()
{
	scanf("%d",&n);
	for (int i=1; i<=2*n; i++)
		scanf("%d",&l[i]);
	sort(l+1,l+2*n+1);
	for (int i=1; i<=2*n; i+=2)
		ans+=l[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// AtCoder Grand Contest 015
// C - Nuske vs Phantom Thnook

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;


const int MAX_N = 2000;
const int MAX_M = 2000;

int N, M, Q;
int nodes[MAX_N + 1][MAX_M + 1];
int edges[2][MAX_N + 1][MAX_M + 1];
bool visited[MAX_N + 1][MAX_M + 1];
int di[4] = { -1, 0, 1, 0 };
int dj[4] = { 0, 1, 0, -1 };


void bfs(int h, int w) {
    queue<pii> q;
    int i, j;

    if (nodes[h][w] == 0 || visited[h][w]) {
        return;
    }
    visited[h][w] = true;
    q.push(pii(h, w));
    while (!q.empty()) {
        i = q.front().first;
        j = q.front().second;
        q.pop();
        for (int k = 0; k < 4; k++) {
            if (i + di[k] <= N && j + dj[k] <= M &&
                    nodes[i + di[k]][j + dj[k]] == 1 && !visited[i + di[k]][j + dj[k]]) {
                edges[k % 2][max(i, i + di[k])][max(j, j + dj[k])]++;
                visited[i + di[k]][j + dj[k]] = true;
                q.push(pii(i + di[k], j + dj[k]));
            }
        }
    }

    return;
}

int main() {

    char c;
    int x1, y1, x2, y2;
    int q_nodes, q_edges;

    cin >> N >> M >> Q;
    memset(nodes, 0, sizeof(0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> c;
            nodes[i + 1][j + 1] = (c == '0' ? 0 : 1);
        }
    }

    memset(visited, 0, sizeof(visited));
    memset(edges, 0, sizeof(edges));
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            bfs(i, j);
        }
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            nodes[i][j] += nodes[i][j - 1];
            edges[0][i][j] += edges[0][i][j - 1];
            edges[1][i][j] += edges[1][i][j - 1];
        }
    }
    for (int j = 1; j <= M; j++) {
        for (int i = 1; i <= N; i++) {
            nodes[i][j] += nodes[i - 1][j];
            edges[0][i][j] += edges[0][i - 1][j];
            edges[1][i][j] += edges[1][i - 1][j];
        }
    }

    for (int q = 0; q < Q; q++) {
        cin >> x1 >> y1 >> x2 >> y2;
        q_nodes = nodes[x2][y2] - nodes[x2][y1 - 1] - nodes[x1 - 1][y2] + nodes[x1 - 1][y1 - 1];
        q_edges = edges[0][x2][y2] - edges[0][x2][y1 - 1] - edges[0][x1][y2] + edges[0][x1][y1 - 1];
        q_edges += edges[1][x2][y2] - edges[1][x2][y1] - edges[1][x1 - 1][y2] + edges[1][x1 - 1][y1];
        cout << q_nodes - q_edges << endl;
    }

    return 0;

}





Measured memory_bytes: 52608
# include <stdio.h>

int main(){
    int N;

    scanf("%d", &N);

    int ans = 0;
    int ct;
    for (int i = 105; i <= N; i++){
        ct = 2;
        if (i % 2 == 0) continue;
        else{
            for (int j = 2; j < i; j++){
                if (i % j == 0) ct++;
                if (ct > 8) break;
            }
        }
        if (ct == 8) ans++;
    }

    printf("%d", ans);

    return 0;
}

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

int main()
{
	double a,b,t;
	cin>>a>>b>>t;
	t+=0.5;
	int i=1,sum=a,rslt=0;
	while(a<=t){
		a=sum*i;
		if(a>t)break;
		rslt+=b;
		i++;
	}
	cout<<rslt<<endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

def mizu(h):
    c = 0
    if h == []:
        return 0
    else:
        c = min(h)
        h0 = list(map(lambda x : x - min(h), h))
        if h0[0] == 0:
            h0.remove(0)
            c = c + mizu(h0)
        else:
            for i in range(len(h0)):
                if h0[i] == 0:
                    h1 = h0[0:i]
                    h2 = h0[i:len(h0)]
                    break
            c = c + mizu(h1) + mizu(h2)
        return c

print(mizu(h))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main()
{
    int n;
    vl a;
    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a[i];
    ll ss = 0;
    rep(i,n) ss += a[i];

    ll as = 0;
    ss -= a[0];
    as += a[0];
    ll ans = abs(as - ss);

    rrep(i,n-2){
        ss -= a[i];
        as += a[i];
        if(ans > abs(as - ss)) ans = abs(as - ss);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
using System;

namespace ABC056C
{
    class Program
    {
        // Search a least value to reach or pass his home
        // means, get sum 1..t until greater than X or equal
        static void Main(string[] args)
        {
            int X = Int32.Parse(Console.ReadLine());
            int Y = 0;
            int t = 0;

            while (X > Y)
            {
                t++;
                Y += t;
            }

            Console.WriteLine(t);
        }
    }
}


Measured memory_bytes: 13140
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()

    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    def root(x):
        if x == par[x]:
            return x
        par[x] = root(par[x])
        return par[x]

    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

    n,a,b = LI()
    par = [i for i in range(n)]
    rank = [0]*n
    x = LI()
    for i in range(n-1):
        if a*(x[i+1]-x[i]) < b:
            unite(i,i+1)
    ans = 0
    f = [1]*n
    f[0] = 0
    for i in range(1,n):
        if f[root(i)]:
            ans += b
            f[root(i)] = 0
        else:
            ans += a*(x[i]-x[i-1])
    print(ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 60980
import java.util.*;

class Main{
	
	public static class RSQ{
		int[] data;
		
		public RSQ(int n){
			data = new int[n+1];
		}
		
		public void add(int k, int a){
			for (int i = k+1; i < data.length; i += i & -i) {
				data[i] += a;
			}
		}
		
		public int sum(int s, int t){
			if (s>0) {
				return sum(0,t)-sum(0,s);
			}
			int comp = 0;
			for (int i = t; i > 0; i -= i & -i) {
				comp += data[i];
			}
			return comp;
		}
		
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		
		RSQ rsq = new RSQ(n);
		for (int i = 0; i < q; i++) {
			int op = sc.nextInt();
			int x = sc.nextInt()-1;
			int y = sc.nextInt();
			
			if(op==0){
				rsq.add(x, y);
			}else {
				System.out.println(rsq.sum(x, y));
			}
		}
	}
	
	
}


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

using namespace std;

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

  vector<double> V;
  for (size_t i = 0; i < N; i++) {
    size_t v;
    cin >> v;
    V.emplace_back(v);
  }

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

  double result = V[0];
  for (size_t i = 1; i < V.size(); i++) {
    result = (result + V[i]) / 2;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
while(1):
    num=int(raw_input())
    if num==0:
        break
    else:
        d=[0,1,2,3,4,5,6]
        sum=1
        for i in range(num):
            dir=num=raw_input()
            if dir=="North":
                d=[0,d[2],d[6],d[3],d[4],d[1],d[5]]
            elif dir=="East":
                d=[0,d[4],d[2],d[1],d[6],d[5],d[3]]
            elif dir=="West":
                d=[0,d[3],d[2],d[6],d[1],d[5],d[4]]
            elif dir=="South":
                d=[0,d[5],d[1],d[3],d[4],d[6],d[2]]
            elif dir=="Right":
                d=[0,d[1],d[3],d[5],d[2],d[4],d[6]]
            else:
                d=[0,d[1],d[4],d[2],d[5],d[3],d[6]]
            sum=sum+d[1]
        print sum

Measured memory_bytes: 4392
import java.util.*;

public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = sc.nextInt();

        int[] arr = new int[n];

        if (s!=(int)1e9){
            for (int i=0; i<k; i++){
                arr[i] = s;
            }
            for (int i=k; i<n; i++){
                arr[i] = (int)1e9;
            }
        }else {
            for (int i=0; i<k; i++){
                arr[i] = s;
            }
            for (int i=k; i<n; i++){
                arr[i] = 1;
            }
        }

        StringBuilder sb = new StringBuilder();

        for (int i=0; i<n; i++){
            sb.append(arr[i]+" ");
        }

        String ans = sb.toString();

        System.out.println(ans);
    }
}


Measured memory_bytes: 46228
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){
  int n;
  cin >> n;
  cout << n/2+n%2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=100005;
const int mod=998244353;
const ll inf=0x3f3f3f3f3f3f3f3f;
struct zb
{
	ll st;
	ll go;
}a[200005];
struct kc
{
	int pos;
	ll ns;
};
ll dp[200005];
int cmp(zb A,zb B)
{
	return A.st<B.st;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].st,&a[i].go);
	}
	sort(a+1,a+n+1,cmp);
	dp[n+1]=1;       //清最后末尾值,即不操作机器人 
	stack <kc> s;
	kc k;
	k.ns=inf;
	k.pos=n+1;
	s.push(k);
	for(int i=n;i;i--)
	{
		while((s.top()).ns<a[i].st+a[i].go)
		{
			s.pop();
		}
		int res=(s.top()).pos;
		dp[i]=dp[res];
		dp[i]=(dp[i]+dp[i+1])%mod;
		kc k2;
		k2.pos=i;
		k2.ns=a[i].st;
		s.push(k2);
	}
	printf("%lld\n",dp[1]);
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>

using namespace std;

void solve()
{
	int m, nmin, nmax;
	while (cin >> m >> nmin >> nmax, m || nmin || nmax)
	{
		vector<int> p(m);
		for (int i = 0; i < m; ++i)
		{
			cin >> p[i];
		}
		int gap = -1;
		int ans = 0;
		for (int i = nmin - 1; i < nmax; ++i)
		{
			if (gap <= p[i] - p[i + 1])
			{
				gap = p[i] - p[i + 1];
				ans = i + 1;
			}
		}
		cout << ans << endl;
	}
}

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

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

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n>0){
        if(n&1) res = res * x % mod;
        x = x * x % mod;
        n>>=1;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    int a[n];
    int b[n]={0};
    rep(i,n){
         cin>>a[i];
         b[a[i]]++;
    }
    ll ans=0;

    if(n%2==0){
        for(int i=1;i<n;i+=2) if(b[i]!=2){
            cout<<0<<endl;
            return 0;
        }
        ans = mod_pow(2, n/2, MOD);
    }
    else{
        for(int i=2;i<n;i+=2) if(b[i]!=2){
            cout<<0<<endl;
            return 0;
        }
        ans = mod_pow(2, n/2, MOD);
    }

    cout<<ans<<endl;
}

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

int foo(int huga){
	if(huga <= 0) return 0;
	else if(huga >= 255) return 255;
	return huga;
}

int main(){
  int N, M, C[16], x, y = 128, i, j, k, l, mi, z;
  	while(1){
		int  temp[20003][256] = {}, temp3[3][256] = {}, count0 = 0, count1 = 0, count2 = 0;
		temp[0][128] = 0;
		for(i = 0; i < 3; i++)for(j = 0; j < 256; j++) temp3[i][j] = -1;
		temp3[0][count0++] = 128;
	    cin>>N>>M;
	if(N == 0 && M ==0)break;
    	for(i = 0; i < M; i++){
			cin>>C[i];
		}
		for(i = 1; i <= N; i++){
			cin>>x;
			for(j = 0; j < 256; j++)temp[i][j] = -1;
			for(j = 0; j < count0; j++){
				for(k = 0; k < M; k++){
					z = foo(C[k] + temp3[0][j]);
					if(temp[i][z] == -1){
						temp[i][z] = temp[i - 1][temp3[0][j]] + (x - z) * (x - z);
						temp3[1][count1] = z;
						count1++;
					} else {
						temp[i][z] = min(temp[i][z], temp[i - 1][temp3[0][j]] + (x - z) * (x - z));
					}
				}
			}
			for(j = 0; j < count1; j++){
				temp3[0][j] = temp3[1][j];
			}
			count0 = count1;
			count1 = 0;
		}
		
		mi = temp[N][temp3[0][0]];
		for(j = 1; j < count0; j++){
			mi = min(temp[N][temp3[0][j]], mi);
		}
		
		cout<<mi<<endl;
			
		
	}
  return 0;
}



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

using namespace std;

int main(){
    int n;
    long long int d;
    cin >> n >> d;
    long long int d2=d*d;
    int ans=0;
    for(int i=0;i<n;i++){
        long long int x,y;
        cin >> x >> y;
        long long int x2=x*x;
        long long int y2=y*y;
        long long int distance2=x2+y2;
        //cout << distance2 << endl;
        if(distance2<=d2){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	m := make(map[int]bool)
	for _, div := range Divisors(N - 1) {
		m[div] = true
	}
	for _, div := range Divisors(N) {
		if div == 1 {
			continue
		}
		if m[div] {
			continue
		}
		x := N
		for x%div == 0 {
			x /= div
		}
		x %= div
		if x == 1 {
			m[div] = true
		}
	}
	delete(m, 1)
	fmt.Println(len(m))
}

func Divisors(n int) []int {
	nums := []int{}
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			nums = append(nums, i)
			if i*i != n {
				nums = append(nums, n/i)
			}
		}
	}
	return nums
}


Measured memory_bytes: 2108
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

k = INT()
s = STR()
if len(s) <= k:
    print(s)
else:
    print(s[:k] + '...')

Measured memory_bytes: 74248
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m,k=0;
	char str[5];
	scanf("%s", str);

	if (str[0] == str[1]&&str[2] == str[1]) { printf("Yes");return 0; }
	else { k--; }
    if (str[2] == str[3]&&str[2] == str[1]) { printf("Yes");return 0; }
	else { k--; }
	printf("No");
	
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 28
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  string a,b;
  int max=0;
  for(int i=1;i<n;i++) {
    a = s.substr(0,i);
    b = s.substr(i);
    int count=0;
    vector<int> A(27,0),B(27,0);
    for(int j=0;j<a.size();j++) {
      A[a[j]-'a']++;
    }
    for(int j=0;j<b.size();j++) {
      B[b[j]-'a']++;
    }
    for(int j=0;j<A.size();j++) {
      if(A[j]>0 && B[j]>0) count++;
    }
    if(max<count) max=count;
  }
  cout << max << endl;
  return 0;
}

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

int main()
{
    int a,b;
    cin >> a >> b;
    int num;
    if(b < 10){
        num = 10*a+b;
    }else if(10 <= b && b < 100){
        num = 100*a+b;
    }else{
        num = 1000*a+b;
    }
    int ans = false;
    for(int i = 1; i <= num; i++){
        if(i*i == num){
            ans = true;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
X=[int(i) for i in input().split()]
ans=[]


while True:
    lenX=len(X)
    for i in range(lenX):
        if X[lenX-i-1] == lenX-i:
            del X[lenX-i-1]
            ans.append(lenX-i)
            break
    else:
        break

ans.reverse()

if len(ans)==n:
    for a in ans:
        print(a)
else:
    print(-1)

Measured memory_bytes: 3064
#pragma once

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
int W, a, b,result;


int main() {
	
	cin >> W >> a >> b;
	result = 0;

	if (a<b&&b>a+W){
		result = b - a - W;
	}

	if (b<a&&a>b+W) {
		result = a - b - W;
	}

	cout << result<< endl;

	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char s;
	int H,W,i,j;
	static int area[105][105];
	for(i=0;i<100;i++)for(j=0;j<100;j++)area[i][j]=-1;
	scanf("%d%d",&H,&W);
	scanf("%c",&s);
	for(i=0;i<H;i++){for(j=0;j<W;j++){
		scanf("%c",&s);
		//printf("%c",s);
		if(s=='c')area[i][j]=0;
		//if(s=='.')area[i][j]=2;
	}scanf("%c",&s);}
	for(i=0;i<H;i++)for(j=0;j<W;j++)if(area[i][j]!=-1&&area[i][j+1]==-1)area[i][j+1]=area[i][j]+1;
	for(i=0;i<H;i++){
		for(j=0;j<W-1;j++)printf("%d ",area[i][j]);
		printf("%d",area[i][j]);
		printf("\n");
		}
	return 0;
}

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

struct Node{
    int key;
    Node *p,*l,*r;//parent,left,rightの意味
};

Node *root,*NIL;//虚無nodeとrootnode

void insert(int v){//keyがvな節点を受け取る関数。
    Node *y=NIL;//親を設定する用
    Node *x=root;//rootを設定
    Node *z;//挿入するやつ
    z=(Node*)malloc(sizeof(Node));
    z->key=v;
    z->l=NIL;
    z->r=NIL;
    while(x!=NIL){//xがNIL、つまり葉になるまで続ける
        y=x;//一つ下へ向かう時に親を保存しておく
        if(z->key < x->key){
            x=x->l;//視点をxに
        }else{
            x=x->r;
        }
    }
    z->p=y;//以下で、親の方にも追加しないと。
    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->l=z;
        }else{
            y->r=z;
        }
    }
}
Node *find(int k){//他で使うためにNode*を返すことにする
    Node *x=root;//こいつを下げていく
    while(x!=NIL){
        if(x->key==k){
            return x;
        }else if(k < x->key){
            x = x->l;
        }else{
            x = x->r;
        }
    }
    return x;
}

Node *getMinimum(Node *x){//xを根とする部分木の中でkeyが最小のものを返す
    // if(x->l == NIL){
    //     return x;
    // }else{
    //     x=x->l;
    // } へたくそなコードやな
    while(x->l != NIL){
        x=x->l;
    }
    return x;
}

Node *getSuccessor(Node *x){//次節点の探索
    if(x->r != NIL)return getMinimum(x->r);
    //右の子がいないなら上に戻らなきゃね
    Node *y = x->p;
    while(y != NIL && x == y->r){//根になるか、xが左の子であるまで上に行く
        x = y;
        y = y->p;
    }
    return y;
}
void deleteNode(int k){
    Node *z = find(k);
    Node *y;
    //削除対象をyということにする。そうすることで子がいくつの場合でも同じ処理が可能。
    if(z->l == NIL || z->r == NIL){
        y = z;
    }else{
        y = getSuccessor(z);
    }
    //yの子xをyの親に付け替える
    //当然、先に左の子がいるか否かを判別すべき(case2があぶれてしまうので)
    Node *x;
    if(y->l != NIL){
        x = y->l;
    }else{
        x = y->r;
    }
    //親の付け替え
    if(x != NIL){//NILである筈がないんだけど,,,,一応,,,,
        x->p = y->p;
    }
    //次は子供の付け替え
    //親の子供のどちらがyなのかを調べる必要が当然ある
    //その前に親がNILなら意味ないので場合分け
    if(y->p == NIL){
        root = x;
    }else{
        if(y == y->p->l){
            y->p->l = x;
        }else{
            y->p->r = x;
        }
    }
    //最後に、zのkeyをyにしてyの完全消滅(この操作はcase3にのみ効いてるけど)
    if( y != z){
    z->key = y->key;
    }//この場合わけいらないと思うけど,,,模範解答がしているので。
     //確かに間違えは起こらないよね。無駄のなさより厳密性を求めている感じかね
    free(y);//いらなくなったら当然解放。
}

//出力用関数を二つ用意
void preorder(Node *u){
    if(u==NIL)return;
    cout<<" "<<u->key;
    preorder(u->l);
    preorder(u->r);
}
void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->l);
    cout<<" "<<u->key;
    inorder(u->r);
}

int main(){
    int n;cin>>n;
    string order;int v;
    for(int i=0;i<n;i++){
        cin>>order;
        if(order=="insert"){
            cin>>v;insert(v);
        }else if(order=="find"){
            cin>>v;Node *x=find(v);
            if(x == NIL){
                cout<<"no"<<endl;
            }else{
                cout<<"yes"<<endl;
            }
        }else if(order=="delete"){
            cin>>v;deleteNode(v);
        }else{
            inorder(root);cout<<endl;
            preorder(root);cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 21776
#include <iostream>
using namespace std;
#define maxn 55
int map[maxn][maxn];
bool judge(int a,int b);
int main(){
	int H,W;
	cin>>H>>W;
	for(int i = 1;i<=H; i++){
		for(int j = 1;j <= W; j++){
			char c;
			cin>>c;
			if(c == '#')
				map[i][j] = 1;
		}
	}
	for(int i = 1;i<=H; i++){
		for(int j = 1;j <= W; j++){
			if(map[i][j] && !judge(i,j)){
				//cout<<i <<' '<<j<<endl;
				cout<<"No";
				return 0;
			}		
		}
	}
	cout<<"Yes";
	return 0;
} 
bool judge(int a,int b){
	if(map[a-1][b] || map[a+1][b] || map[a][b-1] ||map[a][b+1])
		return true;
	return false;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n=0,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		int x[10]={},a=0,b=0,m=0;
		for(j=0;j<10;j++){
			scanf("%d",&x[j]);
		}
		for(j=0;j<10;j++){
			if(x[j]>a){
				a=x[j];
			}
			else if(x[j]>b){
				b=x[j];
			}
			else {
				printf("NO\n");
				m=1;
				break;
			}
		}
		if(m!=1){
			printf("YES\n");
		}
	}
return 0;
}

Measured memory_bytes: 580