akhauriyash/Code-Regression huggingface dataset:
require "set"
n = gets.chomp.to_i

@tree = Hash.new(){|h,k| h[k] = Hash.new}
(n-1).times do
  a,b,c = gets.chomp.split.map(&:to_i)
  @tree[a][b] = c
  @tree[b][a] = c
end

q, K = gets.chomp.split.map(&:to_i)

# K からの距離を格納
@distances = Array.new(n + 1)
@distances[K] = 0

visited = Set.new([K])
next_queue = [[K, 0]]

until next_queue.empty? do
  now_node, now_dis = next_queue.pop
  @tree[now_node].each do |node, dis|
    next if visited.include? node
    @distances[node] = now_dis + dis
    visited.add node
    next_queue.push [node, @distances[node]]
  end
end

def cal_dis(s, e)
  @distances[s] + @distances[e]
end

q.times do
  puts cal_dis(*gets.chomp.split.map(&:to_i))
end


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

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

    int n_sum=0;
    while(n/10){
        n_sum+=n%10;
        n/=10;
    }
    n_sum+=n;

    if(n_sum==1)cout<<10<<endl;
    else cout<<n_sum<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using ll = long long;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) ll v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
const int MOD = 1000000007;
const int INF = 1000000000;

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

  int ans = 0;
  for (auto it = s.begin(); it < s.end(); ++it) {
    char c = *it;
    while (*it == c) ++it;
    --it;
    ++ans;
  }
  OUT(ans-1);

  return 0;
}


Measured memory_bytes: 512
lst=[]
lst2=[]
for i in range(4):
    a = int(input())
    lst.append(a)
lst.remove(min(lst))
for i in range(2):
    b = int(input())
    lst2.append(b)
lst2.remove(min(lst2))
lst.append(lst2[0])
print(sum(lst))


Measured memory_bytes: 5596
s = str(input())
t = str(input())

sr = s[::-1]
tr = t[::-1]

for i in range(len(sr)-len(tr)+1):
    srp = sr[i:i+len(tr)]
    for j in range(len(srp)):
        if srp[j] != '?' and srp[j] != tr[j]:
            break
    else:
        ans = sr.replace('?', 'a')
        ans = ans[0:i] + tr + ans[i+len(tr):]
        print(ans[::-1])
        exit()
else:
    print('UNRESTORABLE')

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

using namespace std;

int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		ans+=r-l+1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
const int N=500010;
int tt;
deque <int> Q;
map <int,int> w[N];
int head[N],to[N*3],nxt[N*3],s[N*3],dis[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void lnk(int x,int y,int z) {
    to[++tt]=y,nxt[tt]=head[x],s[tt]=z,head[x]=tt;
    to[++tt]=x,nxt[tt]=head[y],s[tt]=z,head[y]=tt;
}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1,cnt=n;i<=m;i++) {
	int x=gi(),y=gi(),z=gi(),&X=w[x][z],&Y=w[y][z];
	if(!X) X=++cnt;
	if(!Y) Y=++cnt;
	lnk(X,Y,0),lnk(X,x,1),lnk(Y,y,1);
    }
    memset(dis,-1,sizeof(dis));
    Q.push_back(1),dis[1]=0;
    while(!Q.empty()) {
	int x=Q.front();
	Q.pop_front();
	for(int i=head[x];i;i=nxt[i]) {
	    int y=to[i];
	    if(dis[y]==-1) {
		dis[y]=dis[x]+s[i];
		if(y==n) return cout<<dis[y]/2,0;
		if(s[i]) Q.push_back(y);
		else Q.push_front(y);
	    }
	}
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 64384
#include <iostream>
using namespace std;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c;
    cin >> k;
    int counter = 0;
    while(1){
        if(a >= b){
            b *= 2;
            counter ++;
        }
        if(b >= c){
            c *= 2;
            counter ++;
        }
        if(a < b && b < c){
            break;
        }
    }
    if(counter <= k){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    ll n; cin >> n;
    vector<ll> a(n + 1);
    rep(i, n + 1) cin >> a[i];

    if(n == 0){
        if(a[0] != 1){
            cout << -1 << endl;
        }else{
            cout << 1 << endl;
        }
        return 0;
    }else if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    vector<ll> a_sum(n + 2);
    a_sum[0] = 0;
    _rep(i, 1, n + 2){
        a_sum[i] = a_sum[i - 1] + a[i - 1];
    }
    ll ans = 1;
    ll b = 1;
    _rep(i, 1, n + 1){
        b = min(a_sum[n + 1] - a_sum[i], (b - a[i - 1]) * 2);
        ans += b;
        if((b <= 0 and i != n) or (b < 0)){
            cout << -1 << endl;
            return 0;
        }
    }
    if(ans < a_sum.back()){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  int sz = s.size();
  int cnt = 0;
  rep(i, n){
    if(s[i] == 'R') cnt++;
  }
  rep(i, cnt){
    if(s[i] == 'W') ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3748
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	
	string str;

	cin>>str;
	for(int i=0;i<str.size();i++){
		char x=str[i];
		if(i%2==1){

			if(x=='T')cout<<'a';
			if(x=='L')cout<<'i';
			if(x=='U'&&str[i-1]!='0')cout<<'u';
			if(x=='R')cout<<'e';
			if(x=='D')cout<<'o';
			
		}
		else if(i%2==0&&x!='0'){

			if(x=='2')cout<<'k';
			if(x=='3')cout<<'s';
			if(x=='4')cout<<'t';
			if(x=='5')cout<<'n';
			if(x=='6')cout<<'h';
			if(x=='7')cout<<'m';
			if(x=='8')cout<<'y';
			if(x=='9')cout<<'r';
		}
		else {

			if(str[i+1]!='U')cout<<'w';
			else cout<<"nn";
		}
	}
	cout<<endl;
	return 0;
}
	

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

const int N = 1e5 + 5;
string s;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>s;
    
    int slen = s.length();
    
    int ok = 1;
    for (int i = 0; i < slen-1; i++){
        if(s[i] == s[i+1]){
            ok = 0;
        }
    }
    
    if(ok){
        cout<<"Good"<<endl;
    }else{
        cout<<"Bad"<<endl;
    }
    
    
    return 0;
}



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

// B - Popular Vote
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);

    int total = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        total += A[i];
    }

    int count = 0;
    int min = (total + ((4.0 * M) - 1)) / (4.0 * M);
    // cout << min;
    for (int i = 0; i < N; i++) {
        if (A[i] >= min) {
            count++;
            if (count >= M) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int cnt[31];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin>>N>>M;
    int K[N];
    vector<int> A[N];
    rep(i,0,N){
        cin>>K[i];
        rep(j,0,K[i]){
            int a;
            cin>>a;
            A[i].pb(a);
            cnt[a]++;
        }
    }
    int ans=0;
    rep(i,1,M+1){
        if(cnt[i]==N) ans++;
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 256
n,m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        tnp = 0
        for k in range(m):
            for l in range(m):
                if (a[i+k][j+l]!=b[k][l]):
                    tnp += 1
        if (tnp==0):
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 9208
uses crt;
var n : int64;
s : string;
i,j : longint;
check : array[0..10] of boolean;
a : array[0..10] of extended;
b : array[0..10] of extended;
kq,cnt : extended;
function kc(i,j : integer) : extended;
begin
        if (i=0) or (j=0) then exit(0);
        exit(sqrt(sqr(a[i]-a[j]) + sqr(b[i]-b[j])));
end;

procedure process(m,k : integer);
var j : integer;
begin
        if (m=n+1) then begin cnt := cnt + kq;  exit; end;
        for j := 1 to n do
                if (check[j]=true) then begin
                        kq := kq + kc(j,k);
                        check[j]:=false;
                        process(m+1,j);
                        kq := kq - kc(j,k);
                        check[j]:=true;
                end;
end;

begin
        clrscr;
       { assign(input,'test.inp');reset(input);  }
        readln(n);
        for i := 1 to n do begin readln(a[i],b[i]); check[i]:=true; end;
     {   assign(output,'test.out');rewrite(output);
        clrscr;      } 
        process(1,0);
        kq := 1;
        for j := 1 to n do kq := kq * j;
        write(cnt/kq : 0 : 10);
        {  readln;
        close(output);}
end.



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	vector<ll>a(n+1);
	rep(i,n+1)cin>>a[i];
	ll nextmax=1;
	bool ok=true;
	ll ans=0;
	ll mmax=1e15;
	//cout<<mmax<<endl;
	vector<ll>nms(n+1,1);
	rep(i,n){
		if(nextmax>=a[i]){
			ans+=nextmax;
			nextmax-=a[i];
			if(nextmax<=mmax){
				nextmax*=2;
			}
			nms[i+1]=nextmax;
		}else{
			ok=false;
		}
	}
	if(ok){
		if(nextmax<a[n]){
			cout<<-1<<endl;
			return ;
		}
		else if(nextmax/2<=a[n]){
			ans+=a[n];
		}else{
			//a[n]<nextmax/2
			ll bef=0;
			rep(i,n+1){
				int ite=n-i;
				if(nms[ite]>=bef+a[ite]){
					nms[ite]=bef+a[ite];
				}
				bef=nms[ite];

			}
			ans=0;
			bool can=true;
			vector<ll>nonleaf(n+1);
			rep(i,n+1){
				nonleaf[i]=nms[i]-a[i];
			}
			rep(i,n+1){
				if(i){
					if(nms[i]>=nonleaf[i-1]&&
					nms[i]<=nonleaf[i-1]*2){

					}else{
						can=false;
					}
				}
			}
			if(!can){
				cout<<-1<<endl;
				return ;
			}else{
				rep(i,n+1){
					ans+=nms[i];
				}
			}
		}
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 5572
using System;

namespace abc157_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int sum = N / 2;
            int sumPlus = N % 2;

            if (sumPlus == 0)
            {
                Console.WriteLine(sum);
            }
            else
            {
                Console.WriteLine(sum+1);
            }
        }
    }
}


Measured memory_bytes: 27516
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
using namespace std;

int main(){
  string S ;
  int ans = 1;
  cin >> S ;
  if((S == "AAA") || (S == "BBB")) ans = 0 ;
  if(ans){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  
  return 0 ;
}

Measured memory_bytes: 256
#include<atcoder/all>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;
using namespace atcoder;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}

int mypow(int _x, int _n){ //(int _x, int _n, int_p)
    int ret = 1;
    while(0 < _n){
        if((_n % 2) == 0){
            _x *= _x;
            //(追加) _x %= _p;	
            _n >>= 1;
        }
        else{
            ret *= _x;
            //(追加) ret %= _p;
            --_n;
        }
    }
    return ret;
}

signed main(){
    int ans = INF;
    int n;
    cin >> n;
    vector<int> ret;
    n *= 2;
    int n3 = n;
    for(int i = 2; i * i <= n3; i++) {
        if(n % i == 0) {
            int now1 = 1;
            while(n%i==0){
                n/= i;
                now1 *= i;
            }
            ret.pb(now1);
        }
    }
    ret.pb(n);
    sort(begin(ret), end(ret));
    //REP(i,ret.size()){
        //cout << ret[i] << endl;
    //}

    REP(i,mypow(2,ret.size())){
        //dump(ans);
        int a1 = 1;
        int b1 = 1;
        REP(j,ret.size()){
            if(i & (1<<j)){
                a1 *= ret[j];
            }
            else{
                b1 *= ret[j];
            }
        }
        //dump(a1);
        //dump(b1);
        if(b1==1){
            ans = min(ans,a1-1);
        }
        else if(a1==1){
            ans = min(ans,b1);
        }
        else{
            if(a1>b1){
                int c1 = inv_mod(a1,b1);
                //dump(c1);
                ans = min(ans,a1*c1-1);
            }
            else{
                int c1 = inv_mod(a1,b1);
                //dump(c1);
                ans = min(ans,a1*c1-1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 1e5+10;

int N, U, V;
vi edge[MAX], children[MAX];
int parent[MAX];

void make_tree(int n, int p) {
    parent[n] = p;
    children[n] = vi();
    FORE (c, edge[n]) if (c != p) {
        children[n].push_back(c);
        make_tree(c, n);
    }
}

vi shortest_path(int s) {
    vi shortest;
    int path = s;
    while (path != V) {
        shortest.push_back(path);
        path = parent[path];
    }
    shortest.push_back(V);
    return shortest;
}

ll dnf(int n, int len, int ng) {
    if (children[n].size() == 0) return len;
    ll mx = 0;
    FORE (c, children[n]) if (c != ng) {
        mx = max(mx, dnf(c, len+1, ng));
    }
    return mx;
}

int solve() {
    if (edge[U].size() == 1 && edge[U][0] == V) return 0; // 一手目で終わる

    make_tree(V, -1);
    ll ans = 0;

    vi shortest = shortest_path(U);
    int idx = shortest.size()/2 - 1;
    ans = idx;
    if (shortest.size()&1) ans++;
    int u = shortest[idx], ng = shortest[idx+1];

    make_tree(u, -1);
    ans += dnf(u, 0, ng);
    return ans;
}

int main() {
    cin >> N >> U >> V;
    U--; V--;
    REP (i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    cout << solve() << endl;
}


Measured memory_bytes: 16896
s = input()
#s = "akasakaakasakasakaakas"
lens = len(s)
if len(s)%2 == 1:
    s = s[0:-1]
else:
    s = s[0:-2]
for i in range(lens):
    half = int(len(s)/2)
    if s[0:half] == s[half:half*2]:
        print(half*2)
        break
    else:
        s = s[0:-2]

Measured memory_bytes: 9012
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        mut h: [u64; n],
    }
    h.sort();
    let mut ans = std::u64::MAX;
    for i in 0..n - k + 1 {
        let tmp = &h[i..i + k];
        let diff = tmp.last().unwrap() - tmp.first().unwrap();
        if diff < ans {
            ans = diff
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	
	int l = 0, r = s.size() - 1, ans = 0;
	while(l < r) {
		if(s[l] != s[r]) {
			if(s[l] == 'x') {
				l++;
				ans++;
			} else if(s[r] == 'x') {
				r--;
				ans++;
			} else {
				cout << -1 << endl;
				return 0;
			}
		} else {
			l++;
			r--;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

ll a[5][100005];
ll dp[5][100005];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[0][i] >> a[1][i] >> a[2][i];
	for (int t = 0; t < 3; t++) dp[t][0] = a[t][0];
	for (int i = 1; i < n; i++) {
		for (int t = 0; t < 3; t++) {
			for (int j = 0; j < 3; j++) {
				if (t == j) continue;
				dp[t][i] = max(dp[t][i], dp[j][i - 1] + a[t][i]);
			}
		}
	}
	cout << max({ dp[0][n - 1], dp[1][n - 1], dp[2][n - 1] }) << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = atoi(s.substr(5, 2).c_str());
    if (n <= 4) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}

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

#define OPTIMIZE ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

vector<vector<pair<int64_t, int> > > g;
vector<int> vis;

bool comp(pair<int, int64_t> &p1, pair<int, int64_t> &p2) {
	return p1.second < p2.second;
}

class compq
{
public:
    bool operator()(pair<int64_t, int> &n1, pair<int64_t, int> &n2) {
        return n1.first > n2.first;
    }
};

priority_queue<pair<int64_t, int>, vector<pair<int64_t, int> >, compq> q; 

int getMSTWeight(int startNode) {
	for (int i = 0; i < g[startNode].size(); i++) {
		q.push(g[startNode][i]);
	}
	vis[startNode] = true;

	int64_t totalWeight = 0;

	while (!q.empty()) {
		while (vis[q.top().second] && !q.empty()) { 
			q.pop();
		}

		if (q.empty()) break;

		auto top = q.top();
		q.pop();
		totalWeight += top.first;
		vis[top.second] = true;
		//cout << "selected " << top.second + 1 << "; val: " << top.first << endl;

		for (int i = 0; i < g[top.second].size(); i++) {
			if (!vis[g[top.second][i].second]) {
				q.push(g[top.second][i]);
			}
		}
	}

	return totalWeight;
}

int main() {
	OPTIMIZE

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		g.push_back(vector<pair<int64_t, int> >());
		vis.push_back(false);
	}

	vector<pair<int, int64_t> > vx, vy;

	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		vx.push_back(make_pair(i, x));
		vy.push_back(make_pair(i, y));
	}

	sort(vx.begin(), vx.end(), comp);
	sort(vy.begin(), vy.end(), comp);

	for (int i = 1; i < vx.size(); i++) {
		g[vx[i].first].push_back(make_pair(vx[i].second - vx[i - 1].second, vx[i - 1].first));
		g[vx[i - 1].first].push_back(make_pair(vx[i].second - vx[i - 1].second, vx[i].first));
	}

	for (int i = 1; i < vy.size(); i++) {
		g[vy[i].first].push_back(make_pair(vy[i].second - vy[i - 1].second, vy[i - 1].first));
		g[vy[i - 1].first].push_back(make_pair(vy[i].second - vy[i - 1].second, vy[i].first));
	}

	cout << getMSTWeight(0);

	return 0;
}

Measured memory_bytes: 19984
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	string s;
	cin >> s;
	int j_s, j_e, o_s, o_e, i_s, i_e;
	int res = 0;
	o_s = 0;
	o_e = 0;
	while(o_e < s.size()){
		while(o_s < s.size() && s[o_s] != 'O') o_s++;
		o_e = o_s;
		while(o_e < s.size() && s[o_e] == 'O') o_e++;
		j_e = o_s-1;
		j_s = o_s-1;
		while(j_s >= 0 && s[j_s] == 'J') j_s--;
		i_s = o_e;
		i_e = o_e;
		while(i_e < s.size() && s[i_e] == 'I') i_e++;
		if(o_e - o_s <= min(j_e-j_s, i_e-i_s)) res = max(res, o_e-o_s);
		o_s = o_e;
	}
	cout << res << endl;	
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,X;
    cin >> N >> X;
    vector<int>size(N+1);
    vector<int>paty(N+1);
    size[0] = 1;
    paty[0] = 1;
    for(int i = 0; i < N; i++) {
        size[i+1] = size[i]*2+3;
    }
    for(int i = 0; i < N; i++) {
        paty[i+1] = paty[i]*2+1;
    }
    int ans = 0;
    while(X && N) {
        if(X <= 1+size[N-1]) {
            N--;
            X--;
        }
        else {
            ans+=paty[N-1]+1;
            X-=(2+size[N-1]);
            N--;
        }
    }
    if(X) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main()
{
	string s;
	cin >> s;
	rep(i, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	rep(i, s.size() - 2) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void inline swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void inline swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

class B {
	int h, w;
	vector<string> f;
public:
	B()
	{
		cin >> h >> w;
		f.resize(h);
		REP(i, h)
			cin >> f[i];
	}
	void solve()
	{

		REP(y, h)
		{
			REP(x, w)
			{
				if (f[y][x] == '.')
				{
					char cnt = '0';

					for (int dx = -1; dx <= 1; dx++)
						for (int dy = -1; dy <= 1; dy++)
						{
							if (y + dy >= 0 && y + dy < h && x + dx < w && x + dx >= 0)
								if (f[y + dy][x + dx] == '#')
									cnt++;
						}

					f[y][x] = cnt;
				}

			}
		}

		REP(y, h)
			cout << f[y] << endl;

	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>

using namespace std;

int main(void)
{
	string s;

	cin >> s;

	s[3] = '8';

	cout << s << '\n';
	return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL; // VL a(n);
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VL> VLL; // VII a(n,VI(m)) n * m
typedef pair<ll, ll> PL;
typedef map<ll, ll> MP; // MP a;
typedef vector<pair<ll, ll>> PS; // PS a(n);

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
  ll n,k,m,x=0,y=0,z = 0,h=0,w=0,ans=0,sum = 0, Max = -1, Min = 3e9+1;
  string t;
  bool ok=true; 
  cin >> n >> h;
  VL a(n),b(n);
  rep(i,n){
    cin >> a[i] >> b[i];
  }

  sort(ALL(a));
  sort(RALL(b));
  Max = a[n-1];


  rep(i,n){
    if(Max < b[i]){
      h -= b[i];
      ans++;
    }
    if(h<=0){
      pri(ans);
      return 0; 
    }
  }

  while(h>0){
    h -= Max; 
    ans++;
  } 
  pri(ans);
  return 0;
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,m,sum=0;
    cin>>n>>m;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(all(a),greater<ll>());
    cout<<(a[m-1]>=(double)sum/(4*m)?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ll((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
int main()
{
   ll n,k;
   cin>>n>>k;
   ll h[n+1];
   loop(i,1,n+1) cin>>h[i];
   vl dp(n+1, 1e9);
   dp[1]=0;
   loop(i,2,n+1)
   {
   	revloop(j,i-1,max((ll)1,i-k))
   	{
   		dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]));
	}
   }
   cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

struct Node{int parent,left,right;};
Node T[100001];
int D[100001],H[100001];
void setDepth(int u,int p)
{
	D[u] = p;
	if(T[u].right != -1)
	{
		setDepth(T[u].right,p+1);
	}
	if(T[u].left != -1)
	{
		setDepth(T[u].left,p+1);
	}
}

int setHeight(int u)
{
	int h1,h2;
	h1=h2=0;
	if(T[u].left!=-1)h1 = setHeight(T[u].left)+1;
	if(T[u].right!=-1)h2 = setHeight(T[u].right)+1;
	return H[u] = max(h1,h2);
}


int getSibling(int u)
{
	if(T[u].parent==-1)return -1;
	int p = T[u].parent;
	int l = T[p].left;
	int r = T[p].right;
	if(l==u&&r==-1)return -1;
	if(l==-1&&r==u)return -1;
	if(l==u)return r;
	return l;
}

void Preorder(int i)
{
	cout<<' '<<i;
	if(T[i].left!=-1)Preorder(T[i].left);
	if(T[i].right!=-1)Preorder(T[i].right);
}

void Inorder(int i)
{
	if(T[i].left!=-1)Inorder(T[i].left);
	cout<<' '<<i;
	if(T[i].right!=-1)Inorder(T[i].right);
}

void Postoder(int i)
{
	if(T[i].left!=-1)Postoder(T[i].left);
	if(T[i].right!=-1)Postoder(T[i].right);
	cout<<' '<<i;
	
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0;i<n;i++)
	{
		T[i].left=T[i].right=T[i].parent = -1;
	}
	for(int i = 0;i<n;i++)
	{
		int now;
		cin >> now;
		int l ,r;
		cin >> l >> r;
		T[now].left = l;
		T[now].right = r;
		if(l!=-1)T[l].parent = now;
		if(r!=-1)T[r].parent = now;
	}
	for(int i = 0;i<n;++i)
	{
		if(T[i].parent==-1)
		{
			cout<<"Preorder\n";
			Preorder(i);cout<<endl;
			cout<<"Inorder\n";
			Inorder(i);cout<<endl;
			cout<<"Postorder\n";
			Postoder(i);cout<<endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3100
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int N = 200005;


signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#define double long double
	int n;
	double v[100];
	cin >> n;
	for(int i = 1 ; i <= n ; i ++)
		cin >> v[i];
	sort(v + 1, v + n + 1);
	double cur = v[1];
	for(int i = 2 ; i <= n ; i ++)
		cur = (cur + v[i])/2;
	
	cout << setprecision(10) << cur;
		
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int A, B;
  cin >> A >> B;
  if(A <10 && B < 10){
    cout << A*B << endl;
  }else{
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
     
int main()
{char a[200000],b[200000];int i,c=0;
scanf("%s",a);
scanf("%s",b);
for(i=0;i<200000;i++){
    if(a[i]==0){break;}
    if(a[i]!=b[i]) {c++;}
    }
printf("%d",c);
return 0;
}

Measured memory_bytes: 2096
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	double a,s;
	int i;
	while (~scanf("%lf", &a)) {
		s = a;
		for (i = 0; i < 9; i++) {
			if (i % 2 == 0) a *= 2.0;
			else a /= 3.0;
			s += a;
		}
		printf("%lf\n", s);
	}
	return 0;
}

Measured memory_bytes: 648
#include <stdio.h>

#define N 3
#define MAX 15

typedef struct{
  int A[N][N];
}Pazzle;

Pazzle P;

int d_x[4]={0,1,0,-1},d_y[4]={1,0,-1,0};

void swap(int *A,int *B){
  int h;
  h=*A;
  *A=*B;
  *B=h;
}

int check(Pazzle P){
  int sum=0,i,j,h_y,h_x;

  for( i=0 ; i<N ; i++ ){
    for( j=0 ; j<N ; j++ ){
      if( P.A[i][j]==0 )
        continue;
      h_y=(P.A[i][j]-1)/N-i;
      h_x=(P.A[i][j]-1)%N-j;
      if( h_y<0 )
        sum-=h_y;
      else
        sum+=h_y;
      if( h_x<0 )
        sum-=h_x;
      else
        sum+=h_x;
    }
  }
  return sum;
}

int dfs(int x,int y,int max,int count,int m){
  int i,h,x_0,y_0,ans=-1;

  h=check(P);

  if( h==0 ) return count;
  if( count+h>max ) return -1; 
  for( i=0 ; i<4 ; i++ ){
    x_0=x+d_x[i];
    y_0=y+d_y[i];      
   
    if(( m!=-1&&i==(m+2)%4)||!(0<=x_0 && x_0<N && 0<=y_0 && y_0<N )) continue;  

    swap(&P.A[y][x],&P.A[y_0][x_0]);

    ans=dfs(x_0,y_0,max,count+1,i);

    if( ans!=-1 ) return ans;       

    swap(&P.A[y][x],&P.A[y_0][x_0]);

  }   
  return -1;
}

int main(void){
  Pazzle t_P;
  int  i,j,anser,x_0,y_0;

  for( i=0 ; i<N ; i++ ){
    if( i<N )break;
  }
  
  for( i=0 ; i<N ; i++ ){
    for( j=0 ; j<N ; j++ ){
      scanf("%d",&P.A[i][j]);
      if( P.A[i][j]==0 ){
	x_0=j;
	y_0=i;           
      }        
    }
  }

  t_P=P;

  for( i=1 ; i<46 ; i++ ){
    P=t_P;
    anser=dfs(x_0,y_0,i,0,-1);
    if(anser!=-1){
        printf("%d\n",anser); 
        break;
        }
  }
  return 0;
}








Measured memory_bytes: 2140
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B) {
        if (B != C) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if (B == C || A == C) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
vector <int> L[int(1e5 + 5)], P[int(1e5 + 5)];
bool L_v[int(1e5 + 5)], P_v[int(1e5 + 5)];

int main(){
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++){
    int K; scanf("%d", &K);
    for (int j = 0; j < K; j++){
      int l; scanf("%d", &l);
      L[l].push_back(i);
      P[i].push_back(l);
    }
  }

  queue <int> que; que.push(1);
  P_v[1] = true;
  while (!que.empty()){
    int Q = que.front(); que.pop();

    for (int i = 0; i < P[Q].size(); i++){
      int L_next = P[Q][i];
      if (L_v[L_next]) continue;
      L_v[L_next] = true;
      for (int j = 0; j < L[L_next].size(); j++){
        int P_next = L[L_next][j];
        if (P_v[P_next]) continue;
        P_v[P_next] = true;
        que.push(P_next);
      }
    }
  }

  for (int i = 1; i <= N; i++){
    if (!P_v[i]){
      NO(); return 0;
    }
  }
  YES();


  return 0;
}


Measured memory_bytes: 12224
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
$B = array_map('intval', explode(' ', trim(fgets(STDIN))));
$C = array_map('intval', explode(' ', trim(fgets(STDIN))));

sort($A);
sort($B);
sort($C);

$cnt = 0;
// 中段を固定して、上段と下段を二分探索する
for ($i = 0; $i < $n; ++$i) {
    $target_b = $B[$i];

    // A
    $l = 0;
    $r = $n;
    while ($r - $l >= 1) {
        $mid = floor(($r + $l) / 2);
        if ($A[$mid] >= $target_b) {
            $r = $mid;
        } else {
            $l = $mid + 1;
        }
    }
    // Aはl個選べる
    $al = $l;


    // C
    $l = 0;
    $r = $n;
    while ($r - $l >= 1) {
        $mid = floor(($r + $l) / 2);

        if ($C[$mid] > $target_b) {
            $r = $mid;
        } else {
            $l = $mid + 1;
        }
    }
    // Cはn - l個選べる
    $cl = (int) ($n - $l);

    $cnt = (int) ($cnt + (int) ($al * $cl));
    /* $cnt += (int) ($al * $cl); */
}

echo (int) $cnt, PHP_EOL;


Measured memory_bytes: 25148
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge():src(0),dst(0),weight(0){}
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void Dijkstra(const Graph &g, int s,
              vector<Weight> &dist, vector<ll> &cnt) {
    int n = (int)g.size();
    dist.assign(n, INF); dist[s] = 0;
    cnt.assign(n, 0); cnt[s] = 1;
    priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
    vector<bool> visit(n,false);
    for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
        Edge e = Q.top(); Q.pop();
        if (visit[e.dst]) continue;
        visit[e.dst] = true;
        for(Edge f: g[e.dst]) {
            if (dist[f.dst] > e.weight+f.weight) {
                dist[f.dst] = e.weight+f.weight;
                cnt[f.dst]=cnt[f.src];
                Q.push(Edge(f.src, f.dst, e.weight+f.weight));
            }else if(dist[f.dst] == e.weight+f.weight){
              cnt[f.dst]=(cnt[f.dst]+cnt[f.src])%MOD;
            }
        }
    }
}

int main() {
  int N,M;cin >> N >> M;
  int S,T;cin >> S >> T;S--;T--;
  Graph g(N);
  Edges E(M);
  repeat(i,M){
    int U,V;
    Weight D;
    cin >> U >> V >> D;
    U--;V--;
    E[i] = Edge(U,V,D);
    g[U].push_back({U,V,D});
    g[V].push_back({V,U,D});
  }
  vector<Weight> sdist,tdist;
  vll scnt,tcnt;
  Dijkstra(g,S,sdist,scnt);
  Dijkstra(g,T,tdist,tcnt);
  ll ans = scnt[T]*(scnt[T])%MOD;
  repeat(i,M){
    int u=E[i].src;
    int v=E[i].dst;
    if(sdist[u]>sdist[v]){
      swap(u,v);
    }
    if(sdist[u]+E[i].weight+tdist[v]!=sdist[T]) continue;
    if(2*sdist[u] >= sdist[T] || sdist[T] >= 2*sdist[v]) continue;
    ll tmp = scnt[u]*tcnt[v]%MOD;
    ll dupl = tmp*(tmp)%MOD;
    ans = (ans-dupl+MOD)%MOD;
  }
  repeat(i,N){
    if(sdist[i]+tdist[i] != sdist[T]) continue;
    if(sdist[i] != tdist[i]) continue;
    ll tmp = scnt[i]*tcnt[i]%MOD;
    ll dupl = tmp*(tmp)%MOD;
    ans = (ans-dupl+MOD)%MOD;
  }

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


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

int main()
{
    int N, K, doko;
    long long ans = 0;
    cin >> N >> K;
    vector<int> H(N),hissatsu(K);
    for(int i=0;i<N;i++)
    {
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    for(int i=0;i<N-K;i++)
    {
        ans += H.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4672
#include <bits/stdc++.h>
#define mem(s,t) memset(s,t,sizeof(s))
#define pb(s) push_back(s)
#define inf 0x3f3f3f3f
#define mn 100010
typedef long long ll;
using namespace std;

struct Node
{
    int l,r;
    ll c,w;
    bool operator <(const Node &x)const
    {
        if (x.w==w) return x.r>r;
        return x.w<w;
    };
}e[100010];

bool cmp(Node x,Node y)
{
    return x.l<y.l;
}

int n,m,last;
priority_queue<Node> q;

int main()
{
    int i,j,k;
    scanf("%d%d",&n,&m);
    for (i=1;i<=m;i++)
        scanf("%d%d%lld",&e[i].l,&e[i].r,&e[i].c);
    sort(e+1,e+m+1,cmp);
    while (!q.empty()) q.pop();
    Node p;
    p.l=1; p.r=1; p.w=0;
    q.push(p);
    last=0; j=1;
    while (!q.empty())
    {
        Node p=q.top();
       // cout<<p.l<<' '<<p.r<<' '<<p.w<<endl;
        q.pop();
        if (p.r<=last) continue;
        while (e[j].l<=p.r&&j<=m)
        {
            e[j].w=e[j].c+p.w;
            q.push(e[j]);
            j++;
        }
        last=p.r;
        if (last==n)
        {
            printf("%lld\n",p.w);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}



Measured memory_bytes: 7028
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			String str = sc.next();
			int sum = 0;
			if(str.equals("0")) {
				break;
			}
			
			for(int n = 0; n < str.length();n++) {
				sum += Integer.parseInt(str.substring(n, n+1));
			}
			System.out.println(sum);
		}
	}
}



Measured memory_bytes: 26772
a,b,c,x,y=gets.split.map(&:to_i)
if 2*c<a+b
  if x<y
    if b<c*2
      puts 2*x*c+b*(y-x)
    else
      puts 2*y*c
    end
  else
    if a<c*2
      puts 2*y*c+a*(x-y)
    else
      puts 2*x*c
    end
  end
else
  puts a*x+b*y
end


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

int main(){
    long long s;
    long long w=1e9;

    cin >> s;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << 0 << " "<< 0 << " ";
    cout << w << " "<< 1 << " ";
    if(s%w!=0)cout << (int)(w-(s%w)) << " "<< (int)((s/w)+1) << endl;
    else cout << 0 << " "<< (int)(s/w) << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from decimal import Decimal, ROUND_HALF_UP


def main():
    N,K = list(map(int, sys.stdin.readline().split()))
    A_list = list(map(int, sys.stdin.readline().split()))


    def check(length :int) -> bool:
        cnt = 0

        for a in A_list:
            if a >= length:
                quotient = a / length
                divide = -(-quotient // 1)  # round up
                cnt += (divide - 1)
        
        return (True if cnt <= K else False)


    L = 0            # the minimum length
    R = max(A_list)  # the maximum length

    while (R - L) > 1:
        M = L + (R - L) // 2

        if check(M):
            R = M
        else:
            L = M


    print(R)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32712
# C - Dice and Coin

N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
    if K <= i:
        ans += 1 / N
    else:
        coins = 0
        while i < K:
            i = i * 2
            coins += 1
        ans += (1 / N) * ((1 / 2) ** coins)

print(ans)


Measured memory_bytes: 2940