akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        if ( a.charAt(a.length() - 1) == b.charAt(0)
                && b.charAt(b.length() - 1) == c.charAt(0) ) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define y0    lol
#define y1    lool
#define yn    loool
#define prev  looool
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#ifdef LOCAL
#define rall(x,a) for(x : a)
#else
#define rall(x,a) for(auto x : a)
#endif
#define rng(a) a.begin(), a.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    int r;
    cin >> r;
    if(r < 1200) {
        cout << "ABC" << endl;
    } else if(r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int k;
	cin >> k;

	if (k % 2 == 0) {
		cout << "-1\n";
	} else {
		int s = 7;
		int ans = 1;
		while (ans <= k) {
			if (s % k == 0) {
				cout << ans << "\n";
				return 0;
			}

			s = (s % k) * 10 + 7;
			++ans;
		}

		cout << "-1\n";
	}

	return 0;

}

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

const int N = 101000;

int n, a[N], b[N], val[N << 2], s[N];
long long All;
vector<int> v;

void Add(int x) {
  for(; x <= 3 * n; x += -x & x)
    val[x]++;
}

int Query(int x) {
  int ans = 0;
  for(; x > 0; x -= -x & x)
    ans += val[x];
  return ans;
}

bool Check(int x) {
  for(int i = 1; i <= n; i++)
    b[i] = a[i] <= x;
  for(int i = 1; i <= 2 * n; i++)
    val[i] = 0;
  long long cnt = 0;
  for(int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + b[i];
    if(2 * s[i] - i > 0) cnt++;
    cnt += Query(2 * s[i] - i - 1 + n);
    Add(2 * s[i] - i + n);
  }
  //cerr << x << " " << cnt << endl;
  return cnt >= (All / 2 + 1);
}

int main(void) {
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  All = 1LL * n * (n + 1) / 2;
  int l = 0, r = v.size() - 1, ans;
  while(l <= r) {
    int mid = l + r >> 1;
    if(Check(v[mid])) ans = v[mid], r = mid - 1;
    else l = mid + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2808
def input_from_console():
    n, k = map(int, input().split())

    return n, k


def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)


def main():
    n, k = input_from_console()
    print(n-k+1)



if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
ll n,k;
cin>>n>>k;
if(n*500>=k)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int a, b;
    cin >> a >> b;
    if(a >=13) cout << b << endl;
    else if(a >= 6) cout << b/2 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,a[100005],x,y,dp[100005],r,v[100005],pos=1;

vector <int> g[100005];

void DFS(int nod, int p){
    if(g[nod].size()==1){
        dp[nod]=a[nod];
        return;
    }
    dp[nod]=2*a[nod];
    for(int i : g[nod]){
        if(i==p) continue;
        DFS(i,nod);
        dp[nod]-=dp[i];
        if(dp[i]>a[nod]) pos=0;
    }
    if(dp[nod]>a[nod]) pos=0;
}

int main() {
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<n;i++) cin >> x >> y,g[x].pb(y),g[y].pb(x);
    r=1;
    if(n==2){
        if(a[2]!=a[1]) cout << "NO";
        else cout << "YES";
        return 0;
    }
    while(g[r].size()==1) r++;
    DFS(r,-1);
    for(int i=1;i<=n;i++){
        if(dp[i]<0){
            cout << "NO";
            return 0;
        }
    }
    if(dp[r] || !pos)
        cout << "NO";
    else
        cout << "YES";

}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N;string S;cin>>N>>S;
  REP(i,0,S.size()){
    int ans =(S.at(i)-65+N)%26;
    cout<<char(ans+65);
  }
  cout<<"\n";
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=STR()
    ans=0
    for i in n:
        ans+=int(i)
    if ans%9==0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Measured memory_bytes: 9304
void main() {
	auto s = rs;
	auto p = rs;
	writeln((s ~ s).canFind(p) ? "Yes" : "No");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}



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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll out = max(max(a*c, b*d), max(a*d, b*c));
    cout << out << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 100001

using namespace std;

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

int main() {
    int N;
    bool same[MAX_N];
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        int p_i;
        cin >> p_i;
        same[i] = (p_i == i);
    }
    
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (same[i]) {
            ans++;
            same[i + 1] = false;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, D, A;
  cin >> N >> D >> A;
  D *= 2;
  vector<pair<long, long>> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i).first >> data.at(i).second;
    data.at(i).second = (data.at(i).second + A - 1) / A;
  }
  sort(data.begin(), data.end());
  long ma = 0, ans = 0, sum = 0, sub = 0;
  vector<long> X(N);
  for(long i = 0; i < N; i++){
    sum -= X.at(i);
    if(sum >= data.at(i).second)continue;
    sub = data.at(i).second - sum;
    ans += sub;
    sum = data.at(i).second;
    for(int j = ma; j < N; j++){
      if(data.at(i).first + D < data.at(j).first){
        X.at(j) += sub;
        ma = j;
        break;
      }
      if(j == N - 1)ma = j;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
/****************##################################*************************************************
*                #   Editor : Jewel Mahmud        #                                  *
*                #   CSE 13th, MBSTU              #                                  *
*                #   Date : 20-Jun-19             #                                  *
*****************##################################************************************************/

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define S string
#define D double


int main()
{
    LL n;
    while(cin>>n)
    {
        cout<<3*n*n<<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++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a,b,c=0,d=0,k=0,n,h,w,m,ans=0;
    string s,s2;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if (s=="Cloudy") cout << "Rainy" << endl;
    else if (s=="Rainy")cout << "Sunny" << endl;
    
    return 0;
}

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD   = 1e9 + 7;
const double PI = acos(-1.0);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int INF   = 1e18;

#define fastio            ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define f first
#define s second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define spc " "
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){

    int a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;

}

signed main(){
    fastio;

    solve();

    return 0;
}


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

int main()
{
    string s,a,b,c;
    cin>>s;
    c=s;
    int n=s.size();
    int p=(n-1)/2,q=(n+3)/2;
    reverse(c.begin(),c.end());
    if(c!=s)
        printf("No\n");
    else{
        a.assign(s,0,p);
        b.assign(s,q-1,n);
        string a1=a,b1=b;
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        if(a==a1&&b==b1)
            printf("Yes\n");
        else
            printf("No\n");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll h,w;
  cin >> h >> w;

  char e[h+2][w+2];
  for(ll i=0;i<h+2;i++){
    for(ll j=0;j<w+2;j++){
      if(i==0 || i==h+1 || j==0 || j==w+1)e[i][j]='.';
      else cin >> e[i][j];
    }
  }

  bool ok=1;
  for(ll i=1;i<h+1;i++){
    for(ll j=1;j<w+1;j++){
      if(e[i][j]=='.')continue;
      bool ok2=0;
      for(ll k=0;k<4;k++)if(e[i+dx[k]][j+dy[k]]=='#')ok2=1;
      if(!ok2)ok=0;
    }
  }

  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

string S, T, U;
int a,b,c;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
	cin >> S;
	if(S[0] == S[1] and S[2] == S[0]) {
		No
	}else {
		Yes
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n); i++)
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
bool a[1000000001]={};
int main(){
	int n;
	cin>>n;
	rep(i,n){ 
		int k;
		cin>>k;
		if(a[k]){ 
			cout<<"NO"<<endl;
			return 0;
		}
		else a[k]=true;
	}
		
	
	cout<<"YES"<<endl;
	return 0;
}


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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define eb emplace_back
#define pb push_back
#define lli long long int
#define modn 998244353
#define NL '\n'

using namespace std;

typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< bool > vb;
typedef vector< lli > vli;
typedef vector< vector< char > > vvc;
typedef vector< vector< int > > vvi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef pair< lli, int> pli;
typedef pair< lli, lli> pll;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	#ifdef LOCAL_TEST
		clock_t z = clock();
    	ifstream h("in");
	    ofstream g("out");
	#else
	    #define h cin
	    #define g cout
	#endif // LOCAL_TEST
	
	int n;
	h >> n;
	vi v(n);
	f(i, 0, n, 1)
		h >> v[i];
	int ans = 1, mn = v[0];
	f(i, 1, n, 1){
		if (v[i] <= mn){
			mn = v[i];
			ans++;
		}
	}
	g << ans;
		
	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif // LOCAL_TEST
}



Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ff first
#define ss second
#define rev(a) a.rbegin(),a.rend()
#define all(a) a.begin(),a.end()
#define pi pair<int,int>
#define vii vector<pi>
#define pb push_back
//#define size(a)  (int)(a.size())
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define debug(...) cerr<<" ["<<#__VA_ARGS__<<": "<<(__VA_ARGS__)<<"] ";
#define debugv(...) for(int i=0; i<size(__VA_ARGS__); i++) cerr<<" ["<<#__VA_ARGS__<<i<<": "<<(__VA_ARGS__)[i]<<"] ";
const int mod = 1e8;
const int inf = 1e9+5;
const int inf64 = 1e18+5;
//           -------"Where is your Pen and Paper?"-------
void solve(){
    int k;
    cin>>k;
    string s="ACL";
    while(k--){
        cout<<s;
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);  
    #endif
    */
    int test;
    //cin>>test;
    test=1;
    //int cse=1;
    while(test--){
         //cout<<"Case #"<<cse<<": ";
         solve();
         cout<<endl;
         //cse++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

const int NMAX = 1'000'000'000;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A == B && B == C) {
    cout << ((A % 2 == 1) ? 0 : -1) << endl;
    return 0;
  }

  int i = 0;
  while (true) {
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) break;

    i++;

    int aa = A / 2;
    int bb = B / 2;
    int cc = C / 2;

    A = bb + cc;
    B = cc + aa;
    C = aa + bb;
  }

  cout << i << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++){
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());

    int ans=1;
    int moti=0;
    for(int i=0; i<N; i++){
        if(i==0){
            moti = d.at(i);
            continue;
        }
        if(moti != d.at(i) ){
            moti = d.at(i);
            ans++;
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 3648
w,h,n = [int(x) for x in input().split()]
xy = []
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    xy.append(tmp)

r = w
u = h
l = 0
b = 0

for z in xy:
    if z[2] == 1:
        l = max(l, z[0])
    elif z[2] == 2:
        r = min(r, z[0])
    elif z[2] == 3:
        b = max(b, z[1])
    elif z[2] == 4:
        u = min(u, z[1])

if (r-l) < 0 and (u-b) < 0:
    print(0)
else:
    print(max((r-l)*(u-b), 0))

Measured memory_bytes: 3064
#include <stdio.h>

#define N 100

void dfs( int table[], int begin[], int end[], int pos, int n, int* count )
{
    int i;
    if ( begin[pos] != 0 )
        return;
  
    begin[pos] = ++(*count);
    for( i=0; i<n; ++i ) {
        if ( table[pos*N+i] == 1 ) {
            dfs( table, begin, end, i, n, count );
        }
    }
    end[pos] = ++(*count);
}

int main( void )
{
    int n, i, j, u, k, v;
    int cnt = 0;
    int table[N*N] = {0};
    int begin[N] = {0}, end[N] = {0};
    scanf( "%d", &n );

    for( i=0; i<n; ++i ) {
        scanf( "%d %d", &u, &k );
        for( j=0; j<k; ++j ) {
            scanf("%d", &v);
            table[((u-1)*N)+(v-1)] = 1;
        }
    }

    for( i=0; i<n; ++i )
        if ( begin[i] == 0 )
            dfs( table, begin, end, i, n, &cnt );

    for( i=0; i<n; ++i )
        printf("%d %d %d\n", i+1, begin[i], end[i]);

    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  scanf("%d", &n);

  vector<int> six;
  int i = 6;
  while (i <= n) {
    six.push_back(i);
    i *= 6;
  }

  vector<int> nine;
  i = 9;
  while (i <= n) {
    nine.push_back(i);
    i *= 9;
  }

  int dp[n + 1];
  dp[0] = 0;

  FOR (i, 1, n + 1) {
    dp[i] = dp[i - 1] + 1;
    REP (j, six.size()) {
      if (i >= six[j]) {
        dp[i] = min(dp[i], dp[i - six[j]] + 1);
      }
    }
    REP (j, nine.size()) {
      if (i >= nine[j]) {
        dp[i] = min(dp[i], dp[i - nine[j]] + 1);
      }
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
    int MIN(int a,int b){return a<b?a:b;}
    int main(){
      int n,i,a[100010],b[100010],f[100010]={};
      long long s=1,M=(1e9)+7;
      scanf("%d",&n);
      for(i=0;i<n;i++)scanf("%d",&a[i]);
      for(i=0;i<n;i++)scanf("%d",&b[i]);
      for(i=0;i<n;i++){
        if(i==0||a[i]-a[i-1]){
          f[i]=1;
          if(a[i]>b[i])s=0;
        }
        if(i==n-1||b[i]-b[i+1]){
          f[i]=1;
          if(b[i]>a[i])s=0;
        }    
      }
      if(a[n-1]-b[0])s=0;
      for(i=0;i<n;i++){
        if(f[i])continue;
        s=(s*MIN(a[i],b[i]))%M;
      }
      printf("%lld\n",s);
      return 0;
    }

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

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

    int ans = (n%2 == 0)?n:2*n;
    cout << ans << endl;
}


Measured memory_bytes: 256
def insertionSort(a, n, g)
    cnt=0
    for i in g..n-1 do
        v = a[i]
        j = i - g
        while j >= 0 && a[j] > v do
            a[j+g] = a[j]
            j = j - g
            cnt+=1
        end
        a[j+g] = v
    end
    return cnt
end
 
def shellSort(a,n,m,g)
    cnt = 0
    for i in 0..m-1 do
        cnt+=insertionSort(a, n, g[i])
    end
    return cnt
end
 
n=gets.to_i
a=Array.new
for i in 1..n do
  a.push(gets.to_i)
end
 
m = (Math.log10(2*n+1)/Math.log10(3)).floor
g = Array.new
for i in 1..m do
   g.push((3**i-1)/2)
end
g.reverse!
cnt=shellSort(a,n,m,g)
 
p m
printf("%s\n",g.join(" "))
p cnt
a.each{|v|
  p v
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */
int main(){
    string s, t; cin>>s>>t;
    int n=s.size();
    if(t.size()!=n+1){
        out("No"); return 0;
    }
    rep(i,n){
        if(s[i]!=t[i]){
            out("No"); return 0;
        }
    }
    out("Yes");
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}













int main()
{
    string s;
    int k;
    cin>>s>>k;
    map<string,int> mp;
    for(int len=1;len<=k&&len<=s.length();len++){
         for(int i=0;i<=s.length()-len;i++){
              string t=s.substr(i,len);
              //cout<<t<<"\n";
              mp[t]=1;
         }
    }
    map<string,int>::iterator itr;
    for(itr=mp.begin();itr!=mp.end()&&k>0;itr++){
         if(k==1){
              cout<<itr->fi;
              return 0;}
         else k--;
    }
    
}
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
  T r;
  while (a)
    r = b, b = a, a = r % a;
  return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n;
int x, y;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  string u;
  cin >> s >> t >> u;
  cout << (char)(s[0] - 32) << (char)(t[0] - 32) << (char)(u[0] - 32);
}


Measured memory_bytes: 3508
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

bool comp(int a, int b){
  if (a%10==0)
    return true;
  else if(a%10>b%10)
    return true;
  else return false;
}

int main () {
  VIN(a, 5);
  sort(ALL(a), comp);
  int sum=0;
  REP(i,a.size()){
    if(a[i]%10==0)sum+=a[i];
    else if(i<a.size()-1)
      sum+=((a[i]/10)+1)*10;
    else sum+=a[i];
  }
  cout<<sum;
		 
}


Measured memory_bytes: 256
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int x=0;
	int ans=0;
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			x++;
		}
		else {
			x--;
		}
		ans = max(ans,x);
	}
	cout<<ans<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

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

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

    long b[n + 1] = {};

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

    b[0] = 1;
    for (int i = 1; i <= n; i++) {
        if (b[i] == -1) {
            continue;
        }

        if (b[i - 1] != -1) {
            b[i] += b[i - 1];
        }

        if (i - 2 >= 0 && b[i - 2] != -1) {
            b[i] += b[i - 2];
        }

        b[i] %= 1000000007;
    }

    cout << b[n] << endl;

    return 0;
}


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

const int N = 200005;

vector<int> adj[N];
int n, m;
string s;
int cnt[N][2]; // 0=>A, 1=>B
bool vis[N];

void bfs() {
	queue<int> Q;
	for (int i = 0; i < n; i++) {
		if (cnt[i][0] == 0 || cnt[i][1] == 0) {
			Q.push(i); // invalid nodes
			vis[i] = 1;
		}
	}
	while (!Q.empty()) {
		int cur = Q.front(); // this node will be removed
		Q.pop();
//		for (int i  = 0; i < adj[cur].size(); i++) {
//			int to = adj[cur][i];
//		}
		for (auto to : adj[cur]) {
			if (vis[to])
				continue;
			int curColor = s[cur] - 'A';
			cnt[to][curColor]--;
			if (cnt[to][0] == 0 || cnt[to][1] == 0) {
				Q.push(to);
				vis[to] = 1;
			}
		}
	}
}

int main() {
	cin >> n >> m;
	cin >> s;
	for (int i = 0; i < m; i++) {
		int f, t;
		cin >> f >> t;
		f--, t--;
		adj[f].push_back(t);
		adj[t].push_back(f);
		cnt[f][s[t] - 'A']++;
		cnt[t][s[f] - 'A']++;
	}
	bfs();
	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 12548
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
template <typename T> istream & operator >> (istream & in, vector<T> & xs) { REP (i, xs.size()) { in >> xs[i]; } return in; }

int solve(int k, const vector<int64_t> & d, int n, int64_t x, int64_t m) {
    vector<int64_t> e(k);
    REP (i, k) {
        e[i] = d[i] % m;
    }
    vector<int64_t> acc(k + 1);
    partial_sum(ALL(e), acc.begin() + 1);
    int nq = (n - 1) / k;
    int nr = (n - 1) % k;
    return (n - 1) - ((x + acc[k] * nq + acc[nr]) / m - x / m) - (count(ALL(e), 0) * nq + count(e.begin(), e.begin() + nr, 0));
}

int main() {
    int k, q; cin >> k >> q;
    vector<int64_t> d(k); cin >> d;
    while (q --) {
        int n; int64_t x, m; cin >> n >> x >> m;
        cout << solve(k, d, n, x, m) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int64_t a, b, c;
int64_t k;

int main(){
    cin >> a >> b >> c >> k;
    
    if(k<a) cout << k << endl;
    else if(k>=a && k<=a+b){
        cout << a << endl;
    }
    else if(k>a+b && k<a+b+c){
        cout << a - (k - a - b) << endl;
    }
    else if(k == a+b+c){
        cout << a - c << endl;
    }
}

Measured memory_bytes: 3624
S = input()[::-1]
f = False
while True:
  if S[:5]=="maerd":
    S = S[5:]
    continue
  elif S[:5]=="esare":
    S = S[5:]
    continue
  elif S[:7]=="remaerd":
    S = S[7:]
    continue
  elif S[:6]=="resare":
    S = S[6:]
    continue
  elif S == "":
    f = True
    break
  else:
    break
print("YES" if f else "NO")

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


int main(){
    int n;
    cin>>n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    for(int i=0;i<=n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    ll res = 0;
    for(int i=0;i<n;i++){
	if( b[i] > a[i] ){
	    res += a[i];
	    ll add = min(b[i]-a[i], a[i+1]) ;
	    a[i+1] -=add;
	    res += add;
	}else{
	    res += b[i];
	}
    }
    cout<<res<<endl;

    return 0;
}


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

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long MX = sqrt(N);
const long long H = 17;
const long long MAGIC = 1000;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int m;
int r[N];
bool used[N];
vector < int > v[N];

void solve()
{
        cin >> n >> m;
        for(int i = 1; i <= m; i++){
                int x, y;
                cin >> x >> y;
                v[x].pb(y);
                v[y].pb(x);
        }
        int s = 1, t = 1, bs = true, bt = true;
        used[1] = true;
        while(true){
                bool ch = false;
                if(bs){
                        bs = false;
                        for(int x: v[s]){
                                if(used[x] == false){
                                        ch = true;
                                        bs = true;
                                        r[x] = s;
                                        s = x;
                                        used[x] = true;
                                        break;
                                }
                        }
                }
                if(bt){
                        bt = false;
                        for(int x: v[t]){
                                if(used[x] == false){
                                        ch = true;
                                        bt = true;
                                        r[t] = x;
                                        t = x;
                                        used[x] = true;
                                        break;
                                }
                        }
                }
                if(!ch){
                        break;
                }
        }
        vector < int > ans;
        while(s){
                ans.pb(s);
                s = r[s];
        }
        cout << ans.size() << "\n";
        for(int x: ans){
                cout << x << " ";
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("landscape.in");
        //fout("landscape.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 7288
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;
                   
int n,m;
vector<int> v[100];
int from[100],to[100];

inline int bfs(int i){
  queue<int> q;
  q.push(0);
  int res=1;
  int nof=from[i];
  int noto=to[i];
  bool past[100];
  for(int j=0;j<100;j++)past[j]=0;
  past[0]=1;
  while(!q.empty()){
    int now=q.front();
    q.pop();
    for(int j=0;j<(int)v[now].size();j++){
      if(past[v[now][j]])continue;
      if(now==nof && v[now][j]==noto)continue;
      if(now==noto && v[now][j]==nof)continue;
      q.push(v[now][j]);
      past[v[now][j]]=1;
      res++;
    }
  }
  //cout<<res<<endl;
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    from[i]=a-1;to[i]=b-1;
    v[a-1].push_back(b-1);
    v[b-1].push_back(a-1);
  }
  int ans=0;
  for(int i=0;i<m;i++){
    if(bfs(i)!=n)ans++;
  }
  cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const double eps=1e-6;
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int N;
double dp[3007][3007] ;
double p[3007];
int main()
{
	cin>>N;
	for(int i=1;i<=N;++i)
		cin>>p[i];
	dp[0][0]=1;
	for(int i=1;i<=N;++i){
		for(int j=0;j<=i;++j){
			if(j==0){
				dp[i][0]=dp[i-1][0]*(1-p[i]);
				continue;
			}
			else
				dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
		}
	}
	double ans=0;
	for(int i=N/2+1;i<=N;++i)
		ans+=dp[N][i];
	printf("%.9lf\n",ans);
}




























Measured memory_bytes: 69120
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
    vector<int> a(3);
    for(int i = 0; i < 3; i++) cin >> a[i];
    sort(a.begin(), a.end());
    if(a[0] + a[1] == a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    vvl dp1(n+1, vl(4, 0));
    vvl dp2(n+1, vl(4, 0));
    rep(i,n){
        rep(j,3){
            if(j >= i+1) continue;
            dp1[i+1][j] = dp2[i][j] + a[i];
            dp2[i+1][j] = dp1[i][j];
            if(j-1 >= 0) dp2[i+1][j] = max(dp2[i+1][j], dp2[i][j-1]);
        }
    }
    if(n & 1) cout << max(dp1[n][2], dp2[n][1]) << endl;
    else cout << max(dp1[n][1], dp2[n][0]) << endl;
    return 0;
}

Measured memory_bytes: 33080
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>

using namespace std;

using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const ll INF = (1e+18)+100;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repl(i, l, n) for(int i=l;i<n;++i)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

typedef long double ld;
const ld eps = 1e-8;

void solve() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	rep(i, 1000) {
		string t = to_string(i);
		while (t.size() < 3) {
			t = "0" + t;
		}
		int tmp = 0;
		rep(j, n) {
			if (t[tmp] == s[j]) {
				tmp++;
				if (tmp == 3)break;
			}
		}
		if (tmp == 3) {
			ans++;
		}
	}
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	solve();
	//stop
	return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    lint n, m; cin>>n>>m;
    map<lint, vector<lint> > mp;
    priority_queue<lint> pq;
    rep(i,n){
        lint a,b; cin>>a>>b;
        mp[a].push_back(b);
    }

    lint res = 0;
    for(int i=1; i<=m; i++){
        for(lint a: mp[i]) pq.push(a);
        if(pq.empty()) continue;
        res += pq.top(); pq.pop();

    }
    out(res);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int n;
ll a[200000];
ll s[200001];

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> a[i];
	s[0] = 0;
	REP(i, n) s[i + 1] = s[i] + a[i];
	ll res = abs(s[1] - (s[n] - s[1]));
	REP(i, n - 1) res = min(res, abs(s[i + 1] - (s[n] - s[i + 1])));
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	long long int n, k, counter = 0;
	cin >> n >> k;
	int arr[n + 1], node = 1;
	long long int check[n + 1];
	bitset<200001> set;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	while(set[node] != 1 && counter < k){
		check[node] = counter;
		set[node] = 1;
		counter++;
		node = arr[node];
	}
	if(counter < k){
		counter = counter - check[node];
	}
	k -= check[node];
	k %= counter;
	for(int i = 0; i < k; i++){
		node = arr[node];
	}
	cout << node;
} 

Measured memory_bytes: 5992