akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int ok = 0 ;

    int n ;
    cin >> n ;

    int match = 1 ;
    for ( int i=0 ; i < n ; i ++ )
    {
        int temp ; cin >> temp ;
        if ( temp == match )
        {
            ok ++ ;
            match ++ ;
        }
    }

    if ( ok == 0 )
        cout << -1 ;
    else
        cout << n - ok ;

    line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<stack>
using namespace std;

const int NN=1e5+10;
double a,t;
int b;

int main(){
    scanf("%lf%d%lf",&a,&b,&t);
    int num=((int)((t+0.5)/a))*b;
    printf("%d\n",num);
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

class RMQ{
private:
	int32 n;
	vector<PLL> node, lazy;
	vector<bool> lazyFlag;
public:
	RMQ(){}
	RMQ(vector<int64> v){
		int sz = v.size();
		n = 1; while(n < sz) n *= 2;
		node.resize(2*n-1, PLL(-INF_LL, -1));
		lazyFlag.resize(2*n-1, false);
		for(int32 i = 0;i < sz;i++) node[i+n-1] = {v[i], i};
		for(int32 i = n-2;i >= 0;i--) node[i] = max(node[2*i+1], node[2*i+2]);
	}

	void update(int32 k, int64 x){
		k += n-1;
		node[k].fs = x;
		while(k > 0){
			k = (k-1)/2;
			node[k] = max(node[k*2+1], node[k*2+2]);
		}
	}

	PLL query(int32 a, int32 b, int32 k=0, int32 l=0, int32 r=-1){
		if(a >= b) return PLL(-INF_LL, -1);
		if(r < 0) r = n;

		if(b <= l || r <= a) return PLL(-INF_LL, -1);
		if(a <= l && r <= b) return node[k];

		return max(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r));
	}
};

vector<int32> res;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 n;
	vector<int64> a[2];
	cin >> n;
	a[0].resize(n+2, -INF_LL);
	a[1].resize(n+2, -INF_LL);
	a[0][0] = a[1][1] = 0;
	res.resize(n+2, -1);
	REP(i, n)  cin >> a[i%2][i+2];
	RMQ rmq[2];
	rmq[0] = RMQ(a[0]);
	rmq[1] = RMQ(a[1]);
	FOR(i, 2, n+2){
		PLL ret = rmq[i%2].query(0, i);
		res[i] = ret.sc;
		rmq[i%2].update(i, ret.fs+a[i%2][i]);
	}
	PLL in = max(rmq[0].query(2, n+2), rmq[1].query(2, n+2));
	int32 index = in.sc;
	vector<int32> pos;
	int32 cnt = 0;
	pos.push_back(n+1);
	while(index > 1){
		pos.push_back(index-1);
		index = res[index];
	}
	pos.push_back(0);
	REP(i, pos.size()-2){
		cnt += (pos[i]-pos[i+1]-1)/2;
		if(pos[i]-pos[i+1] > 1)
			cnt++;
	}
	cnt += pos[pos.size()-2]-1;
	cout << in.fs << endl;
	cout << cnt << endl;
	REP(i, pos.size()-2){
		REP(j, (pos[i]-pos[i+1]-1)/2){
			cout << pos[i+1]+2 << endl;
		}
		if(pos[i]-pos[i+1] > 1){
			cout << pos[i+1]+1 << endl;
		}
	}
	REP(i, pos[pos.size()-2]-1){
		cout << 1 << endl;
	}
}


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

typedef long long ll;

template <class T>
void printArray(vector<T> arr) {
	for (T a: arr) cout << a << " ";
	cout << '\n';
}

void printVerdict(bool verdict) {
	cout << (verdict ? "YES": "NO") << '\n';
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cout << (1000 - (n%1000))%1000 << '\n';
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int i,j;
    int K,S;
    int count=0;
    cin>>K>>S;
    for(i=0;i<=K&&i<=S;i++){
        for(j=0;i+j<=S&&j<=K;j++){
            int x=S-i-j;
            if(x<=K)count++;
        }}
    
cout<<count;
  
  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 rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int n; ll k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    vector<int> to(n+1);
    to[0] = 0;
    vector<bool> seen(n, false);
    seen[0] = true;
    int sz = 0;
    int num = 0;
    rep(i,n){
        to[i+1] = a[to[i]];
        if(seen[to[i+1]]){
            num = to[i+1];
            sz = i+1;
            break;
        }
        seen[to[i+1]] = true;
    }
    int pos = sz;
    int lo = 0;
    rrep(i, sz){
        if(num == to[i]){
            pos = i;
            lo = sz - i;
            break;
        }
    }
    vector<int> path, loop;
    rep(i,pos){
        path.pb(to[i]);
    }
    FOR(i, pos, sz){
        loop.pb(to[i]);
    }
    if(k < path.size()){
        cout << path[k] + 1 << endl;
    }
    else{
        ll p = (k-path.size()) % lo;
        cout << loop[p] + 1 << endl;
    }
}


Measured memory_bytes: 5856
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

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 replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define INFL 2000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;


int main() {
	int N, T;
	cin >> N >> T;
	vi t(N);
	rep(i, N) {
		cin >> t[i];
	}
	ll ans = T;
	rep(i, N - 1) {
		ans += min(T, t[i + 1] - t[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int maxn=200010;
int n;
vector<int>G[maxn];
int a[maxn];
vector<int>pre[maxn];
int cur[maxn],top;
int g[maxn];
int dp[maxn];
bool vis[maxn];
void dfs(int x,int pr){
	cur[++top]=a[x];
	int j=lower_bound(g+1,g+n+1,cur[top])-g;
	dp[x]=j;
	pre[j].pb(g[j]);
	g[j]=cur[top];
	// add[j]++;
	// cout<<"dfs: "<<x<<' '<<pr<<' '<<dp[x]<<' '<<cur[top]<<' '<<g[j]<<endl;
	vis[x]=1;
	for(auto to:G[x])if(to!=pr&&!vis[to])dfs(to,x);
	cur[top--]=0;
	// add[j]--;
	g[j]=pre[j].back();
	pre[j].pop_back();
	// if(!add[j])g[j]=INF;
}
void dfs2(int x,int pr){
	for(auto to:G[x])if(to!=pr){
		dp[to]=max(dp[to],dp[x]);
		dfs2(to,x);
	}
}
int main(){
	memset(g,INF,sizeof g);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<n;i++){
        int x,y;
        cin>>x>>y;
        G[x].pb(y);
        G[y].pb(x);
    }
	dfs(1,-1);
	dfs2(1,-1);
	for(int i=1;i<=n;i++)cout<<dp[i]<<endl;
    return 0;
}


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

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		if(s[i] == t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
abcd = list(map(int, list(input())))

for i in range(2**3):
    ans = abcd[0]
    for j in range(3):
        if (i >> j) & 1:
            ans += abcd[j + 1]
        else:
            ans -= abcd[j + 1]
    
    if ans == 7:
        print(abcd[0], end='')
        for j in range(3):
            if (i >> j) & 1:
                print('+', end='')
            else:
                print('-', end='')
            
            print(abcd[j + 1], end='')
        
        print('=7')
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

  auto f = [&](int n) {
    int res;
    if (n%2 == 0) res = n/2;
    else res = 3*n + 1;
    return res;
  };

  vi cnt((int)1e6+1);
  int a = s;
  cnt[a]++;
  rrep(i,(int)1e6) {
    a = f(a);
    cnt[a]++;
    if (cnt[a] == 2) {
      cout << i+1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define sPRINT(str) printf(#str "\n")
#define yOUT sPRINT(Yes)
#define nOUT sPRINT(No)
#define YOUT sPRINT(YES)
#define NOUT sPRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
 
using namespace std;

int main(void)
{   
    int n, ans=0;
    string s;
    cin >> n >> s;

    REP(i, n){
        int cnt = 0;
        for(char c = 'a'; c <= 'z';c++){
            bool flag1 = false, flag2 = false;
            FOR(j, 0, i){
                if(s[j] == c){
                    flag1 = true;
                }
            }
            FOR(j, i, n){
                if(s[j] == c){
                    flag2 = true;
                }
            }
            if(flag1 && flag2){
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }
            cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll M = 1e9 + 7;
ll n;
ll a[300005];
ll b[65];
ll ans;

int main()
{
    scanf("%lld", &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        for(ll j = 0; j < 60; j++)
        {
            if((a[i] & (1LL << j))) b[j]++;
        }
    }
    for(ll j = 0; j < 60; j++)
    {
        ans += (1LL << j) % M * (b[j] * (n - b[j]) % M) % M;
        ans %= M;
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main()
{
  int n, k; cin >> n >> k;
  vector<char> d;
  for (int i = 0; i < k; i++) {
	char t; cin >> t;
	d.push_back(t);
  }
  while (true) {
	bool flag = true;
	string s = to_string(n);
	for (int i = 0; i < s.size(); i++) {
	  for (int j = 0; j < k; j++) {
		if (s[i] == d[j]) {
		  flag = false;
		}
	  }
	}
	if (flag) {
	  cout << n << endl;
	  return 0;
	}
	n++;
  }
  return 0;
}



Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def main():
    K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(K[int(input()) - 1])

if __name__ == "__main__":
    main()

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

int main(void){
  int k, t;
  cin >> k >> t;
  
  vector<int> a(t);
  for(int i = 0; i < t; i++){ cin >> a[i]; }

  int ans = 0, ng = -1;
  for(int i = 0; i < k; i++){
    int max = 0;
    int maxcake = -1;
    for(int j = 0; j < t; j++){
      if(j != ng && max < a[j]){
        max = a[j];
        maxcake = j;
      }
    }
    if(max != 0){
      --a[maxcake];
      ng = maxcake;
    }
    else{
      ans = a[ng];
      break;
    }
  }
  printf("%d\n", a[ng]);

  return 0;
}


Measured memory_bytes: 256
s=input()

ans=""

if len(s)<26:
    cnt_alphabet=[0]*26

    for i in range(len(s)):
        cnt_alphabet[ord(s[i])-97]+=1
    
    moji=""
    for i in range(26):
        if cnt_alphabet[i]<1:
            moji=chr(i+97)
            break
    ans=s+moji

else:
    cnt=25
    
    for i in range(24,-1,-1):
        if ord(s[i])>ord(s[i+1]):
            cnt=i
        else:
            break
    
    if cnt==0:
        ans='-1'
    else:
        min_chr=ord('{')
        for m in s[cnt:]:
            if ord(m)>ord(s[cnt-1]):
                min_chr=min(min_chr,ord(m))
            
        ans=s[:cnt-1]+chr(min_chr)

print(ans)

Measured memory_bytes: 9108
from collections import Counter
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

c = Counter(a)

d = dict(c)
sm = 0
for k, v in c.items():
    mx = (v * (v - 1)) // 2
    nx = ((v - 1) * (v - 2)) // 2
    sm += mx
    d[k] = nx - mx

for v in a:
    print(sm + d[v])


Measured memory_bytes: 31996
#include <vector>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

vector<string> split(string &str, const char *delim){
	vector<string> result;
	int cutAt;
	while( (cutAt = str.find_first_of(delim)) != str.npos ){
		if(cutAt > 0){
			result.push_back(str.substr(0, cutAt));
		}
		str = str.substr(cutAt + 1);
	}
	if(str.length() > 0){
		result.push_back(str);
	}
	return result;
}

void reversepoland(string &exp){
	vector<string> token = split(exp," ");
	vector<double> resolveNumber;
	vector<string> resolveString;
	for(int i=0;i<token.size();i++){
		char *p=NULL;
		double d=strtod(token[i].c_str(),&p);
		if(p-token[i].c_str()==token[i].size()){
			resolveNumber.push_back(d);
			resolveString.push_back(token[i]);
		}else{
			//if(resolveNumber.size()<2){printf("stack few\n");return;}
			double d2=resolveNumber[resolveNumber.size()-1],d1=resolveNumber[resolveNumber.size()-2];
			resolveNumber.pop_back(),resolveNumber.pop_back();
			string s2=resolveString[resolveString.size()-1],s1=resolveString[resolveString.size()-2];
			resolveString.pop_back(),resolveString.pop_back();
			double ret;

			if(token[i]=="+"){ret=d1+d2;}
			else if(token[i]=="-"){ret=d1-d2;}
			else if(token[i]=="*"){ret=d1*d2;}
			else if(token[i]=="/"){ret=d1/d2;}
			//else if(token[i]=="%"){ret=d1%d2;}
			//else if(token[i]=="**"){ret=pow(d1,d2);}
			//else{printf("unknown OP %s\n",token[i].c_str());return;}

			resolveNumber.push_back(ret);
			resolveString.push_back("("+s1+token[i]+s2+")"); //this won't emit "optimized" expression. full of parens.
		}
	}
	//if(resolveNumber.size()!=1){printf("result stack not 1");return;}
	printf("%.0f\n",resolveNumber[0]);
}
int main(){string str;getline(cin,str);reversepoland(str);}

Measured memory_bytes: 1296
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int L = sc.nextInt();
      	String[] strs = new String [N+1];
      	for (int i =0; i<N+1 ; i++){
          	String string = sc.nextLine();
        	strs[i] = string;
        }
        Arrays.sort(strs);
        String str = "";
        for (int i =0; i<N+1 ; i++){
        	str += strs[i];
        }
        System.out.println(str);
   		sc.close();
	}
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=(m); i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int m,k; cin >> m >> k;
    if(k >= pow(2,m)){
        cout << -1 << endl;
        return 0;
    }
    vi ans;
    if(m == 0){
        rep(i,2) ans.push_back(0);
    }else if(m == 1){
        if(k == 1){
            cout << -1 << endl;
            return 0;
        }
        rep(i,2) ans.push_back(0);
        rep(i,2) ans.push_back(1);
    }else{
        rep(i,1<<m) if(i != k) ans.push_back(i);
        ans.push_back(k);
        rrep(i,1<<m) if(i != k) ans.push_back(i);
        ans.push_back(k);
    }
    cout << join(ans, " ") << endl;
    return 0;
}

Measured memory_bytes: 9764
def main():
    N, M = map(int, input().split())
    A = []
    B = []

    for i in range(N):
        B.append(input().split()[0])

    for _ in range(M):
        A.append(input().split()[0])

    for i in range(N - M + 1):
        for j in range(N - M + 1):
            f = True
            for m in range(M):
                for n in range(M):
                    if B[i + m][j + n] != A[m][n]:
                        f = False
                        break
                if f is False:
                    break
            if f is True:
                print("Yes")
                return
    print("No")        

main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define MAX 100001

typedef struct group{
  char name[10];
  int t;
} P;

int head=1, tail, n;
P Q[MAX];

void enqueue(P);
P dequeue(void);
int minimam(int, int);

int main()
{
  int t_res=0, time; 
  int i, q;
  P R;
  
  scanf("%d%d", &n, &q);
  
  for( i = 1 ; i <= n ; i++ ){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  tail = n + 1;

  while( head != tail ){
    R = dequeue();
    time = minimam(q, R.t);
    R.t -= time;
    t_res += time;
    if( R.t > 0 ) enqueue(R);
    else printf("%s %d\n", R.name, t_res);
  }

  return 0;
}

void enqueue(P x)
{
  Q[tail] = x;
  tail = (tail + 1) % MAX;
}

P dequeue()
{
  P x = Q[head];
  head = (head + 1) % MAX;
  return x;
}

int minimam(int t1, int t2)
{
  if( t1 > t2 ) return t2;
  else return t1;
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> e(n + 1);
  for (int i = 2; i <= n; ++i) {
    int a;
    cin >> a;
    e[a].push_back(i);
  }
  function<int(int)> dfs = [&](int v) {
    if (e[v].empty()) {
      return 0;
    }
    vector<int> d;
    for (int i : e[v]) {
      d.push_back(dfs(i));
    }
    sort(d.begin(), d.end());
    for (int i = 0; i < d.size(); ++i) {
      d[i] += d.size() - i;
    }
    sort(d.begin(), d.end());
    return d.back();
  };
  cout << dfs(1) << endl;
  return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d)cout<<"Balanced"<<"\n";
	else if(a+b>c+d)cout<<"Left"<<"\n";
	else cout<<"Right"<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//ARC059_C
//空文字列ならなにも行わない
int main(){
  ll N;
  cin >> N;

  vector <ll> a(N);

  string res = "";

  ll iMin = INF;

  REP(i,N)
  {
    cin >> a[i];
  }

  for(ll i = -100; i <= 100; ++i)
  {
    ll cnt = 0;
    for(ll j = 0; j < N; ++j)
    {
      cnt += abs(a[j] - i) * abs(a[j] - i);
    }
    iMin = min(iMin,cnt);
  }

  cout << iMin << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[]
for i in range(q):
  L,R=map(int,input().split())
  l.append([R,L,i])
l.sort(key=lambda x:x[0])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l[i][0]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l[i][2]]=BIT.sum(l[i][0]+1)-BIT.sum(l[i][1])

for i in range(q):
  print(ans[i])

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

int main(){
    int k,n;
    cin>>k>>n;
    int vec[n];
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        ans=max(ans,vec[i+1]-vec[i]);
    }
    ans=max(ans,vec[0]+k-vec[n-1]);
    cout<<k-ans;
}

Measured memory_bytes: 1024
/*
 ------------------------------------------------------Read question very carefully------------------------------------------------------
 
                       In every question first approach must be basic, atleast give 15 mins for try to solve in basic approach
*/
 #include<iostream>
 #include<cstring>
 #include<string>
 #include<vector>
 #include<utility>
 #include<stdlib.h>
 #include<limits.h>
 #include<cmath>
 #include<set>
 #include<initializer_list>
 #include<unordered_set>
 #include<unordered_map>
 #include<map>
 #include<iomanip>
 #include<algorithm>
 #include<queue>
 #include<stack>
#include <cstdint>
  
 #define sze 1000005
 #define ld long double
 //#define ll unsigned long long
 #define ll long long
 #define endl "\n"
 #define pb push_back
 #define mkp make_pair
 #define mod 1000000007
 #define ff first
 #define ss second
 #define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
 #define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
 #define all(c) (c).begin(),(c).end()
 #define pi                   pair<int,int>
 #define pll                  pair<ll,ll>
 #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
 using namespace std;

//cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
 //const ll inf=1ll<<60;
 //const double pi = 3.14159265358979323846;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod * a%mod)%mod;
        a = (a%mod * a%mod)%mod;
        b >>= 1;
    }
    return res;
}
const ll int  N=2e5+5;
/*vector<ll> adj[N];
vector<ll> vis(N,0);
*/
//int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

ll n,k;
ll arr[N];
ll helper(ll x,ll curr)
{
    ll ans=0;
    F(i,1,n)
    {
        if(!curr)
        {
            ans++;
            curr^=1;
        }
        else
        {
            if(arr[i]<=x)
            {
                ans++;
                curr^=1;
            }
        }
    }
    return ans>=k;
}

 int main()
 {
     IOS;
     char ch[2];
     cin>>ch[0];
     if(ch[0]-'a'>=0)
     {
         cout<<"a"<<endl;
     }
     else
     {
         cout<<"A"<<endl;
     }
 }



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

int main() {
  long N, x, ans = 0;
  cin >> N;
  
  for (int i = N; i > 0; i--) {
    x = sqrt(i);
    x = x * x;
    if (i == x) {
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int g[2][n];
    for(int i=0; i<2; i++)
    for(int j=0; j<n; j++){
        cin >> g[i][j];
    }
    int dp[3][n+1];
    for(int i=0; i<=2; i++)
        for(int j=0; j<=n; j++)
        dp[i][j]=0;
    for(int i=1; i<=2; i++){
        for(int j=1; j<=n; j++){
            dp[i][j] = max(dp[i][j-1],dp[i-1][j])+ g[i-1][j-1];
                //cout << dp[i][j] << " ";
        }
       // cout << endl;
    }
    cout << dp[2][n];
}


Measured memory_bytes: 3620
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int[] oo; int[][] oj;
	void link(int i, int j) {
		int o = oo[i];
		if (o >= 2 && (o & o - 1) == 0)
			oj[i] = Arrays.copyOf(oj[i], o << 1);
		oj[i][oo[i]++] = j;
	}
	byte[] used;
	int[] qu; int cnt;
	int[] dp;
	void init(int n) {
		oo = new int[n]; oj = new int[n][2];
		used = new byte[n];
		qu = new int[n];
		dp = new int[n];
	}
	boolean dfs(int i) {
		if (used[i] != 0)
			return used[i] == 1;
		used[i] = 1;
		for (int o = 0; o < oo[i]; o++) {
			int j = oj[i][o];
			if (dfs(j))
				return true;
		}
		used[i] = 2;
		qu[--cnt] = i;
		return false;
	}
	void main() {
		int n = sc.nextInt();
		int n_ = n * n;
		init(n_);
		for (int i = 0; i < n; i++)
			for (int u = -1, h = 0; h < n - 1; h++) {
				int j = sc.nextInt() - 1;
				int v = i < j ? i * n + j : j * n + i;
				if (h > 0)
					link(u, v);
				u = v;
			}
		cnt = n_;
		for (int u = 0; u < n_; u++)
			if (dfs(u)) {
				println(-1);
				return;
			}
		int ans = 0;
		for (int h = 0; h < n_; h++) {
			int i = qu[h];
			int x = dp[i] + 1;
			ans = Math.max(ans, x);
			for (int o = 0; o < oo[i]; o++) {
				int j = oj[i][o];
				dp[j] = Math.max(dp[j], x);
			}
		}
		println(ans);
	}
}


Measured memory_bytes: 102224
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007



int main(){
    //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin>>n;
    vector<vector<int> > p;
    f0(i,0,n){
        vector<int> temp;
        f0(i,0,3){
            int t;
            cin>>t;
            temp.pb(t);
        }
        p.pb(temp);
    }
    int dp[n+5][3]={{0}};
    f0(i,0,3){
        dp[0][i]=p[0][i];
    }
    
    f0(i,1,n){
        dp[i][0]=p[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=p[i][1]+max(dp[i-1][2],dp[i-1][0]);
        dp[i][2]=p[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 7600
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

string inp;

int main() {
  io();
  
  cin >> inp;
  
  if(inp == "SAT") cout << 1;
  elif(inp == "FRI") cout << 2;
  elif(inp == "THU") cout << 3;
  elif(inp == "WED") cout << 4;
  elif(inp == "TUE") cout << 5;
  elif(inp == "MON") cout << 6;
  else cout << 7;
  
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int n;
  cin >> n;
  int num = 1000-(n % 1000);
  if (num == 1000) {
    cout << 0 << endl;
  }
  else {
    cout << num << endl;
  }
}
  
 

Measured memory_bytes: 3616
import java.util.Scanner;

/**
 * Created by zzt on 17-3-26.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();

        int ret = String.valueOf(n).length();

        for (long i = 1; i <= n/i ; i++) {
            if (n%i==0) {
                ret = Math.min(ret, Math.max(String.valueOf(i).length(), String.valueOf(n / i).length()));
            }
        }
        System.out.println(ret);
    }
}

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

int main() {
    
  int a, b;
  cin >> a >>b;
  int product = a*b;
  
  if(product % 2 == 0){
      cout << "Even" << endl;
  }
  else{
      cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = pow(10, 9) + 7;
//const int mod = 998244353;
//const int mod = ;
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  int t = 0;
  int ans = 1;
  for (int i = 1; i < N; i++)
  {
    if (t == 0)
    {
      if (A.at(i - 1) < A.at(i)) t = 1;
      else if (A.at(i - 1) > A.at(i)) t = -1;
    }
    else
    {
      if (t == 1 && A.at(i - 1) > A.at(i) || t == -1 && A.at(i - 1) < A.at(i))
      {
        ans++;
        t = 0;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
n = int(raw_input())
a = map(int, raw_input().split())
ans = 0
plus = [0] * n
while True:
    s = 0
    for i in xrange(n):
        ans += a[i] / n
        plus[i] = a[i] / n
        s += a[i] / n
        a[i] -= n * (a[i] / n)
    if s == 0:
        break
    for i in xrange(n):
        a[i] += s - plus[i]
print ans


Measured memory_bytes: 30956
n=int(input())
a=list(map(int,input().split()))
a_=[]
for i in range(n):
  if i==0:
    if a[i]<a[i+1]:
      a_.append(-1)
    elif a[i]>a[i+1]:
      a_.append(1)
    else:
      a_.append(0)
  elif i==n-1:
    if a[i-1]<a[i]:
      a_.append(1)
    elif a[i-1]>a[i]:
      a_.append(0)
    else:
      a_.append(0)  
  else:
    if a[i-1]<=a[i] and a[i+1]<=a[i]:
      a_.append(1)
    elif a[i-1]>=a[i] and a[i+1]>=a[i]:
      a_.append(-1)
    else:
      a_.append(0)
m=1000
cou=0
for i in range(n):
  if a_[i]==-1:
    cou+=m//a[i]
    m=m%a[i]
  elif a_[i]==1:
    m+=a[i]*cou
    cou=0
  else:
    continue
print(m)    

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

int main() {
	int r, D, x2000;

	cin >> r >> D >> x2000;
	int x = x2000;
	rep(i, 10) {
		x = r * x - D;
		cout << x << endl;

	}
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
  int n,i;
  int d[4];
  cin >> n;
  for(i=0;i<4;i++){
    d[i]=n%10;
    n/=10;
  }
  if(d[1]==d[2]&&(d[0]==d[1]||d[2]==d[3]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    int64_t S;
    int64_t ans = 0;

    scanf("%"PRId64, &S);

    if (S >= 100 && S < 1300) {
        S %= 100;
        if (S >= 1 && S < 13) {
            puts("AMBIGUOUS");
        } else {
            puts("MMYY");
        }
    } else {
        S %= 100;
        if (S >= 1 && S < 13) {
            puts("YYMM");
        } else {
            puts("NA");
        }
    }

    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    long K; 
    cin >> S >> K;
    for(int i=0; i<S.size(); i++){
        if(S[i] == '1'){
            if(i + 1 == K){
                cout << "1\n";
                break;
            }
        }
        else {
            cout << S[i] << "\n";
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
namespace aoj{
    class program{
     
    static void Main() {
		
        string find=Console.ReadLine();
        FindStr fs=new FindStr(find);
        Console.WriteLine("{0}",fs.find());
     
    }
}
 
class FindStr{
	List<string> words = new List<string>();
    string value;
    public FindStr(string f){
		value=f;
		char[] sep = new char[] {' '};
		bool flg=true;
		while(flg){
			string[] tmp=Console.ReadLine().Split(sep);
			foreach(string w in tmp){
				if(w=="END_OF_TEXT") flg=false;
				words.Add(w);
			}
		}
    }
    public int find(){
        int count =0;
        for(int i=0;i<words.Count;i++){
	        if(words[i].Equals(value,StringComparison.OrdinalIgnoreCase))                       count++;
        }
        return count;
    }
 
}
}

Measured memory_bytes: 5716
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G ((c=A[a]+A[P[a]]+C[a])%k?c:0)+M(
typedef long long L;using namespace std;map<L,L>T U;L P U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=G i++)-M(i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){return Z[a=X[f]]>Z[n=X[b]]?n=b,b=f,K(n):abs(M(O[f])-(a-n?-G O[a])-K(P[a]):M(O[b])));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(n=0);Z[a=H[P[n]]-n?n:0];*Z=++n)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],b=O[a]),S(a,b-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> prices(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> prices[i];
  }

  priority_queue<int64_t, vector<int64_t>> q(prices.begin(), prices.end());

  while (M > 0) {
    auto x = q.top() / 2;
    q.pop();
    q.push(x);
    --M;
  }

  int64_t result = 0;
  while (!q.empty()) {
    result += q.top();
    q.pop();
  }

  cout << result << endl;
}


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

char s[10005];

int main()
{
    scanf("%s",s);
    int len=strlen(s);
    printf("%s",s);
    if (s[len-1]=='s') printf("es\n");
    else printf("s\n");

    return 0;
}

Measured memory_bytes: 3824
//In the name of God:)
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define int long long
using namespace std;
const int MAXN = 10e5 + 10;
int a[MAXN] , dp[MAXN];
void solve(){

}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  int n;
  cin>>n;
  // fill(dp , dp + MAXN , INT_MAX);
  for(int i = 1 ; i <= n ; i++){
    cin>>a[i];
  }
  dp[1] = 0;
  dp[2] = abs(a[2] - a[1]);
  for(int i = 3 ; i <= n ; i++){
    dp[i] = min(dp[i-2] + abs(a[i] - a[i-2]) , dp[i-1] + abs(a[i] - a[i-1]));
  }
  printf("%lld\n", dp[n]);

}


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

int n, m;
vector<vector<int>> g;
int vis[1000000];
int D[1000000];

void dfs(int node)
{
        if(vis[node])
                return;
        vis[node] = 1;
        for(auto j : g[node])
        {
                dfs(j);
                D[node] = max(D[node], D[j] + 1);
        }
}

int main()
{
        int i;
        cin >> n >> m;
        g.resize(n + 1);
        for(i = 0; i < m; i++)
        {
                int u, v;
                cin >> u >> v;
                g[u].push_back(v);
        }
        for(i = 1; i <= n; i++)
        {                                   // make directed edge from 0 to every other vertex 
                g[0].push_back(i);
        }
        dfs(0);
       
        cout << D[0] - 1 << endl;

}


Measured memory_bytes: 12124
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        mut a: [i64;n],
    }

    a.sort();
    let mut ans: Vec<i64> = Vec::new();
    for mid in a[0]..a[n-1]+1 {
        let mut tmp = 0;
        for i in 0..n {
            tmp += (a[i]-mid).pow(2);
        }
        ans.push(tmp);
    }

    ans.sort();
    println!("{}", ans[0]);

}


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

int main(){
    int x,y;
    cin >> x >> y;
    if(x==1||y==1){
        if(x!=1)cout << "Bob" << endl;
        else if(y!=1)cout << "Alice" << endl;
        else cout << "Draw" << endl;
    }else{
        if(x>y)cout << "Alice" << endl;
        else if(x==y) cout << "Draw" << endl;
        else if(x<y)cout << "Bob" << endl;        
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = (int)2e5 + 5;
const int mod = (int)1e9 + 7;
using namespace std;

ll a[maxn];

int main()
{
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	ll ans = 0, h = 0;
	int j = 0;
	for(int i = 0; i < n; i++){
		for( ; j < n; j++){
			if((h|a[j]) != h + a[j]) break;
			else{
				h += a[j];
				ans += (j - i + 1);
			}
		}
		h -= a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

using LL = long long;

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

    int i = 0;
    char c[11] = {'\0'};

    cin >> c;

    vector<char> res;
    res.reserve(11);

    while(c[i] != '\0'){
        if(c[i] == 'B'){
            if(!res.empty()){
                res.pop_back();
            }
        }else{
            res.push_back(c[i]);
        }
        i++;
    }

    for (i = 0; i < res.size(); i++){
        cout << res[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n; cin >> n;
    cout << n * n << '\n';
    return 0;
}

Measured memory_bytes: 3628