akhauriyash/Code-Regression huggingface dataset:
//070 ARC C - GO HOME
#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(){
    int64 x; cin >> x;
    int64 ans;
    for(int i=1;i<=1000000000;++i){
        if (( i * ( i + 1 ) / 2 ) >= x ) { ans = i; break;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

if K == 0:
    print(N ** 2)
    exit()

ans = 0
for b in range(K + 1, N + 1):
    val1 = N // b * (b - K)
    if N % b == 0:
        val2 = 0
    else:
        val2 = max(0, N - (N // b) * b - K + 1)
    ans += val1 + val2
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::greater<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  vector<int> d(n);
  for (int& x : d) {
    cin >> x;
  }
  vector<vector<pair<int, int>>> g(n);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].emplace_back(y, i);
    g[y].emplace_back(x, i);
  }
  vector<int> c(n, -1), w(m);
  for (int i = 0; i < n; ++i) {
    if (c[i] != -1) {
      continue;
    }
    for (const auto& edge : g[i]) {
      if (edge.first < i || d[i] != d[edge.first]) {
        continue;
      }
      if (c[edge.first] == -1) {
        c[edge.first] = 1;
      }
      c[i] = c[edge.first] ^ 1;
      w[edge.second] = d[i];
      break;
    }
  }
  vector<int> ord(n);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), [&] (int l, int r) {
    return d[l] < d[r];
  });
  for (int i = 0; i < n; ++i) {
    int x = ord[i];
    if (c[x] != -1) {
      continue;
    }
    for (const auto& edge : g[x]) {
      if (c[edge.first] == -1 || d[x] < d[edge.first]) {
        continue;
      }
      c[x] = c[edge.first] ^ 1;
      w[edge.second] = d[x];
      break;
    }
  }
  if (find(begin(c), end(c), -1) != end(c)) {
    cout << "-1\n";
  } else {
    for (int i = 0; i < n; ++i) {
      cout << (c[i] ? 'W' : 'B');
    }
    cout << '\n';
    for (int i = 0; i < m; ++i) {
      if (w[i]) {
        cout << w[i] << '\n';
      } else {
        cout << "1000000000\n";
      }
    }
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

int main() {
	string S;
	cin >> S;
	if((S.size()%2==0) ^ (S.front()==S.back())){
	    cout << "Second" << endl;
	}else{
	    cout << "First" << endl;
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> graph(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  vector<vector<int>> colored_nodes(2);
  auto dfs = [&](auto&& dfs, int i, int j, int d) -> void {
    colored_nodes[d % 2].push_back(j);
    for (auto k : graph[j]) {
      if (k == i) continue;
      dfs(dfs, j, k, d + 1);
    }
  };
  dfs(dfs, 0, 0, 0);
  if (colored_nodes[0].size() > colored_nodes[1].size()) swap(colored_nodes[0], colored_nodes[1]);

  int m = colored_nodes[0].size();
  vector<int> r(n);
  for (int i = 1; i <= n; i++) {
    int k;
    if (m <= n / 3) {
      if (i % 3 == 0) {
        k = colored_nodes[0].empty() ? 1 : 0;
      } else {
        k = 1;
      }
    } else {
      if (i % 3 == 0) {
        k = colored_nodes[0].size() < colored_nodes[1].size() ? 1 : 0;
      } else if (i % 3 == 1) {
        k = 1;
      } else if (i % 3 == 2) {
        k = 0;
      }
    }
    r[colored_nodes[k].back()] = i;
    colored_nodes[k].pop_back();
  }

  for (auto e : r) cout << e << ' ';
  cout << endl;
}


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int get(int x) {
	if (x < 10) {
		return x + x * 10;
	}
	int temp = x % 10;
	while (1) {
		x /= 10;
		if (x < 10) {
			temp += x * 10;
			break;
		}
	}
	return temp;
}

int inv(int x) {
	if (x < 10) {
		return x + x * 10;
	}
	int temp = x % 10;
	while (1) {
		x /= 10;
		if (x < 10) {
			temp = temp * 10 + x;
			break;
		}
	}
	if (temp < 10) {
		return 101;
	}
	return temp;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    scanf("%d", &n);
    ll res = 0;
    map <int, int> mp1, mp2;
    for (int i = 1; i <= n; i++) {
		//printf("%d: %d %d\n", i, get(i), inv(i));
		mp1[get(i)]++;
		mp2[inv(i)]++;
	}
	for (auto x : mp1) {
		if (mp2.count(x.fi)) {
			res += (ll)x.se * mp2[x.fi];
		}
	}
	printf("%lld", res);
    return 0;
}


Measured memory_bytes: 3808
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,cnt=0;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=1;i<n;i++){
    if(a[i]==a[i-1]){
      cnt++;
      i++;
    }
  }
  cout << cnt << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int main(){
	int A[3];
	REP(i,3) cin>>A[i];
	int ans=0;
	bool flg=true;
	REP(i,3){
		if (A[i]!=A[(i+1)%3]){
			flg=false;
		}
	}
	if (flg){
		if (A[0]%2==0){
			cout<<-1<<endl;
		}else{
			cout<<0<<endl;
		}
		return 0;
	}
	while(1){
		flg=false;
		REP(i,3){
			if (A[i]%2==1){
				flg=true;
			}
		}
		if (flg) break;
		ans++;
		int B[3];
		REP(i,3) B[i]=A[i];
		REP(i,3){
			A[i]=(B[(i+1)%3]+B[(i+2)%3])/2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int M = 100000;
	int w, h;
	while(cin >> w >> h, w || h) {
		int tab[128][128][4] = {0};

		tab[0][1][0] = tab[1][0][2] = 1;

		for(int i = 0; i < w; i++) {
			for(int j = 0; j < h; j++) {
				if(i+j>1) {
					if(j-1 >= 0) {
						tab[i][j][0] = (tab[i][j-1][0] + tab[i][j-1][1]) % M;
						tab[i][j][1] = tab[i][j-1][2] % M;
					}
					if(i-1 >= 0) {
						tab[i][j][2] = (tab[i-1][j][2] + tab[i-1][j][3]) % M;
						tab[i][j][3] = tab[i-1][j][0] % M;
					}
				}
			}
		}

		int ans = 0;
		for(int i = 0; i < 4; i++)
			ans += tab[w-1][h-1][i];
		cout << ans % M << endl;
	}
}

Measured memory_bytes: 1424
#include <stdio.h>

int main (int argv, char *argc[]){
	int input1, input2, buf;	
	while(1){
		scanf("%d %d", &input1, &input2);
		if(0 == input1 && 0 == input2) break;
		if(input1 > input2){
			buf = input1;
			input1 = input2;
			input2 = buf;
		}
		printf("%d %d\n", input1, input2);
	}
	return 0;
}

Measured memory_bytes: 600
main = do
  s <- reverse <$> getLine
  putStrLn $ f s

f "" = "YES"
f ('m':'a':'e':'r':'d':ns) = f ns
f ('r':'e':'m':'a':'e':'r':'d':ns) = f ns
f ('e':'s':'a':'r':'e':ns) = f ns
f ('r':'e':'s':'a':'r':'e':ns) = f ns
f _ = "NO"


Measured memory_bytes: 7548
#include <stdio.h>

int main() {

	int input, digit;

	scanf("%d", &input);

	digit = input % 10;
	if(digit == 7) {
		printf("Yes\n");
		return 0;
	}

	digit = (input % 100 - input % 10) / 10;
	if(digit == 7) {
		printf("Yes\n");
		return 0;
	}

	digit = (input % 1000 - input % 100) / 100;
	if(digit == 7) {
		printf("Yes\n");
		return 0;
	}

	printf("No\n");
	return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

#define ll long long

int n,k;
int a[212345];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);}

  ll ans=1000;
  ll kabu=0;
  a[n]=0;
  for(int i=0;i<n;i++){
    if(a[i]<a[i+1]){
      kabu += ans/a[i];
      ans %= a[i];}
    else if(a[i]>a[i+1]){
      ans += kabu*a[i];
      kabu = 0;}
  }

  printf("%lld\n",ans);

  return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,ans=0;
    cin>>n;
    long long arr[n];
    for(long i=0;i<n;i++){
    cin>>arr[i];
    }
    sort(arr,arr+n,greater<int>());
    ans+=arr[0];
    n-=2;
    for(long i=1;i<(n/2)+1;i++){
    ans+=2*arr[i];
    }
    if(n%2==1){
    ans+=arr[1+(n/2)];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		sc.close();
		
		if(a*b <= 0) {
			System.out.println("Zero");
		} else if(a > 0) {
			System.out.println("Positive");
		} else {
			if((b-a)%2 == 0) {
				System.out.println("Negative");
			} else {
				System.out.println("Positive");
			}	
		}
		
		return;
	}
	
}

Measured memory_bytes: 10060
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
const int N = 8;
map<vi, bool> used;
int n;
vector<vi> rot = {{1, 2, 3, 0, 5, 6, 7, 4},
                  {6, 7, 1, 0, 2, 3, 5, 4}};

void dfs(vi perm){
    if(used[perm]) return;
    used[perm] = true;

    rep(i, 2){
        vi next_perm(N);
        rep(j, N){
            next_perm[j] = perm[rot[i][j]];
        }
        dfs(next_perm);
    }
}

int main(void){
    vector<string> in(N);
    while(cin >> in[0]){
        rep(i, 1, N) cin >> in[i];
        map<string, int> s2i;
        int idx = -1;
        vi num_color;
        for(auto & e : in){
            if(s2i.find(e) == end(s2i)){
                idx++;
                s2i[e] = idx;
                num_color.push_back(0);
            }
            num_color[idx]++;
        }

        used.clear();

        n = num_color.size();
        vi perm(N);
        rep(i, N) perm[i] = s2i[in[i]];

        sort(_all(perm));
        int res = 0;
        do {
            if(not used[perm]){
                dfs(perm);
                res++;
            }
        } while(next_permutation(_all(perm)));

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;


int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
     for(auto &x:A)cin>>x;
    map<int, lint> cnt;
    for (auto x : A) cnt[x]++;
    lint ret = 0;
    for (auto p : cnt) ret += (p.second - 1) * p.second / 2;
     for(int i=0;i<N;i++) {
        lint n = cnt[A[i]];
        lint tmp = ret - n+1;
        cout << tmp << "\n";
    }
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

string S;
bool b[500000];
ll res, a[500000];

int main() {
	cin >> S;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i] == '>'&&S[i + 1] == '<') {
			b[i + 1] = true;
		}
	}
	if (S[0] == '<') {
		b[0] = true;
	}
	if (S.back() == '>') {
		b[S.size()] = true;
	}
	for (int i = 0; i < S.size(); i++) {
		if (b[i] && S[i] == '<') {
			a[i + 1] = a[i] + 1;
			b[i + 1] = true;
		}
	}
	for (int i = S.size() - 1; i >= 0; i--) {
		if (b[i + 1] && S[i] == '>') {
			a[i] = max(a[i], a[i + 1] + 1);
			b[i] = true;
		}
	}
	for (int i = 0; i <= S.size(); i++) {
		res += a[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 5252
#include <stdio.h>

int main(){
  int ret,win = 0,lose = 0,num = 0;
  char c;
  while(1){
    ret = scanf("%c", &c);
    if(ret == EOF || c == '\n') break;
    else if(c == 'o') win++;
    else if(c == 'x') lose++;
    num++;
  }
  int flag = 0;
  if(lose >= 8) flag = 1;
  if(flag == 0) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define replb(i, a, b) for (ll i = a; i >= b; i--)
#define repl(i, a, b) for (ll i = a; i < b; i++)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
#define pb push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
}
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
}
int cel(int a,int b){return((a-1)/b+1);} 
int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a,int b){
    return (a*b)/gcd(a,b);
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,a,b,ans=0;
    cin>>n;vi v(10001,0);
    rep(i,1,101){
        rep(j,1,101){
            rep(k,1,101){
                a=i*i+j*j+k*k+i*j+j*k+k*i;
                if(a<10001){v[a]++;}
            }
        }
    }
    rep(i,1,n+1)cout<<v[i]<<"\n";
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map> 
#define mod 1000000007
#define ll long long
using namespace std;
char s1[100],s2[100];
int n,i,j,k;
long long ans=1;
int main()
{
	scanf("%d",&n);
	scanf("%s %s",s1+1,s2+1);
	
	for(i=1;i<=n;i++)
	{
		if(i==1)
		{
			if(s1[1]==s2[1]) ans*=3;
			else ans*=6;
		}
		else
		{
			if(s1[i-1]==s2[i-1])
			{
				if(s1[i]==s1[i+1])
				{
					ans*=2;
					i++;
				}
				else ans*=2;
			}
			else 
			{
				if(s1[i]==s1[i+1])
				{
					ans*=3;
					i++;
				}
			}
		}
		ans%=mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
end = [-1]*N
end[-1] = 0

for i in range(N-2, -1, -1):
    end[i] = min(end[i+1]+t[i+1], v[i], v[i+1])

ans = 0
s = 0

for i in range(N):
    e = end[i]

    if s+t[i]<=e:
        ans += (s+s+t[i])*t[i]/2
        s = s+t[i]
    else:
        up = min(v[i], (s+e+t[i])/2)
        ans += (s+up)*(up-s)/2
        ans += (e+up)*(up-e)/2
        ans += up*(t[i]-(up-s)-(up-e))
        s = e

print(ans)

Measured memory_bytes: 38384
#include<stdio.h>

int main(void)
{
    int n,p,i,j,flag,pp;
    int o[50];

    while(scanf("%d%d",&n,&p),n+p){

        pp=p;
        for(i=0;i<n;i++){
            o[i]=0;
        }
        flag=0;

        for(i=0;;i++,i%=n){
            if(p){
                o[i]++;
                p--;
            } else {
                p=o[i];
                o[i]=0;
            }
            for(j=0;j<n;j++){
                if(o[j]==pp){
                    flag=1;
                    break;
                }
            }
            if(flag) break;
        }

        printf("%d\n",i);
    }
    return 0;
}

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

int main() {
  int N;
  long Y;
  cin >> N >> Y;
  
  for(int x=0; x<=N; x++){
    for(int y=0; y<=(N-x); y++){
      if(10000*x + 5000*y + 1000*(N-x-y) == Y){
        cout << x << " " << y << " " << N-x-y << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll> x(m);
  for(ll i=0;i<m;i++) {
    cin >> x[i];
  }
  if(n>=m) {
    cout << 0 << endl;
    return 0;
  }
  sort(x.begin(),x.end());
  ll ans=x[m-1]-x[0];
  priority_queue<ll> q;
  for(ll i=0;i<m-1;i++) {
    q.push(x[i+1]-x[i]);
  }
  for(ll i=0;i<n-1;i++) {
    ans-=q.top();
    q.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int D, N;
int main() {
    cin >> D >> N;
    if(D == 0) {
        if(N == 100) {
            cout << 101 << endl;
        }else {
            cout << N << endl;
        }
    }else if(D == 1) {
        if(N == 100) {
            cout << 101 * 100 << endl;
        }else {
            cout << N * 100 << endl;
        }
    }else {
        if(N == 100) {
            cout << 101 * 10000 << endl;
        }else {
            cout << N * 10000 << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 998244353
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18;
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   ll n,a,b,c;
   cin>>n>>a>>b;
   c=b-a;
   if(c%2==0)
   {
       cout<<c/2<<endl;
       return 0;
   }
   c=min(b-1,(b+a-1)/2);
   c=min(c,n-a);
   c=min(c,(2*n-b-a+1)/2);
   cout<<c<<endl;
}


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

namespace AtCoder.Abc
{
    class A_163_CirclePond
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            
            // 整数の入力
            double r = double.Parse(Console.ReadLine());

            r = 2 * r * 3.14;


            Console.WriteLine(r);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27456
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    int N; SCD(N);
    if (N==1){
        printf("Hello World\n");
    }else{
        int A,B;
        SCD2(A,B);
        PRINTD(A+B);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    a += b;
    int n = 0;
    for (int i = 0; i < a.size(); i++) {
        n *= 10;
        n += a[i] - '0';
    }
    for (int i = 0; i <= 599; i++) {
        if (i * i == n) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
/**
 * @Author:      G_bg
 * @DateTime:    2019-08-04 20:25:28
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
int a[maxn];
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    string str;cin >> str;
    int len = str.length();
    for(int i = 1;i < len;){
        while(i < len && (str[i] != 'L' || str[i-1] != 'R')) i++;
        int j = i-1,sum = 0;
        while(j >= 0 && str[j] == 'R') sum++,j--;
        a[i-1] += (sum+1)/2;
        a[i] += sum/2;
        j = i;sum = 0;
        while(j < len && str[j] == 'L') sum++,j++;
        a[i] += (sum+1)/2;
        a[i-1] += sum/2;
        i = j;
    }
    for(int i = 0;i < len;i++) cout << a[i] << " ";
    cout << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 1104
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);

 string s;cin>>s;
 if(s == "RRR") cout << 3 << endl;
 else if(s == "SSS") cout << 0 << endl;
 else if(s.substr(0,2) == "RR" || s.substr(1,2) == "RR") cout << 2 << endl;
 else cout << 1 << endl;




 return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using TU = tuple<int, int, long long int>;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  vector<int> a(n+1);
  REP(i,n) cin >> a[i+1];
  ll money = 1000;

  for (int i = 1; i < n; i++) {
    ll stocks = 0;
    if (a[i] < a[i+1]) stocks = money/a[i];
    money += (a[i+1] - a[i]) * stocks;
  }
  COUT(money);
  return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  string w;
  int a[27]={};
  bool flag = true;
  cin>>w;
  rep(i,0,w.size()){
    a[w[i]-'a']++;
  }
  rep(i,0,27){
    if(a[i]%2!=0) flag=false;
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main(void) {
  int n, k, s;
  cin >> n >> k >> s;

  // k == nなら{s, s, s, ..., s}
  // k == 0なら{s/2+1, s/2+2, s/2+3, ...}
  vector<int> as(n);
  int t = 500 * 1000 * 1000 + 1; 
  for (int &a : as) {
    a = t++;
  }

  for (int i = 0; i < k; i++) {
    as[i] = s;
  }

  cout << as[0];
  for (int i = 1; i < n; i++) {
    cout << ' ' << as[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 1664
w, h, t = map(int, input().split())
p = int(input())
hiryo = []
for i in range(p):
    x, y, t = list(map(int, input().split()))
    hiryo.append([x, y, t])
hatake = [[0 for i in range(w)] for j in range(h)]
hatake_boolean = []
for i in range(h):
    row = list(map(int, input().split()))
    row_boolean = []
    for j in row:
        if j: row_boolean.append(True)
        else: row_boolean.append(False)
    hatake_boolean.append(row_boolean)

for i in range(p):
    x, y, t = hiryo[i]
    if hatake_boolean[y][x]:
        hatake[y][x] += 1
ans = 0
for row in hatake:
    ans += sum(row)
print(ans)

Measured memory_bytes: 7808
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	cout.precision(16);
	static const int COMBSZ = 128;
	LL C[COMBSZ][COMBSZ] = { 1 };
	for (int i = 1; i < COMBSZ; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
		}
	}
	while (true) {
		int n = -1, a, b;
		cin >> n >> a >> b;
		if (n <= 0) break;
		vector<LL> v(n);
		map<LL, int> m;
		for (int i = 0; i < n; ++i) {
			cin >> v[i];
			m[v[i]] += 1;
		}
		sort(v.rbegin(), v.rend());
		double avg = accumulate(v.begin(), v.begin() + a, 0.0) / a;
		cout << avg << endl;
		LL ans = 0;
		if (v[0] == v[a - 1]) {
			for (int i = a; i <= b; ++i) {
				ans += C[m[v[a - 1]]][i];
			}
		} else {
			for (int i = a - 1; i >= 0; --i) {
				if (v[i] != v[a - 1]) {
					break;
				}
				ans = C[m[v[a - 1]]][a - i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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 main(){
	string s,p;
	cin >> s >> p;
	s += s;
	if(s.find(p)==string::npos) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 1192
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();

        int[] m = new int[n];
        for(int i=0; i<n; i++) {
            m[i] = sc.nextInt();
        }

        int sum = 0;
        for(int i: m) {
            sum += i;
        }

        Arrays.sort(m);

        int rest = 0;
        if(x - sum > 0) {
            rest = (x-sum) / m[0];
            System.out.println(rest+n);
        } else {
            System.out.println(n);
        }
        sc.close();
    }
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var H = inputArray[0];




			//答えの出力
			var ans = getAns(H);
			Console.WriteLine(ans);

		}

		/// <summary>
		// 必要な攻撃の最小回数は、2^x <= H < 2^(x+1)　となる 2^xがHの時と同じ回数になる
		// 2^(x+1)のHを0にするのに必要な回数は、2^(x)のHを0にするのに必要な回数をkとすると、2k+1になる
		// f(x) = sum(2^(i))... i=0~x-1 であることが帰納法で示せる
		/// </summary>
		/// <param name="H"></param>
		/// <returns></returns>
		private static long getAns(long H) {

			if (H == 1) {
				return 1;
			}


			//まずxを求める
			var x = 0;
			while (Math.Pow(2, x+1 ) <= H) {
				x++;
			}
			//Console.WriteLine($"x={x}");

			long ans = 1;
			long exp2 = 1;
			for (int i = 0; i < x; i++) {
				exp2 *= 2;
				ans += exp2;
			}
			return ans;

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    string s; cin >> s;
    map<char, bool> dict;
    for (auto c : s) {
        dict[c] = true;
    }

    bool ok = false;
    if (dict['N'] == dict['S'] && dict['E'] == dict['W']) {
        ok = true;
    }
    string ans = ok ? "Yes" : "No";
    cout << ans << endl;
}

Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_073_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(4).

    01 INP    PIC X(13).
    01 l      PIC 9(6).
    01 r      PIC 9(6).

    01 i      PIC 9(6).

    01 sm     PIC 9(6).

    01 ZS     PIC Z(7).
    01 DUMMY  PIC X(1).

    01 ans    PIC X(6).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    MOVE 0 TO sm.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        ACCEPT INP

        UNSTRING INP
        DELIMITED BY SPACE
        INTO l r

        SUBTRACT l FROM r
        ADD 1 TO r
        ADD r TO sm
    END-PERFORM.

    MOVE sm TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
X,K,D=map(int,input().split())
if D*K<abs(X):
  print(abs(X)-D*K)
else:
  K2=abs(X)//D
  if K2>K:
    K2=K
  if (K-K2)%2==0:
    print(abs(X)-K2*D)
  else:
    ans=min(abs(X)-(K2-1)*D, (K2+1)*D-abs(X))
    print(ans)

Measured memory_bytes: 9088
N, K = map(int, input().split())
S = input()
ans = ''
for i in range(N):
    if i == K-1:
        if S[i] == 'A':
            ans += 'a'
        elif S[i] == 'B':
            ans += 'b'
        else:
            ans += 'c'
    else:
        ans += S[i]
print(ans)

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2e5+10;
int a[MAXN],b[MAXN];
int main()
{
	int n;
	while(cin>>n){
		for(int i=1;i<=n;i++){
			cin>>a[i];
			b[i]=a[i];
		}
		sort(b+1,b+n+1);
		int mid=n/2;
		for(int i=1;i<=n;i++){
			if(a[i]<=b[mid]) cout<<b[mid+1]<<endl;
			else cout<<b[mid]<<endl;
		}
	}
}

Measured memory_bytes: 3712
n,k,*p=map(int,open(0).read().split())
l=[]
l.append(sum(p[:k]))
for i in range(k,n):
    l.append(l[-1]+p[i]-p[i-k])
ind=l.index(max(l))
ans=0
for i in range(k):
    ans += (1+p[ind+i])/2
print(ans) 


Measured memory_bytes: 25036
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int sum=0,res=0;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='R')
        {
            while(a[i]=='R')
            {
                sum++;
                i++;
            }
            i--;
            res=max(res,sum);
            sum=0;
        }
    }
    cout<<res<<endl;
    return 0;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s,t;
vector<int> v[N];
int n;
ll a[N];

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

  cin >> n >> s >> t;
  rep(i,n) {
    cout << s[i] << t[i];
  }
  cout << endl;
}


Measured memory_bytes: 25344
#include<stdio.h>
#include <iostream>
#include<algorithm>
#define ll long long
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        ll num[105];
        ll ans[105];
        for(int i=0;i<n-1;i++)
            cin>>num[i];
        ans[0] = num[0];
        for(int i=0;i<n-1;i++)
            ans[i] = min(num[i],num[i-1]);
        ans[n-1] = num[n-2];
        ll sum=0;
        for(int i=0;i<n;i++) sum+=ans[i];
//            cout<<ans[i]<<" ";

        cout<<sum<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb push_back;
#define sp " ";
void vout(vector<lli> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    vector<lli> ans(10,0);
    lli h,w,all,n;
    map <pii,int> sq;
    cin>>h>>w>>n;
    all=(h-2)*(w-2);
    vi a;
    vi b;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        bool u,d,l,r;
        u=l=d=r=false;
        if(x>2) u=true;
        if(y>2) l=true;
        if(x<h-1) d=true;
        if(y<w-1) r=true;
        if(u&&y>1&&y<w) (sq.count(pii (x-2,y-1))?sq.at(pii (x-2,y-1))+=1:sq[pii (x-2,y-1)]=1);
        if(u&&l) (sq.count(pii (x-2,y-2))?sq.at(pii (x-2,y-2))+=1:sq[pii (x-2,y-2)]=1);
        if(u&&r) (sq.count(pii (x-2,y))?sq.at(pii (x-2,y))+=1:sq[pii (x-2,y)]=1);
        if(d&&y>1&&y<w) (sq.count(pii (x,y-1))?sq.at(pii (x,y-1))+=1:sq[pii (x,y-1)]=1);
        if(d&&l) (sq.count(pii (x,y-2))?sq.at(pii (x,y-2))+=1:sq[pii (x,y-2)]=1); 
        if(d&&r) (sq.count(pii (x,y))?sq.at(pii (x,y))+=1:sq[pii (x,y)]=1);
        if(l&&x>1&&x<h) (sq.count(pii (x-1,y-2))?sq.at(pii (x-1,y-2))+=1:sq[pii (x-1,y-2)]=1);
        if(r&&x>1&&x<h) (sq.count(pii (x-1,y))?sq.at(pii (x-1,y))+=1:sq[pii (x-1,y)]=1);
        if(x>1&&x<h&&y>1&&y<w) (sq.count(pii (x-1,y-1))?sq.at(pii (x-1,y-1))+=1:sq[pii (x-1,y-1)]=1);
    }
    //各正方行列について範囲内における左上のマスを求め、記録する。
    for(pair<pii,int> p:sq){
        ans.at(p.second)+=1;
    }
    ans.at(0)=all-sq.size();
    vout(ans);
}

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

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

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<vector<int>> A(2, vector<int> (N, 0));
	for (int i=0; i<2; i++)
		for (int j=0; j<N; j++)
			cin >>A.at(i).at(j);
	int S0=0, S1=0;
	S0=A.at(0).at(0);
	S1=S0+A.at(1).at(0);
	for (int i=1; i<N; i++) {
		S0 +=A.at(0).at(i);
		S1=max(S1, S0)+A.at(1).at(i);
	}
	cout <<S1 <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
ll ans,n,m;
priority_queue<ll> q;
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=0;i<n;i++)
    {
        ll x;
        scanf("%lld",&x);
        q.push(x);
    }
    while(m--)
    {
        ll x=q.top();q.pop();
        q.push(x/2);
    }
    while(!q.empty())
    {
        ans+=q.top();
        q.pop();
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 1400
#define ll long long
#define dd long double
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
//#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
dd pi = acos(-1) ;
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll fact[100] ;
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll e_gcd(ll a , ll b , ll &x , ll &y){ if(b > a) return e_gcd(b , a , y , x) ; if(b == 0){x = 1 ; y = 0 ; return a ;}
ll x1 , y1 ; e_gcd(b , a%b , x1 , y1) ; x = y1 ; y = (x1 - ((a/b) * y1)) ; return e_gcd(b , a%b , x1 , y1) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r|| (n < 0) || (r < 0)) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n

void solve()
{
    ll n ;
    cin >> n ; 
    ll arr[n] , dp[n+1];
    fo(i , n)
    {
        cin >> arr[i] ;
        dp[i+1] = 0 ;
    }
    ll maxi = 0 ;
    dp[0] = 0 ;
    fo(i , n)
    {
        dp[arr[i]] = dp[arr[i]-1] + 1 ; 
        maxi = max(maxi , dp[arr[i]]) ;
    }
    cout << n - maxi << endl ;
    return ;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif*/
    
    ll t ;
    //cin >> t ;
    t = 1 ;
    
    while(t--)
    {
        solve() ;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {

  int A;
  int B;

  cin >> A;
  cin >> B;

  if (A > 9 || B > 9) {
    cout << "-1" <<endl;
  }else {
    cout << A*B << endl;
  }


  return 0;
}



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

#define maxn 100001
#define ll long long

int u,v,n,m;
int edge[maxn][2];
vector<int> adj[maxn];
int root[maxn];
ll sz[maxn],ans[maxn];

void set_root(int v, int x){
	root[v]=x;
	int u,s=adj[v].size();
	for(int i=0;i<s;i++){
		u=adj[v][i];
		set_root(u,x);
	}
	return;
}

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

	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>edge[i][0]>>edge[i][1];
		ans[i]=0;
	}
	for(int i=1;i<=n;i++){
		sz[i]=1;
		root[i]=i;
	}
	for(int i=m;i>0;i--){
		u=edge[i][0],v=edge[i][1];
		u=root[u],v=root[v];
		if(u==v) continue;
		if(sz[u]>=sz[v]){
			adj[u].push_back(v);
			ans[i]+=sz[u]*sz[v];
			sz[u]+=sz[v];
			set_root(v,u);
		}
		else{
			adj[v].push_back(u);
			ans[i]+=sz[u]*sz[v];
			sz[v]+=sz[u];
			set_root(u,v);
		}
	}
	ll res=0;
	for(int i=1;i<=m;i++){
		res+=ans[i];
		cout<<res<<"\n";
	}
	return 0;
}

Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
#include <iomanip>
using namespace std;
// type alias
typedef long long LL;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))

// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');

// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpf(args...) if(TRACE) { fprintf(stderr, ##args); putchar('\n'); }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
template<class Iter> void dumpc(Iter begin, Iter end) { if (TRACE) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; } }

// $ ../batch 755 | diff 755.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address 755.cpp && ./a.out
int N;

LL res=0;
VI X={3,5,7};
void dfs(int p, LL cur) {
  if(cur<=N) {
    int n=cur;
    SETI S;
    while(n>0) S.emplace(n%10),n/=10;
    res+=(SZ(S)==3);
  }
  if(p>=9) return;

  REP(i,3) {
    dfs(p+1,10*cur+X[i]);
  }
}
void solve() {
  dfs(0,0);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   string s; cin >> s;
   if(s == "ABC") cout << "ARC\n";
   else cout << "ABC\n";    
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

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 long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int x;
    cin >> x;
    for (ll i = -1000; i < 1000; ++i) {
        for (ll j = -1000; j < 1000; ++j) {
            if(i*i*i*i*i-j*j*j*j*j == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3604