akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int fw[N];
int n,k;
int a[N];
int b[N];
void up(int x, int nv){
    while (x < N){
        fw[x] += nv;
        x += x&-x;
    }
}
int sum(int x){
    int res = 0;
    while (x){
        res += fw[x];
        x -= x&-x;
    }
    return res;
}
int main(){
    scanf("%d%d",&n,&k);
    for (int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        int L = max(1,i-a[i]);
        int R = min(n,i+a[i])+1;
        up(L,1);
        if (R <= n) up(R,-1);
    }
    for (int T = 1; T <= k; T++){
        int ct = 0;
        for (int i = 1; i <= n; i++){
            if (a[i] == n && T != 1) {
                ct++;
                b[i] = a[i];
                continue;
            }
            else b[i] = sum(i);
        }
        if (ct == n && T != 1) {
            break;
        }
        for (int i = 1; i <= n; i++){
            if (a[i] == b[i]) continue;
            int L = max(1,i-a[i]);
            int R = min(n,i+a[i])+1;
            up(L,-1);
            if (R <= n) up(R,1);
            a[i] = b[i];
            L = max(1,i-a[i]);
            R = min(n,i+a[i])+1;
            up(L,1);
            if (R <= n) up(R,-1);
        }
    }
    for (int i = 1; i <= n; i++){
        printf("%d ",a[i]);
    }
}


Measured memory_bytes: 6100
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void dfs(int ind,vector<bool>& v, vector<vector<int>>& gr){
    if(v[ind]){
        v[ind]=false;
        for(auto x:gr[ind]) dfs(x,v,gr);
    }
}

void solve(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> gr(n);
    for(int i=0,x,y;i<m;i++){
        cin>>x>>y;
        gr[x-1].push_back(y-1);
        gr[y-1].push_back(x-1);
    }
    int cnt=0;
    vector<bool> v(n,true);
    for(int i=0;i<n;i++){
        if(v[i]){
            cnt++;
            dfs(i,v,gr);
        }
    }
    cout<<cnt-1<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 9544
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
const ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif
 
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll l,r,d,ans;
    
    cin >> l >> r >> d;

    ans = 0;
    for(ll i=l; i<=r; i++){
        if(i%d==0)
            ans++;
    }
    
    cout << ans << endl;
 
    return 0;
}



Measured memory_bytes: 3648
import numpy as np

tmp = list(map(int, input().split()))

N = tmp[0]
M = tmp[1]

i = list(map(int, input().split()))

i = np.array(i)

i = np.sort(i)[::-1]

souwa = np.sum(i)

if i[M-1] < (souwa * (1/(4*M))):
    print("No")
else:
    print("Yes")
# print(i[0]) #出力：i_1
# print(i[1]) #出力：i_2



Measured memory_bytes: 21408
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=1e5+5;

LL n,a[N],sum,ans[N];
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]),sum+=a[i],a[i]*=2;
	for(int i=1;i<=n;i+=2)
		sum-=a[i];
	ans[1]=-sum;
	for(int i=2;i<=n;i++){
		ans[i]=a[i-1]-ans[i-1];
	}
	for(int i=1;i<=n;i++){
		printf("%lld ",ans[i]);
	}
}

Measured memory_bytes: 2816
aj = []
bj = []
c = []

n, m = list(map(int, input().split()))
for i in range(n):
    ai = list(map(int, input().split()))
    aj.append(ai)
for j in range(m):
    bj.append(input())
for k in range(n):
    ctmp = 0
    for l in range(m):
        ctmp = ctmp + int(aj[k][l])*int(bj[l])
    c.append(ctmp)
for o in range(n):
    print(c[o])


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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


int main() {    
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = (double)w * (double)h / 2.0;

    bool multiple = false;
    if((x+x) == w && (y+y) == h) {
        multiple = true;
    }

    cout << fixed;
    cout << std::setprecision(6) << s << " " << multiple << endl;



    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<cstring>
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int a[300];
int b[100003];
int main()
{
 ll a;
 cin>>a;
 ll sum=0;
 for(ll i=1;i*i<=a;i++)
     {
       if(a%i==0){
            if(i!=1)
        if(a/(i-1)*(i)==a)sum+=i-1;
         if(i*i!=a)
         {
             ll q=a/i;
              if(a/(q-1)*(q)==a)sum+=q-1;
         }

       }
     }
     cout<<sum<<endl;
}


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

typedef long long ll;

int main(){
	ll N,K;
	cin >> N >> K;

	N = N%K;
	N = min(N,abs(N-K));

	cout << N << endl;
}

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

ll q;
bool prime[100001];

int main() {
    prime[1] = false;
    prime[2] = true;
    prime[3] = true;
    for (int i = 5; i <= 100000; i+=2) {
        bool flag = false;
        for (int j = 2; j <= sqrt(i); j++) {
            if(i%j == 0){
                flag = true;
                break;
            }
        }
        prime[i] = !flag;
    }
    ll sum[100001];
    
    for (int i = 1; i <= 100000; i++) {
        if(i%2==1 && prime[i] && prime[(1+i)/2]){
            sum[i] = sum[i-1] +1;
        }else{
            sum[i] = sum[i-1];
        }
    }
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        ll l,r;
        std::cin >> l>>r;
        std::cout << sum[r]-sum[l-1] << std::endl;
    }
}


Measured memory_bytes: 1536
#include <stdio.h>

int main(void){
  int a1, a2, a3;
  scanf("%d %d %d",&a1, &a2, &a3); //座標入力
  if (a1>=a3 && a3>=a2){
  printf("Yes");
  }else if (a3<=a2 && a1<=a3){
  printf("Yes");
  }else{
  printf("No");
  }
return 0;
}

Measured memory_bytes: 128
N,K = map(int,input().split())
src = list(map(int,input().split()))

ans = float('inf')
for l in range(N-K+1):
    r = l + K - 1
    if src[l] > 0:
        ans = min(ans, src[r])
    elif src[r] < 0:
        ans = min(ans, -src[l])
    else:
        ans = min(ans, src[r]*2 - src[l], -src[l]*2 + src[r])
print(ans)

Measured memory_bytes: 14696
#include <iostream>
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
using namespace std;

long long int max(long long int a,long long int b){
	if(a>b)return a;
	return b;
}

int main() {
    // your code goes here
    long long int n,W;cin>>n>>W;
    long long int v[n],w[n],dp[n+1][W+1];
    FOR(i,0,n)cin>>w[i]>>v[i];
    FOR(i,0,n+1){
        FOR(j,0,W+1){
            if(i==0 || j==0){
                dp[i][j]=0;
            }else{
                if(j>=w[i-1]){
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
                    
                    
                }else{
                    dp[i][j]=dp[i-1][j];
                }
            }
        }
    }
/*    FOR(i,0,n+1){
        FOR(j,0,W+1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
        
    }
*/    cout<<dp[n][W]<<endl;
    return 0;
}

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

int dp[31] = {1,1,2};
int ans[31];
int n;

int main(){
  
  for(int i = 3 ; i < 31 ; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  for(int i = 0; i < 31 ; i++){
    ans[i] = dp[i] / 10;
    if(dp[i] % 10 != 0) ans[i]++;
    ans[i] = ans[i] / 365 ;
    if(ans[i] % 365 != 0) ans[i]++;
    if(ans[i] == 0) ans[i]++;
  }
  /*
  for(int i = 0; i < 31 ; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  for(int i = 0; i < 31 ; i++){
    cout << dp[i] << " ";
  }
  */
  while(cin >> n, n != 0){

    cout << ans[n] << endl; 
  }
  
  return 0;
}

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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------

int tap(int a,int b){
    if(b==0) return 1;
    if(b==1) return a;
    else return a+(a-1)*(b-1);
}

int main(){
    CIN(A,B);
    int ans;
    rep(i,INF){
        if(tap(A,i)>=B) {ans=i; break;}
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

#define INLINE   inline __attribute__ ((always_inline))
#define NOINLINE __attribute__ ((noinline))

#define ALIGNED __attribute__ ((aligned(16)))

#define likely(x)   __builtin_expect(!!(x),1)
#define unlikely(x) __builtin_expect(!!(x),0)

#define SSELOAD(a)     _mm_load_si128((__m128i*)&a)
#define SSESTORE(a, b) _mm_store_si128((__m128i*)&a, b)

#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define REP(i,a)    FOR(i,0,a)
#define ZERO(m)     memset(m,0,sizeof(m))
#define ALL(x)      x.begin(),x.end()
#define PB          push_back
#define S           size()
#define LL          long long
#define ULL         unsigned long long
#define LD          long double
#define MP          make_pair
#define X           first
#define Y           second
#define VC          vector
#define PII         pair <int, int>
#define PDD         pair <double, double>
#define VI          VC < int >
#define VVI         VC < VI >
#define VVVI        VC < VVI >
#define VPII        VC < PII >
#define VD          VC < double >
#define VVD         VC < VD >
#define VVVD        VC < VVD >
#define VS          VC < string >
#define VVS         VC < VS >
#define DB(a)       cerr << #a << ": " << (a) << endl;
#define ASSERT      assert

template<class T> void print(VC < T > v) {cerr << "[";if (v.S) cerr << v[0];FOR(i, 1, v.S) cerr << ", " << v[i];cerr << "]" << endl;}
template<class T> string i2s(T x) {ostringstream o; o << x; return o.str();}

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> a;
  for(int i = 0; i < N; i++){
    int a_;
    cin >> a_;
    a.push_back(a_);
  }
  //print(a);
  int mi = *min_element(a.begin(), a.end());
  int ma = *max_element(a.begin(), a.end());
  //cout << ma  << " " << mi << endl;
  //if(ma >= a.size()){
  //  cout << "No";
  //  return 0;
  //}
  if(ma- mi >=2){
    cout << "No";
    return 0;
  }

  int mic = 0;
  for(int i = 0; i < a.size(); i++){
    if (a[i] == mi){
      mic++;
    }
  }

  int mac = N - mic;
  if(mac == 0){

    if(mi*2 <= N || mi == N-1){
      cout << "Yes";
      return 0;
    }
    cout << "No";
    return 0;
  }
  if(mac==1){
    cout << "No";
    return 0;
  }

  if((ma - mic)*2 > mac){
    cout << "No";
    return 0;
  }
  if(mic > mi){
    cout << "No";
    return 0;
  }


  cout << "Yes";
  return 0;

}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ll g = n / i;
    ans += i*g*(g+1)/2;
  }
  cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(3*n);
    for(int i = 0; i < 3*n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    ll cnt = 0;
    for(int i = 1; i < 3*n; i++){
        if(i%2 == 0){
            ans += a[3*n-i];
            cnt++;
        }
        if(cnt == n){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int i,sum=0;
	cin>>a;
	for(i=0;i<sizeof(a)/sizeof(a[0]);i++)
		if(a[i]=='1') sum+=1;
	cout<<sum;
	return 0;
} 


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};



int main() {
	vi v;
	string s;
	cin>>s;
	int sl=s.length();
	v.push_back(sl);
	rep(i,0,sl-1)
		if(s[i]!=s[i+1])v.push_back(max(i+1,sl-(i+1)));
	sort(ALL(v));
	print(v[0]);
}

Measured memory_bytes: 768
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

N, M = min(N, M), max(N, M)
if N == M == 1:
    print(1)
elif N == 1:
    print(M - 2)
elif N == 2:
    print(0)
else:
    print(N * M - 2 * (N - 1) - 2 * (M - 1))

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 
 
int main(){
	string s;
	char c='a';
	cin>>s;
	for(int i=0;i<26;i++){
		int ans=0;
		for(int j=0;j<s.size();j++){
			if(s[j]==c){
				ans=1;
			}
		}
		if(ans!=1){
			putchar(c);
			return 0;
		}
		c++;
	}
	cout<<"None"<<endl;
	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	string s;
	cin >> s;
	int n = s.size();
	rep(i, n) {
		cout << 'x';
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    int bad = 0;
    cin >> s;
    for (int i=0; i<s.size(); i++)
    {
        if (s[i] == 'x')  bad++;
    }
    if (15 - bad >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//============================
// ABC134c Exception Handling
//
// 2019/08/14
//  ver.1 TLE
//  ver.2 
//============================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int n;
  cin >> n;

  vector<int> a(n), sort_a;
  for(int i=0; i<n; i++) cin >> a[i];
  sort_a = a;
  sort(sort_a.begin(), sort_a.end());

  for(int i=0; i<n; i++)
  {
    if(a[i] == sort_a[n-1])
    {
      cout << sort_a[n-2] << endl;;
    }
    else
    {
      cout << sort_a[n-1] << endl;;
    }
  }

  return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 3e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,has[505][505];
ll f[505][505],ans;
int dx[5] = {-1,1,0,0};
int dy[5] = {0,0,-1,1};
void dfs(int x,int y)
{
    int now = f[x][y] + has[x][y];
    rep(i,0,3){
        int nx = x+dx[i],ny = y+dy[i];
        if(nx>=1&&nx<=n&&ny>=1&&ny<=n){
            if(f[nx][ny]>now){
                f[nx][ny] = now;
                dfs(nx,ny);
            }
        }
    }
}
int main()
{
    fastio();
    cin>>n;
    int x,y,s;
    rep(i,1,n) rep(j,1,n){
        f[i][j] = min(min(i-1,n-i),min(j-1,n-j));
        has[i][j] = 1;
    }
    ans = 0;
    rep(i,1,n*n){
        cin>>s;
        x = (s+n-1)/n;
        y = s-(x-1)*n;
        ans += f[x][y];
        has[x][y] = 0;
        dfs(x,y);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 21696
#include<stdio.h>
#include <stdbool.h>
int main(){
   int A,B,C,D;
   scanf("%d %d %d %d",&A,&B,&C,&D);
   bool a=true;
while (A > 0 && C > 0)
{
   if (a){
      C -= B;
   }else{
      A -= D;
   }
    a = !a;
}
if (A > 0){
   printf("Yes");
}else{
  printf("No");
}
return 0;
}


Measured memory_bytes: 1688
import itertools as it
import bisect
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
n=int(input())-1
x=[0]+[26**i for i in range(1,20)]
y=list(it.accumulate(x))
keta=bisect.bisect_left(y,n)
#print(y)
number=n-y[keta-1]
#print(number)
#print(keta)
ll=[]
for i in range(keta):
  u=number//(26)**(keta-i-1)
  ll.append(u+1)
  #print(ll)
  number-=u*((26)**(keta-i-1))
ans=list(num2alpha(i).lower() for i in ll)
#print(ll)
if n!=0:
   print(*ans,sep="")  
else:
  print("a")



Measured memory_bytes: 9248
N, K = (int(i) for i in input().split())
K = format(K,'b').zfill(40) 
A = [int(i) for i in input().split()]
A = [format(a,'b').zfill(40) for a in A]
C = [0]*40
for i in range(40):
    cc = 0
    for a in A:
        keta = 39 - i
        if a[keta] == "1":
            cc += 1
    C[keta] = cc
anslis = []
ans = 0
for i in range(40):
    iketa = 39 - i
    if K[i] == "1":
        tempans = ans
        for j in range(i, 40):
            jketa = 39 - j
            if i == j:
                tempans += C[j] * 2**jketa
            else:
                tempans += max(C[j], N-C[j]) * 2**jketa
        anslis.append(tempans)
        ans += (N-C[i]) * 2**iketa
    else:
        ans += C[i] * 2**iketa
anslis.append(ans)
print(max(anslis))

Measured memory_bytes: 17828
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a, b = inintm()
s = input()

x = 0
y = 0

try:
    x = int(s[:a])
    y = int(s[a+1:])
except:
    print("No")
    exit()

if s[a] == "-":
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61712
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
A = np.array(list(map(int, sys.stdin.readline().split())))

print(abs(A).max() - abs(A).min())




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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    long double n; cin >> n;
    vector<double> x(n), y(n);
    for(int i=0; i<n; i++){
        cin >> x[i];
        cin >> y[i];
    }
    long double sum = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i!=j){
                sum += sqrt(pow(x[i]-x[j], 2)+pow(y[i]-y[j],2));
            }
        }
    }
    cout << fixed << setprecision(10) << sum/n << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb(x) push_back(x)

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

void solve(){
    int n, m;
    cin >> n >> m;

    map<int, vector<int> > mp;

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

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        mp[a].pb(b);
        mp[b].pb(a);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        bool check = true;
        for(auto child : mp[i]){
            if(h[i] <= h[child]){
                check = false;
                break;
            }
        }
        if(check) ans++;
    }
    cout << ans;
}

int main(){


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

}

Measured memory_bytes: 14616
#include<stdio.h>

int main( ){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);

  if ( a > b )printf("No\n");
  else if ( a == b )printf("No\n");
  else if ( b > c )printf("No\n");
  else if ( b == c )printf("No\n");
  else printf("Yes\n");

  return 0;
}

Measured memory_bytes: 580
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

sep :: [Int] -> [Int] -> [[Int]]
sep [] ns = [ns]
sep (h : hs) ns
  | h == 0 = ns : sep hs []
  | otherwise = sep hs (h : ns)

calc :: [Int] -> Int
calc [] = 0
calc ls = lmin + sum (map (\ys -> calc ys) separated)
  where
    lmin = minimum ls
    separated = filter (\as -> as /= []) (sep (map (\x -> x - lmin) ls) [])

main = do
  n <- getInt
  hs <- getIntList
  print $ calc hs


Measured memory_bytes: 4304
n=int(input())
l=[]
T=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n-1):
	t=0
	for c,s,f in T[i:]:
		t=max(t,s+f*max(0,(t-s-1)//f+1))+c
	l.append(t)
l.append(0)
for x in l:
    print(x)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main(){
    string s;
     int offset = 'a' - 'A';

    //cin >> s;
    std::getline(std::cin, s);
    int size = s.length();

    for(int i = 0; i < size; i++){
    if(s[i]>=65 && s[i]<=90){
        s[i] = s[i] + offset;
    }else if(s[i]>=97 && s[i]<= 122){
        s[i] = s[i] - offset;  
    }}

    cout << s << endl;

    return 0;
}


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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};



int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N;cin >> N;
	vector<P> D(N); REP(i, N) cin >> D[i].first >> D[i].second;

	bool is{false};
	for (ll i = 0; i < N-2; ++i)
	{
		if (D[i].first == D[i].second && D[i+1].first == D[i+1].second && D[i+2].first == D[i+2].second)
			is = true;
	}

	std::cout << (is ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

typedef struct houi{
    int L;
    int R;
    int U;
    int D;
}houi;

int main(){
    int H,W;cin >> H >> W;
    vector<string> s(H+10);
    rep(i,H)cin >> s[i];

    vector<vector<houi>> A(H+10,vector<houi>(W+10,{0,0,0,0}));


    rep(i,H){
        int tmp = 0;
        rep(j,W){   // L
            if(s[i][j] == '#')tmp = 0;
            else ++tmp;
            A[i][j].L = tmp;
        }
    }


    rep(i,H){
        int tmp = 0;
        for(int j = W-1;j >= 0;--j){   // R
            if(s[i][j] == '#')tmp = 0;
            else ++tmp;
            A[i][j].R = tmp;
        }
    }


    rep(j,W){
        int tmp = 0;
        rep(i,H){   // U
            if(s[i][j] == '#')tmp = 0;
            else ++tmp;
            A[i][j].U = tmp;
        }
    }


    rep(j,W){
        int tmp = 0;
        for(int i = H-1;i >= 0;--i){   // D
            if(s[i][j] == '#')tmp = 0;
            else ++tmp;
            A[i][j].D = tmp;
        }
    }


    int ans = 0;
    rep(i,H)rep(j,W){
        int t = A[i][j].L + A[i][j].R + A[i][j].U + A[i][j].D - 3;
        ans = max(ans,t);
    }

    cout << ans << endl;
}

Measured memory_bytes: 67712
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
ll repow(ll k,ll n)
{
    ll ans=1;
    for(int i=0;i<n;i++)
    {
        ans= (((ans)*k) )%mod;
    }
    return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a;
    int n;
    cin>>n;
    cin>>a;
    int ans=0;
    for(int i=0;i<n-2;i++)
    {
        if(a[i]=='A' && a[i+1]=='B' && a[i+2]=='C')
            ans++;
    }
    cout<<ans;
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int r0 = 0, r1 = 0, r2 = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    if (p <= a) {
      r0++;
    } else if (p <= b) {
      r1++;
    } else {
      r2++;
    }
  }
  cout << min(r0, min(r1, r2)) << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main(void) {
	while(1) {
		int n, start, term, count = 0;
		scanf("%d", &n);
		if(!n) break;
		for(start = 1; start <= n / 2; start++) {
			for(term = 1;; term++) {
				int sum = term * (2 * start + term - 1) / 2;
				if(sum == n) {
					count++;
					break;
				} else if(sum > n) break;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 1028
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

a = I()
b = I()
c = {a, b}
if c == {1, 2}:
    print("3")
elif c == {2, 3}:
    print("1")
else:
    print("2")

Measured memory_bytes: 38256
import sys
from io import StringIO
import unittest

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

    x=[0]*(10**5+1)
    for a in ai:
        x[a]+=1
    
    k=n-1
    x2=0
    while k>=0:
        if k==0 and x[k]==1:
            x2+=0
        elif x[k]==2:
            x2+=1
        else:
            print(0)
            return
        k-=2
    
    print(pow(2,x2,10**9+7))
resolve()

Measured memory_bytes: 16508
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char c = s.charAt(0);
		if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
	}
	
}


Measured memory_bytes: 23764
N = int(input())
A = [int(a) for a in input().split()]

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)
    
A.sort()
c = A[0]
for i in range(1,N):
    ans = gcd(A[i],c)
    if ans == 1:
        break
    else:
        c = ans


print(ans)

Measured memory_bytes: 14252
n = int(input())
lst = [int(x) for x in input().split()]

total = [0, 0]
ret = [0, 0]
for i in range(2):
    for j in range(n):
        total[i] += lst[j]
        if (i + j) % 2 == 0:
            if total[i] >= 0:
                ret[i] += abs(total[i] + 1)
                total[i] = -1
        else:
            if total[i] <= 0:
                ret[i] += abs(total[i] - 1)
                total[i] = 1

print(min(ret))


Measured memory_bytes: 14372
#include<iostream>
#define INF 1e9
using namespace std;

int n,mp[101][101],D[101];
void dijkstra(){
  bool used[101]={};
  for(int i=0;i<101;i++)D[i]=INF;
  D[0]=0;
 
  while(1){
    int cost=INF,pos=-1;
    for(int i=0;i<n;i++) if(!used[i]&&D[i]<cost) pos=i,cost=D[i];//もし使用していなくて格納されているものよりコストが大きれればpositionをずらし、コストに今入っているDを入れる
    if(pos==-1)return ;
    used[pos]=1;//positionをずらしたら見たことになるので１に書き換える    
    for(int i=0;i<n;i++)D[i]=min(D[i],cost+mp[pos][i]);
  }
}

int main(){
     cin>>n;
  for(int i=0;i<101;i++)
    for(int j=0;j<101;j++) mp[i][j]=INF;
   
  for(int i=0,a,m;i<n;i++){
    cin>>a>>m;//aが頂点mが次数
    for(int j=0,b,c;j<m;j++)cin>>b>>c,mp[a][b]=c;
  }
  dijkstra();
  for(int i=0;i<n;i++)cout <<i<<" "<<D[i]<<endl;
   
  return 0;
}



Measured memory_bytes: 3132
class Queue():
    def __init__(self, size=10):
        self.queue = [None] * size
        self.head = self.tail = 0
        self.MAX = size
        self.num_items = 0

    def is_empty(self):
        return self.num_items == 0

    def is_full(self):
        return self.num_items == self.MAX

    def enqueue(self, x):
        if self.is_full():
            raise IndexError

        self.queue[self.tail] = x
        self.num_items += 1
        if self.tail+1 == self.MAX:
            self.tail = 0
        else:
            self.tail += 1

    def dequeue(self):
        if self.is_empty():
            raise IndexError

        x = self.queue[self.head]
        self.num_items -= 1
        if self.head+1 == self.MAX:
            self.head = 0
        else:
            self.head += 1

        return x


class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time

    def print_time(self):
        return self.time

    def print_name(self):
        return self.name


def main():
    n, q = map(int, input().split())
    qq = Queue(n)

    t = 0
    for i in range(n):
        name, time = input().split()
        p = Process(name, int(time))
        qq.enqueue(p)

    while not qq.is_empty():
        p = qq.dequeue()

        if p.time - q <= 0:
            t += p.time
            print("{} {}".format(p.name, t))
        else:
            p.time -= q
            t += q
            qq.enqueue(p)


if __name__ == '__main__':
    main()



Measured memory_bytes: 17160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(b,n*a) << endl;
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int H, W, d;

char c(int x, int y) {
	x = (x % (d * 2) + d * 2) % (d * 2);
	y = (y % (d * 2) + d * 2) % (d * 2);
	if (x < d) {
		if (y < d)return 'R';
		else return 'Y';
	}
	else {
		if (y < d)return 'B';
		else return 'G';
	}
}

int main() {
	cin >> H >> W >> d;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cout << c(i + j, i - j);
		}
		cout << endl;
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m,i,j,k,l;
	cin>>n>>k;
	set<ll> c;
	REP(i,0,k-1)
	{
		ll ans=1;
		cin>>l;
		REP(j,0,l-1){
			cin>>m;
			c.insert(m);
		}
	}
	cout<<n-c.size();
	return 0;
}


Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const ll INF = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2e5 + 7;
const int maxm = 1e5 + 7;
const int mod = 192600817;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main()
{
    IO;
    ll x;
    cin>>x;
    for (ll i=-1000;i<=1000;++i)
    {
        ll y=1LL*i*i*i*i*i+x;
        for (ll j=-1000;j<=1000;++j)
        {
            ll k=1LL*j*j*j*j*j;
            if (y==k)
            {
                cout<<j<<" "<<i<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<int> ls(N);
    for (auto &l : ls) cin >> l;

    sort(ls.begin(), ls.end());

    int n = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            for (int k = j + 1; k < N; ++k) {
                int a = ls[i];
                int b = ls[j];
                int c = ls[k];
                if (a < b + c && b < c + a && c < a + b) {
                    n++;
                }
            }
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
#include<list>

constexpr auto PI = 3.14159265359;

using namespace std;


int main() {
	int N, M;
	cin >> N >> M;

	vector<vector<int>> job(M + 1);
	priority_queue<int> que;

	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		if (M < a)continue;
		job[a].push_back(b);
	} 
	
	long long ans = 0;
	int jobs = 0;

	for (int i = 1; i <= M; ++i) {
		for (int j = 0; j < job[i].size(); ++j) {
			que.push(job[i][j]);
		}
		if (!que.empty()) {
			ans += que.top();
			que.pop();
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 5632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var _X = cin.Read;
            var _Y = cin.Read;
            var X = ToChar(_X);
            var Y = ToChar(_Y);
            char[] num = { 'A', 'B', 'C', 'D', 'E', 'F' };
            var x = Array.IndexOf(num, X);
            var y = Array.IndexOf(num, Y);
            if (x > y)
            {
                WriteLine(">");
            }
            else if (x < y)
            {
                WriteLine("<");
            }
            else
            {
                WriteLine("=");
            }
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


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

#if 0
#define PRINT_TAGS
#endif

typedef struct panel_t_tag {
	char* name;
	int x1, y1, x2, y2;
	struct panel_t_tag* child;
	struct panel_t_tag* next;
} panel_t;

int my_ungetchar_num = 0;
int my_ungetchar_buf[1024];
int my_getchar(void) {
	if (my_ungetchar_num > 0) return my_ungetchar_buf[--my_ungetchar_num];
	return getchar();
}
void my_ungetchar(int c) {
	my_ungetchar_buf[my_ungetchar_num++] = c;
}

panel_t* parse(void) {
	char tag_name[1024];
	int input;
	panel_t* new_panel;
	input = my_getchar();
	if (input != '<') return NULL;
	new_panel = malloc(sizeof(panel_t));
	if (new_panel == NULL) exit(1);
	input = my_getchar();
	ungetc(input, stdin);
	if (input == '/') {
		my_ungetchar('<');
		return NULL;
	}
	if (scanf("%[^>]", tag_name) != 1) exit(1);
	input = my_getchar(); assert(input == '>');
	new_panel->name = malloc(strlen(tag_name) + 1);
	if (new_panel->name == NULL) exit(1);
	strcpy(new_panel->name, tag_name);
	if (scanf("%d,%d,%d,%d", &new_panel->x1, &new_panel->y1, &new_panel->x2, &new_panel->y2) != 4) exit(1);
	input = my_getchar(); assert(input == '<');
	input = my_getchar();
	if (input == '/') {
		if (scanf("%[^>]", tag_name) != 1) exit(1);
		assert(strcmp(new_panel->name, tag_name) == 0);
		input = my_getchar(); assert(input == '>');
		new_panel->child = NULL;
	} else {
		ungetc(input, stdin);
		my_ungetchar('<');
		new_panel->child = parse();
		input = my_getchar();
		if (input == '<') {
			if (scanf("%[^>]", tag_name) != 1) exit(1);
			assert(tag_name[0] == '/' && strcmp(new_panel->name, tag_name + 1) == 0);
			input = my_getchar(); assert(input == '>');
		}
	}
	new_panel->next = parse();
	return new_panel;
}

void free_panel(panel_t* panel) {
	if (panel == NULL) return;
	free(panel->name);
	free_panel(panel->child);
	free_panel(panel->next);
	free(panel);
}

#ifdef PRINT_TAGS
void print_tags(const panel_t* panel, int level) {
	int i;
	if (panel == NULL) return;
	for (i = 0; i < level; i++) printf("  ");
	printf("%s %d %d %d %d\n", panel->name, panel->x1, panel->y1, panel->x2, panel->y2);
	print_tags(panel->child, level + 1);
	print_tags(panel->next, level);
}
#else
int touch(const panel_t* panel, int x, int y) {
	int ret = 0;
	for (; panel != NULL; panel = panel->next) {
		if (panel->x1 <= x && x <= panel->x2 && panel->y1 <= y && y <= panel->y2) {
			int nret = touch(panel->child, x, y);
			if (nret >= 0) printf("%s %d\n", panel->name, nret);
			return -1;
		}
		ret++;
	}
	return ret;
}
#endif

int main(void) {
	char n_str[1024];
	int n, i;
	panel_t* root;
	while (fgets(n_str, sizeof(n_str), stdin) != NULL && sscanf(n_str, "%d", &n) == 1 && n > 0) {
		root = parse();
#ifdef PRINT_TAGS
		print_tags(root, 0);
#else
		for (i = 0; i < n; i++) {
			int x, y;
			if (fgets(n_str, sizeof(n_str), stdin) == NULL || sscanf(n_str, "%d%d", &x, &y) != 2) return 1;
			if (touch(root, x, y) >= 0) {
				puts("OUT OF MAIN PANEL 1");
			}
		}
#endif
		free_panel(root);
	}
	return 0;
}

Measured memory_bytes: 652
import java.util.*;

public class Main{

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    int m = sc.nextInt();
	    if(n==0 && m==0) break;
	    int[] c = new int[m];
	    for(int i=0; i<m; i++) c[i] = sc.nextInt();
	    
	    int INF = 1500000000;
	    int[][] dp = new int[256][n+1];
	    for(int i=0; i<256; i++) Arrays.fill(dp[i], INF);
	    dp[128][0] = 0;
	    
	    for(int i=1; i<=n; i++){
		int x = sc.nextInt();
		for(int j=0; j<256; j++){
		    if(dp[j][i-1]==INF) continue;
		    for(int k=0; k<m; k++){
			int newY = j+c[k];
			if(newY<0) newY = 0;
			else if(newY>255) newY = 255;
			dp[newY][i] = Math.min(dp[newY][i], dp[j][i-1]+(newY-x)*(newY-x));
		    }
		}
	    }
	    
	    int min = INF;
	    for(int i=0; i<256; i++) min = Math.min(min, dp[i][n]);
	    
	    System.out.println(min);
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 37000