akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

char s[510000];
int n;
int a[510000];
int b[510000];

int check(int x) {
	for (int i = 0; i < n; ++i)
		b[i] = a[i];
	b[0] += x;
	int p = 0;
	for (int i = 0; i < n; ++i) {
		b[i] += p;
		p = b[i] / 10;
		b[i] %= 10;
	}
	int sum = 0;
	for (int i = 0; i < n; ++i)
		sum += b[i];
	if (sum <= x)
		return 1;
	else
		return 0;
}

int main() {
	scanf("%s", s);
	n = strlen(s);
	reverse(s, s + n);
	for (int i = 0; i < n; ++i)
		a[i] = s[i] - '0';
	for (int i = 0; i < n; ++i) {
		a[i] *= 9;
	}
	n += 20;
	int p = 0;
	for (int i = 0; i < n; ++i) {
		a[i] += p;
		p = a[i] / 10;
		a[i] %= 10;
	}
	int l = 0;
	int r = 100000000;
	while (r - l > 1) {
		int mid = (l + r) >> 1;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	cout << (r + 8) / 9 << "\n";
	return 0;
}




Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>

using namespace std;

long long choose2(long long n){
    return n * (n - 1) / 2;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);

    for (int i = 0; i < N; ++i){
        cin >> A.at(i);
    }
    for (int i = 0; i < N; ++i){
        A.at(i)--;
    }
    vector<int> cnt(N,0);
    for (int i = 0; i < N; ++i){
        cnt.at(A.at(i))++;
    }

    long long tot = 0;
    for (int i = 0; i < N; ++i){
        tot += choose2(cnt[i]);
    }

    for (int i = 0; i < N; ++i){
        long long ans = tot;
        ans -= choose2(cnt.at(A.at(i)));
        ans += choose2(cnt.at(A.at(i)) - 1);
        cout << ans << endl;
    }

        return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n; cin>> n;

    long double sum= 0, x;
    string u;

    for(int i=0; i<n; i++)
    {
        cin>> x>> u;

        sum += (u== "JPY" ? x : x* 380000);
    }

    cout << fixed << setprecision (8) << sum;
    nl;

    return 0;
}




Measured memory_bytes: 3856
#include<bits/stdc++.h>
#define double long double
//↓TLE,MLE魔!!!
#define int long long
//↑TLE,MLE魔!!!
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main() {
	long long x;
	cin>>x;
	if(x%11==0)cout<<x/11*2<<endl;
	else if(x%11<=6)cout<<x/11*2+1<<endl;
	else cout<<x/11*2+2<<endl;
}


Measured memory_bytes: 256
n,m,c = map(int, input().split())

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

cnt = 0
for i in range(n):
    temp = list(map(int, input().split()))
    judge = 0
    for i,a in enumerate(temp):
        judge = judge + b[i]*a
    judge = judge + c
    if judge > 0:
        cnt = cnt + 1

print(cnt)




Measured memory_bytes: 3060
import itertools

[N,M,X] = list(map(int,input().split()))
CA = []
for i in range(N):
    CA.append(list(map(int,input().split())))
#print('CA:', CA)   ###############

#かう１ 買わない0
a = [0,1]
Ls = list(itertools.product(a, repeat=N))
#print('Ls:', Ls)  #############

ans=100000000
for L in Ls:
    #print('L:            ', L)   #############
    cost=0
    rikai=[0]*(M+1)
    hon=0
    flag=0
    for l in L:
        #print('l,hon:',l,hon)
        if l==1:  #買うなら
            cost+=CA[hon][0]
            #print('CA[hon]:', CA[hon])
            for i in range(1,M+1):
                rikai[i]+=CA[hon][i]
            #print('rikai:', rikai)

        hon+=1

    #理解度X以上あるかcheck
    #print('rikai, cost:', rikai,cost)
    for i in range(1,M+1):
        if rikai[i]<X:  #理解度X未満があったら
            flag=1
    #print('flag:', flag)
    if flag==0:  #理解度すべてX以上
        ans=min(ans,cost)
    else:  #理解度X未満
        continue
if ans==100000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 74752
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int mod;
using uint = unsigned;
struct Z {
    uint v;

    Z(uint v = 0) : v(v) {}

    Z& operator += (const Z &z) {
        v += z.v;
        if (v >= mod) v -= mod;
        return *this;
    }

    Z& operator -= (const Z &z) {
        if (v < z.v) v += mod;
        v -= z.v;
        return *this;
    }

    Z& operator *= (const Z &z) {
        v = static_cast<uint64_t>(v) * z.v % mod;
        return *this;
    }
};

ostream& operator << (ostream &os, const Z &z) {
    return os << z.v;
}

Z operator + (const Z &x, const Z &y) {
    return Z(x.v + y.v >= mod ? x.v + y.v - mod : x.v + y.v);
}

Z operator - (const Z &x, const Z &y) {
    return Z(x.v < y.v ? x.v + mod - y.v : x.v - y.v);
}

Z operator * (const Z &x, const Z &y) {
    return Z(static_cast<uint64_t>(x.v) * y.v % mod);
}

Z qpow(Z base, uint e) {
    Z ret(1);
    for (; e; e >>= 1) {
        if (e & 1) {
            ret *= base;
        }
        base *= base;
    }
    return ret;
}

int qpow(int base, int e, int mod) {
    int ret = 1;
    for (; e; e >>= 1) {
        if (e & 1) {
            ret = (LL) ret * base % mod;
        }
        base = (LL) base * base % mod;
    }
    return ret;
}

const size_t N = 3e3 + 5;

Z pw1[N], pw2[N], comb[N][N];
Z stir[N][N];

int main() {
    int n = read();
    mod = read();
    for (int i = 0; i <= n; ++i) {
        pw1[i] = qpow(2, i);
        pw2[i] = qpow(2, qpow(2, i, mod - 1));
    }
    comb[0][0] = 1;
    stir[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        comb[i][0] = 1;
        for (int j = 1; j <= i; ++j) {
            stir[i][j] = stir[i - 1][j - 1] + stir[i - 1][j] * j;
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
        }
    }
    Z ans = 0;
    for (int i = 0; i <= n; ++i) {
        Z cur = i == 0;
        for (int j = 1; j <= i; ++j) {
            cur += stir[i][j] * j * qpow(pw1[n - i], j - 1);
            cur += stir[i][j] * qpow(pw1[n - i], j);
        }
        cur *= comb[n][i] * pw2[n - i];
        if (i & 1) {
            ans -= cur;
        } else {
            ans += cur;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 70784
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1;i<=n;i++) {
		for (int j = 1;j<=n;j++) {
			if (i*j < n)cnt++;
			if(i*j>n) break;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define mod ((int)1e9+7)
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)2e3+5;

vector<int> v[N];
int dp[N][N];
void bfs(int source) {
    dp[source][source] = 0;
    queue<pair<int,int>> q;
    q.push({0,source});
    while(!q.empty()) {
        pair<int,int> x = q.front();
        q.pop();
        for(auto it:v[x.second]) {
            if(dp[source][it]==(-1)) {
                dp[source][it] = 1 + x.first;
                q.push({dp[source][it],it});
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,x,y;
    cin>>n>>x>>y;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<n;i++) {
        v[i].push_back(i+1);
        v[i+1].push_back(i);
    }
    v[x].push_back(y);
    v[y].push_back(x);
    for(int i=1;i<=n;i++) {
        bfs(i);
    }
    vector<int> ans(n);
    for(int i=1;i<=n;i++) {
        for(int j=1;j<i;j++) {
            if(dp[i][j]>0 && dp[i][j]<n) {
                ans[dp[i][j]]++;
            }
        }
    }
    for(int i=1;i<n;i++) {
        cout<<ans[i]<<"\n";
    }
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    long long ans = 0;
    rep(i, 0, n) {
        ans += distance(a.begin(), lower_bound(a.begin(), a.end(), b[i])) *
               distance(upper_bound(c.begin(), c.end(), b[i]), c.end());
    }
    cout << ans << endl;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int N;
	int rate[9] = {};
	cin >> N;
	for(int i = 0; i < N; i++){
		int in;
		cin >> in;
		if(in < 400)
			rate[0]++;
		else if(in < 800)
			rate[1]++;
		else if(in < 1200)
			rate[2]++;
		else if(in < 1600)
			rate[3]++;
		else if(in < 2000)
			rate[4]++;
		else if(in < 2400)
			rate[5]++;
		else if(in < 2800)
			rate[6]++;
		else if(in < 3200)
			rate[7]++;
		else
			rate[8]++;
	}

	int cnt = 0;
	for(int i = 0; i < 8; i++)
		if(rate[i] > 0)
			cnt++;

	cout << max(1,cnt) << " " << cnt + min(N-cnt, rate[8]) << endl;

	return 0;
}

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


// ------------------------

void solve() {
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K; cin >> K;

    cout  << v[K-1] << endl;

    // cout << ans << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i

if n == 0
  p 0
  exit
end

str = ""
i = 0
while n != 0
  if n % 2 != 0
    n -= 1
    str = '1' + str
  else
    str = '0' + str
  end

  n /= -2
end

puts str


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3088
rooms = [[[0] * 10 for _ in range(3)] for _ in range(4)]
n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    rooms[b-1][f-1][r-1] += v

for i in range(4):
    if i > 0:
        print('#' * 20)
    for j in range(3):
        rooms[i][j][0] = ' ' + str(rooms[i][j][0])
        print(*rooms[i][j])


Measured memory_bytes: 5620
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
using namespace std;

int main(){
    int K;
    cin>>K;
    int S[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<S[K-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=1e5+10;
int n,a[N],o,e;

bool solve(){
	if (!e) return 0;
	if (e&1) return 1;
	if (o!=1) return 0;
	else{
		int g=0;
		rep (i,1,n)
			if (a[i]!=1){
				if (a[i]&1) a[i]--;
				g=__gcd(g,a[i]);
			}
		e=o=0;
		rep (i,1,n)
			if (a[i]!=1){
				a[i]/=g;
				if (a[i]!=1) o+=a[i]&1,e+=!(a[i]&1);
			}
		return solve()^1;
	}
}

int main(){
	scanf("%d",&n);
	rep (i,1,n){
		scanf("%d",&a[i]);
		if (a[i]!=1) o+=a[i]&1,e+=!(a[i]&1);
	}
	puts(solve()?"First":"Second");
	return 0;
}

Measured memory_bytes: 768
a,b=map(int,input().split())
s=list(str(input()))
def count(List):
  num=0
  for i in range(len(List)):
    if List[i]=='-':
      num+=1
  return num
if count(s)!=1:
  print('No')
else:
  if s[a]=='-':
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a[3];
	rep(i, 3) cin>>a[i];
	sort(a, a+3);
	bool even = false;
	rep(i, 3) if(a[i]%2==0) even = true;
	if(even){
		cout<<0<<endl;
	} else {
		cout<<a[0]*a[1]<<endl;
	}
	return 0;
}


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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n,k; cin>>n>>k;
    vi arr[2]; arr[0].resize(n + 1); arr[1].resize(n + 1);
    FOR(i, 0, n) cin>>arr[0][i];
    int turn = 1;
    FOR(kk, 0, k) {
        FOR(i, 0, n) {
            arr[turn][i] = 0;
        }
        
        FOR(i, 0, n) {
            int l = max(0LL, i - arr[1 - turn][i]);
            int r = min(n - 1LL, i + arr[1 - turn][i]);

            arr[turn][l]++;
            arr[turn][r + 1]--;
        }

        FOR(i, 1, n) {
            arr[turn][i] += arr[turn][i - 1];
        }

        bool br = true;
        FOR(i, 0, n) {
            if(arr[turn][i] != arr[1 - turn][i]) {
                br = false; break;
            }
        }

        if (br || kk == k - 1) {
            FOR(i, 0, n) {
                cout<<arr[turn][i] << " ";
            }
            break;
        }

        turn = 1 - turn;
    }

    return 0;
}

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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int N=50+3;
const int M=998244353;


int main(){



	ll n;
	sfl(n)

	ll N=n;

	vector<ll> cnt;

	for(ll i=2;i*i<=N;i++){
		int c=0;
		while(n%i==0){
			n/=i;
			++c;
		}
		if(c!=0)
			cnt.push_back(c);
	}

	if(n!=1)
		cnt.push_back(1);

	int ans=0;

	for(int x:cnt){
		int j=1;

		for(j=1;;++j){
			if(((j*(j+1))/2)>x){
				break;
			}
		}
		ans+=(j-1);
	}

	cout<<ans;
	return 0;
}

Measured memory_bytes: 3692
n=int(input())
s=[]
ans=0
count=1
def comb(n,k):
  for i in range(k-1):
    n*=n-i-1
    k*=k-i-1
  return n//k

for i in range(n):
  a=list(input())
  a.sort()
  " ".join(a)
  s.append(" ".join(a))
s.sort()
for i in range(n-1):
  if s[i]==s[i+1]:
    count+=1
  else:
    ans+=(comb(count,2))
    count=1
if count>0:
  ans+=(comb(count,2))
print(ans)

Measured memory_bytes: 11372
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int a[5];
	char ans[5];
	string b;
	cin>>b;
	for(int i=0;i<4;i++){
		a[i]=b[i]-'0';
		ans[i]='+';
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			int sum=0;
			for(int k=0;k<4;k++){
				if(k==i  && k!=0 || k==j && k!=0){
					sum-=a[k];
				}
				else{
					sum+=a[k];
				}
			}
			if(sum==7){
				ans[i]='-';
				ans[j]='-';
				cout<<a[0]<<ans[1]<<a[1]<<ans[2]<<a[2]<<ans[3]<<a[3]<<"="<<"7"<<endl;
				return(0);
			}
		}
	}
	
    return(0);
}

Measured memory_bytes: 3656
while True :
    n = int(input())
    if n == 0 :
        break
    
    magic = list([0] * n for i in range(n))
    x = (n+1)//2 - 1
    y = (n+1)//2 - 2
    for i in range(1, n**2+1) :
        x += 1
        y += 1
        while True :
            if x >= n :
                x = 0
            if y >= n :
                y = 0
            if magic[x][y] != 0 :
                x += 1
                y -= 1
                if y == -1 :
                    y = n - 1
            if x < n and y < n and magic[x][y] == 0 :
                break
        magic[x][y] = i
        
    for i in range(n) :
        for j in range(n) :
            print('{:4}'.format(magic[i][j]), end="")
        print()
            


Measured memory_bytes: 5636
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S, T; cin>>S>>T;
  sort(S.begin(), S.end());
  sort(T.begin(), T.end(), greater<char>());
  bool can = false;
  bool owari = false;
  for(int i=0;i<S.size();++i) {
    if(S[i]<T[i]) {
      can = true;
      owari = true;
      break;
    }
    else if(S[i]>T[i]) {
      can = false;
      owari = true;
      break;
    }
  }
  if(!owari && S.size()<T.size()) can = true;
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3620
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int N,W;
ll dp[101][100001]={};
int main(void){
    cin>>N>>W;
    int w[N],v[N];
    for(int i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0){
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
            }
        }
    }
    cout<<dp[N][W]<<endl;
   return 0;
}

Measured memory_bytes: 78336
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::min;

fn main() {
    let nab:Vec<u8>=read_vec();
    println!("{}", min(nab[0]*nab[1],nab[2]));
}


Measured memory_bytes: 4352
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n = lines.next().unwrap().unwrap().parse::<u8>().unwrap();
    let s = lines.next().unwrap().unwrap();

    let ans = s
        .bytes()
        .map(|b| ((b - b'A' + n) % 26 + b'A') as char)
        .collect::<String>();

    println!("{}", ans);
}


Measured memory_bytes: 4352
from collections import deque

h, w = map(int,input().split())
field = [list(input()) for i in range(h)]
seen = [[False]*w for i in range(h)]
dis = [[0]*w for i in range(h)]

sx, sy = 0, 0
gx, gy = h-1, w-1

que = deque([[sx, sy]])

while len(que) != 0:
    x, y = que.popleft()
    for i, j in ([1,0], [0,1], [-1,0], [0,-1]):
        px, py = x+i, y+j
        
        if px < 0 or px > h-1 or py < 0 or py > w-1:
            continue
        
        if field[px][py] == '#':
            continue
        
        if seen[px][py]:
            continue
        
        else:
            dis[px][py] = dis[x][y] + 1
            seen[px][py] = True
            que.append([px, py])

if dis[gx][gy] == 0:
    print(-1)
    exit()

c_dot = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == '.':
            c_dot += 1

print(c_dot-dis[gx][gy]-1)


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

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

    double min = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        min += a.at(i);
    }

    min = min / (4 * m);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a.at(i) >= min) cnt++;
    }

    if (cnt >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }   

    return 0;
}


Measured memory_bytes: 3616
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  reverse(a, a+3);
  cout << a[0]*10+a[1]+a[2] << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

def bellmanford(N, s, graph):
  dist = [sys.maxint] * N
  dist[s] = 0
  for i in xrange(N):
    for v in xrange(N):
      if v not in graph: continue
      for k in xrange(len(graph[v])):
        edge = graph[v][k]
        if dist[v] != sys.maxint and dist[edge[0]] > dist[v] + edge[1]:
          dist[edge[0]] = dist[v] + edge[1]
          if i == N-1: return []
  return dist

V,E,r = map(int, raw_input().split())
graph = {}
for _ in xrange(E):
  s,t,d = map(int, raw_input().split())
  if s not in graph:
    graph[s] = []
  graph[s].append([t,d])
costs = bellmanford(V, r, graph)
if len(costs) == 0:
  print "NEGATIVE CYCLE"
else:
  for i in xrange(V):
    if costs[i] == sys.maxint:
      print "INF"
    else:
      print costs[i]

Measured memory_bytes: 6608
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

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


int main() { 
	long long a, b, n; cin>> a >> b >> n;
	ll ans, m = n;
	if (n >= b) {
		m = b - 1;
	}
	ans = (ll)(1.0*a*m/b) - a*(ll)(1.0*m/b);
	cout<<ans;
	return 0;
} 




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
int d[60];
bool dp[2][1<<24];
int main(){
	int n;scanf("%d",&n);
	int Max=0;
	rep(i,n){
		scanf("%d",&d[i]);
	}
	dp[1][0]=true;
	rep(i,n){
		rep(j,1<<24)dp[i%2][j]=false;
		rep(j,1<<24){
			if(dp[!(i%2)][j]==false)continue;
			if(!(j>>d[i]&1))dp[i%2][j|1<<d[i]]=true;
			if(d[i]&&!(j>>(24-d[i])&1))dp[i%2][j|1<<(24-d[i])]=true;
		}
	}
	rep(i,1<<24){
		if(!dp[!(n%2)][i])continue;
		vector<int>v;
		rep(j,24){
			if(i>>j&1)v.push_back(j);
		}
		int sum=INT_MAX;
		rep(i,v.size()){
			sum=min(sum,d[i]);
			if(n>1){
				if(i<v.size()-1){
					int A=v[i+1]-v[i];
					sum=min({sum,A,24-A});
				}
				else{
					int A=v.back()-v.front();
					sum=min({sum,A,24-A});
				}
			}
		}
		Max=max(Max,sum);
	}
	cout<<Max<<endl;
}

Measured memory_bytes: 33024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(int&a,int b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;

int X,N;
bool used[106];
signed main()
{
	cin>>X>>N;
	vi p(N);
	rep(i,N){
		cin>>p[i];
		used[p[i]] = true;
	}

	int mn = inf;
	int ans=-1;
	for (int i = 0; i <= 105; i++) {
		if (used[i]) continue;
		if (chmin(mn, abs(X - i))) {
			ans=i;
		}
	}

	cout<<ans<<endl;
}




Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
  long long int h, w;
  while(1) {
    cin >> h >> w;

    if(h == 0 && w == 0) break;
    
    for(int j=0; j<h; j++) {
        for(int i=0; i<w; i++) {
            if(j == 0 || j == h-1) {
                cout << "#";
            } else if(i == 0 || i == w-1) {
                cout << "#";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
  
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
class Integer
  MOD = 1000000007
  @@inverse = {}
  def plus(other)
    (self + other) % MOD
  end
  def minus(other)
    (self - other) % MOD
  end
  def mult(other)
    ((self % MOD) * (other % MOD)) % MOD
  end
  def divi(other)
    ((self % MOD) * other.inverse) % MOD
  end
  def power(n)
    res = 1
    a = self
    while (n > 0) do
      res = res.mult(a) if n[0]==1
      a = a.mult(a)
      n = n >> 1
    end
    res
  end
  def inverse
    @@inverse[self] ||= self.power(MOD-2)
  end
end

def combi(n,k)
  return 0 if n < k
  k=n-k if 2*k > n
  return 1 if k == 0
  (((n-k+1)..n).reduce(&:mult)).divi ((1..k).reduce(&:mult))
end

N, K = gets.split(' ').map(&:to_i)
R = N - K
(1..K).each do |i|
  puts combi(N-K+1, i).mult combi(K-1, i-1)
end

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N=110;
char a[N][N];
int n,m,r[N],c[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(a[i][j]=='#')r[i]=c[j]=1;
	for(int i=1;i<=n;i++){
		if(!r[i])continue;
		for(int j=1;j<=m;j++)
			if(c[j])cout<<a[i][j];
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long a, long long b){ 
    if (a == 0) 
       return b;
       return gcd(b%a,a);
}
  
int main()
{
    long long a,b,max;
    cin>>a>>b;
    max=(a*b)/gcd(a,b);
    
    cout<<max;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[2020][2020],n,x,y,cnt[2020];
int main()
{
    memset(arr,1,sizeof(arr));
    cin>>n>>x>>y;
    for(int i=1;i<=n;++i)
    {
        for(int j=i;j<=n;++j)
            arr[i][j]=arr[j][i]=j-i;
    }
    arr[x][y]=1;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j) {
            if (arr[i][x] + arr[x][j] < arr[i][j])
                arr[i][j] = arr[j][i] = arr[i][x] + arr[x][j];
            if (arr[i][y] + arr[y][j] < arr[i][j])
                arr[i][j] = arr[j][i] = arr[i][y] + arr[y][j];
        }
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=i+1;j<=n;++j)
            cnt[arr[i][j]]++;
    }
    for(int i=1;i<=n-1;++i)
        printf("%lld\n",cnt[i]);
    return 0;
}

Measured memory_bytes: 32128
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    int x,a,b;
    while(cin>>x>>a>>b){
        a=abs(x-a);
        b=abs(x-b);
        if(a<b) cout<<"A"<<endl;
        else cout<<"B"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  double A,B,H,M;
  cin >> A >> B >> H >> M;
  complex<double> p = polar(A,(H+M/60)/12*2*M_PI);
  complex<double> q = polar(B,M/60*2*M_PI);
  cout << setprecision(16) << abs(p-q) << endl;
  return 0;
}

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

int main() {
	// エラトステネスのふるい

	const int MaxOfPrimeX = 100003;	// 100000以上で最小の素数
	vector<bool> primes(MaxOfPrimeX + 1, true);
	int Limit = static_cast<int>(sqrt(MaxOfPrimeX));

	for (int i = 2; i <= Limit; i++) {
		if (primes[i]) {
			for (int j = 2 * i; j <= MaxOfPrimeX; j++) {
				if (j % i == 0) {
					primes[j] = false;
				}
			}
		}
	}

	int x; cin >> x;
	for (int i = x; i <= MaxOfPrimeX; i++) {
		if (primes[i]) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# ABC 104 C - All Green(my answer for bit)

D, G = map(int, input().split())
p, c = [], []
ans = float('inf')
for _ in range(D):
    a, b = map(int, input().split())
    p.append(a)
    c.append(b)

for bit in range(1 << D):  # bitで完答した問題を列挙
    score = 0
    cnt = 0
    comp = set(range(D))
    for i in range(D):  # 完答した問題のscoreを全て加算
        if bit & (1 << i):
            score += p[i] * 100 * (i + 1) + c[i]
            cnt += p[i]
            comp.discard(i)
    if score < G:  # scoreがGに満たなければ中途半端に解答する
        incomp = max(comp)
        incomp_num = min(p[incomp],
                         -(-(G - score) // (100 * (incomp + 1))))
        score += (incomp + 1) * incomp_num * 100
        cnt += incomp_num
    if score >= G:  # scoreが目標点G以上なら計算回数cntを記録
        ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 9244
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
struct node{
	int x,y,h;
};
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	vector<struct node>v;
	for(int i=0;i<n;i++){
		int x,y,h;
		cin>>x>>y>>h;
		if(h!=0){
			struct node a;
			a.x=x;
			a.y=y;
			a.h=h;
			v.pb(a);
		}
	}
	//cout<<0<<endl;
	int ma=v.size();
	//cout<<ma<<endl;
	if(ma==1){
		cout<<v[0].x<<" "<<v[0].y<<" "<<v[0].h<<endl;
		return 0;
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			int count=1;
			for(int k=1;k<ma;k++){
				int lhs=v[k].h-v[k-1].h;
				int rhs=abs(v[k-1].x-i)+abs(v[k-1].y-j)-abs(v[k].x-i)-abs(v[k].y-j);
				//cout<<lhs<<" "<<rhs<<endl;
				if(lhs!=rhs){
					break;
				}
				count++;				
			}
			//cout<<i<<" "<<j<<" "<<count<<endl;
			if(count==ma){
				cout<<i<<" "<<j<<" "<<v[0].h+abs(v[0].x-i)+abs(v[0].y-j)<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll ans=0;
    rep(i,60){
        ll x=0;
        rep(j,n) if(a[j]>>i&1) x++;
        ll y=x*(n-x)%mod;
        ans+=y*rep_jijo(2,i);
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repin(Array,n) for(int i=0;i<n;i++){cin>>Array[i];}
using namespace std;

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	int N;
	cin >> N;

	int ans = 0;
	int now = 0;
	rep(i, N) {
		int tmp = i + 1;
		int count = 0;
		while (tmp % 2 == 0) {
			tmp /= 2;
			count++;
		}
		if (now <= count) {
			now = count;
			ans = i + 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def merge(A, left, mid, right):
	global cnt

	L = A[left:mid] + [1000000001]
	R = A[mid:right] + [1000000001]

	i = j = 0
	for k in range(left, right):
		if L[i] <= R[j]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1
	cnt += right - left

def mergeSort(A, left, right):
	if left + 1 < right:
		mid = (left + right) // 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)

if __name__ == '__main__':
	n = int(input())
	A = list(map(int, input().split()))
	cnt = 0
	mergeSort(A, 0, n)
	print(*A)
	print(cnt)

Measured memory_bytes: 63732
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

void compress(vector<int> &s, vector<int> &t, vector<int> &d) {
    vector<int> vec;
    for (int v: s) vec.push_back(v);
    for (int v: t) vec.push_back(v);
    for (int v: d) vec.push_back(v);
    sort(vec.begin(), vec.end());
    
    map<int, int> mp;
    rep(i, vec.size()) mp[vec[i]] = i + 1;
    
    for (int &v: s) v = mp[v];
    for (int &v: t) v = mp[v];
    for (int &v: d) v = mp[v];
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> s(n), t(n), x(n), d(q);
    rep(i, n) {
        cin >> s[i] >> t[i] >> x[i];
        t[i]--;
        s[i] -= x[i];
        t[i] -= x[i];
    }
    cin >> d;
    compress(s, t, d);
    
    const int INF = 2000000000;
    vector<vector<int>> min_xs(700000, vector<int>(1, INF));
    rep(i, n) {
        if (t[i] < 0) continue;
        min_xs[max(0, s[i])].push_back(x[i]);
        min_xs[t[i] + 1].push_back(-x[i]);
    }
    
    vector<int> min_x(700000);
    map<int, int> mp;
    rep(i, 700000) {
        for (int x: min_xs[i]) {
            if (0 <= x) mp[x]++;
            else {
                mp[-x]--;
                if (mp[-x] == 0) mp.erase(-x);
            }
        }
        min_x[i] = mp.begin()->first;
    }
    
    rep(i, q) {
        if (min_x[d[i]] == INF) cout << -1 << endl;
        else cout << min_x[d[i]] << endl;
    }
}

Measured memory_bytes: 54772
#include <stdio.h>
int main(void){
    // Here your code !
    int i,j;
    int n = 0;
    scanf("%d",&n);
    int a[100] = {};
    int c[15] = {};
    int min = 0;
    int max = 0;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]/400 < 8){
            c[a[i]/400] += 1;
        }
        else if(a[i]/400 >= 8){
            c[8] += 1;
        }
    }
    for(j=0;j<8;j++){
        if(c[j]>0){
            min += 1;
        }
        
    }
    max = min + c[8];
   
    if(min==0){
        min++;
     }
    
    printf("%d %d ",min,max);
    
    
    return 0;
    
}

Measured memory_bytes: 128
#include <stdio.h>

int bub(int[],int);

int main(){
  int n,i,j=0,put,flag,con = 0;
  int a[100];
  
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  while(j != n-1){
  for(i = n-1;i >= j+1;i--){
    if(a[i-1] > a[i]){
      put = a[i];
      a[i] = a[i-1];
      a[i-1] = put;
      con++;
    }
  }
  j++;
  }
  for(i = 0;i < n;i++){
    if(i != 0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",con);

  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

const int bits = 15;
const int limit = 1 << bits;

int n, i, x, y, z, ans;
vector< pair<int, int> > list[maxN];
int dp[limit];
priority_queue< pair<int, int>, vector< pair<int, int> >, greater< pair<int, int> > > H;
int tp;

void pre() {
    int i, j, to, aux, cnt = 0;

    for (i = 0; i < limit; i++) dp[i] = bits + 1;
    dp[0] = 0;
    H.push(mp(0, 0));

    while (!H.empty()) {
        int conf = H.top().second;
        int cost = H.top().first;
        H.pop();

        if (dp[conf] != cost) continue;
        cnt++;

        for (i = 0; i < bits; i++) {
            for (j = 0; j < bits; j++) {
                if (i == j) continue;
                to = conf ^ (1 << i) ^ (1 << j);

                aux = 1 << (((i + 1) ^ (j + 1)) - 1);
                //if (conf & aux) continue;
                to ^= aux;

                if (dp[to] > dp[conf] + 1) {
                    dp[to] = dp[conf] + 1;
                    H.push(mp(dp[to], to));
                }
            }

            to = conf ^ (1 << i);
            if (dp[to] > dp[conf] + 1) {
                dp[to] = dp[conf] + 1;
                H.push(mp(dp[to], to));
            }
        }
    }

    //for (i = 0; i < 256; i++) cerr << dp[i] << ' ';
    //cerr << '\n';

    cerr << limit - cnt << '\n';
}

void dfs(int node, int root, int need) {
    int act = 0;

    for (auto to : list[node])
        if (to.first != root)
            dfs(to.first, node, to.second), act ^= to.second;

    if (node != 1 && act != need)
        tp ^= ((1 << (act ^ need)) >> 1), ans++;
}

int main()
{
   // freopen("test.in","r",stdin);

    cin >> n;
    pre();
    for (i = 1; i < n; i++) {
        cin >> x >> y >> z;
        x++; y++;
        list[x].pb(mp(y, z));
        list[y].pb(mp(x, z));
    }

    dfs(1, 0, 0);
    ans += dp[tp];

    if (ans % 1) cerr << "Error";
    cout << ans / 2 << '\n';


    return 0;
}


Measured memory_bytes: 13436
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun main(a b)
  (min (mod a b) (- b (mod a b))))

(princ (main (read) (read)))


Measured memory_bytes: 18744
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  ll A[N];
  ll ans = 1;
  vector<pair<ll,ll>> Z;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    Z.push_back(make_pair(abs(A[i]),i));
  }
  sort(Z.begin(),Z.end());
  reverse(Z.begin(),Z.end());
  int minus = 0;
  for (int i = 0; i < K; i++) {
    if (A[Z[i].S] < 0) {
      minus++;
    }
    if (A[Z[i].S] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  if (minus % 2 == 0) {
    for (int i = 0; i < K; i++) {
      ans *= A[Z[i].S];
      ans %= Mod;
    }
    cout << ans << endl;
    return 0;
  } else {
    // 最小- を + に
    // 最小+ を - に
    long double way1 = -1.0;
    long double way2 = -1.0;
    int in1 = -1;
    int in2 = -1;
    for (int i = K; i < N; i++) {
      if (A[Z[i].S] > 0) {
        in1 = i;
        break;
      }
    }
    for (int i = K; i < N; i++) {
      if (A[Z[i].S] < 0) {
        in2 = i;
        break;
      }
    }
    int in1_2 = -1;
    int in2_2 = -1;
    for (int i = K-1; i >= 0; i--) {
      if (A[Z[i].S] < 0) {
        in1_2 = i;
        break;
      }
    }
    for (int i = K-1; i >= 0; i--) {
      if (A[Z[i].S] > 0) {
        in2_2 = i;
        break;
      }
    }

    if (in1 != -1 && in1_2 != -1) {
      way1 = (long double)A[Z[in1_2].S] / (long double)A[Z[in1].S];
      way1 *= -1;
    }
    if (in2 != -1 && in2_2 != -1) {
      way2 = (long double)A[Z[in2_2].S] / (long double)A[Z[in2].S];
      way2 *= -1;
    }

    if (way1 == -1 && way2 == -1) {
      for (int i = N-1; i >= N - K; i--) {
        ans *= A[Z[i].S];
        ans %= Mod;
      }
      if (ans < 0) ans += Mod;
      cout << ans << endl;
      return 0;
    } else if (way1 == -1 || way2 == -1) {
      if (way1 == -1) {
        for (int i = 0; i < K; i++) {
          if (i == in2_2) {
            ans *= A[Z[in2].S];
          } else {
            ans *= A[Z[i].S];
          }
          ans %= Mod;
        }
        if (ans < 0) ans += Mod;
        cout << ans << endl;
        return 0;
      } else {
        for (int i = 0; i < K; i++) {
          if (i == in1_2) {
            ans *= A[Z[in1].S];
          } else {
            ans *= A[Z[i].S];
          }
          ans %= Mod;
        }
        if (ans < 0) ans += Mod;
        cout << ans << endl;
        return 0;
      }
    } else {
      if (way1 >= way2) {
        for (int i = 0; i < K; i++) {
          if (i == in2_2) {
            ans *= A[Z[in2].S];
          } else {
            ans *= A[Z[i].S];
          }
          ans %= Mod;
        }
        if (ans < 0) ans += Mod;
        cout << ans << endl;
        return 0;
      } else {
        for (int i = 0; i < K; i++) {
          if (i == in1_2) {
            ans *= A[Z[in1].S];
          } else {
            ans *= A[Z[i].S];
          }
          ans %= Mod;
        }
        if (ans < 0) ans += Mod;
        cout << ans << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 8504
#include <math.h>
#include <stdio.h>
int main(void)
{
   double x1,y1,x2,y2;
   double kyori;
   scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
   kyori=sqrt((double)((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
   printf("%f\n",(double)kyori);
   return 0;
}



Measured memory_bytes: 2104