akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
    #include <algorithm>
    #include <set>
    #include <unordered_set>
    #include <unordered_map>
    #include <queue>
    #include <utility>
    #include <string.h>
    #include <map>
    #include <stack>
    #include <iomanip>
    #include <chrono>
    #include <random>
    #include <math.h>
    #include <time.h>
    #include <bitset>
    #include <assert.h>
    #define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    #define ll long long
    #define pb push_back 
    #define mp make_pair
    #define ff first
    #define ss second
    #define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
    #define all(x) x.begin(),x.end() 
    #define PII pair <ll,ll>
    #define N 100007
    #define MOD 1000000007
    #define INF 1000000000000000000
    using namespace std;
     
    ll v[N], w[N], dp[107][N];
     
    int main() {
        int n, W, V = 0;
        cin >> n >> W;
        for(int i = 1; i <= n; i++) {
            cin >> w[i] >> v[i];
            V += v[i];
        }
        for(int i = 0; i <= n; i++) {
            for(int j = 0; j <= V; j++) {
                if(i == 0 || j == 0) {
                    dp[i][j] = ((j == 0)? 0 : INT32_MAX);
                }
                else if(v[i] <= j){
                    dp[i][j] = min(w[i] + dp[i-1][j-v[i]], dp[i-1][j]);
                }
                else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
        for(int i = V; i >= 0; i--) {
            if(dp[n][i] <= W) {
                cout << i;
                break;
            }
        }
        return 0;
    }

Measured memory_bytes: 82176
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
const int MOD=1e9+7;
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define ci cout<<"impossible\n"
typedef unsigned long long int ull;
typedef long long int ll;

ll a[500005];
const int M=1e4;
ll cnt[M];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    ll val=0;
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        val+=a[i-1];
        ans=(ans+(val%MOD*a[i]%MOD))%MOD;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 5204
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a + b;
    int r = c + d;
    if(l > r){
        cout << "Left" << endl;
    }else if(l == r){
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
from collections import Counter
'''
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
'''

def cmb(n,r):
    return n*(n-1)//2

N=int(input())
A=list(input().split())
c=Counter(A)
itms=list(c.items())#
lenC=len(c)
num=0

for i in range(lenC):
    itmsi=itms[i][1]
    if itmsi>=2:
        num+=cmb(itmsi,2)


for i in range(N):
    num2=c[A[i]]
    if num2>=3:
        print(num-cmb(num2,2)+cmb(num2-1,2))

    elif num2==2:
        print(num-1)
    else:
        print(num)

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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359


/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,arr[100005];
void solve()
{
	cin>>n;rep(i,0,n)cin>>arr[i];
	sort(arr,arr+n);
	if (0)
	{
		int ansM=0;
		rep(i,0,n/2+1)ansM-=arr[i];
		rep(i,n/2+1,n)ansM+=arr[i];

		int ansP=0;
		rep(i,0,n/2)ansP-=arr[i];
		rep(i,n/2,n)ansP+=arr[i];

		if (ansP>ansM)
		{
			cout<<ansP<<"\n";

			stack<int> S;
			reverse(arr,arr+n);
			rep(i,0,n/2)S.push(arr[i]),S.push(arr[n/2+i+1]);
			S.push(arr[n/2]);

			while(S.size()!=1)
			{
				int a=S.top();S.pop();int b=S.top();S.pop();
				cout<<b<<" "<<a<<"\n";;
				S.push(b-a);
			}
		}
		else
		{
			cout<<ansM<<"\n";
			stack<int> S;
			//reverse(arr,arr+n);
			rep(i,0,n/2)S.push(arr[i]),S.push(arr[n/2+i+1]);
			S.push(arr[n/2]);

			while(S.size()!=1)
			{
				if (S.size()==2)
				{
					int a=S.top();S.pop();int b=S.top();S.pop();
					cout<<a<<" "<<b<<"\n";break;
				}
				int a=S.top();S.pop();int b=S.top();S.pop();

				cout<<b<<" "<<a<<"\n";
				S.push(b-a);
			}
		}

	}
	else
	{

		int ans=0;
		if (n==2)
		{
			cout<<arr[1]-arr[0]<<"\n";
			cout<<arr[1]<<" "<<arr[0];
			return;
		}

		ans=arr[n-1]-arr[0];
		rep(i,1,n-1)ans+=abs(arr[i]);

		cout<<ans<<"\n";
		rep(i,1,n-1)
		{
			if (arr[i]>=0){cout<<arr[0]<<" "<<arr[i]<<"\n";arr[0]-=arr[i];}
		}
		cout<<arr[n-1]<<" "<<arr[0]<<"\n";
		arr[n-1]-=arr[0];
		rep(i,1,n-1)if (arr[i]<0)
		{cout<<arr[n-1]<<" "<<arr[i]<<"\n";arr[n-1]-=arr[i];}

		return;


	}

}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 2688
#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[i];
    int maxindex = -1, maxvalue = 0, nextvalue = 0;
    for(int i = 0; i < n; i++){
        if(a[i] > maxvalue) maxindex = i,nextvalue = maxvalue,maxvalue = a[i];
        else if(a[i] > nextvalue) nextvalue = a[i];
    }
    for(int i = 0; i < n; i++){
        if(i == maxindex) cout << nextvalue << endl;
        else cout << maxvalue << endl;
    }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
普通にとっていけばいいんじゃないかこれ
なんか工夫いるかな
とっては確認とか
先にたんてんきめちゃうとか
1 234とか
12 13つなぐと1がたんてんでなくなる
1個スタートきめて限界まで
1固定でもいいかな
ああ
1-2-7-8
-3
-4-5-6
とか困るのか
いや
1-3でいいのか

*/
vector<vector<ll>> G;
deque<ll> Q;

vector<bool> seen;
void dfs1(ll v) {
  Q.push_back(v);
  seen[v] = true;
  for (auto next_v : G[v]) {
    if (seen[next_v]) continue;
    dfs1(next_v);
    break;
  }
}

void dfs2(ll v) {
  Q.push_front(v);
  seen[v] = true;
  for (auto next_v : G[v]) { 
    if (seen[next_v]) continue;
    dfs2(next_v);
    break;
  }
}

int main() {
  ll N,M; cin>>N>>M;
  G.assign(N+1,vector<ll>(0,0));
  for (ll i = 0; i < M; ++i) {
    ll a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  seen.assign(N+1, false);
  dfs1(1);
  seen[1]=false;
  Q.pop_front();//1とる
  dfs2(1);
  ll qsz=Q.size();
  cout<<qsz<<endl;
  while(!Q.empty()){
    cout<<Q.front()<<" ";
    Q.pop_front();
  }
  cout<<endl;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef vector<int> vi;
typedef vector<vi> mat;
mat op(mat a,mat b){
	int N=a.size();
	mat c=a;
	rep(i,N) rep(j,N) rep(k,N) if(a[i][j]>=0&&b[j][k]>=0) chmax(c[i][k],a[i][j]+b[j][k]);
	return c;
}
int getmx(mat a){
	int N=a.size();
	int mx=-1;
	rep(i,N) rep(j,N) chmax(mx,a[i][j]);
	return mx;
}
int main(){
	int N,M,K;
	int dp[151][150]={};
	int from[151][150]={};
	cin>>N>>M>>K;
	mat m(N,vi(N,0));
	rep(i,N) rep(j,N) m[i][j]=-1;
	rep(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		chmax(m[a][b],c);
	}
	rep1(i,150) rep(j,N) dp[i][j]=-1;
	rep(i,150){
		rep(v,N) rep(u,N){
			if(m[v][u]<0||dp[i][v]<0) continue;
			if(dp[i+1][u]<dp[i][v]+m[v][u]){
				dp[i+1][u]=dp[i][v]+m[v][u];
				from[i+1][u]=v;
			}
		}
		int mx=-1;
		rep(v,N) chmax(mx,dp[i+1][v]);
		if(mx>=K){
			if(i>100){
				cout<<i<<endl;
				return 0;
			}else{
				int x=-1;
				rep(v,N) if(mx==dp[i+1][v]) x=v;
				vector<int> ans;
				ans.pb(x);
				for(int j=i+1;j>0;j--) ans.pb(from[j][x]),x=from[j][x];
				reverse(all(ans));
				cout<<i+1<<endl;
				rep(i,ans.size()) cout<<ans[i]<<(i+1==ans.size()?"\n":" ");
				return 0;
			}
		}
		if(i==149&&mx==-1){
			puts("-1");
			return 0;
		}
	}
	mat ms[20];
	ms[0]=m;
	rep(i,19) ms[i+1]=op(ms[i],ms[i]);
	mat x(N,vi(N,-1));
	rep(i,N) x[i][i]=0;
	int ans=0;
	for(int i=19;i>=0;i--){
		mat nx=op(x,ms[i]);
		if(getmx(nx)<K){
			x=nx;
			ans+=(1<<i);
		}
	}
	cout<<ans+1<<endl;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n, w;
    cin >> n >> w;
    vector<int> ws(n), vs(n);
    for (int i = 0; i < n; ++i) {
        cin >> ws[i] >> vs[i];
    }
    int vsum = accumulate(vs.begin(), vs.end(), 0);
    vector<long long> dp(vsum + 1, numeric_limits<long long>::max());
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int vi = vsum - 1; vi >= 0; --vi) {
            if (dp[vi] == numeric_limits<long long>::max()) continue;
            if (vi + vs[i] > vsum) continue;
            dp[vi + vs[i]] = min(dp[vi + vs[i]], dp[vi] + ws[i]);
        }
    }
    for (int i = vsum; i >= 0; --i) {
        if (dp[i] == -1) continue;
        if (dp[i] <= w) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main()
{
    int n;
    int a, b, c;
    scanf("%d %d %d %d", &n, &a, &b, &c);
    int i;
    int l[10];
    for (i = 0; i < n; i++)
        scanf("%d", &l[i]);
    int ans = 20000000;
    int j, p;
    int x, y, z;
    int d;
    for (i = 0; i < pow(4, n); i++)
    {
        x = y = z = 0;
        d = 0;
        p = i;
        for (j = 0; j < n; j++)
        {

            if (p % 4 == 1)
            {
                if (x > 0)
                    d += 10;
                x += l[j];
            }
            else if (p % 4 == 2)
            {
                if (y > 0)
                    d += 10;
                y += l[j];
            }
            else if (p % 4 == 3)
            {
                if (z > 0)
                    d += 10;
                z += l[j];
            }
            p /= 4;
        }
        d += abs(a - x) + abs(b - y) + abs(c - z);

        if (ans > d && x > 0 && y > 0 && z > 0)
            ans = d;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())

count= []
ans = 0
for i in range(n):
    ab = list(map(int,input().split()))
    count.append(ab)
count.sort()
i = 0
while ans < k:
    ans +=count[i][1]
    i +=1
print(count[i-1][0])

Measured memory_bytes: 27872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll N,T; cin>>N>>T;
  ll r = 0;
  ll t;
  ll t_pre = 0;
  REP(i,N){
    cin >> t;
    if(t==0){continue;}
    r += min(t-t_pre,T);
    t_pre = t;
  }
  r += T;
  cout << r;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
long long  int many=0,N,M;
scanf("%lld",&N);
scanf("%lld",&M);

if(1<N&&1<M){
many=(N-2)*(M-2);
}else{
if(N==1&&M>1)many=M-2;
if(N>1&&M==1)many=N-2;
if(N==1&&M==1)many=1;
}
printf("%lld",many);

return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int h, w, a, b; cin >> h >> w >> a >> b;
    //たて、横を入れ替えない!!
    //個数 * a * b
    cout << h * w - ((h / a) * (w / b)) * a * b << endl;
    
}





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

int	main()
{
    string S;
    cin >> S;
    int N = S.size();
    int max_len = 0;
    set<char> ATGC_set({'A', 'T', 'G', 'C'});
    for (int i = 0; i < N; ++i) {
        int len = N - i;
        for (int j = i; j < N; ++j) {
            if (!ATGC_set.count(S.at(j))) {
                len = j - i;
                break;
            }
        }
        if (max_len < len)
            max_len = len;
    }
    cout << max_len << endl;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int K, N;
	string S;

	cin >> N >> S >> K;
	char h = S[K-1];
	rep(i, N) {
		if (S[i] != h) cout << '*';
		else cout << S[i];
	}
	cout << endl;


	return 0;
}



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

using namespace std;

string s;

int main() {
  cin >> s;
  string t[] = { "SUN","MON","TUE","WED","THU","FRI","SAT"};
  
  int ans;
  rep(i, 7) {
    if (s == t[i]) ans = 7-i;
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{

    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    d=a*b;
    if(d<=c)
    {
        printf("%d\n",d);
    }
    else{
        printf("%d\n",c);
    }
    
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll ans = 0, n;
    cin >> n;
    for(ll i=1;i<=n;++i) {
        if(i % 3 != 0 and i % 5 != 0) {
            ans += i;
        }
    }

    cout << ans << endl;
}


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

const int MAX = 1e6 + 3;

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    vector<int> dp(MAX, 0);

    for (auto x : a) {
        if (dp[x] != 0) {
            dp[x] = 2;
            continue ;
        }
        for (int i = x; i < MAX; i += x) dp[i]++;
    }

    int ans = 0;
    for (auto x : a)
        if (dp[x] == 1) ans++;

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 7932
def main():
    S = input()[::-1]
    s1 = "dream"[::-1]
    s2 = "dreamer"[::-1]
    s3 = "erase"[::-1]
    s4 = "eraser"[::-1]
    ans = "NO"
    while True:
        match_flag = False
        for c in [s1, s2, s3, s4]:
            if S[0:len(c)] == c:
                match_flag = True
                S = S.replace(c, "", 1)
                break
        if match_flag is False:
            break
        if S == "":
            ans = "YES"
            break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
def gumoji(moji):
    if len(moji)%2==0:
        if moji[:int(len(moji)/2)]==moji[-int(len(moji)/2):]:
            return True
    return False

s = str(input())
s = s[:len(s)-1]
#print(s)
while len(s)>=2:
    if gumoji(s):
        break
    else:
        s = s[:len(s)-1]
    
print(len(s))


Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
  ll N, L;
  cin >> N >> L;
  
  vector<string> dict(N);
  for (ll i = 0; i < N; i++){
    cin >> dict.at(i);
  }
  
  sort(dict.begin(), dict.end());
  
  string ans = "";
  for (ll i = 0; i < N; i++){
    ans += dict.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
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 double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int N;
    cin >> N;
    N %= 10;
    if(N == 3){
        cout << "bon" << endl;
    }
    else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
const int size=1e5+5;
int a[size],b[size];
int c[size];
bool cmp(int a,int b)
{
	return a>b;
}
int32_t main()
{
	 int n;
	 scanf("%lld",&n);
	 long long sum=0;
	 for(int i=1;i<=n;i++)
	 {
	 	scanf("%lld%lld",&a[i],&b[i]);
	 	sum=sum+(long long)b[i];
	 	c[i]=a[i]+b[i]; 
	 }
	 sort(c+1,c+1+n,cmp);
	 long long ans=0;
	 for(int i=1;i<=n;i+=2) ans+=(long long)c[i];
	 cout<<ans-sum<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const double PI=3.1415926535;
int main(){
	double a,b,x;
	cin>>a>>b>>x;
	x=x/a;
	if(x>=a*b/2){
		//cout<<((a*a)/(2*a*b-2*x))*(180.0/PI)<<endl;
		printf("%.10f",90.0-atan((a*a)/(2*a*b-2*x))*(180.0/PI));
	}else{
		printf("%.10f",90.0-atan((2*x)/(b*b))*(180.0/PI));
	}
	return 0;
}

Measured memory_bytes: 256
import sys


def solve(n, m, s, k, c):
    maxvs = [0] * (n + 1)
    minvs = [0] * (n + 1)
    for i in enumerate(c):
        for j in i[1]:
            maxvs[j] += s[i[0]]
            if k[i[0]] == 1:
                minvs[j] += s[i[0]]



    # maxmaxvs = max(maxvs)
    # print(maxvs)
    # print(minvs)
    # print(max(maxvs) - min(minvs[1:]) + 1)
    ans = -1
    for i in range(1,  n+1):
        ans = max(ans, maxvs[i]-min(minvs[1:i]+minvs[i+1:]))
    print(ans+1)





while True:
    N, M = map(int, input().split())
    if N == M == 0:
        break
    S = []
    K = []
    C = []
    for i in range(M):
        Skc = list(map(int, input().split()))
        S.append(Skc[0])
        K.append(Skc[1])
        C.append(Skc[2:])
    solve(N, M, S, K, C)



Measured memory_bytes: 9712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> P;

//for vector
inline int norm(const P &a){ return a.fs*a.fs + a.sc*a.sc; }
inline int dot(const P &a, const P &b){return a.fs*b.fs + a.sc*b.sc;}
inline int cross(const P &a, const P &b){return a.fs*b.sc - a.sc*b.fs;}

inline int ccw(const P &a,P b,P c){
  b.fs -= a.fs; b.sc -= a.sc;
  c.fs -= a.fs; c.sc -= a.sc;
  if (cross(b,c)>0) return 1;   //counter clockwise
  if (cross(b,c)<0) return -1; //clockwise
  if (dot(b, c)<-0) return 2;   //c--a--b on line
  if (norm(b)<norm(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

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

  int n,m;
  P b[110],w[110];
  while(cin >> n >> m){
    if(n==0 && m==0)break;
    rep(i,n)cin >> b[i].fs >> b[i].sc;
    rep(i,m)cin >> w[i].fs >> w[i].sc;

    bool ans = false;
    rep(i,n)rep(j,i){
      bool f = true;
      set<int> dirb;
      rep(k,n){
	if(k==i || k==j)continue;
	int tmp = ccw(b[i],b[j],b[k]);
	if(tmp == 0){f = false; break;}
	if(abs(tmp)==1){
	  dirb.insert(tmp);
	  if(dirb.size()==2){f = false; break;}
	}
      }

      if(f){
	set<int> dirw;
	rep(k,m){
	  int tmp = ccw(b[i],b[j],w[k]);
	  if(abs(tmp) != 1){f = false; break;}
	  dirw.insert(tmp);
	  if(dirw.size()==2){f = false; break;}
	}
	if(f && (dirb.size()==0 || dirw.size()==0
		 || *dirb.begin() != *dirw.begin()))ans = true;
      }
      if(ans)break;
    }

    rep(i,m)rep(j,i){
      bool f = true;
      set<int> dirw;
      rep(k,m){
	if(k==i || k==j)continue;
	int tmp = ccw(w[i],w[j],w[k]);
	if(tmp == 0){f = false; break;}
	if(abs(tmp)==1){
	  dirw.insert(tmp);
	  if(dirw.size()==2){f = false; break;}
	}
      }

      if(f){
	set<int> dirb;
	rep(k,n){
	  int tmp = ccw(w[i],w[j],b[k]);
	  if(abs(tmp) != 1){f = false; break;}
	  dirb.insert(tmp);
	  if(dirb.size()==2){f = false; break;}
	}
	if(f && (dirb.size()==0 || dirw.size()==0
		 || *dirb.begin() != *dirw.begin()))ans = true;
      }
      if(ans)break;
    }

    rep(i,n)rep(j,m){
      bool f = true;
      set<int> dirb;
      rep(k,n){
	if(k==i)continue;
	int tmp = ccw(b[i],w[j],b[k]);
	if(tmp == 0 || tmp == -2){f = false; break;}
	if(abs(tmp)==1){
	  dirb.insert(tmp);
	  if(dirb.size()==2){f = false; break;}
	}
      }

      if(f){
	set<int> dirw;
	rep(k,m){
	  if(k==j)continue;
	  int tmp = ccw(b[i],w[j],w[k]);
	  if(tmp == 0 || tmp == 2){f = false; break;}
	  if(abs(tmp)==1){
	    dirw.insert(tmp);
	    if(dirw.size()==2){f = false; break;}
	  }
	}	
	if(f && (dirb.size()==0 || dirw.size()==0
		 || *dirb.begin() != *dirw.begin()))ans = true;
      }
      if(ans)break;
    }

    cout << (ans?"YES":"NO") << endl;
  }
}

Measured memory_bytes: 1200
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        while (a > 0) {
            c -= b;

            if (c <= 0) {
                System.out.println("Yes");
                return;
            }
            a -= d;
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 35700
from collections import Counter
N = int(input())
P = list(tuple(map(int, input().split())) for _ in range(N))
P = sorted(P)

p_q_cand = []
for i in range(N):
    for j in range(i+1, N):
        diff_p = P[j][0]-P[i][0]
        diff_q = P[j][1]-P[i][1]
        p_q_cand.append((diff_p, diff_q))

if N == 1:
    print(1)
else:
    C = Counter(p_q_cand)
    ans = float('inf')
    for v, c in C.items():
        p = v[0]
        q = v[1]
        tmp = 0
        used = set()
        for a, b in sorted(list(P), key=lambda x: (x[0], x[1])):
            if (a-p, b-q) not in used:
                tmp += 1
            used.add((a, b))
        ans = min(ans, tmp)
    print(ans)


Measured memory_bytes: 3572
import bisect
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

#和がx以上になる組み合わせの総数を求める関数
def pattern_num_ge_x(x):
    p=0
    for a in A:
        p+=(N-bisect.bisect_left(A, x-a))
    return(p)

#pattern_num_ge_x(x)がM未満になる最小のxを探す(=r)
#lはM以上になる最大のx
l=-1
r=10**5*2+1
while r-l>1:
    m=(r+l)//2
    if pattern_num_ge_x(m)<M:
        r=m
    else:
        l=m

#和がr以上になる組み合わせの総和を求める(累積和を使用)
S=[0]+list(reversed(A[:]))
for i in range(1,N+1):
    S[i]+=S[i-1]
ans=0
for a in A:
    idx=bisect.bisect_left(A,r-a)
    ans+=a*(N-idx) + S[N-idx]
    M-=(N-idx)

#回数のあまり分lを足す
ans+=l*M

print(ans)

Measured memory_bytes: 56600
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<long long> A(n + 1);
    vector<long long> B(n);
    for (int i = 0; i <= n; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> B[i];
    }

    long long res = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = -1; j <= 0; ++j) {
            int ni = i + j;
            if (ni >= 0 && ni < n) {
                auto cnt = min(B[ni], A[i]);
                res += cnt;
                B[ni] -= cnt;
                A[i] -= cnt;
            }
        }
    }

    cout << res << "\n";


    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll 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 mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> A)
{
    ll ans = 0;
    vector<ll> B(N);
    B = A;
    ll tmp = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] != 0)
        {
            tmp += A[i];
            continue;
        }
        else
        {
            ans += tmp / 2;
            tmp = 0;
        }
    }
    ans += tmp / 2;
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		boolean f = false;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if ((4*i)+(7*j) == n) {
					f = true;
					System.out.println("Yes");
					return;
				} 
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string S;
    cin >> S;
    int even0 = 0, odd1 = 0, even1 = 0, odd0 = 0;
    for (int i = 0; i < S.size(); i++){
        if (i % 2 == 0){
            if (S[i] == '0') even0++;
            else even1++;
        }
        else{
            if(S[i] == '0') odd0++;
            else odd1++;
        }
    }
    //cout << "even0: " << even0 << endl;
    //cout << "odd1: " << odd1 << endl;
    //cout << "even1: " << even1 << endl;
    //cout << "odd0: " << odd0 << endl;

    cout << S.size() - max(even0 + odd1, odd0 + even1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

int ans[555][555];

const int inf = int(1e9);

void solve(istream& cin, ostream& cout) {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    lint s = 0;
    for (int i = h - 1; i < H; i += h) {
        for (int j = w - 1; j < W; j += w) {
            ans[i][j] = -inf;
            s -= inf;
        }
    }
    for (int i = 0; i < H; i += h) {
        for (int j = 0; j < W; j += w) {
            ans[i][j] = inf - 1;
            s += inf - 1;
        }
    }
    if (s <= 0) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        rep(i, 0, H) {
            rep(j, 0, W) {
                cout << ans[i][j] << " ";
            }
            cout << "\n";
        }
    }
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
bool isp[1<<20];
int map[2000][2000];
pair<int,int>where[1<<20];
int dx[]={0,-1,0,1},dy[]={1,0,-1,0};
main()
{
	for(int i=2;i<1<<20;i++)isp[i]=1;
	for(int i=2;i<1<<20;i++)
	{
		if(isp[i])
		{
			for(int j=i+i;j<1<<20;j+=i)isp[j]=0;
		}
	}
	int dir=0,cnt=0,maxcnt=1;
	pair<int,int>p=make_pair(1000,1000);
	for(int i=1;i<1<<20;i++)
	{
		where[i]=p;
		map[p.first][p.second]=i;
		if(maxcnt==cnt)
		{
			cnt=0;
			dir=(dir+1)%4;
			if(dir%2==0)maxcnt++;
		}
		p.first+=dx[dir];
		p.second+=dy[dir];
		cnt++;
	}
	int m,n;
	while(cin>>m>>n,m)
	{
		pair<int,int>next[2000],now[2000],ans;
		for(int i=0;i<2000;i++)now[i]=make_pair(0,-1);
		int y=where[n].first;
		now[where[n].second]=ans=isp[n]?make_pair(1,n):make_pair(0,0);
		bool flag=true;
		while(flag)
		{
			flag=false;
			for(int i=0;i<2000;i++)next[i]=make_pair(0,-1);
			y++;
			for(int i=0;i<2000;i++)
			{
				if(now[i].second<0)continue;
				for(int j=-1;j<=1;j++)
				{
					if(map[y][i+j]>0&&map[y][i+j]<=m)
					{
						flag=true;
						pair<int,int>p=now[i];
						if(isp[map[y][i+j]])p.second=map[y][i+j],p.first++;
						next[i+j]=max(next[i+j],p);
						ans=max(ans,p);
					}
				}
			}
			swap(now,next);
		}
		cout<<ans.first<<" "<<ans.second<<endl;
	}
}



Measured memory_bytes: 20340
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    string res = "NO";
    if(b>a){
        a += v*t;
        b += w*t;
        if(a>=b) res = "YES";
    }else{
        a -= v*t;
        b -= w*t;
        if(a<=b) res = "YES";
    }
    cout << res << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  int n;
  cin >> n;
  int cnt = 0;
  rep(i, n)
  {
    ll a;
    cin >> a;
    bool p = true;
    for (ll i = 2; i * i <= a; i++)
    {
      if (a % i == 0)
      {
        p = false;
        break;
      }
    }
    cnt += p;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  string s,t;
  cin>>s>>t;
  sort(all(s));
  sort(all(t));reverse(all(t));
  if(s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
IDENTIFICATION  DIVISION.
PROGRAM-ID.     HELLO.

 
DATA DIVISION.
	WORKING-STORAGE SECTION.
        01 X PIC S99.
        
        01 STA PIC 9(2) VALUE 30.
        
        01 OUT PIC Z9.
      
PROCEDURE       DIVISION.
    ACCEPT X.
    
    IF X < 30 THEN 
      DISPLAY 'No'
    ELSE
      DISPLAY 'Yes'
    END-IF.
    
    STOP RUN.

Measured memory_bytes: 3688
/*
  AOJ 1079
  Title:
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))

int r,c,q;
int A[50000],B[50000],od[50000];
char skip[50000];

int order_flags[2][50000];


main()
{
  int i,j,ret,s,rs,cs;
  
  while(scanf("%d %d %d",&r,&c,&q)  && (r||c||q))
    {
      memset(order_flags,-1,sizeof(order_flags));
      memset(skip,0,sizeof(skip));
      for(i=0;i<q;i++)
	{
	  scanf("%d %d %d",&A[i],&B[i],&od[i]);
	  if((s=order_flags[A[i]][B[i]])!=-1)
	    skip[s]=1;
	  order_flags[A[i]][B[i]]=i;
	}
      rs=cs=ret=0;
      for(i=0;i<q;i++)
	{
	  if(skip[i]==0)
	    {
	      if(A[i]==0)
		{
		  if(od[i]==0)
		    ret -= cs;
		  else
		    ret += (c - cs),rs ++;
		}
	      else
		{
		  if(od[i]==0)
		    ret -= rs;
		  else
		    ret += (r - rs),cs ++;
		}
	    }
	}
      printf("%d\n",ret);
    }
  return(0);
}

Measured memory_bytes: 1632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int S, W;
	cin >> S >> W;

	string ans = (S <= W) ? "unsafe" : "safe";


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

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

const int MOD = 1e9+7;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};


typedef vector<vector<mint>> mmat;

mmat matmul (mmat &A, mmat &B) {
    mmat C(A.size(), vector<mint>(B[0].size()));
    Rep (i, A.size()) {
        Rep (k, B.size()){
            Rep (j, B[0].size()) {
                C[i][j] = C[i][j] + A[i][k] * B[k][j];
            }
        }
    }
    return C;
}

mmat matpow(mmat A, ll n) {
    mmat B(A.size(), vector<mint>(A.size()));
    Rep (i, A.size()) {
        B[i][i] = mint(1);
    }
    while (n > 0) {
        if (n & 1) B = matmul(B, A);
        A = matmul(A, A);
        n >>= 1;
    }
    return B;
}

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

    ll N, K;
    cin >> N >> K;
    mat a(N, vec(N));
    mmat ma(N, vector<mint>(N));
    Rep (i, N) {
        Rep (j, N) {
            cin >> a[i][j];
            ma[i][j] = mint(a[i][j]);
        }
    }

    

    mmat ansmat = matpow(ma, K);
    mint ans(0);
    Rep (i, N) {
        Rep (j, N) {
            ans += ansmat[i][j];
        }
    }

    cout << ans << endl;

}

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

int main() {
    int a, b, c, i, j=0;
    cin >> a >> b >> c;
    for(i=a; a<=b; a++){
        if(c%a==0) {
            j++;
        }
    }
    cout << j << endl;
    return 0;
}



Measured memory_bytes: 3124
import sys

input = sys.stdin.readline


def main():
    n = input()
    obj = [int(i) for i in input().split()]
    costs = [int(i) for i in input().split()]
    print(sum([o - c for o, c in zip(obj, costs) if o - c > 0]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <assert.h>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>                                    
#include <deque>                                    
#include <queue>
#include <iomanip>
#include <ctime>
#include <random>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;

 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, x, t;
 
inline void boost () {
   ios_base :: sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
}

inline void Solve () {
   cin >> n >> x >> t;
   cout << (n + x - 1) / x * t;

}               
 
signed main () {                                       
  // #ifdef QWERTY
   //   freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                 


Measured memory_bytes: 3648
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

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

const int INF32 = INT_MAX;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);                
    int n;
    cin >> n;
    cout << n * n * n;                
    return false;                                                       
}

Measured memory_bytes: 256