akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, n) for (int i = (a); i < (n); ++i)
using namespace std;
using ll = long long;
using uint = unsigned int;
const ll mod = (ll)1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    if (i < k) continue;
    if (a[i] > a[i - k])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
const int N=6e5+5;
char s[N],t[N];
int x,y,n,a[N],cntA[N],cntB[N],sa[N],rk[N],tsa[N],A[N],B[N],h[N],dp[N][25];
void de()
{
    cout<<"OK"<<endl;
}
void solve()
{
    memset(cntA,0,sizeof(cntA));
    for(int i=1;i<=n;i++) cntA[a[i]]++;
    for(int i=1;i<=100;i++) cntA[i]+=cntA[i-1];
    for(int i=n;i>=1;i--) sa[cntA[a[i]]--]=i;
    rk[sa[1]]=1;
    for(int i=2;i<=n;i++)
    {
        rk[sa[i]]=rk[sa[i-1]];
        if(a[sa[i]]!=a[sa[i-1]]) rk[sa[i]]++;
    }
    for(int l=1;rk[sa[n]]<n;l<<=1)
    {
        for(int i=0;i<=n;i++) cntA[i]=cntB[i]=0;
        for(int i=1;i<=n;i++)
        {
            cntA[A[i]=rk[i]]++;
            cntB[B[i]=i+l<=n?rk[i+l]:0]++;
        }
        for(int i=1;i<=n;i++)
            cntB[i]+=cntB[i-1],cntA[i]+=cntA[i-1];
        for(int i=n;i>=1;i--) tsa[cntB[B[i]]--]=i;
        for(int i=n;i>=1;i--) sa[cntA[A[tsa[i]]]--]=tsa[i];
        rk[sa[1]]=1;
        for(int i=2;i<=n;i++)
        {
            rk[sa[i]]=rk[sa[i-1]];
            if(A[sa[i]]!=A[sa[i-1]]||B[sa[i]]!=B[sa[i-1]]) rk[sa[i]]++;
        }
    }
    for(int i=1,j=0;i<=n;i++)
    {
        if(j)j--;
        while(a[i+j]==a[sa[rk[i]-1]+j]) j++;
        h[rk[i]]=j;
    }
}
void st()
{
    for(int i=1;i<=n;i++)
        dp[i][0]=h[i];
    for(int i=1;1<<i<=n;i++)
        for(int j=1;j+(1<<i)-1<=n;j++)
        dp[j][i]=min(dp[j][i-1],dp[j+(1<<(i-1))][i-1]);
}
int query(int l,int r)
{
    int k=log2(r-l+1);
    return min(dp[l][k],dp[r-(1<<k)+1][k]);
}
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
        a[i]=s[i]-'a'+1;
    solve();
    st();
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
    {
        int res=query(i+1,j);
        int l=sa[i],r=sa[j];
        if(l>r) swap(l,r);
        if(l+res<=r)
            ans=max(ans,res);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 21376
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC160E
{
    class Program
    {
        static void Main(string[] args)
        {
            var XYABC = ReadLong();
            var p = ReadLong();
            var q = ReadLong();
            var r = ReadLong();
            int X = (int)XYABC[0];
            int Y = (int)XYABC[1];

            var red = p.OrderByDescending(x => x).Take(X).ToList();
            var green = q.OrderByDescending(x => x).Take(Y).ToList();
            var transparent = r.OrderByDescending(x => x).Take((int)XYABC[4]).ToList();

            var arr = new List<long>();
            arr.AddRange(red);
            arr.AddRange(green);
            arr.AddRange(transparent);

            arr = arr.OrderByDescending(x => x).Take(X + Y).ToList();
            long ans = arr.Sum();

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        //struct Apple
        //{
        //    public long taste;
        //    public 
        //}

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 47060
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let a = input[0].split(' ')[0]
	let b = input[0].split(' ')[1]
	console.log(a === b ? 'H' : 'D')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int h,w,m;
    cin>>h>>w>>m;
    vector<pair<int,int>> ver(h,{0,0}),hor(w,{0,0});
    for(int i=0;i<h;i++) ver[i].first=i;
    for(int i=0;i<w;i++) hor[i].first=i;

    set<pair<int,int>> st;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        st.insert({x,y});
        ver[x].second++;
        hor[y].second++;
    }

    sort(full(ver),[](const pair<int,int>& a, const pair<int,int>& b)-> bool{ return a.second>b.second || (a.second==b.second && a.first<b.first);});
    // sort(full(hor),[](const pair<int,int>& a, const pair<int,int>& b)-> bool{ return a.second>b.second || (a.second==b.second && a.first<b.first);});
    int mx=ver[0].second;
    vector<int> indices;
    for(int i=0;i<ver.size();i++) if(mx==ver[i].second) indices.pb(ver[i].first);
    int ans=0;
    for(int i=0;i<w;i++){
        int val=hor[i].second+ver[0].second;
        bool flag=true;
        for(int j=0;j<indices.size() && flag;j++)
            if(st.find({indices[j],i})==st.end()) flag=false;
        ans=max(ans,(flag?val-1:val));
    }
    cout<<ans<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 24056
N, K = map(int, input().split())
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)


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

int main()
{
	int a[4];
	while (scanf("%d", a) != EOF)
	{
		for (int i = 1; i < 4; ++i) scanf("%d", a + i);
		sort(a, a + 4);
		int res = 0;
		for (int i = 0; i < 4; ++i) res = res * 10 + a[i];
		puts(res == 1479 ? "YES" : "NO");
	}
	return 0;
}


Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

ll read() {
	ll X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int mod=1e9+7;

map<ll,int> f;

int calc(ll n) {
	if (f.count(n)) return f[n];
	return f[n]=((calc(n/2)+calc((n-1)/2))%mod+calc((n-2)/2))%mod;
}

int main() {
	f[0]=1,f[1]=2;
	printf("%d\n",calc(read()));
	return 0;
}

Measured memory_bytes: 3756
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    K = int(input())
    a = 7
    a %= K
    for k in range(K):
        if a % K == 0:
            print(k + 1)
            return
        a = a * 10 + 7
        a %= K
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define array_length(array) (sizeof(array) / sizeof(array[0]))
#define pb push_back

int main() {
  int c = 0;
  char arr[3];
  string input;
  cin >> input;
  rep(i, 3) {
    arr[i] = input[i];
    if (arr[i] == '1') c++;
  }
  cout << c << endl;
  return 0;
}

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

const int MAXN = 300;
int a[MAXN + 1][MAXN + 1];

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
			cin >> a[i][j];
	}
	bool valid = true;
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			int d = 2E9 + 5;
			for (int k = 1; k <= n; k++)
			{
				if (k == i || k == j)
					continue;
				d = min(d, a[i][k] + a[k][j]);
			}
			if (d < a[i][j])
				valid = false;
			else if (d > a[i][j])
				ans += a[i][j];
		}
	}
	cout << (valid ? ans : -1) << endl;

	return 0;
}

Measured memory_bytes: 640
while true
  n = gets.to_i
  break if n == 0

  a = Array.new

  for i in 1..n
    a.push(gets.to_i)
  end

  ans = -10**10

  for i in 0...n
    sum = 0
    for j in i...n
      sum += a[j]
      ans = sum if sum > ans
    end
  end

  puts ans
end

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int const N = 2e5 + 7;

int n, k;
int ar[N];

bool check(int x)
{
	ll res = 0;
	for (int i = 0; i < n; ++i)	
		res += ceil(1.0 * ar[i] / x) - 1;
	return res <= k;
}

int main()
{
	fastio;

	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> ar[i];

	ll lt = 1, rt = *max_element(ar, ar+n);
	while (lt < rt)
	{
		ll mid = (lt + rt) / 2;
		if (check(mid)) rt = mid;
		else lt = mid + 1;
	}
	cout << lt << '\n';

	return 0;
}


Measured memory_bytes: 4312
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())

signed main(){
  int a,b;
  cin>>a>>b;
  string c,d;
  int ans=0;
  for(int i=a; i<=b; i++){
    c=to_string(i);
    d=c;
    rev(d);
    if(d==c)
      ans++;


  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}


int main() {
	int N;
	int K;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
	}
	N--;
	K--;

	int ans = N / K;
	if (N%K != 0) {
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

struct BFSs{
	int pos;int cost;int BIT;
} BFS;

int Cij[10][10];
int H, W;
int Aij[210][210];
int eNumCnt[10];
int ans;
queue<BFSs> bfs;
int BIT;
int d[10];

int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	cin >> H >> W;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			cin >> Cij[i][j];
		}
	}
	for(int i = 0; i < 10; i++){
		d[i] = Cij[i][1];
	}
	for(int j = 0; j < W; j++){
		for(int i = 0; i < H; i++){
			cin >> Aij[i][j];
			if(Aij[i][j] >= 0){
				eNumCnt[ Aij[i][j] ] ++;
			}
		}
	}

	for(int i = 0; i < 10; i++){
		if(i == 1) continue;

		BFS.pos = i;BFS.cost=0;BFS.BIT=0;
		bfs.push(BFS); BFS.BIT |= (1<<i);
		dbugf(i)dbugln;
		while(bfs.size()>0){
			BFSs first = bfs.front(); bfs.pop();
			for(int j = 0; j < 10; j++){
				if(first.BIT & 1<<j) continue;
				if(first.cost+Cij[first.pos][j] <= Cij[i][j]){
					BFS = first;
					Cij[i][j] = BFS.cost+Cij[BFS.pos][j];
					BFS.BIT |= (1<<j);
					BFS.pos = j;BFS.cost = Cij[i][j];
					bfs.push(BFS);
					dbugf(BFS.pos)dbugf(BFS.cost)dbugln;
				}
			}
		}
	}

	/*
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < 10; k++){
				Cij[i][j] = min(Cij[i][j], Cij[i][k] + Cij[k][j]);
			}
		}
	}
	*/

	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			/*dbugf(i)dbugf(j)*/dbugf(Cij[i][j]);
		}
		dbugln;
	}

	ans = 0;
	for(int i = 0; i < 10; i++){
		ans += Cij[i][1]*eNumCnt[i];
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define ff(i,a,b)  for(int i=a;i<=int(b);++i)
#define fr(i,a,b)  for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
const ll M  = 1e9+7 ;
//const int N = 111;
const int inf = 1<<30;
const double EPS = 1e-9;
//////////////////////    Hi    ^_^  hack me if you can :P
string ys = "YES\n";
string no = "NO\n" ;


int main()
{
    speed;
    string s;
    cin >> s;
    for (int i=0;i<sz(s)/2;i++){
        if (s[i]!=s[sz(s)-1-i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,K;cin >> A >> B >> K;
  vector<int> v(K);
  set<int> s;
  int index = 0;
  repp(i,A,A+K){
    if(i>B)break;
    v[index] = i;
    s.insert(i);
    ++index;
  }
  repp(i,B-K+1,B+1){
    if(s.count(i))continue;
    if(i<A)continue;
    v.push_back(i);
    s.insert(i);
    ++index;
  }
  rep(i,index) cout << v[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define inf 100000000000000000
#define f first
#define s second
using namespace std;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,m;
	cin >> n >> m;
	pair <pair<int,int>,int> v[m];
	for(int i=0;i<m;++i)
		cin >> v[i].f.f >> v[i].s >> v[i].f.s ;
	sort(v,v+m);
	int d[n+1];
	for(int i=1;i<=n;i++)
		d[i]=inf;
	d[1]=0;
	set <int> s;
	s.insert(1);
	s.insert(n);
	for(int i=0;i<m;++i){
		int l=v[i].f.f,r=v[i].s,c=v[i].f.s;
		set <int> :: iterator itl,itr,t;
		itr=s.lower_bound(r);
		itl=s.lower_bound(l);
		int x=d[*itl]+c;
		if(x>=d[*itr])
			continue;
		t=--itr;
		while(d[*t]>=x){
			if(t==s.begin()){
				s.erase(t);
				break;
			}
			t--;
			s.erase(itr);
			itr=t;
		}
		s.insert(r);
		d[r]=x;
	}
	// for(int i=1;i<=n;i++)
	// 	cout << d[i] << " ";
	if(d[n]==inf)
		d[n]=-1;
	cout << d[n] << endl;
}

Measured memory_bytes: 7936
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int m;
int main(){
	lint sum=0,digits=0;
	std::cin>>m;
	rep(i,m){
		lint d,c;
		std::cin>>d>>c;
		sum+=d*c;
		digits+=c;
	}
	std::cout<<digits-1+(sum-1)/9<<std::endl;
	return 0;
}


Measured memory_bytes: 3632
import java.util.*;

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

        int n = sc.nextInt();
        long min = sc.nextInt();
        long ret = -1000000001;

        for (int i = 1; i<n; i++){
            long r = sc.nextInt();
            if (r - min > ret) ret = r - min;
            if (r < min) min = r;
        }
        System.out.println(ret);
    }
}

Measured memory_bytes: 68504
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n;
    cin>>n;
    lli a[n + 1];
    for(int i = 1; i <= n; i ++) {
        cin>>a[i];
    }
    vector<lli> v;
    for(int i = n; i >= 1; i --) {
        lli cnt = 0;
        for(int j = i; j <= n; j += i) {
            cnt += a[j];
        }
        if(cnt % 2 == a[i]) {
            ;
        }
        else {
            a[i] ^= 1;
        }
        if(a[i] == 1) {
            v.push_back(i);
        }
    }

    cout<<v.size()<<'\n';
    for(auto it : v) {
        cout<<it<<' ';
    }


    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3700
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		HashMap<String,Integer> c = new HashMap<>();
		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		for(int i = 0;i < n;i++){
			String s = saori.nextHayami();
			if(s.equals("AC"))ac++;
			if(s.equals("WA"))wa++;
			if(s.equals("TLE"))tle++;
			if(s.equals("RE"))re++;
		}
		System.out.println("AC x  "+ac);
		System.out.println("WA x  "+wa);
		System.out.println("TLE x  "+tle);
		System.out.println("RE x  "+re);
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}


Measured memory_bytes: 46508
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 100
#define NUM 30

int H, W;
char S, T;
string filed[MAX];
vector<int> G[NUM];


void check(int y, int x){
	int num = filed[y][x] - 'A';
	
	if(y-2 >= 0 && filed[y-2][x] == '|'){
		for(int i = y-2; i >= 0; i--){
			if('A' <= filed[i][x] && filed[i][x] <= 'Z'){
				G[num].push_back(filed[i][x]-'A');
				break;
			}
		}
	}
	if(y+2 < H && filed[y+2][x] == '|'){
		for(int i = y+2; i < H; i++){
			if('A' <= filed[i][x] && filed[i][x] <= 'Z'){
				G[num].push_back(filed[i][x]-'A');
				break;
			}
		}
	}
	if(x-2 >= 0 && filed[y][x-2] == '-'){
		for(int i = x-2; i >= 0; i--){
			if('A' <= filed[y][i] && filed[y][i] <= 'Z'){
				G[num].push_back(filed[y][i]-'A');
				break;
			}
		}
	}
	if(x+2 < W && filed[y][x+2] == '-'){
		for(int i = x+2; i < W; i++){
			if('A' <= filed[y][i] && filed[y][i] <= 'Z'){
				G[num].push_back(filed[y][i]-'A');
				break;
			}
		}
	}
}

int bfs(){
	queue<pair<int,int>> Q;
	int used[NUM] = {};
	
	Q.push(make_pair(S-'A',0));
	
	// for(int i = 0; i < 26; i++){
		// if(G[i].size()){
			// cout<<(char)(i+'A')<<" : ";
			// for(int j = 0; j < G[i].size(); j++){
				// cout<<"  "<<(char)(G[i][j]+'A');
			// }cout<<endl;
		// }
	// }
	while(!Q.empty()){
		pair<int,int> num = Q.front();Q.pop();
		
		if(num.first == T-'A') return num.second;
		
		for(int i = 0; i < G[num.first].size(); i++){
			if(used[G[num.first][i]]) continue;
			used[G[num.first][i]] = true;
			Q.push(make_pair(G[num.first][i],num.second+1));
		}
	}
	
	return -1;
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	cin>>H>>W>>S>>T;
	
	for(int i = 0; i < H; i++){
		cin>>filed[i];
	}
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if('A' <= filed[i][j] && filed[i][j] <= 'Z'){
				check(i,j);
			}
		}
	}
	
	cout<<bfs()<<endl;
	
	return 0;
}


Measured memory_bytes: 3236
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    *this << "\n[";
    for (auto &elem : x) *this << elem << ", ";
    return *this << "]";
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << "{" << x.first << ", " << x.second << "}";
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args ...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(string(#args)), args), dbg << endl
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int n, m, K, T, Q, cn;//}
const int inf = 1000000007, mxn = 205;

pair<int, int> a[mxn];

ll euclid(const pair<int, int> &x) {
    return x.first*ll(x.first)+x.second*ll(x.second);
}

double angle(const pair<int, int> &x) {
    return atan2(x.second, x.first);
}

struct cmp { bool operator() (const pair<int, int> &ls, const pair<int, int> &rs) const {
    return angle(ls)<angle(rs);
}};

template<class B, class C> pair<B, C> operator +(const pair<B, C> &x, const pair<B, C> &y) {
    return pair<B, C>(x.first+y.first, x.second+y.second);
}
template<class B, class C> pair<B, C> operator -(const pair<B, C> &x, const pair<B, C> &y) {
    return pair<B, C>(x.first-y.first, x.second-y.second);
}

template<class B> B& operator +=(B &x, const B &y) { return x = x+y; }
template<class B> B& operator -=(B &x, const B &y) { return x = x-y; }

int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.precision(11);
// Main idea is: the points we will take will form a consecutive range if we sort on slopes.
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a+n, cmp());
    for (int i = 0; i < n; i++) {
        a[i+n] = a[i];
    }
    ll mx = 0;
    pair<int, int> cur = {0, 0};
    for (int i = 0, j = 0; j<2*n; ) {
        if (j-i<n and (j<=i or euclid(cur+a[j])>=euclid(cur))) {    // got wa for using > instead >=, for (0, 0)
            cur += a[j++];
            mx = max(mx, euclid(cur));
        } else {
            cur -= a[i++];
            mx = max(mx, euclid(cur));
        }
    }
    cout << sqrt(mx) << '\n';
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Square Carpets
public class Main{

	int w, h, res, L;
	int[][] a, t;
	boolean[][][] ok;
	Map<Integer, Integer> ref;

	void copy(int[][] a, int[][] b){
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)b[i][j]=a[i][j];
	}

	int get(int[][] t){
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)sb.append(t[i][j]);
		return sb.toString().hashCode();
	}

	void dfs(int i, int j, int step){
		if(res<=step)return;
		if(i==h){
			res = step; return;
		}
		if(a[i][j]==0){
			if(j==w-1)dfs(i+1, 0, step);
			else dfs(i, j+1, step);
		}
		if(t[i][j]==1){
			if(j==w-1)dfs(i+1, 0, step);
			else dfs(i, j+1, step);	
		}
		int[][] p = new int[h][w];
		copy(t, p);
		for(int len=L;len>0;len--){
			if(!ok[i][j][len])continue;
			for(int y=i;y<i+len;y++)for(int x=j;x<j+len;x++)t[y][x] = 1;
			int hash = get(t);
			if(ref.containsKey(hash)&&ref.get(hash)<=step){
				copy(p, t); return;
			}
			ref.put(hash, step);
			if(j==w-1)dfs(i+1, 0, step+1);
			else dfs(i, j+1, step+1);
			copy(p, t);
			break;
		}
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			w = sc.nextInt(); h = sc.nextInt();
			if((w|h)==0)break;
			L = Math.min(h, w);
			a = new int[h][w];
			ok = new boolean[h][w][L+1];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)a[i][j]=sc.nextInt();
			for(int d=1;d<=L;d++)for(int i=0;i+d<=h;i++)for(int j=0;j+d<=w;j++){
				boolean f = true;
				for(int y=i;y<i+d;y++)for(int x=j;x<j+d;x++)if(a[y][x]==0)f = false;
				if(f)ok[i][j][d] = true;
			}
			res = w*h;
			ref = new HashMap<Integer, Integer>();
			t = new int[h][w];
			dfs(0, 0, 0);
			System.out.println(res);
		}
	}

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

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

#define debug 0

using namespace std;
typedef long long lint;

const int maxw = 1e5+5, maxn = 105;

int i, j;
int n, w, we, val;
lint d[2][maxw], ans;


int main()
{
    #if debug
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
    #endif

    cin >> n >> w;

    for(i = 1; i <= n; i ++) {
        cin >> we >> val;
        for(j = 0; j <= w; j ++) {
            d[0][j] = d[1][j];
        }
        for(j = we; j <= w; j ++) {
            if(!(j - we != 0 && d[0][j - we] == 0)) {
                d[1][j] = max(d[0][j], d[0][j - we] + val);
            }
            if(d[1][j] > ans) {
                ans = d[1][j];
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
 using namespace std;
 
int main()
{
	int n,c,x=0;
	cin>>n;
	int v[n];
	for(int i=0;i<n;i++){
		cin>>v[i];
	} 		
	sort(v,v+n);
	if(n%2==0){
		x=v[n/2]-v[n/2-1];
	}
	cout<<x;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int a[100], b[100], c[100];
int main(){
	int n;
	cin >> 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 sum = 0;
	for(int i = 1; i <= n; i++){
		int x = a[i];
		if(a[i-1] == a[i] - 1)
			sum += c[x-1];
		sum += b[x];
	}
	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 256
n, x = map(int, input().split())
m = [int(input()) for i in range(n)]

rest = x - sum(m)
min_ = min(m)

count = n

if rest < 0:
    count = 0
else:
    while True:
        rest -= min_
        if rest >= 0:
            count += 1
        else:
            break
print(count)

Measured memory_bytes: 3060
n=int(input())
cnt=0 
dp=[[[0 for j in range(10)]for i in range(10)]for k in range(10)]
ans=[0]
arr=[0]
vis=set()
vis.add(0)
while arr: 
    t=arr.pop(0)
    a=t*10+3 
    b=t*10+5 
    c=t*10+7 
    def ok(x):
        return x<=n and x not in vis 
    for i in [a,b,c]:
        if ok(i):
            vis.add(i)
            ans.append(i)
            arr.append(i)
ans.sort()
from bisect import bisect_left as bl 
c=0 
def valid(a):
    one=0 
    two=0 
    three=0 
    while a: 
        if a%10==3:
            one+=1 
        if a%10==5:
            two+=1 
        if a%10==7:
            three+=1 
        a//=10 
    if one==0 or two==0 or three==0:
        return 0 
    return 1 
for i in ans: 
    if valid(i):
        c+=1 
    if i>n:
        break 
print(c)

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



int main(){
	int64_t X,Y; cin >> X >> Y;
	int64_t i = Y;
	int count = 0;
	while(X <= i){
		count++;
		i /= 2;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << (n + 1) / 2 << '\n';
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//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 SQ(a) ((a)*(a))
#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())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

// ここから編集
template<typename T = int> struct BIT{
  vector<T> node;

  int N;
  BIT(int n){
    N = n;
    node.resize(N+1);
  }

  void add(int i, T x){
    i++;
    while(i <= N){
      node[i] += x;
      i += (i & -i);
    }
  }

  T sum(int i){
    T res = 0;
    while(i > 0){
      res += node[i];
      i -= (i & -i);
    }
    return res;
  }

  

};

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

    ll N; cin >> N;
    //cout << N << endl;
    N--;
    string s = "";
    while(N>=0){
      s += (char)(N%26 + 'a');
      N /= 26;
      N--;
    }
    reverse(all(s));
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3648
<?php
$input = explode(' ', trim(fgets(STDIN)));
$num = intval($input[0]);
$order = intval($input[1]);
$array = array();

for ($i=0; $i < $num; $i++) {
  $tmp = explode(' ', trim(fgets(STDIN)));
  $in = intval($tmp[0]);
  $loop = intval($tmp[1]);
  if (isset($array[$in])) {
    $array[$in] += $loop;
  } else {
    $array[$in] = $loop;
  }
}

ksort($array);
foreach ($array as $key => $value) {
  if ($value >= $order) {
    echo $key."\n";
    break;
  } else {
    $order -= $value;
  }
}


Measured memory_bytes: 13044
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N);

  for (ll i = 0; i < N; i++) {
    cin >> L[i];
  }

  // 降順にソートする
  sort(L.begin(), L.end());

  ll ans = 0;
  // a <= b <= c
  // a, bの全探索
  for (ll a = 0; a < N - 2; a++) {
    for (ll b = a + 1; b < N - 1; b++) {
      // c < a + b
      // c >= b
      ll lower = lower_bound(L.begin(), L.end(), L[a] + L[b]) - L.begin();
      if (lower - (b + 1) < 0) continue;
      ans += lower - (b + 1);
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

struct UnionFind {
    vector<int> par;
    vector<int> depth;
    UnionFind (int num) {
        par.resize(num, -1);
        depth.resize(num, 1);
    }
    int find (int a) {
        if (par[a] == -1) return a;
        else return par[a] = find(par[a]);
    }
    void unite (int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return;
        else {
            if (depth[a] < depth[b]) {
                par[a] = b;
            } else {
                par[b] = a;
                if (depth[a] == depth[b]) {
                    depth[a]++;
                }
            }
        }
    }
};

int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    vector<int> sz(n);
    for (int i = 0; i < n; ++i) {
        sz[uf.find(i)]++;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, sz[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define MP make_pair

typedef double db;

const db EPS = 1e-8;

inline int sign(db a) {
	return a < -EPS ? -1 : a > EPS;
}

struct P {
	db x, y;
	P() {
	}
	P(db _x, db _y) :
			x(_x), y(_y) {
	}
	P operator+(P p) {
		return P(x + p.x, y + p.y);
	}
	P operator-(P p)  {
		return P(x - p.x, y - p.y);
	}
	P operator*(db d) {
		return P(x * d, y * d);
	}
	P operator/(db d) {
		return P(x / d, y / d);
	}
	bool operator<(P p) const {
		int c = sign(x - p.x);
		if (c)
			return c == -1;
		return sign(y - p.y) == -1;
	}
	db dot(P p) {
		return x * p.x + y * p.y;
	}
	db det(P p) {
		return x * p.y - y * p.x;
	}
	db distTo(P p) { return (*this-p).abs(); }

	db alpha() {
		return atan2(y, x);
	}
	void read() {
		cin>>x>>y;
	}
	db abs() {
		return sqrt(abs());
	}
	db abs2() {
		return x * x + y * y;
	}
	P rot90(){
		return P(-y,x);
	}
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

P isSS(P p1, P p2, P q1, P q2) {
	db a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
	return (p1 * a2 + p2 * a1) / (a1 + a2);
}

bool isMiddle(db a, db m, db b) {
    return sign(a - m) == 0 || sign(b - m) == 0 || (a < m != b < m);
}
 
bool isMiddle(P a, P m, P b) {
    return isMiddle(a.x, m.x, b.x) && isMiddle(a.y, m.y, b.y);
}

P proj(P p1, P p2, P me) {
    P dir = p2 - p1;
    return p1 + dir * (dir.dot(me - p1) / dir.abs2());
}

P reflect(P p1, P p2, P me){
	return proj(p1,p2,me) * 2 - me;
}

db nearest(P p1,P p2,P me){
	P h = proj(p1,p2,me);
	if(isMiddle(p1,h,p2))
		return me.distTo(h);
	return min(p1.distTo(me),p2.distTo(me));
}

db getrad(P p1,P p2){
	return atan2l(p1.det(p2),p1.dot(p2));
}

db incircle(P p1, P p2, P p3){
	db A = p1.distTo(p2);
	db B = p2.distTo(p3);
	db C = p3.distTo(p1);
	return sqrtl(A*B*C/(A+B+C));
}

int main(){
	P p1, p2;
	p1.read(),p2.read();
	int n;cin>>n;
	rep(i,0,n){
		P q; q.read();
		P ret = reflect(p1,p2,q);
		printf("%0.10f %0.10f\n",ret.x,ret.y);
	}

	return 0;
}

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  ans=-inf
  a=min(n,k)
  for i in range(a+1):
    sm=0
    for j in range(a+1-i):
      if j!=0:
        _q=l[:i]+l[-j:]
      else:
        _q=l[:i]

      q=[]
      for x in _q:
        heapq.heappush(q,x)
      ans=max(ans,sum(q))

      for _ in range(k-i-j):
        if len(q)>0:
          heapq.heappop(q)
          ans=max(ans,sum(q))
        else:
          break

  return ans

# main()
print(main())


Measured memory_bytes: 5432
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String txt = scan.nextLine();

        HashMap<Character, Boolean> hash = new HashMap<Character, Boolean>();

        for (int i=0; i < txt.length(); i++) {
            if (hash.containsKey(txt.charAt(i))) {
                hash.remove(txt.charAt(i));
            } else {
                hash.put(txt.charAt(i), true);
            }
        }

        if (hash.size() == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main(){
    ll x;cin>>x;
    int a=0;
    double b=sqrt(x);
int c=(int) b;
 
    for(int i=c;i>0;i--){ if(x%i==0){cout<<i+x/i-2<<endl;break; }}

}

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	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 getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	pp := make([]product, n)
	for i := 0; i < n; i++ {
		pp[i].v = getNextInt(scanner)
		pp[i].w = getNextInt(scanner)
		pp[i].t = int(getNextString(scanner)[0] - 'A')
		pp[i].d = getNextInt64(scanner)
		pp[i].s = getNextString(scanner)
	}
	sort.SliceStable(pp, func(i, j int) bool {
		if pp[i].v == pp[j].v {
			if pp[i].w == pp[j].w {
				if pp[i].t == pp[j].t {
					if pp[i].d == pp[j].d {
						return strings.Compare(pp[i].s, pp[j].s) == -1
					}
					return pp[i].d < pp[j].d
				}
				return pp[i].t < pp[j].t
			}
			return pp[i].w < pp[j].w
		}
		return pp[i].v < pp[j].v
	})

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, fmt.Sprintf("%d %d %c %d %s", pp[i].v, pp[i].w, pp[i].t+'A', pp[i].d, pp[i].s))
	}
}

type product struct {
	v int
	w int
	t int
	d int64
	s string
}



Measured memory_bytes: 17472