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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve(){
    
    int k,x;
    cin>>k>>x;
    if(k*500>=x) cout << "Yes";
    else cout << "No";


    

}


int main(){
    solve();
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>

using namespace std;

int main(){
    int n,d=0;
    cin>>n;
    int j=n;
    while (j>=10) {
        d += j%10;
        j = j/10;
    }
    d += j;
    cout<<((n%d==0) ? "Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 22;

int a[N], b[N], c[N];

signed main(){
    IOS;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        cin >> b[i];
    for (int i = 1; i < n; i++)
        cin >> c[i];
    int s = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            s += b[a[i]];
        }
        else {
            s += b[a[i]];
            if (a[i] - a[i-1] == 1)
                s += c[a[i-1]];
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  //sieve
  /*
  vector<int> prime;
  bool vis[111111];
  for(int i = 0; i < 100100; ++i) vis[i] = true;
  vis[0] = false;
  vis[1] = false;
  for(int i = 2; i < 100100; ++i) {
    if(vis[i]) {
      for(int j = 2; i * j < 100100; ++j) {
        vis[i * j] = false;
      }
    }
  }
  for(int i = 2; i < 100100; ++i) {
    if(vis[i]) prime.pb(i);
  }
  */
  int n;
  int a[3333];
  int sum = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    sum += a[i] - 1;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll tmp = b/c - (a-1)/c;
	tmp += (b/d - (a-1)/d);
	ll t1 = (c*d)/(__gcd(c, d));
	tmp -= (b/t1 - (a-1)/t1);
	cout << b - a + 1 - tmp;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979323846
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  int t,x; cin >> t >> x;
  cout << t/(double)x << endl;

  return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
map<pair<int, int>,ll>m;
void solve()
{
   int n;
   cin >> n;
   for( int i = 1; i <= n; i++ )
   {
      string s = to_string( i );
      int x = s[ 0 ] - '0';
      reverse( s.begin(), s.end() );
      int y = s[ 0 ] - '0';
      m[ MP( x, y ) ]++;
      s.clear();
   }
   ll sol = 0;
   for( int i = 1; i <= 9; i++ )
   {
      for( int j = 1; j <= 9; j++ )
      {
         //cout << m[ MP( i, j ) ] << endl;
         sol += m[ MP(i,j)]*m[MP(j,i)];
      }
   }
   cout << sol;
}
int main()
{
	int t = 1;
//	cin >> t;
	while (t--)
	{
		solve();
	}
}


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


int main(){

    int A,B,C,D;
    cin >> A >> B >> C >> D;

    while(1){

        C -= B;
        if(C<=0){
            cout << "Yes" << endl;
            break;
        }
        A-= D;
        if(A<=0){
            cout << "No" << endl;
            break;
        }
    }
    

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    string s, t; cin>>s>>t;
    for(int i=0; i<n; i++){
        bool is_same=true;
        for(int j=i; j<n; j++){
            if(s[j]!=t[j-i]) is_same=false;
        }
        if(is_same){
            cout << 2*i+(n-i) << endl;
            return 0;
        }
    }
    cout << 2*n << endl;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, K;
vector<int> p;

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

    rep(i, N) {
        int a;
        cin >> a;
        p.push_back(a);
    }

    vector<long double> e(N);
    e[0] = (1 + p[0]) / (long double)2;
    for (int i = 1; i < N; ++i) {
        e[i] = e[i - 1] + ((1 + p[i]) / (long double)2);
    }

    long double m = e[K - 1];
    for(int i = K; i < N; ++i) {
        long double sum = e[i] - e[i - K];
        m = max(m, sum);
    }

    cout << fixed << setprecision(12) << m << endl;
    return 0;
}

Measured memory_bytes: 4340
def main2
  n = gets.chomp.to_i
  map = { }
  (1..n).each do |ca|
    command, str = gets.chomp.split(/\s/)
    map[str] = 1 if command == "insert"
    if command == "find"
      if map.has_key? str
        puts "yes"
      else
        puts "no"
      end
    end
  end

end

main2

Measured memory_bytes: 139428
#include<iostream>
#include<cstdio>
using namespace std;
int A[300];
int main(){
	int N,D,X;
	cin>>N;
	cin>>D>>X;
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
		X+=(D+A[i]-1)/A[i];
	}
	printf("%d",X);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int n;
    int ans=0;
    cin >> n;
    int s=1;
    
    while(true){
        int S = s;
        int L = s*10;
        for(int i = S;i<L;i++){
            if(i<=n){
                ans++;
            }else{
                cout << ans<<endl;
                return 0;
            }
        }
        s=s*100;
    }
    
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  if (n % 2 != 0)
  {
    cout << "No" << endl;
    return 0;
  }
  
  string s;
  cin >> s;
  
  int half = n / 2;
  for (int i = 0; i < half; i ++)
  {
    if (s.at(i) != s.at(i + half))
    {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector <int>a;
	rep(i, n) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	int asum = 0;
	int bsum = 0;
	sort(all(a),greater<int>());
	for (int i = 0;i < n;i++) {
		if(i%2==0)asum += a[i];
		else bsum += a[i];
	}
	cout << asum - bsum << endl;
}



Measured memory_bytes: 256
//***********************************JAI SAI RAM***************************************//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ios>
using namespace std;
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define endl '\n'
void solve()
{
    ll n,m,i,j,k,l,o,p,q,r,t,num,den;
     vector<pair<ll,ll>> v1;
     map<pair<ll,ll>,ll> mp;
    long double x;
    cin>>n;
    for(i=0;i<n;i++)
    {
         cin>>x;

         o=llround(x*1000000000.0);
         num=o;
         //cout<<num<<endl;
         den=1000000000;
         p=__gcd(num,den);
         num/=p;
         den/=p;
        p=0;
        while(num>0&&num%2==0)
        {
            num/=2;
            p++;
        }
        q=0;
        while(num>0&&num%5==0)
        {
            num/=5;
            q++;
        }
        while(den>0&&den%2==0)
        {
            den/=2;
            p--;
        }
        while(den>0&&den%5==0)
        {
            den/=5;
            q--;
        }
        mp[{p,q}]++;
        v1.push_back({p,q});
    }
    ll ans=0;
    for(i=0;i<n;i++)
    {
        ll x,y;
        x=v1[i].first;
        y=v1[i].second;
        mp[v1[i]]--;
        for(auto it:mp)
        {
           if(it.first.first+x>=0&&it.first.second+y>=0)
           ans+=it.second;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=2000+5,D=924844033;
s64 dp[N][N][2];int mj[N];
s64 f[N],nf[N],jie[N];
void trans(int n,int m)
{
	per(i,n,0)
	{
		s64 ans=f[i]*nf[0]%D;
		int j=min(i,m);
		while(j)
		{
			(ans+=f[i-j]*nf[j])%=D;
			--j;
		}
		f[i]=ans;
	}
}

int main()
{
	//freopen("1.in","r",stdin);
	int n,k;
	cin>>n>>k;
	rep(i,1,n)
	{
		if(i<=2*k)
		{
			mj[i]=1;
			dp[i][0][0]=1;
			dp[i][1][0]=i-k>=1;
			dp[i][1][1]=i+k<=n;
		}
		else
		{
			int i0=i-2*k;
			mj[i]=mj[i0]+1;
			rep(j,0,mj[i])dp[i][j][0]=(dp[i0][j][0]+dp[i0][j][1])%D;
			rep(j,1,mj[i])(dp[i][j][0]+=dp[i0][j-1][0])%=D;
			if(i+k<=n)rep(j,1,mj[i])dp[i][j][1]=(dp[i0][j-1][0]+dp[i0][j-1][1])%D;
		}
	}
	f[0]=1;
	rep(i,max(1,n-2*k+1),n)
	{
		int m=mj[i];
		rep(j,0,m)nf[j]=(dp[i][j][0]+dp[i][j][1])%D;
		trans(n,m);
	}
	jie[0]=1;
	rep(i,1,n)jie[i]=jie[i-1]*i%D;
	s64 ans=0;
	rep(i,0,n)(ans+=(i%2?-1:1)*jie[n-i]*f[i])%=D;
	cout<<(ans%D+D)%D;
}

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

using ll = long long ;

ll ryuka ( ll N , vector<ll> &memo ){
    
    if( N == 0 ){
        return 2 ;
    }
    
    else if( N == 1 ){
        return 1 ;
    }
    
    if( memo.at(N) != -1 ){
        return memo.at(N) ;
    }
    
    else{
        memo.at(N) = ryuka ( N-1 , memo ) + ryuka ( N-2 , memo ) ;
        return memo.at(N) ;
    }
}

int main() {
    ll N ;
    cin >> N ;
    
    vector<ll> memo( N+1 , -1 ) ;
    
    cout << ryuka ( N , memo ) << endl;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	vector<int> a;
	int nq,cm,x;
	cin>>nq;
	for (int i=0;i<nq;i++){
	    cin>>cm; 
	    switch (cm){
	        case 0: 
	            cin>>x;
	            a.push_back(x);
	            break;
	        case 1:
	            cin>>x;
	            cout<<a[x]<<"\n";
	            break;
	        case 2:
	            a.pop_back();
	            break;
	     }
	}
	return 0;
}



Measured memory_bytes: 3956
s = int(input())

def f(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3*n+1

cnt = 1
while(True):
  if s == 1 or s == 2 or s == 4:
    ans = cnt+3
    break
  s = f(s)
  cnt += 1

print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&c^-1;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int a[1010],n=read();
int main(){
for (int i=1;i<=n;++i) a[i]=read();
int ans=0x3f3f3f3f;
for (int i=-100;i<=100;++i){
  int res=0;
  for (int j=1;j<=n;++j) {
    res+=(a[j]-i)*(a[j]-i);
    }
  ans=min(ans,res);
  }write(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int x[maxn];
void run_case()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> x[i];
    }
    int ans = INF;
    for (int pos = 1; pos <= 100; pos++)
    {
        int res = 0;
        for (int i = 1; i <= n; i++)
        {
            res += (x[i] - pos) * (x[i] - pos);
        }
        ans = min(res, ans);
    }
    cout << ans << "\n";
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
using namespace std;
int n,now,ans=0;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		int lg=log(x)/log(2);
		if ((1<<lg)<x){
			if (now>lg) now=lg;
			else lg++;
		}
		if (lg>now) ans+=lg-now;
		now=lg;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>

int main(){
    unsigned long long int input_N, input_A, input_B;

    scanf("%llu %llu %llu", &input_N, &input_A, &input_B );

    // printf("%llu %llu %llu\n", input_N, input_A, input_B );

    unsigned long long int num_A_in_N =
        input_A * (input_N / (input_A+input_B));
        // (unsigned long long int)((((double)input_N/(double)(input_A+input_B)))*input_A);


    unsigned long long int num_A_out_N =
        std::min(input_N%(input_A+input_B), input_A);

    // printf("%llu\n", num_A_in_N); 
    // printf("%llu\n", num_A_out_N);

    printf("%llu", num_A_in_N + num_A_out_N);
}

Measured memory_bytes: 128
N = int(input())
A = [int(x)-i for x,i in zip(input().split(),range(1,N+1))]
from math import ceil,floor
    
A.sort()


if N%2 == 0:
    b = round((A[floor(N/2)]+A[ceil(N/2)])/2)
else:
    b = A[floor(N/2)]
ans = 0
for a in A:
    ans += abs(a-b)
print(ans)

Measured memory_bytes: 25196
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
typedef long long int ll;
using namespace std;

bool sortbysecdesc(const pair<int,int> a, 
                   const pair<int,int> b) 
{ 
       return a.second>b.second; 
} 

class ungraph
{
public:
  ll v,e;
  vector<ll>* g;

ungraph(ll v, ll e)
{
  this->v=v;
  this->e=e;
  g= new vector<ll>[v+1];
}

void addedge(int e1, int e2)
{
  g[e1].push_back(e2);
}

void sortedges()
{
  for(int i=1;i<=v;i++)
      sort(g[i].begin(), g[i].end());
}

void dfs(vector< pair<int,int> > &postvisit)
{
  int visited[v+1]={0};
  int pv=1;
  for(int i=1;i<=v;i++)
  { 
    if(visited[i]==0)
      { dfs1(i,visited,pv,postvisit);} 
  }
}

void dfs1(int u, int visited[],int &pv,vector< pair<int,int> > &postvisit)
{
   visited[u]=1;
   for(int i=0;i<g[u].size();i++)
   { 
     if(visited[g[u][i]]==0)
        { dfs1(g[u][i],visited,pv,postvisit);} 
   }
   postvisit[u].first=u;
   postvisit[u].second=pv;
   pv++;
}

int longestPath(vector< pair<int,int> > &postvisit)
{   int dist[v+1]={0};
    for(int i=1;i<postvisit.size()-1;i++) {
        int v=postvisit[i].first;
        for(int j=0; j<g[v].size(); j++) {
            int u=g[v][j];
            if(dist[v]+1>dist[u]) dist[u]=dist[v]+1;
        }
    }
    //for(int i=1; i<=v; i++) cout<<dist[i]<<" ";
    return *max_element(dist+1,dist+v+1);
}
};



int main()
{
  int v,e; cin>>v>>e;
  ungraph g(v,e);
  int e1,e2;
  for(int i=0;i<e;i++)
   {
     cin>>e1>>e2;
     g.addedge(e1,e2);
   }
  g.sortedges();
  vector< pair<int,int> > postvisit(g.v+1);
  g.dfs(postvisit);
  sort(postvisit.begin()+1, postvisit.end(), sortbysecdesc); 
  //for(int i=1; i<postvisit.size(); i++) cout<<postvisit[i].first<<" "<<postvisit[i].second<<endl;
  cout<<g.longestPath(postvisit);
}


Measured memory_bytes: 8576
import bisect, copy

n = int(input())
a = list(map(int, input().split()))
b = copy.copy(a)
ans = []
num = 1
count = 0
while num != n:
    if max(a) < 0:
        break
    while a[num - 1] > a[num]:
        a2 = copy.copy(a)
        a2.sort()
        temp = a[num - 1] - a[num]
        temp2 = bisect.bisect_left(a2, temp)
        if temp2 == n:
            temp2 -= 1
        ans.append([a.index(a2[temp2]) + 1, num + 1])
        a[num] += a2[temp2]
        count += 1
        if count == n * 2 + 1:
            break
    num += 1
    if count == n * 2 + 1:
        break

ans2 = []
num = n - 2
count2 = 0
while num != -1:
    if min(b) > 0:
        break
    while b[num] > b[num + 1]:
        b2 = copy.copy(b)
        b2.sort()
        temp = b[num + 1] - b[num]
        temp2 = bisect.bisect_right(b2, temp)
        if temp2 == 0:
            temp2 += 1
        ans2.append([b.index(b2[temp2 - 1]) + 1, num + 1])
        b[num] += b2[temp2 - 1]
        count2 += 1
        if count2 == n * 2 + 1:
            break
    num -= 1
    if count2 == n * 2 + 1:
        break

if len(ans) == 0 and len(ans2) == 0:
    print(0)
elif len(ans) == 0:
    print(len(ans2))
    for i in ans2:
        print(i[0], i[1])
elif len(ans2) == 0:
    print(len(ans))
    for i in ans:
        print(i[0], i[1])
else:
    if len(ans) > len(ans2):
        print(len(ans2))
        for i in ans2:
            print(i[0], i[1])
    else:
        print(len(ans))
        for i in ans:
            print(i[0], i[1])

Measured memory_bytes: 9360
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>

using namespace std;

long long v[105];
char s[20005];

int main() {
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
    //#endif // ONLINE_JUDGE

    while(cin>>s) {
        int lg = strlen(s);

        if(s[0] <= '9' && s[0] >= '0') {
            long long nr = 0;

            for(int i = 0; i < lg; ++i) {
                nr = nr * 10 + s[i] - '0';
            }

            v[++v[0]] = nr;
        }
        else {
            if(s[0] == '*') {
                long long a, b;
                b = v[v[0]--];
                a = v[v[0]--];
                v[++v[0]] = a * b;
            }
            else {
                if(s[0] == '+') {
                    long long a, b;
                    b = v[v[0]--];
                    a = v[v[0]--];
                    v[++v[0]] = a + b;
                }
                else {
                    long long a, b;
                    b = v[v[0]--];
                    a = v[v[0]--];
                    v[++v[0]] = a - b;
                }
            }
        }
    }

    //assert(v[0] == 1);
    cout << v[v[0]] << '\n';

    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n; cin >> n;
    int a[100010] = {};
    int sum = 0;

    rep(i,0,n) {
        cin >> a[i];
        sum += a[i];
    }

    int cs[100010] = {};
    int ret[100010] = {};
    int cntnum = 0;

    if(sum % (n * (n+1) / 2)) cout << "NO" << endl;
    else {
        cntnum = sum / (n*(n+1) / 2);
        rep(i,0,n) {
            int prev = (i - 1 + n) % n;
            int s = a[prev] - a[i];
            // n で割り切れなければ操作回数が小数になるので不適
            // 結果が負になるのも不適 (操作回数は非負整数)
            if( (s+cntnum) % n != 0 || (s + cntnum) / n < 0) {
                cout << "NO" << endl;
                return 0;
            }
            cs[i] += (s + cntnum) / n;
        }
        /*
        rep(i,0,n) ret[0] += cs[i] * ((n - i) % n + 1);
        rep(i,1,n) ret[i] = ret[i-1] - cs[i] * n + cntnum;
        rep(i,0,n) {
            if(ret[i] != a[i]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        */
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
from bisect import bisect_right, bisect_left
n = int(input())
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    a_id = bisect_left(A, b)
    c_id = bisect_right(C, b)
    ans += a_id * (len(C) - c_id)

print(ans)

Measured memory_bytes: 23744
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<deque>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
	  
    int main(){
      int n;
      cin>>n;
      VEC(ll,a,n);
      auto sum = vec(ll,n);
      rep(i,n)sum[i] = 0;
      sum[0] = a[0];
      REP(i,1,n-1)sum[i] += (sum[i-1]+a[i]);
      ll ans = INF*1000;
      rep(i,n){
        if(i == n-1)continue;
        ans = min(ans,abs(sum[i]-(sum[n-1]-sum[i])));
      }
      cout<<ans;
    }

Measured memory_bytes: 3328
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,a[100111];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)get1(a[i]);
	int cur=0,ans=0;//cur=1 - inc   cur=2 - dec
	for(int i=1;i<=n;i++)
	{
		if(i==1||(cur==1&&a[i]<a[i-1])||(cur==2&&a[i]>a[i-1]))
		{
			cur=0;
			ans++;
		}
		else
		{
			if(a[i]>a[i-1])cur=1;else if(a[i]<a[i-1])cur=2;
		}
	}
	printendl(ans);
	return 0;
}

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

signed main(){
  
  while(1){
    
    string s1, s2;
    cin>>s1;
    if( s1 == "." ) break;
    cin>>s2;
  
    if( s1 == s2 ){
      cout<<"IDENTICAL"<<endl;
      continue;
    }
  
    int cnt1 = 0;
    string str;
  
    vector<string> A, B;
  
    for(int i=0;i<(int)s1.size();i++){
    
      if( s1[i] == '\"' ){
      
	if( cnt1 % 2 == 0 ) A.push_back( str );
	else B.push_back( str );
      
	str = "";
      
	cnt1++;
      
      }
      else str += s1[i];
    
    }
    
    A.push_back( str );
    
    int cnt2 = 0;
    
    str = "";
    
    vector<string> C, D;
    
    for(int i=0;i<(int)s2.size();i++){
    
      if( s2[i] == '\"' ){
      
	if( cnt2 % 2 == 0 ) C.push_back( str );
	else D.push_back( str );
      
	str = "";
      
	cnt2++;
      
      }
      else str += s2[i];
    
    }
    
    C.push_back( str );
    
    if( cnt1 != cnt2 ) cout<<"DIFFERENT"<<endl;
    else{
      
      int flag = 0;
	
      for(int i=0;i<(int)A.size();i++){
	
	if( A[i] != C[i] ){
	  cout<<"DIFFERENT"<<endl;
	  flag = 1;
	  break;
	}
	
      }
      
      if( flag == 0 ){
	
	int cnt = 0;
	  
	for(int i=0;i<(int)B.size();i++){
	  
	  if( B[i] != D[i] ) cnt++;
	  
	}
	  
	if( cnt == 1 ) cout<<"CLOSE"<<endl;
	else cout<<"DIFFERENT"<<endl;
	
      }
    
    }

  }
  
  return 0;
}



Measured memory_bytes: 3144
/*    特徴    */

/*    教訓    */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //


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



// --------- library end - //


int main(){

  vector<ll> as;
  rep(i, 5){
    as.push_back(il());
  }

  REP(i, 1, 6){
    if (as[i-1] == 0) cout << i << endl;
  }
  
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b || b == c || a == c){
    if(a == b && b == c) cout << "No" << endl;
  else puts("Yes");
  }
  else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define LL long long
const int MAX = 200005;
int type[MAX] , a[MAX] , b[MAX];
LL ft[2][MAX];

void inc(int idx , int pos , int delta)
{
	for(;pos < MAX; pos |= pos + 1)
		ft[idx][pos] += delta;
}
LL sum(int idx , int pos)
{
	LL ans = 0;
	for(;pos >= 0; pos = (pos & (pos + 1)) - 1)
		ans += ft[idx][pos];
	return ans;
}
int main()
{
    //getFacts();
	int q;
	cin >> q;
	LL sumB = 0;
	vector<int> all;
	for(int i = 0; i < q; i++)
	{
		cin >> type[i];
		if(type[i] == 1)
		{
			cin >> a[i] >> b[i];
			all.PB(a[i]);
		}
	}
	sort(all.begin() , all.end());
	int cnt = 0;
	LL sumAll = 0;
	for(int i = 0; i < q; i++)
	{
		if(type[i] == 2)
		{
			if(cnt == 0)
			{
				cout << "0 0" << endl;
				continue;
			}
			int treba = (cnt + 1) / 2;
			int till = -1;
			for(int bit = 17; bit >= 0; bit--)
			{
				if(sum(0 , till + (1 << bit)) < treba)
					till += (1 << bit);
			}
			till++;
			LL ans = sum(0 , till) * all[till] - sum(1 , till);
			//cout << ans << endl;
			//cout << sumAll << " " << cnt << " " << sum(1 , till) << endl;
			ans += (sumAll - sum(1 , till)) - (cnt - sum(0 , till)) * all[till];
			cout << all[till] << " " << ans + sumB << endl;
		}
		else
		{
			sumB += b[i];
			sumAll += a[i];
			cnt++;
			int idx = lower_bound(all.begin() , all.end() , a[i]) - all.begin();
			inc(0 , idx , 1);
			inc(1 , idx , a[i]);
		}
	}
	
    return 0;
}


Measured memory_bytes: 7800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
      
		if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
		sc.close();
	}
  
}

Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string o, e;
  cin >> o >> e;
  for(int i = 0; i < e.size(); i ++){
    cout << o[i] << e[i];
  }
  if(o.size() > e.size())cout << o[o.size()-1];
  cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(stdR.readLine());
        String[] s = stdR.readLine().split(" ");
        int[] A = new int[N];
        for(int i = 0 ; i < N ; i++) {
            A[i] = Integer.parseInt(s[i]);
        }
        if(N == 2) {
            System.out.println(Math.max(A[0], A[1]));
        }else if(N == 3) {
            System.out.println(Math.max(Math.max(gcd(A[0],A[2]),gcd(A[0],A[1])), gcd(A[1],A[2])));
        }else {
            int[] front = new int[N - 1];
            front[0] = gcd(A[0],A[1]);
            int[] back = new int[N - 1];
            back[0] = gcd(A[A.length - 2], A[A.length - 1]);
            for(int i = 1 ; i < N - 1 ; i++) {
                front[i] = gcd(front[i - 1], A[i + 1]);
                back[i] = gcd(back[i - 1], A[A.length - i - 2]);
            }
            int max = back[N - 3];//0
            for(int i = 1 ; i < N  ; i++) {
                if(i == 1) {
                    max = Math.max(max, gcd(A[0], back[N - 3 - i]));
                }else if(i == N - 1) {
                    max = Math.max(max, front[N - 3]);
                }else if(i == N - 2){
                    max = Math.max(max, gcd(A[N - 1], front[N - 4]));
                }else {
                    max = Math.max(max, gcd(front[i - 2], back[N - 3 - i]));
                }
            }
            System.out.println(max);
        }
    }
    
    private static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 47316
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const LL INF = 1LL << 30;

int main(void) {
	int N, X;
	cin >> N >> X;

	vector<int> m(N);
	rep(i, N) cin >> m[i];

	int min = INF;
	int sum = 0;
	for (int i = 0; i < N; i++){
		chmin(min, m[i]);
		sum += m[i];
	}
	cout << N + (X - sum) / min << endl;
	return 0;
}


Measured memory_bytes: 256
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 100005
# define eps 1e-5
# define MAXM 500001
# define MOD 100000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;
int _MAX(int a, int b){return a>b?a:b;}
int _MIN(int a, int b){return a>b?b:a;}

LL dp[55][55][2505];
int a[55];

int main ()
{
    int n, ave;
    scanf("%d%d",&n,&ave);
    FOR(i,1,n) scanf("%d",a+i);
    dp[0][0][0]=1;
    FOR(i,1,n) FOR(j,0,i-1) FOR(k,0,2500-a[i]) {
        dp[i][j][k]+=dp[i-1][j][k];
        dp[i][j+1][k+a[i]]+=dp[i-1][j][k];
    }
    LL ans=0;
    FOR(i,1,n) ans+=dp[n][i][i*ave];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 26368
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

#define MAX_N	(20)
#define MAX_NN	(MAX_N * (MAX_N - 1) / 2)
#define MAX_D	(400)
#define MAX_ND	(MAX_N * MAX_D)

/* typedef */

typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;

/* global variables */

int n, nn;
int max_d;
int ps[MAX_N], ds[MAX_NN];
int dmap[MAX_ND];
vvi ans;

/* subroutines */

void push_ans() {
  vi *vp = new vi();
  for (int i = 1; i < n; i++)
    (*vp).push_back(ps[i] - ps[i - 1]);
  if (find(ans.begin(), ans.end(), *vp) == ans.end())
    ans.push_back(*vp);
}

bool check(int i0, int i1, int j, int& k, int* used) {
  int pj = ps[j];
  for (int i = i0; i <= i1; i++) {
    int d = abs(pj - ps[i]);
    if (! dmap[d]) return false;
    dmap[d]--;
    used[k++] = d;
  }
  return true;
}

void rec(int i0, int i1) {
  if (false) {
    printf("(%d,%d): ", i0, i1);
    for (int i = 0; i < n; i++) {
      if (i > 0) putchar(',');
      printf("%d", ps[i]);
    }
    putchar('\n');
    for (int d = 1; d <= ds[0]; d++)
      if (dmap[d] > 0) printf(" %d:%d", d, dmap[d]);
    putchar('\n');
  }
  
  if (i0 + 1 == i1) {
    push_ans();
    return;
  }

  int prvd = max_d;
  while (dmap[max_d] == 0) max_d--;
  //printf(" max_d=%d\n", max_d);
  
  int used[MAX_NN];
  int k = 0;
  
  ps[i0 + 1] = ps[n - 1] - max_d;
  if (check(0, i0, i0 + 1, k, used) &&
      check(i1, n - 1, i0 + 1, k, used))
    rec(i0 + 1, i1);
  ps[i0 + 1] = 0;
  while (k > 0) dmap[used[--k]]++;
  
  ps[i1 - 1] = ps[0] + max_d;
  if (check(0, i0, i1 - 1, k, used) &&
      check(i1, n - 1, i1 - 1, k, used))
    rec(i0, i1 - 1);
  ps[i1 - 1] = 0;
  while (k > 0) dmap[used[--k]]++;
  
  max_d = prvd;
}

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    nn = n * (n - 1) / 2;
    memset(dmap, 0, sizeof(dmap));
    ans.clear();
    
    for (int i = 0; i < nn; i++) {
      cin >> ds[i];
      dmap[ds[i]]++;
    }

    memset(ps, 0, sizeof(ps));

    ps[0] = 0;
    ps[n - 1] = ds[0];
    dmap[ds[0]]--;
    max_d = ds[0];
    
    rec(0, n - 1);

    sort(ans.begin(), ans.end());
    
    for (int i = 0; i < ans.size(); i++) {
      vi& ai = ans[i];

      for (int j = 0; j < ai.size(); j++) {
	if (j > 0) cout << ' ';
	cout << ai[j];
      }
      cout << endl;
    }
    
    cout << "-----" << endl;
  }

  return 0;
}

Measured memory_bytes: 1576
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N;
	vector<long long int>dp(100);
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	dp[4] = 6;
	dp[5] = 12;
	for (int i = 3; i < 50; i++) {
		dp[i + 2] = dp[i] * 3;
	}
	while (cin >> N) {
		long long int ans = 0;
		for (int j = N; j > 0; j-=2) {
			ans += dp[j];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  string a,b,ans;
  cin >> n >> a >> b;
  rep(i,n){
    cout << a[i] << b[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			a[i] = Integer.parseInt(sc.next()) - i;
		}
		sc.close();
		Arrays.sort(a);
		yono = a[n / 2] - 1;
		long sad = 0;
		for(int i = 0 ; i < n ; i++){
			sad += Math.abs(a[i] - yono);
		}
		long sada = 0;
		yono++;
		for(int i = 0 ; i < n ; i++){
			sada += Math.abs(a[i] - yono);
		}
		sad = Math.min(sad , sada);
		sada = 0;
		yono++;
		for(int i = 0 ; i < n ; i++){
			sada += Math.abs(a[i] - yono);
		}
		sad = Math.min(sad , sada);
		ou.println(sad);
		ou.flush();
	}
}

Measured memory_bytes: 60296
def kmpTable(w):
    lw = len(w)
    nx = [-1] * (lw + 1)
    j = -1
    for i in range(lw):
        while j >= 0 and w[i] != w[j]:
            j = nx[j]
        j += 1
        nx[i + 1] = j
    return nx
def kmpSearch(s, w):
    ls = len(s)
    start = 0
    w_idx = 0
    ret = []
    nx = kmpTable(w)
    while start + w_idx < ls:
        if s[start + w_idx] == w[w_idx]:
            w_idx += 1
            if w_idx == len(w):
                ret.append(start)
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
        else:
            if w_idx == 0:
                start += 1
            else:
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
    return ret
T = input()
P = input()
ans = kmpSearch(T, P)
if ans:
    print("\n".join(map(str, ans)))	



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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);

    string s;
    cin>>s;
    vector<char> v;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'C' || s[i] == 'F'){
            v.PB((char)s[i]);
        }
    }
    string ans = "No";
    if(!v.size()){
        cout<<ans<<endl;
        return 0;
    }
    for(int i=0;i<v.size()-1;i++){
        if(v[i] == 'C' && v[i+1] == 'F'){
            ans = "Yes";
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    std::string s, s1, s2;

    std::cin >> s;

    for(int i = 0;;i++){
        s.pop_back();
        s.pop_back();

        s1 = s.substr(0, s.size() / 2);
        s2 = s.substr(s.size() / 2, s.size() / 2);


        if(s1 == s2){
            std::cout << s1.size() * 2;

            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
            String n = sc.next();

            if(n.substring(0, 1).equals("7") ||
                n.substring(1, 2).equals("7") ||
                n.substring(2, 3).equals("7")){

                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 35692