akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
using namespace std;

int main(){
  int n,counter=0;
  map<int,int> mp;
  int a[1000010];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    auto itr = mp.find(a[i]);
    if(itr != mp.end()){
      mp.erase(itr);
    }else{
      mp[a[i]]=1;
    }
  }
  for(auto itr =mp.begin();itr!=mp.end();++itr){
    counter++;
  }
  cout << counter <<endl;
}


Measured memory_bytes: 5376
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};


#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;


signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string n;
  cin >> n;
  vector<int> s(sz(n));
  vector<vector<ll>> dp(sz(s)+1, vector<ll>(2));
  ll ans = 0;
  dp[0][1] = 1;
  REP(i, sz(n)) s[i] = n[i] - '0';
  REP(i, sz(n)) {
      dp[i+1][0] = min(dp[i][0] + s[i], dp[i][1] + 10 - s[i]);
      dp[i+1][1] = min(dp[i][0] + s[i] + 1, dp[i][1] + 10 - s[i] - 1);
  }
  cout << dp[sz(n)][0]<< endl;
  return 0;
}


Measured memory_bytes: 59804
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 810114514
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int long long 

int IsPrime(int X){
    for(int i=2;i*i<=X;i++){
        if(X%i==0){
            return false;
        }
    }
    return true;
}

signed main(){
    int N;
    int i=0,now=3;
    cin >> N;
    while(i<N){
        if(IsPrime(now)==true && now%5 == 1){
            cout << now << " ";
            i++;
        }
        now++;
    }
    cout << endl;
	return 0;
}

Measured memory_bytes: 256
/*
// A - Day of Takahashi O(1)
#include <iostream>
using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<(a<=b?a:a-1)<<endl;
    return 0;
}
// B - Maximum Sum O(3log3+K)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    vector<int> V;
    V.push_back(A),V.push_back(B),V.push_back(C);
    sort(V.begin(),V.end());
    for (int i=0; i<K; i++) {
        V[2]*=2;
    }
    cout<<V[0]+V[1]+V[2]<<endl;
    return 0;
}

// C - Grid Repainting 2 O(HW)
#include <iostream>
using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int H,W;
    cin>>H>>W;
    char s[H][W];
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            cin>>s[i][j];
        }
    }
    int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
    bool ans=true;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (s[i][j]=='#') {
                bool found=false;
                for (int k=0; k<4; k++) {
                    int x=i+dx[k];
                    int y=j+dy[k];
                    if (x>=0&&x<H&&y>=0&&y<W&&s[x][y]=='#') {
                        found=true;
                    }
                }
                if (!found) {
                    ans=false;
                }
            }
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}
*/
// D - Five, Five Everywhere O(nloglogn+n)
#include <iostream>
#include <vector>
using namespace std;
const int n=55556;

void eratosthenes(bool prime[]){
    for (int i=0; i<n; i++) {
        prime[i]=true;
    }
    prime[0]=prime[1]=false;
    for (int i=0; i<n; i++) {
        if (prime[i]) {
            for (int j=i+i; j<n; j+=i){
                prime[j]=false;
            }
        }
    }
}
int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    bool Prime[n];
    eratosthenes(Prime);
    int N;
    cin>>N;
    vector<int> a;
    int idx=0;
    for (int i=0; i<n; i++) {
        if (Prime[i]) {
            if (i%5==1) {
                a.push_back(i);
                idx++;
                if (idx==N) {
                    break;
                }
            }
        }
    }
    for (int i=0; i<N; i++) {
        cout<<a[i]<<" "<<flush;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import System.IO (isEOF)

main = do
    quit <- isEOF
    if quit then return () else do
        line <- getLine
        let
            (joi,ioi) = count line
        print joi
        print ioi
        main

count :: String -> (Int,Int)
count s = count' s 0 0
    where
    count' "" joi ioi = (joi,ioi)
    count' ('J':'O':'I':cs) joi ioi = count' ('I':cs) (joi+1) ioi
    count' ('I':'O':'I':cs) joi ioi = count' ('I':cs) joi (ioi+1)
    count' (_:cs) joi ioi = count' cs joi ioi

Measured memory_bytes: 4104
import math

a,b,c = map(float,input().split())

b_y = b * math.sin(math.radians(c))
b_x= b * math.cos(math.radians(c))

Area = a * b_y / 2
Area = round(Area,8)

a_x = a
a_y = 0.0

x_dis = abs(a_x - b_x)
y_dis = abs(a_y - b_y)

dis = math.sqrt(x_dis**2 + y_dis**2)

Length = round(dis,8) + a + b

Tall = b_y

print(Area)
print(Length)
print(Tall)





Measured memory_bytes: 5696
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
int main()
{
    FASTIO
    //   L(T)
    {
        lli n;
        cin >> n;
        lli a[n + 1];
        lli h[200006];
        memset(h, 0, sizeof(h));
        fw(i, 1, n)
        {
            cin >> a[i];
            h[a[i]]++;
        }
        fw(i, 1, n + 1)
        {
            cout << h[i] << "\n";
        }
    }
    return 0;
}

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

int solve(int h, int w) {
    int a[4];
    int s[3];
    int dh = (h + 1) / 3;
    s[0] = dh * w;
    s[1] = ((h - dh) / 2) * w;
    s[2] = (h - dh - (h - dh) / 2) * w;
    sort(s, s + 3);
    a[0] = s[2] - s[0];

    s[0] = dh * w;
    s[1] = (w / 2) * (h - dh);
    s[2] = (w - w / 2) * (h - dh);
    sort(s, s + 3);
    a[1] = s[2] - s[0];

    int dw = (w + 1) / 3;
    s[0] = h * dw;
    s[1] = ((w - dw) / 2) * h;
    s[2] = (w - dw - (w - dw) / 2) * h;
    sort(s, s + 3);
    a[2] = s[2] - s[0];

    s[0] = h * dw;
    s[1] = (h / 2) * (w - dw);
    s[2] = (h - h / 2) * (w - dw);
    sort(s, s + 3);
    a[3] = s[2] - s[0];
    return a[min_element(a, a + 4) - a];
}

int main() {
    int h, w;
    cin >> h >> w;
    cout << solve(h, w) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n;
  cin>>n;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  double up=1,down=0;
  REP(i,n){
    down += 1/(double)a[i];
  }
  double ans;
  ans = up/down;
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  int N, t = 0;
  cin >> N;
  string s;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    if (s == "A") ++t;
    else --t;
    if (t < 0) {
      t += 2*N;
    }
  }
  if (t) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int>alp(26,0);
    for(int i=0;i<n;i++){
        alp[(int)(s[i]-'a')]++;
    }
    long ans = 1;
    long const MOD = 1e9+7;
    for(int i=0;i<26;i++){
        ans *= alp[i] + 1;
        ans %= MOD;
    }
    cout <<ans-1<<endl;
    
}

Measured memory_bytes: 512
#include <iostream> 
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <queue>
using namespace std;

int main()
{
	long long n,i;
	long long num[100001],s[100001]={0};
	scanf("%lld",&n);
	for(i=1;i<=n;i++) scanf("%lld",&num[i]);
	sort(num+1,num+n+1);
	for(i=1;i<=n;i++) s[i]=s[i-1]+num[i];
	for(i=n-1;i>0;i--)
		if(s[i]*2<num[i+1]) 
		{
			//printf("\n%lld %lld %lld\n",s[i],num[i+1],i);
			break;
		}
	printf("%lld\n",n-i);
}

Measured memory_bytes: 1792
//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;  typedef long long ll;
inline int qr(){
	int ret=0,f=0,c=getchar();
	while(!isdigit(c))f|=c==45,c=getchar();
	while(isdigit(c)) ret=ret*10+c-48,c=getchar();
	return f?-ret:ret;
}

const int maxn=5e5+5;
const int inf=0x3f3f3f3f;
vector<int> e[maxn];
int data[maxn],arc[maxn],dr[maxn],n,k;
int seg[maxn<<2],ans[maxn];
void pp(int pos){seg[pos]=min(seg[pos<<1],seg[pos<<1|1]);}
void add(int fr,int to){e[to].push_back(fr);++dr[fr];}

#define mid ((l+r)>>1)
#define lef l,mid,pos<<1
#define rgt mid+1,r,pos<<1|1
int que(int L,int R,int l,int r,int pos){
	if(L>r||R<l) return inf;
	if(L<=l&&r<=R) return seg[pos];
	return min(que(L,R,lef),que(L,R,rgt));
}
void upd(int p,int v,int l,int r,int pos){
	if(p<l||p>r) return;
	if(l==r) return seg[pos]=v,void();
	upd(p,v,lef); upd(p,v,rgt);
	pp(pos);
}
#undef mid
#undef lef
#undef rgt

int main(){
	n=qr(); k=qr();
	for(int t=1;t<=n;++t) data[t]=qr(),arc[data[t]]=t;
	memset(seg,0x3f,sizeof seg);
	for(int t=n;t;--t){
		int t1=que(arc[t]-k+1,arc[t]-1,1,n,1);
		int t2=que(arc[t]+1,arc[t]+k-1,1,n,1);
		if(t1<=n) add(arc[t],arc[t1]);
		if(t2<=n) add(arc[t],arc[t2]);
		upd(arc[t],t,1,n,1);
	}
	static priority_queue<int> q;
	for(int t=1;t<=n;++t)
		if(!dr[t]) q.push(t);
	int cnt=0;
	while(q.size()){
		int now=q.top();
		ans[now]=++cnt;
		q.pop();
		for(auto t:e[now])
			if(--dr[t]==0)
				q.push(t);//asdasd
	}
	for(int t=1;t<=n;++t) printf("%d\n",n-ans[t]+1);
	return 0;
}

Measured memory_bytes: 47104
# AOJ 0161 Sport Meet
# Python3 2018.6.18 bal4u

while True:
	n = int(input())
	if n == 0: break
	team = {}
	for i in range(n):
		a = list(map(int, input().split()))
		s = 0
		for j in range(1, 8, 2):
			s += 60*a[j] + a[j+1]
		team[a[0]] = s
	ans = sorted(team.items(), key=lambda x: x[1])
	print(ans[0][0], ans[1][0], ans[n-2][0], sep='\n')


Measured memory_bytes: 6688
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
#define int long long
string s;
int ans;
signed main(){
  cin>>s;
  int blackN=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='B'){
      blackN++;
    }else{
      ans+=blackN;
    }
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int[][] data={{sc.nextInt(),sc.nextInt(),sc.nextInt()},
					  {sc.nextInt(),sc.nextInt()}
					 };
		int tmp=0;
		int sum=0;
		for(int i=0;i<data.length;i++){
			tmp=data[i][0];
			for(int j=1;j<data[i].length;j++){ 
				if(tmp>data[i][j]){
					tmp=data[i][j];
				}
			}
			sum+=tmp;
		}
		System.out.println(sum-50);
	}
}

Measured memory_bytes: 17308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int xa, ya, xb, yb;
  cin >> xa >> ya >> xb >> yb;
  int s = xb - xa;
  int t = yb - ya;
  int xc, yc, xd, yd;
  tie(xc, yc) = pii(xb-t, yb+s);  
  tie(xd, yd) = pii(xc-s, yc-t);  
  cout << xc << " " << yc << " " << xd << " " << yd << endl;

  return 0;
}

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

int main()
{
  int n;cin>>n;
  vector<vector<int>> pairs(10,vector<int>(10,0));
  int i;
  int ans=0;
  for(i=1;i<=n;i++)
  {
    int end=i%10;
    int j=i;
    while(j>=10)j/=10;
    int sta=j;
    if(sta==end)ans++;
    ans+=(pairs.at(end).at(sta))*2;
    pairs.at(sta).at(end)++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;

    uint64_t n, k;
    in >> n, k;
    out(int(std::log2(n) / std::log2(k) + 1));
}

int main()
{
    prog();
    return 0;
}


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

ancket = []
list_like = []
menu = {}

for i in range(m):
  menu[i+1] = 0

for i in range(n):
  ancket = list(map(int, input().split()))
  k = ancket[0]
  list_like = ancket[1:k+1]
  for j in range(k):
      menu[list_like[j]] += 1
      
sum = 0
for i in range(m):
  if menu[i+1] == n:
    sum += 1

print(sum)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




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

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

int main() {
	//x i+1 = r*x i - D;
	long long r,x[11],D;
	cin >> r >> D >> x[0];
	for(int i=1;i<11;i++) {
		x[i]= (r*x[i-1]) - D;
		cout << x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# 想定解法3

import heapq

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


Q =[]
heapq.heappush(Q, [-(A[0]+B[0]+C[0]), 0, 0, 0])
added_idx = set((0, 0, 0))

for i in range(K):
  nega_ans, x, y, z = heapq.heappop(Q)
  print(-nega_ans)
  if x+1 < X and (x+1, y, z) not in added_idx:
    heapq.heappush(Q, [-(A[x+1]+B[y]+C[z]), x+1, y, z])
    added_idx.add((x+1, y, z))
  if y+1 < Y and (x, y+1, z) not in added_idx:
    heapq.heappush(Q, [-(A[x]+B[y+1]+C[z]), x, y+1, z])
    added_idx.add((x, y+1, z))
  if z+1 < Z and (x, y, z+1) not in added_idx:
    heapq.heappush(Q, [-(A[x]+B[y]+C[z+1]), x, y, z+1])
    added_idx.add((x, y, z+1))


Measured memory_bytes: 4976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> h(n,0);
    rep(i,n) cin >> h[i];
    for(int i=n-2;i>=0;--i){
        if(h[i+1]>=h[i]){
            continue;
        }else{
            if(h[i+1]==h[i]-1){
                --h[i];
                continue;
            }else{
                cout << "No" << "\n";
                return 0;
            }
        }
    }
    cout << "Yes" << "\n";
    return 0;
}   

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

int main(){
    int q;
    double x0,y0,x1,y1,x2,y2,x3,y3;
    cin >> q;
    for(int i=1; i<=q; i++){
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        double a1,a2;
        if(x0==x1 && x2==x3){
            cout << "2" << endl;
        }
        else if(x0==x1){
            if(y2==y3) cout << "1" << endl;
            else cout << "0" << endl;
        }
        else if(x2==x3){
            if(y0==y1) cout << "1" << endl;
            else cout << "0" << endl;
        }
        else{
            a1=(y1-y0)/(x1-x0);
            a2=(y3-y2)/(x3-x2);
           // cout << a1 << " " << a2 << endl;
            if(fabs(a1*a2+1)<0.00001) cout << "1" << endl;
            else if(fabs(a1-a2)<0.00001) cout << "2" << endl;
            else cout << "0" << endl;
        }
    }
    return 0;
}


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

#define endl '\n'

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(0);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

int main() { BUFF
  int a, b, h; cin >> a >> b >> h;
  cout << h*(a+b)/2;
  return 0;
}


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

public class Main {

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

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();

		List<Long> alist = new ArrayList<>();

		for (int i = 0; i < N; i++) {
			alist.add(scanner.nextLong());
		}

		if (alist.get(0) != 0) {
			System.out.println("-1");
			return;
		}

		long count = 0;

		for(int i = N-1; i > 0; i--) {
			long a_i = alist.get(i);
			long a_i_1 = alist.get(i-1);
			if (a_i == a_i_1 + 1) { // 1, 2
				count = count + 1;
			} else if (a_i - a_i_1 > 1) { // 1, 3
				System.out.println("-1");
				return;
			} else {
				count = count + a_i;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 97108
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8),
      cache=True)
def scc_dfs(N, G, idx, low, ord, ids, visited, now_ord, group_num, vis_i, v):
    low[v] = ord[v] = now_ord
    now_ord += 1
    visited[vis_i], vis_i = v, vis_i + 1
    for e in range(idx[v], idx[v + 1]):
        to = G[e, 1]
        if ord[to] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, to)
            low[v] = min(low[v], low[to])
        else:
            low[v] = min(low[v], ord[to])
    if low[v] == ord[v]:
        while True:
            u, vis_i = visited[vis_i - 1], vis_i - 1
            ord[u] = N
            ids[u] = group_num
            if u == v:
                break
        group_num += 1
    return now_ord, group_num, vis_i


@njit((i8, i8[:, :]), cache=True)
def scc(N, G):
    idx = np.searchsorted(G[:, 0], np.arange(N + 1))
    low = np.zeros(N, np.int64)
    ord = np.zeros(N, np.int64) - 1
    now_ord = 0
    group_num = 0
    visited, vis_i = np.empty(N, np.int64), 0
    ids = np.zeros(N, np.int64)
    for v in range(N):
        if ord[v] == -1:
            now_ord, group_num, vis_i = \
                scc_dfs(N, G, idx, low, ord, ids,
                        visited, now_ord, group_num,
                        vis_i, v)
    return group_num, group_num - ids - 1

@njit((i8, i8[:, :]), cache=True)
def main(N, G):
    n_comp, comp = scc(N, G)
    ans = np.empty((N, 2), np.int64)
    ans[:, 0] = np.arange(N)
    ans[:, 1] = comp
    ans = ans[np.argsort(ans[:, 1])]
    idx = np.searchsorted(ans[:, 1], np.arange(n_comp + 1))
    print(n_comp)
    for c in range(n_comp):
        V = ans[idx[c]:idx[c + 1], 0]
        print(len(V))
        for v in V:
            print(v)

N, M = map(int, readline().split())
AB = np.array(read().split(), np.int64).reshape(-1, 2)

AB = AB[np.argsort(AB[:, 0])]

main(N, AB)

Measured memory_bytes: 178436
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  
  if(A+B>A-B){
    cout<<max(A+B,A*B)<<endl;
  }
  else{
    cout<<max(A-B,A*B)<<endl;
  }
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#define  ll long long

void solve(){

  ll n; cin>>n; 
  ll x= n*800;
  ll y= n/15;
  
  y*=200;
  cout<<x-y<<endl;
  }

int main() {
   #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

 ios_base::sync_with_stdio(0);
 cin.tie(0);

  int t =1;  /*cin>>t ;*/

  while(t--){
        solve();
  }

 return 0;
}


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

int main() {
  int h,w;
  cin>>h>>w;

  string board[50];

  for (int i = 0; i < h; ++i) cin >> board[i];

  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; //周囲8マスの座標設定

  for (int i = 0; i < h; ++i) { //1行目から順に
    for (int j = 0; j < w; ++j) { //１列目から一文字ずつ
      if (board[i][j] == '#') continue; //その場が爆弾なら次の文字
      
      int num = 0; 
      for (int d = 0; d < 8; ++ d) { //周囲8マスの検査
        const int ni = i + dy[d]; //i行目からのy座標のズレ
        const int nj = j + dx[d]; //j文字目からのx座標のズレ

        if (ni < 0 || h <= ni) continue; 
        if (nj < 0 || w <= nj) continue; //範囲外なら次のマス
        if (board[ni][nj] == '#') num++; //爆弾ならnumに1足す
      }
      board[i][j] = num + '0'; //座標(i,j)にnumを代入
    }
  }
  for (int i = 0; i < h; ++i) cout << board[i] << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int l[20001];
	for(int i = 0; i < n; i++){
		cin >> l[i];
	}
	sort(l, l + n);
	long long int ans = 0;
	for(int a = 0; a < n; a++){
		for(int b = a + 1; b < n; b++){
			ans += lower_bound(l + b + 1, l + n, l[a] + l[b]) - lower_bound(l + b + 1, l + n, abs(l[a] - l[b]));
			// cout << ans << endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// #define DEBUG 1
#include <cstdio>
#include <vector>

using namespace std;

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

const int N_MAX = 4000;

int A, B;
int N;
char s[N_MAX + 1];

int Q;
int qc;

bool query(int a, int b) {
  qc++;
  char buf[2];
  printf("? %d %d\n", a, b);
  fflush(stdout);
#ifdef DEBUG
  printf("%s\n", s[a] == s[b] ? "Y" : "N");
  return (s[a] == s[b]);
#else
  scanf("%s", buf);
  return (buf[0] == 'Y');
#endif
}

void solve() {
  if (A <= B) {
    puts("Impossible");
    return;
  }
  vector<int> path;
  int v = 0;
  path.push_back(v++);
  while (path.size() <= B) {
    if (query(path.back(), v)) {
      path.push_back(v++);
    } else {
      path.pop_back();
      v++; B--;
      if (path.empty()) {
        path.push_back(v++);
      }
    }
  }
  v = path.back();
  REP(i, N) s[i] = query(v, i) ? '1' : '0';
  s[N] = '\0';
  printf("! %s\n", s);
}

void test() {
  scanf("%s", s);
  // int a = 0, b = 0;
  // REP(i, 3999) if (s[i] == '1') a++; else b++;
  // printf("a: %d, b: %d\n", a, b);
  Q = N * 2;
  qc = 0;
  solve();
  printf("query count: %d (%s)\n", qc, qc > Q ? "NG" : "OK");
}

void input() {
  scanf("%d%d", &A, &B);
  N = A + B;
}

int main() {
  input();
#ifdef DEBUG
  test();
#else
  solve();
#endif
  return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    map<int, int> mp;

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

    int maxv = 0;
    
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if(itr->second > maxv){
            maxv= itr->second;
        }
    }
    cout << maxv << endl;
}

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

int main() {
  IN (int, H);
  IN (int, W);
  IN (int, Ch);
  Ch--;
  IN (int, Cw);
  Cw--;
  IN (int, Dh);
  Dh--;
  IN (int, Dw);
  Dw--;
  vector<vector<int> > score(H + 4, vector<int>(W + 4, -2));
  REP(i, H) {
    REP(j, W) {
      IN(char, c);
      if (c == '.') score.at(i + 2).at(j + 2) = -1;
    }
  }

  queue<pair<int, int> > pos;
  queue<pair<int, int> > pos_next;
  score.at(Ch + 2).at(Cw + 2) = 0;
  pos.push(make_pair(Ch + 2, Cw + 2));

  while(!pos.empty()) {
    pair<int, int> tmp_pos = pos.front();
    pos.pop();
    for (int n = 0 ; n < 4; ++n) {
      int i = tmp_pos.first, j = tmp_pos.second;
      if (n == 0) i--;
      else if (n == 1) j++;
      else if (n == 2) i++;
      else if (n == 3) j--;

      if (score.at(i).at(j) == -1 || score.at(i).at(j) > score.at(tmp_pos.first).at(tmp_pos.second)) {
        score.at(i).at(j) = score.at(tmp_pos.first).at(tmp_pos.second);
        pos.push(make_pair(i, j));
      }
    }

    for (int i = tmp_pos.first - 2; i <= tmp_pos.first + 2; ++i) {
      for (int j = tmp_pos.second - 2; j <= tmp_pos.second + 2; ++j) {
        if (i == tmp_pos.first && j == tmp_pos.second) continue;
        if (score.at(i).at(j) == -1 || score.at(i).at(j) > score.at(tmp_pos.first).at(tmp_pos.second) + 1) {
          score.at(i).at(j) = score.at(tmp_pos.first).at(tmp_pos.second) + 1;
          pos_next.push(make_pair(i, j));
        }
      }
    }

    if (pos.empty()) {
      pos = pos_next;
      while (!pos_next.empty()) pos_next.pop();
    }

    // for debug
    // cout << "(" << tmp_pos.first << ", " << tmp_pos.second << ")" << endl;
    // REP(i, H + 4) {
    //   REP(j, W + 4) {
    //     int tmp_sc = score.at(i).at(j);
    //     if (tmp_sc == -2) cout << '#';
    //     else if (tmp_sc == -1) cout << '.';
    //     else cout << tmp_sc;
    //   }
    //   cout << endl;
    // }
    // cout << endl;

  }
  cout << score.at(Dh + 2).at(Dw + 2) << endl;

  return 0;
}


Measured memory_bytes: 7656
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b)
{
    return *(int*)a-*(int*)b;
}

int main()
{
    int n,i,r=1,t;
    int arr[999];

    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",arr+i);

    qsort(arr,n,4,compare);
    t=arr[0];
    for(i=1;i<n;i++)
    {
        if(t!=arr[i])
        {
            t=arr[i];
            r++;
        }
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N, M;
  scanf("%d %d", &N, &M);
  
  int i, j, sum = 0, ans;
  for(i=0; i<M; i++){
    scanf("%d", &j);
    sum += j;
  }
  
  if(N - sum < 0){
    ans = -1;
  } else{
    ans = N - sum;
  }
  
  printf("%d", ans);
  
  return 0;
}

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

int main() {
	string s;
	int N;
	int *data;
	int *data2;
	int min;
	cin >> N;
	data = new int[N];
	data2 = new int[N];
	for (int i = 0;i < N;i++)cin >> data[i];
	int ans = 0;

	
	for (int i = 0;i < N;i++) {
		if (i == 0) {
			min = data[i];
			data2[i] = min;
		}
		else {
			if (min > data[i]) {
				min = data[i];
				
			}
			data2[i] = min;
		}
	}
	for (int i = 0;i < N;i++) {
		if (data[i] == data2[i])ans++;
	}

	cout << ans << endl;
	
}

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

typedef long long ll;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)


void solve() {
    ll n;
    ll cnt[200010] = {};
    cin >> n;

    for(ll i=2; i<=n; i++) {
        ll x = 0;
        cin >> x;
        cnt[x]++;
    }

    for(ll i=1; i<=n; i++) {
        cout << cnt[i] << '\n';
    }
}

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

Measured memory_bytes: 5224
#include<stdio.h>
#define MAX 100001
#define N -1
typedef struct{
  int parent,x,y;
}Node;
Node Tree[MAX];
int u,a,de[MAX];
int get(int);
void pr(int);
int main(){
  int i,j,l,d,v,z;
  scanf("%d" , &u);
  for(i = 0;i < u; i++){
    Tree[i].parent = N;
    Tree[i].x = N;
    Tree[i].y = N;
  }
  for( i = 0; i < u; i++){
    scanf("%d %d", &v,&d);
    for(j = 0;j<d;j++){
      scanf("%d" , &z);
      if(j ==0)Tree[v].x = z;
      else if(j != 0) Tree[l].y = z;
      l = z;
      Tree[z].parent = v;
    }
  }
  
    
  a = 0;
  for(i = 0;i < u; i++){
    de[i] = get(i);
    if(de[i] > a) a = de[i];
  }
  for(i=0;i<u;i++){
    pr(i);
  }
  return 0;
}
int get(int n){
  int d = 0;
  while(1){
    n = Tree[n].parent;
    if(n == N)break;
    d++;
  }
  return d;
}
void pr(int n){
  int i , j;
  printf("node %d: " , n);
  printf("parent = %d, ", Tree[n].parent);
  printf("depth = %d, ", de[n]);
  if(Tree[n].parent == -1)printf("root, ");
  else if(Tree[n].x == -1)printf("leaf, ");
  else{
    printf("internal node, ");
  }
  printf("[");
  for(i=0, j = Tree[n].x;j != N ; i++,j = Tree[j].y){
  
      if(i)printf(", ");
      printf("%d", j);
    }
  
  printf("]\n");
}
      

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

//const ll mod = 998244353;
const ll mod = 1e9 + 7;
const ll MAX_SIZE = 2000005;
array<ll, MAX_SIZE> fac, inv, finv;
ll fac_init() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % mod;
    finv[0] = modpow(fac[MAX_SIZE - 1], mod - 2, mod);
    repe(i, 1, MAX_SIZE) finv[i] = finv[i - 1] * (MAX_SIZE - i) % mod;
    reverse(all(finv));

    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, mod - 2, mod);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % mod; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % mod * finv[a - b] % mod; }

ll f(ll r, ll c){
    return comb(r + c + 2, r + 1) - 1;
}
int main() {
    init();
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    fac_init();

    ll ans = (f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1) + 5 * mod) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 47104
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, l;
vector<string> ss;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> l;
  REP(i, n) {
    string s;
    cin >> s;
    ss.push_back(s);
  }

  sort(ss.begin(), ss.end());

  REP(i, n) {
    cout << ss[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

long k, a, b;

int input() {
	if (scanf("%ld %ld %ld", &k, &a, &b) < 0) return 0;
	return 1;
}

void init() {
}

long solve() {
	long d = b-a;
	if (d<=2 || k<a) return 1+k;
	k = k+1-a;
	long r = a + d*(k/2);
	if (k%2) r++;
	return r;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	string s, t;cin >> s >> t;int n = s.size(), m = t.size(), j = 0;
	vector<char> a(n), b(m);
	rep(i, n) a[i] = s[i];
	rep(i, m) b[i] = t[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	rep(i, s.size()) s[i] = a[i];
	for (int i = t.size() - 1;i >= 0;i--) {
		t[j] = b[i];j++;
	}
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(const auto &buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

int main() {
	ll n; cin >> n;
	ll l = n * 100 / 108;
	Loop(i, 5) {
		if ((l + i) * 108 / 100 == n) {
			cout << l + i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;

    for(int i=0; i<n; i++){
        if(s.substr(i) == t.substr(0, n-i)){
            cout << n + i;
            return 0;
        }
    }
    cout << 2*n; 

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define foreach(c,it) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
using namespace std;
int n,m,s,t,i,j;
long long ans,c[55][55];
vector<int> v,bt;
long long calc(int t)
{
	int i;
	long long ans=0;
	for(i=1;i<=min(t,m);i++){
		ans+=c[t][i];
	} 
	return ans;
}
void dfs(int x,int xs,const vector<int> &v)
{
	if(x>=bt.size()){
		ans+=xs*calc(v.size());
		return;
	}
	dfs(x+1,xs,v);
	vector<int> t0,t1;
	foreach(v,i){
		if(((*i)>>x)&1){
			t1.push_back(*i);
		}
		else{
			t0.push_back(*i);
		}
	}
	if(!t0.empty()) dfs(x+1,-xs,t0);
	if(!t1.empty()) dfs(x+1,-xs,t1);
}
int main(){
	cin>>n>>m>>s>>t;
	c[0][0]=1;
	rep(i,n){
		c[i][0]=1;
		rep(j,i){
			c[i][j]=c[i-1][j]+c[i-1][j-1];
		}
	}
	if((s&t)!=s){
		puts("0");
		return 0;
	}
	if((s|t)!=t){
		puts("0");
		return 0;
	}
	for(i=0;i<18;i++){
		if(((t>>i)&1)&&!((s>>i)&1)){
			bt.push_back(i);
		}
	}
	rep(i,n){
		int x;
		cin>>x;
		if((s&x)!=s) continue;
		if((t|x)!=t) continue;
		int y=0;
		for(j=0;j<bt.size();j++){
			y|=(((x>>bt[j])&1)<<j);
		}
		v.push_back(y);
//		cerr<<y<<endl;
	}
	dfs(0,1,v);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#define mod 1000000007
#define lim 2000
using namespace std;
 
unsigned long long store[lim];  //store[i]=i!% mod
 
inline unsigned long long power(int n,unsigned long long k ,int m=1000000007)  //return n^k % m
{
 if(k==0) return 1;
 if(k==1) return n;
 unsigned long long f=power(n,k/2,m);
 unsigned long long p=(f*f)%m;
 if(k%2!=0)
  p=(p*n)%m;
 
 return p;
}
 
 
inline unsigned long long invmod(int n,int m)
{
 return power(n,m-2,m);
}
 
void create_store(int m)
{
 
       store[0]=1;
    for(int i=1;i<lim;i++)
    {
        store[i]=(store[i-1]*i)%m;
    }
 
}
 
inline unsigned long long func(int c,int p)
{
    unsigned long long X=power(store[c],p)*store[p];
    return invmod(X%mod,mod);
}
 
unsigned long long dp[1002][1002];
 
int main()
{
    create_store(mod);
    int n,A,B,C,D;
    cin>>n;
    cin>>A>>B>>C>>D;
    dp[A-1][0]=store[n];
    for(int i=A;i<=B;i++)
    {
        //dp[i][0]=store[n];
        for(int p=0;p<=n;p++)
        {
            dp[i][p]=dp[i-1][p];
            for(int cnt=C;cnt<=D;cnt++)
            {
              //  cout<<i<<" "<<cnt<<"\n";
                if(cnt*i>p)
                    break;
                //cout<<dp[i-1][p-cnt*i]<<"&&"<<func(i,cnt)<<" ^^"<<p-cnt*i<<"\n";
                dp[i][p]+=dp[i-1][p-cnt*i]*func(i,cnt);
                dp[i][p]%=mod;
            }
        }
    }
    cout<<dp[B][n];
    return 0;
}

Measured memory_bytes: 8064