akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-7;
const int N=300+10,maxn=60000+10,inf=0x3f3f3f3f3f;

struct edge{
    ll to,Next,c;
}e[N*N];
int cnt,head[N],n;
ll d[N],value[N][N];
bool vis[N];
void add(int u,int v,int c)
{
    e[cnt].to=v;
    e[cnt].c=c;
    e[cnt].Next=head[u];
    head[u]=cnt++;
}
void spfa(int s)
{
    memset(vis,0,sizeof vis);
    memset(d,inf,sizeof d);
    vis[s]=1;
    d[s]=0;
    queue<int>q;
    q.push(s);
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        vis[x]=0;
        for(int i=head[x];~i;i=e[i].Next)
        {
            ll W=e[i].c,To=e[i].to;
            if(d[x]+W<d[To])
            {
                d[To]=d[x]+W;
                if(!vis[To])
                {
                    vis[To]=1;
                    q.push(To);
                }
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cnt=0;
    memset(head,-1,sizeof head);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            ll c;
            cin>>c;
            value[i][j]=c;
            add(i,j,c);
        }
    }
    for(int i=1;i<=n;i++)
    {
        spfa(i);
        for(int j=1;j<=n;j++)
        {
            if(d[j]!=value[i][j])
            {
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1+i;j<=n;j++)
        {
            bool f=0;
            for(int k=1;k<=n;k++)
            {
                if(k==i||k==j)continue;
                if(value[i][k]+value[k][j]==value[i][j])
                {
                    f=1;
                    break;
                }
            }
            if(f)continue;
            ans+=value[i][j];
        }
    }
    cout<<ans<<endl;
    return 0;
}
/********************

********************/


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

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll sum = accumulate(a.begin(), a.end(), 0LL);  // 第三引数を0とするとint型とみなされるためオーバーフロー

	vector<ll> s(n);
	s[0] = a[0];
	for (int i = 1; i < n - 1; i++) s[i] = s[i - 1] + a[i];

	ll ans = INT_MAX;
	for (int i = 0; i < n - 1; i++) ans = min(ans, abs(s[i] - (sum - s[i])));
	cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> x(n);
    REP(i,n) cin>>x[i];
    vector<ll> min_sum(n,0);
    ll ans=0;
    REP(i,n-1){
        min_sum[i] = min( (x[i+1]-x[i]) * a,b);
        ans+=min_sum[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

signed main()
{
	int A, B; cin >> A >> B;

	int ans = 0;

	while (ans < 10000) {
		if (100*A <= 8*ans and 8*ans < 100*(A+1) and 100*B <= 10*ans and 10*ans < 100*(B+1)) {
			cout << ans << endl;
			return 0;
		}
		ans++;
	}

	cout << -1 << endl;
}


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

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

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		double total = 0;

		List<Integer> a = new ArrayList<>();

		for(int i = 0; i < n; i++) {
			int ai = sc.nextInt();
			a.add(ai);
			total += ai;
		}

		int count = 0;

		for(int i = 0; i < n; i++) {
			double l = total / (4 * m);
			if(a.get(i) >= l) {
				count++;
			}
		}

		if(count >= m) {
			System.out.println("Yes");
		}else {
			System.out.println("No");

		}

		sc.close();

	}

}


Measured memory_bytes: 22612
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = new int[N + 1];
		int[][] x = new int[N + 1][N + 1];
		int[][] y = new int[N + 1][N + 1];
		for (int i = 1; i <= N; i++) {
			A[i] = sc.nextInt();
			for (int j = 1; j <= A[i]; j++) {
				x[i][j] = sc.nextInt();
				y[i][j] = sc.nextInt();
			}
		}

		int max = 0;

		for (int bit = 0; bit < (1 << N); bit++) {
			boolean flag = true;

			for (int i = 0; i < N; ++i) {
				if (((bit >> i) & 1) == 0) {
					continue;
				}
				for (int j = 1; j <= A[i+1]; j++) {
					if ((((bit >> (x[i + 1][j] - 1)) & 1) ^ y[i + 1][j]) != 0) {
						flag = false;
					}
				}

			}
			if (flag)
				max = Math.max(max, counter(bit));

		}
		System.out.println(max);

	}

	// 正直者の人数カウンタ
	public static int counter(int x) {
		if (x == 0)
			return 0;
		return counter(x >> 1) + (x & 1);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
  int n,m,t,s;cin>>n>>m;
  s=0;
  for(int i=0;i<m;i++){
    cin >> t; s+=t;
  }
  int r=n-s;
  cout << (r>=0?r:-1) << endl;
  return 0;
}  


Measured memory_bytes: 3636
a, b, k = map(int, input().split())

n = 0
if a < b:
  n = a
else:
  n = b

cd_list = []
i = 1
while i <= n:
  if a % i == 0 and b % i == 0:
    cd_list.append(i)
  i += 1

cd_list.reverse()
print(cd_list[k-1])


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  int wi[n];
  int vi[n];
  int ac = 0;
  for(int i = 0; i<n;i++){
    cin >> wi[i] >> vi[i];
    ac+= vi[i];
  }
  long long dp[2][ac+1];
  for(int i = 0; i<=n;i++){
    for(int j = 0; j<=ac;j++){
      dp[0][j] = 1000000000000;
    }
  }
  dp[0][0]  = 0;
  bool f = 1;
  for(int i = 1; i<=n;i++){
    for(int j = 0; j<=ac;j++){
      if(j>=vi[i-1]){
	dp[f][j] = min(dp[!f][j],dp[!f][j-vi[i-1]]+wi[i-1]);
      }else{
	dp[f][j] = dp[!f][j];
      }
    }
    f = !f;
  }
  int ans = 0;
  for(int i = 0; i<=ac;i++){
    if(dp[!f][i]<=w){
      ans = max(ans,i);
    }
  }
  cout << ans <<'\n';
  return 0;
}


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main(){
 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,c,k;
cin>>n>>c>>k;
ll arr[n];
ll cnt=0;
ll ans=0;
rep(i,0,n)
{
	cin>>arr[i];
}

sort(arr,arr+n);
ll x=arr[0];
rep(i,0,n)
{
	if(arr[i]-x>k)
	{
		ans++;
		x=arr[i];
		cnt=1;

	}
	else
	{
		cnt++;
		if(cnt>c)
		{
			ans++;
			cnt=1;

			x=arr[i];

	
	}

}
//cout<<ans<<endl;
}

cout<<ans+1;
}





Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		// 文字列の入力
		int result = 0;
		if (b > a * n) {
		    result = a * n;
		} else {
		    result = b;
		}
		// 出力
		System.out.println(result);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll a,b,GCD,c = 1;
  cin >> a >> b;
  while(a && b)
  {
      if(a >= b)a %= b;
      else b %= a;
  }
  GCD = a + b;
  for(ll i = 2; i * i <= GCD;i++)
  {
      if(GCD %i == 0) c++;
      while(GCD %i == 0) GCD /= i;
  }
  if(GCD != 1)c++;
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { {0,0,-1,1},{-1,1,0,0} };
struct P {
ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
ll to, cost;
};
struct S {//辺の情報を入れる変数
int from, to, cost;
};
struct H {
int x, y;
};
bool operator<(H a, H b) {
if (a.x != b.x) return a.x < b.x;
return a.y < b.y;
}
ll gcm(ll i, ll j) {//最大公約数
if (i > j) swap(i, j);
if (i == 0) return j;
return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
if (b <= c || d <= a) return 0;
return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++
int n,d[100];
signed main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>d[i];
	}
	sort(d,d+n);
	int sum=0;
	for(int i=0;i<n;){
		int j=i;
		while(j<n&&d[i]==d[j]){
			j++;
		}
		sum++;
		i=j;
	}
	cout<<sum<<endl;
	getchar(); getchar();
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <numeric>
#define m 1000000007
using namespace std;

int A[2000];

int cnt[2000];
int cnt_2[2000];
int main(){
	int n, k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(A[i] > A[j]){
				if(i < j){
					cnt_2[i]++;
				}
				cnt[i]++;
			}
		}
	}
	long long ans = (long long)((long long)k * (k - 1) / 2 % m) * accumulate(cnt, cnt+n, 0LL) % m + (long long)accumulate(cnt_2, cnt_2+n, 0LL) * k % m;
	ans %= m;
	cout << ans;
}

Measured memory_bytes: 384
class Fibonach
  @@fib_table = Array.new(44,nil)

  def self.output(n)
    if n < 2
      return 1
    elsif @@fib_table[n].nil?
      @@fib_table[n] = output(n-2) + output(n-1)
    end
    return @@fib_table[n]
  end
end

input = STDIN.gets.to_i

print "#{Fibonach::output(input)}\n"

Measured memory_bytes: 8676
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

long long func( long long a ) {
    long long ret = 0;

    int b = 0;
    while( ret <= a ) {
        ret = 1 << b;
        b++;
    }
    ret = ret-a;
    return ret;
}


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

    map<long long,int> M;

    vector<long long> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        M[A[i]]++;
    }
    sort( A.begin(), A.end() );

    int ans = 0;
    for ( int i = N-1; i >= 0; i-- ) {

        long long b = func(A[i]);

        if ( A[i] == b ) {
            if ( M[b] >= 2 ) {
                ans++;
                M[b] -= 2;
            }
        }

        else if ( M[b] > 0 && M[A[i]] > 0 ) {
            ans++;
            M[b]--;
            M[A[i]]--;
        }

    }
    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s;
    t=s;
    reverse(s.begin(),s.end());
    if(s==t){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;


typedef pair<int,int> pii;

const int N = 1e5 + 5;

vector<int> g[N];
bool used[N];
int comp[N];

void dfs(int v)
{
    used[v] = true;
    for (int u : g[v])
    {
        if (used[u]) continue;
        comp[u] = comp[v];
        dfs(u);
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);


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

    vector<pii> edges;
    while(q--)
    {
        static int u, v, type;
        scanf("%d%d%d", &u, &v, &type);
        if (type)
            edges.push_back({u, v});
        else
        {
            g[u].push_back(v);
            g[v].push_back(u);
        }
    }

    int cntComp = 0;
    for (int v = 0; v < n; ++v)
    {
        if (!used[v])
        {
            comp[v] = cntComp++;
            dfs(v);
        }
    }

    for (pii e : edges)
    {
        if (comp[e.first] == comp[e.second])
        {
            printf("No");
            return 0;
        }
    }

    m -= n - cntComp;

    if (!edges.empty() && cntComp == 2)
    {
        printf("No");
        return 0;
    }
    if (cntComp - (int)edges.empty() <= m && m <= cntComp * 1LL * (cntComp - 1) / 2)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 6656
#include <iostream>

using namespace std;

int main(){
  
   int a,b,c; cin >> a >> b >> c;
   int five = 0; int seven = 0;
   if(a == 5) five ++;
   if(a == 7) seven++; 
    if(b == 5) five ++;
   if(b == 7) seven++;
     if(c == 5) five ++;
   if(c == 7) seven++;
    if(five == 2 && seven == 1) cout << "YES\n";
    else cout << "NO\n";
}

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

using namespace std;

int a[N];

int main()
{
    int n,m,i;
    
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    long long sum = 0;
    for(i=1;i<=m;i++) sum+=a[i];
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 3772
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, k, q = map(int, input().split())
    qk = q - k
    l = [0] * (n)
    for _ in range(q):
        l[int(input()) - 1] += 1
    print('\n'.join(['Yes' if (i > qk) else 'No' for i in l]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5044
a, b, c = map(int, input().split())
k = int(input())


while k > 0:
    if a >= b:
        b = b*2
        k = k-1
    else:
        break

while k > 0:
    if b >= c:
        c = c*2
        k = k-1
    else:
        break

if a < b and b < c:
    print("Yes")
else:
    print("No")





Measured memory_bytes: 9120
# -*- coding: utf-8 -*-

def judge(m, f, r):
	if m==-1 or f==-1: return "F"
	
	ttl = m + f
	if ttl >= 80: return "A"
	elif ttl >= 65: return "B"
	elif ttl >= 50: return "C"
	elif ttl >= 30:
		return "C" if r>=50 else "D"
	else: return "F"

if __name__ == "__main__":
	while True:
		m, f, r = map(int, raw_input().split())
		if m==-1 and f==-1 and r==-1: break
		print judge(m, f, r)

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


void solve(long long A, long long B, long long C){
    if(A == B) cout << C << endl;
    if(A == C) cout << B << endl;
    if(B == C) cout << A << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n,i,j,flag,s,count=0;
  int array[100];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }
  flag=1;
  while(flag==1){
    flag=0;
    for(j=n-1;j>0;j--){
      if(array[j]<array[j-1]){
	s=array[j];
	array[j]=array[j-1];
	array[j-1]=s;
	flag=1;
	count++;
      }
    }
  }

  for(j=0;j<n-1;j++){
    printf("%d ",array[j]);
  }
  printf("%d\n",array[n-1]);
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
N,M,Q = [ int(it) for it in input().split() ]
lit = [ [ int(it)-1 for it in input().split() ] for i in range(M) ]
liq = [ [ int(it)-1 for it in input().split() ] for i in range(Q) ]

li = [[0]*(N+1) for i in range(N+1)]
for p,q in lit:
  li[p+1][q+1]+=1

for i in range(N+1):
  for j in range(N):
    li[i][j+1] += li[i][j]

for p,q in liq:
  s = 0
  for i in range(p+1,N+1):
    s += li[i][q+1]
  print  (s)
    
  
  


Measured memory_bytes: 113880
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    l = 0
    r = 0
    s = 0
    while l < n and r < n:
        while s&a[r] == 0:
            s += a[r]
            r += 1
            ans += r-l
            if r == n:
                break
        if l==r:
            s += a[r]
            r += 1
        s -= a[l]
        l += 1
    print(ans)

if __name__ == '__main__':
    d()


Measured memory_bytes: 72268
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

long long plusL[100000];
long long plusR[100000];
long long minusL[100000];
long long minusR[100000];
long long a[100000];

int main()
{
	string s;
	cin >> s;
	vector<char> data;

	for (int i = 0; i < s.size(); i++)
	{
		data.push_back(s[i]);
	}
	sort(s.begin(), s.end());
	cout << (s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ? "Yes" : "No");
}



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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    long long A, B, N;
    cin >> A >> B >> N;
    long long x = min(B - 1, N);
    cout << (A * x) / B - A * (x / B) << endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,k;
  cin>>n>>k;
  int ar[n];
  for(int i=0;i<n;i++)
    cin>>ar[i];
  sort(ar,ar+n);
  int sum=0;
  for(int i=0;i<k;i++)
    sum+=ar[i];
  cout<<sum<<"\n";
  return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> P;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define abs(x) ((x)>0?(x):-(x))
const int maxn = 10006, inf = 0x3f3f3f3f;
int n;
int a[maxn];
int gggggggg(int a,int b){
	if(a<b) swap(a,b);
	if(!b) return a;
	return gggggggg(b,a%b);
}
vector<int> fdsgiksafibsfd(maxn,-1);
void init(){
	fdsgiksafibsfd[0]=fdsgiksafibsfd[1]=0;
	for(int i=2;i<maxn;i++){
		if(fdsgiksafibsfd[i]){
			for(int j=2;j*i<maxn;j++) fdsgiksafibsfd[i*j]=0;
		}
	}
}
set<int> fdsgiksafi;
void div(int p){
	int b[maxn];
	for(int i=0;i<n;i++){
		b[i]=a[i];
		a[i+1]+=a[i]*p;
	}
	for(int i=0;i<n;i++) a[i]=b[i];
	n--;
}
ll cal(ll i,ll p){
	ll fdsgiksafi=0;
	for(int j=0;j<=n;j++){
		fdsgiksafi = 1LL * fdsgiksafi * i % p + a[j];
		fdsgiksafi %= p;
	}
	return fdsgiksafi;
}

int main(){
	init();
	cin>>n;
	for(int i=0;i<=n;i++) cin>>a[i];
	int d=abs(a[0]);
	for(int i=1;i<=n;i++) d=gggggggg(d,abs(a[i]));
	int dd=d;
	for(int i=2;i<=d&&i<maxn;i++){
		if(fdsgiksafibsfd[i]&&!fdsgiksafi.count(i)&&d%i==0) {
			fdsgiksafi.insert(i);
			d/=i;
		}
	}
	if(d>1) fdsgiksafi.insert(d);
	for(int i=0;i<=n;i++) a[i]/=dd;
	int tot=1;
	for(int i=0;i<fdsgiksafibsfd.size();i++){if(!fdsgiksafibsfd[i]) continue;
		int p=i;
		int fl=0;
		if(p>100){
			for(int j=0;j<100;j++){
				int k=rand()%p;
				if(cal(k,p)){
					fl=1;
					break;
				}
			}
		}else{
			for(int j=0;j<p;j++){
				if(cal(j,p))
				{
					fl=1;
					break;
				}
			}
		}
		if(!fl && !fdsgiksafi.count(p)) {
			fdsgiksafi.insert(p);
			//div(p);
//			for(int i=0;i<=n;i++){
//				cout<<a[i]<<' ';
//			}
//			cout<<endl;
		}
	}
	for(auto haha:fdsgiksafi) 
	    cout << haha << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
cnt = [0] * (N + 1)
for _ in range(M):
    a, b = map(int, input().split())
    cnt[a] ^= 1
    cnt[b] ^= 1

if all(x == 0 for x in cnt):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W,a,b,A,B;
  cin>>W>>a>>b;
  A=min(a,b),B=max(a,b);
  if(B>W+A)cout<<B-W-A<<endl;
  else cout<<"0"<<endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline()

n=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6+2)
ans=0
for a in A:
  if cnt[a]!=0:
    cnt[a]=2
    continue
  x=a
  while x<10**6+2:
    cnt[x]+=1
    x+=a
for a in A:
  #print(cnt[a])
  if cnt[a]==1:
    ans+=1
print(ans)


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

 
int main()
{
  
  ll t=1,l;
 //  cin>>t;
 

  while(t--)
  {
    ll n,m,x;
    cin>>n>>m>>x;
    ll i ,j,k;
    ll a[100][100],c[100];
    for(k=0;k<n;k++)
    {
      cin>>c[k];
      for(i=0;i<m;i++)
        cin>>a[k][i];

    }
    // cout<<"INPUT DONE!"<<endl;
    ll presum[100][100] = {0};
    for(i=0;i<m;i++)
    {
      presum[0][i] = a[0][i];
    }
    ll sum[m];
    ll mincost = 1e9,cost;
    bool solved = true;
    for(i=1;i<1<<n;i++)
    {
      cost = 0;
      for(k=0;k<m;k++)
        sum[k] = 0;

      for(j=0;j<n;j++)
      {
        ll temp = 1<<j;
        // cout<<temp<<" ";
        if((temp)&i)
        {
          // cout<<j<<" ";
          solved = true;
          cost+=c[j];
          for(k=0;k<m;k++)
          {
            sum[k]+=a[j][k];
            if(sum[k]<x)
              solved = false;
          }
          if(solved)
          {
            mincost = min(mincost,cost);
            // break;
          }
        
        }
       
      }
       // cout<<endl;
    }
    if(mincost==1000000000)
      cout<<-1<<endl;
    else
    cout<<mincost<<endl;

  
   
  }
      
  return 0;
}



/*

  36 151 0 65

*/

// ll val=0,ind;
    // for(ll i=l;i<=r;i++)
    // {
    //   ll func = (x&i)*(y&i);
    //   if(func>val)
    //   {
    //     val = func;
    //     ind = i;
    //   }

    // }

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

int main() {
    int n;
    string s;
    cin >> n >> s;

    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) continue;
        cnt++;
    }
    cnt++;

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

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
	int n;
	for(;cin>>n,n;){
		vector<string>v(n);
		for(int i=0;i<n;i++){
			string s,t;
			cin>>s;
			t+=s[0];
			for(int j=1;j<s.size();j++)if(strchr("aeiou",s[j-1]))t+=s[j];
			v[i]=t;
		}
		sort(v.begin(),v.end());
		if(unique(v.begin(),v.end())!=v.end()){
			puts("-1");
		}else{
			int r=0;
			for(int i=1;i<n;i++){
				int k=0;
				for(;v[i-1][k]==v[i][k];k++);
				if(r<k+1)r=k+1;
			}
			printf("%d\n",r);
		}
	}
}

Measured memory_bytes: 1236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Contexts;
namespace AOJ {
    internal class Program {
        public static void Main(string[] args) { new Program().solve(); }
        void solve() {
            var str = Console.ReadLine();
            var q = int.Parse(Console.ReadLine());
            for(int i = 0; i < q; ++i) {
                var line = Console.ReadLine().Split(' ');
                if(isReplace(line[0])) {
                    str = replace(str, int.Parse(line[1]), int.Parse(line[2]), line[3]);
                } else if(isReverse(line[0])) {
                    str = reverse(str, int.Parse(line[1]), int.Parse(line[2]));
                } else if(isPrint(line[0])) {
                    Console.WriteLine(print(str, int.Parse(line[1]), int.Parse(line[2])));
                }
            }
        }
        bool isReplace(string s) { return s == "replace"; }
        bool isReverse(string s) { return s == "reverse"; }
        bool isPrint(string s) { return s == "print"; }
        string replace(string s, int a, int b, string c) {
            return s.Substring(0, a) + c + s.Substring(b + 1, s.Length - b - 1);
        }
        string reverse(string s, int a, int b) {
            return s.Substring(0, a) +
                   new string(s.Substring(a, b - a + 1).Reverse().ToArray()) +
                   s.Substring(b + 1, s.Length - b - 1);
        }
        string print(string s, int a, int b) { return new string(s.Substring(a, b - a + 1).ToArray()); }
    }
}



Measured memory_bytes: 9460
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x;
    string s,s1,s2;
    cin >> n;   
    if(n%2==0){
        cout << n << endl;
    }
    else cout << 2*n << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 1e6 + 5;
bitset <M> isPrime;
vector <int> p;
int n, ans;

int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	isPrime.flip();
	for(int i = 2; i < M; i++)
	{
		if(isPrime[i])
		{
			for(int j = i * 2; j < M; j += i)
				isPrime[j] = 0;
			p.push_back(i);
		}
	}
	cin >> n;
	for(auto &i : p)
	{
		if(n % i)	continue;
		int cnt = 0;
		while(n % i == 0)
		{
			n /= i;
			cnt++;
		}
		int st = 1, en = cnt, e = 0;
		while(st <= en)
		{
			int mid = (st + en) >> 1;
			if(mid * (mid + 1) / 2 <= cnt)
			{
				e = mid;
				st = mid + 1;
			}
			else	en = mid - 1;
		}
		ans += e;
	}
	if(n > 1)	ans++;
	cout << ans;
    return 0;
}

Measured memory_bytes: 4296
/**
 * ABC129
 * C - Typical Stairs
 */
#include <stdio.h>
#include <string.h>

#define MAX_S 2001
#define EMPTY '.'

int main(void) {
    int h, w;
    int i, j;
    int max = 0;
    int tmp;
    char s[MAX_S][MAX_S];
    int l[MAX_S][MAX_S], r[MAX_S][MAX_S], u[MAX_S][MAX_S], d[MAX_S][MAX_S];

    scanf("%d %d", &h, &w);

    for (i = 0; i < h; i++) {
        scanf("%s", s[i]);
    }

    for (i = 0; i < h; i++) {
        l[i][0] = s[i][0] == EMPTY ? 1 : 0;
        r[i][w - 1] = s[i][w - 1] == EMPTY ? 1 : 0;
        // printf("%c\n", s[i][0]);
        for (j = 1; j < w; j++) {
            // printf("%c\n", s[i][j]);
            l[i][j] = s[i][j] == EMPTY ? l[i][j - 1] + 1 : 0;
            r[i][w - 1 - j] = s[i][w - 1 - j] == EMPTY ? r[i][w - j] + 1 : 0;
        }
    }
    for (j = 0; j < w; j++) {
        d[0][j] = s[0][j] == EMPTY ? 1 : 0;
        u[h - 1][j] = s[h - 1][j] == EMPTY ? 1 : 0;
        for (i = 1; i < h; i++) {
            d[i][j] = s[i][j] == EMPTY ? d[i - 1][j] + 1 : 0;
            u[h - 1 - i][j] = s[h - 1 - i][j] == EMPTY ? u[h - i][j] + 1 : 0;
        }
    }

    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            // printf("%d %d %d %d\n", l[i][j], r[i][j], d[i][j], u[i][j]);
            tmp = l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3;
            if (tmp > max) {
                max = tmp;
            }
        }
    }

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


Measured memory_bytes: 66688
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong(), a = sc.nextLong(), b = sc.nextLong();

        long result = n / (a + b) * a;
        long rem = n % (a + b);
        result += Math.min(rem, a);
        System.out.println(result);
    }
}

Measured memory_bytes: 23892
//************************
    //*  Date: 2018.8.25     *
    //*  Problem:            *
    //*  Author: xuziyuan    * 
    //************************
     
    #include <bits/stdc++.h>
     
    #define rt0 return 0
    #define rep(i,n) for(int i=0;i<n;i++)
    #define repn(i,n) for(int i=1;i<=n;i++)
    #define LL long long
    #define pii pair<int,int>
    #define pb push_back
    #define fi first
    #define se second
    #define mpr make_pair
     
    using namespace std;
     
    const LL MOD=1e9+7;
     
    int n,k,ans=1e9,lb=0,ub;
    int a[100010];
     
    int main()
    {
    	scanf("%d%d",&n,&k);
    	rep(i,n) scanf("%d",&a[i]);
    	ub=k-1;
    	for(;ub<n;lb++,ub++)
    	{
    		int res=0;
    		if((a[lb]<=0&&a[ub]<=0)||(a[lb]>=0&&a[ub]>=0)) res=max(abs(a[lb]),abs(a[ub]));
    		else res=(min(-a[lb],a[ub]))*2+max(-a[lb],a[ub]);
    		//cout<<lb<<' '<<ub<<' '<<res<<' '<<min(-a[lb],a[ub])<<' '<<max(-a[lb],a[ub])<<endl;
    		ans=min(ans,res);
    	}
    	printf("%d\n",ans);
    	rt0;
    }

Measured memory_bytes: 640
import copy
a,b,c = map(int,input().split())
cnt = 0
if (a % 2 == 1) or (b % 2 == 1) or (c % 2 == 1):
    print(0)
    exit()
while 1:
    cnt += 1 
    next_a = b // 2 +  c // 2
    next_b = a // 2 + c // 2
    next_c = a // 2 + b // 2
    if a == next_a and b == next_b and c == next_c:
        print(-1)
        break
    elif (next_a % 2 == 1) or (next_b % 2 == 1) or (next_c % 2 == 1):
        print(cnt)
        break
    a = copy.deepcopy(next_a)
    b = copy.deepcopy(next_b)
    c = copy.deepcopy(next_c)




Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;

int main(){
	int n;
	cin >> n;
	vector<int> input(n);
	rep(i,n) cin >> input[i];
	int cnt=1;
	int flag = 0; //フラグ変数 1:上昇、-1:減少
	bool change=0;
	int before = input[0];
	for(int i=1;i<n;i++){
		int now = input[i];
		if(flag==-1&&now>before){
			cnt++;
			change=1;
		}
		if(flag==1&&now<before){
			cnt++;
			change=1;
		}
		//どっちか定まってなければフラグ立てる
		if(flag==0){
			if(before>now) flag=-1;
			if(before<now) flag=1;
		}	
		if(change){
			change=0;
			flag=0;
		}
		before = now;
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;

const int n = 100005;

int main(){
  int N, M, H[n];
  cin >> N >> M;
  for(int i=1; i<=N; i++) cin >> H[i];

  unordered_set<int> f;
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    if(H[a] >= H[b]) f.emplace(b);
    if(H[b] >= H[a]) f.emplace(a);
  }
  
  cout << N - (int)f.size() << endl;
}

Measured memory_bytes: 6040
//05
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n,a,b;cin>>n>>a>>b,n|a|b;){
    static bool ap[1000001];
    fill(ap,ap+1000001,false);
    ap[0]=true;
    for(int i=a;i<=n;i++){
      ap[i]=ap[i-a];
    }
    for(int i=b;i<=n;i++){
      ap[i]|=ap[i-b];
    }
    cout<<count(ap+1,ap+1+n,false)<<endl;
  }
  return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <climits>

using namespace std;
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define all(x) (x).begin(),(x).end()

using int64 = long long;
using P = pair<int64, int64>;

#define ng {ans=0;break;};

const int MOD = 1000000007;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());

    vector<P> l;
    l.emplace_back(a[0],0);
    for (int i=0; i<n; i++) {
        if (l.back().first == a[i]) l.back().second++;
        else l.emplace_back(a[i], 1);
    }

    int64 pre = -1;
    if (n%2 && l.back().first==0 && l.back().second == 1) {
        pre = 0;
        l.pop_back();
    }
    

    n = l.size();
    int64 ans = 1;
    for (int i=n-1; i>=0; i--) {
        if (pre+2 != l[i].first) ng;
        if (l[i].second != 2) ng;
        if (l[i].first == 0) ng;
        pre = l[i].first;
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1784
Ns,Ms = input().split()
N=int(Ns)
M=int(Ms)
Ls = input().split()
ans=0
L=[]
Lx=[]
for i in range(M):
    L.append(int(Ls[i]))
L.sort()
for i in range(M-1):
    Lx.append(L[i+1]-L[i])
Lx.sort()
if N>=M:
    print(ans)
else:
    for i in range(M-N):
        ans=ans+Lx[i]
    print(ans)
# print(L)
# print(Lx)

Measured memory_bytes: 14728
ls = input().strip().split(' ')
N = int(ls[0])
M = int(ls[1])
ls = []
for i in range(M):
    ln = input().strip().split(' ')
    ls.append((ln[0], int(ln[1]), i))
ls.sort()
result = []
x = 1
lst = -1
for i in ls:
    if i[0] == lst:    x += 1
    else:    x = 1
    result.append((i[2], '{:06d}{:06d}'.format(int(i[0]), x)))
    lst = i[0]
result.sort()
for i in result:
    print(i[1])


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n;
    cin>> n;
    cout<< n*n*n;
    nl;
    

    return 0;
}




Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int ans = 0;
    rep(i, k) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;

  if((A + B) % 2 == 0){
    cout << (A + B) / 2 << endl; 
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  } 

}


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




int main()
{	
	ll n;
	cin>>n;
	
ll v[n];
long double a[n];
long double sum=0,ans=0;


for(ll i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
sum=a[0];	
for(ll i=1;i<n;i++)sum=(sum+a[i])/2;

cout<<sum;

}

Measured memory_bytes: 256
k , n = map(int, input().split())
a_list = list(map(int, input().split()))
a_last = a_list[0] + k
a_list.append(a_last)
distance = -1
for i in range(n):
    distance_btw = a_list[i + 1] - a_list[i]
    if distance_btw > distance:
        distance = distance_btw
print(k - distance)        


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



int main() {

    string  s,t,w; cin >> s >> t;
    w = t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    rep(i,t.length()){
        w[i] = t[t.length()-1-i];
    }


    if(s < w) cout << "Yes";
    else cout << "No";

    return 0;
}











Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var ab = Arrays.stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();

      System.out.println(ab[0] * ab[1]);
    }
  }
}


Measured memory_bytes: 34440
n,m=map(int,input().split())
if n==1:
    print(1)
else:
    dp=[1]*n
    cor=[1]*n
    for i in range(m):
        cor[int(input())]=0
    if cor[0]==0:
        dp[0]=0
    if cor[1]==0:
        dp[1]=0
    for i in range(2,n):
        dp[i]=(dp[i-1]+dp[i-2])%1000000007
        if cor[i]==0:
            dp[i]=0
    print((dp[n-1]+dp[n-2])%1000000007)
    #print(dp)

Measured memory_bytes: 45016
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

template<typename T> class Graph_Matrix{
    private:
        vector<vector<T>> dist;
        int V;
    public:
        Graph_Matrix(int n);
        void add(int from, int to, T cost);
        T get(int from, int to);
        void FloydWarshall();
        bool negative();
};

template<typename T> Graph_Matrix<T>::Graph_Matrix(int n){
    dist = vector<vector<T>>(n + 1, vector<T>(n + 1));
    V = dist.size();
    REP(i,0,n + 1) REP(j,0,n + 1){
        if (i == j) dist[i][j] = 0;
        else dist[i][j] = numeric_limits<T>::max();
    }
}

template<typename T> void Graph_Matrix<T>::add(int from, int to, T cost){
    dist[from][to] = cost;
}

template<typename T> T Graph_Matrix<T>::get(int from, int to){
    return dist[from][to];
}

template<typename T> void Graph_Matrix<T>::FloydWarshall(){
    auto const INF = numeric_limits<T>::max();
    REP(k,0,V)REP(i,0,V)REP(j,0,V){
        if (dist[i][k] == INF || dist[k][j] == INF) continue;
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
}

template<typename T> bool Graph_Matrix<T>::negative(){
    REP(i,0,V){
        if (dist[i][i] < 0) return true;
    }
    return false;
}


int main(){
    int n, m;
    cin >> n >> m;
    Graph_Matrix<int> g(n);
    vector<int> a(m), b(m), c(m);

    REP(i,0,m){
        cin >> a[i] >> b[i] >> c[i];
        g.add(a[i], b[i], c[i]);
        g.add(b[i], a[i], c[i]);
    }

    g.FloydWarshall();
    int ans = 0;
    REP(i,0,m){
        if (g.get(a[i], b[i]) < c[i]) ans++;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void max_new(ll& a,ll b)
{
  a = max(a,b);
}
int main()
{
  int n,w;
  cin >> n >> w;
  vector<ll> dp(w+1);
  for(int i=0;i<n;i++)
  {
    int weight,val; 
    cin >> weight >> val;
    for(int j = w - weight;j>=0;j--)
    {
      max_new(dp[j+weight],dp[j]+val);
    }
  }
  ll ans = 0;
  for(int i=0;i<=w;i++)
  {
    max_new(ans,dp[i]);
  }
  
  cout << ans << endl;
}


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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if(a+b == c || a+c == b || a == b+c)
    ans = "Yes";
    
  cout << ans << endl;  
  return 0;
  
}


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

int main(){
	string S[3];
	cin >> S[0] >> S[1] >> S[2];
	int now = 0, old = 0;
	while(1){
//		printf("now = %d\n", now);
		if(S[now].size() == 0){
			printf("%c\n", (char)((int)'A' + now));
			return 0;
		}
		else{
			now = (int)S[now][0] - (int)'a';
			S[old].erase(S[old].begin());
			old = now;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin>> a>> b>> c;
    if(a == b || b == c || a == c) {
        if(a != b || b != c || a != c) {
            cout <<"Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int basePrice = sc.nextInt();
		int topPrice = sc.nextInt();
		int baseCal = sc.nextInt();
		int[] topCal = new int[n];
		for(int i=0;i<n;i++){
			topCal[i]=sc.nextInt();
		}
		Arrays.sort(topCal);
		for(int i=n;i>0;i--){
			if((baseCal+topCal[i-1])/(basePrice+topPrice)>=(baseCal/basePrice)){
				baseCal += topCal[i-1];
				basePrice += topPrice;
			}
		}
		System.out.println((int)baseCal/basePrice);

	}

}

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

char s[20];

int main()
{
	scanf("%s", s + 1);
	if (s[1] != 'A')
	{
		puts("WA");
		return 0;
	}
	int len = strlen(s + 1);
	for (int i = 1; i <= len; i++)
		if (s[i] >= 'A' && s[i] <= 'Z' && s[i] != 'A' && s[i] != 'C')
		{
			puts("WA");
			return 0;
		}
	int hh = 0;
	for (int i = 3; i < len; i++)
		if (s[i] == 'C')
			hh++;
	if (hh == 1)
		puts("AC");
	else
		puts("WA");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
signed main()
{   
      senky_bansal
      IIIT_ALLAHABAD
      
        string s;
  cin>>s;
  ll f=0;
  for(int i=0;i<s.size()-1;i++)
  {
    if(s[i]==s[i+1])
    {
      f=1;
      break;
    }
  }
  if(f==0) cout<<"Good";
  else
    cout<<"Bad";
      
    
    
    
}







Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#include <climits>
#include <cmath>
#include <cstring>

#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

#define MOD 998244353

ll power(ll a , ll p)
{
	ll result = 1;
	while(p > 0)
	{
		// checking if last bit is 1 or not 
		if(p & 1)
			result = ( (result%MOD) * (a%MOD) ) % MOD;
		
		a = ( (a%MOD) * (a%MOD) ) % MOD;
		p = p>>1;
	}

	return result;
}

int main()
{
	FAST;
	int n;
	cin >> n;
	
	ll arr[n];
	
	for(int i=0 ; i<n ; i++)
		cin >> arr[i];
		
	if(arr[0] != 0)
	{
	    cout << "0";
	    return 0;
	}

	ll count[n];
	memset(count , 0 , sizeof(count));
	
	for(int i=0 ; i<n ; i++)
		count[arr[i]]++;
		
		
	if(count[0] != 1)
	{
	    cout << "0\n";
		return 0;
	}

	ll tree = 1;
	ll temp = n-1;
	for(int i=1 ; i<n ; i++)
	{
		if(count[i] == 0)
		{
		    if(temp == 0)
				break;
			cout << "0\n";
			return 0;
		}

		temp -= count[i];
		tree = (tree * power(count[i-1] , count[i]))%MOD;
	}

	cout << tree << "\n";
	return 0;
}

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

//カッコのバランスを考える問題
//
//バランスの悪いものとは
////閉じかっこの数が少ない
////閉じかっこの数が多い
//
//カウントしている最中でも閉じかっこが多ければそれだけでアウト

int main(){
	int n;
	int count = 0;
	char parentheses;
	int parenthesesNum;

	cin >> n;
	for(int i=0; i < n; i++){
		cin >> parentheses >> parenthesesNum;

		if(parentheses == '(') count += parenthesesNum;
		else count -= parenthesesNum;

		if(count < 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	if(count == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 1156