akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
// #include <unordered_map>
#include <cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m, n) for (int i = m; i < n; i++)
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
#define ST(x, y, z) sort(x + y, x + z);
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
#define re read()
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
// #define int ll
#define LL long long
#define int ll
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}

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 mod = 1e9 + 7;

int qmi(int m, int k, int p)
{
    int res = 1 % p, t = m;
    while (k)
    {
        if (k&1) res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
const int N = 320;
int a[N];
signed main()
{
   // STDIN
    
    int n;
    n = re;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int lo = i;
        int hi = n/i*i;
        ans += (lo/i + hi/i)*hi/2;
    }
    cout << ans << endl;
    // cout << qmi(m*(m-1)/2, n-1, mod)*2 << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int k;cin>>k;
	string s;cin>>s;
	int n=s.length();
	if(n<=k) cout<<s<<"\n";
	else
	{
		string s1="";
		for(int i=0;i<k;i++)
		s1=s1+s[i];
		s1=s1+"...";
		cout<<s1<<"\n";
	}
	return 0;
}

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

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> colors(3, 0);
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        int m = 0;
        for (int k = 0; k < 3; k++) {
            if (colors[k] == a) {
                if (m == 0) {
                    colors[k]++;
                }
                m++;
            }
        }
        if (m == 0) {
            cout << 0 << endl;
            return 0;
        }
        ans *= m;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	int n;
	cin>>n;
	int a,b;
	cin>>a>>b;
	if(a/n!=b/n||a%n==0||b%n==0)
		cout<<"OK\n";
	else
		cout<<"NG\n";
}



Measured memory_bytes: 3568
# -*- coding: utf-8 -*-
import numpy as np
N = input()
t, x, y = [0], [0], [0]
for _ in range(N):
    _t, _x, _y = map(float, raw_input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)
 
txy = np.array([[_t, _x, _y] for _t, _x, _y in zip(t, x, y)], dtype=np.int64)

dm = np.diff(txy, axis=0)

ret = 'Yes'
for d in dm:
    total = np.abs(d[1]) + np.abs(d[2])
    if d[0] < total or (d[0] - total) % 2 != 0:
        ret = 'No'

print ret

Measured memory_bytes: 39452
#include<stdio.h>
#define N 100
int main(void){
  int i,n;
  int cup[3]={0},swp;
  char x[N],hoge,y[N];//65 66 67
  
  for(i=0;scanf("%c%c%c%c",&x[i],&hoge,&y[i],&hoge)==4;i++){}
  n=i;
  cup[0]=1;
  for(i=0;i<n;i++){
    swp=cup[x[i]-65];
    cup[x[i]-65]=cup[y[i]-65];
    cup[y[i]-65]=swp;
  }
  for(i=0;i<3;i++){
    if(cup[i]==1){
      printf("%c\n",i+65);
    }
  }
  return 0;
}

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

int main(){
  int n,l;
  cin>> n >> l;
  vector<string> S(n);
  for(int i=0;i<n;i++) cin>>S.at(i);
  sort(S.begin(),S.end());
  
  for(auto s:S) cout<<s;
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll x, r, d;
	cin>>r>>d>>x;
	forn(i, 1, 11){
		x = r*x - d;
		cout<<x<<endl;
	}
	return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int s, w;
    cin >> s >> w;

    if(s>w) cout << "safe" << endl;
    else cout << "unsafe" << endl;

    return 0;
}


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

int main() {
    int a, b, ans = -1;
    cin >>a>>b;
    
    if(a<=9 && b<=9) ans = a*b;

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int a,b,c=0,d=0,k=0,n,h,w,m,ans=0;
    string s,s2;
    cin >> a >> b >> c >> d; 
    h = max(a,c);
    w = min (b,d);
    cout << max(0,w-h) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str, T: str):
    print(sum([s == t for s, t in zip(S, T)]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        while (true) {
            int n, k;
            cin >> n >> k;
            if (n == 0 && k == 0) break;
            vector<int> v;
//            rep(i, 0, k) cin >> v[i];

            int white = 0;
            rep(i, 0, k) {
                int tmp;
                cin >> tmp;
                if (tmp == 0) white++;
                else v.push_back(tmp);
            }
            sort(all(v));
            v.erase(unique(all(v)), v.end());

            vector<pair<int, int>> tapi;

            int st = 0;
            for (int i = 0; i < v.size(); ++i) {
                if (i + 1 == v.size()) {
                    if (v[i] - v[st] != i - st) {
                        tapi.emplace_back(v[st], v[i - 1]);
                        st = i;
                    }
                    tapi.emplace_back(v[st], v[i]);
                }
                if (i == st) {
                    continue;
                }
                if (v[i] - v[st] != i - st) {
                    tapi.emplace_back(v[st], v[i - 1]);
                    st = i;
                }
            }

            int ans = tapi.back().second - tapi.back().first + 1;
            for (int i = 0; i < tapi.size() - 1; ++i) {
                chmax(ans, tapi[i].second - tapi[i].first + 1);
                if (tapi[i].second + (white + 1) >= tapi[i + 1].first) {
                    chmax(ans, tapi[i + 1].second - tapi[i].first + 1);
                }
            }

            cout << ans << endl;

        }

    }
};


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

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3572
#                               #
    # author : samars_diary #
    # 16-09-2020 │ 18:28:11 #
#                               #

import sys, os.path, math

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=ii();print((pow(10,a,mod())+pow(8,a,mod())-2*pow(9,a,mod()))%mod())
for _ in range(1):
    solve()

Measured memory_bytes: 9164
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	l := make([]int, n)
	for i := range l {
		fmt.Scan(&l[i])
	}

	var ans int = 1
	d := make([]int, n+1)
	for i := 1; i < len(d); i++ {
		d[i] = d[i-1] + l[i-1]
		if d[i] <= x {
			ans++
		}
	}
	fmt.Println(ans)
}

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

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

    long long idx;
    long double result = 0.0;
    for (int i = 1; i<=N; ++i) {
        if (i >= K) {
            result += 1.0;
            continue;
        }
        idx = (long long)ceil(log2((double)K/(double)i));
        result += 1.0 / (long double)pow(2, idx);
    }

    printf("%.12f\n", (double)(result / N));

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

using std::next_permutation;

int N,M,R;
vector<int> r;
vector<vector<int>> c;

vector<vector<int>> table;

int dist(vector<int> & v){
    int sum=0;
    for(int i=0;i<v.size()-1;i++){
        sum+=table[v[i]][v[i+1]];
    }
    return sum;
}

int search(){
    vector<int> v(r.begin(),r.end());
    sort(v.begin(),v.end());
    int min=dist(v);
    while(next_permutation(v.begin(),v.end())){
        min=std::min(min,dist(v));
    }
    return min;
}

vector<int> dijkstra(int s){
    vector<int> d;
    vector<int> q;
    for(int i=0;i<N;i++){
        d.push_back(i==s?0:INT_MAX/2);
        q.push_back(i);
    }

    while(!q.empty()){
        auto min=std::min_element(q.begin(),q.end(),
                [&d](auto u,auto v)->bool{
                return d[u] < d[v];
                });
        int u=*min;
        q.erase(min);
        for(int v=0;v<N;v++){
            if(c[u][v]==0){
                continue;
            }
            d[v]=std::min(d[v],d[u]+c[u][v]);
        }
    }
    return d;
}

void make_table(){
    table=vector<vector<int>>(N,vector<int>(R,-1));
    for(int i:r){
        table[i]=dijkstra(i);
    }
}

int main(){
    cin >> N >> M >> R;
    c=vector<vector<int>>(N,vector<int>(N,0));
    for(int i=0;i<R;i++){
        int _r;
        cin >> _r;
        _r--;
        r.push_back(_r);
    }

    for(int i=0;i<M;i++){
        int _a,_b,_c;
        cin >> _a >> _b >> _c;
        _a--;
        _b--;
        c[_a][_b]=_c;
        c[_b][_a]=_c;
    }

    make_table();

    cout << search() << endl;

    return 0;
}



Measured memory_bytes: 384
N, K = map(int, input().split())

A = list(map(int, input().split()))

min_A = min(A)


ind1 = A.index(1)
len1 = N -ind1
len2 = ind1 + 1

r1= 0
if (len1-1)%(K-1) != 0:
    r1 = 1

r2= 0
if (len2-1)%(K-1) != 0:
    r2 = 1
d = 0



ans1 = (len1-1)//(K-1)+r1 + (len2-1)//(K-1)+r2

ans=[]
ans.append(ans1)
for i in range(1, K):
    ans2 = 0
    r3= 0
    if (len1-i-1)%(K-1) != 0:
        r3 = 1

    r4= 0
    if (len2-((K-1)-i)-1)%(K-1) != 0:
        r4 = 1
    ans2 = (len1-i-1)//(K-1)+r3 + (len2-((K-1)-i)-1)//(K-1)+r4 + 1
    ans.append(ans2)



print(min(ans))


Measured memory_bytes: 14008
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(){
	long long n;
	cin>>n;
	for(long long i=1;i<=n;i++){
		if((i+1)*i/2>=n){
			for(int j=1;j<=i;j++){
				if((i+1)*i/2-n==j);
				else cout<<j<<endl;
			}
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

  int n,q;
  cin>>n;
  vector <int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  cin>>q;
  for(int i=0;i<q;i++){
    int k;
    cin>>k;
    auto it=lower_bound(a.begin(),a.end(),k);
    cout<<distance(a.begin(),it)<<endl;
  }
  return 0;

}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE=10000;
const int SIZE2=5010;
const int SIZE3=400;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string S;
ut N,M,K,X,L,W,H;
// ut A,B,C,D,E,F,G,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL x[2],vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
VI v[2];
bool DP[SIZE*3][4];
bool able(int now){
	REP(j,2) REP(i,SIZE) DP[i][j]=0;
	DP[0][0]=1;
	REP(k,v[now].size()){
		int j=k&1;
		int next=v[now][k];
		REP(i,SIZE){
		//	if(DP[i][j]) cout << i <<" " << (j^1LL) << endl;
			DP[i][j^1LL]=false;
		}
		REP(i,SIZE){
			if(i+next<SIZE) DP[i+next][j^1LL]|=DP[i][j];
			if(i-next>=0) DP[i-next][j^1LL]|=DP[i][j];
		}
	}
	return DP[abs(x[now])][SI(v[now])&1LL];
}
signed main(){
	string s;
	cin >> s;
	cin >> x[0] >> x[1];
	s+=" ";
	int now=0,t=0;
	REP(i,s.size()){
		if(s[i]=='F'){

			t++;
		}
		else{
			if(now==0 && v[now].size()==0){
				v[now].PB(0);
				x[0]-=t;
			}
			else if(t)
				v[now].PB(t);
			now++;
			now%=2;
			t=0;
		}
	}
	REP(i,2) sort(ALL(v[i]),greater<int>());
	if(able(0) and able(1)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 2432
import math
xyzk = list(map(int,input().split()))
abc = [list(map(int,input().split())) for a in range(3)]
ab=[]
for a in abc[0]:
    for b in abc[1]:
        ab.append(a+b)
ab.sort()
ab.reverse()
abc[2].sort()
abc[2].reverse()
abc2=[]
for c in range(len(abc[2])):
    for a in range(min([math.ceil(xyzk[3]),len(ab)])):
        abc2.append(abc[2][c]+ab[a])
abc2.sort()
abc2.reverse()
for a in range(xyzk[3]):
    print(abc2[a])

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

using namespace std;

typedef long long ll;

const int N = 1e3 + 1;
int res[N];

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x = i;
        for (int j = 2; j * j <= x; j++)
        {
            if (x % j == 0)
            {
                int c = 0;
                while (x % j == 0)
                {
                    c++;
                    x /= j;
                }
                res[j] += c;
            }
        }
        if (x != 1)
        {
            res[x]++;
        }
    }
    int M = 1e9 + 7;
    int ans = 1;
    for (int i = 0; i < N; i++)
    {
        ans = (ans * (ll) (res[i] + 1)) % M;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<map>

using namespace std;


int c1, c5, c10, c50, c100, c500;

int main() {
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	int res = c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;
	if (res >= 1000)
		cout << "1" << endl;
	else
		cout << "0" << endl;
	//cin >> c1;

	return 0;
}

Measured memory_bytes: 3104
from collections import deque

N = int(input())
As = list(map(int,input().split()))

h = deque([])
for i in range(N):
  if i%2 == 0:
    h.append(As[i])
  else:
    h.appendleft(As[i])
    
if N%2 == 1:
  h.reverse()
  
print(" ".join(map(str,h)))

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

const int N=1e5+10;
long long n,k,q;

int a[N];
int x;

int main()
{
	cin>>n>>k>>q;
	
	for(int i=0; i<q; i++)
	{
		cin>>x;
		a[x]++;
	}
	
	k-=q;
	for(int i=1; i<=n; i++)
		if(a[i]+k<=0)
			puts("No");
		else
			puts("Yes");
	
	return 0;
}

Measured memory_bytes: 1024
def resolve():
    A = []
    for _ in range(3):
        A.append(list(map(int, input().split())))

    N = int(input())
    b = [int(input()) for _ in range(N)]

    for i in range(3):
        for j in range(3):
            if A[i][j] in b:
                A[i][j] = 0

    for i in range(3):
        if (A[i][0] + A[i][1] + A[i][2] == 0):
            print('Yes')
            return
        if (A[0][i] + A[1][i] + A[2][i] == 0):
            print('Yes')
            return
        if (A[0][0] + A[1][1] + A[2][2] == 0):
            print('Yes')
            return
        if (A[0][2] + A[1][1] + A[2][0] == 0):
            print('Yes')
            return

    print("No")

    return
resolve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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


    ll k,ans = 0;
    cin>>k;
    k++;
    rep(a,1,k)rep(b,1,k)rep(c,1,k){
        ans += gcd(a,gcd(b,c));
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 3648
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: Vec<i32> = (0..n).map(|_| read()).collect();
    println!("{}", a.iter().map(|x| x - 1).sum::<i32>());
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;
using ll = long long;

// Graph template
template <class... Args>
struct Edge
{
	int from, to;
	tuple<Args...> values;
	Edge(int from, int to, Args... values)
		: from(from), to(to), values(values...) {}
};
template <class E>
auto operator<(const E &e, const E &f)
{
	return e.values > f.values;
}

template <class... Args>
class Graph
{
	using Edges = vector<Edge<Args...>>;
	vector<Edges> graph_;

  public:
	Graph(int n) : graph_(n) {}
	size_t size() { return graph_.size(); };
	size_t size() const { return graph_.size(); };
	auto &operator[](unsigned int x) { return graph_[x]; }
	const auto &operator[](unsigned int x) const { return graph_[x]; }
	void AddEdge(int s, int t, Args... v) { graph_[s].emplace_back(s, t, v...); }
};

template <typename T, typename U>
int get_longest_path(const T &g, int s, U &memo)
{
	if (memo[s] >= 0)
		return memo[s];
	int depth = 0;
	for (auto e : g[s])
	{
		depth = max(depth, get_longest_path(g, e.to, memo) + 1);
	}
	return memo[s] = depth;
}

int main()
{
	int n, m;
	cin >> n >> m;
	Graph<> g(n);
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		cin >> u >> v;
		g.AddEdge(u - 1, v - 1);
	}
	vector<int> memo(n, -1);
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans = max(ans, get_longest_path(g, i, memo));
	}
	cout << ans << endl;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	string S; cin >> S;
	int N = S.length();
	reverse(all(S));


	int idx = 0;
	while(idx < N){
		if(S.substr(idx, 5) == "maerd") idx += 5;
		else if(S.substr(idx, 7) == "remaerd") idx += 7;
		else if(S.substr(idx, 5) == "esare") idx += 5;
		else if(S.substr(idx, 6) == "resare")	idx += 6;
		else{
			cout << "NO" << endl;
			return 0;
		}

	}

	cout << "YES" << endl;


	return 0;

}


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

int main() {
  int N;
  cin>>N;
  vector<int> card(N);
  for(int i=0;i<N;i++){
    cin>>card.at(i);
  }
  sort(card.begin(),card.end());
    reverse(card.begin(),card.end());
  int a=0,b=0;
  for(int i=0;i<N;i+=2){
    a+=card.at(i);
  }
  for(int i=1;i<N;i+=2){
    b+=card.at(i);
  }
  cout<<a-b<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

double l[10],v1, v2;

int main()
{
    loop:
    while ( scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2 ) != EOF )
    {
        v2 += v1;
        for( int i = 0; i < 10; i++ )
        {
            l[i] += ( ( i == 0 ) ? 0 : l[i - 1] );
        }
        double t = l[9] / v2;
        double dis = v1 * t;
        for( int i = 0; i < 10; i++ )
        {
            if( dis == l[i] )
            {
                printf( "%d\n", i + 1 );
                goto loop;
            }
            else if( dis < l[i] )
            {
                printf( "%d\n", i + 1 );
                goto loop;
            }
        }
        /* for( int i = 0; i < 10; i++ )
        {
            if( l[i] <= dis && dis <= l[i + 1] )
            {
                printf( "%d\n", i + 2 );
                return 0;
            }
        } */
    }
    return 0;
}


Measured memory_bytes: 2580
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
D = inintl()

D.sort()

print(D[n//2] - D[n//2-1])

Measured memory_bytes: 84448
module T = struct
  type 'a tree = Nil | Node of 'a * 'a tree * 'a tree

  let create () = Nil

  let insert x (t : int tree) =
    let rec doit = function
      | Nil -> Node (x, Nil, Nil)
      | (Node (y, _, _)) as d when x = y -> d
      | Node (y, l, r) when x < y -> Node (y, doit l, r)
      | Node (y, l, r) -> Node (y, l, doit r)
    in
    doit t

  let preorder f t =
    let rec doit = function
      | Nil -> ()
      | Node (x, l, r) -> (f x; doit l; doit r)
    in
    doit t

  let inorder f t =
    let rec doit = function
      | Nil -> ()
      | Node (x, l, r) -> (doit l; f x; doit r)
    in
    doit t
end

let print t =
  let f e = print_string " "; print_int e in
  T.inorder f t;
  print_newline ();
  T.preorder f t;
  print_newline ()

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  let m = read_int () in
  let rec read i t =
    if i < m then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> read (i + 1) (T.insert (int_of_string n) t)
      | _ -> (print t; read (i + 1) t)
    end
  in
  read 0 (T.create ())

Measured memory_bytes: 31784
#include <queue>
#include <cstdio>
#include <algorithm>
using namespace std;
template <typename T>
void read(T &x){ 
	T f=1;x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	x*=f;
}
const int MAXN = 5e5 + 5;
int n , p[MAXN] , b[MAXN];
int head[MAXN] , to[MAXN << 2] , nxt[MAXN << 2] , cnt , du[MAXN] , k;
void add(int u , int v) {nxt[++cnt] = head[u];head[u] = cnt;to[cnt] = v;}
int tr[MAXN << 2];
void build(int l , int r , int now) {
	if(l == r) {
		tr[now] = 1e9;
		return;
	}
	int mid = (l + r) >> 1;
	build(l , mid , now << 1);
	build(mid + 1 , r , now << 1 | 1);
	tr[now] = min(tr[now << 1] , tr[now << 1 | 1]);
}
void update(int l , int r , int now , int x , int y) {
	if(l == r) {
		tr[now] = y;
		return;
	}
	int mid = (l + r) >> 1;
	if(x <= mid) update(l , mid , now << 1 , x , y);
	else update(mid + 1 , r , now << 1 | 1 , x , y);
	tr[now] = min(tr[now << 1] , tr[now << 1 | 1]);
}
int find(int l , int r , int now , int x , int y) {
	if(l >= x && r <= y) {
		return tr[now];
	}
	int mid = (l + r) >> 1 , res = 1e9;
	if(x <= mid) res = min(find(l , mid , now << 1 , x , y) , res);
	if(y > mid) res = min(find(mid + 1 , r , now << 1 | 1 , x , y) , res);
	return res;
}
int ans[MAXN];
int main() {
	read(n);read(k);
	for (int i = 1; i <= n; ++i) {
		read(p[i]);
		b[p[i]] = i;
	}
	build(1 , n , 1);
	update(1 , n , 1 , b[n] , n);
	for (int i = n - 1; i >= 1; --i) {
		int x = find(1 , n , 1 , max(b[i] - k + 1 , 1) , b[i]);
		if(x != 1e9) add(b[i] , b[x]) , du[b[x]] ++;
		x = find(1 , n , 1 , b[i] , min(b[i] + k - 1 , n));
		if(x != 1e9) add(b[i] , b[x]) , du[b[x]] ++;
		update(1 , n , 1 , b[i] , i);
	}
	priority_queue <int , vector<int > , greater<int > > q;
	for (int i = 1; i <= n; ++i) if(!du[i]) q.push(i);
	int tot = 0;
	while(!q.empty()) {
		int x = q.top();
		q.pop();
		ans[++tot] = x;
		for (int i = head[x]; i; i = nxt[i]) {
			du[to[i]] --;
			if(!du[to[i]]) q.push(to[i]);
		}
	}
//	for(int i = 1; i <= n / 2; ++i) swap(ans[i] , ans[n - i + 1]);
	for (int i = 1; i <= tot; ++i) p[ans[i]] = i;
	for (int i = 1; i <= tot; ++i) printf("%d\n" , p[i]); 
	return 0;
}

Measured memory_bytes: 25568
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const long double pi = 3.14159265358979323846;



void solve() {
  ll n; cin >> n;

  string s;
  while (n > 0) {
    --n;
    ll v = n % 26;
    s = (char)('a' + v) + s;
    n /= 26;
  }
  cout << s << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <limits.h>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    
    
    bool done[100];
    for ( int i = 0; i < 100; i++ ) {
        done[i] = false;
    }
    
    
    int N;
    string S;
    string S_head = "";
    string S_tail = "";
    
    cin >> N;
    cin >> S;
    
    
    for ( int i = 0; i < N; i++ ) {
        
        if ( done[i] ) { continue; }
        
        if ( S.substr( i, 1 ) == "(" ) {
            bool is_pair = false;
            if ( i != N-1 ) {
                for ( int j = i + 1; j < N; j++ ) {
                    if ( done[j] ) { continue; }
                    if ( S.substr( j, 1 ) == ")" ) {
                        is_pair = true;
                        done[j] = true;
                        break;
                    }
                }
                if ( !is_pair ) {
                    S_tail += ")";
                }
            }
            else { S_tail += ")"; }
        }
        else {
            S_head += "(";
        }
    }
    
    cout << S_head + S + S_tail << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
        float s[40];
        int n,i, class[6] = {0};

        scanf("%d", &n);

        for (i = 0; i < n; i++) {
               scanf("%f", &s[i]);

               if (s[i] < 165.0)
                       class[0]++;
               else if (s[i] >= 165.0 && s[i] < 170.0)
                       class[1]++;
               else if (s[i] >= 170.0 && s[i] < 175.0)
                       class[2]++;
               else if (s[i] >= 175.0 && s[i] < 180.0)
                       class[3]++;
               else if (s[i] >= 180.0 && s[i] < 185.0)
                       class[4]++;
               else if (s[i] >= 185.0)
                       class[5]++;
        }

        for (i = 0; i < 6; i++) {
                printf("%d:", i+1);
                for (n = 0; n < class[i]; n++)
                       printf("*");
                printf("\n");
        }
        return 0;
}

Measured memory_bytes: 0
import sys
X,Y=map(int,input().split())
if (X+Y)%3!=0:
    print(0)
    sys.exit()
if X>2*Y or Y>2*X:
    print(0)
    sys.exit()
mod=10**9+7
A=(X+Y)//3
B=min(X,Y)-A


ans=1
for i in range(B):
    den=i+1
    num=A-i
    ans=ans*num*pow(den,mod-2,mod)%mod

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

ll dp[105][N], ps[105][N];
int a[N];

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    dp[i][0] = ps[i][0] = 1;
  }
  for (int i = 0; i <= k; i++)
    ps[0][i] = 1;
  dp[0][0] = ps[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      ll lt = j-a[i]-1 >= 0 ? ps[i-1][j-a[i]-1] : 0;
      ll lim = (ps[i-1][j] - lt + MOD) % MOD;
      dp[i][j] = (dp[i][j] + lim) % MOD;
      ps[i][j] = (dp[i][j] + ps[i][j-1]) % MOD;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}

Measured memory_bytes: 159616
#include<iostream>
#include<cstdio>
int main()
{
int a,b,c;
std::cin >> a >> b >> c;
int max = std::max(std::max(a,b),c);
int min = std::min(std::min(a,b),c);
int mid = a+b+c-max-min;
int ans = max-mid+mid-min;
std::cout << ans << std::endl;
return 0;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    vector<int> front(N);
    RPT0(i, N) front[i] = -1;
    int cnt = 1;
    for (int i = 0; i < N && cnt <= K;) {
        if (S[i] == 'o') {
            front[i] = cnt++;
            i += C + 1;
        } else {
            i++;
        }
    }

    vector<int> back(N);
    RPT0(i, N) back[i] = -1;
    cnt = K;
    for (int i = N - 1; i >= 0 && cnt >= 1;) {
        if (S[i] == 'o') {
            back[i] = cnt--;
            i -= C + 1;
        } else {
            i--;
        }
    }

    RPT0(i, N)
    {
        if (S[i] == 'x') continue;
        if (front[i] == -1 || back[i] == -1) continue;
        if (front[i] == back[i]) {
            cout << (i + 1) << endl;
        }
    }
}

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


Measured memory_bytes: 3348
#include <iostream>
#include <math.h>
using namespace std;

int main(void)
{
    int r, m, count;
    int i = 0;
    char w[3];
    count = 0;
    m = 0;
    cin >> w;
    for (i = 0; i < 3; i++)
    {
        if (w[i] == 'R')
        {
            count++;
        }
        if ('S' == w[i])
        {
            if (count > m)
            {
                m = count;
            }
            count = 0;
        }
    }
    if (count > m)
    {
        m = count;
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
void solve(){
	ll l,i,r,d,ans=0;
	cin>>l>>r>>d;
	sfl(i,l,r+1){
		if(i%d==0)
			ans++;
	}
	cout<<ans<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	

Measured memory_bytes: 3640
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    double acc = 0;
    for(int i = 1; i <= n; i++){
        int num = i, cnt = 0;
        while(num < k){
            num <<= 1;
            cnt++;
        }
        acc += pow(2, -cnt);
    }
    cout << fixed << setprecision(20) << acc / n << '\n';
}


Measured memory_bytes: 256
from collections import deque


def main():
    S = list(input())
    D = deque(S)
    Q = int(input())
    T = [tuple(map(str, input().split())) for _ in range(Q)]
    r = False

    for t in T:
        if t[0] == "1" and r == False:
            r = True
        elif t[0] == "1" and r == True:
            r = False
        else:
            if t[1] == "1" and r == False:
                D.appendleft(t[2])
            elif t[1] == "1" and r == True:
                D.append(t[2])
            elif t[1] == "2" and r == False:
                D.append(t[2])
            elif t[1] == "2" and r == True:
                D.appendleft(t[2])

    if r == False:
        print("".join(D))
    else:
        D.reverse()
        print("".join(D))


if __name__ == "__main__":
    main()


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

struct edge { int to,cost; };

int main() {
  int N;cin>>N;
  vector<ll> as(N);
  REP(i,N) cin>>as[i];

  vector<ll> accum_a(N);
  accum_a[0] = as[0];
  FOR(i,1,N) {
    accum_a[i] = accum_a[i-1]+as[i];
  }
  ll ans = LLONG_MAX;
  REP(i,N-1) {
    ans = min(ans, abs(accum_a[N-1]-2*accum_a[i]));
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

bool sortbysec(const pair<int, int>& a, const pair<int, int>& b) 
{
	return (a.second < b.second); 
} 
void maxDisjointIntervals(vector<pair<int, int> > list) 
{  
    sort(list.begin(), list.end(), sortbysec); 
    // for (auto j:list) debug2(j.F, j.S);
    int c=1;
    int r1 = list[0].second; 
  
    for (int i = 1; i < list.size(); i++) { 
        int l1 = list[i].first; 
        int r2 = list[i].second; 
        if (l1 >= r1) { 
            c++;
            r1 = r2; 
        } 
    } 
    cout<<c<<"\n";
} 

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;

	vector <pair <int, int>> a(n);

	for (int i=0;i<n;++i)
	{
		int x, l;
		cin>>x>>l;
		a[i].F = x-l;
		a[i].S = x+l;
		// debug2(a[i].F, a[i].S);
	}
	
	maxDisjointIntervals(a);




	



	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

//10????´?????¨????
int take(int n)
{
  int a=1;
  int i;

  rep(i,n)
    a*=10;

  return a;

}

int main()
{
  int n;
  int i,j;
  char a;
  int v[8];
  cin>>n;

  rep(i,n){
    rep(j,8){
      scanf("\n%c",&a);
      v[j]=a-'0';
    }

    sort(v,v+8);

    int max=0,min=0;

    rep(j,8){
      max+=v[j]*take(j);
      min+=v[7-j]*take(j);
    }
    cout<<max-min<<endl;
  }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;

    vector<pair<ll, ll>> res;
    multiset<ll> st;
    multiset<ll>::iterator x;
    ll suma = 0, sumb = 0;
    int cnt = 0;
    for (int i=0; i<N; ++i) {
        int t;
        cin >> t;
        if (t == 1) {
            ll a, b;
            cin >> a >> b;
            st.insert(a);
            if (cnt == 0) {
                x = st.begin();
            } else if (cnt%2 == 0 && *x <= a) {
                x++;
            } else if (cnt%2 == 1 && a < *x) {
                auto pre = x--;
                suma += *pre - *x;
            }
            ++cnt;
            suma += abs(a - *x);
            sumb += b;
        } else {
            res.push_back(make_pair(*x, suma+sumb));
        }
    }
    for (auto p : res) cout << p.first << ' ' << p.second << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 12980
#include <iostream>
#include <cmath>

using namespace std;

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

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
const long long M=998244353;
const long long iv2=499122177;
int n,t,i,a[N],k,j;
int b[N];
int main()
{
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(i=1;i<=k;++i)
	{
		memset(b,0,sizeof(b));
		for(j=1;j<=n;++j)
		{
			++b[max(j-a[j],1)];
			--b[min(j+a[j]+1,n+1)];
		}
		for(j=1;j<=n;++j)
			b[j]+=b[j-1];
		bool flag=true,flag2=true;
		for(j=1;j<=n;++j)
		{
			a[j]=b[j];
			if(a[j]!=n)
				flag=false;
			if(a[j]!=0)
				flag2=false;
		}
		if(flag||flag2)
			break;
	}
	for(i=1;i<=n;++i)
		printf("%d ",a[i]);
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main() {
  string s;
  cin >> s;
  vt<int> RL;

  //RLの変わるところ
  rep(i,s.size()-1)
    if(s[i]!=s[i+1])
      RL.push_back(i);
  RL.push_back(0);//最後のLのため

  vt<int> total(s.size());
  int k=0;//RL用

  //ゴリオし祭り
  rep(i,s.size()){

    if(s[i]=='R'){

      if(RL[k]>i){
        if((RL[k]-i)%2==0)
          total[RL[k]]++;
        else
          total[RL[k]+1]++;
      }

      if(RL[k]==i){
        total[i]++;
        k++;
      }
    }

    else if(s[i]=='L'){

      if(RL[k]>=i || RL[k]==0){
        if((i-RL[k-1])%2==1)
          total[RL[k-1]+1]++;
        else if((i-RL[k-1])%2==0)
          total[RL[k-1]]++;

        if(i==RL[k])
          k++;
      }
    }
  }


  rep(i,s.size())
    cout << total[i] << " ";
    return 0;
}


Measured memory_bytes: 1528
#include <cstdio>
#include <set>

int main()
{
    char Command[8];
    int Value;

    std::multiset<int> S;
    while(1){
        std::scanf("%s", Command);
        if(Command[0] == 'i'){
            std::scanf("%d", &Value);
            S.insert(Value);
        }else
        if(Command[1] == 'x'){
            std::set<int>::reverse_iterator It = S.rbegin();
            std::printf("%d\n", *It);
            S.erase(--(It.base()));
        }else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 49512