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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll ans=1,n;
	string s;
	map<char,ll> m;
	cin >> n >> s;
	rep(i,n) m[s[i]]++;
	for(auto&& e:m){
		ans=ans*(e.second+1)%mod;
	}
	cout << ans-1 << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,sum=0,ans=0;
	cin>>a>>b;
	if(a<b)
	{
		for(long long i=a;i<=b;i++)
		{
			if(i<0) ans++;
			if(i==0)
			{
				cout<<"Zero";
				return 0;
			}
		}
		sum=b-a+1;
		if(a>0)
		{
			cout<<"Positive";
			return 0;
		}
		if(b<0)
		{
			if(sum%2==0) cout<<"Positive";
			else cout<<"Negative";
			return 0;
		}
		if(ans%2==0) cout<<"Positive";
		else cout<<"Negative";
	}
	if(a>b)
	{
		for(long long i=b;i<=a;i++)
		{
			if(i<0) ans++;
			if(i==0)
			{
				cout<<"Zero";
				return 0;
			}
		}
		sum=a-b+1;
		if(b>0)
		{
			cout<<"Positive";
			return 0;
		}
		if(a<0)
		{
			if(sum%2==0) cout<<"Positive";
			else cout<<"Negative";
			return 0;
		}
		if(ans%2==0) cout<<"Positive";
		else cout<<"Negative";
	}
	if(a==b)
	{
		if(a>0) cout<<"Positive";
		else if(a<0) cout<<"Negative";
		else cout<<"Zero";
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;

int main() {
    int n, a;
    int e = 0, o;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 0) e++;
    }
    o = n - e;

    cout << ((o % 2 == 0) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] v=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(a[j-1]>a[j]){
					int box=v[j-1];
					v[j-1]=v[j];
					v[j]=box;
					box=a[j];
					a[j]=a[j-1];
					a[j-1]=box;
				}
			}
		}
		int max=Integer.MIN_VALUE;
		int maxPtr=0;
		for(int i=0;i<n;i++){
			if(v[i]>max){
				max=v[i];
				maxPtr=a[i];
			}
		}
		System.out.println(maxPtr+" "+max);
	}
}

Measured memory_bytes: 17348
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<int,int> memo;
  rep(i,N){
    int a;
    cin >> a;
    memo[a]++;
  }

  vector< pair<int,int> > v;
  FOR(it,memo){
    v.push_back(*it);
  }

  bool ret = true;
  rep(i,v.size()-1){
    if(v[i].first + 1 != v[i+1].first){
      ret = false;
    }
  }

  if(v[0].second == 1){
    REP(i,1,v.size()){
      if(v[i].second == 1) ret = false;
    }
    if(v[v.size()-1].first != 2 * v[0].first) ret = false;
  }
  else if(v[0].second == 2){
    REP(i,1,v.size()){
      if(v[i].second == 1) ret = false;
    }
    if(v[v.size()-1].first != 2 * v[0].first - 1) ret = false;
  }
  else ret = false;
  

  
  if(ret) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;

using int64 = long long;
using P = pair<int,int>;
using TP = tuple<int,int,int>;

struct edge {
    long u,v,cost;
    edge(long _u, long _v, long _cost): u(_u), v(_v), cost(_cost){}
};

class unionfind {
    vector<int64> _size;
    vector<int64> _root;
public:
    unionfind(int n) {
        _size = vector<int64> (n+1, 1);
        _root = vector<int64> (n+1);
        iota(_root.begin(), _root.end(), 0);
    }
    int64 root(int x) {
        while(x != _root[x]) x = _root[x] = _root[_root[x]];
        return x;
    }
    bool merge(int x, int y) {
        if (is_same(x,y)) return false;
        x = root(x); y = root(y);
        if (_size[x] > _size[y]) swap(x,y);
        _size[y] += _size[x];
        _root[x] = y;
        return true;
    }
    int64 is_same(int x, int y) {
        return root(x) == root(y);
    }
    int64 size(int x) {
        return _size[root(x)];
    }
};

int64 kruskal(const int& n,vector<edge>& edges) {

    auto cmp = [](edge x, edge y) {return x.cost < y.cost;};
    sort(edges.begin(), edges.end(), cmp);
    unionfind uni(n);
    int res = 0;
    for (auto e : edges) {
        if (uni.is_same(e.u , e.v)) continue;
        uni.merge(e.u, e.v);
        res += e.cost;
    }

    return res;
}

int main() {
    int n;
    cin >> n;
    vector<TP> p;
    for (int i=1; i<=n; i++) {
        int x,y;
        cin >> x >> y;
        p.emplace_back(x, y, i);
    }


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

    vector<edge> edges;
    for (int i=0; i<n-1; i++) {
        int x1,y1,u;
        tie(x1, y1, u) = p[i];
        int x2,y2,v;
        tie(x2, y2, v) = p[i+1];
        edges.emplace_back(u,v, abs(x1 - x2));
    }

    auto cmp = [](TP x, TP y) {return get<1>(x) < get<1>(y);};
    sort(p.begin(), p.end(), cmp);

    for (int i=0; i<n-1; i++) {
        int x1,y1,u;
        tie(x1, y1, u) = p[i];
        int x2,y2,v;
        tie(x2, y2, v) = p[i+1];
        edges.emplace_back(u, v, abs(y1 - y2));

    }


    int ans = kruskal(n, edges);

    cout << ans << endl;

}

Measured memory_bytes: 9584
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int k = scan.nextInt(); 
		
		double num[] = new double[n];
		
		for(int i = 0; i < n ; i++){
			num[i] = ((scan.nextDouble()+1)/2);
		}
		

		double exp[] = new double[n];
		exp[0] = num[0];
		
		for(int i = 1; i < n ; i++){
			exp[i] = (exp[i-1] + num[i]);
		}
		
		double max = exp[k - 1];
		double sum = 0;
		
		for(int i = 1; i < n - k + 1; i++){
			sum = exp[i + k - 1]-exp[i-1];
			if(max <= sum)max = sum;
		}
		
		System.out.println(max);
		
	}
}

Measured memory_bytes: 160324
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	ll i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;
	ll ans = i/2*2+o+j/2*2+l/2*2;
	if(i > 0 && j > 0 && l > 0)	ans = max(ans, (i-1)/2*2+o+(j-1)/2*2+(l-1)/2*2+3);
	cout << ans << endl;
	return 0;
}

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

const ll INF = pow(10, 9) + 7;

int main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int ans = 0, now = 1;
  rep(i,n){
    if(now == a[i]){
      now++;
      continue;
    }
    ans++;
  }
  if(now==1){
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}

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

const int N = 1054;

int n;
int x[N], y[N], r[N];
bool used[N];
double e[N][N], d[N];

inline void down(double &x, const double y) {x > y ? x = y : 0;}
inline double max(const double x, const double y) {return x < y ? y : x;}

void Dijkstra(int s) {
	int i, x;
	for (i = 0; i <= n; ++i) d[i] = INFINITY; d[s] = 0;
	for (; ; ) {
		for (x = 0, i = 1; i <= n; ++i)
			if (!used[i] && d[i] < d[x]) x = i;
		if (!x) return;
		used[x] = true;
		for (i = 1; i <= n; ++i) down(d[i], d[x] + e[x][i]);
	}
}

int main() {
	int i, j;
	scanf("%d%d%d%d%d", x + 1, y + 1, x + 2, y + 2, &n);
	n += 2;
	for (i = 3; i <= n; ++i) scanf("%d%d%d", x + i, y + i, r + i);
	for (i = 1; i <= n; ++i)
		for (j = 1; j <= n; ++j)
			e[i][j] = max(hypot(x[i] - x[j], y[i] - y[j]) - (r[i] + r[j]), 0);
	Dijkstra(1);
	printf("%.12lg\n", d[2]);
	return 0;
}

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

int main()
{
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'e' || c == 'o' || c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

lint dp[3][3001][3001];

int main(void){
    int N,S;
    cin >> N >> S;
    int A[N];
    rep(i,N) cin >> A[i];
    dp[0][0][0]=1;
    rep(i,N) rep(j,3001){
        dp[0][i+1][j]=(dp[0][i+1][j]+dp[0][i][j])%MOD;
        dp[1][i+1][j]=(dp[1][i+1][j]+dp[0][i][j])%MOD;
        dp[1][i+1][j]=(dp[1][i+1][j]+dp[1][i][j])%MOD;
        if(j+A[i]<=S) dp[1][i+1][j+A[i]]=(dp[1][i+1][j+A[i]]+dp[1][i][j]+dp[0][i][j])%MOD;
        dp[2][i+1][j]=(dp[2][i+1][j]+dp[1][i][j]+dp[0][i][j])%MOD;
        if(j+A[i]<=S) dp[2][i+1][j+A[i]]=(dp[2][i+1][j+A[i]]+dp[1][i][j]+dp[0][i][j])%MOD;
        dp[2][i+1][j]=(dp[2][i+1][j]+dp[2][i][j])%MOD;
    }
    cout << dp[2][N][S] << endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/04  Problem: ABC 045 B / Link: http://abc045.contest.atcoder.jp/tasks/abc045_b  ----- */


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

	VS s(3);
	FOR(i, 0, 3) {
		cin >> s[i];
	}
	int turn = 0;
	VI idx(3, 0);
	LL ans = 0LL;
	while (1) {
		if (idx[turn] == SZ(s[turn])) {
			ans = turn;
			break;
		}
		int nx = s[turn][idx[turn]] - 'a';
		idx[turn]++;
		turn = nx;
		DD(de("to",turn))
	}


	cout << string(1, ans + 'A') << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, X;
  cin >> N;
  vector<int> vec(N);
  vector<int> diff(N);
  REP(i, N) {
    cin >> vec[i];
    diff[i] = vec[i] - (i+1);
  }
  sort(diff.begin(), diff.end());
  int sub = diff[N/2];
  if (N % 2 == 0) {
    sub = diff[N/2 -1];
  }
  
  ll ans = 0;
  REP(i, N) {
    ans += abs(diff[i] - sub);
  }
  cout << ans << endl;
  return 0;
}  

Measured memory_bytes: 1792
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    std::smatch m;

    if (std::regex_match(S, m, std::regex("A?KIHA?BA?RA?"))) {
        std::cout << "YES" << std::endl;
    }
    else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    aa = list(map(int, input().split()))
    bb = list(map(int, input().split()))
    aa.reverse()
    bb.reverse()
    bb.append(0)

    cnt = 0
    zan = 0
    for a, b in zip(aa, bb):
        # 前回残り勇者
        cnt += min(a, zan)
        # 今回勇者
        if a > zan:
            cnt += min(a - min(a, zan), b)
            zan = b - min(a - min(a, zan), b)
        else:
            zan = b

    print(cnt)
    
resolve()

Measured memory_bytes: 82020
from sys import stdin
from bisect import bisect_right, bisect_left


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    C.sort()

    ans = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22720
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(ll X) {
  cout << 10 - X / 200 << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll X;
  cin >> X;

  solve(X);

  return 0;
}


Measured memory_bytes: 3644
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

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
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var a int
	var s string
	fmt.Fscan(read, &a, &s)
	printansStr(a >= 3200, s, "red")
}


Measured memory_bytes: 640
n = int(input())
i = 1
ans = ''

if n == 0:
    print(0)
    exit()

while n != 0:
    if  n%(2**i) != 0:
        n -= (-2)**(i-1)
        ans += '1'

    else:
        ans += '0'
    i += 1
    
print(int(ans[::-1]))

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

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> v(N, vector<int>(3));
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 3; ++j) {
            cin >> v[i][j];
        }
    }
    vector<int> res(N);
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 3; ++j) {
            bool ok = true;
            for(int k = 0; k < N; ++k) {
                ok &= (i == k || v[i][j] != v[k][j]);
            }
            if(ok) {
                res[i] += v[i][j];
            }
        }
    }
    for(auto x : res) {
        cout << x << endl;
    }
}


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

typedef long long ll;

using namespace std;

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


int main(){
    int N,a,b;
    cin >> N;
    int P[N],Q[N];
    vector<int> base(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    for(int i=1;i<=N;i++) base[i-1] = i;
    int rank = 1;
    do{
        int i=0;
        for(auto num : P){
            if(num == base[i]) {
                i++;
            }
            else break;
        }
        if(i==N) a = rank;
        i=0;
        for(auto num : Q){
            if(num == base[i]) {
                i++;
            }
            else break;
        }
        if(i==N) b = rank;
        rank++;
    }while(next_permutation(base.begin(),base.end()));
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

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

    int n=s.size();
    n--;
    ll ans=0;
    rep(bit,1<<n){
        ll tmp=0;
        ll add=0;
        rep(i,n){
            add*=10;
            add+=s[i]-'0';
            if(bit & 1<<i){
                tmp+=add;
                add=0;
            }
        }
        add*=10;
        add+=s[n]-'0';
        tmp+=add;
        //cout<<tmp<<endl;
        ans+=tmp;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10 ** 9)

N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]
ans = 0


def calc_score(A):
    score = 0
    for a, b, c, d in X:
        if A[b - 1] - A[a - 1] == c:
            score += d
    return score


def dfs(A):
    global ans
    if len(A) == N:
        score = calc_score(A)
        ans = max(ans, score)

    elif len(A) == 0:
        for n in range(1, M + 1):
            dfs([n])
    else:
        for n in range(A[-1], M + 1):
            dfs(A + [n])


dfs([])
print(ans)


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

int main(){
  int n,k;cin>>n>>k;
  vector<int>h(n);
  for(auto&& x:h)cin>>x;
//  for(auto&& x:h)cout<<x;
  
  sort(begin(h),end(h));
  int ans=1e9;
  for(int i=0;i+k-1<n;i++)ans=min(ans,h[i+k-1]-h[i]);
  cout<<ans<<endl;
}

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

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  double T,X,ans;
  cin >> T >> X;
  ans = T/X;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int p = 1e9 + 7;

inline int fpow(int x, int y){
	int ans = 1;
	while(y){
		if(y & 1) ans = 1ll * ans * x % p;
		x = 1ll * x * x % p, y >>= 1;
	}
	return ans;
}

int sum[maxn * maxn], inv[maxn * maxn];

inline int C(int n, int m){
	return 1ll * sum[n] * inv[m] % p * inv[n - m] % p;
}

int n, k;
int f[maxn][maxn];

int main(){
	scanf("%d%d", &n, &k);
	if(k == 1) return printf("1"), 0;
	sum[0] = 1;for(int i = 1;i <= n * k;i++) sum[i] = 1ll * sum[i - 1] * i % p;
	inv[n * k] = fpow(sum[n * k], p - 2);
	for(int i = n * k - 1;~i;i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % p;
	f[0][0] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= i;j++){
			f[i][j] = f[i - 1][j];
			f[i][j] = (f[i][j] + 1ll * f[i][j - 1] * (n - j + 1) % p * C(n * k - i - (j - 1) * (k - 1) - 1, k - 2)) % p;
		}
	}
	printf("%d", f[n][n]);
}

Measured memory_bytes: 48992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


ll dp[110][100010];
int main(){
    int N,W; cin >> N >> W;
    rep(i,110)rep(j,100010) dp[i][j] = 0;
    rep(i,N){
        ll w,v; cin >> w >> v;
        rep(j,W+1){
            if(j-w >= 0) dp[i+1][j] = max(dp[i+1][j],dp[i][j-w]+v);
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;

}



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

using namespace std;

typedef long long ll;


ll largemod(ll m,string s)
{
    ll mod=0;

    for(int i=0; i<s.size(); i++)
    {
        mod = (mod*10 + s[i]-'0')%m;
    }
    return mod;


}

int main(void)
{

    int t;
    cin>>t;
cout<<t+t*t+t*t*t<<endl;




}


Measured memory_bytes: 3620
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* simple problem */

const int inf = 1e9;
const int maxn = 1e5+5;
int A[maxn], dp[maxn];

int dfs(const int i, const int k)
{
    if (i == 0)
        return 0;
    int& ans = dp[i];
    if (-1 == ans) {
        ans = inf;
        FOR(d,1,k+1) if (i-d >= 0) {
            const int j = i-d;
            const int res = dfs(j,k)+abs(A[i]-A[j]);
            ans = min(ans,res);
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,k;
    while (cin >> n >> k) {
        memset(dp,-1,sizeof(dp));
        FOR(i,0,n)
            cin >> A[i];
        const int ans = dfs(n-1,k);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <vector>

using namespace std;
const int maxn = 1e5+100;
const int INF = 0x3f3f3f3f;
#define pr(x)      // cout << #x << " = " << x << " ";
#define prln(x)    // cout << #x << " = " << x <<endl;
#define ll long long
int head[maxn], nxt[maxn], to[maxn], dfsn, cnt, id[maxn], l[maxn], r[maxn], p[maxn], _n, sum[maxn<<2], dep[maxn];
void addedge(int u, int v) {
	nxt[cnt] = head[u];
	head[u] = cnt;
	to[cnt++] = v;
}
void init(int n) {
	cnt = dfsn = 0;
	_n = 1;
	while(_n < n) _n = _n*2;
	int _nn = _n*2;
	for(int i = 0; i <= _nn; ++i) sum[i] = -1;
	for(int i = 0; i <= n;++i) {
		head[i] =-1;
		dep[i] = 0;
	}
}

void dfstree(int fa,int u) {
	id[u] = ++dfsn;
	dep[u] = dep[fa]+1;
	for(int i = head[u]; ~i; i = nxt[i]){
		dfstree(u,to[i]);
	}
	l[u] = id[u]; r[u] = dfsn;
	pr(fa);pr(u);pr(dep[fa]);prln(dep[u]);
}
inline void getans(int& ans, const int& v2){
	if(ans == -1 || dep[ans] < dep[v2]) ans = v2;
}
void pushdown(int rt) {
	if(sum[rt] != -1) {
		getans(sum[rt<<1], sum[rt]);
		getans(sum[rt<<1|1],sum[rt]);
	}
}
void update(int rt, int l, int r, int ql, int qr, int v) {
	if(ql <= l && r <= qr) {
		getans(sum[rt], v);
		pr(sum[rt]);pr(dep[sum[rt]]);pr(v);prln(dep[v]);
		return;
	}
	pushdown(rt);
	int m = l + r >> 1;
	if(m >= ql) update(rt<<1, l, m, ql, qr, v);
	if(m < qr) update(rt<<1|1, m+1, r, ql, qr, v);
}
int query(int rt) {
	rt += _n-1;
	int ans, depth = -1;
	while(rt>=1) {
		if(sum[rt] != -1) {
			if(dep[sum[rt]] > depth) {
				depth = dep[sum[rt]];
				ans = sum[rt];
			}
		}
		rt = rt>>1;
	}
	return ans;
}
int main(){
#ifdef LOCAL
    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
  //freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
 #endif
    int n, m, u, x, test= 0;
    char op[10];
    while(cin >> n >> m && (n||m)) {
    	ll ans = 0;
    	init(n);
    	for(int i = 2; i <= n; ++i) {
    		scanf("%d", &u);
    		addedge(u,i);
    	}
    	//prln(test++);
    	dep[0] = 0;
    	dfstree(0,1);
    	pr(id[1]);prln(dfsn);
    	update(1, 1, _n, l[1], r[1], 1);
    	prln(query(id[1]));
    	//prln(test++);
    	for(int i = 1; i <= n; ++i) {
    		pr(i);pr(dep[i]);prln(id[i]);
    	}
    	for(int i = 0; i < m; ++i) {
    		scanf("%s%d", op, &x);
    		if(op[0] == 'M') {
    			pr(x);pr(id[x]);prln(r[x]);
    			//sum[id[x]+_n-1] = x;
    			update(1, 1, _n, id[x], r[x], x);
    			prln(test++);
    		} else {
    			ans += query(id[x]);
    			pr(x);pr(id[x]);prln(query(id[x]));
    			prln(ans);
    			//prln(test++);
    		}
    	}
    	prln(test++);
    	printf("%lld\n", ans);
    }
    return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;



int main() {

	

	int n, m;
	cin >> n >> m;
	VI v(n);

	REP(i, m) {
		int a, b;
		cin >> a >> b;

		a--; b--;
		v[a]++;
		v[b]++;
	}

	REP(i, n) {
		if (v[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
	

}

Measured memory_bytes: 640
N=int(input())
A=[int(input()) for _ in range(N)]

ans=0
for i in range(N-1):
  if A[i]:
    ans+=A[i]//2
    A[i]%=2
  if A[i] and A[i+1]:
    ans+=1
    A[i]-=1
    A[i+1]-=1
#print(A)

if A[-1]:
  ans+=A[-1]//2
print(ans)

Measured memory_bytes: 7072
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printc;
using io::prints;

const int N = 1e3 + 7;
int n;
ll x[N], y[N], z[N];

inline char work(ll x, ll y, ll &X, ll &Y, ll k) {
	if (abs(x - X) > abs(y - Y)) {
		if (x > X) return X += k, 'R';
		return X -= k, 'L';
	}
	if (y > Y) return Y += k, 'U';
	return Y -= k, 'D';
}

int main() {
	rd(n);
	for (int i = 1; i <= n; i++)
		rd(x[i], y[i]), z[i] = abs(x[i] + y[i]) % 2;
	for (int i = 1; i <= n; i++)
		if (z[i] != z[1]) return print(-1), 0;
	vector<ll> d;
	for (int i = 30; ~i; i--) d.pb(1ll << i);
	if (!z[1]) d.pb(1ll);
	print(d.size());
	for (ll k : d) print(k, ' ');
	prints("");
	for (int i = 1; i <= n; i++) {
		ll X = 0, Y = 0;
		for (ll k : d)
			printc(work(x[i], y[i], X, Y, k));
		prints("");
	}
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
using namespace std;
int main(){
    int n,max,min;
    long long sum=0;
    int a[10001];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum=sum+a[i];
        if(i==1){
            max=a[i];
            min=a[i];
        }
        else{
            if(max<a[i]){
                max=a[i];
            }
            if(min>a[i]){
                min=a[i];
            }
        }
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3128
#include<stdio.h>
#include<stdlib.h>
#define INF 1000000001
typedef struct vertice
{
  int cost;
  int status;
  int numOfAdj;
  int *adjList;
  int *costList;
} ver;
ver *v;
int n;//the number of vertices
void init();
void setArray(int);
void dijkstra(void);
int main(void)
{
  int i,j;//counter
  int key;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++)
    {
      scanf("%d",&key);
      scanf("%d",&v[key].numOfAdj);
      setArray(key);
      for(j=0;j<v[key].numOfAdj;j++) scanf("%d%d",&v[key].adjList[j],&v[key].costList[j]);
    }
  dijkstra();
  free(v);
  return 0;
}
void init(void)
{
  int i;//counter
  v=(ver*)malloc(sizeof(ver)*n);
  for(i=0;i<n;i++)
    {
      v[i].numOfAdj=0;
      v[i].status=0;
      v[i].cost=INF;
    }
}
void setArray(int key)
{
  v[key].adjList=(int*)malloc(sizeof(int)*v[key].numOfAdj);
  v[key].costList=(int*)malloc(sizeof(int)*v[key].numOfAdj);
}
void dijkstra(void)
{
  int i;//count
  int current=0;
  int viewing;
  int next;
  int minCost;
  v[0].cost=0;
  for(;;)
    {
      v[current].status=1;
      minCost=INF;
      for(i=0;i<v[current].numOfAdj;i++)
	{
	  viewing=v[current].adjList[i];
	  if(v[viewing].status==0)
	    {
	      if(v[current].cost+v[current].costList[i]<v[viewing].cost)
		{
     		  v[viewing].cost=v[current].cost+v[current].costList[i];
		  //printf("v[%d].cost=%d\n",viewing,v[viewing].cost);
		}
	    }
	}
      for(viewing=0;viewing<n;viewing++)
	{
	  if(v[viewing].status==0&&v[viewing].cost<minCost)
	    {
	      minCost=v[viewing].cost;
	      next=viewing;
	    }
	}
      if(minCost==INF) break;
      //printf("next->%d\n",next);
      current=next;
    }
  for(i=0;i<n;i++) printf("%d %d\n",i,v[i].cost);
}



Measured memory_bytes: 5768
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    return (b == 0) ? a : gcd(b, a % b);
}
int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    unordered_map<int, int> mp;
    for (int j = n; j >= 1; j--)
    {
        if ((mp[j] + a[j]) % 2 == 1)
        {
            b[j]++;
            for (int i = 1; i * i <= j; i++)
            {
                if (j % i == 0)
                {
                    mp[i]++;
                    if (i * i != j)
                        mp[j / i]++;
                }
            }
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (b[i] == 1)
            cnt++;
    }
    cout << cnt << endl;
    for (int i = 1; i <= n; i++)
    {
        if (b[i] == 1)
            cout << i << endl;
    }
}


Measured memory_bytes: 10696
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,K,a,b;cin>>N>>K;
  vector<P> AB;
  REP(i,0,N){
    cin>>a>>b;
    AB.push_back(make_pair(a,b));
  }
  sort(ALL(AB));
  int idx=0,sum=0;;
  REP(i,0,N){
    sum+=AB[i].second;
    if(sum>=K){
      a=AB[i].first;
      break;
    }
  }
  print(a)

}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	ll ok = 1e9, ng = 0;
	ll k = n * (n+1) / 2 / 2 + 1;
	BinaryIndexedTree<ll> bit(202020);
	while(ok-ng>1){
		ll mid = (ok+ng)/2;
		vl sum(n+1,0);
		rep(i,n){
			ll c = (a[i]<=mid) ? 1 : -1;
			sum[i+1] = sum[i] + c;
			bit.add(100000+sum[i+1],1);
		}
		ll cnt = 0;
		REP(i,1,n+1){
			if(a[i-1]<=mid){
				cnt += n-i+1 - bit.sum(100000+sum[i]-1);
			}else{
				cnt += n-i+1 - bit.sum(100000+sum[i]+1);
			}
			bit.add(100000+sum[i],-1);
		}
		if(cnt >= k) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

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

ll keta(ll n) {
    ll res = 0;
    ll p = 1;
    while(n >= p) {
        p *= 10;
        res++;
    }
    return res;
}

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) {
            cout << "OK" << endl;
            break;
        }
        if(i == b) {
            cout << "NG" << endl;
            break;
        }
    }
}

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

bool data[110];

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

    int ans = 0;
    for(int i = 0; i < N; ++i){
        int d;
        cin >> d;
        if(!data[d]){
            data[d] = true;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

     long long int a,b,c,d,e,f,i,j,t=0,u=0;
     string x,y;
     vector<int> v;
     vector<int> v1;
     vector<int> v2;
     cin>>x;
     for(i=0;i<x.length();i++){
        if(x[i]=='A')
            t++;
        else if(x[i]=='B')
            u++;
     }
     if(t>=1 && u>=1){
        cout<<"Yes"<<endl;
     }
     else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 256
#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 n; cin >> n;
	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		ans *= i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <math.h>
int main(void){
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.8f\n",sqrt(pow(x2-x1,2)+pow(y2-y1,2)));
	return 0;
}


Measured memory_bytes: 2100
nums = input().split()
N = int(nums[0])
K = int(nums[1])
S = input()
s1 = S[:K - 1]
s2 = S[K:]

if S[K - 1] == 'A':
    s = s1 + 'a' + s2

elif S[K - 1] == 'B':
    s = s1 + 'b' + s2

else:
    s = s1 + 'c' + s2

print(s)


Measured memory_bytes: 3060
// C言語

#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

#define MAX	10000


// 解法(分けた方が見やすいかなと思って関数にした)
int Answer(int N , vector<int> character)
{
	int ans = 9999999;
	// 消す基準となる玉の位置
	for (int i = 0; i < N; i++)
	{
		// k : 変えた後の色
		for (int j = 1; j <= 3; j++)
		{
			
			// 色を変えたところで意味のない部分は考えない(悪いけどごり押し) ここから-----
			if (i == 0)
			{
				if (character[i + 1] != j)
				{
					continue;
				}
			}
			else if (i == N - 1)
			{
				if (character[i - 1] != j)
				{
					continue;
				}
			}
			else
			{
				if (character[i - 1] != j && character[i + 1] != j)
				{
					continue;
				}
			}
			// ----- ここまで
			

			// vectorをコピーし、指定した要素を削除する
			vector<int>search(character);
			vector<int>::iterator it = search.begin() + i;
			it = search.erase(it);
			search.insert(it , j);

			int cnt = 1;
			for (int k = 0; k < search.size(); k += cnt)
			{
				cnt = 1;
				for (int l = k + 1; l < search.size(); l++)
				{
					if (search[k] != search[l])
					{
						break;
					}
					cnt++;
				}
				// 4つ以上なら削除する
				if (cnt >= 4)
				{
					it = search.begin() + k;
					search.erase(it , it + cnt);
					// 途中から探索し直す
					k = - 1;
					cnt = 1;
				}
			}

			

			ans = min(ans , (int)search.size());
			// 0なら探索終了
			if (search.empty() == true)
			{
				return 0;
			}
		}
	}

	return ans;
}
	

int main(void)
{
	int N;
	vector<int> character;

	while (1)
	{
		// 宣言やら入力やら
		int ans = 0;
		int i;
		cin >> N;
		if (N == 0)
		{
			break;
		}
		character.resize(N);
		for (i = 0; i < N; i++)
		{
			cin >> character[i];
		}

		ans = Answer(N , character);

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1352
//@source : 
//@create : 15:19:50 Tuesday 30/06/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; ++i) {
        int v;
        cin >> v;
        s.insert(v);
    }
    vector<int> a;
    for (int i = -101; i <= 101; ++i) {
        if (s.find(i + x) == s.end()) {
            a.push_back(i + x);
        }
    }
    int pos = 0;
    for (int i = 1; i < a.size(); ++i) {
        if (abs(a[i] - x) < abs(a[pos] - x)) {
            pos = i;
        }
    }
    cout << a[pos] << "\n";
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    while (t--) {
        solve();
    }
  //  cerr << fixed << setprecision(5) << double(clock()) * 1000 / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int[] a = new int[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		int n = sc.nextInt();
		Arrays.sort(a);
		long ans = 0;
		int m = n/a[2];
		for(int i = 0; i <= n/a[2]; i++) {
			for(int j = 0; j <= n/a[1]; j++) {
				int x = n -(i * a[2] + j * a[1]);
				if(x % a[0] == 0 && x >= 0) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32816