akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int dp[500001][4];
int main() {
	int n; cin >> n;
	ll a[100000];
	rep(i, n) {
		cin >> a[i];
	}
	ll sum = 0;
	bool f = true;
	ll cnt = 0;
	ll mi = INF;
	if (a[0] != 0) {
		if (a[0] < 0)f = false;
		sum = a[0];
		rep1(i, n - 1) {
			sum += a[i];
			if (f) {
				if (sum >= 0) {
					cnt += sum + (ll)1;
					sum = -1;
				}
				f = !f;
			}
			else {
				if (sum <= 0) {
					cnt += (ll)1 - sum;
					sum = 1;
				}
				f = !f;
			}
		}
		mi = min(mi, cnt);
	}
	cnt = abs(a[0] - 1); sum = 1; f = true;
	rep1(i, n - 1) {
		sum += a[i];
		if (f) {
			if (sum >= 0) {
				cnt += sum + (ll)1;
				sum = -1;
			}
			f = !f;
		}
		else {
			if (sum <= 0) {
				cnt += (ll)1 - sum;
				sum = 1;
			}
			f = !f;
		}
	}
	mi = min(mi, cnt);
	cnt = abs(a[0] + 1); sum = -1; f = false;
	rep1(i, n - 1) {
		sum += a[i];
		if (f) {
			if (sum >= 0) {
				cnt += sum + (ll)1;
				sum = -1;
			}
			f = !f;
		}
		else {
			if (sum <= 0) {
				cnt += (ll)1 - sum;
				sum = 1;
			}
			f = !f;
		}
	}
	mi = min(mi, cnt);
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long X){
    FOR(x, -2000, 2000){
        FOR(y, -2000, 2000){
            if (x*x*x*x*x - y*y*y*y*y == X){
                cout << x << " " <<  y << endl;
                return;
            }
        }
    }
}

int main(){

    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}



Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,m,a;
  cin >> n >> m;
  a=m/n;
  while (1){
    if (m%a==0 && m/a>=n) break;
    a--;
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lp(n) for(int i = 0; i < n; i++)
#define LP(i, a, n) for(int i = a; i < n; i++)
#define lpp(i, n) for(int i = 0; i < n; i++)
#define INF 1e9+7
using namespace std;
int c;
void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];
  lp(n1)
    L[i] = A[left + i];
  lp(n2)
    R[i] = A[mid + i];
  L[n1] = INF;
  R[n2] = INF;
  int i = 0;
  int j = 0;
  LP(k,left,right){
    c++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}
void mergeSort(int A[], int left, int right) {
  if(left+1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
int main(){
  int n, S[500000];
  cin >> n;
  lp(n) cin >> S[i];
  mergeSort(S, 0, n);
  lp(n) cout << S[i] << (n-1 == i ? "\n":" ");
  cout << c << endl;
  return 0;
}




Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,z;
cin >> x;
if(x < 100)
cout << "0" << endl;
if(100 <= x && x < 2100){
y = x % 100;
if(y <= (x / 100) * 5)
cout << "1" << endl;
else
{
    cout << "0" << endl;
}
}
if(x >= 2100){
int z = x / 2100;
int a = (x % 2100) + z * 100;
if(a <= 5 * (x - (z * 100)/ 100))
cout << "1" << endl;
else
{
    cout << "0" << endl;
}
}
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

cost1 = 0
for i in range(X, N):
    if i in A:
        cost1 += 1

cost2 = 0
for i in range(X, 0, -1):
    if i in A:
        cost2 += 1
print(min(cost1, cost2))



Measured memory_bytes: 9064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
 
 
int main() {
    std::string s; std::cin >> s;
    int n = s.size();
    if (n & 1) {
        std::cout << "No" << std::endl;
        return 0;
    }
    for (int i = 0; i < n - 1; i += 2) {
        if (s[i] != 'h' || s[i + 1] != 'i') {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}

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

template<typename T,const T inf = (1LL<<30)>
int lis(const std::vector<T>& s, bool is_strict=true){
	vector<T> dp(s.size()+5,inf);
	for(const auto& v : s){
		auto idx = is_strict ?	lower_bound(dp.begin(),dp.end(),v) :
								 upper_bound(dp.begin(),dp.end(),v);
		*idx = v;
	}
	return lower_bound(dp.begin(),dp.end(),inf) - dp.begin();
}

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

    cout << lis(a) << endl;
}



Measured memory_bytes: 4428
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,l;cin>>n>>m>>l;
    ll lim = 1e+15;
    vector<vector<pair<ll,ll>>> mat(n, vector<pair<ll,ll>>(n, pair<ll,ll>(1e+15, 0)));
    vector<vector<ll>> d(n,vector<ll>(n,1e+15));
    vector<set<ll>> nbs(n);
    rep(i,n) {
        mat[i][i].first = 0;
        d[i][i] = 0;
    }
    rep(i,m) {
        ll a,b,c;cin>>a>>b>>c;
        a--;b--;
        if(c<=l) {
            d[a][b] = c;
            d[b][a] = c;
            nbs[a].insert(b);
            nbs[b].insert(a);
            // mat[a][b].first = mat[b][a].first = 0;
            // mat[a][b].second = mat[b][a].second = c;
        }
    }
    ll q;cin>>q;
    vector<ll> s(q), t(q);
    rep(i,q) {
        cin>>s[i]>>t[i];
        s[i]--;t[i]--;
    }
    
    rep(i,n) {
        vector<bool> flg(n,false);
        priority_queue<tuple<ll,ll,ll>, vector<tuple<ll,ll,ll>>, greater<tuple<ll,ll,ll>>> pq;
        pq.emplace(0, 0, i); 
        while(!pq.empty()) {
            auto tmp = pq.top();
            pq.pop();
            ll now = get<2>(tmp), cnt= get<0>(tmp), dist = get<1>(tmp);
            DEBUG{
                printf("now: %lld, cnt: %lld, dist: %lld\n", now,cnt,dist);
            }
            if (flg[now]) continue;
            for(auto x:nbs[now]) {
                if (flg[x]) continue;
                ll _cnt, _dist;
                if(dist + d[now][x] <= l) {
                    _cnt = cnt;
                    _dist = dist + d[now][x];
                }else if(d[now][x] <= l) {
                    _cnt = cnt+1;
                    _dist = d[now][x];
                }
                if(_cnt < mat[i][x].first || _cnt == mat[i][x].first && _dist < mat[i][x].second) {
                    mat[i][x].first = _cnt;
                    mat[i][x].second = _dist;
                    pq.emplace(_cnt, _dist, x);
                }
            }
            flg[now] = true; 
        }
        DEBUG{
            cout << endl;
        }
    }
    rep(i,q) {
        cout << (mat[s[i]][t[i]].first == ll(1e+15) ? -1 : mat[s[i]][t[i]].first)  << endl;
    }
    return 0;
}


Measured memory_bytes: 11424
""" AtCoder """

import sys
input = sys.stdin.readline

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

def f(h):
    if h == []:
        return 0
    elif len(h) == 1:
        return h[0]
    elif 0 in h:
        return f(h[:h.index(0)]) + f(h[h.index(0)+1:])
    else:
        min_h = min(h)
        for i in range(len(h)):
            h[i] -= min_h
        return f(h[:h.index(0)]) + f(h[h.index(0)+1:]) + min_h

print(f(h))


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

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;
    long long z = a;
    a -= min(a, k);
    k -= min(z, k);
    b -= min(k, b);
    cout << a << " " << b << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll N,K;
    cin>>N>>K;
    map<ll,ll> m;
    rep(i,K){
        ll d;
        cin>>d;
        rep(j,d){
            ll a;
            cin>>a;
            m[a]++;
        }
    }
    cout<<N-m.size()<<endl;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include<string>
#include <stdio.h>

using namespace std;

int main()
{
	long double a, b;
	cin >> a >> b;

	if (a>b)
	{
		cout << "GREATER" << endl;
	}
	else if (a<b)
	{
		cout << "LESS" << endl;
	}
	else
	{
		cout << "EQUAL" << endl;
	}
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
    int flag=1;
    scanf("%d%d%d",&a,&b,&c);
    int aa=a;
    int k=0;
    for(int i=a;i<=1000000;i+=a)
    {
        if(i%b==c)
        {
            printf("YES\n");
            flag=0;
            break;
        }
    }
    if(flag)
        printf("NO\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin>>n;
    vector<int> t(n),x(n),y(n);
    rep(i,n){
        cin>>t[i]>>x[i]>>y[i];
    }
    bool ans=true;
    rep(i,n){
        if((x[i]+y[i])%2!=t[i]%2){
            ans =false;
        }
        if(x[i]+y[i]>t[i]){
            ans = false;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { 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; }
typedef long long ll;

int main(){
  int N; cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  rep(i,N) {
    cout << A[N-1-i];
    if (i+1 != N) {
      cout << " ";
    }
  }
  cout << endl;
}



Measured memory_bytes: 3128
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
bool h = false;
ll reg1 = 0;
bool judge(ll x){
    cout << x << endl;
    string s;
    cin >> s;
    ll reg;
    if (s == "Vacant"){
        h = true;
        return 0;
    }else if(s=="Male"){
        reg = ((1 + (x) % 2) % 2);
    }else{
        reg = (( (x) % 2) % 2);
    }
    return reg == reg1;
}
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
ll combi(ll a, ll b)
{
    if (a < b)
        return 0;
    ll res = 1;
    for (ll i = a; i >= a - b + 1; i--)
    {
        res *= i;
        res %= MOD;
    }
    rep3(i, 1, b + 1)
    {
        res *= modinv(i, MOD);
        res %= MOD;
    }
    return res;
}
//a,m=MOD MOD逆元
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    V vec(n);
    rep(i, n) cin >> vec[i];
    V vec2(n);
    vec2 = vec;
    ll res = 0;
    reverse(all(vec2));
    rep(i,min(n,k)+1){
        rep(j,i+1){
            ll m =i-j;
            V temp;
           // cout<<i<<" "<<j<<" "<<m<<endl;
            rep(l, j) temp.push_back(vec[l]);
            rep(l, m) temp.push_back(vec2[l]);
            sort(all(temp));
            ll sum = 0;
        //    rep(i,temp.size())cout<<temp[i]<<" ";
          //  cout<<endl;
          //  cout<<k-j-m<<endl;
          ll reg=k-j-m;
            rep(l,temp.size()){
                if(temp[l]<0&&reg>0){
                    reg--;
                    continue;
                }
                sum+=temp[l];
            }
            chmax(res, sum);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var dict = new Dictionary<int, int>();
            for (int i = 0; i < N; ++i)
            {
                int a = ReadInt();
                if (!dict.ContainsKey(a)) { dict[a] = 0; }
                ++dict[a];
            }
            Console.WriteLine(dict.Values.Count(value => (value % 2) != 0));
        }
    }
}


Measured memory_bytes: 21212
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

ll f (ll x, ll idx)
{
    if (x <= 0) return 0;
    ll ret = x / (1LL << (idx + 1LL)) * (1LL << idx);
    return ret + max(0LL, x % (1LL << (idx + 1LL)) - (1LL << idx) + 1);
}

int main ()
{
    ll A,B;
    cin >> A >> B;

    ll ans = 0;
    for (ll i = 0LL; i <= 60LL; i++) {
        ll cnt = f(B, i) - f(A - 1LL, i);
        cnt %= 2LL;
        ans |= (cnt << i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
	
	long long n;
	cin >> n;
	
	n = 2 * n;
	
	long long ans = 0;
	vector<long long> arr(n);
	
	for(long long i=0;i<n;i++)
		cin >> arr[i];

	sort(arr.begin() , arr.end());
	
	for(long long i=0;i<n;i++){
		
		ans = ans + arr[i];
		i++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#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 gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld double
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
ll mod=1e9+7;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }

struct segtree{
    vector<ll> seg;
    segtree(ll n){
        seg.resize(4*n+4,0);
    }
    ll merge(ll a, ll b){
        return max(a,b);
    }
    ll get(ll pos,ll l,ll r,ll st,ll en){
        if(l>en || r<st || l>r){
            return 0;
        }
        if(st<=l && en>=r){
            return seg[pos];
        }
        ll b=(l+r)/2;
        return merge(get(2*pos,l,b,st,en),get(2*pos+1,b+1,r,st,en));
    }
    void update(ll pos,ll l,ll r,ll idx,ll val){
        if(l==r){
			if(seg[pos]<val)
            	seg[pos]=val;
            return;
        }
        ll b=(l+r)/2;
        if(idx<=b){
            update(2*pos,l,b,idx,val);
        }
        else{
            update(2*pos+1,b+1,r,idx,val);
        }
        seg[pos]=merge(seg[2*pos],seg[2*pos+1]);
        return;
    }
};

ll hi[200001];
ll bi[200001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	segtree obj(n);
	for(ll i=1;i<=n;i++) cin>>hi[i];
	for(ll i=1;i<=n;i++) cin>>bi[i];
	ll ans=0;
	for(ll i=1,x;i<=n;i++){
		x=obj.get(1,1,n,1,hi[i]-1)+bi[i];
		ans=max(ans,x);
		obj.update(1,1,n,hi[i],x);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(long long i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int N = 50;

int main() {
    ll k;
    cin >> k;
    ll x = k/N;

    vector<ll> ans(N);
    rep(i, N) {
        ans[i] = x + N -1;
    }

    rep(i, k%N) {
        ans[i] += N;
        rep(j, N) {
            if(i != j) {
                ans[j]--;
            }
        }
    }

    cout << N << "\n";
    rep(i, N) {
        cout << ans[i] << " ";
    }

    cout << endl;
    return 0;
}

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

int main() {
  int A;
  cin >> A;
  if( A < 1200){
   cout << "ABC" << endl; 
  }else{
     if( A < 2800){
   cout << "ARC" << endl; 
  }else{
      cout << "AGC" << endl; 
     }
  }
}



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

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

    vector<int> powers(N);
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;

        for (; a % 2 == 0; a /= 2)
            powers[i]++;
    }

    sort(begin(powers), end(powers));

    vector<int> optimal(N);
    for (int i = 0, j = 0, k = N-1; i < N; i++)
    {
        if (i % 2 == 0) optimal[i] = powers[j++];
        else optimal[i] = powers[k--];
    }

    bool ok = true;
    for (int i = 0; i+1 < N; i++)
        ok &= optimal[i] + optimal[i+1] >= 2;

    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

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

    int N;
    cin>>N;
    string ans ="";

    for(int i=0;i< s.size();i += N){
        ans += s[i];
    }

    put(ans);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main() {
  int l,r,d; cin >>l>>r>>d;
  cout << r/d - (l-1)/d << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC153D - Caracal vs Monster

        Scanner sc = new Scanner(System.in);

        long h = sc.nextLong();

        if (h == 1) {
            System.out.println(1);
            return;
        }
        
        long x = h;
        int cnt = 0;
        while(true) {
            x /=2;
            cnt++;
            if (x == 1) break;
        }
        
        long ans = 2;
        for (int i = 0; i < cnt; i++) {
            ans *= 2;
        }
        
        if (cnt > 0) ans--;

        System.out.println(ans);
    }

}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		string[] str2 = Console.ReadLine().Split();
		var listA = new List<long>();
		var listB = new List<long>();
		var listC = new List<long>();
		var listAB = new List<long>();
		for(var i=0;i<N;i++){
			long a = long.Parse(str2[i]);
			if(a > 0){
				listA.Add(a);
				listAB.Add(a);
			} else if(a<0){
				listB.Add(a);
				listAB.Add(a);
			} else {
				listC.Add(a);
			}
		}
		listA.Sort((x,y)=>y.CompareTo(x));
		listB.Sort((x,y)=>y.CompareTo(x));
		listAB.Sort((x,y)=>Math.Abs(y).CompareTo(Math.Abs(x)));
		long ans = 0;
		long mod = (long)Math.Pow(10,9)+7;
		if(K <= listAB.Count){
			ans = 1;
			int ct = 0;
			long minP = 99999999999;
			long minM = 99999999999;
			for(var i=0;i<K;i++){
				if(listAB[i] > 0){
					ans = ans * listAB[i] % mod;
					minP = Math.Min(minP,listAB[i]);
				} else {
					ans = ans * -listAB[i] % mod;
					minM = Math.Min(minM,-listAB[i]);
					ct++;
				}
			}
			bool flag = false;
			long ans1 = ans;
			long ans2 = ans;
			long a3 = -1;
			long a4 = -1;
			if(ct % 2 == 1){
				for(var i=K;i<listAB.Count;i++){
					if(listAB[i] > 0){
						a3 = Math.Max(a3,listAB[i]);
					} else {
						a4 = Math.Max(a4,-listAB[i]);
					}
				}
				if(minP == 99999999999){
					if(a3 == -1 && a4 == -1){
						if(listC.Count > 0){
							ans = 0;
						} else {
                          ans = (-ans + mod) % mod;
                        }
					} else if(a3 == -1){
						if(listC.Count>0){
							ans = 0;
						} else {
							ans = 1;
							for(var i=listAB.Count-1;i>=listAB.Count-K;i--){
								ans = ans * (-listAB[i]) % mod;
							}
							ans = (-ans + mod) % mod;
						}
					} else {
						ans = ans * a3 % mod;
						ans = ans * Mpow(minM,mod-2,mod) % mod;
					}
				} else {
					if(a3 == -1 && a4 == -1){
						if(listC.Count > 0){
							ans = 0;
						} else {
                          ans = (-ans + mod) % mod;
						}
					} else if(a3 == -1){
						ans = ans * a4 % mod;
						ans = ans * Mpow(minP,mod-2,mod) % mod;
					} else if(a4 == -1){
						ans = ans * a3 % mod;
						ans = ans * Mpow(minM,mod-2,mod) % mod;
					} else {
						if(minP * a3 > minM * a4){
							ans = ans * a3 % mod;
							ans = ans * Mpow(minM,mod-2,mod) % mod;
						} else {
							ans = ans * a4 % mod;
							ans = ans * Mpow(minP,mod-2,mod) % mod;
						}
					}
				}
			}
		}
		Console.WriteLine((ans+mod)%mod);
	}
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
}

Measured memory_bytes: 46136
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,m,u,v,du[10010],place[10010],a[10010];
vector<int> G[10010];
set< pair<int,int> > Se;
int main() {
	read(n);
	for(int i=1;i<n;i++){
		read(u);read(v);
		G[u].push_back(v);
		G[v].push_back(u);
		du[u]+=1;
		du[v]+=1;
	}
	for(int i=1;i<n;i++){
		Se.insert(make_pair(du[i],i));
	}
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	int ans = 0;
	for(int i=1;i<=n;i++){
		pii cv = *Se.begin();
		Se.erase(cv);
		place[cv.second] = a[i];
		ans+=cv.first*a[i];
		for(auto ct:G[cv.second]){
			if(place[ct])continue;
			Se.erase(make_pair(du[ct],ct));
			du[ct]-=1;
			Se.insert(make_pair(du[ct],ct));
		}
	}
	cout<<ans<<endl;
	for(int i=1;i<=n;i++)cout<<place[i]<<' ';
	cout<<endl;
	return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int m;
    cin >> m;

    cout << 24 + (24 - m) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e9
// #define ll long long ll
 
typedef long long ll;
ll mod = 1e9 + 7;
 
long long fast_exp(long long a, long long b)
{
	if(b <= 0)
	   return 1;
	else
	{
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
	}
}
typedef long double ld;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin>>n;
    map <string,int> ms;
    int m = 0;
    string s;
    for(int i = 0; i<n ; i++)
    {
        cin>>s;
        ms[s]++;
        m = max(m,ms[s]);
    }
    set <string> ans;
    for(auto e: ms)
    {
        if(e.ss == m)
            ans.insert(e.ff);
    }
    for(auto e: ans)
        cout<<e<<endl;
    return 0; 
}

Measured memory_bytes: 33280
#include <iostream>
#include<string>
#include<utility>
using namespace std;
int main() {
    pair<string,int> go[100000];
    int i=0;
    while(cin>>go[i].first>>go[i].second){
        i++;
    }
    int at;
    string fir;
    at=0;
    for(int l=0;l<i;++l){
        fir="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
        for(int j=l;j<i;++j){
            if(go[j].first<=fir){
                fir=go[j].first;
                at=j;
            }
        }
        swap(go[at],go[l]);
    }
    fir=go[0].first;
    for(int k=1;k<i;++k){
        if(go[k].first!=fir){
        fir=go[k].first;
        }
        else{
            go[k].first="-1";
        }
    }
    int min=100000;
    
    for(int k=0;k<i;++k){
        at=k;
        min=100000;
        for(int l=k;l<i;++l){
            if(l!=k&&go[l].first!="-1"){
                break;
            }
            if(go[l].second<min){
                min=go[l].second;
                at=l;
            }
        }
        swap(go[k].second,go[at].second);
    }
    for(int k=0;k<i;++k){
        if(go[k].first=="-1"){
            cout<<" "<<go[k].second;
        }
        else if(go[k].first!="-1"&&k!=0){
            cout<<endl<<go[k].first<<endl<<go[k].second;
        }
        else{
            cout<<go[k].first<<endl<<go[k].second;

        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4644
def resolve():
    n, m = map(int, input().split())
    s = []
    c = []

    for _ in range(m):
        si, ci = map(int,input().split())
        s.append(si)
        c.append(ci)

    if n == 1:
        str_num = str(0)
        flg = True

        for si, ci in zip(s, c):
            if ci != 0:
                flg = False

        if flg:
            print(0)
            return

    for num in range(10 ** (n-1), 10 ** n):
        str_num = str(num)
        flg = True

        for si, ci in zip(s, c):
            if str_num[si - 1] != str(ci):
                flg = False

        if flg:
            print(num)
            return

    print(-1)

resolve()

Measured memory_bytes: 3064
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int a,b,k;
    cin >> a >> b >> k;
    
    if((a+b)<=k) {
        cout << 0 << " " << 0;
        return 0;
    }
    
    if(a>=k) {
        cout << a-k << " " << b;
        return 0;
    }
    cout << 0 << " " << b-(k-a);
    
	return 0;
    
}

Measured memory_bytes: 8832
import math
N=int(input().strip())
A=list(map(int,input().split()))
nns=[2**i for i in range(31)]
def func(n,x):
    return n%nns[x]==0
def binsearch_int(func, min_x, max_x):
    """func(x) == Trueとなる最大のxを返す
    """
    if func(max_x):
        return max_x
    if not func(min_x):
        return None
    left,right=min_x,max_x
    while left+1<right:
        mid=(left+right)//2
        if func(mid):
            left=mid
        else:
            right=mid
    return left
print(sum(binsearch_int(lambda x: func(i,x),0,int(math.log2(i))+1) for i in A))

Measured memory_bytes: 4148
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
L=[0]
R=[0]
for i in range(n-1):
    L.append(gcd(L[i],a[i]))
    R.append(gcd(R[i],a[-1-i]))
MAX=0
for i in range(n):
    MAX=max(MAX,gcd(L[i],R[-1-i]))
print(MAX)


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);

    for (int i = 0;i < n;i++){
        cin >> l.at(i);
    }

    sort(l.begin(),l.end(),greater<int>());
    int sum = 0;
    for (int i = 1;i < n;i++){
        sum += l.at(i);
    }

    if (l.at(0) < sum){
        cout << "Yes" << endl;    
    }
    else if (l.at(0) >= sum) {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;


int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    int all=0;
    REP(i,n){
        cin >> v[i];
        all^=v[i];
    }

    REP(i,n)
        v[i]^=all;

    REP(i,n)
        cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 3968
package main

import (
	"fmt"
	"strings"
)

func main() {
	a := strings.Split("abcdefghijklmnopqrstuvwxyz", "")

	var n int
	fmt.Scanf("%d", &n)

	x, y := 0, 0
	var ans string
	for {
		x = (n - 1) / 26
		y = (n - 1) % 26

		ans = a[y] + ans

		if x == 0 {
			break
		}
		n = x
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1836
n, k = map(int,input().split())
R, S, P = map(int,input().split())
t = str(input())
dic_rsp = {'r':P, 's':R, 'p':S}
ans = 0
for ik in range(k):
    tmp = 'o'
    for ii in range(ik,n,k):
        if ii==0:
            ans+=dic_rsp[t[ii]]
            tmp = t[ii]
        else:
            if t[ii]!=tmp:
                ans+=dic_rsp[t[ii]]
                tmp = t[ii]    
            else:
                tmp = 'o'                    
print(ans)

Measured memory_bytes: 3316
n = gets.to_i

as, bs = [], []

n.times do
  a, b = gets.split.map &:to_i
  as << a
  bs << b
end

def median(xs)
  xs = xs.sort
  n = xs.size
  if n.even?
    xs[n / 2] + xs[n / 2 - 1]
  else
    xs[n / 2]
  end
end


ma = median as
mb = median bs
puts mb - ma + 1


Measured memory_bytes: 22160
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[100010];
int u[111111];
int dp[111111];
int f(int x){
    if(x<=0) return 0;
    if(dp[x]!=-1) return dp[x];
    int nm=inf;
    for(int n=0;n<b;n++){
	nm=min(nm,f(x-i[n])+u[n]);
    }
    return dp[x]=nm;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>a>>b;
    memset(dp,-1,sizeof(dp));
    for(int n=0;n<b;n++) cin >>i[n]>>u[n];
    cout <<f(a)<<'\n';
    return (0);
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

const int day[13]={0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int Uday[13]={0,31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int y,m,d,ty,tm,td;
long long int ans=0;
bool uru=false;

void uruu(int year){
	uru=false;
	if(year%4==0)uru=true;
	if(year%100==0)uru=false;
	if(year%400==0)uru=true;
}


int main(void){
	while(1){
		scanf("%d%d%d%d%d%d",&y,&m,&d,&ty,&tm,&td);
		if(y==-1 && m==-1 && d==-1 && ty==-1 && tm==-1 && td==-1)break;
		ans=0;
		uruu(y);
		while(1){
			if(y==ty && m==tm && d==td)break;
			else{
				ans++;
				if(uru){
					if(d==Uday[m]){
						m++;
						d=1;
						if(m==13){
							y++,uruu(y),m=1;
						}
					}else{
						d++;
					}
				}else{
					if(d==day[m]){
						m++;
						d=1;
						if(m==13){
							y++,uruu(y),m=1;
						}
					}else{
						d++;
					}
				}
			}
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

bool simulate(const vector<int> &L, const vector< pair<int, int> > &vp, int T, int M){
	int N = vp.size();
	vector<int> lest(T+1, 0);
	vector<bool> ok(vp.size(), false);
	for(int i=0;i<M;i++) lest[L[i]]++;
	int cnt = N-M;
	for(int i=1;i<T;i++){
		if(cnt == 0) return true;
		if(lest[i]==0) continue;
		for(int j=M;j<N;j++){
			if(ok[j]) continue;
			if(i%vp[j].second <= vp[j].first){
				if(i+L[j] > T) return false;
				cnt--;
				ok[j] = true;
				lest[i]--;
				lest[i+L[j]]++; 
			}
			if(lest[i] == 0) break;
		}
		lest[i+1] += lest[i];
	}
	return cnt == 0;
}

int main(){
	int N, T;
	while(cin >> N >> T, N){
		vector<int> L(N);
		vector< pair<int, int> > vp(N);
		for(int i=0;i<N;i++){
			cin >> L[i] >> vp[i].first >> vp[i].second;
			vp[i].second += vp[i].first;
		}
		for(int i=1;i<=N;i++){
			if(simulate(L, vp, T, i)){
				cout << i << endl; break;
			}
		}
	}
}

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

using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    string s;
    vector<string> v(n);
    for(int i=0;i<n;i++){
        cin >> s;
        v[i] = s;
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b) { 
   if (b == 0) 
      return a; 
   return gcd(b, a % b);  
} 

void solve(){

    string s;
    cin >> s;

    int l = s.size();
    bool flag = true;

    for(int i =0;i<l;i++){
        if(i%2==0){
            if(s[i]=='R' || s[i]=='U' || s[i]=='D');
            else{
                flag = false;
                break;
            }
        }
        else{
            if(s[i]=='L' || s[i]=='U' || s[i]=='D');
            else{
                flag = false;
                break;
            }
        }
    }
 
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 384
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#ifdef LOCAL
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" s << "\033[0m"
#else
#define cerr(s)
#endif
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12

void _main(int tc) {
  string s, t;
  cin >> s >> t;

  vector<vector<int>> mem(s.size() + 1, vector<int>(t.size() + 1, -1));

  function<int(int, int)> lcs = [&](int i, int j) -> int {
    if (i == s.size() or j == t.size()) return 0;
    if (mem[i][j] != -1) return mem[i][j];
    if (s[i] == t[j])
      return mem[i][j] = 1 + lcs(i + 1, j + 1);
    else
      return mem[i][j] = max(lcs(i + 1, j), lcs(i, j + 1));
  };

  // mem[s.size()] = vector<int>(t.size(), 0);
  // rep(i, s.size() + 1) mem[i][t.size()] = 0;

  lcs(0, 0);

  int i = 0, j = 0;
  string ans = "";
  while (i < s.size() && j < t.size()) {
    if (s[i] == t[j]) {
      ans += s[i];
      i++, j++;
    } else {
      if (mem[i + 1][j] > mem[i][j + 1]) {
        i++;
      } else {
        j++;
      }
    }
  }
  cout << ans << endl;

#ifdef LOCAL
  cerr(<< setw(4) << " ");
  rep(i, t.size()) cerr(<< setw(4) << t[i]);
  cerr(<< endl);
  rep(i, s.size() + 1) {
    if (i < s.size())
      cerr(<< setw(4) << s[i]);
    else
      cerr(<< setw(4) << " ");
    rep(j, t.size() + 1) cerr(<< setw(4) << mem[i][j]);
    cerr(<< endl);
  }
#endif
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

struct Card{char mark, value;};

bool Stable(Card C1[], Card C2[], int N){
    for(int i = 0; i < N; i++){
        if(C1[i].mark != C2[i].mark) return false;
    }
    return true;
}

void BubbleSort(Card C[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N -1; j > i; j--){
            if(C[j].value < C[j - 1].value){
                swap(C[j], C[j - 1]);
            }
        }
    }
}

void SelectionSort(Card C[], int N){
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(C[minj].value > C[j].value) minj = j;
        }
        if(minj != i){
            swap(C[i], C[minj]);
        }
    }
}

void print(Card C[], int N){
    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << C[i].mark << C[i].value;
    }
    cout << endl;
}

int main(){
    Card C1[100], C2[100];
    int N;
    cin >> N;
    for(int i  = 0; i < N; i++){
        cin >> C1[i].mark >> C1[i].value;
    }
    for(int i  = 0; i < N; i++){
        C2[i] = C1[i];
    }
    
    BubbleSort(C1, N);
    SelectionSort(C2, N);
    print(C1, N);
    cout << "Stable" << endl;
    
    print(C2, N);
    if(Stable(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}


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

int main() {
    long long n, ans=0;
    cin >> n;
    if(n%2 == 0)  {
        n /= 2;
        while(n/5 > 0) {
            n /= 5;
            ans += n;
        }
    }
    
    cout << ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;


//----------ダイクストラ pair<index,len>----------
void dijkstra(int node_size, vector<pair<int, int>>* link, bool *used, int s, int* result)
{
	REP(i, node_size)
	{
		result[i] = INT64_MAX;
		used[i] = false;
	}
	result[s] = 0;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q; //len, index
	q.push(pair<int, int>(0, s));
	while (q.size() > 0)
	{
		int d, p;
		tie(d, p) = q.top();
		q.pop();
		if (used[p]) continue;
		used[p] = true;
		for (pair<int, int>& l : link[p])
		{
			if (result[l.first] > d + l.second)
			{
				result[l.first] = d + l.second;
				q.push(pair<int, int>(d + l.second, l.first));
			}
		}
	}
}

int N, M, L;
int Q;
int S[100000];
int T[100000];
using P = pair<int, int>;

vector<P> link[300];

list<int> new_link[300];

int get_step(int s, int t)
{
	bool used[300] = {};

	queue<int> q;
	q.push(s);
	used[s] = true;

	int step = 0;
	while (q.size() > 0)
	{
		step++;

		int q_size = q.size();
		for (int i = 0; i < q_size; i++)
		{
			int a = q.front();
			q.pop();
			
			for (int l : new_link[a])
			{
				if (used[l]) continue;
				used[l] = true;
				if (l == t) return step;
				q.push(l);
			}
		}
	}

	return 0;
}

signed main()
{
	cin >> N >> M >> L;
	REP(i, M)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a -= 1;
		b -= 1;

		if (c <= L)
		{
			link[a].push_back(P(b, c));
			link[b].push_back(P(a, c));
			new_link[a].push_back(b);
			new_link[b].push_back(a);
		}
	}
	cin >> Q;
	REP(i, Q) cin >> S[i] >> T[i];

	for (int s = 0; s < N; s++)
	{
		int dik[300];
		bool used[300];
		dijkstra(N, link, used, s, dik);

		for (int d = 0; d < N; d++)
		{
			if (d == s) continue;
			if (dik[d] <= L)
			{
				if (!CONTAINS(new_link[s], d))
				{
					new_link[s].push_back(d);
					new_link[d].push_back(s);
				}
			}
		}
	}

	REP(i, Q)
	{
		int step = get_step(S[i] - 1, T[i] - 1);
		cout << (step - 1) << endl;
	}
}



Measured memory_bytes: 7912