akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n; ans=1;
    int e=2;
    while(n>1){
        int t=n/2;
        ans+=e;
        n/=2; e*=2;
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 250010
#define ll long long
ll qpow(ll x,ll y,ll p){
	ll r=1;
	for (;y;y>>=1,x=x*x%p)
		if (y&1)
			r=r*x%p;
	return r;
}
template<int x,int p>
	struct hsh{
		int v;
		hsh<x,p> operator<<(int n){return {v*qpow(x,p-1+n,p)%p};}
		hsh<x,p> operator>>(int n){return {v*qpow(x,p-1-n,p)%p};}
		hsh<x,p> operator+(hsh<x,p> o){return {(v+o.v+p)%p};}
		hsh<x,p> operator-(hsh<x,p> o){return {(v-o.v+p)%p};}
		hsh<x,p> operator+(int o){return {(v+o+p)%p};}
		hsh<x,p> operator-(int o){return {(v-o+p)%p};}
		bool operator==(hsh<x,p> o){return v==o.v;}
	};
typedef hsh<89,1000000007> H1;
typedef hsh<91,1000000009> H2;
typedef hsh<97,19260817> H3;
struct Table{
	H1 key1;
	H2 key2;
	int cnt;
} h[19260817];
int n;
char s[N];
int sum[N];
H1 f1[N];
H2 f2[N];
H3 f3[N];
int find(H1 key1,H2 key2,H3 key3){
	int i=key3.v;
	for (;h[i].cnt && !(key1==h[i].key1 && key2==h[i].key2);++i==19260817?i=0:0);
	return i;
}
void insert(H1 key1,H2 key2,H3 key3){
	int w=find(key1,key2,key3);
	h[w].key1=key1,h[w].key2=key2;
	h[w].cnt++;
}
int main(){
	scanf("%d%s",&n,s+1);	
	for (int i=1;i<=n;++i)
		sum[i]=sum[i-1]+(s[i]=='<'?-1:s[i]=='>'?1:0);
	for (int i=n;i>=1;--i)
		if (s[i]=='<')
			f1[i]=f1[i+1]>>1,f2[i]=f2[i+1]>>1,f3[i]=f3[i+1]>>1;
		else if (s[i]=='>')
			f1[i]=f1[i+1]<<1,f2[i]=f2[i+1]<<1,f3[i]=f3[i+1]<<1;
		else if (s[i]=='+')
			f1[i]=f1[i+1]+1,f2[i]=f2[i+1]+1,f3[i]=f3[i+1]+1;
		else
			f1[i]=f1[i+1]-1,f2[i]=f2[i+1]-1,f3[i]=f3[i+1]-1;
	ll ans=0;
	for (int i=1;i<=n;++i){
		insert(f1[i]-f1[1]<<sum[i-1],f2[i]-f2[1]<<sum[i-1],f3[i]-f3[1]<<sum[i-1]);
		int w=find(f1[i+1]<<sum[i],f2[i+1]<<sum[i],f3[i+1]<<sum[i]);
		ans+=h[w].cnt;
	}
	printf("%lld\n",ans);
	return 0;
}





















Measured memory_bytes: 229048
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int X, K;
	cin >> X >> K;
	int r[100002];
	rep1(i, K) cin >> r[i];
	r[0] = 0;
	r[K + 1] = 2e9;

	int L = 0;
	int R = X;
	int takasa = 0;
	int katamuki = -1;
	int *ri = r;

	int Q;
	cin >> Q;
	rep(i, Q) {
		int t, a;
		cin >> t >> a;
		
		while (t > *(ri + 1)) {
			takasa += katamuki * (*(ri + 1) - *ri);
			if (katamuki < 0) {
				L -= min(0, takasa + L);
				R -= min(0, takasa + R);
			}
			else {
				L -= max(0, takasa + L - X);
				R -= max(0, takasa + R - X);
			}
			ri++;
			katamuki *= -1;
		}
		chmax(a, L);
		chmin(a, R);
		a += takasa + katamuki * (t - *ri);
		chmax(a, 0);
		chmin(a, X);
		co(a);
	}

	Would you please return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int main()
{
	int a, b, c;
	int i,count=0;

	scanf("%d %d %d",&a, &b, &c);
	for(i=a;i<=b;i++){
		if((c % i) == 0)
			count++;
	}
	printf("%d\n", count);

	return 0;
}

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

namespace ABC124A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var raw_input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var A = raw_input[0];
            var B = raw_input[1];

            var ans = 0;

            if (A < B)
            {
                ans += B;
                B--;
            }
            else
            {
                ans += A;
                A--;
            }

            if (A < B)
            {
                ans += B;
                B--;
            }
            else
            {
                ans += A;
                A--;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,i,m,sum=0;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)cin>>arr[i];
    m=arr[0];
    for(i=0;i<n;i++)
    {
        if(arr[i]>m)m=arr[i];
        else sum+=m-arr[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ull mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

vl fact(3005);

ll Fact(ll n){
	if(fact[n]) return fact[n];
	if(!n) return fact[n]=1;
	return fact[n]=Fact(n-1)*n%mod;
}

ll Div(ll n,ll m){
	return n*Pow_mod(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(Fact(n),Fact(n-k)*Fact(k)%mod);
}

int n,m;
string s;

int ff(int l,int r){
	int t=0;
	for(int i=l;i<r;i++) t+=s[i]-'0';
	return t;
}

ll f(vp a){
	int l=a[0].first,r=a[0].second,t=ff(l,r);
	vl dp(n+1);
	dp[t]++;
	for(int i=1;i<a.size();i++){
		int L=a[i].first,R=a[i].second;
		t=ff(r,R);
		vl DP(n+1);
		for(int j=0;j<=r-l;j++) for(int k=max(0,L-r+j);k<=min(j,L-l);k++){
			(DP[j-k+t]+=nCk(L-l,k)*dp[j])%=mod;
		}
		l=L,r=R;dp=DP;
	}
	ll res=0;
	for(int i=0;i<=r-l;i++) (res+=dp[i]*nCk(r-l,i))%=mod;
	return res;
}

int main(){
	cin>>n>>m>>s;
	vp a;
	ll res=1;
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		if(a.empty()) a.push_back({l-1,r});
		else{
			int t=a.back().second;
			if(t<l){
				(res*=f(a))%=mod;
				a.clear();
			}
			if(t<r) a.push_back({l-1,r});
		}
	}
	if(a.size()) (res*=f(a))%=mod;
	cout<<res<<endl;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b<c+d)
    cout << "Right" << endl;
  else if(a+b==c+d)
    cout << "Balanced" << endl;
  else
    cout << "Left" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using edge = int;
using graph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;


int main() {
	ll  n,x;cin >>n>> x;
	ll ans=n-1;
	if(x>=n){++ans;}
    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
sum=0
sum1=0
l=list(map(int,input().split()))
for i in range(n):
  sum+=l[i]
for i in range(n):
  sum1+=l[i]
  if sum1>=sum//2:
    sum2=sum1-l[i]
    break
print(min(abs(sum-sum1-sum1),abs(sum-sum2-sum2)))

Measured memory_bytes: 26396
#include <stdio.h>

int triangle (int a, int b, int c) {
	if ((a*a == b*b + c*c) ||
		(b*b == c*c + a*a) ||
		(c*c == a*a + b*b)) {
		return (1);
	}

	return (0);
}

int main (void) {
	int i;
	int n;
	int a, b, c;
	int flag;

	while (scanf("%d", &n)==1) {
		for (i=0; i<n; i++) {
			scanf ("%d %d %d", &a, &b, &c);
			flag = triangle (a, b, c);

			if (flag == 1) {
				printf ("YES\n");
			}else{
				printf ("NO\n");
			}
		}
		
	}

	return (0);
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void)
{
int a,b;
char op;

while(1){
scanf("%d %c %d",&a,&op,&b);
if(op=='+'){
printf("%d\n",a+b);
}
else if(op=='-'){
printf("%d\n",a-b);
}
else if(op=='*'){
printf("%d\n",a*b);
}
else if(op=='/'){
printf("%d\n",a/b);
}
else if(op=='?'){
break;
}
}
return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	int ok = 0;
	for (auto x: a) {
		if (x * 4 * m >= sum) {
			ok++;
		}
	}

	cout << (ok >= m ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun,  4th Aug 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

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

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << "\t"; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

// Given an array, find the sum of products of all subsets of length 
// greater than n/2.

// dp[i][j] : value obtained among the first i elements by 
// 			  taking subsets of size j only.

// dp[i][j] = dp[i-1][j] + dp[i-1][j-1] * a[i]

void solve() {

	int n;
	cin >> n;

	vector<double> a(n+1,0.0);
	rep(i,1,n+1) cin >> a[i];

	vector<vector<double>> dp(n+1, vector<double>(n+1,0.0));

	dp[0][0] = 0.0;

	rep(i,0,n+1){
		rep(j,0,n+1){
			dp[i][j] = 0.0;
			
			if(i+j == 0) {
				dp[i][j] = 1;
				continue;
			}
			if(i < j) continue;

			if(i != 0) dp[i][j] += dp[i-1][j] * (1-a[i]); 
			if(i != 0 && j != 0) dp[i][j] += dp[i-1][j-1] * a[i];
		}
	}

	double ans = 0;
	rep(i,1,n+1){
		if(i > n/2) ans += dp[n][i];
	}

	for(auto r:dp) pvi(r);

	cout << ans << endl;

}


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

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

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int[][] a = new int[n][n];
        int[][] dist = new int[n][n];
        boolean[][] via = new boolean[n][n];
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++) {
                a[i][j] = in.ni();
                dist[i][j] = a[i][j];
                via[i][j] = false;
            }
        }
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if(k==i||k==j) continue;
                    if(dist[i][j]>=dist[i][k]+dist[k][j]){
                        dist[i][j] = dist[i][k]+dist[k][j];
                        via[i][j] = true;
                    }
                }
            }
        }
        boolean flag = true;
        out:for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if(a[i][j]!=dist[i][j]){
                    flag = false;
                    break out;
                }
            }
        }
        long sum = 0;
        if(flag){
            for (int i = 0; i < n; i++) {
                for (int j = i; j < n; j++) {
                    if(!via[i][j]) sum += dist[i][j];
                }
            }
        }else sum = -1;
        out.println(sum);
    }

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

Measured memory_bytes: 33072
//#12

#include <iostream>
using namespace std;

int main()
{
	int  x, y;
	cin >> x >> y;

	while (!(x == 0 && y == 0))
	{
		if (x > y)
		{
			cout << y << " " << x << endl;
		}
		else
			cout << x << " " << y << endl;
		cin >> x >> y;

	}

	return 0;
}


Measured memory_bytes: 3008
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k  = sc.nextLong();

        long[] a = new long[n];
        long[] aa = new long[n];
        long[] f = new long[n];
        long asum = 0;
        long max = 0;
        for(int i=0; i<n; i++) {
            aa[i] = sc.nextInt();
            asum += aa[i];
        }
        for(int i=0; i<n; i++) {
            f[i] = sc.nextInt();
        }

        Arrays.sort(aa);
        Arrays.sort(f);

        for(int i=0; i<n; i++) {
            a[i] = aa[n-1-i];
        }
        if(asum <= k) {
            System.out.println(0);
            return;
        }

        for(int i=0; i<n; i++) {
            max = Math.max(max, a[i] * f[i]);
        }

        if(k == 0) {
            System.out.println(max);
            return;
        }

        long left = 0;
        long right = max;
        long mid = ((right + left) / 2);
        while(right - left > 1) {
            mid = ((right + left) / 2);
            long sum = 0;
            for(int i=0; i<n; i++) {
                if(a[i] * f[i] > mid) {
                    long c = mid / f[i];
                    sum += a[i] - c;
                }
            }
            if(sum <= k) {
                right = mid;
            } else {
                left = mid;
            }
        }

        System.out.println(right);


    }
}


Measured memory_bytes: 106860
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<int> zalgo(string s){
	int i=1,j=0,n=s.size();
	vector<int> a(n,0);
	a[0]=n;
	while(i<n){
		while(i+j<n && s[j]==s[i+j]) j++;
		a[i]=j;
		if(j==0){i++;continue;}
		int k=1;
		while(i+k<n && k+a[k]<j){a[i+k]=a[k];++k;}
		i+=k;j-=k;
	}
	return a;
}
bool ng[514514];
int cal2(string s2,int p){
	int t=s2.size();//cout<<s2<<' '<<t<<endl;
	vector<int> z=zalgo(s2);
	//memset(ng,false,sizeof(ng));
	REP(i,1,t){
		REP(j,2,t+1){
			if(i*j>t) break;
			if(z[i*(j-1)]>=i){
				//cout<<p<<' '<<i<<' '<<j<<endl;
				if(p==0) ng[i*j]=true;
				else ng[t-i*j]=true;
			}
			else break;
		}
	}
}
int main()
{
	string s;
	cin>>s;int n=s.size();
	memset(ng,false,sizeof(ng));cal2(s,0);
	reverse(All(s));cal2(s,1);
	if(!ng[n]){
		cout<<1<<endl<<1<<endl;return 0;
	}
	int out=0;
	REP(i,1,n){
		if(!ng[i]) out++;
	}
	if(out<1){
		cout<<n<<endl<<1<<endl;return 0;
	}
	cout<<2<<endl<<out<<endl;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

template< typename T >
struct Compress {
  vector< T > xs;

  Compress() = default;

  Compress(const vector< T > &vs) {
    add(vs);
  }

  Compress(const initializer_list< vector< T > > &vs) {
    for(auto &p : vs) add(p);
  }

  void add(const vector< T > &vs) {
    copy(begin(vs), end(vs), back_inserter(xs));
  }

  void add(const T &x) {
    xs.emplace_back(x);
  }

  void build() {
    sort(begin(xs), end(xs));
    xs.erase(unique(begin(xs), end(xs)), end(xs));
  }

  vector< int > get(const vector< T > &vs) const {
    vector< int > ret;
    transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) {
      return lower_bound(begin(xs), end(xs), x) - begin(xs);
    });
    return ret;
  }

  int get(const T &x) const {
    return lower_bound(begin(xs), end(xs), x) - begin(xs);
  }

  const T &operator[](int k) const {
    return xs[k];
  }
};


bool dfs(int e, int v, int p, vector<vector<pair<int,int> >> &g, vector<int> &ans, vector<bool> &went, vector<int> &diff){
  went[v]=true;
  //  cout << "vertex " << v << endl;
  for(auto i:g[v]){
    int to = i.first;
    int ind = i.second;
    if(went[to]) continue;
    dfs(ind,to,v,g,ans,went,diff);
  }
  if(p==-1) return diff[v];
  if(diff[v]){
    ans.pb(e);
    diff[v]^=1;
    if(p!=-1) diff[p]^=1;
  }
  return 0;
  
}

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


  int n,m;
  cin >> n >> m;
  vector<int> a;
  vector<pair<int,int>> cor;

  rep(i,n){
    int ta,tb;
    cin >> ta >> tb;
    cor.pb({ta,tb});
    a.pb(ta);
  }
  Compress<int> comp(a);
  comp.build();

  rep(i,n){
    cor[i]={comp.get(cor[i].first),cor[i].second};
  }
  sort(cor.begin(),cor.end());

  vector<tuple<int,int,int>> code;
  rep(i,m){
    int l,r;
    cin >> l >> r;

    int cl = comp.get(l);
    int cr = comp.get(r);
    if(cl==cr){
      if(comp[cr]!=r){
	continue;
      }
    }
    if(comp[cr]==r) cr++;
    code.pb(make_tuple(cl,cr,i+1));   
  }
  //  rep(i,n) cout << "input state " << cor[i].first << " \n"[i==n-1];
  //  rep(i,code.size()) cout << get<0>(code[i]) << " " << get<1>(code[i]) << endl;

  vector<int> diff;
  diff.pb(cor[0].second);
  rep(i,n-1){
    diff.pb(cor[i].second^cor[i+1].second);
  }
  diff.pb(cor[n-1].second);
  vector<vector<pair<int,int> >> g(n+1);
  vector<bool> went(n+1,false);

  rep(i,code.size()){
    int from = get<0>(code[i]);
    int to = get<1>(code[i]);
    int ind = get<2>(code[i]);
    //cout << "from to ind " << from << " " << to << " " << ind << endl;
    g[from].pb({to,ind});
    g[to].pb({from,ind});
  }
  //  cout << "graph made "<< endl;
  vector<int> ans;
  //  rep(i,n+1) cout << diff[i] << " \n"[i==n];
  rep(i,n+1){
    if(!went[i]){     
      if(dfs(-1,i,-1,g,ans,went,diff)){
	cout << -1 << endl;
	return 0;
      }
    }
  }
  cout << ans.size() << endl;
  sort(ans.begin(),ans.end());
  rep(i,ans.size()){
    cout << ans[i] << " \n"[i==ans.size()-1];
  }
  
  
  return 0;
    

}


Measured memory_bytes: 21868
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> ab(x*y);
  vector<ll> a(x);
  vector<ll> b(y);
  vector<ll> c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  rep(i, x) {
    rep(j, y) {
      ab[i*y+j] = a[i]+b[j];
    }
  }
  sort(ab.rbegin(), ab.rend());
  ab.resize(k);

  vector<ll> abc(k*z);
  rep(i, k) {
    rep(j, z) {
      abc[i*z+j] = ab[i]+c[j];
    }
  }
  sort(abc.rbegin(), abc.rend());
  rep(i, k) {
    cout << abc[i] << '\n';
  }
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
string a;
long long ans;
int main()
{
    cin>>a;
	if(a[0]!='C') ans++;
    if(a[1]!='O') ans++;
    if(a[2]!='D') ans++;
    if(a[3]!='E') ans++;
    if(a[4]!='F') ans++;
    if(a[5]!='E') ans++;
    if(a[6]!='S') ans++;
    if(a[7]!='T') ans++;
    if(a[8]!='I') ans++;
    if(a[9]!='V') ans++;
    if(a[10]!='A') ans++;
    if(a[11]!='L') ans++;
    if(a[12]!='2') ans++;
    if(a[13]!='0') ans++;
    if(a[14]!='1') ans++;
    if(a[15]!='6') ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    if (a - c).abs() <= d ||
       ((a - b).abs() <= d && (b - c).abs() <= d) {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main() {
	int N, num, prev, sum = 0;
	vector<int> vec;
	cin >> N;
	cin >> prev;
	rep(i, N-1) {
		cin >> num;
		if(num == prev+1) {
			vec.push_back(prev-1);
		}
		prev = num;
	}
	rep(i, N) {
		cin >> num;
		sum += num;
	}
	rep(i, N-1) {
		cin >> num;
		rep(j, vec.size()){
			if(i == vec[j]) sum += num;
		}
	}
	cout << sum;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

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

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	ll N, K;
	cin >> N >> K;
	ll ans = 0;
	for (ll b = K + 1;b <= N;b++) {
		ans += (N / b) * (b - K);
		ll rest = N % b;
		if(rest > 0)
			ans += max(0LL, rest - max(0LL, (K - 1)));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int D = reader.nextInt();
		int X = reader.nextInt();
		int ans = X;
		for (int i = 1; i <= N; i++) {
			int num = reader.nextInt();
			ans += (D - 1) / num + 1;
		}
		System.out.print(ans);
	}
}



Measured memory_bytes: 22100
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a[3][3];
    bool appear[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) cin>>a[i][j];
    }
    int n; cin>>n;
    int b[n];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<3;i++){
        for(int j=0;j<n;j++){
            appear[i][j] = false;
            for(int k=0;k<n;k++){
                if(a[i][j]==b[k]) appear[i][j] =true;
            }
        }
    }
    string ans="No";
    for(int i=0;i<3;i++){
        if(appear[i][0] && appear[i][1] && appear[i][2]) ans="Yes";
    }
    for(int i=0;i<3;i++){
        if(appear[0][i]&&appear[1][i]&&appear[2][i]) ans="Yes";
    }
    if(appear[0][0] && appear[1][1]&&appear[2][2]) ans="Yes";
    if(appear[0][2]&&appear[1][1]&&appear[2][0]) ans="Yes";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s1 = sc.next();
      String s2 = sc.next();
      String s3 = sc.next();
      String a = s1.substring(0,1).toUpperCase();
      String b = s2.substring(0,1).toUpperCase();
      String c = s3.substring(0,1).toUpperCase();
      System.out.println(a+b+c);
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, nuevo, path, act;
  cin >> n >> k;
  int arr[n];
  int dp[n];
  memset(dp, 0, sizeof(dp));
  for(int i=0; i<n; ++i){
    cin >> arr[i]; 
  }
  dp[1]=abs(arr[0]-arr[1]);
  for(int i=2; i<n; ++i){
    act=INT_MAX;
    for(int m=i-1; m>=max(0,i-k); --m){
      nuevo = dp[m]+abs(arr[m]-arr[i]);
      act= nuevo<act? nuevo:act;
    }
    dp[i]=act;
  }
  cout << dp[n-1];
  return 0;
}

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

// dfmt off
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;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    writefln("%.10f", cast(real)((N + 1) / 2) / N);
}


Measured memory_bytes: 256
/*
ID: alec3
LANG: C++14
PROG:
*/
/*
We use bitmasks to test every possible combination of
rows and columns and for each we count the number of
black squares it leaves.  If that number is k we've
found a valid answer.
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int pct(int x) { return __builtin_popcount(x); }

ll FIRSTTRUE(function<bool(ll)> f, ll lb, ll rb) {
	while(lb<rb) {
		ll mb=(lb+rb)/2;
		f(mb)?rb=mb:lb=mb+1;
	}
	return lb;
}


int main()
{
    io;
    // store rows as binary strings in g
    string g[6];
    int h, w, k, ans = 0;
    cin >> h >> w >> k;

    // input
    FOR(i, 0, h){
        cin >> g[i];
    }

    // loop through 2 ^ h possibilities
    // 00000 -> 00001 -> 000010 -> 000011 -> 0000100 -> 0000101 -> ...
    // a 1 represents row we're coloring
    // we start with a single row and shift it 0 -> h pos with i2
    FOR (i, 0, 1 << h){
        // loop through 2 ^ w possibilities
        // same as above but a 1 represents a column we choose to color
        // start with a single column and shift it 0 -> w pos with j2
        FOR (j, 0, 1 << w){
            int c = 0;
            // loop through rows
            FOR (i2, 0, h){
                // loop through columns
                FOR (j2, 0, w){
                    // the & returns 1 only if the left operand has in one in the lowest
                    // order position (other positions are irrelevant)

                    // if there is a 0 in the i2th pos and a 0 in the j2th pos than we're keeping
                    // that square so check if it's black.  If it is count it
                    if ((i >> i2 & 1) == 0 && (j >> j2 & 1) == 0 && g[i2][j2] == '#'){
                        c ++;
                    }
                }
            }
            // correct number of black squares.
            if (c == k){
                ans ++;
            }
        }
    }

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


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

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i, x;
	int data[3000];
	int data2[3000];
	for(i = 0;i < 3000;i++){
		scanf("%d %d", &data[i], &data2[i]);
		if(data[i] == 0 && data2[i] == 0) break;
	}
	for(i = 0;i < 3000;i++){
		if(data[i] == 0 && data2[i] == 0){
			break;
		}else {
			if(data[i] > data2[i]){
				x = data[i];
				data[i] = data2[i];
				data2[i] = x;
			}
		}
		printf("%d %d\n", data[i], data2[i]);
	}
	return 0;
}

Measured memory_bytes: 1820
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


int gcd(int a,int b){
	if(a<b)swap(a,b);
	while(b!=0){
		int c = a%b;
		a=b;
		b=c;
	}
	return a;
}

int lcm(int a,int b){
	int d = gcd(a,b);
	return (a/d * b/d)*d;
}

int main(){
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF){
		
		printf("%d %d\n",gcd(a,b),lcm(a,b));
		
	}
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 12;
const int MAX_M = 1005;
const int MAX_BIT = 1 << MAX_N;

int N;
int M;
int A[MAX_M], B[MAX_M], C[MAX_M];

int dp[MAX_M][MAX_BIT];

signed main()
{
  cin >> N >> M;
  REP(m,M) {
    cin >> A[m] >> B[m];
    REP(mm, B[m]) {
      int d; cin >> d; d--;
      C[m] |= (1 << d);
    }
  }

  REP(n,MAX_M) {
    REP(s,MAX_BIT) {
      dp[n][s] = INF_LL;
    }
  }

  int MAX_S = 1 << N;
  dp[0][0] = 0;
  REP(m,M) {
    REP(s,MAX_S) {
      if(dp[m][s] == INF_LL) continue;
      dp[m+1][s] = min(dp[m+1][s], dp[m][s]);
      dp[m+1][s | C[m]] = min(dp[m+1][s | C[m]], dp[m][s] + A[m]);
    }
  }

  
  cout << (dp[M][MAX_S-1] == INF_LL ? -1 : dp[M][MAX_S-1]) << endl;

  return 0;
}


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


long long A[100100],B[100100];

int main(){
	long long n,sum=0,a,b;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	
	for(int i=0;i<=n;i++){
		if(i==0){
			B[i]=abs(A[i]);
			sum+=B[i];
		}
		else if(i==n){
			B[i]=abs(A[i-1]);
			sum+=B[i];
		}
		else{
			B[i]=abs(A[i-1]-A[i]);
			sum+=B[i];
		}
	}
	
	
	for(int i=0;i<n;i++){
		if(i==0)
			a=abs(A[i+1]);
		else
			a=abs(A[i-1]-A[i+1]);
		
		b=B[i]+B[i+1];
		
		if(a==b) cout << sum << endl;
		else if(a<b) cout << sum-(b-a) << endl;
		else if(a>b) cout << sum+(a-b) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

char str[1000][81];
// ツ妥、ツ形ツつオツつゥツづ按つ「
int len[4];
int dx[] = {-1,-1,-1, 0, 1, 1, 1, 0};
int dy[] = {-1, 0, 1, 1, 1, 0,-1,-1};
int n;

void rec(int x, int y, int dir, int hen) {
  str[y][x] = ' ';
  if (len>=0) hen[len]++;
  if (dir >= 0) {               // -1ツ　ツづ債催渉可つセツつッ
    int xx = x+dx[dir];
    int yy = y+dy[dir];
    if (!(xx<0||xx>=80||yy<0||yy>=n) && str[yy][xx]=='*') {
      rec(xx,yy,dir,hen);
      return;
    }
  }
  REP(i,8) {
    int xx = x+dx[i];
    int yy = y+dy[i];
    if (!(xx<0||xx>=80||yy<0||yy>=n) && str[yy][xx]=='*') {
      rec(xx,yy,i,hen+1);
      return;
    }
  }
}

int main() {
  int nn = 0;
  while(cin>>n,n) {
    memset(str,0,sizeof(str));
    cin.ignore();
    REP(i, n) {
      string s;
      getline(cin, s);
      strcpy(str[i], s.c_str());
    }
    map<int, int> res; 
    REP(y,n) {
      REP(x,80) {
        if (str[y][x] == '*') {
          REP(i,3) len[i]=1;
          len[3] = 2;
          rec(x,y,-1,-1);
          sort(len,len+4);
          int area;
          if (len[0]==len[1]) area = (len[2]+len[3])*len[0]/2;
          else if (len[1]==len[2]) area = (len[0]+len[3])*len[1]/2;
          else if (len[2]==len[3]) area = (len[0]+len[1])*len[2]/2;
          res[area]++;
        }
      }
    }
    if (nn)cout << string(10,'-')<<endl;
    else nn=1;
    FOR(it, res) {
      cout << it->first << " " << it->second << endl;
    }
  }
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    vector<int> v(n);
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        cin >> v[a-1];
    }

    vector<int>::iterator it = max_element(v.begin(), v.end());
    cout << (it - v.begin() + 1) << ' ' << *it << endl;

    return 0;
}

Measured memory_bytes: 1192
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
max_bit = 40
dp = [[-1] * 2 for i in range(41)]  # dp[i][j] = 上からi bitまで、j smaller

dp[0][0] = 0
for d in range(max_bit):
    mask = 1 << (max_bit-d-1)

    # Aでもともとd bit目にbitが立っているものの個数
    num = len([1 for i in range(N) if A[i] & mask])
    #print([1 for i in range(N) if A[i] & mask])

    # Xのbit bit目を0,1にしたときのコスト
    cost0 = mask * num
    cost1 = mask * (N - num)
    # smaller -> smaller
    if dp[d][1] != -1:
        # 0でも1でもいい！
        dp[d + 1][1] = max(dp[d + 1][1], dp[d][1] + max(cost0, cost1))

    # exact -> smaller
    if dp[d][0] != -1:
        if K & mask:  # kのd桁目が1だったらXのd桁目は0にする
            dp[d + 1][1] = max(dp[d + 1][1], dp[d][0] + cost0)

    # exact -> exact
    if dp[d][0] != -1:
        if K & mask:
            dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + cost1)
        else:
            dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + cost0)

# print(dp)
print(max(dp[max_bit][0], dp[max_bit][1]))


Measured memory_bytes: 97868
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>

using namespace std;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

int n;
int counter=0;
int glaph[100][100]={{}};
int ans[100][2]={{}};
void depthsearch(int t){
	counter++;
	ans[t][0]=counter;
	for(int i=0;i<n;i++){
		if(glaph[t][i]==1 and ans[i][0]==0){
			depthsearch(i);
		}
	}
	counter++;
	ans[t][1]=counter;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		cin>>k;
		for(int j=0;j<k;j++){
			int l;
			cin>>l;
			l--;
			glaph[i][l]=1;
		}
	}
	for(int i=0;i<n;i++){
		if(ans[i][0]==0){
			depthsearch(i);
		}
	}
	for(int i=0;i<n;i++){
		cout<<(i+1)<<" "<<ans[i][0]<<" "<<ans[i][1]<<endl;
	}
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (10 * max(a, max(b, c))) + ((a + b + c) - max(a, max(b, c))) << endl;
    return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left
        self.right = right

pre = []
def preorder(t, n):
    pre.append(n)
    if t[n].left is not None:
        preorder(t, t[n].left)
    if t[n].right is not None:
        preorder(t, t[n].right)

ino = []
def inorder(t, n):
    if t[n].left is not None:
        inorder(t, t[n].left)
        ino.append(n)
    else:
        ino.append(n)
    if t[n].right is not None:
        inorder(t, t[n].right)
    if n not in ino:
        ino.append(n)

post = []
def postorder(t, n):
    if t[n].left is not None:
        postorder(t, t[n].left)
    if t[n].right is not None:
        postorder(t, t[n].right)
    post.append(n)

n = int(input())
t = {k: Node(None, None, None) for k in range(n)}
for _ in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] != -1:
        t[tmp[1]].parent = tmp[0] # 親
        t[tmp[0]].left = tmp[1] # 左の子
    if tmp[2] != -1:
        t[tmp[2]].parent = tmp[0] # 親
        t[tmp[0]].right = tmp[2] # 右の子

for node in range(n):
    if t[node].parent is None:
        preorder(t, node)
        inorder(t, node)
        postorder(t, node)

print("Preorder")
print(" " + " ".join([str(k) for k in pre]))
print("Inorder")
print(" " + " ".join([str(k) for k in ino]))
print("Postorder")
print(" " + " ".join([str(k) for k in post]))


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string s;
int sum[200005];

int main(void){
    scanf("%d",&n);
    cin >> s;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(s[i]=='#')sum[i+1]++;
        sum[i+1]+=sum[i];
    }
    int ans=n-sum[n];
    int val=0;
    for(int i=0;i<n;i++){
        if(s[i]=='#')val++;
        int bl=sum[n]-sum[i];
        ans=min(ans,val+(n-(i+1)-bl));
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1284
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

#define MAX_V (100010)

int V;
int E;
vector<int> G[MAX_V];

int order_arrival[MAX_V];
int lowest_num[MAX_V];
bool arrived[MAX_V];
// int parent[MAX_V];
int order;
set<int> ans;
int num_child;

void dfs( int cur, int pre ) {
    // parent[cur] = pre;
    arrived[cur] = true;
    order_arrival[cur] = lowest_num[cur] = order;
    order++;
    
    for ( int i = 0; i < G[cur].size(); i++ ) {
	int next = G[cur][i];
	if ( !arrived[next] ) {	// ??????
	    // parent[next] = cur;
	    dfs( next, cur );
	    lowest_num[cur] = min( lowest_num[cur], lowest_num[next] );
	}
	else if ( next != pre ) { // ?????§???????????°??????????????????
	    lowest_num[cur] = min( lowest_num[cur], order_arrival[next] );
	}
    }

    if ( pre == 0 ) num_child++;
    else if ( pre != -1 ) {
	if ( order_arrival[pre] <= lowest_num[cur] ) ans.insert( pre );
    }
}

int main()
{
    scanf("%d %d", &V, &E);
    memset(arrived, false, V);
    order = 0;
    num_child = 0;

    for ( int i = 0; i < E; i++ ) {
	int s, t;
	scanf("%d %d", &s, &t);
	G[s].push_back( t );
	G[t].push_back( s );
    }

    dfs( 0, -1 );
    // for ( int i = 0; i < V; i++ ) {
    // 	printf("order: %d\n", order_arrival[i]);
    // 	printf("lowest: %d\n", lowest_num[i]);
    // }
    
    if ( num_child >= 2 ) ans.insert( 0 );
    
    // sort( ans.begin(), ans.end() );

    for ( set<int>::iterator it = ans.begin(); it != ans.end(); it++ ) {
	printf("%d\n", *it);
    }
    
    return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fto(i, s, e) for(int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for(int i = (s); i < (e); ++i)
#define fdto(i, s, e) for(int i = (s); i >= (e); --i)
#define fat(i, a) for(auto i : a)
#define fit(it, var) for(auto it = (var).begin(); it != (var).end(); ++it)
#define frit(it, var) for(auto it = (var).rbegin(); it != (var).rend(); ++it)

#define bc __builtin_popcountll
#define isbit(x, bit) (((x >> bit) & 1) != 0)
#define onbit(x, bit) (x | (1LL << (bit)))
#define offbit(x, bit) (x & ~(1LL << (bit)))
#define y1 ansdj
#define endl '\n'
#define _bug(...) bug(__func__, __LINE__, __VA_ARGS__)

#define ll long long
#define cd complex<double>
#define ii pair<int, int>
#define pl pair<ll, ll>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()

template<class T, class Cmp = less<T>> using oss = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;

template<class T1, class T2> ostream& operator<<(ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

template<class T> ostream& operator<<(ostream &os, vector<T> const &v) {
	fto1 (i, 0, sz(v)) { os << v[i]; if (i < sz(v)-1) os << ' '; }
	return os;
}

template<class T> void buga(T const &v, int l, int r) { fto (i, l, r) { cout << v[i] << " \n"[i == r]; } }

template<class T> void bug(T const &v) { cout << v << endl; }
template<class T, class... Args> void bug(T const &v, Args const&... args) { cout << v << ' '; bug(args...); }
 
double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
int const maxn = 1e6+3;



int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n; cin >> n;
	
	fto (i, 1, n) {
		if (floor(1.08*i) == n) {
			bug(i);
			return 0;
		}
	}

	bug(":(");

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


Measured memory_bytes: 256
from itertools import product  


N = int(input())  
S = input()  

R_i = [i for i, s in enumerate(S) if s == "R"]  
G_i = [i for i, s in enumerate(S) if s == "G"]  
B_i = {i for i, s in enumerate(S) if s == "B"}  

R = len(R_i)  
G = len(G_i)  
B = len(B_i)  

xs = map(sorted, product(R_i, G_i))  

s = 0  
for x in xs:  
    k = 2 * x[1] - x[0]  # 2j-i  
    if k in B_i:  
        s += 1  
    i = 2 * x[0] - x[1]  # 2j-k  
    if i in B_i:  
        s += 1  
    j = (x[0] + x[1]) / 2  # (i+k)/2  
    if j in B_i:  
        s += 1  

print(R * G * B - s)  

Measured memory_bytes: 9272
H, N = map(int, input().split())

inf = float('inf')
dp = [inf] * (H + 1)
dp[0] = 0
for _ in range(N):
    A, B = map(int, input().split())
    for i in range(H):
        t1 = i + A
        if t1 > H:
            t1 = H
        t2 = dp[i] + B
        if t2 < dp[t1]:
            dp[t1] = t2
print(dp[H])


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> n;
  FOR(i, 1, min(A, B) + 1) {
    if (A % i == 0 && B % i == 0) n.push_back(i);
  }
  cout << n[n.size() - K] << endl;
}

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

int main(){
    unsigned long long n;
    cin>>n;
    vector<long long> a(87);
    a.at(0) = 2;
    a.at(1) = 1;
    for(int i=2; i<87; i++){
        a.at(i) = a.at(i-2) + a.at(i-1);
    }
    cout<<a.at(n)<<endl;
    return 0;
}

Measured memory_bytes: 384