akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 998244353;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll w, s;
  cin >> s >> w;
  cout << ((w >= s) ? "unsafe" : "safe") << en;

  return 0;
}


Measured memory_bytes: 3640
def main():
    N, A, B = map(int, input().split())
    S = input()

    count = 0
    countB = 0
    for c in S:
        if count >= A+B:
            print("No")
        else:
            if c == "a":
                print("Yes")
                count += 1
            elif c == "b":
                if countB >= B:
                    print("No")
                else:
                    print("Yes")
                    count += 1
                    countB += 1
            else:
                print("No")


main()

Measured memory_bytes: 4024
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int cnt[3][SIZE];
int D[33][33];
int main(){
    int N,C;
    R(N,C);
    FOR(i,1,C)FOR(j,1,C)R(D[i][j]);
    FOR(i,1,N)FOR(j,1,N){
        int x;
        R(x);
        cnt[(i+j)%3][x]++;
    }
    int an=1e9;
    FOR(i,1,C)FOR(j,1,C)FOR(k,1,C){
        if(i==j||j==k||i==k)continue;
        int now=0;
        FOR(r,1,C)now+=cnt[0][r]*D[r][i]+cnt[1][r]*D[r][j]+cnt[2][r]*D[r][k];
        an=min(an,now);
    }
    W(an);
    return 0;
}


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

int main(){
    int A,B,C,X;
    cin >> A >> B >> C >> X;

    int r;

    int count=0;
    for(int i=A;i>=0;i--){
        for(int j=B;j>=0;j--){
            r=(X-i*500-j*100)/50;
            if(r<=C && r>=0) count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    int h;
    scanf("%d", &N);
    int Rh;
    int sum;
    scanf("%d", &Rh);
    for(int i=0; i<N-1; i++){
        scanf("%d", &h);
        if(h<Rh){
            sum += Rh-h;
        }
        Rh = h;
    }
    sum += Rh;
    printf("%d", sum);
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var i = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Console.WriteLine(string.Join("\n", Enumerable.Range(i[0], i[2]).Union(Enumerable.Range(i[1] - i[2] + 1, i[2])).Where(x => i[0] <= x && x <= i[1]).OrderBy(x => x).Select(x => x.ToString())));
    }
}

Measured memory_bytes: 13532
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0] == '7' || (s[1] == '7' || s[2] == '7')){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228
#define complex complex228

const int N = 55;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

int mod(int x) {
	x %= MOD;
	if (x < 0) x += MOD;
	return x;
}

int dp[N][N][N * N];

ghost main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, K;
	cin >> n >> K;
	dp[0][0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= i; ++j) {
			for (int k = 0; k <= K; ++k) {
				if (!dp[i][j][k]) continue;
				add(dp[i + 1][j][k + 2 * j], dp[i][j][k]);
				add(dp[i + 1][j + 1][k + 2 * (j + 1)], dp[i][j][k]);
				if (j) {
					add(dp[i + 1][j][k + 2 * j], mod(2 * j * dp[i][j][k]));
					add(dp[i + 1][j - 1][k + 2 * (j - 1)], mod(dp[i][j][k] * j * j));
				}
			}
		}
	}
	cout << dp[n][0][K] << '\n';
	return 0;
} // kek ;
// Ого! Кажетсья это $#@!










Measured memory_bytes: 65792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int n;
    cin >> n;
    rep(i,0,n){
        int a,b,c;
        cin >> a >> b >> c;
        a = pow(a,2);
        b = pow(b,2);
        c = pow(c,2);
        bool flag = false;
        if(a+b==c||b+c==a||c+a==b) flag = true;
        printf("%s\n", flag?"YES":"NO");
    }
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1005;
const int MOD=1e9+7;

int n, m, ans=1;
int r[N], c[N], a[N][N], f[N*N], pref[N*N], suf[N*N];
map<int, int> cnt, row, col;

int32_t main()
{
	IOS;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>r[i];
		row[r[i]];
	}
	for(int i=1;i<=m;i++)
	{
		cin>>c[i];
		col[c[i]];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			a[i][j]=min(r[i], c[j]);
			f[a[i][j]]++;
			if(r[i]==c[j])
				cnt[r[i]]++;
		}
	}	
	for(auto &it:cnt)
	{
		if(it.second>1)
		{
			cout<<0;
			return 0;
		}
	}
	for(int i=1;i<=n*m;i++)
	{
		pref[i]=pref[i-1] + f[i];
		if(pref[i]>i)
		{
			cout<<"0";
			return 0;
		}
	}
	int have=0;
	for(int i=n*m;i>=1;i--)
	{
		have+=f[i];
		if(cnt.find(i)!=cnt.end())
			ans*=1;
		else if(row.find(i)!=row.end())
		{
			int canhave=0;
			for(int j=1;j<=m;j++)
			{
				if(c[j]>=i)
					canhave++;
			}
			ans*=min(have, canhave);
		}
		else if(col.find(i)!=col.end())
		{
			int canhave=0;
			for(int j=1;j<=n;j++)
			{
				if(r[j]>=i)
					canhave++;
			}
			ans*=min(have, canhave);
		}
		else
			ans*=have;
		ans%=MOD;
		have--;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 21120
import heapq


n, k = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

q = []
for a, b in info:
    heapq.heappush(q, (a, b))

while q:
    a, b = heapq.heappop(q)
    if k <= b:
        print(a)
        exit()
    else:
        k -= b

Measured memory_bytes: 73176
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


def main():
	x,n=MI()
	p=[]
	if n!=0:
		p=LI()
	p.sort()

	diff=105
	ans=105

	for i in range(105,-1,-1):
		if i in p:
			continue
		else:
			if abs(i-x)<=diff:
				ans=i
				diff=abs(i-x)

	print(ans)













if __name__ == "__main__":
	main()


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;
 //code
    int n , k;

    cin >> n >> k;

    int ans = k;

    for(int i = 1 ; i < n ; ++i){
    	ans *= k-1;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i).sort
sign = Array.new(n,nil)
if a[0] >= 0 then
  puts a.inject(:+) - a[0] * 2
  cnt = a[0]
  (n - 2).times do |i|
    puts cnt.to_s + " " + a[i + 1].to_s
    cnt = cnt - a[i + 1]
  end
  puts a[n - 1].to_s + " " + cnt.to_s
elsif a[n - 1] <= 0 then
  puts a.inject(:+) * -1 + a[n - 1] * 2
  cnt = a[n - 1]
  (n - 1).times do |i|
    puts cnt.to_s + " " + a[i].to_s
    cnt = cnt - a[i]
  end
else
  puts a.map(&:abs).inject(:+)
  cnt = a[0]
  pos = n - 2
  while a[pos] >= 0
    puts cnt.to_s + " " + a[pos].to_s
    cnt = cnt - a[pos]
    pos -= 1
  end
  puts a[n - 1].to_s + " " + cnt.to_s
  cnt = a[n - 1] - cnt
  while pos > 0
    puts cnt.to_s + " " + a[pos].to_s
    cnt = cnt - a[pos]
    pos -= 1
  end
end

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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

int N, M;
string S;
static ll dp[3002][3002];

const ll MODP = 1000000007;
ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}

ll invMod(ll a, ll m) {
  ll x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;
  else                         return 0; // unsolvable
}


ll powmod(ll n, ll m){
	ll ret = 1;
	for(int i=0;i<m;i++){
		ret = (ret * n) % MODP;
	}
	return ret;
}


ll comb(ll n, ll m){
	if (m<0 || n<m) return 0; //failsafe
	ll ret = 1;
	for(int i=1;i<=m;i++){
		ret = (ret * (n-m+i)) % MODP;
		ret = (ret * invMod(i, MODP)) % MODP;
	}
	return ret % MODP;
}


int main(void){
	cin >> N >> M;
	cin >> S;
	int l[M], r[M], c[M];
	int sum[N+1]={0};
	for(int i=1;i<=N;i++){
		sum[i] = sum[i-1] + ((S[i-1]=='1') ? 1 : 0);
	}
	vpii a;
	int maxi = 0;
	for(int i=0;i<=M;i++){
		if (i<M){
			cin >> l[i] >> r[i];
		}
		if (i==M || (i>0 && l[i]>l[i-1])){
			a.pb(mp(l[i-1], maxi));
			maxi = 0;
		}
		if (i<M){
			maxi = max(maxi, r[i]);
		}
	}
	vpii b;
	maxi = -1;
	for(int i=0;i<a.size();i++){
		if (maxi < a[i].second){
			b.pb(a[i]);
			maxi = a[i].second;
		}
	}
	for(int i=0;i<b.size();i++){
		c[i] = sum[b[i].second] - sum[b[i].first-1];
		b[i].first--;
		//cout << b[i].first << " " << b[i].second << " " << c[i] << endl;
	}
	
	dp[0][c[0]] = 1;
	for(int i=0;i+1<b.size();i++){
		if (b[i].second > b[i+1].first){
			for(int j=0;j<=b[i].second-b[i].first;j++){
				for(int k=0;k<=b[i+1].second-b[i+1].first;k++){
					int d = sum[b[i+1].second] - sum[b[i].second];
					int c1 = j - k + d;
					int c2 = k - d;
					//cout << i << " " << j << " " << k << " " << d << endl;
					if (d<0 || c1<0 || c2<0 || c2>b[i].second-b[i+1].first) continue;
					dp[i+1][k] = (dp[i+1][k] + dp[i][j] * comb(b[i+1].first - b[i].first, c1)) % MODP;
				}
			}
		}else{
			for(int j=0;j<3002;j++){
				dp[i+1][c[i+1]] = (dp[i+1][c[i+1]] + dp[i][j] * comb(b[i].second - b[i].first, j)) % MODP;
			}
		}
	}
	/*
	for(int i=0;i<b.size();i++){
		cout << "i = " << i << endl;
		for(int j=0;j<3002;j++){
			if (dp[i][j]!=0){
				cout << "dp[i][" << j << "] = " << dp[i][j] << endl;
			}
		}
	}
	*/
	ll ans = 0;
	for(int i=0;i<3002;i++){
		ans = (ans + dp[b.size()-1][i] * comb(b[b.size()-1].second - b[b.size()-1].first, i)) % MODP;
	}
	cout << ans << endl;
	
	
	
	
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    int n, m;
    std::cin >> n >> m;
    std::uint32_t x = (1 << m) - 1;
    for (int i : boost::irange(0, n)) {
        std::uint32_t y = 0;
        int k = read<int>();
        for (auto j : boost::irange(0, k)) {
            y |= 1 << (read<int>() - 1);
        }
        x &= y;
    }
    out(__builtin_popcount(x));
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


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

int main()
{
    long long n,k=0,i=0,j=0,t=0;


   cin>>n;
   while(n--)
   {
       string s;
       cin>>s;
       if(s=="AC")
        k++;
       else if(s=="WA")
        i++;
       else if(s=="TLE")
        j++;
       else if(s=="RE")
        t++;

   }
   //if(k!=0)
   cout<<"AC x "<<k<<endl;
    //if(i!=0)
   cout<<"WA x "<<i<<endl;
   //if(j!=0)
   cout<<"TLE x "<<j<<endl;
   //if(t!=0)
   cout<<"RE x "<<t<<endl;





return 0;

}



Measured memory_bytes: 3628
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//参照http://www27.atpages.jp/tasuku/pro/3_algo.pdf 

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int main()
{
  int n;
  cin >>n;
  int ans=n;
  vector<int> a(n),b(n);//スタート、ゴールから
  for(int i = 0;i < n;i++){
    cin>>a[i];
    b[i] = i+1;
  }//d[v] =スタートからの距離,h[v]=ゴールからの距離
  map<vector<int>,int> d,h;
  //解は最大でもn-1;
  //ゴールから探索
  {
    h[b] = 0;
    queue<vector<int> > q;
    q.push(b);
    while(!q.empty()){
      vector<int> v = q.front();
      int cost = h[v];
      q.pop();
      if(v ==a){//一致するなら
	ans = cost;
	break;
      }
      if(cost >=4)
	break;
      for(int i = 0;i < n;i++){
	for(int j = i+1;j < n;j++){
	  vector<int> next = v;
	  reverse(next.begin()+i,next.begin()+j+1);
	  if(!h.count(next)){//まだ無ければ追加
	    h[next] = cost+1;
	    q.push(next);
	  }
	}
      }
    }
  }
    //スタートからの探索
    {
      d[a] = 0;
      queue<vector<int> > q;
      q.push(a);
      while(!q.empty()){
	vector<int> v = q.front();
	int cost = d[v];
	q.pop();
	if(h.count(v)){
	  ans = cost + h[v];
	  break;
	}
	if(cost >=4){
	  break;
	}
	for(int i = 0;i < n;i++){
	  for(int j = i+1;j < n;j++){
	    vector<int> next = v;
	    reverse(next.begin()+i, next.begin()+j+1);
	    if(!d.count(next)){
	      d[next] = cost +1;
	      q.push(next);
	    }
	  }
	}
      }
    }
    if(ans ==n){
      ans =n-1;
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 81196
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;

namespace AtCoderer
{
    public class App
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = new string[n];
            var v = new int[n];
            for(int i = 0;i<n;i++)
           {
               var r = Console.ReadLine().Split();
               s[i]=r[0];v[i]=int.Parse(r[1]);
           }
          Console.WriteLine(string.Join("\n",s.Zip(v,(x,y)=>new {s=x,v=y}).Select((x,i)=>new{x.s,x.v,ind=i}).OrderBy(x=>x.s).ThenByDescending(x=>x.v).Select(x=>x.ind+1)));
        }
    }
}

Measured memory_bytes: 13792
#include <iostream>
using namespace std;
struct Dice{
    int a[6];
    void D(char c) {
        int b;
        
        if (c == 'E') {
            b=a[0]; a[0]=a[3]; a[3]=a[5]; a[5]=a[2]; a[2]=b;
        } else if (c == 'W') {
            b=a[0]; a[0]=a[2]; a[2]=a[5]; a[5]=a[3]; a[3]=b;
        } else if (c == 'S') {
            b=a[0]; a[0]=a[4]; a[4]=a[5]; a[5]=a[1]; a[1]=b;
        }else {
            b=a[0]; a[0]=a[1]; a[1]=a[5]; a[5]=a[4]; a[4]=b;
        }
    }
};

int main() {
    Dice dice;
    
    for (int i = 0; i < 6; i++) {
        cin >> dice.a[i];
    }
    string s;
    cin >> s;
    
    for (int i = 0; i < s.size(); i++) {
        dice.D(s[i]);
    }
    
    cout << dice.a[0] << endl;
    
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;

void solve() {
    int n;
    cin >> n;
    vll a(n);
    fori(i,0,n) cin >> a[i];
    ll r = 0, total = a[0] + a[1];
    fori(i,2,n) r ^= a[i];
    ll x = -1e16, y = 0; 
    rep(i,45,0) {
        if(r & (1ll << i)) {
            if(a[0] & (1ll << i)) {
                x += (1ll << i);
                x = max(x,y);
                y += (1ll << i);
            }
            else{
                x += (1ll << i);
            }
            total -= (1ll << i);    
        }
        else {
            if(total >= (1ll << (i + 1))){
                if(!(a[0] & (1ll << i))) {
                    y = -1e16; 
                }
                x += (1ll << i);
                y += (1ll << i);
                total -= (1ll << (i + 1));
            }
            else {
                if(a[0] & (1ll << i)) {
                    x = max(x,y);
                }
            }
        }
    }
    if(total == 0 && (x > 0 || y > 0)) {
        if(r == max(x,y)^(a[0] + a[1] - max(x,y))) {
            cout << a[0] - max(x,y) << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
    solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3648
import sys

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

for x in range(N+1):
    if x*10000 > Y:
        break
    if Y - x*10000 > (N-x)*5000:
        continue
    for y in range(N+1-x):
        z = N - (x + y)
        if (x*10000 + y*5000 + z*1000) == Y:
            print(x,y,z)
            sys.exit()

print(-1,-1,-1)


Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::*;

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parsing")
}

fn main() {
  let a: u32 = read::<u32>();
  let b: u32 = read::<u32>();

  let mut aa: String = String::from("");
  let mut bb: String = String::from("");

  for _ in 0..b {
    aa = aa + &a.to_string();
  }
  for _ in 0..a {
    bb = bb + &b.to_string();
  }

  if aa.parse::<u32>().unwrap() > bb.parse::<u32>().unwrap() {
    println!("{}", aa);
  } else {
    println!("{}", bb);
  }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
//#include "atcoder/all"
//using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	vector<int>a(1000100, 1);
	FOR(i, 1, 1000100) {
		for(int j = i + i; j < 1000100; j += i) {
			a[j] += 1;
		}
	}
	int N;
	cin >> N;
	int ans = 0;
	FOR(i, 1, N) {
		ans += a[N - i];
	}
	out(ans);
}

Measured memory_bytes: 10984
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let mut v: Vec<Vec<i32>> = Vec::new();
    for _ in 0..2 {
        v.push(get!([i32]));
    }
    let mut dp = vec![vec![0; n + 1]; 2];
    dp[0][0] = v[0][0];
    for i in 0..2 {
        for j in 0..n {
            if i == 0 && j == 0 {
                continue;
            }
            if 1 <= i && 1 <= j {
                dp[i][j] = std::cmp::max(dp[i - 1][j] + v[i][j], dp[i][j - 1] + v[i][j]);
            } else {
                if i == 0 {
                    dp[i][j] = dp[i][j - 1] + v[i][j];
                }
                if j == 0 {
                    dp[i][j] = dp[i - 1][j] + v[i][j];
                }
            }
        }
    }
    println!("{}", dp[1][n - 1]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b;
    cin >> a >> b;
    if (a * b % 2 == 0) {
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
    return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;


int mod = 998244353;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    pair<int, int> rng[K]; rep(i, K) cin >> rng[i].first >> rng[i].second;
    vector<ll> work(N+1, 0);
    vector<ll> dp(N+1, 0);
    dp[1] = 1;
    for(int i = 1; i < N; i++){
        dp[i] += work[i-1];
        rep(j, K){
            pair<int, int> pi = rng[j];
            work[min(N, i + pi.first - 1)] = (work[min(N, i + pi.first - 1)] + dp[i] + mod) % mod;
            work[min(N, i + pi.second)] = (work[min(N, i + pi.second)] - dp[i] + mod) % mod;
        }
        work[i] = (work[i] + work[i-1]) % mod;
    }
    dp[N] += work[N-1];
    //rep(i, N+1) cout << dp[i] << " "; cout << endl;
    cout << dp[N] % mod << endl;
    return 0;
}

Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  bool flag=true;
  for(auto i:arr){
  if(i%2==0){
  if(i%3 ==0 || i%5==0)
    ;
    else{
      flag=false;
      break;
    }

  }

  }
   if(flag)
      cout<<"APPROVED";
    else
      cout<<"DENIED";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int N, K;
vec< int > a;
#define MAXN 5000
#define MAXK 5000
bool l[MAXN + 1][MAXK + 1];
bool r[MAXN + 1][MAXK + 1];

bool isOK(int id) {
  if (id == -1)
    return true;
  if (id == N)
    return false;
  bool flg[MAXK + 1] = {false};
  FORS(v0, 0, K) {
    if (!l[id][v0])
      continue;
    FORS(v1, 0, K) {
      if (!r[N - 1 - id][v1])
        continue;
      if (v0 + v1 <= K)
        flg[v0 + v1] = true;
    }
  }
  int begin = K - a[id];
  chmax(begin, 0ll);
  chmin(begin, K);
  int end = K;
  chmax(end, 0ll);
  chmin(end, K);
  int pos = count(flg + begin, flg + end, true);
  return pos <= 0;
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N >> K;
  a.resize(N);

  REP(i, N) { cin >> a[i]; }
  sort(ALL(a));
  l[0][0] = true;
  r[0][0] = true;
  REP(i, N) {
    FORS(j, 0, K) { l[i + 1][j] = l[i][j]; }
    FORS(j, 0, K) {
      if (l[i][j]) {
        int val = j + a[i];
        if (val <= K) {
          l[i + 1][val] = true;
        }
      }
    }
  }

  REP(i, N) {
    FORS(j, 0, K) { r[i + 1][j] = r[i][j]; }
    FORS(j, 0, K) {
      if (r[i][j]) {
        int val = j + a[N - 1 - i];
        if (val <= K) {
          r[i + 1][val] = true;
        }
      }
    }
  }

  int left = -1, right = N;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (isOK(mid)) {
      left = mid;
    } else {
      right = mid;
    }
  }
  print(right);
}
// https://pyteyon.hatenablog.com/entry/2019/02/20/194140

Measured memory_bytes: 49152
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef map<int,int> MPi; typedef pair<Int,Int> Pl; typedef int8_t shor;
const int mod = 1e9+7; const Int INF=1e18+1LL;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en,h) for(int i=st; i<=en; i+=h)
#define PU push_back
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;

int n,a,b,c; V(int) bw;

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

	cin>>n; WeightedGraph<int> g(n); bw.assign(n,-1);
	for (int i = 0; i < n-1; i++){
		cin>>a>>b>>c; c%=2;
		g[--a].emplace_back(--b,c);
		g[b].emplace_back(a,c);
	}
	queue<int> q; q.push(0); bw[0]=0;
	while(!q.empty()){
		int p=q.front(); q.pop();
		for(auto e:g[p]){
			if(!(bw[e]+1)){
				bw[e]=(bw[p]+e.cost)%2; q.push(e);
			}
		}
	}
	for (int i = 0; i < n; i++)cout<<bw[i]<<'\n';
}

Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#define REP(i, n) for(int i=0; i<n; i++)
using namespace std;

int main()
{
	int K, X;
	cin >> K >> X;
	vector<int> V;
	int left, right;
	left = -10000;
	right = 10000;
	if (-10000 <= X-K)
	{
		left = X - K + 1;
	}
	if (X - K <= 10000)
	{
		right = X + K -1;
	}
	for (int v = left; v <= right; v++)
	{
		V.push_back(v);
	}

	REP(i, V.size())
	{
		cout << V[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
auto solve() -> void {
    int n; cin >> n;
    vector<pair<int, int>> a(n);
    int last = -1;
    int ct = 0;
    bool can = false;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
        if (a[i].first != a[i].second) {
            ct = 0;
        } else {
            ct++;
        }
        if (ct >= 3) can = true;
    }
    if (can) cout << "Yes\n";
    else cout << "No\n";
}
auto main() -> int {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    while (tc--) {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;

ll t=1;

void solve()
{
    cin>>n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)cin>>v[i];
    c=0;
    for(ll i=1;i<n;i++)
    {
        if(v[i]<v[i-1])c+=(v[i-1]-v[i]),v[i]=v[i-1];
    }
    cout<<c;
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 4776
S = input()
l = len(S)
cnt = 0
cnt2 = 0
for i in range(l):
	if (S[i] != 'A' and i == 0):
		print("WA")
		exit(0)

	if (2 <= i and i < l-1 and S[i] == 'C'):
		cnt += 1

	if S[i].isupper():
		cnt2 += 1


if (cnt != 1 or cnt2 != 2):
	print("WA")
	exit(0)

print("AC")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll gcd(ll a, ll b){
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
vll extgcd(ll a, ll b) {
  ll x, y;
  for (ll u = y = 1, v = x = 0; a;) {
    ll q = b / a;
    swap(x -= q * u, u);
    swap(y -= q * v, v);
    swap(b -= q * a, a);
  }
  return vll{x, y, b};
}
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  ll s = 0;
  vll a(n);
  re(i, n){
    scanf("%lld", &a[i]);
    s += a[i] - 1;
  }
  if(n==1){
    std::cout << (a[0]==1?"Second":"First") << '\n';
    return 0;
  }
  if(s%2==1){
    std::cout << "First" << '\n';
    return 0;
  }

  ll tm = 0;
  while(true){
    ll idx = -1;
    bool flag = true;
    for(int i=0;i<n;i++){
      if(a[i]%2==1) {
        if(idx!=-1||a[i]==1){
          flag = false;
          break;
        }
        idx = i;
      }
    }
    if(!flag) break;
    a[idx]--;
    ll g = a[0];

    for(int i=1;i<n;i++) g = gcd(g, a[i]);
    ll p = 0;
    for(int i=0;i<n;i++) p += (a[i] - 1);
    ll t = 0;
    for(int i=0;i<n;i++){
      a[i]/=g;
      t += a[i] - 1;
    }
    if(p%2==t%2) break;
    tm++;
  }
  //std::cout << tm << '\n';
  std::cout << (tm%2?"First":"Second") << '\n';
  return 0;
}


Measured memory_bytes: 1024
c =  input()
if c == 'a':
    flag = 1
elif c=='i':
    flag = 1
elif c=='u':
    flag = 1
elif c=='e':
    flag = 1
elif c=='o':
    flag = 1
else :
    flag = 0;

if flag == 1:
    print('vowel')
else :
    print('consonant')

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

class Main{
  static boolean found = false;
  public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st  = new StringTokenizer(br.readLine());

    int N = Integer.parseInt(st.nextToken());
    
    st  = new StringTokenizer(br.readLine());

    int[] arr = new int[N];

    for (int i=0; i<N; i++) {
      arr[i] = Integer.parseInt(st.nextToken());
    }

    long ans = 0;

    for (int i=1; i<N; i++) {
      if(arr[i]<arr[i-1]){
        ans+=arr[i-1]-arr[i];
        arr[i] = arr[i-1];
      }
    }

    out.println(ans);

    out.close();
  }

  
}










Measured memory_bytes: 55164
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
typedef unsigned long long wolf;
vector<wolf>v[700];
int d[30][30];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&b,&a,&c),a){
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&d[i][j]);
		int sz=a*b/64+1;
		int n=a*b;
		for(int i=0;i<n;i++)v[i]=vector<wolf>(sz,0);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			for(int k=0;k<a;k++)for(int l=0;l<b;l++){
				int dis=ABS(i-k)+ABS(j-l);
				if(dis==0||dis==c){
					v[i*b+j][(k*b+l)/64]^=(1LL<<((k*b+l)%64));
				}
			}
		}

		int last=a*b%64;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if(d[i][j])v[i*b+j][sz-1]+=(1LL<<last);
			}
		}
	/*	for(int i=0;i<n;i++){
			for(int j=0;j<sz;j++)printf("%llu ",v[i][j]);
			printf("\n");
		}
	*/	for(int i=0;i<n;i++){
			int at=-1;
			for(int j=i;j<n;j++){
				if(v[j][i/64]&(1LL<<(i%64))){at=j;break;}
			}
			if(!~at)continue;
			if(i!=at)swap(v[i],v[at]);
			for(int j=0;j<n;j++){
				if(j==i)continue;
				if(v[j][i/64]&(1LL<<(i%64))){
					for(int k=0;k<sz;k++)v[j][k]^=v[i][k];
				}
			}
		}
		bool ok=true;
		for(int i=0;i<n;i++){
			if(v[i][sz-1]&(1LL<<last)){
				bool OK=false;
				for(int j=0;j<n;j++)if(v[i][j/64]&(1LL<<(j%64)))OK=true;
				if(!OK)ok=false;
			}
		}
		if(ok)printf("1\n");
		else printf("0\n");
	}
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define MOD 1000000007
int n, k, a[200009];
LL check(int x) {
	LL ret = 0;
	rep(i, n)ret += (LL)ceill((Lf)a[i] / (Lf)x) - 1;
	return ret;
}

int main(void) {
	in("%d%d", &n, &k);
	rep(i, n)in("%d", &a[i]);
	int p = 0, q = MOD / 2, r = MOD, ans = n;
	while (r - p > 1) {
		if (check(q) <= (LL)k) r = q;
		else p = q;
		q = (p + r) / 2;
	}
	if (check(r) <= k)ans = r;
	if (check(q) <= k)ans = q;
	if (check(p) <= k)ans = p;
	printf("%d\n", ans ? ans : 1);
	return 0;
}

Measured memory_bytes: 2892
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    double l;
    cin>>l;
    printf("%.10f\n",l*l*l/27.0);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
sorted_X = sorted(X)
sorted_indices = sorted(range(len(X)), key=lambda k: X[k])
median_index = N // 2 - 1
ans = []
for i, x in enumerate(sorted_X):
    if i <= median_index:
        ans.append((sorted_indices[i], sorted_X[median_index + 1]))
    elif median_index < i:
        ans.append((sorted_indices[i], sorted_X[median_index]))
ans = sorted(ans, key=lambda x: x[0])
for x in ans:
    print(x[1])


Measured memory_bytes: 124888
S = set(list(input()))

if len(S) == 4:
    print('Yes')
elif len(S) == 1 or len(S) == 3:
    print('No')
else:
    if {'N', 'S'} == S or {'W', 'E'} == S:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
ll l[1000001];
bool mark[1000001];
void solve()
{
  ll n;
  cin>>n;
  
  ll ans=0;
  
  if(n!=1){
      // ll res=1;
      for(ll i=1;i<n;i++){
          ll x=n-i;
         ll res=1;
            while(l[x]>1){
                ll tmp=0;
                ll y=l[x];
                
                while(x>1&&x%y==0){
                    x/=y;
                    tmp++;
                }
                
                res*=(1+tmp);
            }
           
           ans+=res;
          }
          
      
  }
  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.
  memset(mark,false,sizeof(mark));
  
  l[1]=1;
  for(ll i=2;i<1000001;i++){
      if(!mark[i]){
          l[i]=i;
          
          for(ll j=i*i;j<1000001;j+=i){
              if(!mark[j]){
                  mark[j]=true;
                  l[j]=i;
              }
          }
      }
  }
  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 12404
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))

def sol(y):
    B = [[]]
    for a in A:
        if a < y and len(B[-1]) > 0:
            B.append([])
        if a >= y:
            B[-1].append(a)

    C = []
    for grp in B:
        grp.sort()
        C += grp[:max(0, len(grp) - K + 1)]
    C.sort()

    return C[Q - 1] - y if len(C) >= Q and C[0] == y else 10**18

ans = 10**18
for y in A:
    ans = min(ans, sol(y))

print(ans)


Measured memory_bytes: 3316
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 String UN = "UNRESTORABLE";
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sc.close();
		boolean f=false;
		int d = s.length - t.length;
		ArrayList<String> ans = new ArrayList<>();
		for (i = 0; i <= d; i++) {
			char[] ss = new char[s.length];
			for (j = 0; j < i; j++) {
				ss[j]=s[j]=='?'?'a':s[j];
			}
			for (j = 0; j < t.length; j++) {
				if(s[i+j]!=t[j]&&s[i+j]!='?') {
					break;
				}
				ss[i+j]=t[j];
			}
			if(j==t.length) {
				for (j=i+t.length;j < s.length; j++) {
					ss[j]=s[j]=='?'?'a':s[j];
				}
				ans.add(new String(ss));
				f=true;
			}
		}
		Collections.sort(ans);
		out.println(f?ans.get(0):UN);
	}
}


Measured memory_bytes: 25172