akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
//const ll MOD = 1e9+7;
const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

using T = ll;
const int MAX_V = 5e5;
//演算の内容
T f(T a, T b){return max(a, b);}
//何で初期化するか
T other = 0;

struct segment_tree{
    int n;
    T seg[2*MAX_V];
    //要素数N(0〜N-1)の初期化されたセグメント木を構築
    segment_tree(int N){
        n = 1;
        while(n < N) n *= 2;
        fill_n(seg, 2*n-1, other);
    }
    //i番目の要素をxに変更(0番目から数える)
    void update(int i, T x){
        i += n-1;
        seg[i] = x;
        while(i > 0){
            i = (i-1)/2;
            seg[i] = f(seg[2*i+1], seg[2*i+2]);
        }
    }
    //query(a, b)で[a, b)における演算の結果を取得
    T query(int a, int b, int i = 0, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(a >= r || b <= l) return other;
        elif(a <= l && r <= b) return seg[i];
        else{
            T vl = query(a, b, 2*i+1, l, (l+r)/2);
            T vr = query(a, b, 2*i+2, (l+r)/2, r);
            return f(vl, vr);
        }
    }
};

int main(){
    int N;
    cin >> N;
    pll p[N];
    rep(i, N){
        ll x, d;
        cin >> x >> d;
        p[i] = pll(x, x+d);
    }
    sort(p, p+N);
    ll L[N], R[N];
    rep(i, N){
        L[i] = p[i].first, R[i] = p[i].second;
    }
    segment_tree seg(N);
    rep(i, N){
        seg.update(i, i);
    }
    rep3(i, N-1, 0){
        int j = lower_bound(L, L+N, R[i])- L;
        seg.update(i, seg.query(i, j));
    }
    //a[i]:=i個目のロボットを起動したときにどこまで消滅するか
    int a[N];
    rep(i, N){
        a[i] = seg.query(i, i+1);
        //cout << a[i] << endl;
    }
    //dp[i]:=起動させるロボットがi番目以降のものだけであるときの組み合わせの数
    ll dp[N+1];
    dp[N] = 1;
    rep3(i, N-1, 0){
        dp[i] = dp[i+1] + dp[a[i]+1];
        dp[i] %= MOD;
    }
    cout << dp[0] << endl;
}

Measured memory_bytes: 14720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int s[400],l[400],p[400];
int m;
int w[400];
int dp[400][400]= {0};//dp[i番目まで見たとき][メロディ長]
int main(){
    cin >> n;
    
    for(int i=1;i<=n;i++){
        cin >> s[i] >> l[i] >> p[i];
        for(int j=s[i];j<=l[i];j++){
            dp[i][j] = max(dp[i][j],p[i]);
        }
    }
    for(int i=0;i<396;i++){
        if(i>=l[1]){
            for(int j=s[1];j<=l[1];j++){
                if(dp[1][i-j]!=0){
                    dp[1][i] = max(dp[0][i],dp[1][i-j]+p[1]);
                }
            }
        }
    }
for(int i=1;i<=n;i++){
        for(int j=1;j<=396;j++){
            dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
            if(j>=s[i]){
                for(int k=s[i];k<=l[i]&&k<=j;k++){
                    if(dp[i+1][j-k]!=0){
                        dp[i+1][j] = max(dp[i+1][j],dp[i+1][j-k]+p[i]);
                    }
                }
            }
        }
    }

    cin >> m;
    bool checker = false;
    for(int i=1;i<=m;i++){
        cin >> w[i];
        if(dp[n][w[i]]==0){
            checker = true;
        }
    }

    if(checker){
        cout << -1 << endl;
    }else{
        for(int i=1;i<=m;i++){
            cout << dp[n][w[i]] << endl;
        }
        
    }
    
    return 0;

}


Measured memory_bytes: 3592
#include <iostream>

constexpr int days[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
constexpr int ldays[12] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 };
bool is_leap_year(const int &n) {
	return (n % 400 == 0) || ((n % 100 != 0) && (n % 4 == 0));
}
void swap(int &ay, int &am, int &ad, int &by, int &bm, int &bd) {
	int y{ ay }, m{ am }, d{ ad };
	ay = by; am = bm; ad = bd; by = y; bm = m; bd = d;
}
bool foward(const int &ay, const int &am, const int &ad, const int &by, const int &bm, const int &bd) {
	return (ay < by) || ((ay == by) && ((am < bm) || (am == bm && ad < bd)));
}
int days_from_new_years_day(const int &y, const int &m, const int &d) {
	return (is_leap_year(y)) ? ldays[m - 1] + d - 1 : days[m - 1] + d - 1;
}
int days_among(int from_year, int from_month, int from_day, int to_year, int to_month, int to_day) {
	if (!foward(from_year, from_month, from_day, to_year, to_month, to_day)) swap(from_year, from_month, from_day, to_year, to_month, to_day);
	int res = days_from_new_years_day(to_year, to_month, to_day) - days_from_new_years_day(from_year, from_month, from_day);
	for (auto y = from_year; y < to_year; ++y) {
		if (is_leap_year(y)) res += 366;
		else res += 365;
	}
	return res;
}
int main() {
	int fy, fm, fd, ty, tm, td;
	for (; std::cin >> fy >> fm >> fd >> ty >> tm >> td && fy >= 0 && fm >= 0 && fd >= 0 && ty >= 0 && tm >= 0 && td >= 0;) {
		std::cout << days_among(fy, fm, fd, ty, tm, td) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int k,a,b;
    cin >> k >> a >> b;
    for(int i = a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void update(ll& x, ll& y) {
	ll low = -INT_INF, high = INT_INF;

	while(high - low > 200) {
		ll mid = (low + high) / 2;
		ll fmid = abs(x + mid) + abs(y - mid);
		ll fmid1 = abs(x + mid + 1) + abs(y - mid - 1);

		if(fmid1 < fmid) {
			low = mid;
		} else {
			high = mid;
		}
	}

	ll opt = low;

	for(ll i = low; i <= high; ++i) {
		if(abs(x + i) + abs(y - i) < abs(x + opt) + abs(y - opt)) {
			opt = i;
		}
	}

	x += opt;
	y -= opt;
}

const int MAXN = 307;
ll a[MAXN], d[MAXN], answ = 0;
int n, m, k;
ll dp[MAXN][MAXN];

void relax(ll& x, ll y) {
	x = (y < x ? y : x);
}

void init() {
	for(int i = 0; i < MAXN; ++i) {
		for(int j = 0; j < MAXN; ++j) {
			dp[i][j] = LL_INF;
		}
	}
}

void dump() {
#ifdef __LOCAL
	for(int i = 0; i < m; ++i) {
		cout << d[i] << ' ';
	}

	cout << '\n';
#endif
}

void solve() {
	init();
	cin >> n >> k;
	n += 2;
	m = n - 1;

	for(int i = 1; i < n - 1; ++i) {
		cin >> a[i];
	}

	for(int i = 0; i < m; ++i) {
		d[i] = a[i + 1] - a[i];
	}

	dump();
	dp[0][0] = 0;
	
	for(int i = 0; i < m; ++i) {
		for(int j = 0; j < m; ++j) {
			ll cur = 0;

			for(int i2 = i; i2 < m; ++i2) {
				cur += d[i2];	
				relax(dp[i2 + 1][j + 1], dp[i][j] + abs(cur));
			}
		}
	}

	cout << dp[m][m - k] / 2 << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main(){
  int a,n,i;
  cin>>a>>n;
  if(a>=n){
  	for(i=0;i<a;i++)
  		cout<<n;
  }
  else
	for(i=0;i<n;i++)
  		cout<<a;
  	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=1000005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int X[MAXN],p[MAXN],Y[MAXN],inv,Invlim,Lim,n,sum;
int upd(int x,int y){ return x+y>=mods?x+y-mods:(x+y<0?x+y+mods:x+y); }
int quick_pow(int x,int y)
{
	int ret=1;
	for (;y;y>>=1)
	{
		if (y&1) ret=1ll*ret*x%mods;
		x=1ll*x*x%mods;
	}
	return ret;
}
void Fwt_xor(int *a,int opt)
{
	for (int l=2;l<=Lim;l<<=1)
		for (int i=l>>1,j=0;j<Lim;j+=l)
			for (int k=j;k<j+i;k++) 
			{
				int x=a[k],y=a[k+i];
				a[k]=upd(x,y),a[k+i]=upd(x,-y);
			}
	if (opt!=1) 
		for (int i=0;i<Lim;i++) a[i]=1ll*a[i]*Invlim%mods;
}
int main()
{
	n=read(),Lim=1<<n;
	for (int i=0;i<Lim;i++) sum+=(p[i]=read());
	inv=quick_pow(sum,mods-2);
	Invlim=quick_pow(Lim,mods-2);
	for (int i=0;i<Lim;i++) 
	{
		p[i]=1ll*inv*p[i]%mods;
		Y[i]=mods-1;
	}
	p[0]=upd(p[0],-1);
	Y[0]=(1<<n)-1;
	Fwt_xor(p,1),Fwt_xor(Y,1);
	for (int i=0;i<Lim;i++) X[i]=1ll*Y[i]*quick_pow(p[i],mods-2)%mods;
	Fwt_xor(X,-1);
	for (int i=0;i<Lim;i++) printf("%d\n",upd(X[i],-X[0]));
	return 0;
}


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

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

Measured memory_bytes: 256
s=input()
t=input()
slen=len(s)
tlen=len(t)
min=tlen
def howdifferent(t1,t):
    count=0
    for i in range(len(t)):
        if t1[i]!=t[i]:
            count+=1
    return count
for i in range(slen-tlen+1):
    t1 = s[i:]
    if howdifferent(t1,t)<min:
        min = howdifferent(t1,t)
print(min)

Measured memory_bytes: 9136
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M,K;
int A[200010],B[200010];
int C[400010];
deque<int> D;

signed main(){
	cin>>N>>M>>K;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,M){
		cin>>B[i];
	}
	int sum=0;
	REP(i,N){
		sum+=A[i];
		if(sum<=K){
			D.push_back(A[i]);
		}
	}
	sum=0;
	REP(i,M){
		sum+=B[i];
		if(sum<=K){
			D.push_front(B[i]);
		}
	}
	int siz=D.size();
	REP(i,siz){
		C[i]=D[i];
		DEB(C[i])END
	}
	sum=0;
	int r=0;
	int ans=0;
	REP(l,siz){
		while(r<siz&&sum+C[r]<=K){
			sum+=C[r];
			r++;
		}
		DEB(l)DEB(r)END
		ans=max(ans,r-l);
		if(l==r){
			r++;
		}
		else{
			sum-=C[l];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 13048
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,k,a[N];
long double s[N];
long double ans;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>a[i],s[i]=s[i-1]+1.0*(a[i]+1)*0.5;
  for(int i=1;i+k-1<=n;i++){
    ans=max(ans,s[i+k-1]-s[i-1]);
  }
  cout<<fixed<<setprecision(8)<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
char S[200005];
int C[26];
int main() {
	scanf("%s", S);
	ll ans = 1;
	int len = strlen(S);
	for (int i = 0; i < len; ++i) {
		ans += i - C[S[i] - 'a'];
		++C[S[i] - 'a'];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
nums = input().split()
W = int( nums[0])
H = int( nums[1])
x = int( nums[2])
y = int( nums[3])
r = int( nums[4])
  
if (x - r) >= 0 and (x + r) <= W:
    if (y - r) >= 0 and (y + r) <= H:
        print( "Yes")
    else:
        print( "No")
else:
    print( "No")

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

const long long MAX_P = 200001;
const long long MOD = 1000000007;

// 入力はすべて正とする
// 素数判定O(√n)
bool is_prime(long long n) {
	for (long long i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return n != 1; // 1の場合は例外
}
// 約数の列挙O(√n)
vector<long long> divisor(long long n) {
	vector<long long> res;
	for (long long i = 1; i * i <= n; i++) {
  	if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) res.push_back(n / i);
		}
	}
	return res;
}
// 素因数分解O(√n)
map<long long, long long> prime_factor(long long n) {
	map<long long, long long> res;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

void solve(long long N){
	vector<long long> v = divisor(N);
	long long res = INF;
	// res = min(res, 1+N-2);
	for (auto x: v) {
		res = min(res, x+(N/x)-2);
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



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


int L[3001][3001];  
void lcs( string X, string Y, int m, int n )  
{  
   
    int i, j;  

    for (i = 0; i <= m; i++)  
    {  
        for (j = 0; j <= n; j++)  
        {  
        if (i == 0 || j == 0)  
            L[i][j] = 0;  
      
        else if (X[i - 1] == Y[j - 1])  
            L[i][j] = L[i - 1][j - 1] + 1;  
      
        else
            L[i][j] = max(L[i - 1][j], L[i][j - 1]);  
        }  
    }  

}

int main()
{
    string s,t;
    cin>>s>>t;
    
    lcs(s,t,s.length(),t.length());
    /*for(int i=0;i<=s.size();i++)
    {
        for(int j=0;j<=t.size();j++)
        cout<<L[i][j]<<" ";
        
        cout<<endl;
    }*/
    
    int x=s.size();
    int y=t.size();
    string lcss="";
    while(x>0 && y>0)
    {
        if(s[x-1]==t[y-1])
        {
            lcss+=s[x-1];
            x--;
            y--;
        }
        else if(L[x-1][y]>L[x][y-1])
        x--;
        else
        y--;
        
    }
    reverse(lcss.begin(),lcss.end());
    cout<<lcss;
    
}

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

int main(){
    int N;
    cin>>N;
    string s[100];
    for(int i=0;i<N;i++){
        cin>>s[i];
    }
    int M;
    cin>>M;
    string t[100];
    for(int i=0;i<M;i++){
        cin>>t[i];
    }
    int MAX=-1e9;
    for(int i=0;i<N;i++){
        int cnt=0;
        for(int j=0;j<N;j++){
            if(s[i]==s[j]) cnt++;
        }
        for(int j=0;j<M;j++){
            if(s[i]==t[j]) cnt--;
        }
        MAX=max(MAX,cnt);
    }

    if(MAX<0)cout<<0<<endl;
    else cout<<MAX<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,ans=0;
  cin>>n;
  vector<int> a(n);
  for(i=0;i<n;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  auto it1=a.begin();
  while(it1!=a.end()){
    auto it2=lower_bound(a.begin(),a.end(),(*it1)+3);
    ans=max(ans,(int)distance(it1,it2));
    it1=lower_bound(a.begin(),a.end(),(*it1)+1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll q,w;
  string s,t;
  char a[200],b[200],d[200];
  cin >> s >> t;
  q=s.length();
  w=t.length();
  rep(i,q)a[i]=s[i];
  rep(i,w)b[i]=t[i];
  sort(a,a+q);
  sort(b,b+w);
  rep(i,w)d[i]=b[w-1-i];
  rep(i,q)s[i]=a[i];
  rep(i,w)t[i]=d[i];
  if(s<t)printf("Yes");
  else printf("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;cin>>N>>K;vector<int> H(N);
    int D=1000000000;
    for(int i=0;i<N;i++){
        cin>>H.at(i);
    }sort(H.begin(),H.end());
    for(int j=0;j<=N-K;j++){
        D=min(D,H[j+K-1]-H[j]);
    }cout<<D<<endl;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		List<Pair>[] lists = new ArrayList[n];
		for (int i = 0; i < n; i++)
			lists[i] = new ArrayList<Pair>();
		while (true) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			if ((a | b | c) == 0)
				break;
			lists[a - 1].add(new Pair(b - 1, c));
		}
		int r = scanner.nextInt();
		StringBuilder builder = new StringBuilder();
		while (r-- > 0) {
			int[] b = new int[m];
			for (int i = 0; i < m; i++)
				b[i] = scanner.nextInt();
			int res = 0;
			for (Pair p : lists[0]) {
				res += b[p.b] * p.cost;
			}
			builder.append(res);
			for (int i = 1; i < n; i++) {
				res = 0;
				for (Pair pair : lists[i]) {
					res += b[pair.b] * pair.cost;
				}
				builder.append(' ').append(res);
			}
			builder.append('\n');
		}
		System.out.print(builder);
	}

	class Pair {
		int b, cost;

		public Pair(int b, int cost) {
			super();
			this.b = b;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Pair [b=" + b + ", cost=" + cost + "]";
		}

	}
}

Measured memory_bytes: 303312
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

bool ispal(string s){
    int i=0, j=s.length()-1;
    while(i<j){
        if(s[i]!=s[j])  return false;
        i++,j--;
    }
    return true;
}
int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    int n=s.length();
    string s1 = s.substr(0,n/2);
    string s2 = s.substr((n/2+1),n/2);
    if(ispal(s) && ispal(s1) && ispal(s2)){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    string s; cin >> s; s = s + 'T';
    int x, y; cin >> x >> y;
    vector<int> v1,v2;
    bool d = true;
    int cnt = 0;
    REP(i,s.size()){
        if (s[i]=='F') cnt++;
        if (s[i]=='T'){
            if(d)v1.push_back(cnt);
            else v2.push_back(cnt);
            cnt = 0;
            d = !d;
        }
    }
    int m = v1.size(), n = v2.size();
    vector<vector<bool>> dp1(m,vector<bool>(16005)), dp2(n+1,vector<bool>(16005));
    dp1[0][8000] = true; dp2[0][8000]= true;
    REP(i,m-1){
        REP(j,16005){
            if(dp1[i][j]) {dp1[i+1][j+v1[i+1]]=true;dp1[i+1][j-v1[i+1]]=true;}
        }
    }
    REP(i,n){
        REP(j,16005){
            if(dp2[i][j]) {dp2[i+1][j+v2[i]]=true;dp2[i+1][j-v2[i]]=true;}
        }
    }
    bool f = (8000+x-v1[0] >= 0 && dp1[m-1][8000+x-v1[0]] && dp2[n][8000+y]);
    cout << (f ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 16256
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<utility>
#include<tuple>
#include<queue>
#define LL long long
#define TT std::tuple<LL,int,int>
#define PP std::pair<int,int>
LL D[310];
LL ans;
int N;
std::vector<TT> A;
struct edge
{
	int to;
	LL cost;
};
std::vector<edge> list[310];


void dset(int N) {
	for (int i = 0; i < N; i++) {
		D[i] = 1 << 30;
	}
}
int main() {
	std::cin >> N;
	dset(N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			LL tmp;
			std::cin >> tmp;
			if (i >= j)continue;
			A.push_back(TT{ tmp,i,j });
		}
	}
	std::sort(A.begin(), A.end());
	std::unique(A.begin(), A.end());
	for (int jj = 0; jj < (int)A.size(); jj++) {
		dset(N);
		std::priority_queue<PP, std::vector<PP>, std::greater<PP>> pq;
		LL a;
		int b, c;
		std::tie(a, b, c) = A[jj];
		D[b] = 0;
		pq.push({ D[b],b });
		while (!pq.empty()) {
			PP p = pq.top();
			pq.pop();
			if (D[p.second] < p.first)continue;
			for (int k = 0; k < (int)list[p.second].size(); k++) {
				edge e = list[p.second][k];
				if (D[e.to] <= D[p.second] + e.cost)continue;
				D[e.to] = D[p.second] + e.cost;
				pq.push({ D[e.to],e.to });
			}
		}
		if (D[c] < a) {
			std::cout << -1 << std::endl;
			return 0;
		}
		if (D[c] > a) {
			list[b].push_back(edge{ c, a });
			list[c].push_back(edge{ b, a });
			ans += a;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define mod 1000000007
string s;
int dp[111111][4];
signed main(){
	cin>>s;
	for(int i=s.size();i>=0;i--){
		for(int j=3;j>=0;j--){
			if(i==s.size()){
				if(j==3)dp[i][j]=1;
			}
			else{
				if(s[i]=='?')dp[i][j]=dp[i+1][j]*3;
				else dp[i][j]=dp[i+1][j];
				if(j<3&&(s[i]=='?'||(j==0&&s[i]=='A')||(j==1&&s[i]=='B')||(j==2&&s[i]=='C')))dp[i][j]+=dp[i+1][j+1];
				dp[i][j]%=mod;
			}
		}
	}
	cout<<dp[0][0]<<endl;
	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n1,n2,bell;
  long long int tmp,money[1000],hess=0;
  string item[1000],ITEM,aizu,riri;

  while(1){

    cin >> n1;
    if(n1==0){
      break;
    }
    for(int i=0;i<n1;i++){
      cin >> item[i] >> money[i];
      //cout << i << endl;
    }

    /*for(int i=0;i<n1-1;i++){
      for(int j=n1-1;j>i;j--){
	if(money[j]<money[j-1]){
	  tmp=money[j];
	  money[j]=money[j-1];
	  money[j-1]=tmp;
	}
      }
      }*/
    
    cin >> n2;
    for(int i=0;i<n2;i++){
      cin >> ITEM >> bell;
      for(int j=0;j<bell;j++){
	cin >> aizu;
	for(int t=0;t<n1;t++){
	  if(item[t]==aizu){
	    hess+=money[t];
	    //cout << hess << endl;
	  }
	}
      }

      for(int j=0;j<n1;j++){
	if(item[j]==ITEM){
	  //cout << "Ai" << endl;
	  if(money[j]>hess){
	    money[j]=hess;
	  }
	  //cout << money[j] << endl;
	}
      }
      hess=0;
    }

    cin >> riri;
    for(int i=0;i<n1;i++){
      if(riri==item[i]){
	cout << money[i] << endl;
      }
    }
  }
  return (0);
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  for (int i = a; i <= b; i++)
  {
    string s = to_string(i);
    if(s[0]==s[4]&&s[1]==s[3]) ans++;
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    int q = readln.chomp.to!int;
    foreach (i; 0 .. q) {
        int[] tmp = readln.chomp.split.to!(int[]);
        a[tmp[0]..tmp[1]].reverse;
    }
    foreach (i, x; a) {
        x.write;
        if (i != n - 1) " ".write;
        else writeln;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)5e5 + 9;
int tt[N];
bool use[N];

int main(){
  fastIO;
  int n, k;
  cin >> n >> k;
  if(k == 1){
    cout << "No" << "\n";
    return 0;
  } 
  if(k == 2 * n - 1){
    cout << "No\n";
    return 0;
  }
  if(n == 2){
    cout << "Yes\n1\n2\n3";
    return 0;
  }
  if(k == 2){
    tt[n-1] = 3;
    tt[n] = 2;
    tt[n + 1] = 1;
    tt[n + 2] = 4;
    use[1] = true;
    use[2] = true;
    use[3] = true;
    use[4] = true;
  }
  else{
    tt[n-1] = 1;
    tt[n] = k;
    tt[n + 1] = k + 1;
    tt[n + 2] = 2;
    use[k] = true;
    use[k + 1] = true;
    use[1] = true;
    use[2] = true;
  }
  int p = 1;
  cout << "Yes\n";
  for(int i = 1; i <= 2 * n - 1; i ++ ){
    while(use[p]){
      p ++ ;
    }
    if(tt[i] == 0){
      tt[i]=p;
      use[p] = true;
    }
    cout << tt[i] << "\n";
  }
  for(int i = 1; i <= 2 * n - 1; i ++ ){
    if(!use[i]){
      assert(0);
    }
  }
  return 0;
}

Measured memory_bytes: 2560
tmp0 = input().split()
n = int(tmp0[0])
k = int(tmp0[1])
a = []
b = []
for i in range(n):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

arr = [0]*(10**5 + 1)
for i in range(n):
    arr[a[i]] += b[i]

count = 0
for i in range(10**5 + 1):
    count += arr[i]
    if count >= k:
        print(i)
        break


Measured memory_bytes: 13772
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int n,s=0,a[111];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++){
		if (a[i]!=a[i-1]){
		   s++;
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;

int a[100003],n,k;
bool vis[100003];
vector<int> v[100003];

ll ans=1;
void dfs(int s,int pa)
{
	vis[s]=1;
	for (int i=0; i<v[s].size(); i++)
	{
		int u=v[s][i];
		if (u==pa) continue;
		if (vis[u]) continue;
		a[u]=2;
				
		if (k-a[s]<0) ans=0;
		ans=ans*(k-a[s])%1000000007;
		a[s]++;		
		
		dfs(u,s);
	}
}
int main()
{
	cin>>n>>k; ans=k;
	
	for (int i=1; i<n; i++)
	{
		int x,y; cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	a[1]=1;
	dfs(1,-1);
	cout << ans;
 } 

Measured memory_bytes: 10880
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int INF = 1e9;

int H, W;
bool f;

void check(int y, int x, int py, int px, int total, vector< vector<int> > &v, vector<int> &h, vector<int> &w){
  int sum = 0, ty, tx;
  while(y < H - 1 && x < W - 1){
    if(v[y][x] == INF) { ty = y; tx = x; }
    else sum += v[y][x];
    y += py; x += px;
  }
  v[ty][tx] = total - sum;
  h[ty]--; w[tx]--;
}

vector< vector<int> > solve(vector< vector<int> > v, vector<int> &h, vector<int> &w){
  int cnt = 0;
  REP(i, H) REP(j, W) if(v[i][j] == INF) ++cnt;
  while(cnt != 0){
    bool flg = false;
    REP(i, H) if(h[i] == 1) { check(i, 0, 0, 1, v[i][W - 1], v, h, w); --cnt; flg = true; }
    REP(i, W) if(w[i] == 1) { check(0, i, 1, 0, v[H - 1][i], v, h, w); --cnt; flg = true; }
    if(!flg) { return vector< vector<int> >(); }
  }
  f = true;
  return v;
}

int main() {
  bool t = false;
  while(cin >>H && H){
    cin >>W;
    ++H; ++W;
    f = false;
    vector< vector<int> > v(H, vector<int>(W));
    vector<int> w(W, 0), h(H, 0);
    REP(i, H){
      REP(j, W){
        string s; cin >>s;
        if(s != "?") v[i][j] = atoi(s.c_str());
        else { v[i][j] = INF; h[i]++; w[j]++; }
      }
    }
    if(t) cout <<endl;
    t = true;
    vector< vector<int> > ans = solve(v, h, w);
    if(f) { REP(i, H) REP(j, W) if(v[i][j] == INF) cout <<ans[i][j] <<endl; }
    else cout <<"NO" <<endl;
  }
  return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

double dp[3340][3340];

int main(){
    fastcin();

    int n;
    cin >> n;
    vector<double> p(n);
    rep(i, n) cin >> p[i];
    dp[0][0] = 1;
    rep(i, n){
        rep(j, i+1){
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1.-p[i]);
        }
    }
    double ans = 0.;
    // cout << dp[n][2] << endl;
    REP(i, n/2+1, n+1) ans += dp[n][i];
    cout << decimal << ans << endl;
}

Measured memory_bytes: 78464
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int cnt[100010];
signed main(void)
{
	int n, m;
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		if(a == 1) {
			cnt[b-1]++;
		} else if(b == 1) {
			cnt[a-1]++;
		} else {
			cnt[a-1]++;
			cnt[b-1]++;
		}
	}

	bool flag = true;
	FOR(i, 1, n) {
		if(cnt[i]%2) flag = false;
	}
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


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

int main() {
    string S;
    cin >> S;
    bool p = S[0] == 'R';
    bool q = S[1] == 'R';
    bool r = S[2] == 'R';
    if (p and q and r) {
        cout << 3 << endl;
    } else if ((p and q) or (q and r)) {
        cout << 2 << endl;
    } else if (p or q or r) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int h,w;
  bool flg,FLG,tmp,TMP;
  while(cin >> h >> w && h||w){
    flg = true,tmp=false;
    for(int i=0;i<h;i++){
      FLG = flg,TMP=tmp;
      for(int j=0;j<w;j++){
    cout << (FLG ? "#" : ".");
    swap(FLG,TMP);
      }
      cout << endl;
      swap(flg,tmp);
    }
    cout << endl;
  }
}


Measured memory_bytes: 3088
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;
void read(int &x){
	char ch;bool ok;
	for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
	for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=1e5+10;
int mm,m,n,a[60];
long long f[60];
long long ans;
void dfs(int x,int n,long long sum){
	if(x==n/2+1){
		if(sum==m){
			long long now=a[1]>=0?(9-a[1]):(9+a[1]);
			for(rg int i=2;i<x;i++)now=now*(a[i]>=0?(10-a[i]):(10+a[i]));
			ans+=n&1?now*10:now;
		}
		return ;
	}
	if(sum+10ll*(f[n-x]-f[x-1])<m||sum-10ll*(f[n-x]-f[x-1])>m)return ;
	for(rg int i=-9;i<10;i++){
		a[x]=i;
		dfs(x+1,n,sum+1ll*a[x]*(f[n-x]-f[x-1]));
	}
}
int main(){
	read(m),mm=m;f[0]=1;
	while(mm)n++,mm/=10;
    for(rg int i=1;i<=18;i++)f[i]=f[i-1]*10;
	for(rg int i=n;i<=18;i++)dfs(1,i,0);
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,cnt;
  ll vlist[120000]={};
  cin >> n >> k;
  ll a,b;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    vlist[a]+=b;
  }
  for(int i=0;i<=120000;i++){
    cnt += vlist[i];
    if(cnt>=k){
      cout << i <<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1152
s=input()
S=[]
t=input()
T=[]
for i in range(len(s)):
    S.append(s[i])
for i in range(len(t)):
    T.append(t[i])
S.sort()
T.sort()
T.reverse()
for i in range(min(len(S),len(T))):
    ans=[S[i],T[i]]
    ans.sort()
    #print(ans)
    #print(S[i])
    #print(ans[0])
    if ans[0]==S[i] and ans[0]!=T[i]:
        print("Yes")
        exit()
#print(T)
#print(S)
if len(set(S))==1 and len(set(T))==1:
    if len(S)<len(T):
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef long double ld;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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





int main(){

    bool flag=false;
    ll ans=0,sum=0;

    string s,t;
    cin>>s>>t;

    rep(i , s.length())
    {
        if(s[i]!= t[i])++ans;
    }


    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

vector<int> A(10,0);

void vec_assign(int i1,int i2,int i3,int i4,int i5,int i6,int i7,int i8,int i9,int i10){
  A[0] = i1;A[1] = i2;A[2] = i3;A[3] = i4;A[4] = i5;A[5] = i6;
  A[6] = i7;A[7] = i8;A[8] = i9;A[9] = i10;
  return;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int N, M, Q, ans = 0, tmp; cin >> N >> M >> Q;
  
    vector<int> a(Q),b(Q),c(Q),d(Q);
    for(int i = 0; i <Q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
  
    for(int i1 = 1;i1 <= M; i1++){
      for(int i2 = i1;i2 <= M; i2++){
        for(int i3 = i2;i3 <= M; i3++){
          for(int i4 = i3;i4 <= M; i4++){
            for(int i5 = i4;i5 <= M; i5++){
              for(int i6 = i5;i6 <= M; i6++){
                for(int i7 = i6;i7 <= M; i7++){
                  for(int i8 = i7;i8 <= M; i8++){
                    for(int i9 = i8;i9 <= M; i9++){
                      for(int i10 = i9;i10 <= M; i10++){
                        tmp = ans;
                        ans = 0;
                        vec_assign(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10);
                        for(int q = 0; q <Q; q++){
                          if(A[b[q]-1] - A[a[q]-1] == c[q]) ans += d[q];
                        }
                        ans = max(ans, tmp);           
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    cout << ans;

  	return 0;
}

Measured memory_bytes: 3644
use proconio::input;
use std::convert::TryFrom;

fn main() {
    unsafe {
        input!(n: usize, k: usize, ijc: [(usize, usize, char); n]);
        let mut g = vec![vec![0; k + 1]; k + 1];
        let mut b_count = 0;
        let mut w_count = 0;
        for &(i, j, c) in &ijc {
            *g.get_unchecked_mut(i % k + 1).get_unchecked_mut(j % k + 1) +=
                if ((i / k + j / k) % 2 == 1) ^ (c == 'W') {
                    w_count += 1;
                    1
                } else {
                    b_count += 1;
                    -1
                };
        }
        for i in 1..=k {
            let gi = &mut g.get_unchecked_mut(i);
            for j in 1..=k {
                let [x, y] = <&mut [_; 2]>::try_from(gi.get_unchecked_mut(j - 1..=j)).unwrap();
                *y += *x;
            }
        }
        for i in 1..=k {
            let [gi_minus_one, gi] =
                <&mut [_; 2]>::try_from(g.get_unchecked_mut(i - 1..=i)).unwrap();
            for j in 1..=k {
                *gi.get_unchecked_mut(j) += gi_minus_one.get_unchecked(j);
            }
        }

        let mut gik = vec![0; k];
        let gjk = &g[k];
        for i in 0..k {
            gik[i] = g[i][k];
        }

        let mut min = std::i32::MAX;
        let mut max = std::i32::MIN;
        for i in 0..k {
            for j in 0..k {
                let x = -gik[i] - gjk[j] + 2 * g.get_unchecked(i).get_unchecked(j);
                if x < min {
                    min = x;
                }
                if max < x {
                    max = x;
                }
            }
        }
        println!(
            "{}",
            std::cmp::max(
                -(g.get_unchecked(k).get_unchecked(k) + min) + w_count,
                g.get_unchecked(k).get_unchecked(k) + max + b_count
            )
        );
    }
}


Measured memory_bytes: 10316
#include <iostream>
using namespace std;
int main()
{
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int a;
		cin >> a;
		if (i & 1 && a & 1)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
while True:
    x, y, s = map(int, input().split())
    if x == 0: break
    
    def tax(p,x): #税抜き価格pに対してx％の税込価格を出す関数
        return p * (100 + x) // 100
    
    def solve(X,Y,S):
        max = 0
        for a in range(1,S):
            for b in range(1,S):
                sum = tax(a,X) + tax(b,X)
                if sum == S:
                    if tax(a,Y) + tax(b,Y) > max:
                        max = tax(a,Y) + tax(b,Y)
                if sum > S:
                    break
        return max
    
    print(solve(x,y,s))


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

int main() {
  int y[] = {111, 222, 333, 444, 555, 666, 777, 888, 999};
  int n;
  std::cin >> n;

  for (int i = 0; i < 9; i++) {
    if (y[i] - n >= 0) {
      std::cout << y[i] << std::endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    long long n, k;
    std::cin >> n >> k;

    constexpr long long mod = 1000000007;
    long long m             = n + 1;
    long long l             = k - 1;
    std::cout << (m * (m * m + 5) / 6 - l * (-2 * l * l + 3 * n * l + 3 * n + 8) / 6) % mod << std::endl;
    return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;
int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	long long kfk = c - a - b;
	if (kfk > 0 && kfk * kfk > 4 * a * b) {
		cout << "Yes" ;
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
import heapq
K, T = map(int, input().split())
L = list(map(lambda x: -int(x), input().split()))

heapq.heapify(L)

while L and len(L) > 1:
    a = heapq.heappop(L)
    b = heapq.heappop(L)
    r = b-a
    if r > 0:
        heapq.heappush(L, -r)
if L:
    print(-heapq.heappop(L)-1)
else:
    print(0)


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

using namespace std;

int main(){

while(1){
int H,W;

cin>>H>>W;
if(H==0 && W==0) break;

for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if((i+j) %2 ==0) 
cout<<"#";

else cout<<".";

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


Measured memory_bytes: 3100
#include<stdio.h>

int main(void){
  int s,m,l,c;
  scanf("%d %d %d",&s,&m,&l);
  if(s>m){
    c=s;
    s=m;
    m=c;
  }
  if(s>l){
    c=s;
    s=l;
    l=c;
  }
  if(m>l){
    c=m;
    m=l;
    l=c;
  }
  printf("%d %d %d\n",s,m,l);
  return(0);
}

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

int main() {
  int N,A,x,y,ans;
  pair<int,int> z;
  ans = 0;
  cin >> N;
  vector<vector<int>> wit(N,vector<int>(N,2));
  for (int i=0;i < N;i++){
    cin >> A;
    for (int j=0;j < A;j++){
      cin >> x >> y;
      wit.at(i).at(x-1) = y;
    }
  }
  for (int i=0;i < 1 << N;i++){
    bitset<15> bit(i);
    bool flg=0;
    for (int j=0;j < N;j++){
      if (bit.test(j)) {
        for (int k=0;k < N;k++){
          if ((wit.at(j).at(k) != 2) && (bit.test(k) != wit.at(j).at(k))){
            flg=1;
            break;
          }
        }
        if (flg) break;
      }
    }
    if (flg) continue;
    else {int tmp=bit.count();ans = max(ans,tmp);}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define SQRN 4000000
#define Mod 1000000007ll
typedef long long ll;
ll jc[SQRN+50],inv[SQRN+50],f[2050][2050];
int n,k;
inline ll qpow(ll b,ll p){
	ll res=1ll;
	while(p){
		if(p&1) (res*=b)%=Mod;
		p>>=1ll;
		(b*=b)%=Mod;
	}return res;
}
inline ll C(ll x,ll y){
	return jc[x]*inv[y]%Mod*inv[x-y]%Mod;
}
int main(){
	scanf("%d%d",&n,&k);
	if(k==1)
		return puts("1"),0;
	jc[0]=1ll;
	for(ll i=1;i<=SQRN;++i)
		jc[i]=jc[i-1]*i%Mod;
	inv[SQRN]=qpow(jc[SQRN],Mod-2ll);
	for(ll i=SQRN;i>=1;--i)
		inv[i-1]=inv[i]*i%Mod;
//	printf("** %lld\n",inv[10]);
	for(int i=1;i<=n;++i)
		f[i][0]=1ll;
	for(int i=1;i<=n;++i){
//		printf("** %d: ",i);
		for(int j=1;j<=i;++j){
			(f[i][j]=f[i-1][j]+f[i][j-1]*1ll*(n-j+1)%Mod*C(n-i+(n-j+1)*(k-1)-1,k-2)%Mod)%=Mod;
//			printf("|* %lld %lld %lld *|",f[i-1][j],f[i][j-1]*(n-j+1),C(n-1+(n-j+1)*(k-1),k-2));
		}
//		puts("");
	}
	printf("%lld\n",f[n][n]);
	return 0;
}


Measured memory_bytes: 93952
N,K = map(int, input().split() )
A = list(map(int, input().split()))

Cn = [0] * (N+1)
Uq = set()
for a in A:
  Cn[a] += 1
  Uq.add(a)

Cn.sort(reverse=True)

if len(Uq) <= K:
  print(0)
else:
  print(sum(Cn[K:]))

Measured memory_bytes: 26812