akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<vector>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, int> pli;
 
const int MX = 1<<19;
 
struct Tree{
	int t[MX*2];
	void update(int x, int v){
		x += MX; t[x] = v;
		while(x > 1){
			x /= 2;
			t[x] = min(t[x*2], t[x*2+1]);
		}
	}
	int read(int s, int e){
		s += MX, e += MX;
		int ans = 2e9;
		while(s <= e){
			if( s&1 ) ans = min(ans, t[s++]);
			if( ~e&1 ) ans = min(ans, t[e--]);
			s /= 2, e /= 2;
		}
		return ans;
	}
}mn;
 
struct BIT{
	ll t[MX];
	int read(int x){
		ll ans = 0;
		while(x){
			ans += t[x];
			x -= x&-x;
		}
		return ans;
	}
	void update(int x, int v){
		while(x < MX){
			t[x] += v; x += x&-x;
		}
	}
}sum;
 
int A[MX], B[MX];
 
int main()
{
	int N, Q, cnt = 0;
	ll ans = 0;
	scanf("%d%d", &N, &Q);
	for(int i = 1; i <= 2*N; i++) scanf("%d", A+i);
	for(int i = 1; i <= 2*N; i++) scanf("%d", B+i);
	for(int i = 2; i <= 2*N-1; i++) if( A[i] > B[i] ) cnt++;
	ans += A[1] + A[2*N];
	for(int i = 2; i <= 2*N-1; i++){
		mn.update(i, max(A[i], B[i]) - min(A[i], B[i]));
		ans += max(A[i], B[i]);
	}
 
	for(int i = 1; i <= Q; i++){
		int x, a, b;
		scanf("%d%d%d", &x, &a, &b);
		if( x == 1 || x == 2*N ) ans -= A[x];
		else{
			if( A[x] > B[x] ) cnt--;
			ans -= max(A[x], B[x]);
		}
		A[x] = a; B[x] = b;
		mn.update(x, max(a, b) - min(a, b));
		if( x == 1 || x == 2*N ) ans += A[x];
		else{
			if( A[x] > B[x] ) cnt++;
			ans += max(A[x], B[x]);
		}
		if( cnt%2 == 1 ) printf("%lld\n", ans - mn.read(2, 2*N-1));
		else printf("%lld\n", ans);
	}
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
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());
  
  cout<<a.at(N-1)-a.at(0)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define F first
#define S second
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll h = 0, n = 0;
  cin >> h >> n;
  ll a[n];
  for (ll i = 0; i < n; ++i)
    cin >> a[i], h -= a[i];
  if (h > 0) cout << "No";
  else cout << "Yes";
}



Measured memory_bytes: 4356
import java.io.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int[] a = in.nextIntArray(n);

        int[] ans = new int[n];
        for (int i=0; i < a.length; i++) {
            ans[a[i]-1] = i+1;
        }
        out.println(Arrays.stream(ans).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

using namespace std;


int main() {
  int k; cin >> k;
  string s; cin >> s;
  if (s.size() > k) {
    cout << s.substr(0, k) << "..." << endl;
  }
  else {
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
import sys
import math
N=int(input())
alist=list(map(int,input().split()))

all_GCD=alist[0]
for i in range(1,N):
  all_GCD=math.gcd(all_GCD,alist[i])
  if all_GCD==1:
    break
else:
  print("not coprime")
  sys.exit(0)

max_a=max(alist)  
dlist=[i for i in range(max_a+1)]
for i in range(2,int(max_a**0.5)+1):
  if dlist[i]<i:
    continue
  else:
    for j in range(i**2,max_a+1,i):
      dlist[j]=i  
#print(dlist)

fact_set=set()
for i in range(N):
  ai=alist[i]
  facts=set()
  while ai>1:
    facts.add(dlist[ai])
    ai//=dlist[ai]    
  #print(facts)
  
  for f in facts:
    if f in fact_set:
      print("setwise coprime")
      sys.exit(0)
    else:
      fact_set.add(f)
else:
  print("pairwise coprime")

Measured memory_bytes: 205252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3 + 5;
 ll dp[N][N]={};
/*
    a b c d
  0 0 0 0 0
b 0 0 1 1 1
c 0 0 1 2 2
d 0 0 1 2 3
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s1,s2,ans="";
    cin>>s1>>s2;
    for(int i=1;i<=s1.size();i++){
        for(int j=1;j<=s2.size();j++){
           if(s1[i-1]==s2[j-1]){
            dp[i][j]=1+dp[i-1][j-1];

           }
           else {
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
           }
        }
    }
    int i=s1.size(),j=s2.size();
    while(i&&j){
            if(dp[i][j]==dp[i-1][j]){
                i--;
            }
            else if(dp[i][j]==dp[i][j-1])
                j--;
        else if(dp[i][j]!=dp[i-1][j-1]){
             ans+=s1[i-1];
            i--;
            j--;
        }


    }
    reverse(ans.begin(),ans.end());
  /*for(int i=1;i<=s1.size();i++){
        for(int j=1;j<=s2.size();j++){
         cout<<dp[i][j]<<' ';

        }
        cout<<endl;
    }
*/

cout<<ans;
    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007

#define MAXN 100005

vector<int> adj[MAXN];
int par[MAXN] = {0};
int ans[MAXN];

void bfs(int s){
    queue<int> q;
    q.push(s);
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for(int i=0; i<adj[p].size(); i++){
            int node = adj[p][i];
            if(par[node]==1){
                ans[node]=p;
                q.push(node);
            }
            else{
                par[node]--;
            }
        }
    }
}


signed main(){
    fast;
    // #ifndef ONLINE_JUDGE
    //     freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
    //     freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    // #endif
    int n, m;
    cin>>n>>m;
    int z = n+m-1;
    for(int i=0; i<z; i++){
        int a, b;
        cin>>a>>b;
        adj[a].pb(b);
        par[b]++;
    }
    For(i, 1, n+1){
        if(par[i]==0){
            ans[i] = 0;
            bfs(i);
        }
    }
    For(i, 1, n+1){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 7808
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MAX (101)
#define MOD (1000000007)

using namespace std;

typedef long long ll;

ll a, b, c;

int main() {
    cin >> a >> b >> c;
    
    if ((a < c && b < c) || (a > c && b > c)) {
        cout << "No";
    } else {
        cout << "Yes";
    }
}


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

bool solve(int j, int n, int A[], int m){ // A[j]〜A[n-1]（j >= 0）までの要素を使ってmが作れるか
  if(m == 0){
    return true;
  }
  if(j >= n){
    return false;
  }
  bool res1 = solve(j+1, n, A, m-A[j]); // A[j]を使った上で，A[j+1]〜A[n-1]までの要素を使ってmが作れるか
  bool res2 = solve(j+1, n, A, m);  // A[j]を使わず，A[j+1]〜A[n-1]までの要素を使ってmが作れるか
  return (res1 || res2);
}

int main(){
  int n;
  cin >> n;
  int A[n];
  rep(i,n) cin >> A[i];
  int q;
  cin >> q;
  int m[q];
  rep(i,q) cin >> m[i];
  bool CanMake;

  rep(i,q){
    CanMake = solve(0, n, A, m[i]);
    if(CanMake){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3104
#include <iostream>

int main()
{
    int r, g, b;
    std::cin >> r >> g >> b;
    int rgb = 100 * r + 10 * g + b;
    if (rgb % 4 == 0) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[22][(1<<22)];
int n;
int arr[22][22];
int md = 1e9+7;
long long rec(int x, int mask){
	if(x == n)return 1;
	if(dp[x][mask] != -1)return dp[x][mask];
	long long ret = 0;
	for(int i = 0; i < n; i++){
		if((mask & (1<<i)) == 0 && arr[x][i] == 1){
			int mmask = (mask | (1<<i));
			ret += rec(x+1, mmask);
			ret %=md;
		}
	}
	return dp[x][mask] = ret;
}
int main(){
	for(int j = 0; j < 22; j++)
		for(int i = 0; i <(1<<22); i++)
			dp[j][i] = -1;
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j =0 ; j < n; j++)
			cin >> arr[i][j];
			
	cout << rec(0,0);
}

Measured memory_bytes: 721152
#include <stdio.h>

void swap(int *a, int *b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(void)
{
	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);
	if (!(1 <= x && x <= 100) &&
		!(1 <= y && y <= 100) &&
		!(1 <= z && z <= 100))
		{
			return 0;
		}
	swap(&x, &y);
	swap(&x, &z);
	printf("%d %d %d\n", x, y, z);
	return 0;
}

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




    int main(){
        int r, k;
        int x;
        std::cin >> r >> k >> x;
        for (int i = 0; i < 10; ++i)
        {
            x = x*r-k;
            std::cout << x << "\n";
        }
        return 0;
    }


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,y,s;
	scanf("%d %d",&x,&y);
	while(1)
	{
		if(x<y){s=x;x=y;y=s;}
		if(y==0){break;}
		x=x%y;
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	vector<int> a(3);
	rep(i, 3) cin >> a.at(i);
	sort(a.begin(), a.end());

	int ans = a.at(0) + a.at(1);

	cout << ans << endl;



	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,f[10][100],p[100][11],ma = -INF;
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 10;j++) cin >> f[j][i];
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 11;j++) cin >> p[i][j];
	}
	for(int i = 1;i < (1 << 10);i++){
		int ans = 0;
		for(int j = 0;j < n;j++){
			int cnt = 0;
			for(int k = 0;k < 10;k++){
				if(f[k][j] && ((i >> k) & 1)) cnt++;
			}
			ans += p[j][cnt];
		}
		ma = max(ma,ans);
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,cnt,b[102],m[30],ans;
char c;
int main(){
	scanf("%d\n",&n);
	for(int i=1;i<=n;i++){
		scanf("%c",&c);
		b[i]=c-'a';
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=i;j++)m[b[j]]=1;
		for(int k=i+1;k<=n;k++)
			if(m[b[k]]==1){
				++cnt;	
				m[b[k]]=0;
			}
		ans=max(ans,cnt);
		cnt=0;
		memset(m,0,sizeof(m));
	}
	printf("%d",ans);
} 

Measured memory_bytes: 128
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;
int n;
long long ans;
int main()
{
	cin>>n;
	ans=(n*800)-(n/15)*200;
	cout<<ans<<"\n";

	return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

template <typename T>
class SegTree {
   private:
    int n;
    T ID_ELEM;
    vector<T> dat;
    T op(const T &a, const T &b) { return a | b; }

   public:
    SegTree(int n, T ID_ELEM) : ID_ELEM(ID_ELEM) {
        this->n = 1;
        while (this->n < n) {
            this->n *= 2;
        }
        dat.resize(2 * this->n - 1, ID_ELEM);
    }

    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = n;
        if (a >= r || b <= l) {
            return ID_ELEM;
        } else if (a <= l && r <= b) {
            return dat[k];
        }
        int mid = (l + r) / 2;
        return op(query(a, b, k * 2 + 1, l, mid), query(a, b, k * 2 + 2, mid, r));
    }

    void update(int k, T a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(int k) {
        k += n - 1;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    T &at(int k) { return dat[k + n - 1]; }
    void print() {
        int lf = 0;
        cerr << "Debug:" << endl;
        rep(i, 2 * n - 1) {
            cerr << "(" << dat[i] << ")\t";
            if (i == lf) {
                lf = lf * 2 + 2;
                cerr << endl;
            }
        }
    }
    T get(int k) { return dat[k + n - 1]; }
};

int n, q;
string str;

int main() {
    cin >> n;
    cin >> str;
    cin >> q;
    SegTree<int> st(n, int());
    rep(i, n) { st.update(i, 1 << (int)(str[i] - 'a')); }
    rep(i, q) {
        int c;
        scanf("%d", &c);
        if (c == 1) {
            int iq;
            char ch;
            scanf("%d %c", &iq, &ch);
            if (st.at(iq - 1) != 1 << (int)(ch - 'a')) {
                int s = 1 << (int)(ch - 'a');
                st.update(iq - 1, s);
            }
        } else {
            int l, r;
            scanf("%d%d", &l, &r);
            printf("%d\n", __builtin_popcount(st.query(l - 1, r)));
        }
    }
    return 0;
}

Measured memory_bytes: 4996
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int x,y;
  while(cin >> x >> y){
    int ans = 0;
    if(x == 1) ans += 300000;
    if(x == 2) ans += 200000;
    if(x == 3) ans += 100000;
    if(y == 1) ans += 300000;
    if(y == 2) ans += 200000;
    if(y == 3) ans += 100000;
    if(x == 1 and y == 1) ans += 400000;
    cout << ans << endl;
  }

  return 0;
}


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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int a, b;
    double t;

    cin >> a >> b >> t;
    t += 0.5;

    cout << b * ((int) (t / a)) << endl;


    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
B = [list(map(int, input().split())) for _ in range(M)]

pt = []
G = [[None, 1] for x in range(N+1)]

def find(x):
    n = G[x]
    c = []
    while not n[0] is None:
        c.append(n)
        n = n[0]
    for ci in c:
        ci[0] = n
    return n

cnt = 0
while len(B):
    x, y = B.pop()
    wx = find(x)
    wy = find(y)
    if wx is wy:
        pt.append(0)
    else:
        pt.append(wx[1] * wy[1])
        wx[1] += wy[1]
        wy[0] = wx

    #print(G)

cnt = 0
for _ in range(M):
    cnt += pt.pop()
    print(cnt)


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

using namespace std;

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

  int n;
  string s;

  cin >> s;

  n = (int)s.size();
  s = '0' + s;

  if (s[1] == '0') {
    cout << "-1\n";
    return 0;
  }

  if (s[n] == '1') {
    cout << "-1\n";
    return 0;
  }

  for (int i = 1; i < n; i++) {
    if (s[i] != s[n - i]) {
      cout << "-1\n";
      return 0;
    }
  }

  int rt = 1;
  for (int i = 1; i <= n - 1; i++) {
    cout << rt << ' ' << i + 1 << '\n';
    if (s[i] == '1') rt = i + 1;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int,int>>>data(N);
  for(int i=0;i<N;i++){
    int L;
    cin >> L;
    for(int j=0;j<L;j++){
      int x,y;
      cin >> x >> y;
      x--;
      data.at(i).push_back(make_pair(x,y));
    }
  }
  
  int ans=0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> s(tmp);
    bool a=true;
    for(int i=0;i<N;i++){
      if(((1<<i)&tmp)!=0){
        for(int j=0;j<data.at(i).size();j++){
          if(((1<<data.at(i).at(j).first)&tmp)==0&&data.at(i).at(j).second==1){
            //cout << tmp << " " << i  <<" " << j << endl;
            a=false;
          }
          else if(((1<<data.at(i).at(j).first)&tmp)!=0&&data.at(i).at(j).second==0) {
            //cout << tmp << " " << i  << j << endl;
            a=false;
          }
        }
      }
    }
    int l=s.count();
    if(a) {
      ans=max(ans,l);
      //cout << tmp << endl;
    }
  }
  
  cout << ans;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,A,B,C;
  cin >> n >> A >> B >> C;
  int l[n];
  int p,min;
  int a,b,c;
  bool BIT1,BIT2;
  min= 1000000000;
  for(int i = 0;i < n;i++){
    cin >> l[i];
  }
  for(long int bit = 0;bit<(1<<2*n);bit++){
    p = a = b = c = 0;
    for(int i = 0;i < 2*n;i+=2){
      if(bit&(1<<i))BIT1 = true;
      else BIT1 = false;
      if(bit&(1<<i+1))BIT2 = true;
      else BIT2 = false;
      if(BIT1 == false && BIT2 == false){
        a += l[i/2];
        p += 10;
      }else if(BIT1 == true && BIT2 == false){
        b += l[i/2];
        p += 10;
      }else if(BIT1 == false && BIT2 == true){
        c += l[i/2];
        p += 10;
      }
    }
    p += abs(a-A) + abs(b-B) + abs(c-C);
    p -= 30;
    if(p < min && a != 0 && b != 0 && c != 0){
      min = p;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, a, b, c, now = 0;
  scanf("%d%d%d", &a, &b, &c);
  while( 1 ) {
    if((now % 60) <= c && c <= now % 60 + a) {
      for(j = 0; j <= a; ++j) {
        if(now % 60 == c) break;
        ++now;
      }
      printf("%d\n", now);
      return 0;
    } else {
      now += a + b;
      if(!(now % 60)) {
        printf("-1\n");
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2752
#include<algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int a,b;
	cin>>a>>b;
  	if(a==1) a+=13;
  	if(b==1) b+=13;
	if(a<b) cout<<"Bob"<<endl;
  	else if(a>b) cout<<"Alice"<<endl;
  	else cout<<"Draw"<<endl;
  	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int A[50][50];
main(){
    int N,M;
    cin >> N >> M;
    for(int i = 0;i < M;i++){
        int a,b;
        cin >> a >> b;
        A[a-1][b-1]++;
        A[b-1][a-1]++;
    }
    for(int i = 0;i < N;i++){
        int cnt = 0;
        for(int j = 0;j < N;j++){
            cnt += A[i][j];
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 256
import sys
import math
from fractions import gcd
from collections import deque
from copy import deepcopy
import heapq
# import queue
# from collections import Counter
# from itertools import accumulate
from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N, M = map(int, sys.stdin.readline().split())
L = list(map(int, sys.stdin.readline().split()))

L = list(map(lambda x : x * -1, L))
heapq.heapify(L)
for _ in range(M):
    x = heapq.heappop(L)
    x = math.ceil(x / 2)
    heapq.heappush(L, x)

print(-1 * sum(L))

Measured memory_bytes: 120212
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int n;
  cin>>n;
  float a[n],sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=1/a[i];
  }
  printf("%.5f\n",1/sum);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n, m;
int b[100010];
LL dp[100010];

void init() {

}

void input() {
  cin >> n >> m;
  REP(i, n+5) b[i] = 0;
  REP(i, m) {
    int a;
    cin >> a;
    b[a] = 1;
  }
}

void solve() {
  REP(i, n+5) dp[i] = 0;
  dp[0] = 1;
  REP(i, n) {
    if (b[i+1] == 0) dp[i+1] = (dp[i+1] + dp[i]) % 1000000007;
    if (b[i+2] == 0) dp[i+2] = (dp[i+2] + dp[i]) % 1000000007;
  }
  cout << dp[n] << endl;
}

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


Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

const double PI = acos(-1);

int main(void) {
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;
  double theta;
  if(2*x < a*b) {
    double y = 2*x/b;
    theta = atan2(y, b);
  } else {
    double y = 2*x/a - b;
    theta = atan(a / (b-y));
  }
  printf("%.10f\n", 90 - theta * 180 / PI);
  
  return 0;
}


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

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define pii pair<int, int>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}
inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}
inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }
/*-----------------------------------------------------MATH------------------------------------------------*/

const int inf = 1e9;
const int MAXN = 2e5 + 10;
ll mod = 1e9 + 7;
vector<int> arr;
void solve(){
    int n,m;
    cin>>n>>m;
    arr.resize(n+1);
    for(int i=0;i<n+1;i++) arr[i]=-1;
    int pen=0;
    int good=0;
    for(int i=0;i<m;i++){
        int a;
        string s;
        cin>>a>>s;
        if(arr[a]==0) continue;
        if(s=="AC"){
            good++;
            if(arr[a]!=-1) pen+=arr[a];
            arr[a]=0;
        }
        else if(s=="WA" && arr[a]==-1){
            arr[a]=1;
        }
        else if(s=="WA") arr[a]++;
    }
    cout<<good<<" "<<pen<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n=1;
    for (int i = 0; i < n; i++) solve();
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>

int main(){
    int n, h[114], bar=1, cnt = 0, max=0;
    bool connection = false;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d",&h[i]);
        if(h[i] > max){
            max = h[i];
        }
    }

    for(bar = 1;bar <= 100; bar++){
        connection = false;
        if(bar > max){
            break;
        }
        for(int i = 0; i < n; i++){
            
            if(connection == false){
                if(h[i] >= bar){
                    connection = true;
                    cnt++;
                }
            }else{
                if(h[i] < bar){
                    connection = false;
                }
            }
        }
    }
    
    printf("%d\n", cnt);

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long a = scanner.nextLong();
		long b = scanner.nextLong();
		long x = scanner.nextLong();

		long bx = b/x;
		long ax = a/x;
		if(a%x==0) ax--;
		System.out.println(bx-ax);
		scanner.close();
	}

}


Measured memory_bytes: 23508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(a*b + " " + ((2*a)+(2*b)));


	}

}


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

#define SIZE 1000000

struct WORD {
	char value[15];
	struct WORD *next;
};

struct WORD* HashTable[SIZE];	//default: all NULL

int HashFunc(char s[]) {
	long long hash = 0;
	for (int i = 0; s[i] != '\0'; i++) {
		hash += s[i] * (i + 1);
	}
	return (int)(hash * 13 % SIZE);
}

void AddWord(char s[], int hashNum) {
	struct WORD* newWord = (struct WORD*)malloc(sizeof(struct WORD));
	strcpy(newWord->value, s);
	newWord->next = NULL;
	if (HashTable[hashNum] == NULL) HashTable[hashNum] = newWord;
	else {
		newWord->next = HashTable[hashNum];
		HashTable[hashNum] = newWord;
	}
}

void Insert(char s[]) {
	int hash = HashFunc(s);
	AddWord(s, hash);
}

void Find(char s[]) {
	int hash = HashFunc(s);
	struct WORD* pos;
	for (pos = HashTable[hash]; pos != NULL; pos = pos->next) {
		if (!strcmp(s, pos->value)) {
			printf("yes\n");
			return;
		}
	}
	printf("no\n");
	return;
}

int main() {
	int n;
	char command[10], value[15];
	for (int i = 0; i < SIZE; i++) {
		HashTable[i] = NULL;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s %s", command, value);
		if (!strcmp(command, "insert")) Insert(value);
		else if (!strcmp(command, "find")) Find(value);
	}

	return 0;
}


Measured memory_bytes: 27360
package main

import (
	"container/list"
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	var ch, cw, dh, dw int
	fmt.Scan(&ch, &cw, &dh, &dw)
	ch--
	cw--
	dh--
	dw--

	ss := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&ss[i])
	}

	const inf int = 1e18
	// const inf int = 9

	ds := [1100][1100]int{}
	for i := 0; i < len(ds); i++ {
		for j := 0; j < len(ds[i]); j++ {
			ds[i][j] = inf
		}
	}

	dx := []int{0, 0, -1, 1}
	dy := []int{-1, 1, 0, 0}

	q := list.New()
	q.PushBack(Point{cw, ch})

	ds[ch][cw] = 0
	e := q.Front()
	for e != nil {
		p := e.Value.(Point)
		q.Remove(e)

		cx, cy := p.x, p.y
		if cx == dw && cy == dh {
			// break
		}

		for d := 0; d < len(dx); d++ {
			nx := cx + dx[d]
			ny := cy + dy[d]
			if 0 <= nx && nx < w && 0 <= ny && ny < h {
				if ds[ny][nx] > ds[cy][cx] && ss[ny][nx] == '.' {
					ds[ny][nx] = ds[cy][cx]
					q.PushFront(Point{nx, ny})
				}
			}
		}

		for ox := -2; ox <= 2; ox++ {
			for oy := -2; oy <= 2; oy++ {
				nx := cx + ox
				ny := cy + oy
				if 0 <= nx && nx < w && 0 <= ny && ny < h {
					if ds[ny][nx] == inf && ss[ny][nx] == '.' {
						ds[ny][nx] = ds[cy][cx] + 1
						q.PushBack(Point{nx, ny})
					}
				}
			}
		}
		e = q.Front()
	}

	// for i := 0; i < h; i++ {
	// 	fmt.Println(ds[i][:w])
	// }

	if ds[dh][dw] == inf {
		fmt.Println(-1)
		return
	}

	fmt.Println(ds[dh][dw])
}

// Point .
type Point struct {
	x, y int
}


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

using namespace std;

int main()
{
  int A, B, C;

  scanf("%d %d %d", &A, &B, &C);

  if (A + B + C == 17)
  {
    printf("YES");
  }
  else
  {
    printf("NO");
  }
}

Measured memory_bytes: 256
/*            AUTHOR - SHIVAM GUPTA
                       Jalpaiguri Govt. Engg College             */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<ll> ve[100005];
ll vis[100005],z;

void solve()
{
    ll n=0,m=0,i=0,j=0,k=0,c=0,l=0,r=0,p=0,q=0,x=0,y=0,z=0,flag=0,sum=0;
    ll a[405]={0},dp[405][405]={0};
    cin>>n;
    for(i=1;i<=n;i++)
    cin>>a[i];
    for(i=1;i<=n;i++){
        a[i]+=a[i-1];
        for(j=1;j<=n;j++){
            if(i==j)
                dp[i][j]=0;
            else
                dp[i][j]=1e18;
        }
    }
    
    // Matrix Chain Multiplication
    for(i=1;i<=n;i++)
    {
        for(k=1;k+i<=n;k++)
        {
            ll temp;
            for(j=k;j<=i+k-1;j++){
                temp = dp[k][j]+dp[j+1][i+k];
                temp += a[i+k]-a[k-1];
                dp[k][k+i] = min(temp, dp[k][k+i]);
            }
        }
    }
    cout<<dp[1][n]<<endl;
    
}
bool imp=false;int main()
{
    fio;
    int t=1;
    if(imp)
	cin>>t;
	ll j=t;
    while(t--){
    // cout<<"Case #"<<j-t<<": ";
    solve();}
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>

using namespace std;

void print_data(int data[], int N) {
    cout << data[0];
    for (int i = 1; i < N; i++) cout << " " << data[i];
    cout << endl;
}

int bubble_sort(int data[], int N) {
    int swap_count = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int i = N - 1; i > 0; i--) {
            if (data[i] < data[i-1]) {
                swap(data[i], data[i-1]);
                swap_count++;
                flag = true;
            }
        }
    }
    return swap_count;
}

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

    int data[N];
    for (int i = 0; i < N; i++) cin >> data[i];
    int swap_count = bubble_sort(data, N);
    print_data(data, N);
    cout << swap_count << endl;
    
    return 0;
}



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

using namespace std;

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

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

    int n;
    cin>>n;

    double odd, result;

    if(n%2==0)
        odd=n/2;
    else
        odd=(n/2)+1;

    result = odd/(double)n;

    printf("%.10f\n", result);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    
    if( a <= b && ( a + w ) >= b )
    {
        cout << 0 << endl;
        return 0;
    }
    if( b <= a && ( b + w ) >= a )
    {
        cout << 0 << endl;
        return 0;
    }
    cout << min( abs( b - ( a + w ) ), abs( a - ( b + w ) ) ) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	bool ok[3][3][2010] = {};
	string s[3];
	for(int i = 0;i < 3;i++) cin >> s[i];
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			if(i == j) continue;
			for(int k = 0;k <= s[i].length();k++){
				ok[i][j][k] = true;
				for(int l = 0;k + l < s[i].length() && l < s[j].length();l++){
					if(s[i][k + l] != '?' && s[j][l] != '?' && s[i][k + l] != s[j][l]) ok[i][j][k] = false;
				}
			}
		}
	}
	int ans = INF;
	vector<int> v = {0,1,2};
	do{
		for(int i = 0;i <= s[v[0]].length();i++){
			for(int j = 0;j <= max((int)s[v[1]].length(),(int)s[v[0]].length() - i);j++){
				if(ok[v[0]][v[1]][i] && (j <= s[v[1]].length() ? ok[v[1]][v[2]][j] : true) && (i + j <= s[v[0]].length() ? ok[v[0]][v[2]][i + j] : true)){
					chmin(ans,max({(int)s[v[0]].length(),i + (int)s[v[1]].length(),i + j + (int)s[v[2]].length()}));
				}
			}
		}
	}while(next_permutation(all(v)));
	cout << ans << endl;
}


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


using namespace std;

int main()
{
    int a,b,k;

    cin>>a >> b >> k;

    if(k*2>=(b-a+1))
    {
        for(int i=a; i<=b; i++)
        {
            printf("%d\n",a);
            a++;
        }
    }


    else
    {
        b=b-k+1;
        for(int i=1; i<=k*2; i++)
        {
            if(i>k)
            {
                printf("%d\n",b);
                b++;
            }
            else
            {
                printf("%d\n",a);
                a++;
            }

        }
    }
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int left;
	int right;
	int par;
}data;

void preorder(data* T,int i) {
	printf(" %d", i);
	if(T[i].left!=-1) preorder(T,T[i].left);
	if(T[i].right!=-1) preorder(T,T[i].right);
}

void inorder(data* T, int i) {
	if (T[i].left != -1) inorder(T,T[i].left);
	printf(" %d", i);
	if(T[i].right!=-1) inorder(T,T[i].right);
}

void postorder(data* T, int i) {
	if (T[i].left != -1) postorder(T,T[i].left);
	if(T[i].right!=-1) postorder(T,T[i].right);
	printf(" %d", i);
}

int main() {
	int i,n;
	data T[25];
	int id, left, right;

	scanf("%d", &n);

	for (i = 0; i < n; i++) T[i].left = T[i].right = T[i].par = -1;


	for (i = 0; i < n; i++){
		scanf("%d%d%d", &id, &left, &right);
		if (left != -1) {
			T[id].left = left;
			T[left].par = id;
		}
		if (right != -1) {
			T[id].right = right;
			T[right].par = id;
		}
	}

	for (i = 0; i < n; i++)
		if (T[i].par == -1) break;

			printf("Preorder\n");
			preorder(T,i);
			printf("\n");

			printf("Inorder\n");
			inorder(T,i);
			printf("\n");

			printf("Postorder\n");
			postorder(T,i);
			printf("\n");


	return 0;
}



Measured memory_bytes: 2140
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

O = input()
E = input()

ans = ""
for i in range(len(O)):
    if i < len(E):
        ans += O[i] + E[i]
    else:
        ans += O[i]
print(ans)


Measured memory_bytes: 8912
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    static int n;
    // Nodeのリスト
    static List<Node> nodes = new List<Node>();
    // 辿っているQueue
    static Queue<Node> queue = new Queue<Node>();

    // Node
    class Node
    {
        // 距離
        public int dist = -1;
        // 隣接NodeのId（index）
        public List<int> adjacentIds;
    }

    // メイン
    static void Main(string[] args)
    {
        Parse();
        
        Bfs(nodes[0]);

        Print();
    }

    // 入力をパース
    static void Parse()
    {
        // 行数を取得
        n = int.Parse(Console.ReadLine().Split()[0]);

        // nodeを作成
        for (int i = 0; i < n; i++)
        {
            nodes.Add(new Node());
        }

        // nodeの中身設定
        for (int i = 0; i < n; i++)
        {
            List<int> nums = Console.ReadLine().Split().Select(str => int.Parse(str)).ToList();
            nodes[nums[0] - 1].adjacentIds = nums.GetRange(2, nums[1]).Select(id => id - 1).ToList();
        }
    }

    // 幅優先探索
    static void Bfs(Node start)
    {
        start.dist = 0;
        queue.Enqueue(start);
        while (queue.Count() > 0)
        {
            Node node = queue.Dequeue();
            foreach (var id in node.adjacentIds)
            {
                if (nodes[id].dist == -1)
                {
                    nodes[id].dist = node.dist + 1;
                    queue.Enqueue(nodes[id]);
                }
            }
        }
    }

    // 出力
    static void Print()
    {
        for (int i = 0; i < n; i++)
        {
            System.Console.WriteLine(string.Format("{0} {1}", i + 1, nodes[i].dist));
        }
    }
}



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

const int N = (1<<18) + 6;

int mx1[N],mx2[N];
int mx1_id[N],mx2_id[N];
int a[N];
int ans[N];

void update(int x,int val,int id)
{
    if (id == mx1_id[x] || id == mx2_id[x]) return;
    if (val > mx1[x])
    {
        mx2[x] = mx1[x];
        mx2_id[x] = mx1_id[x];
        mx1[x] = val;
        mx1_id[x] = id;
    }
    else if (val > mx2[x])
    {
        mx2[x] = val;
        mx2_id[x] = id;
    }
}

int main ()
{
    int n;
    scanf("%d",&n);
    memset(mx1_id,-1,sizeof(mx1_id));
    memset(mx2_id,-1,sizeof(mx2_id));
    int nn=(1<<n);
    for (int i=0;i<nn;++i)
    {
        scanf("%d",&a[i]);
    }
    for (int mask=0;mask<nn;++mask)
    {
        if (mask == 0)
        {
            update(0,a[0],0);
            continue;
        }
        update(mask,a[mask],mask);
        for (int i=0;i<n;++i)
        {
            if (((1<<i)&mask) != 0)
            {
                int _ = ((1<<i)^mask);
                if (_ == 0)
                {
                    update(mask,a[0],0);
                    continue;
                }
                update(mask,mx1[_],mx1_id[_]);
                update(mask,mx2[_],mx2_id[_]);
            }
        }
        ans[mask] = mx1[mask] + mx2[mask];
        ans[mask] = max(ans[mask],ans[mask-1]);
    }
    for (int i=1;i<nn;++i)
    {
        printf("%d%c",ans[i]," \n"[i==nn-1]);
    }
}



Measured memory_bytes: 9216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?middle:'\n'));
}
void array_show(LL *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?middle:'\n'));
}

void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<int> v1[2];
char ca[100005];
LL s=0;

void check(int dis,int a,LL m){
	if(a==-1)return;
	if(v1[0][a]==-1 && v1[1][a]==-1)return;
	if(v1[0][a]==-1 || v1[1][a]==-1){
		LL b=m-dis;
		int i=0;
		for(;(b&(1<<i))==0;i++);
		s^=(1<<i);
	}
	check(dis+1,v1[0][a],m);
	check(dis+1,v1[1][a],m);
}

int main(){
	LL n,m;
	int a,b,c;
	int i,j,k;
	cin>>n>>m;
	v1[0].push_back(-1),v1[1].push_back(-1);
	for(i=0;i<n;i++){
		cin>>ca;
		for(j=0,a=0;j<strlen(ca);j++){
			if(ca[j]=='0')k=0;
			else k=1;
			if(v1[k][a]==-1){
				v1[k][a]=v1[0].size();
				v1[0].push_back(-1),v1[1].push_back(-1);
			}
			a=v1[k][a];
		}
	}
	check(0,0,m);
	cout<<(s!=0?"Alice":"Bob")<<endl;
	return 0;
}


Measured memory_bytes: 3700
s = str(input())

l = len(s)

data = [0] * l

for i in range(0,l):
    if s[i] == "L" and s[i-1] == "L":
        if s[data[i-1]] == "L":
            data[i] = data[i-1] - 1
        else:
            data[i] = data[i-1] + 1
    if s[i] == "L" and s[i-1] == "R":
        data[i] = i

for j in range(1,l+1):
    if s[-j] == "R" and s[-j+1] == "R":
        if s[data[-j+1]] =="L":
            data[-j] = data[-j+1] - 1
        else:
            data[-j] = data[-j+1] + 1
    if s[-j] == "R" and s[-j+1] == "L":
        data[-j] = l-j

ans = [0] * l

for i in range(0,l):
    ans[data[i]] += 1

print(" ".join(list(map(str,ans))))

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

int main(){
  int n,q;
  cin>>n>>q;
  vector<pair<int,pii>> vec;
  vector<int> res(q,0);

  rep(i,n){
      int s,t,x;
      cin>>s>>t>>x;
      vec.push_back(make_pair(s-x,make_pair(1,x)));
      vec.push_back(make_pair(t-x,make_pair(-1,x)));
  }
  rep(i,q){
      int d;
      cin>>d;
      vec.push_back(make_pair(d,make_pair(2,i)));
  }
  sort(vec.begin(),vec.end());
  multiset<int> mt;

  for(auto v:vec){
      if(v.second.first==1){
          mt.insert(v.second.second);
      }
      else if(v.second.first==-1){
          mt.erase(mt.find(v.second.second));
      }else{
          if(mt.empty()){
            res[v.second.second]=-1;    
          }
          else{
            res[v.second.second]=*mt.begin();
          }
      }
  }
  rep(i,q){
      cout<<res[i]<<endl;
  }
}

Measured memory_bytes: 18536
// Problem : Five Variables
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc170_a
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testcases \
    int tcc;      \
    cin >> tcc;   \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    fast_io;
    vi v(5); in(v);
    lp(i,0,5) if(v[i]==0) cout<<(i+1);
}

Measured memory_bytes: 3584