akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M],br[M],k;
vector<pi> adj;

bool check(ll m)
{
	ll h = k;
	for(auto v:adj)
	{
		ll g = m/v.ss;
		if(v.ff<=g)
			continue;
		else
			h -= v.ff-g;
		if(h < 0)
			return 0;
	}
	return 1;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	ll n,i,m = 0,l,r;
	
	cin >> n >> k;

	for(i=1;i<=n;++i)
		cin >> ar[i];

	sort(ar+1,ar+n+1);

	for(i=1;i<=n;++i)
		cin >> br[i];

	sort(br+1,br+1+n);

	for(i=1;i<=n;++i)
		adj.pb(pi(ar[i],br[n-i+1]));

	l = 0;
	r = 1e12;
	while(l<=r)
	{
		m = (l+r)/2;
		if(check(m) && (m == 0 || check(m-1) == 0))
			break;
		else if(check(m))
			r = m-1;
		else
			l = m+1;
	}

	cout << m << "\n";
	return 0;
}

	

Measured memory_bytes: 10096
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t X, sum = 0;
    cin >> X;
    for (int64_t i = 1; ; i++){
        sum += i;
        if (sum >= X) {
            cout << i << endl;
            return 0;
        }
    }
}

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

int main()
{
    int a, b, c;

    cin >> a>> b >> c;
    int sum = 0;
    sum = b + c;
   
    int total = sum - a;
    if(total >= 0)
    {
        cout << total << endl;
    }
    else{
        cout << 0 << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,c=0;
    char s[5];
    scanf("%s",s);
    for(i=0;i<3;i++)
        if(s[i]==s[i+1])
        c++;
    if(c)
        printf("Bad\n");
    else
        printf("Good\n");
    return 0;
}


Measured memory_bytes: 128
#coding:utf-8
n = int(input())
if (n%2==1):
    print (0)
    exit()
n//=2
ls_p = []
p = 5
while(p<10e+18):
    ls_p.append(p)
    p*=5
#print (ls_p)
print (sum([n//p for p in ls_p]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

//区間の最小値をインデックス付きで求めてくれるセグメント木
struct Segtree{
    int n;
    vector<P> dat;
    Segtree(){}
    Segtree(int _n){
        n = 1;
        while(n < _n) n *= 2;
        dat.clear();
        rep(i, 0, 2 * n){
            dat. push_back(P(INF, -1));
        }
    }
    void update(int k, int a){
        dat[k + n - 1].first = a;
        dat[k + n - 1].second = k;
        k += n - 1;        
        while(k > 0){
            k = (k - 1) / 2;
            int l = 2 * k + 1, r = 2 * k + 2;
            int MIN = INF, id = -1; 
            if(dat[l].first > dat[r].first){
                MIN = dat[r].first; id = dat[r].second;
            }else{
                MIN = dat[l].first; id = dat[l].second;
            }
            dat[k].first = MIN; dat[k].second = id;
        }
    }
    // max[a, b)
    P query(int a, int b){
        return query(a, b, 0, 0, n);
    }
    P query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return P(INF, -1);
        if(a <= l && r <= b) return dat[k];
        else{
            int mid = (l + r) / 2;
            P vl = query(a, b, 2 * k + 1, l, mid);
            P vr = query(a, b,  2 * k + 2, mid, r);
            return (vl.first > vr.first ? vr : vl);
        }
    }
};

struct S{
    int MIN, left, right;//[left, right)
    bool operator>(const S &s) const{
        return MIN > s.MIN;
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n);
    map<int, int> mp;
    vector<Segtree> seg(2, Segtree(n));
    rep(i, 0, n){
        cin >> p[i]; p[i]--;
        mp[p[i]] = i;
        // if(i % 2 == 0){
            seg[i % 2].update(i, p[i]);
            seg[!(i % 2)].update(i, INF);
        // }else{
            // odd.update(i, p[i]);
            // even.update(i, INF);
        // }
    }
    priority_queue<S, vector<S>, greater<S> > q;
    q.push(S{seg[0].query(0, n).first, 0, n});
    vector<int> ans;
    while(!q.empty()){
        S s = q.top(); q.pop();
        if(s.MIN == INF) continue;
        // cout << s.MIN << " " << s.left << " " << s.right << ' ';
        int idx = seg[s.left % 2].query(s.left, s.right).second;
        int idx2 = seg[!(s.left % 2)].query(idx + 1, s.right).second;
        int MIN2 = seg[!(s.left % 2)].query(idx + 1, s.right).first;
        ans.push_back(s.MIN);
        ans.push_back(MIN2);
        // cout << s.MIN << ' ' << MIN2 << endl;
        q.push(S{seg[s.left % 2].query(s.left, idx).first, s.left, idx});
        q.push(S{seg[(idx + 1) % 2].query(idx + 1, idx2).first, idx + 1, idx2});
        q.push(S{seg[(idx2 + 1) % 2].query(idx2 + 1, s.right).first, idx2 + 1, s.right});
    }
    for(int ii = 0; ii < ans.size(); ii++){
        if(ii) cout << ' ';
        cout << ans[ii] + 1;
    }
    cout << endl;
}

Measured memory_bytes: 44260
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define ll long long
#define vi vector<ll>
#define ss second
#define ff first
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
#define w(x) int x; cin>>x; while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define fo(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define re(i, j) fo(i, 0, j, 1)
#define pi 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define lo lower_bound
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define z 1000000000000000000
using namespace std;
ll ab(ll a,ll b)
{
    if(a>b)
    return a-b;
return b-a;
}
ll factor(ll n)
{
    ll ans=0;
    for(ll j=1;j*j<=n;j++)
    {
        if(n%j==0)
        {
            if(j*j==n)
            ans++;
            else
            {
                ans+=2;
            }
        }
    }
    return ans;
}
ll power(ll x, ll y,ll p)  
{  
    int res = 1;
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0)  
    {   
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
ll pow(ll x,ll y) 
{ 
    int res = 1; 
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1; 
        x = x*x;   
    } 
    return res; 
}
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout); 
  
#endif
}
vector<ll> get_prime_factors_less_than(ll n){
    vector<ll> factor;
    vector<ll> prime(n,1);
    prime[0]=0,prime[1]=0;
    for(ll i = 2 ; i <= n ; i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
ll digit(ll n)
{
    ll q=0;
    while(n>0)
    {
        q++;
        n/=10;
    }
    return q; 
}
ll sq(ll n)
{
    return n*n;
}
ll NR(ll n, ll r) 
{ 
    long long p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
  
            // gcd of p, k 
            long long m = __gcd(p, k); 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
    } 
  
    else
        p = 1; 
  
    // if our approach is correct p = ans and k =1 
    return p ;
}
int main() 
{
    cp();
    long double n,m;
    cin>>n>>m;
    long double w=n*m;
    ll q=w;
    cout<<q<<endl; 
    return 0;
}

Measured memory_bytes: 3756
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k, a[200009];
long long pre[200009], ans;
map<int, int> mp;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		pre[i] = a[i];
		pre[i] += pre[i - 1];
	}
	mp[0]++;
	for (int j = 1; j <= n; j++) {
		int tmp = j - k;
		if (tmp >= 0) {
			mp[(pre[tmp] - tmp) % k]--;
		}
		ans += mp[(pre[j] - j) % k];
		mp[(pre[j] - j) % k]++;
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0;i < s.size();++i) {
		int now = 0;
		for (int j = i;j < s.size();++j) {
			bool ok = false;
			if (s[j] != 'A' && s[j] != 'G' && s[j] != 'C' && s[j] != 'T')ok = true;
			if (ok)break;
			else {
				now++;
				ans = max(ans, now);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define N 100000
using namespace std;

int main(){
  vector<int> num;
  rep(i, 0, 3){
    int n;
    cin >> n;
    num.push_back(n);
  }
  sort(all(num));
  cout << (num[2]*10+num[1] + num[0]) << endl;
  return 0;
}


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

using namespace std;

int main () {
    int n;
    int a[200];

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    int cnt = 0;
    while (true) {
        
        bool flag = false;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 != 0) {
                flag = true;
                break;
            }
        }

        if (flag) break;

        for (int i = 0; i < n; i++) {
            a[i] /= 2;
        }
        cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const int MAX = 1100000;
vector<long long> cnt; // cnt[n] := n! が 2 で何回割れるか
void pre() {
    cnt.assign(MAX, 0);
    for (int i = 1; i < MAX; ++i) {
        int j = i;
        int add = 0;
        while (j % 2 == 0) ++add, j /= 2;
        cnt[i] = cnt[i-1] + add;
    }
}

int solve(const string &S) {
    pre();
    vector<int> a;
    for (int i = 0; i + 1 < S.size(); ++i) {
        int x = S[i] - '0';
        int y = S[i+1] - '0';
        a.push_back(abs(x - y));
    }
    long long parity = 0;
    for (int i = 0; i < a.size(); ++i) {
        long long ex = cnt[a.size()-1] - cnt[i] - cnt[a.size()-i-1];
        if (ex > 0) continue;
        parity += a[i];
    }

    if (parity & 1) return 1;
    else {
        bool exist_one = false;
        for (int i = 0; i < a.size(); ++i) if (a[i] == 1) exist_one = true;
        if (exist_one) return 0;
        else {
            parity = 0;
            for (int i = 0; i < a.size(); ++i) {
                long long ex = cnt[a.size()-1] - cnt[i] - cnt[a.size()-i-1];
                if (ex > 0) continue;
                parity += a[i] / 2;
            }
            if (parity & 1) return 2;
            else return 0;
        }
    }
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    cout << solve(S) << endl;
}

















Measured memory_bytes: 16252
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e,k;
    cin >>a>>b>>c>>d>>e>>k;
    if(e-a>k){
        cout <<":("<<endl;
    }
    else{
        cout <<"Yay!"<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>
using namespace std;

long long int N = 1000000007;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = 0;

  for(int i=0;i<101;i++){
    if(a <= i && i < b)
      if(c <= i && i < d)
        ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

int n;
ll a[300][300];
bool need[300][300];

int main(){
    cin >> n;
    REP(i, n){
        REP(j, n){
            cin >> a[i][j];
        }
    }

    REP(i, n) REP(j, n) need[i][j] = true;

    bool flag = true;
    REP(k, n){
        REP(i, n){
            REP(j, n){
                if(i==k || j==k) continue;
                if(a[i][j] > a[i][k] + a[k][j]){
                    flag = false; break;
                }
                if(a[i][j] == a[i][k] + a[k][j]){
                    need[i][j] = false;
                }
            }
            if(!flag) break;
        }
        if(!flag) break;
    }

    if(!flag){
        cout << -1 << endl;
    } else {
        ll output = 0;
        REP(i, n){
            for(int j=0; j<i; j++){
                if(need[i][j]) output += a[i][j];
            }
        }
        cout << output << endl;
    }

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V){os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P){return os << "(" << P.first << "," << P.second << ")";}
#ifndef ONLINE_JUDGE
#define TRACE
#endif

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){ cout << name << " : " << arg1 << endl; }
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...) 1
#endif
#define mp make_pair
#define pb push_back
#define endl '\n'
#define F first
#define S second
#define I insert
typedef long double ld;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
const int N = 1e5+5;
int h[N], dp[N];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout<<setprecision(25);
    int n; cin>>n;
    for(int i=0;i<n;i++) cin>>h[i];
	dp[1] = abs(h[1]-h[0]);
	for(int i=2;i<n;i++) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n-1];
}

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


const ll MAX = 200000+1;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    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;
    }
}

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


// aのn乗のMOD
ll modpow(ll a,ll n){
    ll res = 1;
    while(n>0){
        // &１つはビット積
        if(n&1) res = res * a%MOD;
        a = a*a%MOD;
        n>>=1;
    }
    return res;
}

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

    COMinit();
	ll n,a,b;
	cin>>n>>a>>b;
    ll c_a=1,c_b=1;
    rep(i,a){
        c_a*=(n-i);
        c_a%=MOD;
        c_a*=inv[i+1];
        c_a%=MOD;
    }
    rep(i,b){
        c_b*=(n-i);
        c_b%=MOD;
        c_b*=inv[i+1];
        c_b%=MOD;
    }
    ll ans = modpow(2,n)-1;
    if(ans<0) ans+=MOD;
    ans -= c_a;
    if(ans<0) ans+=MOD;
    ans -= c_b;
    if(ans<0) ans+=MOD;
    cout<<ans<<"\n";
	
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll S, W;
    cin >> S >> W;
    if(W >= S) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int k;
  cin >> k;
  int ans = 0;
  reps(a, k) reps(b, k) reps(c, k) {
    ans += gcd(gcd(a, b), c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;
void insert(int);

void inorder (Node);
void preorder (Node);
int search(Node,int);


int main(){

  int n,num,i;
  char command[10];

  scanf("%d",&n);

  root = NULL;
  for(i = 0 ; i < n ; i++){

    scanf("%s",command);

    if(command[0] == 'i'){//insert
      scanf("%d",&num);
      insert(num);
    }

    else if(command[0] == 'p'){//print
      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");
    }
    else if(command[0] == 'f'){//find
      scanf("%d",&num);

      Node test = search(root,num);
      if(test != NULL)printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}


void insert( int z){

  Node y = NULL;
  Node x = root;
  Node k;

  k = malloc(sizeof(struct node));

  k -> key = z;
  k -> left = NULL;
  k -> right = NULL;


  while(x != NULL){
    y = x;
    if(k -> key < x->key){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
    k->parent = y;
    if(y == NULL)root = k;
    else if(k->key < y->key)y->left = k;
    else y->right = k;
}


void inorder (Node o){
  if(o->left != NULL)inorder(o->left);
  printf(" %d",o->key);

  if(o->right != NULL)inorder(o->right);
}




void preorder(Node o){
  printf(" %d",o->key);

  if(o->left != NULL)preorder(o->left);
  if(o->right != NULL)preorder(o->right);
}


int search (Node u,int k){
  if(u == NULL || k ==  u->key)return u;
  if(k < u->key)return search(u->left,k);
  else return search(u->right,k);
}

Measured memory_bytes: 19364
#include<iostream>
using namespace std;
long long a,b,c=0,d,e[1000001],f[1000001];
int main(){
	cin>>a;
	b=a;
	while(b>0){
		c+=b%10;
		b/=10;
	}
	if(c==1){
		cout<<10<<endl;
	}
	else{
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
def bub(x,l):
  if x == n:
    return [tuple(l)]
  ret = list()
  for i in range(1,n+1):
    if i not in l:
      ret += bub(x+1,l+[i])
  return ret
a = bub(0,list())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
print(abs(a.index(p) - a.index(q)))


Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll mo = 1000000007;
auto mod = [](ll modx) {modx%=mo;modx+=mo;modx%=mo;return modx; };
vector<ll> factorial(ll n)
{
  vector<ll> fac;
  fac.push_back(1);
  for (ll i = 1; i < n + 10; i++)
  {
    fac.push_back((fac[i - 1] * i) % mo);
  }
  return fac;
}
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
vector<ll> fac = factorial(100000);
ll sum=fac[n-1];
rep(i,n-1){
  ans=mod(ans+(a[i+1]-a[i])*sum);
  sum=mod(sum+fac[n-1]*mypow(i+2,mo-2));
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 2168
w, h, n = map(int, input().split())
field = [[0 for _ in range(w)] for _ in range(h)]
for i in range(n):
    x, y, a = map(int, input().split())
    for j in range(w):
        for k in range(h):
            if a == 1:
                if j < x:
                   field[k][j] = 1
            elif a == 2:
                if j >= x:
                    field[k][j] = 1
            elif a == 3:
                if k < y:
                    field[k][j] = 1
            elif a == 4:
                if k >= y:
                    field[k][j] = 1
cnt = 0
for i in range(h):
    cnt += sum(field[i])
print(w * h - cnt)


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

        int a = sc.nextInt(); //red
        int b = sc.nextInt(); //green
        int c = sc.nextInt(); //blue
        int k = sc.nextInt();

        for (int i = 0; i < k; i++) {

            if (b <= a) {
                b = b * 2;
            } else if (c <= b) {
                c = c * 2;
            }

        }

        String result = "No";
        if (b > a && c > b) {
            result = "Yes";
        }

        System.out.println(result);      

	}
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

const long long MOD = 1000000007;
const int MAX_N = 2000, MAX_A = 2000;
ll n,k;
int a[MAX_N];
int cnt[MAX_A+1];
ll c[MAX_N];
ll inv2;

long long mod_pow(long long a, long long b)
{
  if (b == 0) return 1;
  long long ret = mod_pow(a, b/2);
  ret = ret * ret % MOD;
  if (b % 2 == 1) ret = a * ret % MOD;
  return ret;
}


int main()
{
  inv2 = mod_pow(2,MOD-2);
  cin >> n >> k;
  forn(i,n) cin >> a[i];

  ll res = 0;
  forn(i,n) {
    for (int j = i+1; j < n; j++) {
      if (a[i] > a[j]) res++;
    }
  }

  res = (res * k) % MOD;

  forn(i,n) {
    forn(j,n) {
      if (a[i] > a[j]) cnt[i]++;
    }
  }

  forn(i,n) {
    res = (res + cnt[i]*k%MOD*(k-1)%MOD*inv2%MOD) % MOD;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String s = in.next(), t = in.next();
            if (s.length() + 1 == t.length()) {
                t = t.substring(0, t.length() - 1);
                out.println(t.equals(s) ? "Yes" : "No");
            } else out.println("No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32472
import sys
import numpy as np

import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    A = []
    input_raw = read_func().strip().split()
    for i in range(N):
        A.append(int(input_raw[i]))

    A.sort(reverse = True)
    sum_A = [0 for i in range(N)]
    for i in range(N-1, -1, -1):
        if i == N - 1:
            sum_A[i] = A[i]
        else:
            sum_A[i] = A[i] + sum_A[i + 1]


    count = 1
    for i in range(1, N):
        if 2* sum_A[i] >= A[i - 1]:
            count += 1
        else:
            break;

    print count

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	
	long long x, y, mn=2;
	cin>>x>>y;
	if (x%y==0) cout<<-1;
	else {
		for (int i=x; ;) {
			if (i%y!=0) {
				cout<<i;
				break;
			}
			i=x;
			i*=mn;
			mn++;
		}
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL int
#define int long long
inline LL read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	LL k=0,kk=1;if (c=='-')c=getchar(),kk=-1;
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(LL x){if (x<0)x=-x,putchar('-');if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(LL x){write(x);puts("");}
int a,b,c,aa,aaa,aaaa,bb,bbb,bbbb,cc,ccc,cccc,ans;
signed main(){
	a=read();b=read();c=read();ans=1e9;
	for (int i=-100;i<=100;i++){
		aa=max((i-a+1)/2,0ll);aaa=a+aa*2;aaaa=aaa-i;
		bb=max((i-b+1)/2,0ll);bbb=b+bb*2;bbbb=bbb-i;
		cc=max((i-c+1)/2,0ll);ccc=c+cc*2;cccc=ccc-i;
		ans=min(ans,aa+aaaa+bb+bbbb+cc+cccc);
	}writeln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

struct UnionFind {
    vl par;
    vl rank;
    
    UnionFind(ll n = 1) {
        init(n);
    }
    
    void init(ll n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 1;
    }
    
    int root(ll x) {
        if (par[x] == x) {
            return x;
        }
        else {
            ll r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }
    
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        par[y] = x;
        rank[x] += rank[y];
        return true;
    }

    int getRank(ll i) {
        i = root(i);
        return rank[i];
    }
};

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m;
    cin>>n>>m;
    vector<LP> ab(m);
    cin>>ab;
    rep(i, m) {
        ab[i].fi--;
        ab[i].se--;
    }

    vl ans(m + 1);
    ans.back() = n * (n - 1);
    UnionFind ds(n);
    for (int i = m - 1; i >= 0; --i) {
        if (!ds.issame(ab[i].fi, ab[i].se)) {
            ll r1 = ds.getRank(ab[i].fi);
            ll r2 = ds.getRank(ab[i].se);
            ds.merge(ab[i].fi, ab[i].se);
            ans[i] = ans[i + 1] - 2 * r1 * r2;
        }
        else ans[i] = ans[i + 1];
    }
    rep(i, m) {
        cout<<ans[i + 1] / 2<<endl;
    }
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N, C, K;
    cin >> N >> C >> K;
    vector<ll> T(N);
    rep(i,N)cin >> T[i];
    sort(all(T));
    int r = 0;
    int ans = 0;
    for(int l = 0; l < N;){
        while(r < N && r - l + 1 <= C && T[r] <= T[l] + K){
            r++;
        }
        //cerr << l << " " << r << endl;
        l = r;
        ans++;
    }
    cout << ans << endl;
}

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

const int MAX_N=100;

bool dp[MAX_N][MAX_N][MAX_N*MAX_N];
int a[MAX_N][MAX_N],b[MAX_N][MAX_N],N,M;

bool check(int val){
	if(0<=val&&val<MAX_N*MAX_N) return true;
	return false;
}

int main(){
	cin>>N>>M;
	for(int i=0;i<N;i++) for(int j=0;j<M;j++) cin>>a[i][j];
	for(int i=0;i<N;i++) for(int j=0;j<M;j++) cin>>b[i][j];
	dp[0][0][abs(a[0][0]-b[0][0])]=1;
	for(int i=0;i<N;i++) for(int j=0;j<M;j++) if(i!=N-1||j!=M-1){
		for(int k=0;k<MAX_N*MAX_N;k++) if(dp[i][j][k]){
			int x,y,val;
			if(i+1<N){
				x=i+1; y=j; 
				val=abs(k+abs(a[x][y]-b[x][y]));
				if(check(val)) dp[x][y][val]=1;
				val=abs(k-abs(a[x][y]-b[x][y]));
				if(check(val)) dp[x][y][val]=1;
			}
			if(j+1<M){
				x=i; y=j+1;
				val=abs(k+abs(a[x][y]-b[x][y]));
				if(check(val)) dp[x][y][val]=1;
				val=abs(k-abs(a[x][y]-b[x][y]));
				if(check(val)) dp[x][y][val]=1;
			}	
		}
	}
	for(int k=0;k<MAX_N*MAX_N;k++) if(dp[N-1][M-1][k]){
		printf("%d\n",k);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 79232
def main():
    n,m = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(n)]
    b = [int(input()) for _ in range(m)]
    for x in a:
        ans = 0
        for i in range(m):
            ans += x[i] * b[i]
        print(ans)
    
if __name__ == '__main__':
    main()


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

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(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;
}

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
		string s ;
		cin >> s ;
		rep(i,s.size()){
			cout << 'x' ;
		}
		cout << endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗を求めるらしい
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
	//dominoに借りたやつです
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[n])

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;
string s = "";

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	llint a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 0)cout << a - b << rt;
	else cout << b - a << rt;

	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.3.4
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define VTiii vector<Tiii>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define PI 3.141592653589793238462
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;} // 最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;} // 最小公倍数lcm
int mypow(int x, int n, int m){ // 累乗x^n(mod m) O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){if((n-r)<r)r=n-r; // nCr(小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){if((n-r)<r)r=n-r; // nCr(%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
Vi stpowV(){Vi a(100001);
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
//Vi stpow = stpowV();  // 階乗配列(%MOD)
void press(auto &v){v.erase(unique(ALL(v)),v.end());} // 圧縮
Vi Vsum(Vi &v){Vi S(v.size()+1);rep(i,1,S.size())S[i]+=v[i-1]+S[i-1];return S;} // 累積和
int keta(int k,int i){string s = itos(k);return s[s.size()-i]-'0';} // i桁目の数字



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,m,qw,er,ty;
  cin >> n >> qw >> m;
  
  if(n!=m) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[100100][3];

    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    int sum[100100][3];

    sum[0][0]=a[0][0];
    sum[0][1]=a[0][1];
    sum[0][2]=a[0][2];
        
    for(int i=1;i<n;i++)
    {
        sum[i][0]=max(sum[i-1][1]+a[i][0],sum[i-1][2]+a[i][0]);

        sum[i][1]=max(sum[i-1][0]+a[i][1],sum[i-1][2]+a[i][1]);

        sum[i][2]=max(sum[i-1][0]+a[i][2],sum[i-1][1]+a[i][2]);
        
    }

   // cout << sum[n-1][0] << " " << sum[n-1][1] << sum[n-1][2] << endl;
    cout << max(max(sum[n-1][0],sum[n-1][1]),max(sum[n-1][1],sum[n-1][2])) << endl;
    return 0;

}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s[2]==s[3]){
        if(s[4]==s[5]){
            cout<<"Yes";
        }else{
            cout<<"No";
        }
        
    }else{
    cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

const double PI = acos(-1);

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

struct Point
{
	double x, y;
	Point(){};
	Point(double x, double y):x(x), y(y){};

	Point operator - (const Point& p) const{
		return Point(x-p.x, y-p.y);
	}

	double getAng(){
		return atan2(y, x);
	}
	double getCross(const Point& p) const{
		return x*p.y-y*p.x;
	}
	double getDot(const Point& p) const{
		return x*p.x+y*p.y;
	}
};

struct Circle
{
	Point p;
	double r;
	Circle(){};
	Circle(double x, double y, double r):p(x, y), r(r){};
	Circle(Point p, double r) :p(p),r(r){};

};

struct Line{
	Point p;
	double ang;
	Line(){};
	Line(Point p1, Point p2):p(p1), ang((p2-p1).getAng()){};
	Line(Point p, double ang):p(p), ang(ang){};
};
	
int n;
Circle c[1010];
Point taro, oni;
Line l;
Point lv;

bool checkSigneCross(Point p){
	return lv.getCross(p-l.p) > 0;
}

Point getCrossPoint(Line L){
	Point ret;
	ret.x = L.p.x + 1000000 * cos(L.ang);
	ret.y = L.p.y + 1000000 * sin(L.ang);
	bool sign = checkSigneCross(L.p), sign2 = checkSigneCross(ret);
	sign2 = sign^sign2;
	//cout<<sign2<<endl;
	double l = 0.0, r = 1000000.0, m;
	rep(i, 1000){
		m = (l + r) / 2.0;
		ret.x = L.p.x + m * cos(L.ang) * (sign2?1:-1);
		ret.y = L.p.y + m * sin(L.ang) * (sign2?1:-1);
		if(checkSigneCross(ret) == sign) l = m;
		else r = m;
	}
	return ret;
}

bool checkInCircle(const Circle& C, const Point& P){
	Point p = C.p-P;
	return p.x*p.x+p.y*p.y < C.r*C.r + EPS;
}

bool check(){
	for(int i = 0; i < n; i++){
		if(checkInCircle(c[i], taro)^checkInCircle(c[i], oni)) return true;
		else if(checkInCircle(c[i], taro)&&checkInCircle(c[i], oni)) continue;
		Line l2(c[i].p, l.ang+PI/2.0);

		Point p =  getCrossPoint(l2);
		if(checkInCircle(c[i], p) && (taro-p).getDot(oni-p) < 0) return true;
	}
	return false;
}

int main(){
	int m;
	while(cin>>n && n){
		rep(i, n) cin>>c[i].p.x>>c[i].p.y>>c[i].r;
		cin>>m;
		rep(i, m){
			cin>>taro.x>>taro.y>>oni.x>>oni.y;
			l = Line(taro, oni);
			lv = Point(cos(l.ang), sin(l.ang));
			cout<<(check()?"Safe":"Danger")<<endl;
		}
	}
}

Measured memory_bytes: 1308
n = list(input())
j = int(input())

for i in range(j):
    cmd,a,b,*c = input().split()
    a = int(a)
    b = int(b)
    if cmd == "print":
        print(*n[a:b+1],sep = "")
    elif cmd == "reverse":
        n[a:b+1] = reversed(n[a:b+1])
    else:
        n[a:b+1] = c[0]
        


Measured memory_bytes: 5736
#include<bits/stdc++.h>
using namespace std;
 
 
int main() {
 
    //input
    int j;
    vector<int>vec;
    for (int i = 0; i < 3; ++i) {
        cin>>j;
        vec.push_back(j);
    }

    //solve
    int count = 0;
    //if same already
    if(vec[0] == vec[1] && vec[1] == vec[2]){
        cout<<count;
        return 0;
    }

    sort(vec.begin(),vec.end());
    //std::sort(s.begin(), s.end(), std::greater<int>());

    int diff0=(vec[2]-vec[0]);
    int diff1=(vec[2]-vec[1]);

    int a0=(diff0/2);
    int a1=(diff1/2);

    int m0=(diff0%2);
    int m1=(diff1%2);

    if(m0== 0 && m1 ==0){
        count=a0+a1;
    }else if(m0== 1 && m1 ==0){
        count=a0+a1+2;
    }else if(m0 == 0 && m1 ==1){
        count=a0+a1+2;
    }else{
        //if both is odd
        count=a0+a1+1;
    }

    cout<<count;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  int x = 0;
  rep(i, n){
    ans = (ans + (long long)a[i] * x) % mod;
    x = (x + a[i]) % mod;
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 3984