akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main()
{
  finp;
  ll n,m;
  string s,t;
  cin>>n>>m>>s>>t;
  
  ll lc = (n*m)/__gcd(n,m);


  ll p1 = 0;
  ll p2 = 0;
  
  ll sz = lc;
  //while((sz/n) < n)sz+=lc;
  //while((sz/m) < m)sz+=lc;
  map<int,char> my;
  afor(i,0,n-1)
  {
    my[i*(sz/n) + 1] = s[i];
  }
  afor(i,0,m-1)
  {
    if(my.count(i*(sz/m) + 1) && my[i*(sz/m) + 1]!=t[i])
    {
      cout<<"-1";
      return 0;
    }
  }
  cout<<sz;

  
return 0;
}

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

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

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;


int main(){
    ll h; cin>>h;
    ll ans = 0,i = 1;
    while(h>0){
        h /=2;
        ans+= i;
        i *=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 2e18;
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vector<ll> b;
    rrep(i, n) {
        b.push_back(-a[i]);
    }

    ll ok = -LINF, ng = LINF, mid;
    while (ng - ok > 1) {
        mid = (ok + ng) / 2;
        // mid = 6;
        ll sum = 0;
        rep(i, n) {
            int nok, nng, nmid;
            if (a[i] >= 0) {
                nok = -1, nng = n;
                while (nng - nok > 1) {
                    nmid = (nok + nng) / 2;
                    (a[nmid] * a[i] < mid ? nok : nng) = nmid;
                }
                sum += (ll)(nok + 1);
            } else {
                nok = n, nng = -1;
                while (nok - nng > 1) {
                    nmid = (nok + nng) / 2;
                    (a[nmid] * a[i] < mid ? nok : nng) = nmid;
                }
                sum += (ll)(n - nok);
            }
        }
        rep(i, n) {
            if (a[i] * a[i] < mid) sum--;
        }
        sum /= 2;
        (sum < k ? ok : ng) = mid;
        // cout << mid << " " << sum << endl;
    }
    cout << ok << endl;
}


Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main (void) {
    int a, b, c;
    cin >> a >> b >> c;

    if (a < b && a < c){
        if(b < c){
            cout << a + b << endl;
        }else{
            cout << a + c << endl;
        }
    }else if(b < a && b < c){
        if(c < a){
            cout << b + c << endl;
        }else{
            cout << b + a << endl;
        }
    }else{
        if(a < b){
            cout << c + a << endl;
        }else{
            cout << c + b << endl;
        }
    }

    
    return 0;
}


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


using namespace std;


using ll = long long;


bool search(vector<ll> &A, ll m, ll d)
{
    if (m == 0)
        return true;
    else if (d < 0)
        return false;

    bool ret = search(A, m - A[d], d - 1);
    ret = ret || search(A, m, d - 1);
    return ret;
}


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

    vector<ll> A(n);

    for (ll i = 0; i < n; i++)
        cin >> A[i];

    cin >> q;
    for (ll i = 0; i < q; i++) {
        ll tmp;
        cin >> tmp;
        if (search(A, tmp, n)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
std::vector<int> v;
int dp[201][100005];
int f(int i,int x){
  if(dp[i][x]!=-1)return dp[i][x];
  if(i==0)return dp[i][x]=x%v[0];
  int res=0;
  res+=f(i-1,x%v[i]);
  res+=f(i-1,x)*i;
  res%=MOD;
  return dp[i][x]=res;
}

//main
signed main(){
  int N,X;cin>>N>>X;
  memset(dp,-1,sizeof(dp));
  v.resize(N);for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  cout<<f(N-1,X)<<endl;
}


Measured memory_bytes: 157312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	string s,t;cin>>s>>t;
	int n=s.size(),m=t.size();
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());	
	int smin=s[0],tmax=t[m-1];
	//cout<<smin<<" "<<tmax<<endl;
	if(smin<tmax) cout<<"Yes"<<endl;
	else{
		int chk=0;
		for(int i=0;i<min(n,m);i++){
			if(s[i]==t[i]) continue;
			else if(s[i]<t[i]){
				chk=1;
				break;
			}
			else{
				chk=2;
				break;
			}
		}
		if(chk==0){
			if(n<m) chk=1;
			else chk=2;
		}
		if(chk==1) cout<<"Yes"<<endl;
		else if(chk==2) cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

double dist(int x1, int y1, int x2, int y2) {
  return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

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

	int n;
	cin >> n;
	int x[n], y[n];
	rep(i, n) cin >> x[i] >> y[i];

	double res = 0;

	rep(i, n) {
		REP(j, i + 1, n) {
			res += dist(x[i], y[i], x[j], y[j]) * (n - 1) * 2;
		}
	}


	fcout << res / (n * (n - 1)) << endl;
	return 0;
}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define INF_INT 2147483647

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}



int main(){
    
    long N,K; cin >> N >> K;
    std::vector<long long> x;
    for(long i=0; i<N; i++){
        long long temp; cin >> temp;
        x.push_back(temp);
    }

    long long ans = 9223372036854775807;
    for(long i=0; i<N-K+1; ++i){
        long left = i;
        long right = i+K-1;
        if(x[left]*x[right]<0){
            ans = min(ans, min(abs(x[right]-x[left])+abs(x[right]), abs(x[right]-x[left])+abs(x[left])));
        } else {
            ans = min(ans, max(abs(x[right]), abs(x[left])));
        }
    }

    cout << ans << endl;
    
    return 0;

}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <limits.h>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  string A,B;
  cin >> A >> B;
  if(A.size()!=B.size()){
    if(A.size()>B.size()){
      cout << "GREATER" << endl;
      return 0;
    }
    else{
      cout << "LESS" << endl;
      return 0;
    }
  }
  rep(i,A.size()){
    if(ctoi(A[i])>ctoi(B[i])){
      cout << "GREATER" << endl;
      return 0;
    }
    if(ctoi(A[i])<ctoi(B[i])){
      cout << "LESS" << endl;
      return 0;
    }
  }
  cout << "EQUAL" << endl;
} 


Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int cnt[100100];

int main(void){
	int n,d,i,p=0,ans=0;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> d;
		++cnt[d];
	}
	n /= 2;
	for(i=0; i<100100; ++i){
		p += cnt[i];
		if(p == n){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
const int maxn=5e5+10;
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}

int t,n,m,k;
int gg[205][205];
int main(){
    rep(i,1,200) rep(j,1,200) gg[i][j]=__gcd(i,j);
    scanf("%d",&n);
    ll s=0;
    rep(i,1,n) rep(j,1,n) rep(k,1,n) s+=__gcd(gg[i][j],k);
    printf("%lld\n",s);
    return 0;
}




//const int M=1<<20;
//ll t1[M*2+5],t2[M*2+5],ans,ca[M],cb[M];
//inline void upd(int i){t1[i]=t1[i<<1]+t1[i<<1|1];t2[i]=max(t2[i<<1],t1[i<<1]+t2[i<<1|1]);}
//inline void add(int i,int v){for(t1[i+=M]+=v;i>>=1;upd(i));}
//int n,m,p,x,y,i,j;
//struct mons{int x,y,z;}a[M];
//int main(){
//	for(i=0;i<M;++i)ca[i]=cb[i]=1ll<<60;ans=-(1ll<<60);
//	scanf("%d%d%d",&n,&m,&p);
//	for(i=1;i<=n;++i)scanf("%d%d",&x,&y),ca[x]=min(ca[x],(ll)y);
//	for(i=1;i<=m;++i)scanf("%d%d",&x,&y),cb[x]=min(cb[x],(ll)y);
//	for(i=0;i<M;++i)t2[i+M]=-cb[i];for(i=M-1;i;--i)upd(i);
//	for(i=1;i<=p;++i)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
//	sort(a+1,a+p+1,[&](const mons&a,const mons&b){return a.x<b.x;});
//	for(i=0,j=1;i<M;++i){
//		for(;j<=p && a[j].x<i;++j)add(a[j].y,a[j].z);
//		ans=max(ans,t2[1]-ca[i]);
//	}
//	printf("%lld\n",ans);
//	return 0;
//}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
 
int main() {
  unsigned long counter=0;
  int N;
  cin >> N ;
  map<string, long> DB;
  
  for(int i=0; i<N; i++){
    std::vector<char> buf(10);
    string hoge = "";
    for(int k=0; k<10; k++)
      cin >> buf.at(k);
    sort(buf.begin(), buf.end());
    for(int k=0; k<10; k++)
      hoge += buf.at(k);
    if(DB.count(hoge))
      DB[hoge]++;
    else
      DB[hoge]=1;
  }
  
  string name;
  unsigned long val;
  for(auto p : DB){
    auto val = p.second;
    counter += ((val-1)*val/2);
  }
  
  cout << counter <<endl;
  
  return 0;
}//endmain


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

if sum(A) == 0:
    print("Yes")
    exit(0)

cnt = {}
for a in A:
    if a not in cnt:
        cnt[a] = 1
    else:
        cnt[a] += 1

if len(cnt) == 2:
    if cnt[0] == N // 3:
        print("Yes")
        exit(0)

if len(cnt) == 3:
    k1, k2, k3 = cnt.keys()
    v1, v2, v3 = cnt.values()
    if not (k1 ^ k2 ^ k3):
        if v1 == v2 and v2 == v3:
            print("Yes")
            exit(0)

print("No")


Measured memory_bytes: 60784
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using T=tuple<ll,ll,vl>;
ll INF=1LL<<60;
ll MOD=1000000007;
vector<ll> longest(200001,1);
vector<vector<ll>> gr(200001, vector<ll>(0));
vector<ll> d(200001,INF);
vector<ll> a(200001,0);

void dfs(ll x,vl &vec){
    for(auto k:gr[x]){
        if(d[k]==d[x]+1){
            auto x=lower_bound(vec.begin(), vec.end(), a[k]);
            auto y=*x;
            *x=a[k];
            longest[k]=lower_bound(vec.begin(), vec.end(), INF)-vec.begin();
            dfs(k,vec);
            *x=y;
        }
    ;}
}



int main(){
    ll N;
    cin >> N;
    vector<ll> u(N-1,0);
    vector<ll> v(N-1,0);
    for(ll i=0;i<N;i++){
        cin>>a[i]
    ;}
    for(ll i=0;i<N-1;i++){
        cin>>u[i]>>v[i];
        u[i]--;v[i]--;
    ;}
    for(ll i=0;i<N-1;i++){
        gr[u[i]].emplace_back(v[i]);
        gr[v[i]].emplace_back(u[i]);
    ;}

    d[0]=0;
    queue<ll> qu;
    //訪問フラグ
    vector<ll> check(N,0);
    check[0]=1;

    //bfs
    qu.push(0);
    while(!qu.empty()){
        ll x=qu.front();
        qu.pop();
        for(ll i=0;i<gr[x].size();i++){
             ll k=gr[x][i];
             if(check[k])continue;
             d[k]=d[x]+1;
             qu.push(k);
             check[k]=1;
        }
        
    }

    vector<ll> vec(N,INF);
    vec[0]=a[0];


    dfs(0,vec);

    for(ll i=0;i<N;i++){
        cout<<longest[i]<<endl;
    ;}



    return 0;
}


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

int main(){
    string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
let (n, m) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n m -> (n, m)
let ab = Array.init m @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a, b)

let cnt = Array.make 100_001 0

let () =
  Array.iter (fun (a, b) ->
    cnt.(a) <- cnt.(a) + 1;
    cnt.(b) <- cnt.(b) + 1
  ) ab;
  print_endline @@ if Array.for_all (fun cnt -> cnt mod 2 = 0) cnt then "YES" else "NO"

Measured memory_bytes: 10016
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

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

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int half = min(x[i], k - x[i]);
    ans += half * 2;
  }
  cout << ans << endl;
}


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

const int N = 1e5 + 10;
int a[N], b[N];
map<int, int> mp;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b + n);
    for (int i = 0; i < n; i++)
        mp[b[i]] = i;
    int ans = 0;
    for (int i = 0; i < n; i++)
        if (i % 2 != mp[a[i]] % 2)
            ans++;
    ans /= 2;
    cout << ans;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 10001;

int prime[N];
bool is_prime[N+1];

int sieve(){
  int p =0;
  for(int i=0;i<=N;i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(int i=2;i<=N;i++){
    if(is_prime[i]){
      prime[p++] = i;
      for(int j=2*i;j<=N;j+=i) is_prime[j] = false;
    }
  }
  return p;
}

int main(){
  int n,p = sieve();
  while(cin >> n && n){
    int a[N], head = 0, tail = 0, ans = 0;

    for(int i=0;i<p;i++){
      if(prime[i] > n) break;
      a[tail++] = 0;
      for(int j=head; j<tail; j++){
	a[j] += prime[i];
	if(a[j] >= n){
	  if(a[j] == n) ans++;
	  head++;
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
static bool larger(const int& a, const int& b) {return a > b;}
int main()
{
  int N;
  cin >> N;
  vector <int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end(), larger);
  int l = 0, s = 0, pl = 0, ps = 0;
  for (int i = 0; i < N; i++) {
    if (l == 0) {
      if (A[i]==pl) {
        l = pl;
      } else {
        pl = A[i];
      }
    } else if (s == 0) {
      if (A[i]==ps) {
        s = ps;
      } else {
        ps = A[i];
      }
    }
  }
  cout << (long long)l*s << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**8)
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
dp=[[0,0,0] for i in range(n)]
dp[0]=l[0]
def dp1(x):
  if dp[x]!=[0,0,0]:
    return dp[x]
  else:
    dp2=dp1(x-1)
    ansa=l[x][0]+max(dp2[1],dp2[2])
    ansb=l[x][1]+max(dp2[0],dp2[2])
    ansc=l[x][2]+max(dp2[1],dp2[0])
    dp[x]=[ansa,ansb,ansc]
    return dp[x]
print(max(dp1(n-1)))

Measured memory_bytes: 123824
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define j1 j1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N,M; cin>>N>>M;

  ll x[N],y[N],z[N];

  rep(i,N){
    cin>>x[i]>>y[i]>>z[i];
  }

  vector<ll> xi={1,1,1,1,-1,-1,-1,-1};
  vector<ll> yi={1,1,-1,-1,1,1,-1,-1};
  vector<ll> zi={1,-1,1,-1,1,-1,1,-1};

  ll ans=-INF2;

  rep(i,8){
    vector<ll> sum;

    rep(j,N){
      sum.emplace_back(x[j]*xi[i]+y[j]*yi[i]+z[j]*zi[i]);
    }

    sort(ALL(sum),greater<ll>());

    ll temp=0;
    rep(j,M){
      temp+=sum[j];
    }

    maxi(ans,temp);
  }

  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<map>
#include <vector>
#include<iostream>
#include<algorithm>
using namespace std;
//struct cmp
//{	
//	bool operator()(const string&str1,const string& str2)
//	{	
//			if(mp[str1]==mp[str2])
//				return str1<str2;
//			return mp[str1]>mp[str2];
//	} 
//};

bool cmp(pair<string,int> a, pair<string,int> b) {
	if(a.second==b.second)
		return a.first<b.first;
	return a.second > b.second;
}
int main() {
	int n,a;
	string ss;
	map<string,int>mp;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>ss;
		mp[ss]++;
	}
	vector< pair<string,int> > vec;
	for(map<string,int>::iterator it = mp.begin(); it != mp.end(); it++){    
		vec.push_back( pair<string,int>(it->first,it->second) );
	}
	sort(vec.begin(),vec.end(),cmp);
	vector<pair<string,int> >::iterator it=vec.begin();
	cout<<it->first<<endl;
	for(vector<pair<string,int> >::iterator iter=vec.begin()+1;iter!=vec.end();iter++){
		if(iter->second==it->second)
			cout<<iter->first<<endl;
	}
	return 0;
}

Measured memory_bytes: 28404
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 string s;
 cin >> s;
 if(s[0] != s[1] && s[1] != s[2] && s[0] != s[2])cout << "Yes" << endl;
 else cout << "No" << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,r; cin>>n>>r;
	if(n>=10) cout<<r;
	else{
		cout<<r+(100*(10-n));
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();   
    int area = a*b;
    int length = 2*a+2*b;
    System.out.println(area + " " + length);
    }
}


Measured memory_bytes: 26356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long k = sc.nextLong();
		long a[] = new long[n];
		long b[] = new long[m];
		long prefix1[] = new long[n + 1];
		long prefix2[] = new long[m + 1];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextLong();
		}
		for (int i = 1; i <= n; i++) {
			prefix1[i] = prefix1[i - 1] + a[i - 1];
		} for (int i = 1; i <= m; i++) {
			prefix2[i] = prefix2[i - 1] + b[i - 1];
		}
		long max = 0;
		for (int i = 0; i <= n; i++) {
			long x = k - prefix1[i];
			if (x < 0)
				break;
			long ans = bs(prefix2, x);

			ans += i;
			max = Math.max(ans, max);
		}
		System.out.println(max);


	}
	public static long bs(long prefix2[], long x) {
		int l = 1, r = prefix2.length - 1;
		long res = 0;
		while (l <= r) {
			int mid = l + (r - l) / 2;
			if (prefix2[mid] <= x) {
				res = mid;
				l = mid + 1;
			} else {
				r = mid - 1;
			}
		}
		return res;
	}
}





class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new
		                        InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException  e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}

Measured memory_bytes: 69372
#include <stdio.h>
int main(void){
    
    int a,b;
    
    scanf("%d", &a);
    scanf("%d", &b);
    
    if(a<b){
    puts("a < b");
    }
    
    else if(a>b){
    puts("a > b");
    }
    
    else if(a == b){
    puts("a == b");
    }
    
    return 0;
}



Measured memory_bytes: 2040
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		D(sc);
	}
	
	public static void A(Scanner sc) {
		int m = sc.nextInt();
		out.println(24-m+24);
	}
	
	public static void B(Scanner sc) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		Pattern p = Pattern.compile("[0-9]{"+ a + "}-[0-9]{" + b + "}");
		Matcher m = p.matcher(s);
		if(m.find()) out.println("Yes");
		else out.println("No");
	}
	
	// t+e%f == 0 満たす最初のe>0を求め、eを返す
	public static int rete(int t, int f) {
		return (int)Math.ceil(t/(double)f)*f - t;
	}
	
	//受け取ったi -> Nの所要時間を返す
	public static int calctime(int i, int[] S, int[] F, int[] C) {
		if(i==S.length) return 0;
		int t = S[i]+C[i];
		for(int j=i+1;j<S.length;j++) {
			if(t<=S[j]) t+=(S[j]-t)+C[j];
			else t+=rete(t,F[j])+C[j];
		}
		return t;
	}
	
	public static void C(Scanner sc) {
		int N = sc.nextInt();
		int[] C = new int[N-1];
		int[] S = new int[N-1];
		int[] F = new int[N-1];
		for(int i=0;i<N-1;i++) {
			C[i] = sc.nextInt();
			S[i] = sc.nextInt();
			F[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			out.println(calctime(i,S,F,C));
		}
	}
	
	// b[i]==1 -> 素数なbを返す
	public static boolean[] eratos(int n) {
		boolean[] ret = new boolean[n+1];
		if(n<2) return ret;
		for(int i=2;i<n+1;i++) ret[i] = true;
		for(int i=2;i<n;i++) {
			if(ret[i]) {
				for(int k=2;i*k<n+1;k++) ret[i*k]=false;
			}
		}
		return ret;
	}
	
	//make 2017 ただし、min~max
	public static HashSet<Integer> get2017(boolean[] b, int min, int max){
		HashSet<Integer> set = new HashSet<Integer>();
		for(int i=(min+1)/2;2*i-1<max+1;i++) {
			if(b[i] && 2*i-1<b.length &&  b[2*i-1]) set.add(2*i-1);
		}
		return set;
	}
	
	public static void D(Scanner sc) {
		int Q = sc.nextInt();
		int[] l = new int[Q];
		int[] r = new int[Q];
		int[] res = new int[Q];
		int minl = Integer.MAX_VALUE;
		int maxr = 0;
		for(int i=0;i<Q;i++) {
			l[i] = sc.nextInt();
			if(l[i]<minl) minl=l[i];
			r[i] = sc.nextInt();
			if(r[i]>maxr) maxr=r[i];
		}
		boolean[] primelist = eratos(maxr);
		HashSet<Integer> set2017 = get2017(primelist,minl,maxr);
		for(int cand : set2017) {
			//out.println(cand);
			for(int i=0;i<Q;i++) {
				if(cand>=l[i] && cand<=r[i]) res[i]++;
			}
		}
		for(int i=0;i<Q;i++) {
			out.println(res[i]);
		}
	}
}


Measured memory_bytes: 69572
#include<iostream>//AT2559
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include <algorithm>
#include<cmath>
#include<vector>
#include<set>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b&&c<=b)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int box[] = new int[3];
        
        for(int i = 0; i < box.length; i++){
            box[i] = sc.nextInt();
        }
        Arrays.sort(box);
        
        System.out.println(box[0] + " " + box[1] + " " + box[2]);
    }
}


Measured memory_bytes: 26168
n=int(input())
h=[0]+list(map(int,input().split()))
c=0
while True:
    if any(h):
        for i in range(n):
            if h[i]==0 and h[i+1]>0:
                c+=1
        for i in range(n+1):
            if h[i]>0:
                h[i]-=1
    else:
        break
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

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

    vector<int> ans(N);
    for(int i = 0; i < K; i++){
        ans[i] = S;
    }

    if(S == 1e9){
        for(int i = K; i < N; i++){
            ans[i] = 1e9 - 1;
        }
    }
    else{
        for(int i = K; i < N; i++){
            ans[i] = S + 1;
        }
    }
    
    for(int i = 0; i < N; i++){
        cout << ans[i];
        if(i == N - 1){
            cout << endl;
        }
        else{
            cout << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 1664
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  vector<int> cnt(n);
  rep(i,m){
    int x,y;
    cin>>x>>y; --x; --y;
    ++cnt[x]; ++cnt[y];
  }
  for(int x:cnt)if(x%2){
      cout<<"NO"<<endl;
      return 0;
    }
  cout<<"YES"<<Endl;
  return 0;
}


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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    
    int sum=0; bool flag=false;
    for(int i=0; i<B; i++){
        sum += A;
        if(sum%B==C) flag=true;
    }
    
    cout << ((flag)?"YES":"NO") << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int a, b;
    cin >> a >> b;

    bool z = true;
    for(int i = 1; i < 1500; i++){
        if(floor(i*0.08) == a && floor(i*0.10) == b){
            z = false;
            cout << i << endl;
            break;
        }
    }
    if(z) cout << "-1" << endl;
    return 0;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	ll A, B;
	cin >> A >> B;
	ll x = 0;
	A--;
	for(ll i = A - A % 4; i <= A; i++)
		x ^= i;
	for(ll i = B - B % 4; i <= B; i++)
		x ^= i;
	cout << x << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 28/Mar/20 06:16:57 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n, x, y;
	cin >> n >> x >> y;
	map< int, int > mp;
	fr (i, 1, x + 1) {
		fr (j, i + 1, x + 1) {
			mp[j - i]++;
		}
		fr (j, x + 1, n + 1) {
			int ans = min (j - i, x - i + 1 + abs (y - j));
			mp[ans]++;
		}
	}

	fr (i, x + 1, y + 1) {
		fr (j, i + 1, n + 1) {
			int ans = min (j - i, i - x + 1 + abs (j - y));
			mp[ans]++;
		}
	}

	fr (i, y + 1, n + 1) {
		fr (j, i + 1, n + 1) {
			mp[j - i]++;
		}
	}

	fr (i, 1, n) pr (mp[i]);

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>


int main(void){

    int a;

    int i =1;
    for(;i <=10000;i++){
        scanf("%d", &a);
        if(a==0){ break; }
        else{ 
            printf("Case %d: %d\n", i, a);
        }
    }

    return 0;
}


Measured memory_bytes: 2060
# coding:utf-8
from copy import deepcopy

H, W, K = map(int, input().split(' '))
C = []
ans = 0

for _ in range(H):
    row = input()
    C.append([el for el in row])

for h in range(2**H):
    for w in range(2**W):
        h_red = str(bin(h)).lstrip("0b").zfill(H)
        w_red = str(bin(w)).lstrip("0b").zfill(W)
        table = deepcopy(C)
        num_black = 0
        for i, f in enumerate(h_red):
            if f == '1':
                table[i] = ['r' for _ in range(W)]
        for i, f in enumerate(w_red):
            if f == '1':
                for s in table:
                    s[i] = 'r'
        for s in table:
            num_black += s.count('#')
        if num_black == K:
            ans += 1

print(ans)


Measured memory_bytes: 9340
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] r = new int[8];
            int c = 0;

            string[] s = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                int v = int.Parse(s[i]);
                v /= 400;
                if(v >= 8)
                {
                    c++;
                }
                else
                {
                    r[v]++;
                }
            }

            int kind = 0;
            for (int i = 0; i < 8; i++)
            {
                if(0 != r[i])
                {
                    kind++;
                }
            }

            int min = 0;
            int max = 0;

            if (c == 0)
            {
                min = kind;
                max = kind;
            }
            else if (kind == 0)
            {
                min = 1;
                max = c;
            }
            else
            {
                min = kind;
                max = kind + c;
            }

            Console.WriteLine("{0} {1}", min, max);
        }
    }
}


Measured memory_bytes: 13140
#include<cstdio>

using namespace std;

int split_num(int n){
    int num = 0;
    for(int i = 1; i <= n; i++){
        if (n % i == 0){
            num++;
        }
    }
    return num;
}

int main(){
    int n;
    scanf("%d", &n);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if (i % 2 == 1) {
            if (split_num(i) == 8) {
                ans++;
            }
        }
        

        
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> p;
int K,X,Y;
bool xflip, yflip, xyswap;
vector<p> def;
void pushdef(int x,int y) {
    if(xyswap)swap(x,y);
    if(xflip)x*=-1;
    if(yflip)y*=-1;
    def.push_back(p(x, y));
}
main(){
    cin>>K>>X>>Y;
    if(X<0)xflip=true,X*=-1;
    if(Y<0)yflip=true,Y*=-1;
    if(X>Y)xyswap=true,swap(X,Y);
    if(X+Y&1&&~K&1){
        cout<<-1<<endl;
        return 0;
    }
    if(X+Y<K&&X+Y&1){
        pushdef(X,-K+X);
        pushdef((K+X-Y)/2,K-(K+X-Y)/2);
        pushdef(-(K+X-Y)/2,K-(K+X-Y)/2);
    }else{
        int tarx,tary;
        if (X+Y<K||K&1&&((X+Y)/K&1)==(X+Y&1)){
            int U=X+Y,V=-X+Y;
            int u=U-U%K+K,v=V-K;
            tarx=(u-v)/2,tary=(u+v)/2;
        } else {
            int U=X+Y,V=-X+Y;
            int u=U-U%K,v=V-K;
            tarx=(u-v)/2,tary=(u+v)/2;
        }
        if((X+Y)%K!=0)pushdef(X-tarx,Y-tary),X=tarx,Y=tary;
        for(int i=0;i<X/K;i++)pushdef(K,0);
        for(int i=0;i<Y/K;i++)pushdef(0, K);
        if(X %K!=0)pushdef(X % K,Y%K);
    }
    cout<<def.size()<<" ";
    int x=0,y=0;
    for(int i=0;i<def.size();i++)x+=def[i].first,y+=def[i].second,cout<<x<<" "<<y<<" ";
}


Measured memory_bytes: 3952
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	s := getString()
	r := 0
	w := 0
	for i := 0; i < N; i++ {
		if s[i] == 'R' {
			r++
		} else {
			w++
		}
	}
	sw := 0
	for i := 0; i < r; i++ {
		if s[i] == 'W' {
			sw++
		}
	}

	// out(r, w, sw)
	ans := min(r, min(w, sw))
	out(ans)
}


Measured memory_bytes: 2436
from itertools import count

S = int(input())


def bis(p, ok, ng):
    mid = (ok + ng) // 2
    return (
        ok if abs(ok - ng) == 1 else
        bis(p, mid, ng) if p(mid) else
        bis(p, ok, mid)
    )


R = bis(lambda n: n**2 >= S, 10**9, 0)
(Y1, X2) = (
    (0, 0) if R**2 == S else
    next(
        (Q // x, x)
        for Q in (
            r**2 - S
            for r in count(R)
        )
        for x in range(1, int((Q**0.5) + 1))
        if Q % x == 0 and Q // x <= 10**9
    )
)
ans = '{} {} {} {} {} {}'.format(
    0,
    0,
    R,
    Y1,
    X2,
    R
)

print(ans)


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

#define int long long
#define INF 9223372036854775807
#define M_PI 3.14159265358979323846
#define double long double

int mod = INF;

int fastPow(int b, int e){int r = 1;while(e){if(e%2 == 1){r*=b;r%=mod;}b*=b;b%=mod;e/=2;}return r;}
int pgcd(int a, int b){ if(a%b == 0) return b; else return pgcd(b, a%b);}
int sign(int a){if(a < 0){ return -1;}if(a == 0) {return 0;}if(a > 0) {return 1;}}
bool isPrime(int a){if(a == 1) {return false;}int f = sqrt(a);for(int i = 2; i<=f; i++){if(a%i == 0){return false;}}return true;}
int toInt(string s){int tot = 0;for(int i = s.size()-1; i >= 0; i--){tot+=((s[i]-'0')%mod)*fastPow(10,i);tot%=mod;}return tot;}
string toString(int a){string s = "";while(a){s = (char)('0'+a%10) + s;a/=10;}return s;}

vector<int> we(109);
vector<int> v(109);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    int tot = 0;
    for(int i = 1; i <= n; i++){
        cin >> we[i] >> v[i];
        tot+=v[i];
    }
    vector<int> ve(tot+1, INF/2);
    ve[0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = tot+1-v[i]; j >= 0; j--){
            ve[j+v[i]] = min(ve[j+v[i]], ve[j]+we[i]);
        }
    }
    int ans = INF;
    for(int i = 0; i < tot+1; i++){
        if(ve[i] <= w){
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String w = in.next();
        boolean nonEvenExists = w.chars().mapToObj(i -> (char) i)
                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()))
                .entrySet()
                .stream()
                .anyMatch(e -> e.getValue() % 2 == 1);
        System.out.println(nonEvenExists ? "No" : "Yes");
    }
}


Measured memory_bytes: 33024
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    N = int(len(S))
    ans = YES

    for i in range(N//2):
        if S[i] != S[-1 - i]:
            ans = NO
            break

    S_left, S_right = S[:N//2], S[N//2 + 1:]

    for i in range(N//2//2):
        if S_left[i] != S_left[-1 - i]:
            ans = NO
            break
        if S_right[i] != S_right[-1 - i]:
            ans = NO
            break
    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <stdio.h>
#include <list>

using namespace std;

//#define EPS (1e-10)
//
//struct Point{
//    Point(double _x = 0, double _y = 0){
//        x = _x;
//        y = _y;
//    }
//    double x;
//    double y;
//
//    Point operator + (Point p){
//        return Point(x + p.x, y+ p.y);
//    }
//
//    Point operator - (Point p){
//        return Point(x - p.x, y - p.y);
//    }
//
//    Point operator * (double a){
//        return Point(a * x, a * y);
//    }
//
//    Point operator / (double a){
//        return Point(x / a, y / a);
//    }
//
//    double abs(){
//        return sqrt(norm());
//    }
//
//    double norm(){
//        return x * x + y * y;
//    }
//
//    bool operator < (const Point &p) const{
//        return x!=p.x ? x < p.x : y < p.y;
//    }
//
//    bool operator == (const Point &p) const{
//        return fabs(x - p.x) && fabs(y - p.y) < EPS;
//    }
//
//};
//
//typedef Point Vector;
//
//double dot(Vector a, Vector b){
//    return a.x * b.x + a.y * b.y;
//}

int main() {

    int count = 0;
    int n;scanf("%d",&n);

    std::vector<int> arr(n);
    for(int i=0;i<n;i++){
        scanf("%d", &arr[i]);
    }

    bool ok = true;

    while(true){

        for(int i=0;i<n;i++){
            if(arr[i]%2==0){
                arr[i]/=2;
            }else{
                ok=false;
            }
        }

        if(!ok){
            break;
        }

        count++;

    }

    printf("%d",count);

    return 0;

}

Measured memory_bytes: 256
n,x = [int(_) for _ in input().split()]
l = [int(_) for _ in input().split()]
s = [l[0]]
for i in range(1,n):
    s.append(l[i] + s[-1])
ans = 0
for i in range(n):
    if s[i] <= x:
        ans += 1
print(ans+1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define MAX 50000
int judge(const void* a,const void* b){
	return *(long long int*)a-*(long long int*)b;
}

int main(){
	long long int a[MAX];
	long long int i,n,ans,wait;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
			for(i=0;i<MAX;i++){
				a[i]=0;
			}
		for(i=0;i<n;i++){
			scanf("%lld",&a[i]);
		}
		qsort(a,n,sizeof(long long int),judge);
		ans=0;
		wait=0;
		for(i=0;i<n-1;i++){
			wait+=a[i];
			ans+=wait;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1108