akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
struct edge{
	int to;
	int from;
	int dis;
};

struct land{
	int edge_n;
	int cost;
	int connectedge;
};

int main() {
	int n;
	while (cin >> n, n){
		vector<edge> e;
		int con[801];
		land l[801] = {0};
		int ans =800*100000;
		for (int i = 2; i <= n; i++){
			cin >> con[i];
		}
		for (int i = 2; i <= n; i++){
			int a;
			cin >> a;
			e.push_back({ con[i], i, a });
			e.push_back({ i, con[i], a });
			l[i].edge_n++;
			l[con[i]].edge_n++;
		}
		for (int i = 1; i <= n; i++){
			if (l[i].edge_n == 1){
				REP(j, e.size()){
					if (e[j].from == i){
						l[e[j].to].cost += e[j].dis;
						l[e[j].to].connectedge++;
					}
				}
			}
		}
		int max=0;
		for (int i = 1; i <= n; i++){
			if (l[i].edge_n!=1&&l[i].edge_n - 1 == l[i].connectedge || l[i].edge_n == l[i].connectedge){
				function<int(int start, int from)> f = [&](int start, int from){
					int ans=0;
					for (int i = 0; i<e.size(); i++){
						if (e[i].from == start&&e[i].to != from&&l[e[i].to].edge_n != 1){
							int a = f(e[i].to, e[i].from) + e[i].dis;
							if (a>ans)ans = a;
						}
					}
					return ans;
				};
				int a = f(i,0);
				if (a > max)max = a;
			}
		}
		int ans2=0;
		for (int i = 0; i <= n; i++){
			ans2 += l[i].cost;
		}
		for (int i = 0; i < e.size(); i++){
			if (e[i].to<e[i].from&&l[e[i].from].edge_n != 1 && l[e[i].to].edge_n != 1)ans2 += e[i].dis * 3;
			
		}
		ans2 -= max;
		cout << ans2 << endl;
	}
}

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

int main() {
	int N, K; cin >> N >> K;
	vector<int> L(N);
	for( int &k : L )cin >> k;
	sort(L.begin(), L.end());
	reverse(L.begin(), L.end());
	int ans = 0;
	for( int i = 0; i < K; i++ ){
		ans += L[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <ctype.h>
#include <set>
#include <map>
#include <list>

#define MAXN 10000000
using namespace std;

int N;
int record[100050];
int output=0;
int zhizhen=1;

void f()
{
    int woca=record[zhizhen];
    while(zhizhen<=N && record[zhizhen]==woca)
    {
        zhizhen++;
    }
    if(zhizhen<=N)
    {
        //printf("wocadd");
        if(record[zhizhen]<woca)
        {
            while(zhizhen<=N && record[zhizhen]<=record[zhizhen-1])
            {
                zhizhen++;
            }
        }
        else
        {
            while(zhizhen<=N && record[zhizhen]>=record[zhizhen-1])
            {
                zhizhen++;
            }
        }
    }
}

int main()
{
	//freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
    {
        scanf("%d",&record[i]);
    }


    while(zhizhen<=N)
    {
        f();
        output++;
    }
    printf("%d",output);
	return	0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    clock_t start = clock();
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    random_device rand;
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) ans[i] = rand() % 26;
    
    auto calc_score = [&] () {
        vector<ll> v(26, -1);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            v[ans[i]] = i;
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                ret -= c[j] * (i - v[j]);
            }
        }
        return ret;
    };
    
    ll score = calc_score();
    
    while (clock() - start <= 1.95 * CLOCKS_PER_SEC) {
        ll change_at1 = rand() % d, into1 = rand() % 26;
        ll change_at2 = rand() % d, into2 = rand() % 26;
        ll memo1 = ans[change_at1], memo2 = ans[change_at2];
        ll memo_score = score;
        ans[change_at1] = into1; ans[change_at2] = into2;
        score = calc_score();
        if (score < memo_score && clock() - start <= CLOCKS_PER_SEC) {
            ans[change_at1] = memo1; ans[change_at2] = memo2;
            score = memo_score;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << ans[i] + 1 << endl;
    xout << score << endl;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];

  rep(i, n - m + 1) {
    rep(j, n - m + 1) {
      bool flag = true;
      rep(k, m) rep(l, m) flag &= (a[i + k][j + l] == b[k][l]);
      if (flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
  return 0;
}


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

class UnionFind {
private:
	vector< int > data;
	int num_of_g;
	
public:
	UnionFind(int n) : data(n, -1), num_of_g(n) {}
	
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		
		if (x == y) return 0;
		
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y]; data[y] = x;
		--num_of_g;
		
		return 1;
	}
	
	bool sameSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
	int getNumOfG() { return num_of_g; }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    UnionFind uf(N);
    vector<vector<int>> F(N), B(N);

    for (int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unionSet(a, b);
        F[a].push_back(b);
        F[b].push_back(a);
    }

    for (int i=0; i<K; ++i) {
        int c, d;
        cin >> c >> d;
        --c; --d;
        B[c].push_back(d);
        B[d].push_back(c);
    }

    for (int i=0; i<N; ++i) {
        int ans = uf.size(i) - F[i].size();
        for (int v : B[i]) if (uf.sameSet(i, v)) --ans;
        cout << ans - 1 << (i<N-1 ? " " : "\n");
    }
}

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


    using namespace std;
    using ll = long long;
    using ull = unsigned long long;
    using pii = pair<int, int>;
    using pll = pair<ll, ll>;



    const int INF = 0x3f3f3f3f;
    const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
    const int NMAX = 1e5 + 5;
    const int MOD = 1e9 + 7;
    #define endl "\n"


        vector<int> tabBoth;
        vector<int> tabBob;
        vector<int> tabAlice;

    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int a;
        int b;
        int c;
        cin>>a;
        b=0;
        c=a;
        for (int i = 0; i < 3; ++i)
        {
            b+=a;
            a*=c;
        }
        cout<<b;

        return 0;
    }


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    char str[1001];
    while(1){
        scanf("%s", str);
        if (str[0] == '0') break;
        int sum = 0;
        for (int i = 0; i < strlen(str);i++){
            int a = str[i] -'0';
            sum += a;
        }
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 2672
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(int n){return n==0?1:10*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

int gcd(int a, int b)
{
    return b == 0 ? a : gcd(b, a % b);
}

bool is_prime[1000010];
void sieve() {
    for (int i = 0; i < 1000010; ++i) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i < 1000010; ++i) {
        if (is_prime[i]) continue;
        for (int j = i + i; j < 1000010; j += i) {
            is_prime[j] = false;
        }
    }
}

bool exist[1000100];

signed main()
{
    sieve();
    int N; cin >> N;
    vi A(N);

    rep(i, N) cin >> A[i], exist[A[i]] = true;

    int G = 0;

    rep(i, N) G = gcd(G, A[i]);

    if (G != 1) {
        cout << "not coprime\n";
        return 0;
    }

    bool is_pair = true;

    for (int i = 2; i <= 1000000; ++i) {
        int cnt = 0;

        for (int j = i; j <= 1000000; j += i) {
            if (exist[j]) cnt++;
        }

        if (cnt > 1)  is_pair = false;
    }

    if (is_pair) cout << "pairwise coprime\n";
    else cout << "setwise coprime\n";
}


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B; cin >> A >> B;
  int ans = -1;
  for(int i = 1000; i > 0; i--){
    if(A == int(i * 0.08) && B == int(i * 0.1)) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int selectionSort(int A[], int N);
int main()
{	
	int A[100];
	int N;
	int sw;
	cin>>N;
	for (int i = 0; i < N; ++i)
	{
		cin>>A[i];
	}
	sw=selectionSort(A,N);
	for (int i = 0; i < N; ++i)
	{	
		if(i) cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	cout<<sw<<endl;
	return 0;
}
int selectionSort(int A[], int N)
{
	int i,j,sw=0,minj;
	for(i=0; i<=N-1; ++i)
	{	
		minj=i;
		for(j=i; j<=N-1; ++j)
		{
			if (A[j]<A[minj])
			{
				minj=j;
			}
		}
		if(i!=minj){
			++sw;}
		swap(A[i],A[minj]);	
	}
	return sw;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, m, n) for (int i = m; i < n; i++)
using T = tuple<int, int, int>;

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  vector<string> s(h);
  for (string &i : s) cin >> i;
  vector<vector<int>> l(h, vector<int>(w, -1));
  deque<tuple<int,int,int>> q;
  q.emplace_back(T(ch, cw, 0));
  while (!q.empty()) {
    auto [gh, gw, gl] = q.front();
    q.pop_front();
    if (l[gh][gw] != -1) continue;
    l[gh][gw] = gl;
    if (gh + 1 < h and s[gh + 1][gw] == '.') q.emplace_front(T(gh + 1, gw, gl));
    if (gh - 1 >= 0 and s[gh - 1][gw] == '.') q.emplace_front(T(gh - 1, gw, gl));
    if (gw + 1 < w and s[gh][gw + 1] == '.') q.emplace_front(T(gh, gw + 1, gl));
    if (gw - 1 >= 0 and s[gh][gw - 1] == '.') q.emplace_front(T(gh, gw - 1, gl));
    FOR(i, -2, 3) FOR(j, -2, 3) {
      int nh = gh + i, nw = gw + j;
      if (0 <= nh and nh < h and 0 <= nw and nw < w and s[nh][nw] == '.') q.emplace_back(T(nh, nw, gl + 1));
    }
  }
  cout << l[dh][dw] << endl;
  return 0;
}

Measured memory_bytes: 10780
import java.util.Scanner;
 
    class Main{
    public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
 
    int r, c, i, j, sum1 = 0, sum2 = 0;
    int data[][] = new int[150][150];
    //scanf("%d%d", &r, &c);
    r = scan.nextInt();
    c = scan.nextInt();
    for (i = 0; i < r; i++) {
        for (j = 0; j < c; j++) {
            //scanf("%d", &data[i][j]);
            data[i][j] = scan.nextInt();
            sum1 += data[i][j];
        }
        data[i][c] = sum1;
        sum1 = 0;
    }
    for (j = 0; j <= c; j++) {
        for (i = 0; i < r; i++) {
            sum2 += data[i][j];
        }
        data[r][j] = sum2;
        sum2 = 0;
    }
    for (i = 0; i <= r; i++) {
        for (j = 0; j < c; j++) {
            //printf("%d ", data[i][j]);
            System.out.print(data[i][j] + " ");
        }
        //printf("%d\n", data[i][c]);
        System.out.println(data[i][c]);
    }
 
 
    }
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  mint ans = 0;
  for(int i = k; i <= n+1; ++i) {
    ans += i * (n - i + 1) + 1;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
long long modpow(long long a, long long n, long long mod=(1LL<<62)){
	long long res = 1;
	while (n > 0){
		if (n & 1)
		res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main(){
	ll n,p,ans=1LL;
	cin >>n>>p;
	map<ll, int> dis;
	for (ll i = 2LL; i <= sqrt(p); i++) {
		while (p % i == 0) {
			dis[i]++;
			p /= i;
	//		clog << i << endl;
		}
	}
//	clog << p << endl;
	if (p != 1LL) {
		dis[p]++;
	}
	repi(itr, dis) {
	//	clog << (itr->F) << " " << (itr->S) << endl;
		ans *= modpow(itr->F, itr->S / n); }
	cout << ans << endl;
}

Measured memory_bytes: 3680
ALF = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
AZ = {i:ALF[i] for i in range(len(ALF))}
H,W = list(map(int,input().split()))
S = [input().split() for _ in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w] == 'snuke':
            print(AZ[w]+str(h+1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bool C(ll K, ll target, const vector<ll>& v, const vector<ll>& w){
  ll cnt = 0;
  rep(i,v.size()){
    ll a = v[i];
    ll b = w[i];

    if(a*b>target){
      cnt += a - (target/b);
    }
  }
  return cnt > K;
}

int main(){
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> v, w;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));
  rep(i,N){
    ll a;
    cin >> a;
    w.push_back(a);
  }
  sort(ALLOF(w));
  reverse(ALLOF(w));

  ll lb = -1, ub = (ll)(1e18);
  while(ub-lb>1){
    ll mid = lb + (ub-lb)/2;
    if(C(K,mid,v,w)) lb = mid;
    else ub = mid;
  }

  cout << ub << endl;
  
  return 0;
}




Measured memory_bytes: 4848
n = int(input().rstrip())
xmax = -10_000_000_000
xmin = 10_000_000_000
ymax = -10_000_000_000
ymin = 10_000_000_000
for i in range(n):
    x, y = map(int,input().split())
    xpy = x+y
    xmy = x-y
    xmax = max(xpy,xmax)
    xmin = min(xpy,xmin)
    ymax = max(xmy,ymax)
    ymin = min(xmy,ymin)
print(max(xmax-xmin,ymax-ymin))

Measured memory_bytes: 9216
n=int(input())
g=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append((b-1,i))

vc=[0] * n
ec=[-1]*(n-1)
for p,ci in enumerate(g):
    color = 1
    for c, i in ci:
        if vc[p] == color:
            color += 1
        vc[c] = color
        ec[i] = color
        color += 1
        

print(max(ec))
for i in range(n-1):
    print(ec[i])


Measured memory_bytes: 27744
N,X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
k1 = k2 = 0
for i in range (N):
  if sum(A[:i+1]) > X:
    k1 = i
    k2 = 1
    break
  elif sum(A) == X:
    k1 = N
    k2 = 1
    break
if k2 == 0:
  k1 = N - 1
print(k1)


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector <int > y;
    int t[n];
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    sort(t,t+n);
    int mx=t[n-1];
    int co=0;
    for(int i=1;i<=100000;i++){
        if(mx%i==0){
            y.push_back(i);
            co++;
        }
    }

    int k=0;
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=k;j<co;j++){
            if(t[i]<=y[j]){
                ans+=(y[j]-t[i]);
                break;
            }
            else {
                k++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    
    int count = 0;
    
    for (int i=0; i<n; i++) {
        if (a[i]*4*m < sum) {
            count++;
        }
    }

    if (n-count >= m) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
import math

n = int(input())
answer_lists = [0 for i in range(10001)]
for x in range(1, int(math.sqrt(n+1)), 1):
    for y in range(1, int(math.sqrt(n+1)), 1):
        for z in range(1, int(math.sqrt(n+1)), 1):
            formula = (x+y+z)**2 - (x*y + y*z + z*x)
            if formula <= n:
                answer_lists[formula] += 1
            else:
                break
for i in range(1, n+1, 1):
    print(answer_lists[i])

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

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int xl, xr, yb, yt;
    xl = 0;
    xr = W;
    yb = 0;
    yt = H;

    for (int i=0; i<N; ++i) {
        int x, y;
        int a;
        cin >> x >> y >> a;

        if (a == 1) {
            if (x > xl) xl = x;
        }
        else if (a == 2) {
            if (x < xr)xr = x;
        }
        else if (a == 3) {
            if (y > yb) yb = y;
        }
        else if (a == 4) {
            if (y < yt) yt = y;
        }
    }

    int area;
    if ((xl >= xr) || (yb >= yt)) {
        area = 0;
    }
    else {
        area = (xr - xl) * (yt - yb);
    }

    cout << area << endl;
}

Measured memory_bytes: 3632
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    // TODO solve
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int d = scanner.nextInt();
        final int a = scanner.nextInt();

        final List<Monster> list = IntStream.range(0, n)
                .mapToObj(i -> new Monster(scanner.nextInt(), scanner.nextInt()))
                .sorted(Comparator.comparingLong(monster -> monster.x))
                .collect(Collectors.toList());

        final List<Integer> indices = list.stream()
                .map(m -> m.x)
                .collect(Collectors.toList());

        long sum = 0;
        long counter = 0;
        final long[] array = new long[n];
        for (int i = 0; i < list.size(); i++) {
            final Monster monster = list.get(i);
            if (sum < monster.hp) {
                final long diff = monster.hp - sum;
                final long tmp = (diff + a - 1) / a;
                counter += tmp;
                sum += tmp * a;

                final int last = monster.x + 2 * d;
                final int found = Collections.binarySearch(indices, last);
                if (found >= 0) {
                    int idx = found;
                    if(idx >=n){
                        idx = n-1;
                    }
                    array[idx] += tmp * a;
                } else {
                    int idx = ~found - 1;
                    if (idx >= n) {
                        idx = n - 1;
                    } else if (idx < 0) {
                        idx = 0;
                    }
                    array[idx] += tmp * a;
                }
            }
            sum -= array[i];
        }
        System.out.println(counter);
    }

    static class Monster {
        final int x;
        final long hp;

        Monster(final int x, final int hp) {
            this.x = x;
            this.hp = hp;
        }
    }
}


Measured memory_bytes: 131492
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

bool dfs(string& s, int i) {
  if (i >= s.size()) return true;
  bool ok = false;
	if (s.find("dream",i) == i) ok |= dfs(s, i+5);
	if (s.find("dreamer", i) == i) ok |= dfs(s, i + 7);
	if (s.find("erase", i) == i) ok |= dfs(s, i + 5);
	if (s.find("eraser", i) == i) ok |= dfs(s, i + 6);

	return ok;
}

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

	string s; cin >> s;

	if (dfs(s,0)) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

long inner(long prefix, long left, long right){
    long result, ten=1;
    result = prefix + left + right;
    for(int i=1; i<11; i++){
        ten *= 10;
        if(right/ten >0) {
            result += inner(prefix+left, right/ten, right%ten);
        }
        else break;
    }
    return result;
}

void solve(long S){
    cout << inner(0, 0, S) << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
// const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int s1, s2;
    s1 = a * b;
    s2 = c * d;
    cout << max(s1, s2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;
int main() {
	int n, a, b; cin >> n >> a >> b;

	int ans = 0;

	for (int i = 1; i <= n; i++) {
		int c = 0;
		int t = i;
		for (int j = 0; j < 5; j++) c = c + t % 10,t = t / 10;
			if (a <= c && c <= b) {
				ans = ans + i;
		}
	}
	cout << ans << endl;
}

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

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define ll long long
#define pb push_back
#define PI M_PI
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
     IOS
     int a,b;
     cin>>a>>b;
     
     if(b>=a)
          cout<<"unsafe\n";
     else
          cout<<"safe\n";

     return 0;
}



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

int main(){
  int N;
  cin>>N;
  int a=N/1000,b=N%1000/100,c=N%100/10,d=N%10;
  if(a==b&&b==c||b==c&&c==d){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var min = 9999999999
    val p = (1..n).map {readLine()!!.toLong()}.sortedDescending()
    for (i in 0..n - m){
        var cmin = p[i] - p[i + m - 1]
        if(cmin < min) min = cmin
    }
    println(min)
}

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

using namespace std;

#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)

template<typename T>
void err(T a){
    cerr<<a<<'\n';
    cerr<<"END OF DEBUG"<<'\n'<<'\n';
}

const long double PI=acos(-1.0);  
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

/*head------[@cordercorder]*/

const int maxn=(int)1e5+10;

int a[maxn],n,k;
int dp[maxn];

void solve(){
    dp[1]=0;
    int mine;
    for(int i=2;i<=n;i++){
        mine=(int)1e9+10;
        for(int j=i-1;j>=i-k&&j>=1;j--){
            mine=min(mine,dp[j]+abs(a[i]-a[j]));
        }
        dp[i]=mine;
    }
    printf("%d\n",dp[n]);
}

int main(void){
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    solve();
    return 0;
}

Measured memory_bytes: 1024
import Control.Monad
import Data.List
import Data.Maybe

main = do
    [n, m] <- map read . words <$> getLine
    ab <- map (map read. words) <$> replicateM n getLine :: IO [[Integer]]
    cd <- map (map read. words) <$> replicateM m getLine :: IO [[Integer]]
    let dists = map (map (\[[a, b], [c, d]] -> abs(a-c) + abs(b-d))) $  map (\x -> sequence [[x], cd]) ab
    let ans = map (\d -> 1 + fromMaybe (-1) (elemIndex (minimum d) d)) dists
    mapM_ print ans

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define MOD 1000000007
using namespace std;

int main(){
  char a;
  cin >> a;
  cout << char(a + 1) << endl;
  
  return 0;
} 


Measured memory_bytes: 256
n = int(input())

f = [1] * (n+1)
f[1] = 1

for i in range(2, n+1):
    for j in range(0,n+1,i):
        f[j] += 1
ans = 0
for k in range(1, n+1):
    ans += k * f[k]

print(ans)

Measured memory_bytes: 151624
//
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))//yoku wakarannkedo bennrisou
#define min(p,q)((p)<(q)?(p):(q))//ue ni onaji
//#define N

int main()
{
  int n,k,i,j,tmp,ans=0;
  scanf("%d %d", &n,&k);

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

  for(i = 1; i <= n-1; i++){
    for(j = i+1; j <= n; j++){
      if(a[i]<a[j]){
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
      }
    }
  }
  //for(i = 1; i <= n; i++) {
  //  printf("%d\n", a[i]);
  //}
  for(i = n;i>=n-k+1; i--) {
    ans+=a[i];
  }
  printf("%d\n", ans);



  return 0;
}


Measured memory_bytes: 1748
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[114514];
int main()
{
	int n,now=0,out=1;
	cin>>n;
	rep(i,n) cin>>a[i];
	rep(i,n-1){
		int p=0;
		if(a[i]<a[i+1]) p=1;
		if(a[i]>a[i+1]) p=-1;
		if(p==0) continue;
		if(now!=p && now!=0){
			out++;now=0;
		}
		else now=p;
		//cout<<now<<endl;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 640
n = gets.chomp.to_i
array = gets.split(" ").map(&:to_i)

array_new = array.sort
count = 0

n.times do |i|
    if array[i] != array_new[i]
        count += 1
    end
end

if count <= 2
    puts "YES"
else
    puts "NO"
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using pii = pair<int,int>;
#define fir first
#define sec second
#define all(v) begin(v),end(v)

int par[11111];
int siz[11111];

void init(int n) {
    for(int i=0; i<n; ++i) {
        par[i]=i;
        siz[i]=0;
    }
}

int find(int v) {
    if(par[v]==v) return v;
    return par[v]=find(par[v]);
}


bool unite(int u,int v) {
    u=find(u);
    v=find(v);
    if(u==v) return false;
    if(siz[u]<siz[v]) swap(u,v);
    siz[u]+=siz[v];
    par[v]=u;
    return true;
}

int n,m;
pii crd[11111];
double ans;
vector<tuple<double,int,int>> egs;

signed main() {
    cin>>n>>m;
    init(n);
    for(int i=0; i<n; ++i) {
        cin>>crd[i].fir>>crd[i].sec;
    }
    for(int i=0; i<m; ++i) {
        int u,v; cin>>u>>v;
        u--,v--;
        double len=sqrt(pow(crd[u].fir-crd[v].fir,2)+pow(crd[u].sec-crd[v].sec,2));
        egs.emplace_back(len,u,v);
        ans+=len;
    }
    sort(all(egs),greater<>());
    for(auto &e:egs) {
        int a,b; double c;
        tie(c,a,b)=e;
        if(unite(a,b)) {
            ans-=c;
        }
    }
    cout<<setprecision(10)<<ans<<endl;
}



Measured memory_bytes: 3652
#include <stdio.h>

int N;
int A[1000000];

int count[100000];

int main(void) {
	int i;
	int max = 0;

	int taberu = 0;
	int twocount = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
		count[A[i]]++;
		if (A[i] > max) max = A[i];
	}
	for (i = 1; i <= max; i++) {
		if (count[i] >= 2) {
			if (count[i] % 2 == 0) {
				taberu += count[i] - 2;
				twocount++;
			} else {
				taberu += count[i] - 1;
			}
		}
	}
	if (twocount % 2 == 0) {
		taberu += twocount;
	} else {
		taberu += twocount + 1;
	}
	printf("%d\n", N - taberu);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include<stdlib.h>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    vector<int> v;
    int x;
    for(int i = 0; i < n; i++){
        scanf("%d", &x);
        v.push_back(x);
    }
    int dp[n];
    dp[n-1] = 0;
    dp[n-2] = abs(v[n-1]-v[n-2]);
    for(int i = v.size()-3; i>=0; i--){
        dp[i] = min(dp[i+2]+abs(v[i+2]-v[i]),dp[i+1]+abs(v[i+1]-v[i]));
    }
    printf("\n%d", dp[0]);

    return 0;
}


Measured memory_bytes: 1144
//#define DEBUG 2

#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <regex>
#include <fstream>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;

void run() {
	int n; cin >> n;
	vector<int> hash(100001);
	REP(i, n) {
		int x; cin >> x;
		hash[x] += 1;
		if (hash[x] == 3) {
			hash[x] = 1;
		}
	}

	vector<int> id;
	
	REP(i, 100001) {
		if (hash[i] > 0) id.push_back(i);
	}

	REP(i, id.size()) {
		if (hash[id[i]] == 2) {
			for(int j = id.size() - 1; j >= i+1; j--) {
				if (hash[id[j]] == 2) {
					hash[id[i]] = 1;
					hash[id[j]] = 1;
					break;
				}
			}
		}

	}
	int ans = id.size();
	REP(i, id.size()) {
		if (hash[id[i]] == 2) ans--;
	}
	cout << ans << endl;
}

int main() {
#ifdef DEBUG
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	for(int i = 0; i < DEBUG; i++) {
		cout << "cnt:" << i << " ------------" << endl;
		run();
	}
#else
	run();
#endif
	return 0;
}


Measured memory_bytes: 1276
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

int GCD(int a, int b) {
	return b ? GCD(b, a%b) : a;
}

//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

int main() {
	double a,b,t;
	cin >> a >> b >> t;
	double x = t + 0.5;
	int ans  = x / a;
	cout << b*ans;
	
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int[] count = new int[26];
		while (sc.hasNextLine()) {
			String input = sc.nextLine();

			
			for (char c : input.toCharArray()) {
				c = Character.toLowerCase(c);
				if ('a' <= c && c <= 'z') {
					count[c - 'a']++;
				}
			}
		}

		for (int i = 0; i < 26; i++) {
			System.out.println((char) ('a' + i) + " : " + count[i]);
		}
	}

}

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

using namespace std;

static const int maxn = 1e5 + 5;

int tnode, tedge;
vector <int> graph[maxn];

int dp[maxn];
bool memoize[maxn];

inline int longestPath(int u)
{
      int &ret = dp[u];
      bool &mem = memoize[u];
      if (mem) return ret;
      mem = 1;
      int maxi = 0;
      for (int v : graph[u])
      {
            int go = 1 + longestPath(v);
            if (go > maxi) maxi = go;
      }
      return ret = maxi;
}

int main()
{
      scanf("%d %d", &tnode, &tedge);
      for (int e = 1; e <= tedge; e++)
      {
            int u, v;
            scanf("%d %d", &u, &v);
            graph[u].emplace_back(v);
      }
      int maxi = 0;
      for (int i = 1; i <= tnode; i++)
      {
            if (longestPath(i) > maxi) maxi = longestPath(i);
      }
      printf("%d", maxi);
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n; cin >> n;
	string s; cin >> s;
	int one=0;
	REP(i,n){
		if(s[i]=='1')
			one++;
	}
	if(one==0){
		REP(i,n)
			cout << 1 << endl;
		return 0;
	}
	if(one==1){
		if(s[n-1]=='1'){
			REP(i,n){
				if(s[i]=='1')
					cout << 0 << endl;
				else
					cout << 2 << endl;
			}
		}
		else{
			REP(i,n){
				if(i==n-1)
					cout << 2 << endl;
				else if(s[i]=='1')
					cout << 0 << endl;
				else
					cout << 1 << endl;
			}
		}
		return 0;
	}
	int p1=1, p2=1, sum1=0, sum2=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='1'){
			sum1=(sum1+p1)%(one+1);
			sum2=(sum2+p2)%(one-1);
		}
		p1=(p1*2)%(one+1);
		p2=(p2*2)%(one-1);
	}
	VI anss(n);
	p1=1, p2=1;
	for(int i=n-1;i>=0;i--){
		int ans=1;
		if(s[i]=='1'){
			int sum=sum2;
			sum+=(one-1-p2);
			sum%=one-1;
			while(sum!=0){
				int md=0;
				REP(i,30){
					if(sum>>i&1)
						md++;
				}
				sum%=md;
				ans++;
			}
		}
		else{
			int sum=sum1;
			sum+=p1;
			sum%=one+1;
			while(sum!=0){
				int md=0;
				REP(i,30){
					if(sum>>i&1)
						md++;
				}
				sum%=md;
				ans++;
			}
		}
		anss[i]=ans;
		p1=(p1*2)%(one+1);
		p2=(p2*2)%(one-1);
	}
	REP(i,n)
		cout << anss[i] << endl;
	return 0;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
bool vis[N];
int head[N], to[2 * N], nxt[2 * N], num;
void init(int n)
{
	for(int i = 1; i <= n; ++ i) head[i] = 0;
	num = 0;
}
void addedge(int u, int v)
{
	nxt[ ++ num] = head[u];
	to[num] = v;
	head[u] = num;
}
void dfs(int u)
{
	vis[u] = 1;
	for(int e = head[u]; e; e = nxt[e])
	{
		int v = to[e];
		if(vis[v]) continue;
		dfs(v);
	}
}
int main () {
	cin >> n >> m;
	init(n);
	for(int i = 1; i <= m; ++ i)
	{
		int u, v;
		cin >> u >> v;
		addedge(u, v);
		addedge(v, u);
	}
	int num = 0;
	for(int i = 1; i <= n; ++ i)
	{
		if(vis[i]) continue;
		dfs(i);
		num ++;
	}
	cout << num - 1;
    return 0;
}

Measured memory_bytes: 6908
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    char s;
    cin >> s;
    if (s=='a' || s=='i'|| s=='u'|| s=='e'|| s=='o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
/*
    Ujjawal Pabreja [cuber_coder]
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== BigInt begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== BigInt ends ======

// ====== PBDS begins ======
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, 
//         tree_order_statistics_node_update> 
//         pbds; 
// ====== PBDS ends ======

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    ll n;
    cin >> n;
    ll a[n + 5];
    init(a, 0);
    for(ll i = 1 ; i * i <= n ; i++){
        for(ll j = 1 ; j * j <= n ; j++){
            for(ll  k = 1 ; k * k <= n ; k++){
                ll val = i * i + j * j + k * k + i * j + j * k + k * i;
                if(val > n){
                    break;
                }
                a[val]++;
            }
        }
    }
    // repe(i,1,n + 5){
    //     a[i] += a[i - 1];
    // }
    rep(i,n) cout << a[i + 1] << endl;
}

int main(){
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}


Measured memory_bytes: 3692