akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <iomanip>
#define INT long long int
#define MOD 1000000007
#define oo 978654321
#define OO 9999999987654321ll
#define PI (3.141592653589793238462643383279502884197)
#define Q (5.0*PI - 20.0)
#define H (10.0*PI - 20.0)
using namespace std;

INT a, b, c, d, n, X[200020], Y[200020], lis[200020], cnt, ed, v, C;
long double ans;
struct JK{ INT x, y; } T[200020];

int main()
{
    ios::sync_with_stdio(false);
    cin>>a>>b>>c>>d>>n;
    for(int i = 0 ; i < n ; i++ )
    {
        cin>>X[i]>>Y[i];
        if( (min(a, c) <= X[i]&&X[i] <= max(a, c)) and ( min(b, d) <= Y[i]&&Y[i] <= max(b, d) ) )
                T[cnt++] = { X[i], Y[i] };
    }
    if( a == c ) return cout<<setprecision(20)<<(long double)(abs(b-d)*100.0+(cnt?H:0))<<endl, 0;
    if( b == d ) return cout<<setprecision(20)<<(long double)(abs(a-c)*100.0+(cnt?H:0))<<endl, 0;

    if( cnt )
    {
        if( (a < c and b < d) or (c < a and d < b) ) sort(T, T+cnt, [](JK a, JK b){ return a.x < b.x; });
        else sort(T, T+cnt, [](JK a, JK b){ return a.x > b.x; });
        lis[0] = T[0].y; ed = 0;
        for(int i = 1 ; i < cnt ; i++ )
        {
            if( lis[ed] < T[i].y ) ed++, lis[ed] = T[i].y;
            else
            {
                v = (int)(lower_bound(lis, lis+ed+1, T[i].y) - lis);
                lis[v] = T[i].y;
            }
        }
        C = ed+1;
        INT X = min(abs(a-c), abs(b-d)) + 1;
        if( C == X ) ans = (long double)((abs(b-d)+abs(a-c))*100.0L+Q*(C-1)+H);
        else ans = (long double)((abs(b-d)+abs(a-c))*100.0L+Q*(C));
    }
    else ans = (long double)((abs(b-d)+abs(a-c)))*100.0L;
    cout<<setprecision(20)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, maxw;

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n >> maxw;
  vi weight(n+1);
  vi val(n+1);
  rep(i, 1, n){
  	cin >> weight[i] >> val[i];
  }
  ll dp[101][100001];
  rep(i, 0, 100000) dp[0][i]=1e9+1;
  dp[0][0]=0;

  int ans=-1;
  rep(i, 1, n){
  	rep(j, 1, 100000){
  		dp[i][j]=min(dp[i-1][j], (j-val[i]>=0? weight[i]+dp[i-1][j-val[i]]:1000000001));
  		if(dp[i][j]<=maxw){
  			ans=max(ans, j);
  		}
  	}
  }
  cout << ans;
}

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

constexpr int MAX_N = 1e5;

int H[MAX_N];

int main() {
  int N; cin >> N;
  for (int i{}; i < N; ++i) cin >> H[i];

  int ans{};
  int right{};
  for (int left{}; left < N; ++left) {

    while (right < N - 1 && H[right] >= H[right+1]) {
      ++right;
    }

    ans = max(ans, right - left);

    left = right++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
$start_time = Time.now
a, b, n = gets.chomp.split(" ").map{|e|e.to_i}

def check(a,b,x)
	return (a*x/b).to_i - a*(x/b).to_i
end

def doit(a,b,n)
	if b>n then
		return check(a,b,n)
	else
		max = 0
		x = b-1
		while x<=n do
			c = check(a,b,x)
			if c>max then max = c end
			x += b
			if Time.now - $start_time > 1.5 then return max end
		end
		c = check(a,b,n)
		if c>max then max = c end
		return max
	end
end

print doit(a,b,n)

#5 7 20

Measured memory_bytes: 14352
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int n,h;
vector <int> a;
vector <int> b;

int main(){
  cin >> n >> h;
  REP(i,n){
    int s,t;
    cin >> s >> t;
    a.pb(s);
    b.pb(t);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  int l = a[0];
  int ans = 0;
  REP(i,n){
    if(l<b[i]&&h>0){
      h -= b[i];
      ans ++;
    }
  }
  if(h>0){
    ans += (h+l-1)/l;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1276
n = int(input())
aaa = {}
bbb = list(map(int, input().split(' ')))
bbb.append(999999999999)
for i in range(n-1, -1, -1):
    aaa[i] = min(bbb[i], bbb[i-1])
print(sum([aaa[i] for i in range(n)]))

Measured memory_bytes: 38256
#include <cstdio>

int main()
{
  int n;
  int a[200000];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
  }
  int b[200000];
  int m = 0;
  for (int i = n; i > 0; --i)
  {
    int r = 0;
    for (int j = i * 2; j <= n; j += i)
    {
      r += b[j - 1] & 1;
    }
    b[i - 1] = (r & 1) ^ a[i - 1];
    if (b[i - 1] == 1) ++m;
  }
  printf("%d\n", m);
  for (int i = 0; i < n; ++i)
  {
    if (b[i]) printf("%d ", i + 1);
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 2432
import queue

h,w = map(int, input().split())
s = [input() for i in range(h)]

white = 0

for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            white += 1

q = queue.Queue()

move = [[0,1],[0,-1],[1,0],[-1,0]]

q.put([0,0])

inf = float('inf')
d = [[inf for i in range(w)] for j in range(h)]
d[0][0] = 0

while not q.empty():
    p = q.get()
    for m in move:
        if 0<=p[0]+m[0]<h and 0<=p[1]+m[1]<w and d[p[0]+m[0]][p[1]+m[1]] == inf and s[p[0]+m[0]][p[1]+m[1]] != '#':
            d[p[0]+m[0]][p[1]+m[1]] = d[p[0]][p[1]]+1
            q.put([p[0]+m[0], p[1]+m[1]])

if d[h-1][w-1] ==inf:
    print(-1)
else:
    print(white-d[h-1][w-1]-1)


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

struct vw{
  int v, w;
};

typedef pair<double, int> p;
typedef pair<p, int> pp;
#define inf INT_MIN

int n, m;
int ave[1111];
vector<vw> h;
int dp[111][10001];

int solve(int x, int wight){

  int ret = inf;
  if(dp[x][wight] != -1) return dp[x][wight];
  if(x == n) return 0;
  
  int w = h[x].w, v = h[x].v;
  if(wight + w <= m) ret = max(ret,solve(x+1,wight+w) + v);
  ret = max(ret,solve(x+1,wight));
 
  return dp[x][wight] = ret;
}


int main(){

  cin >> n >> m;

  memset(dp,-1,sizeof(dp));

  for(int i = 0; i < n; i++){
    int v, w;
    cin >> v >> w;
    h.push_back((vw){v,w});
  }
			    
  int ans = solve(0,0);
  cout << ans << endl;


}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll x, k, d, ans; cin >> x >> k >> d;
    if(x < 0) x *= -1;
    if(k < x/d) {
        ans = x-d*k;
    }
    else {
        k = k-x/d;
        x = x%d;
        if(k%2 == 0) ans = x;
        else ans = my_abs(x-d);
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>

using namespace std;

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

int main(){
    int K; cin >> K;
    long long ans = 0;
    for(int i=1; i<=K; ++i){
        for(int j=1; j<=K; ++j){
            for(int k=1; k<=K; ++k){
                long long g;
                g = gcd(i, j);
                g = gcd(g, k);
                ans += g;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
///created: 4/Jul/2019 14:46:30

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
const int modulo = 1e9 + 7;

#ifdef LOCAL_DEBUG_NTV1612
template<class __Ty>
string to_string(__Ty a) {
	string res = "[ ";
	bool f = true;
	for (auto &p : a) { res += (f ? string("") : string(", ")) + to_string(p); f = false;	}
	return res + " ]";
}
void _debug() { fprintf(stderr, "\n"); }
template<typename __Ty_head, typename... __Ty_tail>
void _debug(__Ty_head head, __Ty_tail... tail) { fprintf(stderr, "%s ", to_string(head).c_str()); _debug(tail...); }
#define debug(...) fprintf(stderr, "DEBUG [%s]: ", #__VA_ARGS__), _debug(__VA_ARGS__)
#else
#define debug(...) 0
#endif

template<class __Ty> bool mini(__Ty& a, __Ty b) { return a > b ? ((a = b) | 1) : (0); }
template<class __Ty> bool maxi(__Ty& a, __Ty b) { return a < b ? ((a = b) | 1) : (0); }
template<class __Ty> __Ty add(__Ty a, __Ty b) { return (a + b) % (__Ty(modulo)); }
template<class __Ty> __Ty sub(__Ty a, __Ty b) { __Ty m(modulo); return ((a - b) % m + m) % m; }

int mul(int a, int b) {
	return int((1LL * a * b) % (1LL * modulo));
}

const int N = 1e5 + 1;
int dp[N][2000], fact[2 * N];
bool ip[N];

int fpow(int a, int p) {
	if (p == 0) return 1;
	int tmp = fpow(a, p / 2);
	tmp = mul(tmp, tmp);
	if (p % 2) tmp = mul(tmp, a);
	return tmp;
}

void precalc() {
	fact[0] = 1;
	for (int i = 1; i < 2 * N; ++i)
		fact[i] = mul(fact[i - 1], i);
}

int C(int n, int k) {
	return mul(fact[n], fpow(mul(fact[k], fact[n - k]), modulo - 2));
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int m, n, ft = 2, ans = 1;
	precalc();
	cin >> n >> m;
	while (m > 1) {
		if (m % ft == 0) {
			int cnt = 0;
			while (m % ft == 0) {
				m /= ft;
				cnt++;
			}
			debug(ft, cnt);
			ans = mul(ans, C(cnt + n - 1, cnt));
		}
		else ft++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define d double
const int sz=3000;
d prob[sz];
d dp[sz][sz]; // dp [i][x] stores the probability of getting x heads out of i coins
d solve(int n){
    dp[0][0]=1.0;
    //initialise first column
    for(int i=1;i<=n;++i){
        dp[i][0]=dp[i-1][0]*(1-prob[i]);
    } 
    // filling rest of the dp
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            // select j heads with i-1 coins and this time tail comes
            d option1=dp[i-1][j]*(1-prob[i]);
            // select j-1 heads with i-1 coins and this time heads comes
            d option2=(dp[i-1][j-1])*prob[i]; 
            if(j<=i)
                dp[i][j]=option1+option2;
            else
                dp[i][j]=0;
        }
    }
    /*for(int i=0;i<=n;++i){
        for(int j=0;j<=n;++j){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    d ans=0.0;
    for(int j=n/2+1;j<=n;++j){
        ans+=dp[n][j];
    }
    return ans;
}

int main() {
int n=0;cin>>n;
    for(int i=1;i<=n;++i){
        cin>>prob[i];
    }
    cout<<fixed<<setprecision(10)<<solve(n)<<endl;
    return 0;
}


Measured memory_bytes: 70528
/*input
*/

// #include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <cstdint>
#include <tuple>
#endif
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 2e5+10;
typedef long long int lld;
typedef long long ll;

#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define mset(a, v) memset(a, v, sizeof(a))
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }


#define popcount __builtin_popcountll

ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}


ll Array[lim],BArray[lim],dp[lim];

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt 
    freopen("output.txt", "w", stdout);
    #endif

    lld T,i,p,j,l,e,r,b,c,k,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,m,ans=0,left,right;
    string A,B;
    cin>>n;
    rep(i,1,n) cin>>Array[i];
    sort(Array+1,Array+n+1);
    reverse(Array+1,Array+n+1); pos=1;
    // Error(Array[1]);
    rep(i,1,(n)/2) {
        if(i==1) ans+= Array[i];
        else ans += Array[i]*2;
    }
    if(n%2==1) ans+= Array[(n+1)/2];
    cout<<ans<<endl;
    return 0;
}





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

int main()
{
    int ans1=0, ans2=0, f=0;
    char b[100002], *p;
    scanf("%s", b);
    p = b;
    while(*p != '\0'){
        if(*p == (f = (f == 0)) + 48) ans1++;
        p++;
    }
    f=1;
    p = b;
    while(*p != '\0'){
        if(*p == (f = (f == 0)) + 48) ans2++;
        p++;
    }
    (ans1 > ans2) ? printf("%d\n", ans2): printf("%d\n", ans1);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define PI 3.14159265
ll exponent(ll x,ll n,ll m)
{  if(n==0)
    return 1;
    if(n%2!=0)
    {
        return (x*exponent(((x%m)*(x%m))%m,(n-1)/2,m))%m;
    }
    else
    return exponent(((x%m)*(x%m))%m,n/2,m);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    if(m==n)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        if (cin.nextint * cin.nextint % 2 == 0)
        {
            WriteLine("No");
        }
        else
        {
            WriteLine("Yes");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

double d, w, h, n, a, r;

int main(){
	while (cin >> d >> w >> h&&d + w + h){
		if (d > w)swap(d, w);
		if (w > h)swap(w, h);
		cin >> n;
		REP(i, n){
			cin >> r;
			if (r * 2 > sqrt(pow(d, 2) + pow(w, 2)))cout << "OK\n";
			else cout << "NA\n";
		}
	}
}

Measured memory_bytes: 1184
s = input()

d = len(s) - 1

def dfs(depth: int, cur:int, s: str, res: str) -> int:
    if depth == d:
        tmp = s + res[:1]
        return cur + int(tmp)
    
    else:
        tmp = s + res[:1]
        return dfs(depth+1, cur+int(tmp), "", res[1:]) \
                + dfs(depth+1, cur, tmp, res[1:])
                
ans = dfs(0, 0, "", s)

print(ans)

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

using namespace std;

namespace {

#define VERA(i, a, b)for(auto i=(ll)(a);i<(ll)(b);++i)
#define ANDY(i, a, b)for(auto i=(ll)(a);i>(ll)(b);--i)

typedef long long ll;
typedef long double dd;

void Solve(ll test_num) {
  (void) test_num;
  ll N, K;
  cin >> N >> K;
  vector<ll> arr(N);
  for (auto& a : arr)
    cin >> a;
  ll g = arr.front();
  VERA(i, 1, N) g = __gcd(g, arr[i]);
  sort(arr.begin(), arr.end());
  if (K % g || (K > arr.back())) {
    cout << "IMPOSSIBLE\n";
    return;
  }
  cout << "POSSIBLE\n";
}

void Init() {
}

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("../input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand(1223);
  Init();
  ll tests = 1;
//  cin >> tests;
  VERA(test, 1, tests + 1) {
    Solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
const int MN=100000,MQ=100000;
int N;
string s[MN];
int k[MQ];
string o[MQ];

int trie[500000][26];
vector<int> id2qs[500000];
int v2id[MN];
int id2v[500000];
int sum[500000];
int I=1;

int cnt[26][26];
int ans[MQ];
int up[MN];

void dfs(int nowid){
	for(int q:id2qs[nowid]){		//query
		rep(i,26) for(int j=i+1;j<26;j++){
			ans[q]+=cnt[o[q][j]-'a'][o[q][i]-'a'];
		}
	}
	rep(c,26) if(trie[nowid][c]>=0){
		rep(c2,26){
			int v2=trie[nowid][c2];
			if(v2>=0) cnt[c][c2]+=sum[v2];
		}
		dfs(trie[nowid][c]);
		rep(c2,26){
			int v2=trie[nowid][c2];
			if(v2>=0) cnt[c][c2]-=sum[v2];
		}
	}
}

int main(){
	rep(i,500000) id2v[i]=-1;
	rep(i,500000) rep(j,26) trie[i][j]=-1;
	cin>>N;
	rep(i,N) cin>>s[i];
	int Q;
	cin>>Q;

	sum[0]=N;
	rep(v,N){
		int now=0;
		int L=s[v].size();
		rep(i,L){
			int c=s[v][i]-'a';
			if(trie[now][c]==-1){
				trie[now][c]=I;
				I++;
			}
			now=trie[now][c];
			sum[now]++;
		}
		v2id[v]=now;
		id2v[now]=v;
	}

	rep(v,N){
		int now=0;
		int L=s[v].size();
		rep(i,L){
			int c=s[v][i]-'a';
			now=trie[now][c];
			if(id2v[now]>=0) up[v]++;
		}
		up[v]--;
	}


	rep(i,Q){
		cin>>k[i];
		k[i]--;
		cin>>o[i];
		id2qs[v2id[k[i]]].pb(i);
	}


	vector<int> vs;
	rep(i,N) vs.pb(i);
	dfs(0);
	rep(i,Q){
		ans[i]+=up[k[i]];
		cout<<ans[i]+1<<endl;
	}
}


Measured memory_bytes: 121088
# coding:utf-8


INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


s = input()
if s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

abc = 'abcdefghijklmnopqrstuvwxyz'
used = set()

ans = ''
if len(s) != 26:
    for c in abc:
        if c not in s:
            print(s + c)
            exit()

else:
    prev_c = ord(s[-1])
    candidate = []
    for i in range(25)[::-1]:
        curr = ord(s[i])
        next = ord(s[i + 1])
        if curr >= next:
            candidate.append(next)
        else:
            candidate.append(next)
            ct = ord('z')
            for c_int in candidate:
                if c_int < curr: continue
                ct = min(ct, c_int)
            print(s[:i] + chr(ct))
            exit()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s1,s2,s3;
	char a,b,c;
	cin>>s1>>s2>>s3;
	a=s1[0];
	b=s2[0];
	c=s3[0];
	cout<<a<<b<<c;
	return 0;
} 

Measured memory_bytes: 256
from collections import Counter

N = int(input())
V = tuple(map(int, input().split(' ')))

v1 = V[::2]
v2 = V[1::2]

v1_count = Counter(v1)
v1_count[-1] = 0
v2_count = Counter(v2)
v2_count[-1] = 0

v1 = sorted([(value, key) for key, value in v1_count.items()], reverse=True)
v2 = sorted([(value, key) for key, value in v2_count.items()], reverse=True)

if v1[0][1] == v2[0][1]:
    print(min(N - v1[0][0] - v2[1][0], N - v2[0][0] - v1[1][0]))
else:
    print(N - v1[0][0] - v2[0][0])


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

using int64 = long long;

int main() {
	string s;
	cin >> s;
	
	int ans = s.size();
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) continue;
		ans = min(ans, max(i + 1, (int)s.size() - i - 1));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N, M;
string s[101], t[101];

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

  map<string, int> m;

  cin >> N;
  rep(i, N) cin >> s[i];
  cin >> M;
  rep(i, M) cin >> t[i];
    
  rep(i, N) m[s[i]]++;
  rep(i, M) m[t[i]]--;
  
  int ans=0;
  rep(i, N) ans= max(ans, m[s[i]]);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
	int N = 0;
	int C[20] = {};
	int V[20] = {};
	int A[20] = {};
	int max = 0;
	std::cin >> N;

	for (int i = 0; i < N; i++) {
		std::cin >> V[i];
	}

	for (int i = 0; i < N; i++) {
		std::cin >> C[i];
		A[i] = V[i] - C[i];
	}

	for (int i = 0; i < N; i++) {
		if (A[i] < 0) {
		
		}
		else {
			max += A[i];
		}
	}

	std::cout << max << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int N,K;
int sumBrack[4000][4000];
int sumWhite[4000][4000];

int calcBlack(int x1,int y1,int x2,int y2){
    int res = 0;
    if(0<x1 && 0<y1) res+=sumBrack[x1-1][y1-1];
    if(0<x1)         res-=sumBrack[x1-1][y2];
    if(0<y1)         res-=sumBrack[x2][y1-1];
    res+=sumBrack[x2][y2];
    return res;
}

int calcWhite(int x1,int y1,int x2,int y2){
    int res = 0;
    if(0<x1 && 0<y1) res+=sumWhite[x1-1][y1-1];
    if(0<x1)         res-=sumWhite[x1-1][y2];
    if(0<y1)         res-=sumWhite[x2][y1-1];
    res+=sumWhite[x2][y2];
    return res;
}

int main(void){
    cin>>N>>K;
    REP(i,N){
        int x,y;
        char c;
        cin>>x>>y>>c;
        x%=(2*K);
        y%=(2*K);
        if(c=='W'){
            sumBrack[x][y]++;
            sumBrack[x+2*K][y]++;
            sumBrack[x][y+2*K]++;
            sumBrack[x+2*K][y+2*K]++;
        }else{
            sumWhite[x][y]++;
            sumWhite[x+2*K][y]++;
            sumWhite[x][y+2*K]++;
            sumWhite[x+2*K][y+2*K]++;
        }
    }
    REP(i,4*K)
        REP(j,4*K){
                if(0<j){
                    sumBrack[i][j] += sumBrack[i][j-1];
                    sumWhite[i][j] += sumWhite[i][j-1];
                }
        }
    REP(i,4*K)
        REP(j,4*K){
            if(0<i){
                sumBrack[i][j] += sumBrack[i-1][j];
                sumWhite[i][j] += sumWhite[i-1][j];
            }
        }
    REP(i, 4*K){
        REP(j, 4*K){
            // printf("%d\t",sumWhite[i][j]);
        }
        // printf("\n");
    }
    int ans = 0;
    REP(i,2*K)
        REP(j,2*K){
            int res = 0;
            int w=0, b=0;
            w += calcWhite(i,j,i+K-1,j+K-1);
            w += calcWhite(i+K,j+K,i+2*K-1,j+2*K-1);

            b += calcBlack(i+K,j,i+2*K-1,j+K-1);
            b += calcBlack(i,j+K,i+K-1,j+2*K-1);
            // printf("w=%d b=%d\n",w,b);
            res = w + b;
            ans = max(ans, res);
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 125184
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

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

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

    // bool isRev = false;
    vector<int> frnt;
    vector<int> back;
    rep(i, 0, n) {
        int val;
        cin >> val;
        if (i % 2 == 0) {
            frnt.push_back(val);
        } else {
            back.push_back(val);
        }
    }

    if (n % 2 != 0) {
        reverse(frnt.begin(), frnt.end());
        for (int val : frnt) {
            printf("%d ", val);
        }
        rep(i, 0, back.size()) {
            printf("%d", back[i]);
            if (i != back.size() - 1) {
                printf(" ");
            } else {
                printf("\n");
            }
        }
    } else {
        reverse(back.begin(), back.end());
        for (int val : back) {
            printf("%d ", val);
        }
        rep(i, 0, frnt.size()) {
            printf("%d", frnt[i]);
            if (i != frnt.size() - 1) {
                printf(" ");
            } else {
                printf("\n");
            }
        }
    }
    return 0;
}


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

int arr[100005];

int main()
{
    memset(arr, 0, sizeof(arr));
    int n;
    cin >>n;
    int a, b , c;
    for(a=1;a<=100;a++)
    for(b=1;b<=100;b++)
    for(c=1;c<=100;c++)
    {
        arr[a*a+b*b+c*c+a*b+a*c+b*c]++;
        //if((a^2+b^2+c^2+a*b+a*c+b*c)==1)
           // cout << a << " " << b <<" "  << c << endl;
    }

    for(int i=1;i<=n;i++)
        cout << arr[i] << endl;


	return 0;
}



Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll div_c, div_d, div_cd;
    div_c = b / c - (a - 1) / c;
    div_d = b / d - (a - 1) / d;
    ll cd = 1;
    cd = c * d / gcd(c, d);
    div_cd = b / cd - (a - 1) / cd;
    cout << b - a + 1 - div_c - div_d + div_cd << endl;
    return 0;
}

Measured memory_bytes: 3624
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;














const int INF = 1e9;
signed main(){
    int h, w, k;
    cin >> h >> w >> k;
    char c[h][w];
    int co = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> c[i][j];
            if (c[i][j] == '1') co++;
        }
    }
    if (co <= k){
        cout << 0;
        return 0;
    }
    int m = (1 << (h - 1));
    int dp[h + 1][w + 1];
    for (int i = 0; i < w + 1; i++) dp[0][i] = 0;
    for (int j = 0; j < h + 1; j++) dp[j][0] = 0;
    for (int i = 1; i < h + 1; i++){
        for (int j = 1; j < w + 1; j++){
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + (c[i - 1][j - 1] == '1');
        }
    }
   /* for (int i = 0; i < h + 1; i++){
        for (int j =0 ; j < w + 1; j++){
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    } */
    int A = INF;
    for (int mask = 0; mask < m; mask++){
        int ansek = 0;
        vector<int> c;
        c.pb(0);
        bool fl1 = 1;
        for (int i = 0; i < h - 1; i++){
            if (mask & (1 << i)){ansek++; c.pb(i + 1);}
        }
        c.pb(h);
        vector<int> ans(ansek + 1);
        for (int i = 1; i < w + 1; i++){
            for (int q = 1; q < c.size(); q++){
                ans[q - 1] += dp[c[q]][i] - dp[c[q]][i - 1] - dp[c[q - 1]][i] + dp[c[q-1]][i - 1];
            }
            bool fl = 0;
            for (int i = 0; i < ans.size(); i++){
                if (ans[i] > k){
                    ansek++;
                    fl = 1;
                    break;
                }
            }
            if (fl){
                for (int q = 1; q < c.size(); q++){
                    ans[q - 1] = dp[c[q]][i] - dp[c[q]][i - 1] - dp[c[q - 1]][i] + dp[c[q-1]][i - 1];
                }
                for (int i = 0; i < ans.size(); i++){
                    if (ans[i] > k){
                        fl1 = 0;
                        break;
                    }
                }
            }
        }
        if (fl1 == 0) continue;
        A = min(A, ansek);
     //   cout << "******* " <<  ansek << ' ' << mask << endl;
    }
    cout << A;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void)
{

	for (int i = 0; i < 3; i++) {
		string s;
		cin >> s;
		cout << s[i];
	}
	cout << endl;

	return 0;
}



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

using namespace std;

string join(const vector<int>& v, const char delim = 0) {
    string s;
    if (!v.empty()) {
        s += to_string(v[0]);
        for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
            if (delim) s += delim;
            s += to_string(v[i]);
        }
    }
    return s;
}
int main() {
    string S;
    cin >> S;

    vector<char> characters(S.begin(), S.end());
    vector<vector<char>> split {};

    // Split
    string prev { "" };
    for (char c : characters) {
        if (prev.back() == 'L' && c == 'R') {
            vector<char> chars(prev.begin(), prev.end());
            split.push_back(chars);
            prev = c;
        } else {
            prev += c;
        }
    }

    vector<char> chars(prev.begin(), prev.end());
    split.push_back(chars);


    vector<int> results {};
    for (const auto& list : split) {

        vector<char> Rs {};
        vector<char> Ls {};

        for (int i { 0 }; i < list.size(); ++i) {
            char c = list[i];
            if (c == 'R') Rs.push_back(c);
            else Ls.push_back(c);
        }

        if (list.size() % 2 == 0) {
            for (int R_i { 0 }; R_i < Rs.size() - 1; ++R_i) {
                results.push_back(0);
            }
            results.push_back(list.size() / 2);

            results.push_back(list.size() / 2);
            for (int L_i { 0 }; L_i < Ls.size() - 1; ++L_i) {
                results.push_back(0);
            }
        } else {
            for (int R_i { 0 }; R_i < Rs.size() - 1; ++R_i) {
                results.push_back(0);
            }

            if (Rs.size() % 2 == 0) {
                results.push_back(list.size() / 2);
                results.push_back((list.size() / 2) + 1);
            } else {
                results.push_back((list.size() / 2) + 1);
                results.push_back(list.size() / 2);
            }

            for (int L_i { 0 }; L_i < Ls.size() - 1; ++L_i) {
                results.push_back(0);
            }
        }
    }


    cout << join(results, ' ') << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for (int i = 0; i < N; i++)
        cin >> D[i];

    int res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            res += D[i] * D[j];
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_N=3e5;
ll N,f[MAX_N],C[MAX_N+1],D[MAX_N+1],psmD[MAX_N+2],psmkD[MAX_N+2];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N){
		ll a;
		cin>>a;
		C[a]++;
	}
	REP(i,N){
		D[C[i+1]]++;
	}
	psmD[0]=psmkD[0]=0;
	REP(i,N+1){
		psmD[i+1]=psmD[i]+D[i];
		psmkD[i+1]=psmkD[i]+i*D[i];
	}
	REP(x,N){
		f[x]=(psmkD[x+2]+(x+1)*(psmD[N+1]-psmD[x+2]))/(x+1);
	}
	REP(x,N)f[x]*=-1;
	REP(i,N){
		ll ans=upper_bound(f,f+N,-(i+1))-f;
		if(ans==0){
			cout<<0<<endl;
		}else{
			cout<<ans<<endl;
		}
	}
}


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

int main()
{
    int n, m;
    while (cin >> n >> m, n | m)
    {
        int a[n], b[m];
        int sumA = 0;
        int sumB = 0;

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            sumA += a[i];
        }
        for (int i = 0; i < m; i++)
        {
            cin >> b[i];
            sumB += b[i];
        }

        int ai = 1e9, bi = 1e9;

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (sumA - a[i] + b[j] == sumB + a[i] - b[j] && a[i] + b[j] < ai + bi)
                {
                    ai = a[i];
                    bi = b[j];
                }
            }
        }

        if (ai == 1e9)
        {
            cout << -1 << "\n";
        }
        else
        {
            cout << ai << " " << bi << "\n";
        }
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

//最大公約数
int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main(){
    int N, K; cin >> N >> K;
    ll Max = 0;
    vector<ll> V(N); 
    for(int i = 0; i < N; i++) { 
        cin >> V[i]; 
        Max = max(Max, V[i]);
        if(V[i] == K){cout << "POSSIBLE" << endl; return 0;}
    }
    if(N == 1) {
        if(V[0] == K) cout << "POSSIBLE" << endl;
        else cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    if(Max < K){ cout << "IMPOSSIBLE" << endl; return 0;}

    ll GCD = gcd(V[0], V[1]);
    for(int i = 2; i < N; i++) GCD = gcd(GCD, V[i]);

    if(K % GCD == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    


}

Measured memory_bytes: 1024
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7

tenA = 0

N.times do |i|
  (i + 1).upto(N - 1) do |j|
    tenA += 1 if A[i] > A[j]
  end
end

tenB = 0

N.times do |i|
  N.times do |j|
    tenB += 1 if A[i] > A[j]
  end
end

puts (tenA * K + tenB * (K * (K - 1)) / 2) % MOD


Measured memory_bytes: 1788
n = int(input())
s = input()
l = [i for i in s]
ans = 'Yes'
if n%2 == 1:
  print('No')
else:
  for j in range(int(n/2)):
    if l[j] != l[int(j + n/2)]:
      ans = 'No'
      break
      
  print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
    for(int i=g;i<n;i++){
        int v = A[i];
        int j = i-g;
        while(j>=0&&A[j]>v){
            A[j+g] = A[j];
            j = j-g;
            cnt++;
        }
        A[j+g]=v;
    }
}

void shellSort(int A[],int n){
    /** \brief 
     *
     * \param 
     * \param 
     * \return 
     *int h=1;
    while(h<n){
        G.push_back(h);
        h = 3*h+1;
    }
     */                             
    int h=1;
    while(h<=n){
        G.push_back(h);
        h = 3*h+1;
    }
    for(int i=G.size()-1;i>=0;i--){
        insertionSort(A,n,G[i]);
    }
}


int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    cnt = 0;
    shellSort(A,n);
    cout<<G.size()<<endl;
    for(int i=G.size()-1;i>=0;i--){
        cout<<G[i];
        if(i) cout<<" ";
    }
    cout<<endl;
    cout<<cnt<<endl;
    for(int i=0;i<n;i++){
        cout<<A[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 7040
#include<cstdio>

using namespace std;

int gcd(int a,int b){
	if(!b) return a;
	else return gcd(b,a%b);
}

int main(void){
	int a,b;
	int g;

	for(;scanf("%d%d",&a,&b)==2;){
		g=gcd(a,b);
		printf("%d %d\n",g,a/g*b);
	}

	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace atcoder;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int K = 20;
const int KM = 1 << (K - 1);
int dat[1 << K];
int laz[1 << K];
int zero = 0;

void eval(int A, int l, int r) {
	if (laz[A] == zero) return;
	if (A * 2 < 1 << K) {
		laz[A * 2] = max(laz[A * 2], laz[A]);
		laz[A * 2 + 1] = max(laz[A * 2 + 1], laz[A]);
	}
	dat[A] = max(dat[A], laz[A]);
	laz[A] = zero;
}

int update(int L, int R, int X, int A, int l, int r) {
	eval(A, l, r);
	if (r <= L || R <= l) return dat[A];
	if (L <= l && r <= R) {
		laz[A] = max(laz[A], X);
		return max(dat[A], laz[A]);
	}
	dat[A] = max(update(L, R, X, A * 2, l, (l + r) / 2), update(L, R, X, A * 2 + 1, (l + r) / 2, r));
	return dat[A];
}

void add(int L, int R, int X) {
	update(L, R, X, 1, 0, KM);
}

int check(int L, int R, int A, int l, int r) {
	eval(A, l, r);
	if (r <= L || R <= l) return zero;
	if (L <= l && r <= R) return dat[A];
	return max(check(L, R, A * 2, l, (l + r) / 2), check(L, R, A * 2 + 1, (l + r) / 2, r));
}

int query(int L, int R) {
	return check(L, R, 1, 0, KM);
}

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


	int N, K;
	cin >> N >> K;

	rep(i, N) {
		int a;
		cin >> a;
		int b = query(a, a + 1);
		add(max(0, a - K), min(300300, a + K) + 1, b + 1);
	}

	co(query(0, 300300));

	Would you please return 0;
}

Measured memory_bytes: 8412
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define pb push_back
#define inin(x) int x; cin>>x;
#define ll long long
#define pb push_back

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

int main()
{
	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	cout << min(p*a, b + max(0, p - c)*d) << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N;
    cin>>N;
    vector<ll> x(N),y(N);
    rep(i,N){
        cin>>x[i]>>y[i];
    }
    double ans = 0;
    rep(i,N){
        rep(j,N){
            if(i==j) continue;
            double tmp = sqrtf(pow(x[i]-x[j],2.0)+pow(y[i]-y[j],2.0));
            ans += tmp;
        }
    }
    cout << fixed;
    ans /= N;
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define ll long long
#define ld long double


int main() {
	
	int n;
	cin >> n;
	int i = 0;
	while (n % 1000 != 0) {
		i++;
		n++;
	}
	cout << i << endl;
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(n); ll sum=0; int mi=inf;
   rep(i,0,n){int tmp; scanf("%d",&tmp); sum+=tmp; chmin(mi,tmp);}
   if(n&1)printf(sum&1?"First\n":"Second\n");
   else printf((sum&1)|(mi&1)?"First\n":"Second\n");
   return 0;
}


Measured memory_bytes: 3624