akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int x,y,z,k; cin >> x >> y >> z >> k;
    vector<ll> a(x),b(y),c(z);
    for(int i = 0; i < x; i++){
        cin >> a[i];
    }
    for(int i = 0; i < y; i++){
        cin >> b[i];
    }
    for(int i = 0; i < z; i++){
        cin >> c[i];
    }
    sort(c.begin(),c.end(),greater<ll>());
    vector<ll> absum;
    for(int A = 0; A < x; A++){
        for(int B = 0; B < y; B++){
            absum.push_back(a[A]+b[B]);
        }
    }
    sort(absum.begin(),absum.end(),greater<ll>());
    vector<ll> ans;
    for(int i = 0; i < min(x*y,k); i++){
        for(int j = 0; j < z; j++){
            ans.push_back(absum[i]+c[j]);
        }
    }
    sort(ans.begin(),ans.end(),greater<ll>());
    for(int i = 0; i < k; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 43368
n, m=map(int,input().split())

l_max=0
r_min=n

for i in range(m):
    l, r=map(int,input().split())
    if l>l_max:
        l_max=l
    if r<r_min:
        r_min=r

ans=r_min-l_max+1
if ans>=0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut tot = 1i64;
    for a in a {
        tot = tot.saturating_mul(a);
    }
    let bil = 1_000_000_000;
    puts!("{}\n", if tot > bil * bil { -1 } else { tot });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2352
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<ll> A(N+1), B(N+1, 0);
	rep(i, N+1) cin >> A[i];
	rep(i, N) cin >> B[i];
	ll cnt = 0;
	ll over = 0;
	rep(i, N+1) {
		if(A[i]<=B[i]+over) {
			cnt += A[i];
			if(over<A[i]) over = B[i]+over-A[i];
			else over = B[i];
		} else {
			cnt += (B[i]+over);
			over = 0;
		}
	}

	cout << cnt << endl;
	
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a, b, c;
	cin>>a>>b;
	rep(i, 0, b.length()-1) c += b[i];
	if (a == c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<x<<endl;
#define Nmax 500005
using namespace std;

ll n, ans, a, b;
string s;

int main()
{
    cin >> n >> a >> b;
    if (n==1){
        if (a==b) cout << 1 << '\n';
        else cout << 0 << '\n';
    }
    else if (a == b) cout << 1 << '\n';
    else if (a > b) cout << 0 << '\n';
    else cout << (b * (n - 1) + a) - (a * (n - 1) + b) + 1 << '\n';

    return 0;
}


Measured memory_bytes: 256
import bisect

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 = 0

for b in B:
    indexA = bisect.bisect_left(A, b)
    indexC = bisect.bisect_right(C, b)

    ans += indexA * (N-indexC)

print(ans)

Measured memory_bytes: 23232
use proconio::input;
fn main() {
    input! {
        n:isize,
        mut ar: [usize; n]
    }

    ar.sort();
    let mut num = [0; 1_000_001];
    for x in ar {
        num[x] += 1;
    }

    let mut res = 0;

    for i in 1..=1_000_000 {
        if num[i] == 0 {
            continue;
        }
        if num[i] == 1 {
            res += 1;
        }

        for j in (0..=1_000_000).step_by(i) {
            num[j] = 0;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 9048
n = int(input())
L = list(map(int,input().split()))
a = 1
L = sorted(L)
for i in L:
    a = a*i
    if a == 0:
        break
    if a > 10**18:
        break
 
if a <= 10**18:
    print(a)
else:
    print(-1)

Measured memory_bytes: 21772
import sys
from itertools import accumulate

rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))

n, k = rm()
a = [(i+1)/2 for i in rl()]
a = [0] + list(accumulate(a))
ans = 0
for i in range(n-k+1):
    ans = max(ans, a[i+k] - a[i])
print(ans)

Measured memory_bytes: 31788
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C - (A - B), 0) << endl;
}


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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

int dp[101][101];

void solve() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> f(H, vector<char>(W));
  vector<vector<int>> dp(H, vector<int>(W, INF));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> f[i][j];
    }
  }
  dp[0][0] = f[0][0] == '#';
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i != 0 || j != 0) {
        if (i > 0) {
          if (f[i - 1][j] == '.' && f[i][j] == '#') {
            dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
          } else {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
          }
        }
        if (j > 0) {
          if (f[i][j - 1] == '.' && f[i][j] == '#') {
            dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
          } else {
            dp[i][j] = min(dp[i][j], dp[i][j - 1]);
          }
        }
      }
    }
  }
  cout << dp[H - 1][W - 1] << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 384
let () =
  let open Queue in
  let n = read_int () in
  let preorder = create () in
  for _ = 0 to n - 1 do
    add (Scanf.scanf "%d " (fun i -> i)) preorder;
  done;
  let inorder = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let t = Array.make (40 + 1) 0 in
  Array.iteri (fun i e -> t.(e) <- i) inorder;
  let postorder = create () in
  let rec doit l r =
    if l >= r then ()
    else begin
      let root = take preorder in
      let m = t.(root) in
      doit l m;
      doit (m + 1) r;
      add root postorder
    end in
  doit 0 n;
  print_int (take postorder);
  iter (fun e -> print_string " "; print_int e) postorder;
  print_newline ()

Measured memory_bytes: 2380
#include<bits/stdc++.h>
using namespace std;
long long int gcd(long long int a,long long int b)
    {if(a%b==0){return b;}
    return gcd(b,a%b);
    }
long long int seive[1000005];
int main()
    {ios::sync_with_stdio(0);
    cin.tie(0);
    //long long int seive[1000005];
    memset(seive,0,sizeof(seive));
    seive[1]=1;
    for(long long int i=2;i<1000005;i++)
        {if(seive[i]==0)
            {seive[i]=i;
            for(long long int j=i*i;j<1000005;j+=i){seive[j]=i;}
            }
        }
    long long int n;
    cin>>n;
    long long int arr[n];
    for(long long int i=0;i<n;i++){cin>>arr[i];}
    unordered_map<long long int,long long int> mp;
    long long int poss=1;
    for(long long int i=0;i<n;i++)
        {set<long long int> s;
        long long int z=arr[i];
        while(z!=1)
            {s.insert(seive[z]);
            z=z/seive[z];
            }
        for(auto x:s)
            {if(mp.find(x)!=mp.end()){poss=0;break;}
            //cout<<x<<" ";
            mp[x]=1;
            }
        //cout<<"\n";
        if(poss==0){break;}
        }
    if(poss){cout<<"pairwise coprime"<<"\n";exit(0);}
    long long int z=arr[0];
    for(long long int i=0;i<n;i++){z=gcd(z,arr[i]);}
    if(z==1){cout<<"setwise coprime\n";}
    else{cout<<"not coprime\n";}
    }


Measured memory_bytes: 19280
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define f first
#define s second 
using namespace std;
const LL INF = (LL) 1e9 + 5;
const LL MOD = (LL) 1e9 + 7;
const int MAXN = 2000005;

LL fac[MAXN], inv[MAXN];

LL C(LL n, LL k) {
	return fac[n] * inv[k] % MOD * inv[n - k] % MOD;
}

LL qpow(LL a, LL pw) {
	LL res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

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

	fac[0] = inv[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = qpow(fac[i], MOD - 2);
	}

	LL r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	
	LL sum = C(r1 + c1, r1), u = r1, d = r1, l = c1, r = c1, ans = sum;
	for (LL dist = r1 + c1 + 1; dist <= r2 + c2; dist++) {
		sum = (sum * 2 + C(dist - 1, d - 1) - C(dist - 1, u) + MOD) % MOD;
		l++; r++;
		if (u < r2) {
			u++;
			l--;
			sum = (sum + C(dist, u)) % MOD;
		}
		if (r > c2) {
			sum = (sum - C(dist, d) + MOD) % MOD;
			d++;
			r--;
		}
		ans += sum;
//		cout << "At " << dist << " " << d << " " << u << " " << l << " " << r << "\n";
	}
	
	cout << ans % MOD << '\n';
	
	return 0;
}

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

int main () {
  int N;
  cin >> N;
  
  int f = 0;
  int a =N;
  while (a > 0) {
    f += a % 10;
    a /= 10;
  }
  
  if (N % f == 0) {
    cout << "Yes" << endl;
  }
  else { 
    cout << "No" << endl;
  }
}

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

signed main() {
  int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    	std::string s(a,'0');
    	std::string t(w-a,'1');
  		std::string S(a,'1');
  		std::string T(w-a,'0');
  for(int i=0;i<h;++i){
    if(i<b){
    	printf("%s%s\n",s.c_str(),t.c_str());
    }
    else{
    	printf("%s%s\n",S.c_str(),T.c_str());
    }
  }
}


Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

	while (1) {
		long long n;
		cin >> n;
		if (n == 0) break;
		int sum = 1;
		for (int i = 2; i * i <= n; i++) {
			if (n % i == 0) {
				sum += i;
				if(i != n/i)
					sum += n / i;
			}
		}
		if (n == 1) sum = 0;
		string s;
		if (sum == n) s = "perfect number";
		else if (sum > n) s = "abundant number";
		else s = "deficient number";

		cout << s << endl;
	}

	return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <deque>
using namespace std;

int main() {
    int K, X;
    cin >> K >> X;

    for(int i = 0; i < 2 * (K - 1) + 1; ++i)
    {
        int num = X - (K - 1) + i;
        cout << num << " ";
    }
}

Measured memory_bytes: 888
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
max_Vi = 10**3
max_Wi = W
dp=[0]+[max_Wi+1]*(N*max_Vi)
dp=np.array(dp)
for i in range(N):
  wi,vi=map(int,input().split())
  dp[vi:]=np.minimum(dp[vi:],dp[:-vi]+wi)
print(np.max(np.where(dp <= W)))

Measured memory_bytes: 14808
Infinity = 1000000

def bellman graph, s
  n = graph.size
  dist = Array.new(n, Infinity)
  dist[s] = 0

  #始点以外のすべての点について最短経路計算を行う
  (1..n).each do |u|
    #すべての辺をもとに最短経路を更新
    n.times do |i|
      graph[i].each do |v|
        newLength = dist[i] + 1
        if newLength < dist[v]
           raise Exception.new("negative cycle found.") if i == n
          dist[v] = newLength
        end
      end
    end
  end
  dist
end

#ネットワーク取得
n = $stdin.gets.to_i
graph = Array.new(n).map{Array.new}
n.times do
  input = $stdin.gets.split(" ").map(&:to_i)
  input[1].times do |t|
    graph[input[0] - 1] << input[t + 2] - 1
  end
end

#パケット処理
$stdin.gets.to_i.times do
  s, d, v = $stdin.gets.split(" ").map(&:to_i)
  dist = bellman(graph, s - 1)
  if dist[d - 1] + 1 <= v
    puts dist[d - 1] + 1
  else
    puts "NA"
  end
end

Measured memory_bytes: 6540
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if (500*i + 100*j + 50*k == x):
        count = count + 1

print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int grid[3][3];
int x[3], y[3];

int main(){
    rep(i, 3) rep(j, 3) cin >> grid[i][j];
    x[0] = 0;
    rep(i, 3) y[i] = grid[0][i] - x[0];
    rep(i, 3) x[i] = grid[i][0] - y[0];
    bool good = true;
    rep(i, 3) rep(j, 3){
        if(x[i] + y[j] != grid[i][j]) good = false;
    }
    if(good) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int c;
    cin >> c;
    if(c >=65 && c <= 90) cout << "1\n";
    else if(c >= 97 && c <= 122) cout << "2\n";
    else cout << "0\n";
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	struct Point {
		double x, y;
		Point operator+(const Point &r) const { return Point{ x + r.x, y + r.y }; };
		Point operator-(const Point &r) const { return Point{ x - r.x, y - r.y }; };
		Point operator*(const double &r) const { return Point{ x * r, y * r }; }
		double operator*(const Point &r) const { return x * r.x + y * r.y; }
		Point N() const { return { y, -x }; }
		bool Par(const Point &r) const {
			if (x == 0.0 && y == 0.0) return true;
			if (r.x == 0.0 && r.y == 0.0) return true;
			if (x == 0.0 && r.x == 0.0) return true;
			if (x == 0.0 || r.x == 0.0) return false;
			return abs(y / x - r.y / r.x) < 1e-10;
		}
	};
	Point P[50];
	double D[50][50];
	pair<Point, double> I(UL a, UL b, UL c) {
		Point ab = P[b] - P[a], ac = P[c] - P[a];
		if (ab.Par(ac)) return{ {0.0,0.0}, 1e8 };
		Point Nab = ab.N(), Nac = ac.N();
		Point bc = P[c] - P[b];
		double S = (Nac.y * bc.x - Nac.x * bc.y) / (Nac.y * Nab.x - Nac.x * Nab.y);

		Point ans = (Nab * S + ab) * 0.5;
		double d = ans * ans;
		if (d == 1.25) {
			int i = 1;
		}
		return { ans + P[a], d };
	}

	void Solve() {
		UL N; cin >> N;
		rep(i, N) cin >> P[i].x >> P[i].y;
		rep(a, N) rep(b, N) {
			double dx = P[b].x - P[a].x, dy = P[b].y - P[a].y;
			D[a][b] = sqrt(a * a + b * b);
		}
		double ans = 9e7;
		for (UL a = 0; a < N; a++) {
			for (UL b = a + 1; b < N; b++) {
				for (UL c = b + 1; c < N; c++) {
					auto i = I(a, b, c);
					if (ans <= i.second) continue;
					bool ok = true;
					Point p = i.first;
					double d = i.second;
					rep(j, N) {
						double dx = p.x - P[j].x;
						double dy = p.y - P[j].y;
						if (dx * dx + dy * dy > d + 1e-8) ok = false;
					}
					if (ok) ans = d;
				}
				{
					bool ok = true;
					Point p = (P[a] + P[b]) * 0.5;
					double d = (P[a] - p) * (P[a] - p);
					rep(j, N) {
						double dx = p.x - P[j].x;
						double dy = p.y - P[j].y;
						if (dx * dx + dy * dy > d + 1e-8) ok = false;
					}
					if (ok) ans = d;
				}
			}
		}
		cout << sqrt(ans) << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int k, s;
  cin >> k >> s;

  int ans = 0;
  rep(i, k+1) rep(j, k+1){
    int z = s-i-j;
    if(0<=z && z<=k) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

signed main(){
    string s;
    cin >> s;
    vector<int> v(1, 0);
    for(auto& x : s)
        v.emplace_back(v.back() ^ (1 << (x - 'a')));
    vector<int> dp(1 << 26, MOD);
    dp[0] = 0;
    for(int i = 0; i < v.size(); ++i){
        for(int j = 0; j < 26; ++j)
            dp[v[i] ^ (1 << j)] = min(dp[v[i] ^ (1 << j)], dp[v[i]] + 1);
    }
    cout << max(1, dp[v.back()]) << endl;
}


Measured memory_bytes: 263544
n, m, l = map(int, input().split())
A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for i in range(l)] for j in range(m)]
C = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    t = list(map(int, input().split()))
    for j in range(m):
        A[i][j] = t[j]

for i in range(m):
    t = list(map(int, input().split()))
    for j in range(l):
        B[i][j] = t[j]

for i in range(l):
    for j in range(n):
        for k in range(m):
            C[j][i] += A[j][k] * B[k][i]
for i in range(n):
    for j in range(l):
        if j == l - 1:
            print(str(C[i][j]))
        else:
            print(str(C[i][j]) + " ", end="")

Measured memory_bytes: 9056
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	long ans = ((pow(10, n) + pow(8, n)) % MOD - pow(9, n) * 2 % MOD + MOD) % MOD;
	    System.out.println(ans);
	}
	
	static long pow(long x, long p) {
	    if (p == 0) {
	        return 1;
	    } else if (p % 2 == 0) {
	        return pow(x * x % MOD, p / 2);
	    } else {
	        return pow(x, p - 1) * x % MOD;
	    }
	}
}

Measured memory_bytes: 35680
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let N = input[0].split(' ')[0]
	let As = input[1].split(' ')
	As = As.sort((a, b) => a - b)
	for(let i = 0; i < As.length - 1; i++) {
		if(As[i] === As[i + 1]) {
			console.log('NO')
			return
		}
	}
	console.log('YES')
}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

// types
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll h,w;
  cin >> h >> w;
  vll v(26, 0);
  REP(i, h){
    string s;
    cin >> s;
    REP(j, s.size())
      v[s[j]-'a']++;
  }

  ll p1, p2, p4;
  p1=p2=p4=0;
  REP(i, 26){
    p4 += v[i]/4;
    p2 += v[i]%4/2;
    p1 += v[i]%2;
  }

  ll acp2 = 0;
  if(h%2==1)
    acp2 += w/2;
  if(w%2==1)
    acp2 += h/2;

  string ans="Yes";
  if(acp2<p2 || (acp2-p2)%2!=0)
    ans = "No";

  if((h%2==1 && w%2==1 && p1!=1) || ((h%2==0 || w%2==0) && p1!=0))
    ans = "No";

  cout << ans << endl;

}


Measured memory_bytes: 256
while True:
    a, op, b = (x for x in input().split())
    int_a = int(a)
    int_b = int(b)
    ans = 0

    if op == r"?" :break
    elif op == r"+":ans = int_a + int_b
    elif op == r"-":ans = int_a - int_b
    elif op == r"*":ans = int_a * int_b
    elif op == r"/":ans = int_a // int_b
    print(ans)

Measured memory_bytes: 7712
#include <stdio.h>
int main(void){
    long a,b,k;
    scanf("%ld%ld%ld",&a,&b,&k);
    if(a>k) printf("%ld %ld",a-k,b);
    else if(b-(k-a)>0) printf("0 %ld",b-(k-a));
    else printf("0 0");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <numeric>
using namespace std;
int main(){
    string c;
    cin >> c;
    string ans;
    if(c=="a"||c=="i"||c=="u"||c=="e"||c=="o"){
        ans = "vowel";
    }else{
        ans = "consonant";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
l = map(int, raw_input().split())
a = l[0]
b = l[1]
c = l[2]
x = l[3]
y = l[4]

if a+b <= 2*c:
	price = a*x + b*y
	tmp = 0
else:
	if x < y:
		price = 2*c*x
		tmp = y-x
	else:
		price = 2*c*y
		tmp = x-y

if tmp !=0:
	if x > y:
		if tmp*a > tmp*2*c:
			price += tmp*2*c
		else:
			price += tmp*a
	elif y > x:
		if tmp*b > tmp*2*c:
			price += tmp*2*c
		else:
			price += tmp*b

print price

Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;
    
    vector<ll> a(n);
    vector<ll> asum(n,0);
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i!=0)asum[i]=a[i]+asum[i-1];
        else asum[i]=a[i];
    }
    
    ll mindiff=asum[n-1],sum=asum[n-1];
    for(int i=0;i<n;i++){
        mindiff=min(mindiff,abs(sum-2*asum[i]));
    }

    cout << mindiff << endl;

    //Wrong Answer
    // 
    // ll mindiff=INF;
    // int pt=-1;
    // for(int i=0;i<n;i++){
    //     if(mindiff>abs(asum[n-1]-2*asum[i])){
    //         mindiff=abs(asum[n-1]-2*asum[i]);
    //         pt=i;
    //     }else{
    //         break;
    //     }
    //     if(mindiff==0)break;
    // }

    // cout << mindiff << endl;

    // ll sum=asum[n-1],half=asum[pt];

    // if(mindiff==0){
    //     cout << 0 << endl;
    // }else if(sum-2*half>0){
    //     int ans=0,diff=mindiff;
    //     while(diff){
    //         ans+=ceil(diff/2);
    //         sum+=ans;
    //         half+=ans;
    //         diff=sum-2*half;
    //     }
    //     cout << ans << endl;
    // }else{
    //     int ans=0,diff=mindiff;
    //     while(diff){
    //         ans+=ceil(diff/2);
    //         sum-=ans;
    //         half-=ans;
    //         diff=abs(sum-2*half);

    //         cout << diff << endl;
    //     }
    //     cout << ans << endl;
    // }

    return 0;
}


Measured memory_bytes: 6376
n,k = map(int, raw_input().split())
ab = []
for i in range(n):
  a,b = map(int, raw_input().split())
  ab.append((a,b))

ab.sort()
k -= 1
for a,b in ab:
  if k >= b:
    k -= b
  else:
    print a
    exit()


Measured memory_bytes: 18436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		StringBuilder ans = new StringBuilder();
		sb.append(br.readLine());
		int num = Integer.parseInt(br.readLine());
		for(int i = 0 ; i < num ; i++){
			String s[] = br.readLine().split(" ");
			if(s[0].equals("print")){
				ans.append(sb.substring(Integer.parseInt(s[1]), Integer.parseInt(s[2])+1)).append("\n");
			}else if(s[0].equals("reverse")){
				StringBuilder sb2 = new StringBuilder(sb.substring
						(Integer.parseInt(s[1]), Integer.parseInt(s[2])+1));
				sb.replace(Integer.parseInt(s[1]), Integer.parseInt(s[2])+1,sb2.reverse().toString());
			}else{
				sb.replace(Integer.parseInt(s[1]), Integer.parseInt(s[2])+1,s[3]);
			}
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 24860
import math

class Point():
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

class Line():
    def __init__(self, x1, y1, x2, y2):
        self.p1 = Point(x1, y1)
        self.p2 = Point(x2, y2)

    def projection(self, p):
        a = (self.p2.y - self.p1.y)/(self.p2.x - self.p1.x) if self.p2.x != self.p1.x else float('inf')
        if a == 0:
            return (p.x, 2*self.p1.y - p.y)
        elif a == float('inf'):
            return (2*self.p1.x - p.x, p.y)
        else:
            b = self.p2.y - a*self.p2.x
            d = abs(-1*a*p.x + p.y - b)/math.sqrt(1 + a*a)
            ans_y = [p.y + math.sqrt(4*d*d/(a*a+1)), p.y - math.sqrt(4*d*d/(a*a+1))]
            ans_x = [p.x - a*(_y - p.y) for _y in ans_y]

            rst_x, rst_y = None, None
            tmp = abs(-1*a*ans_x[0] + ans_y[0] - b)/math.sqrt(1 + a*a) - d
            if tmp < abs(-1*a*ans_x[1] + ans_y[1] - b)/math.sqrt(1 + a*a) - d:
                rst_x, rst_y = ans_x[0], ans_y[0]
            else:
                rst_x, rst_y = ans_x[1], ans_y[1]
            return round(rst_x, 9), round(rst_y, 9)

x1, y1, x2, y2 = list(map(int, input().split(' ')))
line = Line(x1, y1, x2, y2)
q = int(input())
for i in range(q):
    x, y = list(map(int, input().split(' ')))
    p = Point(x, y)
    rst_x, rst_y = line.projection(p)
    print(rst_x, rst_y)



Measured memory_bytes: 5704
#!/usr/bin/env python3
import sys


def solve(N: int, T: int, A: int, H: "List[int]"):
    mn = float('inf')
    ret = -1
    for i in range(N):
        t = T - H[i] * 0.006
        diff = abs(A - t)
        if diff < mn:
            ret = i + 1
            mn = diff
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    H = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, T, A, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const string YES = "Yes";
const string NO = "No";



// ***************************************

int main(){

    string S;
    cin >> S;
    for(auto& s: S){
        if (s == '7'){
            cout << YES << endl;
            return 0;
        }
    }

    cout << NO << endl;

    return 0;
}


Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		long sum = 0;
		ArrayList<Long> list = new ArrayList<Long>();

		for(int i=0;i<Math.pow(2, s.length()-1);i++){
			String bit = Integer.toBinaryString(i);
			while(bit.length() < s.length()-1){
				bit = 0 + bit;
			}
			//System.out.println(bit);
			int count = 0;
			int pos = 0;
			list.clear();
			for(int j=0;j<bit.length();j++){
				if(bit.charAt(j) == '1'){
					list.add(Long.parseLong(s.substring(pos,j+1)));
					count++;
					pos = j+1;
				}
			}
			if(count == 0){
				list.add(Long.parseLong(s,10));
			}else{
				list.add(Long.parseLong(s.substring(pos,s.length())));
			}
			for(int j=0;j<list.size();j++){
				//System.out.println(list.get(j));
				sum += list.get(j);
			}
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
signed main(){
	n=read();
	int ans=1;
	while(n){
		n>>=1;
		ans*=2;
	}
	printf("%lld\n",ans-1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
inline int read()
{
	static char buf[1<<21],*p1,*p2;
	int f=0,c=1; char ch=gc();
	while(ch<'0'||ch>'9') { if(ch=='-') c=-1; ch=gc(); }
	while(ch>='0'&&ch<='9') { f=f*10+ch-'0'; ch=gc(); }
	return c*f;
}
int n,a[123456];
bool cmp(int a,int b) { return a>b; }
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;++i)
	{
		if(i+1<=a[i+1]) continue;//没到边上
		int j=0; 
		while(a[i+j+1]==i) ++j;//一段平的 
		if( ((a[i]-i)&1) || (j&1) ) puts("First");
		else puts("Second");
		return 0;   
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#define INF 10000000000
#define MOD 1000000007

using namespace std;

int main()
{
    int N, x, y;
    cin >> N;
    x = 800 * N;
    y = 200 * (N / 15);
    cout << x - y << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;cin>>a>>b>>c;
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);

    if(a==5 && b == 5 && c == 7) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

int main(){
    while(1){
        int n, m;
        cin >> n >> m;
        if (!n || !m) break;
        int r;
        cin >> r;
        vector<vector<int> > data(m, vector<int>(721, 0));
        for (int i = 0; i < r; i++){
            int t, pc, student, s;
            cin >> t >> pc >> student >> s;
            student--;
            t -= 540;
            if (s == 1) data[student][t] += 1;
            else data[student][t] -= 1;
        }
        for (int i = 0; i < m; i++){
            for (int j = 0; j < 720; j++) data[i][j+1] += data[i][j];
        }
        int q;
        cin >> q;
        for (int i = 0; i < q; i++){
            int ts, te, stm;
            cin >> ts >> te >> stm;
            ts -= 540;
            te -= 540;
            stm--;
            int ans = 0;
            for (int j = ts; j < te; j++){
                if (data[stm][j] > 0) ans++;
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 30540
import java.util.Scanner;

class Main{
public static void main(String[] args){

	
	  int cnt=1;
	String  text1= "Case";
	String  text2=":";
 
	Scanner s = new Scanner(System.in);
while(s.hasNext())
	{
		int a=s.nextInt();
		if(a==0){break;}
		System.out.println(text1+" "+cnt + text2+" "+ a);
		cnt++;
		
		}
		
	}
}


Measured memory_bytes: 42860
#include<cstdio>

using namespace std;

int N;

bool check(int m){
	int sum = 0;
	for(int i = m; i >= 1; --i){
		if(sum + i <= N) sum += i;
	}
	return sum == N;
}

void output(int m){
	int sum = 0;
	for(int i = m; i >= 1; --i){
		if(sum + i <= N){
			printf("%d\n", i);
			sum += i;
		}
	}
}

void solve(){
	int lb = 0, ub = N;
	while(ub - lb > 1){
		int mid = (ub + lb) / 2;
		if(check(mid)){
			ub = mid;
		}else{
			lb = mid;
		}
	}
	output(ub);
}

int main(){
	scanf("%d", &N);
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int main(void){
    ll N,K;cin>>N>>K;
    N %= K;
    if(K-N<=N) cout << K-N << endl;
    else cout << N << endl;
    return 0;
}

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

using namespace std;

#define READ freopen("input", "r", stdin)
#define WRITE freopen("output", "w", stdout)

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
//    READ;
//    WRITE;
    int arr[5], k;
    bool flag = true;
    for (int i = 0;i < 5; i++) {
        cin >> arr[i];
    }


    cin >> k;

    for (int i = 0;i < 5; i++) {
        for (int j = 0;j < 5; j++) {
            if (arr[j] - arr[i] > k) {
                flag = false;
                break;
            }
        }
    }

    if (flag)
        cout << "Yay!" << '\n';
    else
        cout << ":(" << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	static final int MOD = 1_000_000_007;
	Scanner sc;
	int N;
	int[] c;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		c = new int[60];
		
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			for (int j = 0; j < 60; j++) {
				if ((a & 1)>0) c[j]++;
				a >>>= 1;
			}
		}
		long ans = 0L;
		long d = 1L;
		for (int j = 0; j < 60; j++) {
			ans = (ans + (long)c[j]*(N-c[j])%MOD*d) % MOD;
			d = (d << 1)%MOD;
		}
		System.out.println( ans );
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}

Measured memory_bytes: 90548
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, Z, W;
int A[2002];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Z >> W;
  A[0] = Z;
  A[1] = W;
  rep(i, N) cin >> A[i+2];
  N+=2;
  long long m = -(1LL<<60);
  m = max(m, abs(0LL+W-A[N-1]));
  if (N>3) m = max(m, abs(0LL+A[N-2]-A[N-1]));
  cout << m << "\n";
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i < n ; ++i){
		cin >> a[i];
	}
	int dp[n];
	memset(dp,0,sizeof(dp));
	if(n==1)return 0;
	dp[0]=0;
	dp[1] = abs(a[1]-a[0]);

	for(int i=2; i<n ; ++i){
		dp[i] = min(dp[i-1] + abs(a[i-1]-a[i]) , dp[i-2] + abs(a[i-2]-a[i]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
//============================================================================
// Name        : aoj0007.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<algorithm>
using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	for(int i = 0;i<3;i++){
		for(int j = 0;j<3;j++){
			if(a[i] < a[j]){
				swap(a[i],a[j]);
			}
		}
	}
	cout << a[0] << " "  << a[1]  << " " << a[2] << endl;
	return 0;
}


Measured memory_bytes: 3096
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K = int(input())
lis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lis[K-1])



Measured memory_bytes: 61872
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = (int)2e5 + 5;
const int mod = (int)1e9 + 7;
using namespace std;

int a[maxn];

int main()
{
	int n; scanf("%d", &n);
	int l = 1;
	ll ans = 0, sum = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		while((sum ^ a[i]) != sum + a[i]) sum ^= a[l], l++;
		sum ^= a[i];
		ans += (i - l + 1);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	minr := math.MaxInt32
	maxr := -math.MaxInt32

	for i := 0; i < n; i++ {
		r := getNextInt(scanner)
		maxr = maxint(maxr, r-minr)
		minr = minint(minr, r)
	}

	fmt.Fprintln(writer, maxr)
	writer.Flush()
}

func maxint(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minint(a, b int) int {
	if a < b {
		return a
	}
	return b
}



Measured memory_bytes: 4632
#ifndef LOCAL
#pragma GCC optimize("O2")
#endif
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N;
    double a, test=0.5000;
    cin >> N;

    if(N%2==0){
        a = 0.5000;
        //cout << a;
    }
    else if(N%2==1){
        //a = double ((int (N/2 + 1)) / N);
        a = double(int(N/2 + 1)) / N;
    }

    //cout << a << test;
    printf("%4f", a);

}

Measured memory_bytes: 256
N, X = map(int, input().split())
A = sorted(list(map(int, input().split())))
l = [0]*N
for i in range(N):
  if X >= A[i]:
    if i == N-1:
      l[i] = X
      X -= X
    else:
      l[i] = A[i]
      X -= A[i]
  else:
    l[i] = X
    X -= X
ans = [A[i]-l[i] for i in range(N)].count(0)
print(ans)

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

int main() {
	string S;
	cin >> S;
	if (S.substr(0, 2) > "00" && S.substr(0, 2) < "13" && S.substr(2, 2) > "00" && S.substr(2, 2) < "13") cout << "AMBIGUOUS";
	// else if (S.substr(0, 2) > "12" && S.substr(2, 2) > "12" || S.substr(0, 2) == "00" || S.substr(2, 2) == "00") cout << "NA";
	else if (S.substr(0, 2) > "12" && S.substr(2, 2) > "12") cout << "NA";
	else if (S.substr(0, 2) == "00" && S.substr(2, 2) == "00") cout << "NA";
	else if (S.substr(0, 2) > "00" && S.substr(0, 2) < "13" && S.substr(2, 2) == "00") cout << "MMYY";
	else if (S.substr(2, 2) > "00" && S.substr(2, 2) < "13" && S.substr(0, 2) == "00") cout << "YYMM";
	else if (S.substr(0, 2) > "13" && S.substr(2, 2) == "00") cout << "NA";
	else if (S.substr(0, 2) == "00" && S.substr(2, 2) > "13") cout << "NA";
	else if (S.substr(0, 2) > "12") cout << "YYMM";
	else cout << "MMYY";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

string s;
LL n, k;

int main() {
	cin >> s >> k;
	n = SL(s);
	
	vector<LL> v;
	inc(i, n) {
		if(i == 0 || s[i] != s[i - 1]) { v.PB(0); }
		v.back()++;
	}
	
	LL ans = 0;
	if(SI(v) == 1) {
		ans = n * k / 2;
	} else {
		if(s.front() == s.back()) {
			LL a = 0, b = 0;
			incID(i, 1, SI(v) - 1) { a += v[i] / 2; }
			b = (v.front() + v.back()) / 2;
			ans = a * k + b * (k - 1) + v.front() / 2 + v.back() / 2;
		} else {
			LL sum = 0;
			RF(e, v) { sum += e / 2; }
			ans = sum * k;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct node {
	vector<int> child;
	vector<int> parent;
	int flag;
	int indeg;
};
int main() {
	int N, M;
	cin >> N >> M;
	node*T = new node[N];
	int A, B;
	for (int i = 0; i < N - 1 + M; i++) {
		cin >> A >> B;
		T[A-1].child.push_back(B-1);
		T[B-1].parent.push_back(A-1);
	}
	for (int i = 0; i < N; i++) {
		T[i].flag = 0;
		T[i].indeg = T[i].parent.size();
	}
	vector<int>ts;
	queue<int>q;
	for (int i = 0; i < N ; i++) {
		if (T[i].indeg == 0 && T[i].flag == 0) {
			q.push(i);
			T[i].flag = 1;
			while (!q.empty()) {
				int now = q.front();
				q.pop();
				ts.push_back(now);
				for (int tmp : T[now].child) {
					T[tmp].indeg--;
					if (T[tmp].indeg == 0 && T[tmp].flag == 0) {
						q.push(tmp);
						T[tmp].flag = 1;
					}
				}
			}
		}
	}
	vector<int>out(N);
	for (int i = 0; i < N; i++) {
		out[ts[i]] = i+1;
	}
	for (int i = 0; i < N; i++) {
		int ans = -1;
		int max = 0;
		for (int tmp : T[i].parent) {
			if (max < out[tmp]) {
				max = out[tmp];
				ans = tmp;
			}
		}
		cout << ans+1 << endl;
	}
}


Measured memory_bytes: 13436
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
using namespace std;

int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

bool isPrime(int x){
    int i;
    if(x<2)return 0;

}

int x[5];
int main(){
    for(int i=0;i<5;i++){
        cin>>x[i];
        if(x[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636