akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ALDS1_4_A_LinearSearch
{
	class Program
	{
		static void Main ( string[] args )
		{
			string nothing = Console.ReadLine ();

			string[] searchStr = Console.ReadLine ().Split (' ');

			nothing = Console.ReadLine ();
			nothing[0].GetHashCode ();

			string[] elementStr = Console.ReadLine ().Split (' ');

			int findCount = 0;
			foreach (var item in elementStr)
			{
				bool isContain = searchStr.Any (item2 => item == item2);

				if (isContain)
				{
					findCount++;
				}
			}

			Console.WriteLine (findCount);
		}
	}
}

Measured memory_bytes: 9952
#include<stdio.h>
#include<math.h>
#include<string.h>

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

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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    vector<int> s('Z' + 1);
    cin >> n;
    rep(i, n) {
        string si;
        cin >> si;
        s[si[0]]++;
    }

    cout << "AC x " << s['A'] << endl;
    cout << "WA x " << s['W'] << endl;
    cout << "TLE x " << s['T'] << endl;
    cout << "RE x " << s['R'] << endl;

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	vector<P>r(n), b(n);
	rep(i, n)cin >> r[i].first >> r[i].second;
	rep(i, n)cin >> b[i].first >> b[i].second;
	sort(ALL(b));
	int ans = 0;
	rep(i, n) {
		int now = 0;
		int idx = -1;
		rep(j, r.size()) {
			if (r[j].first < b[i].first&&r[j].second < b[i].second) {
				if (r[j].second >= now) {
					now = r[j].second; idx = j;
				}
			}
		}
		if (idx >= 0) {
			ans++; r.erase(r.begin() + idx);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

dp=[float('inf')]*(2**n)
dp[0]=0

for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    cnt=0
    for j in c:
        cnt+=2**(j-1)
    
    for j in range(2**n):
        dp[j|cnt]=min(dp[j|cnt],dp[j]+a)


if dp[2**n-1]>10**10:
    print(-1)

else:
    print(dp[2**n-1])

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

int main(){
  int H,W;
  cin >> H >> W;

  string S[H];
  rep(cnt, H) {
    cin >> S[cnt];
  }
  
  rep(cnt_h,H) {
    rep(cnt_w,W) {
      if (S[cnt_h].at(cnt_w) != '#') {
        char x = 0;
        for (int i = -1; i <= 1; ++i) {
          for (int j = -1; j <= 1; ++j) {
            if ( (0 <= cnt_h + i) && (cnt_h + i < H) &&
                 (0 <= cnt_w + j) && (cnt_w + j < W) ) {
              x += (S[cnt_h + i].at(cnt_w + j) == '#');
            }
          }
        }
        switch(x) {
          case 0:
            S[cnt_h].at(cnt_w) = '0';
            break;
          case 1:
            S[cnt_h].at(cnt_w) = '1';
            break;
          case 2:
            S[cnt_h].at(cnt_w) = '2';
            break;
          case 3:
            S[cnt_h].at(cnt_w) = '3';
            break;
          case 4:
            S[cnt_h].at(cnt_w) = '4';
            break;
          case 5:
            S[cnt_h].at(cnt_w) = '5';
            break;
          case 6:
            S[cnt_h].at(cnt_w) = '6';
            break;
          case 7:
            S[cnt_h].at(cnt_w) = '7';
            break;
          case 8:
            S[cnt_h].at(cnt_w) = '8';
            break;
        }
      }
    }
  }
  
  rep(cnt, H) {
    cout << S[cnt] << endl;
  }  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vl X(N), Y(N), Z(N);
    rep(i, N) cin >> X[i] >> Y[i] >> Z[i];
    ll ans = 0;

    rep(b,8){
        vc<pair<ll, ll>> P(N);
        ll x = (b & 1) != 0, y = (b & 2) != 0, z = (b & 4) != 0;
        rep(i,N){
            P[i].first += (x ? X[i] : -X[i]);
            P[i].first += (y ? Y[i] : -Y[i]);
            P[i].first += (z ? Z[i] : -Z[i]);
            P[i].second = i;
        }
        sort(all(P), greater<pair<ll,ll>>());

        ll sumx = 0, sumy = 0, sumz = 0;
        rep(j,M){
            ll pi = P[j].second;
            sumx += (x ? X[pi] : -X[pi]);
            sumy += (y ? Y[pi] : -Y[pi]);
            sumz += (z ? Z[pi] : -Z[pi]);
        }
        // cout << x << y << z << " " << sumx << " " << sumy << " " << sumz << endl;
        chmax(ans, abs(sumx) + abs(sumy) + abs(sumz));
    }

    cout << ans << endl;
}

Measured memory_bytes: 892
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

vector<bool> isprime;

void eratos(ll n) {
	isprime.resize(n + 1);
	for (ll i = 0; i <= n; i++) {
		isprime[i] = true;
	}
	isprime[0] = false;
	isprime[1] = false;
	for (ll i = 2; i * i <= n; i++) {
		if (isprime[i]) {
			ll j = i + i;
			while (j <= n) {
				isprime[j] = false;
				j = j + i;
			}
		}
	}
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	eratos(MAX);
	vector<ll> pr; for (int i = 2; i < MAX; i++) if (isprime[i]) pr.push_back(i);
	while (kkt) {
		ll n; scanf("%lld", &n);
		if (n == 0) break;
		if (isprime[n]) puts("0");
		else {
			auto itr = upper_bound(pr.begin(), pr.end(), n);
			ll r = *itr;
			ll l = *prev(itr);
			printf("%lld\n", r - l);
		}
	}
	return 0;

}


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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define rev_all( x ) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  unordered_map<string, int> mp;
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    mp[s]++;
  }
  for(string s: {"AC", "WA", "TLE", "RE"}){
    cout << s << " x " << mp[s] << endl;
  }
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3648
N = int(input())
S = input()

ss = []
for s in S:
    if s not in ss:
        ss.append(s)

max_count = 0
for i in range(1, N-1):
    count = 0
    for s in ss:
        x = S[0:i]
        y = S[i:N]
        if s in x and s in y:
            count += 1
    if count > max_count:
        max_count = count

print(max_count)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
string str[105];

int main() {
    int a,b,n,T,cas=0,l;

    cin>>n>>l;
    for(int i=0;i<n;++i) {
        cin>>str[i];
    }
    sort(str, str+n);
    for(int i=0;i<n;++i) {
        cout<<str[i];
    }
    return 0;
}

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

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

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

    int n;
    cin >> n;

    vector<long long int> a(n);
    rep(i, n) cin >> a[i];

    vector<long long int> c(n + 1, 0);

    rep(i, n) c[a[i]]++;

    vector<long long int> cnt(n + 1, 0);

    long long int sum = 0;
    rep(i, n + 1) {
        if (c[i] >= 2) {
            cnt[i] = c[i] * (c[i] - 1) / 2;
            sum += cnt[i];
        }
    }

    rep(i, n) {
        long long int ans;

        ans = sum - cnt[a[i]];
        if (c[a[i]] - 1 >= 2) {
            ans += (c[a[i]] - 1) * (c[a[i]] - 2) / 2;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 7296
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int m, k;
  cin >> m >> k;
  vector<int> v;
  int n = pow(2, m) - 1;
  vector<bool> visited(n + 1, false);
  if (k > n) {
    cout << "-1\n";
    return 0;
  }
  for (int i = 0; i < m; i++) {
    if (k & (1 << i)) {
      v.push_back((1 << i));
      visited[(1 << i)] = true;
    }
  }
  if (sz(v) == 1) {
    if (n == 1) {
      cout << "-1\n";
      return 0;
    }
    cout << k << " ";
    for (int i = 0; i <= n; i++) {
      if (i != k) {
        cout << i << " ";
      }
    }
    cout << k << " ";
    for (int i = n; i >= 0; i--) {
      if (i != k) {
        cout << i << " ";
      }
    }
    cout << "\n";
  } else if (k == 0) {
    for (int i = 0; i <= n; i++) {
      cout << i << " " << i << " ";
    }
    cout << "\n";
  } else {
    vector<int> ans(1, k);
    for (int i = 0; i <= n; i++) {
      if (!visited[i] && i != k) {
        ans.push_back(i);
      }
    }
    for (int i = 0; i <= n; i++) {
      if (visited[i] && i != k) {
        ans.push_back(i);
      }
    }
    for (int i = n; i >= 0; i--) {
      if (!visited[i] && i != k) {
        ans.push_back(i);
      }
    }
    ans.push_back(k);
    for (int i = n; i >= 0; i--) {
      if (visited[i] && i != k) {
        ans.push_back(i);
      }
    }
    int xxx = 0;
    for (int i = 0; i <= n; i++) {
      if (!visited[i] && i != k) {
        xxx ^= i;
      }
    }
    if (xxx != 0) {
      cout <<"-1\n";
    }
    for (int i = 0; i < sz(ans); i++) {
      cout << ans[i] << " ";
    }
    cout << "\n";
  }
}



Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;

    cin >> N;
    
    cout << ((N + 1) * N) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#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, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

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

    string S;
    cin>>S;
    ll N;
    N=S.size();

    ll dp[N+1][13];
    
    //dp初期化
    FOR(i,0,13){
        FOR(j,0,N+1){
            dp[j][i]=0;
        }
    }
    dp[0][0]=1;

    //桁ごとに見る（上から）
    char s;
    int c;
    FOR(i,1,N+1){
        s=S[i-1];
        if(s=='?') {
            FOR(k,0,10){
                //?は0~9の値を取りうる
                FOR(j,0,13){
                    dp[i][(10*j+k)%13]+=dp[i-1][j];
                    dp[i][(10*j+k)%13]%=MOD;
                }
            }
        }else{
            FOR(j,0,13){
                c=s-'0'; //intに変換
                dp[i][(10*j+c)%13]+=dp[i-1][j];
                dp[i][(10*j+c)%13]%=MOD;
            }
        }
    }

    cout<<dp[N][5]%MOD<<endl;

}
//601
//char s; s=s-'0'とやってしまって手こずった(sはcharなのでint入らない)

Measured memory_bytes: 10704
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Sum_1 = sum(A)
for i in range(N):
    A[i+1] = max(A[i+1] - max(B[i]-A[i],0) ,0)
    A[i] = max(A[i]-B[i],0)
Sum_2 = sum(A)
print(Sum_1 - Sum_2)
 

Measured memory_bytes: 18624
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int N = 120000;

int n;
int a[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	map<int, int> mm;
	for (int i = 0; i < n; ++i)
		++mm[a[i]];
	if (n % 3 == 0) {
		int g = n / 3;
		vector<int> vv;
		for (auto x: mm) {
			if (x.second % g != 0) {
				cout << "No\n";
				return 0;
			}
			while (x.second)
				vv.push_back(x.first), x.second -= g;
		}
		if ((vv[0] ^ vv[1] ^ vv[2]) != 0)
			cout << "No\n";
		else
			cout << "Yes\n";
	}
	else {
		if (mm[0] != n)
			cout << "No\n";
		else
			cout << "Yes\n";
	}
	return 0;
}




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

int main(){
    long long int n, k;
    cin >> n >> k;
    long long int res = n % k;
    if(abs(res-k) < res) res = abs(res-k);
    if(n < res) res = n;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
n,q=map(int,input().split())

par=[-1 for i in range(n)]

def root(a):
    if par[a]<0:
        return a
    else:
        return root(par[a])

def size(a):
    return -par[root(a)]

def connect(a,b):
    a=root(a)
    b=root(b)
    if a==b:
        return False
    if size(a)<size(b):
        a,b=b,a
    par[a]+=par[b]
    par[b]=a
    return True

for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        connect(b,c)
    else:
        if root(b)==root(c):
            print(1)
        else:
            print(0)

Measured memory_bytes: 11836
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string o,e;
    cin>>o>>e;
    if(o.size()==e.size()) {
        rep(i,o.size()) {
            cout<<o[i]<<e[i];
        }
    }
    else {
        rep(i,e.size()) {
            cout<<o[i]<<e[i];
        }
        cout<<o[o.size()-1];
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
  int i, j, n, input, rt, count = 0;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &input);

    count++;
    
    if (input == 2) {
      continue;
    }

    if (input % 2 == 0) {
      count--;
      continue;
    }
    rt = sqrt(input);
    for (j = 3; j <= rt; j += 2) {
      if (input % j == 0) {
	count--;
	break;
      }
    }
  }

  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 596
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dic1 = {}
dic2 = {}
for i in d:
    if i in dic1:
        dic1[i] += 1
    else:
        dic1[i] = 1
for i in t:
    if i in dic2:
        dic2[i] += 1
    else:
        dic2[i] = 1
for i in t:
    if i not in dic1:
        print("NO")
        exit()
    elif dic1[i] < dic2[i]:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 56672
//============================================================================
// Name        : training.cpp
// Author      : CoNKeR The Red Squirrel
//============================================================================
#include <bits/stdc++.h>

#define MAX_N 200005
#define INF 1000000000
#define bit(mask, i) (mask & (1<<i))

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef long long ll;
typedef double lf;

ll dp[MAX_N], frec[30], n;

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

    //freopen("acmproject.in", "r", stdin);
    //freopen("acmproject.out", "w", stdout);

    string s;
    cin>>s;
    n = (ll)s.size();
    dp[0] = 1;
    frec[s[0] - 'a']++;
    for(ll i = 1; i < n; ++i) { dp[i] = dp[i - 1] + i - frec[s[i] - 'a']++; }
    cout<<dp[n - 1]<<"\n";

    return 0;
}

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


int gcd(int a, int b) {
  int smaller = min(a, b);
  int bigger = max(a, b);
  if(smaller == 0) return bigger;
  int surplus = bigger % smaller;
  if (surplus == 0) return smaller;
  surplus = gcd(smaller, surplus);
  return surplus;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  if(n == 2){
    cout << a[1] << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  vector<int> left(n + 1, 0), right(n + 1, 0);
  for (int i = 0; i < n; ++i) left[i+1] = gcd(left[i], a[i]);
  for (int i = n-1; i >= 0; --i) right[i] = gcd(right[i+1], a[i]);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    // 左側
    int l = left[i];
    // 右側
    int r = right[i + 1];
    // 更新
    ans = max(ans, gcd(l, r));
  }
  cout << ans << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    if (i + 1 < n) {
      mx = max(mx, a[i + 1] - a[i]);
    } else {
      mx = max(mx, k - (a[i] - a[0]));
    }
  }
  cout << k - mx << '\n';
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int compar(const void *p0, const void *p1){
	const int a=*(const int*)p0, b=*(const int*)p1;
	return a-b;
}
void solve(void)
{
	const int n=3;
	const int k=2;
	int a[100];
	int sum=0;
	int i;
	for(i=0;i<n;++i){
		scanf("%d", a+i);
	}
	qsort(a, n, sizeof(*a), compar);
	for(i=0;i<k;++i){
		sum+=a[i];
	}
	printf("%d\n", sum);
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 200011

const ll def = 1000000000LL;
const double PI = 3.141592653589793;

ll px1, px2, py1, py2;
ll n, i;
pair<ll, ll> P[maxN];
bool rev;

vector< pair<ll, ll> > aux;
vector<ll> ord;
double ans;

bool special_cases() {
    if (px1 != px2 && py1 != py2)
        return false;

    if (px1 == px2 && py1 == py2) {
        cout << 0.00;
        return true;
    }

    double ans = 0.00;
    if (px1 == px2) {
        ans = 100LL * (py2 - py1);

        for (i = 1; i <= n; i++) {
            if (P[i].first == px1 && P[i].second > py1 && P[i].second < py2)
                ans += 10.00 * PI - 20.00;
        }
    } else {
        ans = 100LL * (px2 - px1);

        for (i = 1; i <= n; i++) {
            if (P[i].second == py1 && P[i].first > px1 && P[i].first < px2)
                ans += 10.00 * PI - 20.00;
        }
    }

    printf("%.15lf", ans);
    return true;
}

ll solve() {
    int i;

    ord.clear();
    for (auto e : aux) {
        auto it = lower_bound(ord.begin(), ord.end(), e.second);
        if (it == ord.end()) {
            ord.pb(e.second);
        } else {
            assert(*it != e.second);
            *it = e.second;
        }
    }

    return ord.size();
}

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

    cin >> px1 >> py1 >> px2 >> py2;
    if (px1 > px2) {
        swap(px1, px2);
        swap(py1, py2);
    }
    if (py1 > py2) {
        py1 = def - py1;
        py2 = def - py2;
        rev = true;
    }

    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> P[i].first >> P[i].second;
        if (rev) P[i].second = def - P[i].second;
    }

    if (special_cases())
        return 0;

    assert(px1 < px2);
    assert(py1 < py2);

    for (i = 1; i <= n; i++) {
        if (P[i].first >= px1 && P[i].first <= px2)
            if (P[i].second >= py1 && P[i].second <= py2)
                aux.pb(P[i]);
    }

    

    sort(aux.begin(), aux.end());
    ll vv = solve();

    ans = 100LL * (px2 - px1 + py2 - py1);
    ans += (5.00 * PI - 20.00) * (1.00 * vv);

    if (vv == min(py2 - py1 + 1, px2 - px1 + 1))
        ans += 5.00 * PI;

    assert(ans > 0.00);

    printf("%.15lf", ans);

    return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    rep(i, n) {
        scanf("%d", &a[i]);
    }
    float reverse = 0;
    rep(i, n) {
        float dis = 1 / (float)a[i];
        reverse += dis;
    }
    printf("%f", 1 / reverse);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

#define INF 100000

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

    for (int i = 0; i < 9; i++) {
        if (i * 111 < N && N <=  (i + 1) * 111) {
            cout << (i + 1) * 111 << endl;
            break;
        }
    }
    
    return 0;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}






int main(void){
    char s[15];
    int j = 0;
    int pre = 0;
    char tmp[15];
    int pattern;
    int len;
    long long ans = 0;

    scanf("%s", s);
    len = strlen(s);
    for (int i = 0; i < 1 << (len-1); i++){
        j = 1;
        pre = 0;
        pattern = i;
        pattern += 1 << len;
        while (pattern != 0){
            if ((pattern & 1) == 1){
                for (int k = 0; k < j - pre; k++){
                    tmp[k] = s[k+pre];
                    tmp[k+1] = '\0';
                }
                pre = j;
                ans += atoll(tmp);
            }
            pattern = pattern >> 1;
            j++;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 128
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    bool[4][5][5] m;
    foreach(i;0..9)
        foreach(j,b;readln().chomp().map!"a!='0'"().array())
            if(b)
                foreach(k;0..2)
                    m[i/2+k*(i%2)][j+k*(1-i%2)][k*2+i%2]=true;
    string r;
    int x=0,y=0,d=0;
    do{
        foreach(i;-1..3)
        {
            auto n = (d+i+4)%4;
            if(m[y][x][n])
            {
                x += [1,0,-1,0][n];
                y += [0,1,0,-1][n];
                d=n;
                r~="RDLU"[n];
                break;
            }
        }
    }while(x!=0 || y!=0);
    writeln(r);
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス //
using lint = long long;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

// End of Template //



int main() {

    int K;
    cin >> K;
    vi v = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    cou(v[K - 1]);

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<map>
using namespace std;
typedef long long LL;

int n, k;
bool a[10];
bool solve(int x) {
    for ( ; x; x /= 10)
        if (a[x%10]) return false;
    return true;
}
int main() {
	cin >> n >> k;
    for (int i = 0, t; i < k; i++){
        cin >> t;
        a[t] = 1;
	}
    while(!solve(n)) n++;
    cout << n << endl;
    return 0;
}

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

typedef long long ll;

const int maxn = 1e2 + 5;
const int maxw = 1e5 + 5;
const int inf = 0x3f3f3f3f;

int N, W;
ll w[maxn], v[maxn], d[maxn][maxw] = {0};

int main() {
    cin >> N >> W;
    for (int i = 1; i <= N; ++i) cin >> w[i] >> v[i];
    ll ans = 0;
    for (int i = 1; i <= N; ++i)
        for (int j = 0; j <= W; ++j) {
            if (j < w[i]) d[i][j] = d[i - 1][j];
            else d[i][j] = max(d[i - 1][j], d[i - 1][j - w[i]] + v[i]);
            ans = max(ans, d[i][j]);
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 79360
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int n = int.Parse(Console.ReadLine());
            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();
            // 整数の入力
            int q = int.Parse(Console.ReadLine());

            var countArray = new long[100001];

            for (var i = 0; i < a.Length; i++)
            {
                countArray[a[i]]++;
            }
            var result = a.Sum();

            for (int i = 0; i < q; i++)
            {
                var bc = Console.ReadLine().Split().Select(long.Parse).ToArray();
                result += (bc[1] - bc[0]) * countArray[bc[0]];
                countArray[bc[1]] += countArray[bc[0]];
                countArray[bc[0]] = 0;
                Console.WriteLine(result);
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 51260
o = input()
e = input()
if len(o) == len(e):
    for i in range(len(o)):
        print(o[i], end="")
        print(e[i], end="")
else:
    for i in range(len(e)):
        print(o[i], end="")
        print(e[i], end="")
    print(o[len(e)])
print()

Measured memory_bytes: 3064
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int ans;
  _int64 x,y;
  scanf("%lld%lld",&x,&y);
  ans=0;
  while (x<=y)
  {
    ans++;
    x*=2;
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 256
#
import sys
import math
import numpy as np
import itertools


# いくつか入力
n,m = (int(i) for i in input().split())  
# m行複数列の数をリストに
l = [[int(i) for i in input().split()] for i in range(m)] 

l = sorted(l, key=lambda x:x[0])
answer=1
a=l[0][0]
b=l[0][1]
for i in range(1,m):
    if l[i][0] >= b:
        answer += 1
        a=l[i][0]
        b=l[i][1]
    else:
        a=l[i][0]
        b=min(b,l[i][1])
#    print(answer,"-",a,b)

print(answer)




Measured memory_bytes: 32660
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b)
{
  return ((a)*1ll*(b))%mod;
}

void add_self(int &a,int b)
{
  a+=b;
  if(a>=mod)a-=mod;
}

int add(int a,int b){
  int c=a+b;
  if(c>=mod){
    c-=mod;
  }
  return c;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b)
{
  int res=1;
  while(b)
  {
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

const int N=1000002;

ll dp[205][205][205];

void solve(){
  int n;
  cin>>n;
  vi a(n);
  cin>>a;
  reverse(all(a));
  int l=2,r=3;
  if(a[0]>2){
    cout<<-1;
    return;
  }
  for(int i=1;i<n;i++){
    if(l%a[i]){
      l+=(a[i]-l%a[i]);
    }
    r=(r/a[i])*a[i]+a[i]-1;
  }
  int flag=l,flag2=r;
  for(int i=n-1;i>=0;i--){
    flag-=flag%a[i];
    flag2-=flag2%a[i];
  }
  if(flag==2&&flag2==2){
    cout<<l<<' '<<r;
  }
  else{
    cout<<-1;
  }
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tc=1;
  //~ cin>>tc;
  for(int _=0;_<tc;_++){
    //~ cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1)
      cout<<"\n";
  }
}

Measured memory_bytes: 1024
program main
  implicit none
  integer(8) i,N,W(100),S,AllW,Sst
  read(*, *) N
  read(*, *) (W(i), i = 1,N)
  AllW = 0
  do i = 1,N
    AllW = AllW + W(i)
  end do
    
  S = 0
  do i = 1,N
    S = S + W(i)
    if (AllW-2*S < 0) then
      exit
    else
      Sst = S
    end if
  end do

  write(* ,*) min(AllW-2*Sst,abs(AllW-2*S))
end program main


Measured memory_bytes: 640
n = gets.to_i
eles = []
n.times {
	op = gets.split( " " )
	if "insert" == op[0]
		eles.unshift( op[1] )
	elsif "delete" == op[0]
		i = eles.index( op[1] )
		if i
			eles.delete_at( i )
		end
	elsif "deleteFirst" == op[0]
		eles.shift( )
	elsif "deleteLast" == op[0]
		eles.pop
	end
}

puts( eles.join( " " ) )

Measured memory_bytes: 482224
package main

import (
	. "fmt"
)

// func init() { Println("----------------------------------------") }

func main() {
    var a, b, x int
    Scanf("%d %d %d", &a, &b, &x)

    if x < a || a + b < x {
        Println("NO")
    } else {
        Println("YES")
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> x(N);
  for (ll i = 0; i < N; ++i) {
    cin >> x.at(i);
  }
  vector<ll> sx = x;
  sort(sx.begin(), sx.end());
  ll mid1 = sx.at(N / 2 - 1);
  ll mid2 = sx.at(N / 2);
  ll cnt1 = upper_bound(sx.begin(), sx.end(), mid1) - lower_bound(sx.begin(), sx.end(), mid1);
  ll cnt2 = upper_bound(sx.begin(), sx.end(), mid2) - lower_bound(sx.begin(), sx.end(), mid2);
  for (ll i = 0; i < N; ++i) {
    if (x.at(i) >= mid2) {
      cout << mid1 << endl;
    }
    else {
      cout << mid2 << endl;
    }
  }

}


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


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    const int INF = 1e9;
    int h,w;
    cin >> h >>w;
    vector<string> m(h);
    for (int i = 0; i < h; i++){
        cin >> m[i];
    }
    
    auto id = [&](int r, int c){
        return r*w + c;
    };
    
    vector<vector<int> > d(h*w, vector<int>(h*w, INF));
    for (int i = 0; i < h*w; i++)d[i][i] = 0;
    
    
    auto add_edge = [&](int r1, int c1, int r2, int c2){
        d[id(r1,c1)][id(r2, c2)] = 1;
        d[id(r2, c2)][id(r1, c1)] = 1;
    };
    
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if(m[i][j] == '#')continue;
            if(i+1<h&& m[i+1][j] == '.')add_edge(i ,j ,i+1, j);
            if(j+1< w&& m[i][j+1]== '.')add_edge(i,j, i, j+1);
            if(i-1>= 0 && m[i-1][j] == '.')add_edge(i,j, i-1, j);
            if(j-1 >= 0 && m[i][j-1] == '.')add_edge(i,j, i, j-1);
        }
    }
    
    
    
    //    //闭包
    //    memset(d, 0, sizeof(d));
    //    for (int i = 0; i < n; i++)d[i][i] = 1;
    //    for(int i = 1; i <= m; i++){
    //        int u,v;
    //        cin>>u>>v;
    //        d[u][v] = 1;  //有向图
    //    }
    
    for(int k = 0; k < h*w; k++)
        for(int i = 0; i < h*w; i++)
            for(int j = 0; j < h*w; j++)
                if(d[i][k] < INF && d[k][j] < INF)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    
    int mx = 0;
    for (int i = 0; i < h*w; i++){
        for (int j = 0; j < h*w; j++){
            if(d[i][j]!=INF)mx = max(mx , d[i][j]);
        }
    }
    cout << mx << "\n";
    
    return 0;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const int N = 1e5 + 5;
vi adj[N];
int p[N] , w[N];
int n;

int f(int u){
    if(u == p[u])return u;
    return p[u] = f(p[u]);
}

bool is_connected(int a , int b){
    return f(a) == f(b);
}

void connect(int a , int b){
    a = f(a);
    b = f(b);
    if(a == b)return;
    if(w[a] < w[b])swap(a,b);
    w[a] += w[b];
    p[b] = a;
}

void init(){
    for(int i = 0 ; i < N ; i++)
        p[i] = i , w[i] = 1;
}

int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    init();
    vii edges;
    int n , u , v, c;
    cin >> n;
    vi ans(n , -1);
    loop(i,n-1){
        cin >> u >> v >> c;
        u-- , v--;
        if(c&1)edges.pb({u,v});
        else connect(u,v);
    }

    for(auto edge : edges){
        //cout << f(edge.fr) << " " << f(edge.sc) << endl;
        adj[f(edge.fr)].pb(f(edge.sc));
        adj[f(edge.sc)].pb(f(edge.fr));
    }


    queue<int> q;
    ans[f(0)] = 0;
    q.push(f(0));
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int nxt : adj[u]){
            if(ans[nxt] == -1){
                ans[nxt] = 1 - ans[u];
                q.push(nxt);
            }
        }
    }

    loop(i,n)cout << ans[f(i)] << endl;


    return 0;
}


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

#define endl '\n'

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

    int n, k, c; cin >> n >> k >> c;
    int l[k], r[k];
    string s; cin >> s;
    for (int i=0, t = 0; i<n && t<k; i++){
        if (s[i] == 'o'){
            l[t++] = i;
            i += c;
        }
    }
    for (int i=n-1, t=k-1; i>=0 && t>=0; i--){
        if (s[i] == 'o') {
            r[t--] = i;
            i -= c;
        }
    }
    for (int i=0; i<k; i++){
        if (l[i] == r[i]) cout << l[i] +1<< endl;
    }
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;cin>>n;
	string s;cin>>s;
	ll cnt1 = 0;
	ll cnt2 = 0;

	for(ll i = 0; i < n; i++) {
		if (s[i] == '.')cnt1++;
	}
	ll ans = LINF;
	for(int i = 0; i < n; i++) {
		if (s[i] == '.'){
			ans = min(ans,cnt1 + cnt2);
			cnt1--;
		}
		else{
			ans = min(ans,cnt1 + cnt2);
			cnt2++;
		}
	}
	ans = min(ans,cnt2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys, math
from sys import stdin, stdout

rem = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, stdin.readline().split())

d,n=take()
if d==0 and n==100:
    print 101
elif d==1 and n==100:
    print 10100
elif d==2 and n==100:
    print 100**(d)*n +10000
else:
    print 100**(d)*n

Measured memory_bytes: 2568
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
#include <string> 
#include <sstream>
#include <cstring> 
#include<cmath>
using namespace std;
int main()
{
	string x;
	cin >> x;
	int y = 0;
	for (int i = 0; i < 3; i++) {
		if (x[i] == 'o')
			y++;
	}
	cout << 700 + 100 * y;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* debugging */
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;

    
    
    //code
    int n;
    cin >> n;
    int a[n] , p[n] = {0};

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

    p[0] = a[0];
    for(int i = 1; i < n ; ++i){
    	p[i] = p[i-1] + a[i];
    }

    // for(int i = 0 ; i < n ; ++i){
    // 	cout << p[i] << " ";
    // }
    int ans = 1e9;
    for(int i = 1; i < n ; ++i){
    	// cout << p[i] - p[n-1]-p[i-1];
    	ans = min( ans , abs(p[i] - (p[n-1]-p[i])));
    }

    cout << ans;
    return 0;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  string T;
  cin>>T;
  for(auto x:T){
    if(x=='?') cout<<'D';
    else cout<<x;
  }
  cout<<endl;
}

Measured memory_bytes: 3756