akhauriyash/Code-Regression huggingface dataset:
N,K = map(int,input().split())
X = list(map(int,input().split()))

ans = 10**20
for i in range(N-K+1):
    fst = i
    lst = i+K-1

    if X[lst]<=0:
        ans = min(ans,abs(X[fst]))
    elif X[fst]>=0:
        ans = min(ans,X[lst])
    else:
        dis = max(abs(X[fst]),X[lst])+min(abs(X[fst]),X[lst])*2
        ans = min(ans,dis)

print(ans)

Measured memory_bytes: 14380
#include <bits/stdc++.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++)
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;

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

    for (int i = 0; i < t.size(); i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 3632
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::vector<mint> ac(n+1,0);
	rep(i,n) {
		ac[i+1] = ac[i]+mint(i+1).inv();
	}
	debug(ac);
	mint ave = 0;
	rep(i,n) {
		debug(ac[i+1]+ac[n-1]-mint(1));
		ave+=mint(a[i])*(ac[i+1]+ac[n-i]-mint(1));
	}
	rep(i,n) ave*=mint(i+1);
	print(ave);
}


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

int main(){
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> s(100010,0);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        s[a] += b;
    }

    for (int i = 1; i < 100010;i++){
        if(s[i]>=K){
            cout << i;
            return 0;
        }
        K -= s[i];
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
#define f(i,s,e) for(i=s;i<e;++i)
#define fr(i,s,e) for(i=s;i>=e;i--)
#define ff(i,s,e,f) for(i=s;i<e && f;++i)
#define mem(arr,val) memset(arr, val, sizeof(arr))
#define mems(arr, val, n) memset(arr, val, n)
#define vec vector<int>
#define pr pair<int,int>
#define vp vector<trip>
#define _in(v) for(auto &x:v) cin>>x;
#define _out(v) for(auto x:v) cout<<x<<" "; cout<<endl;
#define lim 1000000
#define mod 1000000007
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define flush this_thread::sleep_for(chrono::seconds(0));
using namespace std;


signed main(void)
{
    Arena
    register int i,j,num,z,t=1;
    //cin>>t;
    f(z,1,t+1)
    {
        int n;cin>>n;
        int ans = ((n/500)*1000)+(((n%500)/5)*5);
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
  int a;
  string s;
  cin>>a>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}

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

int main(void){
  string str;
  cin >> str;

  for(int i=0; i<3; i++){
	if(str.at(i)==str.at(i+1)){
	  cout << "Bad" << endl;
      exit(0);
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

 long long modpow(long long n, long long k,long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     ll a,b,c,d;
     cin >> a >> b >> c >> d;
     ll ans = -LLONG_MAX;
     ans = max(a*c,ans);
     ans = max(a*d,ans);
     ans = max(b*c,ans);
     ans = max(b*d,ans);
     cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

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

int main()
{
    for (;;) 
    {
        int n,m =0;
        cin >> n >> m;
        if (n==0 &&m ==0) 
        {
            break;
        }
        int arr[n+m];
        for (int i = 0; i < n + m;  i++) 
        {
            cin >> arr[i];
        }

        int result_sum = 1000;
        int result_n=0;
        int result_m=0;
        for (int k = 0; k < n; k++) 
        {
            for (int l = n; l < m + n ; l++) 
            {
                int sum_n =0;
                int sum_m =0;
                int tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;

                //set sum_m sum_n
                for (int i = 0; i < n; i++) 
                {
                    sum_n += arr[i];
                }
                for (int i = n; i < n+m; i++) 
                {
                    sum_m += arr[i];
                }
                if (sum_m == sum_n) 
                {
                    if ( arr[k] + arr[l] < result_sum) 
                    {
                        result_sum = arr[k] + arr[l];
                        result_n = arr[k];
                        result_m = arr[l];
                    }
                }
                tmp = arr[l];
                arr[l] = arr[k];
                arr[k] = tmp;
                //tmp = arr[k];
                //arr[k] = arr[l];
                //arr[l] = tmp;
            }
        }
        if (result_m ==0 && result_n == 0) 
        {
            cout << -1<< endl;
        }else{
        cout << result_m << " " << result_n << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
#define int long long

signed main() {
    int n, m;
    cin >> n >> m;
    vector <int> dp(n, 0);
    int a, b;
    rep (i, m - 1) {
        if (i == 0) cin >> a >> b;
        else a = b, cin >> b;
        int from, to;
        if (a >= b) from = b, to = a;
        else        from = a, to = b;
        dp[from - 1] += 1;
        dp[to - 1]   -= 1;
    }

    rep (i, n - 1) dp[i + 1] += dp[i];

    long long ans = 0;
    rep (i, n - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        if (dp[i] == 0);
        else if (b * dp[i] + c > a * dp[i]) ans += a * dp[i];
        else ans += b * dp[i] + c;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>

int F[45] = {1, 1};

int fib_recurse(int n) {
    if (n < 2) {
        return 1;
    }
    return fib_recurse(n - 1) + fib_recurse(n - 2);
}

int fib_memo(int n) {
    if (n < 2) {
        return F[n] = 1;
    }
    if (F[n]) return F[n];
    return F[n] = fib_memo(n - 1) + fib_memo(n - 2);
}

int fib_dp(int n) {
    if(n < 2) {
        return F[n];
    }
    for (int i = 2; i <= n; i++) {
        F[n] = F[i - 1] + F[i - 2];
    }
}

int main() {
    int n;
    std::cin >> n;
    std::cout << fib_memo(n) << std::endl;
    return 0;
}


Measured memory_bytes: 3136
N,M,P = map(int, input().split())
E = [[] for _ in range(N)]
E2 = [[] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int, input().split())
    E[a-1].append((b-1, -c+P))
    E2[b-1].append(a-1)

used1 = [0]*N
used1[0] = 1
from collections import deque
q = deque()
q.append(0)
while q:
    u = q.pop()
    for e in E[u]:
        if used1[e[0]] == 1:
            continue
        used1[e[0]] = 1
        q.append(e[0])

used2 = [0]*N
used2[N-1] = 1
q.append(N-1)
while q:
    u = q.pop()
    for e in E2[u]:
        if used2[e] == 1:
            continue
        used2[e] = 1
        q.append(e)

L = [0]*N
for i in range(N):
    L[i] = used1[i] & used2[i]
        
def BellmanFord(E, N, source):
    inf = 10**12
    d = [inf for _ in range(N)]
    d[source] = 0
    
    for i in range(N):
        for j in range(N):
            for edge in E[j]:
                if d[edge[0]] > d[j] + edge[1]:
                    d[edge[0]] = d[j] + edge[1]
                    if i == N-1 and L[edge[0]]== 1:
                        return -1
    
    return d

d = BellmanFord(E, N, 0)
if d == -1:
    print(-1)
else:
    print(max(0, -d[-1]))

Measured memory_bytes: 53100
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

int main(void){
    int r;
    cin >> r;
    cout << 2*r*M_PI << endl;
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll x[n],y[n],h[n];
    for(int i = 0; i < n; i++){
        ll temp1,temp2,temp3;
        cin >> temp1 >> temp2 >> temp3;
        x[i] = temp1;
        y[i] = temp2;
        h[i] = temp3;
    }
    ll cx,cy,hh;
    bool hoge = false;
    ll ansx,ansy,ansh;
    for(int i = h[0]; i < h[0]+401; i++){
        for(int j = 0; j < 101; j++){
            for(int k = 0; k < 101; k++){
                bool ok = true;
              cx = j;
              cy = k;
              hh = i;
                for(int l = 0; l < n; l++){
                    ll height = max(0,(int)(hh-(int)abs(cx-x[l])-(int)abs(cy-y[l])));
                    if(height != h[l]) ok = false;
                  //break;
                }
                if(ok){
                    ansx = j;
                    ansy = k;
                    ansh = i;
                    //break;
                }
            }
        }
    }
    cout << ansx << " " << ansy << " " << ansh;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax];
int dist[nax];
bool visited[nax];

void dfs(int a){
	visited[a] = true;
	for(int b : edges[a]){
		dist[b] = max(dist[b], dist[a] + 1);
		--in_degree[b];
		if(in_degree[b] == 0){
			dfs(b);
		}
	}
}
void max_self(int &a, int b){
	a = max(a,b);
	}

int main(){
int n,e;
scanf("%d%d",&n,&e);
for(int i = 0; i < e; ++i){
	int a,b;
	scanf("%d%d",&a,&b);
	edges[a].push_back(b);
	++in_degree[b];
	}
for(int i = 1; i <=n ; ++i){
	if(!visited[i] && in_degree[i] == 0){
		dfs(i);
		}
}

int answer = 0;
for(int i = 1; i <= n ; ++i){
	max_self(answer,dist[i]);
	}
printf("%d\n",answer);
}

Measured memory_bytes: 9728
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
	bool ok = false;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '7') {
			ok = true;
		}
	}
	if (ok) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
int a,b,l;
string s; 
int main()
{
    cin>>a>>b>>s;
    l=s.size();
    if(s[a]!='-'){
        cout<<"No";
        return 0;
    }
    for(int i=0;i<l;i++)
    {
        if(s[i]>='0'&&s[i]<='9'||i==a);
        else
        {
            cout<<"No ";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
   ll n;
   cin>>n;
   ll ans=1;
   vcl a(n);
   rep(i,n) {
       cin>>a[i];
       if(ans>0){
       if(log10(a[i])+log10(ans)>18){
           ans=-1;
       }
       else {
           ans*=a[i];
       }}
       else {if(a[i]==0 || ans==0){
           ans=0;
       }
       }
       }
       if(ans>1000000000000000000){
           cout<<-1<<endl;
       }
  else{ cout<<ans<<endl;}

}

Measured memory_bytes: 4056
#include <iostream>
#include <math.h>
using namespace std;

int main(void)
{
	int n, f;
	double xa, xb, ya, yb, ra, rb;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		double distance;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		if (ra > rb)
		{
			distance = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
			if (distance < (ra - rb)) f = 2;
			else if (distance >= (ra - rb) && distance <= (ra + rb)) f = 1;
			else f = 0;
		}
		else
		{
			distance = sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
			if (distance < (rb - ra)) f = -2;
			else if (distance >= (rb - ra) && distance <= (rb + ra)) f = 1;
			else f = 0;
		}
		cout << f << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N;  cin>>N;
  vector<int> v(N);
  rep(i,0,N) cin>>v[i];
  int res=v[0];
  rep(i,1,N){
    res ^= v[i];
  }
  rep(i,0,N){
    cout<<(res^v[i])<<" ";
  }
  return 0;
}


Measured memory_bytes: 4024
import heapq

H, W = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())

ch -= 1; cw -= 1; dh -= 1; dw -= 1; 

s = []
for _ in range(H):
    s.append(list(input()))
cs = [[1000000 for _ in range(W)] for _ in range(H)]

q = []
heapq.heappush(q, (0, (ch, cw)))

while q:
    c, (h, w) = heapq.heappop(q)
    if cs[h][w] < c:
        continue
    cs[h][w] = c
    for nh, nw in [(h - 1, w), (h + 1, w), (h, w - 1), (h, w + 1)]:
        if 0 <= nh < H and 0 <= nw < W and s[nh][nw] == '.' and c < cs[nh][nw]:
            cs[nh][nw] = c
            heapq.heappush(q, (c, (nh, nw)))
    for nh in range(h - 2, h + 3):
        for nw in range(w - 2, w + 3):
            if 0 <= nh < H and 0 <= nw < W and s[nh][nw] == '.' and c + 1 < cs[nh][nw]:
                cs[nh][nw] = c + 1
                heapq.heappush(q, (c + 1, (nh, nw)))

print(-1 if cs[dh][dw] == 1000000 else cs[dh][dw])


Measured memory_bytes: 153184
N,M=[int(x) for x in input().split()]
An=[input() for _ in range(N)]
Bn=[input() for _ in range(M)]
ans='No'
for i in range(N-M+1):
  for c in range(N-M+1):
    for r in range(M):
      if An[i+r][c:c+M]!=Bn[r]:
        break
    else:
      ans='Yes'
    if ans=='Yes':
      break
  if ans=='Yes':
    break
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <deque>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b) cout<<c<<endl;
  else if(a==c) cout<<b<<endl;
  else cout<<a<<endl;
  return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u32>();
    let (a, b, c, d) = (line[0], line[1], line[2], line[3]);

    if a+b < c+d{
        println!("Right");
    }else if a+b >c+d{
        println!("Left");
    }else{
        println!("Balanced");
    }
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);


// ABC047B - すぬけ君の塗り絵 2 イージー
int main(){
  int W, H, N;
  cin >> W >> H >> N;

  VECTOR_DIM2(bool, data, H, W, true);
  rep(i, N) {
    int xi, yi, ai;
    cin >> xi >> yi >> ai;
    switch (ai) {
      case 1:
        // black < xi
        rep(y,H){
          rep(x,W){
            if (x < xi) {
              data[y][x]=false;
            }
          }
        }
        break;
      case 2:
        // black > xi
        rep(y,H){
          rep(x,W){
            if (x >= xi) {
              data[y][x]=false;
            }
          }
        }
        break;
      case 3:
        // black < yi
        rep(y,H) {
          if (y < yi) {
            rep(x,W){
              data[y][x]=false;
            }
          }
        }
        break;
      case 4:
        // black > yi
        rep(y,H) {
          if (y >= yi) {
            rep(x,W){
              data[y][x]=false;
            }
          }
        }
        break;
    }
  }
  int count=0;
  rep(i,H){
    rep(j,W){
      if (data[i][j]) {
        ++count;
      }
    }
  }
  cout << count << endl;


  return 0;
}


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

#define rep(i, n) for (ll i = 1; i < (ll)(n); i++)
#define ll long long
using namespace std;

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

int main() {
  int k;
  cin >> k;
  int count = 0;
  rep(l, k + 1) {
    rep(m, k + 1) {
      rep(n, k + 1) {
        count += gcd(gcd(n, m), l);
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3636
// Comment
// simple

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

string S; int K, N;
int main() {
	cin >> S >> K;
	N = SZ(S);

	vector<string> list;
	for(int i=0; i<K; i++) {
		string test = "z";
		test[0] += (i+1);
		list.push_back(test);
	}
	for(int i=1; i<=N; i++) {
		for(int j=i; j<=min(N, i+4); j++) {
			list.push_back(S.substr(i-1, j-i+1));
			sort(ALL(list));
			list.erase(unique(ALL(list)), list.end());
			list.resize(K);
		}
	}
	printf("%s\n", list.back().c_str());
	return 0;
}


Measured memory_bytes: 3652
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    L = []
    [L.append(list(map(int,input().split()))) for i in range(N)]
    L.sort(key=lambda x:x[0])
    
    drink = 0
    sougaku = 0
    
    #愚直に回す
    for i in range(N):
        nedan, kazu = L[i]
        for j in range(kazu):
            if drink == M:
                break
            else:
                drink = drink + 1
                sougaku = sougaku + nedan
    
    print(sougaku)
   
if __name__ == '__main__':
    main()

Measured memory_bytes: 29512
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = [input() for i in range(3)]


    i = [0]*3
    map = {}
    map['a'] = 0
    map['b'] = 1
    map['c'] = 2
    cur = 0

    while i[0]<=len(s[0]) and i[1]<=len(s[1]) and i[2]<=len(s[2]):
        
        ncur = map[s[cur][i[cur]]]
        i[cur] += 1
        cur = ncur
        if i[0] == len(s[0]) and cur == 0:
            print('A')
            return
        elif i[1] == len(s[1]) and  cur == 1:
            print('B')
            return
        elif i[2] == len(s[2]) and cur == 2:
            print('C')
            return
        

solve()


Measured memory_bytes: 3064
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

ll n,a[200005],i,j,k,l,c[4]={0};
ld dp[400][400][400]={0};

int main()
{
    cin>>n;
    rep(i,0,n-1)cin>>a[i],c[a[i]]++;
    dp[0][0][0]=0;
    for(k=0;k<=n;k++)
    {
        for(j=0;j<=n;j++)
        {
            for(i=0;i<=n;i++)
            {
                if(i==0 && j==0 && k==0)continue;
                dp[i][j][k]=1;
                if(i>0) dp[i][j][k]+=ld(i)*dp[i-1][j][k]/ld(n);
                if(j>0) dp[i][j][k]+=ld(j)*dp[i+1][j-1][k]/ld(n);
                if(k>0) dp[i][j][k]+=ld(k)*dp[i][j+1][k-1]/ld(n);
                dp[i][j][k]*=(ld(n)/ld(i+j+k));
            }
        }
    }cout<<setprecision(15)<<dp[c[1]][c[2]][c[3]];
    return 0;
}


Measured memory_bytes: 755840
#include<bits/stdc++.h>
using namespace std;
int countAB(string s)
{
    int cnt = 0;
    size_t pos = 0;
    while(pos != string::npos)
    {
        pos = s.find("AB",pos);
        if(pos != string::npos)
            cnt++,pos++;
    }
    return cnt;
}
int main()
{
    int n;
    cin>>n;
    int ans = 0;
    int prefix=0,suffix=0,both=0;
    for(int i=0;i<n;++i)
    {
        string s;
        cin>>s;
        ans+=countAB(s);
        if(s[s.size()-1]== 'A' && s[0] == 'B')
            both++;
        else if(s[0]=='B')
            prefix++;
        else if(s[s.size()-1] == 'A')
            suffix++;
    }
    int turn = 0;
    while(true)
    {
        if(turn == 0)
        {
            if(suffix)
            {
                turn = 1;
                suffix--;
            }else if(both)
            {
                turn = 1;
                both--;
            }else
            {
                break;
            }
        }else if(turn == 1)
        {
            if(both)
            {
                ans++;
                turn = 1;
                both--;
            }else if(prefix)
            {
                ans++;
                turn = 0;
                prefix--;
            }else
            {
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> p(M);
    vector<vector<int> > s(M);
    REP(i, M)
    {
        int k;
        cin >> k;
        s.at(i).resize(k);
        REP(j, k)
        {
            cin >> s.at(i).at(j);
        }
    }
    REP(i, M) {
        cin >> p.at(i);
    }

    int cnt = 0;
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        bool flag = true;
        REP(i, M) {
            int sum = 0;
            for(int j = 0; j < s.at(i).size(); j++){
                if(bit & (1<<s.at(i).at(j)-1)) {
                    sum++;
                }
            }
            if(sum%2 != p.at(i)) {
                flag = false;
            }
        }

        if(flag) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
x = raw_input()
w,h = [int(i) for i in x.split()]
p = []
for i in range(w):
    p.append(input())
q = []
for i in range(h):
    q.append(input())
cost = 0
p.sort()
q.sort()
iter = w+h

p_iter = 0
q_iter = 0
for i in range(iter):
    if(w==0):
        cost += q[q_iter]*(w+1)
        h -= 0
        q_iter += 1

    elif(h==0):
        cost += p[p_iter]*(h+1)
        w -= 0
        p_iter += 1

    elif(p[p_iter]==q[q_iter] and h>w):
        cost += p[p_iter]*(h+1)
        w -= 1
        p_iter += 1

    elif(p[p_iter]<q[q_iter]):
        cost += p[p_iter]*(h+1)
        w -= 1
        p_iter += 1
    
    else:
        cost += q[q_iter]*(w+1)
        h -= 1
        q_iter += 1
    
print cost

Measured memory_bytes: 15340
#include <iostream>
#include <cstdio>
using namespace std;

int n,p,a;
long long J=0,O=1;

int main()
{
	//freopen("In.txt","r",stdin);
	scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a&1)
		{
			O=J+O;
			J=O;
		}
		else
		{
			J=J<<1;
			O=O<<1;
		}
	}
	if(p)cout<<J;
	else cout<<O;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
# 約数は、常にペアになる。


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


org = make_divisors(n)
div = sorted(org)

divNum = len(div)


if (divNum % 2 == 0):
    indA = int(divNum / 2) - 1
    indB = int(divNum / 2)
else:
    indA = int((divNum - 1) / 2)
    indB = indA

# print(div[indA])

A = len(str(div[indA]))
B = len(str(div[indB]))

ans = max(A, B)
print(ans)


Measured memory_bytes: 3064
import math

# エラストテネスの篩
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0

    while True:
        prime = min(A)

        if prime > math.sqrt(limit):
            break

        P.append(prime)

        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1

    for a in A:
        P.append(a)

    return P

def main():
  X = int(input())

  # ルジャンドル予想(未証明だが、、)
  # -> n^2 と (n+1)^2 の間に必ず素数が存在する
  # 10^(5/2) = 316.2277...
  # 317^2 = 100489
  P = eratosthenes(10**5+489)

  i = 0
  while True:
      if P[i] >= X:
          break
      i += 1

  print(P[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 7192
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int max_el = -1;
	int sec_max = -1;
	int max_pos = -1;
	for(int i = 0 ; i < n ; i++)
	{
		int a;
		cin>>a;
		if(a > max_el)
		{
			sec_max = max_el;
			max_el = a;
			max_pos = i;
		}
		else if(a > sec_max)
		 sec_max = a;
	}
	for(int i = 0; i < n; i++)
	{
		if(i!=max_pos)
			cout<<max_el<<endl;
		else
			cout<<sec_max<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
//Code by : Abhishek Tiwari
//codechef.com/users/devil_within || hackerearth.com/@devil_within
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int 
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repr(i,a,b) for(int i=(a);i>(b);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pii pair<int,int> 
#define ff first
#define ss second 
#define mod 1000000007
#define inf 1000000000
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
using namespace std;

/*******************************************************************************************/
/*******************************************************************************************/
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { 
    os<<"["; for(int i=0;i<v.size()-1; ++i)os<<v[i]<<", ";os<<v[v.size()-1]<<"]\n"; return os; 
} 
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { 
    os<<"{"; for(auto it : v) { os<<it; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) { 
    os<<"{"; for(auto it:v){ os<<"("<<it.first<<" : "<<it.second<<")"; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) { 
    os<<"("; os<<v.first<<", "<< v.second<<")"; 
    return os; 
} 
template<typename T> T maxi(T a,T b){return a>b ? a:b;}
template<typename T> T mini(T a,T b){return a<b ? a:b;}
/*******************************************************************************************/
/*******************************************************************************************/
int fpow(int x, int y, int p); 


int32_t main()  
{
#ifndef ONLINE_JUDGE
//freopen("input.txt" , "r" , stdin);freopen("output.txt" , "w" , stdout);freopen("error.txt" , "w" , stderr);
#endif
fio;
int tcases = 1;
//cin>>tcases;
for(int tcase = 1 ; tcase <= tcases ; ++tcase)
{
    int n;
    cin>>n;
    vector<double> dp(n+1 , 0);
    dp[0] = 1;
    rep( i, 0 , n)
    {
        double phead;
        cin>>phead;
        for(int j = i+1 ; j>=0 ; --j)
        {
            dp[j] = (j==0 ? 0 : dp[j-1]*phead) + dp[j]*(1 - phead);
        }
    }
    double ans  = 0;
    rep(i , 1 , n+1)
    {
        int tails = n - i;
        if(i > tails)
        ans+= dp[i];
    }
    cout<<fixed<<setprecision(10)<<ans;
        
    //cout<<"Case #"<<tcase<<": ";
}
return 0;
}



//Functions 

int fpow(int x, int y, int p) { 
    int res = 1; 
   x = x % p;  
   while (y > 0) { 
     if (y & 1) 
        res = (res * x) % p; 
     y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class UnionFind
{
public:
    vector<s64> p;

    UnionFind() {}
    UnionFind(s64 size)
    : p(vector<s64>(size, -1))
    {}

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

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

        if (p[x] > p[y]) swap(x, y);
        p[x] += p[y];
        p[y] = x;
    }

    s64 size(int x)
    {
        return -p[findSet(x)];
    }

    s64 findSet(int x)
    {
        if (p[x] < 0) return x;
        else p[x] = findSet(p[x]);
        return p[x];
    }
};

vector< pair<int, int> > bridge;

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

    s64 N, M;
    cin >> N >> M;

    bridge.resize(M);
    UnionFind uf(N);

    int u, v;
    rep (i, M)
    {
        cin >> u >> v;
        bridge[i] = make_pair(u - 1, v - 1);
    }

    vs64 ans(M, 0);
    ans[M - 1] = N * (N - 1) / 2;
    for (int i = M - 1; i >= 1;  --i)
    {
        int A = bridge[i].first, B = bridge[i].second;
        if (!uf.same(A, B))
        {
            ans[i - 1] = ans[i] - uf.size(A) * uf.size(B);
            uf.unite(A, B);
        }
        else
        {
            ans[i - 1] = ans[i];
        }
    }

    rep (i, M)
    {
        cout << ans[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}



int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	rep(i, n - 1) {
		if (a[i + 1] < a[i]) {
			ans += a[i] - a[i + 1];
			a[i + 1] = a[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define rep(i,n) for (i=1;i<=(n);++i)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
int mod = 1e9 + 7;
int main()
{
	int n, p[100], i, w=0,j;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> p[i];
		if (p[i] != i) w++;
	}
	if ((w == 2) || (w == 0)) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var a = long.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();

            var result = 0;

            for (var i = 0; i < a; i += 2)
            {
                if (list[i] % 2 == 1)
                {
                    result++;
                }
            }


            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27948
import heapq
N,M = map(int,input().split())

A = list(map(int,input().split()))
H = []
for i in A:
  heapq.heappush(H, -int(i))
for i in range(M):
  a = heapq.heappop(H)
  heapq.heappush(H, -(-a//2))
print(-sum(H))

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
vi order;
bool cmp(int a, int b) {
	return order[a] < order[b];
}
int dfs(int u, vi& trap, vi& a, vi& vis, int* cyc) {
	vis[u]=1;
	if(!vis[a[u]]) {
		dfs(a[u], trap, a, vis, cyc);
	} else if(vis[u]==1 && vis[a[u]]==1) {
		*cyc=u;
	}
	vis[u]=2;
}
int32_t main(void)
{
	IOS;
	string s1, s2;
	cin>>s1>>s2;
	int n = s1.length();
	int cnt=0;
	for(int i = 0; i < n; i++) {
		if(s1[i]==s2[i]) cnt++;
	}
	cout<<cnt<<endl;
	time();
	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 rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  ll ans = 0;
  rep(i,n-1){
    ans += a[(i+1)/2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4808
f::String->String->Int->Int
f _ [] ans=ans
f [] (x:xs) ans=f (x:[]) xs ans
f (x:xs) (y:ys) ans
      |x=='0' && y=='1'=f xs ys (ans+2)
      |x=='1' && y=='0'=f xs ys (ans+2)
      |otherwise=f (y:x:xs) ys ans

main = do
       xs<-getLine
       putStrLn $ show $ f [] xs 0

Measured memory_bytes: 7548
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    double ans = (double)w*h/2;
    cout << ans << " ";
    if(x*2==w&&y*2==h)cout << 1 << endl;
    else cout << 0 << endl;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll z = *x;
  *x = *y;
  *y = z;
}
void print(vector<ll> vec){
  ll length = (ll)vec.size();
  rep(i,length){
    if(i != 0){cout << " ";}
    cout << vec[i];
  }
  cout << endl;
}
int main() {
  ll x;
  cin >> x;
  double ans;
  if(x % 2 == 0){
    ans = 0.5;
  }else{
    ans = ((double) (x/2)+1) / x;
  }
  printf("%.10f",ans);
}

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

vector<LL> vec;
int k;
void solve();
inline void search(LL preEle, int cntOfDigit);
void loop();
int main() {
    //freopen("test.out", "w", stdout);
    solve();
    return 0;
}

void loop() {
    for (int i = 1; i <= 9; i++) search(i, 2);
}
void solve() {
    cin >> k;
    for (int i = 1; i <= 9; i++) vec.emplace_back(i);
    loop();
    sort(vec.begin(), vec.end());
    cout << vec[k - 1] << endl;
}
#ifndef online
inline void search(LL preEle, int cntOfDigit) {
    if (cntOfDigit >= 11) return;
    LL cur = preEle * 10;
    if (preEle % 10 != 0) vec.emplace_back( cur+ preEle % 10 - 1);
    vec.emplace_back(cur + preEle % 10);
    if (preEle % 10 != 9) vec.emplace_back(cur + preEle % 10 + 1);
    if (preEle % 10 != 0) search(cur + preEle % 10 - 1, cntOfDigit + 1);
    search(cur + preEle % 10, cntOfDigit + 1);
    if (preEle % 10 != 9) search(cur + preEle % 10 + 1, cntOfDigit + 1);
}
#endif

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T = ll> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

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

int main() {
    ll x=in();
    ll y=in();
    int ans=0;
    while(y>=x){y/=2;ans++;}
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve() {
    string s;
    cin >> s;
    string a;
    for (int q = 0; q < 10; ++q) {
        a += "hi";
        if (a == s) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef tuple<int, int, int> TP;

int main() {
  int L; cin >> L;
  int k = 1, N = 0;
  while (k <= L) {
    k *= 2; ++N;
  }
  int r = N - 1;
  int kr = k/2;

  vector<TP> es;
  k = 1;
  for (int i = 1; i < N; ++i) {
    es.push_back({i, i + 1, 0});
    es.push_back({i, i + 1, k});
    k *= 2;
  }

  k /= 2;
  for (int i = N - 1; i > 0; --i) {
    if (L - k >= kr) {
      es.push_back({i, N, L - k});
      L -= k;
    }
    k /= 2;
  }

  cout  << N << " " << es.size() << endl;
  for (auto [u, v, w] : es) {
    cout << u << " " << v << " " << w << endl;
  }
}


Measured memory_bytes: 3632