akhauriyash/Code-Regression huggingface dataset:
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	double w,h,x,y;
	scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
	printf("%.2f ", (w * h / 2.00));
	if(w / 2.00 == x && h / 2.00 == y)	printf("1\n");
	else	printf("0\n");
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

void solve(int n){
    vector<vector<int>> ok(n,vector<int>(31));
    rep(i,n){
        int m;
        cin>>m;
        rep(j,m){
            int x;
            cin>>x;
            ok[i][x]=1;
        }
    }
    rep(i,31){
        vector<int> OK(n,0);
        rep(j,n)if(ok[j][i])OK[j]=1;
        for(int j=i-1 ; j>=0;--j){
            int can=0;
            rep(k,n)if(OK[k]&&ok[k][j])can=true;
            if(can){
                rep(k,n)if(ok[k][j])OK[k]=1;
            }
            int ans=0;
            rep(k,n)if(OK[k])++ans;
            if(ans==n){
                cout<<i<<endl;
                return;
            }
        }
    }
    cout<<-1<<endl;
    return ;

}
int main(){
    int n;
    while(cin>>n,n!=0)solve(n);
    return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

struct UnionFind {
  vector<int> par, s;
  UnionFind(int n=2e5) { init(n); }
  void init(int n) { 
    s.assign(n, 1); par.resize(n); 
    iota(par.begin(), par.end(), 0);
  }
  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
    else par[y] = x, s[x] = s[x] + s[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return s[find(x)]; }
};

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

  ll n, m;
  cin >> n >> m;
  auto e = make_v<ll>(m, 3);
  REP(i, m) {
    cin >> e[i][1] >> e[i][2] >> e[i][0];
    e[i][1]--, e[i][2]--;
  }

  ll sum = 0;
  UnionFind uf(n);
  vector<vector<PII>> g(n);
  sort(ALL(e));
  REP(i, m) {
    if(uf.same(e[i][1], e[i][2])) continue;
    uf.unite(e[i][1], e[i][2]);
    g[e[i][1]].push_back({e[i][2], e[i][0]});
    g[e[i][2]].push_back({e[i][1], e[i][0]});
    sum += e[i][0];
  }

  auto d = make_v<ll>(n, n);
  fill_v(d, 0);
  function<void(ll,ll,ll,ll)> dfs = [&](ll v, ll p, ll s, ll dist) {
    d[s][v] = dist;
    ll ret = 0;
    for(auto to: g[v]) {
      if(to.first == p) continue;
      dfs(to.first, v, s, max(dist,to.second));
    }
  };
  REP(i, n) dfs(i, -1, i, 0);

  // REP(i, n) cout << d[i] << endl;

  ll q;
  cin >> q;
  REP(i, q) {
    ll s, t;
    cin >> s >> t;
    s--, t--;
    cout << sum - d[s][t] << endl;
  }

  return 0;
}


Measured memory_bytes: 149760
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] p = new int[n];
    for(int i=0; i<n; i++){
      p[i] = sc.nextInt();
    }
    
    Arrays.sort(p);
    int ans = 0;
    for(int i=0; i<k; i++){
      ans += p[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 38784
#include <iostream>
using namespace std;
string a;
string b;
int main()
{
    cin>>a;
    for(auto it:a)
    {
        if(it!='x')b+=it;
    }
    bool ok=1;
    for(int st=0,dr=b.size()-1;st<dr;st++,dr--)
        ok&=(b[st]==b[dr]);
    if(!ok){cout<<-1;return 0;}
    int rez=0;
    for(int st=0,dr=a.size()-1;st<dr;)
    {
        if(a[st]==a[dr]){st++;dr--;}
        else
        {
            rez++;
            if(a[st]=='x')st++;
            else dr--;
        }
    }
    cout<<rez;
    return 0;
}


Measured memory_bytes: 512
//written by libra9z
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
string s;
int main()
{
	cin>>s;
	for (int i=0;i<8;++i) s.pop_back();
	cout<<s<<endl;
	return 0;
}

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

int main(void){
    
    int i,sum=0;
    char o[51],e[51];
    
    scanf( "%s",o );
    scanf( "%s",e );
    
    int lo = strlen(o);
    int le = strlen(e);
    
  
    for( i = 0; i < le; i++ ){
        printf( "%c%c",o[i],e[i] );
    }
    
    if( lo > le && e[i] == '\0' ){
        printf( "%c",o[lo-1] );
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>


const long long p = 1000000007;

int main()
{
    int n;
    std::cin >> n;
    std::vector<long long> counter(26);
    for (int i = 0; i < n; i++) {
        char c;
        std::cin >> c;
        counter.at(c - 'a')++;
    }

    long long result = 1;

    for (int i = 0; i < 26; i++) {
        result = result * (counter.at(i) + 1) % p;
    }

    if (result == 0) {
        std::cout << p - 1 << std::endl;
    } else {
        std::cout << result - 1 << std::endl;
    }


    return 0;
}

Measured memory_bytes: 256
//c++11
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
    long int x, y;
    int ans;
    vector<long int> vx, vy;
    
    while(cin >> x >> y){
        vx.push_back(x);
        vy.push_back(y);
    }

    for(int i=0; i < vx.size(); i++ ){
        long int div = 1, sum = vx[i]+vy[i];
        for(int j = 0; ; j++){
            if(sum / div < 1){
                ans = j;
                break;
            }else{
                div *= 10;
            }
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    string c1,c2,c3;
    cin >> c1 >> c2 >> c3;
    string ans = "";
    ans += c1[0];
    ans += c2[1];
    ans += c3[2];
    // string ans = c1[0] + c2[1] + c3[2];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;

  int maxl = 0;
  for (int l = 1; l <= n; l++) {
    bool ok = true;
    for (int i = 0; ok && i < l; i++)
      ok = (s[n - l + i] == t[i]);
    if (ok) maxl = l;
  }

  printf("%d\n", n * 2 - maxl);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] memo = new int[100000];
		long ans = 0;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			memo[a-1]++;
			ans+=a;
		}
		int q = sc.nextInt();
		int b[] = new int[q];
		int c[] = new int[q];
		for(int i = 0; i < q; i++) {
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		for(int i = 0; i < q; i++) {
			ans+=((c[i]-b[i])*memo[b[i]-1]);
			memo[c[i]-1]+=memo[b[i]-1];
			memo[b[i]-1]=0;
			System.out.println(ans);
		}
	}
}

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

int main(){
	string s;
	cin >>s;
	int cnt=0;
	for (auto i:s){
		if (i=='o')
			cnt++;
	}
	if (15-s.size()+cnt<8)
		cout <<"NO";
	else
		cout <<"YES";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, K = map(int, input().split())

if K == 1:
    N = 0

else:
    if N // K > 0:
        i = N//K
        N = N - (K * i)
    while abs(N-K)<N:
        N = abs(N-K)
print(N)

Measured memory_bytes: 38256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#define fs first
#define se second
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int maxn=1e3+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int ans=b*(b-1)/2;
	ans+=a*(a-1)/2;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
// using int = long long;
using lpair = pair<int, int>;
const int MOD = 1e9+7;
// const int INF = 1e18;
#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i>=(n);i--)
#define printa(x,n) for(int i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
int isSquare(int x){
    int lv = 0, rv = x+1;
    while(rv - lv > 1){
        int mid = (lv + rv) / 2;
        if(mid * mid >= x){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    if(rv * rv == x){
        return rv;
    }else{
        return -1;
    }
}

void solve(){
    int N;
    cin >> N;
    rep(n,1,N+1){
        int ans = 0;
        for(int x = 1; x * x <= n; x++){
            for(int y = 1; y*y <= n; y++){
                int v1 = x + y;
                int v2 = x * x + y * y + x * y - n;
                int r = v1 * v1 - 4 * v2;
                int val = isSquare(r);
                if(r >= 0 && val >= 0){
                    if((-v1+val) > 0 && (-v1+val) % 2 == 0){
                        ans++;
                    }
                    if((-v1-val) > 0 && (-v1-val) % 2 == 0){
                        ans++;
                    }
                }

            }
        }
        print(ans);
    }

    

}

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

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int D[300];
int dist[300];
vector<int> G[300], R[300];
vector<int> G2[300];
bool used[300];
int ord[300];

vector<int> vs;
void dfs(int x) {
  if (used[x]) return;
  used[x] = true;
  for (int t : G[x]) dfs(t);
  vs.pb(x);
}
void rdfs(int x, int k) {
  if (used[x]) return;
  used[x] = true;
  ord[x] = k;
  for (int t : R[x]) rdfs(t, k);
}

int scc() {
  vs.clear();
  rep(i, N) used[i] = false;
  rep(i, N) dfs(i);
  rep(i, N) used[i] = false;
  int k = 0;
  for (int i=vs.size()-1; i>=0; i--) {
    if (!used[vs[i]]) rdfs(vs[i], k++);
  }
  return k;
}
void dfs2(int x) {
  if (used[x]) return;
  used[x] = true;
  for (int t : G2[x]) dfs2(t);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> M) {
    if (M == 0) break;
    cin >> N;
    N+=2;
    D[0] = 0;
    rep(i, N-2) cin >> D[i+1];
    D[N-1] = 0;
    bool ng = false;
    rep(i, N) G[i].clear(), R[i].clear();
    rep(i, N-1) {
      for (int k=1; k<=M; k++) {
        int t = i+k;
        if (t > N) t = N;
        if (t < 0) t = 0;
        t += D[t];
        if (t > N) t = N;
        if (t < 0) t = 0;
        if (i == t) continue;
        G[i].pb(t);
        R[t].pb(i);
      }
    }
    int K = scc();
    rep(i, K) G2[i].clear();
    rep(i, N) {
      for (int t : G[i]) {
        if (ord[i] == ord[t]) continue;
        G2[ord[i]].pb(ord[t]);
      }
    }
    rep(i, K) {
      sort(all(G2[i])); uniq(G2[i]);
    }
    rep(i, N) used[i] = false;
    dfs2(ord[0]);
    rep(i, K) {
      if (i == ord[N-1]) continue;
      if (used[i] && G2[i].empty()) ng = true;
    }
    if (!ng) cout << "OK\n";
    else cout << "NG\n";
  }
  return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int M;
int K;
int res[300000];
int main(){
  int i, j;
  rd(M);
  rd(K);
  if(K >= (1<<M)){
    wt_L(-1);
    wt_L('\n');
    return 0;
  }
  if(M==1){
    if(K==0){
      wt_L("0 0 1 1");
      wt_L('\n');
    }
    else{
      wt_L("-1");
      wt_L('\n');
    }
    return 0;
  }
  j = 0;
  for(i=0;i<1<<M;i++){
    if(i!=K){
      res[j++] = i;
    }
  }
  res[j++] = K;
  for(i=(1<<M)-1;i>=0;i--){
    if(i!=K){
      res[j++] = i;
    }
  }
  res[j++] = K;
  {
    int Lj4PdHRW;
    if(j==0){
      putchar_unlocked('\n');
    }
    else{
      for(Lj4PdHRW=0;Lj4PdHRW<j-1;Lj4PdHRW++){
        wt_L(res[Lj4PdHRW]);
        wt_L(' ');
      }
      wt_L(res[Lj4PdHRW]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190706-1

// --- original code ---
// int M, K;
// int res[3d5];
// {
//   int i, j;
// 
//   rd(M,K);
//   if(K >= (1<<M)){
//     wt(-1);
//     return 0;
//   }
// 
//   if(M==1){
//     wt( if[K==0, "0 0 1 1", "-1"] );
//     return 0;
//   }
//   
//   j = 0;
//   rep(i,1<<M) if(i!=K) res[j++] = i;
//   res[j++] = K;
//   for(i=(1<<M)-1;i>=0;i--) if(i!=K) res[j++] = i;
//   res[j++] = K;
// 
//   wt(res(j));
// 
// /*  int x, y, z, m;
//   rep(x,j) rep(y,x+1,j) if(res[x]==res[y]){
//     m = 0;
//     rep(z,x,y+1) m ^= res[z];
//     if(m!=K) wt(x,y,m,":",res[x]);
//   }
// */
// }


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

public class BinarySearch{
	public static void Main()
	{
		Console.ReadLine();
		var sList = ReadLineAndToIntList();
		Console.ReadLine();
		var tList = ReadLineAndToIntList();
	
		int count = 0;
	
		foreach (var t in tList)
		{
			if(sList.BinarySearch(t) > -1) count++;
		}
		
		Console.WriteLine(count);
	}
	
	//??????????????????????????????
	public static List<int> ReadLineAndToIntList()
	{
		return Console.ReadLine().Split().Select (c => int.Parse(c)).ToList();
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  //int *a, *b, *d, *sign;
  vector<int> a(m); //a = new int[m];
  vector<int> b(m); //b = new int[m];
  vector<int> d(n); //d = new int[n];
  vector<int> sign(n); //sign = new int[n];
  vector<vector<int>> neighbor(n);
  vector<int> next;
  d[0]=0;
  for(int i=1;i<n;i++){
    d[i]=9999999;
  }
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    neighbor[a[i]-1].push_back(b[i]);
    neighbor[b[i]-1].push_back(a[i]);
  }
  int sel;
  for(int i=0;i<neighbor[0].size();i++){
    sel = neighbor[0][i];
    d[sel-1] = 1;
    sign[sel-1] = 1;
    next.push_back(sel);
  }
  int now;
  int possi=1;
  for(int i=0;i<next.size();i++){
    now = next[i];
    for(int j=0;j<neighbor[now-1].size();j++){
      sel = neighbor[now-1][j];
      if(d[sel-1]>d[now-1]+1){
        d[sel-1] = d[now-1] + 1;
        sign[sel-1] = now;
        next.push_back(sel);
      }
    }
    if(i>10*n){
      possi = 0;
      break;
    }
  }

  if(possi){
    cout << "Yes" << endl;
    for(int i=1;i<n;i++){
      cout << sign[i] << endl;
    }
  }else{
    cout << "No" << endl;
  }

  /*delete[] a;
  delete[] b;
  delete[] d;
  delete[] sign;*/
  return 0;
}

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

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

using namespace std;

using uint=unsigned int;
using ll=long long;

uint xor128(){
	static uint d[]={1145141919,1919810893,810893364,364114514};
	uint t=d[0]^(d[0]<<11);
	REP(i,3)
		d[i]=d[i+1];
	return d[3]=d[3]^(d[3]>>19)^(t^(t>>8));
}

struct Node{
	Node *l,*r;
	uint pri;
	int s,v,mn;
} buf[200000];

using NP=Node*;

NP newNode(int v){
	static int c=0;
	buf[c]=Node{NULL,NULL,xor128(),1,v,v};
	return &buf[c++];
}

const int inf=1145141919;

inline int Mini(NP x){
	return x?x->mn:inf;
}

inline int Size(NP x){
	return x?x->s:0;
}

inline NP Update(NP x){
	x->s=Size(x->l)+Size(x->r)+1;
	x->mn=min({x->v,Mini(x->l),Mini(x->r)});
	return x;
}

inline NP LinkL(NP x,NP l){
	x->l=l;
	return Update(x);
}

inline NP LinkR(NP x,NP r){
	x->r=r;
	return Update(x);
}

inline NP CutL(NP x){
	x->l=NULL;
	return Update(x);
}

inline NP CutR(NP x){
	x->r=NULL;
	return Update(x);
}

NP Merge(NP a,NP b){
	static pair<NP,bool> pl[128];
	int c=0;
	while(a&&b){
		if(a->pri>b->pri){
			pl[c++]=MP(a,true);
			a=a->r;
		}else{
			pl[c++]=MP(b,false);
			b=b->l;
		}
	}
	NP t=a?a:b;
	while(c){
		NP p=pl[--c].first;
		bool rch=pl[c].second;
		if(rch)
			LinkR(p,t);
		else
			LinkL(p,t);
		t=p;
	}
	return t;
}

using Res=Node;

Res Split(NP x,int k){
	if(k<=0)
		return Res{NULL,x};
	else if(x->s<=k)
		return Res{x,NULL};
	else if(k<=Size(x->l)){
		Res s=Split(x->l,k);
		return Res{s.l,Merge(s.r,CutL(x))};
	}else{
		Res s=Split(x->r,k-Size(x->l)-1);
		return Res{Merge(CutR(x),s.l),s.r};
	}
}

inline void Set(NP x,int k,int v){
	int ls=Size(x->l);
	if(k<ls)
		Set(x->l,k,v);
	else if(k==ls)
		x->v=v;
	else
		Set(x->r,k-ls-1,v);
	Update(x);
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

NP t[200000];

int main(){
	int n=read(),q=read();
	REP(i,n)
		t[i]=newNode(read());
	while(n>1){
		int k=n/2;
		REP(i,k)
			t[i]=Merge(t[i*2],t[i*2+1]);
		if(k*2<n)
			t[k]=t[k*2];
		n=(n+1)/2;
	}
	NP root=t[0];
	REP(_,q){
		int x=read(),y=read(),z=read();
		if(x==0){
			Res s1=Split(root,y);
			Res s2=Split(s1.r,z+1-y-1);
			Res s3=Split(s2.r,1);
			root=Merge(Merge(s1.l,s3.l),Merge(s2.l,s3.r));
		}else if(x==1){
			Res s1=Split(root,y);
			Res s2=Split(s1.r,z+1-y);
			printf("%d\n",Mini(s2.l));
			root=Merge(s1.l,Merge(s2.l,s2.r));
		}else if(x==2){
			Set(root,y,z);
		}
	}
}

Measured memory_bytes: 11008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	sort(v.begin(), v.end());
	double ans = v.at(0);
	for (int i = 1; i < n; i++) {
		ans = (ans + v[i]) / 2;
	}

	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define clr(x) memset(x, 0, sizeof(x))
#define all(a) a.begin(),a.end()
#define forn(i, a,b) for(int i = int(a); i < int(b); ++i)
#define forn_r(i, b, a) for(int i = int(b); i > int(a); i--)
#define trav(a,x) for (auto& a : x)
#define printArray(array, length) for(int i = 0; i < length; i++) cout<< array[i] << (i == length - 1 ? '\n' : ' '); 
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define debug(x) cout << #x << "=" << x << endl
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
template <typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template <typename T> bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }

using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t =1;
    //cin>>t;
    while(t--){
    	int n;
    	cin>>n;
    	string s;
    	cin>>s;
    	int l=0;
    	int ans=0;
    	forn_r(i,n-1,-1){
    		if(s[i]=='R'){
    			while(s[l]!='W'&& l<i){
    				l++;
    			}
    			if(l<i){
    				s[l]='R';
    				s[i]='W';
    				ans++;
    			}
    			
    		}
    		//print(s);
    	}
    	print(ans);
       	 
    }
    return 0;
}

Measured memory_bytes: 3744
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, ll> ipair;
typedef pair<int, int> edge;
typedef tuple<int, int, ll, int> ituple;
const ll INF = LLONG_MAX;

class BellmanFord{
  const static int MAX_VERTEX = 10000;
  const static int MAX_EDGE = 10000;

protected:
  int V, E;
  int from[MAX_EDGE], to[MAX_EDGE];
  ll cost[MAX_EDGE];
  bool isNegativeLoop = false;

public:
  BellmanFord(int v, int e){
    assert(v <= MAX_VERTEX);
    assert(e <= MAX_EDGE);
    V = v;
    E = 0;
  }

  void addEdge(int f, int t, ll c){
    from[E] = f;
    to[E] = t;
    cost[E] = c;
    E++;
  }

  /**
   * 負の閉路がない場合: 各頂点への最短経路
   * 負の閉路がある場合: 空のvector
   */
  vector<ll> shortestPath(int start){
    vector<ll> result(V, INF);
    result[start] = 0;
    int count = 0;

    while (true){
      bool isUpdate = false;
      for (int i = 0; i < E; i++){
        if (result[from[i]] != INF && (result[to[i]] > result[from[i]] + cost[i])){
          result[to[i]] = result[from[i]] + cost[i];
          isUpdate = true;
        }
      }
      if (!isUpdate){
        break;
      }
      count++;
      if (count == V){
        // 負の閉路がある
        isNegativeLoop = true;
        break;
      }
    }
    return result;
  }

  /* 負閉路があるかどうか */
  bool hasNegativeLoop(){
    return isNegativeLoop;
  }

  /**
   * shortestPathの結果を使って負閉路を出す
   */
  vector<bool> findNegativeLoop(vector<ll> result){
    vector<bool> negative(V, false);
    for (int j = 0; j < V; j++){
      for (int i = 0; i < E; i++){
        if (result[from[i]] != INF && (result[to[i]] > result[from[i]] + cost[i])){
          result[to[i]] = result[from[i]] + cost[i];
          negative[to[i]] = true;
        }

        if (negative[from[i]]){
          negative[to[i]] = true;
        }
      }
    }

    return negative;
  }

};


// const int MOD = (int)1e9 + 7;
// const double EPS = 1e-10;
#define PI acosl(-1)
#define MAX_N 2000 + 5
int n, m;
ll a[MAX_N], b[MAX_N], c[MAX_N];

void exec(){
  cin >> n >> m;
  BellmanFord bf = BellmanFord(n, m);
  for (int i = 1; i <= m; i++){
    scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
    bf.addEdge(a[i]-1, b[i]-1, -c[i]);
  }

  vector<ll> result = bf.shortestPath(0);

  if (bf.hasNegativeLoop()){
    vector<bool> negative = bf.findNegativeLoop(result);
    if (negative[n-1]){
      cout << "inf" << endl;
      return;
    }
  }

  cout << -result[n-1] << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 384
import sys
n = int(input())
A = list(map(int,sys.stdin))
cnt = 0
G = [int((2.25**i-1)/1.25)for i in range(17,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print('\n'.join(map(str,A)))


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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	int k,x;
	cin>>k>>x;
	FOR(i,x-k+1,x+k){
		printf("%d ",i);
	}

	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
    #include <string.h>
     
    int main()
    {
      int i,j,k,n,m;
      
      scanf("%d %d",&n,&m);
      
      char a[n];
      
      scanf("%s",a);
      
      a[m-1]=a[m-1]+32;
      printf("%s",a);
      
      return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl <<"\n"
#define con continue
#define br break
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
ll mx=INT_MAX;
ll mi=INT_MIN;
const ll MOD=998244353;
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
#define io { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define cer cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

int main()
{
        io;
        //////////////////////////////////
        ll n,i,j,s=0,p=0,m=0,k,q=0;
        cin>>n>>m>>k;
        vll v(n),dp1(n,0),vv(m),dp2(m,0);
        for(i=0;i<n;i++)cin>>v[i];
        for(i=0;i<m;i++) cin>>vv[i];
        dp1[0]=v[0];
        dp2[0]=vv[0];
        for(i=1;i<n;i++) dp1[i]=dp1[i-1]+v[i];
        for(i=1;i<m;i++) dp2[i]=dp2[i-1]+vv[i];
        for(i=0;i<m;i++)
        {
            if(dp2[i]<=k) s++;
        }
      //  cout<<s nl;
        q=m-1;
        ll c;
        for(i=0;i<n;i++)
        {
             p=dp1[i];
            if(p>k) br;
            c=i+1;
            ll x=0;
            for(j=q;j>=0;j--){
                if(dp2[j]+p<=k){x=1;br;}
            }
            if(x==1){
                c=c+(j+1);
            }
           
            s=max(c,s);
            q=j;
           // cout<<p+dp2[j]<<" "<<q<<" "<<s<<" "<<c nl;
        }
        cout<<s ;
        //////////////////////////////////
        cer;
}


Measured memory_bytes: 9528
from collections import deque
n = int(input())
A = list(map(int,input().split()))

b = deque()
for i,a in enumerate(A):
    if i % 2 == 0:
        b.append(a)
    elif i % 2 == 1:
        b.appendleft(a)

if n % 2 == 1:
    b.reverse()
print(*b)

Measured memory_bytes: 25532
def solve():
    n, l = map(int, input().split())
    t = [l+i for i in range(n)]
    mint = 100
    index = 0
    for i, v in enumerate(t):
        if mint > abs(v):
            mint = min(mint, abs(v))
            index = i
    t.pop(index)
    print(sum(t))




if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    string A,B;
    cin >> A >> B;
    int NA = A.length();
    int NB = B.length();
    string ans = "GREATER";
    if(NA>NB){
    }else if(NB>NA){
        ans = "LESS";
    }else{
        REP(i,NA){
            if(int(A[i])>int(B[i])){
                break;
            }else if(int(B[i])>int(A[i])){
                ans = "LESS";
                break;
            }else{
                ans = "EQUAL";
            }
        }
    }
    cout << ans;

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,lef;
string S;
set<int> E[202020];
int A[202020],B[202020];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>S;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].insert(y-1);
		E[y-1].insert(x-1);
	}
	
	set<int> Q;
	FOR(i,N) {
		FORR(e,E[i]) {
			if(S[e]=='A') A[i]++;
			if(S[e]=='B') B[i]++;
		}
		if(A[i]==0 || B[i]==0) Q.insert(i);
	}
	
	lef=N;
	while(Q.size()) {
		x=*Q.begin();
		Q.erase(Q.begin());
		lef--;
		FORR(e,E[x]) if(e!=x) {
			E[e].erase(x);
			if(S[x]=='A') A[e]--;
			if(S[x]=='B') B[e]--;
			if(A[e]==0 || B[e]==0) Q.insert(e);
		}
	}
	if(lef) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 34512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string s;
int n;

int main()
{
    cin >> n >>s;
    int x = 0;
    int ans = 0;
    for(char c : s)
    {
        if(c == 'I')
        {
            x++;
        }
        else
        {
            x--;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int r;
    cin >> r;
    cout << 3 * r * r << "\n";
}

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

#define MAXN (3010)

int n, a[MAXN];
bool state[MAXN];
std::vector<int> vec[MAXN];

void dfs(int u, int fa){
	for(auto v : vec[u]){
		if(v == fa) continue;
		dfs(v, u);
		if(!state[v] && a[u] > a[v]){
			state[u] = true;
		}
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		scanf("%d", a + i);
	}
	for(int i = 1; i < n; ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	for(int i = 1; i <= n; ++ i){
		memset(state, 0, sizeof state);
		dfs(i, 0);
		if(state[i]){
			printf("%d ", i);
		}
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
  ll p = 0;
  ll win = 0;
  ll ans = 0;
  string S;
  cin >> S;
  iter(c, S) {
    if(c == 'g') {
      if(p) {
        ans++;
        p--;
      } else {
        p++;
      }
    } else {
      if(p) {
        p--;
      } else {
        p++;
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 100010
vll g[M];
ll p[M],lev[M];

int main(){
	IOS;
	tihs;

	ll n,m;cin>>n>>m;
	rep(i,0,m){
		ll u,v;cin>>u>>v;
		u--,v--;
		g[u].pb(v),g[v].pb(u);
	}
	rep(i,0,n)lev[i]=-1,p[i]=i;
	lev[0]=0;
	queue<ll>q;
	q.push(0);
	while(!q.empty()){
		ll u=q.front();q.pop();
		for(auto v:g[u])if(lev[v]==-1)lev[v]=lev[u]+1,p[v]=u,q.push(v);
	}
	cout<<"Yes\n";
	rep(i,1,n)cout<<p[i]+1<<"\n";

	return 0;
}

Measured memory_bytes: 13792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll m[55];
ll C[55][55];
bool cmp(ll x,ll y)
{
    return x>y;
}
void init()
{
    for(int i=1;i<=50;i++){
        C[i][0] = C[0][i] = 1LL*1;
    }

    for(int i=1;i<=50;i++)
    {
        for(int j=1;j<=i;j++)
        {
            C[i][j] = (C[i-1][j] + C[i-1][j-1]);
        }
    }
}
int main()
{
    int n,a;
    double b;
    init();
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&m[i]);
    }
    sort(m+1,m+1+n,cmp);
    ll sum = 0;
    for(int i=1;i<=a;i++)
    {
        sum += m[i];
    }
    double ave = (double)sum/(double)a;
    ll k = m[a];
    ll cnt1 = 0,cnt2 = 0 ;
    for(int i=1;i<=n;i++)
    {
        if(m[i] == k){
            cnt1++;
        }
    }
    for(int i=1;i<=a;i++)
    {
        if(m[i] == k){
            cnt2++;
        }
    }
    ll res = 0;
    if(cnt2 == a){
        for(int i=a;i<=b;i++)
        {
            res += C[cnt1][i];
        }
    }else{
        res += C[cnt1][cnt2];
    }
    printf("%.6lf\n",ave);
    printf("%lld\n",res);
    return 0;
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    // 処理
    int l = a + b;
    int r = c + d;

    // 出力
    if (l < r) {
        cout << "Right" << endl;
    } else if (l > r) {
        cout << "Left" << endl;
    } else {
        cout << "Balanced" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S  = sc.next();
    char[]ss = S.toCharArray();
    
    int cou = 0;
    for(int i=0; i<N-2; i++){
        if(ss[i]=='A' && ss[i+1]=='B' && ss[i+2]=='C'){
            cou++;
        }   
}
	System.out.println(cou);
      }
}

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

int main() {
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    if (W >= V)
    {
        cout << "NO" << endl;
        return 0;
    }
    ll X =(abs(B - A) + V - W - 1) / (V - W);
    if (X <= T)
    {
        cout << "YES" << endl;
    } else
    {
        cout << "NO" << endl;
    }
    
    
    
  return 0;
}


Measured memory_bytes: 3636
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from itertools import accumulate
def resolve():
    N,=pin()
    A1=lispin()
    A2=lispin()
    B1=list(accumulate(A1))
    B2=list(accumulate(A2))
    ans=B1[0]+B2[-1]
    for i in range(1,N):
        ans=max(ans,B1[i]+B2[-1]-B2[i-1])

    print(ans)
        
    
#%%submit!
resolve()

Measured memory_bytes: 38384
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int N,M;
	string S;
	cin>>N>>M>>S;
	reverse(S.begin(),S.end());
	S+="0";

	vector<int> step(1,0);
	int now=0;
	while(now<N){
		bool safe=false;
		for(int next=min(now+M,N); next>now;next--){
			if(S[next]=='0'){
				safe=true;
				now=next;
				step.push_back(now);
				break;
			}
		}
		if(!safe)break;
	}

/*
	cout<<endl<<S<<endl;
	for(auto num:step){
		cout<<num<<" ";
	}
	cout<<endl;
*/

	if(now==N){
		reverse(step.begin(),step.end());
		rep(i,step.size()-1){
			cout<<step[i]-step[i+1]<<" ";
		}
		cout<<endl;
	}
	else{
		cout<<-1<<endl;
	}
	return 0;
}


Measured memory_bytes: 1144
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	vector<ll> x(n), y(n), z(n);
	rep(i, n) cin >> x[i] >> y[i] >> z[i];
	ll ans = -1e18;
	rep(i, 2) rep(j, 2) rep(k, 2){
		//if 0 -> + is good
		//i 1 -> - is good
		vector<ll> v(n);
		rep(l, n){
			v[l] = (x[l] * (!i ? -1 : 1)) + (y[l] * (!j ? -1 : 1)) + (z[l] * (!k ? -1 : 1));
		}
		sort(all(v));
		reverse(all(v));
		ll cur = 0;
		rep(l, m) cur += v[l];
		ans = max(ans, cur);

	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

struct check_bipartite {
    int V;
    vector<vector<int>> adj;
    vector<int> depth;
    vector<bool> visited;

    check_bipartite(int v = -1) {
        if (v >= 0)
            init(v);
    }

    void init(int v) {
        V = v;
        adj.assign(V, {});
        depth.assign(V, -1);
        visited.assign(V, false);
    }

    void add_edge(int a, int b) {
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    pair<int, int> dfs(int node, int parent) {
        assert(!visited[node]);
        depth[node] = parent < 0 ? 0 : depth[parent] + 1;
        visited[node] = true;
        pair<int, int> sizes = {0, 0};

        if (depth[node] % 2 == 0)
            sizes.first++;
        else
            sizes.second++;

        for (int neighbor : adj[node])
            if (neighbor != parent) {
                if (!visited[neighbor]) {
                    pair<int, int> p = dfs(neighbor, node);

                    if (p.first < 0)
                        return {-1, -1};

                    sizes.first += p.first;
                    sizes.second += p.second;
                }

                if (depth[node] % 2 == depth[neighbor] % 2)
                    return {-1, -1};
            }

        return sizes;
    }

    vector<pair<int, int>> solve() {
        vector<pair<int, int>> sizes;

        for (int i = 0; i < V; i++)
            if (!visited[i])
                sizes.push_back(dfs(i, -1));

        return sizes;
    }

    static bool is_valid(const vector<pair<int, int>> &sizes) {
        for (pair<int, int> p : sizes)
            if (p.first < 0)
                return false;

        return true;
    }
};


const int N_MAX = 705;

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

    int N, M;
    cin >> N >> M;
    vector<vector<bool>> adj(N, vector<bool>(N, false));

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        adj[a][b] = adj[b][a] = true;
    }

    check_bipartite solver(N);

    for (int i = 0; i < N; i++)
        for (int j = i + 1; j < N; j++)
            if (!adj[i][j])
                solver.add_edge(i, j);

    vector<pair<int, int>> sizes = solver.solve();

    if (!solver.is_valid(sizes)) {
        cout << -1 << '\n';
        return 0;
    }

    bitset<N_MAX> possible;
    possible[0] = true;

    for (pair<int, int> bi : sizes)
        possible = (possible << bi.first) | (possible << bi.second);

    int best = N * N;

    for (int s = 0; s <= N; s++)
        if (possible[s])
            best = min(best, s * (s - 1) / 2 + (N - s) * (N - s - 1) / 2);

    cout << best << '\n';
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[100001];
ll row[100001];
int main()
{
  vector<pair<ll,ll > >v;
  ll n,m;
  cin>>n>>m;
  for(ll i=0; i<n; i++)
  {
      ll c,mo;
      cin>>mo>>c;
      v.push_back({mo,c});
  }
  sort(v.begin(),v.end());
  long long money=0;
  for(ll i=0; i<v.size(); i++)
  {
      if(m<0)break;
      if(v[i].second>m)
      {
          money+=m*v[i].first;
          m-=m;
      }
      else
      {
          money+=v[i].first*v[i].second;
          m-=v[i].second;
      }
  }
  cout<<money<<endl;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 int n,a[10],b[10],arr[10],ansa=0,ansb=0;

int main()
{ cin>>n;


    ll counter=0;
    for(int i=0;i<n;i++){
        arr[i]=i+1;
        cin>>a[i];
    }
    for(int i=0;i<n;i++){

        cin>>b[i];
    }

do{
        counter++;
        bool asa=true,asb=true;
        for(int i=0;i<n;i++){
            if(arr[i]!=a[i])
            asa=false;
       if(arr[i]!=b[i])
            asb=false;


        }
if(asa)
                ansa=counter;
if(asb)
                ansb=counter;

}while(next_permutation(arr,arr+n));
cout<<abs(ansa-ansb);
    return 0;
}


Measured memory_bytes: 256