akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

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

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }

    if (n != 1) res[n] = 1;

    return res;
}

int main() {
    INIT;

    ll N;
    cin >> N;

    map<ll, ll> res;

    reps(i, 1, N + 1) {
        map<ll, ll> tmp = prime_factor(i);
        // cout << "--- " << i << " ---" << endl;

        for (auto e : tmp) {
            res[e.first] += e.second;
            // cout << e.first << ": " << e.second << endl;
        }
        // cout << "*" << endl;

        // for (auto e : res) {
        //     cout << e.first << ": " << e.second << endl;
        // }
    }

    mint ans(1);

    for (auto e : res) {
        ans *= (e.second + 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

import javax.sql.rowset.serial.SerialArray;

public class Main {

		public static void main(String[] args){
			
			Scanner sc = new Scanner(System.in);

			
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();

			int ans = 0;
			ans = Math.abs(a - c) ;
			if(ans <= d){
			    System.out.println("Yes");
			    return ;
			}
			
			int ans2 = Math.abs(a - b) ;
			
			int ans3 = Math.abs(c - b) ;
			
			if((ans2 <= d ) & (ans3 <= d )) {
			    System.out.println("Yes");
			    return ;
			}

		    System.out.println("No");
		    return ;
		}
}


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

vector<vector<int> > arr;

void display(int n){
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 10; j++){
      cout << arr[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}

bool dfs(int n, int i, int left, int right){
  if(i == 10) return true;

  bool ans = false;
  if(left < arr[n][i]) ans = dfs(n, i + 1, arr[n][i], right);
  if(right < arr[n][i]) ans = dfs(n, i + 1, left, arr[n][i]);

  return ans;
  
}

int main(){
  int n;
  cin >> n;
  arr.resize(n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 10; j++){
      int tmp;
      cin >> tmp;
      arr[i].push_back(tmp);
    }
  }

  //display(n);

  for(int i = 0; i < n; i++){
	bool ans = dfs(i, 0, 0, 0);
	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3008
import java.io.*;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
	
	Scanner sc=new Scanner(System.in);
	
	int N=sc.nextInt();
	int ar[]=new int[N];
	for (int i = 0; i < N; i++) {
	    ar[i]=sc.nextInt();
	}
	int ans=0;
	for (int i = 0; i < N; i++) {
	    
	    if (ar[ar[i]-1]==i+1) {
		
		ans++;
	    }
	}
	System.out.println(ans/2);
	
    }


 
    
    
}


Measured memory_bytes: 32680
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int S;
    cin >> S;
    int h=S/3600;
    int m=S/60%60;
    int s=S%60;
    cout << h<<":"<<m<<":"<<s<<endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/



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

int main(){
    int n;
    cin>>n;
    vector<vector<pair<int,int>>> v(n,vector<pair<int,int>>());
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        for(int j=0;j<a;j++){
            int x,y;
            cin>>x>>y;
            x--;
            v[i].push_back(make_pair(x,y));
        }
    }

    int ans=0;
    for(int i=0;i<(1<<n);i++){
        vector<int> d(n,0);
        int cnt=0;
        bool ok=true;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                d[j]=1;
                cnt++;
            }
        }
        for(int j=0;j<n;j++){
            if(d[j]){
                for(auto k : v[j]){
                    if(k.second!=d[k.first]) ok=false;
                }
            }
        }
        if(ok) ans=max(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int k;
    scanf("%d",&k);
    if (k % 2 == 0) {
        printf("%d\n",k * k / 4);
    } else {
        printf("%d\n",(k - 1) * (k + 1) / 4);
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    vector<vector<int>> tree;
    vector<pair<int, int>> edge;
    vector<int> dig;
    vector<int> c;
    vector<int> label;


    void input() {
        cin >> N;
        dig.resize(N);
        tree.resize(N);
        c.resize(N);
        label.resize(N, -1);
        rep(i, 0, N - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            edge.emplace_back(a, b);
            tree[a].push_back(b);
            tree[b].push_back(a);
            dig[a]++;
            dig[b]++;
        }
        rep(i, 0, N) {
            cin >> c[i];
        }
    }

    void solve() {
        input();


        queue<int> que;
        for (int i = 0; i < N; ++i) {
            if (dig[i] == 1) {
                que.push(i);
            }
        }

        int idx = 0;
        sort(all(c));


        while (!que.empty()) {
            int top = que.front();
            que.pop();
            if (label[top] == -1) {
                label[top] = c[idx++];
            }
            for (auto e : tree[top]) {
                dig[e]--;
                if (dig[e] == 1) {
                    que.push(e);
                }
            }
        }

        ll M = 0;
        for (auto e : edge) {
            M += min(label[e.first], label[e.second]);
        }

        cout << M << endl;
        for (auto e : label) {
            cout << e << " ";
        }
        cout << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1272
from functools import lru_cache

n, a = int(input()), list(map(int, input().split()))

@lru_cache(maxsize=None)
def f(x, y, l, r):
    if r - l + 1 <= 2:
        return 0
    return min(a[i] * (x + y) + f(x, x + y, l, i) + f(x + y, y, i, r) for i in range(l + 1 , r))

print(a[0] + a[-1] + f(1, 1, 0, n - 1))

Measured memory_bytes: 126876
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
const int maxn = 100000 + 5;
typedef long long int64;
int n, m;
vector<int> adj[maxn];
int visited[maxn];
int color[maxn];

int64 solve()
{
  fill(visited, visited+n+1, 0);
  int64 sp = 0;
  int64 p2 = 0;
  int64 pc = 0;
  for (int i = 1; i <= n; ++i) if (visited[i] == 0)
  {
    visited[i] = 1;
    color[i] = 0;
    queue<int> q;
    q.push(i);
    int mixed = 0;
    int cnt = 0;
    while (!q.empty())
    {
      int curr = q.front(); q.pop();
      ++cnt;
      for (auto& next: adj[curr])
      {
        if (visited[next]) mixed |= color[curr] == color[next];
        else color[next] = color[curr] ^ 1, visited[next] = 1, q.push(next);
      }
    }
    if (cnt == 1) ++sp;
    else if (mixed) ++pc;
    else ++p2;
  }
  int64 ans = 0;
  ans += sp * n * 2 - sp - sp * (sp - 1);
  ans += 2 * p2 + pc;
  ans += 2 * p2 * (p2 - 1);
  ans += pc * (pc - 1);
  ans += 2 * p2 * pc;
  // cout << sp << " " << p2 << " " << pc << endl;
  return ans;
}

int64 bf()
{
  int64 ans = 0;
  set<pair<int, int>> st;
  for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j)
  if (st.count({i, j}) == 0)
  {
    pair<int, int> now{i, j};
    queue<pair<int, int>> q;
    q.push(now);
    st.insert(now);
    ++ans;
    while (!q.empty())
    {
      auto curr = q.front(); q.pop();
      for (auto& a: adj[curr.first]) for (auto& b: adj[curr.second]) if (st.count({a, b}) == 0)
      {
        st.insert({a,b}); q.push({a,b});
      }
    }
  }
  return ans;
}

int main()
{
  while (scanf("%d%d", &n, &m) == 2)
  {
    for (int i = 0; i < m; ++i)
    {
      int u, v; scanf("%d%d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    cout << solve() << endl;
    // cerr << bf() << endl;
    for (int i = 1; i <= n; ++i) adj[i].clear();
  }
  return 0;
}

Measured memory_bytes: 7680
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<sstream>
#include<numeric>
#include<queue>
#include<cstdio>
#include<iterator>
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb(x) push_back(x)
ll mod = 1e9 + 7;
ll inf = 1e9 + 7;
template<typename T, typename U>
T binpow(T a, U n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return (binpow(a, n - 1) * a) % mod;
    else {
        ll b = binpow(a, n / 2) % mod;
        return (b * b) % mod;
    }
}
template<typename T>
T gcd(T a, T b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
template<typename T>
istream& operator>>(istream& str, vector<T>& vec) {
    for (auto& w : vec) str >> w;
    return str;
}
template<typename T>
ostream& operator<<(ostream& str, vector<T>& vec) {
    for (auto& w : vec) str << w << ' ';
    return str;
}
 
 
 
 
 
int main() {
    ll h, w, ch, cw, dh, dw, m;
    cin >> h >> w >> m;
    /*vector<vector<ll>>vec(h, vector<ll>(w, inf));
    vector<vector<bool>> mapp(h, vector<bool>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char c;
            cin >> c;
            if (c == '.')mapp[i][j] = 1;
        }
    }
    for(int i )*/
    vector<int> cols(w), rows(h);
    vector <pair<int, int>>tg(m);
    set<pair<int, int>>mn;
    for (int i = 0; i < m; ++i) {
        cin >> tg[i].first >> tg[i].second;
        mn.insert(tg[i]);
        rows[tg[i].first - 1]++;
        cols[tg[i].second - 1]++;
    }
    int maxcol = max_element(all(cols)) - cols.begin();
    int maxrow = max_element(all(rows)) - rows.begin();
    vector<int>irow, icol;
    for (int i = 0; i < rows.size(); ++i) {
        if (rows[i] == rows[maxrow])irow.push_back(i);
    }
    for (int i = 0; i < cols.size(); ++i) {
        if (cols[i] == cols[maxcol])icol.push_back(i);
    }
    bool flag = false;
    for (int i = 0; i < irow.size(); ++i) {
        for (int j = 0; j < icol.size(); ++j) {
            if (mn.count({ irow[i] + 1 ,icol[j] + 1 }) == 0) {
                flag = true;
                break;
            }
        }
    }
    if (!flag) {
        cout << cols[maxcol] + rows[maxrow] - 1;
    }
    else {
        cout << cols[maxcol] + rows[maxrow];
    }
 
}

Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    string s;cin>>s;
    int mx=0,tmp=0;
    rep(i, s.size()){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')tmp++;
        else{mx = max(mx, tmp);tmp=0;}
    }
    mx = max(mx,tmp);
    co(mx);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,x;
  cin>>N>>x;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int i=0;
  for(;i<N;i++){
    x-=a[i];
    if(x<0){
      cout<<i<<endl;
      return 0;
    }
    if(x==0){
      cout<<i+1<<endl;
      return 0;
    }
  }
  if(x==0){
    cout<<i<<endl;
  }
  if(x>0){
    cout<<i-1<<endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a>=1&&b>=1&&c>=1&&d>=1&&a<=100&&b<=100&&c<=100&&d<=100)
    {
        while(a>0&&c>0)
        {
            c=c-b;
            if(c<=0)
            {
                cout<<"Yes"<<endl;
            }
            else
            {
                a=a-d;
                if(a<=0)
                {
                    cout<<"No"<<endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    int e = 0;
    rep(i,n) e += (s[i]=='E');

    int ans = n-1;
    int w = 0;
    rep(i,n){
        e -= (s[i]=='E');
        ans = min(ans, e+w);
        w += (s[i]=='W');
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

const int N = 1e6;


int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n ;
    cin >> n;
    vector <int> v;

    while(n){
        int t = n % 26;
        if(t==0) v.push_back(26 - 1),n--; 
        else  v.push_back(t - 1); 
        n/=26;
    } 
    reverse(v.begin() , v.end());
    for(auto x : v ) cout << (char) (x + 'a');

    return 0;
}



Measured memory_bytes: 3648
/*
 * author :Sadik Hassan(_sad_)
 *
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)2e5+5;
const int MOD =(int)1e9+7;
const ll INF = (ll)1e18+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    vi a(n);
    ll ans=0;
    rep(i,n)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ini2(n,m) scanf("%d%d",&n,&m)
#define inl2(n,m) scanf("%lld%lld",&n,&m)
#define prnti(n) printf("%d",n)
#define prnti2(n, m) printf("%d %d",n,m)
#define prntl(n) printf("%lld",n)
#define prntl2(n, m) printf("%lld %lld",n,m)
#define SP() printf(" ")
#define NL() printf("\n")
int main()
{
    int n,m;
    cin >> n >> m;
    ll sum =0;
    for(int i=0;i<m;i++)
    {
        int k;
        cin >> k ;
      sum += k;
    }
    if(sum>n) cout << -1 <<endl;
    else cout << n - sum << endl;
    return 0;
}


Measured memory_bytes: 3592
def inv_gcd(a,b):
    a=a%b
    if a==0:
        return (b,0)
    s=b;t=a
    m0=0;m1=1
    while(t):
        u=s//t
        s-=t*u
        m0-=m1*u
        s,t=t,s
        m0,m1=m1,m0
    if m0<0:
        m0+=b//s
    return (s,m0)
def inv_mod(x,m):
    assert 1<=m
    z=inv_gcd(x,m)
    assert z[0]==1
    return z[1]
def crt(r,m):
    assert len(r)==len(m)
    n=len(r)
    r0=0;m0=1
    for i in range(n):
        assert 1<=m[i]
        r1=r[i]%m[i]
        m1=m[i]
        if m0<m1:
            r0,r1=r1,r0
            m0,m1=m1,m0
        if (m0%m1==0):
            if (r0%m1!=r1):
                return (0,0)
            continue
        g,im=inv_gcd(m0,m1)
        u1=m1//g
        if ((r1-r0)%g):
            return (0,0)
        x=(r1-r0)//g % u1*im%u1
        r0+=x*m0
        m0*=u1
        if r0<0:
            r0+=m0
    return (r0,m0)
N=int(input())
def divide(n):
    res=[]
    i=1
    while(i*i<=n):
        if n%i==0:
            res.append(i)
            if i*i!=n:
                res.append(n//i)
        i+=1
    return res
ans=2*N
for b in divide(2*N):
    c=(2*N)//b
    tmp=crt([0,c-1],[b,c])
    if tmp==(0,0):
        continue
    x=tmp[0]
    if x==0:
        x=tmp[1]
    ans=min(x,ans)
print(ans)

Measured memory_bytes: 69672
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

bool ifwar(int war1[], int war2[], int N, int M, int X, int Y){
  for(int i = X + 1; i <= Y; i++){
    if( (*max_element(war1, war1 + N) < i) && (*min_element(war2, war2 + M) >= i) ){
      return true;
    }
  }
  return false;
}

int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  int war1[N];
  int war2[M];
  for(int i = 0; i < N; i++){
    cin >> war1[i];
  }
  for(int i = 0; i < M; i++){
    cin >> war2[i];
  }

  bool war = ifwar(war1, war2, N, M, X, Y);
  if(war){
    cout << "No War" << endl;
  } else if(!war){
    cout << "War" << endl;
  }

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N=sc.nextInt();
        long[] A=new long[N];
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
        }
        long[] x=new long[N];//山の雨;
        x[0]=2*A[0];
        for(int i=1;i<N;i++){
            x[i]=(A[i-1]-x[i-1]/2)*2;

        }
        long sub=((x[0]+x[N-1])/2-A[N-1])/2;
        for(int i=0;i<N;i++){
            if(i%2==0){
                System.out.println(x[i]-sub*2);
            }else{
                System.out.println(x[i]+sub*2);

            }
        }


    }
}


Measured memory_bytes: 85740
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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

int main()
{
    int d;
    cin >> d;
    int c[30]={}, last[30]={}, s[400][30]={}, v = 0;
    rep(i, 26)
            cin >>
        c[i];

    rep(i, d) rep(j, 26)
            cin >>
        s[i][j];

    rep(i, 26)
        last[i] = 0;

    rep(i, d)
    {
        int t;
        cin >> t;
        t--;

        v += s[i][t];
        last[t] = i + 1;

        rep(j, 26)
        {
            if (j == t)
                continue;
            v -= c[j] * (i + 1 - last[j]);
        }
        cout << v << endl;
    }

    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
  int i,k,n;
  string s1,s2;
  int d1[82],d2[82],d3[82];
  cin >> n;
  for( k=0; k<n; k++ ){
    cin >> s1 >> s2;
    if( s1.size() > 80 || s2.size() > 80 ){
      cout << "overflow" << endl;
      continue;
    }
    for( i=0; i<s1.size(); i++ ) d1[i] = s1[s1.size()-i-1] - '0';
    for( i=s1.size(); i<80; i++ ) d1[i] = 0;
    for( i=0; i<s2.size(); i++ ) d2[i] = s2[s2.size()-i-1] - '0';
    for( i=s2.size(); i<80; i++ ) d2[i] = 0;
    d3[0]=0;
    for( i=0; i<80; i++ ){
      d3[i] += d1[i] + d2[i];
      if( d3[i] >= 10 ){ d3[i] %= 10; d3[i+1]=1; }
      else d3[i+1]=0;
    }
    i=80;
    if( d3[i] > 0 ){
      cout << "overflow" << endl;
      continue;
    }
    while( i > 0 && d3[--i] == 0 )
      ;
    while( i >= 0 ) cout << d3[i--];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){    
// Your code here!    
int a, b, c;    
scanf("%d %d %d",&a,&b,&c);    
if(a<b&&b<c){        
printf("Yes\n");    
}    
else {        
printf("No\n");    
}    
return 0;    
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<cstdint>

int const MAXA = 1e5;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::vector<int> nA(MAXA+1, 0);
  int N; std::cin >> N;
  int64_t sum = 0;
  for(int i = 0; i < N; ++i) {
    int a; std::cin >> a;
    sum += a;
    ++nA[a];
  }
  int Q; std::cin >> Q;
  for(int q = 0; q < Q; ++q) {
    int B, C; std::cin >> B >> C;
    int64_t nB = nA[B];
    sum += nB * (C-B);
    std::cout << sum << "\n";
    nA[B] = 0;
    nA[C] += nB;
  }
  return 0;
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  string a,b,c;
  cin >> a >> b >> c;

  printf("A%cC\n", b[0]);
  
  return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class UnionFind:
    __slots__ = ["N", "group_count", "root", "rank"]
    def __init__(self, N): self.N, self.group_count, self.root, self.rank = N, N, [-1] * N, [0] * N
    def __repr__(self): return str(self.all_groups())

    def find(self, x):
        while self.root[x] >= 0: x = self.root[x]
        return x

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return
        if self.rank[x] > self.rank[y]: x, y = y, x
        self.root[y] += self.root[x]
        self.root[x] = y
        if self.rank[x] == self.rank[y]: self.rank[y] += 1
        self.group_count -= 1

    def same(self, x, y): return self.find(x) == self.find(y)
    def count(self, x): return -self.root[self.find(x)]
    def members(self, x): return [i for i in range(self.N) if self.same(x, i)]
    def roots(self): return [i for i, x in enumerate(self.root) if x < 0]
    def all_groups(self):
        d = defaultdict(lambda: [])
        for i in range(self.N): d[self.find(i)].append(i)
        return dict(d)


def main():
    N, Q = LI()
    TUV = LIR(Q)

    uf = UnionFind(N)

    for t, u, v in TUV:
        if t == 0:
            uf.union(u, v)
        else:
            print(int(uf.same(u, v)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 44948
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<double, ll> pdl;

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready, resolve
    int H,N;
    cin >> H >> N;
    vector<int> AList;
    vector<int> BList;
    AList.resize(N);
    BList.resize(N);
    for (int i=0; i<N; i++) {
        int a,b;
        cin >> AList.at(i);
        cin >> BList.at(i);
    }

    ll dp[(int)2e4];
    for (int i=0; i<2e4; i++) dp[i] = LLONG_MAX;
    //memset(dp, LLONG_MAX, sizeof(dp));
    dp[0] = 0;
    for (int i=0; i<N; i++) {
        for (int j=0; j<=1e4-AList[i]; j++) {
            if(dp[j] != LLONG_MAX ) dp[j+AList[i]] = min(dp[j] + BList[i],dp[j+AList[i]]) ;
        }
    }

    ll ans = LLONG_MAX;
    for(int i=H; i<2e4; i++) {
        ans = min(ans, dp[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
def main():
    H, W = (int(_) for _ in input().split())
    N = int(input())
    A = [int(_) for _ in input().split()]
    lst = []
    for i, a in enumerate(A, 1):
        lst += [i] * a
    for i in range(H):
        x = lst[i*W:(i+1)*W] if i%2 == 0 else lst[i*W:(i+1)*W][::-1]
        print(*x)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int k,x;
int main()
{
	scanf("%d%d",&k,&x);
	for (int i=x-k+1;i<x+k-1;i++) printf("%d ",i);
	printf("%d",x+k-1);
	return 0;
}

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

using namespace std;

#define MOD 1000000007

int main() {
	long long n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	long long tmp = 0, tmp1 = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if (a[i] > a[j]) tmp++;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (a[i] > a[j]) tmp1++;
		}
	}
	cout << ((tmp * k) % MOD + (tmp1 * ((k * (k - 1) / 2) % MOD))) % MOD << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

void sort(int *val, int n) {
	for (int i = n - 1; i > 0; i--) {
		for (int j = 0; j < i; j++) {
			if (val[i] < val[j]) swap(val[i], val[j]);
		}
	}
}

bool judge(int *val, int n, int num) {
	for (int i = 0; i < n; i++) {
		if (val[i] % num != 0) return false;
	}
	return true;
}

int main() {
	int n, i, k, harf, count;
	int val[3], div[10000];

	cin >> n;

	for (i = 0; i < n; i++) cin >> val[i];
	sort(val, n);

	harf = (int)sqrt(val[0]);

	div[0] = count = 1;
	for (i = 2; i <= harf; i++) {
		if (val[0] % i == 0) div[count++] = i;
	}

	cout << 1 << endl;
	for (i = 1; i < count; i++) {
		if (judge(&val[1], n - 1, div[i])) cout << div[i] << endl;
	}
	if (div[count - 1] == harf) count--;
	for (i = count - 1; i >= 0; i--) {
		k = (int)(val[0] / div[i]);
		if (judge(&val[1], n - 1, k)) cout << k << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD=1e9+7,n,ans=1,v[1001];

signed main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    int tmp=i;
    for(int j=2;j*j<=tmp;j++)while(tmp%j==0)tmp/=j,v[j]++;
    v[tmp]++;
  }
  for(int i=2;i<=1000;i++)ans=ans*(v[i]+1)%MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main (String[] args)
    {
        try
        {
            Scanner sc = new Scanner(System.in);
            int i, n, sum;
            double avg, s2;
            double[] s = new double[10000];

            for (i = 0; true; i++)
            {
                n = sc.nextInt();
                if (n == 0) break;
                sum = 0;
                s2 = 0;
                int[] x = new int[n];
                for (int m = 0; m < n; m++)
                {
                    x[m] = sc.nextInt();
                    sum += x[m];
                }
                avg = (double) sum / n;

                for (int m = 0; m < n; m++)
                {
                    s2 += (double) (x[m] - avg) * (x[m] - avg);
                }
                s[i] = Math.sqrt(s2 / n);
            }
            sc.close();

            for (int m = 0; m < i; m++)
            {
                System.out.println(s[m]);
            }
        }
        catch (NumberFormatException e)
        {
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 33200
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  int it = 1;
  while(it <= n){
    it *= 2;
  }
  it /= 2;

  cout << it << endl;
}


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

int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	int a, b;
	cin >> a >> b;
	if(b == 1) cout << "0" << endl;
	else {
		cout << (b - 2) / (a - 1) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk,d; 
	 scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	 ll s=0,ss=0;
	 k=-INF;
	if(a<=0&&b>=0) s=1;
	if(c<=0&&d>=0) s=1;
	k=max(a*c,k);
	k=max(a*d,k);
	k=max(b*c,k);
	k=max(b*d,k);
	if(s) k=max(k,(ll)0);
	cout<<k<<endl;
} 

Measured memory_bytes: 3252
def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def fiveh_num(n):
    return n*500
def oneh_num(n):
    return n*100
def fif_num(n):
    return n*50

count = 0
flag_1 = 0
a = input()
b = input()
c = input()
x = input()
while flag_1==0:
    while int(a)<0 and int(a)>50 and is_integer(a):
        print('a is failed')
        a = input()
    while int(b)<0 and int(b)>50 and is_integer(b):
        print('b is failed')
        b = input()
    while int(c)<0 and int(c)>50 and is_integer(c):
        print('c is failed')
        c = input()
    if int(a)+int(c)+int(c) < 1:
        print('a or b or c is failed ')
        a = input()
        b = input()
        c = input()
    else:
        flag_1 = 1
while is_integer(x) and int(x)<50 and int(x)>20000 and int(x)%50!=0:
    print('x is failed')
    x = input()

a_num = int(a)
b_num = int(b)
c_num = int(c)
x_num = int(x)

while 1:
    if a_num*500 > x_num:
        a_num -= 1
    elif a_num*500 == x_num:
        a_num -= 1
        count += 1
    elif a_num*500 < x_num:
        while 1:
            if a_num*500 + b_num*100 > x_num:
                b_num -= 1
            elif a_num*500 + b_num*100 == x_num:
                b_num -= 1
                count += 1
            elif a_num*500 + b_num*100 < x_num:
                while 1:
                    if a_num*500 + b_num*100 + c_num*50 > x_num:
                        c_num -= 1
                    elif a_num*500 + b_num*100 + c_num*50 == x_num:
                        c_num -= 1
                        count += 1
                    elif a_num*500 + b_num*100 + c_num*50 < x_num:
                        c_num = int(c)
                        break
                b_num -= 1
            if b_num < 0:
                b_num = int(b)
                break
        a_num -= 1
    if a_num < 0:
        break

print('{}'.format(count))

Measured memory_bytes: 9288
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
double rdata[12][12];
double table[1<<12][12];
const double eps = 1e-10;

void pre_calc(int n,double *r){
  rep(i,n){
    rep(j,n){
      double A=r[i]+r[j],B=r[i]-r[j];
      rdata[i][j]=sqrt(A*A-B*B);
    }
    rdata[i][i]=0;
  }
}


double solve(int now,int n,int state,double *r,
	     int last){
  if ( table[state][last] >-eps)return table[state][last];
    
  if ( now == n){
    return table[state][last]=r[last];
  }


  double ret=1000000000;
  rep(i,n){
    if ( ((1<<i)&state)!= 0)continue;
    ret=min(ret,rdata[last][i]+solve(now+1,n,(state|(1<<i)),r,i));
  }
  
  return table[state][last]=ret;
}

main(){
  double in;
  while(cin>>in ){
    string t;getline(cin,t);stringstream sin(t);
    int n=0;
    double r[12];
    while(sin>>r[n])n++;
    bool used[12]={false};
    sort(r,r+n);
    pre_calc(n,r);
    rep(i,(1<<n)){
      rep(j,n)table[i][j]=-1;
    }

    double ret=in+1;
    rep(i,n){
      ret=min(ret,r[i]+solve(1,n,(1<<i),r,i));
    }
    
    if (ret<in+eps)puts("OK");
    else puts("NA");
    
  }
  return false;
}

Measured memory_bytes: 1328
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

int main(){

long long N,M,ans;
cin >> N >> M;

if(N*2<=M){
    ans = N + (M-N*2)/4;
}else{
    ans = M / 2;
}

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


}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,x,a,tmp,ans;

main() {
    cin >> n >> x >> tmp,n--;
    rep(i,n) {
        cin >> a;
        ans += max((int)0,tmp+a-x);
        tmp = max((int)0,a-max((int)0,tmp+a-x));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x;
    cin>>x;
    for(long long int i=-200;i<=200;++i)
    {
        long long int tp=i*i*i*i*i+x;
        long long int op=pow(tp,0.2);
        for(int j=0;j<2;++j)
        {
            long long int num=op+j;
            if(num*num*num*num*num==tp)
            {
                cout<<op+j<<" "<<i<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4092
from collections import defaultdict
from functools import reduce
from operator import xor


def dfs(s, links, fixed):
    q = [s]
    while q:
        v = q.pop()
        if fixed[v]:
            continue
        fixed[v] = True
        q.extend(links[v])


def solve(n, aaa, bbb):
    a0 = reduce(xor, aaa, 0)
    b0 = reduce(xor, bbb, 0)
    aaa.append(a0)
    bbb.append(b0)
    ad = defaultdict(set)
    bd = defaultdict(set)
    for i, a in enumerate(aaa):
        ad[a].add(i)
    for i, b in enumerate(bbb):
        bd[b].add(i)
    ac = {a: len(s) for a, s in ad.items()}
    bc = {b: len(s) for b, s in bd.items()}
    if ac != bc:
        return -1
    links = defaultdict(set)
    ans = 0
    for a, b in zip(aaa, bbb):
        if a == b:
            continue
        ans += 1
        links[a].add(b)

    if not ans:
        return 0

    if a0 == b0:
        links[a0].add(b0)
    else:
        ans -= 1

    fixed = {a: False for a in links}
    for a in links:
        if fixed[a]:
            continue
        ans += 1
        dfs(a, links, fixed)

    return ans - 1


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print(solve(n, aaa, bbb))


Measured memory_bytes: 127764
use proconio::input;
use proconio::marker::{Bytes, Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        n: usize,
        k: usize,
        a: [usize; n],
    }
    for i in 0..n-k {
        if a[i] < a[i+k] {
            println!("Yes");
        }
        else {
            println!("No");
        }
    }
}


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

int main() {
    int N,count=0;
    cin >> N;
    vector<int> data(N);
    for(int i=0; i<N; i++){
        cin >> data.at(i);
    }
    for(int i=1;i<N-1;i++){
        if ((data.at(i-1) >data.at(i) && data.at(i)>data.at(i+1)) ||(data.at(i-1) <data.at(i) && data.at(i)<data.at(i+1))){
            count ++;
        }
        }
        cout << count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 202333
using namespace std;
long long a[maxn];
int main() {
	long long n, k;
	scanf("%lld%lld", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%lld", a + i);
	sort(a + 1, a + n + 1);
	long long L = -1000000000000000233LL, R = 1000000000000000233LL, M;
	while(R - L > 1) {
		M = (L + R) >> 1;
		long long C = 0;
		for(int i = 1; i < n; ++i) {
			if(a[i] == 0) {
				if(0 <= M) C += n - i;
				continue;
			} else if(a[i] < 0) {
				if(a[i] * a[i + 1] <= M) C += n - i;
				else if(a[i] * a[n] > M) C += 0;
				else {
					int l = i + 1, r = n, m;
					while(r - l > 1) {
						m = (l + r) >> 1;
						if(a[i] * a[m] <= M) r = m;
						else l = m;
					}
					C += n - r + 1;
				}
			} else {
				if(a[i] * a[i + 1] > M) C += 0;
				else if(a[i] * a[n] <= M) C += n - i;
				else {
					int l = i + 1, r = n, m;
					while(r - l > 1) {
						m = (l + r) >> 1;
						if(a[i] * a[m] <= M) l = m;
						else r = m;
					}
					C += l - i;
				}
			}
		}
		if(C >= k) R = M;
		else L = M;
	}
	printf("%lld", R);
} 

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int x, t;
	cin >> x >> t;
	if (x - t <= 0) {
		cout << 0 << endl;
	} else {
		cout << x - t << endl;
	}
	return 0;
}

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

int main ()
{
    int n,k;
    cin>>n>>k;
    int ans[120]={0};
    int m=0;
    for(int i=0;i<k;i++)
    {
        int d,t;
        cin>>d;
        for(int j=0;j<d;j++)
        {
            cin>>t;
            ans[t-1]++;
        }

    }
    for(int i=0;i<n;i++)
        if(!ans[i]) m++;
    cout<<m<<endl;
	return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define UP 0
#define DOWN 1

int main(){
    // cout << fixed << setprecision(5);

    lli N;
    scanf("%lld",&N);
    vector<lli> A;
    A.resize(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }

    lli left=0,right;
    lli cnt=0;

    while(left<N){
        lli state;
        if(A[left]==A[left+1]){
            left++;
            continue;
        }
        if(A[left]>A[left+1]){
            state=DOWN;
        }
        else{
            state=UP;
        }
        right = left+1;

        while(right<N+1){
            if(right==N){
                left=right;
                break;
            }
            bool ok = true;
            if(state==UP && A[right-1]>A[right])ok = false;
            if(state==DOWN && A[right-1]<A[right])ok = false;
            if(ok)right++;
            else {
                left = right;
                break;
            }
        }
        cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>
 
using namespace std;
typedef long long ll;
 
 
typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[9]={1,0,-1,0,1,1,-1,-1,0};
int dy[9]={0,1,0,-1,1,-1,-1,1,0};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define re(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl;
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,h,w;
ll start,end;
 
ll x[500005],y[500005],z[500005];
string s,t,u;
bool flag;
bool check[100005];
 
 
int main(){
    cin>>n;
    cin>>u;
    m = (1<<n);
    s = u.substr(0,n);
    t = u.substr(n,n);
    reverse(t.begin(),t.end());
    map<pair<string,string>,ll> mp;
    vector<pair<string,string>> v;
    for(i=0;i<m;i++){
        string a,b,c,d;
        for(j=0;j<n;j++){
            if((i>>j) & 1){
                a = a + s[j];
                c = c + t[j];
            }else{
                b = b + s[j];
                d = d + t[j];
            }
        }
        
        //deba(a);
        mp[pair<string,string>(a,b)]++;
        v.pb(pair<string,string>(d,c));
    }
    for(i=0;i<v.size();i++){
        ans += mp[v[i]];
    }
    p(ans);
    
    return 0;
}

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

using namespace std;

int main()
{
   long long int n,a,b,sum=0;
   cin>>n;
   a=n%500;
   n=n/500;
   sum+=n*1000;
   n=a/5;
   sum+=n*5;
   cout<<sum;
   return 0;
}


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

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b){if (b == 0) return a;return gcd(b, a % b);}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }



int main(){
    int N, ans=0, sum=0, c, d, cs=0, ds=0;
    cin >> N;
    int X[N];
    for(int i = 0; i < N; ++i) cin >> X[i];
    for(int i = 0; i < N; ++i){
        sum += X[i];
    }
    c = sum / N;
    d = c + 1;
    for(int i = 0; i < N; ++i){
        cs += pow((X[i] - c), 2);
        ds += pow((X[i] - d), 2);
    }
    ans = min(cs, ds);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256