akhauriyash/Code-Regression huggingface dataset:
#include<iostream>                                                    
 #include<vector>                                                      
 using namespace std;                                                  
 bool search(vector<int> a, int n){                                    
   for(vector<int>::iterator itr = a.begin(); itr != a.end();++itr){   
     if(*itr == n) return true;                                        
   }                                                                   
   return false;                                                       
 }                                                                     
 int main(void){                                                       
   int s,n = 1,front,push = 0;                                         
   cin >> s;                                                           
   vector<int> a = {s};                                                
   while(1){                                                           
     front = a[n-1];                                                   
     n++;                                                              
     if(front % 2 == 0){//偶数                                           
       push  = front/2;                                                
     }                                                                 
     else{                                                             
       push = front*3 + 1;                                             
     }                                                                 
     if(!search(a,push)){                                              
       a.push_back(push);                                              
     }                                                                 
     else break;                                                       
   }                                                                   
   cout << n << endl;                                                  
   return 0;                                                           
 }                                                                     

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args){
		char[] S = sc.next().toCharArray();
		char[] P = sc.next().toCharArray();
		int n = S.length;
		int m = P.length;

		int[] T = new int[m+1];
		T[0] = -1;
		T[1] = 0;
		int i = 2;
		int j = 0;
		while(i <= m){
			if(P[i-1] == P[j]){
				T[i] = j + 1;
				i++;
				j++;
			}else if(j > 0){
				j = T[j];
			}else{
				T[i] = 0;
				i++;
			}
		}

		i = 0;
		j = 0;
		StringBuilder ans = new StringBuilder();
		while(i + j < n){
			if(P[j] == S[i + j]){
				j++;
				if(j == m){
					ans.append(i);
					ans.append("\n");
				}else{
					continue;
				}
			}
			i = i + j - T[j];
			if(j > 0){
				j = T[j];
			}
		}

		System.out.print(ans);
	}

	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next(){
			while(st == null || !st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				}catch(IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
	}
}

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

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

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0){
			return 0;
		}
		vector<int> v(n);
		rep(i,n){
			cin>>v[i];
		}
		int pos=0;
		int ans=-1;
		rep(j,m){
			// cout<<pos<<endl;
			int t;
			cin>>t;
			if(ans>=0) continue;
			if(pos+t>=n-1){
				ans=j+1;
				continue;
			}
			if(pos+t+v[pos+t]>=n-1){
				ans=j+1;
			}
			pos+=t;
			pos+=v[pos];
		}
		// if(ans==-1){
			// cout<<m<<endl;
		// }
		// else{
			cout<<ans<<endl;
		// }
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b:i--)

int main() {
    // your code goes here
    ll n;
    cin >> n;
    if(n%2==0) cout << n/2 << endl;
    else cout << (n+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

const ll MAX = 5100000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

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

/*
重複がなかった場合は n+1 C i
重複があるのは重複している数のindexをそれぞれl,rとしたとき
l + (n - r)　が i-1以下の場合だけ。（実装上は気にしなくてもよい nCr(n<r)が0なので）
与えられた配列を重複だけ表示すると
--l---r---
のようになりこの場合重複する組み合わせは
--[l---r]---
[l---r]の右と左からi - 1個を選ぶ組み合わせの数と等しくなる


*/

ll a[101010];
int solve()
{
    ll n;
    cin >> n;
    map<ll, ll> m;
    ll v;
    for(int i=0; i < n + 1; i++){
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]] == 2){
            v = a[i];
        }
    }

    ll l=-1, r;
    for(int i=0; i < n + 1; i++){
        if(a[i] == v && l == -1){
            l = i;
        }else if(a[i] == v){
            r = i;
        }
    }

    COMinit();
    for(ll i=0; i < n + 1; i++){
        ll k=COM(l + (n - r), i);
        cout << (COM(n + 1, i + 1) - k + MOD) % MOD << endl;
    }

    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}



Measured memory_bytes: 127744
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<ll> x(N),y(N);
  for(int i=0;i<N;i++) cin>>x[i]>>y[i];

  int ans=N;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      map<pair<ll,ll>,bool> mp;
      for(int k=0;k<N;k++){
        mp[make_pair(x[k],y[k])]=true;
      }

      ll p=x[i]-x[j];
      ll q=y[i]-y[j];
      int tmp=0;
      for(int k=0;k<N;k++){
        if(mp[make_pair(x[k]-p,y[k]-q)]) continue;
        else tmp++;
      }
      if(tmp==0) tmp++;
      ans=min(ans,tmp);
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    string s;
    cin >> s;
    reverse(all(s));
    while(s.size() > 0) {
        if(s.substr(0, 5) == "esare") {
            s = s.substr(5);
        } else if (s.substr(0, 6) == "resare") {
            s = s.substr(6);
        } else if (s.substr(0, 5) == "maerd") {
            s = s.substr(5);
        } else if (s.substr(0, 7) == "remaerd") {
            s = s.substr(7);
        } else {
            cout << "NO" << endl;
            exit(0);
        }
    }
    cout << "YES" << endl;
    exit(0);
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

    /* チェックリスト
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        int r = 0;
        int n = 0;
        for(char c : s1.toCharArray()){
            if(c == s2.charAt(n)){
                r++;
            }
            n++;
        }
        System.out.println(r);
    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int a[10];

int main() {
    int n, p = -1, cnt = 0;
    cin >> n;
    for (int i = 0; i < 4; i++) {
        if (n % 10 == p)
            cnt++;
        else
            cnt = 0;
        if (cnt >= 2) {
            cout << "Yes" << endl;
            return 0;
        }
        p = n % 10;
        n /= 10;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, C;
	cin >> N >> C;

	int D[C][C];
	rep(i, 0, C) rep(j, 0, C) cin >> D[i][j];
	int c[N][N];
	rep(i, 0, N) rep(j, 0, N) {
		cin >> c[i][j];
		--c[i][j];
	}

	int cost[3][C]; // (i+j)%3から色Cに変えるときにかかるコスト
	memset(cost, 0, sizeof(cost));
	rep(ic, 0, C) rep(i, 0, N) rep(j, 0, N) {
		cost[(i + j) % 3][ic] += D[c[i][j]][ic];
	}

	int rsl = 1 << 30;
	int c_array[3];

	for(c_array[0] = 0; c_array[0] < C; c_array[0]++) {
		for(c_array[1] = 0; c_array[1] < C; c_array[1]++) {
			if(c_array[1] == c_array[0]) continue;
			for(c_array[2] = 0; c_array[2] < C; c_array[2]++) {
				if(c_array[2] == c_array[0] or c_array[2] == c_array[1]) continue;
				int tmp = 0;
				rep(i, 0, 3) tmp += cost[i][c_array[i]];
				rsl = min(rsl, tmp);
			}
		}
	}

	cout << rsl << endl;

}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int> b(n);
	for (auto &v : b) {
		cin >> v;
	}

	vector<int> ans;
	for (int i = b.size() - 1; i >= 0; i--) {
		if (b.empty()) {
			break;
		}

		if (b[i] == i + 1) {
			ans.push_back(b[i]);
			b.erase(begin(b) + i);
			i = b.size();
		}
	}
	

	if (ans.size() != n) {
		cout << -1 << endl;
		return 0;
	}

	reverse(begin(ans), end(ans));
	for (auto v : ans) {
		cout << v << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
   int n;
   cin >> n;
   vector<ll>a(n),b(n);
   ll sum =0;
   for(int i=0;i<n;i++){cin>>a.at(i);sum+=a.at(i);}
   for(int j=0;j<n;j++){cin>>b.at(j);sum-=b.at(j);}
   bool che = true;
   for(int i=0;i<n;i++){
      if(a.at(i)<b.at(i))che=false;
   }
   if(che){cout<<0<<endl;return 0;}
   if(sum<0){cout<<-1<<endl;return 0;}
   vector<ll>c(n);
   ll ans = 0;
   sum =0;
   for(int i=0;i<n;i++){
      c.at(i)= a.at(i)-b.at(i);
      if(c.at(i)<0){ans++;
      sum+=c.at(i);
      }
   }
   sort(c.begin(),c.end());
   reverse(c.begin(),c.end());
   for(int i=0;i<n;i++){
      if(sum>=0)break;
      ans++;
      sum+=c.at(i);
   }
   cout << ans << endl;
}
    



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)998244353

template<typename T>
struct SegTree{
    int num,bt;
    vector<T> node;

    void init(int num,T n){
        int i = 0,j=1;
        this->num = num;
        for (i = 0; j < num+1;i++)
            j*=2;
        j *= 2;
        bt = j / 2 - 1;

        node.resize((j - 1),0);
        for (int i = 0; i < num; i++){
            sett(i, n);
        }
    }
    inline T calc(T& a,T& b){
        return a + b;
    }
    void sett(int x,T n){
        int i = bt+x;
        node[i] = n;
        while(i!=0){
            i = (i - 1) / 2;
            node[i] = calc(node[i * 2 + 1],node[i * 2 + 2]);
        }
    }
    T gett(int x,int y){
        int i = bt+x;
        T sss = 0;
        if(x==0&&y==num-1){
            return node[0];
        }
        if(x!=0){
            int i = bt + x-1;
            int j = 1,l=x-1,r=x-1;
            while(i!=0){
                if(i%2&&x<=l+j&&r+j<=y){
                    sss = calc(node[i + 1],sss);
                }
                i = (i - 1) / 2;
                j *= 2;
                l = l / j*j;
                r = r / j*j+j-1;
            }
        }

        i = bt + y+1;
        int j = 1,l=y+1,r=y+1;
        while(i!=0){
            if(i%2==0&&x<=l-j&&r-j<=y){
                sss = calc(node[i - 1],sss);
            }
            i = (i - 1) / 2;
            j *= 2;
            l = l / j*j;
            r = r / j*j+j-1;
        }
        return sss;
    }
};


ll N;
vector<pll> xyv;
ll i,j,k,ans;
ll pow2[202020];
int main(){
    scanf("%lld", &N);

    fornum(i,0,N){
        ll x, y;
        scanf("%lld%lld", &x, &y);
        xyv.push_back({x, y});
    }
    pow2[0] = 1;
    fornum(i,0,N){
        pow2[i + 1] = pow2[i] * 2 % MOD;
    }
    sort(xyv.begin(), xyv.end());
    vector<pll> yiv;
    j = 0;
    fornum(i,0,N){
        if(i>0&&xyv[i].first==xyv[j].first){
            yiv.push_back({xyv[i].second, j});
        }else{
            yiv.push_back({xyv[i].second, i});
            j = i;
        }
    }
    sort(yiv.begin(), yiv.end());
    SegTree<ll> stu,std;
    vector<ll> opv(N);
    stu.init(N, 0);
    fornum (i,0,N){
        ll ii = yiv[i].second;
        stu.sett(ii, stu.gett(ii, ii) + 1);
    }

    std.init(N, 0);
    fornum(i, 0, N)
    {
        ll ii = yiv[i].second;
        stu.sett(ii, stu.gett(ii, ii) - 1);
        ll dl=0, dr=0, ul=0, ur=0;
        if(ii>0)
            dl = std.gett(0, ii-1);
        if(ii<N-1)
            dr = std.gett(ii+1, N - 1);
        if(ii>0)
            ul = stu.gett(0, ii - 1);
        if(ii<N-1)
            ur = stu.gett(ii+1, N - 1);
        ans = (ans + ((pow2[N]-1) + MOD * 4 
        - pow2[dl] * (pow2[dr]-1) % MOD 
        - pow2[dr] * (pow2[ur]-1) % MOD 
        - pow2[ur] * (pow2[ul]-1) % MOD 
        - pow2[ul] * (pow2[dl]-1) % MOD)) % MOD;
        std.sett(ii, std.gett(ii, ii) + 1);
        //printf("%lld\n", ans);
    }

    printf("%lld", ans);

    return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b, c;
    cin >> a >> b >> c;
    cout <<  c<< " " << a << " " << b<< "\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int> a(n)
#define PQ(a) priority_queue<int> a
#define PQmin(a) priority_queue<int, : vector<int>, greater<int>> a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a+b> c+d){
        cout << "Left" << endl;
    }
    else if(a+b<c+d){
        cout << "Right" << endl;

    }
    else
        cout << "Balanced" << endl;
    return 0;
}


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

int main()
{
    int n, m, i, x, cnt = 0, total = 0;
    cin>>n>>m;
    int arr[n];
    for(int y = 0; y < n; y++)
    {
        cin>>arr[y];
        total += arr[y];
    }
    double k = (double) total / (m * 4);
    for(auto y: arr)
    {
        if(y >= k)
            cnt++;
    }
    if(cnt >= m)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

int main(){
  int size, part1_end, part2_begin, offset, i;
  char str[100], rev[100];
  char str_part1[50], rev_part1[50];
  char str_part2[50], rev_part2[50];
  cin >> str;

  size = strlen(str);
  part1_end = (size-1)/2;
  part2_begin = (size+3)/2;
  
  for(i=0, offset=0; i<size; i++){
  	rev[i] = str[size-i-1];
    rev[i+1] = '\0';
    if(i<part1_end){
      str_part1[i] = str[i];
      rev_part1[i] = str[part1_end-i-1];
      str_part1[i+1] = '\0';
      rev_part1[i+1] = '\0';
    }
    else if(i>=part2_begin-1){
      str_part2[offset] = str[(part2_begin+offset)-1];
      rev_part2[offset] = str[(size-1)-offset];
      str_part2[offset+1] = '\0';
      rev_part2[offset+1] = '\0';
      offset++;
    }
  }
  /*
  cout << "size:" << size << endl;
  cout << "str:" << str << endl;
  cout << "rev:" << rev << endl;
  cout << "part1_end:" << part1_end << endl;
  cout << "str_part1:" << str_part1 << endl;
  cout << "rev_part1:" << rev_part1 << endl;
  cout << "part2_begin:" << part2_begin << endl;
  cout << "str_part2:" << str_part2 << endl;
  cout << "rev_part2:" << rev_part2 << endl;
  */
    
  if((strcmp(str, rev)==0) &&
      (strcmp(str_part1, rev_part1)==0) &&
       (strcmp(str_part2, rev_part2)==0)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int cnt[100050];

int main(){

    int n, a, q, b, c;
    cin >> n;

    long long sum = 0;
    for(int i=0;i<n;i++){
        cin >> a;
        sum+=a;
        cnt[a]++;
    }

    cin >> q;
    for(int i=0;i<q;i++){
        cin >> b >> c;
        sum+=(c-b)*cnt[b];
        cnt[c]+=cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int n,x;

int l[51],p[51];

int fun(int cn,int cx)
{
    if(cn==0)
    {
        if(cx<=0)
         return 0;
         else
          return 1;
    }
    else if(cx==1)
     return 0;
    else if(cx<=1+l[cn-1])
     return fun(cn-1,cx-1);
     else if(cx==(2+l[cn-1]))
      return p[cn-1]+1;
     else if(cx<=2+2*l[cn-1])
      return (p[cn-1]+1+fun(cn-1,cx-l[cn-1]-2));
      else
       return (2*p[cn-1]+1);
}

int32_t main()
{
    fast;
    cin>>n>>x;
    l[0]=1;
    p[0]=1;
    for(int i=1;i<51;i++)
    {
        l[i]=2*l[i-1]+3;
        p[i]=2*p[i-1]+1;
    }
    int res=fun(n,x);
    cout<<res<<"\n";
    return 0;
}

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

int main()
{
    int n,a,b;
    string s;
    cin>>n>>a>>b>>s;
    int r1=0,r2=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='a'){
            r1++;
            if(r1<=a+b) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }else if(s[i]=='b'){
            r1++;r2++;
            if(r1<=a+b && r2<=b) cout<<"Yes"<<endl;
            else {
                cout<<"No"<<endl;
                r1--;r2--;
            }
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c;
    fp((a <= c)&&(b >= c));
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int mp[105][105],a[105*105],h,w,n;
int main(){
	scanf("%d%d", &h, &w); int tail = 1;
	scanf("%d", &n);
	for( int i = 1; i <= n; i++ ) scanf("%d", &a[i]);
	for( int i = 1; i <= h; i++ ){
		if( i & 1 ){
			for( int j = 1; j <= w; j++ ){
				while( !a[tail] ) tail++;
				mp[i][j] = tail; a[tail]--;
			}
		}
		else{
			for( int j = w; j >= 1; j-- ){
				while( !a[tail] ) tail++;
				mp[i][j] = tail; a[tail]--;
			}
		}
	}
	for( int i = 1; i <= h; i++ ){
		for( int j = 1; j <= w; j++ )
			printf("%d ", mp[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{

    long long x,y;
    scanf("%lld%lld",&x,&y);
    long long a[100];
    a[0]=x+y;
    a[1]=x-y;
    a[2]=x*y;
    int n=3;
    for(int i=0; i<n-1; i++)
    {
        for(int j=0; j<n-i-1; j++)
        {
            if(a[j]>a[j+1])
            {
                int temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    printf("%lld\n",a[2]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
  int h, w, i, j, k;
  scanf("%d%d", &h, &w);
  char s[h][w + 10];
  for(i = 0; i < h; ++i) scanf("%s", s[i]);
  for(i = 0; i < h; ++i) {
    bool b = true;
    for(j = 0; j < w; ++j) if(s[i][j] == '#') b = false;
    if(b) {
      h--;
      for(j = i; j < h; ++j) for(k = 0; k < w; ++k) s[j][k] = s[j + 1][k];
      i--;
    }
  }
  for(i = 0; i < w; ++i) {
    bool b = true;
    for(j = 0; j < h; ++j) if(s[j][i] == '#') b = false;
    if(b) {
      w--;
      for(j = i; j < w; ++j) for(k = 0; k < h; ++k) s[k][j] = s[k][j + 1];
      i--;
    }
  }
  for(i = 0; i < h; ++i) {
    for(j = 0; j < w; ++j) printf("%c", s[i][j]);
    printf("\n");
  }
  return 0;
}

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

int main(){
    string s;cin>>s;
    vector<int> dna(1,0);
    string n;
    rep(i,s.size()){
        if(s[i]=='A')dna.back()++;
        else if(s[i]=='C')dna.back()++;
        else if(s[i]=='G')dna.back()++;
        else if(s[i]=='T')dna.back()++;
        else dna.push_back(0);
    }
    sort(dna.rbegin(), dna.rend());
    cout << dna[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#define writ(x,c) write(x),putchar(c);
typedef long long ll;
using namespace std;
inline int read()
{
    char c;int x=0;bool f=0;
    for(;!isdigit(c);c=getchar()) if(c=='-') f=1;
    for(;isdigit(c);c=getchar()) x=(x<<1)+(x<<3)+(c^48);
    return (f ? -x : x);
}
#define int ll
const int N=4e4+5,p=1e9+7,H=2001;
ll fac[N],inv[N];
ll ksm(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%p;
		a=a*a%p,b>>=1;
	}
	return res;
}
ll C(int x,int y){return fac[x]*inv[y]%p*inv[x-y]%p;}
int n,a[2000001],b[2000001],c[4005][4005];
#undef int
int main()
{
#define int ll
	fac[0]=1;
	for(int i=1;i<=N-10;++i) fac[i]=fac[i-1]*i%p;
	inv[N-10]=ksm(fac[N-10],p-2);
	for(int i=N-11;i>=0;--i) inv[i]=inv[i+1]*(i+1)%p;
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),b[i]=read(),c[H-a[i]][H-b[i]]++;
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			c[i][j]=(c[i][j]+c[i-1][j])%p,c[i][j]=(c[i][j]+c[i][j-1])%p;
	ll ans=0;
	for(int i=1;i<=n;i++) ans=(ans+c[H+a[i]][H+b[i]])%p;
	for(int i=1;i<=n;i++) ans=(ans-C((a[i]+b[i])<<1,a[i]+a[i])+p)%p;
	printf("%lld\n",ans*ksm(2,p-2)%p);
	return 0;
}

Measured memory_bytes: 131968
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
int cnt[2][105];
int h, w;
bool flag[110][110];

int main() {
	int n;
	cin >> n;
	vector<double>a(n);
	double total = 0;
	rep(i, n) {
		cin >> a[i];
		total += a[i];
	}
	total /= n;
	int res = round(total);
	int ans = 0;
	rep(i, n) {
		ans += (a[i] - res) * (a[i] - res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
N = int(input())
L =[0]+ list(map(int,input().split()))+[0]
dis = 0
for i in range(N+1):
    dis += abs(L[i] - L[i+1])
#print(L,dis)
for i in range(1,N+1):
    print(dis + abs(L[i-1]-L[i+1]) - abs(L[i-1]-L[i]) - abs(L[i]-L[i+1]))




Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int H,W;
bool used[55][55];
bool black[55][55];
bool white[55][55];
string board[55];
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
bool outrange(int y,int x,int turn)
{
  if(y<0 || y>=H || x<0 || x>=W || used[y][x])
    {
      return true;
    }
  if(turn==0 && board[y][x]=='W') return true;
  else if(turn==1 && board[y][x]=='B') return true;
  else return false;
}
void bfs(int y,int x,int turn)
{
  used[y][x]=true;
  if(turn==0) black[y][x]=true;
  if(turn==1) white[y][x]=true;
  for(int k=0;k<4;k++)
    {
      int ny=y+dy[k];
      int nx=x+dx[k];
      if(!outrange(ny,nx,turn))
	{
	  bfs(ny,nx,turn);
	}
    }
}

int main(void)
{
  while(cin >> W >> H&& W)
    {
      int bnum=0;
      int wnum=0;
      memset(used,false,sizeof(used));
      memset(black,false,sizeof(black));
      memset(white,false,sizeof(white));
      for(int i=0;i<H;i++)
	{
	  cin >> board[i];
	}
      for(int i=0;i<H;i++)
	{
	  for(int j=0;j<W;j++)
	    {
	      if(board[i][j]=='B' && !used[i][j]) bfs(i,j,0);
	    }
	}
      memset(used,false,sizeof(used));
      for(int i=0;i<H;i++)
	{
	  for(int j=0;j<W;j++)
	    {
	      if(board[i][j]=='W' && !used[i][j]) bfs(i,j,1);
	    }
	}
      for(int i=0;i<H;i++)
	{
	  for(int j=0;j<W;j++)
	    {
	      if(board[i][j]=='.' &&black[i][j]&&!white[i][j]) bnum++;
	      if(board[i][j]=='.' && white[i][j]&&!black[i][j]) wnum++;
	    }
	}
      cout << bnum << ' ' << wnum << endl;
    }
  return 0;
}



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

typedef long long ll;

int main(){
    string s;
    cin >> s;
    int size = s.size();
    int e(0),ans(0);
    for(int i=0;i<size;i++){
        char c(s[i]);
        if(c!='A'&&c!='C'&&c!='G'&&c!='T'){
            ans = max(e,ans);
            e = 0;
        }else{
            e++;
        }
    }
    ans = max(ans,e);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3604
#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>;

int main(){
   int k;
   cin >> k;
   int x = 7%k;
   for(int i=1;i<=k;i++){
      if(x == 0){
         cout << i << endl;
         return 0;
      }else{
         x = (x*10+7)%k;
      }
   }
   cout << -1 << endl;
   return 0;  
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    } else {
        return d < 0 ? -1 : 1;
    }
}

struct Vector {
    double x, y;

    Vector(double x = 0, double y = 0) : x(x), y(y) {
    }
    
    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double length(const Vector& a) {
    return sqrt(dot(a, a));
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

double ccw(const Point& a, const Point& b, const Point& c) {
    return cross(b - a, c - a);
}

double diameter(vector<Point> s) {
    vector<Point> p = s;
    int n = p.size();
    if (n == 2) {
        return length(p[0] - p[1]);
    }
    int i = 0, j = 0;
    
    for (int k = 0; k < n; k++) {
        if (p[i] < p[k]) {
            i = k;
        }
        if (!(p[j] < p[k])) {
            j = k;
        }
    }
    //cout<<i<<" "<<j<<endl;
    double res = 0;
    
    int si = i, sj = j;
    
    while (i != sj || j != si) {
        //cout<<i<<" "<<j<<endl;
        res = max(res, length(p[i] - p[j]));
        if (dcmp(cross(p[(i + 1) % n] - p[i], p[(j + 1) % n] - p[j])) < 0) {
            i = (i + 1) % n;
        } else {
            j = (j + 1) % n;
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
 
    cout << fixed << setprecision(8) << diameter(p) << endl;

    return 0;
}

Measured memory_bytes: 6540
import math

if __name__ == '__main__':
    n, d = map(int, input().split())
    l = []
    for i in range(0, n):
        l.append(list(map(int, input().split())))
    count = 0
    for i in range(0, n):
        for j in range(i + 1, n):
            s = 0
            for k in range(0, d):
                s += math.pow(l[i][k] - l[j][k], 2)
            if math.sqrt(s).is_integer():
                count += 1
    print(count)


Measured memory_bytes: 3064
a,b,c = input()
A = 0
if a == "o":
  A += 1
if b == "o":
  A += 1
if c == "o":
  A += 1
 
if A == 3:
  print(1000)
if A == 2:
  print(900)
if A == 1:
  print(800)
if A == 0:
  print(700)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		sc.close();
		String a [] = new String [3];
		a[0] = N.substring(0,1);
		a[1] = N.substring(1,2);
		a[2] = N.substring(2,3);

		for(int i = 0; i < 3; i++) {
			if(a[i].equals("1")) {
				a[i] = "9";
			}else if(a[i].equals("9")) {
				a[i] = "1";
			}
		}

		System.out.println(a[0]+a[1]+a[2]);

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char** argv){
	string s;
	cin >> s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, a, b)    for (int i(a); i <= (b); ++i)
#define dec(i, a, b)    for (int i(a); i >= (b); --i)
#define MP      make_pair
#define fi      first
#define se      second
 
 
typedef long long LL;
 
const int N = 1e3 + 5;
 
int a[N], b[N];
int n, m, c, fg;
char s[45];
 
 
int main(){
 
    scanf("%d", &n);
    c = 0;
 
    rep(i, 1, n){
        scanf("%d%d", a + i, b + i);
        if ((a[i] + b[i]) & 1) ++c;
        else --c;
    }
 
    if (abs(c) != n) return 0 * puts("-1");
 
    m = 31 + (c < 0);
 
    printf("%d\n", m);
    rep(i, 0, 30) printf("%d ", 1 << i);
    if (c < 0) putchar(49);
    putchar(10);
 
    rep(i, 1, n){
        int x = a[i], y = b[i];
        if (c < 0) s[31] = 'R', --x;
        fg = 0;
        dec(j, 30, 0){
            if (abs(x) < abs(y)) swap(x, y), fg ^= 1;
            if (x > 0) x -= 1 << j, s[j] = fg ? 'U' : 'R';
            else x += 1 << j, s[j] = fg ? 'D' : 'L';
        }
 
        puts(s);
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <math.h>
#include <algorithm>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

bool solve(ll x, ll y, ll n){
    ll sq = -3*(x*x)-2*x*y+4*n-3*(y*y);
    if(sq < 0) return 0;
    ll temp = sq;
    sq = sqrt(sq);
    if(sq * sq != temp) return 0;
    ll sol1 = (-y-x+(ll)sq)/2;
    ll sol2 = (-y-x-(ll)sq)/2;
    if(sol1 > 0 || sol2 > 0){
        return true;
    }else{
        return false;
    }
}

int main(){ ll n;
    cin >> n;
    for (ll i=1; i<=n; i++){
        ll ans = 0;
        for (ll j=1; j<=sqrt(i); j++){
            for (ll k=1; k<=sqrt(i); k++){
                if (solve(j, k, i)) {
                    ++ans;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3556
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var t = int.Parse(line[1]);
        var r = new int[t+1];
        for (int i = 0; i < n; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var a0 = int.Parse(line2[0]);
            var a1 = int.Parse(line2[1]);
            r[a0]++;     r[a1 ]--;
        }
        var r2 = new int[t + 1];
        for (int i = 0; i < t; i++) r2[i + 1] = r2[i] + r[i];
        Console.WriteLine(r2.Max());
    }
}

Measured memory_bytes: 10580
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s;
int k;
set <string> st;

int main() { 

  getline(cin, s);
  cin >> k;

  for (int i = 0; i < sz(s); i++) {
    for (int j = i; j < min(i + 5, sz(s)); j++) {
      string cur = s.substr(i, j - i + 1);
      st.insert(cur);
      if (sz(st) > k) {
        st.erase(*st.rbegin());
      }
    }
  }

  cout << *st.rbegin() << endl;

  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;
template< typename T > using Vec = vector< T >;

struct Edge {int to, c; };

Vec< bool > checkVisible(int N, Vec< Vec< int > >& rev) {
	queue< int > que;
	que.push(N-1);
	
	Vec< bool > vis(N, false);
	vis[N-1] = true;
	
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (int u : rev[v]) {
			if (vis[u]) continue;
			que.push(u);
			vis[u] = true;
		}
	}
	
	return vis;
}

void solve(int N, Vec< Vec< Edge > >& edges, Vec< Vec< int > >& rev) {
	Vec< bool > vis = checkVisible(N, rev);
	Vec< lint > cst(N, -(1LL << 60));
	cst[0] = 0;
	
	bool inf = false;
	for_(rep,0,N+1) {
		for_(v,0,N) if (vis[v]) for (Edge& e : edges[v]) {
			if (vis[e.to] && cst[e.to] < cst[v] + e.c) {
				cst[e.to] = cst[v] + e.c;
				if (rep == N) inf = true;
			}
		}
	}
	
	if (inf) puts("inf");
	else cout << cst[N-1] << endl;
}

int main() {
	int N, M;
	cin >> N >> M;
	
	Vec< Vec< Edge > > edges(N);
	Vec< Vec< int > > rev(N);
	
	for_(i,0,M) {
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		edges[a].push_back(Edge{b, c});
		rev[b].push_back(a);
	}
	
	solve(N, edges, rev);
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void){
	int value = 700;
	string s;
	cin >> s;
	if (s[0] == 'o')value += 100;
	if (s[1] == 'o')value += 100;
	if (s[2] == 'o')value += 100;
	cout << value;
	return 0;
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using M = array<array<int , 8>, 8>;

void bom(M &m, int x, int y) {
	static int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
	m[y][x] = 0;
	for (int i = 1; i <= 3; i++)
		for (int j = 0; j < 4; j++) {
			int tx = x + dx[j] * i, ty = y + dy[j] * i;
			if (tx >= 0 && tx < 8 && ty >= 0 && ty < 8 && m[ty][tx])
				bom(m, tx, ty);
		}
}

int main() {
	M m;
	int n = in();
	for (int k = 1; k <= n; k++) {
		gcu();
		for (auto &i: m) {
			for (int &j: i)
				j = gcu() - '0';
			gcu();
		}
		int x = in() - 1, y = in() - 1;
		if (m[y][x])
			bom(m, x, y);
		outl("Data ", k ,":");
		for (auto i: m) {
			for (int j: i)
				out(j);
			outl();
		}
	}
}


Measured memory_bytes: 2456
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

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

Measured memory_bytes: 3508
class SegmentTree:
    def __init__(self, size, op, e):
        self._op = op
        self._e = e
        self._size = size
        t = 1
        while t < size:
            t *= 2
        self._offset = t - 1
        self._data = [e] * (t * 2 - 1)

    def __getitem__(self, key):
        return self._data[self._offset + key]

    def __setitem__(self, key, value):
        op = self._op
        data = self._data
        i = self._offset + key
        data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            data[i] = op(data[i * 2 + 1], data[i * 2 + 2])

    def build(self, iterable):
        op = self._op
        data = self._data
        data[self._offset:self._offset + self._size] = iterable
        for i in range(self._offset - 1, -1, -1):
            data[i] = op(data[i * 2 + 1], data[i * 2 + 2])

    def query(self, start, stop):
        def iter_segments(data, l, r):
            while l < r:
                if l & 1 == 0:
                    yield data[l]
                if r & 1 == 0:
                    yield data[r - 1]
                l = l // 2
                r = (r - 1) // 2
        op = self._op
        it = iter_segments(self._data, start + self._offset,
                           stop + self._offset)
        result = self._e
        for v in it:
            result = op(result, v)
        return result


max_A = 300000

N, K, *A = map(int, open(0).read().split())

st = SegmentTree(max_A + 1, max, 0)
for a in A:
    st[a] = st.query(max(a - K, 0), min(a + K + 1, max_A + 1)) + 1

print(st.query(0, max_A + 1))


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

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

    int i = 0;
    while(a > 0 && c > 0)
    {
        if(i++ % 2 == 0) c -= b;
        else a -= d;
    }

    cout << (c <= 0 ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 3596