akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)

void corr(vector<ll> const& l,int& right){
  int left=0;
  int mid;
  int key=right;
  while(right-left<1){
    mid=(left+right)/2;
    if(l[mid]==l[key])right=mid;
    else left=mid;
  }
}
int bs(vector<ll> const& l,int key){
  int left=0;
  int right=l.size()-1;
  int mid;
  while(right>left+1){
    mid=(left+right)/2;
    if(l[mid]>key)right=mid;
    else left=mid;
  }
  if(l[right]==l[right-1])corr(l,right);
  if(key<l[0])right=0;
  if(key>=l[l.size()-1])right=l.size();
  return right;
}
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  vector<ll> b_sum(n+1,0);
  vector<ll> c_sum(n);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  vector<ll> b_num(n+1,0);
  rep(i,n)b_num[i]=n-bs(c,b[i]);
  b_sum[n-1]=b_num[n-1];
  rep1(i,n-1)b_sum[n-i-1]=b_sum[n-i]+b_num[n-i-1];
  ll ans=0;
  //  rep(i,n)cout<<b_sum[i]<<" "<<b_num[i]<<endl;
  rep(i,n)ans+=b_sum[bs(b,a[i])];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  if (S == "RRR") {
    ans = 3;
  } else if (S == "RRS") {
    ans = 2;
  } else if (S == "SRR") {
    ans = 2;
  } else if (S == "SSS") {
    ans = 0;
  } else {
    ans = 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) = abc156d()

fun abc156d() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }

    var answer = Mint(2).modPow(n.toLong())
    answer -= 1
    answer -= comb(n, a)
    answer -= comb(n, b)

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private fun modPow(n: Long, p: Long, m: Long = MOD): Long {
    var x = n
    var y = p
    var result = 1L

    x %= m
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % m
        y = y shr 1
        x = (x * x) % m
    }

    return result
}

// useful for big N, and small K
private fun comb(n: Int, k: Int, m: Long = MOD): Long {
    if (n < k) return 0

    val min = Math.min(k, n - k)
    var value = 1L

    for (i in 1L..min) {
        value *= n - i + 1
        value %= m
        value *= modPow(i, m - 2, m)
        value %= m
    }
    return value
}

private class Mint(value: Long = 0L) {
    constructor(other: Mint) : this(other.value)

    private val value = if (value < 0) (value % MOD) + MOD else value % MOD
    operator fun unaryPlus() = this
    operator fun unaryMinus() = Mint(MOD - this.value)
    operator fun inc() = this.plus(1)
    operator fun dec() = this.minus(1)
    operator fun plus(other: Long) = Mint(this.value + other)
    operator fun plus(other: Mint) = this.plus(other.value)
    operator fun minus(other: Long) = Mint(this.value - other)
    operator fun minus(other: Mint) = this.plus(-other)
    operator fun times(other: Long) = Mint(this.value * other)
    operator fun times(other: Mint) = this.times(other.value)
    operator fun div(other: Long) = this.times(Mod.modPow(other, MOD - 2, MOD))
    operator fun div(other: Mint) = this.div(other.value)
    fun modPow(other: Long) = Mint(Mod.modPow(this.value, other, MOD))
    override fun toString() = this.value.toString()
    override fun hashCode() = value.hashCode()
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as Mint
        return value == other.value
    }

    companion object Mod {
        private fun modPow(n: Long, p: Long, m: Long = MOD): Long {
            var x = n
            var y = p
            var result = 1L
            x %= m
            while (y > 0) {
                if (y % 2 == 1L) result = (result * x) % m
                y = y shr 1
                x = (x * x) % m
            }
            return result
        }
    }
}


Measured memory_bytes: 36396
#include <stdio.h>
#include <stdlib.h>
#include<math.h>

int main(){
  int x;
  scanf("%d",&x);
  int ans=0;
  if(x==1){
    puts("1");
    return 0;
  }
  for(int i=2;i<sqrt(x);i++){
    for(int j=2;;j++){
      int num = pow(i,j);
      if(num>x)break;
      if(num > ans) ans=num;
    }
  }
  printf("%d\n",(int)ans);
  return 0;
}


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

int main() {
	int n, m; cin >> n >> m;
	vector<int>a(n);
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		a[x - 1]++; a[y - 1]++;
	}

	for (int i = 0; i < n; i++) {
		if (a[i] % 2 != 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1000000

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,a[200010],b[200010];
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=n;i>=1;i--){
	ll sum=0;
	for(int j=i*2;j<=n;j+=i)sum+=b[j];
	sum%=2;
	if(sum==a[i])b[i]=0;
	else b[i]=1;
    }
    vector<ll> ans;
    for(int i=1;i<=n;i++)if(b[i]==1)ans.push_back(i);
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
	if(i)cout<<" ";
	cout<<ans[i]<<endl;
    }
}




Measured memory_bytes: 5364
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b;cin>>a>>b;
    string s;cin>>s;
    bool f=true;
    for(int i=0;i<(int)s.length();i++){
        if(i==a){
            if(s[i]!='-') f=false;
        }
        else{
            if(s[i]<'0' || '9'<s[i]) f=false;
        }
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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




//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e5 + 1;//                                                             |
//----------------------------------------------------------------------------------





//main func
void solve()
{
    ll a,b,c;cin>>a>>b>>c;
    vl n(a),m(b);
    /*queue<ll> n,m;
    for(int i=0;i<a;i++){
        ll tmp;cin>>tmp;
        n.push(tmp);
    }
    for(int i=0;i<b;i++){
        ll tmp;cin>>tmp;
        m.push(tmp);
    }*/
    for(auto &i:n) cin>>i;
    for(auto &i:m) cin>>i;
    
    ll i=0,j=0;
    ll sums=0;
    ll ans=0;
    while(c>0 && i<a){
        if(sums+n[i]<=c){
            sums+=n[i];
            i++;
            ans++;
        }
        else break;
    }
    ll k=ans;
    i--;
    //show(i);
    
    while(j<b){
        while(sums+m[j]>c && i>=0){
            sums-=n[i];
            i--;
            k--;
        }
        if(sums+m[j]<=c){
            sums+=m[j];
            j++;
            k++;
            ans=max(ans,k);
        }
        else{
            break;
        }
        
    }
    cout<<ans<<"\n";
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}


Measured memory_bytes: 6356
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
const int maxn=2000;
int n,k;
int f[maxn+8][maxn+8],g[maxn+8][maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int power(int a,int k)
{
    if (k<0) return 1;
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
    if (k&1)
        sum=1ll*sum*a%mod;
    return sum;
}

int main()
{
    n=read(),k=read();
    g[0][0]=1;
    for (int i=1;i<n;i++)
	{
	    g[i][0]=g[i-1][0];
	    for (int j=1;j<=i;j++)
		    g[i][j]=(g[i][j-1]+g[i-1][j])%mod;
	}
    int ans=g[n-1][k-1];
    ans=1ll*ans*power(2,n-k-1)%mod;
    printf("%d\n",ans);
    return 0;
}

    


Measured memory_bytes: 15744
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
MOD = 10**9+7
def gcd(a, b):
    while a and b:
        if a > b:
            a %= b
        else:
            b %= a
    return max(a, b)

def lcm(a, b):
    _gcd = gcd(a, b)
    return a * b // _gcd

_a = a_ls[0]
for a in a_ls:
    _a = lcm(_a, a)
ls = [_a // a for a in a_ls]
print(sum(ls) % MOD)

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

using namespace std;

int main() {
    int h,n;
  cin>>h>>n;
  int x,i;
  for(i=0;i<n;i++){
      cin>>x;
      h=h-x;
  }
  if(h>0)
  cout<<"No"<<endl;
  else
  cout<<"Yes"<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int n, k;
int a[100010];
int main(void){
	cin >> n >> k;
	ll sum = 0;
	rep(i, n){
		cin >> a[i];
		if(a[i] >= 0) sum += a[i];
	}
	ll ans = 0;
	/*
	rep(i, n - k + 1){
		ll cnt = 0;
		// printf("i %d\n", i);
		reps(j, i, i + k){
			// printf("%d\n", j);
			if(a[j] >= 0) cnt += a[j];
		}
		chmax(ans, sum - cnt);
	}
	*/
	ll cnt = 0;
	rep(i, k){
		if(a[i] >= 0) cnt += a[i];
	}
	chmax(ans, sum - cnt);
	int l = 0;
	reps(j, k, n){
		if(a[j] > 0) cnt += a[j];
		if(a[l] > 0) cnt -= a[l];
		l++;
		// printf("%lld\n", sum - cnt);
		chmax(ans, sum - cnt);
	}

	/*
	//kますとる
	rep(i, n - k + 1){
		ll cnt = 0;
		ll pulus = 0;
		// printf("i %d\n", i);
		reps(j, i, i + k){
			if(a[j] < 0) cnt += a[j];
		}
		chmax(ans, sum + cnt);
	}
	*/
	// printf("k\n");
	cnt = 0;
	rep(i, k){
		if(a[i] < 0) cnt += a[i];
	}
	chmax(ans, sum  + cnt);
	l = 0;
	reps(j, k, n){
		if(a[j] < 0) cnt += a[j];
		if(a[l] < 0) cnt -= a[l];
		l++;
		// printf("%lld\n", sum + cnt);
		chmax(ans, sum + cnt);
	}


	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
vector<int>vc;
int main(){
int a,b,c;
cin>>a>>b>>c;
vc.push_back(a);
vc.push_back(b);
vc.push_back(c);
sort(vc.begin(),vc.end());
if (vc[0]==vc[1])
    cout<<vc[2];
else if ( vc[0] < vc[1] || vc[0] > vc[1] )
    cout<<vc[0];
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int p[100000];
int main() {
	int N;
	cin >> N;
	rep(i, N) cin >> p[i];
	int ans = 0;
	rep(i, N - 1) {
		if (p[i] == i + 1) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	if (p[N - 1] == N) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin>>s;
	cout<<s.substr(0,1)<<s.length()-2<<s.substr(s.length()-1,1)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int n;
int s[100000];

int Binary(int a){
  int L = 0;
  int C = 0;
  int R = n;
  while(R > L){

  C = (L + R)/2;

  if(a == s[C]){
    return 1;
  }
  else if(a < s[C])
    R = C;
  else if(a > s[C])
    L = C + 1;
  }
  return 0;
}



int main(){

int a, q, i, j, ans = 0;


  scanf("%d", &n);
for(i = 0; i < n; i++){
  scanf("%d", &s[i]);
}

  scanf("%d", &q);
for(i = 0; i < q; i++){
  scanf("%d", &a);
  if(Binary(a) == 1)
    ans++;
}

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if((a + b) % 2 == 1)
    cout << (a + b) / 2 + 1 << endl;
  else 
    cout << (a + b) / 2 << endl;
}

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

using namespace std;

typedef long long ll;

static const ll md = 1e9+7;
static const ll mx = 100000;


int main(int, char**)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	
	int n, m;
	cin >> n >> m;
	vector<int> s(n);
	vector<int> t(m);
	for (int i = 0; i < n; ++i)
		cin >> s[i];
	for (int i = 0; i < m; ++i)
		cin >> t[i];

	vector<ll> x1(n+1, 0);
	vector<ll> x2(n+1);

	x2[0] = 0;
	ll* y1;
	ll* y2;
	for (int i = 0; i < m; ++i) {
		if (i % 2 == 0) {
			y1 = &(x1[0]); y2 = &(x2[0]);
		} else {
			y1 = &(x2[0]); y2 = &(x1[0]);
		}
		for (int j = 0; j < n; ++j) {
			if (s[j] == t[i]) {
				y2[j+1] = (y2[j] + y1[j+1] + 1)%md;
			} else {
				y2[j+1] = (y2[j] + y1[j+1] - y1[j])%md;
			}
			if (y2[j+1] < 0) y2[j+1] += md;
		}
	}

	cout << ((y2[n] + 1)%md) << endl;
	return 0;
}


Measured memory_bytes: 384
N = int(input())
headB=0
tailA=0 
both = 0
ans = 0
for j in range(N):
    t = input()
    if t[0] == "B":
        if t[-1] == "A":
            both += 1
        else:
            headB += 1
    elif t[-1] == "A":
        tailA += 1
    ans += t.count("AB")
if both > 0:
    ans += both - 1
    if tailA > 0 or headB > 0:
        ans += 1
ans += min(tailA,headB)
print(ans)

Measured memory_bytes: 3064
#include <iostream>

int main () {
	int N, A, B;
	int sum, num;
	int ans = 0;
	std::cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		sum = 0;
		num = i;
		while (num > 0) {
			sum += num % 10;
			num /= 10;
		}
		if (A <= sum && sum <= B) {
			ans += i;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 888
use std::io::{stdin, Read};
use std::str::FromStr;


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 token")
}


fn main() {
    let a: u32 = read();
    let b: u32 = read();

    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> cse(N+1, 0), csw(N+1, 0);

    for(int i = 0; i < N; ++i) {
        cse[i+1] += cse[i];
        if(S[i] == 'E') cse[i+1] += 1;
        csw[i+1] += csw[i];
        if(S[i] == 'W') csw[i+1] += 1;
    }

    int ans = INF;
    for (int i = 0; i < N; ++i) {
        int now = csw[i] + (cse[N]-cse[i+1]);
        ans = min(ans, now);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n == 0) cout << 1 << endl;
    else if(n == 1) cout << 2 << endl;
    else if(n == 2) cout << 1 << endl;
    else cout << 0 << endl;
}

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

int main(){
    long long int a,b,c,d,e,f,g;
    cin >> a;
    if(a < 2){
        cout <<0;
    }else if(a == 2){
        cout <<2;
    }else{
        b = 10;
        for(int i=0;i<a-1;i++){
          b = (b*10%1000000007)%1000000007;
        }
      	b = b % 1000000007;
        c = 8;
        for(int i = 0;i<a-1;i++){
            c = (c*8%1000000007)%1000000007;
        }
        c = c%1000000007;
        d = 9;
        for(int i = 0;i<a-1;i++){
            d = (d*9%1000000007)%1000000007;
        }
        d = d%1000000007;
        d = (b-2*d+c)%1000000007;
        if(d <0){
            d = d + 1000000007;
        }
        cout << d;
    }
}

Measured memory_bytes: 3624
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unrolong long-loops")
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#define F first
#define S second
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int k=(int)s.size();
    while(k--){
        cout<<'x';
    }
    return 0;
}
/*
 1 - u
 2 - d
 3 - r
 4 - l
 
 
 9
 0 1 0 2
 1
 0 2 0 3 2
 0 3 0 4 3
 0 4 1 0 4
 1 0 1 1 5
 1 1 1 2 6
 1 2 1 3 7
 1 3 1 4 8
 1 4 2 0 9
 */


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%s", $t);
$l = strlen($s);
for ($i = 0; $i < $l; $i++) {
	$p[$s[$i]][] = $i;
}
$t1 = str_split(count_chars($t, 3));
foreach ($t1 as $c) {
	if (!isset($p[$c])) exit('-1');
	$i = 0;
	for ($j = 0; $j < $l; $j++) {
		if ($p[$c][$i] < $j) {
			$i++;
			if (!isset($p[$c][$i])) {
				$p[$c][$i] = $l + $p[$c][0];
			}
		}
		$next[$c][$j] = $p[$c][$i];
	}
}
$x = 0;
$j = -1;
for ($i = 0; $i < strlen($t); $i++) {
	$j++;
	if ($j == $l) { $x += $l; $j = 0; }
	if ($next[$t[$i]][$j] >= $l) {
		$x += $l;
	}
	$j = $next[$t[$i]][$j] % $l;
}
echo $x + $j + 1;

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

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int n,ans=0,b[maxn],cnt[maxn][26],x;
string str[maxn],tmp;
vector<pair<string,int>> vec;
bool flag;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep(n) cin >> str[i];
    rep(n){reverse(all(str[i]));b[i]=str[i].back()-'a';str[i].pop_back();}
    rep(n) vec.pb(mp(str[i],i));
    sort(all(vec));
    rep(n) rep1(j,26) cnt[i][j]=0;
    rep(n) for(auto c: vec[i].first) cnt[i][c-'a']++;
    rep(n) cnt[i][b[vec[i].second]]++;
    rep(n){
        tmp.clear();
        flag=false;
        rep3(j,sz(vec[i].first)-1,0){
            if(vec[i].first[j]!='z'){
                flag=true;
                rep1(k,j) tmp.pb(vec[i].first[k]);
                tmp.pb(vec[i].first[j]+1);
                break;
            }
        }
        if(!flag) x=n;
        else x=lower_bound(all(vec),mp(tmp,-1ll))-vec.begin();
        rep2(j,i+1,x) if(cnt[j][b[vec[i].second]]>=cnt[i][b[vec[i].second]]) ans++;
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 59684
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    bool f;

    int l = s.length() - t.length();
    for (int i = l; i >= 0; --i) {
        string tmp = s.substr(i, t.length());
        f = true;
        for (int j = 0; j < t.length(); ++j) {
            if (tmp[j] == '?' || tmp[j] == t[j]) {
                continue;
            } else {
                f = false;
                break;
            }
        }
        if (f) {
            for (int k = 0; k < t.length(); ++k) {
                s[i + k] = t[k];
            }
            for (int z = 0; z < s.length(); ++z) {
                if (s[z] == '?') s[z] = 'a';
            }
            break;
        }
    }

    if (f)
        cout << s << endl;
    else
        cout << "UNRESTORABLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[200010];
int n;
vector<ll> acc;

ll calc(ll s, ll t, ll left, ll right){
    ll b = s;
    ll c = left - s;
    ll d = t - left;
    ll e = acc[n] - t;
    ll mn = min({b, c, d, e});
    ll mx = max({b, c, d, e});
    return mx - mn;
}


int main(){
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n+1) acc.push_back(0);
    rep(i, n) acc[i+1] += acc[i] + a[i];
    ll ans = LINF;

    for(int i = 2; i < n-1; i++){
        ll left = acc[i];
        ll right = acc[n] - acc[i];
        auto itr1 = lower_bound(acc.begin(), acc.end(), left/2);
        auto itr2 = lower_bound(acc.begin(), acc.end(), left+right/2);
        ans = min(ans, calc(*itr1, *itr2, left, right));
        ans = min(ans, calc(*prev(itr1), *itr2, left, right));
        ans = min(ans, calc(*itr1, *prev(itr2), left, right));
        ans = min(ans, calc(*prev(itr1), *prev(itr2), left, right));
    }

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


Measured memory_bytes: 6828
A, B, C, D, E, F = map(int, input().split())
water = [(A * i + B * j) * 100 for i in range(11) for j in range(11)][1:]
sugar = [C * i + D * j for i in range(101) for j in range(101)]

ans = [100, -1]
for w in water:
    for s in sugar:
        if w + s <= F and s <= E * w // 100:
            if s / (w + s) > ans[1] / ans[0]:
                ans = [w + s, s]
            
print(*ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        int cnt = 0;
        for(int i=0; i<n; i++) {
            if(i % 2 == 0) {
                if(a[i] % 2 != 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 35688
N = int(input())
A = list(map(int, input().split()))

dic = {}
for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for n in range(1,N+1):
    if n in dic:
        print(dic[n])
    else:
        print(0)



Measured memory_bytes: 33348
n = int(input())

arr = []

for i in range(2):
	arr += [list(map(int,input().split()))]

ans = 0

for j in range(n):
	tmp = 0
	tmp += sum(arr[0][0:j+1])
	tmp += sum(arr[1][j:])
	ans = max(ans,tmp)

print(ans)
	
	

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e4;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int n;
signed main()
{
	Very_fast;
	cin>>n;
	ll x,y;
	for(int i=-2000;i<=2000;i++)
	{
		x=(ll)i*i*i*i*i;
		for(int j=-2000;j<=2000;j++)
		{
			y=(ll)j*j*j*j*j;
//			if(i==-2000&&j==2000)cout<<x<<" "<<y<<"\n";
			if(x-y==n)
			{
				cout<<i<<" "<<j<<"\n";
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3660
from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので
b_acc = [0] + list(accumulate(b))  # 今度は[0]が必要です

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        break

    # 最初は 0 <= x < m + 1 の範囲で、この範囲を狭めていきます
    ok = 0
    ng = m + 1   
    # ng = ok + 1のとき、ok <= x < ng は ok <= x < ok + 1で、x = okに確定します
    while abs(ng - ok) > 1:
        mid = (ok + ng) // 2
        # bをmid冊読めるか？
        if b_acc[mid] <= rem:
        # 読めるならok
            ok = mid
        else:
        # 読めないならng
            ng = mid

    bn = ok
    ans = max(ans, an + bn)

print(ans)

Measured memory_bytes: 49180
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque



def main():
    num, k = map(int, input().split())
    data = list(map(int, input().split()))

    a_list = [0 for i in range(((num + 1) * num) // 2)]
    ind = 0
    for i in range(num):
        for j in range(i, num):
            if j == i:
                a_list[ind] = data[j]
            else:
                a_list[ind] = a_list[ind - 1] + data[j]
            ind += 1

    ans = 0
    now_x = 2 ** 40

    for i in range(41):
        kari = ans + now_x
        count = 0
        for i in range(len(a_list)):
            if a_list[i] & kari == kari:
                count += 1

        if count >= k:
            ans = kari
        now_x //= 2

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 76396
/*

         o###########oo
      o##"          ""##o
    o#"                "##
  o#"                    "#o
 #"  ##              ##   "##
#"                          ##
#  ###################       #
#                            #
#                            #
#                            #
#                            #
#                            #
#                            #
#o                           #
"#o                         ##
 "#o                       ##
  "#o                    o#"
   "#o                  ##
     "#o              o#"
       "#ooo      ooo#######oo
        ###############   "######o
     o###""        "###o      # ###
   o###o     oooo    ###    oo####"
 o###**#     #**#   ############"
 ""##""""""""""###########    #
    # oooooooo#"#**     ##    #
    # #       # # **    ##    #
    #o#       #o#  *****###ooo#
                        ##
                        ##   o###o
                        ## o##***##
               o########## #***#**##o
             o##"   ""###  #***##***#
 o#######o  ###   oo####   ##**####*#
o##"  ""#############""     ##****###
##"         ##              ##*##*###
##          ###              ##### ##
##           ###              # ##  #
##            ##                 #
##             ##
##             ###
##              ###oo
###              ""###
 ###
  ###
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

typedef vector<vector<ll> > matrix;

matrix mul(matrix a, matrix b){
    matrix c;
    c.resize(a.size());
    for (int i = 0; i < c.size(); i++)
        c[i].resize(b[0].size(), 0);
    for (int i = 0; i < c.size(); i++)
        for (int j = 0; j < c[i].size(); j++)
            for (int k = 0; k < b.size(); k++)
                c[i][j] = (c[i][j] + a[i][k] * b[k][j]);
    return c;
}

matrix def;

matrix bpow(matrix a, ll st){
    if (st == 0)
        return def;
    if (st == 1)
        return a;
    matrix b = bpow(a, st >> 1);
    b = mul(b, b);
    if (st & 1)
        b = mul(a, b);
    return b;
}

ll AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MOD = 1e9 + 993;

ll myrand(){
    ll ZR = (XR * AR + YR * BR + CR) % MOD;
    XR = YR;
    YR = ZR;
    return ZR;
}

ll sqr(ll x){
    return x * x;
}

const ll llinf = 2e18;

const ld EPS = 1e-9;

const ld PI = atan2(0, -1);

const int maxn = 2e5 + 100, inf = 1e9 + 100, mod = 1e9 + 993;

string s;

int a[26];

int main()
{
    #ifdef ONPC
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #else
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++)
        a[s[i] - 'a']++;
    ll answer = 1 + n * (ll)(n - 1) / 2;
    for (int i = 0; i < 26; i++)
        answer -= a[i] * (ll)(a[i] - 1) / 2;
    cout << answer;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b > a * c)
    {
        cout << c << endl;
    }
    else
    {
        cout << b / a << endl;
    }
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
const int mx=200005;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    V<ll> a(n);
    cinf(n,a);
    ll l=0,r=1000000000;
    while(r-l>1){
        ll m=(r+l)/2;
        bool ok=1;
        ll kk=k;
        rep(i,n){
            ll x=(a[i]-1)/m;
            kk-=x;
            if(kk<0){
                ok=0;
                break;
            }
            
        }
        if(ok)r=m;
        else l=m;
    }
    cout<<r<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 4668
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int main(){

    int N,K;
    cin>>N>>K;

    cout<<N-K+1<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void sortVector(vector<T> &v, bool lesser = true) { lesser ? sort(all(v)) : sort(all(v), greater<T>()); }
bool isPrime(int n){
    if(n < 2) return false; else if(n == 2) return true; else if(n%2 == 0) return false;
    double sqrtNum = sqrt(n); for(int i = 3;i <= sqrtNum; i += 2) if(n%i == 0) return false;
    return true; }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<ll> L(n);
    rep(i, n) cin >> L[i];

    sortVector(L);
    int ans = 0;

    for(int i = 0;   i < n-2; ++i)
    for(int j = i+1; j < n-1; ++j)
    for(int k = j+1; k < n;   ++k){
        if( L[i] + L[j] > L[k] && 
            L[i] != L[j] && L[j] != L[k] && L[k]!= L[i])
            ++ans;
    }

    cout << ans << endl;

return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> A(N-1);
  vector<int> B(N);
  
  for(int i = 0; i < N-1;i++) {
    cin >> A.at(i);
  }
  
  for(int i = 0; i < N-1; i++) {
    B.at(A.at(i)-1)++;
  }
  
  for(int i = 0; i < N; i++) {
    cout << B.at(i) <<endl;
  }
  
  return 0;
}


Measured memory_bytes: 4776
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9+7;

int main(){
  ll n,m,sum=0;cin>>n>>m;
  vll a(m);
  rep(i,0,m){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum>n){cout<<-1<<endl;}
  else{cout<<n-sum<<endl;}
}

Measured memory_bytes: 3704
mod=10**9+7
N=int(input())
A = list(map(int,input().split()))
B=[0]*N
for i in range(N):
 B[i]=str(bin(A[i])).rjust(62,"0")
f=0
for i in range(2,62):
 d=0
 e=0
 for j in range(N):
  c=B[j]
  if c[i]=="1":
   d+=1
  else:
   e+=1
 f+=d*e*pow(2,61-i,mod)
 f%=mod
print(f)


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
    int n , a , b;
    scanf("%d %d %d" ,&n ,&a ,&b) ;

    if((b-a)&1) printf("Borys\n") ;
    else printf("Alice\n") ;
    return 0 ;
}

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

typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<Int, P> T;

vector<T> vec;
Int suml[108000], sumr[108000];
Int a, b, c;
Int x, y, z;
Int res = -(1LL << 60);
int main(){
  cin >> x >> y >> z;
  Int n = x + y + z;
  Int sumc = 0;
  for(Int i = 0;i < n;i++){
    cin >> a >> b >> c;
    sumc += c;
    a -= c;
    b -= c;
    vec.push_back(T(b-a,P(a, b)));
  }
  sort(vec.begin(), vec.end());

  
  multiset<Int> hoge;
  Int sum = 0;
  for(Int i = 0;i < n;i++){
    Int a = vec[i].second.first;
    hoge.insert(a);
    sum += a;
    if(hoge.size() > x){
      sum -= *hoge.begin();
      hoge.erase(hoge.begin());
    }
    suml[i] = sum;
  }
  sum = 0;
  hoge.clear();
  for(Int i = n-1;i >= 0;i--){
    Int b = vec[i].second.second;
    hoge.insert(b);
    sum += b;
    if(hoge.size() > y){
      sum -= *hoge.begin();
      hoge.erase(hoge.begin());
    }
    sumr[i] = sum;
  }

  for(Int i = x-1;i < x + z;i++){
    res = max(res, suml[i] + sumr[i+1]);
  }

  cout << res + sumc << endl;
  return 0;
  
}

Measured memory_bytes: 8560
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 2; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  double x;
  cin >> x;

  double save = 100; int year = 0;
  while (save < x)
  {
      /* code */
      save = floor(save*1.01);
      year++;
  }
  
  cout << setprecision(10) << year << endl;
  return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n; cin >> n;
    int ans = 0;
    for(int q = 1; q * q <= 4*n; q++){
        if(n % q != 0) continue;
        int m = n / q - 1;
        if(m <= q) continue;
        ans += m;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
heart_taka, power_taka, heart_aoki, power_aoki = map(int, input().split())

aliveTaka = True
aliveAoki = True
while (aliveTaka) and (aliveAoki):
    heart_aoki -= power_taka
    heart_taka -= power_aoki
    if heart_aoki <= 0:
        aliveAoki = False
    if heart_taka <= 0:
        aliveTaka = False

if aliveAoki == False:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long int n,k,ans=0;
int px(int a,int b)
{
    return a>b;
}
int main()
{
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,px);
    for(int i=0;i<k;i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

#define i64 long long int
#define ran 202202

int n;
int s[ran][2];

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		int x;
		scanf("%d", &x);
		
		if(i>x) s[i-x][0]++;
		if(i+x<=n) s[i+x][1]++;
	}
	
	i64 ans = 0;
	for(int i=1;i<=n;i++)
		ans += 1LL*s[i][0]*s[i][1];
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 5340
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    std::string s; std::cin >> s;
    int k; std::cin >> k;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a') continue;
        int t = 'z' - s[i] + 1;
        if (t <= k) {
            s[i] = 'a';
            k -= t;
        }
    }
    s.back() = ((int)s.back() - 'a' + k) % 26 + 'a';
    std::cout << s << std::endl;
    return 0;
}

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

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

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>
#define F first
#define S second
#define MP make_pair
#define INF int(1e9)
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;


inline int in() {
  int temp;
  scanf("%ld", &temp);
  return temp;
}

int n, k, dp[10][2001];
vector<int> books[10];
int main()
{
  n = in(); k = in();
  for (int i = 0; i < n; i++) {
    int a = in();
    books[in() - 1].push_back(a);
  }
  for (int i = 0; i < 10; i++){
    sort(books[i].begin(), books[i].end(), greater<int>());
  }
  for (int i = 0; i < 10; i++)
  {
    if(books[i].empty()) continue;
    for (int j = 0; j < books[i].size() - 1; j++)
    {
      books[i][j + 1] += books[i][j] + 2 * (j + 1);
    }
  }
  for (int i = 0; i < books[0].size(); i++)
  {
    dp[0][i + 1] = books[0][i];
  }
  for (int i = 1; i < 10; i++)
  {
    for (int j = 0; j < books[i].size(); j++)
    {
      for (int l = 0; l + j + 1 <= k; l++) {
        if (!dp[i - 1][l] && l) break;
        dp[i][l + j + 1] = max(max(dp[i][l + j + 1], dp[i - 1][l + j + 1]), dp[i - 1][l] + books[i][j]);
      }
    }
    if(books[i].empty())
    {
      for(int j = 0; j <= k; j++)
      {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }
  cout << dp[9][k] << endl;
}

Measured memory_bytes: 3284
n=gets.to_i
c=gets.split.map &:to_i
a=[0]*n
gets.to_i.times{|i|
	t,x,d=gets.split.map &:to_i
	t=-1 if t==2
	x-=1
	a[x]+=t*d
	if a[x]<0||c[x]<a[x]
		p x+1
		exit
	end
}
p 0


Measured memory_bytes: 8908
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  string s=to_string(n);
  int m=s.length();
  int c=0;
  rep(i,0,m) c+= (s[i]-'0');
  if(n%c==0) cout<<"Yes\n";
  else cout<<"No\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    bool ans=true;
    reverse(s.begin(),s.end());
    rep(i,n){
        string ss=s.substr(i,7);
        bool ok=false;
        if(ss=="remaerd"){i+=6; ok=true;}
        ss=s.substr(i,6);
        if(ss=="resare"){i+=5; ok=true;}
        ss=s.substr(i,5);
        if(ss=="maerd"||ss=="esare"){i+=4; ok=true;}
        if(ok==false)ans=false;
    }
    cout<<(ans==true?"YES":"NO")<<endl;
}

Measured memory_bytes: 512