akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
a,b,x = MAP()
if x > a * b * a / 2: #台形
    ans = atan((2 * b - 2 * x / pow(a, 2)) / a) * 180 / pi
    print(ans)
else:
    ans = atan(pow(b, 2) * a / 2 / x) * 180 / pi
    print(ans)


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

using namespace std;

using ll = long long;

int Solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) cin >> a[i];

    int cur = 1;
    for (int i = 0; i <= n; ++i) {
        if (cur == 2) return i;
        cur = a[cur];
    }
    return -1;
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 640
s = gets.chomp.split("").map{|i| i=="R" ? 1 : 0}
n = s.length
ans = [0] * n
sum_sub = [0] * 2

start = 0
now = 0
step = 0
(0..n-1).each do |i|
    sum_sub[step % 2] += 1
    now += 1
    step += 1

    if now == n || (s[start] ^ s[now]) == 1
        if s[start] == 1 #右に向かう集団
            ans[now] += sum_sub[1]
            ans[now-1] += sum_sub[0]
        else
            ans[start-1] += sum_sub[1]
            ans[start] += sum_sub[0]
        end
        
        start = i+1
        now = i+1
        step = 0
        sum_sub = [0] * 2
    end
    break if start >= n
end

puts ans.join(" ")

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

int main() {
  int N, M;
  cin >> N >> M;
  bool map[10][10];
  memset(map, false, sizeof(map));
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    map[a][b] =true; map[b][a] = true;
  }
  
  vector<int> path(N);
  rep(i, N)  path[i] = i;
  
  int count = 0;
  do {
    if (path[0] != 0) continue;
    
//    rep(i, N)  cout << path[i];
    
    rep(i, N-1) {
      int j = path[i+1];
      if (map[path[i]][j] == true) {
        if (i == N-2)  {count++;// rep(k, N) cout << path[k];
                       }
        continue;
      }
      else break;
    }
  } while (next_permutation(path.begin(), path.end()));
  
  
  cout << count << endl;
}
    
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >>a >>b >>c;
  
  if (b >= a*c){
    cout << c << endl;
  }
  else{
    if (b >=a){
      cout << b/a << endl;
    }
      else{
        cout << 0 << endl;
      }
  }
}

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

int main() {
    int N;cin >> N;
    int H[N] = {};
    for (int i = 0;i < N;i++){
        cin >> H[i];
    }
    int M[N] = {};
    M[0] = H[0];
    int sum = 1;
    for (int i = 1;i < N;i++){
        if (H[i] >= M[i - 1]){
            sum++;
            M[i] = H[i];
        }
        else M[i] = M[i - 1];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
N,X,D=map(int,input().split())
r=N*(X!=0)+1
if D:
 f,c,r={},[0]*10**8,0
 for x,y,z in sorted((((N-k)*j+~-k)*k//2+k*X//D,j,k*X%D)for k in range(N+1)for j in[0,2]):
  if c[z]+y<1:
   f[z]=x
  if c[z]<y:
   r+=x-f[z]+1
  c[z]-=y-1
print(r)

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long a, long long b, long long c){
    // a + b + 2(ab)^0.5 < c
    // 2(ab)^0.5 < c - a - b
    // => c - a - b > 0 && 4ab < (c-a-b)^2

    bool yes = c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b);
    cout << (yes ? "Yes" : "No") << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    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: 3640
import math

S = int(input())
p = 0
n = 1

while S - n * 3 >= 0:
  p += math.factorial(S - n * 2 - 1) // (math.factorial(n - 1) * math.factorial(S - n * 3))
  n += 1

print(p % (10 ** 9 + 7))

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    multiset<int> st;
    REP(i, pow(2, n)){
        int s; cin >> s;
        st.insert(s);
    }
    queue<int> q;
    q.push(*st.rbegin());
    st.erase(prev(st.end(), 1));
    while(q.size() != pow(2, n)){
        int p = q.front(); q.pop();
        q.push(p);
        if(st.lower_bound(p) == st. begin()){
            cout << "No" << endl;
            return 0;
        }
        q.push(*prev(st.lower_bound(p), 1));
        st.erase(prev(st.lower_bound(p), 1));
    }
    cout << "Yes" << endl;
}   

Measured memory_bytes: 16936
#include<bits/stdc++.h>
using namespace std;
long long dp[100100][3];
const int M=1e9+7;
int main()
{
	string S;
	cin>>S;
	long long cnt=1;
	for(int i=0;i<S.length();i++)
	{
		if(S[i]=='A')
		{
			dp[i+1][0]=(dp[i][0]+cnt)%M;
			dp[i+1][1]=dp[i][1];
			dp[i+1][2]=dp[i][2];
		}
		if(S[i]=='B')
		{
			dp[i+1][0]=dp[i][0];
			dp[i+1][1]=(dp[i][1]+dp[i][0])%M;
			dp[i+1][2]=dp[i][2];
		}
		if(S[i]=='C')
		{
			dp[i+1][0]=dp[i][0];
			dp[i+1][1]=dp[i][1];
			dp[i+1][2]=(dp[i][2]+dp[i][1])%M;
		}
		if(S[i]=='?')
		{
			dp[i+1][0]=(dp[i][0]*3+cnt)%M;
			dp[i+1][1]=(dp[i][1]*3+dp[i][0])%M;
			dp[i+1][2]=(dp[i][2]*3+dp[i][1])%M;
			cnt=(cnt*3)%M;
		}
	}
	cout<<dp[(int)S.length()][2]<<endl;
	return 0;
}

Measured memory_bytes: 2816
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	switch N % 10 {
	case 0, 1, 6, 8:
		fmt.Println("pon")
	case 3:
		fmt.Println("bon")
	default:
		fmt.Println("hon")
	}
}


Measured memory_bytes: 1756
//shara's here
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
  speed;  
  ll k , sum = 0;
    cin >> k;
    for( ll a = 1; a <= k; a++ ){
    for( ll b = 1; b <= k; b++ ){
    for( ll c = 1; c <= k; c++ ){
        sum+=__gcd((__gcd(a,b)),c);
    }
    }
    }
    cout << sum << endl;




























return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() { 
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  ll n = sz(s);
  ll m = 2<<(n-2);
  ll ans = 0;
  if(n==1){
    cout<<n<<endl;
    return 0;
  }
  rep(i,m){
    bitset<10> b(i);
    ll d = 1;
    ans+=s[0]-'0';
    srep(j,1,n){
      if(b[j-1]==0)d*=10LL;
      else d=1;
      ans+=(s[j]-'0')*d;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
      cin>>a.at(i);
      b.at(i)=a.at(i);
    }
    int max=*max_element(b.begin(),b.end());
    sort(b.begin(),b.end());
    for(int i=0;i<n;i++){
      if(a.at(i)!=max){
        cout<<max<<endl;
      }else{
       cout<<*(----b.end())<<endl;
      }
    }
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = 1000000;
		boolean[] p = new boolean[N + 1];
		for (int i = 2; i <= Math.sqrt(N); i++) {
			if (!p[i]) {
				for (int j = i * 2; j <= N; j += i) {
					p[j] = true;
				}
			}
		}
		int[] map = new int[N + 1];
		int count = 0;
		for (int i = 2; i <= N; i++) {
			if (!p[i]) {
				count++;
			}
			map[i] = count;
		}
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int sum = 0;
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int c = Math.max(a - b, 2);
				int d = Math.min(a + b, 1000000);
				sum+= map[d] -map[c-1];
			}
			System.out.println(sum-n);
		}
	}
}

Measured memory_bytes: 33160
use proconio::{fastout, input};

fn pow5(a: i128) -> i128 {
    a * a * a * a * a
}

#[fastout]
fn main() {
    input! {
        x: i128,
    }
    for i in 0..1000 {
        let a = pow5(i as i128);
        for j in 0..1000 {
            let b = pow5(j as i128);
            if a - b == x {
                println!("{} {}", i, j);
                return;
            }
            if a + b == x {
                println!("{} {}", i, -(j as i128));
                return;
            }
        }
    }
}


Measured memory_bytes: 2156
import numpy as np

def main():
    n, k = map(int, input().split())
    p = [list(map(str, input().split())) for _ in range(n)]
    arr = [[[0]*2 for j in range(k)] for i in range(k)]
    for i in range(n):
        x, y, c = p[i]
        x, y = int(x), int(y)
        mx, my = x%k, y%k
        f = False
        if (x//k)%2 != (y//k)%2:
            f = not f
        if c == "W":
            f = not f
        if f:
            arr[0][0][0] += 1
            arr[mx][0][0] -= 1
            arr[0][my][0] -= 1
            arr[mx][my][0] += 2
        else:
            arr[0][my][0] += 1
            arr[mx][0][0] += 1
            arr[mx][my][0] -= 2
        f = False
        if (x//k)%2 != (y//k)%2:
            f = not f
        if c == "B":
            f = not f
        if f:
            arr[0][0][1] += 1
            arr[mx][0][1] -= 1
            arr[0][my][1] -= 1
            arr[mx][my][1] += 2
        else:
            arr[0][my][1] += 1
            arr[mx][0][1] += 1
            arr[mx][my][1] -= 2
    np_arr = np.array(arr)
    np_arr = np.cumsum(np_arr, axis=0)
    np_arr = np.cumsum(np_arr, axis=1)
    print(int(np.max(np_arr)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 170868
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a(int H){
  if(H==1)
    return 1;
  else
    return a(H/2)*2+1;
}
signed main(){
  int H,i=0;
  cin>>H;
  cout<<a(H)<<endl;
}

Measured memory_bytes: 3572
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	double a, b, x; cin >> a >> b >> x;
	double theta = 0;
	cout << fixed << setprecision(15) ;
	if (x >= ((a * a * b) / 2)) {
		theta = atan((a * a * a) / (2 * (a * a * b - x)));
		theta *= (180 / PI);
		cout << 90 - theta;
	}
	else {
		theta = atan((2 * x ) / (a * b * b));
		theta *= (180 / PI);
		cout << 90 - theta;
	}

	return 0;
}

Measured memory_bytes: 4068
#include <stdio.h>

int main(){

    long long a, b, c;

    scanf("%lld %lld %lld", &a, &b, &c);

    long long res = c-b-a;

    if(res >= 0 && (4 * a * b < res * res)){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	priority_queue<double, vector<double>, greater<double>>q;
	for (int i = 0; i < N; i++)
	{
		int num;
		cin >> num;
		q.push(num);
	}
	while (q.size() != 1)
	{
		double a, b, c;
		a = q.top();
		q.pop();
		b = q.top();
		q.pop();
		c = (a + b) / 2;
		q.push(c);
	}
	cout << q.top();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

Graph G;

void dfs(int u, ll s, vector<int>& vec){
  vec[u]=s;
  for(auto& e : G[u]){
    if(vec[e]!=-1)continue;
    dfs(e, s+1, vec);
  }
}

int main(){
  int n,u,v;cin >> n >> u >> v;
  --u;--v;
  G.resize(n);
  for(int i = 0; i < n-1; ++i){
    int s,t;cin >> s >> t;
    --s;--t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  vector<int> a(n,-1),t(n,-1);
  dfs(u,0,t);
  dfs(v,0,a);
  
  ll ans = 0;
  for(int i = 0; i < n; ++i){
    if(G[i].size()!=1)continue;
    if(a[i]>t[i] && a[i]>ans) ans = a[i];
  }
  cout << ans-1 << endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define push_back(x) push_back(x)
#define ll long long
#define MP make_pair
int main()
{
	
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll j=0;
		ll ans=0;
		while(a>0&&c>0)
		{
			if(j%2==0)
			{
				c=c-b;
				//cout<<"hello"<<endl;
				ans=1;
			}
			else
			{
				a=a-d;
				//cout<<"WLLO"<<endl;
				ans=2;
			}
			j++;

		}
		if(ans==2)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;

}

Measured memory_bytes: 3632
import java.io.BufferedReader

fun main() {
    val br = System.`in`.bufferedReader()
    val n = br.readInt()
    val d = br.readInt().toLong()
    var ct = 0
    repeat(n) {
        val x = br.readInt().toLong()
        val y = br.readInt().toLong()
        if (x * x + y * y <= d * d) {
            ct++
        }
    }
    print(ct)
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

Measured memory_bytes: 38240
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


//1~Nまでの登場回数を考える
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),idx(n+1);
    rep(i,n){
        cin>>a[i];
        idx[a[i]]=i;
    }
    ll ans=0;
    set<ll> used;
    //範囲の幅考えるときに↓の端っこ考えたやつ入れておけば
    //lower_boundでbeginとかendとか出てきても安心
    used.insert(n);used.insert(-1);
    for(int i=1;i<=n;i++){
        auto ite=used.lower_bound(idx[i]);
        auto nxt=ite;
        auto pre=ite;pre--;
        ans+=(*nxt-idx[i])*(idx[i]-*pre)*i;
        used.insert(idx[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12800
N=int(input())
pn=tuple(int(i) for i in input().split())
qn=tuple(int(i) for i in input().split())
l=[]
for i in range(1,N+1):
    l.append(i)
import itertools
ln=list(itertools.permutations(l))
print(abs(ln.index(pn)-ln.index(qn)))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n;
    cin >> n;

    string a, b, c;
    cin >> a >> b >> c;

    int64_t count = 0;
    for (auto i : irange(0L, n)) {
        auto ca = a[i];
        auto cb = b[i];
        auto cc = c[i];

        if (ca == cb && cb == cc) {
            continue;
        }

        count += 2;
        if (ca == cb || cb == cc || cc == ca) {
            --count;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std; 
int main(){
  int a,b,c,d;
  int w,x,y,z;
  cin>>a>>b>>c>>d;
  cin>>w>>x>>y>>z;
  int A=a+b+c+d;
  int B=w+x+y+z;
  if(A>B) cout<<A<<endl;
  else if(A<B) cout<<B<<endl;
  else  cout<<A<<endl;
  
return 0;
}

Measured memory_bytes: 3104
from itertools import product


def state_brute_force(state, count):
    state_list = [state for _ in range(count)]
    for s in product(*state_list):
        yield s


num_switch, num_lamp = map(int, input().split())
switches = [[0] * num_switch for _ in range(num_lamp)]

for n in range(num_lamp):
    i, *s = map(int, input().split())
    for si in s:
        switches[n][si - 1] = 1
condition = list(map(int, input().split()))

ans = 0
for on_off in state_brute_force([0, 1], num_switch):
    lamp_on = 0
    for i, lamp_switch in enumerate(switches):
        on_s = [si & state == 1 for si, state in zip(lamp_switch, on_off)]
        if on_s.count(True) % 2 == condition[i]:
            lamp_on += 1
    if lamp_on == num_lamp:
        ans += 1

print(ans)




Measured memory_bytes: 3064
import sys
import math

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
N = int(X[2])

m = A // B
j = A % B

if N >=B-1:
    print(max(0,m*(B-1)-1+j))
else:
    k = B-N
    print(max(0,j+m*N-math.ceil(j*k/B)))

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

using namespace std;

int main() {

	long n;

	cin >> n;

	vector<vector<long>> h(n + 1,vector<long>(4));

	for (long i = 1; i <= n; i++) {
		cin >> h[i][1] >> h[i][2] >>h[i][3];
	}

	vector<vector<long>> dp(n+2,vector<long>(4));

	/*
	dp[n][1]:nにaを選んだの最大値
	dp[n][2]:nにbを選んだの最大値
	dp[n][3]:nにcを選んだの最大値
	*/

	for (long i = 0; i <= n + 1; i++) {
		for (long j = 1; j <= 3; j++) {
			dp[i][j] = 1000000000;
		}
	}
	
	dp[0][1] = 0; dp[0][2] = 0; dp[0][3] = 0;

	dp[1][1] = h[1][1];
	dp[1][2] = h[1][2];
	dp[1][3] = h[1][3];

	for (long i = 2; i <= n; i++) {
		dp[i][1] = h[i][1] + max(dp[i - 1][2], dp[i - 1][3]);
		dp[i][2] = h[i][2] + max(dp[i - 1][1], dp[i - 1][3]);
		dp[i][3] = h[i][3] + max(dp[i - 1][1], dp[i - 1][2]);
	}

	cout << max(dp[n][1],max(dp[n][2],dp[n][3])) << endl;
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  double angle=90,x=0,y=0,pi=3.141592653589793;
  int d,a;
  while(cin >> s){
    if(s=="0,0"){
      cout << (int)x << endl << (int)y << endl;
      return 0;
    }
    for(int i=0;i<s.size();i++){
      if(s[i]==','){
        string ss=s.substr(0,i),tt=s.substr(i+1,s.size()-i-1);
        d=atoi(ss.c_str()),a=atoi(tt.c_str());
      }
    }
    x+=cos(pi*(angle)/180)*(double)d;
    y+=sin(pi*(angle/180))*(double)d;
    angle-=(double)a;
  }
  return 0;
}



Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;
ll i;

int main(){
    string s;
    cin>>s;
    if(s.at(4)==s.at(5)&&s.at(3)==s.at(2))cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}


Measured memory_bytes: 256
import sys
import heapq
input = sys.stdin.readline


def dijkstra(s, E):
    inf = float('inf')
    d = [inf for i in range(len(E))]
    d[s] = 0
    q = [(0, s)]
    while q:
        c, p = heapq.heappop(q)
        if d[p] < c:
            continue
        for cost, to in E[p]:
            if d[to] > d[p] + cost:
                d[to] = d[p] + cost
                heapq.heappush(q, (d[to], to))
    return d


def main():
    N, M = map(int, input().split())
    E = [[] for _ in range(N)]
    for _ in range(M):
        s, t, c = map(int, input().split())
        E[s-1].append((c, t-1))
    for i in range(N-1):
        E[i+1].append((0, i))

    A = dijkstra(0, E)

    ans = A[N-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 79024
import java.io.*;
import java.util.*;

public class Main {

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public float nextFloat() {
            return Float.parseFloat(next());
        }

    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    /** CHECKLIST:
     * LIMITS (DOES BRUTE FORCE WORK?)
     * CHECK ALL PARAMETERS
     * INT VS LONG
     */
    public static void main(String[] args) {
        int n = r.nextInt(); // number of items
        int w = r.nextInt(); // max capacity
        long[] weights = new long[n+1];
        long[] values = new long[n+1];
        for(int i = 1; i <= n; i++){
            weights[i] = r.nextLong();
            values[i] = r.nextLong();
        }
        long[][] dp = new long[n+1][w+1];
        for(int i = 1; i <= n; i++){ // using only the first i items
            for(int j = 0; j <= w; j++){ // max weight j
                if(weights[i] > j){
                    dp[i][j] = dp[i-1][j];
                } else{
                    dp[i][j] = Math.max(dp[i-1][j], dp[i-1][(int)(j-weights[i])] + values[i]);
                }
            }
        }
        long max = 0;
        for(int j = 0; j <= w; j++){
            max = Math.max(max, dp[n][j]);
        }
        pw.println(max);

        pw.close();
    }
}

/**
                _        _                 _                                                
               | |      | |               | |                                               
   ___ ___   __| | ___  | |__  _   _    __| | __ _ _ __ _ __ ___ _ __     _   _  __ _  ___  
  / __/ _ \ / _` |/ _ \ | '_ \| | | |  / _` |/ _` | '__| '__/ _ \ '_ \   | | | |/ _` |/ _ \ 
 | (_| (_) | (_| |  __/ | |_) | |_| | | (_| | (_| | |  | | |  __/ | | |  | |_| | (_| | (_) |
  \___\___/ \__,_|\___| |_.__/ \__, |  \__,_|\__,_|_|  |_|  \___|_| |_|   \__, |\__,_|\___/ 
                                __/ |                               ______ __/ |            
                               |___/                               |______|___/             
 */

Measured memory_bytes: 126420
import sys
sys.setrecursionlimit(300000)
from bisect import bisect_left

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


# 区間updateと要素クエリ
class SegmentTree(object):

    def __init__(self, n, ele, segfun):
        self.ide_ele = ele
        self.segfun = segfun
        self.n = n
        self.N0 = 1 << n.bit_length()
        self.data = [self.ide_ele] * (self.N0 * 2)

    def update(self, l, r, val):
        l += self.N0
        r += self.N0
        while l < r:
            if l & 1:
                self.data[l] = self.segfun(self.data[l], val)
                l += 1
            if r & 1:
                self.data[r - 1] = self.segfun(self.data[r - 1], val)
                r -= 1
            l //= 2
            r //= 2

    def query(self, i):
        i += len(self.data) // 2
        ret = self.data[i]
        while i > 0:
            i //= 2
            ret = self.segfun(ret, self.data[i])
        return ret

N, Q = MI()
STX = [tuple(MI()) for _ in range(N)]
D = [I() for _ in range(Q)]

seg = SegmentTree(Q, INF, min)
for S, T, X in STX:
    # [S - X, T - X) に出発する人(l番目の人からr番目の人まで)が影響を受ける
    l = bisect_left(D, S - X)
    r = bisect_left(D, T - X)
    seg.update(l, r, X)

for i in range(Q):
    ans = seg.query(i)
    if ans == INF:
        print(-1)
    else:
        print(ans)

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

remainder = N // K
N = N - K*remainder

if N == 0:
    print(N)
    exit();

abc = abs(N-K)

for i in range(10**18):
    N = abc
    abc = abs(N-K)
    if N + abc == K and abc < N:
        break;

print(abc)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

struct pnt{
    int cost, y, x;
};

vector<vector<int>> mv={{1,0},{-1,0},{0,1},{0,-1}};

int dist[1002][1002];
int bfs(queue<pnt> &que, vector<vector<char>> &mat){
    for(int i=0; i<1002; i++){
        for(int j=0; j<1002; j++){
            dist[i][j]=-1;
        }
    }

    while((int)que.size()>0){
        pnt p=que.front();
        que.pop();
        if(dist[p.y][p.x]>=0){
            continue;
        }
        dist[p.y][p.x]=p.cost;

        for(auto &m:mv){
            if(mat[p.y+m[0]][p.x+m[1]]=='.'){
                que.push({p.cost+1,p.y+m[0],p.x+m[1]});
            }
        }
    }

    int ans=0;
    for(int i=0; i<1002; i++){
        for(int j=0; j<1002; j++){
            ans=max(ans,dist[i][j]);
        }
    }
    return ans;
}

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> mat(H+2,vector<char>(W+2,'@'));
    
    queue<pnt> que;
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            cin >> mat[i][j];
            if(mat[i][j]=='#'){
                que.push({0,i,j});
            }
        }
    }

    cout << bfs(que, mat) << endl;

}

Measured memory_bytes: 23760
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
const int tree_size = (1 << 19);
int n;
vector<int>a, p;
vector<int> mx(tree_size, -2e18);

int get_max(int v, int l, int r, int L, int R) { // l , r - границы L,R запрос
    // если не перес
    // полуинтервал
    if(R <= l || L >= r)
        return -2e18;
    if(L <= l && r <= R)
        return mx[v];
    int m = (r + l)/2;
    return max(
                get_max(2*v+1, l, m, L, R),
                get_max(2*v+2, m, r, L, R)
              );
}

void relax(int v, int l, int r, int i, int x) {
    mx[v] = max(mx[v], x);
    if (r-l==1)
        return;
    int m = (l + r)/2;
    if(i < m)
        relax(2*v+1, l , m, i , x);
    else
        relax(2 * v + 2, m, r, i, x);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    p.resize(n);
    forn(i, n)
        cin >> a[i];
    forn(i, n)
        cin >> p[i];
    vector<int>b=a;
    sort(b.begin(),b.end());
    map<int,int>m;
    forn(i, n)
        m[b[i]]=i;
    forn(i, n)
        a[i]=m[a[i]];
    int ans = 0;
    forn(i, n)
    {
        int cur = max(get_max(0, 0, n, 0, a[i]), 0ll) + p[i];
        ans = max(ans, cur);
        relax(0, 0, n, a[i], cur);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24568
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define SZ(x) ((int)(x).size())
#define ll long long
#define int ll
#define el '\n'
template<class T> bool inline rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool inline rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);

vv<bool> dp(1000000+10, false);
dp[0]=true;
for(int i=0;i+105<SZ(dp);++i){
	if(!dp[i]) continue;
	for(int j: {100, 101, 102, 103, 104, 105}){
		dp[i+j]=true;
	}
}
int n; cin>>n;
cout<<dp[n]<<el;

return 0;
}


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

using namespace std;

int main(){
    long long n, m;
    cin >> n >> m;
    vector<long long>dmg;
    long long maxdmg = 0, garbo = 0;
    for(long long i = 0; i < n; ++i){
        long long tmp, tmp1; cin >> tmp >> tmp1;
        dmg.push_back(tmp1);
        if(tmp > maxdmg)maxdmg = tmp;
    }
    long long i = 0;
    sort(dmg.begin(), dmg.end(), greater<long long>());
    for(auto x:dmg){
        if(x > maxdmg){
         garbo += x, ++i;
         if(garbo >= m){
            cout << i;
            return 0;
         }
        }
    }
    cout << i + (int)ceil((double)(m - garbo) / (double)maxdmg);
    return 0;
}


Measured memory_bytes: 1400
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    int A, B; cin >> A >> B;
    int ans = 0;
    ans += ((A > B) ? A : B);
    if (A > B) A--;
    else B--;
    ans += ((A > B) ? A : B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(Args: Array<String>) {
    val List = readLine()!!
    val S1 = List[0]
    val S2 = List[1]
    val S3 = List[2]
    val S4 = List[3]
    if(S1 == S2 || S2 == S3 || S3 == S4) {
        println("Bad")
    } else {
        println("Good")
    }
}

Measured memory_bytes: 30024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	char s[10]={};
	scanf("%s",&s);
	bool bo[10]={};
	for(int i=0;i<strlen(s);i++)
		bo[s[i]-'a']=1;
	for(char i='a';i<='c';i++)
		if(!bo[i-'a']) {
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
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); }


int main() {
    int A,B;
    int ans=0;
    cin>>A>>B;
    if((A+B)%2==1){Out("IMPOSSIBLE");return 0;}
    ans=(A+B)/2;

    Out(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define MOD 1000000007
const int64_t INF = 1e18;
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

i64 N, K; cin >> N >> K;
VI A(N); invec(A);
sort(ALL(A));

i64 ok = INF+1, ng = -INF-1;
while(ok - ng > 1){
    i64 m = (ok + ng) / 2;
    bool judge = [&]{
        i64 tot = 0;
        rep(i, 0, N){
            if (A[i] < 0){
                int ok1 = N, ng1 = -1;
                while (ok1 - ng1 > 1){
                    int m1 = (ok1 + ng1) / 2;
                    if (A[m1] * A[i] < m) ok1 = m1; else ng1 = m1;
                }
                tot += N - ok1;
            }
            else {
                int ok1 = N, ng1 = -1;
                while (ok1 - ng1 > 1){
                    int m1 = (ok1 + ng1) / 2;
                    if (A[m1] * A[i] < m) ng1 = m1; else ok1 = m1;
                }
                tot += ok1;
            }
            if (A[i] * A[i] < m) --tot;
        }
        tot /= 2;
        return tot < K;
    }();
    if (judge) ng = m; else ok = m;
}
cout << ng << "\n";
return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
 
const ULL M = 998244353;

struct RQ {
 using RQV = ULL;
 struct RQRV{ ULL b,c; };
 static RQV Zero(){ return 0; }
 static RQRV RZero(){ return { 1,0 }; }
 // addition
 static RQV f(RQV a,RQV b){ return (a+b) % M; }
 // update function
 static void uf(RQV& a,RQV b){ a = b; }
 // effect of range queries n-sized
 static void ef(RQV& a,RQRV b,int n){ a = (b.b*a + b.c*n) % M; }
 // range query update
 static void ruf(RQRV& a,RQRV b){
  a.b = (a.b * b.b) % M; 
  a.c = (a.c * b.b + b.c) % M;
 }
 // comparation
 static bool cmp(RQV l,RQV r){ return l<=r; }
 struct Node{
  RQV v; RQRV r;
 };
 int N;
 vector<Node> V;

 void init(int n){
  N=1; while (N<n) N*=2;
  V.assign(N*2,{Zero(),RZero()});
 }

 void spread(int i,int z){
  ef(V[i].v,V[i].r,z);
  if (z!=1) {
   ruf(V[i*2].r,V[i].r);
   ruf(V[i*2+1].r,V[i].r);
  }
  V[i].r = RZero();
 }

 void upd(int p,RQV v){
  for(int d=N; d>=1; d/=2) spread(p/d,d);
  p+=N; uf(V[p].v,v);
  int z=1;
  while(p!=1){
   p/=2; z*=2;
   V[p].v = f(V[p*2].v,V[p*2+1].v);
   ef(V[p].v,V[p].r,z);
  }
 }

 void updr(int l,int r,RQRV v,int a=0,int b=0,int i=-1){
  if(i==-1){ a=0; b=N; i=1; }
  spread(i,b-a);
  if(r<=a || b<=l) return;
  else if(l<=a && b<=r){ ruf(V[i].r,v); spread(i,b-a); return; }
  updr(l,r,v,a,(a+b)/2,i*2);
  updr(l,r,v,(a+b)/2,b,i*2+1);
  V[i].v = f(V[i*2].v,V[i*2+1].v);
 }

 RQV query(int l,int r,int a=0,int b=0,int i=-1){
  if(i==-1){ a=0; b=N; i=1; }
  if(r<=a || b<=l) return Zero();
  spread(i,b-a);
  if(l<=a && b<=r) return V[i].v;
  RQV q1 = query(l,r,a,(a+b)/2,i*2);
  RQV q2 = query(l,r,(a+b)/2,b,i*2+1);
  q1 = f(q1,q2);
  ef(q1,V[i].r,min(r,b)-max(l,a));
  return q1;
 }

 int find(int l,RQV v,int a=0,int b=0,int i=-1){
  static RQV x;
  if(i==-1){ a=0; b=N; i=1; x=Zero(); }
  spread(i,b-a);
  if(b<=l) return N;
  if(l<=a && !cmp(v,f(x,V[i].v))){ x=f(x,V[i].v); return N; }
  if(b-a==1) return a;
  int q1 = find(l,v,a,(a+b)/2,i*2);
  if(q1!=N) return q1;
  return find(l,v,(a+b)/2,b,i*2+1);
 }
};

int N,Q;
RQ G;
 
int main(){
 scanf("%d%d",&N,&Q);
 G.init(N);
 rep(i,N){
  int a; scanf("%d",&a);
  G.upd(i,a);
 }
 rep(q,Q){
  int c; scanf("%d",&c);
  if(c==0){
   int l,r,b,c; scanf("%d%d%d%d",&l,&r,&b,&c);
   G.updr(l,r,{(ULL)b,(ULL)c});
  }
  if(c==1){
   int l,r; scanf("%d%d",&l,&r);
   printf("%llu\n",G.query(l,r));
  }
 }
 
 return 0;
}

Measured memory_bytes: 27744
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define mod 1000000007
using namespace std;

int main()
{
    ll t=1;
    //cin>>t;
    
    while(t--)
    {
        ll n, k;
        cin>>n>>k;
        
        vector<ll> arr(n);
        for(ll i=0; i<n; i++)
        {
            cin>>arr[i];
        }
        
        ll dp[n+1];
        
        dp[0] = 0;
        
        for(ll i=1; i<n; i++)
        {
            dp[i] = INT_MAX;
            for(ll j=i-1; j >= 0 && j>=(i-k); j--)
            {
                dp[i] = min(dp[i], dp[j] + abs(arr[i]-arr[j]));
            }
        }
        
        cout<<dp[n-1]<<endl;
    }
    return 0;
}

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

int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

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

    bool flag = true;
    rep(i, N - 1) if (A[i] == A[i + 1])
        flag = false;

    flag ? cout << "YES" : cout << "NO";

    cout << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    cin >> a[0];
    int vmax=a[0],vmin=a[0],ans=-1e9;
    for(int i=1;i<n;i++){
        cin >> a[i];
        if(vmax <= a[i]){
            vmax = a[i];
            ans = max(ans,vmax-vmin);
        }else if(vmin >= a[i]){
            ans = max(ans, a[i]-vmin);
            vmin = a[i];
            vmax =a[i];
        }
    }
    cout <<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

vector<vector<ll>>G;
ll dp[100100];

ll rec(ll v){
  if(dp[v]!=-1)return dp[v];

  ll res=0;
  for(auto nv:G[v])chmax(res,rec(nv)+1);

  return dp[v]=res;
}

int main(){

  ll n,m;cin>>n>>m;
  G.assign(n,vector<ll>());
  rep(i,0,m){
    ll a,b;cin>>a>>b;
    G[--a].push_back(--b);
  }

  CLR(dp,-1);

  ll ans=0;
  rep(v,0,n)chmax(ans,rec(v));
  
  out(ans);

  return 0;
}


Measured memory_bytes: 8576