akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

    std::vector<ll> X(N);
    
    std::for_each(X.begin(), X.end(), [](auto &x) { cin >> x; });

    std::vector<ll> sorted_X(X);
    std::sort(sorted_X.begin(), sorted_X.end(), std::greater<>());

    std::vector<ll> B(N);

    for (ll i = 0; i < N; ++i) {
        if (X[i] > sorted_X[N / 2]) {
            B[i] = sorted_X[N / 2];
        } else {
            B[i] = sorted_X[N / 2 - 1];
        }
    }

    std::for_each(B.begin(), B.end(), [](auto &x) { cout << x << endl; });

    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz size()
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

#define ll long long

double sqr(double x) {
	return (double) x*x;
}

int main() {

	int n;
	cin>>n;

	int zam = n;
	int r = 0;

	int kolku = 0;
		

	while (zam) {
		r*=10;
		r+=7;
		kolku++;
		zam/=10;
	}

	if (n%2 == 0 || n%5 == 0)
		cout<<"-1\n";
	else {

	
		int md = r%n;
		while (md) {
			md = (md*10+7) % n;
			kolku ++;

			if (kolku>n) break;
		}

		if (kolku>n) 
			cout<<"-1\n";
		else 
			cout<<kolku<<"\n";
	}

    return 0;
}

Measured memory_bytes: 3624
//PKU 1979
#include<iostream>
#include<cstdio>
char mat[21][21];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int w,h;
using namespace std;

void check(int x,int y){
	int i;
	int mx,my;
	for(i=0;i<4;i++){
		mx=x+dx[i];
		my=y+dy[i];
		if(mx<w && my<h && mx>=0 && my>=0){
			if(mat[my][mx]=='.'){
				mat[my][mx]='z';
				check(mx,my);
			}
		}
	}
	return;
}

int main(void){
	int i,j;
	int mx,my;

	while(cin>>w>>h,(w||h)){
		for(i=0;i<21;i++)for(j=0;j<21;j++)mat[i][j]=0;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cin>>mat[i][j];
			}
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(mat[i][j]=='@'){
					mx=j,my=i;
					mat[my][mx]='z';
				}
			}
		}
		check(mx,my);//4ツ陛サツ古シツづ個づづェツつゥツ行ツつュ

		int cnt=0;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(mat[i][j]=='z'){
					cnt++;
				}
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

long long a, b, x;
int main() {
  while (cin >> a >> b >> x) {
	a += x, b += x;
	cout << b/x - (a-1)/x << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,c;
	char b;
	scanf("%d %c %d",&a,&b,&c);
	if(b=='-') printf("%d\n",a-c);
	else 
	{
		printf("%d\n",a+c);
	//	printf("\n");
	//	printf("Since %d+%d=%d, the output should be %d.\n",a,c,a+c,a+c);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				B[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < n; i++) {
			long c;
			for(int j = 0; j < l; j++) {
				c = 0;
				for(int k = 0; k < m; k++) {
					c += A[i][k] * B[k][j];
				}
				System.out.print(c);
				if(j == l - 1) { System.out.println(""); break;}
				System.out.print(" ");
				
			}
		}
		
		
		sc.close();
	}
	
}



Measured memory_bytes: 56480
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e3;
const int MAXW = 1e5+5;

int N, W;
int v[MAX], w[MAX];
int dp[MAX][MAXW];

void solve() {
	memset(dp, 0, sizeof dp);
	cin >> N >> W;
	for(int i=1; i<=N; i++) cin >> w[i] >> v[i];
	for(int i=1; i<=N; i++) {
		for(int j=0; j<=W; j++) {
			if(j < w[i]) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(v[i]+dp[i-1][j - w[i]], dp[i-1][j]);
		}
	}
	cout << dp[N][W];
}

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

 	solve();

  	return 0;
}



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


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d) - max(a, c);
    cout << (ans > 0 ? ans : 0) << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [0]*N
for i in range(N):
    A[i] =int(input()) 

#最大値とその次に大きい値を取り出す
first_A = sorted(A)[-1]
second_A = sorted(A)[-2]

for i in range(N):
    if (A[i]== first_A):
        print(second_A)
    else:
        print(first_A)
        

Measured memory_bytes: 14660
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

const int N = 1e5 + 10;

int n, m;
priority_queue<int> available;
vector<int> job[N];

class DSummerVacation {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n >> m;

		for (int i = 0; i < n; i++) {
			int a, b;
			in >> a >> b;
			job[a].push_back(b);
		}

		int ans = 0;
		for (int i = m - 1; i >= 0; i--) {
			for (int x : job[m - i])
				available.push(x);
			if (!available.empty()) {
				int p = available.top();
				ans += p;
				available.pop();
			}
		}
		out << ans;
	}
};

int main() {
	DSummerVacation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
#define enld endl

int main(){
    int a,b,c,n,m,k;
    string s;
    cin>>a;
    cout<<3*a*a<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main ( String[] args ){
		Scanner sc = new Scanner( System.in );
		while( true ){
			String src = sc.next();
			char[] strc = src.toCharArray();
			String type = sc.next();
			char diff =  'a' - 'A';
			switch (type.toCharArray()[ 0 ] ){
			case 'X':
				return;
			case 'U':
				if( 'a' <= strc[ 0 ] && strc[ 0 ] <= 'z' ){
					strc[ 0 ] -= diff; // to upper case
				}
				for( int i = 1; i < strc.length; i++ ){
					if( strc[ i ] == '_' ){
						String s1 = "";
						String s2 = "";
						for( int j = 0; j < i; j++ ){
							s1 += strc[ j ];
						}
						if( 'a' <= strc[ i + 1 ] && strc[ i + 1 ] <= 'z' ){
							strc[ i + 1 ] -= diff;
						}
						for( int j = i + 1; j < strc.length; j++ ){
							s2 += strc[ j ];
						}
						strc = ( s1 + s2 ).toCharArray();
					}
				}
				System.out.println( strc );
				break;
			case 'L':
				if( 'A' <= strc[ 0 ] && strc[ 0 ] <= 'Z' ){
					strc[ 0 ] += diff; // to upper case
				}
				for( int i = 1; i < strc.length; i++ ){
					if( strc[ i ] == '_' ){
						String s1 = "";
						String s2 = "";
						for( int j = 0; j < i; j++ ){
							s1 += strc[ j ];
						}
						if( 'a' <= strc[ i + 1 ] && strc[ i + 1 ] <= 'z' ){
							strc[ i + 1 ] -= diff;
						}
						for( int j = i + 1; j < strc.length; j++ ){
							s2 += strc[ j ];
						}
						strc = ( s1 + s2 ).toCharArray();
					}
				}
				System.out.println( strc );
				break;
			case 'D':
				if( 'A' <= strc[ 0 ] && strc[ 0 ] <= 'Z' ){
					strc[ 0 ] += diff; // to upper case
				}
				for( int i = 1; i < strc.length; i++ ){
					if( 'A' <= strc[ i ] && strc[ i ] <= 'Z' ){
						String s = "";
						for( int j = 0; j < i; j++ ){
							s += strc[ j ];
						}
						s += "_";
						strc[ i ] += diff;
						for( int j = i; j < strc.length; j++ ){
							s += strc[ j ];
						}
						strc = s.toCharArray();
					}
				}
				System.out.println( strc );
				break;
			}

		}
	}
}

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

constexpr unsigned long MOD = 998244353;
constexpr unsigned long mx = 1000001;
constexpr unsigned long R = 4294967296, MODinv = 998244351, R2 = 932051910, mask = R - 1, R_bitsize = 32;

constexpr unsigned long montgomery_reduction(unsigned long a){
    return (a + (mask & a * MODinv) * MOD) >> R_bitsize;
}

template<unsigned long maxsize, unsigned long MOD, unsigned long primesize>
class divisor_convolution_coefficients{
    unsigned long sieve[maxsize];
public:
    unsigned long prime[primesize];
    unsigned long coef[maxsize];
    constexpr divisor_convolution_coefficients() : coef(), sieve(), prime(){
        coef[1] = R2;
        for(unsigned long i = 2; i < maxsize; ++i){
            coef[i] = R2 * i % MOD;
            sieve[i] = 1;
        }
        for(unsigned long i = 2, c = 0; i < maxsize; ++i)if(sieve[i]){
                prime[c++] = i;
                for(unsigned long j = i; j < maxsize; j += i){
                    sieve[j] = 0;
                    (coef[j] *= MOD + 1 - i) %= MOD;
                }
            }
    }
};

constexpr divisor_convolution_coefficients<mx, MOD, 78498> coef{divisor_convolution_coefficients<mx, MOD, 78498>()};

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;

    unsigned long ans{0};
    unsigned long max_size{0};
    vector<unsigned long> hoge(mx);
    for(unsigned long _ = 0, i; _ < N; ++_){
        cin >> i;
        max_size = max(i, max_size);
        ++hoge[i];
    }
    ++max_size;

    for(const auto& i : coef.prime)for(unsigned long j = max_size / i; j; --j)hoge[j] += hoge[j * i] * i;
    for(auto& i : hoge)i %= MOD;

    ans = MOD - hoge[1];
    for(unsigned long i = 1; i < max_size; ++i)if(hoge[i])ans += montgomery_reduction(montgomery_reduction(hoge[i] * hoge[i]) * coef.coef[i]);
    (ans += (ans & 1) * MOD) >>= 1;
    cout << ans % MOD << endl;

    return 0;
}

Measured memory_bytes: 8700
//18, 08, 2018, 09:32:26 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = 510;
vector< int > pos[N];
int pre[N][N];
int n, m, q;

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

    scanf("%d %d %d", &n, &m, &q);

    for(int i = 0 ; i < m ; i++){
        int l, r;

        scanf("%d %d", &l, &r);

        pos[r].push_back(l);
    }

    for(int i = 1 ; i <= n ; i++){
        sort(pos[i].begin(), pos[i].end());
    }

    for(int i = 1 ; i <= n ; i++){
    
        for(int j = i ; j <= n ; j++){
            if(j > i)
                pre[i][j] = pre[i][j - 1];
            
            int lo = lower_bound(pos[j].begin(), pos[j].end(), i) - pos[j].begin();  
            int hi = upper_bound(pos[j].begin(), pos[j].end(), j) - pos[j].begin();

            pre[i][j] += hi - lo;
        }
    }

    while(q--){
        int l, r;

        scanf("%d %d", &l, &r);

        printf("%d\n", pre[l][r]);
    }

    return 0;
}

Measured memory_bytes: 3200
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int alpha[3]={};
	string S;
	cin>>S;
	for(int i=0;i<3;i++)
		alpha[S[i]-'a']++;
	for(int i=0;i<3;i++)
		if(!alpha[i]){
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations

n, x = [int(i) for i in input().split()]
while n or x:
    ans = 0
    for a in combinations(range(1, n + 1), 3):
        if sum(a) == x:
            ans += 1
    print(ans)
    n, x = [int(i) for i in input().split()]



Measured memory_bytes: 5640
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int p[n+1];
    double e[n+1]={},ans=0.0;
    for(int i=1;i<=n;i++)cin>>p[i];
    for(int i=1;i<=n;i++){
        e[i]=(p[i]+1)/2.0;
    }
    for(int i=1;i<=n;i++){
        e[i]+=e[i-1];
    }
    for(int i=1;i<=n-k+1;i++){
        ans=max(ans,e[i+k-1]-e[i-1]);
    }
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int n, cnt;

	while (1) {
		cnt = 0;
		scanf("%d", &n);
		if (n == 0)
			break;
		while (1) {
			if (n == 1)
				break;
			else if (n % 2 == 0) {
				n /= 2;
				cnt++;
			} else {
				n = n * 3 + 1;
				cnt++;
			}
		}
		printf("%d\n", cnt);
	}

	return 0;
}

	

Measured memory_bytes: 600
n = int(input())
a = list(map(int,input().split()))
b = 0

for i in range(n):
    b += a[i]

c = int(b/n)
d = c + 1
e = 0
f = 0

for i in range(n):
    e += (a[i]-c)**2
    f += (a[i]-d)**2

print(min(e,f))



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

using namespace std;

int main() {
  string S;
  cin >> S;
  int min_num = 999;

  for ( int i = 0; i < S.size() - 2; i++ ) {
    string partial = S.substr( i, 3 );
    int num = atoi( partial.c_str() );
    int num_abs = abs( num - 753 );
    min_num = min( num_abs, min_num );
  }
  cout << min_num << endl;
  return 0;
}

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

struct edge {int to, cost; };
typedef pair<int, int> P;
int V;
vector <edge> G[100010];
int d[100010];

void dijkstrra(int s){
    priority_queue <P, vector<P>, greater<P> > que;
    fill(d, d + V, 1000000000);
    d[s] = 0;
    que.push(P(0 , s));
    
    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first)  continue;
        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    cin >> V;
    int e, r;   cin >> e >> r;
    for(int i = 0; i < e; i++){
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back({t, d});
    }
    dijkstrra(r);
    for(int i = 0; i < V; i++){
        if(d[i] == 1000000000)
            cout << "INF" << endl;
        else
            cout << d[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12948
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int W[11],K[11];
  for(int i=0;i<10;i++){
    scanf("%d",&W[i]);
  }
  for(int i=0;i<10;i++){
    scanf("%d",&K[i]);
  }
  sort(W,W+10);
  sort(K,K+10);
  printf("%d %d\n",W[7]+W[8]+W[9],K[7]+K[8]+K[9]);
}

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

using namespace std;

#define ll			long long
#define ALL(s)			(s).begin(),(s).end()
#define ALLn(s,n)		s,s+n
#define F			first
#define S			second
#define pb			push_back
#define tc(t)			int t; cin >> t; while(t--)
#define _			ios_base::sync_with_stdio(false); cin.tie(NULL);
#define PI 3.141592653589793238
const ll MOD = 1e9 + 7;
const ll INF = INT_MAX;
const ll MAX_N = 1e6 + 7;


void solve() {
    ll n,m;
    cin >> n >> m;
    ll a[m];
    ll sum = 0;

    for(int i = 0; i < m; ++i) {
		cin >> a[i];
		sum += a[i];
	}

	if(sum > n) cout << "-1\n";
	else cout << (n - sum) << "\n";
}

int main() {_
    //tc(t) 
	solve();
}


Measured memory_bytes: 3688
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
 
#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
 
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;
 
using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
 
//struct edge {int from, to, cost;};
 
constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}
 
template<class T> inline T sqr(T x) {return x*x;}
 
void solve() {
    int n,m;
    cin >> n >> m;
    vector<VP> d(m);
    map<int,int> cnt;
    int in;
    REP(i,0,n) {
        cin >> in;
        cnt[in]++;
    }
    for (auto p: cnt) {
        int key = p.first, value = p.second;
        d[key%m].pb(key, value);
    }
    REP(i,0,m) sort(all(d[i]), [](auto &l, auto &r) {
        return l.second % 2 > r.second % 2;
    });
    LL ans = 0;
    REP(i,1,(m+1)/2) {
        LL tmp = 0;
        LL sum1 = 0, sum2 = 0;
        REP(j,0,d[i].size()) sum1 += d[i][j].second;
        REP(j,0,d[m-i].size()) sum2 += d[m-i][j].second;
        //dump(sum1);
        //dump(sum2);
        int n = abs(sum1 - sum2);
        if (sum1 <= sum2) {
            tmp += sum1;
            RREP(j,0,d[m-i].size()) {
                if (d[m-i][j].second <= n) {
                    tmp += d[m-i][j].second / 2;
                    n -= (d[m-i][j].second / 2) * 2;
                } else {
                    tmp += n / 2;
                    break;
                }
            }
        } else {
            tmp += sum2;
            RREP(j,0,d[i].size()) {
                if (d[i][j].second <= n) {
                    tmp += d[i][j].second / 2;
                    n -= (d[i][j].second / 2) * 2;
                } else {
                    tmp += n / 2;
                    break;
                }
            }
        }
        ans += tmp;
        //dump(i);
        //dump(tmp);
    }
    if (m % 2 == 0) {
        LL tmp = 0;
        REP(i,0,d[m/2].size()) tmp += d[m/2][i].second;
        ans += tmp / 2;
    }
    LL tmp = 0;
    REP(i,0,d[0].size()) tmp += d[0][i].second;
    ans += tmp / 2;
    cout << ans << endl;
}
 
int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 13544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;
}

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

#define INF (1e9)
#define INF_LL (1e17)
#define YJ 1145141919810

using LL = long long;
using ULL = unsigned long long;

using namespace std;

#define MAX_N 50
#define MAX_M 50

LL N;

LL check(LL a)
{
  int ret = 0;
  while(a){
    ret++;
    a /= 10;
  }
  return ret;
}

int main()
{

  cin >> N;
  LL ans = 1145141919;
  for (LL i = 1; i <= 100005 && i <= N; i++) {
    if(N%i != 0){
      continue;
    }
    LL j = N/i;
    ans = min(ans, max(check(i), check(j)));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     string S;
     cin >> S;
     int count=0;
     for(char a='a'; a<='z'; a++){
         for(int b=0; b<S.size(); b++){
             if(S[b]==a){
                 count+=1;
             }
         }
         if(count==0){
             cout << a << endl;
             return 0;
         }
         count=0;
     }
     cout << "None" << endl;
 }

Measured memory_bytes: 512
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

struct Edge {
    int v;
    int a;
    int b;
};

static const int maxS = 3000;

ll mem[51][maxS+1];

int main(void)
{
    int N, M, S;
    cin >> N >> M >> S;
    vector<vector<Edge> > E;
    E.resize(N);
    REP(i, M) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u; --v;
        E[u].push_back(Edge{v, a, b});
        E[v].push_back(Edge{u, a, b});
    }
    vector<int> C(N), D(N);
    REP(i, N) {
        cin >> C[i] >> D[i];
    }

    REP(i, N) REP(s, maxS+1) mem[i][s] = LONG_LONG_MAX;

    priority_queue<pair<ll, pair<int, int> > > Q;
    mem[0][min(maxS, S)] = 0;
    Q.push({0, pair<int, int>{0, min(maxS, S)}});
    while(!Q.empty()) {
        ll t = -Q.top().first;
        int u = Q.top().second.first;
        int s = Q.top().second.second;
        Q.pop();
        if (t > mem[u][s]) {
            continue;
        }
        if (s != maxS) {
            int ns = min((ll)maxS, (ll)s+C[u]);
            ll nt = t + D[u];
            if (nt < mem[u][ns]) {
                Q.push({-nt, pair<int, int>{u, ns}});
                mem[u][ns] = nt;
            }
        }
        for (auto &e : E[u]) if (s >= e.a) {
            int ns = s - e.a;
            ll nt = t + e.b;
            assert(ns >= 0);
            if (nt < mem[e.v][ns]) {
                Q.push({-nt, pair<int, int>{e.v, ns}});
                mem[e.v][ns] = nt;
            }
        }
    }

    FOR(i, 1, N) {
        ll minT = LONG_LONG_MAX;
        REP(s, maxS+1) {
            minT = min(minT, mem[i][s]);
        }
        cout << minT << endl;
    }
    
    return 0;
}


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

int main()
{
	int n;
	cin>>n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	for(int i = 0; i < n; i++)
	{
		string s;
		cin>>s;
		if(s[0] == 'A') ac++;
		else if( s[0] == 'W') wa++;
		else if( s[0] == 'T') tle++;
		else re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
 
template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
const int MAX = 10010;
int n;
int a[MAX],b[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n){
    cin >> a[i];
  }
  R(i,n){
    cin >> b[i];
  }
  int ak = 0;
  R(i,n){
    if(a[i]%2 != b[i]%2){
      b[i]++;
      ak++;
    }
    if(a[i] > b[i]){
      ak += a[i] - b[i];
    }else{
      ak -= (b[i] - a[i])/2;
    }
  }
  if(ak > 0){
    cout << "No\n";
  }else{
    cout << "Yes\n";
  }
}

Measured memory_bytes: 384
#include <stdio.h>
#define N 1001
#define inf 1000
int n, M[N][N];
int color[N], d[N], f[N], t;
int Q[2*N], head=0, tail=0;
 
void enqueue(int x){
  Q[tail++] = x;
}
int dequeue(){
  int x;
  x = Q[head++];
  return x;
}
void bfs(int s){
  int i, u, v;
  enqueue(s);
  for(i = 1; i <= n; i++) d[i] = inf;
  d[s] = 0;
  while(head != tail){
    u = dequeue();
    for(v = 1; v <= n; v++){
      if(M[u][v] == 0) continue;
      if(d[v] != inf) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
}
 
int main(){
  int u, k, v, i, j;
  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      M[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    scanf("%d %d",&u, &k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      M[u][v] = 1;
    }
  }
  bfs(1);
  for(i = 1; i <= n; i++){
    if(d[i] == inf) d[i] = -1;
    printf("%d %d\n",i, d[i]);
  }
  return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#include <time.h>
#include <assert.h>


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(8);
    srand(time(NULL));

	ll n;
	cin>>n;
	ll mul = 1;
	ll a[n];
	bool flag = false;
	ll mx = 1000000000000000000;
	For(i,0,n){
		cin>>a[i];
		if(a[i]==0){
			cout<<0;
			return 0;
		}
		// deb2(mul,mx/a[i]);
		if(mx/a[i] >= mul and !flag)
			mul *= a[i];
		else{
			mul = -1;
			flag = true;
		}
	}
	cout<<mul;
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 4436
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    while(true){
        int n;
        cin>>n;
        if(n==0) break;
        V<string> s(n),t(n);
        cinf(n,s);
        int kk=0;
        rep(i,n){
            int m=s[i].size();
            t[i]=s[i][0];
            for(int j=1;j<m;j++){
                if(s[i][j-1]=='a'||s[i][j-1]=='i'||s[i][j-1]=='u'||s[i][j-1]=='e'||s[i][j-1]=='o'){
                    t[i]+=s[i][j];
                }
            }
            int mm=t[i].size();
            chmax(kk,mm);
        }
        bool ok=0;
        int k;
        for(int i=1;i<=kk;i++){
            set<string> st;
            for(int j=0;j<n;j++){
                if(i<t[j].size()) st.insert(t[j].substr(0,i));
                else st.insert(t[j]);
            }
            if(st.size()==n){
                k=i;
                ok=1;
                break;
            }
        }
        if(ok) cout<<k<<endl;
        else cout<<-1<<endl;
    }
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >>k;
    cout << a[k-1] << endl;

}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
s = input()
now = 1
cnt = 0
Nums = []
for i in range(len(s)):
    if s[i] == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
if len(Nums) % 2 == 0:
    Nums.append(0)

ans = 0
Add = 2 * k + 1

sum = [0] * (len(Nums) + 1)

for i in range(len(Nums)):
    sum[i + 1] = sum[i] + Nums[i]

for i in range(len(Nums))[::2]:
    left = i
    right = min(i + Add, len(Nums))
    tmp = sum[right] - sum[left]
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 8004
#include <bits/stdc++.h>
#define inf 1000000000
#define mod 1000000007
using namespace std;
std::string ExtractString(std::string s, int begin, int end){
	std::string t;
	for(int i=begin; i<end; i++) t+=s[i];
	return t; }// [beg, end)を抽出

int main(){
    string s;cin>>s;
    vector<string> a(4);
    a[0]="dream";a[1]="dreamer";a[2]="erase";a[3]="eraser";

    while(s.size()>=7){
        if(ExtractString(s,s.size()-5,s.size())==a[0])s.erase(s.size()-5,5);
        else if(ExtractString(s,s.size()-7,s.size())==a[1])s.erase(s.size()-7,7);
        else if(ExtractString(s,s.size()-5,s.size())==a[2])s.erase(s.size()-5,5);
        else if(ExtractString(s,s.size()-6,s.size())==a[3])s.erase(s.size()-6,6);
        else {cout<<"NO"<<endl;return 0;}
    }
    if(s.size()==0 || s==a[0] || s==a[2] || s==a[3]){cout<<"YES"<<endl;return 0;}
    cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int n, i, j, factorial;
		String str;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			factorial = (int) (Math.pow(2, n));
			char[] cha = new char[n];
			for(i = 0; i < factorial; i++) {
				str = Integer.toBinaryString(i);
				for(j = 0; j < str.length(); j++) {
					cha[j] = str.charAt(j);
				}
				System.out.print(i + ":");
				for(j = 0; j < str.length(); j++) {
					if(cha[str.length() - j - 1] == '1') {
						System.out.print(" " + j);
					}
				}
				System.out.println();
			}
		}
	}
}



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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A, B);
    ll ans = 1;
    for(ll p = 2; p * p <= g; p++) {
        if(g % p == 0) {
            ans++;
            while(g % p == 0)
                g /= p;
        }
    }
    ans += g > 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

pair<int,int> ps[100000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    int a, b;
    scanf("%d%d", &a, &b);
    ps[i] = make_pair(a, b);
  }
  sort(ps, ps + n);
  printf("%d\n", ps[n-1].first + ps[n-1].second);
  return 0;
}


Measured memory_bytes: 896
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

ll r;
int main() {
    cin >> r;

    ll ans = 3 * r * r;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define TESTCASES 0
using namespace std;

int n;

map<string,int> Mp;

int Go() {

  scanf("%d", &n);

  for(int i = 0 ; i < n ; ++i){
    string s;
    cin >> s;
    Mp[s]++;
  }

  int cnt = 0;
  for(auto el : Mp) cnt++;

  cout << cnt << endl;

  return 0;
}


int main() {


  int t;
  if (TESTCASES) scanf("%d", &t);
  else           t = 1;

  while (t--) Go();
}

Measured memory_bytes: 19252
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut ans = 0;
    let mut s = 0;
    let mut l = 0;
    for r in 0..n {
        s ^= a[r];
        ans += r - l + 1;
        while l <= r && r + 1 < n && s ^ a[r + 1] != s | a[r + 1] {
            s ^= a[l];
            l += 1;
        }
    }

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


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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s<t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n,k; cin>>n>>k; vll stone(n,0); forA(i,0,n,1)cin>>stone[i];
	ll dp[n]={0}; dp[0]=0; dp[1]=abs(stone[1]-stone[0]);
	forA(i,2,n,1)
	{
		ll ans=INT_MAX;
		forA(j,1,k+1,1)
		{	
			if(i-j<0)break;
			ll x = dp[i-j]+abs(stone[i]-stone[i-j]);
			ans=min(ans,x);
		}
		dp[i]= ans;
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 4768
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner cro=new Scanner(System.in);
int N,M,i,j,delx,dely,min,ind;
N=cro.nextInt();
M=cro.nextInt();
int students[][]=new int[N][2];
int checkpoints[][]=new int[M][2];
for(i=0;i<N;i++)
{
students[i][0]=cro.nextInt();
students[i][1]=cro.nextInt();
}
for(i=0;i<M;i++)
{
checkpoints[i][0]=cro.nextInt();
checkpoints[i][1]=cro.nextInt();
}
for(i=0;i<N;i++)
{
delx=students[i][0]-checkpoints[0][0];
dely=students[i][1]-checkpoints[0][1];
if(delx<0) delx=-delx;
if(dely<0) dely=-dely;
min=delx+dely;
ind=1;
for(j=1;j<M;j++)
{
delx=students[i][0]-checkpoints[j][0];
dely=students[i][1]-checkpoints[j][1];
if(delx<0) delx=-delx;
if(dely<0) dely=-dely;
if(delx+dely<min)
{
min=delx+dely;
ind=j+1;
}
}
System.out.println(ind);
}
}
}

Measured memory_bytes: 21844
n = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)
z = x.zip(y).map {|a, b| (a - b).abs }
[1, 2, 3].each do |p|
  puts '%.5f' % z.map {|c| c ** p }.inject(0, :+) ** (1.0 / p)
end
puts '%.5f' % z.max

Measured memory_bytes: 8876
/* #include <bits/stdc++.h> */
#include <vector>
#include <iostream>
#include <deque>
#include <unordered_map>
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair< int, int > pii;
typedef vector< int > vi;

//
struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);

        // Mainly for demonstration purposes, i.e. works but is overly simple
        // In the real world, use sth. like boost.hash_combine
        return h1 ^ h2;  
    }
};
//

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    if (x == 0) return y;
    return gcd(y % x, x);
}

ll euclid(ll a, ll b, ll &x, ll &y) {
	if (b) { ll d = euclid(b, a % b, y, x);
		return y -= a/b * x, d; }
	return x = 1, y = 0, a;
}

const ll mod = 1000000007;
struct Mod {
	ll x;
	Mod(ll xx) : x(xx) {}
	Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
	Mod operator-(Mod b) { return Mod((x - b.x + mod) % mod); }
	Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
	Mod operator/(Mod b) { return *this * invert(b); }
	Mod invert(Mod a) {
		ll x, y, g = euclid(a.x, mod, x, y);
		 return Mod((x + mod) % mod);
	}
	Mod operator^(ll e) {
		if (!e) return Mod(1);
		Mod r = *this ^ (e / 2); r = r * r;
		return e&1 ? *this * r : r;
	}
};

void solve() {
    int N; cin >> N;
    unordered_map<pair<ll, ll>, pair<int, int>, pair_hash> ok;
    ll AB0 = 0;
    for (int i = 0; i < N; i++) {
        ll A, B; cin >> A >> B;
        if (A == 0 && B == 0) {
            AB0++;
            continue;
        }
        ll G = gcd(abs(A), abs(B));
        A /= G;
        B /= G;
        int nrots = 0;
        while (A < 0 || B <= 0) {
            A *= -1;
            swap(A, B);
            nrots++;
        }
        pii curr = ok[{A, B}];
        if (nrots % 2) {
            curr.first++;
        } else {
            curr.second++;
        }
        ok[{A, B}] = curr;
    }
    Mod sol(1);
    for (pair<pair<ll, ll>, pair<int, int>> p : ok) {
        int x, y;
        tie(x, y) = p.second;
        Mod a = (Mod(2) ^ x) - 1;
        Mod b = (Mod(2) ^ y) - 1;
        sol = sol * (Mod(1) + a + b);
    }
    sol = sol - Mod(1);
    sol = sol + AB0;
    cout << (sol.x % mod + mod) % mod << "\n";
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    solve();
}


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

using namespace std;
typedef long long ll;


int main(){
    
    ios_base::sync_with_stdio(0);
    int n,m;
    cin>>n>>m;
    int a[n][m];
    int b[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }
    for(int i=0;i<m;i++)    cin>>b[i];

    int c[n];
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<m;j++){
            sum += (a[i][j]*b[j]);
        }
        c[i] = sum;
    }
    for(int i=0;i<n;i++)    cout<<c[i]<<endl;
    return 0;
}




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

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

using LL = long long;

namespace _buff {

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

}

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

int main() {
    int n = read();
    vector<int> a(n);
    generate_n(begin(a), n, read);
    sort(begin(a), end(a), greater<int>());

    int p = 0;
    for (; p < n; ++p) {
        if (p >= a[p]) {
            break;
        }
    }
    --p;
    int q = 0;
    for (; q < n; ++q) {
        if (a[q] <= p) break;
    }

    cerr << "p = " << p << '\n';
    cerr << "to up " << a[p] << "  to right " << q << '\n';

    puts(~(a[p] - p) & 1 || ~(q - p) & 1 ? "First" : "Second");

    return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int x, a;
  cin >> x >> a;

  if(x < a){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
  return 0;
}



Measured memory_bytes: 256