akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

ll n,k,a,b,c,d,x,y,z,m,l;
ll ans;
vecl arr(N);
ll dp[509][509];
ll pre[N];



void test_case() {

    
   int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int &i:a)cin>>i;
	sort(a.begin(),a.end());
	int lo=-1e18,hi=1e18;
	while((hi-lo)>1)
	{
		int mid=(lo+hi)/2;
		int sum=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]>0)
				sum+=lower_bound(a.begin(),a.end(),(long double)mid/a[i])-a.begin();
			if(a[i]<0)sum+=n-(upper_bound(a.begin(),a.end(),(long double)mid/a[i])-a.begin());
			if(a[i]==0)
			{
				if(mid>0)
				sum+=n;
			}
			if(a[i]*a[i]<mid)sum--;
		}
		if(sum/2<k){lo=mid;}
		else hi=mid;
 
	}
	cout<<lo<<"\n";







}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}


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

using namespace std;

int main(){
        int prime[1000000];
        bool is_prime[1000000];
        int i=2,j=2,n,count=0;
        while(scanf("%d",&n) != EOF){
                int p = 0;
                for(i = 0;i <= n; i++){
                        is_prime[i] = true;
                }
                is_prime[0]=is_prime[1]=false;
                for(i = 2; i<=n;i++){
                        if(is_prime[i]){
                                prime[p++] = i;
                                for(j = 2*i; j <= n; j+=i) is_prime[j] = false;
                        }
                }
                cout << p << endl;
        }
        return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; i64 p; scanf("%d%d%lld", &n, &m, &p);
	std::vector<int> loop, a(m), b(m);
	std::vector<i64> c(m);
	std::vector<std::vector<std::pair<int, i64>>> g(n), rg(n);
	for(int i = 0; i < m; i++) {
		scanf("%d%d%lld", &a[i], &b[i], &c[i]);
		if(a[i] == b[i]) {
			a[i]--; b[i]--;
			loop.push_back(i);
			continue;
		}
		
		g[a[i] - 1].push_back({b[i] - 1, c[i] - p});
		rg[b[i] - 1].push_back({a[i] - 1, c[i] - p});
		a[i]--; b[i]--;
	}

	std::vector<bool> from0(n, false), from1(n, false); from0[0] = from1[n - 1] = true;
	std::queue<int> qu; qu.push(n - 1);
	while(!qu.empty()) {
		auto p = qu.front(); qu.pop();

		for(auto e: rg[p]) {
			if(from1[e.first]) continue;
			from1[e.first] = true;
			qu.push(e.first);
		}
	}
	qu.push(0);
	while(!qu.empty()) {
		auto p = qu.front(); qu.pop();

		for(auto e: g[p]) {
			if(from0[e.first]) continue;
			from0[e.first] = true;
			qu.push(e.first);
		}
	}
	
	for(auto i: loop) {
		if(c[i] - p <= 0) continue;
		if(c[i] - p > 0 and from0[a[i]] and from1[a[i]]) {
			printf("-1\n");
			return 0;
		}
	}

	std::vector<std::vector<std::pair<int, i64>>> G(n);
	for(int i = 0; i < m; i++) {
		if(a[i] == b[i]) continue;
		if(from0[a[i]] and from1[b[i]]) {
			G[a[i]].push_back({b[i], p - c[i]});
		}
	}
		
	bool isFinish = true;
	const i64 INF = 1LL << 60;
	std::vector<i64> dist(n, INF); dist[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int v = 0; v < n; v++) {
			for(auto e: G[v]) {
				if(dist[v] != INF and dist[e.first] > dist[v] + e.second) {
					dist[e.first] = dist[v] + e.second;
					if(i == n - 1) isFinish = false;
				}
			}
		}
	}
	if(!isFinish) {
		printf("-1\n");
		return 0;
	}

	printf("%lld\n", std::max(0LL, -dist[n - 1]));
	return 0;
}


Measured memory_bytes: 896
main(){
	int n,pm,pe,pj,ps;
	for(;scanf("%d",&n),n;){
		for(;n--;){
			scanf("%d%d%d",&pm,&pe,&pj);
			ps=pm+pe+pj;
			if(pm==100||pe==100||pj==100||pm+pe>=180||ps>=240)
				puts("A");
			else if(ps>=210||ps>=150&&(pm>=80||pe>=80))
				puts("B");
			else
				puts("C");
		}
	}
	exit(0);
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s, t;
    cin >> s >> t;
    string ans = "No";
    for (char c = 'a'; c <= 'z'; c++) {
        if (s + c == t) ans = "Yes";
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

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

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

    ll cdiv = b/c - (a-1)/c;
    ll ddiv = b/d - (a-1)/d;
    ll all = b-a+1;
    ll x = c*d;
    //printf("%lld ",x);
    ll r;
    ll gcd;
    if(c>d){
        r = c % d;
        while(r!=0){
            c = d;
            d = r;
            r = c % d;
        }
        gcd = x/d;
    }
    else{
        r = d % c;
        while(r!=0){
            d = c;
            c = r;
            r = d % c;
        }
        gcd = x/c;
    }
    ll gcdiv = b/gcd - (a-1)/gcd;
    //printf("%lld %lld %lld\n",gcd,cdiv,ddiv);
    cout<<all+gcdiv-cdiv-ddiv;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from bisect import bisect_left, bisect
N = int(input())
A = sorted(tuple(map(int, input().split())))
B = sorted(tuple(map(int, input().split())))
C = sorted(tuple(map(int, input().split())))

AB = []
result = 0
 
for i in range(N):
    AB = bisect_left(A, B[i])
    BC = N - bisect(C, B[i])
    result += AB * BC

print(result)

Measured memory_bytes: 23360
#include <stdio.h>

int main(void)
{
  int a, b, c;

  scanf("%d/%d/%d",&a,&b,&c);

  if(a<2019){ printf("Heisei\n");
                return 0; }
  else if(a>2019) {printf("TBD\n");
        return 0; }
  if(b<04)  {printf("Heisei\n");
                return 0; }
  else if(b>04) {printf("TBD\n");
        return 0; }
  if(c<=30) {printf("Heisei\n");
                return 0;;}
  else if(c>30) {printf("TBD\n");
        return 0; }
  return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    char[] buf = new char[0];

    public static void main(String[] args) {
        FastScanner scanner = new FastScanner(System.in);
        int n = scanner.nextInt();
        List<Integer> L = new ArrayList();
        for(int i=0;i<n;i++) {
            L.add(scanner.nextInt());
        }
        Collections.sort(L);

        long answer = 0;
        for(int i=0;i<n - 2;i++) {
            for(int j=i+1;j<n - 1;j++) {
                int a = L.get(i);
                int b = L.get(j);
                int lower = Math.max(a - b, b - a);
                int upper = a + b;
                int lowerResult = Math.max(~Collections.binarySearch(L, lower + 1, (x, y) -> x - y >= 0 ? 1 : -1), j + 1);
                int upperResult = Math.min(~Collections.binarySearch(L, upper - 1, (x, y) -> x.compareTo(y) > 0 ? 1 : -1), n);

                if (upperResult - lowerResult > 0) {
                    answer += (upperResult - lowerResult);
                }
            }
        }
        System.out.println(answer);
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

}

Measured memory_bytes: 46760
#include<iostream>
using namespace std;
int main() {
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if(r <= x && x <= W - r && r <= y && y <= H - r) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
return 0;
}
    


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

void InputNumbers(int& Count,std::vector<int>& Numbers);
void OutputNumbers(const std::vector<int>& Numbers);
int BubbleSort(std::vector<int>& Numbers);

int main()
{
	int Count = 0;
	std::vector<int> Numbers;
	InputNumbers(Count,Numbers);
	
	int SwapCount = BubbleSort(Numbers);
	
	OutputNumbers(Numbers);
	std::cout << SwapCount << std::endl;
	
	return 0;
}

void InputNumbers(int& Count,std::vector<int>& Numbers)
{
	std::cin >> Count;
	for(int i=0;i<Count;i++)
	{
		int Input = 0;
		std::cin >> Input;
		Numbers.push_back(Input);
	}
}

void OutputNumbers(const std::vector<int>& Numbers)
{
	for(unsigned int i=0;i<Numbers.size();i++)
	{
		std::cout << Numbers[i] << std::flush;
		if(i != Numbers.size() - 1)
		{
			std::cout << " " << std::flush;
		}else{
			std::cout << std::endl;
		}
	}
}

int BubbleSort(std::vector<int>& Numbers)
{
	int SwapCount = 0;
	for(unsigned int i = 0;i<Numbers.size();i++)
	{
		for(unsigned int j = Numbers.size() - 1;j > i;j--)
		{
			if(Numbers[j] < Numbers[j-1])
			{
				std::swap(Numbers[j],Numbers[j-1]);
				SwapCount++;
			}
		}
	}
	return SwapCount;
}

Measured memory_bytes: 1220
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200000;
int n, s;
vector < int > ans;
vector < int > g[N];
set < int > h[N];
int a[N], p[N], dep[N];
void dfs(int v, int c, int d = 0, int pr = -1){
    if (c == 1)
    h[d].insert(v); else{
        if (h[d].find(v) == h[d].end()) return;
        h[d].erase(v);
    }
    p[v] = pr;
    dep[v] = d;
    //cout << v << endl;
    for (auto u: g[v]){
        dfs(u, c, d + 1, v);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (i != 1)
        g[a[i]].pb(i);
	}
	int ans = 0;
	if (a[1] != 1) ans++;
	dfs(1, 1);
	p[1] = 1;
	//cout << "!" << endl;
	for (int i = n; i > k; i--){
        while(!h[i].empty()){
            ans++;
            int v = *h[i].begin();
            for (int j = 1; j < k; j++){
                v = p[v];
            }
          //  cout << "v = " << v << endl;
            dfs(v, 0, dep[v]);
        }
	}
	cout << ans;
}


Measured memory_bytes: 30848
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<ctype.h>
#include<stack>
#include<math.h>
#include <string>
#include<algorithm>
#include<iomanip>
#define _for(i,a,b) for(int i = (a);i < (b);i++)
#define mset(x) memset(x,0,sizeof(x));
using namespace std;

int main() {
	long long int c,k,ans,ans1;
	cin>>c>>k;
	ans = c * k;
	ans1 = (c + k) * 2;
	cout<<ans<<" ";
	cout<<ans1<<endl;
	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main () {
	int x;
	cin >> x;
	int a = x / 100, b = x % 100;
	int k = b/5;
	if (a >= k) {
		if (b % 5 == 0) {
			puts("1");
			return 0;
		}
		cout << (a - k > 0) << endl;
	}
	else {
		puts("0");
	}
}

Measured memory_bytes: 256
if __name__ == '__main__':
    while True:
        try:
            n = int(input())
            counter = 0
            for a in range(10):
                for b in range(10):
                    for c in range(10):
                        for d in range(10):
                            if a + b + c + d == n:
                                counter += 1
            print(counter)
        except EOFError:
            break


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

void solve(long long N, std::vector<long long> T, std::vector<long long> A){
    ll a = 1;
    ll b = 1;
    for (int i = 0; i < N; i++) {
	ll c = T[i];
	ll d = A[i];
        ll multi = max(a%c ? (a/c + 1) : (a/c), b%d ? (b/d + 1) : (b/d));
	a = c * multi;
	b = d * multi;
    }
    cout << a + b << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> T(N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&T[i]);
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(T), std::move(A));
    return 0;
}


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

vector<int> adj[100005];
long long int dp[100005][2];

long long int mod=1e9+7;

long long int solve( int root, int prev, int col){
   //coloring the root with black color
   if(dp[root][col]!=-1)
   	return dp[root][col];
   dp[root][col]=1;
   if( col==0){
     for(int v:adj[root]){
     	if(v!=prev){
          solve(v,root, 1);
          dp[root][col]*=dp[v][1];
          dp[root][col]%=mod;
     	}
     }  
   } 
   else{
     
     for(int v:adj[root]){
     	if(v!=prev){
     	  solve(v,root,0);
     	  solve(v,root, 1);	
          dp[root][col]*=((dp[v][0]+dp[v][1])%mod);
          dp[root][col]%=mod;
     	}
     } 
   }
   return dp[root][col]%mod;
  
}


int main(){

int n;
cin>>n;
int u,v;
for(int i=0;i<n-1;i++){
	cin>>u;
	cin>>v;
	adj[u].push_back(v);
	adj[v].push_back(u);
}
for(int i=1;i<=n;i++){
   for(int j=0;j<2;j++)
   	dp[i][j]=-1;
}

cout<<((solve(1,-1,0)+ solve(1,-1,1))%mod)<<endl;
}

Measured memory_bytes: 14208
//  A

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
    int n[200],d[200],ans_a, ans_b,x[200],y[200];
    int i,l = 0,a,max_x,max_y,min_x,min_y;
    
    while(1){
        
        scanf("%d",&a);
        x[0] = 0; y[0] = 0;
        if(a == 0)
            break;
        if(a == 1){
            ans_a = 1;
            ans_b = 1;
        }
        else{
            for(i=0;i<a-1;i++)
                scanf("%d %d",&n[i],&d[i]);
            max_x = x[0];
            max_y = y[0];
            min_x = x[0];
            min_y = y[0];
            
            for(i=0;i<a-1;i++){
                if(n[i] == 0){
                    x[i+1] = 0;
                    y[i+1] = 0;
                }
                else {
                    x[i+1] = x[n[i]];
                    y[i+1] = y[n[i]];
                }
                
                switch(d[i]){
                    case 0:x[i+1]--;break;
                    case 1:y[i+1]--;break;
                    case 2:x[i+1]++;break;
                    case 3:y[i+1]++;break;
                }
                
                if(max_x < x[i+1] )
                    max_x = x[i+1];
                if(max_y < y[i+1])
                    max_y = y[i+1];
                if(min_x > x[i+1] )
                    min_x = x[i+1];
                if(min_y > y[i+1])
                    min_y = y[i+1];
            }
            ans_a = max_x + abs(min_x) + 1;
            ans_b = max_y + abs(min_y) + 1;
        }
        cout << ans_a << " " << ans_b << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
l = [list(map(int, input().split())) for _ in range(3)]

for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            b1 = l[0][0] - a1
            b2 = l[0][1] - a1
            b3 = l[0][2] - a1

            a = [a1, a2, a3]
            b = [b1, b2, b3]

            cnt = 0
            for i in range(3):
                for j in range(3):
                    if l[i][j] == a[i] + b[j]:
                        cnt += 1
            if cnt == 9:
                print("Yes")
                exit()
print("No")


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

struct eds{
    long long a,b;

    bool operator<(const eds& another) const{
        if(a != another.a)return a < another.a;
        return b < another.b;
    }
};
int main(){
    int n;
    cin >> n;
    vector<eds> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec[i].b >> vec[i].a;
    }
    int count=0;
    bool t=true;
    sort(vec.begin(), vec.end());
    for(int i=0;i<n;i++){
        count+=vec[i].b;
        if(count>vec[i].a)t=false;
    }
    if(t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> v;
    v.resize(N);
    rep(i, N){
        v[i] = i;
    }
//    cout << "test"<<endl;
    int tst;
    vector<int> P;
    vector<int> Q;
    rep(i, N){
        cin >> tst;
        tst--;
        P.push_back(tst);
    }

    rep(i, N){
        cin >> tst;
        tst--;
        Q.push_back(tst);
    }
    int c = 1;
    int a = -1;
    int b = -1;
    do {

        bool flag1 = true;
        bool flag2 = true;
        rep(i, N){
            if (v[i] != P[i]) flag1 = false;
            if (v[i] != Q[i]) flag2 = false;
        }
        if (flag1) a = c;
        if (flag2) b = c;
        c++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		for(int i = 0; i < N; i++)
			h[i] = sc.nextInt();
		int[] dp = new int[N];
		dp[1] = Math.abs(h[1]-h[0]);
		for(int i = 2; i < N; i++)
			dp[i] = Math.min(dp[i-1] + Math.abs(h[i]-h[i-1]), dp[i-2] + Math.abs(h[i]-h[i-2]));
		System.out.println(dp[N-1]);

	}

}


Measured memory_bytes: 50772
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		int now = 0;
		int count = 1;
		for (int i = 0; i < 1000001; i++) {
			if (a[now] == 2) {
				System.out.println(count);
				return;
			} else {
				now = a[now]-1;
				count++;
			}
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 53096
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
vector<ll> G[200001];
bool used[200001]={};
void search(ll d[],ll x,ll sum){
  if(used[x])return;
  used[x]=true;
  d[x]+=sum;
  for(int i=0;i<G[x].size();i++){
    search(d,G[x][i],d[x]);
  }
}
int main(){
  ll n,q,a,b,p,x,mrank=0;
  cin >> n >> q;
  ll rank[n],rsum[n];
  ll d[n];
  bool en[n];
  ll vad[n];
  fill(vad,vad+n,0);
  fill(rank,rank+n,-1);
  fill(en,en+n,false);
  fill(rsum,rsum+n,0);
  fill(d,d+n,0);
  rank[0]=0;
  for(ll i=0;i<n-1;i++){
    cin >> a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(ll i=0;i<q;i++){
    cin >> p >> x;
    p--;
    d[p]+=x;
  }
  search(d,0,0);
  for(ll i=0;i<n;i++){
    cout << d[i]<<" ";
  }
  cout << endl;
}

Measured memory_bytes: 29312
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l,ans,num;
ll x[500005],y[500005],z[500005];
bool dame,flag;
char s[500005],t[500005];
bool used[500005];

int main(){
    cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
		y[i] = x[i];
	}
	sort(x,x+n);
	sort(y,y+n);
	reverse(x,x+n);
	for(j=32;j>=0;j--){
		num = (1 << j);
		//p(num);
		for(i=0;i<n;i++){
			if(used[i])continue;
			a = num - x[i];
			b = lb(y,y+n,a+1) - lb(y,y+n,a);
			if(b >= 1){
				c = lb(y,y+n,a) - lb(y,y+n,-1);
				c = n - 1 - c;
				c -= (b - 1);
				while(i == c){
					c++;
				}
				while(used[c] && x[c+100] == a && used[c + 100]){
					c += 100; 
				}
				while(used[c]){
					c++;
				}
				while(i == c){
					c++;
				}
				if(!used[c] && x[c] == a){
					used[c] = true;
					used[i] = true;
					ans++;
					//pe(i);p(c);
				}
			}
		}
	}
	p(ans);


    return 0;
}

Measured memory_bytes: 33024
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
c = []
for i in range(M):
  p, y = map(int, input().split())
  c.append((p, y, i))
c.sort(key = lambda x: (x[0], x[1]))
table = [0] * (N + 1)
res = [None] * M
for i in range(M):
  p, y, j = c[i]
  table[p] += 1
  res[j] = str(p).zfill(6) + str(table[p]).zfill(6)
for i in range(M):
  print(res[i])


Measured memory_bytes: 77276
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,k) for (int i = 0; i < (int)(k); i++)
#define all(c) begin(c), end(c)

int main() {
    int a, b;
    while (cin >> a >> b) {
        if (a <= 0 && 0 <= b) {
            cout << "Zero";
        } else if(a > 0){
            cout << "Positive";
        } else {
            a = min(a, -1);
            b = min(b, -1);
            int d = b - a + 1;
            cout << (d % 2 == 0 ? "Positive" : "Negative");
        }
        cout << endl;
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


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

    rep(i, n) {
        a[i] -= i+1;
    }
    sort(a.begin(), a.end());

    ll tmp = a[a.size()/2];

    ll ans = 0;
    rep(i, n) {
        ans += abs(a[i] - tmp);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int N,W,v,w,ans=0;
    scanf("%d %d",&N,&W);
    vector<int> dp(W+1);
    fill(dp.begin(), dp.end(), 0);
    for(int i=0;i<N;i++){
        scanf("%d %d",&v,&w);
        dp[w]=max(dp[w],v);
        for(int j=0;j<W-w+1;j++){
            if(dp[j]!=0){
                dp[j+w]=max(dp[j+w],dp[j]+v);
            }
        }
    }
    for(int i=0;i<W+1;i++){
        ans=max(ans,dp[i]);
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
    for (int i = 0; i < 3000; i++) {
        int x_i, y_i;
        cin >> x_i >> y_i;
        
        if ((x_i == 0) && (y_i == 0)) {
          break;
        }
         else {
             cout << min(x_i, y_i) << " " << max(x_i, y_i) << endl;
         }
    }
}


Measured memory_bytes: 3136
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

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

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll dp[100001];
bool vis[100001];
void dfs(vl g[], ll n)
{
	vis[n]=true;

	for(ll x:g[n])
	{
		if(!vis[x])
			dfs(g,x);
		dp[n]=max(dp[n],1+dp[x]);
	}
}
void solve(){
	ll n,m;
	cin>>n>>m;
	vl g[n+1];
	ll i;

	rep(i,m)
	{
		ll l,r;
		cin>>l>>r;
		g[l].eb(r);
	}
	fill(dp+1,dp+n+1,1);

	fr(i,1,n)
	{
		if(!vis[i])
			dfs(g,i);
	}
	ll mx=*max_element(dp+1,dp+n+1);
	cout<<mx-1;
}

int main(){
	//fio();
	fast

	solve();
	return 0;
}

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

using namespace std;

void solve()
{
	int N, A, B, C, X;
	while(cin >> N >> A >> B >> C >> X)
	{
		if(!N && !A && !B && !C && !X)
		{
			break;
		}
		vector<int> Vec(N);
		for(int i = 0; i < N; ++i)
		{
			cin >> Vec[i];
		}
		int count = 0;
		for(int i = 0; i < N; ++i)
		{
			while(Vec[i] != X)
			{
				X = (A * X + B) % C;
				++count;
				if(count > 10000)
				{
					cout << -1 << endl;
					goto NEXT;
				}
			}
			X = (A * X + B) % C;
			++count;
		}
		cout << count - 1 << endl;
NEXT:
		;
	}
}

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

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<cmath>

#define MIN(a,b) (a)>(b)?(b):(a)

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	vector<int> A(N,0);
	for (int i = 0,h; i < N; i++) {
		cin >> h;
		H[i] = h;
	}
	for (int i = 1; i < N; i++) {
		if (H[i-1] >= H[i]) {
			A[i]=A[i-1]+1;
		}
		else {
			A[i] = 0;
		}
	}
	cout << *max_element(A.begin(),A.end());
	return 0;
}

Measured memory_bytes: 1024
from networkx.utils.union_find import UnionFind
n,q=map(int,input().split())
a=[[int(i) for i in input().split()] for _ in range(q)]

uf=UnionFind()
for i in range(n):
     uf.union(i,i)
for x in a:
     if x[0]==0:
          uf.union(x[1],x[2])
     else:
          f=x[1]
          while True:
               if f==uf.parents[f]:break
               f=uf.parents[f]
          b=x[2]
          while True:
               if b==uf.parents[b]:break
               b=uf.parents[b]
          print(1 if f==b else 0)

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

int main(){
  int h, w;
  cin >> h >> w;

  char s[50][50];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> s[i][j];
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      int cnt = 0;

      if(s[i][j] == '#') cout << '#';

      else{
	if(i != 0){
	  if(s[i-1][j] == '#') cnt++;
	  if(j != 0 && s[i-1][j-1] == '#') cnt++;
	  if(j != w-1 && s[i-1][j+1] == '#') cnt++;
	}
      
	if(i != h-1){
	  if(s[i+1][j] == '#') cnt++;
	  if(j != 0 && s[i+1][j-1] == '#') cnt++;
	  if(j != w-1 && s[i+1][j+1] == '#') cnt++;
	}
      
	if(j != 0){
	  if(s[i][j-1] == '#') cnt++;
	}
    
	if(j != w-1){
	  if(s[i][j+1] == '#') cnt++;
	}

	cout << cnt;
      }
    }

    cout << endl;
     
  }
  
  return 0;

}

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

int factorial(int n) {
    int f = 1;
    REP(i, 1, n) f *= i;
    return f;
}

int main() {
    int N, M; cin >> N >> M;
    int G[N][N] = {0};
    REP(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a][b] = 1;
        G[b][a] = 1;
    }

    vector<int> order(N);
    REP(i, 0, N) order[i] = i;

    int ans = 0;
    REP(i, 0, factorial(N)) {
        bool ok = true;
        REP(j, 0, N - 1) {
            if (G[order[j]][order[j + 1]] != 1) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
        next_permutation(order.begin(), order.end());
    }

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

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

using namespace std;

int main() {
    int n;

    cin >> n;

    vector<int> a(n);

    for (int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int r = 0;

    for (int j = 0; j < n; ++j) {
        if (j % 2 == 0)
            r += a.at(j);
        else
            r -= a.at(j);
    }

    cout << r;

}


Measured memory_bytes: 256
# -*- coding=utf-8 -*-
price = [int(input()) for p in range(int(input()))]

# N ^ 2 のコード → ダメダメ
# max_ = price[1] - price[0]
# for i in range(1, len(price)):
#     for j in range(0, i):
#         if price[i] - price[j] >= max_:
#             max_ = price[i] - price[j]

# Nのコード　→ いけるぞ！
# まずは最小値を調査
min_ = price[0]
max_ = -1000000000000
for i in range(1, len(price)):
    if price[i] - min_ > max_:
        max_ = price[i] - min_

    if price[i] < min_:
        min_ = price[i]

print(max_)



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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N+1,0);
    a.at(0)=2;
    a.at(1)=1;
    for(ll i=2;i<a.size(); i++){
        a.at(i)=a.at(i-1)+a.at(i-2);
        }
    cout << a.at(N) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;

using P = pair<int, int>;


int main() {
    int W, a, b;
    cin >> W >> a >> b;
    if (a + W < b) {
        cout << b - (a + W) << endl;
    } else if (b + W < a) {
        cout << a - (b + W) << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


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

    ll n;
    
    cin >> n;

    ll ntmp = n;
    map<ll,ll> numlist;

    ll a = 2;
    numlist[a] = 0;
    while(ntmp >= a*a){
        if(ntmp%a == 0){
            ntmp/=a;
            numlist[a]++;
        }else{
            a++;
            if(ntmp%a == 0)
                numlist[a] = 0;
        }
    }
    if(ntmp > 1)
        numlist[ntmp]++;

    print(numlist);

    ll ans = 0;
    for(auto& p: numlist){
        ll limit = p.second;
        ll use = 1;
        while(limit > 0){
            limit -= use;
            if(limit >= 0){
                ans++;
            }
            use++;
        }
        print(limit, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int h;
		Scanner in = new Scanner(System.in);
		h = in.nextInt();
		int[] heap = new int[h];
		for(int i = 0; i < h; i++) {
			heap[i] = in.nextInt();
		}
		for(int i = h/2; i >= 0; i--) {
			heap = maxHeapify(heap, i, h);
		}
		for(int n: heap) {
			System.out.print(" " + n);
		}
		System.out.println();
	}
	
	public static int[] maxHeapify(int[] a, int i, int h) {
		int l = (2 * i) + 1;
		int r = (2 * i) + 2;
		int largest;
		
		if(l < h && a[l] > a[i]) {
			largest = l;
		}
		else {
			largest = i;
		}
		if(r < h && a[r] > a[largest]) {
			largest = r;
		}
		if(largest != i) {
			int temp = a[i];
			a[i] = a[largest];
			a[largest] = temp;
			return maxHeapify(a, largest, h);
		}
		else {
			return a;
		}
	}
}


Measured memory_bytes: 167276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string process(int x, int y){
  x = 1000000 + x;
  y = 1000000 + y;
  string xx = to_string(x);
  string yy = to_string(y);
  return xx.substr(1,6) + yy.substr(1,6);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  vector<pair<int, int>> pr(m);
  for(int i=0; i<m; i++){
    cin >> p[i] >> y[i];
    pr[i] = make_pair(y[i], i);
  }
  vector<int> num(n+1);
  string ans[100010];
  sort(pr.begin(), pr.end());
  for(int i=0; i<m; i++){
    int t1 = pr[i].first;
    int t2 = pr[i].second;
    num[p[t2]]++;
    ans[t2] = process(p[t2], num[p[t2]]);
  }
  for(int i=0; i<m; i++) {
    cout << ans[i] << endl;
  }
}


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

bool can_add_suff(string s, string t) {
	return s.size() >= t.size() &&
		s.compare(0, t.size(), t) == 0;
}

bool check_pref(string s, string t) {
	if (s.size() == t.size()) {
		return true;
	}
	if (s.size() < t.size()) {
		return false;
	}
	return s.at(t.size()) == 'd' || s.at(t.size()) == 'e';
}

void Main() {
	string s;
	cin >> s;
	string t("");


	string ret = "YES";
	while (s.size() > 0) {
		string t("");
		if (can_add_suff(s, "dreamer")) {
			t = "dreamer";
			if (check_pref(s, t)) {
				s = s.erase(0, t.size());
				continue;
			}
		}
		if (can_add_suff(s, "dream")) {
			t = "dream";
			if (check_pref(s, t)) {
				s = s.erase(0, t.size());
				continue;
			}
		}
		if (can_add_suff(s, "eraser")) {
			t = "eraser";
			if (check_pref(s, t)) {
				s = s.erase(0, t.size());
				continue;
			}
		}
		if (can_add_suff(s, "erase")) {
			t = "erase";
			if (check_pref(s, t)) {
				s = s.erase(0, t.size());
				continue;
			}
		}
		ret = "NO";
		break;
	}

	cout << ret << endl;
}

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


Measured memory_bytes: 512
#include <iostream>
#define int long long
using namespace std;

signed main() {
  int A, B, K;
  cin >> A >> B >> K;
  
  if (A > K) {
    cout << A - K << " " << B << endl;
  } else {
    if (A + B < K) cout << 0 << " " << 0 << endl;
    else cout << 0 << " " << A + B - K << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
int main()
{
 int t;cin>>t;
 int b=0,c=0,d=0,e=0;
 for(int i=0;i<t;i++)
 {
     string a;
     getline(cin>>ws,a);
     if(a[0]=='A'&&a[1]=='C')b++;
     else if(a[0]=='W'&&a[1]=='A')c++;
     else if(a[0]=='T'&&a[1]=='L'&&a[2]=='E')d++;
    else if(a[0]=='R'&&a[1]=='E')e++;

 }
cout<<"AC "<<"x "<<b<<endl;
cout<<"WA "<<"x "<<c<<endl;
cout<<"TLE "<<"x "<<d<<endl;
cout<<"RE "<<"x "<<e<<endl;
}


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

/*テストコードをコピーさせていただき、一度提出させていただきます*/

using LL = long long;
 
 int main() {
 
     int N;
     cin >> N;
 
     vector<int> a(N + 1);
     for (int i = 1; i <= N; i++) {
         cin >> a[i];
     }
 
     vector<int> ans;
     vector<int> b(N + 1, 0);
     for (int i = N; i >= 1; i--) {
         int sum = 0;
         int j = 1;
         while(i * j <= N){ sum += b[i*j]; ++j; }

         if ((sum + a[i]) % 2 == 1) {
             b[i]++;
             ans.push_back(i);
         }
     }
 
     reverse(ans.begin(), ans.end());
 
     cout << ans.size() << endl;
     for(auto x: ans) cout << x << " ";
 
 }

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int main(){
 char a[100],  b[100],  c[100];
 scanf("%s %s %s", &a, &b, &c);
 
 int akhirA= strlen(a)-1;
 int akhirB= strlen(b)-1;
 if(a[akhirA] == b[0] && b[akhirB] == c[0]){
  puts("YES");
 }
 else{
  puts("NO");
 }
 return 0;
}

Measured memory_bytes: 1660
#include <stdio.h>
int main()
{
    int x, i;
    
    for (i = 1; i > 0; i++) {
        scanf ("%d", &x);
        if (x == 0) {
            break;
        }
        printf ("Case %d: %d\n", i, x);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PAIR pair<double, double>
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
#define PI acos(-1)
const LL MOD = (LL)1e9+7;
const LL INF = (LL)1e9+7;
const LL INFLL = (LL)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

string str;
int n;

vector<vector<int>> dp;

int func(int i, int j){
	if(j>=n)return 0;
	if(str[i] != str[j]) return 0;
	if(dp[i][j]>=0)return dp[i][j];
	return dp[i][j] = 1 + func(i+1, j+1);
}

int main(){
	cin >> n >> str;
	dp.resize(n, vector<int>(n, -1));

	LL ans = 0;
	REP(i, n){
		for(int j=i+1;j<n;++j){
			chmax(ans, min(j-i, func(i, j)));  
		}
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 98304
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

class DisjointSet {
public:
	// ２つのグループを１つにまとめる　と　2つの要素が同じグループに所属しているかどうかを判定する
	// 木が深くなればなるほど効率が悪くなるので、
	// rankを使うことにより必要以上に深さが大きくなることがないように管理する
	vector<int>rank, p, S; // p->parent  S[findSet(v)] ->連結成分の大きさ
	DisjointSet() {}
	DisjointSet(int size) {

		S.resize(size, 1);
		rank.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}
	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	bool same(int x, int y) {   // 判定する
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) { // 連結するときにはこれを使う
		if (same(x, y))return;
		link(findSet(x), findSet(y));
	}
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}

		S[x] = S[y] = S[x] + S[y];
	}
	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);// path compression
		}
		return p[x];
	}
	int connectedComponentSize(int x) {
		return S[findSet(x)];
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<vector<int>>v(N);
	set<int>spoken;
	DisjointSet union_find(M);

	rep(i, 0, N) {
		int K; cin >> K;
		rep(j, 0, K) {
			int l; cin >> l;
			l--;
			v[i].emplace_back(l);
			spoken.insert(l);

			union_find.unite(v[i][0], l);

		}
	}

	cout << (spoken.size() == union_find.connectedComponentSize(v[0][0]) ? "YES" : "NO") << endl;


	return 0;
}

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

class C
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Enumerable.Range(0, n).Select(i => new string(Console.ReadLine().OrderBy(s => s).ToArray())).GroupBy(s => s).Where(g => g.Count() > 1).Select(g => g.Count()).Sum(c => (long)c * (c - 1) / 2);
        Console.WriteLine(a);
    }
}


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

struct	ModCombi {
	int	sup;
	int	mod;
	vector<int64_t>	fact;
	vector<int64_t>	inv;
	vector<int64_t>	inv_fact;
	ModCombi(int sup, int mod):
		sup(sup), mod(mod), fact(sup), inv(sup), inv_fact(sup) {
		assert(1 < sup && sup <= static_cast<int>(1e+7));
		fact.at(0) = fact.at(1) = 1;
		inv.at(1) = 1;
		inv_fact.at(0) = inv_fact.at(1) = 1;
		for (int i = 2; i < sup; ++i) {
			fact.at(i) = fact.at(i - 1) * i % mod;
			inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
			inv_fact.at(i) = inv.at(i) * inv_fact.at(i - 1) % mod;
		}
	}
	int64_t	calc(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fact.at(n) * (inv_fact.at(k) * inv_fact.at(n - k) % mod) % mod;
	}
};

int64_t	modpow(int64_t a, int64_t n, int mod)
{
	int64_t	res = 1;
	while (n > 0) {
		if (n & 1)
			res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int	main()
{
	const static int	mod = 998244353;
	int	N, M, K;
	cin >> N >> M >> K;
	ModCombi	modcombi(N + 1, mod);
	int64_t	total = 0;
	for (int k = 0; k <= K; ++k) {
		int64_t	num_combi = modcombi.calc(N - 1, k);
		int64_t	color_pattern = modpow(M - 1, N - 1 - k, mod) * M % mod;
		total = (total + num_combi * color_pattern % mod) % mod;
	}
	cout << total << endl;
}


Measured memory_bytes: 7948
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    string s, t; cin >> s >> t;
    ll s_size = s.size(), t_size = t.size();

    vector<vector<ll>> dp(s_size+1, vector<ll>(t_size+1));
    
    for(ll i = 0; i < s_size; i++){
        for(ll j = 0; j < t_size; j++){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else{
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    ll i = s_size, j = t_size;
    string ans = "";
    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }else if(dp[i][j] == dp[i][j-1]){
            j--;
        }else{
            ans = s[i-1] + ans;
            i--; j--;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define ll long long int
#define NMAX 1000005

using namespace std;

ifstream fin("test.in");
ofstream fout("test.out");

ll n, val, i, x, nrMutat;
struct numar{
    ll val;
    ll index;
};
numar N[NMAX];
int criteriu(numar a, numar b){
    if(a.val < b.val)
        return 1;
    return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(i=1; i<=n; i++){
        cin >> x;
        N[i].val = x;
        N[i].index = i;
        }
    sort(N+1, N+n+1, criteriu);
    for(i=1; i<=n; i++){
        if((i%2) != (N[i].index%2))
            ++nrMutat;
    }
    cout << nrMutat/2 << '\n';
    return 0;
}

Measured memory_bytes: 1792