akhauriyash/Code-Regression huggingface dataset:
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = b; i >= (a); --i)
#define repdl(i, a, b) for(ll i = b; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool ihmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
#endif
#ifndef _TEMPLATE_OPT
#define _TEMPLATE_OPT
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#endif
using namespace std;

int a[500005];

struct Query {
  int l, r, id, ans;
};

// freqcnt
int freq[500005];
int distinct = 0;
void freqadd(int x) { 
//write("FA", x, freq[x], "->", freq[x]+1);
  if (!freq[x]) distinct++; freq[x]++; }
void freqrem(int x) { 
  
//write("FR", x, freq[x], "->", freq[x]-1);
  freq[x]--; if (!freq[x]) distinct--; }
Query query[500005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n, q; read(n, q);
  rep(i, 1, n + 1) read(a[i]);
  rep(i, 0, q) read(query[i].l, query[i].r), query[i].id = i;
  
  const int BS = 1200;
  sort(query, query + q, [](const Query& a, const Query& b) {
    if (a.l / BS != b.l / BS) return a.l / BS < b.l / BS;
    else return (a.l / BS % 2 ? a.r < b.r : a.r > b.r);
    });

  // inclusive [cl, cr]
  int cl = 1, cr = 0;
  rep(i, 0, q) {
    int nl = query[i].l, nr = query[i].r;
    while (cl > nl) freqadd(a[--cl]);
    while (cr < nr) freqadd(a[++cr]);
    while (cl < nl) freqrem(a[cl++]);
    while (cr > nr) freqrem(a[cr--]);
    query[i].ans = distinct;
  }

  sort(query, query + q, [](const Query& a, const Query& b) { return a.id < b.id; });
  rep(i, 0, q) write(query[i].ans);
}



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

void cca(int *c,int *a,int *n,int *count){
	*c-=2;
	--*a;
	++*count;
}
void ccc(int *c,int *a,int *n,int *count){
	*c-=3;
	++*count;
}
void can(int *c,int *a,int *n,int *count){
	--*c;
	--*a;
	--*n;
	++*count;
}

int main(){
	int Q,c,a,n;
	cin>>Q;
	for(int i=0;i<Q;i++){
		int count=0;
		cin>>c>>a>>n;
		while(1){
			if(c>=1&&a>=1&&n>=1){
				can(&c,&a,&n,&count);
			}
			else if(c>=2&&a>=1){
				cca(&c,&a,&n,&count);
			}
			else if(c>=3){
				ccc(&c,&a,&n,&count);
			}
			else break;
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll a,b;
	rl2(a,b);
	cout << max({a+b, a-b, a*b}) << endl;
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
ok = [0 for i in range(N)] 
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    ok[a-1]+=1
ans = 0
for i in range(N):
  if ok[i] == 0:
    ans += 1
print(ans)


Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,m,a[500010],l,r,tag[500010];
bool ck(int o){
	FOR(i,0,n) tag[i]=0;
	FOR(i,0,n-1){
		int l=m-a[i],r=(o-a[i]+m)%m;
		int L,R;
		if (l<=r){
			L=lower_bound(a,a+n,l)-a;
			R=upper_bound(a,a+n,r)-a-1;
			if (L>R) return 0;
			L=(L+i+n)%n;
			R=(R+i+n)%n;
			if (L<=R){
				++tag[L],--tag[R+1];
			}
			else{
				++tag[L],++tag[0],--tag[R+1];
			}
		}
		else{
			L=lower_bound(a,a+n,l)-a;
			if (L<=n-1){
				L=(L+i+n)%n;
				R=(n-1+i+n)%n;
				if (L<=R){
					++tag[L],--tag[R+1];
				}
				else{
					++tag[L],++tag[0],--tag[R+1];
				}
			}
			R=upper_bound(a,a+n,r)-a-1;
			if (R>=0){
				L=(0+i+n)%n;
				R=(R+i+n)%n;
				if (L<=R){
					++tag[L],--tag[R+1];
				}
				else{
					++tag[L],++tag[0],--tag[R+1];
				}
			}
		}
	}
	int t=0;
	FOR(i,0,n-1){
		t+=tag[i];
		if (t==n && (i&1)) return 1;
	}
	return 0;
}
int main(){
	cin>>n>>m;
	n<<=1;
	FOR(i,0,n-1) getint(a[i]);
	sort(a,a+n);
	l=0,r=m-1;
	while (l<r){
		int o=l+r>>1;
		if (ck(o)) r=o;
		else l=o+1;
	}
	cout<<r<<endl;
	return 0;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    string s = input<string>();
    
    int n = s.size();
    auto check = [&](int l, int r) {
        range(i, 0, r - l) if (s[i + l] != s[r - i - 1]) return false;
        return true;
    };
    
    if (check(0, n) && check(0, (n - 1) / 2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            String T = in.next();

            boolean ok = false;

            if (S.equals(T.substring(0, S.length()))) ok = true;


            out.println(ok ? "Yes" : "No");

        }

    }
}



Measured memory_bytes: 35876
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,s[1000],p[1000],q[1000],r[1000],cal[1000],i,a,b,c,d,flg;
	while(1){
		cin>>n;
		if(n==0) break;
		for(i=0;i<n;i++){
			cin>>s[i]>>p[i]>>q[i]>>r[i];
			cal[i]=(p[i]+r[i])*4+q[i]*9;
		}
		cin>>a>>b>>c>>d;
		flg=0;
		for(i=0;i<n;i++){
			if(a>=p[i]&&b>=q[i]&&c>=r[i]&&d>=cal[i]){
				flg=1;
				cout<<s[i]<<endl;
			}
		}
		if(flg==0) cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007
 
using graph = vector<vector<ll>>;
 
int main(){
    string s,t;
    cin >> s;
    cin >> t;
    int ans = t.length();
    for(int i = 0; i <= s.length() - t.length(); i++){
      int huga = 0;
        for(int j = 0; j < t.length(); j++){
            if(s[i+j] != t[j]){
                huga++;
            }
        }
      ans = min(ans,huga);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e2+5, L = 14, OO = 0x3f3f3f3f;
const int M= 1e9+7;
const double ESP = 1e-8;

int n;
double A[3000];
double mem[3000][3000];
double solve(int idx, int tot){
    if(idx == n){
        if(tot>n/2)
            return 1;
        return 0;
    }

    double& ret = mem[idx][tot];
    if(ret != -1)
        return ret;

    return ret = (solve(idx+1,tot+1)*A[idx]) + (solve(idx+1, tot)* (1-A[idx]));
}

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=0; i<3000; i++)fill(mem[i], mem[i]+3000, -1);
    for(int i=0; i<n; i++){
        cin>>A[i];
    }
    cout<<fixed<<setprecision(10)<<solve(0,0);

}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void solve(){
string s;
cin>>s;
string s1="ABC";
if(s==s1)
cout<<"ARC";
else cout<<s1;

}
int main()
{
    ll t=1;
  //  cin>>t;
    while(t--)
    {
     solve();
     cout<<endl;
    }
	return 0;
}

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

void solve(long long N, vector<long long> a){
  long long ans = 0;
  while (true) {
    for ( long long i = 0; i < N; i++ ) {
      while (a[i] >= N) {
        ans += (a[i] / N);
        for ( long long j = 0; j < N; j++ ) {
          if (i == j) continue;
          a[j] += (a[i] / N);
        }
        a[i] = a[i] % N;
      }
    }
    bool flag = false;
    for ( long long i = 0; i < N; i++ ) {
      if (a[i] >= N) { flag = true; }
    }
    if (flag == false) break;
  }
  cout << ans << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



Measured memory_bytes: 256
// D - Moving Piece
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N, K; cin>>N>>K;
	vi P(N); rep(i, N) cin>>P[i], P[i]--;
	vi C(N); rep(i, N) cin>>C[i];

	ll INF = 1e18;
	ll score = -INF;
	rep(st, N){
		ll lap_sc = 0;
		int lap_cn = 0;
		int nx = st;
		while(true){
			lap_cn++;
			lap_sc += C[nx];
			nx = P[nx];
			if(nx == st) break;
		}
		lap_sc = max(0LL, lap_sc);

		ll sum_sc = 0;
		for(int k_cn=1; k_cn<=K; k_cn++){
			sum_sc += C[nx];
			score = max(score, sum_sc + lap_sc * ((K - k_cn) / lap_cn));
			nx = P[nx];
			if(nx == st) break;
		}
	}
	cout<< score <<endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    ll L;
    cin >> N >> L;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    bool ok = false;
    int pos = -1;
    rep(i, N - 1){
        if(A[i] + A[i + 1] >= L){
            ok = true;
            pos = i + 1;
            break;
        }
    }
    if(!ok){
        output("Impossible", 0);
        return 0;
    }
    output("Possible", 0);
    vector<int> ret;
    ret.pb(pos);
    repd(i, pos + 1, N){
        ret.pb(i);
    }
    for(int i = pos - 1;i >= 1; i--){
        ret.pb(i);
    }
    
    reverse(all(ret));
    
    rep(i, ret.size()){
        output(ret[i], 0);
    }
    
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

int widths[1500*1500];
int len = 0;

int vecCount(int key){
    int ret = 0;
    int h = lower_bound(widths,widths+len,key) - widths;
    int t = upper_bound(widths,widths+len,key) - widths;
    if(widths[h] != key) ret = 0;
    else ret = t - h;
    return ret;
}

int main(){

    while(true){
	int n,m;
	int ans = 0;
	cin >> n >> m;
	if(n==0 && m == 0) break;
	vi h(n),w(m);
	int index = 0;
	REP(i,n) scanf("%d",&h[i]);
	REP(i,m) scanf("%d",&w[i]);
	REP(i,m){
	    widths[index] = w[i];
	    index++;
	    int sum = w[i];
	    FOR(j,i+1,m){
		sum += w[j];
		widths[index] = sum;
		index++;
	    }
	}
	len = index;
	sort(widths,widths+len);

	REP(i,n){
	    int sum = h[i];
	    ans += vecCount(sum);
	    FOR(j,i+1,n){
		sum += h[j];
		ans += vecCount(sum);
	    }
	}
	cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 7412
#include <stdio.h>
#include <stdlib.h>

int main(){
    int N, M, C;
    int i,j;
    int temp, row_sum;
    int ans = 0;
    
    scanf("%d %d %d", &N, &M, &C);
    
    int B[M];
    
    for (i=0; i<M; i++) {
        scanf("%d", &B[i]);
    }
    
    for (i=0; i<N; i++){
        row_sum = 0;
        for (j=0; j<M; j++) {
            scanf("%d", &temp);
            row_sum += temp*B[j];
        }
        if (row_sum+C > 0) {
            ans++;
        }
    }
    printf("%d", ans);
    
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = b[a[-1]-1]
for i in range(n-1):
  ans += b[a[i]-1]
  if a[i] + 1 == a[i+1]:
    ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 9192
n, m = map(int, input().split())
dat_a = []
dat_b = []
for i in range(n):
    dat_a.append(input())
for i in range(m):
    dat_b.append(input())

if n == 1 and m == 1:
    if dat_a[0][0] == dat_b[0][0]:
        t = True
    else:
        t = False

for i in range(n - m + 1):
    for j in range(n - m + 1):
        for k in range(m):
            #print(dat_a[i + k][j : j + m])
            if dat_a[i + k][j : j + m] != dat_b[k]:
                t = False
                break
            t = True
        if t:
            break
    if t:
        break

print("Yes" if t else "No")


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<ld, ld> pdd;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;

ll N,combo;
int A[100000], B[100000], C[100000];

ll calc(ld mid) {
    vector<pdd> v;
    F0R(i,N) {
        pdd tmp = {(C[i]-B[i]*mid)/A[i],-(ld)A[i]/B[i]};
        if (tmp.s < 0) tmp.s = -tmp.s;
        else tmp.s = MOD-tmp.s;
        v.pb(tmp);
    }
    sort(v.begin(),v.end());
    
    Tree<ld> T;
    ll ret = 0;
    F0R(i,N) {
        ret += T.order_of_key(v[i].s);
        T.insert(v[i].s);
    }
    return ret;
}

void solve() {
	ld lox = -1000000000, hix = 1000000000;
	assert(calc(hix) == combo);
	F0R(i,70) {
	    ld mid = (lox+hix)/2;
	    if (2*calc(mid) >= combo) hix = mid; // first one such that 2*calc(mid) >= combo
	    else lox = mid;
	}
	cout << lox << " ";
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N; combo = N*(N-1)/2;
	F0R(i,N) cin >> A[i] >> B[i] >> C[i];
	cout << fixed << setprecision(11);
	F0R(i,N) swap(A[i],B[i]);
	solve();
	F0R(i,N) swap(A[i],B[i]);
	solve();
}

// read!
// ll vs. int!

Measured memory_bytes: 6828
X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
        print(X)
        exit()

p.sort()
tmp = [i for i in range(-111, 111)]
for i in p:
        tmp.remove(i)

ans_num = float("Inf")
ans_i = 0
for i in range(len(tmp)):
        if abs(X - tmp[i]) < ans_num:
                ans_num = abs(X - tmp[i])
                ans_i = i


print(tmp[ans_i])


Measured memory_bytes: 9204
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	double p;
	if (n % 2 == 1) p = double(n + 1) / 2 / n;
	else p =(double) n / 2 / n;
	cout << p << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, K;
	cin >> N >> K;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	int ans = INF;
	for (int i = 0; i < (1ll << N); i++) {
		if (i & 1)continue;
		vector<int>copy(N);
		copy = a;
		vector<int>v(N);
		rep(j, N)v[j] = (i >> j) & 1;
		int mx = copy[0];
		int sum = 0;
		rep(j, N) {
			if (j == 0)continue;
			if (v[j] == 1) {
				if (mx < copy[j])continue;
				sum += mx - copy[j] + 1;
				copy[j] = mx + 1;
			}
			mx = max(mx, copy[j]);
		}
		int cnt = 1;
		mx = copy[0];
		rep(j, N) {
			if (!j)continue;
			if (mx < copy[j])cnt++;
			mx = max(mx, copy[j]);
		}
		if (cnt >= K)chmin(ans, sum);
	}
	cout << ans << endl;
}

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

using namespace std;
int n,c,v[109],w[109],sum;
long long dp[109][100009];
int main()
{
    cin>>n>>c;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=sum;j++)
        {
            if(dp[i-1][j]==-1)continue;
            if(dp[i-1][j+v[i]]!=-1)
            {
                dp[i][j+v[i]]=min(dp[i-1][j+v[i]],dp[i-1][j]+w[i]);
            }
            else dp[i][j+v[i]]=dp[i-1][j]+w[i];
            dp[i][j]=min(dp[i-1][j],dp[i][j]);
            if(dp[i][j]==-1)
                dp[i][j]=dp[i-1][j];
        }
    }
    for(int i=sum;i>=0;i--)
    {
        if(dp[n][i]<=c&&dp[n][i]!=-1)
        {
            cout<<i;
            return 0;
        }
    }
}



Measured memory_bytes: 85376
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
 
vector<int>a,dp;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
    ll n;cin>>n;
    a.resize(n);
    dp.resize(n,1e9);
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    dp[0]= 0;
    dp[1]= abs(a[0]-a[1]);
    //dp[2]= min(abs((a[0]-a[2])),abs(a[1]-a[2]));
    for (int i=2;i<n;i++){
        dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

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

  int i, r[n];
  for (i = 0; i < n; i++)
  {
    cin >> r[i];
  }

  int minv = r[0];
  int maxv = -1000000000;

  for (i = 1; i < n; i++)
  {
    maxv = max(maxv, r[i] - minv);
    minv = min(minv, r[i]);
  }

  cout << maxv << endl;

  return 0;
}



Measured memory_bytes: 3884
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a,b = 0,0
for i, perm in enumerate(itertools.permutations(range(1, N+1)), 1):
    if P==perm:
        a = i
    if Q==perm:
        b = i
    if a > 0 and b > 0:
        print(abs(a-b))
        exit()

Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef pair<double,int> P;
int N,M,from[101],nid[101];
double inf=1e5,d[101][101],d2[101][101];
bool vis[101];
vector<int> cycle;
bool visit(int v,int s,int r){
	if(v==r) return 0;
	if(vis[v]) return v==s;
	cycle.pb(v);
	vis[v]=1;
	return visit(from[v],s,r);
}
double dir_msp(int r){	//root = r
	int S=N;
	bool update=1;
	while(update){
//		printf("   S=%d\n",S);
		update=0;
		double sco=0;
/*		rep(i,S){
			rep(j,S) printf("%.2f ",d[i][j]);
			puts("");
		}*/
		rep(i,S){
			if(i==r) continue;
			P mn=P(inf,-1);
			rep(j,S) if(i!=j) mn=min(mn,P(d[j][i],j));
			if(mn.fs==inf) return inf;
			from[i]=mn.sc;
			sco+=mn.fs;
//			printf("from[%d]=%d\n",i,from[i]);
//			show(sco);
		}
		rep(i,S){
			if(i==r) continue;
			rep(j,S) vis[j]=0;
			cycle.clear();
			if(!visit(i,i,r)) continue;
			update=1;
			int len=cycle.size();
			cycle.pb(cycle[0]);
			int S2=S-len+1,it=0;
			rep(j,S){
				if(!vis[j]) nid[j]=it++;
				else nid[j]=-1;
			}
			r=nid[r];
			rep(j,S) if(nid[j]!=-1){		//o->o
				rep(k,S) if(nid[k]!=-1){
					d2[nid[j]][nid[k]]=d[j][k];
				}
			}
			rep(j,S) if(nid[j]!=-1){		//i->o
				double mn=inf;
				rep(k,S) if(nid[k]==-1) mn=min(mn,d[k][j]);
				d2[S2-1][nid[j]]=mn;
			}
			double csum=0;
			rep(j,len) csum+=d[cycle[j+1]][cycle[j]];
			rep(j,S) if(nid[j]!=-1){
				double mn=inf;
				rep(k,len){
					mn=min(mn,d[j][cycle[k]]+csum-d[cycle[k+1]][cycle[k]]);
				}
				d2[nid[j]][S2-1]=mn;
			}
			S=S2;
			rep(j,S) rep(k,S) d[j][k]=d2[j][k];
			break;
		}
		if(!update) return sco;
	}
}
double v[101][100];
int main(){
	cin>>M>>N;
	rep(i,N) rep(j,M) cin>>v[i+1][j];
	N++;
	rep(i,N) rep(j,N) if(i!=j){
		double a=0,b=0,c=0,r=0;
		rep(k,M) a+=v[j][k]*v[j][k];
		rep(k,M) b+=2*v[i][k]*v[j][k];
		rep(k,M) c+=v[i][k]*v[i][k];
		if(a==0) r=0;
		else r=b/2/a;
		d[j][i]=a*r*r-b*r+c;
	}
/*	rep(i,N){
		rep(j,N) printf("%.2f ",d[i][j]);
		cout<<endl;
	}*/
	printf("%.12f\n",dir_msp(0));
}

Measured memory_bytes: 1504
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double dp[42][42][42][42];
int rev[42][42][42][42];
double x[42];
double y[42];
pair<pair<int,int>,int>in[42];
double d[42][42];
double th[42][42];
int out[42];
int conv[42];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d",&in[i].first.second,&in[i].first.first);
		in[i].second=i;
	}
	std::sort(in,in+a);
	for(int i=0;i<a;i++){
		x[i]=in[i].first.second;
		y[i]=in[i].first.first;
		conv[i]=in[i].second;
	}
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		if(i==j)continue;
		th[i][j]=atan2(y[j]-y[i],x[j]-x[i]);
		if(th[i][j]<0)th[i][j]+=acos(-1.0)*2;
	//	printf("%d %d: %f\n",i,j,th[i][j]);
	}
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		d[i][j]=x[i]*y[j]-y[i]*x[j];
	}
	for(int i=0;i<=a;i++)for(int j=0;j<=a;j++)for(int k=0;k<=a;k++)for(int l=0;l<=a;l++)
		dp[i][j][k][l]=99999999999.9;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++){
			dp[i][1][j][i]=d[i][j];
		}
		for(int j=1;j<a;j++){
			for(int k=i+1;k<a;k++){
				for(int l=i;l<a;l++){
					if(dp[i][j][k][l]<9999999999.9){
						
						for(int m=i;m<a;m++){
							if(l==m||k==m)continue;
							if(th[l][k]>th[k][m])continue;
							if(dp[i][j+1][m][k]>dp[i][j][k][l]+d[k][m]){
//printf("%d %d %d %d: -> %d %f\n",i,j,k,l,m,dp[i][j][k][l]+d[k][m]);
								dp[i][j+1][m][k]=dp[i][j][k][l]+d[k][m];
								rev[i][j+1][m][k]=l;
							}
						}
					}
				}
			}
		}
	}
	int c;scanf("%d",&c);
	while(c--){
		int t;scanf("%d",&t);
		double res=99999999999.9;
		int I=0;
		int L=0;
		for(int i=0;i<a;i++){
			for(int l=0;l<a;l++){
				if(res>dp[i][t][i][l]){
					res=dp[i][t][i][l];
					I=i;L=l;
				}
			}
		}
		if(res>9999999999.9){
			printf("NA\n");continue;
		}
		int K=I;
		for(int i=0;i<t;i++){
			
			int toL=rev[I][t-i][K][L];
			K=L;L=toL;out[t-1-i]=conv[K]+1;
		}
		for(int i=0;i<t;i++){
			if(i)printf(" ");
			printf("%d",out[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 35668
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL 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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
int a[1 << 18];
pair<int, int> dp[1 << 18];
int ans[1 << 18];

int main(){
    cin >> n;
    REP(i, (1 << n))cin >> a[i];
    dp[0] = make_pair(0, 0);
    for(int bit = 1;bit < (1 << n);bit++){
        vector<int> v;
        v.emplace_back(bit);
        REP(i, n){
            if(bit & (1 << i)){
                v.emplace_back(dp[bit - (1 << i)].first);
                v.emplace_back(dp[bit - (1 << i)].second);
            }
        }
        sort(ALL(v));
        UNIQUE(v);
        sort(ALL(v), [&](int u, int v){return a[u] > a[v];});
        dp[bit].first = v[0];
        dp[bit].second = v[1];
    }
    for(int i = 1;i < (1 << n);i++){
        ans[i] = max(ans[i - 1], a[dp[i].first] + a[dp[i].second]);
    }
    for(int i = 1;i <= (1 << n) - 1;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 7168
#include<stdio.h>
#define MAX 10000
void fibonacci(int);

int F[MAX];
int n;
int main(){

    scanf("%d",&n);
    fibonacci(n);
    printf("%d\n",F[n]);

return 0;
}

void fibonacci(int n){
    int i;
    F[0]=1;
    F[1]=1;
    for(i=2;i<=n;i++){
        F[i] = F[i-2]+F[i-1];
    }
}



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

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007

    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n,m;
        cin>>n>>m;
        vi a(n);
        rep0(n) cin>>a[i];
        sort(all(a));
        std::vector<pair<int,int>> v;
        rep0(m){
            int b,c;
            cin>>b>>c;
            v.pb({c,b});
        }
        sort(all(v),greater<pair<int,int>>());
        int c=0;
        rep0(m){
            if(c>=n) break;
            int j=v[i].ss,k=v[i].ff;
            while(c<n&&j>0&&a[c]<k){
                a[c]=max(a[c],k);
                c++;
                j--;
            }
        }
        int sum=0;
        rep0(n) sum=(sum+a[i]);
        //rep0(n) cout<<a[i]<<" ";
        cout<<sum;

     }
    signed main()
    {   
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int N, X, Y;
	cin >> N >> X >> Y;
  X--;
  Y--;
	int path_number[N];
  rep(i, N) path_number[i] = 0;
  rep(i, N-1)
  {
    repd(j, i+1, N)
    {
      int shortest_path = j-i;
      shortest_path = min(shortest_path, abs(X-i)+abs(Y-j)+1);
      path_number[shortest_path]++;
    }
  }
  repd(i, 1,  N) cout << path_number[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main() { 
   int a, b; cin >> a >> b;
   if(a%3==0 or b%3==0 or (a+b)%3==0) cout << "Possible" << ln;
   else cout << "Impossible" << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;




//**************Problem C**************
int main() {
	int N = 0;
	cin >> N;
	vector<int> vec1(N,0);
	vector<int> vec2(N,0);
	vector<int> value(N, 0);

	for (int i = 0; i < N; i++)
		cin >> vec1[i];
	for (int i = 0; i < N; i++)
		cin >> vec2[i];

	int val1 = 0;
	int val2 = 0;

	val1 = vec1[0];
	val2 = accumulate(vec2.begin(), vec2.end(), 0);
	value[0] = val1 + val2;

	for (int i = 1; i < N; i++) {
		val1 += vec1[i];
		val2 -= vec2[i-1];
		value[i] = val1 + val2;
	}

	
	cout << *std::max_element(value.begin(), value.end()) << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <string.h>

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

    int ac  = 0;
    int wa  = 0;
    int tle = 0;
    int re  = 0;

    for (int i = 0; i < count; i++)
    {
        char input[4];
        scanf("%s", input);

        if (strcmp(input, "AC") == 0)
        {
            ac++;
            continue;
        }

        if (strcmp(input, "WA") == 0)
        {
            wa++;
            continue;
        }

        if (strcmp(input, "TLE") == 0)
        {
            tle++;
            continue;
        }

        if (strcmp(input, "RE") == 0)
        {
            re++;
        }
    }

    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);

    return 0;
}


Measured memory_bytes: 1704
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;

const int MAXN=1e5+5;

int n,m,Q;
int co[MAXN],last[MAXN];
int Ehead[MAXN],ecnt;
struct edge{
    int v,nxt;
}E[MAXN*2];
struct node{
    int pos,val,co;
}T[MAXN];

void addedge(int u,int v){
    E[++ecnt]=(edge){v,Ehead[u]};
    Ehead[u]=ecnt;
}

void dfs(int u,int dep,int co,int fa=0){
    if(dep<=last[u]) return;
    last[u]=dep;
    if(!::co[u]) ::co[u]=co;
    for(int i=Ehead[u];i;i=E[i].nxt){
        int v=E[i].v;
        if(v==fa) continue;
        dfs(v,dep-1,co,u);
    }
}

int main(){
    //freopen("splatter.in","r",stdin);
    //freopen("splatter.out","w",stdout);

    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        addedge(u,v);
        addedge(v,u);
    }
    memset(last,-1,sizeof last);
    scanf("%d",&Q);
    for(int i=1;i<=Q;i++) scanf("%d%d%d",&T[i].pos,&T[i].val,&T[i].co);
    for(int i=Q;i>=1;i--) dfs(T[i].pos,T[i].val,T[i].co);
    for(int i=1;i<=n;i++) printf("%d\n",co[i]);

    fclose(stdin);
    fclose(stdout);
}


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

int main() {
	int N;
	cin >> N;
	int A[N], B[N];
	for (int i=0; i<N; i++){
	    cin >> A[i] >> B[i];
	}
	for (int i=0; i<N-2; i++){
	    if (A[i]==B[i] && A[i+1]==B[i+1] && A[i+2]==B[i+2]){
	        cout << "Yes" << endl;
	        return 0;
	    }
	}
	cout << "No" << endl;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      x: usize,
    }

    let mut y = x%100;
    let mut cnt = 0;
    for i in (1..6).rev() {
        cnt += y/i;
        y = y%i;
    }
    if x/100 >= cnt {
        puts!("{}\n", 1);
    } else {
        puts!("{}\n", 0);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int cnt = 0;
vector< vector<int> > lcs;

int LCS(string s1,string s2,int N,int M){
	if(N==0 || M==0){
		return 0;
	}
	if(lcs[N][M]!=-1){
		return lcs[N][M];
	}
	cnt++;
	if(s2[N-1]==s1[M-1]){
		lcs[N][M] = (1+LCS(s1,s2,N-1,M-1));
	}
	else{
		lcs[N][M] = max(LCS(s1,s2,N,M-1),LCS(s1,s2,N-1,M));	
	}
	return lcs[N][M];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s1,s2;
	cin>>s1>>s2;
	
	lcs.resize(s2.size()+1);
	for(int i=0;i<=s2.size();i++){
		lcs[i].resize(s1.size()+1,-1);
	}
	//long long final_ans = solveKnapsack(N,MAX);
	//int ans = LCS(s1,s2,s2.size(),s1.size());
	for(int i=0;i<=s1.size();i++){
		lcs[0][i] = 0;
	}
	for(int i=0;i<=s2.size();i++){
		lcs[i][0] = 0;
	}
	for(int i=1;i<=s2.size();i++){
		for(int j=1;j<=s1.size();j++){
			if(s1[j-1]==s2[i-1]){
				lcs[i][j] = lcs[i-1][j-1] + 1;
			}
			else{
				lcs[i][j] = max(lcs[i-1][j],lcs[i][j-1]);
			}
		}
	}
	string lcsans = "";
	if(lcs[s2.size()][s1.size()]==0){
		cout<<"";
		return 0;
	}
	int i=s2.size(),j=s1.size();
	while(i>0 && j>0){
		if(s2[i-1] == s1[j-1]){

			lcsans = s1[j-1] + lcsans;
			i--;
			j--;
		}
		else if(lcs[i-1][j]>lcs[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	cout<<lcsans<<endl;
	return 0;
}

Measured memory_bytes: 38848
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	maxBufsize = 1000000
)

func inputs(lines int, rdr *bufio.Reader) []string {
	var strSlice []string

	//rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)

	for i := 0; i < lines; i++ {

		line := ReadLine(rdr)
		strSlice = append(strSlice, line)

	}

	return strSlice
}

// ReadLine is to read long line
func ReadLine(rdr *bufio.Reader) string {
	buf := make([]byte, 0, maxBufsize)
	for {
		l, p, e := rdr.ReadLine()

		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}

	return string(buf)
}

//DivideConvertInt is to divide and convert
func DivideConvertInt(line string, num int) []int {
	tmp := strings.Split(line, " ")

	intSlice := make([]int, num)

	for i := 0; i < num; i++ {
		intTmp, _ := strconv.Atoi(tmp[i])
		intSlice[i] = intTmp
	}

	return intSlice
}

func main() {
	rdr := bufio.NewReaderSize(os.Stdin, maxBufsize)
	line0 := inputs(1, rdr)

	line0Int := DivideConvertInt(line0[0], 2)

	N := line0Int[0]
	K := line0Int[1]

	line1 := inputs(1, rdr)

	A := DivideConvertInt(line1[0], N)

	check := []int{}
	ord := make([]int, N+1)

	for i := 0; i < N+1; i++ {
		ord[i] = -1
	}

	i := 1

	for {
		if ord[i] == -1 {
			ord[i] = len(check)
			check = append(check, i)
			i = A[i-1]
		} else {
			break
		}
	}

	cycle := len(check) - ord[i]

	l := ord[i]

	if K < l {
		fmt.Println(check[K])
	} else {
		K -= l
		K %= cycle
		fmt.Println(check[l+K])
	}

}


Measured memory_bytes: 17696
// 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);
}

ll f(ll h){
	if(h==1)return 1;
	return 2*f(h/2)+1;
}

void solveTest(){
	ll h;
	cin>>h;
	cout<<f(h)<<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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

vector<string> name;
vector<vector<int>> G;
void rec(int n,int dep){
    cout << string(dep,'.') << name[n] << endl;
    for(auto next:G[n]){
        rec(next,dep+1);
    }
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    name.resize(n);
    G.resize(n);
    for(int i = 0; i < n;i++){
        int p; cin >> p;
        string S; cin >> S;
        name[i] = S;
        if(p == 0) continue;
        p--;
        G[p].push_back(i);
    }
    rec(0,0);
    return 0;
}



Measured memory_bytes: 3476
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

const int NMAX = 200000 + 5;
typedef long long int lint;
const lint INF = 1E18 + 15;

struct Node {
    int st, dr;
    lint minPlus;
    lint minMinus;
    lint minimum;
    lint lazy;

    void makeLazy(lint val) {
        minPlus += val;
        minMinus += val;
        minimum += val;
        if (st != dr)
            lazy += val;
    }
} tree[4 * NMAX];

void propagate(int node) {
    if (tree[node].lazy) {
        tree[node << 1].makeLazy(tree[node].lazy);
        tree[(node << 1) + 1].makeLazy(tree[node].lazy);
        tree[node].lazy = 0;
    }
}

void build(int node, int st, int dr) {
    tree[node].st = st, tree[node].dr = dr;
    tree[node].minPlus = tree[node].minMinus = tree[node].minimum = INF;
    if (st == dr)
        return ;
    int mid = (st + dr) >> 1;
    build(node << 1, st, mid);
    build((node << 1) + 1, mid + 1, dr);
}

void update(int node, int where, lint val) {
    if (tree[node].st == tree[node].dr) {
        tree[node].minPlus = val + where;
        tree[node].minMinus = val - where;
        tree[node].minimum = val;
        return ;
    }
    propagate(node);

    int mid = (tree[node].st + tree[node].dr) >> 1;
    if (where <= mid)
        update(node << 1, where, val);
    else
        update((node << 1) + 1, where, val);

    tree[node].minPlus = min(tree[node << 1].minPlus, tree[(node << 1) + 1].minPlus);
    tree[node].minMinus = min(tree[node << 1].minMinus, tree[(node << 1) + 1].minMinus);
    tree[node].minimum = min(tree[node << 1].minimum, tree[(node << 1) + 1].minimum);
}

lint queryPlus(int node, int st, int dr) {
    if (tree[node].st == st && tree[node].dr == dr)
        return tree[node].minPlus;
    propagate(node);

    int mid = (tree[node].st + tree[node].dr) >> 1;
    if (dr <= mid)
        return queryPlus(node << 1, st, dr);
    else if (st > mid)
        return queryPlus((node << 1) + 1, st, dr);
    else
        return min(queryPlus(node << 1, st, mid),
                   queryPlus((node << 1) + 1, mid + 1, dr));
}

lint queryMinus(int node, int st, int dr) {
    if (tree[node].st == st && tree[node].dr == dr)
        return tree[node].minMinus;
    propagate(node);

    int mid = (tree[node].st + tree[node].dr) >> 1;
    if (dr <= mid)
        return queryMinus(node << 1, st, dr);
    else if (st > mid)
        return queryMinus((node << 1) + 1, st, dr);
    else
        return min(queryMinus(node << 1, st, mid),
                   queryMinus((node << 1) + 1, mid + 1, dr));
}

int main()
{
    //freopen("data.in", "r", stdin);
    ios_base :: sync_with_stdio(false);
    cin.tie(0);

    int N, Q, A, B;
    cin >> N >> Q >> A >> B;

    build(1, 1, N);

    int last = B;
    update(1, A, 0);

    while (Q --) {
        int x;
        cin >> x;

        lint cost = min(x + queryMinus(1, 1, x),
                       -x + queryPlus(1, x, N));
        tree[1].makeLazy(abs(x - last));

        update(1, last, cost);
        last = x;
    }

    cout << tree[1].minimum << '\n';
    return 0;
}


Measured memory_bytes: 22784