akhauriyash/Code-Regression huggingface dataset:
n =int(input())
if 100<=n<=111:
  print(111)
elif 112<=n<=222:
  print(222)
elif 223<=n<=333:
  print(333)
elif 334<=n<=444:
  print(444)
elif 445<=n<=555:
  print(555)
elif 556<=n<=666:
  print(666)
elif 667<=n<=777:
  print(777)
elif 778<=n<=888:
  print(888)
elif 889<=n<=999:
  print(999)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i,j;
    long long r=0;
    for(i=1;i<=n;i++)
    {
        long long int s=0;
        for(j=1;;j++)
        {
            if(i*j<=n) s+=(i*j);
            else break;
        }
        //cout<<s<<endl;
        r += s;
    }
    cout<<r;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A=0,B=0,C=0;
  string S;
  cin >> S;
  rep(i,3){
    if(S[i]=='a')A++;
    else if(S[i]=='b')B++;
    else C++;
  }
  if(A>1||B>1||C>1)Out("No");
  else Out("Yes");
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

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);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

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

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

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

    int N = (1 << n);

    multiset<int> T;
    vector<int> V(1);

    REP(i, N) {
        int s;
        cin >> s;
        T.insert(s);
        chmax(V[0], s);
    }

    REP(i, n){
        vector<int> W = V;

        for(int s : V){
            auto ite = T.lower_bound(s);
            if(ite == T.begin()){
                cout << "No" << endl;
                return 0;
            }
            ite--;
            W.push_back(*ite);
            T.erase(ite);
        }

        sort(all(W), greater<>());
        swap(V, W);
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 14200
#include <bits/stdc++.h>
#define N 1010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define form(l, r, i)	for(int i = l; i <= r; ++i)
#define forv(r, l, i)	for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const int inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modwdop = 998244353ll;
 
ll pp = 13337ll;
ll modw = 1e9 + 7;
 
using namespace std;

ll get(ll n)
{
	return (n * (n + 1) / 2);
}

int main()
{
	barnarnar
	ll n;
	cin >> n;
	cout << get(n) - get(n / 3) * 3 - get(n / 5) * 5 + get(n / 15) * 15;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}




ll sum[2000];
int main() {

	ll N;
	vector<ll> W;
	cin >> N;
	
	W.resize(N);


	rep(i, N) {
		cin >> W[i];
		if (i == 0)
			sum[i] = W[i];
		else
			sum[i] = sum[i - 1] + W[i];
	}

	ll ans = inf;
	rep(i, N) {
		ans = min(abs(sum[i] - (sum[N - 1] - sum[i])), ans);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  ll l, r;
  cin >> l >> r;
  r = min(r,l+2018);
  ll mi = 2019;
  for (ll i = l; i <= r; i++) {
    for (ll j = i+1; j <= r; j++) {
      mi = min(mi,(i*j)%2019);
    }
  }
  cout << mi << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[300005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1,j=1;i<=n;i=j=j+1){
		while(1){
			if(j+1>n||a[j+1]!=j+1)break;
			if(j+2>n||a[j+2]==j+2)break;
			j+=2;
		}
		for(int k=i;k<=j;++k)
			if(a[k]<i||a[k]>j)
				return puts("No"),0;
		for(int k=i,x=0,y=0;k<=j;++k){
			if(a[k]<k){
				if(a[k]<x)return puts("No"),0;
				x=a[k];
			}
			if(a[k]>k){
				if(a[k]<y)return puts("No"),0;
				y=a[k];
			}
		}
	}
	return puts("Yes"),0;
}


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

string apple("apple"), peach("peach");

bool match(string::iterator ss, string trg){
    string::iterator it = trg.begin();
    while( it != trg.end() && *ss == *it ){
        ss++; it++;
    }
    return ( it == trg.end() );
}

int main(){
    string text;
    getline(cin, text);
    for( string::iterator it = text.begin(); it != text.end(); it++ ){
        if( match(it, apple) ) text.replace( it, it+5, "peach");
        else if( match(it, peach) ) text.replace( it, it+5, "apple");
    }
    cout << text << endl;
    return 0;
}

Measured memory_bytes: 1184
N,Y=map(int,input().split())

for i in range(N+1):
    for j in range(N-i+1):
        if(Y==i*10000+j*5000+(N-i-j)*1000):
            print('{i} {j} {k}'.format(i=i,j=j,k=N-i-j))
            exit()
print('-1 -1 -1')


Measured memory_bytes: 65200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ALL(v)   v.begin(),v.end()
int main()
	{
		speed
		int n;
		cin >> n;
		vector<int> vec(n);
		for(auto &a : vec)cin >> a
		;
		int ans = 0;	
		sort(ALL(vec));	
		cout <<  vec[n/2 ] - vec[n/2-1];
		
	}	


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

using namespace std;

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

	vector<int> A(N);
	long long sum = 0;

	for (int i = 0; i < N; i++)	{
		cin >> A[i];
	}
	
	for(int i = 1; i < N; i++) {
		if(A[i] < A[i-1]) {
			sum += A[i-1] - A[i];
			A[i] = A[i-1];
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4036
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

class UnionFind {
public:
  vector<int> par, rank, sizes; // parent, depth, size(only for root)
  UnionFind(int sz) : par(sz), rank(sz, 0), sizes(sz, 1){
    rep(i,sz) par[i]=i; // initial tree is independent each other
  }
  int find(int x){
    if(par[x]==x) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x==y) return;  // already belong to same tree
    if(rank[x] < rank[y]){  // y becomes parent node
      par[x] = y;
      sizes[y] += sizes[x];
    } else {  // x becomes parent node
      par[y]=x;
      if(rank[x]==rank[y]) rank[x]++;
      sizes[x] += sizes[y];
    }
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  int size(int x){
    return sizes[find(x)];
  }
}; // END class UnionFind

int main(){
  int n,q;
  cin>>n>>q;
  UnionFind uf(n);

  rep(i,q){
    int c,x,y;
    scanf("%d %d %d", &c, &x, &y);
    if(c==0) uf.unite(x,y);
    else {
      if(uf.same(x,y)) printf("1\n");
      else printf("0\n");
    }
  }

  return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
bool isPrime(ll n); // 素数か
vector<ll> primes(ll n); // 素因数分解
int ctoi(char c){return c - '0';}

const ll COM_MAX = (ll)(1e6+100); // combinationの最大値
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
void comb_init(); // 初期化
ll comb(ll n,ll k); // nCk


template<typename T>bool isOk(int key,T value){
  return key <= value.fi;
}
template<typename T>T binary_search(vector<pair<int,int>> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}


// TODO: write
int main() { 
  int n,m;cin>>n>>m;
  print((n==m)?"Yes":"No");
  return 0;
}




void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%INF;
    inv[i]=INF-inv[INF%i]*(INF/i)%INF;
    finv[i]=finv[i-1]*inv[i]%INF;
  }
}

ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


/* 二分探索の時に使う
template<typename T>bool isOk(T key,T value){
  return key <= value;
}
template<typename T>T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}
*/

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

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

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

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


void Main() {
    ll x, a;
    int year=0;
    cin >> x;

    a = 100;
    while(a < x) {
        year++;
        a += a * 0.01;
    }

    COUT(year);
} 

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



Measured memory_bytes: 3592
function parseInt(x) parse(Int, x) end

	n = parseInt(readline())
	a = map(parseInt, split(readline()))
	b = Array{Int}(n)
	if n%2 == 0
		for i in 1:2:n
			b[div(n,2)-div(i,2)] = a[i]
		end
		for i in 2:2:n
			b[div(n,2)+div(i,2)] = a[i]
		end
		for i in 1:n
			println(b[n-i+1])
		end
	else
		for i in 1:2:n
			b[div(n,2)+1-div(i,2)] = a[i]
		end
		for i in 2:2:n
			b[div(n,2)+1+div(i,2)] =a[i]
		end
		for i in 1:n
			println(b[i])
		end
	end




Measured memory_bytes: 222352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
int n;
ll W;
ll v[101];
ll w[101];
ll f[101][101][301];
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    read(W);
    FOR(i, 1, n){
        read(w[i]);
        read(v[i]);
    }
    w[0]=w[1];
    FOR(i, 1, n) w[i]-=w[0];
    FFOR(i, 0, n) FOR(j, 0, i) FFOR(k, 0, 300){
        f[i+1][j][k]=max(f[i+1][j][k], f[i][j][k]);
        if(w[0]*(j+1)+k+w[i+1]<=W) f[i+1][j+1][k+w[i+1]]=max(f[i+1][j+1][k+w[i+1]], f[i][j][k]+v[i+1]);
    }
    ll ans=0;
    FOR(j, 0, n) FOR(k, 0, 300) ans=max(ans, f[n][j][k]);
    writeln(ans);
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<int> v(n), c(n);
  for(int i=0; i<n; i++)
    cin >> v.at(i);
  for(int i=0; i<n; i++) {
    cin >> c.at(i);
    v.at(i) -= c.at(i);
    if(v.at(i) > 0) {
      ans += v.at(i);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define f first
#define s second

string l;
ll ans, m = 1e9+7, coun, three[100005], two[100005];

int main() {
	three[0] = 1;
	FOR(i, 1, 100000) {
		three[i] = 3 * three[i-1];
		three[i] %= m;
	}
	two[0] = 1;
	FOR(i, 1, 100000) {
		two[i] = 2 * two[i-1];
		two[i] %= m;
	}
	cin >> l;
	FOR(i, 0, l.length()-1) {
		//cout << (l[i] == '0') << ' ';
		if (l[i] == '0') continue;
		//cout << coun * 2 + three[l.length() - i - 1] << ' ';
		ans += (two[coun] * three[l.length() - i - 1]) % m;
		ans %= m;
		coun++;
	}
	ans += two[coun];
	ans %= m;
	cout << ans;
}


Measured memory_bytes: 2048
N = int(input())
S = input()
num_W = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        if S[i] == 'W':
            num_W[i] = 1
    else:
        if S[i] == 'W':
            num_W[i] = num_W[i-1] + 1
        else:
            num_W[i] = num_W[i - 1]

num_E_rev = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
    if i == N - 1:
        if S[i] == 'E':
            num_E_rev[i] = 1
    else:
        if S[i] == 'E':
            num_E_rev[i] = num_E_rev[i+1] + 1
        else:
            num_E_rev[i] = num_E_rev[i + 1]

ans = float('inf')
for i in range(N):
    if i == 0:
        ans = min(ans, num_E_rev[i + 1])
    elif i == N - 1:
        ans = min(ans, num_W[-1])
    else:
        ans = min(ans, num_W[i-1] + num_E_rev[i+1])
print(ans)


Measured memory_bytes: 17864
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<pair<string, int> > df;
	for(int i = 0; i < n; i++){
		string s;
		int x;
		cin >> s >> x;
		df.pb(mp(s, x));
	}
	string t;
	cin >> t;
	ll ans = 0, mk = 0;
	for(int i = 0; i < df.size(); i++){
		if(mk)
			ans += df[i].second;
		if(df[i].first == t)
			mk = 1;
	}
	cout << ans << '\n';

}

Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int main()
{

    int n ;
    string s ;
    cin >> n >> s ;
    int W= 0 ;
    /// W ||  E
    int E = 0 ;
    for (int i =0 ; i < n ;i++)
    {
        if (s[i] == 'E')E++;
    }
    int ans = n+1;
    for (int i =0 ; i < n ;i++)
    {
        if (s[i] == 'E')E--;
        ans = min (ans , W + E );
        if (s[i] == 'W')W++;
    }
    printf ("%d\n" ,ans );

}


Measured memory_bytes: 900
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338327950288
int main(void){
    int a, b, i;
    char op;
    for(i=0; i<1000000000000000; i++){
        scanf("%d %c %d",&a, &op, &b);
        if(op == '+'){
            printf("%d\n",a+b);
        }
        else if(op == '-'){
            printf("%d\n",a-b);
        }
        else if(op == '*'){
            printf("%d\n",a*b);
        }
        else if(op == '/'){
            printf("%d\n",a/b);
        }
        else if(op == '?'){
            break;
        }
    }
        
    return 0;
}



Measured memory_bytes: 2104
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      aa: [i64; n],
    }
    let mut avg = 0;
    for i in 0..n {
        avg += aa[i];
    }
    let mut min_v = 10001;
    let mut ans = 0;
    for i in 0..n {
        let a = (aa[i] * n as i64 - avg).abs();
        if a < min_v {
            min_v = a;
            ans = i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.12.28 20:13:56
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

// ===================### char →　int ###=================== //
int ctoi(char c) {
    int ret = c - '0';
    if (0 <= ret && ret < 10) {
        return ret;
    } else {
        return -1;
    }
}

int main() {
    int n, T, c[111], t[111];
    scanf("%d%d", &n, &T);
    rep(i, n) scanf("%d%d", &c[i], &t[i]);

    int ret = 111111;
    rep(i, n) {
        if (t[i] <= T) {
            ret = min(ret, c[i]);
        }
    }

    if (ret == 111111)
        printf("TLE\n");
    else
        printf("%d\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <queue>
#include <functional>
#include <vector>

using namespace std;

typedef pair <int, int> P;

int main() {
	string b;
	priority_queue< P, vector<P>, greater<P> > pq;
	while (getline(cin, b)) {
		if (b == "") {
			break;
		}
		int a = b.find(',');
		int n1 = 0;
		for (int i = 0; i < a; i++) {
			n1 *= 10;
			n1 += (b[i]-'0');
		}
		int n2 = 1;
		P p;
		p.first = n1;
		p.second = n2;
		pq.push(p);
	}
	int v, w;
	char c;
	priority_queue< P, vector<P>, greater<P> > pqq;
	while (cin >> v >> c >> w) {
		P p;
		p.first = v;
		p.second = 1;
		pqq.push(p);
	}
	while (!pq.empty()) {
		P p = pq.top();
		pq.pop();
		while (!pq.empty() && (pq.top()).first == p.first) {
			P pp = pq.top();
			pq.pop();
			p.second += pp.second;
		}
		if (pqq.empty()) {
			break;
		}
		while (true) {
			P q = pqq.top();
			if (q.first > p.first) {
				break;
			} else {
				pqq.pop();
				while (!pqq.empty() && (pqq.top()).first == q.first) {
					P qq = pqq.top();
					pqq.pop();
					q.second += qq.second;
				}
				if (p.first == q.first) {
					cout << p.first << " " << p.second+q.second << endl;
					break;
				} else {
					if (pqq.empty()) {
						break;
					}
					while (!pqq.empty() && (pqq.top()).first < p.first) {
						pqq.pop();
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
int main()
{
	int N , A , B;
	while(scanf("%d%d%d",&N,&A,&B) == 3)
	{
		int tt = max(A,B);
		int TT = min(A,B);
		if((tt-TT)%2 == 0)
		printf("Alice\n");
		else
		printf("Borys\n");		
		
	}
	
	return 0;
}

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

int main() {
  int n, d, x; cin >> n >> d >> x;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = x;

  rep(i,n) {
    int day = 1, b = 1;
    while(day <= d) {
      ans++;
      day = b * a[i] + 1;
      b++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
$n, *abc = gets.split.map!(&:to_i)
$s = $stdin.take($n).map! { |str| str.tr('ABC', '012').chars.map!(&:to_i) }

def solve(abc, path, k, &block)
  return if abc.any?(&:negative?)
  return yield path if k == $n

  i, j, = $s[k]
  abc[i] +=1; abc[j] -= 1; path << i
  solve(abc, path, k + 1, &block)
  abc[i] -=2; abc[j] += 2; path[-1] = j
  solve(abc, path, k + 1, &block)
  abc[i] +=1; abc[j] -= 1; path.pop
end

sol = nil
solve(abc, [], 0) { |path| sol = path; break }

if sol
  puts :Yes
  puts sol.join("\n").tr("012", "ABC")
else
  puts :No
end

load __FILE__ unless $stdin.eof?


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  int A[N][M], B[M];
  for(int i = 0; i < M; i++) cin >> B[i];
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  
  /* 配列の中身の確認
  for(int i = 0; i < M; i++) cout << B[i] << " ";
  cout << endl;
  
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      cout << A[i][j] << " ";
    }
    cout << endl;
  }
  */
  
  int count = 0;
  
  for(int i = 0; i < N; i++) {
    int ans = 0;
    for(int j = 0; j < M; j++) {
      ans += A[i][j] * B[j];
    }
    if(ans + C > 0) count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import itertools

ALPHA = sorted([s for s in 'zyxwvutsrqponmlkjihgfedcba'])


def main():
    S = input().strip()

    if 'zyxwvutsrqponmlkjihgfedcba' == S:
        return '-1'

    if len(set(ALPHA) - set([s for s in S])) != 0:
        return S + sorted(set(ALPHA) - set([s for s in S]))[0]

    for i in range(len(S) - 1, 0, -1):
        if S[i - 1] > S[i]:
            pass
        else:
            break

    for a in sorted(set(ALPHA) - set(S[:i])):
        if a > S[i - 1]:
            return S[:i - 1] + a


if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
N = int(input())
W = []
W.append(input())
for _ in range(N-1):
    W.append(input())
    if W[-1] in W[:-2]:
        print("No")
        break
    if W[-1][0] != W[-2][-1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, L;
    std::cin >> N >> L;

    std::vector<std::string> S(N);

    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }

    std::sort(S.begin(), S.end());

    for (std::string s : S) {
        std::cout << s;
    }

    std::cout << std::endl;


}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX], color[MAX];
	
  for(int i=0;i < n;++i){
    d[i] = INFTY;
    color[i] = WHITE;
  }
	
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    int u = -1;
    for(int i=0;i < n;++i){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(int v = 0;v < n;++v){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u] + M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(int i=0;i < n;++i){
    cout << i << " ";
    if(d[i] == INFTY) cout << -1 << endl;
    else cout << d[i] << endl;
  }
}

int main(){
  cin >> n;
	
  for(int i=0; i < n;++i){
    for(int j=0; j < n;++j){
      M[i][j] = INFTY;
    }
  }
	
  int k, c, u, v;
  for(int i=0;i < n;++i){
    cin >> u >> k;
    for(int j=0;j < k;++j){
      cin >> v >> c;
      M[u][v] = c;
    }
  }
	
  dijkstra();
	
  return 0;
}



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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
double a;
cin>>a;
printf("%.10lf\n",a*2.0*3.14159265358979);
}

Measured memory_bytes: 3736
n = int(input())
X = []
Y = []

for _ in range(n):
    x, y = map(int, input().split())
    X.append(x+y)
    Y.append(x-y)

a, b, c, d = max(X), min(X), max(Y), min(Y)
print(max(abs(a-b), abs(c-d)))


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

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

    int n;
    cin >> n;
    bool flg = false;

    rep(i, n){
        char s;
        cin >> s;

        if(s == 'Y') flg = true;
    }

    cout << (flg? "Four": "Three") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long int ll;
int main(){
  ll n,m;
  cin >> n>>m;
  vector <ll>p;
for(ll i=1;i*i<=m;i++) if(m%i==0) p.push_back(i);
ll ma=-1;
for(int i=0;i<p.size();i++){
  if((m/(m/p[i]))>=n) ma=max(ma,(m/p[i]));
}
for(int i=0;i<p.size();i++){
if((m/p[i])>=n) ma=max(ma,p[i]);
}
cout <<ma<<endl;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int a[maxn],r[maxn],f[maxn],n;

int main() {
    read(n);
    for(int i=1;i<=n;i++) read(a[i]),r[a[i]]=i;
    int ans=1;
    for(int i=1;i<=n;i++)
        if(r[a[i]-1]&&r[a[i]-1]<i)
            f[i]=f[r[a[i]-1]]+1,ans=max(ans,f[i]);
        else f[i]=1;
    write(n-ans);
    return 0;
}


Measured memory_bytes: 9216
#include<stdio.h>

int main(){
    int N, K;
    int A[110000];
    int minpos;
    int i,j,k;
    int ans = 110000;
    int anstmp;
    int length;

    scanf("%d %d", &N, &K);
    for(i=0; i<N; i++){
        scanf("%d", &A[i]);
        if(A[i] == 1){
            minpos = i+1;
        }
    }

    length = N;

    if(minpos <= K){
        for(i=0; i<minpos; i++){
            anstmp = 1;
            anstmp += i/(K-1);
            if(i%(K-1) != 0){
                anstmp += 1;
            }
            anstmp += (N-i-K)/(K-1);
            if((N-i-K)%(K-1) != 0){
                anstmp += 1;
            }
            if(anstmp<ans){
                ans = anstmp;
            }
        }
    }else{
        for(i=minpos-K; i<minpos; i++){
            anstmp = 1;
            anstmp += i/(K-1);
            if(i%(K-1) != 0){
                anstmp += 1;
            }
            anstmp += (N-i-K)/(K-1);
            if((N-i-K)%(K-1) != 0){
                anstmp += 1;
            }
            if(anstmp<ans){
                ans = anstmp;
            }
        }
    }

    if(N==K){
        ans = 1;
    }

    printf("%d", ans);

    return 0;
}

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

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


  int x,y;cin>>x>>y;
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){

      if(i + j == x && i*2+j*4==y){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
        cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 3644
input = gets.chomp.split(" ").map { |e|e.to_i  }

n,k = input
list = 0
sum = 0

list = gets.chomp.split(" ").map { |e|e.to_i  }
list.sort!

for i in 0..k - 1 do
  sum += list[i]
end

puts sum


Measured memory_bytes: 14336
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())+['END']
lis = []
now = S[0]
for s in S[1:]:
    if s!=now:
        lis.append(now)
        now = s

print(len(lis)-1)

Measured memory_bytes: 82464
#include "bits/stdc++.h"

using ll = long long;
using namespace std;

const int N = 1001;
bool visited[N][N];

void solveCase() {
   int n, m;
   cin >> n >> m;
   vector <string> v(n);
   for(int i = 0; i < n; i++) {
      cin >> v[i];
   }
   deque <pair <pair <int, int>, int>> d;

   for(int i = 0; i < n; i++) {
      for(int j = 0; j < m; j++) {
         if(v[i][j] == '#') {
            d.push_back({{i, j}, 0});
            visited[i][j] = true;
         }
      }
   }

   int ans = 0;

   while(!d.empty()) {
      auto t = d.front();
      d.pop_front();
      int r = t.first.first;
      int c = t.first.second;
      int dist = t.second;
      ans = max(ans, dist);
      
      for(int i = -1; i <= 1; i++) {
         for(int j = -1; j <= 1; j++) {
            if(abs(i) + abs(j) == 1) {
               int r_ = r + i;
               int c_ = c + j;
               if(r_ >= 0 && r_ < n && c_ >= 0 && c_ < m) {
                  if(visited[r_][c_] == false) {
                     visited[r_][c_] = true;
                     d.push_back({{r_, c_}, dist + 1});
                  }
               }
             }
         }
      }
   }

   cout << ans << endl;

}


int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}


Measured memory_bytes: 17396
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    // https://kira924age.hatenadiary.com/entry/2019/03/29/140724
    int n;cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];
    ll ans=0;
    ll s=0,x=0,r=0;
    rep(l,n){
        while(r<n && (s+a[r])==(x^a[r])){
            s+=a[r];
            x^=a[r];
            r++;
        }
        ans+=(r-l);

        if(r==l) r++;
        else{
            s-=a[l];
            x^=a[l];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  string plural;
  if (s[s.size() - 1] == 's') {
    plural = s + "es";
  } else {
    plural = s + "s";
  }
  cout << plural << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int N,cnt=0,ans=0;
int main(){
  cin >> N;
  for(int i=1;i<=N;i+=2){
    cnt=0;
    for(int j=1;j<=i;j+=2){
      if(i%j==0) cnt++;
    }
    //cout << cnt << endl;
    if(cnt==8) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int num,a,b,c;
  int count=0;

  cin>>num;
  a=num/100;
  num-=a*100;
  b=num/10;
  num-=b*10;
  c=num;

  count+=a+b+c;
  cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> b(n);

	vector<int> ans;
	while(a.size()) {
		bool ok = false;
		for(int i = a.size()-1; i >= 0; i--) {
			if(a[i]-(i+1)==0) {
				ans.push_back(a[i]);
				a.erase(a.begin()+i);
				ok = true;
				break;
			}
		}
		if(!ok) {
			cout << -1 << endl;
			return 0;
		}
	}
	reverse(ans.begin(), ans.end());
	for(auto e: ans) {
		cout << e <<endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N,K; cin >> N >> K;
  ll ans = K;
  rep(i,N-1) ans *= (K-1);
  cout << ans << endl;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,ans=0;
  string s,t;
  cin >>a>>b>>c;
  int n=b/c;
  rep(i,b/c){
    if(a<=(i+1)*c&&(i+1)*c<=b) ans++;
  }
  cout <<ans;
}

Measured memory_bytes: 3604
let m_1e9 = int_of_float 1e9 + 7
let ( +^ ) x y = (x + y) mod m_1e9
let ( -^ ) x y = x - y + if x < y then m_1e9 else 0
let ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9

let (n, a, b) = Scanf.sscanf (read_line ()) "%d %d %d" @@ fun n a b -> (n, a, b)

let nPr n r = Array.(init r ((-) n) |> fold_left ( *^ ) 1)

let rec mod_pow x n =
  if n = 0 then 1
  else let t = mod_pow x (n / 2) in t *^ t *^ if n mod 2 = 0 then 1 else x

let nCr n r = nPr n r *^ mod_pow (nPr r r) (m_1e9 - 2)

let () = Printf.printf "%d\n" @@ mod_pow 2 n -^ nCr n a -^ nCr n b -^ 1

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

struct Bipartite_Graph : UnionFind {
  vector< int > color;

  Bipartite_Graph(int v) : color(v + v, -1), UnionFind(v + v) {}

  bool bipartite_graph_coloring() {
    for(int i = 0; i < color.size() / 2; i++) {
      int a = find(i);
      int b = find(i + (int) color.size() / 2);
      if(a == b) return (false);
      if(color[a] < 0) color[a] = 0, color[b] = 1;
    }
    return (true);
  }

  bool operator[](int k) {
    return (bool(color[find(k)]));
  }
};

int main() {
  int N, M;
  bool g[700][700] = {{}};
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x][y] = true;
    g[y][x] = true;
  }
  Bipartite_Graph uf(N);
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < i; j++) {
      if(g[i][j]) continue;
      uf.unite(i + N, j);
      uf.unite(j + N, i);
    }
  }
  if(uf.bipartite_graph_coloring()) {
    int sz[1401][2] = {{}};
    for(int i = 0; i < N; i++) {
      sz[min(uf.find(i + N), uf.find(i))][uf[i]]++;
    }
    bitset< 701 > bit;
    bit[0] = true;
    for(int i = 0; i < 2 * N; i++) {
      bit = (bit << sz[i][0]) | (bit << sz[i][1]);
    }
    int ret = INF;
    for(int i = 0; i <= N; i++) {
      int rest = N - i;
      if(bit[i]) ret = min(ret, i * (i - 1) / 2 + rest * (rest - 1) / 2);
    }
    cout << ret << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();
        int N = sc.nextInt();

        int ans = solve(H, W, N);

        System.out.println(ans);
    }

    private static int solve(int H, int W, int N) {
        int longer = Math.max(H, W);
        int count = N/longer;

        if (N%longer != 0) {
            count++;
        }

        return count;
    }

}


Measured memory_bytes: 23120
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int a[200001],b,n;

int main()
{
	cin >> n;
	for(int i=0;i<n-1;i++){
		cin >> b;
		a[b]++;
	}
	for(int i=1;i<=n;i++){
		cout << a[i] << "\n";
	}
}

Measured memory_bytes: 4400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,b,a) for(ll i=b-1;i>=a;i--)
#define pq_min priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define pq_max priority_queue<pair<ll,ll>>
#define forx(i,a,b) for(ll i=a;i<b;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
typedef pair<pp,pp> ppll;
const ll mod=998244353;
const ld pi = 3.14159265359;
const ll N=100005;
ll n,q;

ll power(ll a,ll b)
{
    ll res=1;
    a%=mod;
    while(b>0)
    {
        if(b%2==1)
        {
            res = (res * a)%mod;
        }
        b/=2;
        a = (a*a)%mod;
    }
    return res;
}


int main()
{
  fast;
  ll n,m;
  cin>>n>>m;
  cout<<n*m;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	string n, t; cin >> n >> t;

	rep(i, n.size()) {
		if (n[i] != t[i]) { cout << "No" << endl; return 0; }
	}

	if (n.size() + 1 == t.size()) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3652