akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int d;
double y[10];
int dcmp(double d1, double d2){
    if(fabs(d1 - d2) < 1e-3)
        return 0;
    return 1;
}
int check(int idx){
    int i, j, cnt2, record[d], last=0;
    double dtmp = 1, ans;
    int flag=0, key;
    for(i=0,cnt2=0; i<d+3; i++){
        if(i == idx) continue;
        else if(!flag){
            flag = 1;
            key = i;
            continue;
        }
        record[last++] = i;
        if(cnt2 == d+1){
            break;
        }
        cnt2++;
    }
 //   printf("key = %d\n",key);
    //!i, the chosen one;
   /* for(i=0; i<last; i++)
        printf("record[%d]=%d\n",i,record[i]);*/
    for(i=0, ans=0; i<last; i++){
        for(j=0,dtmp=1; j<last; j++){
            if(record[i] == record[j]){
                continue;
            }
        //    printf("record[%d] = %d\trecord[%d]=%d\n",i,record[i],j,record[j]);
            dtmp *= (float)(key-record[j])/(record[i]-record[j]);
       //     printf("dtmp=%lf\n\n",dtmp);
        }
        ans += dtmp * y[record[i]];
    //    printf("ans = %lf\n",ans);
    }
  //  printf("y[%d]=%lf\n",key,y[key]);
    if(!dcmp(ans, y[key]))
        return 1;
    return 0;
}
int main(){
    int i;
    while(scanf("%d",&d)!=EOF && d){
        for(i=0; i<d+3; i++)
            scanf("%lf", &y[i]);
       /* for(i=0; i<d+3; i++)
            printf("%lf", y[i]);*/
        for(i=0; i<d+3; i++){
     //       printf("check[%d]=%d\n\n\n",i,check(i));
            if(check(i)){
                printf("%d\n",i);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int x0=0, x1=w, y0=0, y1=h;
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1){
      x0 = max(x0, x);
    } else if(a==2){
      x1 = min(x1, x);
    } else if(a==3){
      y0 = max(y0, y);
    } else if(a==4){
      y1 = min(y1, y);
    }
  }
  int X = max(0,(x1-x0));
  int Y = max(0,(y1-y0));
  int ans = X*Y;
  cout << ans << ln;
  return 0;
}

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


int main() {
int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];}
  int MAX=vec[0];
  int counter=0;
  for(int i=0;i<N;i++){
    MAX=(max(MAX,vec[i]));
         if(MAX==vec[i]){
           counter++;
         }
         }
         
  
  
  cout<<counter<<endl;
  

}


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

using namespace std;

int main(){

	int n,k;
	cin>>n>>k;
	
	int arr[n];
	for (int i=0;i<n;i++) cin>>arr[i];
	
	int dp[n];
	
	dp[0]=0;
	
//	for (int i=0;i<=k;i++){
//		dp[i]=abs(arr[i]-arr[0]);
//	}
	
	for (int i=1;i<n;i++){
		dp[i]=INT_MAX;
		for (int j=1;j<=k;j++){
			if (i-j>=0){
				dp[i]=min(abs(arr[i]-arr[i-j])+dp[i-j],dp[i]);
			}
		}
	}

	cout<<dp[n-1]<<endl;

	return 0;
}


Measured memory_bytes: 4380
#include <stdio.h>

int main() {
  int a[3][3];
  int N;
  int b[N];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &b[i]);
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (a[j][k] == b[i]) {
          a[j][k] = 0;
        }
      }
    }
  }
  int count1;
  int count2;
  int c = 0;
  //横
  for (int i = 0; i < 3; i++) {
    count1 = 0; //横
    count2 = 0; //縦
    for (int j = 0; j < 3; j++) {
      if (a[i][j] == 0) {
        count1 += 1;
      }
      if (a[j][i] == 0) {
        count2 += 1;
      }
    }
    if (count1 == 3 || count2 == 3) {
      c += 1;
    }
  }
  int count3 = 0;
  for (int i = 0; i < 3; i++) {
    if (a[i][i] == 0) {
      count3 += 1;
    }
  }
  if (count3 == 3) {
    c += 1;
  }
  if (a[0][2] == 0 && a[1][1] == 0) {
    if (a[2][0] == 0) {
      c += 1;
    }
  }
  if (c > 0) {
    printf("Yes\n");

  } else {
    printf("No\n");
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define maxn 100005

int main()
{
	ll n, k, temp;
	bool dp[maxn];
	cin >> n >> k;
	vector<ll> x;
	for (int i = 0; i < n; ++i) {
		cin >> temp;
		x.push_back(temp);
	}
	for (int i = 1; i <= k; ++i) {
		bool current = false;
		for (auto each : x) {
			if (i - each >= 0) {
				current = current || !dp[i - each];
			}
		}
		dp[i] = current;
	}
	string str = dp[k] ? "First" : "Second";
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n];
    ll cnt[100010] = {};
    ll sum = 0;
    rep(i, 0, n) {
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    int q;
    cin >> q;
    while (q--) {
        ll b, c;
        cin >> b >> c;
        sum -= b * cnt[b];
        ll tmp = cnt[b];
        cnt[b] = 0;
        cnt[c] += tmp;
        sum += c * tmp;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long 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(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    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;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    map<pair<ll, ll>, P> mp;
    int zero = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            zero++;
            continue;
        }
        ll g = gcd(a, b);
        a /= g; b /= g;
        if (b < 0) a = -a, b = -b;
        if (a < 0 && b == 0) a = 1;
        bool rot = (a <= 0);
        if (rot) {
            ll tmp = a;
            a = b;
            b = -tmp;
        }
        if (rot) mp[{a, b}].se++;
        else mp[{a, b}].fi++;
    }
    mint ans = 1;
    for (auto&& p : mp) {
        ll s = p.se.fi, t = p.se.se;
        mint now = 0;
        now += 1;
        now += mint(2).pow(s) - 1;
        now += mint(2).pow(t) - 1;
        ans *= now;
    }
    ans += zero;
    ans -= 1;
    cout << ans << endl;
}

Measured memory_bytes: 16128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include <math.h>
#include<algorithm>
#include <map>
using namespace std;

int main(int argc,char** argv)
{

	int n,m,X,Y;
	cin >> n >> m >> X >> Y;

	int x[n],y[m];
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < m; i++){
		cin >> y[i];
	}
	sort(x,x+n);
	sort(y,y+m);

	if(y[0]<=X){
		cout << "War"<<endl;
		return 0;
	}
	else if(Y<=x[n-1]){
		cout << "War"<<endl;
		return 0;
	}
	else if(y[0]<=x[n-1]){
		cout << "War"<<endl;
		return 0;
	}

	cout << "No War"<<endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int n[101][101];
int W,H,N;

void print(){
  cout<<endl;
  rep(i,H){
    rep(j,W){
      cout<<n[i][j]<<" ";
    }
    cout<<endl;
  }
}

void paint(int x,int y,int a){
  if(a==1){
    rep(i,H)rep(j,x)n[i][j]=1;
  }else if(a==2){
    rep(i,H)REP(j,x,W)n[i][j]=1;
  }else if(a==3){
    rep(i,y)rep(j,W)n[i][j]=1;
  }else if(a==4){
    REP(i,y,H)rep(j,W)n[i][j]=1;
  }
}

int main(){
  cin>>W>>H>>N;
  rep(i,101)rep(j,101)n[i][j]=0;
  rep(i,N){
    int x,y,a;
    cin>>x>>y>>a;
    paint(x,y,a);
    //print();
  }

  int ans=0;
  rep(i,H)rep(j,W)if(n[i][j]==0)ans++;
  cout<<ans<<endl;
  
  return 0;
}
	   


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
count1=0
count2=0
for i in range(n):
    if a[i]%2==0:
        count1+=1
        if a[i]%3==0 or a[i]%5==0:
            count2+=1
if count1==count2:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
int w,h,x,y,r;
scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
if((x+r<=w)&&(y+r<=h)&&(x-r>=0)&&(y-r>=0)){
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}

Measured memory_bytes: 580
#include<cstdio>

int main(){
	int N;
	scanf("%d", &N);
	int A[N];
	int min = 50;
	for (int i = 0; i < N; ++i)	{
		scanf("%d", &A[i]);
		int k = 0;
		while(A[i] % 2 == 0){
			A[i] /= 2;
			k++;
		}
		if(k < min) min = k;
	}
	printf("%d\n", min);
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double L; cin>>L;
  double l=L/3;
  cout<<fixed<<setprecision(7);
  cout<<l*l*l<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>
#include <sstream>

using namespace std;

#define int long long
#define ull unsigned long long
#define double long double
#define time time228
#define left left228
#define right right228


template<typename T> void uin(T &a, T b) {
    if (b < a) a = b;
}

template<typename T> void uax(T &a, T b) {
    if (b > a) a = b;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n % 2 == 0) {
        vector< vector<int> > v;
        for (int i = 1; i <= n / 2; ++i) {
            v.push_back({i, n - i + 1});
        }
        vector< pair<int, int> > e;
        for (int i = 0; i < (int)v.size(); ++i) {
            for (int j = i + 1; j < (int)v.size(); ++j) {
                for (int a = 0; a < 2; ++a) {
                    for (int b = 0; b < 2; ++b) {
                        e.push_back({v[i][a], v[j][b]});
                    }
                }
            }
        }
        cout << (int)e.size() << '\n';
        for (auto p : e) {
            cout << p.first << " " << p.second << "\n";
        }
    } else {
        vector< vector<int> > v;
        for (int i = 1; i <= (n - 1) / 2; ++i) {
            v.push_back({i, n - 1 - i + 1});
        }
        v.push_back({n});
        vector< pair<int, int> > e;
        for (int i = 0; i < (int)v.size(); ++i) {
            for (int j = i + 1; j < (int)v.size(); ++j) {
                for (int a = 0; a < (int)v[i].size(); ++a) {
                    for (int b = 0; b < (int)v[j].size(); ++b) {
                        e.push_back({v[i][a], v[j][b]});
                    }
                }
            }
        }
        cout << (int)e.size() << '\n';
        for (auto p : e) {
            cout << p.first << " " << p.second << "\n";
        }
    }
    return 0;
}








Measured memory_bytes: 512
#include <iostream>
#define EPS 1e-7
using namespace std;
int main(){
	int t,n,m,p,q;
	double exvn=0,exvp=0,max=0.0,vv=0.0;
	cin>>t;
	while(t--){
		cin>>n>>m;
		double tmp=0.0;
		vv=0.0;
		for(int i=0,v;i<m;++i){
			double r;
			cin>>v>>r;
			tmp+=(double)v*r;
			vv+=r;
		}
		exvn=tmp/vv;
		if(max<exvn)max=exvn;
	}
	vv=0.0;
	cin>>p>>q;
	for(int i=0,v;i<q;++i){
		double r;
		cin>>v>>r;
		exvp+=(double)v*r;
		vv+=r;
	}
	exvp/=vv;
	if(max-exvp>EPS)cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
using namespace std;
int n;
long long int a[222222];
long long int AB(long long int x){return x>0?x:-x;}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		int x;
		scanf("%d",&x);
		a[i] = a[i-1] + x;
	}
	long long int res = 0;
	for(int i=1; i<n; i++){
		long long int now = AB(a[i] - (a[n]-a[i]));
		if(i == 1 || now < res)
			res = now;
	}
	cout << res <<endl;
	return 0;
}

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

int main()
{
    int dp1[100001],dp2[100001],dp3[100001];
    dp1[0]=0;
    dp2[0]=0;
    dp3[0]=0;
    int n,i;
    cin>>n;
    int a[n],b[n],c[n];
    cin>>dp1[0]>>dp2[0]>>dp3[0];
    for(i=1;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        dp1[i]=max(dp2[i-1]+a[i],dp3[i-1]+a[i]);
        dp2[i]=max(dp1[i-1]+b[i],dp3[i-1]+b[i]);
        dp3[i]=max(dp1[i-1]+c[i],dp2[i-1]+c[i]);
    }
    cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]));
    
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int a,b,s,c,sum;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a<b+c){
		sum=(b+c)-a;
	}
	if(!(a<b+c)){
		sum=0;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdlib.h>

int main(void){

  int n,k;
  int p[1000];
  
  std::cin >> n >> k;
  for(int i=0;i<n;i++){
    std::cin >> p[i];
  }
  
  int t=0;
  
  for(int j=0; j<n-1; j++){
    for(int i=0; i<n-1; i++){
      if(p[i]>p[i+1]){
        t = p[i];
        p[i]=p[i+1];
        p[i+1] = t;
      }
    }
  }

  int total=0;
  
  for (int i=0;i<k;i++){
    total+=p[i];
  }
  
  std::cout <<total;
  
  
  
  //std::cout << n << " " << k <<"\n";
  /*
  for(int i=0;i<n;i++){
    std::cout << p[i] << " ";
  }
  std::cout << "\n";
 */
  return(0);
}

Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
void printarray(int *a, int n)
{
    REP(i, n)
    {
        if (i > 0)
            cout << " ";
        cout << a[i];
    }
    cout << endl;
}

void insertionSort(int *a, int n)
{
    printarray(a, n);
    rep(i, 1, n)
    {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        printarray(a, n);
    }
}
int bubbleSort(int *a, int n)
{
    int ans = 0;
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int j = n - 1; j >= 1; j--)
        {
            if (a[j] < a[j - 1])
            {
                swap(a[j], a[j - 1]);
                ans++;
                flag = true;
            }
        }
    }
    printarray(a, n);
    return ans;
}
int main(void)
{
    int n;
    cin >> n;
    int a[101];
    REP(i, n)
    {
        cin >> a[i];
    }
    //    insertionSort(a, n);
    cout << bubbleSort(a, n) << endl;
}



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

int main()
{
  int n,m;cin>>n>>m;
  vector<int> s(m);
  vector<int> c(m);
  int i;
  for(i=0;i<m;i++)cin>>s.at(i)>>c.at(i);
  vector<int> num(n,-1);
  bool ok=true;
  for(i=0;i<m;i++)
  {
    if(num.at(s.at(i)-1)!=-1&&num.at(s.at(i)-1)!=c.at(i))
    {
      cout<<-1<<endl;
      ok=false;
      break;
    }
    num.at(s.at(i)-1)=c.at(i);
  }
  if(num.at(0)==0&&n!=1)
  {
    ok=false;
    cout<<-1<<endl;
  }
  if(ok)
  {
    for(i=0;i<n;i++)
    {
      if(num.at(i)==-1)
      {
        if(i==0&&n!=1)cout<<1;
        else cout<<0;
      }
      else cout<<num.at(i);
    }
      cout<<endl;
  }
}


Measured memory_bytes: 256
w = list(input().rstrip())
t = {}
for i in range(len(w)):
    k = w[i]
    if k in t:
        t[k] += 1
    else:
        t[k] = 1


r = True
for v in t.values():
    if v % 2 == 1:
        r = False
        break

print('Yes' if r else 'No')


Measured memory_bytes: 3060
using System;
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            if (s1.Length - s2.Length == 0)
            {
                for (int i = 0; i < s1.Length; i++)
                {
                    Console.Write(s1[i]+""+s2[i]);
                }
            }
            else {
                Console.Write(s1[0]);
                for (int i = 0; i < s2.Length; i++) {
                    Console.Write(s2[i] + ""+ s1[i + 1]);
                }
            }
            Console.WriteLine();
        }
        
    }


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	string S, T; cin >> S >> T;
	map<int, int> mp;
	REP(i, S.size()) {
		if (mp[S[i]] != 0) {
			if (mp[S[i]] != T[i]) {
				cout << "No" << endl;
				return;
			}
		} else {
			mp[S[i]] = T[i];
		}
	}
	map<int, int> m2;
	REP(i, S.size()) {
		if (m2[T[i]] != 0) {
			if (m2[T[i]] != S[i]) {
				cout << "No" << endl;
				return;
			}
		} else {
			m2[T[i]] = S[i];
		}
	}
	cout << "Yes" << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 916
#include <iostream>
#include <string>
#include <cmath>
#include <math.h>
using namespace std;

int main(){
	int a, b, ko = 0, ta = 0;
	char knm;
	long int sum=0;
	while(cin>>a){
		cin >> knm >> b;
		sum += a*b;
		ko++;
		ta += b;
	}
	double he;
	he = ta / ko;
	int ans = round(he+0.5);
	cout << sum << endl
		<< ans << endl;
	return 0;
}

Measured memory_bytes: 3056
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  map<string, ll> mp;
  for (int i = 0; i < N; i++)
  {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto &e : mp)
  {
    ll t = e.second;
    ans += t * (t - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
template <typename Iter, typename T> int gt(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L; }
template <typename Iter, typename T> int ge(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L; }
template <typename Iter, typename T> int lt(Iter L, Iter R, T v) { return lower_bound(L, R, v) - L - 1; }
template <typename Iter, typename T> int le(Iter L, Iter R, T v) { return upper_bound(L, R, v) - L - 1; }
template <typename Bst, typename T> typename Bst::const_iterator gt(const Bst& bst, T v) { return bst.upper_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator ge(const Bst& bst, T v) { return bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator lt(const Bst& bst, T v) { return bst.lower_bound(v) == bst.begin() ? bst.end() : --bst.lower_bound(v); }
template <typename Bst, typename T> typename Bst::const_iterator le(const Bst& bst, T v) { return bst.upper_bound(v) == bst.begin() ? bst.end() : --bst.upper_bound(v); }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    multiset<int> s;
    for(int x : a) {
        auto it = lt(s, x);
        if(it != s.end()) {
            s.erase(it);
        }
        s.insert(x);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	long long int x[5] = {a, b, c, d, e};
	long long int m = n;
	for(int i=0;i<5;i++){
		m = min(m, x[i]);
	}
	if(m==n){
		cout << 5 << endl;
		 return 0;
	}
	long long int ans = n/m;
	if(m==1){
		cout << ans+4 << endl;
		return 0;
	}
	cout << ans+5 << endl;
	return 0;
}

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

struct Card { char suit, value; };

void selectionSort(struct vector<Card> &A, int N){
    for(int i = 0; i < N; i++){
        int tmp_j = i;
        for(int j = i + 1; j < N; j++){
            if(A.at(tmp_j).value > A.at(j).value){
                tmp_j = j;
            }
        }
        swap(A.at(i), A.at(tmp_j));
    }
}

void bubleSort(struct vector<Card> &A, int N){
    for(int i = 0; i < N; i++){
        for(int j = N - 1; j > i; j--){
            if(A.at(j-1).value > A.at(j).value){
                swap(A.at(j), A.at(j-1));
            }
        }
    }
}

void print(struct vector<Card> A, int N){
    for(int i = 0; i < N; i++){
        if(i!=0){
            cout << " ";
        }
        cout << A.at(i).suit << A.at(i).value;
    }
    cout << endl;
}

bool is_stable(struct vector<Card> A, struct vector<Card> B, int N){
    bool stable = true;
    for(int i = 0; i < N; i++){
        if(A.at(i).suit != B.at(i).suit){
            stable = false;
            break;
        }
    }
    return stable;
}


int main(){
    int N;
    char ch;
    cin >> N;
    vector<Card> C1(N), C2(N);
    for(int i = 0; i < N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i = 0; i < N; i++){
        C2[i] = C1[i];
    }

    selectionSort(C2, N);
    bubleSort(C1, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if(is_stable(C1, C2, N)){
        cout << "Stable" << endl; 
    }
    else{
        cout << "Not stable" << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include<iostream>
#include<vector>

using namespace std;

int main(void){
     int n;
     int a=0,b=0,c=0;
     cin >> n;
     for(int i=0;i<n;i++){
	  cin >> a >> b >> c;
	  if(a*a == b*b + c*c){
	       cout << "YES" << endl;
	  }else if(b*b == a*a + c*c){
	       cout << "YES" << endl;
	  }else if(c*c == a*a + b*b){
	       cout << "YES" << endl;
	  }else{
	       cout << "NO" << endl;
	  }
     }
     return 0;
}

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

int main(){
	int a[5];
	vector<int> b(5);
	int last=0;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if (a[i] % 10 != 0 && a[i] % 10 <= a[last] % 10) {
			last = i;
		}
	}

	
	int ans = 0;

	for (int i = 0; i < 5; i++) {
		if (i == last)continue;
		if (a[i] % 10 == 0) {
			ans += a[i];
		}
		else {
			ans += ((a[i]/10)+1)*10;
		}
	}

	cout << ans + a[last] << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N,M;
	while(1){
	int n[4000]={};
	int G=0;
	int H=0;
	cin>>N>>M;if(N==0&&M==0)break;
	for(int i=1;i<=N;i++)
	for(int j=1;j<=M;j++)
	{
		int x;cin>>x;
		n[j]+=x;
	}
	for(int i=1;i<=M;i++){int max=0,p=0;
		for(int j=1;j<=M;j++)
		{
			if(max<n[j]){max=n[j];p=j;}
		}
		if(i>1)cout<<" ";
		cout<<p;
		n[p]=0;
	}


	cout<<endl;
}
	return 0;
}
			
	

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;
vector<long long>v(N);

long long bsum=0;
rep(i,N){
    long long a,b;
    cin>>a>>b;
    v[i]=a+b;
    bsum+=b;
}
bsum=-bsum;
sort(v.begin(),v.end());

long long ans=0;
for(int i=N-1;i>=0;i-=2){
ans+=v[i];
}
cout<<ans+bsum<<endl;
 return 0;
}
/*
3
10 10
20 20
30 30

20


3
20 10
20 20
20 30

20

6
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000

-2999999997

*/

Measured memory_bytes: 1024
#!/usr/bin/env python3

N  = int(input())

ans = [0, 0]
T, A = [0] * 1001, [0] * 1001

for i in range(N):
    T[i], A[i] = map(int, input().split())

    if i != 0 and T[i - 1] - T[i] >= 0 or A[i - 1] - A[i] >= 0:
        t = T[i-1] // T[i] if T[i-1] % T[i] == 0 else T[i-1] // T[i] + 1
        s = A[i-1] // A[i] if A[i-1] % A[i] == 0 else A[i-1] // A[i] + 1

        m = max(t, s)

        T[i] *= m
        A[i] *= m

    ans = [T[i], A[i]]

print (int(sum(ans)))


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

namespace pb_ds {   
    namespace io {
        const int MaxBuff = 1 << 15;
        const int Output = 1 << 23;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
        char Out[Output], *iter = Out;
        inline void flush() {
            fwrite(Out, 1, iter - Out, stdout);
            iter = Out;
        }
    }
 
    template<class Type = int> inline Type read() {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }
}
 
using namespace pb_ds;

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

vector<int> G[N]; queue<int> Q; int col[N], n;

int main () {

	File();

	n = read();

	For (i, 1, n - 1) {
		int u = read(), v = read();
		G[u].push_back(v); G[v].push_back(u);
	}
	col[1] = 1; col[n] = 2; Q.push(1); Q.push(n);

	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		for (int v : G[u]) if (!col[v])
			col[v] = col[u], Q.push(v);
	}
	
	int ans = 0;
	For (i, 1, n) 
		ans += col[i] == 1 ? 1 : -1;
	puts(ans > 0 ? "Fennec" : "Snuke");

	return 0;

}

Measured memory_bytes: 7680
#include <iostream>
#include <string>
using namespace::std;
int main()
{       int i;
        string str;
        getline( cin, str);
        for(i=0;i<str.length();i++)
        {

                if( (str[i]>='a')&&(str[i]<='z'))
                        { cout<<(char) (str[i]-32);}
                else if(str[i]>='A'&&str[i]<='Z')
                          {cout<<(char) (str[i]+32);}
                 else
                 { cout<<str[i];
                    }

        }
      cout<<endl;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const ll inf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,x;
int a[maxn];
ll dp[210][maxn];
int cmp(int a,int b){
    return a>b;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>x;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    dp[0][x]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=x;j++){
            (dp[i][j%a[i]]+=dp[i-1][j])%mod;
            (dp[i][j]+=dp[i-1][j]*(n-i)%mod)%mod;
        }
    }
    ll ans=0;
    for(int j=0;j<=x;j++){
        ans=(ans+dp[n][j]*j%mod)%mod;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 156544
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,a,b,c = LI()
    inv_100 = pow(100,mod-2,mod)
    a = a*inv_100%mod
    b = b*inv_100%mod
    c = (1-c*inv_100)%mod
    c = pow(c,mod-2,mod)
    fact = [1]
    N = 2*n
    for i in range(1,N+1):
        fact.append(fact[-1]*i%mod)
    inv = [None]*(N+1)
    inv[N] = pow(fact[N], mod-2, mod)
    for i in range(N)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod
    ans = 0
    fa,fb,fc = pow(b,n,mod),pow(a,n,mod),pow(c,n+1,mod)
    for i in range(n):
        ans += inv[i]*fact[n+i]*fc*(fb+fa)%mod
        ans %= mod
        fa *= a
        fb *= b
        fc *= c
        if fa >= mod:
            fa %= mod
        if fb >= mod:
            fb %= mod
        if fc >= mod:
            fc %= mod
    print(ans*inv[n-1]%mod)
    return

#Solve
if __name__ == "__main__":
    solve()


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


// int dp(vector<vector<int>>& mem, vector<int>& w, vector<int>& v, int W, int i) {
//     if(i == 0 || W == 0) {
//         mem[i][W] = 0;
//         return mem[i][W];
//     }
//     if(w[i-1] <= W) {
//         int j = i-1;
//         int x = mem[i-1][W-w[j]] > -1? mem[i-1][W-w[j]]: (dp(mem, w, v, W-w[j], i-1) + v[j]);
//         int y = mem[i-1][W] > -1? mem[i-1][W]: dp(mem, w, v, W, i-1); 
//         mem[i][W] = max(x, y);
//         return mem[i][W];
//     }
//     mem[i][W] = mem[i-1][W] > -1? mem[i-1][W]: dp(mem, w, v, W, i-1);
//     return mem[i][W];
// }
long long max(int a, int b) {
    return a > b? a: b; 
}

int main() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n);
    vector<int> v(n);
    vector<vector<long long int>> mem(n+1, vector<long long int>(W+1, 0));
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= W; j++) {
            if(w[i-1] <= j) {
                mem[i][j] = max(mem[i-1][j], mem[i-1][j-w[i-1]] + v[i-1]);
            }
            else {
                mem[i][j] = mem[i-1][j];   
            }
        }
    }
    cout << mem[n][W];
    return 0;
}

Measured memory_bytes: 83044
#include <stdio.h>
int p = 0;
int main() {
	int N, X, i, m;
	m = 0;
	scanf("%d", &N);
	scanf("%d", &X);
	int mj[N];
	for (i = 0; i < N; i++) {
		scanf("%d", &mj[i]);
	}
	for (i = 0; i < N; i++) {
		p = p + mj[i];
	}
	for (i = 0; i < N; i++) {
		if (mj[0] >= mj[i]) {
			mj[0] = mj[i];
		}
	}
	X = (X - p) / mj[0];
	N = X + N;
	printf("%d", N);
	return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
	int a[101],b,i,n;
	scanf("%d",&n);
    for(i=0;i<4;i++)
	{
		a[i]=n%10;
		n/=10;
	}
	if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3])||(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]))
	{
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
string a,b,c;
int n,fix[1003];
int ans;
int main(){std::ios::sync_with_stdio(false);
cin>>n>>a>>b>>c;
for(int i=n-1;i>=0;i--){
	if(a[i]==b[i]&&b[i]==c[i]){
		fix[i]=0;
	}else{
		if(a[i]==b[i]||b[i]==c[i]||a[i]==c[i]){
			fix[i]=1;
		}else{
			fix[i]=2;
		}
	}
}
for(int i=0;i<n;i++){
	ans+=fix[i];
}
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/





Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b, c;
	while (scanf("%d%d%d", &a, &b, &c) && (a != -1 || b != -1 || c != -1))
	{
		if (a < 0 || b < 0)
			puts("F");
		else if (a + b >= 80)
			puts("A");
		else if (a + b >= 65)
			puts("B");
		else if (a + b >= 50 || c >= 50)
			puts("C");
		else if (a + b >= 30)
			puts("D");
		else
			puts("F");
	}
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    string N; cin>>N;
    if(N=="ABC") Out("ARC");
    else Out("ABC");
}

Measured memory_bytes: 3648
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> As(N);
    rep(i,0,N) {
        cin >> As[i];
    }
    sort(As.begin(), As.end());
    auto count_leq = [&As, N](ll x) {
        ll ans = 0;
        rep(i,0,N) {
            if (As[i] == 0) {
                if (x >= 0) {
                    ans += N - 1;
                }
            } else if (As[i] > 0) {
                ll y;
                if (x >= 0) {
                    y = x / As[i];
                } else {
                    y = x / As[i];
                    if (x % As[i] != 0) {
                        y--;
                    }
                }
                ans += distance(As.begin(), upper_bound(As.begin(), As.end(), y));
                if (As[i] * As[i] <= x) {
                    ans--;
                }
            } else {
                ll y;
                if (-x >= 0) {
                    y = (-x)/(-As[i]);;
                    if (abs(x) % abs(As[i]) != 0) {
                        y++;
                    }
                } else {
                    y = (-x)/(-As[i]);
                }
                ans += N - distance(As.begin(), lower_bound(As.begin(), As.end(), y));
                if (As[i] * As[i] <= x) {
                    ans--;
                }
            }
        }
        ans /= 2;
        return ans;
    };
    ll abs_max = numeric_limits<ll>::min();
    rep(i,0,N) {
        abs_max = max(abs_max, As[i]*As[i]);
    }
    ll bad = -abs_max-1;
    ll good = +abs_max+1;
    while (good != bad + 1) {
        ll mid = (bad + good) / 2;
        if (count_leq(mid) >= K) {
            good = mid;
        } else {
            bad = mid;
        }
    }
    cout << good << endl;
}

/*
 
 5 3
 -1000000000 -1000000000 0 1000000000 1000000000
 
 */


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

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int col=s[n/2];
    int K=-1;
    REP(i,n/2)if(col!=s[i])chmax(K,i);
    reverse(ALL(s));
    REP(i,n/2)if(col!=s[i])chmax(K,i);
    K=n-(K+1);
    cout<<K<<endl;
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
#define sz(x)                 (int)(x.size())
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.141592653589793238462643383279;

#define int                   long long

typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; scanf("%d", &_x); return _x; }
long long lin() {long long _x; scanf("%lld", &_x); return _x; };

signed main() { 
        int n, a, b;
        cin >> n >> a >> b;
        if (a > b) cout << 0 << endl;
        else if (n == 1) {
                if (b - a > 0) cout << 0 <<endl;
                else cout << 1 << endl;
        }
        else {
                int sum1, sum2;
                sum1 = (n - 2) * b;
                sum2 = (n - 2) * a;
                cout << sum1 - sum2 + 1 << endl;
        }
        return 0;
}               



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

int main() {
    int N, now=0;
    cin >> N;
    vector<pair<int, int>> jobs(N);
    for(int i=0; i<N; i++) {
        int a, b;
        cin >> a >> b;
        jobs[i] = make_pair(b, a);
    }
    sort(jobs.begin(), jobs.end());

    for(int i=0; i<N; i++) {
        now += jobs[i].second;
        if(now > jobs[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

#define K 10000

int main(){
  int i,j,n,C[K+1];
  int *A,*B;

  scanf("%d",&n);

  A = (int *)malloc(sizeof(int) * n+1);
  B = (int *)malloc(sizeof(int) * n+1);
  
  for(i = 0 ; i < n ; i++)
    scanf("%d",&A[i+1]);

  for(i = 0 ; i <= K ; i++)
    C[i] = 0;

  for(j = 1 ; j <= n ; j++)
    C[A[j]]++;

  for(i = 1 ; i <= K ; i++)
    C[i] = C[i] + C[i-1];

  for(j = 1 ; j <= n ; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }


  for(i = 1 ; i <= n ; i++){
    printf("%d",B[i]);

    if(i < n) printf(" ");
  }

  printf("\n");


  return 0;
}
  

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

#define MAX_NUM 100000

vector<vector<int> > day2scores(MAX_NUM);


int main() {
  priority_queue<int> q;
  int n, m;
  long long ans = 0;

  cin >> n >> m;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    day2scores[a].push_back(b);
  }

  rep1(i, m) {
    vector<int> todays = day2scores[i];
    for (auto it = todays.begin(); it != todays.end(); it ++) {
      q.push(*it);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    long long a;
    double b;
    cin >> a >> b;
    long long c = b *100 + 0.1;
    cout << a * c/100 << endl;
    return 0;
}


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

int main() {
string s ;
    cin >> s ;
  int N=s.size();
  int A=0;
  int Z=0;
  for (int i=0; i<N; i++){
  if(s[i]=='A'){
  A=i;
    break;
  }
  }
  for (int i=N-1; i>0; i--){
  if(s[i]=='Z'){
  Z=i;
    break;
  }
  }
  cout << Z-A+1 << endl;  
}


Measured memory_bytes: 640