akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  int sum = 0;

  vector<int> A(N + 1);
  for (int i = 1; i < N + 1; i++) {
    cin >> A.at(i);
    sum += abs(A.at(i - 1) - A.at(i));
  }
  sum += abs(A.at(N));

  A.push_back(0);

  for (int i = 1; i < N + 1; i++) {
    cout << sum - abs(A.at(i) - A.at(i - 1)) - abs(A.at(i) - A.at(i + 1)) + abs(A.at(i - 1) - A.at(i + 1)) << "\n";
  }
}

Measured memory_bytes: 1656
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// A/B problems
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ary := strings.Split(strings.TrimSpace(sc.Text()), " ")
	a, _ := strconv.Atoi(ary[0])
	b, _ := strconv.Atoi(ary[1])
	fmt.Printf("%v %v %f\n", int(a/b), a%b, float64(a)/float64(b))
}



Measured memory_bytes: 1116
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.nextLong();
        }
        sc.close();

        Arrays.sort(a);
        
        long ans = 0;
        long x = 0;
        for(int i=0; i<n-1; i++){
            int mi = n-i-1;
            if(a[mi] == a[mi-1]){
                if(x == 0){
                    x = a[mi];
                    i++;
                }else{
                    ans = x * a[mi];
                    break;
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 51336
n,m=map(int,input().split())
nl=[list(map(int,input().split())) for i in range(n)]
ml=[list(map(int,input().split())) for i in range(m)]

for j in range(n):
  best=100000000000
  for i in range(m):
    d=abs(ml[i][0]-nl[j][0]) + abs(ml[i][1]-nl[j][1])
    if best>d:
      best=d
      ans=i+1
  print(ans)

Measured memory_bytes: 9080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int pchk = 0, gchk = 0, win = 0, lose = 0;
		for (int i = 0; i < str.length(); i++) {
			if (pchk < gchk) {
				if (String.valueOf(str.charAt(i)).equals("g")) {
					win++;
				}
				pchk++;
			} else {
				if (String.valueOf(str.charAt(i)).equals("p")) {
					lose++;
				}
				gchk++;
			}
		}
		System.out.println(win - lose);
		scan.close();
	}
}


Measured memory_bytes: 18364
#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
#include <queue>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <functional>
#include <bitset>
using namespace std;
#define ll long long

const int N = 1e5+15;

int A[N],B[N];
int ind[N*2];
void solve() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        scanf("%d %d",&A[i],&B[i]);
    }
    ll ret = 0,a=0,b=0;
    for(int i=1;i<=n;++i) {
        a += A[i],b+=B[i];
    }
    ret = min(a,b);
    vector<pair<int,int> > in;
    for(int i=1;i<=n;++i) {
        int aid = i*2-1, bid = i*2;
        in.push_back(make_pair(A[i],aid));
        in.push_back(make_pair(B[i], bid));
    }
    sort(in.begin(),in.end());
    for(int i=0;i<(int)in.size();++i) {
        ind[in[i].second] = i;
    }
    ll sum = 0;
    for(int i=0;i<n-2;++i) {
        sum += in[i].first;
    }
    for(int i=1;i<=n;++i) {
        int aid = i*2-1,bid = i*2;
        int pos = n-2;
        ll cur = sum;
        if(ind[aid]<n-2) {
            --pos;
            cur -=A[i];
        }
        if(ind[bid]<n-2) {
            --pos;
            cur -= B[i];
        }
        cur += A[i] + B[i];
        for(int j = n-2;pos<n-2;++j) {
            if(in[j].second!= aid && in[j].second != bid) {
                cur += in[j].first;
                ++pos;
            }
        }
        ret = min(ret,cur);
    }
    printf("%lld\n",ret);
}

int main() {
    //freopen("/Users/gotop/Documents/ps_practice/ps_practice/input.txt", "r", stdin);
    solve();
}


Measured memory_bytes: 3440
use std::io;

fn main() {
    let mut abk = String::new();
    io::stdin().read_line(&mut abk).unwrap();
    let mut abk = abk.split_whitespace();
    let a: u32 = abk.next().unwrap().parse().unwrap();
    let b: u32 = abk.next().unwrap().parse().unwrap();
    let k: u32 = abk.next().unwrap().parse().unwrap();

    if (b - a) > (k - 1) * 2 {
        for i in a..(a+k) {
            println!("{}", i);
        }
        for i in (b - k + 1)..(b + 1) {
            println!("{}", i);
        }
    } else {
        for i in a..(b+1) {
            println!("{}", i);
        }
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n],brr[n];
    rep(i,0,n)cin>>arr[i]>>brr[i];
    sort(arr,arr+n);
    sort(brr,brr+n);

    if(n%2)
    {
        int diff = brr[n/2]-arr[n/2]+1;
        cout<<diff;
    }
    else
    {
        int a = (arr[n/2]+arr[n/2-1]);
        int b = (brr[n/2]+brr[n/2-1]);
        cout<<b-a+1;
    }

    return 0;
}



Measured memory_bytes: 5152
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string S, T;
	int s = 0, i = 0;
	cin >> S >> T;
	while(S[i])
	{
		if (S[i] != T[i])
		{
			s++;
		}
		i++;
	}
	cout << s;
}

Measured memory_bytes: 3932
#include<bits/stdc++.h>
#include<numeric>
#define int long long
const int inf=1e9+5;
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;cin>>n>>k;
    int h[n];for(int i=0;i<n;i++)cin>>h[i];
    vector<int> dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j]=min(dp[i]+abs(h[j]-h[i]),dp[j]);
                //cout<<dp[j]<<"-";
        }
        }
        
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1]<<endl;
            
        
    }
    


Measured memory_bytes: 1792
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
last = [-1]*26
ans = 0
for i in range(D):
  TEMP = -float('inf')
  T = -1
  for t in range(26):
    temp = 0
    temp += s[i][t-1]
    tempo = last[t-1]
    last[t-1] = i
    temp -= sum([c[j]*(i-last[j]) for j in range(26)])
    if temp > TEMP:
      T = t
      TEMP = temp
    last[t-1] = tempo
  print(T+1)
  last[T-1] = i
  ans += TEMP

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

int main(void){
  
  int A, B; cin >> A >> B;
  
  int hantei = B % A;
  
  if(hantei == 0){
    
    cout << A + B << endl;
    
  }else{
    
    cout << B - A << endl;
    
  }
  
  return 0;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const int MaxN = 100005;

int tot, len;
char s[MaxN + 5];
char c[MaxN + 5];
int pre[MaxN + 5], suf[MaxN + 5];

bool check() {
	for(int i = 1; i <= tot / 2; i++) {
		if(c[i] != c[tot - i + 1])
			return 0;
	}
	return 1;
}

/*
void Todo() {
	for(int i = 1; i <= len; i++) {
		if(s[i] == 'x') pre[i] = pre[i - 1] + 1;
		else pre[i] = pre[i - 1];
	}
	for(int i = len; i >= 1; i--) {
		if(s[i] == 'x') suf[i] = suf[i + 1] + 1;
		else suf[i] = suf[i + 1];
	}
}
*/

int main()
{
	while(scanf("%s", s + 1) != EOF)
	{
		tot = 0;
		len = strlen(s + 1);
		for(int i = 1; i <= len; i++) {
			if(s[i] != 'x') 
				c[++tot] = s[i];
		}
		if(check() == 0) printf("-1\n");
		else {
			int cnt = 0;
			int l = 1, r = len;
			while(l <= r) {
				if(s[l] == s[r]) {
					l++;
					r--;
				}
				else if(s[l] == 'x' && s[r] != 'x') {
					l++;
					cnt++;
				}
				else if(s[l] != 'x' && s[r] == 'x') {
					r--;
					cnt++;
				}
			}
			printf("%d\n", cnt);
		}
	}
	return 0;
}

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

using namespace std;

int main(){
	
	int n;
	
	cin>>n;
	
	int arr[n+1][4];
	
	for(int i=1; i<=n; i+=1){
		
		cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
	}
	
	for(int i=2; i<=n; i+=1){
		
		arr[i][1] += max(arr[i-1][2],arr[i-1][3]);
		
		arr[i][2] += max(arr[i-1][1],arr[i-1][3]);
		
		arr[i][3] += max(arr[i-1][2],arr[i-1][1]);
	}
	
	cout<<max(arr[n][1],max(arr[n][2],arr[n][3]));
}

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

using namespace std;
using ll = long long;

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

int mod = 1e9 + 7;

ll dp[100005];

ll f(int i) {
  if (i < 0) return 0;
  if (dp[i] == -1) return 0;
  if (dp[i] != 0) return dp[i];
  return dp[i] = (f(i - 1) + f(i - 2)) % mod;
}

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int a;
    cin >> a;
    dp[a] = -1;
  }
  dp[0] = 1;
  // ll ans = f(n);
  rep(i, n) {
    if (dp[i] == -1) continue;
    if (dp[i + 1] != -1) dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
    if (dp[i + 2] != -1) dp[i + 2] = (dp[i + 2] + dp[i]) % mod;
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 4264
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
int main() {
  string s; cin >> s;
  int K; cin >> K;
  int N = s.size();
  set<string> ss;
  for (int i = 0; i < N; ++i) {
    string x;
    for (int j = 0; i + j < N && j <= 5; ++j) {
      x += s[i + j];
      ss.insert(x);
    }
  }
  auto it = ss.begin();
  for (int i = 0; i < K-1; ++i) ++it;
  cout << *it << endl;
}


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


int main(){
  int n;
  cin >> n;
  int a,b;
  cin >> a >> b;
  int cnt1,cnt2,cnt3;
  cnt1=0;
  cnt2=0;
  cnt3=0;
  for(int i=0;i<n;++i){
    int p;
    cin >> p;
    if(p<=a) cnt1++;
    else if(p>=b+1) cnt3++;
    else cnt2++;
  }
  int ans=min(cnt1,cnt2);
  ans=min(ans,cnt3);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
n, a, b = map(int, input().split())

if a > b:
	print(0)

else:
	if n == 1:
		if a == b:
			print(1)
		else:
			print(0)

	elif n == 2:
		print(1)

	else:
		print(b * (n - 2) - a * (n - 2) + 1)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pip;

const int N = 1e5 + 10;

set<pip> c[N]; int p[N];

set<pii> eG[2], eB;
pii swp(pii x){ if (x.first < x.second) return x; else return pii(x.second, x.first); }

void insG(int G, int u, int v){
	pii e = swp(pii(u, v));

	c[u].insert(pip(G, e));
	c[v].insert(pip(G, e));

	if (eG[1 - G].count(e)) eB.insert(e);
	eG[G].insert(e);
}

void ersG(int G, int u, int v){
	pii e = swp(pii(u, v));

	c[u].erase(pip(G, e));
	c[v].erase(pip(G, e));

	eB.erase(e);
	eG[G].erase(e);
}

int findpar(int u){ return (p[u] == u ? u : p[u] = findpar(p[u])); }

void mrg(int u, int v){
	u = findpar(u), v = findpar(v);
	if (c[v].size() > c[u].size()) swap(u, v);
	p[v] = u;

	while(c[v].size()){
		pip e = *c[v].begin();
		ersG(e.first, e.second.first, e.second.second);
		if (e.second.first == v) e.second.first = u;
		if (e.second.second == v) e.second.second = u;
		insG(e.first, e.second.first, e.second.second);
	}
}

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

	int n; cin >> n;
	iota(p, p + n, 0);
	for (int k = 0; k < 2; k++)
		for (int i = 0; i < n - 1; i++){
			int u, v; cin >> u >> v; u--; v--;
			insG(k, u, v);
		}

	int cnt = 0;
	while(eB.size()){
		cnt++;
		pii e = *eB.begin(); ersG(0, e.first, e.second); ersG(1, e.first, e.second);
		mrg(e.first, e.second);
	}

	if (cnt == n - 1) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 43520
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,v=map(int,readline().split())
    b,w=map(int,readline().split())
    t=int(readline())

    if v<=w:
        print("NO")
    else:
        if a<b:
            if a+v*t>=b+w*t:
                print("YES")
            else:
                print("NO")
        elif b<a:
            if b-w*t<a-v*t:
                print("NO")
            else:
                print("YES")

if __name__=="__main__":
    main()

Measured memory_bytes: 9196
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(b+c<a)
        cout<<0<<endl;
    else
        cout<<b+c-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 100;
int N, a[MAX];
ll pd[MAX];

int main(int argc, char** argv) {
	scanf("%d", &N);
	REP(i, 1, N) scanf("%d", a+i);
	pd[0] = 1000;
	REP(i, 1, N) {
	    pd[i] = max(pd[i], pd[i-1]);
	    ll k = pd[i]/a[i];
	    ll m = pd[i]%a[i];
	    REP(j, i+1, N)
            pd[j] = max(pd[j], k*a[j]+m);
	}
	printf("%lld\n", pd[N]);
	return 0;
}


Measured memory_bytes: 3812
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;

string b[110], r[110];

int main(){
	
	int n, m;
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> b[i];
	cin >> m;
	for (int i = 0; i < m; i++)cin >> r[i];

	
	for (int i = 0; i < n; i++) {
		int rnum = 0, bnum = 0;
		for (int j = 0; j < n; j++) {
			if (b[i] == b[j]) bnum++;
		}

		for (int j = 0; j < m; j++) {
			if (b[i] == r[j]) rnum++;
		}
		ans = max(ans, bnum - rnum);
	}

	for (int i = 0; i < m; i++) {
		int rnum = 0, bnum = 0;
		for (int j = 0; j < n; j++) {
			if (r[i] == b[j]) bnum++;
		}

		for (int j = 0; j < m; j++) {
			if (r[i] == r[j]) rnum++;
		}
		ans = max(ans, bnum - rnum);
	}

	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int x, y, z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
int n, a[N];
bitset<4000001> f;
vector<int> res;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	fo(i, n)
		cin >> a[i];
	f[0] = 1;
	fo(i, n)
		f |= (f << a[i]);

	for(int i = 0; i <= 4000000; ++i)
		if(f[i])
			res.pb(i);
	cout<<res[res.size() / 2];		
	return 0;            
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<int> A;

void init()
{
	cin >> N;
	CINV(A, N);
}

int X;

inline void add(int x, map<int, int>& m)
{
	m[x]++;
	if (m[x] == X) {
		m.erase(x);
		add(x-1, m);
	}
}

inline bool isok(int x)
{
	X = x;
	int pre = 0;
	map<int, int> m;
	rep(i, N) {
		if (pre < A[i]) {
			pre = A[i];
			continue;
		}
		pre = A[i];
		add(A[i], m);
		for (auto x = m.rbegin(); x != m.rend(); x++) {
			if ((*x).first > A[i]) {
				m.erase((*x).first);
			} else {
				break;
			}
		}
		if (m.count(0)) return false;
	}
	return true;
}

void solve()
{
	bool f = true;
	rep(i, N-1) {
		f &= A[i] < A[i+1];
	}
	if (f) {
		cout << 1 << endl;
		return;
	}
	int ok = 1000000000;
	int ng = 1;
	int cnt = 1;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (isok(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 2500;
int a[N], b[N];
int dp[2][201][5201];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    if (n / 100 == n % 10) cout << "Yes"; else cout << "No";
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := newIo()
	defer io.Flush()
	N, M := io.NextInt(), io.NextInt()
	x := M / N

	for {
		if (M-(x*N))%x == 0 {
			break
		}
		x--
	}
	fmt.Println(x)
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<utility>
#include<vector>
#include<math.h>
using namespace std;
long long pow2(long long x,int y,long long mod) {
  if(y == 0)return 1;
  else if(y%2 == 0)return (long long)powl(pow2(x,y/2,mod),2.0)%mod;
  else return (((long long)powl(pow2(x,y/2,mod),2.0)%mod)*x)%mod;
}
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  long long ans = pow2(2,N,1000000007);
  long long i,a = 0,b = 0,last = 1;
  if(A == N)a = 1;
  if(B == N)b = 1;
  for(i=1;i<=max(min(A,N-A),min(B,N-B));i++) {
    last = ((last*(N-i+1)%1000000007)*pow2(i,1000000005,1000000007))%1000000007;
    if(min(A,N-A)==i)a = last;
    if(min(B,N-B)==i)b = last;
  }
  cout << (ans-a-b-1+3000000021)%1000000007 << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const int N = 1 << 20;
const int MOD = 1e9 + 7;
typedef long long int ll;
priority_queue< pair< int, int > > pq;
vector< pair<int,int> >vp;
#define f(a, n) for(int i = a; i  < n ; i++) 
//#define endl "\n" 
//#define sort(v) sort(v.begin() , v.end())
#define print(v) for(int i = 0 ; i < v.size() ; i++) cout << v[i] << ' '  
map< int, int > mp, mpp;
vector< int>v;
int visit[N] ;
//push_back
//insert 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main () 
{ 
   int  n , k ; 
   cin >> n >> k ; 
   int a[n] ; 
   for(int i = 0 ; i < n ; i++) cin >> a[i] ; 
   	int ans = 0 ; 
   sort(a , a + n) ; 
   for(int i = 0 ; i < k ; i++) ans += a[i] ; 
   	cout << ans ; 
    
}
/*






*/


Measured memory_bytes: 3616
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C, D, E, F);

// ===

fn build_table(a: usize, b: usize, mul: usize, f: usize) -> Vec<bool> {
    let mut table = vec![false; f+1];
    table[0] = true;
    for i in 0..f+1 {
        if table[i] {
            if i + a * mul <= f {
                table[i+a*mul] = true;
            }
            if i + b * mul <= f {
                table[i+b*mul] = true;
            }
        }
    }
    table
}

fn main() {
    let (a, b, c, d, e, f): (usize, usize, usize, usize, usize, usize) = read();

    let water_table = build_table(a, b, 100, f);
    let sugar_table = build_table(c, d, 1, f);

    let mut back_sugar_table = vec![0; f+1];
    let mut last = 0;
    for i in 0..f+1 {
        if sugar_table[i] {
            last = i;
        }
        back_sugar_table[i] = last;
    }

    // (a, b) := a/b
    let mut best_rate = (0, 1);
    let mut best_total = 0;
    let mut best_sugar = 0;

    for w in 1..f+1 {
        if water_table[w] {
            let max_sugar = min(w * e / 100, f - w);
            let sugar = back_sugar_table[max_sugar];
            if best_rate.0 * (w + sugar) <= best_rate.1 * 100 * sugar {
                best_rate = (100 * sugar, w + sugar);
                best_total = w + sugar;
                best_sugar = sugar;
            }
        }
    }

    println!("{} {}", best_total, best_sugar);
}

Measured memory_bytes: 4352
import java.util.*;
 
 public class Main
{
  public static void main(String []args)
  {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int tot = 0;
    for(int i = 1 ; i <= n ; i++)
    {
      int x = sc.nextInt();
      if(x%2 == i%2 && i%2 == 1)
        tot++;
    }
    System.out.println(tot);
  }
}

Measured memory_bytes: 35640
//  .:::.   .:::.
// :::::::.:::::::
// :::::::::::::::
// ':::::::::::::'
//   ':::::::::'
//     ':::::'
//       ':'
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
using namespace std;
double dp[3005][3005]; 
int main()
{
    FIO;
    ll t, q, maxx, n, m, k, i, j, k1, k2, k3, x, flag, ans, sum, cnt, prev, y;
    cin>>n;
    vector<double> v(n);
    rep(i,0,n)
    {
        cin>>v[i];
    }
    dp[0][0] = (1 - v[0]);
    dp[0][1] = v[0];
    rep(i,1,n)
    {
        rep2(j,n-1,0)
        {
            dp[i][j+1] += (dp[i-1][j]*v[i]);
            dp[i][j] += (dp[i-1][j]*(1.0 - v[i]));
        }
    }
    double ans1 = 0.00;
    rep(j,n/2+1,n+1)
    {
        ans1+=dp[n-1][j];
        // cout<<dp[n-1][j]<<endl;
    }
    cout<<setprecision(10);
    cout<<ans1<<endl;
    return 0;    
}
/*
axyb
abyxb
*/

Measured memory_bytes: 70656
function Main(input){
	function compareFunc(a,b){
    	return a - b;
    }
    input = input.trim().split(' ');
    input.sort(compareFunc);
    a = input[1]-input[0];
    b = input[2]-input[1];
    ans = a + b;
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7752
#include <iostream>
#include <string>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		int answer = 0, cur = 0, next = 3;
		for(int i = 0; i < n; ++i){
			string s;
			cin >> s;
			if(s == "lu"){
				cur |= 1;
			}else if(s == "ru"){
				cur |= 2;
			}else if(s == "ld"){
				cur &= ~1;
			}else if(s == "rd"){
				cur &= ~2;
			}
			if(cur == next){
				++answer;
				next = cur ^ 3;
			}
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	l := scanFloat64()

	fmt.Fprintf(wr, "%f\n", l*l*l/27)
}


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

int main(){
    int H,A; cin >> H >> A;
    int ans=H/A;
    if (H%A!=0) ans++;
    cout << ans << endl;
}

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

using namespace std;

int main(){
	string s;
	cin >> s;
	if(s == "SUN")
		cout << 7;
	else if(s == "MON")
		cout << 6;
	else if(s == "TUE")
		cout << 5;
	else if(s == "WED")
		cout << 4;
	else if(s == "THU")
		cout << 3;
	else if(s == "FRI")
		cout << 2;
	else if(s == "SAT")
		cout << 1;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    var nk = input[0].split(' ');
    var n = parseInt(nk[0], 10);
    var k = parseInt(nk[1], 10);
    var s = input[1];
    var block = 1;
    for(var i = 0; i < n-1; i++){
        
        block += (s[i] != s[i+1]) ? 1 : 0;
    }
    var happiness = Math.min(n-block+(2*k), n-1);

	console.log(happiness);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
using static System.Math;using static System.Console;using System.Collections.Generic;using System.Linq;using System;using System.Collections;
using System.Runtime.Serialization;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine());
    static int[] ReadInts => Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine());
    static long[] ReadLongs => Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    static int mod = (int)Pow(10, 9) + 7;
    public static int Mod(int a,int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion



    static void Main()
    {
        List<int> anses = new List<int>();

        while (true)
        {
            int n = ReadInt;
            if (n == 0) break;

            int[][] times = new int[n*2][];
            for (int i = 0; i < n; i++)
            {
                times[i * 2] = new int[2];
                times[i * 2+1] = new int[2];


                string[] train = ReadStrs;
                int[] hms_start = train[0].Split(':').Select(s => Convert.ToInt32(s)).ToArray();
                int[] hms_end = train[1].Split(':').Select(s => Convert.ToInt32(s)).ToArray();

                times[i*2][0] = 1;
                times[i*2][1] = hms_start[0] * 3600 + hms_start[1] * 60 + hms_start[2];

                times[i * 2+1][0] = -1;
                times[i * 2+1][1] = hms_end[0] * 3600 + hms_end[1] * 60 + hms_end[2];
            }

            int ans = 0;
            int current = 0;

            int[] imos = new int[24 * 3600];

            for (int i = 0; i < times.Length; i++)
            {
                imos[times[i][1]] += times[i][0];
            }

            for (int i = 0; i < imos.Length; i++)
            {
                if (imos[i] == 0) continue;
                current += imos[i];
                ans = Max(ans, current);
            }

            anses.Add(ans);
        }
        WriteLine(string.Join("\n",anses));

    }



}



Measured memory_bytes: 37280
(let ((n (read))
      (a (make-array 0 :element-type 'integer
                       :adjustable t
                       :fill-pointer 0))
      (ans 0))
     (dotimes (i n)
       (vector-push-extend (read) a))
     (loop for i from 1 upto (- n 2)
           do (if (or (and (< (aref a (1- i)) (aref a i)) (< (aref a i) (aref a (1+ i)))) (and (> (aref a (1- i)) (aref a i)) (> (aref a i) (aref a (1+ i))))) (incf ans)))
     (princ ans))

Measured memory_bytes: 13664
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 3010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = INF ;
const ll linf = 1e15 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

ll dp[N][N] ;
ll a[N] ;
int n ;

signed main() {
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]) ;
	for (int i = 1; i <= n; i++) dp[i][i] = a[i] ;
	for (int i = 2; i <= n; i++)
	for (int j = 1; i + j - 1 <= n; j++)
	dp[j][i + j - 1] = max(a[j] - dp[j + 1][i + j - 1], -dp[j][i + j - 2] + a[i + j - 1]) ;
	printf("%lld\n", dp[1][n]) ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 70016
class Dice
  def initialize(men)
    @t, @s, @e, @w, @n, @b = men
  end

  def top
    @t
  end

  def move(d)
    case d
    when 'N'
      @t, @s, @b, @n = @s, @b, @n, @t
    when 'W'
      @w, @b, @e, @t = @t, @w, @b, @e
    when 'E'
      @w, @b, @e, @t = @b, @e, @t, @w
    when 'S'
      @t, @s, @b, @n = @n, @t, @s, @b
    end
  end
end

d = Dice.new(gets.split)
gets.chomp.split('').each {|dir| d.move(dir) }
puts d.top



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

long long int pow_five(int a){
	long long int result=1;
	for(int i=0; i<a; ++i) result*=5;
	return result;
}

int main(){
	long long int N;
	while(cin >> N&&N){
		long long int ans=0;
		int i=1;
		while(true){
			long long int tmp=pow_five(i);
			if(N/tmp==0) break;
			ans+=N/tmp;
			++i;
		}
		cout << ans << endl;
	}
	return 0;
}

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

const int mod = 1000000007;

// mod 逆元
long long inverse(long long a) {
    long long b = mod;
    long long u = 1, v = 0;
    while(b > 0) {
        int t = a / b;
        swap(a -= t * b, b);
        swap(u -= t * v, v);
    }
    return (u % mod + mod) % mod;
}

const int MAX = 200000;
// 階乗を前計算しておく
long long fact[MAX + 1], finv[MAX + 1];
void factinit() {
    fact[0] = 1;
    for(int i = 1; i <= MAX; i++)
        fact[i] = fact[i - 1] * i % mod;
    finv[MAX] = inverse(fact[MAX]);
    for(int i = MAX; i > 0; i--)
        finv[i - 1] = finv[i] * i % mod;
}
long long comb(int n, int k) {
    if(n < k || k < 0) return 0;
    return fact[n] * finv[k] % mod * finv[n - k] % mod;
}
long long f(int x, int y) { return comb(x + y, x); }

int H, W, N;
pair<int, int> wall[3009];

long long dp[3009];

int main() {
    factinit();

    cin >> H >> W >> N;
    for(int i = 0; i < N; i++) {
        int r, c;
        cin >> r >> c;
        r--;
        c--; // 0-indexed にする
        wall[i] = make_pair(r, c);
    }
    // ゴールにも壁があるとみなすと実装が楽
    wall[N] = make_pair(H - 1, W - 1);

    sort(wall, wall + N);

    for(int i = 0; i <= N; i++) {
        dp[i] = f(wall[i].first, wall[i].second);
        for(int j = 0; j < i; j++) {
            int dx = wall[i].first - wall[j].first;
            int dy = wall[i].second - wall[j].second;
            dp[i] = (dp[i] - dp[j] * f(dx, dy) % mod + mod) % mod;
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 3456
import math
import sys
import os
from operator import mul
from collections import Counter

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N,K,L = LI()
pq = [LI() for _ in range(K)]
rs = [LI() for _ in range(L)]

road = UnionFind(N)
for r in pq:
    f = r[0]-1
    t = r[1]-1
    road.union(f,t)

rail = UnionFind(N)
for r in rs:
    f = r[0]-1
    t = r[1]-1
    rail.union(f,t)

# ans = [-1]*N
# for i in range(N):
#     if not ans[i]==-1:
#         continue
#     road_set = set(road.members(i))
#     rail_set = set(rail.members(i))
#     group = road_set & rail_set
#     count = len(group)
#     for j in group:
#         ans[j]=count

union_sets=[(road.find(i),rail.find(i)) for i in range(N)]
# (0,1),(0,1),(2,2)
# 共通の親を持つ数をカウント
counts=Counter(union_sets)
# (0,1):2, (2,2):1
ans=[counts[union_set] for union_set in union_sets]

print(*ans)



Measured memory_bytes: 183120
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int n,sum=0,su=0,min2=100000;
    cin>>n;
    vector<int>w(n);
    rep(i,n)cin>>w[i];
    rep(j,n)sum+=w[j];
    rep(k,n){
        su+=w[k];
        min2=min(min2,abs(sum-su*2));
    }
    cout<<min2;
    return 0;
}

Measured memory_bytes: 256
//  RAKSHIT KADAM
 #include <bits/stdc++.h>
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
 #warning !!!check the size of arrayss!!!
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define newMOD  998244353
 #define MAX 300006
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define INF 2000000000000000005

 #define vi vector<ll>
#define pi 3.1415926535897932384626433832795
#define Endl endl
#define lb lower_bound
#define ub upper_bound

using namespace std;
//ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
//int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
 //ddfdsfdfs

//ll modInverse(int a, int m){ return power(a, m-2, m);} // if a and m are relativelyprime
ll a[MAX];
ll b[MAX];
ll n,k;
ll _;
ll pos(ll i,ll ans)
{
    ll l=1,r=n;ll ret=0;
    while(l<=r)
    {
        ll mid=(l+r)>>1;
        if(a[i]*a[mid]<ans)
        {
            ret=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    return (ret>=i? (ret-1) : (ret));
}
ll neg(ll i,ll ans)
{
    ll l=1,r=n;
    ll ret=0;
    while(l<=r)
    {
        ll mid=(l+r)>>1;
        if(b[mid]*a[i]<ans)
        {
            ret=mid;l=mid+1;
        }
        else r=mid-1;
    }
    return (ret>n-i? (ret-1) : (ret));
}
bool check(ll ans)
{
    ll see=0;
    for(ll i=1;i< _ ;i++)
    {
        see+=neg(i,ans);
        
    }
    for(ll i=_;i<=n;i++)
    {
        see+=pos(i,ans);
        
    }
    see/=2;
    return see>=k;
}
void solve()
{
    cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    for(ll i=1;i<=n;i++)
    {
        b[i]=a[n+1-i];
    }
    
    _ = n+1 ; // IN THE CASE WE DONT FIND ANY NON NEGATIVE NUMBER;
    for(ll i=1;i<=n;i++)
    {
        if(a[i]>=0){_=i;break;}
    }
    ll l=-INF;ll r=INF;ll ans;
    while(l<=r)
    {
        ll mid = (l+r)>>1;
        if(check(mid))
        {
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans-1<<endl;
    
}
signed main()
{
 
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//    }


 solve();
    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i= 0;i<(int)c;i++)
int main() {
  string s,t;
  cin >> s;
  cin >> t;
  int z = 0;
  for(int i= 0;i<3;i++){
    if(s[i]==t[i]){
      z++;
    }
  }
 cout << z << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include<bitset>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include <iomanip>
using namespace std;

int main()
{
    double n; cin>>n;
    double cnt=0;
    for(int i=0;i<n;i++){
        if((i+1)%2!=0){
            cnt++;
        }
    }
    cout<<cnt/n<<endl;
    
    
    return 0;
}


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

int main() {

    int a, b, k, i, count;

    cin >> a >> b >> k;

    count = 0;
    for(i = a; i > 0; i--) {
        if((a % i == 0) && (b % i == 0)) {
            // cout << i << endl;
            count++;
        }
        if(k == count) break;
    }
    
    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<tuple>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	REP(i, n) cin>>a[i];
	vector<int> dp(n + 1);
	dp[0] = -1;
	FOR(i, 1, n + 1) {
		dp[i] = INF;
	}
	FOR(i, 1, n + 1) {
		vector<int>::iterator ite = lower_bound(ALL(dp), a[i - 1]);
		if(ite != a.end()) *ite = a[i - 1];
	}
	int res = 0;
	REP(i, n + 1) {
		if(dp[i] != INF) res = i;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3640
x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
if a > b:
    t = a
    a = b
    b = t
if b > c:
    t = b
    b = c
    c = t
if a > b:
    t = a
    a = b
    b = t
print(str(a) + " " + str(b) + " " + str(c))


Measured memory_bytes: 5596
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

map<int, int> counts;

int main() {
    int N; cin >> N;
    for (int j = 0; j < N; ++j) {
        int v; cin >> v;
        if (counts.find(v) == end(counts)) {
            counts[v] = 0;
        }
        ++counts[v];
    }

    int ans = 0;
    for (pair<const int, int>& p : counts) {
        if (p.first <= p.second) {
            ans += p.second - p.first;
        } else {
            ans += p.second;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ll long long

//25689897455 85 100

ll calc(ll i, ll a, ll b)
{
    ll ans =(a*i)/b - a*(i/b);
    return ans;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    ll a, b, n;
    scanf("%lld %lld %lld", &a, &b, &n);
    if(n >= b){
        ll per = n/b;
        ll mul = per*b;
        mul--;
        cout << calc(mul, a, b) << endl;
    }
    else {
        cout << calc(n, a, b) << endl;
    }
}



Measured memory_bytes: 3688
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = []
        for i in range(2, int(math.sqrt(m)) + 1):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False

    def is_prime(self, n):
        return self.A[n]

def main():
    rr = []

    pr = Prime(10**12)

    while True:
        a,d,n = LI()
        if n == 0:
            break
        r = -1
        c = 0
        for i in range(a,10**6+1,d):
            if pr.is_prime(i):
                c += 1
                if c == n:
                    r = i
                    break
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 16672
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

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

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


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

	int ans = -1;
	double x1, x2;

	for (int i = 1; i < 1500; ++i)
	{
		x1 = i * 0.08;
		x2 = i * 0.1;
		if (floor(x1) == A && floor(x2) == B)
		{
			ans = i;
			break;
		}
	}

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

Measured memory_bytes: 3620
<?php
while (1) {
    list($h, $w) = explode(" ", trim(fgets(STDIN)));
    if ($h == 0 && $w == 0) exit;
    for ($i = 0; $i < $h; $i++) {
        echo substr(str_repeat('.#', $w), ($i % 2) ? 0 : 1, $w) . PHP_EOL;
    }
    echo PHP_EOL;
}

Measured memory_bytes: 15368