akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MAX_V 100000
using namespace std;
int V,m,w[100001],S[100001];
vector<int> vv[100001];
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];
int C[100001],F[100001],U[100001],ans,UU[100001],UUU[100001];

void DFS(int p,int pr){
  if(S[p]++)return;
  for(int i=0;i<vv[p].size();i++){
    int np=vv[p][i];
    if(pr!=np){
      G[p].push_back(np);
      rG[np].push_back(p);
      DFS(np,p);
    }
  }
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++)if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++)if(!used[rG[v][i]])rdfs(rG[v][i],k);
}

int scc(){
  for(int v=0;v<V;v++)if(!used[v])dfs(v);
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]])rdfs(vs[i],k++);
  return k;
}

bool DFS1(int p){
  if(U[p]++)return 0;
  bool f=F[cmp[p]]>=2;
  for(int i=0;i<G[p].size();i++)
    f|=DFS1(G[p][i]);
  ans+=w[p]*f;
  return UU[p]=f;
}

int DFS2(int p){
  if(UUU[p]++)return 0;
  int res=0;
  for(int i=0;i<G[p].size();i++)
    res=max(res,DFS2(G[p][i]));  
  return res+(UU[p]?0:w[p]);
}

int main(){
  cin>>V>>m;
  for(int i=0;i<V;i++)cin>>w[i];
  for(int j=0,a,b;j<m;j++){
    cin>>a>>b;a--,b--;
    vv[a].push_back(b),vv[b].push_back(a);
  }
  DFS(0,-1);
  scc();
  for(int i=0;i<V;i++)F[cmp[i]]++;
  DFS1(0);
  cout<<ans+DFS2(0)<<endl;
  return 0;
}

Measured memory_bytes: 28896
/**********************************/
	#include <bits/stdc++.h>
	#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define lli long long int
	#define pb push_back
	#define tr(container, it) for(auto it = container.begin(); it != container.end(); it++)
	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp>
	#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
	using namespace __gnu_pbds;
	using namespace std;
	const lli MAX=1000000;
	const lli mod=1e9+7;
	/**********************************/
	auto cmp=[](const pair<lli,string>&p1,const pair<lli,string>&p2){return (p1.first>p2.first)||(p1.first==p2.first&&p1.second<p2.second);};
	struct order{
		template<class T>
		bool operator()(T const& a,T const& b){
			if(a.first==b.first)
				return a.second<b.second;
			return a.first>b.first;
		}
	};
	struct HASH{
	  size_t operator()(const pair<lli,lli>&x)const{
	    return hash<lli>()(((long long)x.first)^(((long long)x.second)<<32));
	  }
	};
	/**********************************/

lli maxsubarray(vector<lli> &v,lli n){
	lli max_so_far=v[0],cur_max=v[0],i;
	for(i=1;i<n;i++){
		cur_max = max(v[i],cur_max+v[i]);
		max_so_far=max(cur_max,max_so_far);
	}
	return max_so_far;
}
void multiply(lli F[(lli)2][(lli)2], lli M[(lli)2][(lli)2]); 
  
void power(lli F[(lli)2][(lli)2], lli n); 
  
lli fib(lli n) 
{ 
  lli F[(lli)2][(lli)2] = {{1,1},{1,0}}; 
  if (n == 0) 
    return 0; 
  power(F, n-1); 
  return F[0][0]; 
} 

void power(lli F[(lli)2][(lli)2], lli n) 
{ 
  if( n == 0 || n == 1) 
      return; 
  lli M[(lli)2][(lli)2] = {{1,1},{1,0}}; 
  
  power(F, n/2); 
  multiply(F, F); 
  
  if (n%2 != 0) 
     multiply(F, M); 
} 
  
void multiply(lli F[(lli)2][(lli)2], lli M[(lli)2][(lli)2]) 
{ 
  lli x =  (((F[0][0]%mod)*(M[0][0]%mod))%mod + ((F[0][1]%mod)*(M[1][0]%mod))%mod)%mod;
  lli y =  (((F[0][0]%mod)*(M[0][1]%mod))%mod + ((F[0][1]%mod)*(M[1][1]%mod))%mod)%mod;  
  lli z =  (((F[1][0]%mod)*(M[0][0]%mod))%mod + ((F[1][1]%mod)*(M[1][0]%mod))%mod)%mod; 
  lli w =  (((F[1][0]%mod)*(M[0][1]%mod))%mod + ((F[1][1]%mod)*(M[1][1]%mod))%mod)%mod; 
  
  F[0][0] = x; 
  F[0][1] = y; 
  F[1][0] = z; 
  F[1][1] = w; 
} 
lli dp[100005][3];
lli h[100005][3];
lli solve(lli sl,lli i,lli n){
	if(i>=n-1){
		dp[i][sl]=h[i][sl];
		return h[i][sl];
	}
	if(dp[i][sl]!=-1)
		return dp[i][sl];
	lli ans = INT_MIN;
	if(sl==0){
		ans = max((h[i][sl]+solve(1,i+1,n)),(h[i][sl]+solve(2,i+1,n)));
	}
	else if(sl==1){
		ans = max((h[i][sl]+solve(0,i+1,n)),(h[i][sl]+solve(2,i+1,n)));
	}
	else{
		ans = max((h[i][sl]+solve(0,i+1,n)),(h[i][sl]+solve(1,i+1,n)));
	}
	dp[i][sl]=max(ans,dp[i][sl]);
	return dp[i][sl];
}

int main(){
	fast;
	lli n,i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>h[i][0]>>h[i][1]>>h[i][2];
	}
	memset(dp,-1,sizeof(dp));
	lli ans = INT_MIN;
	// for(i=0;i<n;i++)
	// 	cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<"\n";
	for(i=0;i<3;i++)
	ans = max(ans,solve(i,0,n));
	cout<<ans;
}

Measured memory_bytes: 11136
import Data.List

main = do
  k <- (read :: String -> Int) . last . words <$> getLine
  nums <- sortBy (\x y -> compare (length x) (length y)) . group . sort . map (read :: String -> Int) . words <$> getLine
  let kind = length nums
  if kind > k then putStrLn $ show . length . concat . take (kind - k) $ nums
              else putStrLn "0"


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

	if(a>=10 || b>=10){
		cout<<-1<<endl;
	}else{
		cout<<a*b<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
#define mod 1000000007
int main(){
	fast;
	ll n;
	cin>>n;
	ll arr[n];
	vector <int> ans;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	for(ll i=0;i<n;i++)
	{
		if(n%2 == 0)
			if(i%2 != 0)
				ans.insert(ans.begin(), arr[i]);
			else
				ans.push_back(arr[i]);
		else
			if(i%2 == 0)
				ans.insert(ans.begin(), arr[i]);
			else
				ans.push_back(arr[i]);
 
	}
	for(int i=0;i<ans.size();i++)
	{
		cout<<ans[i]<<" ";
	}
	return 0;
}



Measured memory_bytes: 5852
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

vector<int>vec[M+2];

 main()

{
    fast
    int n,m,a,b;
    cin>>n>>m;
    f(i,1,n)
    {
        cin>>a>>b;
        int last=m-a;
        if(last<0)continue;
        vec[last].pb(b);
    }
    set<int>s;
    map<int,int>cnt;
    int ses=0;
    rf(i,M-1,0)
    {
         for(auto x:vec[i])
         {
             s.insert(-x);
             cnt[x]++;
         }
         if(s.size()){
         int mx=*s.begin();
         mx=-mx;
         ses+=mx;
         cnt[mx]--;
         if(cnt[mx]==0)s.erase(-mx);}
    }
    cout<<ses<<endl;
















    return 0;

}













Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int e, y;
  cin >> e >> y;
  if (e == 0) {
    if (1868 <= y && y <= 1911) {
      cout << "M" << y - 1868 + 1 << endl;
    }
    if (1912 <= y && y <= 1925) {
      cout << "T" << y - 1912 + 1 << endl;
    }
    if (1926 <= y && y <= 1988) {
      cout << "S" << y - 1926 + 1 << endl;
    }
    if (1989 <= y && y <= 2016) {
      cout << "H" << y - 1989 + 1 << endl;
    }
  } else {
    if (e == 1) {
      cout << 1868 + y - 1 << endl;
    }
    if (e == 2) {
      cout << 1912 + y - 1 << endl;
    }
    if (e == 3) {
      cout << 1926 + y - 1 << endl;
    }
    if (e == 4) {
      cout << 1989 + y - 1 << endl;
    }
  }
}



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

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



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int a[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
	int x,y;
	cin >> x >> y;
	if(a[x] == a[y])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cmath>
#define int long long
int n,q;
int mi[200001],sum[200001];
int summ[1000001],s,t,lazi[1000001];
using namespace std;

void bui(int k,int l,int r)
{
	if(l==r)
	{
		summ[k]=mi[l];
		return;
	}
	int mid=(l+r)>>1;
	bui(k<<1,l,mid),bui(k<<1|1,mid+1,r);
	summ[k]=(summ[k<<1]+summ[k<<1|1])%998244353; 
	return ;
}

void add(int k,int l,int r,int v)
{
	lazi[k]=v;
	summ[k]=(((sum[r]-sum[l-1]+998244353)%998244353)*v)%998244353;
	return;
}

void pushd(int k,int l,int r,int mid)
{
	if(lazi[k]==0)
		return;
	add(k<<1,l,mid,lazi[k]);
	add(k<<1|1,mid+1,r,lazi[k]);
	lazi[k]=0;
	return;
}

void updata(int k,int l,int r,int v)
{
	if(l>=s&&r<=t)
	{
		add(k,l,r,v);
		return;
	}
	int mid=(l+r)>>1;
	pushd(k,l,r,mid);
	if(s<=mid) updata(k<<1,l,mid,v);
	if(mid<t) updata(k<<1|1,mid+1,r,v);
	summ[k]=(summ[k<<1]+summ[k<<1|1])%998244353;
}

signed main()
{
	scanf("%lld%lld",&n,&q);
	mi[1]=1,sum[1]=1;
	for(int i=2;i<=n;i++)
	{
		mi[i]=(mi[i-1]*10)%998244353;
		sum[i]=(mi[i]+sum[i-1])%998244353;
	}
	bui(1,1,n);  
	int num;
	for(int i=1;i<=q;i++)
	{
		int ss,tt;
		scanf("%lld%lld%lld",&ss,&tt,&num);
		s=n-tt+1,t=n-ss+1;
		updata(1,1,n,num);
		printf("%lld\n",summ[1]);
	}

	return 0;
 }


Measured memory_bytes: 15120
import java.util.Scanner;

class Main{
     public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n = scan.nextInt();
    	int a[] = new int[n];
    	
    	for(int i = 0; i < n; i++){
    		a[i] = scan.nextInt();
    	}
    	
    	for(int i = n - 1; i >= 0; i--){
    		System.out.print(a[i]);
    		if(i != 0){
    			System.out.print(" ");
    		}
    	}
    	System.out.println("");
     }
}

Measured memory_bytes: 26392
//
//  main.cpp
//  ABC159
//
//  Created by 安藤光希 on 2020/04/20.
//  Copyright © 2020 安藤光希. All rights reserved.
// https://atcoder.jp/contests/abc158


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i<n; i++)
using namespace std;
typedef long long ll;

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

/* A
 
 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

mint dp[105][100005];

int main() {
    int n, k; cin >> n >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    rep(i,n+1) dp[i][0] = 1;
    vector<mint> sum(k+1,1);
    REP(i,n+1) {
        vector<mint> sum_tmp(k+1);
        sum_tmp[0] = 1;
        REP(j,k+1) {
            if (j-a[i-1] >= 1) dp[i][j] = sum[j] - sum[j-a[i-1]-1];
            else dp[i][j] = sum[j];
            sum_tmp[j] = sum_tmp[j-1] + dp[i][j];
        }
        swap(sum_tmp,sum);
    }
    cout << dp[n][k] << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

using pii = pair<int,int>;
vector<pii> xedge,yedge;

using edge = tuple<ll,int,int>;
vector<edge> graph;


struct Union_find{
	Union_find(int n){par.resize(n),iota(_all(par),0);}
	int find(int x){return (par[x]==x)?x:par[x]=find(par[x]);}
	void unite(int a,int b){a=find(a),b=find(b);par[a]=b;}
	bool same(int a,int b){return find(a)==find(b);}
	vector<int> par;
};


int main(void){
	int n;
	cin >> n;
	rep(i,n){
		int x,y;
		cin >> x >> y;
		xedge.push_back(pii(x,i));
		yedge.push_back(pii(y,i));
	}

	sort(begin(xedge),end(xedge));
	sort(begin(yedge),end(yedge));
	
	rep(i,n-1){
		graph.push_back(edge(xedge[i+1].first-xedge[i].first,xedge[i].second,xedge[i+1].second));
		graph.push_back(edge(yedge[i+1].first-yedge[i].first,yedge[i].second,yedge[i+1].second));
	}

	sort(begin(graph),end(graph));

	Union_find uf(n);

	ll ans = 0LL;
	for(auto &e:graph){
		ll c,a,b;
		tie(c,a,b) = e;
 		if(uf.same(a,b)) continue;
 		ans += c;
 		uf.unite(a,b);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8040
import numpy

K = int(input())
N = 50

ans = numpy.array([49]*50)
ans += K // N
for i in range(K % N):
    ans -= 1
    ans[i] += 50

# print(ans)
ans = list(map(str, ans))
print(N)
print(" ".join(ans))

# cnt = 0
# while not (all(map(lambda x: x <= 49, ans))):
#     cnt += 1
#     ans.sort()
#     ans[-1] -= 50
#     ans[:49] += 1
# 
# print(cnt)

Measured memory_bytes: 12464
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const signed INF_=1001001001; const int INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N=IN,H=IN;
    vi a(N),b(N);
    REP(i,N) {
        a[i]=IN,b[i]=IN;
    }

    vector<pii> B;
    B.reserve(N);
    int mx=(*max_element(ALL(a)));
    int idx=0;
    int sum=0;
    REP(i,N) {
        if(a[i]==mx) {
            idx=i;
        }
        if(b[i]>mx) {
            B.push_back({b[i],i});
            sum+=b[i];
        }
    }
    sort(RALL(B));
    int ans=0;
    if(sum>=H) {
        REP(i,SZ(B)) {
            if(H>0) {
                H-=B[i].first;
                ans++;
            }
        }
    } else {
        REP(i,SZ(B)) {
            if(B[i].second==idx) continue;
            if(H<=0) {
                break;
            }
            H-=B[i].first;
            ans++;
        }
    }
    while(H>b[idx]) {
        H-=a[idx];
        ans++;
    }
    if(H>0) {
        ans++;
        H-=b[idx];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(),s.end());
    vector<string>v = {
        "maerd",
        "remaerd",
        "esare",
        "resare"
    };
    bool ok = false;
    int pos = 0;
    while(pos < n){
        ok = false;
        for(auto i: v){
            if(i == s.substr(pos,i.size())) {
                ok = true;
                int sz = i.size();
                pos += sz;
                break;
            }
        }
        if(ok == false){
            cout << "NO" << endl;
            return 0;
        }
    }

    if(pos == n)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 200100;
int dp[maxn], n;
int last_ind[30];
string code;
int pntr[maxn];
char c[maxn];

int main() {
    cin>>code;
    n = code.length();

    for(int i=0;i<26;i++) last_ind[i] = n;

    pntr[n] = n + 1;
    c[n] = 'a';
    dp[n] = 1;
    dp[n+1] = 0;
    code += 'a';
    for(int i=n-1;i>=0;i--) {
        // fix character i as start of the subsequence
        // let j -> be the second character of the result

        last_ind[int(code[i] - 'a')] = i;

        dp[i] = 1000000;
        for(int j=0;j<26;j++) {

            if(dp[last_ind[j] + 1] + 1 < dp[i]) {
                dp[i] = dp[last_ind[j] + 1] + 1;
                pntr[i] = last_ind[j] + 1;
                c[i] = char('a' + j);
            }
        }
    }

    int result = dp[0];
    int x = 0;
    while(result) {
        cout<<c[x];
        x = pntr[x];
        result--;
    }

    return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> bamboo_length(n);
    rep(i, n) cin >> bamboo_length[i];
    llong needed_iteration = 0;
    rep(i, n) needed_iteration += pow(4, i);
    needed_iteration *= 3;

    int ans = 1000000000;
    rep(bit, needed_iteration + 1) {
        llong tmp_bit = bit;
        list<int> com;
        while (1) {
            com.push_back(tmp_bit % 4);
            tmp_bit /= 4;
            if (tmp_bit < 4) {
                com.push_back(tmp_bit);
                break;
            }
        }

        if (com.size() < n) {
            int needed_add_0 = com.size();
            for (int i = 0; i < n - needed_add_0; ++i) {
                com.push_back(0);
            }
        }

        int len_a = 0, len_b = 0, len_c = 0;
        int cnt_a = 0, cnt_b = 0, cnt_c = 0;
        int i = 0;
        stl_rep(itr, com) {
            // cout << *itr << " ";
            if (*itr == 0) len_a += bamboo_length[i], ++cnt_a;
            if (*itr == 1) len_b += bamboo_length[i], ++cnt_b;
            if (*itr == 2) len_c += bamboo_length[i], ++cnt_c;
            ++i;
        }
        // cout << endl;
        if (len_a == 0 || len_b == 0 || len_c == 0) continue;
        ans = min(ans, abs(a - len_a) + abs(b - len_b) + abs(c - len_c) + 10 * (cnt_a - 1 + cnt_b - 1 + cnt_c - 1));
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    string s;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        if (s == "Y")
        {
            cout << "Four" << endl;
            exit(0);
        }
    }
    cout << "Three" << endl;
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  long long A,B,C,K;
  long long res;
  cin >> A >> B >> C >> K;
  res = min (A,K) - max (0ll, K-A-B);

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

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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

int main()
{
  int costs[] = {0, 6000, 4000, 3000, 2000};
  rep(i, 4){
    int id, n;
    id = in();
    n = in();
    printf("%d\n", costs[id] * n);
  }
  return 0;
}

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

using namespace std;
typedef long long lld;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b,a%b);
}

int main() {
	int n;
	cin >> n;
	lld sum = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				sum += gcd(gcd(i,j),k);
			}
		}
	}	
	cout << sum << endl;
	
	return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int W, H; cin >> W >> H;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
    rep(i, W){
        ll a; cin >> a;
        pq.push(make_pair(a, 0));
    }
    rep(i, H){
        ll a; cin >> a;
        pq.push(make_pair(a, 1));
    }
    //(W+1)*(H+1)-1本の辺を引く
    //W+H回選ぶ
    ll ans = 0;
    int loop = W+H;
    rep(i, loop){
        ll val = pq.top().first;
        int which = pq.top().second;
        //cout << "val: " << val << ", which: " << which << endl;
        if(which){
            ans += val*(W+1);
            H--;
        }
        else{
            ans += val*(H+1);
            W--;
        }
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

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

bool custom_sort(int &x, int &y)
{
    if(x<y)
        return 1;
    else
        return 0;
}

void always_ignore_function_name()
{
    int n;
    cin>>n;
    vi cnt(4,0);
    while(n--)
    {
        string s;
        cin>>s;
        if(s[0]=='A')
            cnt[0]++;
        if(s[0]=='W')
            cnt[1]++;
        if(s[0]=='T')
            cnt[2]++;
        if(s[0]=='R')
            cnt[3]++;
    }
    cout<<"AC x "<<cnt[0]<<endl;
    cout<<"WA x "<<cnt[1]<<endl;
    cout<<"TLE x "<<cnt[2]<<endl;
    cout<<"RE x "<<cnt[3]<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        always_ignore_function_name();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3848
def sum_dict(d, sum, b, c):
    val = 0
    if b in d:
        val = d[b]
        sum -= (b * val)
        del d[b]
        d[c] = d.get(c, 0) + val
        sum += (c * val)
    return sum, d
    
n = int(input())
a = [int(x) for x in input().split()]
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
s = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    s, d = sum_dict(d, s, b, c)
    print(s)

Measured memory_bytes: 20640
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
 
#define pb 					push_back
 
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
 
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<"\n";
 
	return os;
}
 
 
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<"\n";
 
	return os;
}

int main() {
	int a, b;
	cin >> a >> b;
	for(int i=0; i<=1300; i++) {
		if((int)(i*0.08) == a && (int)(i*0.1) == b) {
			cout << i << "\n";
			return 0;
		}
	}
	cout << -1 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;

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

    int times[N+1]={};
    
    times[0]=0;
    for(int i=1; i<=N; i++){
        times[i]=times[i-1]+1;
        
        int six=6;
        while(i-six>=0){
            times[i]=min(times[i],times[i-six]+1);
            six*=6;
        }
        int nine=9;
        while(i-nine>=0){
            times[i]=min(times[i],times[i-nine]+1);
            nine*=9;
        }
    }
    
    cout<<times[N]<<endl;
    return 0;
}




Measured memory_bytes: 640
n = int(input())
p = [int(input()) for _ in range(n)]

if sum(p)%10:
    print(sum(p))
else:
    p.sort()
    i = 0
    for i in range(n):
        if p[i]%10:
            print(sum(p) - p.pop(i))
            break
    else: print(0)


Measured memory_bytes: 3064
julia -En,s=`tr '
' ,`1";A=3n;f(b,n)=n<b?n:f(b,n÷b)+n%b;g(b)=b>1&&f(b,n)==s?A<b?A:b:A;A=g(n+1);for b=1:isqrt(n);A=g(b);A=g((n-s)÷b+1);end;A>2n?-1:A"

Measured memory_bytes: 155132
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll L, R; cin >> L >> R;
  R = min(R, L + 4038);
  ll ans = INF;
  for (ll i = L; i <= R; ++i){
    for (ll j = i + 1; j <= R; ++j){
      ans = min(ans, (i * j) % 2019);
    }
  }
  cout << ans << endl;
}


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

char data[102][102];
void DFS(char key,int i,int j){
  if(data[i][j]!=key)
    return;
  data[i][j]='0';
  DFS(key,i,j-1);
  DFS(key,i,j+1);
  DFS(key,i+1,j);
  DFS(key,i-1,j);
}
int main(){
  int cnt;
  while(1){
    cnt=0;
    for(int i=0;i<102;i++){
      for(int j=0;j<102;j++){
        data[i][j]='0';
      }
    }
    int H,W;
    cin>>H>>W;
    if(!H&&!W)
      break;
    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        cin>>data[i][j];
      }
    }
    //cout<<endl;
    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        if(data[i][j]!='0'){
          DFS(data[i][j],i,j);
          cnt++;
          //cout<<cnt<<endl;
          /*for(int k=1;k<=H;k++){
            for(int z=1;z<=W;z++){
              cout<<data[k][z];
            }
            cout<<endl;
          }*/
          //cout<<endl;
        }
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m,d,count=0,d1,d2;
    cin>>m>>d;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            d1=0;
            d2=j%10;
            if(j>=10){
                d1=j/10;
            }
            if(d1*d2==i && d1>=2 && d2>=2){
                count++;
            }
        }
    }
    cout<<count<<'\n';
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  llc(n);
  vector<string> s(n);
  vector<ll> a(n, 0);
  r1(i, n) cin >> s.at(i);
  sort(s.begin(), s.end());
  ll b=0;
  if (n==1) cout << s.at(0) << endl;
  else {
    r2(i, n) if(s.at(i)==s.at(i-1)) {
      a.at(i)=a.at(i-1)+1;
      b=max(a.at(i),b);
    }
    r1(i,n) if(a.at(i)==b) cout << s.at(i) << endl;
  }
}

Measured memory_bytes: 15872
#include <stdio.h>
static const int N = 1000;
 
void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
      printf("%d", A[i]);
  }   
  printf("\n");
}
 
int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);
 
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
   
  trace(A, n);
 
  for(i=2;i<=n;i++){
    v=A[i];
    j=i-1;
    while(j>0 && A[j]>v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    trace(A, n);
  }
    
  return 0;
}

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
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...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc145/tasks/abc145_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int r; cin >> r;
    res = r*r;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll res = max(a * c, b * d);
  res = max(res, a * d);
  res = max(res, b * c);
  cout << res << endl;
  return 0; 
}


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

vector < int > Z_algorithm(string &W) {
    int i = 1, j = 0;
    vector < int > Z(W.size());
    Z[0] = W.size();
    while (i < W.size()) {
        while (i + j < W.size() && W[i + j] == W[j]) j++;
        Z[i] = j; 
        if (j == 0) { i++; continue; }
        int k = 1;
        while (Z[k] + k < j) {
            Z[i + k] = Z[k];
            k++;
        }
        i += k, j -= k;
    }
    return (Z);
}

vector < bool > isgood(string &W) {
    vector < int > Z;
    vector < bool > ret(W.size() + 1, true);
    Z = Z_algorithm(W);
    
    for (int p = 1; p < W.size(); p++) {
        if (!ret[p]) continue;
        for (int k = 2; (k - 1) * p <= Z[p]; k++) {
            ret[k * p] = false;
        }
    }
    return (ret); 
}

int main() {
    string W, RW;
    cin >> W;

    RW = W;
    reverse(begin(RW), end(RW));
    
    vector < bool > ans1, ans2;

    ans1 = isgood(W); //prefix
    ans2 = isgood(RW);
    reverse(begin(ans2), end(ans2)); //suffix
    
    int ans = 0;
    for (int i = 0; i <= W.size(); i++) {
        ans += (ans1[i] && ans2[i]);
    }
    if (ans == 0) cout << W.size() << endl << 1 << endl;
    else if (ans1[W.size()]) cout << 1 << endl << 1 << endl;
    else cout << 2 << endl << ans << endl;
    
    return (0);
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;

int main(void){
    ll result = 0;
    
    ll N;
    cin >> N;
    int count = 0;
    for(int i = 1; i <= N; i += 2){
        for(int j = 1; j <= N; j ++){
            if(i % j == 0){
                count ++;
            }
        }
        if(count == 8){
            result ++;
        }
        count = 0;
    }
    
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      var n = readLine.split(" ").map(_.toInt)
      while( n(0) != 0 || n(1) != 0) {
        println("#"*n(1))

        (2 to n(0)-1).foreach(s=> { print("#");print("."*(n(1)-2));print("#\n") })

        if(n(0)>1) {
          println("#"*n(1))
        }
        println("")
        n = readLine.split(" ").map(_.toInt)
      }
  }
}

Measured memory_bytes: 45088
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;

long long sum[200010],ans;
int num[100000010],tot,n,a[2000010];
map <long long,int> mp;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum[i]=sum[i-1]+a[i];
		if(mp[sum[i]]==0) mp[sum[i]]=++tot;
	}
	for(int i=1;i<=n;i++)
	{
		if(sum[i]==0) ans++;
		if(num[mp[sum[i]]]==0)
		{
			num[mp[sum[i]]]++;
		}
		else
		{
			ans+=num[mp[sum[i]]];
			num[mp[sum[i]]]++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 20352
# coding: utf-8
# Your code here!

import numpy as np

N, K = map(int, input().rstrip().split(' '))
H = np.array(list(map(int, input().rstrip().split(' '))))

if K > N:
    K = N

dp = np.array([0] * N)
dp[0] = 0
for i in range(K):
    dp[i] = np.abs(H[i] - H[0])

for i in range(K, N):
    dp[i] = np.min(dp[i-K:i] + np.abs(H[i-K:i] - H[i]))
    
print(dp[N-1])


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


int main () {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22){
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
}

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

string s;

bool is_ok(int cnt){
    for(int i = 0; i <= cnt/2; i++){
        if(s[i] != s[cnt/2 + i + 1]) return false;
    }
    return true;
}

int main(void){
    cin >> s;
    int len = s.size();
    for(int i = len - 3; i >= 1; i -= 2){
        if(is_ok(i)){
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     point        complex<ll>
#define    cp(a,b)          (((conj(a))*(b)).imag())
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
string st;
int a[2002];
vector<int> arr;
int get(int a,int b){
   return upper_bound(all(arr),b)-lower_bound(all(arr),a);
}
int main(){
    GO();
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int no;
        cin>>no;
        arr.pb(no);
    }
    sort(all(arr));
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int a=arr[i];
            int b=arr[j];
            int mx= a+b-1;
            int mi=max(llabs(a+1-b),llabs(b+1-a));
            int add=0;
            if(a>=mi&&a<=mx) add++;
            if(b>=mi&&b<=mx) add++;
            ll ret=get(mi,mx)-add;
            ans+=ret;
           // cout<<ret<<endl;
        }
    }
    cout<<ans/3<<endl;
}






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


int main(){
	int a,b,c;
	cin>>a;
	cin>>b;
	cin>>c;
	int mx = max({a,b,c});
	int mn = min({a,b,c});
	int ans = mx*10 + mn + (a+b+c - mx - mn);
	cout<< ans <<endl;
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int m = INT_MAX;
    int res = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (x < m) {
            m = x;
            res++;
        }
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
w = []
for _ in range(n):
    w.append(input())

ans = True
if len(set(w)) != len(w):
    print("No")
else:
    tmp = w[0][-1]
    for x in w[1:]:
        if tmp != x[0]:
            ans = False
            break
        else:
            tmp = x[-1]
    if ans:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());

            for (int j = a; j < a * b; j += a) {
                if (j % b == c) {
                    out.println("YES");
                    return;
                }

            }
            out.println("NO");

            // 出力


        }

    }
}



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

int n;
ll m, a[101010], as[101010];

int main()
{
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    sort(a, a + n);

    as[n - 1] = a[n - 1];
    for(int i = n - 1; i >= 1; i--) as[i - 1] = as[i] + a[i - 1];

    ll ok = 300000, ng = -1;
    ll res = 0;
    while(abs(ok - ng) > 1)
    {
        ll mid = abs(ok + ng) / 2;
        ll cnt = 0, sum = 0;
        rep(i, n)
        {
            auto ptr = lower_bound(a, a + n, mid - a[i]);
            int num = (int)(ptr - a);
            
            sum += as[num] + a[i] * (n - num);
            cnt += n - num;
        }
        sum += (mid - 1) * (m - cnt);
        
        if(cnt > m)
        {
            ng = mid;
        }
        else
        {
            ok = mid;
            res = sum;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000

int main() {
	long long x, y, z;
	long long s, ans;
	scanf("%lld %lld %lld", &x, &y, &z);
	ans = y / z;
	ans -= ((x - 1) / z);
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {

        static void Main(string[] args)
        {

            var N = Console.ReadLine().Split().Select(x => int.Parse(x.ToString())).ToArray().First();
            var ds = Console.ReadLine().Split().Select(x => int.Parse(x.ToString())).ToList();
            var M = Console.ReadLine().Split().Select(x => int.Parse(x.ToString())).ToArray().First();
            var ts = Console.ReadLine().Split().Select(x => int.Parse(x.ToString())).ToList();

            Dictionary<int, int> dds = new Dictionary<int, int>();
            Dictionary<int, int> dts = new Dictionary<int, int>();

            foreach (var item in ds)
            {
                if (dds.ContainsKey(item))
                {
                    dds[item] = dds[item] + 1;
                }
                else
                {
                    dds.Add(item, 1);
                }
            }

            foreach (var item in ts)
            {
                if (dts.ContainsKey(item))
                {
                    dts[item] = dts[item] + 1;
                }
                else
                {
                    dts.Add(item, 1);
                }
            }

            foreach (var item in dts)
            {
                if (dds.ContainsKey(item.Key))
                {
                    if (item.Value > dds[item.Key])
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                }
                else
                {
                    Console.WriteLine("NO");
                    return;
                }
            }


            Console.WriteLine("YES");


        }


    }
}


Measured memory_bytes: 49340
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <bits/stdc++.h>
#define PI acos(-1)
#define fs first
#define sc second
#define debug freopen("1.in","r",stdin),freopen("1.out","w",stdout);
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll maxn = 1e6 + 10;
const ll mod = 998244353;

int n, arr[maxn], ans = 0, test, cnt = 0;

int main(){
    ios;
    cin >> n;
    cin >> test;
    for (int i = 2; i <= n; i ++){
        cin >> arr[i];
        if (arr[i] <= test){
            test = arr[i];
            cnt ++;
        }
        else{
            ans = max(cnt, ans);
            test = arr[i];
            cnt = 0;
        }
    }
    ans = max(cnt, ans);
    cout << ans;

    return 0;
}

Measured memory_bytes: 640
N = int(input())
Ali = list(map(int,input().split()))
Alis = set()
Blis = set()

Ali.sort()

for i in range(N):
  if Ali[i] in Alis:
    Blis.add(Ali[i])
    continue
  Alis.add(Ali[i])

Alis -= Blis

for i in range(N):
  Alis.difference_update(range(Ali[i]*2, Ali[-1]+1, Ali[i]))
  
print(len(Alis))

Measured memory_bytes: 32288