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

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

int main() {
  string s, t;
  int n;
  cin >> n >> s >> t; 
  
  string ans = "";
  int len = 2*n;
  rep (i, len) {
    (i%2 == 0) ? ans.push_back(s[i/2]) : ans.push_back(t[i/2]);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> a(3*N,0);
    for(ll i=0;i<3*N;++i)cin>>a[i];
    //b[i]は区間[0,N+i)の上位N個のsum
    vector<ll> b(N+1,0);
    //c[i]は区間[N+i,3N)の下位N個のsum
    vector<ll> c(N+1,0);
    ll sum=0;
    multiset<ll> S;
    for(ll i=0;i<N;++i){S.insert(a[i]);sum+=a[i];}
    for(ll i=0;i<=N;++i){
        b[i]=sum;
        S.insert(a[N+i]);
        sum+=a[N+i];
        sum-=(*S.begin());
        S.erase(S.begin());
    }

    S.clear();
    sum=0;

    for(ll i=2*N;i<3*N;++i){S.insert(a[i]);sum+=a[i];}
    for(ll i=N;i>=0;--i){
        c[i]=sum;
        S.insert(a[N+i-1]);
        sum+=a[N+i-1];
        sum-=(*(prev(S.end())));
        S.erase((prev(S.end())));
    }

    ll ans=-INF;
    for(ll i=0;i<=N;++i)chmax(ans,b[i]-c[i]);

    prt(ans)

    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>

using namespace std;

int main() {
    string s[3];
    cin >> s[0];
    cin >> s[1];
    cin >> s[2];

    for (size_t i = 0; i < 3; i++)
    {
        transform(s[i].begin(), s[i].end(), s[i].begin(), (int(*)(int))toupper);
        cout << s[i][0];
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = A+B;

    if(ans % 2 != 0) {
    	System.out.println("IMPOSSIBLE");
    } else {
    	System.out.println(ans/2);
    }
  }
}

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

int main(void){
    char t[1200];
    int n=0,e=0,w=0,s=0;
    scanf("%s",t);
    for (int i=0; i<strlen(t); i++){
        if (t[i]=='N'){
            n=1;
        } else if (t[i]=='E'){
            e=1;
        } else if (t[i]=='W'){
            w=1;
        } else if (t[i]=='S'){
            s=1;
        }
    }
    if (n==s && e==w){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
	return 0 ;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int solve(const string& s, int c) {
  int ret = 0;
  rep(i, s.size()) if ((s[i] - '0') != ((i + c) % 2))++ ret;
  return ret;
}

int main() {
  in(string, s);
  out(min(solve(s, 0), solve(s, 1)));
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll f(ll n) {
    switch(n % 4) {
        case 0:
            return n;
        case 1:
            return 1;
        case 2:
            return n + 1;
        case 3:
            return 0;
    }
}

int main()
{
    ll A, B; cin >> A >> B;
    cout << (f(A-1) ^ f(B)) << endl;
    return 0;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    cout << (s[0] == '9' || s[1] == '9' ? "Yes" : "No") << endl;
}


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

total = sum(votes)

c = 0
threshold = 1 / (4 * m) * total
for v in votes:
    if c == m:
        break
    if v >= threshold:
        c += 1
if c == m:
    print("Yes")
else:
    print("No")


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
//#define end endl
//#define endl() end()
#define f first
#define s second
#define pb push_back
#define mp make_pair

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

vector<ii> va, vm, vf;

int main(){ _
	char end = '\n';
	int n;

	cin >> n;

	for (int i=0; i<n; i++)
	{
		string s;
		cin >> s;
		int ca = 0, cf = 0, c=0;

		for (int j=0; j<s.size(); j++)
		{
			if (s[j] == '(')
				c++;
			else
			{
				if (c)
				{
					c--;
				}
				else
					cf++;
			}
		}
		c = 0;
		for (int j=((int)s.size())-1; j>=0; j--)
		{
			if (s[j] == ')')
				c++;
			else
			{
				if (c)
				{
					c--;
				}
				else
					ca++;
			}
		}
		if (ca > cf)
		{
			va.pb(mp(cf,ca));
		}
		else if (ca == cf)
		{
			vm.pb(mp(cf,ca));
		}
		else
		{
			vf.pb(mp(ca,cf));
		}
	}
	sort(va.begin(),va.end());
	sort(vm.begin(),vm.end());
	sort(vf.begin(),vf.end());


	int saldo = 0;
	int bom = 1;
	for (int i=0; i<va.size(); i++)
	{
		//cout << "[" << va[i].f << " " << va[i].s << endl;
		if (saldo < va[i].f)
		{
			bom = 0;
			break;
		}
		saldo -= va[i].f;
		saldo += va[i].s;
	}

	for (int i=0; i<vm.size(); i++)
	{
		//cout << "=" << vm[i].f << " " << vm[i].s << endl;
		if (saldo < vm[i].f)
		{
			bom = 0;
			break;
		}
		saldo -= vm[i].f;
		saldo += vm[i].s;
	}


	for (int i=((int)vf.size())-1; i>=0; i--)
	{
		//cout << "]" << vf[i].f << " " << vf[i].s << endl;

		saldo -= vf[i].s;
		if (saldo < 0)
			bom = 0;
		saldo += vf[i].f;
	}

	if (saldo!=0)
		bom = 0;
	if (bom)
		cout << "Yes\n";
	else
		cout << "No\n";


	exit(0);
}


Measured memory_bytes: 11296
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

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> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(string S) {
  cout << (int(S.size()) >= 4 && S.substr(0, 4) == "YAKI") << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	string S;
	cin >> S;
	solve(S);
	return 0;
}


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

int main(){
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	while(m--){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		mp[a]++;
		mp[b]++;
	}
	for(int i = 0; i < n; i++) cout << mp[i] << endl;
}

Measured memory_bytes: 256
N=int(input())
MOD=10**9+7

primes=[]
is_prime = [True]*(N+1)
is_prime[0]=is_prime[1]=False
i=2
for i in range(N+1):
    if is_prime[i]:
        primes.append(i)
        j=i*2
        while j <= N:
            is_prime[j]=False
            j+=i

factor_num=dict()
for p in primes:
    factor_num[p]=0
for n in range(2,N+1):
    for p in primes:
        m=n
        while m:
            if m%p:
                break
            factor_num[p]+=1
            m//=p

ans=1
for f in factor_num.values():
    ans=ans*(f+1)%MOD

print(ans)


Measured memory_bytes: 39408
#include<stdio.h>

int main(void){
  int a, b, c, d, e, k;
  scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &k);
  if( (e-a) <= k ){
    printf("Yay!\n");
  }else{
    printf(":(\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;

typedef pair<int, int> P;

void Main() {
  int H, W, D;
  cin >> H >> W >> D;

  P A[H * W + 1];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int n;
      cin >> n;
      A[n] = P(i, j);
    }
  }
  long long cost[H * W];
  for (int i = 1; i <= D; i++) {
    cost[i] = 0;
    for (int j = i + D; j <= H * W; j += D) {
      cost[j] = cost[j - D] + abs(A[j].first - A[j - D].first) + abs(A[j].second - A[j - D].second);
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << cost[r] - cost[l] << endl;
  }
}

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



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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
	int n,h,w; cin >> n >> h >> w;
	vector<int> x(n);
	for(auto &e : x) cin >> e;
	vector<bool> p(n*w, false);
	for(int i = 0; i < n; i++){
		if(i & 1){
			for(int j = 0; j < w; j++){
				p[i*w + j - x[i]] = true;
			}
		}
		else{
			for(int j = 0; j < w; j++){
				p[i*w + j + x[i]] = true;
			}
		}
	}
	int ans = 0;
	for(auto e : p)ans += e ? 0 : h;
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if (u==s) a--;
    else b--;
    cout<<a<<' '<<b;   
    return 0;
}

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

int main() {
    int N, S; cin >> N >> S;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    int res = N + 1;
    int right = 0;
    int sum = 0;
    for(int left = 0; left < N; ++left) {
        while(right < N && sum < S) {
            sum += A[right];
            ++right;
        }

        if(sum < S) break;
        res = min(res, right - left);

        if(left == right) ++right;
        else sum -= A[left]; 
    }
    
    cout << (res < N + 1 ? res : 0) << endl;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e5+7;
const int n_max = 1e9;



int main(){
    ll s; cin >> s;

    ll x2 = 1e9, y2 = 1;
    ll y3,x3;
    y3 = (s / x2) + 1;
    if(1e9 < y3)y3 = 1e9;
    x3 = y3 * x2 - s;
    cout << "0 0 1000000000 1 " << x3  << ' ' << y3 << endl;
    // cout << endl;
    return 0;

}

Measured memory_bytes: 256
import sys
X,N = map(int,input().split())
if N == 0:
  print(X)
  sys.exit()
  
p = list(map(int,input().split()))

for i in range(N):
  X_ = X+i
  _X = X-i
  
  if not _X in p:
    print(_X)
    sys.exit()
  elif not X_ in p:
    print(X_)
    sys.exit()
print(X-1)

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

int N, K, result;
char S[100010];

int main(){
	cin >> N >> K >> S;
	result = 0;
	for (int i = 1; i < N; i++)
		result += (S[i] == S[i - 1]);
	result = min(result + 2 * K, N - 1);
	cout << result << endl;
}

Measured memory_bytes: 3724
def main():
    n = int(input())
    a_list = sorted(list(map(int, input().split())), reverse=True)
    ans = a_list[0]

    cnt = 1
    i = 1
    while True:
        if cnt >= n - 2:
            break
        ans += a_list[i] * 2
        i += 1
        cnt += 2

    if cnt == n - 2:
        ans += a_list[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 105064
X,K,D = map(int,input().split( ))
X = abs(X)
a = X//D
b = X%D
if a >= K:
    ans = X - K*D
else:   
    if abs(b - D) < abs(b):
        a += 1
        b = abs(b-D)
    K -= a
    if K%2 == 0:
        ans = b
    else:
        ans = abs(b-D)
print(ans)

Measured memory_bytes: 9124
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t C;
int64_t V[100000];
int64_t X[100000];

int64_t L_go[100000];
int64_t L_ret[100010];

int64_t R_go[100000];
int64_t R_ret[100010];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> C;
	for (int32_t i = 0; i < N; i++)
	{
		in >> X[i] >> V[i];
	}

	int64_t vsum = 0;
	for (int32_t i = 0; i < N; i++)
	{
		vsum += V[i];
		R_go[i] = vsum - X[i];
		R_ret[i+1] = std::max(R_ret[i], vsum - X[i] * 2);
	}
	vsum = 0;
	for (int32_t i = N-1; i >= 0; i--)
	{
		vsum += V[i];
		L_go[i] = vsum - (C-X[i]);
		if (i != 0) {
			L_ret[i - 1] = std::max(L_ret[i], vsum - (C - X[i]) * 2);
		}
	}

	int64_t max = 0;

	for (int32_t i = 0; i < N; i++)
	{
		max = std::max(max,
			R_go[i] + L_ret[i]
			);
		max = std::max(max,
			L_go[i] + R_ret[i]
		);
	}

	out << max << endl;

	return 0;
}
#endif


Measured memory_bytes: 4992
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
Alice=[0,0]
Bob=[0,0]
for i in a:
  if Alice[1]==Bob[1]:
    Alice[0]+=i
    Alice[1]+=1
  else:
    Bob[0]+=i
    Bob[1]+=1
print(Alice[0]-Bob[0])

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

int main () {
    int r, c;
    cin >> r >> c;
    vector<vector<int>> r_c(r+1, vector<int>(c));

    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> r_c[i][j];
        }
    }

    for (int i = 0; i < c; i++) {
        int result = 0;
        for (int j = 0; j < r; j++) {
            result += r_c[j][i];
        }
        r_c[r][i] = result;
    }

    for (int i = 0; i < r_c.size(); i++) {
        for (int j = 0; j < r_c[i].size(); j++) {
            printf("%d ", r_c[i][j]);
        }
        printf("%d\n", accumulate(r_c[i].begin(), r_c[i].end(), 0));
    }
    return 0;
}


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

int main(){
  int A, B, K;
  cin >> K >> A >> B;
  bool ans = false;
  for(int i = A; i <= B; i++){
    if(i % K == 0){
      ans = true;
    }
  }
  if(ans) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

ll f(ll x){
  if(x%2==0){return x/2;}
  else{return 3*x+1;}
}

int main() {
  ll s,ans,cnt=0;
  cin>>s;
  vector<ll> a;
  a.push_back(s);
  
  for(ll i=1;cnt<2;i++){
    a.push_back(f(a[i-1])); 
    if(a[i]==1){cnt++;}
  }
  bool flag=false;
  rep1(i,a.size()){
    rep0(j,i){if(a[i]==a[j]){ans=i; flag=true; break;}}
    if(flag){break;}
  }
  cout<<ans+1<<endl;
}

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

int main()
{
	int a,b,c,ans1,ans2, ans3,temp,temp2,temp3;
	scanf("%d %d %d", &a, &b, &c);
	temp = a;
	a = 0;
	if(c>b)
        ans1 = c-b;
	else
        ans1 = b-c;

	temp2 = b;
	b = 0;
	if(c>temp)
        ans2 = c-temp;
	else
        ans2 = temp-c;

	temp3 = c;
	c = 0;
	if(temp>temp2)
        ans3 = temp-temp2;
	else
        ans3 = temp2-temp;

	if(ans1>=ans2 && ans1>=ans3)
        printf("%d\n", ans1);
    else if(ans2>=ans1 && ans2>=ans3)
        printf("%d\n", ans2);
    else
        printf("%d\n", ans3);
    return 0;

}




Measured memory_bytes: 128
string = list(input())

def isA(strlist):
    if strlist[0] == 'A':
        return True

def isC1(strlist):
    if strlist[2:-1].count('C') == 1:
        return True

def issmall(strlist):
    strlist = strlist[2:-1] + [strlist[1]] + [strlist[-1]]
    strlist.remove('C')
    string = ''.join(strlist)
    if string.islower():
        return True


if isA(string) and isC1(string) and issmall(string):
    print('AC')
else:
    print('WA')



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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int inf = (1<<28);
const ll infl = (1LL<<60);

int main() {
    int N, L, Q; cin >> N;
    vl x(N); ina(x, N);
    vvl dp(N, vl(50));
    cin >> L >> Q;
    rep(i,N) {
        dp[i][0] = upper_bound(all(x), x[i]+L)-x.begin() - 1;
    }
    rep(k,40) rep(i,N) {
        dp[i][k+1] = dp[dp[i][k]][k];
    }

    rep(i,Q) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        ll ans = 1;
        while (dp[a][0] < b) {
            int k = lower_bound(all(dp[a]), b)-dp[a].begin() - 1;
            a = dp[a][k];
            ans += pow(2, k);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 44544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        int c = Integer.parseInt(a + b);

        int d = (int) Math.sqrt(c);
        if (c == d * d) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 39384
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    int a[s.size()]={};
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A' and s[i+1]=='C'){
            a[i+1]=1;
        }
    }
    for(int i=0;i<s.size()-1;i++){
        a[i+1]+=a[i];
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        l--;
        r--;
        cout<<a[r]-a[l]<<endl;
    }
   return 0;

}

Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
	puts(a==b?"=":a<b?"<":">");
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int ans = 1;
    for(int i = 0; i < n; i++){
      ans = Math.min(2 * ans, ans + k);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // memset()
#include <stdbool.h>

#define MAX_N 100000
#define MAX_F 50000

int s[MAX_N];
bool f[MAX_F];
int m = 0;

bool
search(int x)
{
	int l = 0, r = m - 1;
	while (l <= r)
	{
		int i = (l + r) / 2;
		if (x > s[i])
			l = i + 1;

		else if (x < s[i])
			r = i - 1;

		else
			return true;
	}

	return false;
}

int
main(int argc, char** argv)
{
	int n = 0;
	int q = 0;
	int u = 0;
	int v = 0;
	int i;

	memset(f, 0x00, sizeof(f));
	scanf("%d", &n);
	m = 0;
	for (i = 0; i < n; ++i)
	{
		scanf("%d", &u);
		if (u < MAX_F)
			f[u] = true;
		else
			s[m++] = u;
	}

	scanf("%d", &q);
	int count = 0;
	for (i = 0; i < q; ++i)
	{
		scanf("%d", &v);
		if (v < MAX_F)
		{
			if (f[v])
				count++;
		}
		else
		{
			if (search(v))
				count++;
		}
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;cin>>s;
    string ans;
    for(int i=0;i<s.size();i++){
        if(s[i]=='B'){
            if(ans.size()==0){
                continue;
            }
            ans=ans.erase(ans.size()-1);
        }
        else{
            ans+=s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3580
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

l = [int (i) for i in raw_input ().split ()]
d = defaultdict (int)
for i in l: d [i] += 1
print [i for i in d if d [i] == 1][0]



Measured memory_bytes: 4392
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
int main(){
  long long mini=INF;
  long long w,h;
  cin>>h>>w;
  if(h%3==0||w%3==0){
    cout<<0<<endl;
    return 0;
  }
  long long a,b,c;
  for(int i=1;i<=w;i++){
    if(h%2==1){
      a=i*h;
      b=(w-i)*h;
      c=(w-1)*(h+h%2);
    }else{
      a=i*h;
      b=(w-i)*int(h/2);
      c=(w-i)*int(h/2);
    }
    
    mini=min(mini,max(a,max(b,c))-min(a,min(b,c)));
 
    if(h%2==0){
      a=i*h;
      b=(w-i)*(int(h/2)+1);
      c=(w-i)*(int(h/2)-1);
    }
    
    //cout<<a<<" "<<b<<" "<<c<<endl;
    mini=min(mini,max(a,max(b,c))-min(a,min(b,c)));
  }
 
  
  //cout<<"hh"<<endl;
  for(int i=1;i<h;i++){
    if(w%2==1){
      a=i*w;
      b=(h-i)*int(w/2);
      c=(h-i)*(int(w/2)+1);
    }else{
      a=i*w;
      b=(h-i)*(int(w/2)-1);
      c=(h-i)*(int(w/2)+1);
    }
    //cout<<a<<" "<<b<<" "<<c<<endl;
    mini=min(mini,max(a,max(b,c))-min(a,min(b,c)));
    if(w%2==0){
      a=i*w;
      b=(h-i)*(int(w/2));
      c=(h-i)*(int(w/2));
    }
    mini=min(mini,max(a,max(b,c))-min(a,min(b,c)));
  }
  if(w>3){
    long long s;
    s=(int(w/3)+1)*h-int(w/3)*h;
    mini=min(mini,s);
  }
  
  if(h>3){
    long long s;
    s=(int(h/3)+1)*w-int(h/3)*w;
    mini=min(mini,s);
  }
  cout<<mini<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[55] = {}, z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) z += a[i] * a[j];
    cout << z;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] st = s.split(" ");
		int[] ints = new int[3];
		for (int i = 0; i < 3; i++) {
			ints[i] = Integer.parseInt(st[i]);
		}
		Arrays.sort(ints);
		System.out.print(ints[0]);
		System.out.print(" ");
		System.out.print(ints[1]);
		System.out.print(" ");
		System.out.println(ints[2]);
	}

}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(int i = (int)k; i < (int)n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(int i = (int)n-1; i > (int)k-1; i--)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl;

typedef long long ll;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int N, M;
bool c[9][9] = {false};
int ans=0;

void dfs(int pos, vector<bool> open) {
    bool ok=true;
    REP(i,1,open.size()) if(open[i]) ok=false;
    if(ok) {
        ans++;
        return;
    }

    REP(i,2,10) {
        if(c[pos][i] && open[i]) {
            open[i] = false;
            dfs(i,open);
            open[i] = true;
        }
    }
}

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

    cin >> N >> M;
    rep(i,M) {
        int a, b;
        cin >> a >> b;
        c[a][b] = c[b][a] = true;
    }

    vector<bool> arr = vector<bool>(N+1,true);
    arr[0]=arr[1]=false;

    dfs(1,arr);
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    set<string> myset;
    rep(i, n)
    {
        string s;
        cin >> s;
        myset.insert(s);
    }

    cout << myset.size() << endl;
}

Measured memory_bytes: 19180
def main():
    N = int(input())
    A = list(map(int, input().split()))

    count = [0] * (N)

    for i in range(len(A)):
        # print(i)
        count[A[i]-1] += 1

    for s in range(len(count)):
        print(count[s])






if __name__ == '__main__':
    main()

Measured memory_bytes: 32240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <limits.h>
 
using namespace std;

const int MAXN = 1e6 + 2;
const int INF = 1e9;
const double PI = 3.141592653589793;

int lc(vector<int>& a) {
    int n = a.size();
    if (n == 0) {
        return 0;
    }
    vector<int> d(n + 1);
    d[0] = -INF;
    for (int i=1; i<=n; ++i) {
        d[i] = INF;
    }
     
    for (int i=0; i<n; i++) {
        int j = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
        if (d[j-1] < a[i] && a[i] < d[j]) {
            d[j] = a[i];
        }
    }
    for (int i = n; i >= 0; --i) {
        if (d[i] != INF) {
            return i;
        }
    }
    return 0;
}
 
double find_min(vector<pair<int, int>>& a, int x1, int y1, int x2, int y2) {
    int n = a.size();
    if (y2 < y1) {
        y1 *= -1;
        y2 *= -1;
        for (int i = 0; i < n; ++i) {
            a[i].second *= -1;
        }
    }
    std::vector<pair<int, int>> cur;
    for (int i = 0; i < n; ++i) {
        if (a[i].first <= x2 && a[i].first >= x1 && a[i].second <= y2 && a[i].second >= y1) {
            cur.push_back(a[i]);
        }
    }
    double ans = 0;
    vector<int> k(cur.size());
    sort(cur.begin(), cur.end());
    for (int i = 0; i < (int)cur.size(); ++i) {
        k[i] = cur[i].second;
    }
    int lcs = lc(k);
    if (lcs == x2 - x1 + 1 || lcs == y2 - y1 + 1) {
        ans += 10 * PI - 20.0;
        ans += (20.0 - 5 * PI);
    }
    return 100.0*((double)x2 - (double)x1 + (double)y2 - (double)y1) + ans - (double)lcs * (20.0 - 5 * PI);
}
 
int main(void) {
    int x1, y1, x2, y2;
    int n;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 > x2) {
        std::swap(x1, x2);
        std::swap(y1, y2);
    }
    scanf("%d", &n);
    std::vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &a[i].first, &a[i].second);
    }
    if (x1 == x2) {
        for (int i = 0; i < n; ++i) {
            if (a[i].first == x1 && a[i].second <= max(y2, y1) && a[i].second >= min(y1, y2)) {
                printf("%.15g\n", abs((double)y2 - (double)y1)*100.0 + 10.0 * PI - 20.0);
                return 0;
            }
        }
    } else if (y1 == y2) {
        for (int i = 0; i < n; ++i) {
            if (a[i].second == y1 && a[i].first <= max(x2, x1) && a[i].first >= min(x1, x2)) {
                printf("%.15g\n", abs((double)x2 - (double)x1)*100.0 + 10.0 * PI - 20.0);
                return 0;
            }
        }
    }
    printf("%.15g\n", find_min(a, x1, y1, x2, y2));
    return 0;
}

Measured memory_bytes: 4976
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;

void Onigiri()
{
  int n;
  cin>>n;
  int ans=0;
  rep(i,1,n+1)
  rep(j,1,n+1)
  rep(k,1,n+1)
  {
    ans=ans+__gcd(i,__gcd(j,k));
  }
  cout<<ans;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
//#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}
int a[maxn], b[maxn];


int main(void) {
    FAST_IO;
    int n;
    cin >> n;
    for (int i = 1; i <= n + 1; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    ll tot = 0;
    for (int i = 1; i <= n; i++) {
        int x = min(a[i], b[i]);
        a[i] -= x;
        b[i] -= x;
        tot += x;
        if (b[i] > 0) {
            tot += min(b[i], a[i + 1]);
            a[i + 1] -= min(b[i], a[i + 1]);
        }
    }
    cout << tot << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int ABCD, A[4];
    cin >> ABCD;
    A[0] = ABCD/1000;
    A[1] = (ABCD - A[0]*1000)/100;
    A[2] = (ABCD - A[0]*1000 - A[1]*100)/10;
    A[3] = ABCD - A[0]*1000 - A[1]*100 - A[2]*10;

    int bit, sum;
    char ans[3];
    for(bit=0; bit<(1<<3); bit++) {
        // cout << bit << endl;
        sum = A[0];
        int i;
        for(i=0; i<3; i++) {
            if(bit & (1<<i)) {
                sum += A[i+1];
                ans[i] = '+';
            } else {
                sum -= A[i+1];
                ans[i] = '-';
            }
        }
        if(sum==7) {
            break;
        }
    }

    cout << A[0] << ans[0] << A[1] << ans[1] << A[2] << ans[2] << A[3] << "=7" << endl;

    return 0;
    
}

Measured memory_bytes: 256
function check(rrr)
    tmp = rrr
    res = "OK"
    posstr = string.sub(s, tmp, tmp)
    for i = 1, q do
        if(svtgt[i] == posstr) then
            if(svway[i] == "L") then
                if(tmp == 1) then
                    res = "LEFT"
                else
                    tmp = tmp - 1
                    posstr = string.sub(s, tmp, tmp)
                end
            else
                if(tmp == n) then
                    res = "RIGHT"
                else
                    tmp = tmp + 1
                    posstr = string.sub(s, tmp, tmp)
                end
            end
        end
        if(res ~= "OK") then break end
    end
    return res
end

n, q = io.read("*n", "*n", "*l")
s = io.read()

svtgt, svway = {}, {}
for i = 1, q do
    tgt, zz, way = io.read(1, 1, "*l")
    table.insert(svtgt, tgt)
    table.insert(svway, way)
end
leftmin = 1
leftmax = n
leftkill = 0
fres, nres = check(1), check(n)
if(nres == "LEFT") then
    leftkill = n
elseif(fres == "LEFT") then
    while(1 < leftmax -leftmin) do
        leftmid = math.floor((leftmin + leftmax) / 2)
        midret = check(leftmid)
        if(midret == "LEFT") then
            leftmin = leftmid
        else
            leftmax = leftmid
        end
    end
    leftkill = leftmin
end
rightmin = 1
rightmax = n
rightkill = 0
if(check(1) == "RIGHT") then
    rightkill = n
elseif(nres == "RIGHT") then
    while(1 < rightmax - rightmin) do
        rightmid = math.floor((rightmin + rightmax) / 2)
        midret = check(rightmid)
        if(midret == "RIGHT") then
            rightmax = rightmid
        else
            rightmin = rightmid
        end
    end
    rightkill = n + 1 - rightmax
end
print(n - leftkill - rightkill)


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

int main(void) {
    vector<int> abc(3);
    for(int i=0;i<3;i++) {
        cin >> abc[i];
    }

    sort(abc.begin(), abc.end());
    cout << abc[2]*10+abc[1]+abc[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd



int main() {
	int n, k;
	cin >> n >> k;
	if (k % 2 != 0) {
		ll temp = n / k;
		cout << temp * temp*temp;
	}
	else {
		ll temp = n / k;
		if (n%k >= k / 2) {
			cout << temp * temp*temp + (temp + 1)*(temp + 1)*(temp + 1);

		}
		else {
			cout << temp * temp*temp*2;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main(){
  int n;cin>>n;bool a[100001];rep(i,100001)a[i] = false;
  int k = 0;
  rep(i,n){
    int aa;cin>>aa;
    if(!a[aa]){
      a[aa] = true;
      k++;
    }
  }
  if(k%2){
    cout << k << endl;
  }else{
    cout << k - 1 << endl;
  }
}


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


int main(){
	int n;
	cin>>n;
	
	int prox=10;
	int odd=1;
	
	int res=0;
	
	for (int i=1; i<=n; i++){
		if (i==prox){
			prox*=10;
			odd=!odd;
		}
		
		res+=odd;
		
	}
	
	cout<<res<<endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long
#define MAXN 200005
using namespace std;

int N,M0,M1;
vector<int> adj[2][MAXN];
vector<int> s[2][MAXN];

int p[2][MAXN];
void dfs(int u, int x, int f){
	p[f][u] = x;
	s[f][x].push_back(u);
	
	int v;
	for(int k=0;k<adj[f][u].size();k++){
		v = adj[f][u][k];
		if(!p[f][v]) dfs(v, x, f);
	}
}

int ans[MAXN], vis[MAXN];
void work(int id){
	int x = p[0][id];
	int v;
	for(int k=0;k<s[0][x].size();k++){
		v = s[0][x][k];
		vis[p[1][v]]++;
	}

	for(int k=0;k<s[0][x].size();k++){
		v = s[0][x][k];
		ans[v] = vis[p[1][v]];
	}
	
	for(int k=0;k<s[0][x].size();k++){
		v = s[0][x][k];
		vis[p[1][v]]--;
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin>>N>>M0>>M1;
	
	int u,v;
	for(int i=1;i<=M0;i++){
		cin>>u>>v;
		adj[0][u].push_back(v);
		adj[0][v].push_back(u);
	}
	for(int i=1;i<=M1;i++){
		cin>>u>>v;
		adj[1][u].push_back(v);
		adj[1][v].push_back(u);
	}
	
	for(int i=1;i<=N;i++){
		if(!p[0][i]){
			dfs(i,i,0);
		}
		if(!p[1][i]){
			dfs(i,i,1);
		}
	}
	
	for(int i=1;i<=N;i++){
		if(ans[i] == 0){
			work(i);
		}
	}
	
	//for(int i=1;i<=N;i++) cout<<p1[i]<<" "<<p2[i]<<endl;
	for(int i=1;i<=N;i++) cout<<ans[i]<<" ";
	return 0;
}



Measured memory_bytes: 36608
S = list(input())
N = len(S)

con_1 = S[0:int((N-1)/2)]
con_2 = S[int((N+3)/2)-1:N]

if S == S[::-1] and con_1 == con_1[::-1] and con_2 == con_2[::-1]: 
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	string s; cin >> s;
	int n = s.size();
	int ans = 3;
	for (int mask = 0; mask < (1 << n); mask++) {
		int ci = 0, cw = 0;
		for (int i = 0; i < n; i++) {
			if (!(mask&(1 << i)))continue;
			if (s[i] == 'i')ci++;
			else if (s[i] == 'w')cw++;
		}
		if (!(ci == 2 && cw == 1))continue;

		int tmp = 1;
		int l = 0, r = n - 1;
		while (true) {
			if (l == r) break;
			if (!(mask&(1 << l))) { l++; continue; }
			if (!(mask&(1 << r))) { r--; continue; }

			if (s[l] == '['&&s[r] == ']')tmp+=2;
			else if (s[l] == ']'&&s[r] == '[')tmp+=2;
			else if (s[l] == '('&&s[r] == ')')tmp+=2;
			else if (s[l] == ')'&&s[r] == '(')tmp+=2;
			else if (s[l] == '{'&&s[r] == '}')tmp+=2;
			else if (s[l] == '}'&&s[r] == '{')tmp+=2;
			else if (s[l] == 'i'&&s[r] == 'i')tmp+=2;
			else { tmp = 3; break; }
			l++; r--;
		}
		chmax(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <stdio.h>

using namespace std;

int n;
string from[10];
string to[10];
string start;
string end;

bool replace(string &next, int i) {
  int index = 0;
  if (next.find(from[i], 0) == string::npos) { return false; }
  while (index < (int)next.size()) {
    int nindex = next.find(from[i], index);
    if (nindex == (int)string::npos) { break; }
    next.replace(nindex, (int)from[i].size(), to[i]);
    index = nindex + (int)to[i].size();
  }
  return true;
}

int calc(string str) {
  //cout << str << endl;
  if (str == end) { return 0; }
  if (str.size() >= end.size()) { return 100; }
  int ret = 100;
  for (int i = 0; i < n; i++) {
    string next = str;
    if (!replace(next, i)) { continue; }
    ret = min(ret, 1 + calc(next));
  }
  return ret;
}

int main() {
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> from[i] >> to[i];
    }
    cin >> start;
    cin >> end;
    int ans = calc(start);
    if (ans >= 100) {
      puts("-1");
    } else {
      printf("%d\n", ans);
    }
  }
}

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

int main(){
	int n,m,x,y;
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> x >> y;
	int t;
	while(n--){
		cin >> t;
		x = max(x, t);
	}
	while(m--){
		cin >> t;
		y = min(y, t);
	}
	cout << (x < y?"No War":"War") << '\n';
}


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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "3";

int a[siz], b[siz];

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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int n, m, k;
    cin >> n >> m >> k;

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

        a[i] += a[i - 1];
    }

    for (int i = 1; i <= m; i++) {
        cin >> b[i];

        b[i] += b[i - 1];
    }

    int ans = 0;
    for (int i = 0, j = m; i <= n; i++) {
        if (k - a[i] < 0) {
            break;
        }

        while (a[i] + b[j] > k) {
            j--;
        }

        ans = max(ans, i + j);
    }

    cout << ans << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(b-a)<=d && abs(c-b)<=d)||abs(c-a)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

void print_vec(vector<int> A)
{
	for(int i = 0 ; i < A.size() ; i++)
	{
		cout<<A[i]<<" ";
	}
	cout<<endl;
}


int main()
{
  int n;
  cin>>n;
  vector<int> A(n);
  vector<int> B(n);
  vector<int> C(n-1);
  for(int i = 0 ; i < n ; i++)
  {
  	cin>>A[i];
  	A[i]--;
  }
  for(int i = 0 ; i < n ; i++)
  {
  	cin>>B[i];
  }
  for(int i = 0 ; i < (n-1) ; i++)
  {
  	cin>>C[i];
  }
  long long int ans = 0 ;
  for(int i = 0 ; i < n ; i++)
  {
  	ans += B[A[i]];
  	if(i > 0  && A[i-1] == (A[i]-1))
  	{
  		ans += C[A[i-1]];
  		//cout<<"i: "<<i<<" C[i-1]: "<<C[i-1]<<endl;	
  	}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll K;
	cin >> K;

	vector<ll> A;
	vector<ll> L;

	for (ll i = 1; i <= 9; ++i)
	{
		A.push_back(i);
		L.push_back(i);
	}

	for (ll i = 0; i < 10; ++i)
	{
		vector<ll> B = A;
		A.clear();

		for (const auto e : B)
		{
			ll x = e % 10;

			if (x > 0)
			{
				A.push_back(e * 10 + x - 1);
				L.push_back(e * 10 + x - 1);
			}
			A.push_back(e * 10 + x);
			L.push_back(e * 10 + x);
			if (x < 9)
			{
				A.push_back(e * 10 + x + 1);
				L.push_back(e * 10 + x + 1);
			}
		}
	}

	sort(L.begin(), L.end());

	cout << L[K - 1] << endl;
}


Measured memory_bytes: 18996
#include<bits/stdc++.h>
using namespace std;
#define ll long  long int 

int main()
{   
  
    ll n;
    cin>>n;
    long double d=(double)(n*n*n)/27;
    string s=to_string(d);
    for(int i=0;i<6;i++)
    {
        s+='0';
    }
    cout<<s<<endl;


    return 0;
}

Measured memory_bytes: 3696
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
immutable string YES = "Yes";
immutable string NO = "No";
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long D;
    D = input.front.to!long;
    input.popFront;

    long T;
    T = input.front.to!long;
    input.popFront;

    long S;
    S = input.front.to!long;
    input.popFront;

    solve(D, T, S);
}

void solve(long D, long T, long S)
{
    writeln(D <= T * S ? YES : NO);
}


Measured memory_bytes: 3756