akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int n, m;
int s[10], c[10];
bool judge = true;

int main() {

	cin >> n >> m;

	rep(i, m) cin >> s[i] >> c[i];

	if (n == 1) {
		rep(i, 10) {
			bool ans = true;
			rep(j, m) {
				if (c[j] != i) {
					ans = false;
				}
			}
			if (ans) {
				cout << i << endl;
				judge = false;
				break;
			}
		}
	}
	else if (n == 2) {
		int tmp[2];
		REP(i, 10, 100) {
			int x = i;
			for (int j = 1;j >= 0; j--){
				tmp[j] = x % 10;
				x /= 10;
			}
			bool ans = true;
			rep(j, m) {
				if (c[j] != tmp[s[j] - 1]) {
					ans = false;
				}
			}
			if (ans) {
				cout << i << endl;
				judge = false;
				break;
			}
		}
	}
	else {
		int tmp[3];
		REP(i, 100, 1000) {
			int x = i;
			for (int j = 2; j >= 0; j--) {
				tmp[j] = x % 10;
				x /= 10;
			}
			bool ans = true;
			rep(j, m) {
				if (c[j] != tmp[s[j] - 1]) {
					ans = false;
				}
			}
			if (ans) {
				cout << i << endl;
				judge = false;
				break;
			}
		}
	}

	if (judge)cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define ll long long
using namespace std;
int main(){
ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=max(b*d,a*c);
 
  ans=max(ans,a*d);
  ans=max(ans,b*c);
  cout<<ans;
return 0;
}

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

using namespace std;

typedef long long ll;

const ll maxn=100010;

vector<pair<ll,int> >v;

int n,a,b;

ll dis;
struct node
{
	ll x,y;
	int id;
}point[maxn];

bool cmp(node x,node y)
{
	if(x.x!=y.x) return x.x<y.x;
	return x.y<y.y;
}

int fa[maxn];
ll ans[maxn];
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
ll num[maxn];

void work(int k)
{
    vector<pair<ll,int> >::iterator l,it;
    v.clear();
    int pos=1;
	bool flag=false;
    for (int i=1;i<=n;i++)
    {
        if (point[i].x!=point[i-1].x)
		{
			v.clear();
			flag=true;
		} 
        while(point[i].x-point[pos].x>dis&&pos<=n) pos++;
        while(point[i].x-point[pos].x==dis&&pos<=n)
		{
			v.push_back(make_pair(point[pos].y,point[pos].id));
			pos++;
		} 
//        cout<<pos<<endl;
        it=lower_bound(v.begin(),v.end(),make_pair(point[i].y-dis+k,0));//这里的k不能判重吗 
        if (flag)
		{
		    flag=false;
			l=v.begin();
		}
        l=max(l,it);
        if (it==v.end()||it->first >point[i].y+dis-k) continue;
        for(;l!=v.end()&&l->first<=point[i].y+dis-k;l++) 
        {
            int fx=find(l->second);
			int fy=find(point[i].id);
            if (fx!=fy) fa[fx]=fy;
        }
        num[point[i].id]+=(l-it);
//        cout<<p[i].id<<" "<<cnt[p[i].id]<<endl;
        if (l!=it) l--;
    }
}
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&point[i].x,&point[i].y);
	} 
    dis=abs(point[a].x-point[b].x)+abs(point[a].y-point[b].y);
    for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		point[i].id=i;
		ll tmpx=point[i].x;
		ll tmpy=point[i].y;
		point[i].x=tmpx-tmpy;
		point[i].y=tmpx+tmpy;
	} 
    sort(point+1,point+n+1,cmp);
    work(0);
    for (int i=1;i<=n;i++) swap(point[i].x,point[i].y);
    sort(point+1,point+n+1,cmp);
    work(1);
    for (int i=1;i<=n;i++) ans[find(i)]+=num[i];
    printf("%lld",ans[find(a)]);
}

//last time
//I'm so South

Measured memory_bytes: 5364
Tatemono = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

n = int(input())
#b棟(4)f階(3)のr番目の部屋(10)にv人が追加

for _ in range(n):
    b,f,r,v=map(int,input().split())
    Tatemono[b-1][f-1][r-1] = v+Tatemono[b-1][f-1][r-1]
    


for building_no, no in zip(Tatemono, range(len(Tatemono))):
    for floor_no in building_no:
        for room_no in floor_no:
            print(" ",end ="")
            print(room_no,end="")

        print("")

    if len(Tatemono) == no+1:
        break

    print("####################")


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

using lint = long long int;

int main(){
    lint A,B,C;
    lint K;
    lint ans;

    cin >> A >> B >> C >> K;
    if(K%2){
        ans = B - A;
    }
    else{
        ans = A - B;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def task():
    i=int(input())
    ac=0
    tle=0
    wa=0
    re=0
    while(i):
        i-=1
        s=input()
        if(s=="AC"):
            ac+=1
        elif(s=="WA"):
            wa+=1
        elif(s=="TLE"):
            tle+=1
        elif(s=="RE"):
            re+=1
    print("AC x",ac)
    print("WA x",wa)
    print("TLE x",tle)
    print("RE x",re)
def default():
    t=1
    while(t):
        t-=1
        task()
if(__name__=="__main__"):
    default()


Measured memory_bytes: 69948
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 2019
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
inline int add(int x, int y, int mod) {
   if (y >= mod) y %= mod;
   if (x >= mod) x %= mod;
   x  += y;
   return (x >= mod ? x - mod : x);
} 
inline int mul(int x, int y, int mod) {
  if (x >= mod) x %= mod;
  if (y >= mod) y %= mod;
  return (x*y) % mod;
}
inline int sub(int x, int y, int mod) {
  x -= y;
  if (x + mod <= 0) {
	x %= mod;
  }
  return (x < 0 ? x+mod : x);
}
int PowerMod(int x, int n, int mod) {
  int res = 1;
  for (;n > 0;) {
	if (n & 1) {
	  res 	= mul(res, x, mod);
	}
	x = mul(x, x, mod);
	n /= 2;
  }
  return res;
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin >> s;
		int n = s.size();
		map<int,int>mp;
		mp[0]=1;
		int ans =0 ;
		int last =0 ,cur =0 ;
		for(int i =n-1;i>=0;i--){
			int d= s[i]-'0';
			last = mul(d,PowerMod(10,n-1-i,MOD),MOD);
			cur=add(cur,last,MOD);
			// trace(cur);
			ans+=mp[cur];
			mp[cur]++;
		}
		cout << ans <<'\n';
	
	
	}
	return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL ksc(LL a,LL n,LL mod){
	LL ret=0;
	for(;n;n>>=1){
		if(n&1){ret+=a;if(ret>=mod)ret-=mod;}
    	a<<=1;if(a>=mod)a-=mod;
	}
	return ret;	
}
LL ksm(LL a,LL n,LL mod){
	LL ret = 1;
	for(;n;n>>=1){ 
		if(n&1)ret=ksc(ret,a,mod);
        a=ksc(a,a,mod);
	}
	return ret;
}
int millerRabin(LL n){
	if(n<2 || (n!=2 && !(n&1)))return 0;
	LL d=n-1;for(;!(d&1);d>>=1);
	for(int i=0;i<20;++i){
		LL a=rand()%(n-1)+1;
		LL t=d,m=ksm(a,d,n);
		for(;t!=n-1 && m!=1 && m!=n-1;m=ksc(m,m,n),t<<=1);
		if(m!=n-1 && !(t&1)) return 0;
	}
    return 1;
}
LL cnt,fact[100];
LL gcd(LL a,LL b){return !b?a:gcd(b,a%b);}
LL pollardRho(LL n, int a){
	LL x=rand()%n,y=x,d=1,k=0,i=1;
	while(d==1){
		++k;
		x=ksc(x,x,n)+a;if(x>=n)x-=n;
		d=gcd(x>y?x-y:y-x,n);
		if(k==i){y=x;i<<=1;}
	}
	if(d==n)return pollardRho(n,a+1);
	return d;
}
void findfac(LL n){
	if(millerRabin(n)){fact[++cnt]=n;return;}
	LL p=pollardRho(n,rand()%(n-1)+1);
	findfac(p);
	findfac(n/p);
}
LL l,ans;
LL n;
LL a[100],b[100];
int main()
{
	scanf("%lld",&n);
	if (n==1) {printf("0"); return 0;}
	findfac(n);
	sort(fact+1,fact+1+cnt);
	for (int i=1;i<=cnt;++i)
	{
		if (fact[i]!=fact[i-1])
		{
			++l;
			a[l]=fact[i];
			++b[l];
		}
		else ++b[l];
	}
	for (int i=1;i<=l;++i)
	{
		for (int j=1;j<=100;++j)
		if (b[i]>=j) {++ans; b[i]-=j;}
		else break;
	}
	printf("%lld",ans);
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  char prev = s[0];
  rep(i, s.size()) {
    if (s[i] != prev) {
      ans++;
      prev = s[i];
    }
  }
  ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <unordered_map>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int s = 100 * r + 10 * g + b;
    if (s % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = map(int, readline().split())
    a = list(map(int, readline().split()))
    zero_plus = [0] * 60  # 0を選んだときに増える数
    one_plus = [0] * 60

    for x in a:
        s = format(x, "b")
        s = s[::-1]
        l = len(s)
        for i in range(60):
            if i >= l:
                one_plus[i] += 1
            elif s[i] == "0":
                one_plus[i] += 1
            else:
                zero_plus[i] += 1

    dp = dict()
    dp[True] = [-INF] * 61
    dp[False] = [0] * 61

    k_bin = format(k, "b")
    k_bin_length = k.bit_length()

    for i in range(59, -1, -1):
        cur = 2 ** i
        d = k_bin_length - i - 1
        if d < 0:
            dp[False][i] = dp[False][i + 1] + zero_plus[i] * cur
        else:
            zero = cur * zero_plus[i]
            one = cur * one_plus[i]
            if k_bin[d] == "1":
                dp[True][i] = max(dp[False][i + 1] + zero, dp[True][i + 1] + one, dp[True][i + 1] + zero)
                dp[False][i] = dp[False][i + 1] + one
            else:
                dp[True][i] = max(dp[True][i + 1] + zero, dp[True][i + 1] + one)
                dp[False][i] = dp[False][i + 1] + zero

    print(max(dp[True][0], dp[False][0]))


if __name__ == '__main__':
    main()


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

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

    int odds = 0; 
    int evens = 0; 
    for (int i = 1; i <= n; i++) {
        if (i % 2) odds++; 
        else evens++; 
    }

    cout << odds * evens << endl; 
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N), l(N), r(N);
    rep(0, i, N)
    {
        cin >> a.at(i);
        if (i == 0)
        {
            l.at(i) = a.at(i);
        }
        else
        {
            l.at(i) = gcd(l.at(i - 1), a.at(i));
        }
    }
    for (ll i = N - 1; i >= 0; i--)
    {
        if (i == N - 1)
        {
            r.at(i) = a.at(i);
        }
        else
        {
            r.at(i) = gcd(r.at(i + 1), a.at(i));
        }
    }

    ll ans = 1;
    rep(1, i, N - 1)
    {
        ans = max(ans, gcd(l.at(i - 1), r.at(i + 1)));
    }
    ans = max(ans, l.at(N - 2));
    ans = max(ans, r.at(1));
    cout << ans << endl;
}

Measured memory_bytes: 5616
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int count = 0;
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    while (true) {
      boolean flag = false;
      for (int i = 0; i < n; i++) {
        if (a[i] % 2 != 0) {
          flag = true;
          break;
        }
      }
      if (flag) break;
      for (int i = 0; i < n; i++) {
        a[i] = a[i] / 2;
      }
      count++;
    }
    System.out.println(count);
  }
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;


struct DSU {
  vector<int> par, sz;
  DSU(int n):par(n),sz(n,1) { iota(par.begin(), par.end(), 0); }
  int find(int v) { return par[v]==v?v:(par[v]=find(par[v])); }
  void unite(int u, int v){
    u=find(u), v=find(v);
    if(u!=v){
      if(sz[u]<sz[v]) swap(u, v);
      par[v]=u;
      sz[u]+=sz[v];
    }
  }
  int size(int v) { return sz[par[v]]; }
  bool same_set(int u, int v) { return find(u)==find(v); }
};


int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  int m;  cin >> m;
  DSU dsu(n);
  for (int i = 0; i < m; ++i){
    int a, b; cin >> a >> b;  a--, b--;
    dsu.unite(a, b);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i){
    ans = max(ans, dsu.size(i));
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n,te;
    cin >> n;
    vector<int> a(n);
    set<int> s;
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        s.insert(a.at(i));
    }

    int ans=s.size();
    if(s.size()%2==0){
        ans--;
    }

    cout << ans << endl;

}

Measured memory_bytes: 5376
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    if(n==1) cout << a[0];
    else if(n%2==0){
        for(int i=n/2; i>0; i--){
            cout << a[i*2-1] << ' ';
        }
        for(int i=0; i<n/2-1; i++){
            cout << a[i*2] << ' ';
        }
        cout << a[n-2];
    }else{
        for(int i=(n+1)/2; i>0; i--){
            cout << a[i*2-2] << ' ';
        }
        for(int i=0; i<n/2-1; i++){
            cout << a[i*2+1] << ' ';
        }
        cout << a[n-2];
    }
    
    return 0;
}

Measured memory_bytes: 2944
// Cease to struggle and you cease to live
// B.cpp
// Created by Nickwzk on 2019-02-16 20:18
#include <bits/stdc++.h>
using namespace std;

inline int read() {
	int x = 0, ch = getchar(); bool fg = 1;
	while(ch < '0' || ch > '9') { if(ch == '-') fg = 0; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return fg ? x : -x;
}
int a[100103];
int main() {
	int n = read(), m = read();
	for(int i = 1; i <= n; i++) {
		int u = read();
		for(int j = 1; j <= u; j++) {
			a[read()]++;
		}
	}
	int ans = 0;
	for(int i = 1; i <= m; i++) if(a[i] == n) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key) {
    return key % M;
}

int h2(int key) {
    return 1 + (key % (M - 1));
}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
}

int main(void) {
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);

        if (com[0] == 'i') insert(str);
        else if (find(str)) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 15348
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  auto dp = make_v(n+1, 2, 0LL);
  dp[0][0] = 0; dp[0][1] = -1e15;
  REP(i, n){
    dp[i+1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
    dp[i+1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
  }

  cout << dp[n][0] << endl;

  return 0;
}


Measured memory_bytes: 6144
N,M,C = map(int, input().split())
b = list(map(int, input().split()))

a_s = []
for i in range(N):
  a_s.append(list(map(int, input().split())))

count = 0
for a in a_s:
  total = 0
  for i in range(len(a)):
    total += a[i]*b[i]
  if total + C > 0:
    count += 1
  
print(count)

Measured memory_bytes: 3064
S=input()
X=['dream'[::-1], 'dreamer'[::-1], 'erase'[::-1], 'eraser'[::-1]]
S=S[::-1]
while 1:
    S2=S
    for x in X:
        if x == S[:len(x)]:
            S = S[len(x):]
    if S == '':
        print('YES')
        break
    if S2==S:
        print('NO')
        break

Measured memory_bytes: 3336
/*                                                                                 
	Author :- Gaurang_Kothiya
	
	Quote :- " Practice makes a man perfect. "		
*/  
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
const ll inf= 1e9;
const ll inf64= 1e18;
const ll MOD= 1e9 +7;



void Solve()
{
	ll n,m,k;
	cin>>n>>m>>k;
	
	ll ans=0;
	v(ll) a(n),b(m);
	fe(x,a) cin>>x;
	fe(x,b) cin>>x;
	
	f(i,1,n-1) a[i] += a[i-1];
	f(i,1,m-1) b[i] += b[i-1];
	
	f(i,0,n-1)
	{
		if(a[i]<=k)
		{
			ll res= k- a[i];
			auto itr= upper_bound(all(b),res);
			ans=max(ans,(ll)(itr-b.B)+i+1);
		}
		else break;
	}
	
	f(i,0,m-1)
	{
		if(b[i]<=k)
		{
			ll res= k- b[i];
			auto itr= upper_bound(all(a),res);
			ans=max(ans, (ll)(itr-a.B)+i+1);
		}
		else break;
	}
	
	cout<<ans;	
}
 
signed main() 
{
	speed		
	
	int q=1;
	//	cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 6316
import * as fs from "fs";

const input = fs.readFileSync("/dev/stdin", "utf8").split(/\n/);
const N: number = +input[0];
const numbers = input[1].split(" ");
let inputNum: number[] = [];
for (let i = 0; i < numbers.length; i++) {
  inputNum[i] = +numbers[i];
}
let sum = 0;
let sum2 = 0;
for (let i = 0; i < N; i++) {
  sum += inputNum[i];
  sum2 += inputNum[i] * inputNum[i];
}
const ans = (sum * sum - sum2) / 2;
console.log(ans);

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll n;
	cin>>n;
	ll a[n];
	scan(a, 0, n);
	sort(a, a+n);
	ll ans = 0;
	cout<<a[n/2] - a[n/2 - 1]<<endl;

}

Measured memory_bytes: 4408
package main

import (
	"fmt"
)

func abs(n int64) int64 {
	if n >= 0 {
		return n
	} else {
		return -n
	}
}

func main() {
	var x, k, d int64
	fmt.Scan(&x)
	fmt.Scan(&k)
	fmt.Scan(&d)
	x = abs(x)
	ans := x

	if x > abs(k*d) {
		ans = x - abs(k*d)
	} else {
		if (k-x/d)%2 == 0 {
			ans = x % d
		} else {
			temp := x % d
			if abs(temp+d) < abs(temp-d) {
				ans = abs(temp + d)
			} else {
				ans = abs(temp - d)
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1772
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int diff(int a, int b, int c) {
  vector<int> t;
  t.push_back(a);
  t.push_back(b);
  t.push_back(c);

  std::sort(t.begin(), t.end());

  return (t[1] - t[0]) != (t[2] - t[1]);
}

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

  vector<int> r;
  vector<int> g;
  std::unordered_set<int> b;
  rep(i,S.size()) {
    if (S[i] == 'R') r.push_back(i);
    else if (S[i] == 'G') g.push_back(i);
    else b.insert(i);
  }

  long long sum = r.size() * g.size() * b.size();
  rep(i,r.size()) {
    rep(j,g.size()) {
      // RGB, BRG
      int m = std::min(r[i], g[j]);
      int d = abs(r[i] - g[j]);
      int mx = std::max(r[i], g[j]);
      if (b.find(m - d) != b.end()) --sum;
      if (b.find(mx + d) != b.end()) --sum;

      // RBG, GBR
      if (d % 2 == 0) {
        if (b.find((r[i] + g[j]) / 2) != b.end()) --sum;
      }
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int N, A[3][3], b[10];
bool appear[3][3];
int main()
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
            cin >> A[i][j];
    }
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> b[i];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            appear[i][j] = false;
            for (int k = 0; k < N; k++)
            {
                if (A[i][j] == b[k])
                    appear[i][j] = true;
            }
        }
    }
    string ANS = "No";
    for (int i = 0; i < 3; i++)
    {
        if (appear[i][0] and appear[i][1] and appear[i][2])
            ANS = "Yes";
    }
    for (int i = 0; i < 3; i++)
    {
        if (appear[0][i] and appear[1][i] and appear[2][i])
            ANS = "Yes";
    }

    if (appear[0][0] and appear[1][1] and appear[2][2])
        ANS = "Yes";
    if (appear[0][2] and appear[1][1] and appear[2][0])
        ANS = "Yes";
    cout << ANS << endl;
    return 0;
}

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

int main()
{
    long long w,h,x,y;
    cin >> w >> h >> x >> y;
    
    float surface = w*h/2.0;
    if( 2*x == w && 2*y == h ){
        cout << surface << " " << 1 << endl;
        return 0;
    } 
    else{
        cout << surface << " " << 0 << endl;
        return 0;
    }
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
if A == sorted(A) and len(A) == len(set(A)):
  print(1)
  exit(0)

def check(X):
  idx = [0]
  ltr = [0]
  for a in A:
    if idx[-1] < a:
      idx.append(a)
      ltr.append(0)
    else:
      while True:
        while idx[-1] > a:
          idx.pop()
          ltr.pop()
        if idx[-1] != a:
          idx.append(a)
          ltr.append(0)
        if idx[-1] == 0:
          return False
        ltr[-1] += 1
        if ltr[-1] < X:
          break
        a = idx[-1] - 1
        idx.pop()
        ltr.pop()
  return ltr[0] == 0

t = [1, N]
while t[1] - t[0] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(t[1])


Measured memory_bytes: 114480
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int X;
	cin>>X;
	int sum = 0;
	int k = 1;
	while(sum < X) {
		sum += k;
		if(sum >= X) cout<<k<<endl;
		++k;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<LL> A(N);
    REP(i, N)cin >> A[i];

    LL res = 0;
    while(true){
        bool end = true;
        vector<LL> add(N);
        REP(i, N){
            LL a = A[i] / N;
            if(a>0)end = false;
            res += a;
            REP(j, N){
                if(i==j)continue;
                add[j] += a;
            }
            A[i] = A[i] % N;
        }
        REP(i, N)A[i] += add[i];
        if(end)break;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())

ans_all_black = 0   #全て黒くする方の解
ans_all_white = 0   #全て白くする方の解
ans_right_black = 100 #右をすべて黒くする解

#  #:黒
#  .:白
#黒の右隣に白が来ないようにしたい
#∴すべて黒
#　すべて白
#　白連続の後に黒連続
#のどれかが完成形

#一度白の全数を調べる
all_white = 0
left_white=[]

for i in range(N):
  if S[i]==".":
    all_white  = all_white + 1
    if i==0:
      left_white.append(1) 
    else:
      left_white.append(left_white[i-1]+1) 
  else:
    if i==0:
      left_white.append(0) 
    else:
      left_white.append(left_white[i-1])
    
ans_all_black = all_white     #全数黒にするには白をすべてひっくり返す
ans_all_white = N - all_white #全数白にするには黒をすべてひっくり返す＝すべての中で白出ないものをひっくり返す

#print("all_black:",ans_all_black)
#print("all_white:",ans_all_white)

ans_right_black = N

#右側全黒
for i in range(N):
  #print(i,":",i + 1 - left_white[i],":",ans_all_black - left_white[i])
  #i+1文字目において:左を全部白にするのに必要な塗り数:右を全部黒にするのに必要な塗り数
  ans_right_black = min(i + 1 - left_white[i] + ans_all_black - left_white[i] , ans_right_black)
  
ans = min(ans_all_white,ans_all_black,ans_right_black)
print(ans)

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

int main(){
int A,B;
   cin>>A>>B;
  
  
  int count=0;
  for(int i=A; i<=B; i++){
   int a=i/10000, b=i%10, c=i/1000%10, d=i/10%10;
     if(a==b && c==d){count++;}
  }
  
  cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int N = 300010;
#define x first
#define y second
#define pb push_back
#define mp make_pair

int n, u, v, lng, num, md;
vector<int> g[N];
pii fn;

int dfs(int u, int p) {
	multiset<int> st;
	int nt = 0;
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i];
		if (v == p)continue;
		++nt;
		st.insert(1 + dfs(v, u));
	}
	num += nt/2;
	vector<int> go;
	while (st.size()) {
		int bk = (*--st.end());
		st.erase(st.find(bk));
		auto it = st.upper_bound(md - bk);
		if (it != st.begin())
			it--;
		if (st.size() && *it + bk <= md) {
			lng = max(lng, *it + bk);
			st.erase(it);
		} else {
			go.pb(bk);
			lng = max(lng, bk);
		}
	}
	sort(go.begin(),go.end());
	if(p == -1 && nt%2 == 0 && go.size())lng = oo;
	if(nt%2 == 0 && go.size() > 2)lng = oo;
	if(nt%2 == 1 && go.size() > 1)lng = oo;
	if(!go.size())return 0;
	return go[0];
}

bool check() {
	lng = num = 0;
	int res = dfs(1, -1);
	lng = max(lng, res);
	num += (res>0);
	return lng <= md;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i) {
		scanf("%d%d", &u, &v);
		g[u].pb(v);
		g[v].pb(u);
	}
	int lo = 1 , hi = 300000, best = -1;
	while (lo <= hi) {
		md = (lo + hi) / 2;
		bool ss = check();
		if (ss) {
			fn = mp(num, lng);
			hi = md - 1;
		} else {
			lo = md + 1;
		}
	}
	printf("%d %d\n", fn.x, fn.y);
	return 0;
}


Measured memory_bytes: 25088
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import math


def main():
    mod=10**9+7
    a,b,c=MI()
    
    
    
    if 4*a*b<(c-(a+b))**2:
        f=1
    else:
        f=0
        
    if c<(a+b):
        f=0
        
    if f==1:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 38528
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
using ll = long long;
using namespace std;


int main() {
    string s;
    cin >> s;
    int n = s.length();
    long long dp[100010][4] = {};
    for (int i = n; i >= 0; i--) {
        for (int j = 3; j >= 0; j--) {
            if (i == n) {
                dp[i][j] = (j == 3 ? 1 : 0);
            }
            else {
                dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3 : 1);
                if (j < 3 && (s[i] == '?' || s[i]=="ABC"[j])) {
                    dp[i][j] += dp[i + 1][j + 1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}


Measured memory_bytes: 3584
def main():
    N, M = map(int, input().split())
    X = [j for j in map(int, input().split())]
    if N >= M:
        print(0)
        exit()
    X.sort()
    s = max(X)-min(X)
    d = [X[i+1]-X[i] for i in range(M-1)]
    d.sort()
    if N == 1:
        print(s)
    else:
        print(s-sum(d[-N+1:]))


main()


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n;
vl a,b;
int main() {
    cin>>n;
    a.resize(n+1);
    b.resize(n);
    REP(i,n+1)cin>>a[i];
    REP(i,n)cin>>b[i];

    ll ans = 0;

    ll mon = a[n];
    ll slay = 0;
    FORR(i,0,n){
        //mon += a[i+1];
        slay = b[i];

        //DEBUG(mon);
        //DEBUG(slay);

        ans += min(mon, slay);
       // DEBUG(ans);
        slay = slay-mon;
        slay = max(0ll,slay);
        mon = a[i];
        //DEBUG(mon);
        ans += min(mon,slay);
        //DEBUG(ans);
        mon = mon-slay;
        mon = max(0ll, mon);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	string str;
	cin >> str;
	int ans = 0;
	for(int i=0; i<4; i++){
		if(str.at(i) == '+'){
			ans++;
		}else{
			ans--;
		}
	}
	cout << ans << endl;
}


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

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int N = Integer.parseInt(str);
			str = br.readLine();
			String[] s = str.split(" ",0);
			for(int i = N-1;i>=0;i=i-2) {
				System.out.print(s[i]+" ");
			}
			for(int i = N%2;i<N;i = i+2) {
				System.out.print(s[i]+" ");
			}

		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 81736
n=int(input())
l=list(map(int,input().split()))
ans =[0 for _ in range(n)]
count=0
for i in range(n-1,-1,-1):
    if sum([ans[j]for j in range(i,n,i+1)])%2!=l[i]:
        ans[i]=1
        count +=1

print(count)
[print(i+1,end=" ") for i,x in enumerate(ans) if x==1]

Measured memory_bytes: 8784
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

// https://atcoder.jp/contests/abc154/tasks/abc154_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		for(int i=0;i<N;i++) {
			array[i] = sc.nextInt();
		}
		sc.close();

		// LinkedHashSetオブジェクトを用意
		Set<Integer> linkedHashSet = new LinkedHashSet<Integer>();

		// 配列の要素を順にLinkedHashSetオブジェクトへ追加
		for (int i = 0; i < array.length; i++) {
			linkedHashSet.add(array[i]);
			}

		linkedHashSet.size();

		if(linkedHashSet.size()==array.length) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 72668
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = n/500;

    if(n-(b*500)<=a){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, a, i;
  char s[1000];
  scanf("%d", &n);
  scanf("%s", s);
  a = 0;
  for(i = 0; i < n; i++){
    if(s[i] == 'A') {
      i++;
      if(i < n && s[i] == 'B') {
        i++;
        if(i < n && s[i] == 'C') {
          a++;
        } else {
          i--;
        }
      } else {
        i--;
      }
    }
  }
  printf("%d\n", a);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String []args){
		//????????£????????????
		Scanner sc = new Scanner(System.in);
		//??\???????????????????????£?????????
		String word =sc.nextLine();
		//
		StringBuilder out = new StringBuilder();
		//??£?¨?
		 String w;
		 //
		 for(int i =0; i<word.length();i++){
			 w= word.substring(i,i+1);
			//?????£?????\?????????????°???????????????§???????????????
			 if(w.equals(w.toLowerCase())){
				 w = w.toUpperCase();
			//?????£?????\??????????????§?????????????°????????????????
			}else if(w.equals(w.toUpperCase())){
				w = w.toLowerCase();
			}
			 System.out.append(w);
		 }

		 //??¨???
		 System.out.println(out);
	}
}

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n, c, k;
    cin >> n >> c >> k;
    vector<Int> t(n);
    for (Int i = 0; i < n; i++) {
        cin >> t[i];
    }
    sort(all(t));
    Int res = 0;
    Int pre = t[0];
    Int cnt = 1;
    for (Int i = 1; i < n; i++) {
        if (cnt == c or t[i] - pre > k) {
            res++;
            pre = t[i];
            cnt = 1;
        } else {
            cnt++;
        }
    }
    print(res + 1);
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4008
#include"bits/stdc++.h"
using namespace std;


int main()
{
    int a,n,m,co=0;
    cin >> a >> n >> m;
    int b=log10(m)+1;
    long long c;
    for(int y=0;y<9*b;y++){
        c=1;
        for(int j=0;j<n;j++)
            c*=y+a;
        if(c>m) continue;
        int i=0;
        while(c/10>0){
            i+=c%10;
            c/=10;
        }
        i+=c%10;
        if(y==i&&i!=0){
            co++;
        }
    }
    cout << co << endl;
    return 0;
}



Measured memory_bytes: 3368
#include <stdio.h>

int main(){
  
  int n1, n2, S[1000000], T[1000000];
  int i, j, count = 0;
  int l, m, r;
  
  scanf("%d",&n1);
  for(i = 0;i < n1;i++){
    scanf("%d", &S[i]);
  }
  
  scanf("%d",&n2);
  for(i = 0;i < n2;i++){
    scanf("%d",&T[i]);
  }
  
  for(i = 0;i < n2;i++){
    l = 0;
    r = n1;
    
    while(l < r){
      m = (l + r)/2;
      if(S[m] == T[i]){
	count++;  break;
      }
      else if(T[i] < S[m]){
	r = m;
      }
      else {l = (m + 1);}
    }
  } 
  
  printf("%d\n",count);
  return 0;
  
}

Measured memory_bytes: 4860
let k = [0; 1; 2; 3];;
let h()=Scanf.scanf"%d %d %d %d "(fun a b c d->[a;b;c;d]);;
let rec f()=
  let a=h()in
  let b=h()in
  let g(m,n)s i=
    let z(m,n)x j=
      if x=s then
        if i=j then(m+1,n) else(m,n+1)
      else(m,n)
    in
    List.fold_left2 z(m,n)a k
  in
  let m,n=List.fold_left2 g(0,0)b k in
  f(Printf.printf "%d %d\n"m n);;
try f()with _->()

Measured memory_bytes: 2312
# coding: utf-8

# In[1]:

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))


# In[2]:

import numpy as np


# In[3]:

V = np.array(V)
C = np.array(C)


# In[4]:

bene = V-C
print(np.sum(bene[bene>0]))


# In[ ]:





Measured memory_bytes: 19720
#include <iostream>

using namespace std;
long long int a[200005],sum;
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    long long check=sum/2,c=0,ans=1e18;;
    for(int i=0;i<n;i++){
        c+=a[i];
        ans = min(ans,abs(check-c)+abs(sum-c-check));
    }
    cout<<ans;
}

Measured memory_bytes: 1792
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a == b){
        cout << "Draw" << endl;
    }
    else if(a == 1){
        cout << "Alice" << endl;
    }
    else if(b == 1){
        cout << "Bob" << endl;
    }
    else if(a < b){
        cout << "Bob" << endl;
    }
    else {
        cout << "Alice" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let (n, k): (usize, usize) = parse_line().unwrap();
    let a: Vec<usize> = parse_line().unwrap();
    let mut i: usize = 0;

    while i <= n-1 {
        if i >= k && a[i-k] < a[i] {
            println!("Yes");
        } else if i >= k && a[i-k] >= a[i] {
            println!("No");
        }
        i = i+1;
    }
}


Measured memory_bytes: 5896
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<int> graph[200010];
vector<ll> value(200010);

void dfs(int from, int to){
    for(auto next:graph[to]){
        if(from == next)continue;
        value[next] += value[to];
        dfs(to, next);
    }
}
main(){
    int N,Q;
    cin >> N >> Q;
    rep(i,0,N-1){
        int u,v;
        cin >> u >> v;
        u--,v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    rep(i,0,Q){
        int p,x;
        cin >> p >> x;
        value[p-1] += x;
    }
    dfs(-1, 0);

    rep(i,0,N)cout << value[i] << " ";
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define push_back pb
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int A[100100];
    priority_queue<pair<int,int>> PQ;
    int B[100100],C[100100];
    ll sum = 0;

    REP(i,N){
        cin >> A[i];
        PQ.push(make_pair(A[i],1));
    }
    REP(i,M){
        cin >> B[i] >> C[i];
        PQ.push(make_pair(C[i],B[i]));
    }
    REP(i,N){
        pair<int,int> P = PQ.top();
        PQ.pop();
        sum += P.first;
        if(P.second > 1){
            P.second--;
            PQ.push(P);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii; 
#define mkp make_pair
#define fi first
#define se second
int n,m,P;
vector<pii> g[2503];
int vis[2503];
long long dp[2503];
long long ans[2503];
vector<int>nums;
int main(){
	cin>>n>>m>>P;
	for (int i=0;i<2503;i++) dp[i]=-1e18; 
	for (int i=0;i<m;i++){
		int x,y,c;scanf("%d%d%d",&x,&y,&c);
		g[x].push_back(mkp(y,c-P)); 
	}
	queue <int> qu;
	qu.push(1); 
	while (!qu.empty()){
		int u=qu.front();qu.pop();
		nums.push_back(u);
		for (int i=0;i<g[u].size();i++) if (!vis[g[u][i].fi]){
			vis[g[u][i].fi]=1;
			qu.push(g[u][i].fi); 
		}
	}
	dp[1]=0;
	for (int times=1;times<=5000;times++){
		for (int i=0;i<nums.size();i++){
			int x=nums[i];
			for (int i=0;i<g[x].size();i++)
				dp[g[x][i].fi]=max(dp[g[x][i].fi],dp[x]+g[x][i].se);
		}
	}
	for (int i=1;i<=n;i++) ans[i]=dp[i];
	for (int times=1;times<=5000;times++){
		for (int i=0;i<nums.size();i++){
			int x=nums[i];
			for (int i=0;i<g[x].size();i++)
				dp[g[x][i].fi]=max(dp[g[x][i].fi],dp[x]+g[x][i].se);
		}
	}
	if (ans[n]!=dp[n]) cout<<"-1";
	else cout<<max(0ll,dp[n]);
}

Measured memory_bytes: 512
#include <stdio.h>
int main() {
	int  i, j , n , k , a , b , sum;
	scanf("%d", &i);
	scanf("%d", &j);
	scanf("%d", &n);
	scanf("%d", &k);
	scanf("%d", &a);
	scanf("%d", &b);
	sum = i*1 + j*5 + n*10 + k*50 + a*100 + b*500;
	if (sum >= 1000) {
		printf("1\n");
	}
	else if (sum < 1000) {
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 2596
def get(x):
    if x == ".":
        return "#"
    else:
        return "."


def print_fig(h, w):
    for i in range(h):
        if i % 2 == 0:
            s = "."
        else:
            s = "#"
        for _ in range(w):
            print(get(s), end="")
            s = get(s)
        print("")
    print("")
                


while True:
    w, h = map(int, input().split())
    if (w, h) == (0, 0): break
    print_fig(w, h)


Measured memory_bytes: 7012
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, K;
    while(cin >> N >> K){
        vector<int> A(N), B(N);
        for(int i=0;i<N;i++) cin >> A[i] >> B[i];
        long long res = 0;
        for(int i=0;i<N;i++){
            if((K|A[i]) == K) res += B[i];
        }
        for(int i=0;i<30;i++){
            if(!(K&(1<<i))) continue;
            long long cur = 0;
            int mask = ~((1<<i)-1);
            for(int j=0;j<N;j++){
                if(A[j]&(1<<i)) continue;
                if(((K|A[j])&mask) == (K&mask)) cur += B[j];
            }
            res = max(res, cur);
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 1024