akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
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);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct UnionFind {
  vector<int> par; // 親を指すvector,-par[親]は木のサイズ
  UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
  int root(int x) { // 親をたどる&データの整理
    if(par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool unite(int x, int y) { // データの結合
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool same(int x, int y) {return root(x) == root(y);} // 所属判定
  int size(int x) {return -par[root(x)];} // 木のサイズ
};

const int N = 5010;

//head

int n, k;
int p[N];
ll c[N];
UnionFind uft(N);
ll sum[N];
ll ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  rep(i, n) {
    cin >> p[i];
    p[i]--;
  }
  rep(i, n) cin >> c[i];

  rep(i, n) {
    uft.unite(i, p[i]);
  }

  rep(i, n) if(uft.root(i) == i) {
    int now = p[i];
    while(now != i) {
      sum[i] += c[now];
      now = p[now];
    }
    sum[i] += c[i];
  }
  ans = c[0];

  rep(i, n) {
    int now = p[i];
    ll val = 0;
    ll ma = c[now];
    int kk = k;
    if(kk >= uft.size(i)*2) kk = kk%uft.size(i) + uft.size(i);
    rep(j, kk) {
      val += c[now];
      chmax(ma, val);
      now = p[now];
    }
    if(sum[uft.root(i)] > 0) ma += sum[uft.root(i)] * ((k - kk) / uft.size(i));
    chmax(ans, ma);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string S,T;
    cin>>S>>T;
    int L=S.size();
    int ans=0;
    for(int i=0;i<L;i++){
        if(S[i]!=T[i])ans++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, dp[max_n], mod[2], sum[2], pw[2][max_n];
string s;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    dp[0] = 0;
    for (int i = 1; i < max_n; ++i) {
        dp[i] = 1 + dp[i % __builtin_popcount(i)];
    }
    cin >> n >> s;
    int cnt = 0;
    for (char c : s) {
        cnt += c == '1';
    }
    mod[0] = cnt + 1;
    mod[1] = cnt - 1;
    for (int i = 0; i < 2; ++i) {
        if (mod[i] == 0) {
            continue;
        }
        pw[i][0] = 1;
        for (int j = 1; j < max_n; ++j) {
            pw[i][j] = 2LL * pw[i][j - 1] % mod[i];
        }
        for (int j = 0; j < n; ++j) {
            if (s[j] == '1') {
                sum[i] += pw[i][n - 1 - j];
                sum[i] %= mod[i];
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        int ans = 0;
        if (s[i] == '0') {
            ans = 1 + dp[(sum[0] + pw[0][n - 1 - i]) % mod[0]];
        } else if (mod[1]) {
            ans = 1 + dp[(sum[1] + mod[1] - pw[1][n - 1 - i]) % mod[1]];
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 6192
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vi A(N);
  cin >> A;
  int S = 0;
  map<int, int> cnt;
  rep(i, 0, N) {
    S += A[i];
    cnt[A[i]]++;
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int B, C;
    cin >> B >> C;
    int t = cnt[B];
    S -= t * B;
    S += t * C;
    cnt[B] -= t;
    cnt[C] += t;
    cout << S << endl;
  }
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 9976
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int n,t,t1,t2,i;
  long long int res=0;
  cin>>n>>t;

  cin>>t1;
  for(i=1;i<n;i++){
    cin>>t2;
    if((t2-t1)<t) res+=t2-t1;
    else res+=t;
    t1=t2;
  }
  res+=t;
  cout<<res<<endl;
  return 0;
}


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

bool isPrime(long x){
	if(x == 2)
		return true;
	else if((x < 2) || (x % 2 == 0))
		return false;

	int i = 3;
	while(i <= sqrt((double)x)){
		if(x % i == 0)
			return false;
		i += 2;
	}

	return true;
}

int main(){
	int n, count = 0;
	long num;
	vector<long> p;
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>num;
		p.push_back(num);
	}
	
	for(int i=0;i<n;i++)
		if(isPrime(p[i]))
			count++;

	cout<<count<<endl;	
	
	return 0;
}

Measured memory_bytes: 1340
a, b = (int(i) for i in input().split())
s = input()

result = ""
if len(s)!=a + b + 1:
    result = "No"
elif s[a]!="-":
    result = "No"
else:
    for i in range(len(s)):
        if s[i] == "-" and i != a:
            result = "No"
        if s[i] != "-" and int(s[i]) not in range(0, 10):
            result = "No"
    if result !="No":
        result = "Yes"
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n = in(); int N=n;
  int d;
  int i=1;
  while(n>0){
    d = (n%10);
    n /= 10;
    i++;
  }
  int ans = d;
  rep(j,i-2){
    ans *= 10; ans += d;
  }
  if(ans<N){
    d++;
    ans = d;
    rep(j,i-2){
      ans *= 10; ans += d;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();

			String S = scan.next();
			char[] c = new char[N];
			c = S.toCharArray();

			int[]R = new int[N];Arrays.fill(R, 1000000);
			int[]W = new int[N];Arrays.fill(W,1000000);

			int k = 0;
			for(int i = 0;i<N;i++) {
				if(c[i]=='W') {
					W[k] = i;k++;
				}
			}

			int j = 0;
			for(int i = N-1;i>=0;i--) {
				if(c[i]=='R') {
					R[j] = i;j++;
				}
			}

			int count = 0;
			for(int i = 0;i<N;i++) {
				//System.out.println(W[i]+" "+R[i]);
				
				if(W[i]==1000000||R[i]==1000000)break;
				
				if(W[i]<R[i])count++;
				else break;

			}


			System.out.println(count);




		}


	}





}


Measured memory_bytes: 42608
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

void dfs(ll y, ll x, vector< vector<bool> > &used, vector<ll> &X, vector<ll> &Y, vector< vector<ll> > &h) {
  if(used[y][x]) return;
  used[y][x] = true;

  ll dd[5] = { 0, -1, 0, 1, 0 };
  REP(i, 0, 4) {
    ll ny = y + dd[i], nx = x + dd[i + 1];
    if(0 <= ny && ny < Y.size() && 0 <= nx && nx < X.size() && h[y][x] == h[ny][nx]) {
      dfs(ny, nx, used, X, Y, h);
    }
  }
}

int main(void) {
  ll N;
  while(cin >> N, N != 0) {
    vector<ll> L(N), T(N), R(N), B(N), X, Y;
    REP(i, 0, N) {
      cin >> L[i] >> T[i] >> R[i] >> B[i];
      X.push_back(L[i]);
      X.push_back(R[i]);
      Y.push_back(B[i]);
      Y.push_back(T[i]);
    }
    X.push_back(-1);
    X.push_back(1000001);
    Y.push_back(-1);
    Y.push_back(1000001);

    sort(X.begin(), X.end());
    X.erase(unique(X.begin(), X.end()), X.end());
    sort(Y.begin(), Y.end());
    Y.erase(unique(Y.begin(), Y.end()), Y.end());

    REP(i, 0, N) L[i] = lower_bound(X.begin(), X.end(), L[i]) - X.begin();
    REP(i, 0, N) R[i] = lower_bound(X.begin(), X.end(), R[i]) - X.begin();
    REP(i, 0, N) B[i] = lower_bound(Y.begin(), Y.end(), B[i]) - Y.begin();
    REP(i, 0, N) T[i] = lower_bound(Y.begin(), Y.end(), T[i]) - Y.begin();

    vector< vector<ll> > h(Y.size(), vector<ll>(X.size()));
    REP(i, 0, Y.size()) REP(j, 0, X.size()) {
      ll p = 0;
      REP(k, 0, N) if(B[k] <= i && i < T[k] && L[k] <= j && j < R[k]) p = p | (1LL << k);
      h[i][j] = p;
    }

    ll ans = 0;
    vector< vector<bool> > used(Y.size(), vector<bool>(X.size(), false));
    REP(i, 0, Y.size()) REP(j, 0, X.size()) if(!used[i][j]) dfs(i, j, used, X, Y, h), ans++;
    cout << ans << endl;
  }
}


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

#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
long long mod=1000000007;
//int count=INT_MAX;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    while(testcases--){   
        int a;
        cin>>a;
        cout<<(a)+(a*a)+(a*a*a)<<endl;
    }
    
    return 0;
}
 


Measured memory_bytes: 3632
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint mo=1000000007;
template <class typ> struct BIT{
	vector<typ> x;
	BIT(int n):x(n,0){}
	typ sum(int a,int b){
		if(a>b) return 0;
		if(a==0){
			typ s=0;
			for(int i=b;i>=0;i=(i&(i+1))-1){
				s+=x[i];s%=mo;
			}
			return s;
		}
		else return (sum(0,b)-sum(0,a-1)+mo)%mo;
	}
	void add(int ind,typ f){
		for(int i=ind;i<x.size();i|=i+1){
			x[i]+=f;x[i]%=mo;
		}
	}
};
vector<int> le;
lint dp[200100][2][2];
int main()
{
	int n,m,now=0;string s;
	cin>>n>>m;
	cin>>s;s+='X';
	rep(i,m){
		now++;
		if(s[i]!=s[i+1]){
			le.pb(now);now=0;
		}
	}
	if(le.size()==1){
		memset(dp,0,sizeof(dp));
		dp[1][0][0]=dp[1][1][1]=1;
		REP(i,1,n) rep(j,2){
			dp[i+1][0][j]+=dp[i][0][j]+dp[i][1][j];
			dp[i+1][1][j]+=dp[i][0][j];
			dp[i+1][0][j]%=mo;
			dp[i+1][1][j]%=mo;
		}
		cout<<(dp[n][0][0]+dp[n][0][1]+dp[n][1][0])%mo<<endl;
		return 0;
	}
	if(n%2>0){
		cout<<0<<endl;return 0;
	}
	int ma=le[0]/2+1;
	for(int i=0;i<(int)le.size()-1;i+=2){
		if(le[i]%2>0) ma=min(ma,le[i]/2+1);
	}
	//cout<<ma<<endl;
	BIT<lint> bit(n/2+10);
	bit.add(0,1);
	REP(i,1,n/2){
		//cout<<i<<' '<<bit.sum(max(0,i-ma),i-1)<<endl;
		bit.add(i,bit.sum(max(0,i-ma),i-1));
	}
	lint out=0;
	REP(i,1,min(n/2,ma)+1){
		//cout<<i<<endl;
		out+=bit.sum(n/2-i,n/2-i)*i*2;out%=mo;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    int ans = 1000000000;
    for (int k = -100; k <= 100; k++){
        int cur = 0;
        for (int i = 0; i < n; i++){
            cur += (a[i]-k)*(a[i]-k);
        }
        ans = min(ans,cur);
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
import Control.Monad
import Data.List

solveSub [x] = [x]
solveSub (x:xs)
    | x0 > y0 = y:x:ys
    | x0 == y0 && x1 <= y1 = y:x:ys
    | x0 == y0 && x1 > y1 = x:y:ys
    | otherwise = x:y:ys
    where
        (y:ys) = solveSub xs
        x0 = (fst x)!!0
        y0 = (fst y)!!0
        x1 = read ((fst x)!!1) :: Int
        y1 = read ((fst y)!!1) :: Int

solve [] = []
solve xs = y : solve ys
    where
        (y:ys) = solveSub xs

main = do
    n <- readLn :: IO Int
    spn <- replicateM n (words <$> getLine)
    putStr $ unlines $ map (show.snd) $ solve $ zip spn [1..n]


Measured memory_bytes: 4964
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	string s;
	cin>>s;
	if(s.find('7')!=string::npos){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
}


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

const int Nmax=200010;

int main() {
	string A;
	cin >> A;
	ll S[26]={};
	ll l=A.length();
	ll ans=(l*(l-1))/2+1;
	for(int i=0;i < l;i++)
		S[A[i]-'a']++;
	
	for(int i=0;i < 26;i++)
		ans -= S[i]*(S[i]-1)/2;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int cnt[4];
int cnt2[5];


int main() {
	for (int k = 0; k < 3; k++)
	{
		int a,b;cin>>a>>b;
		a--;
		b--;
		cnt[a]++;
		cnt[b]++;
	}
	for(int i=0;i<4;i++)cnt2[cnt[i]]++;

	if(cnt2[1] == 2 && cnt2[2] == 2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
s = input()

n = len(s)

power = [0]*(n+1)
power[-1] = 1
x = 1

for i in range(n-1,-1,-1):
	x = (x*10) % 2019
	power[i] = x
	
mod19 = [0]*(n+1)

cnt = [0]*2020

x=0
for i in range(n, 0,-1):
	x = (x+int(s[i-1])*power[i])%2019
	mod19[i] = x
	cnt[x]+=1
	
# ~ print(power)
# ~ print(mod19)
	
ans = 0

for i in range(2020):
	x = cnt[i]
	ans+= x*(x-1)//2
	# ~ if x>0: print(i, x)

	
print(ans+cnt[0])




Measured memory_bytes: 23480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int n,k,ans = 0;
		String str;
		String[] s;
		str = bf.readLine();
		s = str.split(" ");
		n = Integer.parseInt(s[0]);
		k = Integer.parseInt(s[1]);
		str = bf.readLine();
		s = str.split(" ");
		for(int i = 0;i < n;++i) {
			if(k <= Integer.parseInt(s[i])) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 31216
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
half=n//2
lst=[]
tmp=0
if n%2==0:
    tmp=1
for i in range(m):
    if i%2==1:
        lst.append([half-i//2,half+i//2+2])
    else:
        lst.append([1+i//2,n-i//2])

for i in range(m):
    print(*lst[i])

# dic=defaultdict(int)
# for i in range(m):
#     tmp=lst[i]
#     dic[tmp[1]-tmp[0]]+=1
#     dic[n-tmp[1]+tmp[0]]+=1
# print(dic)

Measured memory_bytes: 81416
#include <stdio.h>

int main(void) {
   int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);

    int x;
        if(a<b)
       x=a;
       else
       x=b;
    int y;
    if(c<d)
       y=c;
       else
       y=d;

      int ans=x+y;
      printf("%d\n",ans);
           










  return 0;
}

Measured memory_bytes: 128
import sys
A1 = list(map(int, sys.stdin.readline().split()))
A2 = list(map(int, sys.stdin.readline().split()))
A3 = list(map(int, sys.stdin.readline().split()))
N = int(sys.stdin.readline())
b = [int(sys.stdin.readline()) for _ in range(N)]
A = A1 + A2 + A3
i = 0
while i <= 8:
  if b.count(A[i]):
    A[i] = 101
  i += 1
bingoFlag = False
k = 0
while k <= 2:
  if A[k] == A[k+3] == A[k+6] or A[k*3] == A[k*3 + 1] == A[k*3 + 2]:
    bingoFlag = True
    break
  k += 1
if A[0] == A[4] == A[8] or A[2] == A[4] == A[6]:
  bingoFlag = True
if bingoFlag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        double x[] = new double[100];
        double y[] = new double[100];
        double p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
 
        int N = scanner.nextInt();
 
        for(int i = 0; i < N; i++)x[i] = scanner.nextDouble();
        for(int i = 0; i < N; i++)y[i] = scanner.nextDouble();
 
        for(int i = 0; i < N; i++){
            p_1 += Math.abs(x[i]-y[i]);
            p_2 += (x[i]-y[i])*(x[i]-y[i]);
            p_3 += Math.abs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
            p_infinity = Math.max(p_infinity, Math.abs(x[i]-y[i]));
        }
 
        System.out.printf("%.10f\n", p_1);
        System.out.printf("%.10f\n", Math.sqrt(p_2));
        System.out.printf("%.10f\n", Math.cbrt(p_3));
        System.out.printf("%.10f\n", p_infinity);
    }
}


Measured memory_bytes: 29156
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = sorted(enumerate(A), key=lambda x: x[1])
B = sorted(enumerate(B), key=lambda x: x[1])

flag = False
for i in range(N):
  if A[i][1] > B[i][1]:
    print('No')
    break
  elif i > 0 and A[i][1] <= B[i-1][1]:
    flag = True
else:
  if flag:
    print('Yes')
  else:
    D = dict((a[0], b[0]) for a, b in zip(A, B))
    count = 0
    x = D[0]
    while x != 0:
      x = D[x]
      count += 1
    print('Yes' if count < N-1 else 'No')


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

int main(){
  int n,m,t;cin>>n>>m;
  vector<long long> dp(n+1,0);
  dp[0]=1;
  dp[1]=1;
  REP(i,m){
    cin>>t;
    dp[t]=-1;
  }
    
  for(int i=2;i<=n;i++){
    if(dp[i]!=-1){
      if(dp[i-1]!=-1) dp[i]+=dp[i-1];
      if(dp[i-2]!=-1) dp[i]=(dp[i]+dp[i-2])%MOD;
    }
  }
  cout<<dp[n];
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
		int i,x,n,max,min;
		long long sum;
		scanf("%d",&n);
		max=-99999999;
		min=99999999;
		sum=0;
		for(i=0;i<n;i++) {
			scanf("%d",&x);
			sum+=x;
			if(x>max) {
				max=x;
			}
			if(x<min) {
				min=x;
			}
		}
		printf("%d %d %lld\n",min,max,sum);
		return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
typedef vector<vector<Weight>> Graph;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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

	ll n, d;
  cin >> n >> d;
	//vector<ll> a(n); 
	int cnt = 0;
	rep(i,n) {ll a,b;cin >> a >> b; if (a*a + b*b <= d*d) cnt++; }

	cout << cnt << endl;

}


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

int main() {
  int n;
  cin >> n;
  bool ok = false;
  vector<long long> a(n), b(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  for(int i = 0; i < n; i++) cin >> b.at(i);
  
  long long dis = 0, cnt = 0;
  for(int i = 0; i < n; i++){
    dis += b.at(i) - a.at(i);
    if(a.at(i) > b.at(i)) continue;
    cnt += (b.at(i) - a.at(i) + 1) / 2;
  }
  
  if(dis >= cnt) ok = true;
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3780
#include<stdio.h>
int main(){
    int a,b,c,h;
    h=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        h=b;
        b=a;
        a=h;
    }
    if(b>c){
        h=c;
        c=b;
        b=h;
    }
    if(a>b){
        h=b;
        b=a;
        a=h;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  char a, b;
  in2(a, b);
  if(a == b)
    out('=');
  else if(a < b)
    out('<');
  else
    out('>');
  memi;
}

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

#define MAX_N 100000
int c[MAX_N];
bool IsPrime[MAX_N + 1];

void get_primes() {
  IsPrime[0] = false; IsPrime[1] = false;

  for (int i = 2; i < MAX_N; i++) {
    for (int j = 2; j*j <= i; j++) {
      if (i % j == 0) { IsPrime[i] = false; }
    }
  }
}

int main() {
  memset(IsPrime, 1, sizeof(IsPrime));
  get_primes();

  memset(c, 0, sizeof(c));
  for (int i = 3; i <= MAX_N; i+=2) {
    if (IsPrime[i] && IsPrime[(i+1)/2]) {
      c[i]++;
    }
  }
  for (int i = 3; i <= MAX_N; i++) {
    c[i] += c[i - 1];
  }

  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int L, R;
    cin >> L >> R;
    cout << c[R] - c[L -1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] g = new int[4];
		int[][] map;
		int min = 10000000;
		int count = 0;
		int xa = 0;
		int xb = 0;
		int xc = 0;
		int xd = 0;
		int ya = 0;
		int yb = 0;
		int yc = 0;
		int yd = 0;
		for(int i=0;i<4;i++) g[i] = sc.nextInt();
		for(int i=1;i<=n;i++){
			map = new int[n][n];
			count = 1;
			for(int j=0;j<=n-i;j++){
				for(int k=0;k<i;k++){
					map[j][k] = count;
					if(count==g[0]){
						xa = k;
						ya = j;
					}else if(count==g[1]){
						xb = k;
						yb = j;
					}else if(count==g[2]){
						xc = k;
						yc = j;
					}else if(count==g[3]){
						xd = k;
						yd = j;
					}
					count++;
				}
			}
			
			min = Math.min(min, Math.abs(xb-xa)+Math.abs(xd-xc)+Math.abs(yb-ya)+Math.abs(yd-yc));

		}
		System.out.println(min);
	}	
}

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

int main() {
  int k, ans = 0;
  cin >> k;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount.append(0)

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])-1
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penalties += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
	ll n;
	cin>>n;
	ll a[10010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll p[1000010]={};
	for(ll i=2;i<=1000000;i++){
		if(p[i]!=0){
			continue;
		}
		ll j=2;
		while(i*j<=1000000){
			if(p[i*j]==0){
			p[i*j]=i;
			}
			j++;
		}
	}
	map<ll,ll>ch;
	for(ll i=0;i<n;i++){
		ll now=a[i];
		map<ll,ll>cnt;
		while(p[now]!=0){
			cnt[p[now]]++;
			now/=p[now];
		}
		if(now!=1){
			cnt[now]++;
		}
		for(auto itr=cnt.begin();itr!=cnt.end();itr++){
			ll num=itr->first;
			ll val=itr->second;
			ch[num]=max(ch[num],cnt[num]);
		}
	}
	ll lcm=1;
	for(auto itr=ch.begin();itr!=ch.end();itr++){
		ll num=itr->first;
		ll val=itr->second;
		lcm*=modpow(num, val, 1000000007);		
		lcm%=inf;
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now=a[i];
    // a を 10000000007 で割ってから b の逆元をかけて計算
        ans+= lcm * modinv(now, inf) % inf ;
        ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 12112
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int N, i;
	cin >> N >> i;
	cout << N - i + 1 << endl;
}

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

int main() {
  ll n;
  cin >> n;
  ll ans = 1e18;
  for (ll i = 1; i*i <= n; ++i) {
    if (n%i != 0) continue;
    ll j = n/i;
    ans = min(ans, i+j-2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 100000;
int main()
{
    int W, H;
    while(cin >> W >> H, W || H) {
        int dp[105][105][2][2] = {};
        dp[0][0][0][0] = dp[0][0][1][0] = 1;
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if(i < H - 1) {
                    (dp[i + 1][j][0][0] += dp[i][j][1][1]) %= mod;
                    (dp[i + 1][j][0][1] += dp[i][j][0][0] + dp[i][j][0][1]) %= mod;
                }
                if(j < W - 1) {
                    (dp[i][j + 1][1][0] += dp[i][j][0][1]) %= mod;
                    (dp[i][j + 1][1][1] += dp[i][j][1][0] + dp[i][j][1][1]) %= mod;
                }
            }
        }
        int (*p)[2] = dp[H - 1][W - 1];
        cout << (p[0][0] + p[0][1] + p[1][0] + p[1][1]) % mod << endl;
    }
    return (0);
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  if(s[0] != '1' || s[n - 1] != '0') ok = false;
  rep(i, n / 2) if(s[i] != s[n - 2 - i]) ok = false;
  if(!ok) {
    cout << -1 << endl;
    return 0;
  }
  rep2(i, n / 2 + 1, n) s[i] = '0';
  reverse(all(s));
  vector<vector<int>> g(n);
  int u = 0, v = 0;
  rep2(i, 1, n) {
    v++;
    g[u].push_back(v);
    if(s[i] == '1') u = v;
  }
  set<P> st;
  rep(i, n) for(auto v : g[i]) st.insert({min(i, v), max(i, v)});
  for(auto p : st) cout << p.first + 1 << ' ' << p.second + 1 << '\n';
}

Measured memory_bytes: 12108
s, t = [0] * 2

def format_input(filename = None):
	global s, t
	if filename == None:
		s = str(input())
		t = str(input())

	elif filename == '__random__':
		from random import randint as rng
		from random import choices
		s = ''.join(choices('abcdefghijklmnopqrstuvwxyz', k = rng(1, 10)))
		t = ''.join(choices('abcdefghijklmnopqrstuvwxyz', k = len(s) + 1))
		print(s)
		print(t)

def get_answer():
	answer = 'No'

	if s == t[:-1]:
		answer = 'Yes'

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 9084
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut evidences: Vec<Vec<isize>> = Vec::new();
    for _i in 0..n {
        let mut evidence: Vec<isize> = vec![-1; n];

        let a: usize = iterator.next().unwrap().parse().unwrap();
        for _j in 0..a {
            let x: usize = iterator.next().unwrap().parse().unwrap();
            let y: isize = iterator.next().unwrap().parse().unwrap();

            evidence[x - 1] = y;
        }

        evidences.push(evidence)
    }

    let mut ans: usize = 0;

    let m: usize = 2_usize.pow(n as u32);
    for i in 0..m {
        let mut valid = true;

        let vec = binary_vec(i, n);
        for j in 0..n {
            if vec[j] != 1 {
                continue;
            }
            for k in 0..n {
                if evidences[j][k] == -1 {
                    continue;
                }
                if evidences[j][k] != vec[k] {
                    valid = false;
                    break;
                }
            }
        }

        if valid {
            ans = max(ans, count(vec))
        }
    }

    return ans.to_string();
}

fn binary_vec(i: usize, len: usize) -> Vec<isize> {
    let binary_str = format!("{:0>1$b}", i, len);
    let result: Vec<isize> = binary_str.chars().map(|c| if c == '0' { 0 } else { 1 }).collect();
    return result;
}

fn count(vec: Vec<isize>) -> usize {
    let mut result = 0;
    for i in vec.iter() {
        if i == &1 {
            result += 1;
        }
    }
    return result;
}

#[test]
fn test() {
    assert_eq!(
        solve(
            r"3
1
2 1
1
1 1
1
2 0"
        ),
        "2"
    );
    assert_eq!(
        solve(
            r"3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0"
        ),
        "0"
    );
    assert_eq!(
        solve(
            r"2
1
2 0
1
1 0"
        ),
        "1"
    );
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> a(n);
    map<ll, ll> mp;
    REP(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    if(mp.size() == 1) {
        if(mp.find(0) != mp.end()) {
            cout << "Yes" << en;
            return;
        }
    } else if(n % 3 == 0) {
        if(mp.size() == 2) {
            if(mp[0] == n / 3) {
                cout << "Yes" << en;
                return;
            }
        } else if(mp.size() == 3) {
            auto it = mp.begin();
            auto a = *it;
            it++;
            auto b = *it;
            it++;
            auto c = *it;
            if((a.first ^ b.first) == c.first and a.second == b.second and a.second == c.second) {
                cout << "Yes" << en;
                return;
            }
        }
    }

    cout << "No" << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    int rev = 0;

    vector<char> first;
    vector<char> last;
    rep(i, q){
        int t; cin >> t;
        if (t == 1){
            rev ^= 1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1){
                if (rev) last.push_back(c);
                else first.push_back(c);
            } else {
                if (!rev) last.push_back(c);
                else first.push_back(c);
            }
        }
    }

    if (!rev){
        rep(i, first.size()) cout << first[first.size()-1-i];
        cout << s;
        rep(i, last.size()) cout << last[i];        
    } else {
        rep(i, last.size()) cout << last[last.size()-1-i];
        reverse(s.begin(), s.end());
        cout << s;
        rep(i, first.size()) cout << first[i];        
    }
    cout << endl;

}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int N, count = 0;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; i++) cin >> p[i];
    for(int i = 1; i < N-1; i++){
        if((p[i-1] < p[i]) && (p[i] < p[i+1]) ){
            count++;
        }
        else if((p[i-1] > p[i]) && (p[i] > p[i+1])){
            count++;
        }
    }
    cout << count << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){

    ll N,K;
    cin >> N >> K;
    vector<ll> V(N),bit(50);
    rep(i,0,N)cin >> V[i];
    
    //cout << endl;
    rep(i,0,50){
        rep(j,0,N){
            if((1LL << i) & V[j])bit[i]++;
        }
    }
    ll maxi = 0;
    while(K >= 0){

        ll x = 0;
        rep(i,0,50){
            if( ((1LL << i) & K) && bit[i] * 2 < N)x += 1LL << i;
        }
        ll ans = 0;
        rep(i,0,N)ans += V[i] ^ x;
        //cout << x << endl;
        //cout << ans << endl;
        maxi = max(maxi, ans);
        bool flag = false;
        int idx;
        rep(i,0,50){
            if(flag && ((1LL << i) & K) ) {
                idx = i;
                break;
            }
            if(( (1LL << i) & K) == 0)flag = true;
        }
        ll mask = ((1LL << 50) - 1) - ((1LL << (idx)) - 1);
        //cout << bitset<50>(K) << endl;
        K = (K & mask) - 1;
        //cout << bitset<50>(mask) << endl;
        //cout << bitset<50>(K) << endl;
        //cout << K << endl;
    }
    cout << maxi << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

#define Pi 3.14159265                   

int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   
   ll sum = 0;
   rep(m)
   {
       ll a;
       cin>>a;
       sum+=a;
   }
   if(sum>n)
        cout<<-1;
   else cout<<n-sum;        
   
   return 0;        
}  
  
   

Measured memory_bytes: 3640
//
//  abc149_d.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

std::vector<int> permutations;

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

int main() {
  int n, k;
  ll pt[3];
  std::cin >> n >> k;
  std::cin >> pt[0] >> pt[2] >> pt[1];

  string t;
  std::cin >> t;
  std::map<char, ll> m;
  int hands[n];
  m['r'] = 0;
  m['p'] = 1;
  m['s'] = 2;

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int win = (m[t[i]] + 1) % 3;
    int cur_hand = win;
    if (i-k >= 0) {
      int last_hand = hands[i-k];
      if (cur_hand == last_hand) {
        cur_hand = (cur_hand + 1) % 3;
        if (i+k < n) {
          int next_win = (m[t[i+k]] + 1) % 3;
          if (cur_hand == next_win) cur_hand = (cur_hand + 1) % 3;
        }
      }
    }
    // std::cout << cur_hand;
    if (cur_hand == win) ans += pt[win];

    hands[i] = cur_hand;
  }
  std::cout << std::endl;
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N=in(); vi A(N);
  rep(i,N) cin >> A[i];
  sort(all(A));
  int i=0; int j=N-1;
  vector<pii> ret;

  int Q=0; // num negatives
  rep(i,N){
    if(A[i]<0) Q++;
  }
  Q = min(max(Q,1),N-1);
  rep(i,Q,N-1){
    ret.pb({A[0],A[i]});
    A[0] -= A[i];
  }
  rep(i,1,Q){
    ret.pb({A[N-1],A[i]});
    A[N-1] -= A[i];
  }
  ret.pb({A[N-1],A[0]});
  cout << A[N-1]-A[0] << endl;
  for(auto x : ret){
    cout << x.first << " " << x.second << endl;
  }

  return 0;
}


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

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

    char *S = (char *) malloc(sizeof(char) * (N + 1));

    scanf("%s", S);

    int i;

    char prev = S[0];
    int sum = 0;

    for(i = 1; i < N; i ++){
        if(S[i] == prev){
            sum ++;
        }
        prev = S[i];
    }
    sum += 2 * K;

    if(sum > N - 1){
        sum = N - 1;
    }
    printf("%d\n", sum);
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))

l = 0
r = 0
tmp = float('inf')
ans = 0
while l < N and r < N:
    tmp = L[l]
    while r < N and L[r] <= tmp:
        tmp = L[r]
        r += 1
    if r == N:
        ans = max(ans, r-l)
    else:
        ans = max(ans, r-l)
        l = r
        r = l
print(ans-1)


Measured memory_bytes: 59632
#include <stdio.h>

int main(void) {
	int n;
	int a[101] = {0};
	int i;
	scanf("%d",&n);

	for (i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < n; ++i) {
		printf("%d", a[n-i-1]);
		if (i != n-1) {
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	double t,ans=0;
	int n,k,i,now;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		t=1.0/n;now=i;
		while(now<k){
			now*=2;t/=2;
		}
		ans+=t;
	}
	printf("%.12lf",ans);
	return 0;
 } 

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;
vector<pair<int,int>> E[101010];
ll D[101010];

void dfs(int cur,int pre,int d) {
	D[cur]=d;
	FORR(e,E[cur]) if(e.first!=pre) dfs(e.first,cur,d^e.second);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y>>r;
		E[x-1].push_back({y-1,r%2});
		E[y-1].push_back({x-1,r%2});
	}
	dfs(0,0,0);
	FOR(i,N) cout<<D[i]%2<<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: 8832