akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(int n, vector<pair<int,int>>& edges, vector<pair<int,int>>& paths) {
        int m = paths.size();
        int M = 1 << m;
        vector<vector<pair<int, int>>> graph(n);
        for (int i = 0; i < edges.size(); ++i) {
            int u = edges[i].first, v = edges[i].second;
            graph[u].emplace_back(v, i);
            graph[v].emplace_back(u, i);
        }

        int rt = 0;
        vector<int> ord;
        vector<int> pars(n, -1);
        ord.push_back(rt);

        for (int i = 0; i < ord.size(); ++i) {
            int u = ord[i];
            for (auto& e : graph[u]) {
                int v = e.first;
                if (v == pars[u]) {
                    continue;
                }
                pars[v] = u;
                ord.push_back(v);
            }
        }

        vector<int> masks(n, 0);

        function<bool(int,int,int,vector<int>&)> dfs = [&](int u, int t, int p, vector<int>& path) {
            if (u == t) {
                return true;
            }
            for (auto& e : graph[u]) {
                int v = e.first;
                int idx = e.second;
                if (v == p) {
                    continue;
                }
                path.push_back(idx);
                if (dfs(v, t, u, path)) {
                    return true;
                }
                path.pop_back();
            }
            return false;
        };

        for (int i = 0; i < m; ++i) {
            int u = paths[i].first, v = paths[i].second;
            vector<int> P;
            dfs(u, v, -1, P);
            for (auto x : P) {
                masks[x] |= 1 << i;
            }
        }
        vector<long long> dp(M, 0);
        dp[0] = 1;

        for (int i = 0; i < n - 1; ++i) {
            for (int j = M - 1; j >= 0; --j) {
                dp[j | masks[i]] += dp[j];
            }
        }

        return dp[M - 1];
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<pair<int,int>> edges;
    for (int i = 0; i + 1 < n; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        edges.emplace_back(u, v);
    }
    int m;
    cin >> m;
    vector<pair<int,int>> paths;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        paths.emplace_back(u, v);
    }

    Solution sol;
    cout << sol.solve(n, edges, paths) << "\n";

    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define N 100010
ll dp[N],a[N];
int main(){
	fast;
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	dp[1]=0;dp[2]=fabs(a[2]-a[1]);
	for(int i=3;i<=n;i++){
		ll maxv=2147483647;
		for(int j=i-1;j>=max(1,i-k);j--){
			maxv=min(maxv,dp[j]+fabs(a[i]-a[j]));
		}dp[i]=maxv;
	}
	cout<<dp[n]<<endl;
	return 0;
}/*『你强归你强，Siyuan比你强』*/

Measured memory_bytes: 1792
#include <iostream>

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

int main() {
    int n, k;
    std::cin >> n >> k;

    int date[100];
    int dp[100][4][4];
    rep(i, 100) {
        date[i] = 0;
        rep(a, 4) rep(b, 4) dp[i][a][b] = 0;
    }

    int d, p;
    rep(i, k) {
        std::cin >> d >> p;
        date[d - 1] = p;
    }

    if (date[0] == 0)
        dp[0][0][1] = dp[0][0][2] = dp[0][0][3] = 1;
    else
        dp[0][0][date[0]] = 1;
    repr(i, 1, n) {
        if (date[i] == 0) {
            repr(p, 1, 4) rep(a, 4) rep(b, 4) if (a != b || b != p)
                dp[i][a][p] += dp[i - 1][b][a] % 10000;
        } else {
            rep(a, 4) rep(b, 4) if (a != b || b != date[i]) dp[i][a][date[i]] +=
                dp[i - 1][b][a] % 10000;
        }
    }
    int total = 0;
    rep(a, 4) rep(b, 4) total += dp[n - 1][a][b];
    std::cout << total % 10000 << std::endl;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int,int> pii;
typedef std::pair<int,double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;


int D;
int N;

void dfs(int node, int parent, vector<vector<int>>& g, int cnt){
    if (cnt > D){
        N = node;
        D = cnt;
    }
    for(auto ne: g[node]){
        if (ne == parent) continue;
        dfs(ne,node,g,cnt+1);
        
    }    
}

void solve(){
    int n;
    cin >> n;
    vector<vector<int>> g(n+1,vector<int>());
    rep(i,n-1){
        int x,y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    
    D = 0;
    N = -1;
    dfs(1,-1,g,0);
    
    dfs(N,-1,g,0);
    
    if (D == 0) cout << "First";
    else if (D%3 == 1) cout << "Second";
    else cout << "First";
    
    
}





int main(){
    int T;
    T = 1;
    // cin >> T;
    while(T--){
        solve();
        cout << endl;
    }
}





































Measured memory_bytes: 26500
def counting_sort(a,k):
    C = []
    for i in range(k):
        C.append(0)
    for ai in a:
        C[ai] += 1
    s = 0
    for i in range(k):
        s += C[i]
        C[i] = s
    b = []
    for i in range(len(a)):
        b.append(None)
    p = 0
    for i in range(k):
        while p < C[i]:
            b[p] = i
            p += 1
    return b


n = int(raw_input())
a = map(int,raw_input().split(' '))
print ' '.join(map(str,counting_sort(a,10000)))

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

using namespace std;

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

	string ans = "";
	for(int i=0;i<s.size();++i){
		char c = s[i];
		if(ans.size()>0 && c == 'B'){
			ans = ans.substr(0,ans.size()-1);
		}
		else if(c=='B'){
		    continue;
		}
		else{
			ans+=c;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    bool is_black[H][W];
    for (int i = 0; i < H; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++)
        {
            if (s[j] == '.')
            {
                is_black[i][j] = false;
            }
            else
            {
                is_black[i][j] = true;
            }
        }
    }

    //cout << "hoge" << endl;

    vector<int> n_black(H, 0);
    int sum_black = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (is_black[i][j])
            {
                n_black[i]++;
                sum_black++;
            }
        }
    }

    if (K > sum_black)
    {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;

    for (int i = 0; i < (1 << H); i++)
    {

        vector<bool> h_used(H, false);
        int deleted_black = 0;
        for (int j = 0; j < H; j++)
        {
            if (i & (1 << j))
            {
                h_used[j] = true;
                deleted_black += n_black[j];
            }
        }

        vector<int> n_w_black(W, 0);
        for (int j = 0; j < W; j++)
        {
            for (int k = 0; k < H; k++)
            {
                if (is_black[k][j] && !h_used[k])
                {
                    n_w_black[j]++;
                }
            }
        }

        //count deleted black
        int dp[W][sum_black + 1];
        for (int j = 0; j < W; j++)
        {
            for (int k = 0; k < sum_black + 1; k++)
            {
                dp[j][k] = 0;
            }
        }
        dp[0][deleted_black]++;
        dp[0][deleted_black + n_w_black[0]]++;
        for (int j = 1; j < W; j++)
        {
            for (int k = 0; k < sum_black + 1; k++)
            {
                if (dp[j - 1][k] > 0)
                {
                    dp[j][k] += dp[j - 1][k];
                    dp[j][k + n_w_black[j]] += dp[j - 1][k];
                }
            }
        }
        ans += dp[W - 1][sum_black - K];
        //cout << deleted_black << " " << ans << endl;
    }

    cout << ans << endl;
}

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


int main() {
    int N,R;
    cin >> N >> R;
    if(N>=10){
        cout << R << endl;
    }else{
        int nn = 100*(10-N);
        cout << R + nn << endl;
    }


    return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }



int main()
{
	int n;
	int64_t ans;

	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	ans = a[n - 1];
	for (int i = 0; i < n - 2; i++)
		ans += (int64_t)a[n - 2 - i / 2];
	cout << ans << endl;
}

Measured memory_bytes: 4112
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int a, b;
    cin >> a >> b;
    cout << a* b << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;

    if (b < 10) a *= 10;
    else if (b < 100) a *= 100;
    else a *= 1000;
    int num = a + b;

    string ans = "No";
    for (int i = 1; i <= 317; i++){
        if (i * i == num){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, M;
    scan(N, M);
    auto G = new long[][](N, N);
    foreach (_; 0 .. M)
    {
        long a, b;
        scan(a, b);
        G[a - 1][b - 1] = G[b - 1][a - 1] = 1;
    }
    // foreach (g; G)
    //     writeln(g);
    auto ID = new long[](N);
    auto L = new long[](N);
    auto visited = new bool[][](N, N);
    ID[] = -1;
    ID[0] = 0;
    L[] = -1;
    L[0] = 0;
    long cnt;
    long id;
    long[] stack = [0];
    loop: while (!stack.empty)
    {
        long x = stack.back;
        // writeln(x);
        // writeln(L, stack);
        foreach (i; 0 .. N)
            if (G[x][i] == 1 && !visited[x][i])
            {
                visited[x][i] = visited[i][x] = true;
                if (ID[i] == -1)
                {
                    ID[i] = L[i] = ++id;
                    stack ~= i;
                }
                L[x] = L[x].min(ID[i]).min(L[i]);

                continue loop;
            }
        stack.popBack();
        // writefln("back: %d-%d %d %d", x, stack.back, L[x], ID[x]);
        if (!stack.empty)
        {
            L[stack.back] = L[stack.back].min(ID[x]).min(L[x]);
            if (L[x] == ID[x])
            {
                cnt++;
            }
        }
    }

    writeln(cnt);
}


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


int main() {

    string n;
    cin >> n;
    ll N = stoi(n);
    int res = 0;
    for (int i = 0; i < n.size(); ++i) {
        res += n[i] - '1' + 1;

    }
    if (N % res == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
int partition(int,int);
int A[N];
int main(){
  int i,p=0,r,j;

  scanf("%d",&r);
  for(i=0;i<r;i++)scanf("%d",&A[i]);
 
  j=partition(p,r-1);
  
  for(i=0;i<r;i++){
    // if(i<r-1)printf("%d ",A[i]);
     if(i==j)printf("[%d] ",A[i]);
     else if(i<r-1)printf("%d ",A[i]);
     else printf("%d\n",A[i]);
  }
  return 0;
}
int partition(int p,int r){
  int x,i,j,y;
  x = A[r];
  i = p-1;
  
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      y = A[i];
      A[i] =A[j];
      A[j]=y;
    }
  }
  y = A[i+1];
  A[i+1] = A[r];
  A[r] = y;
  //printf("a\n");
  return i+1;
}

Measured memory_bytes: 984
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    char s[120],ans[10]="keyence";
    scanf("%s",s);
    if (strncmp(s,ans,7)==0){
        printf("YES\n");
        return 0;
    }
    if (strncmp(s+strlen(s)-7,ans,7)==0){
        printf("YES\n");
        return 0;
    }
    int count=0,last=6;
    for (int i=0; i<strlen(s); i++){
        if (ans[count]==s[i]){
            count++;
        } else {
            break;
        }
    }
    for (int i=strlen(s)-1; i>=0; i--){
        if (ans[last]==s[i]){
            last--;
        } else {
            break;
        }
        if (count-1==last){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

string dec2four (int n)
{
	string res = "";

	while ( n > 0 ){
		res += n % 4 + '0';
		n /= 4;
	} // end while

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

	return res;
}
int main()
{
//	cut here before submit 
//	freopen ("testcase.dec24", "r", stdin );
	string str = "";
	string res = "";
	int n;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;

		if (n == -1 ){
			break;
		} // end if
		if (n == 0){
			res = "0";
		}else{
			res = dec2four (n);
		} // end if

		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

void primes(vi& p, const int N) {
	vb ok(N + 1, true);
	ok[0] = false;
	ok[1] = false;
	FOR(i, 2, N + 1) {
		if (!ok[i]) continue;
		for (int j = i * 2; j < N + 1; j += i) {
			ok[j] = false;
		}
	}

	FOR(i, 2, N + 1) {
		if (ok[i]) p.push_back(i);
	}
}

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

	int N; cin >> N;
	const ll MOD = 1e9 + 7;

	vi p;
	primes(p, N);

	map<int, ll> cnt;
	for (int n : p) {
		cnt[n] = 0;
	}

	FOR(i, 2, N + 1) {
		for (int j : p) {
			int t = i;
			while (t % j == 0) {
				cnt[j]++;
				t /= j;
			}
		}
	}

	ll ans = 1;
	for (int n : p) {
		if (cnt[n] == 0) continue;
		ans *= (cnt[n] + 1);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define mnx 1000001
#define pr pair<ll,ll>
#define ez 
using namespace std;


void masterstroke()
{   ll x,a;
	cin>>x>>a;
	if(x<a){
		cout<<0<<endl;
	}
	else{
		cout<<10<<endl;
	}
}


int main(){

	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)
	masterstroke();

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define ls rt<<1
#define rs rt<<1|1
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 5e5+5;
const ll MOD = 1e9+7;

int seq[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int k;
    cin >> k;
    cout << seq[k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  int h = 0,w = 0;
  int i = 0,j = 0;

  for(;;){
    scanf("%d %d",&h,&w);

    if( (h == 0) && ( w == 0) ){
      break;
    } else {
      for( i = 0;i < h;i++){
        for(j = 0;j <w;j++){
          if(i == 0|| i == (h -1)||j == 0 || j == (w-1)){
            printf("#");
          }else{
            printf(".");
          }
        }
        puts("");
      }
      puts("");
  }
  }
  return 0;
}

Measured memory_bytes: 588
/*
TASK: AGC141 - E - Who Says a Pun?
LANG: C++
NAME: picolylamine
*/
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>

using namespace std;

#define N_MAX 5010

int ret = 0;

void calc(char *str, int len)
{
	int Z[N_MAX];
	Z[0] = len;
	int j = 0;
	for (int i = 1; i < len;){
		for (; i + j < len; j++){
			if (str[j] != str[i + j]){
				break;
			}
		}
		Z[i] = j;

		if (0 == j){
			i++;
			continue;
		}

		int k;
		for (k = 1; k < j; k++){
			if (Z[k] + k < j){
				Z[i + k] = Z[k];
			}
			else{
				break;
			}
		}
		i += k; j -= k;
	}

	for (int i = 0; i < len; i++){
		if (Z[i] <= i){
			ret = max(ret, Z[i]);
		}
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N; scanf("%d", &N);
	char S[N_MAX]; scanf("%s", S);

	for (int i = 0; i < N; i++){
		calc(S + i, N - i);
	}

	printf("%d", ret);


	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = 0;
    if (n == 1)
        ans = b == a ? 1 : 0;
    else if (a <= b)
        ans = (n - 2) * (b - a) + 1;

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


Measured memory_bytes: 256
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    string N; cin >> N;
    cout << count(all(N), '2') << endl;
}





Measured memory_bytes: 3584
package main

import "fmt"

func main() {
	var (
		s string
	)
	week := [7]string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
	fmt.Scan(&s)
	res := 0
	for i := 0; i < 7; i++ {
		if week[i] == s {
			res = (7 - i)
		}
	}
	fmt.Println(res)
}


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

#define ll long long

int K;
int dp[11][11];
string res;

void f(int n, int x, int k)
{
	//printf("%d %d %d\n", n, x, k);
	if (n == 0) return;

	int sum = 0;
	for(int i=max(0, x-1); i<=min(9, x+1); i++)
	{
		int prv = sum;
		sum += dp[n-1][i];
		if (sum >= k)
		{
			res += (char)('0'+i);
			f(n-1, i, k - prv);
			return;
		}
	}
}

int main()
{
	scanf("%d", &K);
	for(int j=0; j<10; j++)
		dp[0][j] = 1;
	for(int i=1; i<=10; i++)
	{
		for(int j=0; j<10; j++)
		{
			if (j) dp[i][j] += dp[i-1][j-1];
			dp[i][j] += dp[i-1][j];
			if (j!=9) dp[i][j] += dp[i-1][j+1];
			//printf("%d %d : %d\n", i, j, dp[i][j]);
		}
	}

	int sum = 0;
	for(int i=0; i<=10; i++)
	{
		for(int j=1; j<10; j++)
		{
			int prv = sum;
			sum += dp[i][j];
			if (sum >= K)
			{
				res += (char)('0'+j);
				f(i, j, K - prv);
				goto END;
			}
		}
	}
	END:
	for(char x : res)
		printf("%c", x);
	return 0;
}

Measured memory_bytes: 256
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;

// d = distance(lower_bound(all(x)), upper_bound(all(x)));

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main(){
  string s; cin >> s; int N=s.size(), k=N, b=0;
  rep(i, 1, N) {
    if (s[i-1] == s[i] && b==0) {
      b=1; k--; i++;
    } else b=0;
  }
  cout << k << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <list>
#include <map>
#include <set>
using namespace std;

int main()
{
	int n;
	while(cin>>n)
	{
		int p[4];
		int x=0;
		for(int a=n;a>0;a/=10)
		{
			p[x]=a%10;
			x++;
		}
		if(p[0]==p[1]&&p[1]==p[2])
		{
			cout<<"Yes"<<endl;
		}
		else if(p[1]==p[2]&&p[2]==p[3])
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
}

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

int main(){
  int N; cin>>N;
  int A[201];
  for(int i=0;i<N;++i) cin>>A[i];
  
  int ans =0;
  while(true){
    bool exist_odd=false;
    for(int i=0;i<N;++i){
      if (A[i]%2==1)exist_odd=true;
    }
    if (exist_odd) break;
    
    for (int j=0;j<N;++j){
      A[j]/=2;
    }
    
    ++ans;
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 256
A = [list(map(int, input().split())) for i in range(3)]

N = int(input())
B = [int(input()) for i in range(N)]

ans='No'

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j]=-1

for i in range(3):
    if sum(A[i])==-3:
        ans='Yes'
    if A[0][i]+A[1][i]+A[2][i]==-3:
        ans='Yes'

if A[0][0]+A[1][1]+A[2][2]==-3:
    ans='Yes'

if A[0][2]+A[1][1]+A[2][0]==-3:
    ans='Yes'

print(ans)

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

int main() {
  long a, b; cin >> a >> b;
  while (b > 0) {
    long r = a % b; a = b; b = r;
  }
  int num = 1;
  for (long i = 2; i <= a; i++) {
    if (i > a / i) {
      num++; break;
    }
    if (a % i == 0) {
      a /= i; num++;
      while (a % i == 0) a /= i;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Button{
	int left,right,top,under,link_index;
	char to_name[21];
};

struct Page{
	char name[21];
	vector<Button> B;
};

int num_page,W,H;
int* buffer;

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}


void func(){

	Page page[101];

	int pointer,buffer_size;

	int num_button;

	for(int i = 0; i < num_page; i++){
		scanf("%s %d",page[i].name,&num_button);

		for(int k = 0; k < num_button;k++){
			Button button;
			scanf("%d %d %d %d %s",&button.left,&button.top,&button.right,&button.under,button.to_name);
			page[i].B.push_back(button);
		}
	}

	for(int i = 0; i < num_page; i++){
		for(int k = 0; k < page[i].B.size();k++){
			for(int p = 0; p < num_page; p++){
				if(strCmp(page[i].B[k].to_name,page[p].name)){
					page[i].B[k].link_index = p;
					break;
				}
			}
		}
	}

	buffer[0] = 0;
	pointer = 0;
	buffer_size = 1;


	int M,tmp_x,tmp_y;
	scanf("%d",&M);

	char order[10];

	for(int loop = 0; loop < M; loop++){
		scanf("%s",order);

		switch(order[0]){
		case 'c':
			scanf("%d %d",&tmp_x,&tmp_y);

			for(int i = 0; i < page[buffer[pointer]].B.size();i++){
				if(tmp_x >= page[buffer[pointer]].B[i].left && tmp_x <= page[buffer[pointer]].B[i].right &&
						tmp_y >= page[buffer[pointer]].B[i].top && tmp_y <= page[buffer[pointer]].B[i].under){
					buffer_size = pointer+1;
					buffer[buffer_size] = page[buffer[pointer]].B[i].link_index;
					buffer_size++;
					pointer++;
					break;
				}
			}
			break;
		case 'b':
			if(pointer > 0)pointer--;
			break;
		case 'f':
			if(pointer < buffer_size-1)pointer++;
			break;
		case 's':
			printf("%s\n",page[buffer[pointer]].name);
			break;
		}
	}

}

int main(){

	buffer = new int[50000];

	while(true){
		scanf("%d",&num_page);
		if(num_page == 0)break;

		scanf("%d %d",&W,&H);

		func();
	}

	return 0;
}

Measured memory_bytes: 3100
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int num;
            while((num = scn.nextInt()) > 0) {
                int min = scn.nextInt();
                int max = scn.nextInt();

                int[] ary = new int[-~num];
                for(int i = 0; i < num; i++) {
                    int tmp = scn.nextInt();
                    ary[i]   -= tmp;
                    ary[-~i] += tmp;
                }

                int gap = 0;
                int ans = 0;
                for(int i = min; i <= max; i++) {
                    if(gap <= ary[i]) {
                        gap = ary[i];
                        ans = i;
                    }
                }

                System.out.println(ans);
            }
        }
    }
}

Measured memory_bytes: 55712
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

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

    vector<long long> v;
    rep(i,n){
        int x;
        cin >> x;
        if(not v.empty() && x == *(--v.end())) continue;
        v.emplace_back(x);
    }

    int cnt = 0;
    int f = 0;
    int cur = v[0];
    range(i,1,v.size()){
        if(cur < v[i] && f == 0) f = 1;
        else if(cur > v[i] && f == 0) f = 2;

        if(f == 1 && cur > v[i]){
            cnt++;
            f = 0;
        }else if(f == 2 && cur < v[i]){
            cnt++;
            f = 0;
        }
        cur = v[i];
    }
    cnt++;
    cout << cnt << endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b; scanf("%d%d", &a, &b);
	for (int i = 1; i < 1000000; ++i) {
		if ((int)(i*0.08) == a && (int)(i*0.1) == b) {
			printf("%d", i);
			return;
		}
	}
	printf("-1");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n;
  cin >> n;
  rep(i, n) {
    int a;
    cin >> a;
    if (a%2) {
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int main(){
	int x,y,i,xx;
	cin >> x>> y;
	if(x%y==0){
		cout <<-1<<endl;
	}else{
		xx = x%y;
		for(i=1;i>=1;i++){
			if(xx*i%y!=0){
				cout << x*i <<endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
(let* ((n (read))
    (a 0)
    (b n))

    (loop for i from 1 while (> b 0) do
        (progn
            (incf a (rem b 10))
            (setq b (floor (/ b 10)))
        )
    )
    (if (zerop (rem n a))
        (princ "Yes")
        (princ "No")    
    )
)

Measured memory_bytes: 23728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[m];
		int[] d = new int[m];
		
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		
		for(int i = 0; i < m; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			int min = distance(a[i] , b[i], c[0], d[0]);
			int jmin = 0;
			for(int j = 1; j < m; j++) {
				if(distance(a[i], b[i], c[j], d[j]) < min) {
					min = distance(a[i], b[i], c[j], d[j]);
					jmin = j;
				}
			}
			System.out.println(jmin + 1);
		}
	}
	
	private static int distance(int sx, int sy, int tx, int ty) {
		return Math.abs(sx - tx) + Math.abs(sy - ty);
	}
}


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

int n,m,a,b;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();m=rd();a=rd();b=rd();
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) if ((i<=b&&j<=a)||(i>b&&j>a)) putchar('1');
		else putchar('0');
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <map>
using namespace std;

int N,A[200200];

bool chk(int d)
{
	map<int, int> chk;
	for (int i=1;i<N;i++) if (A[i-1] >= A[i]){
		int x = A[i];
		while (1){
			auto I = chk.lower_bound(x+1);
			if (I != chk.end()) chk.erase(I);
			else break;
		}
		while (x > 0){
			auto I = chk.find(x);
			int v = (I == chk.end()) ? 0 : I->second;
			if (v + 1 == d){
				chk.erase(x); x--;
			}
			else{
				if (I == chk.end()) chk[x] = 1;
				else I->second++;
				break;
			}
		}
		if (x == 0) return false;
	}
	return true;
}

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++) scanf ("%d",&A[i]);

	bool g = 1;
	for (int i=1;i<N;i++) if (A[i-1] >= A[i]) g = 0;
	if (g){
		puts("1");
		return 0;
	}

	int l = 1, r = N;
	while (l + 1 < r){
		int m = (l + r) / 2;
		if (chk(m)) r = m;
		else l = m;
	}
	printf ("%d\n",r);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <stdio.h>
using namespace std;
using ll =long long;

int main (void) {
  ll s[3];
  cin >> s[0] >> s[1] >> s[2];
  if (s[0]*s[1]*s[2]%2==0){
    cout << 0;
    return 0;
  }
  sort(s,s+3);
  ll ans=s[0]*s[1];
  cout << ans;
  return 0;
}

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

long f(long n, long x){
  if(n == -1) return 0;
  return n/x + 1;  //ある数nの中にある数xの倍数がいくつあるかの式 +1は0があるから
}

int main(){
  long a, b, x;
  cin >> a >> b >> x;
  
  cout << f(b, x) - f(a-1, x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int s[1000];
  int n;
  double mean, square_a;
  while (cin >> n) {
    if (!n) break;
    mean = 0;
    for (int i{0}; i < n; ++i) {
      cin >> s[i];
      mean += s[i];
    }
    mean /= n;
    square_a = 0;
    for (int i{0}; i < n; ++i) {
      square_a += (s[i] - mean) * (s[i] - mean);
    }
    cout << fixed << setprecision(5) << sqrt(square_a / n) << '\n';
  }
}



Measured memory_bytes: 3196
while 1:
	n,w = map(int,raw_input().split())
	if (n,w) == (0,0):
		break
	hist = []
	value = [int(raw_input()) for i in range(n)]
	value.sort()
	tmphist = 0.0
	tmpthle = w
	for v in value:
		while v >= tmpthle:
			hist.append(tmphist)
			tmphist = 0.0
			tmpthle += w
		tmphist += 1.0
	else :
		hist.append(tmphist)
	while hist[-1] == 0:
		hist.pop()
	highest = max(hist)
	col = len(hist)
	print sum([(col-1.0-i) / (col-1.0) * hist[i] / highest for i in range(col)]) + 0.01

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int a,b;
  cin>>a>>b;
  int ans=-1;
  for(int i=1;i<10100;i++){
  	if(i*8/100==a&&i*10/100==b){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> b(n-1);
	rep(i,n-1) cin >> b[i];
	/*
	vector<int> a(n);
	a[0] = b[0];
	for(int i = 1; i < n-1; i++) a[i] = min(b[i-1], b[i]);
	a[n-1] = b[n-2];
	*/
	
	int res = 0;
	res += b[0];
	for(int i = 1; i < n-1; i++) res += min(b[i-1], b[i]);
	res += b[n-2];
	cout << res << endl;
	return 0;
}

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

#define ll long long int

void init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
}

int main()
{
    init();
    int t,n;
    ll a,b,c,d,e;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='?')
            s[i]='D';
    }
    cout<<s<<endl;
    return 0;
}


/*



*/



Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const string yes = "Yes";
const string no = "No";

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

  if (N==M) cout << yes << endl;
  else cout << no << endl;

  return 0;
}


Measured memory_bytes: 256
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define bf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 1100009
#define MIN -1
#define M 10000007
#define mod 100000
#define INF 5e17
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define mp make_pair
#define pb push_back
bool desc(ll i, ll j) { return i > j; }
ll d, x, y;
void gcd(ll A, ll B) {
    if(B == 0) {d = A;x = 1;y = 0;}
    else {
        gcd(B, A%B);ll temp = x;x = y;y = temp - (A/B)*y;
    }
}
 
ll power(ll x,ll n)
{   if(n==0) return 1;
    else if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
ll ar[MAX],not_prime[MAX],dp[2009][2009];
priority_queue< P > pq[MAX];
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<=100;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=100;i+=p) not_prime[i]=1;
        }
    }
}
ll bc(ll n, ll k)
{if (k==0 || k==n)
    return 1;
 return  bc(n-1, k-1) + bc(n-1, k);
}
ll modi(ll i){
    gcd(i,M);
    return (x%M+M)%M;
}
int main(){
    bf; 
    ll i,j,k,e=0,o=0,flag,lans,r=0,t,l,ans,q,sum,p,n; //dont use d,x,y 
    string s;
    cin>>n>>p;
    for(i=1;i<=n;i++){
        cin>>ar[i];
        if(ar[i]%2) o++;
        else e++;
    }
    ans=power(2,e); //cout<<bc(24,2)<<" ";
    if(p%2){
        r=0;
        for(i=1;i<=o;i+=2){
            r+=bc(o,i);
        }
        cout<<ans*r;
    }
    else{
        r=0;
        for(i=0;i<=o;i+=2){
            r+=bc(o,i);
        }
        cout<<ans*r;
    }
    return 0;
} 

Measured memory_bytes: 37120
#include<iostream>

using namespace std;

int main()
{
    int S,s,m,h;
    int a;
    cin>>S;

    h = S/3600;
    a = S - 3600 * h;
    m = a/60;
    s = a - 60 * m;
    
    cout<<h<<':'<<m<<':'<<s<<'\n';
}


Measured memory_bytes: 3116
/*
 *  stay hungry, stay foolish, stay home.
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define ml cout<<"\n"
 
#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define in insert
#define ff first
#define ss second
#define mod 1000000007

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	ios_base::sync_with_stdio(false);
     	cin.tie(NULL);
    	cout.tie(NULL);    
	ll n,k;cin>>n>>k;
	ll s=0;
	rep(i,0,k){
		ll a;cin>>a;
		s+=a;
	}
	if(s>n){
		cout<<-1<<endl;
	}else{
		cout<<n-s<<endl;
	}
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include <stdlib.h>
int main(){
  int x,y,n;
  scanf("%d %d %d",&n,&x,&y);
  int a,b;
  a=x<y?x:y;
  b=x+y-n;
  if(b<0)
    b=0;
  printf("%d %d",a,b);

  return 0;
}

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

int main() {
  vector<int> time;
  int i;
  for (i = 0; i < 2; i++) {
    int n;
    cin >> n;
    int j;
    for (size_t j = 0; j < n; j++) {
      int h, m;
      cin >> h >> m;
      time.push_back(h * 100 + m);
    }
  }

  sort(time.begin(), time.end());
  time.erase(unique(time.begin(), time.end()), time.end());

  for (i = 0; i < time.size(); i++) {
    cout << time[i] / 100 << ':' << setfill('0') << setw(2) << time[i] % 100;
    if (i != time.size() - 1) {
      cout << ' ';
    }
  }
  cout << endl;


  return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> idx(N);
  for (int i = 0; i < N; i++) {
    idx[i] = i;
  }
  sort(idx.begin(), idx.end(), [&](int a, int b) { return A[a] < A[b]; });
  for (int i = 0; i < N; i++) {
    cout << idx[i] + 1 << (i == N - 1 ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 1664
import sys
x=int(input())
n = x
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
if x in primes:
    del primes[-1]
if x==2:
    print(2)
    sys.exit()
if x%2==0:
    x=x+1
while True:
    if all(x%i!=0 for i in primes):
        print(x)
        sys.exit()
    else:
        x=x+2

Measured memory_bytes: 14312
N = int(input())

ans = 1 
top_count = -1
for i in range(2, N + 1):
    temp = i
    count = 0
    while temp % 2 == 0:
        count += 1
        temp = temp / 2
    if top_count < count:
        ans = i
        top_count = count

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define PI 3.14159265358979323846264338327950288419716939937510
#define mp make_pair
#define vvl vector<vector<ll>>
#define vll vector<ll>
#define vpll vector<pll>
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll pwr(ll x, ll y)
{
    ll res = 1;
    x = x ;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) ;
        y = y >> 1;
        x = (x * x) ;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x,  z, w, g, key,  k, n, m, a, b, t, c, d;
    ll t2, t3, t4, t1, t5, t6;
    string s;
    //t=1;
    ll ans = -inf - 1;
    cin >> a >> b >> c >> d;
    t1 = b * d;
    ans = std::max(ans, t1);
    t2 = b * c;
    ans = std::max(ans, t2);
    t3 = a * d;
    ans = std::max(ans, t3);
    t4 = a * c;
    ans = std::max(ans, t4);
    cout << ans;


    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector<vector<int> > G;
vector<int> ans;
queue<int> q;

int main(){

    int N, M;
    cin >> N >> M;
    ans.assign(N, -1);
    G.resize(N);


    for(int i=0; i< M; ++i){
        int A, B;
        cin >> A >> B;
        --A; --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    q.push(0);
    ans[0] = 1;

    bool can_go = false;

    while(q.size() > 0){
        int cur_node = q.front();
        q.pop();
        for(auto next_node: G[cur_node]){
            if( ans[next_node] == -1 ){
                ans[next_node] = cur_node;
                q.push(next_node);
                can_go = true;
            }
        }
    }

    if(can_go){
        cout << "Yes" << endl;
        for(int i=1; i<N; ++i){
            if( ans[i] == -1 ){
                cout << "No" << endl;
            }else{
                cout << ans[i]+1 << endl;
            }
        }
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 10184
import sys
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
A = list(map(int, input().split()))

import heapq

A = [-a for a in A]
heapq.heapify(A)

for _ in range(m):
    tmp = heapq.heappop(A)/2
    heapq.heappush(A, tmp)
    
ans = 0
for a in A:
    ans += -int(a)
print(ans)

Measured memory_bytes: 93208
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var c = new int[3].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

		var f = new[] { 0, 1, 2 };
		for (int a0 = 0; a0 <= 100; a0++)
		{
			var b = Array.ConvertAll(c[0], x => x - a0);

			for (int a1 = 0; a1 <= 100; a1++)
			{
				if (!Array.TrueForAll(f, j => a1 + b[j] == c[1][j])) continue;

				for (int a2 = 0; a2 <= 100; a2++)
					if (Array.TrueForAll(f, j => a2 + b[j] == c[2][j])) { Console.WriteLine("Yes"); return; }
			}
		}
		Console.WriteLine("No");
	}
}


Measured memory_bytes: 13524