akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define endl "\n"
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}

template<typename Head, typename... Tail>
struct vector_demensions
{
	using type=vector<typename vector_demensions<Tail...>::type>;
};

template<typename Head>
struct vector_demensions<Head> { using type=Head; };

template<typename T>
vector<T> make_vectors(int size, T val)
{
	return vector<T>(size, val);
}

template<typename T=int, typename... Args>
auto make_vectors(int size, Args... tail)
	-> typename vector_demensions<Args..., T>::type
{
	auto val=make_vectors<T>(forward<Args>(tail)...);
	return vector<decltype(val)>(size, val);
}



int main()
{
	int n;
	cin>>n;
	auto a(read<LL>(n));
	VLL s(n+1);
	REP(i,n)
		s[i+1]=s[i]+a[i];
	sort(ALL(s));
	//print(s);
	LL ans=0;
	LL seq=1;
	REP(i,n)
	{
		if(s[i]==s[i+1])
		{
			seq++;
		}
		else
		{
			ans+=seq*(seq-1)/2;
			seq=1;
		}
	}
	ans+=seq*(seq-1)/2;
	print(ans);
}


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

using namespace std;

queue<vector<int>> que;

void solve(vector<int> vec){

}


int main(void)
{
    int N,M,tmp;
    long long sum=0,ans;
    vector<int> T,P,X;

    cin>>N;
    for(int i=0;i<N;i++){
        cin>>tmp;
        T.push_back(tmp);

        sum+=tmp;
    }
    
    cin>>M;
    for(int i=0;i<M;i++){
        cin>>tmp;
        P.push_back(tmp);

        cin>>tmp;
        X.push_back(tmp);
    }

    for(int i=0;i<M;i++){
        ans = sum;
        ans=ans-T[P[i]-1];
        ans=ans+X[i];

        cout<<ans<<endl;
    }





 
	return 0;
}


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

int main(){
    int k,s;
    cin >> k >> s;
    int cnt = 0;
    for(int x = 0; x <=k; x++){
        for(int y = 0; y <= k; y++){
            int z = s-x-y;
            if(z<0 || z > k)continue;
            if(x+y+z==s){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define MOD 1000000007
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define dforn(a, n) for(int a = (n)-1; a>=0; --a)
#define forall(a, all) for(__typeof(all.begin()) a = all.begin(); a != all.end(); ++a)
#define EPS 0.000000000001
typedef long long tint;
using namespace std;

int main()
{
	int n;
	cin >> n;
	cout << 48-n << endl;
	return 0;
}


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

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int a = 0, b = 0, c = 0, d = 0, r, f = 0;
	REP(i, 6) {
		scanf("%d", &r);
		if (r == 1)a++;
		if (r == 2)b++;
		if (r == 3)c++;
		if (r == 4)d++;
	}
	if (a % 2 + b % 2 + c % 2 + d % 2 == 2)f = 1;
	YES(f);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[3][3];
int main()
{
	for(int i=0;i<3;i++)
	{
		for(int c=0;c<3;c++)
		{
			cin>>a[i][c];
		}
	}
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int b;
		cin>>b;
		for(int i=0;i<3;i++)
		{
			for(int c=0;c<3;c++)
			{
				if(a[i][c]==b)
				{
					a[i][c]=0;
				}
			}
		}
	}
	for(int i=0;i<3;i++)
	{
		if((a[i][0]==0)&&(a[i][1]==0)&&(a[i][2]==0))
		{
			cout<<"Yes";
			return 0;
		}
		if((a[0][i]==0)&&(a[1][i]==0)&&(a[2][i]==0))
		{
			cout<<"Yes";
			return 0;
		}
	}
	if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0)
	{
		cout<<"Yes";
		return 0;
	}
	if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  string S,T;
  cin >> S >> T;

  if (S.size() < T.size()) {
    cout << "UNRESTORABLE"<< endl;
    return 0;
  }

  string ans;

  for (int i = 0; i <= S.size() - T.size(); ++i) {
    string s = S;
    bool flag = true;
    for (int j = 0; j < T.size(); ++j) {
      if (S[i+j] != '?' && S[i+j] != T[j]) {
        flag = false;
        break;
      }
      s[i+j] = T[j];
    }

    if (flag) {
      for (int j = 0; j < s.size(); ++j) {
        if (s[j] == '?') s[j] = 'a';
      }
      if (ans.empty()) ans = s;
      chmin(ans, s);
    }
  }

  if (ans.empty())
    cout << "UNRESTORABLE" << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <cstdio>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
    int x[100], n;
    bool swap_flag = true;
    int count = 0;

    // ????´???°??¨??°????????\???
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++){
        scanf("%d", &x[i]);
    }

    // ??????????????????
    while(swap_flag){
        swap_flag = false;
        for(int i=n-1 ; i>0 ; i--){
            if(x[i-1] > x[i]){
                swap(x[i-1], x[i]);
                swap_flag = true;
                count++;
            }
        }
    }

    for(int i=0 ; i<n-1 ; i++){
        printf("%d ", x[i]);
    }
    printf("%d\n", x[n-1]);
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 2672
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    string s;
    int i, n;

    cin >> s;

    n = s.size();

    for(i=0; i<n; i++){
        if(s[i] == ','){
            cout <<  " ";
        }
        else{
            cout << s[i];
        }
    }

    cout << endl;

    return 0;
}

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

int main(void){
    int n;
    string ans;

    cin >> n;

    int l[n];
    int max = 0;
    int max_i;
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> l[i];
        sum += l[i];
        if(max < l[i]){
            max = l[i];
            max_i = i;
        }
    }

    if(2 * l[max_i] < sum){
        ans = "Yes";
    }else{
        ans = "No";
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int m[100][100];
	int a, b; cin >> a >> b;
	if (a > b) {
		rep(i, 100) {
			rep(j, 100) {
				m[i][j] = 1;
			}
		}
		rep(i, a) {
			int x = i / 25; int y = i % 25; x *= 4; y *= 4;
			m[x][y] = 0;
			if (i < b-1) {
				m[x + 1][y] = m[x + 2][y] = m[x + 2][y + 1] = m[x + 2][y + 2] = m[x + 1][y + 2] = m[x][y + 2] = m[x][y + 1] = 0;
			}
		}
	}
	else {
		rep(i, 100) {
			rep(j, 100) {
				m[i][j] = 0;
			}
		}
		rep(i, b) {
			int x = i / 25; int y = i % 25; x *= 4; y *= 4;
			m[x][y] = 1;
			if (i < a-1) {
				m[x + 1][y] = m[x + 2][y] = m[x + 2][y + 1] = m[x + 2][y + 2] = m[x + 1][y + 2] = m[x][y + 2] = m[x][y + 1] = 1;
			}
		}
	}
	cout << "100 100" << endl;
	rep(i, 100) {
		rep(j, 100) {
			if (m[i][j])cout << "#";
			else cout << ".";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V

main :: IO ()
main = readLine >>= main'
    where
        main' nq = getLine >>= main'' nq
        main'' [n, q] s = readContents q >>= printRes . solve n s
        printRes = mapM_ print 

solve :: Int -> String -> [[Int]] -> [Int]
solve n s = map answer
    where
        vs = V.fromList $ 0 : build 0 s

        build acc (x : y : zs)
            | x == 'A' && y == 'C' = acc : (acc + 1) : build (acc + 1) zs
            | otherwise = acc : build acc (y : zs)
        build _ [] = []
        build acc _ = [acc]

        answer [l, r] = vs V.! r - vs V.! l


readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 37500
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>

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

using namespace std;

void printv(vector<int> vi)
{
    rep(i,vi.size()) {
        cout << vi[i] << " ";
    }
    cout << endl;
}

short data[5002][5002];

int main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    vector<int> x, y;
    vector<int> ux, uy;

    int n, m;

    cin >> n >> m;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        x.push_back(a);
        y.push_back(b);
    }
    ux = x;
    uy = y;
    ux.push_back(INT_MAX);
    ux.push_back(INT_MIN);
    uy.push_back(INT_MAX);
    uy.push_back(INT_MIN);

    //printv(ux);
    //printv(uy);

    sort(ux.begin(), ux.end());
    sort(uy.begin(), uy.end());

    //printv(ux);
    //printv(uy);

    ux.erase(unique(ux.begin(), ux.end()), ux.end());
    uy.erase(unique(uy.begin(), uy.end()), uy.end());

    //printv(ux);
    //printv(uy);

    rep(i,n) {
        x[i] = lower_bound(ux.begin(), ux.end(), x[i]) - ux.begin();
        y[i] = lower_bound(uy.begin(), uy.end(), y[i]) - uy.begin();
        data[y[i]][x[i]]++;
    }

    //printv(x);
    //printv(y);

    for (int i=0; i<5002; i++) {
        for (int j=1; j<5002; j++) {
            data[i][j] += data[i][j-1];
        }
    }

    for (int i=1; i<5002; i++) {
        for (int j=0; j<5002; j++) {
            data[i][j] += data[i-1][j];
        }
    }

    rep(i,m) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a = lower_bound(ux.begin(), ux.end(), a) - ux.begin();
        b = lower_bound(uy.begin(), uy.end(), b) - uy.begin();
        c = upper_bound(ux.begin(), ux.end(), c) - ux.begin() - 1;
        d = upper_bound(uy.begin(), uy.end(), d) - uy.begin() - 1;
        int ans = data[d][c] - data[d][a-1] - data[b-1][c] + data[b-1][a-1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 52120
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, d;
	while(cin >> n >> d) {
		int ans = 0;
		ans = (n + 2 * d) / (2 * d + 1);
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;

double dp[2002][2002];

int main()
{
  int N, T;
  while(cin >> N >> T, N || T) {
    string ring; cin >> ring;

    reverse(ring.begin(), ring.end());

    memset(dp, 0.0, sizeof(dp));
    for(int i = 0; i < N; i++) {
      if(ring[i] == 'R') dp[0][i] = 1.0;
    }

    for(int i = 0; i < T; i++) {
      for(int j = 0; j < N; j++) {
	for(int k = 1; k <= 6; k++) {
	  dp[i+1][(j+k)%N] += dp[i][j] / 6;
	}
      }
    }

    double ans = 0.0;
    for(int i = 0; i < N; i++) ans = max(ans, dp[T][i]);

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

Measured memory_bytes: 34424
#include<iostream>
using namespace std;
int main()
{
	long long int n,d;
	cin>>n>>d;
	d=d*d;
	int ans=0;
	while(n--)
	{
		long long int x,y;
		cin>>x>>y;
		long long int D=abs(x*x)+abs(y*y);
		//cout<<D<<endl;
		if(D<=d)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;

int main()
{
    ll x,y,z;

    cin>>x>>y>>z;

    ll temp;

    temp=x;
    x=z;
    z=y;
    y=temp;

    cout<<x<<" "<<y<<" "<<z<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;

void solve(){

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

    string s;
    cin >> s;
    int l=s.size();

    if (l%2==0){
        for(int i=0;i<s.size()/2;i++){
            int a= 2*i;
            cout << s[a];
        }   

    }
    else{
        for(int i=0;i<=s.size()/2;i++){
            int a= 2*i;
            cout << s[a];
        }
    }


    return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main()
{
	long long i, j=0, k, K;
	string S;

	cin >> S; cin >>K;

	for (i = 0; i < K; i++) {
		if (S[i] == '1')j++;
		else {
			k = i;
			break;
		}
	}

	if (j >= K)
		cout << 1 << endl;
	else
		cout << S[k] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] c = new int[m];
		for(int i = 0; i < m; i++) {
			c[i] = sc.nextInt();
		}
		int[] dp = new int[n + 1];
		for(int i = 0; i <= n; i++) {
			dp[i] = i;
		}
		for(int i = 0; i < m; i++) {
			for(int j = 0; j <= n; j++) {
				if(j - c[i] >= 0) {
					dp[j] = Math.min(dp[j], dp[j - c[i]] + 1);
				}
			}
		}
		System.out.println(dp[n]);
	}
}




Measured memory_bytes: 26820
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

a=int(arr_data[0][0])
b=int(arr_data[0][1])


print((a-1) * (b-1))


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int r, g;
    cin >> r >> g;
    cout << 2*g - r << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int main(void) {
    int i, n, ary[MAX];
    for(scanf("%d", &n), i = ~-n; ~i; scanf("%d", &ary[i--]));
    for(i = 0; i < n; printf("%d%s", ary[i++], -~i - n ? " " : "\n"));
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

int a[100010];
constexpr int64_t MOD=1e9+7;

int main() {
    int n,m;
    cin>>n>>m;
    int x;
    for(int i=0;i<m;++i)cin>>x,a[x]=1;
    int64_t s=0,t=1;
    for(int i=1;i<=n;++i){
        int64_t c=0;
        if(!a[i]){
            c=s+t;
            c%=MOD;
        }
        s=t;
        t=c;
    }
    cout<<t<<endl;
    return 0;
}


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

#define MAX_N 100000000

priority_queue<pair<int, int>> Q;
int d[MAX_N], n, s, x[MAX_N], y[MAX_N];

int main() {
	cin >> n >> s;
	Q.push(make_pair(0, -1000000000));
	for (int i = 0; i < s; i++) {
		cin >> x[i] >> y[i];
		d[x[i]] += y[i];
		Q.push(make_pair(d[x[i]], -x[i]));
		while (true) {
			pair<int, int>p = Q.top();
			if (p.first == d[-p.second]) {
				cout << -p.second << ' ' << p.first << endl; break;
			}
			Q.pop();
		}
	}
}

Measured memory_bytes: 8520
main = do
  [a, b] <- map read . words <$> getLine
  putStr $ f a b
 
f 1 1 = "Draw"
f 1 _ = "Alice"
f _ 1 = "Bob"
f x y
  | x == y = "Draw"
  | x > y = "Alice"
  | otherwise = "Bob"

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	long long n,t = 1e13;
	int f = 0;
	cin >> n;
	for(long long i=2;i <= sqrt(n);i++){//判断是否为质数 若不是输出最小step 
		if(n%i == 0){
			t = min(t,i+n/i-2);
			f = 1;
		}
	}
	if(f) cout << t;
	else cout << n-1;  
	return 0; 
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    char s[3];
    int ans = 0, t = 0;
    for(int i = 0; i < 3; ++i)
        scanf("%c", &s[i]);
    if(s[0] == 'R')
        ++t;
    for(int i = 1; i < 3; ++i)
        if(s[i] == 'R'){
            ++t;
        }else{
            if(t > ans){
                ans = t;
                t = 0;
            }
        }
    if(t > ans)
        ans = t;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1668
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] a) {
    auto b = a.enumerate(1).map!("a.value - a.index").array;
    b.sort();
    long median = b[b.length / 2];
    return b.map!(e => abs(e - median)).sum;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}


Measured memory_bytes: 11608
fun main(args : Array<String>) {
    val S = readLine()!!

    val s1 = S.substring(0, 2)
    val s2 = S.substring(2, 4)


    val isYYMM = isYY(s1) && isMM(s2)
    val isMMYY = isMM(s1) && isYY(s2)

    // ANBUIVIOUG
    if (isMMYY && isYYMM) {
        println("AMBIGUOUS")
        return
    }

    if (isMMYY) {
        println("MMYY")
        return
    }

    if (isYYMM) {
        println("YYMM")
        return
    }

    println("NA")
}


fun isMM(string: String) : Boolean {
    val int = string.toInt()
    return 1 <= int && int <= 12
}

fun isYY(string: String) : Boolean {
    val int = string.toInt()
    return 0 <= int && int <= 99
}

Measured memory_bytes: 31704
#include <bits/stdc++.h>
using namespace std;
int n, a[109];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) {
		for(int j = i - 1; j >= 0; j--) {
			if(a[j] > a[j + 1]) swap(a[j], a[j + 1]);
			else break;
		}
		for(int j = 0; j < n; j++) {
			if(j) cout << ' ';
			cout << a[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
# -*- coding: utf-8 -*-
#INF = 2**31 -1
#n, q = list(map(int, input().split()))
#
#lis = [INF for i in range(n)]
#
#for i in range(q):
#  data = list(map(int, input().split()))
#  if len(data) == 4:
#    a, s, t, x = data
#    for j in range(s, t+1):
#      lis[j] = x
#  else: 
#    b, k = data
#    print(lis[k])



INF = 2**31 - 1
n, q = list(map(int, input().split()))
lazy = [None for i in range(4*n)]
for i in range(n):
  lazy[i] = INF

def updata(a, b, x, k, l, r):
  m = (l+r)//2
  if a >= r or b <= l:
    return 0
  elif a <= l and b >= r:
    lazy[k] = x
  else:
    if lazy[k] != None:
      lazy[k*2+1] = lazy[k]
      lazy[k*2+2] = lazy[k]
      lazy[k] = None
    updata(a, b, x, k*2+1, l, m)
    updata(a, b, x, k*2+2, m, r)

def find(x, k, l, r):
  m = (l+r)//2
  if lazy[k] != None:
    print(lazy[k])
  else:
    if x < (l+r)//2:
      find(x, k*2+1, l, m)
    else:
      find(x, k*2+2, m, r)
      
for i in range(q):
  data = list(map(int, input().split()))
  if len(data) == 4:
    f, a, b, x = data
    updata(a, b+1, x, 0, 0, n)
  else:
    f, i = data
    find(i, 0, 0, n)


Measured memory_bytes: 10052
#include <stdio.h>

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

    long y;
    scanf("%ld", &y);
    y /= 1000;

    int i, j;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= n - i; j++) {
            if (y == ((10 * i) + (5 * j) + (n - i - j))) {
                printf("%d %d %d\n", i, j, n - i - j);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int main() {
  string s;
  R s;
  while(s.size()>3) {
    bool ck=false;
    REP(i,1,s.size()-3) {
      if(s.substr(i,3)=="mew") {
	s=s.substr(0,i)+s.substr(i+3);
	ck=true;
	break;
      }
    }
    if(!ck) break;
  }
  if(s!="mew") pr("Rabbit");
  else pr("Cat");
  return 0;
}


Measured memory_bytes: 1196
#113_B
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))

H_real=(T-A)/0.006

H_index=[]
for i in range(N):
    H_index.append((abs(H[i]-H_real),i+1))
H_index=sorted(H_index,key=lambda x:x[0])

print(H_index[0][1])

Measured memory_bytes: 3188
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int AMAX = 100000;
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		HashMap<Integer, Integer> map = new HashMap<>();
		int a = 0;
		Integer v = null;
		for(i=0;i<n;i++) {
			a = parseInt(sc.next());
			v = map.get(a);
			if(v == null) {
				map.put(a, 1);
			} else {
				map.put(a, v + 1);
			}
		}
		sc.close();
		int[] an = new int[AMAX];
		for (i = 0; i < AMAX; i++) {
			v = map.get(i-1);
			if(v != null) {
				an[i] += v;
			}
			v = map.get(i);
			if(v != null) {
				an[i] += v;
			}
			v = map.get(i+1);
			if(v != null) {
				an[i] += v;
			}
		}
		Arrays.parallelSort(an);
		out.println(an[AMAX-1]);
	}
}


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

using namespace std;

int main()
{
    int move_num;
    
    while (cin >> move_num) {
        if (move_num == 0) break;

        vector<int> dice = {1, 2, 3, 4, 5, 6};
        int ans = 1;
        
        for (int i = 0; i < move_num; ++i) {
            string direction;

            cin >> direction;

            int temp;

            switch (direction[0]) {
                case 'N':
                    temp = dice[0];
                    dice[0] = dice[1];
                    dice[1] = dice[5];
                    dice[5] = dice[4];
                    dice[4] = temp;
                    
                    ans += dice[0];
                    break;
                case 'S':
                    temp = dice[0];
                    dice[0] = dice[4];
                    dice[4] = dice[5];
                    dice[5] = dice[1];
                    dice[1] = temp;
                    
                    ans += dice[0];

                    break;
                case 'E':
                    temp = dice[0];
                    dice[0] = dice[3];
                    dice[3] = dice[5];
                    dice[5] = dice[2];
                    dice[2] = temp;
                    
                    ans += dice[0];
                    break;
                case 'W':
                    temp = dice[0];
                    dice[0] = dice[2];
                    dice[2] = dice[5];
                    dice[5] = dice[3];
                    dice[3] = temp;
                    
                    ans += dice[0];
                    break;
                case 'L':
                    temp = dice[1];
                    dice[1] = dice[3];
                    dice[3] = dice[4];
                    dice[4] = dice[2];
                    dice[2] = temp;
                    
                    ans += dice[0];
                    break;
                case 'R':
                    temp = dice[1];
                    dice[1] = dice[2];
                    dice[2] = dice[4];
                    dice[4] = dice[3];
                    dice[3] = temp;
                    
                    ans += dice[0];
                    break;
                default:
                    break;
            }

        }

        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1208
N,X=gets.chomp.split(' ').map{|n| n.to_i}
D=gets.chomp.split(' ').map{|n| n.to_i}
DSUM=Array.new(D.size){}
DSUM[0]=D[0]
for i in 1..(N-1)
	DSUM[i] = D[i] + DSUM[i-1]
end
min = 10**18
for m in 1..N
	items = (N*1.0/m).ceil # items
	sum = (N+m)*X
	if(m < N)
		sum += 2*(DSUM[N-0-1]-DSUM[N-m-1])
	else
		sum += 2*DSUM[N-0-1]
	end
	for itemsj in 0..(items-1)
		if(itemsj != items-1)
			sum += (2*(itemsj+1)+1)*(DSUM[N-itemsj*m-1]-DSUM[N-(itemsj+1)*m-1])
		else
			sum += (2*(itemsj+1)+1)*DSUM[N-itemsj*m-1]
		end
	end
	min = sum if min > sum
end
puts min



Measured memory_bytes: 23452
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int X, Y;
  int ans = 0;

  cin >> X >> Y;

  cout << X + Y/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long int N, M;

int main() {
	cin >> N >> M;
	if (N == 1 && M == 1) {
		cout << 1 << endl;
	}
	else if (N == 1) {
		cout << M - 2 << endl;
	}
	else if (M == 1) {
		cout << N - 2 << endl;
	}
	else {
		cout << N*M - 2 * M - 2 * N + 4 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
using ll=long long;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[n] = {};
    ll mo[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i==0) mo[i] = a[i]%m;
        else mo[i] = (mo[i-1] + a[i])%m;
    }
    map<ll, ll> ma;
    for(int i=0; i<n; i++){
        ma[mo[i]]++;
    }
    
    ll ans = 0;
    if(ma.count(0) != 0) ans += ma[0];
    for(auto s: ma){
        ans += s.second*(s.second-1)/2;
    } 
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int main(){

  char s[51];
  char t[51];
  scanf("%s %s",s,t);

  int sl = strlen(s);
  int tl = strlen(t);

  if(sl < tl){
    printf("UNRESTORABLE");
    return 0;
  }

  char ans[51];

  int flag = 0;
  for(int i = sl-tl; i >= 0; --i){
    flag = 0;
    strcpy(ans,s);

    for(int j = 0; j < tl; ++j){
      if(s[i+j] != '?' && s[i+j] != t[j]){
        flag = 1;
        break;
      }
      ans[i+j] = t[j];
    }
    if(flag == 0) break;
  }

  if(flag == 1){
    printf("UNRESTORABLE");
    return 0;
  }

  for(int i = 0; i < sl; ++i){
    if(ans[i] == '?') ans[i] = 'a';
  }

  printf("%s",ans);
  return 0;

}


Measured memory_bytes: 128
let () =
  let n, m = Scanf.scanf "%d %d" (fun n m -> n, m) in
  let a = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun a b -> a, b)) in
  let b = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun c d -> c, d)) in
  a |> Array.map (fun (xa, ya) ->
    Array.mapi (fun i (xb, yb) -> (abs (xb-xa) + abs (yb-ya), i+1)) b
    |> Array.fold_left min (101010101010, -1))
  |> Array.iter (fun (_,i) -> Printf.printf "%d\n" i)


Measured memory_bytes: 512
n = int(input())
v = list(map(int, input().split()))

u = v[1::2]
d = v[0::2]
    
#print(u)
#print(d)

U = [0] * 100010
for i in range(len(u)):
    U[u[i]] += 1
    
D = [0] * 100010
for i in range(len(d)):
    D[d[i]] += 1
   
if U.index(max(U)) == D.index(max(D)):
    u = sorted(U, reverse=True)
    d = sorted(D, reverse=True)
    s = n - u[1] - d[0] if u[1] > d[1] else n - u[0] - d[1]
    print(s)
    exit()
    
print(n - max(U) - max(D))

Measured memory_bytes: 20616
package main

import (
    "fmt"
)

func scanInput() (n int, nums []int) {
    fmt.Scanf("%d", &n)
    nums = make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &nums[i])
    }
    return
}

func main() {
    _, nums := scanInput()
    length := len(nums)

    for i, v := range nums {
        node := i + 1

        parent := node / 2
        left := 2 * node
        right := 2 * node + 1

        fmt.Printf("node %d: key = %d,", node, v)
        if 0 < parent && parent <= length {
            fmt.Printf(" parent key = %d,", nums[parent - 1])
        }
        if left <= length {
            fmt.Printf(" left key = %d,", nums[left - 1])
        }
        if right <= length {
            fmt.Printf(" right key = %d,", nums[right - 1])
        }
        fmt.Println(" ")
    }
}



Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

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



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;
vector< vector<int > > a;
stack<int> s;
int vis[100001]= {0};
void dfs(int v)
{
    vis[v]=1;
    for(auto i:a[v])
        if(vis[i]==0)
            dfs(i);
        s.push(v);
}

int main()
{
    int n,m;
    cin>>n>>m;
    a.resize(n);
    int x,y;
    int b[n]={0};
    for (int i = 0; i < m; ++i) {
        cin>>x>>y;
        x--;
        y--;
        a[x].push_back(y);
        b[y]=1;
    }

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

    int dp[n]={0};
    while (!s.empty())
    {
        for(auto i:a[s.top()])
        {
            dp[i]=max(dp[i],dp[s.top()]+1);
        }
        s.pop();
    }
    int ans=0;
    for (int i = 0; i <n ; ++i) {
        ans=max(ans,dp[i]);
    }

     cout<<ans;
}

Measured memory_bytes: 11596
package main

import "fmt"

func main() {
	cards := make([][]rune, 3)
	for i := 0; i < 3; i++ {
		var tmp string
		fmt.Scan(&tmp)
		cards[i] = make([]rune, len(tmp))
		for j, r := range tmp {
			cards[i][j] = r
		}
	}
	current := 0
	for {
		if len(cards[current]) == 0 {
			break
		} else {
			switch cards[current][0] {
			case 'a':
				current, cards[current] = 0, cards[current][1:]
			case 'b':
				current, cards[current] = 1, cards[current][1:]
			case 'c':
				current, cards[current] = 2, cards[current][1:]
			}
		}
	}
	var winner string
	switch current {
	case 0:
		winner = "A"
	case 1:
		winner = "B"
	case 2:
		winner = "C"
	}
	fmt.Println(winner)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pii pair<ll,ll>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))

typedef long long ll;
const ll mod = 1e9+7;
const int sz = 500;


int main(){

    ll n,a,b;
    cin >> n >> a >> b;

    if(a==0) cout << 0 << endl;
    else if(b==0) cout << n << endl;
    else {
        ll rem = n - (a+b);


               ll val = a+b;
               ll ans = a * (n/val);
               ans += min((n%val),a);
               cout << ans << endl;

    }
    return 0;
}


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

int main(){
    ll n, k;
    cin>>n>>k;

    vector<ll> a(n+1, 0);
    vector<ll> p(n+1, 1);
    for(int i=1; i<=n; i++){
        cin>>a[i];
       
        if(1<=i && i<=k){
            p[k] *= a[i];
            p[k] = p[k] % 1000000009;
        }
    }
/*

    for(int i=k+1; i<=n; i++){
        p[i] = p[i-1]/a[i-k]*a[i];
    }

    for(int i=k; i<=n; i++){
        cout<<p[i]<<endl;
    }
*/
    for(int i=k; i<n; i++){
        //cout<<a[i-k+1]<<" "<<a[i+1]<<endl;
        if(a[i-k+1]<a[i+1]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N + 1);
    A.at(0) = 2;
    A.at(1) = 1;
    for(int i = 2; i <= N; i++){
        A.at(i) = A.at(i - 2) + A.at(i - 1);
    }
    cout << A.at(N) << endl;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sf scanf
#define pf printf
#define str string
#define vec vector
#define rep(i, n) for (i = 0; i < n; ++i)
#define rep0(i, n) for (i = 0; i <= n; ++i)
#define rep1(i, n) for (i = 1; i <= n; ++i)
#define repp(i, a, n) for (i = a; i <= n; ++i)
#define repb(i, a, n) for (i = a; i >= n; --i)
#define asort(a) sort(a.begin(), a.end())
#define vi vector<int>
#define pb push_back
#define mpp make_pair
#define fi first
#define se second
#define mem(a, n) memset(a, n, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))

using namespace std;
typedef long long ll;

int main() {
    ll a, b, c, d, l, m, r;
    sf("%lld %lld %lld %lld", &a, &b, &c, &d);

    m = a - 1;
    l = (c*d) / __gcd(c, d);
    r = b - b/c - b/d + b/l -
        m + m/c + m/d - m/l;

    pf("%lld\n", r);

    return 0;
}


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

using namespace std;

int translate(char ch){
	switch(ch){
	case 'I':	return 1;
	case 'V':	return 5;
	case 'X':	return 10;
	case 'L':	return 50;
	case 'C':	return 100;
	case 'D':	return 500;
	case 'M':	return 1000;
	}
	return -1; //must not reach here
}

int main(){
	char buf[101];
	int sum;
	bool subFLG;

	while(scanf("%s",buf)!=EOF){
		sum = 0;
		subFLG = false;
		for(int i=0;buf[i] != '\0';i++){
			if(buf[i+1] != '\0' && translate(buf[i]) < translate(buf[i+1]) && subFLG == false){
				sum += -1*(translate(buf[i]));
				subFLG = true;
			}else{
				sum += translate(buf[i]);
				subFLG = false;
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 2592
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int partition(int *a, int lo, int hi)
{
    int i, j, x, t;
 
    x = a[hi], i = lo-1;
    for (j = lo; j < hi; j++) {
        if (a[j] <= x) i++, t = a[i], a[i] = a[j], a[j] = t;
    }
    t = a[++i], a[i] = a[hi], a[hi] = t;
    return i;
}
 
int a[100002];
 
int main()
{
    int n, i, k;
     
    n = in(); for (i = 0; i < n; i++) a[i] = in();
    k = partition(a, 0, n-1);
    printf((!k? "[%d]": "%d"), a[0]);
    for (i = 1; i < n; i++) {
        putchar(' ');
        printf((k==i? "[%d]": "%d"), a[i]);
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    vector<ll> a(n), b(n), c(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    rep(i, n) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    rep(i, n) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    
    ll ans = 0;
    rep(i, n) {
        auto pos1 = lower_bound(a.begin(), a.end(), b[i]);
        ll x = pos1 - a.begin();
        auto pos2 = upper_bound(c.begin(), c.end(), b[i]);
        ll y = c.end() - pos2;
        ans += x*y;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
#n,m= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#a.popは10^5あるときTLEしやすい!注意!
#これを消すとなぜかWAになる呪い
s = 0
n = len(a)
bit = [0 for i in range(n-1)]
while sum(bit)<len(bit):
    r = 0
    bit[0]+=1
    if bit[0]==2:
        p = 0
        while bit[p] == 2:
            bit[p]=0
            p+=1
            bit[p]+=1
    str = []
    for i in range(n-1):
        str.append(a[i])
        if bit[i]:str.append(',')
    str.append(a[n-1])
    pa  = ''.join(str)
    ans = pa.split(',')
    for i in range(len(ans)):
        ans[i] = int(ans[i])
    s+=sum(ans)
print(s+int(a))

Measured memory_bytes: 5076
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n - 1):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
    if minj != i:
        a[i], a[minj] = a[minj], a[i]
        cnt += 1
print(" ".join(map(str, a)))
print(cnt)


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};



signed main() {
	int a[3];
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	sort(begin(a), end(a));
	printf("%s", (a[1] + a[0]) == a[2] ? "Yes\n" : "No\n");

	return 0;
}

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

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

    int n, m, x, y;
    cin >> n >> m >> x >> y;

    vector<int> a(n), b(m);
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    for (int z = x + 1; z <= y; ++z)
    {
        if (a.back() < z && z <= b.front())
        {
            cout << "No War" << endl;
            return 0;
        }
    }

    cout << "War" << endl;

    return 0;
}

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

int main(){
	ll a,b,n;
	cin >> a >> b >> n;
	ll ans = a*min(n,b-1)/b;
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    REP (i, M) {
        cin >> A[i];
        ans += A[i];
    }

    ans = max((int64_t)-1, N - ans);
    cout << ans << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc163/abc163_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc163/abc163_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc163/abc163_b && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3668