akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r){
  int m, root;

  if (l >= r) return;

  root = pre[pos++];
  m = distance(in.begin(), find(in.begin(), in.end(), root));

  rec(l, m);
  rec(m + 1, r);
  post.push_back(root);
}

void solve(){
  pos = 0;

  rec(0, pre.size());

  for (int i=0; i<n; i++){
    if (i) cout << " ";
    cout << post[i];
  }
  cout << endl;
}

int main(){
  int k;

  cin >> n;
  for (int i=0; i<n; i++){
    cin >> k;
    pre.push_back(k);
  }

  for (int i=0; i<n; i++){
    cin >> k;
    in.push_back(k);
  }

  solve();

  return 0;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main () {
  int r, g,b;
  cin >> r >> g >> b;
  if ((r * 100 + g * 10 + b) % 4 == 0) {
    cout <<"YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long n,d,c=0;
  cin>>n>>d;
  while(n--)
  {
    long x,y;
    cin>>x>>y;
    double dist=sqrt(x*x+y*y);
    if(dist<=(d*1.0))
      c++;
  }
  cout<<c;
}

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

// RE and TLE
int bod_main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  // sort(a.rbegin(), a.rend());
  vector<int> p(n);
  rep(i, n) {
    rep(j, n) { p.push_back(a[i] + a[j]); }
  }
  sort(p.rbegin(), p.rend());

  ll ans = 0;
  rep(i, m) ans += p[i];
  cout << ans << endl;
  return 0;
}

int main() {
  int n;
  ll m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<ll> s(n + 1);  // 累積和
  rep(i, n) s[i + 1] = s[i] + a[i];

  // a内の値がx以上の要素の合計と個数
  auto calc = [&](int x) {
    ll tot = 0, num = 0;
    rep(i, n) {
      int j = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
      num += n - j;
      tot += s[n] - s[j];
      tot += a[i] * ll(n - j);
    }
    return make_pair(tot, num);
  };

  int l = 0, r = 200001;
  while (l + 1 < r) {
    int c = (l + r) >> 1;
    if (calc(c).second >= m)
      l = c;
    else
      r = c;
  }
  auto p = calc(l);
  ll ans = p.first;
  ans -= (p.second - m) * l;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15



int main() {
	string s;
	cin >> s;
	int a = s[0]-'0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
	if(a+b+c+d == 7)
		cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	else if(a-b+c+d == 7)
		cout <<  a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	else if(a+b-c+d == 7)
		cout <<  a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	else if(a+b+c-d == 7)
		cout <<  a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	else if(a-b-c+d == 7)
		cout <<  a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	else if(a+b-c-d == 7)
		cout <<  a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	else if(a-b-c-d == 7)
		cout <<  a << "-" << b << "-" << c << "-" << d << "=7" << endl;
	else if(a-b+c-d == 7)
		cout <<  a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string S;
    cin >> S;
    int ans = 700;
    if(S[0] == 'o')
        ans += 100;
    if(S[1] == 'o')
        ans += 100;    
    if(S[2] == 'o')
        ans += 100;
    cout << ans << endl;
        
    return 0;
}

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

int main(){
	int n,ans=0;
	string s[]={"3","5","7"};
	stack<string> q;
	cin >> n;
	q.push("");
	while(!q.empty()){
		string k = q.top();
		q.pop();
		if(k.find('3')!=k.find('8'))
		if(k.find('5')!=k.find('8'))
		if(k.find('7')!=k.find('8'))
		if(stoi(k)<=n)ans++;
		if(k.size()<9){
			for(int i=0;i<3;i++)q.push(k+s[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int x[100];
int y[100];
int r[100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d%d%d",x+i,y+i,r+i);
		int b;
		scanf("%d",&b);
		for(int i=0;i<b;i++){
			int c,d,e,f;
			scanf("%d%d%d%d",&c,&d,&e,&f);
			bool ok=false;
			for(int j=0;j<a;j++){
				if((c-x[j])*(c-x[j])+(d-y[j])*(d-y[j])>=r[j]*r[j]||(e-x[j])*(e-x[j])+(f-y[j])*(f-y[j])>=r[j]*r[j]){
					if((e-c)*(x[j]-c)+(f-d)*(y[j]-d)<0){
						if((x[j]-c)*(x[j]-c)+(y[j]-d)*(y[j]-d)<=r[j]*r[j])ok=true;
					}else{
						if((e-c)*(x[j]-c)+(f-d)*(y[j]-d)>(e-c)*(e-c)+(f-d)*(f-d)){
							if((x[j]-e)*(x[j]-e)+(y[j]-f)*(y[j]-f)<=r[j]*r[j])ok=true;
						}else{
							if((x[j]-c)*(x[j]-c)+(y[j]-d)*(y[j]-d)-((e-c)*(x[j]-c)+(f-d)*(y[j]-d))*((e-c)*(x[j]-c)+(f-d)*(y[j]-d))/((e-c)*(e-c)+(f-d)*(f-d))<=r[j]*r[j])ok=true;
						}
					}
				}
			}
			if(ok)printf("Safe\n");
			else printf("Danger\n");
		}
	}
}

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

int main() {
	string s, t; cin >> s >> t;
	int cnt = 0;
	if (s.size() > t.size()) {
		for (int i = 0; i < s.size() - t.size(); i++) {
			string tmp = s.substr(i, t.size());
			int cnt_tmp = 0;
			for (int j = 0; j < t.size(); j++) {
				if (tmp[j] == t[j]) {
					cnt_tmp++;
				}
			}
			if (cnt_tmp > cnt)cnt = cnt_tmp;
		}
		cout << t.size() - cnt << endl;
	}
	else {
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == t[i])cnt++;
		}
		cout << s.size() - cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

#ifdef LOCAL
#include<prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vector<int> W(N);
    int s1 = 0;
    REP(i, N) {
        cin >> W[i];
        s1 += W[i];
    }

    int ans = s1;
    int s2 = 0;
    REP(i, N) {
        s2 += W[i];
        s1 -= W[i];
        ans = min(abs(s1 - s2), ans);
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int main(void){
    int n;
    cin >> n;
     vector<pair<string ,int>> v;
     for(int i=0;i<n;i++){
         string temp1;
         int temp2;
         cin >> temp1 >> temp2;
         v.push_back(make_pair(temp1,temp2));
     }
     string s;
     bool flag = 0;
     cin >> s;
     long long int ans =0;
     for(int i=0;i<v.size();i++){
         if(flag == 1){
        ans+= v[i].second;
         }else{
             if(v[i].first == s){
                 flag = 1;
             }
         }
     }
     cout << ans << endl;
     return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define MAX 110

int main() {
	int n, m, x, y, X[MAX], Y[MAX]; 
	scanf("%d %d %d %d", &n, &m, &x, &y);
	FOR(i, 0, n) scanf("%d", &X[i]); 
	FOR(i, 0, m) scanf("%d", &Y[i]);

	sort(X, X + n); sort(Y, Y + m);

	bool isWar = true;

	if (X[n - 1] > Y[0]) {
		printf("War\n"); return 0;
	}

	for (int i = X[n - 1] + 1; i <= Y[0]; i++) {
		if (x < i && i <= y) {
			isWar = false; break;
		}
	}

	if (isWar) printf("War\n");
	else printf("No War\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}


void oneCase () {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a % 2 == 1) {
            continue;
        }
        if (a % 3 == 0 || a % 5 == 0) {
            continue;
        }
        cout << "DENIED" << "\n";
        return;
    }

    cout << "APPROVED" << "\n";

}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
 
int main(){
    int n;
    cin >> n;
    vector<int> a(n+2,0);
    REP(i,n){
        cin >> a[i+1];
    }
    int p=0,q=0;
    int as = 0;
    REP(i,n+1){
        as += abs(a[i+1]-a[i]);
    }
    REP(i,n){
        int ans = as - abs(a[i+2]-a[i+1]) - abs(a[i+1]-a[i]) + abs(a[i+2]-a[i]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b

N = int(input())
A = [ int(v) for v in input().split() ]
AR = list(reversed(A))

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()

l_list = [0]
r_list = [0]
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i], AR[i]) )

n = []
j = -2   
for i in range(0, N):
    l = l_list[i]
    r = r_list[j]
    n.append(GCD(l, r))
    j -= 1
print(max(n))

Measured memory_bytes: 14400
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

signed main(){
  int n,m;
    cin>>n>>m;
  vector<vector<int>> A(m,vector<int>(10));

  FOR(i,0,m){
    int k;
      cin>>k;
    FOR(j,0,k){
      ll a;
        cin>>a;
      A[i][a-1]++;
    }
  }
  vll p(m);
  FOR(i,0,m){
    cin>>p[i];
  }

  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    bool b=true;
    for(int i=0;i<m;i++){
      int s=0;
      for(int j=0;j<10;j++){
        if(bit &(1<<j)){
          s+=A[i][j];
        }
      }
      if(s%2!=p[i]){
        b=false;
      }
    }
    if(b){
      ans++;
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, k, r, s, p;
string t;
int point[1000];
bool isNotWin[100100];
signed main() {

    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    point['r'] = p;
    point['s'] = r;
    point['p'] = s;
    int ans = 0;

    for(int i = 0; i < n; i++) {
        if(i + k < n && t[i] == t[i+k] && !isNotWin[i]) {
            isNotWin[i+k] = true;
        }
        else
            ans += point[t[i]];
    }

    cout << ans << endl;

  
    return 0;
}



Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

long long floor_sum(long long n,long long m,long long a,long long b){
    long long ans=0LL;
    if(a>=m){
        ans += n*(n-1LL)*(a/m)/2LL;
        a %= m;
    }
    if(b>=m){
        ans += n*(b/m);
        b %= m;
    }
    long long ym = (a*n+b)/m;
    long long xm =ym*m-b;
    if(ym==0) return ans;
    ans += (n-(xm+a-1LL)/a)*ym;
    ans += floor_sum(ym,a,m,(a-xm%a)%a);
    return ans;
}

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int test; cin >> test;
    while(test--){
        ll n,m,a,b; cin >> n >> m >> a >> b;
        cout << floor_sum(n,m,a,b) << "\n";
    }
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

void eratos ( int n, vector<bool>&  prime){
	prime[2] = true; prime[0] = prime[1] = false;
	for(int i = 3; i <= n; i += 2) prime[i] = true, prime[i+1] = false;
	for(int i = 3; i*i <= n ; i += 2) if(prime[i]){
		for(int j = i * i, k = i * 2; j <= n; j += k) prime[j] = false;
	}
}



int main()
{
 
	cin.tie(0); ios_base::sync_with_stdio(false);
	vector<bool> pr(100020);
	eratos(100015, pr);
	
	VI v;
	rep(i,100001) if(i&1 && pr[i]){
		int p = (i +1)/2;
		if(pr[p]) v.push_back(i);
	}
	//rep(i,50) printf("%d, ",v[i]); puts("");
	int q;
	cin >>q;
	
	while(q--){
		int l,r;
		cin >>l >>r;
		
		auto it = lower_bound(all(v),l);
		if(it == v.end()){ cout <<"0\n"; continue;}
		int st = it - v.begin();
		
		auto it2 = upper_bound(all(v), r);
		int to = it2 - v.begin();
		if(v[to] != r) to--;
		//dbg(st, v[st], to, v[to]);
		cout << to +1  - st  <<"\n";
	}
	
	return 0;
}

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

namespace ABC142C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] Ainput = Console.ReadLine().Split(' ');
            int[] A = new int[N];
            int[] ans = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(Ainput[i]);
                ans[A[i] - 1] = i + 1;
            }
            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 40104
unittest
{
	assert( [ "2 0", "1 3" ].parse.expand.solve == 2 );
	assert( [ "1 1", "50" ].parse.expand.solve == 0 );
	assert( [ "3 0", "1 1 1" ].parse.expand.solve == 4 );
	assert( [ "45 1", "17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26" ].parse.expand.solve == 17592186044416 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto np = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( np[ 1 ], as );
}

auto solve( long p, long[] as )
{
	return dfs( as )[ p ];
}

long[ 2 ] dfs( long[] as )
{
	static long[ 2 ][ long[] ] memo;
	
	if( as !in memo )
	{
		auto k = as.idup;
		auto p = as[ 0 ] % 2;
		if( as.length == 1 )
		{
			if( p == 0 ) memo[ k ] = [ 2L, 0L ];		// 食べない→0枚(偶数)、食べる→a枚(偶数)
			else         memo[ k ] = [ 1L, 1L ];		// 食べない→0枚(偶数)、食べる→a枚(奇数)
		}
		else
		{
			auto r = dfs( as[ 1 .. $ ] );
			if( p == 0 ) memo[ k ] = [ r[ 0 ] + r[ 0 ], r[ 1 ] + r[ 1 ] ];		// 食べない→r枚(偶奇引継)、食べる→a+r枚(偶奇引継)
			else         memo[ k ] = [ r[ 0 ] + r[ 1 ], r[ 1 ] + r[ 0 ] ];		// 食べない→r枚(偶奇引継)、食べる→a+r枚(偶奇反転)
		}
	}
	return memo[ as ];
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

void DFS(void);
void DFS_visit(int);

int n, im[N][N];
int color[N],d[N], f[N], t=0;

int main()
{
  int i, j, u, k, v;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      im[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      im[u-1][v-1]=1;
    }
  }
 
  DFS();

  return 0;
}
void DFS()
{
  int i;

  for(i=0;i<n;i++){
    color[i]=WHITE;
  }

  for(i=0;i<n;i++){
    if(color[i]==WHITE) DFS_visit(i);
  }

  for(i=0;i<n;i++) printf("%d %d %d\n",i+1, d[i],f[i]);

}
void DFS_visit(int a)
{
  int b;

  color[a]=GRAY;
  t++;
  d[a]=t;

  for(b=0;b<n;b++){
    if(im[a][b]==1 && color[b]==WHITE) DFS_visit(b);
  }
  color[a]=BLACK;
  t++;
  f[a]=t;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h> 
using namespace std;
#define N 100010

int vis[N];
int dp[N];

int dfs(int u, vector<vector<int> >& adj){
	if(!vis[u]){
		vis[u] = 1;
		for(auto v: adj[u])
			dp[u] = max(dp[u], 1+dfs(v,adj));
	}
	return dp[u];
}
  

int main() {

	int n, m;
	cin >> n >> m;
	vector<vector<int> > adj(n);
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		cin >> u >> v;
		adj[u-1].push_back(v-1);
	}

	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if(!vis[i]){
			ans = max(ans, dfs(i,adj));
		}
	}

	cout <<ans << endl; 
} 

Measured memory_bytes: 8576
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {

    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (auto& i : A)std::cin >> i;
    int bucketSize = static_cast<int>(std::sqrt(N));
    std::vector<int> bucket(N / bucketSize + (N % bucketSize ? 1 : 0), 0);
    for (int i = 0; i < N; ++i) bucket[i / bucketSize] = gcd(bucket[i / bucketSize], A[i]);

    int ans = -1;

    auto getGCD = [&](int l, int r) {
        int tmp = 0;
        for (int i = l; i < r; ++i) {
            if (i % bucketSize || i + bucketSize >= r)tmp = gcd(tmp, A[i]);
            else {
                tmp = gcd(tmp, bucket[i / bucketSize]);
                i += bucketSize - 1;
            }
        }
        return tmp;
    };

    for (int i = 0; i < N; ++i) {
        ans = std::max(ans, gcd(getGCD(0, i), getGCD(i + 1, N)));
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    cout << ceil(n/2.0) << endl;
}


Measured memory_bytes: 256
var fs = require('fs');

// class Stdin
function Stdin() {
  this.__input = null;
  this.__lines = [];
  this.__index = 0;
}
Stdin.prototype.init = function() {
  this.__input = fs.readFileSync('/dev/stdin', 'utf-8');
  this.__lines = this.__input.split("\n");
  this.__index = 0;
}
Stdin.prototype.readline = function() {
  if(this.__index === this.__lines.length) this.init();
  return this.__lines[this.__index++];
};
Stdin.prototype.readlines = function() {
  if(this.__index === this.__lines.length) this.init();
  cur = this.__index; this.__index = this.__lines.length;
  return this.__lines.slice(cur);
};
var stdin = new Stdin;

Array.prototype.imap = function() { return this.map((x)=>parseInt(x)); }
Array.prototype.fmap = function() { return this.map((x)=>parseFloat(x)); }
Array.prototype.smap = function() { return this.map((x)=>String(x)); }
Array.prototype.ffill = function(cb) {
  for(var i=0; i<this.length; ++i) { this[i] = cb(i); } return this;
}
Array.prototype.max = function() {
  if(this.length === 0) return undefined;
  res = this[0];
  for(var i=1; i<this.length; ++i) if(res < this[i]) res = this[i];
  return res;
}
Array.prototype.min = function() {
  if(this.length === 0) return undefined;
  res = this[0];
  for(var i=1; i<this.length; ++i) if(this[i] < res) res = this[i];
  return res;
}

Number.prototype.times = function(cb) { for(var i=0; i<this; ++i) cb(i); return this; }

Object.prototype.forEach = function(cb) { Object.keys(this).forEach(cb); }
Object.prototype.map = function(cb) { Object.keys(this).map(cb); }

var l = stdin.readline().split(' ').imap();
var N = l[0], C = l[1];

var cha = new Array(C).ffill(()=>new Array(100003).fill(0));

N.times((i)=> {
  var l = stdin.readline().split(' ').imap();
  var s = l[0], t = l[1], c = l[2];
  cha[c-1][s] += 1;
  cha[c-1][t] -= 1;
});

var res = new Array(100003).fill(0);
C.times((i)=> {
  cha[i].forEach((e, j)=> {
    if(e === 1) res[j-1] += 1;
    else if(e === -1) res[j] -= 1;
  });
});
var cur = 0, ans = 0;
res.forEach((e)=> {
  cur += e;
  ans = Math.max(cur, ans);
});

console.log(ans);

Measured memory_bytes: 83652
n = int(input())
a = list(map(int,input().split()))
count = [0]*(10**5+5)
for v in a:
    count[v] += 1

maxX = 0
maxV = 0

for i in range(10**5+1):
    val = count[i-1] + count[i] + count[i+1]
    if val > maxV:
        maxV = val
        maxX = i
print(maxV)

Measured memory_bytes: 14004
import java.util.Scanner;
import java.math.BigInteger;
 
public class Main {
	public static void main(String args[]) {
		BigInteger T, A;
		T = BigInteger.ZERO;
		A = T;
		
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		for (int i = 1; i <= n; i++) {
			int _x = scanner.nextInt();
			int _y = scanner.nextInt();
			BigInteger x = BigInteger.valueOf(_x);
			BigInteger y = BigInteger.valueOf(_y);
			
			if (i == 1) {
				T = x;
				A = y;
				continue;
			}

			BigInteger D = x.multiply(A).subtract(T.multiply(y));
			if (D.compareTo(BigInteger.ZERO) >= 0) {
				for (int j = 0; j <= 1000; j++) {
					BigInteger Z = D.add(x.multiply(BigInteger.valueOf(j)));
					if (Z.mod(y).compareTo(BigInteger.ZERO) == 0) {
						BigInteger q = BigInteger.valueOf(j);
						BigInteger p = Z.divide(y);
						T = T.add(p);
						A = A.add(q);
						break;
					}
				}
	 
			}
			else {
				for (int j = 0; j <= 1000; j++) {
					BigInteger Z = y.multiply(BigInteger.valueOf(j)).subtract(D);
					if (Z.mod(x).compareTo(BigInteger.ZERO) == 0) {
						BigInteger q = Z.divide(x);
						BigInteger p = BigInteger.valueOf(j);
						T = T.add(p);
						A = A.add(q);
						break;
					}
				}
			}
	}
			System.out.println(T.add(A).toString());
}
}


Measured memory_bytes: 77076
#include<bits/stdc++.h>
#define INF 1e9+7
#define ll long long
#define F first
#define S second
#define N 300005
#define M 1000000009
#define mp make_pair
#define ull unsigned long long
#define sc(n) scanf("%d",&n)
#define gcd __gcd
#define pb push_back
using namespace std;
int a[N];
int main(){
	ios_base::sync_with_stdio(0);
	int n,k;
	ll sum =0,sem=0;
	cin>>n;
	for(int i=0;i<3*n;i++)
		cin>>a[i];
	sort(a,a+3*n);
	int t=n;
	for(int i=n;i<2*n;i++){
		sem +=a[i];
	}
	for(int i=3*n-2;i>0,t;i-=2){
		sum+=a[i];
		t--;
	}
	cout<<max(sem,sum)<<endl;
	return 0; 	
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e5+10;
const ll inf=0x3f3f3f3f;
ll a[N],b[N];
ll dp[N];
int main()
{
   ll h,n;
   while(cin>>h>>n)
   {
   memset(dp,0x3f,sizeof(dp));
   dp[0]=0;
   for(ll i=1;i<=n;++i)
   {
       cin>>a[i]>>b[i];
   }
   for(ll i=1;i<=n;++i)
    {
      for(ll j=a[i];j<=1e5;++j)
      {
         if(dp[j-a[i]]!=inf)
            dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
      }
   }
   ll m=inf;
   for(ll i=h;i<=1e5;++i)
   {
      m=min(m,dp[i]);
   }
   cout<<m<<endl;
   }
   return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 1; i <= n; i++)
	{
		if (((int)log10(i) + 1) % 2 == 1)
		{
			count++;
		}
	}
	cout << count;
}


Measured memory_bytes: 31872
#include<stdio.h>
int main(void){
    int d,a,b=0,c=0,i,j;
    
    while(scanf("%d",&d) != EOF){
        a=600/d;
        for(i=0;i<a;i++){
            c+=d*(b*b);
            b+=d;
        }
        printf("%d\n",c);
        b=0;
        c=0;
    }
    return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;

#define ll long long

const int maxN=20010;
const int Mod=998244353;

int Fac[maxN],Ifc[maxN];

int QPow(int x,int cnt);
int C(int n,int m);

int main(){
	int n,K;
	Fac[0]=Ifc[0]=1;for (int i=1;i<maxN;i++) Fac[i]=1ll*Fac[i-1]*i%Mod;
	Ifc[maxN-1]=QPow(Fac[maxN-1],Mod-2);for (int i=maxN-2;i>=1;i--) Ifc[i]=1ll*Ifc[i+1]*(i+1)%Mod;
	scanf("%d%d",&K,&n);
	for (int i=2;i<=K+K;i++){
		int sum=0,mm=(min(i-1,K)-max(i-K,1)+2)/2;
		for (int j=0;j+j<=n;j++) sum=((1ll*((j&1)?(-1):(1))*C(mm,j)%Mod*C(n-2*j+K-1,K-1)%Mod+sum)%Mod+Mod)%Mod;
		printf("%d\n",sum);
	}
	return 0;
}

int QPow(int x,int cnt){
	int ret=1;
	while (cnt){
		if (cnt&1) ret=1ll*ret*x%Mod;
		x=1ll*x*x%Mod;cnt>>=1;
	}
	return ret;
}

int C(int n,int m){
	if (n<m) return 0;
	//cout<<n<<" "<<m<<endl;
	return 1ll*Fac[n]*Ifc[n-m]%Mod*Ifc[m]%Mod;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int main(){
int n,i;
double jijou,s[1000],goukei,heikin,goukei2,hensa;
while(1){
goukei=0,heikin=0,goukei2=0,hensa=0,jijou=0;
scanf("%d",&n);
if(n==0) break;
for(i=0;i<n;i++){
scanf("%lf",&s[i]);
goukei+=s[i];
}
heikin=goukei/i;
for(i=0;i<n;i++){
jijou=pow(s[i]-heikin,2);
goukei2+=jijou;
}
hensa=sqrt(goukei2/i);
printf("%lf\n",hensa);
}
return 0; }


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

using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N), s(N + 1, 0);
    map<int, vector<int>> m;
    m[0].push_back(0);
    rep(i, N) {
        cin >> A[i];
        A[i] = (A[i] + K - 1) % K;
        s[i + 1] = (s[i] + A[i]) % K;
        m[s[i + 1]].push_back(i + 1);
    }
    //rep(i, N) cout << A[i];
    //cout << endl;
    //rep(i, N + 1) cout << s[i];
    //cout << endl;
    ll ans = 0;
    for (auto i = m.begin(); i != m.end(); i++) {
        //cout << i->first << endl;
        rep(j, i->second.size() - 1) {
            int l = i->second[j];
            int r = lower_bound(i->second.begin(), i->second.end(), l + K) - i->second.begin();
            ans += r - 1 - j;
            //cout << "l=" << l << " r=" << r << endl;
            //cout << "ans = " << ans << " " << endl;
        }
        //cout << endl;
    }
    cout << ans << endl;
}

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

int main(void){
    int n;cin >> n;
    
    ll alina = 0;
    for(ll i = 1;i <= n;i++)alina += i;
    
    cout << alina - n << endl;
}

Measured memory_bytes: 3608
/*
AOJ 0022 Maximum Sum Sequence
*/
#include <stdio.h>


 
int main(){
    int n;
    long  a[5000];
    long long max, tmp;
    int  i,j;
  
    while(scanf("%d",&n) && n!=0){
      for( i=0; i<n; i++)scanf("%ld",&(a[i]));
 
        max = a[0]; tmp=0;
 
        for( i=0; i<n; i++){
            for( j=i; j<n; j++){
                tmp+=a[j];
                if(max<tmp)
                    max=tmp;
            }
            tmp=0;
        }
        printf("%lld\n",max);
    }
 
    return 0;
}

Measured memory_bytes: 628
s=input()

if s=='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)
elif s=='SAT':
  print(1)
else:
  print(7)

Measured memory_bytes: 61780
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var r []rune
	for n > 0 {
		n--
		r = append([]rune{rune('a' + n%26)}, r...)
		n /= 26
	}
	fmt.Println(string(r))
}


Measured memory_bytes: 1772
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int d = fs.nextInt();
        int n = fs.nextInt();

        if (n == 100)
            n++;
        long ans = (long) Math.pow(100, d) * n;
        System.out.println(ans);
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    if (n >= 30) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
    //cin.rdbuf()->in_avail()
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin >> n;
	int c[n];
	for(int i=0;i<n;i++)
		cin >> c[i];
	sort(c,c+n);
	int sum=0,f=1;
	for(int i=0;i<n;i++){
		sum=(sum+((n-i+1)*c[i])%mod)%mod;
		if(i)f=(f*4)%mod;
	}
	cout << (sum*f)%mod;
}


Measured memory_bytes: 1792
/*
dreamerer
*/
#include <bits/stdc++.h>
using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; const int N = 5e5 + 5, M = 998244353, INF = 0x3f3f3f3f; const ll LNF = 0x3f3f3f3f3f3f3f3f; void Main();
void debug() { cerr << endl; } template <typename T, typename... Ts> void debug(T x, Ts... y) { cerr << "\033[31m" << x << "\033[0m"; if (sizeof...(y) > 0) cerr << ' '; debug(y...); } template <typename T> void debug(const T& a, int l, int r, char c) { for (int i = l; i <= r; ++i) cerr << "\033[31m" << a[i] << "\033[0m" << (i == r ? '\n' : c); }
void print() { cout << '\n'; } template <typename T, typename... Ts> void print(T x, Ts... y) { cout << x; if (sizeof...(y) > 0) cout << ' '; print(y...); } template <typename T> void print(const T& a, int l, int r, char c) { for (int i = l; i <= r; ++i) cout << a[i] << (i == r ? '\n' : c); }
void input() {} template <typename T, typename... Ts> void input(T& x, Ts&... y) { cin >> x; input(y...); } template <typename T> void input(T* a, int l, int r) { for (int i = l; i <= r; ++i) cin >> a[i]; } template <typename T> void input(vector<T>& a, int l, int r) { for (int i = l; i <= r; ++i) cin >> a[i]; }
template <typename T> void Max(T& a, T b) { if (a < b) a = b; } template <typename T> void Min(T& a, T b) { if (a > b) a = b; } template <typename T> void Add(T& a, T b) { a += b; if (a > M) a -= M; if (a < 0) a += M; } template <typename T> void Mul(T& a, T b) { a = a * b % M; } template <typename T> T Mod(T a) { return (a % M + M) % M; }
int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); /* cout << setprecision(10) << fixed; */
#ifdef Zmm
    if (argc) { freopen((string(*(argv)).substr(2, string(*(argv)).size() - 6) + string(".cpp")).c_str(), "r", stdin); string x; cin >> x; }
#endif
    Main();
}
void replaceAll(std::string& str, const std::string& from, const std::string& to) {
    if(from.empty())
        return;
    size_t start_pos = 0;
    while((start_pos = str.find(from, start_pos)) != std::string::npos) {
        str.replace(start_pos, from.length(), to);
        start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
    }
}
/*
s=input()
s=s.replace('eraser','')
s=s.replace('erase','')
s=s.replace('dreamer','')
s=s.replace('dream','')
if s=='':
    print("YES")
else :
    print("NO")
*/
void Main() {
    string s;
    input(s);
    replaceAll(s, "eraser", "");
    replaceAll(s, "erase", "");
    replaceAll(s, "dreamer", "");
    replaceAll(s, "dream", "");
    print(s.size() == 0 ? "YES" : "NO");
}

Measured memory_bytes: 3776
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[5005];
ll dp[5005][5005];

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    scanf("%s", str);
    int m=strlen(str);

    dp[0][0]=1;
    int i,j;
    for(i=0; i<n; i++) {
        for(j=0; j<=n; j++) {
            if(dp[i][j]) {
                dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*2)%MOD;
                if(j>0) dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j])%MOD;
                if(j==0) dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
            }
        }
    }
    ll ans=(dp[n][m]*minv(mpow(2,m)))%MOD;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 193920
#include <iostream>
#include <string>

int main() {
    std::string str;
    std::cin >> str;

    int cnt = 0;
    for (int i = 0; i < str.size(); i++) {
        cnt += str[i] - '0';
    }

    std::printf("%s\n", cnt % 9 == 0 ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif

#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define two pair<int,int>
#define ll long long int
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define oo 1e15
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define rep(a1,b1,c1) for(int a1=b1;a1<c1;a1++)
#define repb(a2,b2,c2) for(int a2=b2;a2>=c2;a2--)
#define speedforces std::ios::sync_with_stdio(false)
#define watch(x) cerr << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file  freopen("output.txt", "w", stdout);

const int N = 200005;
int dp[105][N];

signed main(){
//input_from_file;
speedforces;
int n,W; cin>>n>>W;
int w[n+1] , v[n+1];
memset(dp,0,sizeof dp);
rep(i,1,n+1) cin>>w[i]>>v[i];
rep(i,1,N) dp[0][i] = oo;
rep(i,1,n+1) rep(j,1,N){
  dp[i][j] = dp[i-1][j];
  if(v[i] <= j) dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
}
int ans = 0;
rep(i,1,n+1) rep(j,1,N) 
if(dp[i][j] <= W) ans = max(ans,j);
cout<<ans<<endl;
}

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

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for (ll i = b; i <= e; i++)
#define FORD(i, b, e) for (ll i = b; i >= e; i--)
#define SIZE(x) ((ll)(x).size())
#define pb push_back
#define st first
#define nd second
#define all(a) begin(a), end(a)
#define watch(x) cerr << (#x) << " is " << (x) << '\n';

const ll mod = 961748941;
const ll SZ = 50000;
const ll k = 31;

ll h[SZ];
ll p[SZ];

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

    ll n;
    string s;

    cin >> n >> s;

    p[0] = 1;
    FOR(i, 1, s.size()) {
        p[i] = (k * p[i - 1]) % mod;
    }

    FOR(i, 1, s.size()) {
        h[i] = h[i - 1] + p[i - 1] * (s[i - 1] - 'a');
        h[i] %= mod;
    }

    unordered_map<ll, ll> m;

    ll l = 1;
    ll r = n;

    while (l < r) {
        ll mid = (l + r) / 2;

        ll i = mid;
        bool ok = 0;
        FOR(j, 1, n - i + 1) {
            ll hash = (h[j + i - 1] - h[j - 1] + mod) % mod;
            hash = (hash * p[n - j]) % mod;
            if (m.count(hash) == 0) {
                m[hash] = j + i - 1;
            } else if (m[hash] < j) {
                ok = 1;
            }
        }
        m.clear();

        if (ok) {
            l = mid + 1;
        } else {
            r = mid;
        }
    }

    cout << l - 1;

    return 0;
}


Measured memory_bytes: 512