akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define ll long long
using namespace std;
const int N=15,S=1500,P=998244353;
int C[N][N],cnt[S],sr[N],sc[N],dpr[N][N][3],dpc[N][N][3];
int add(int x,int y){ x+=y; return x>=P?x-P:x; }
int fpw(int x,int y){
    int s=1; for (;y;y>>=1,x=(ll)x*x%P) if (y&1) s=(ll)s*x%P;
    return s;
}
int main(){
    int n,m; cin>>n>>m;
    rep(i,0,max(n,m)){
        C[i][0]=1;
        rep(j,1,i) C[i][j]=add(C[i-1][j],C[i-1][j-1]);
    }
    rep(i,1,n){
        char s[N]; cin>>s;
        rep(j,1,m)
            if (s[j-1]=='#') sr[i]|=1<<j-1,sc[j]|=1<<i-1;
    }
    rep(s,1,(1<<max(n,m))-1)
        rep(i,1,max(n,m)) cnt[s]+=s>>i-1&1;
    rep(j,1,m) dpc[n][j][2]=(ll)C[m][j]*(1<<m-j)%P;
    int ans=1<<m;
    per(i,n,1)
        per(j,m,1){
            dpc[i][j][0]=add(dpc[i][j][1],dpc[i][j][2]);
            rep(k,1,i-1){
                dpr[k][j][1]=add(dpr[k][j][1],(ll)add(add(dpc[i][j][2],dpc[i][j][2]),dpc[i][j][1])*C[i][k]%P);
                dpr[k][j][2]=add(dpr[k][j][2],(ll)((1<<i-k)-2)*dpc[i][j][2]%P*C[i][k]%P);
            }
            ans=(ans+(ll)dpc[i][j][2]*((1<<i)-2))%P;
            dpr[i][j][0]=add(dpr[i][j][1],dpr[i][j][2]);
            rep(k,1,j-1){
                dpc[i][k][1]=add(dpc[i][k][1],(ll)add(add(dpr[i][j][2],dpr[i][j][2]),dpr[i][j][1])*C[j][k]%P);
                dpc[i][k][2]=add(dpc[i][k][2],(ll)((1<<j-k)-2)*dpr[i][j][2]%P*C[j][k]%P);
            }
            ans=(ans+(ll)dpr[i][j][2]*((1<<j)-2)%P);
        }
    rep(s1,1,(1<<n)-1)
        rep(s2,1,(1<<m)-1){
            bool f=false;
            rep(i,1,n)
                if (s1>>i-1&1){
                    int c=cnt[sr[i]&s2]; f=f||c==0||c==cnt[s2];
                }
            rep(i,1,m)
                if (s2>>i-1&1){
                    int c=cnt[sc[i]&s1]; f=f||c==0||c==cnt[s1];
                }
            if (!f){
                int coef=fpw((ll)C[n][cnt[s1]]*C[m][cnt[s2]]%P,P-2);
                ans=add(ans,(ll)add(dpc[cnt[s1]][cnt[s2]][0],dpr[cnt[s1]][cnt[s2]][0])*coef%P);
            }
        }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
def main():
    MOD=10**9+7

    mod13=[1]*(10**5+1)
    for i in range(10**5):
        mod13[i+1]=mod13[i]*10%13
    
    s=list(input())[::-1]
    l=len(s)
    
    dp=[[0]*13 for _ in range(1+l)]

    if s[0]=='?':
        for num in range(10):
            t=num%13
            dp[1][t]+=1
    else:
        num=int(s[0])
        t=num%13
        dp[1][t]=1

    for i in range(1,l):
        if s[i]=='?':
            for j in range(13):
                for num in range(10):
                    t=(j+mod13[i]*num)%13
                    dp[i+1][t]+=dp[i][j]
                    dp[i+1][t]%=MOD
        
        else:
            num=int(s[i])
            for j in range(13):
                t=(j+mod13[i]*num)%13
                dp[i+1][t]+=dp[i][j]
                dp[i+1][t]%=MOD
    
    print(dp[-1][5])
 
if __name__=='__main__':
    main()

Measured memory_bytes: 66152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

const ll MAX = 510000;
const ll MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
   ll n,k;
   cin >> n >> k;
   vector<ll> a(n);
   rep(i,n)cin >> a[i];
   sort(ALL(a),greater<ll>());
   COMinit();
   ll ans=0;
   rep(i,n-k+1)
   {
      ans =ans+a[i]*COM(n-1-i,k-1)%MOD;
      //ans %=MOD;
   }
   reverse(ALL(a));
   rep(i,n-k+1)
   {
      ans =ans-a[i]*COM(n-1-i,k-1)%MOD;
      if(ans<0)ans += MOD;
      ans %=MOD;
   }
   
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 12928
a=input()
b=input()

if len(a)<len(b):
    print('LESS')
elif len(a)>len(b):
    print('GREATER')
else:
    f=0
    for i in range(len(a)):
        if a[i]>b[i]:
            print('GREATER')
            break
        elif a[i]<b[i]:
            print('LESS')
            break
        else:
            f+=1
            continue
    if f==len(a):
        print('EQUAL')
        

Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    long long h[N];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }

    // 足場 0 ~ N-1
    long long dp[N]; // dp[i] := 足場i番目までの最小コスト
    dp[0] = 0; // 足場 0
    dp[1] = abs(h[1]-h[0]); // 足場 1
    for(int i = 2; i < N; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[N-1] << endl;


    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

const double PI=3.14159265358979323846; // or M_PI


void Main() {
    ll n, m, a, count=0, total=0;
    vector<ll> a_vec;
    cin >> n >> m;

    REP(i, n) {
        cin >> a;
        total += a;
        a_vec.push_back(a);
    }

    //COUT(total);

    REP(i, n) {
        if (a_vec[i] * 4 * m >= total) {
            count++;
        }
    }
    //cout << m << " " << count << endl;
    if (m <= count) {
        COUT("Yes");
    }
    else{
        COUT("No");
    }
}

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




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
const int DIM = 3e5 + 5;
 
priority_queue<int> prq;
 
int arr[DIM];
long long dp1[DIM], dp2[DIM];
 
int main( void ) {
    
    int n;
    cin >> n; n *= 3;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    for( int i = 1; i <= n; i ++ ) {
        dp1[i] = dp1[i - 1] + arr[i];
        prq.push( -arr[i] );
        
        if( prq.size() > n / 3 ) {
            dp1[i] -= -prq.top();
            prq.pop();
        }
    }
    
    while( prq.empty() == false )
        prq.pop();
    
    for( int i = n; i >= 1; i -- ) {
        dp2[i] = dp2[i + 1] + arr[i];
        prq.push( arr[i] );
        
        if( prq.size() > n / 3 ) {
            dp2[i] -= prq.top();
            prq.pop();
        }
    }
    
    long long ans = numeric_limits<long long> :: min();
    for( int i = n / 3; i + (n / 3) <= n; i ++ )
        ans = max( ans, dp1[i] - dp2[i + 1] );
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
    
    string str; cin>>str;
    
    int n = str.length();
    
    int a=0;
       
    for(int i=0;i<n/2;++i){
        if(str[i]!=str[n-i-1])a=1;
    }
    
    for(int i=0;i<(n-1)/2;++i){
    if(str[i]!=str[(n-1)/2 -i - 1])a=1;
    }
    
    for(int i=(n+3)/2 - 1;i<n;++i){
    if(str[i]!=str[n-i-1])a=1;
    }
    
  if(a==1) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
    
        
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> Pairs;

const int N = 202020;
#define get() getchar()
template<typename T>
inline void read(T &x) {
    static char c; x = 0; int sgn = 0;
    for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
    for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
    if (sgn) x = -x;
}

int n;
ll addl, addr, ans;
int l[N], r[N];
priority_queue<ll> L;
priority_queue<ll, vector<ll>, greater<ll> > R;

template<typename T>
inline T Abs(T x) {
    return x < 0 ? -x : x;
}

int main(void) {
    read(n);
    for (int i = 1; i <= n; i++) {
        read(l[i]); read(r[i]);
        if (i == 1) {
            L.push(l[i]); R.push(l[i]);
            addl = addr = 0;
            continue;
        }
        int len2 = r[i] - l[i], len1 = r[i - 1] - l[i - 1];
        addl -= len2;
        addr += len1;
        ll lb = L.top() + addl, rb = R.top() + addr;
        if (l[i] < lb) {
            ans += Abs(lb - l[i]);
            R.push(lb - addr);
            L.push(l[i] - addl);
            L.push(l[i] - addl);
            L.pop();
        } else if (l[i] > rb) {
            ans += Abs(rb - l[i]);
            L.push(rb - addl);
            R.push(l[i] - addr);
            R.push(l[i] - addr);
            R.pop();
        } else {
            L.push(l[i] - addl);
            R.push(l[i] - addr);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2796
S = input()
N = len(S)

dp = [None] * (N + 1)
dp[0] = (0, 1)
for i in range(1, N + 1):
    summation = 0
    cnt = 0
    for j in range(i):
        summation += int(S[j:i]) * dp[j][1] + dp[j][0]
        cnt += dp[j][1]
    dp[i] = (summation, cnt)

print(dp[N][0])

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

unsigned long long A, B, X;

int main(int argc, char **argv)
{
	cin >> A >> B >> X;
	if (A % X != 0)
	{
		A = A + X - (A % X);
	}
	B = B - (B % X);

	if (B < A)
		cout << 0 << endl;
	else
		cout << (B - A) / X + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char in[120];
pair<pair<string, int>, int> data[110];
int main(){  
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    string temp;
    int    point;
    cin >> temp >> point;
    data[i] = make_pair(make_pair(temp, -point), i);
  }
  sort(data, data+N);
  for(int i=0; i<N; i++)	cout << data[i].second + 1 << endl; 
}

Measured memory_bytes: 256
import itertools

n, m, q = [int(x) for x in input().split()]
 
tmp = []
for i in range(q):
    a, b, c, d = [int(x) for x in input().split()]
    tmp.append([a, b, c, d])

t = list(itertools.combinations_with_replacement(range(1, m + 1), n))

score = 0
for _t in t:
    _s = 0
    for a, b, c, d in tmp:
        if c == _t[b - 1] - _t[a - 1]:
            _s += d
    score = max(_s, score)
print(score)

Measured memory_bytes: 21504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	bool judge = false;
	for (int i = N; i < 1e9; i++) {
		int cnt = 0;
		for (int j = 2; j*j <= N; j++) {
			if (i % j == 0) cnt++;
		}
		if (cnt == 0) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll a;
    cin >> a;
    long double b;
    cin >> b;
    long double tmp = (long double)a * b;
    long long ans = floor(tmp);
    print(ans);
    



}



//queue<pint>().swap(q); キュー内を全て削除
//priority_queue<ll, vector<ll>, greater<ll> > que;
//auto dp=make_v<int>(4,h,w);
//vector<vector<ll>> g;
//g.assign(n, vector<ll>()); g.resize(n);でも大丈夫っぽい
//fill_v(dp,0);
//int n;
//cin >> n;
//vector<int> test(n);
//cins(all(test));
//array_output(all(test));
// Yes(true);


Measured memory_bytes: 3748
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

int n,m;
vector<int> g[100010];
int main(void){
  ioboost();

  cin >> n >> m;
  rep(i,m){
    int a,b;cin >> a >> b;
    a--,b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  queue<int> q;
  q.push(0);
  
  vector<int> ans(n,-1);
  
  while(q.size()){
    int x = q.front();
    q.pop();
    for(int i : g[x]){
      if(ans[i] >= 0){
        continue;
      }else{
        ans[i] = x;
        q.push(i);
      }
    }
  }
  cout << "Yes" << '\n';
  rep(i,n-1)cout << ans[i+1]+1<< '\n';
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, K;
int a[1111];
vec<int> cand;

int func(int mask) {
   int cnt = 0;

   for (int i = 0; i < cand.size(); i++) {
      if ((cand[i] & mask) == mask) cnt++;
   }

   return cnt;
}

signed main() {
   cin >> N >> K;
   rep (i, N) {
      cin >> a[i];
   }

   for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = i; j < N; j++) {
         sum += a[j];
         cand.push_back(sum);
      }
   }

   int ans = 0;
   for (int i = 40; i >= 0; i--) {
      if (func(ans | (1LL << i)) >= K) {
         ans |= (1LL << i);
      }
   }

   cout << ans << endl;

   return 0;
}

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

int main()
{
    int m;              // 中間試験
    int r;              // 期末試験
    int f;              // 再試験
    int num;            // 生徒数
    const int MAX = 50;

    num = 0;

    while (1) {
        cin >> m >> r >> f;

        if (m == -1 && r == -1 && f == -1) break;

        if ((m >= -1 && m <= 50) && (r >= -1 && r <= 50) && (f >= -1 && f <= 100)) {
            if (m == -1 || r == -1) {
                cout << "F" << endl;
            } else if ((m+r) >= 80) {
                cout << "A" << endl;
            } else if ((m+r) >= 65) {
                cout << "B" << endl;
            } else if ((m+r) >= 50) {
                cout << "C" << endl;
            } else if ((m+r) >= 30) {
                if (f >= 50) {
                    cout << "C" << endl;
                } else {
                    cout << "D" << endl;
                }
            } else {
                cout << "F" << endl; 
            }
        }

        if (++num >= 50) break;
    }

    return 0;
}


Measured memory_bytes: 3136
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in1(N);

    vll x(N), y(N);
    rep(i, N) in2(x[i], y[i]);

    ll ans = 0;

    vll v(N);

    rep(i, N)
    {
        v[i] = x[i] - y[i];
    }

    sort(all(v));

    chmax(ans, v.back() - v.front());

    vll u(N);

    rep(i, N)
    {
        u[i] = x[i] + y[i];
    }

    sort(all(u));

    chmax(ans, u.back() - u.front());

    outl(ans);

    return 0;
}


Measured memory_bytes: 9512
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
	return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
	return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
	return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
	return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
	return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
	return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
	if (exp == 0) {
		return 1;
	}

	if (exp == 1) {
		return base;
	}

	if (exp % 2 == 0) {
		return powSz(base * base, exp / 2);
	}
	else {
		return base * powSz(base, exp - 1);
	}
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t gcdZu(size_t m, size_t n) {
	size_t temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static uint64_t A[100000];

int main(void) {
	size_t N;

	uint64_t sum = 0;

	scanf("%zu", &N);
	for (size_t i = 0; i < N; i++) {
		scanf("%"PRIu64, &A[i]);

		sum += A[i];
	}

	uint64_t mt[2];

	mt[0] = sum;
	for (size_t i = 1; i < N; i += 2) {
		mt[0] -= 2*A[i];
	}

	printf("%"PRIu64" ", mt[0]);
	for (size_t i = 1; i < N; i++) {
		mt[i % 2] = (A[i - 1] - mt[(i - 1) % 2] / 2) * 2;

		printf("%"PRIu64, mt[i%2]);
		if (i < N - 1) {
			putchar(' ');
		}
	}

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <climits>
#include <cfloat>
#include <queue>
#include <stack>

using namespace std;

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

const int INF = INT_MAX;

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

int main(){
    stack<int> st;
    int x;
    while(cin>>x){
        if(x==0){
            cout << st.top() << endl;
            st.pop();
            continue;
        }else{
            st.push(x);
        }
    }
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    bool flag=0;
    for(int i=0;i<str.size();i++)
	{
        if(str[i]=='C')
            flag=1;
        if(str[i]=='F'&&flag==1)
		{
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll a[100010], S[100010];
ll mi = INF, ma;

template<typename T>
struct BIT {
  int n;
  std::vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main()
{
  std::cin >> N;

  rep( i, N ) {
    std::cin >> a[i];

    chmin( mi, a[i] );
    chmax( ma, a[i] );
  }

  ll ng = mi-1, ok = ma+1;

  while( ok-ng > 1 ) {
    ll mid = (ng+ok)/2;

    auto C = [&]( ll x ) {
      std::fill( S, S+N+2, 0 );
      
      rep( i, N )
        S[i+1] = S[i]+(a[i]<=x ? 1 : -1);

      ll ret = 0;
      BIT<ll> bit( 200010 );

      const ll base = 100010;

      rep( i, N+1 ) {
        ret += bit.sum( S[i]-1+base );

        bit.add( S[i]+base, 1 );
      }

      return ret >= N*(N+1)/2/2+1;
    };

    (C(mid) ? ok : ng) = mid;
  }

  std::cout << ok << std::endl;

  return 0;
}

Measured memory_bytes: 3428
#include<bits/stdc++.h>
        using namespace std;
        int main(){
          int a;
            cin>>a;
          for(int i=1;i<10;i++)
            for(int j=1;j<10;j++){
              if(i*j == a){
                cout<<"Yes"<<endl;
                return 0;
              }
            }
          cout<<"No"<<endl;
        }


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

int main() {
  ll n, k; cin >> n >> k;
  if(n > k) {
    n = n % k;
    n = min(n, k-n);
  } else {
    n = min(n, k-n);
  }
  cout << n << endl;
  return 0;
}

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

signed main(){
	int N, x, a[100100], count = 0;
	
	cin>>N>>x;
	
	rep(i,N){
		cin>>a[i];
	}
	
	rep(i,N-1){
		if(a[i]+a[i+1] > x){
			int temp = a[i+1]+a[i];
			if(a[i] <= x) count += temp - x, a[i+1] -= temp - x;
			else count += temp - x,a[i+1] = 0;
		}
	}
	cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);

    int a,b,c;
    cin >> a >> b >> c;

    int x,y;
    cin >> x >> y;

    long long best = 1000000000000000000LL;
    for(int i = 0; i <= max(x,y); ++i)
    {
        int cura = max(0, x - i);
        int curb = max(0, y - i);
        long long t = 2LL * i * c + cura *1LL * a + curb *1LL * b;
        best = min(t, best);
    }
    cout << best << endl;
}


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

int main(){
    int i;
    int start,end;
    char str[200000] = {};
    scanf("%s",str);

    for(i=0;i<200000;i++){
        if(str[i]=='A'){
            start = i;
            break;
        }
    }
    for(i=199999;i>0;i--){
        if(str[i]=='Z'){
            end = i;
            break;
        }
    }

    printf("%d\n",end-start+1);

    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from collections import deque

n = int(sys.stdin.readline())
ai = list(map(int, sys.stdin.readline().split()))

o = [0] * 9

for a in ai:
	if a < 400:
		o[0] += 1
	elif a < 800:
		o[1] += 1
	elif a < 1200:
		o[2] += 1
	elif a < 1600:
		o[3] += 1
	elif a < 2000:
		o[4] += 1
	elif a < 2400:
		o[5] += 1
	elif a < 2800:
		o[6] += 1
	elif a < 3200:
		o[7] += 1
	else:
		o[8] += 1

on = 0
for i in range(0, 8):
	if o[i] > 0:
		on += 1

min = on
if min == 0:
	min = 1

on += o[8]

max = on

print(str(min) + ' ' + str(max))


Measured memory_bytes: 3316
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return
    
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    
    print(prod)

main()

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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;
       
int a[Sz * 10], b[Sz * 10];
                   
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;      
  for (int i = 1; i <= n; i++) {
    int x; cin >> x;
    a[x] = b[x] = i;
  }
  int ptr = 1;                     
  for (int i = 1; i <= n*n; i++) {
    if (b[i]) {  
      for (int j = 1; j < b[i]; j++) {
        while (a[ptr] )
          ptr++;
        if (ptr >= i) {
          cout << "No"; return 0;
        }    
        a[ptr] = b[i];
      }
    }
  }   
  ptr = n * n;
  for (int i = n*n; i >= 1; i--) {
    if (b[i]) {
      for (int j = 1; j <= n - b[i]; j++) {
        while (a[ptr])
          ptr--;
        if (ptr <= i) {
          cout << "No"; return 0;
        }
        a[ptr] = b[i];
      }
    }
  }

  cout << "Yes" << endl;
  for (int i = 1; i <= n*n; i++)
    cout << a[i] << ' ';        


  return 0;
}






// Coded by Z..



Measured memory_bytes: 3968
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    A = I()
    B = I()
    for i in range(1,4):
        if(i != A and i != B):
            print(i)
            return

if __name__ == "__main__":
    main()


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

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b)){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
//Created by Aminul on 8/15/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long x = in.nextLong(), k = in.nextLong(), d = in.nextLong();
        long div = abs(x) / d;
        div = min(div, k);
        k -= div;
        if (k % 2 == 1) {
            div++;
        }

        if (x < 0) pw.println(abs(x + (div * d)));
        else pw.println(abs(x - (div * d)));
        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 27128
X = [int(input()) for _ in range(5)]
ans = 0
Y = []
for i in range(len(X)):
    Y.append(X[i] % 10 if X[i] % 10 != 0 else 10)

m = Y.index(min(Y))

for j in range(len(X)):
    if j == m:
        ans += X[j]
    elif X[j] % 10 == 0:
        ans += X[j]
    else:
        ans += X[j]//10 * 10 + 10

print(ans)

Measured memory_bytes: 3064
a = input()
B = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P","Q", "R","S","T","U","V","W","X","Y","Z"]
b = ["a","b", "c","d","e", "f","g", "h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
if a in B:
    print("A")
else:
    print("a")

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

struct edge{
	edge(){}
	edge(ll from, ll to, ll cost, ll id) :from(from), to(to), cost(cost), id(id){}
	ll from, to, cost, id;
};

edge es[100000];
using Graph = vector<vector<edge>>;

int N, M;

const ll INF = 1LL << 55;

void dijkstra(int s, const Graph& g, vector<ll>& dist){
	using P = pair<ll, int>;
	dist = vector<ll>(N, INF);
	dist[s] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push({ 0, s });
	while(q.size()){
		ll d = q.top().first, v = q.top().second;
		q.pop();
		for(auto e : g[v]){
			if(dist[e.to] > d + e.cost){
				dist[e.to] = d + e.cost;
				q.push({ d + e.cost, e.to });
			}
		}
	}
}

int use[100000];
int bri[100000];

using Pii = pair<int, int>;

std::pair<std::vector<int>, vector<Pii>> bridge(const Graph& g){
	const int n = g.size();
	int idx = 0, s = 0, t = 0, k = 0;
	std::vector<int> ord(n, -1), onS(n), stk(n), roots(n), cmp(n);
	vector<Pii> brdg;
	std::function<void(int, int)> dfs = [&](int v, int u){
		ord[v] = idx++;
		stk[s++] = v;
		onS[v] = true;
		roots[t++] = v;
		for(auto& e : g[v]){
			int w = e.to;
			if(ord[w] == -1)
				dfs(w, v);
			else if(u != w && onS[w])
				while(ord[roots[t - 1]] > ord[w]) --t;
		}
		if(v == roots[t - 1]){
			brdg.emplace_back(u, v);
			while(1){
				int w = stk[--s];
				onS[w] = false;
				cmp[w] = k;
				if(v == w) break;
			}
			--t;
			++k;
		}
	};
	for(int u = 0; u < n; u++){
		if(ord[u] == -1){
			dfs(u, n);
			brdg.pop_back();
		}
	}
	return std::make_pair(cmp, brdg);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	cin >> N >> M;

	Graph G(N), Gr(N);
	for(int i = 0; i < M; i++){
		ll u, v, cost;
		cin >> u >> v >> cost;
		u--, v--;
		es[i] = edge(u, v, cost, i);
		G[u].push_back(edge(u, v, cost, i));
		Gr[v].push_back(edge(v, u, cost, i));
	}

	vector<ll> d(N), dr(N);
	dijkstra(0, G, d);
	dijkstra(1, Gr, dr);

	ll dist = d[1];
	Graph G2(N);
	map<Pii, int> idmap;
	for(int i = 0; i < M; i++){
		edge e = es[i];
		ll dd = d[e.from] + e.cost + dr[e.to];
		if(dist == dd){
			use[i] = 1;
			for(int loop = 0; loop < 2; loop++){
				G2[e.from].push_back(e);
				swap(e.from, e.to);
				idmap[{e.from, e.to}] = i;
			}
		}
	}

	auto res = bridge(G2);
	for(auto p : res.second){
		for(int i = 0; i < 2; i++){
			if(idmap.count(p)){
				bri[idmap[p]] = 1;
			}
			swap(p.first, p.second);
		}
	}

	for(int i = 0; i < M; i++){
		if(!use[i]){
			edge e = es[i];
			ll dd = d[e.to] + e.cost + dr[e.from];
			if(dist > dd){
				cout << "HAPPY" << endl;
			}
			else{
				cout << "SOSO" << endl;
			}
		}
		else{
			if(bri[i]){
				cout << "SAD" << endl;
			}
			else{
				cout << "SOSO" << endl;
			}
		}
	}
}

Measured memory_bytes: 55428
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int[] t1 = new int[n];
    int[] t2 = new int[m];
    for(int i = 0; i < n; i++) {
      t1[i] = sc.nextInt();
    }
    for(int i = 0; i < m; i++) {
      t2[i] = sc.nextInt();
    }
    int p = 0;
    for(int i = x + 1; i <= y; i++) {
      int s = 0;
      for(int j = 0; j < n; j++) {
        if(t1[j] >= i) s = 1;
      }
      for(int j = 0; j < m; j++) {
        if(t2[j] < i) s = 1;
      }
      if(s == 0) p = 1;
    }
    String ans = "War";
    if(p == 1) ans = "No War";
    System.out.println(ans);
  }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

bool comp(ll a, ll b) {
	return (a > b);
}

int main() {
	doublade();
	// w(t) {
		ll n, m;
		cin >> n >> m;
		vl a(n);
		ll sum = 0;
		rep(i, n) {
			cin>>a[i];
			sum += a[i];
		}
		sort(all(a), comp);
		ll temp = ceil((float)sum/(4*m));
		rep(i, m) {
			if(a[i]<temp) {
				cout<<"No\n";
				return 0;
			}
		}
		cout<<"Yes\n";
	// }
	return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#define MAX 100000
using namespace std;

int n, A[MAX+1], L[MAX];

int lis() {
  L[0] = A[0];
  int length = 1;

  for ( int i = 1; i < n; i++ ) {
    if ( L[length - 1] < A[i] )
      L[length++] = A[i];
    else
      *lower_bound(L, L + length, A[i]) = A[i];
  }

  return length;
}

int main() {
  cin >> n;
  for ( int i = 0; i < n; i++ )
    cin >> A[i];

  cout << lis() << endl;

  return 0;
}


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

using namespace std;

int main(){
  int N = 0;
  cin >> N;
  vector<long long int> A(N),a(N),b(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < N; i++) a[i] = A[i];
  for(int i = 0; i < N; i++) b[i] = A[i];
  
  long long int cnt1 = 0, cnt2 = 0;
  long long int M1 = 0,M2 = 0;
  
  for(int i = 0; i < N; i++){
    if(M1 + a[i] > 0){
      if(i % 2 == 0){
        ;
      }else{
        cnt1 += abs(-1 - (M1 + a[i]));
        a[i] = -1 - M1;
      }
    }else if(M1 + a[i] < 0){
      if(i % 2 == 1){
        ;
      }else{
        cnt1 += abs(1 - (M1 + a[i]));
        a[i] = 1 - M1;
      }
    }else if(M1 + a[i] == 0){
      if(i % 2 == 0){
        cnt1 += abs(1 - (M1 + a[i]));
        a[i] = 1 - M1;
      }else{
        cnt1 += abs(-1 - (M1 + a[i]));
        a[i] = -1 - M1;
      }
    }
  M1 += a[i];  
  }
  
  for(int i = 0; i < N; i++){
    if(M2 + b[i] > 0){
      if(i % 2 == 1){
        ;
      }else{
        cnt2 += abs(-1 - (M2 + b[i]));
        b[i] = -1 - M2;
      }
    }else if(M2 + b[i] < 0){
      if(i % 2 == 0){
        ;
      }else{
        cnt2 += abs(1 - (M2 + b[i]));
        b[i] = 1 - M2;
      }
    }else if(M2 + b[i] == 0){
      if(i % 2 == 1){
        cnt2 += abs(1 - (M2 + b[i]));
        b[i] = 1 - M2;
      }else{
        cnt2 += abs(-1 - (M2 + b[i]));
        b[i] = -1 - M2;
      }
    }
  M2 += b[i];  
  }
  long long int ans = min(cnt1, cnt2);
  cout << ans;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, ans = 0;
ll A[100100], B[100100], C[100100];
int main() {
    cin >> N;
    for (ll i = 0; i < N; i++) cin >> A[i]; sort(A, A + N);
    for (ll i = 0; i < N; i++) cin >> B[i]; sort(B, B + N);
    for (ll i = 0; i < N; i++) cin >> C[i]; sort(C, C + N);
    
    for (ll i = 0; i < N; i++){
        ll a, c;
        a = lower_bound(A, A + N, B[i]) - A ;
        c = lower_bound(C, C + N, B[i] + 1) - C ;
        ans += a*(N - c);
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-1-i]){
            ans++;
        }
    }
    cout<<ans<<endl;

    
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);

template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000002;

int st[10*20010];

void update(int v,int tl,int tr,int ind,int val){
	if(tl==tr){
		st[v]+=val;
		return;
	}
	if(ind<=((tl+tr)>>1)){
		update(2*v,tl,tl+tr>>1,ind,val);
	}
	else{
		update(2*v+1,(tl+tr)/2+1,tr,ind,val);
	}
	st[v]=st[2*v]+st[2*v+1];
}

int query(int v,int tl,int tr,int l,int r){
	if(l>r)return 0;
	if(l<=tl&&tr<=r){
		return st[v];
	}
	return query(2*v,tl,(tl+tr)/2,l,min(r,(tl+tr)/2))+query(2*v+1,(tl+tr)/2+1,tr,max(l,(tl+tr)/2+1),r);
}
int cnt[2001];
int dp[2001];
int les[2001];
void solve(){
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	cin>>a;
	int ans=0;
	for(int i=0;i<n;i++){
		cnt[a[i]]++;
		dp[i]=query(1,0,2000,a[i]+1,2000);
		update(1,0,2000,a[i],1);
	}
	int cn=0;
	for(int i=1;i<=2000;i++){
		
			les[i]=cn;
			//~ add(ans,mul(mul(cnt[i],cn),(k-1)));
		//~ }
		//~ add(cn,cnt[i]);
		cn+=cnt[i];
	}
	for(int i=0;i<n;i++){
		int val=mul(k,(mul(2,dp[i])+mul((k-1),les[a[i]]))%mod);
		val=mul(val,powz(2,mod-2));
		add(ans,val);
	}
	cout<<ans;
		
		
	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 384
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    s = f.read_str()
    k = f.read_int()
    n = len(s)
    cand = set()

    for i in xrange(1,6):
        for j in xrange(n-i+1):
            cand.add(s[j:j+i])

    cand = sorted(list(cand))

    return cand[k-1]


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6124