akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef pair<int,int> P;

const int INF = 1e9;

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

	int n;
	cin >> n;

	int ns[4];
	for(int i=0;i<4;i++){
		ns[3-i] = n % 10;
		n /= 10;
	}

	int res;
	char ans[3];
	for(int i=0;i<(1<<3);i++){
		res = ns[0];
		for(int j=0;j<3;j++){
			int bit = (i>>j) & 1;
			if(bit == 0){//+
				res += ns[j+1];
				ans[j] = '+';
			}else if(bit == 1){//-
				res -= ns[j+1];
				ans[j] = '-';
			}	
		}
		if(res == 7) break;
	}

	for(int i=0;i<3;i++){
		cout << ns[i] << ans[i];
	}
	cout << ns[3] << "=7\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <ctime>
#include <set>
#include <map>
#include <vector>
using namespace std;

template <typename T>
T next_int() {
	T x = 0, p = 1;
	char ch;
	do { ch = getchar(); } while(ch <= ' ');
	if(ch == '-') {
		p = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		x = x * 10 + (ch - '0');
		ch = getchar();
	}
	return p * x;
}

const int max_int = (int)1e9 + 228;
const int max_n = (int)1e5 + 228;
const int mod = (int)1e9 + 7;

int main() {
//	freopen(".in", "r", stdin);

	int n = next_int<int>();
	int m = next_int<int>();

	vector<int> a(n + 1);
	vector<bool> us(n + 1);
	for(int i = 1; i <= n; i++) {
		a[i] = 1;
		us[i] = (i == 1);
	}

	for(int i = 0; i < m; i++) {
		int x = next_int<int>();
		int y = next_int<int>();
	
		if(us[x] && a[x] == 1) {
			us[x] = 0;
			a[y]++;
			us[y] = 1;
			a[x]--;
		} else 
		if(us[x]) {
			us[y] = 1;
			a[y]++;
			a[x]--;
		} else {
			if(a[x]) a[x]--, a[y]++;
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; i++) ans += us[i];

	cout << ans << "\n";
}

Measured memory_bytes: 640
#include <algorithm>
#include <chrono>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long Int;

#define KIND 26
//#define KIND 2
Int D;
Int c[KIND];
Int s[400][KIND];
Int last[KIND];

std::chrono::time_point<std::chrono::steady_clock> start;

Int range(Int l, Int r)
{
    Int len = r - l - 1;
    return -len * (len + 1) / 2;
}

void tic()
{
    start = std::chrono::steady_clock::now();
}

double toc()
{
    auto now = std::chrono::steady_clock::now();
    std::chrono::duration<double> duration = now - start;
    return duration.count();
}

struct ContestInfo {
    set<Int> held[KIND];
    vector<Int> t;
    int D;
    Int score = 0;
    ContestInfo(int D) : D(D)
    {
        t.resize(D, -1);
        for (int i = 0; i < KIND; i++) {
            held[i].insert(-1);
            held[i].insert(D);
            score += c[i] * range(-1, D);
        }
    }

    void add(int d, int q)
    {
        if (t[d] != -1) {
            cout << "Add failed" << endl;
            exit(1);
        }
        t[d] = q;
        score += s[d][q];
        held[q].insert(d);
        auto it = held[q].find(d);
        auto rit = next(it);
        auto lit = prev(it);
        score -= c[q] * range(*lit, *rit);
        score += c[q] * range(*it, *rit);
        score += c[q] * range(*lit, *it);
    }

    void erase(int d)
    {
        if (t[d] == -1) {
            cout << "erase failed" << endl;
            exit(1);
        }
        int q = t[d];
        t[d] = -1;
        score -= s[d][q];
        auto it = held[q].find(d);
        auto rit = next(it);
        auto lit = prev(it);
        score += c[q] * range(*lit, *rit);
        score -= c[q] * range(*it, *rit);
        score -= c[q] * range(*lit, *it);
        held[q].erase(it);
    }

    void change(int d, int q)
    {
        erase(d);
        add(d, q);
    }

    void output()
    {
        for (int i = 0; i < D; i++) {
            cout << t[i] + 1 << endl;
        }
    }
};

Int calc_score(vector<Int> t)
{
    Int score = 0;
    fill(last, last + 26, -1);
    for (int d = 0; d < D; d++) {
        score += s[d][t[d]];
        last[t[d]] = d;
        for (int i = 0; i < KIND; i++) {
            score -= c[i] * (d - last[i]);
        }
        // cout << score << endl;
    }
    return score;
}

int main()
{
    tic();
    cin >> D;
    for (Int i = 0; i < KIND; i++) {
        cin >> c[i];
    }
    for (Int d = 0; d < D; d++) {
        for (Int i = 0; i < KIND; i++) {
            cin >> s[d][i];
        }
    }

    ContestInfo ci(D);

    for (int d = 0; d < D; d++) {
        Int t;
        t = rand() % KIND;
        ci.add(d, t);
    }
    Int current_score = ci.score;

    while (toc() < 1.9) {
        Int d, q;
        d = rand() % D;
        q = rand() % KIND;
        int old = ci.t[d];
        ci.change(d, q);
        Int new_score = ci.score;
        if (new_score < current_score) {
            ci.change(d, old);
        }
        else {
            current_score = new_score;
        }
    }
    ci.output();
    return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define len(a) a.length()
using namespace std;

signed main(){
    fast_io;
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    while(n){
        n/=k;
        ans++;
    }
    cout<<ans;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
#define p(l) (ll)pow(2, l + 1) - 1

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	double dif = 1000;
	int ans = 0;
	makei(n);
	makev(a, n);
	double avg = (double)accumulate(all(a), 0) / n;
	rep(n) {
		if (abs(avg - a[i]) < dif) {
			dif = abs(avg - a[i]);
			ans = i;
		}
	}
	say(ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class AtCoDeerAndPaintCans {
    static void Main() {
        
        // 直近三日分のペンキを取得
        string[] input  = Console.ReadLine().Split(' ');

        // 重複を排除したリストに変換
        List<string> distinct_cans = new List<string>();
        foreach(string s in input) {
            if (!distinct_cans.Contains(s))
                distinct_cans.Add(s);
        }

        Console.WriteLine(distinct_cans.Count);
    }

}

Measured memory_bytes: 2776
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=200005;

int a[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int main(void) {
	int n=read();
	rep(i,1,n) a[i]=read();
	std:: sort(a+1,a+n+1);
	if (a[1]==a[n]) {
		if (a[1]==n-1) return 0&puts("Yes");
		if (a[1]*2<=n) return 0&puts("Yes");
		return 0&puts("No");
	} else if (a[1]+1==a[n]) {
		int s=0;
		rep(i,1,n) s+=(a[i]==a[1]);
		if (a[1]<s||(a[n]-s)*2>n-s) puts("No");
		else puts("Yes");
	} else puts("No");
	return 0;
}

Measured memory_bytes: 512
r, c = map(int, input().split())
l = []
for i in range(r):
  l.append(list(map(int, input().split())))
  l[i] += [sum(l[i])]
  print(*l[i])
l = list(zip(*l))
for i in range(c): print(sum(l[i]), end = " ")
print(sum(l[c]))


Measured memory_bytes: 5776
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;




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

  ll N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  string t;
  cin >> t;

  ll ans = 0;
  REP(st, K){
    if (st+1>=N) break;
    ll nK = (N-st-1)/K+1; 
    vector<vector<ll>> dp(nK, vector<ll>(3,0)); // max score end with {r, s, p}
    REP(i,nK){
      if (i==0){
        if(t[st+i*K]=='s') dp[i][0] = R;
        if(t[st+i*K]=='p') dp[i][1] = S;
        if(t[st+i*K]=='r') dp[i][2] = P;
      } else {
        dp[i][0] = max(dp[i-1][0], max(dp[i-1][1], dp[i-1][2]));
        dp[i][1] = max(dp[i-1][0], max(dp[i-1][1], dp[i-1][2]));
        dp[i][2] = max(dp[i-1][0], max(dp[i-1][1], dp[i-1][2]));
        if(t[st+i*K]=='s') dp[i][0] = max(dp[i][0], max(dp[i-1][1],dp[i-1][2]) + R);
        if(t[st+i*K]=='p') dp[i][1] = max(dp[i][1], max(dp[i-1][2],dp[i-1][0]) + S);
        if(t[st+i*K]=='r') dp[i][2] = max(dp[i][2], max(dp[i-1][0],dp[i-1][1]) + P);
      }
      //cout << i << ": " << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << "\n";
    }
    ans += max(max(dp[nK-1][0], dp[nK-1][1]), dp[nK-1][2]);
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 5840
#include <stdio.h>

int cnt=0;
int A[1000000];
int G[100];

void insertionSort(int A[],int n,int g){
  int i,v,j;

  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  int m,i=0,h;

  for(h=1;h<=n;i++){
    G[i]=h;
    h=3*h+1;
  }
  m=i;
  printf("%d\n",m);
  for(i=0;i<m;i++){
    printf("%d",G[m-i-1]);
    if(i<m)printf(" ");
    insertionSort(A,n,G[m-i-1]);
  }
}

int main(void){
  int n,i;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  shellSort(A,n);
  printf("\n");
  printf("%d\n",cnt);
  for(i=0;i<n;i++)printf("%d\n",A[i]);

  return 0;
}



Measured memory_bytes: 5632
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
        string S, a, b, c;
        cin >> S;
        if(S[0] == S[1] && S[1] == S[2] &&S[2] == S[3]){
                cout << "No";
                return 0;
        }
        if(S[0] == S[1] && S[2] == S[3]){
          cout << "Yes";
        }
        else if(S[0] == S[2] && S[1] == S[3]){
          cout << "Yes";
        }
        else if(S[2] == S[1] && S[0] == S[3]){
          cout << "Yes";
        }
        else{
                cout << "No";
        }
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int rez=1<<30;
int fr[305];
int A[305][305];
int N,M;
int U[305];
int st[305];
int main()
{
    cin>>N>>M;rez=N;
    for(int i=1;i<=N;i++){for(int j=1;j<=M;j++)cin>>A[i][j];st[i]=1;fr[A[i][1]]++;}
    int spmax=0,maxi=0;
    for(int j=1;j<=M;j++)if(maxi<fr[j]){maxi=fr[j];spmax=j;}
    rez=maxi;
    for(int i=1;i<M;i++)
    {
        int spmax=0,maxi=0;
        for(int j=1;j<=M;j++)if(maxi<fr[j]){maxi=fr[j];spmax=j;}
        U[spmax]=1;
        for(int j=1;j<=N;j++)
        {
            fr[A[j][st[j]]]--;
            while(U[A[j][st[j]]]){st[j]++;}
            fr[A[j][st[j]]]++;
        }
        spmax=0;maxi=0;
        for(int j=1;j<=M;j++)if(maxi<fr[j]){maxi=fr[j];spmax=j;}
        rez=min(rez,maxi);
    }
    cout<<rez;
    return 0;
}


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

int sum[5005][5005];
int main() {
	int n, m; scanf("%d%d", &n, &m);
	rep(i, m) {
		int a, b, x; scanf("%d%d%d", &a, &b, &x);
		sum[a][b]++; sum[a][b + 1]--;
		sum[a + x + 1][b]--; sum[a + x + 2][b + 1]++;
		sum[a + x + 1][b + x + 2]++; sum[a + x + 2][b + x + 2]--;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i + 1; j++)sum[i][j] += sum[i][j - 1];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i + 1; j++)sum[i][j] += sum[i - 1][j];
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= i + 1; j++) {
			sum[i][j] += sum[i - 1][j - 1]; cnt += (sum[i][j] > 0);
		}
	printf("%d\n", cnt);
}

Measured memory_bytes: 70048
N, X = map(int, input().split())

a = [1]
p = [1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])
        
print(f(N, X))

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define inf 0x3f3f3f3f
#define ll long long
#define ull unsigned long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;

string s;
int r, c, k;
int a[15][1005];
int sum[15][1005];
vector<int> q;
int num[15];
int ans = inf;

void solve() {
	int g = q.size();
	q.push_back(r);
	memset(num, 0, sizeof num);
	for (int j = 1; j <= c; ++j) {
		int p = 0;
		for (int i = 1; i <= r; ++i) {
			if (i > q[p])
				++p;
			num[p] += a[i][j];
			if (num[p] > k) {
				++g;
				memset(num, 0, sizeof num);
				p = 0;
				for (int ii = 1; ii <= r; ++ii) {
					if (ii > q[p])
						++p;
					num[p] += a[ii][j];
					if (num[p] > k)
						return;
				}
				break;
			}
		}
	}
	ans = min(ans, g);
}

void dfs(int n) {
	if (n == r) {
		solve();
		q.pop_back();
		return;
	}
	dfs(n + 1);
	q.push_back(n);
	dfs(n + 1);
	q.pop_back();
}

int main()
{
	io;
	cin >> r >> c >> k;
	for (int i = 1; i <= r; ++i) {
		cin >> s;
		for (int j = 1; j <= c; ++j)
			a[i][j] = s[j - 1] - '0';
	}
	dfs(1);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
#include<bitset>
using namespace std;


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

	if (((N / 100) % 10) == 7 || ((N / 10) % 10) == 7 || ((N / 1) % 10) == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;

}

Measured memory_bytes: 3104
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int k;
  scanf("%d",&k);
  int *a=(int *)malloc(sizeof(int)*k);
  int i;
  for(i=0;i<k;i++) scanf("%d",a+i);
  if(a[k-1]!=2){
    printf("-1\n");
    return;
  }
  int64 min,max;
  min=2;
  max=3;
  for(i=k-2;i>=0;i--){
    int64 t=(min+a[i]-1)/a[i]*a[i];
    if(!(t/a[i]*a[i]<=max)){
      printf("-1\n");
      return;
    }
    min=t;
    max=max/a[i]*a[i]+a[i]-1;
  }
  printf("%lld %lld\n",min,max);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



int vert[1024];
int csize[2][1024];

int main() {
	int n;
	
	while (1) {
		cin >> n; if (n==0) break;
		
		int ans = 0;
		minit(vert, 0); minit(csize, 0);
		string line;
		
		for_(i, 0, n) {
			cin >> line;
			int horiz = 0;
			int *can = csize[i&1];
			int *prev = csize[(i+1)&1];
			
			for_(j, 1, n+1) {
				if (line[j-1]=='.') {
					horiz++;
					vert[j]++;
					
					can[j] = min(prev[j-1]+1, min(horiz, vert[j]));
					ans = max(ans, can[j]);
				} else {
					can[j] = vert[j] = horiz = 0;
				}
			}
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    
    ll n,y;
    cin >> n >> y;
    rep(i,n+1){
        rep(j,n-i+1){
            rep(k,n-i-j+1){
                if(i+j+k == n && 10000*i + 5000*j + 1000*k == y){
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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

int main() {
  char c;
  cin >> c; // 変数sで入力を一行受け取る
  
  if (c == 'a') {
    cout << "vowel" << endl;
  }
  else if (c == 'e') {
    cout << "vowel" << endl;
  }
  else if (c == 'i') {
    cout << "vowel" << endl;
  }
  else if (c == 'o') {
    cout << "vowel" << endl;
  }
  else if (c == 'u') {
    cout << "vowel" << endl;
  }
    
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, ans=0;
    cin>>n;

    if (n>=100000)
        ans = 90909;
    else if (n>=10000)
        ans = 9 + 900 + (n-9999);
        else if (n>=1000)
            ans=909;
            else if (n>=100)
            ans=9+(n-99);
        else if (n>=10) ans=9;
        else ans = n;
    cout<<ans;
}


Measured memory_bytes: 256
//#include <bits/c++config.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
//#pragma GCC optimize(2)
using namespace std;
int read() {
	int x=0;
	bool fu=0;
	char ch=0;
	while(ch>'9'||ch<'0') {
		ch=getchar();
		if(ch=='-')fu=1;
	}
	while(ch<='9'&&ch>='0') x=(x*10+ch-48),ch=getchar();
	return fu?-x:x;
}
ll n,m,t1,t2,g[17][17],full[1<<16],dp[17][1<<16];
long long tot;
int main(){
	memset(dp,-0x80,sizeof(dp));
    dp[0][1]=0;
    cin>>n>>m;
    F(i,1,m){
    	cin>>t1>>t2;
    	t1--,t2--;
      	cin>>g[t2][t1];
    	tot+=g[t2][t1];
    	g[t1][t2]=g[t2][t1];
	}
	for(register int i=1;i<(1<<n);i++){
		for(ri j=1;j<n;j++){
			if(i&(1<<j)){
				for(ri k=0;k<j;k++){
					if(i&(1<<k)){
						full[i]+=g[j][k];
					}
				}
			}
		}
	}for(register int S=1;S<(1<<n);S+=2){
		for(register int i=0;i<n;i++){
			if(!(S&(1<<i)))continue;
			for(register int j=1;j<n;j++){
				if(!g[i][j]||(S&(1<<j)))continue;
				dp[j][S|(1<<j)]=max(dp[j][S|(1<<j)],dp[i][S]+g[i][j]);
			}
			ri s2=((1<<n)-1)^S;
			for(register int j=s2;j;j=(j-1)&s2){
				dp[i][S|j]=max(dp[i][S|j],dp[i][S]+full[(1<<i)|j]);
			}
		}
	}
	cout<<tot-dp[n-1][(1<<n)-1];
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <unordered_set>

using namespace std;
#define vi vector<int>
#define uset unordered_set
#define ll long long
#define vll vector<ll>

class Graph
{
public:
	struct Node
	{
		uset<int> incoming_edges;
		uset<int> outgoing_edges;
	};
	vector<Node> nodes;
	Graph(int node_count);
	void AddEdge(int start_node, int end_node);
};

Graph::Graph(int node_count)
{
	nodes = vector<Node>(node_count);
}

void Graph::AddEdge(int start_node, int end_node)
{
	nodes[end_node].incoming_edges.insert(start_node);
	nodes[start_node].outgoing_edges.insert(end_node);
}

/// <summary>
/// Returns a topological ordering of the given graph
/// </summary>
vi topological_sort(Graph* graph)
{
	vi topological_ordering; // A vector that will contain the topological ordering
	topological_ordering.reserve(graph->nodes.size());
	list<int> entry_nodes; // A linked list of nodes that have no incoming edge

	// Fill entry nodes list
	for (int i = 0; i < graph->nodes.size(); i++)
	{
		if (graph->nodes[i].incoming_edges.empty())
			entry_nodes.push_back(i);
	}

	// Topological sort
	while (!entry_nodes.empty())
	{
		// An entry node can be visited at any point so we can add it to the topological ordering
		int entry_node_index = entry_nodes.front();
		entry_nodes.pop_front();
		topological_ordering.push_back(entry_node_index);

		// Effectively erase the current entry node from the graph (its outgoing edges do not need to be erased) 
		for (int neighbor: graph->nodes[entry_node_index].outgoing_edges)
		{
			graph->nodes[neighbor].incoming_edges.erase(entry_node_index);
			// If after erasing the connecting edge the neighbor has no more incoming edges it has become an entry node
			if (graph->nodes[neighbor].incoming_edges.empty())
				entry_nodes.push_back(neighbor);
		}
	}
	return topological_ordering;
}

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

	int node_count, edge_count;
	cin >> node_count >> edge_count;

	Graph graph = Graph(node_count);
	for (int i = 0; i < edge_count; i++)
	{
		int start_node, end_node;
		cin >> start_node >> end_node;
		graph.AddEdge(start_node-1, end_node-1);
	}
	
	Graph copy_graph = graph;
	vi topological_order = topological_sort(&copy_graph);
	vll longest_path = vll(topological_order.size()); // A vector keeping the longest path ending with each node

	for (int node_index: topological_order)
	{
		ll max_neighbor_path = -1;
		for (int neighbor: graph.nodes[node_index].incoming_edges)
			max_neighbor_path = max(max_neighbor_path, longest_path[neighbor]);
		
		longest_path[node_index] = max_neighbor_path + 1;
	}
	
	ll max_path_length = *max_element(longest_path.begin(), longest_path.end());
	cout << max_path_length;
	return 0;
}

Measured memory_bytes: 51188
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


# i<jに対して
# Ai-i = -Aj-j か Ai+i=-Aj+jがなり立つ組を探せばよい
N = read_a_int()
A = read_ints()


def ret_kumiawase(X, Y):  # どっちもリスト
    ret = 0
    cnt = Counter()
    for i in range(N - 1, -1, -1):
        ret += cnt[X[i]]  # X[i]の数字の個数を加算する
        cnt.update([Y[i]])  # X[i]の数字の個数を加算する
    return ret


# 前者から
Ai = []
for i, a in enu(A):
    Ai.append(a - i)
Aj = []
for i, a in enu(A):
    Aj.append(-a - i)
ans = ret_kumiawase(Ai, Aj)


# 後者
Ai = []
for i, a in enu(A):
    Ai.append(a + i)
Aj = []
for i, a in enu(A):
    Aj.append(-a + i)
ans += ret_kumiawase(Ai, Aj)
print(ans)


Measured memory_bytes: 141984
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		int l = a.length();
		boolean n=false,s=false,w=false,e=false;
		for(int i = 0; i < l; i++){
			char c = a.charAt(i);
			if(c=='N'){
				n=true;
			}
			if(c=='S'){
				s=true;
			}
			if(c=='E'){
				e=true;
			}
			if(c=='W'){
				w=true;
			}
		}
		if(n==s && e==w){
			sb.append("Yes");
		}else{
			sb.append("No");
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 7892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll p=1e9+7;
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[n-1-i];
  }
  vector<ll> ruiseki(n+1,0);
  for(ll i=0;i<n;i++){
    ruiseki[i+1]=a[i]+ruiseki[i];
    ruiseki[i+1]%=p;
  }
  ll ans=0;
  for(ll i=0;i<n;i++){
    ans+=(ruiseki[i]*a[i])%p;
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6360
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return x*y//gcd(x,y)


def f(X, C, D):
    return X - X//C - X//D + X//lcm(C,D)


def main():
    A, B, C, D = map(int, input().split())

    ans = f(B, C, D) - f(A-1, C, D)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n, m = [int(i) for i in input().split()]
p = [[int(i) for i in input().split()] for _ in range(m)]
a = []
for x in p:
    if x[0] == 1:
        a.append(x[1])

b = []
for x in p:
    if x[1] == n:
        b.append(x[0])
if set(a) & set(b):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 48660
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INT = 1e9;
const ll LINF = 1e18;

void solve(){
    int n,m; cin >> n >> m;
    vector<pll> p(n);
    for(int i = 0; i < n;i++){
        ll x,y; cin >> x >> y;
        p[i] = {x,y};
    }
    sort(p.begin(),p.end());
    for(int i = 0; i < m;i++){
        int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
        ll xl = lower_bound(p.begin(), p.end(), pll(x1,-LINF)) - p.begin();
        ll xr = upper_bound(p.begin(),p.end(),pll(x2,LINF)) - p.begin();
        
        ll ans = 0;
        for(ll j = xl; j < xr;j++){
            if(y1 <= p[j].second && p[j].second <= y2) ans++;
        }
        cout << ans << endl;
    }
}
int main(void){
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 3296
n, m, x = gets.split.map(&:to_i)
a = []
c = []
n.times{
  a_tmp = gets.split.map(&:to_i)
  c << a_tmp.shift
  a << a_tmp
}
ans = 1001001001
[false, true].repeated_permutation(n).to_a.each{|ft|
  a_sum = Array.new(m, 0)
  c_sum = 0
  n.times{|i|
    if ft[i]
      c_sum += c[i]
      m.times{|j|
        a_sum[j] += a[i][j]
      }
    end
  }
  a_min = a_sum.min
  ans = c_sum if a_min >= x && c_sum < ans
}
p ans == 1001001001 ? -1 : ans


Measured memory_bytes: 15032
n = int(input())
t = n.bit_length()
n -= 2 ** (t - 1) - 1
k = t
res = list(range(1, t))
for i in range(t, -1, -1):
    if (n >> i) & 1:
        res.insert(i, k)
        k += 1
print(len(res) * 2)
print(' '.join(map(str, list(range(1, k)) + res)))


Measured memory_bytes: 38384
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


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

	string s;
	cin >> s;

	int ans = 0;
	for(int i = 1; i < n - 1; i++){
		int counter = 0;
		for(int j = 0; j < i; j++){
			bool ok = false;
			bool same = false;
			for(int k = 0; k < j; k++){
				if(s[j] == s[k]){
					same = true;
					break;
				}
			}
			if(same)continue;
			for(int k = i; k < n; k++){
				if(s[j] == s[k]){
					ok = true;
					break;
				}
			}
			if(ok){
				counter++;
			}
		}

		ans = max(ans, counter);
	}

	cout << ans << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int sum=0;
int main()
{
	int a;
	char b;
	cin>>a;
	int ans=0;
	for(int i=1;i<=a;i++)
	{
		cin>>b;
		if(b=='I') ans++;
		else ans--;
		sum=max(sum,ans);
	}
	cout<<sum;
 } 
 

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

bool flag;
ll n, ans, centroid = -1;
vector<PII> g[100010];
ll dfs(ll v, ll p) {
    ll ret = 1;
    bool is_centroid = true;
    for(auto to: g[v]) {
        if(to.first == p) continue;
        ll sz1 = dfs(to.first, v);
        if(sz1 > n/2) is_centroid = false;
        ret += sz1;
        // sz と n-sz
        ll sz2 = n-sz1;
        // cout << v << " " << to.first << " " << to.second << " " << sz1 << " " << sz2 << endl;
        if(sz1 == sz2) {
            ans += (sz1*2-1) * to.second;
            flag = true;
        } else {
            ans += min(sz1, sz2) * 2 * to.second;
        }
    }
    if(n-ret > n/2) is_centroid = false;
    if(is_centroid) centroid = v;
    return ret;
}

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

    cin >> n;
    REP(i, n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }

    dfs(0, -1);
    if(!flag) {
        assert(centroid != -1);
        ll mi = LLINF;
        for(auto i: g[centroid]) {
            chmin(mi, i.second);
        }
        ans -= mi;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 14592
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int N,L;
	string S[110];
	cin>>N>>L;
	for(int i=0;i<N;++i)cin>>S[i];
	sort(S,S+N);
	string add="";
	for(int i=0;i<N;++i){
		add+=S[i];
	}
	cout<<add<<endl;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){

int A,sum=0;
rep(i,3){
    cin>>A;
sum+=A;
}
if(sum>=22)cout<<"bust"<<endl;
else cout<<"win"<<endl;
return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main() {
    int x;
    cin >> x;
    string ans;
    ans = (x >= 30)  ?"Yes":"No";
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  998244353;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

using Node = pair<ll, int>;
vector<vector<Node>> to;
vector<bool> ans;
vector<bool> used;
void dfs(int c, bool color) {
  if(used[c]) return;
  used[c] = true;
  ans[c] = color;
  for(const auto next: to[c]) {
    dfs(next.second, color ^ (next.first % 2 == 1));
  }
}
signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  to.resize(n);
  REP(i, n-1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    to[a].emplace_back(c, b);
    to[b].emplace_back(c, a);
  }

  ans.resize(n);
  used.resize(n, false);
  dfs(0, 0);
  if(set<bool>(all(ans)).size() == 1) {
    ans[0] = 1 ^ ans[0];
  }
  REP(i, n) {
    cout << ans[i] << endl;
  }
  return 0; 
}


Measured memory_bytes: 8576
x1, y1, x2, y2 = list(map(int, input().split()))

vx = x2 - x1
vy = y2 - y1

x3 = x2 - vy
y3 = y2 + vx
x4 = x1 - vy
y4 = y1 + vx

print(x3, y3, x4, y4)

Measured memory_bytes: 9156
import Data.List

hoge1 :: [String] -> String
hoge1 xs = snd $ head $ reverse $ sort $ map hoge' $ group $ sort xs
    where
        hoge' (x:xs) = (length xs + 1 , x)

hoge2 :: [String] -> String
hoge2 = foldr foo ""
    where
        foo x y = if length y < length x then x else y

main :: IO ()
main  = getLine
    >>= return . words
    >>= return . (\ ss -> [hoge1 ss , " " , hoge2 ss])
    >>= mapM_ putStr
    >> putStrLn ""

Measured memory_bytes: 3652
x1, y1, x2, y2 = map(int, input().split())
dx = abs(x1 - x2)
dy = abs(y1 - y2)
x = 0
y = 0
fx = 1
fy = 1
if y2 < y1:
    if x2 > x1:
        fx = 1
        fy = 1
    else:
        fx = 1
        fy = -1
else:
    if x2 > x1:
        fx = -1
        fy = 1
    else:
        fx = -1
        fy = -1
x = x2 + fx * dy
y = y2 + fy * dx
print(x, y, end = ' ')
x1 = x2
y1 = y2
x2 = x
y2 = y
dx = abs(x1 - x2)
dy = abs(y1 - y2)
if y2 < y1:
    if x2 > x1:
        fx = 1
        fy = 1
    else:
        fx = 1
        fy = -1
else:
    if x2 > x1:
        fx = -1
        fy = 1
    else:
        fx = -1
        fy = -1
x = x2 + fx * dy
y = y2 + fy * dx
print(x, y)


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

using namespace std;

void fast();

/*
*
* Watch out! Another Buggy Code From Muhammad_Mamdouh, Happy Coding;
*
*/

int main()
{
    fast();
    int n; cin >> n;
    int a = 0, b = 0, c = 0, d = 0;

    while (n--)
    {
        string s; cin >> s;

        if (s == "AC")
            ++a;
        if (s == "WA")
            ++b;
        if (s == "TLE")
            ++c;
        if (s == "RE")
            ++d;
    }

    cout << "AC" << " x " << a << '\n';
    cout << "WA" << " x " << b << '\n';
    cout << "TLE" << " x " << c << '\n';
    cout << "RE" << " x " << d << '\n';

    return 0;
}

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

Measured memory_bytes: 3620
object Main {
  val MinValue = -1000000
  val MaxValue = 1000000

  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val nums = io.StdIn.readLine().split(" ").map(_.toInt)
    val (min, max, sum) =
      nums.foldLeft((MaxValue, MinValue, 0L)) { case (acc, num) =>
        (acc._1.min(num), acc._2.max(num), acc._3 + num)
      }
    println(s"$min $max $sum")
  }
}

Measured memory_bytes: 49828
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n,m;
 cin>>n>>m;
 vector<int> a(n,0);
 vector<mp> b(m);
 for(ll i=0;i<m;i++){
  ll s,c;
  cin>>s>>c;
  if( n != 1 )if( s==1 && c==0 ){
   cout<<-1<<endl;
   return 0;
  }
  b[i] = mp(s,c);
 }
 sort(b.begin(),b.end());
 auto it = unique(b.begin(),b.end());
 b.erase( it , b.end() );
 //m = it - b.begin();
 m = b.size();
 for(ll i=0;i<m-1;i++){
  if(b[i].first == b[i+1].first ){
   cout<<-1<<endl;
   return 0;
  }
 }
 /*ll sum = 0;
 for(ll i=0;i<m;i++){
  //cout<<b[i].first<<' '<<b[i].second<<endl;
  sum += pow(10, n-b[i].first )*b[i].second + 0.5;
 }
 ll keta = pow(10, n-1 )+0.5;
 if( sum/keta == 0){
  //cout<<-1<<endl;
  sum += keta;
  return 0;
 }
 cout<<sum<<endl;
*/
 ll sum = 0;
 if( n!= 1 )if( m==0 ||b[0].first != 1 ){
  sum += pow(10,n-1);
 }

 for(ll i=0;i<m;i++){
  //cout<<b[i].first<<' '<<b[i].second<<endl;
  sum += pow(10, n-b[i].first )*b[i].second + 0.5;
 }
 cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int64_t N,P,a,c[1<<20],i,j;string S;main(){cin>>N>>P>>S;if(10%P){reverse(S.begin(),S.end()),c[0]=j=1;for(char v:S)i+=(v-48)*(j=j*10%P),a+=c[i%=P]++;}else for(;i<N;a+=(S[i++]-8)%P?0:i);cout<<a;}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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




int main() {
    int p, q, r;
    cin >> p >> q >> r;
    int longest = max(max(p, q), r);
    cout << p + q + r - longest << endl;
}


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

d ={'R':set(), 'G':set(),'B':set()}


for i,x in enumerate(s):
    d[x].add(i+1)
    
# print(d)

ans = 1
for k in d:
    ans*=len(d[k])
    
for i in d['R']:
    for j in d['G']:
        if (i+j)%2 == 0:
            v = (i+j)//2
            if v in d['B']:ans-=1
                
for i in d['R']:
    for j in d['B']:
        if (i+j)%2 == 0:
            v = (i+j)//2
            if v in d['G']:ans-=1
                
for i in d['B']:
    for j in d['G']:
        if (i+j)%2 == 0:
            v = (i+j)//2
            if v in d['R']:ans-=1
                
    

    
    
    
    
print(ans)
    


Measured memory_bytes: 9312
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();
        int l = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n ; i++ ) {
            s[i] = sc.next();
        }
        Arrays.sort(s);
        StringBuilder sb = new StringBuilder();
        for (int i = 0 ; i < n ; i++) {
            sb.append(s[i]);
        }
        System.out.println(sb);
    }

}

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

const int MAXN=1e5+10;

long long dp[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,W,w,v;
    cin>>n>>W;
    for(int i=0;i<n;i++)
    {
        cin>>w>>v;
        for(int j=W;j-w>=0;j--)
            dp[j]=max(dp[j],dp[j-w]+v);
    }
    cout<<dp[W];
}


Measured memory_bytes: 1024
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        waru = 4 * h * n - N * n - N * h
        if waru != 0:
            w = (N * h * n) / waru
            if w > 0 and int(w) / w == 1:
                print("{} {} {}".format(h, n, int(w)))
                exit()


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



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

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  ll n;
  cin >> n;
  string s = {};
  while (n) {
    int x = n % 26;
    if (x == 0) {
      s += 'z';
      n /= 26;
      n--;
    } else {
      s += ('a' + x - 1);
      n /= 26;
    }
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
 
using namespace std;
 
int main(){
 
    ll n,a,b;
    cin >> n >> a >> b;
    if(a > b){
        cout << 0;
        return 0;
    }
    if(n == 1 && a != b){
        cout << 0;
        return 0;
    }
    if(n == 1 && a == b){
        cout << 1;
        return 0;
    }

    cout << (b-a)*(n-2) + 1;

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll N; cin >> N;
    REPR(k,sqrt(N)){
        if(N%k == 0){
            int a = to_string(N/k).size();
            int b = to_string(k).size();
            cout << max(a,b) << endl;
            return 0; 
        }
    }
    return 0;
}

Measured memory_bytes: 3732