akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	map<char, int>a;
	string s;
	cin >> s;
	map<char, int>::iterator it;
	for (int i = 0; i < s.size(); i++) {
		it = a.find(s[i]);
		if (it == a.end()) {
			a.insert(map<char, int>::value_type(s[i], 1));
		}
		else
			a[s[i]]++;
	}
	bool l = true;
	it = a.begin();
	while (it != a.end()) {
		if ((*it).second % 2 == 1) l = false;
		it++;
	}
	if (l) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
function main() {
  var
  i,
  line, words,
  dict = {},
  len = input.length;
  input.forEach(function(line) {
    if(line.trim() === '') return;
    line = line.split(' ');
    if(!dict[line[0]]) {
      dict[line[0]] = [];
    }
    dict[line[0]].push(parseInt(line[1], 10));
  });
  words = Object.keys(dict);
  words.sort();
  words.forEach(function(word) {
    dict[word].sort(function(a, b){
      return a - b;
    });
    console.log(word);
    console.log(dict[word].join(' '));
  });
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 8552
#include <bits/stdc++.h>
using namespace std;
int main(){
	int K; cin >> K; 
	int ans = 0; 
	for(int a = 1; a <= K; a++){
		for(int b = 1; b <= K; b++){
			for(int c = 1; c <= K; c++){
				int tmp = gcd(a, b); 
				ans += gcd(tmp, c); 
			}
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 3636
#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 x, a, b;
	cin >> x >> a >> b;

	if (a >= b) cout << "delicious" << endl;
	else if (x >= (b - a)) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}


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

using namespace std;

int main()
{
	int a,m,h = 0;
	m = 0;
	
	cin >> a ;
	
	while(a >= 3600){
		a = a - 3600;
		h++;
	}
	while(a >= 60){
		a = a - 60;
		m++;
	}
	
	
	cout << h << ":"<< m << ":" << a << endl;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

class UnionFind {
  public:
    // 親の番号を格納する。親の場合 -1 になる
    vector<int> Parent;

    // 宣言されたとき Parent の値はすべて -1 にする
    UnionFind(int N) { Parent = vector<int>(N, -1); }

    // 与えられた値 x がどの親であるか調べる
    int root(int x) {
        // x が親だったとき
        if (Parent[x] < 0)
            return x;
        // 辺の縮約をいっしょにおこなう
        return Parent[x] = root(Parent[x]);
    }

    // 木の全体の数を返す
    int size(int x) {
        // マイナスがついているのは root
        // 以下の数をマイナスの値で管理しているから
        return -Parent[root(x)];
    }

    // 2つの引数を同じ親にする
    bool merge(int x, int y) {
        x = root(x);
        y = root(y);

        // 同じ親の場合くっつけない
        if (x == y)
            return false;

        // x のほうが必ず大きな size にしたい
        if (size(x) < size(y))
            swap(x, y);
        Parent[x] += Parent[y];
        Parent[y] = x;
        return true;
    }
};

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

    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    REP(i, M) cin >> a[i] >> b[i];

    set<int> v;
    REP(i, M) {
        if (a[i] == 1) {
            v.insert(b[i]);
        }
    }

    REP(i, M) {
        if (b[i] == N && v.count(a[i])) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 6528
n = int(raw_input())
a = map(int, raw_input().split())

sum = sum(a)
if(sum >= 0):
    ave = int(float(sum) / n + 0.5)
else:
    ave = int(float(sum) / n - 0.5)   

cost = 0
for item in a:
    cost += pow(abs(item - ave), 2)
    

print cost,

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){
	string s;
	cin>>s;
	
	if(s[s.size()-1]=='s') s+="es";
	else s+="s";
	
	cout<<s<<endl;
}

Measured memory_bytes: 3628
N = input()
T_list = list(map(int,input().split()))
M = input()
drink_list = []
for i in range(int(M)):
    drink_dict = {}
    P,X = map(int,input().split())
    drink_dict[P] = X
    drink_list.append(drink_dict)

for d in drink_list:
    for p in d.keys():
        sum_time = 0
        for i in range(1,len(T_list)+1):
            if p == i:
                sum_time += d[p]
            else:
                sum_time += T_list[i-1]
        print(sum_time)


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	int data[5] = {0},p,j;
	int x,y;
	for(x=0; x<5; x++)
	{
		scanf("%d",&data[x]);
	}
	if((p=data[0]) > data[1])
		p = data[1];
	if(p > data[2])
		p = data[2];
	if((j=data[3]) > data[4])
		j = data[4];
	printf("%d\n",p+j-50);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*-----Library-----*/
signed main(){
    int n;
    cin>>n;
    int cnt[3]={};
    int ans=1;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        int c=0;
        int memo=-1;
        for(int j=0;j<3;j++){
            if(cnt[j]==k){
                memo=j;
                c++;
            }
        }
        ans*=c;
        ans%=MOD;
        cnt[memo]++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/abc061/tasks/abc061_c
# C - Big Array

N, K = list(map(int, input().split()))
ab_list = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    ab_list.append((a, b))

ab_list = sorted(ab_list, key=lambda x: x[0])
c = 0
for a, b in ab_list:
    c += b
    if c >= K:
        ans = a
        break

print(ans)



Measured memory_bytes: 19064
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

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

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

int A[100100];
map<long long int, long long int> m;

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    long long int a;
    long long int tmp = 0;
    m[0] = 1;
    ll ans = 0;
    for(int i = 0; i < N; ++i) {
    	cin>>a;
    	tmp+=a;
    	ans += m[tmp];
    	m[tmp]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12800
#define rep(i, m, n) for(int i = m; i < n; i++)
#define repM(i, m, n) for(int i = n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll; using namespace std;
//typedef pair<int,int> pii; using namespace std;

// d = distance(lower_bound(all(x)), upper_bound(all(x)));

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main(){
  int N, K, m=1; cin >> N >> K; string s; cin >> s;
  if (N==1) {cout << s << endl; return 0;}

  int bc = 1e5; bool best = false;
  rep(i, 0, N) bc = min((int)s[i], bc);
  
  string worst, bestest;
  rep(i, 0, N) worst += 'z';
  rep(i, 0, N) bestest += 'a';
  
  if (K > 15 || 1<<(K-1) >= N) {
    //cout << "in" << endl;
    sort(s.begin(), s.end());
    for(int i=0; i<N; i++) cout << s[0];
    cout << endl;
    return 0;
  }
  
  string sn = s;
  
  for (int k=0; k<K; k++) {
    string s2 = sn;
    reverse(s2.begin(), s2.end());
    string s3 = sn + s2; sn = worst;
    for(int i=0; i<=N; i++) {
      if (s3.substr(i,N) < sn) sn = s3.substr(i,N);
      //cout << k << " "<< sn << endl;
    }
    reverse(sn.begin(), sn.end());
  }
  reverse(sn.begin(), sn.end());
  cout << sn << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll n, m, q;
ll a[51] = {}, b[51] = {}, c[51] = {}, d[51] = {};
ll answer = 0;
void RecursiveFunction(ll Iteration, ll MaxA, vector<ll> A)
{
	if (Iteration == n + 1)
	{
		ll SumDi = 0;
		for (ll i = 1; i <= q; i++)
		{
			if (A[b[i]] - A[a[i]] == c[i])
			{
				SumDi += d[i];
			}
		}
		answer = max(answer, SumDi);
		return;
	}
	else
	{
		for (ll i = MaxA; i <= m; i++)
		{
			A[Iteration] = i;
			RecursiveFunction(Iteration + 1, i, A);
		}
	}
}

int main() {
	vector<ll> A(11, 0);
	cin >> n >> m >> q;
	for (int i = 1; i <= q; i++)
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	for (ll i = 1; i <= m; i++)
	{
		RecursiveFunction(1, i, A);
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3564
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));
		int num = Integer.parseInt(br.readLine());
		int i = 0;

		while (num != 0) {
			i++;
			System.out.println("Case " + i + ": " + num);
			num = Integer.parseInt(br.readLine());

		}
	}
}


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

int main(){
  int n;
  cin >> n;
  cout << n << ":";
  int m = sqrt(n);
  while (n % 2 == 0) {
    n /= 2;
    cout << " " << 2;
  }

  int i = 3;
  while (i <= m) {
    if (n % i == 0) {
      cout << " " << i;
      n /= i;
    } else {
      i += 2;
    }
  }
  if (n != 1) {
    cout << " " << n;
  }
  cout << endl;
}


Measured memory_bytes: 3120
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=1e9+7;
#define N 300000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
main(){
    ll int n;
    ll int a[N];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    ll int sum[N];
    sum[0]=a[0];
    rep2(i,1,n-1){
        sum[i]=sum[i-1]+a[i];
    }
    ll int ans=1e16;
    rep(i,n-1){
        ll int a1=*(lower_bound(sum,sum+n,sum[i]/2));
        ll int a2=*(lower_bound(sum,sum+n,sum[i]/2)-1);
        ll int a;
        if(a1*2-sum[i]<sum[i]-a2*2) a=a1;
        else a=a2;
        ll int b=sum[i]-a;
        ll int c1=*(lower_bound(sum,sum+n,(sum[i]+sum[n-1])/2))-sum[i];
        ll int c2=*(lower_bound(sum,sum+n,(sum[i]+sum[n-1])/2)-1)-sum[i];
        ll int c;
        if(c1*2+sum[i]-sum[n-1]<-sum[i]+sum[n-1]-c2*2) c=c1;
        else c=c2;
        ll int d=sum[n-1]-sum[i]-c;
        ans=min(ans,max({a,b,c,d})-min({a,b,c,d}));

    }
    cout<<ans;
    return 0;
}

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

bool isprime(int n){
  for(int i = 2; i <= sqrt(n); i++){
  	if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n; cin >> n;
  while(!isprime(n)) n++;
  cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int N;
  cin >> N;
  vector<int> a(N), b(N), c(N);
  for (int i = 0; i < N; ++i) cin >> a[i] >> b[i] >> c[i];
  int dp[3][100005];
  memset(dp, 0, sizeof(int));
  dp[0][0] = a[0];
  dp[1][0] = b[0];
  dp[2][0] = c[0];
  for (int i = 1; i < N; ++i)
    {
      dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
      dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i];
      dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i];
    }
  cout << max(max(dp[0][N - 1], dp[1][N - 1]), dp[2][N - 1]) << endl;
  return 0;
}


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

using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    if(n < 105) cout << "0\n";
    else if(n < 135)    cout << "1\n";
    else if(n < 165)    cout << "2\n";
    else if(n < 189)    cout << "3\n";
    else if(n < 195)    cout << "4\n";
    else    cout << "5\n";




    return 0;
}

Measured memory_bytes: 256
K=int(input())
x=[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(x[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define MAGIC cin.tie(NULL); ios_base::sync_with_stdio(false)
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

int gcd(int a, int b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl

int32_t main()
{
    MAGIC;
    int N; cin >> N;
    vector<int> A(N+1), B(N+1), C(N);
    for(int i = 1; i <= N; i++) cin >> A[i];
    for(int i = 1; i <= N; i++) cin >> B[i];
    for(int i = 1; i <= N-1; i++) cin >> C[i];
    
    int ret = 0;
    
    for(int i = 1; i <= N; i++)
    {
        ret += B[A[i]];
        if(i == 1) continue;
        if(A[i-1] + 1 == A[i])
            ret += C[A[i-1]];
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define N 100005
 
int n, m;
int a[N<<1];
 
int main() {
    scanf("%d %d", &n, &m);
    int nn = n << 1;
    for (int i = 1; i <= nn; i ++) scanf("%d", &a[i]);
    sort(a+1, a+nn+1);
    int st = 0, en = n+1;
    while (en - st > 1) {
        int mid = en + st >> 1;
        int len = mid * 2;
        int pos = nn - len;
        bool flag = 0;
       // for (int i = 1; i <= pos && !flag; i ++) {
       //     if (a[i] + a[pos+1-i] >= m) flag = 1;
       // }
        for (int i = pos+1; i <= nn && !flag; i ++) {
            if (a[i] + a[nn+pos+1-i] < m) flag = 1;
        }
        if (flag) en = mid;
        else st = mid;
    }
    int len = st * 2;
    int mx = 0, pos = nn - len;
    for (int i = 1; i <= pos; i ++) {
     	mx = max(mx, a[i] + a[pos+1-i]);
      if (a[i]+a[pos+1-i] >= m) assert(0), assert(st == 0 && a[nn]+a[nn-1] >= m);
    	//assert(a[i]+a[pos+1-i]<m);
    }
    for (int i = pos+1; i <= nn; i ++) {
     	mx = max(mx, a[i]+a[nn+pos+1-i]-m);
    	assert(a[i]+a[nn+pos+1-i]>=m);
    }
    printf("%d\n", mx);
	return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<char>>();

    let mut a = Vec::new();
    let mut c = Vec::new();
    for i in 0..n {
        a.push(vec![0; n-i]);
        c.push(Vec::new());
        for j in i..n {
            c[i].push(s[j]);
        }
    }

    for b in 0..n {
        a[b][0] = n-b;
        let mut i = 1;
        let mut j = 0;
        while i < n-b {
            while i+j < n-b && c[b][j] == c[b][i+j] { j+=1 }
            a[b][i] = j;
            if j == 0 { i+=1; continue; }
            let mut k = 1;
            while i+k < n-b && k+a[b][k] < j { a[b][i+k] = a[b][k]; k+=1; }
            i+=k;
            j-=k;
        }
    }

    let mut ans = 0;
    for i in 0..n-1 {
        for j in 0..n-i {
            if a[i][j] > ans {
                ans = std::cmp::max(ans, std::cmp::min(j, a[i][j]));
            }
        }
    }
    println!("{}", ans);
}

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

int main() {
int   n;
cin >>n;
double add,kisu;
if(n%2==0){
    add=n/2;
    kisu=n/2;
}
else{
    add=n/2;
    kisu=n/2+1;
}
double ans =kisu/n;
cout <<fixed <<setprecision(8);
cout <<ans <<endl;
}



Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]

from collections import Counter
c = Counter(A)
keys, values = zip(*c.most_common())

n = len(values)
ans = 0

for i in range(n):
    if values[i]%2 == 1:
        ans += 1
        
print(ans)

Measured memory_bytes: 28544
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int m, f, b; cin >> m >> f >> b;
	cout << (m + f < b ? "NA" : to_string(max(0, b - m))) << endl;
}


Measured memory_bytes: 3280
#include <iostream>
#include <sstream>
#include <map>
#include <algorithm>
using namespace std;
int main(){
	string line;
	getline(cin, line);
	stringstream ss;
	ss << line;
	string s;
	map<string, int> cnt;
	string maxLengthString = "";
	pair<int, string> maxEncount(0,"");
	while(ss >> s){
		cnt[s]++;
		if( maxLengthString.size() < s.size()) maxLengthString = s;
		if(maxEncount.first < cnt[s]){
			maxEncount = make_pair<int,string>(cnt[s],s);
		}
	}
	cout << maxEncount.second << " " << maxLengthString << endl;
	return 0;
}

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

int main() {
    int arr[] = {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};
    int k;

    cin >> k;
    cout << arr[k - 1] << endl;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int a,b;
    cin >> a >> b;
    cout << (a-1) * (b-1) << endl;
    return 0;
}


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

    string s1,s2;
     cin>>s1>>s2;

    for(int i=0;i<n;i++)
    {

        cout<<s1[i]<<s2[i];
    }

    cout<<endl;
    exit(0);
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int n, p;
	string s;
	cin >> n >> p >> s;
	ll ans=0;
	if(p==2 || p==5) {
		for(int i=0; i<n; ++i)
			if((s[i]-'0')%p==0)
				ans+=i+1;
	 } else {
		map<int, int> mp;
		++mp[0];
		int t=0, p2=1;
		for(int i=n-1; ~i; --i) {
			t=(t+(s[i]-'0')*p2)%p;
			ans+=mp[t];
			mp[t]++;
			p2=p2*10%p;
		}
	}
	cout << ans;
}

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

using namespace std;

char cr[200];
int tt;

const int maxn = 505;
char a[maxn][maxn], b[maxn][maxn];

int main() {
  int n = 0, m = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char ch = getchar();
      while (ch != '.' && ch != '#') ch = getchar();
      a[i][j] = b[i][j] = ch;
    }
  for (int i = 1; i <= n; i++) {
    a[i][1] = '#', b[i][m] = '#';
    if (i & 1)
      for (int j = 2; j <= m - 1; j++) a[i][j] = '#';
    else
      for (int j = 2; j <= m - 1; j++) b[i][j] = '#';
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) putchar(a[i][j]);
    puts("");
  }
  puts("");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) putchar(b[i][j]);
    puts("");
  }
  return 0;
}


Measured memory_bytes: 1280
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    print (N - 2) * 180

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <queue>
#include <vector>

#define MAXN 100000
#define INF ( 1LL << 60 )
#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef long long ll;

using namespace std;

int color[MAXN];
ll d[MAXN];

ll bfs ( ll K )
{
  deque<ll> Q;
  ll now = 1;

  for ( int i = 0; i < K; ++i ) color[i] = WHITE, d[i] = INF;
  Q.push_front(1);
  color[now%K] = GRAY;
  d[now%K] = 1;

  while(!Q.empty())
  {
    now = Q.front(); Q.pop_front();
    if ( color[now%K] == BLACK ) continue;

    //cout << "now = " << now <<", now mod/k = " << now%K << "\n";

    ll tmp1,tmp2;
    tmp1 = now*10;
    //cout << "tmp1 mod/k = " << tmp1%K << "\n";
    if ( color[tmp1%K] != BLACK ) {
      if ( d[tmp1%K] > d[now%K] ) {
        d[tmp1%K] = d[now%K];
        Q.push_front(tmp1%K);
        if ( color[tmp1%K] == WHITE ) color[tmp1%K] = GRAY;
      }
    }

    tmp2 = now+1;
    //cout << "tmp2 mod/k = " << tmp2%K << "\n";
    if ( color[tmp2%K] != BLACK ) {
      if ( d[tmp2%K] > d[now%K]+1 ) {
        d[tmp2%K] = d[now%K]+1;
        Q.push_back(tmp2%K);
        if (color[tmp2%K] == WHITE ) color[tmp2%K] = GRAY;
      }
    }

    color[now%K] = BLACK;

  //  cout << "\n";
  }

  /*
  for ( int i = 0; i < K; ++i ) {
    printf("node%d = %d\n", i, d[i]);
  }
  */
  return d[0];
}

int main()
{
  ll K;

  cin >> K;

  cout << bfs(K) << "\n";
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int A, B, C, X; cin >> A >> B >> C >> X;
    int ans = 0;
    for(int i = 0; i <= A; i++) for(int j = 0; j <= B; j++) for(int k = 0; k <= C; k++) {
        if(500 * i + 100 * j + 50 * k == X) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        int[] a = ReadIntArray();

        int numOdd = 0, numMul4 = 0, numMul2 = 0;

        for (int i = 0; i < n; i++)
        {
            int x = a[i];
            if ((x&1) == 1){ numOdd++; }

            if ((x&3) == 0)
            {
                numMul4++;
            }
            else if ((x&1) == 0)
            {
                numMul2++;
            }

        }
      
        if (numOdd == 0 && numMul2 >= 2)
        {
            WriteLine("Yes");
            return;
        }

        if (numMul2 > 0){ numOdd++; }

        if (numOdd == 0 || (numMul4 > 0 && numMul4 + 1 >= numOdd))
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }
    }
}


Measured memory_bytes: 19680
{
	const process = (a: string[]) => {
		const length = parseInt(a[0])
		const fromFirst = parseInt(a[1])
		return length - fromFirst + 1
	}

	const Main = (input: string): void => {
		//const num = parseInt(input)
		const ary = input.split(" ")
		console.log(process(ary))
	}

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



Measured memory_bytes: 7372
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
sieve()
x = int(input())
for i in range(x,MAXN):
    if spf[i]==i:
        print(i)
        break

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

ll lcm(ll a, ll b) {
    return a / __gcd(a, b) * b;
}

ll calc(ll A, ll C, ll D) {

    if (C == D) {
        return (A - floor(A/(C)));
    }

    return (A - A/C - A/D + A/(lcm(C, D)));
}

int main() {

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll ans = calc(B, C, D) - calc(A-1, C, D);
    if (ans < 0) ans = 0;
    cout << ans << endl;    
    
    
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N, K;
	cin >> N >> K;
	vec(H);
	fx(N) {
		vecp(H);
	}
	int dp[110000];

	fx(N+K+1) {
		dp[x] = INT_MAX;
	}
	dp[0] = 0;
	fx(N) {
		fy(K) {
			if (x+y+1<N) {
				dp[x + y + 1] = min(dp[x + y + 1], dp[x] + abs(H.at(x) - H.at(x + y + 1)));
			}
		}
	}
	ce(dp[N-1])
    return 0;
}



Measured memory_bytes: 1144
n,m = map(int,input().split())
h = list(map(int,input().split()))
t = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    t[a-1].append(h[b-1])
    t[b-1].append(h[a-1])
ans=0
for i in range(n):
    hi=h[i]
    if len(t[i])>0:
        ta=t[i]
        if hi>max(ta):
            ans+=1
    else:
        ans+=1
print(ans)

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

int n,m,i,b;
long long int a[100005];

int main ()
{
	for ( i = 0 ; i <= 100004 ; ++ i )
	    a[i] = 1;
	
	cin >> n >> m;
	for ( i = 1 ; i <= m ; ++ i )
	{
		cin >> b;
		a[b] = 0;
	}
	
	for ( i = 2 ; i <= n ; ++ i )
		a[i] = ( a[i-1] + a[i-2] ) * a[i] % 1000000007;
	
	cout << a[n] << endl;
	
	return 0;
	
}

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

constexpr int MOD = 1e9 + 7;

int mod_pow(int x, int n, int m) {
  if (n == 0)
    return 1;
  int res = mod_pow(x * x % m, n / 2, m);
  if (n % 2 == 1)
    res = res * x % m;
  return res;
}

//逆元
int mod_inv(int a, int m) {
  int b = m, u = 1, v = 0;
  while (b) {
    int t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

signed main() {
  int n, a, b;
  cin >> n >> a >> b;

  int ans = (mod_pow(2, n, MOD) - 1 + MOD) % MOD;

  int sub_a = 0, sub_b = 0;
  if (n >= a) {
    int temp = 1;
    for (int i = n; i >= n - a + 1; i--) {
      temp *= i;
      temp %= MOD;
    }

    for (int i = a; i >= 1; i--) {
      temp *= mod_inv(i, MOD);
      temp %= MOD;
    }

    sub_a = temp;
  }

  if (n >= b) {
    int temp = 1;
    for (int i = n; i >= n - b + 1; i--) {
      temp *= i;
      temp %= MOD;
    }

    for (int i = b; i >= 1; i--) {
      temp *= mod_inv(i, MOD);
      temp %= MOD;
    }

    sub_b = temp;
  }

  ans = (ans - sub_a + MOD) % MOD;
  ans = (ans - sub_b + MOD) % MOD;

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

Measured memory_bytes: 256
#include<algorithm>
using namespace std;
#include<stdio.h>
int main(void)
{
	//ソート（並び替え）
	int N,a[100];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a + N);//小さい順に並び変えられる
	
	printf("%d", a[N - 1] - a[0]);

	return 0;

}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

ll rec(ll x){
    if(x==1) return 1;
    else {
        ll attack = 0;
        attack = rec(x/2) * 2 + 1;
        return attack;
    }
}

int main() {
    ll H;
    cin >> H;
    cout << rec(H) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 999999999
using namespace std;
int n;
int a[105];
int f[105];
int ans=0;
int main()
{
	cin>>n;
	a[n]=inf; 
	for(int i=1;i<n;i++) cin>>a[i];
	f[1]=a[1];
	for(int i=2;i<=n;i++)
	f[i]=min(a[i-1],a[i]);
	for(int i=1;i<=n;i++) ans+=f[i];
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
	string str;
	//string reverse="";
	cin>>str;
	for (int i=str.length()-1; i>-1; i--){
		cout<<str.at(i);
	}
	cout<<endl;
	//cout<<reverse<<endl;
	return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool X[N][N];

void initialize(){
  int i;
  for(i=0 ; i<N ; i++){
    row[i]=FREE,col[i]=FREE;
  }
  for(i=0 ; i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}

void printBoard(){
  int i,j;
  for(i=0 ; i<N ; i++){
    for(j=0 ; j<N ; j++){
      if(X[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  for(i=0 ; i<N ; i++){
    for(j=0 ; j<N ; j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }
  for(j=0 ; j<N ; j++){
    if(NOT_FREE==col[j] || NOT_FREE==dpos[i+j] || NOT_FREE==dneg[i-j+N-1])continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int i,j,k,r,c;
  initialize();
  for(i=0 ; i<N ; i++)
    for(j=0 ; j<N ; j++) X[i][j]=false;
  scanf("%d",&k);
  for(i=0 ; i<k ; i++){
    scanf("%d %d",&r,&c);
    X[r][c]=true;
  }
  recursive(0);
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5+10 , OO = 0x3f3f3f3f ;
//const int mod = 1000000007;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int heights[N] , n;
int mem[N];

int goo(int idx){ ///// 4
                  ///// 10 30 40 20
	if(idx > n) return OO;
	if(idx == n-1) return 0;
	int& ret = mem[idx];
	if(~ret) return ret;
	
	int choice1 =  goo(idx+1) + abs(heights[idx] - heights[idx+1]);
	int choice2 = goo(idx+2) + abs(heights[idx] - heights[idx+2]);
	return ret = min(choice1 , choice2);
}


int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin >> n;
	for(int i = 0 ; i < n ; ++i)
		cin >> heights[i];

	clr(mem , -1);
	cout << goo(0) << "\n";



    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const int MAX_N = 200005;
int Nn;
ll cntN = 0,cntZ = 0,cntP = 0;
vector<ll> N,P;
ll A[MAX_N];

ll f(ll x)
{
	ll res = 0,y;
	if (x == 0)
	{
		return cntN * cntP;
	}
	else if (x < 0)
	{
		rep(i,cntN)
		{
			y = x / N[i];
			res += P.end() - upper_bound(P.begin(),P.end(),y);
		}
		return res;
	}
	else
	{
		res += cntN * cntP + (cntN+cntP)*cntZ + (cntZ*(cntZ-1))/2;
		ll temp = 0, cnt = 0;
		rep(i,cntP)
		{
			y = (x + P[i] - 1) / P[i];
			if (P[i] < y) cnt++;
			temp += lower_bound(P.begin(),P.end(),y) - P.begin();
		}
		temp = (temp - cnt) / 2;
		res += temp;
		temp = 0,cnt = 0;
		rep(i,cntN)
		{
			y = (x - N[i] - 1) / N[i];
			if (N[i] > y) cnt++;
			temp += N.end() - upper_bound(N.begin(), N.end(),y);
		}
		temp = (temp - cnt) / 2;
		res += temp;
		return res;
	}
}

ll f2(ll x)
{
	ll res = 0;
	rep(i,Nn)
	{
		if (A[i] < 0)
		{
			int l = -1, r = Nn;
			while(l+1 < r)
			{
				int c = (l+r)/2;
				if (A[i] * A[c] < x) r = c; else l = c;
			}
			res += Nn-r;
		}
		else
		{
			int l = -1, r = Nn;
			while(l+1 < r)
			{
				int c = (l+r)/2;
				if (A[i] * A[c] < x) l = c; else r = c;
			}
			res += l+1;
		}
		if (A[i] * A[i] < x) res--;
	}
	res /= 2;
	return res;
}

int main()
{
	ll K;
	cin >> Nn >> K;
	rep(i,Nn)
	{
		cin >> A[i];
		if (A[i] > 0)
		{
			 cntP++;
			 P.push_back(A[i]);
		}
		else if (A[i] < 0)
		{
			 cntN++;
			 N.push_back(A[i]);
		}
		else
		{
			 cntZ++;
		}
	}

	sort(A,A+Nn);
	sort(P.begin(),P.end());
	sort(N.begin(),N.end());
	ll l = -ll(1e18) - 1, r = ll(1e18) + 1, m;
	while(l+1 < r)
	{
		m = (l+r)/2;
		//cout << m << " " << f2(m) << endl;
		if (f(m) < K) l = m;
		else r = m;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>

using namespace std;

int main() {
	int k, x;

	cin >> k >> x;

	for (int i = x - k + 1; i <= x + k - 1 ; i++) {
		cout << i << endl;
	}


	return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 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):
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = lcm(a,b);
    cout << ans << endl;
    return 0;
}


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


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

const int oo = 1e9 + 7;
const int mod = 1e9 + 7;


int main (){
    ll x, carry = 0;
    cin >> x;

    if (sqrt(8*x + 1) == (int)sqrt(8*x + 1)) carry++;

    ll ans = (1LL + (ll)sqrt(8*x + 1))/2LL;
    cout << ans - carry << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll n = s.size();
  ll num;cin>>num;

  ll lr = 0;
  bool plus = true;
  for(int i=0;i<n;i++){
    if(i%2){
      if(s[i] == '+')plus = true;
      else plus = false;
    }else{
      if(plus)lr += (s[i]-'0');
      else lr *= (s[i]-'0');
    }
  }
  ll cl = 0;
  vi nu;
  nu.pb(s[0]-'0');
  for(int i=1;i<n;i+=2){
    if(s[i] == '+'){
      nu.pb(s[i+1]-'0');
    }else{
      nu[nu.size()-1] *= (s[i+1]-'0');
    }
  }
  //cout<<nu.size()<<endl;

  for(auto a:nu){cl+=a;}
  //cout<<cl<<" "<<lr<<endl;
  if(cl != num && lr != num){
    cout<<"I"<<endl;
  }else{
    if(cl == lr)cout<<"U"<<endl;
    else if(cl == num)cout<<"M"<<endl;
    else cout<<"L"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3232
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret




def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

    ans = 0
    for i in range(n - 1):
        if a[i] + a[i + 1] <= x:
            continue

        v = a[i+1] + a[i] - x
        if a[i + 1] >= v:
            a[i + 1] -= v
            ans += v
        else:
            ans += a[i + 1]
            v -=a[i+1]
            a[i + 1] = 0
            a[i] -= v
            ans+=v
    
    print(ans)




            


    




    


if __name__ == '__main__':
    main()


Measured memory_bytes: 16364
n,m=map(int,input().split())
p=list(map(int,input().split()))
pa=list(range(n))
def find(u):
  if u!=pa[u]:pa[u]=find(pa[u])
  return pa[u]
for i in range(m):
  a,b=map(int,input().split())
  a=find(a-1)
  b=find(b-1)
  if a!=b:pa[a]=b
c=0
for i in range(n):
  if find(p[i]-1)==find(i):c+=1
print(c)

Measured memory_bytes: 20556
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 123456789;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

bool p[1001];
int main() {
	p[1]=1;
	fup(i,2,1000,1)
	{
		int t=i;
		while(1)
		{
			t*=i;
			if(t>1000)break;
			p[t]=1;
		}
	}
	int n;
	scanf("%d",&n);
	while(!p[n--]);
	printf("%d",n+1);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=200000;

int main(){
	int R[MAX],n;
	
	cin >> n;
	for(int i=0;i<n;i++)cin >> R[i];
	
	int maxv=-2000000000;
	int minv=R[0];
	
	for(int i=1;i<n;i++){
		maxv=max(maxv,R[i]-minv);
		minv=min(minv,R[i]);
	}
	
	cout << maxv << endl;
	
	return 0;
}

Measured memory_bytes: 3872
n = int(input())
inp = input().split()
def check(n, inp):
    for i in range(n):
        num = int(inp[i])
        if ((num%2) == 0):
            if ((num%3) != 0) and ((num%5) != 0):
                return 1
    return 0
judge = check(n, inp)
if judge ==1:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3064