akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define FF first
#define SS second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define inf 1e18
#define mod 1000000007
#define PI 3.1415926535
#define endl "\n"
#define runtime cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

inline int sbt(int x) {return __builtin_popcount(x);}
inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }



int32_t main() {
	fastio
	int n, x, t;
	cin >> n >> x >> t;
	int times = ceil((n + 0.0) / (x + 0.0));

	cout << times*t;



	runtime
	return 0;
}


Measured memory_bytes: 3760
N = int(input())
h = list(map(int, input().split()))
dp = [10000000000]*(N)
dp[0] = 0
for i in range(N-2):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
dp[N-1] = min(dp[N-1], dp[N-2] + abs(h[N-1] - h[N-2]))
print(dp[N-1])


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

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011

#define MAXS 100010
int n;
LL MOD;
VI graf[MAXS];
LL dp[MAXS];
int P[MAXS];

LL odp[MAXS];

void dfs_s(int v){
		
	dp[v]=1;
	
	for(auto x:graf[v]){
		if(x!=P[v]){
			P[x]=v;
			dfs_s(x);
			dp[v]=(dp[v]*dp[x])%MOD;
		}
	}
	
	dp[v]=(dp[v]+1)%MOD;
}


void dfs2(int v){		//smieszne przechodzenie przez wierzcholki z zamienianiem korzenia bo wymuszaja nam modulo
						//i nie mozemy skorzystac z fermata
	
	vector<LL> pref;
	
	LL prf_s=1;
	
	for(auto x:graf[v]){
		prf_s*=dp[x];
		prf_s%=MOD;
		pref.PB(prf_s);
	}
	odp[v]=(prf_s+1)%MOD;
	dp[v]=odp[v];
	
	prf_s=1;
	vector<LL> drzw;	//iloczyn wszystkich innych lisci oprocz tego jednego
	
	FORD(i,SIZE(graf[v])-1,0){
		if(i)
			drzw.PB((pref[i-1]*prf_s)%MOD);
		else
			drzw.PB(prf_s);
		prf_s=(prf_s*dp[graf[v][i]])%MOD;
	
	}
	
	reverse(ALL(drzw));
	
	
//	cout<<v<<":\n";
	REP(i,SIZE(graf[v])){		
	//	cout<<dp[graf[v][i]]<<": "<<drzw[i]<<"\n";
		
		if(graf[v][i]!=P[v]){
			LL cat1=dp[graf[v][i]];
			LL cat2=dp[v];
			dp[v]=drzw[i]+1;
			
			dfs2(graf[v][i]);
			
			dp[graf[v][i]]=cat1;
			dp[v]=cat2;
		}
	}
	
}

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin>>n>>MOD;
	
	REP(i,n-1){
		int t1,t2;
		cin>>t1>>t2;
		graf[t1].PB(t2);
		graf[t2].PB(t1);
	}
	
	P[1]=1;
	dfs_s(1);
	
	dfs2(1);
	FOR(i,1,n)
		cout<<(odp[i]-1+MOD)%MOD<<"\n";
	
	return 0;
	
}


Measured memory_bytes: 24704
use std::io::stdin;

fn main() {
    let mut input1 = String::new();
    let mut input2 = String::new();

    stdin().read_line(&mut input1).unwrap();
    let first_input: Vec<&str> = input1.split_whitespace().collect();
    let hp: u32 = first_input[0].parse().unwrap();
    let skill_num: usize = first_input[1].parse().unwrap();

    stdin().read_line(&mut input2).unwrap();
    let splitted_nums: Vec<&str> = input2.split_whitespace().collect();
    let mut sum = 0;
    let mut i = 0;
    while i < skill_num {
        let tmp: u32 = splitted_nums[i].parse().unwrap();
        sum += tmp;
        i += 1;
    }
    if hp <= sum {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main()
{
  int n = 6, d[ n+1 ];
  for( int i = 1; i <= n; i++ ) {
    cin >> d[i];
  }

  string cmd;
  cin >> cmd;
  for( int i = 0; i <= cmd.size(); i++ ) {

    if( false ) {
      cout << " "  << "," << d[1] << endl;
      cout << d[4] << "," << d[2] << "," << d[3] << "," << d[5] << endl;
      cout << " "  << "," << d[6] << endl;
      cout << endl;
    }

    char c = cmd[i];
    int tmp;

    if( c == 'N' ){
      tmp = d[1]; d[1] = d[2]; d[2] = d[6]; d[6] = d[5]; d[5] = tmp;
    }
    if( c == 'S' ){
      tmp = d[1]; d[1] = d[5]; d[5] = d[6]; d[6] = d[2]; d[2] = tmp;
    }
    if( c == 'E' ){
      tmp = d[1]; d[1] = d[4]; d[4] = d[6]; d[6] = d[3]; d[3] = tmp;
    }
    if( c == 'W' ){
      tmp = d[1]; d[1] = d[3]; d[3] = d[6]; d[6] = d[4]; d[4] = tmp;
    }
  }
  cout << d[1] << endl;

  return 0;
}

Measured memory_bytes: 3168
def main():
    n, *p = map(int, open(0).read().split())
    ans = 0
    i = False
    for p, q in enumerate(p, 1):
        j = p == q
        i = (i or j) and (not i)
        ans += i

    print(ans)


if __name__ == '__main__':
    main()


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

int b[2005];

int main()
{
	int n,x,y;
	cin>>n>>x>>y;
	int k;
	
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++)
		{
			k=min(min(abs(j-i),abs(i-x)+1+abs(j-y)),abs(i-y)+1+abs(j-x));
			b[k]++;
		}
	
	for(int i=1; i<=n-1; i++)
		cout<<b[i]<< endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long x;
  cin >> x;
  
  long long count=0;
  while(x>=500){
    x-=500;
    count+=1000;
  }
  
  while(x>=5){
    x-=5;
    count+=5;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
//4008802802
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define forn(i, a) for(register int i=0; i<a; i++)
#define Forn(i, a) for(register int i=1; i<=a; i++)
#define memINF 127
#define all(x) x.begin(), x.end()
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;
typedef vector<vector<ll> > matrix;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=1e5+5;
const int MAX_LOG=17;

int N, a, res=INT_MAX;
map<int,int>MP1, MP0;
vector<pi> odd, even;

inline int cal(pi a1, pi a2)
{
    if(a1.s==a2.s)
        return N-max(a1.f, a2.f);
    return N-a1.f-a2.f;
}

int main()
{
    N=in();
    MP0.clear();
    MP1.clear();
    Forn(i, N)
    {
        a=in();
        if(i&1)
           MP1[a]++;
        else
           MP0[a]++;
    }
    foreach(it, MP0)
    {
        odd.eb(mp(it->s, it->f));
        sort(odd.rbegin(), odd.rend());
        while(odd.size()>3)
            odd.pop_back();
    }
    foreach(it, MP1)
    {
        even.eb(mp(it->s, it->f));
        sort(even.rbegin(), even.rend());
        while(even.size()>3)
            even.pop_back();
    }
    foreach(it, odd)
        foreach(ii, even)
            res=min(res, cal(*it, *ii));
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vp vector<pair<ll,ll> >
#define se second
#define fi first
#define vi vector<ll>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define fab(i,a,b) for(ll i=a;i<=b;i++)
#define inp(n,a) for(ll i=0;i<n;i++){cin>>a[i];}
#define FASTER std::ios::sync_with_stdio(false)
#define DEBUG(x) cout<<#x<<" = "<<x<<endl
#define strToInt(x,z) istringstream y(x);y>>z  //(string,lleger)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b / __gcd(a,b);
#define mod 1000000007
#define pi 3.14159265
using namespace std;


const long long  MOD =1000000007;

int vis[1000010]={0};
vi graph[100010];
	deque<int> path;
void dfs(int x, int type)
{
	for(auto i: graph[x])
	if(!vis[i])
	{
		vis[i]=1;
		if(type)path.push_front(i);
		else path.push_back(i);
		dfs(i,type);
		return;
	}
}
int main()
{
	FASTER;
	
	int n, m;
	cin >> n >> m;
		int x, y;
	rep(i,m)
	{
	
		cin >> x >> y;
		graph[x].pb(y);
		graph[y].pb(x);
	}


	path.push_back(y);
	path.push_front(x);
	vis[x]=1;
	vis[y]=1;

		int left = path.front();
		int right = path.back();
		dfs(left,1);
		dfs(right,0);
		cout << path.size()<<endl;
	while(!path.empty())
	{
		cout << path.front() <<" ";
		path.pop_front(); 
	}
	
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
#define MOD 1000000007

using namespace std;

int main() {

	int n; cin >> n;

	vector<int> a(100001);
	for (int i = 0; i < n; i++) {
		int num; cin >> num;
		a[num]++;
	}

	int sum = 0;
	for (int i = 1; i < 100000; i++) {
		if (sum < a[i-1] + a[i] + a[i+1])	{
			sum = max(sum,a[i-1] + a[i] + a[i+1]);	
		}
	}

	cout << sum << endl;


	return 0;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;
struct edge {
  ll to;
  ll weight;
};

vector<edge> edges[ARRAY];
bool flg[ARRAY];
int color[ARRAY];

void dfs(ll v) {
  FOREACH(e, edges[v]) {
    // DEBUG(v);
    // DEBUG("=>");
    // DEBUG(e.to);
    // LN();
    if (!flg[e.to]) {
      flg[e.to] = true;
      if (e.weight & 1) {
        color[e.to] = color[v] ^ 1;
      } else {
        color[e.to] = color[v];
      }
      dfs(e.to);
    }
  }
}

void input() {
  IN(N);
  ll u, v, w;
  REP(i, N) {
    IN(u);
    IN(v);
    IN(w);
    edges[u].pb((edge){v, w});
    edges[v].pb((edge){u, w});
    flg[i] = false;
    color[i] = -1;
  }
}

void solve() {
  color[1] = 1;
  dfs(1);
  FOR(i, 1, N+1) {
    PRINT(color[i]);
  }
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;

int n,k;
int w[100010];
ll sum[100010];
bool f(ll bound){
    ll index=0;
    ll take=1;
    rep(truck,0,k){
        while(index+take<=(n+1)&&sum[index+take]-sum[index]<=bound){
            take++;
        }
        take--;
        index+=take;
        take=1;
    }
    if(index>=n)return true;
    else return false;
}

int main( ){
    cin>>n>>k;
    rep(i,0,n)cin>>w[i];
    rep(i,0,n+1)sum[i+1]=sum[i]+w[i];
    ll nmax=100000;
    ll wmax=10000;
    ll high=nmax*wmax+1;
    ll low=0;
    while(abs(high-low)>1){
        ll mid=(high+low)/2;
        if(f(mid)){
            high=mid;
        }
        else{
            low=mid;
        }
    }
    cout<<high<<endl;
    return 0;
}





Measured memory_bytes: 4276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll t = 0,a = 0;
    for(int i=0;i<N;i++){
        ll T,A;
        cin >> T >> A;
        ll l = 0,r = 1e18/max(T,A);
        while(l+1<r){
            ll m = (l+r)/2;
            if(m*T>=t && m*A>=a) r = m;
            else l = m;
        }
        t = T*r,a = A*r;
    }
    cout << a+t << "\n";
}

Measured memory_bytes: 3660
# -*- coding: utf-8 -*-
from scipy.misc import comb

def main():
     n = int(input())
     a = list(map(int, input().split()))
     num_a = dict()
     com_a = dict()

     for i in a:
          if not i in num_a.keys():
               num_a[i] = 1
          else:
               num_a[i] += 1

     for i in num_a.keys():
          value = num_a[i]
          com_a[i] = com(value)

     # print(num_a)
     # print(com_a)

     pre_ans = sum(com_a.values())
     # print('pre_ans:{}'.format(pre_ans))

     for i in range(n):
          k = a[i]
          ans = pre_ans - com_a[k] + com(num_a[k] - 1)
          print(ans)

def com(n):
     return comb(n, 2, exact=True)

if __name__ == "__main__":
    main()


Measured memory_bytes: 41772
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	ll lo = 0, hi = 2e9;
	while(lo < hi){
		ll mid = (lo + hi + 1) / 2;
		ll add = 0;
		for(int i = 0; i < n; i++){
			ll raz = v[i] - mid * b;
			if(raz <= 0) continue;
			add += raz / (a - b);
			add += (raz % (a - b) != 0);
		}
		if(add > mid) lo = mid;
		else hi = mid - 1;
	}
	cout << lo + 1;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define MAX 100
#define INFTY 9999999
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];
int i,v,j,e,b;
  
int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];
  int sum;

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  sum = 0;
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=M[i][p[i]];
  }

  return sum;
}

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

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>
int main ()
{
  int N,H[100000];
  int i,j,k,ans;
  
  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
    scanf("%d",&H[i]);
  }

  ans=0;
  k=0;
  for(i=1;i<N;i++)
  {
    if(H[i-1]>=H[i])
    {
      k++;
    }
    else
    {
      if(k>ans)
      {
        ans=k; 
      }
      k=0;
    }
  }
  
  if(k>ans)
      {
        ans=k;
        k=0;
      }
  
  printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int a[3][3];
    int c[3][3];
    rep(i, 0, 3) {
        rep(j, 0, 3) {
            cin >> a[i][j];
            c[i][j] = 0;
        }
    }

    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) {
        rep(j, 0, 3) {
            rep(k, 0, 3) {
                if(b[i] == a[j][k]) {
                    c[j][k] = 1;
                }
            }
        }
    }

    int count_x = 0;
    int count_y = 0;
    rep(i, 0, 3) {
        count_x = 0;
        count_y = 0;
        rep(j, 0, 3) {
           if(c[i][j] == 1) {
               count_x++;
           }
           if(c[j][i] == 1) {
               count_y++;
           } 
        }
        if(count_y == 3 || count_x == 3) {
            cout << "Yes" << endl;
            return 0;
        }
        if(c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1) {
            cout << "Yes" << endl;
            return 0;
        }
        if(c[0][2] == 1 && c[1][1] == 1 && c[2][0] == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
  int n, r;
  cin >> n >> r;
  if(n<10){
    cout << r + 100 * (10 - n) << endl;
  }else{
    cout << r << endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  ll N, Y;
  cin >> N >> Y;
  int x = 0;
  int y = 0;
  int z = 0;
  bool ok = false;
  for(int i=0; i <= N; i++){
    x = i;
    if((-9000*x - 1000*N + Y)%4000 != 0)
      continue;
    y = (-9000*x - 1000*N + Y)/4000;
    z = N - x - y;
    if(x >= 0 && y >= 0 && z >= 0){
      ok = true;
      break;
    }
  }
  if(ok)
    cout << x << " " << y << " " << z << endl;
  else
    cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    ll ans = 0;
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s.at(i) == '+') ++ans;
        else --ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)

	ans := "NG"
	for i := a; i <= b; i++ {
		if i%k == 0 {
			ans = "OK"
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N,M;
  cin>>N>>M; 
  cout<<min(N%M,M-N%M)<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

//Main
public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();

		long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(), d = sc.nextLong();
		System.out.println(Math.max(a * c, Math.max(a * d, Math.max(b * c, b * d))));

	}

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;// shuffle, then sort
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 32824
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

const int maxn = 3e5 + 7;

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

int main() {
    LL a,b;
    while(cin >> a >> b) {
        cout << (a*b)/gcd(a,b) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

signed main(){
  int a,b;
  cin>>a>>b;
  cout<<(a-1)*(b-1)<<en;
}

Measured memory_bytes: 256
using System;

namespace AtCoderABC131C
{
    class Program
    {
        static void Main(string[] args)
        {
            long ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            long A = long.Parse(s[0]);
            long B = long.Parse(s[1]);
            int C = int.Parse(s[2]);
            int D = int.Parse(s[3]);

            ans = getans(B, C, D) - getans(A - 1,C,D);

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

        static long getans(long A,int x,int y)
        {
            long xcount = A / x;
            long ycount = A / y;

            long xycount = A / getLCM(x, y);

            long ans = A - xcount - ycount + xycount;

            return ans;
        }

        static long getLCM(int a,int b)
        {
            long ret = (long)a * b;

            if(a<b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            int r = a % b;

            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }

            ret = ret / b;

            return ret;
        }
    }
}


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

using namespace std;

int main(){
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  cout << fixed << setprecision(10) << abs(polar(A, M_PI / 6 * H + M_PI / 360 * M) - polar(B, M_PI / 30 * M)) << endl;
  
  return 0;
}

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

int main (){
    int N;
    cin >> N;
    vector<int> list(N);
    int ans = 0;
    for(int i = 0;i < N;i++){
        cin >> list.at(i);
        ans ^=list.at(i);
    }
    int ans2;

    for(int i = 0;i < N;i++){
        ans2 = ans ^ list.at(i);
        cout << ans2 << endl;
    }



    
}

Measured memory_bytes: 4048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int MAX = (int) (1e+5);
            int[] cnt = new int[MAX + 1];
            for (int i = 0; i < n; i++) {
                int val = in.nextInt();
                cnt[val]++;
            }
            for (int i = 2; i <= MAX; i++)
                cnt[i] += cnt[i - 1];
            int ans = 0;
            for (int k = 1; k <= MAX; k++) {
                int c1 = cnt[k - 1];
                int c2 = n - c1;
                if (c1 == c2)
                    ans++;
            }
            out.print(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 34396
#include <stdio.h>
#include <math.h> 
int main(void){  
double r, c, s;   
while(scanf("%lf", &r) != EOF)  {         
c = 2.0 * r * M_PI;    
s = r * r * M_PI;       
printf("%.6lf %.6lf\n", s, c);  
}   
return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    string s;
    int ans=0,cnt=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
            cnt++;
        }else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    if(c < min(a,b) || c > max(a,b)){
        cout << "No";
    } else {
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
denkyu_switch=[]
res=0
for i in range(m):
    denkyu_switch+=[list(map(int, input().split()))[1:]]
p=list(map(int, input().split()))
for i in range(2**n):
    denkyu = [0] * m
    for j in range(n):
        if i>>j & 1:
            for k in range(m):
                if j+1 in denkyu_switch[k]:
                    denkyu[k]+=1
    denkyu2=[i%2 for i in denkyu]
    if p==denkyu2:
        res+=1
print(res)


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

ll N,A[16],x[16][16],y[16][16];
ll S[16],M=0;

bool check(){
    for(ll i=1;i<=N;i++){
        if(S[i]==1){
            for(ll j=1;j<=A[i];j++){
                if(S[x[i][j]] != y[i][j]){

                    return false;
                }
            }
        }
    }
    return true;
}

void dfs(int i){
    if(i==N+1){
        if(check()){
            ll cnt=0;
            for(ll j=1;j<=N;j++)if(S[j]==1)cnt++;
            M = max(M,cnt);
        }
        return;
    }
    S[i] = 1;
    dfs(i+1);
    S[i] = 0;
    dfs(i+1);
}



int main(void){
    cin >> N;
    for(ll i=1;i<=N;i++){
        cin >> A[i];
        for(ll j =1;j<=A[i];j++)cin >>x[i][j] >> y[i][j];
    }
    dfs(1);
    cout << M << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
ll dp[1010][1010];
ll mod = 1e9 + 7;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h)
    {
        cin >> s[i];
    }
    dp[0][0] = 1;
    rep(i, h)
    {
        rep(j, w)
        {
            if (s[i][j] == '#')
                continue;
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
            dp[i][j + 1] += dp[i][j];
            dp[i][j + 1] %= mod;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin>>n;
    int flag=0,state=0;
    for(int i=0;i<n;i++){
    	int x,y; cin>>x>>y;
    	if(x==y) state++;
    	else state=0;
    	if(state==3) flag=1;
    }
    if(flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3684
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CCitySavers solver = new CCitySavers();
        solver.solve(1, in, out);
        out.close();
    }

    static class CCitySavers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int[] a = in.readIntArray(n + 1);
            int[] b = in.readIntArray(n);

            long answer = 0;
            for (int i = 0; i < n; i++) {
                int val = Math.min(a[i], b[i]);
                answer += val;
                a[i] -= val;
                b[i] -= val;

                val = Math.min(a[i + 1], b[i]);
                answer += val;
                a[i + 1] -= val;
                b[i] -= val;
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readIntArray(int n) {
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = nextInt();
            }
            return x;
        }

    }
}



Measured memory_bytes: 42652
package main

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

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	in := sc.Text()

	a, _ := strconv.Atoi(strings.Split(in, " ")[0])
	b, _ := strconv.Atoi(strings.Split(in, " ")[1])

	if a > b {
		fmt.Println("a > b")
	} else if a < b {
		fmt.Println("a < b")
	} else {
		fmt.Println("a == b")
	}
}



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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> v(n);
    cinv(v,0,n);
    ld ave =0;
    FOR(i,0,n){
      ave+=v[i];
    }
    FOR(i,0,n){
      v[i]*=n;
    }
    ll po=0;
    ll minf=1e9;
    FOR(i,0,n){
      if(minf>abs(ave-v[i])){
        minf=abs(ave-v[i]);
        po=i;
      }
    }
    cout<<po<<endl;
}


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

int main() {
	int N, A, a = 0;
	cin >> N;
	unordered_map<int, int> b;
	for (int i = 0; i < N; i++) {
		cin >> A;
		b[A]++;
	}
	for (const pair<int, int>& i : b) {
		if (i.second % 2 == 0) a++;
	}
	if (a % 2) cout << b.size() - 1;
	else cout << b.size();
}

Measured memory_bytes: 4388
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

__attribute__((constructor)) static void init()
{
    ios::sync_with_stdio(false);
    std::cin.tie(0);
}

int main()
{
    uint n;
    cin >> n;
    n %= 10;

    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        return 0;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        return 0;

    default:
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e3+5;
const int MD=998244353;
int a[N],f[N][N][3];
void add(int &x,int y) {
    x+=y;
    if(x>=MD) x-=MD;
}
int main() {
    //freopen("in.txt","r",stdin);
    int n,s;
    scanf("%d%d",&n,&s);
    for(int i=0;i<n;i++) {
        scanf("%d",&a[i]);
    }
    f[0][0][0]=1;
    for(int i=0;i<n;i++) {
        for(int j=0;j<=s;j++) {
            add(f[i+1][j][0],f[i][j][0]);
            add(f[i+1][j][1],f[i][j][0]),add(f[i+1][j][1],f[i][j][1]);
            add(f[i+1][j][2],f[i][j][0]),add(f[i+1][j][2],f[i][j][1]),add(f[i+1][j][2],f[i][j][2]);
            if(j+a[i]<=s) {
                add(f[i+1][j+a[i]][1],f[i][j][0]),add(f[i+1][j+a[i]][1],f[i][j][1]);
                add(f[i+1][j+a[i]][2],f[i][j][0]),add(f[i+1][j+a[i]][2],f[i][j][1]);
            }
        }
    }
    printf("%d\n",f[n][s][2]);
    return 0;
}

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

using namespace std;

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

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

  string s;
  cin >> s;
  vector<int> vals;
  int val = 0;
  for (char c : s) {
    if (c == 'g') {
      val++;
    } else {
      val--;
    }
    vals.push_back(val);
  }
  for (int i = (int) vals.size() - 2; i >= 0; i--) {
    vals[i] = min(vals[i], vals[i + 1]);
  }
  int res = 0;
  int curval = 0;
  for (int i = 0; i < s.size(); i++) {
    if (curval == 0) {
      assert(s[i] == 'g');
      curval++;
    } else if (s[i] == 'p') {
      curval--;
    } else if (res * 2 + 2 <= vals[i]) {
      res++;
      curval--;
//      cout << "#" << (i + 1) << " -> " << vals[i] << endl;
    } else {
      curval++;
    }
//    cout << curval;
    assert(curval >= 0);
  }
//  cout << endl;
  cout << res;
  return 0;
}

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
#define all(v) (v).begin(),(v).end()
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
ll fact[100010];
ll finv[100010];
void factorial(int n){
    fact[0]=1;
    finv[0]=1;
    for(int i=1;i<=n;i++)
        fact[i]=fact[i-1]*i,fact[i]%=MOD,finv[i]=fermat_inv(fact[i]);
}
ll ncr(ll n,ll r)
{
    if(n<r)
        return 0;
    else{
        ll x=finv[r]*finv[n-r]%MOD;
        return fact[n]*x%MOD;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    //SieveOfEratosthenes(1000000);
    //factorial(100005);
    while(t--){
        int n;
        cin>>n;
        ll a[n],b[n];
        for(int i=0;i<n;i++){
            ll x,y;
            cin>>x>>y;
            a[i]=x+y;
            b[i]=x-y;
        }
        sort(a,a+n);
        sort(b,b+n);
        cout<<max(a[n-1]-a[0],b[n-1]-b[0]);
    }
}

Measured memory_bytes: 6756
#include <iostream>
#include <string>
#include <queue>
using namespace std;

int main(){
    queue<int> number;
    long long int left_sum[21] = {};
    long long int left_temp[21] = {};
    int n;
    cin >> n;
    for(int i = 0;i<n-1;i++){
        int temp;
        cin >> temp;
        number.push(temp);
    }
    left_sum[number.front()] = 1;
    number.pop();
    while(!number.empty()){
        int temp;
        for(int i = 0;i<21;i++){
            if(left_sum[i] == 0) continue;
            temp = i + number.front();
            if(0<= temp && temp <= 20){
                left_temp[temp] += left_sum[i];
            }
            temp = i - number.front();
            if(0<= temp && temp <= 20){
                left_temp[temp] += left_sum[i];
            }
        }
        for(int i = 0;i<21;i++) {
            left_sum[i] = left_temp[i];
            left_temp[i] = 0;
        }
        number.pop();
    }
    int right;
    cin >> right;
    cout << left_sum[right] << endl;
    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int x,a;
    cin >> x >> a;
    if(x<a){
        cout << 0 << endl;
    }
    else{
        cout << 10 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  int n,m,x;
  cin >> n>> m>> x;
  vector<int> a(n+1);
  for(int i = 0; i < m; ++i){
    int b;cin >> b;
    ++a[b];
  }
  int t1=0,t2=0;
  for(int i = 0; i < x; ++i){
    t1+=a[i];
  }
  for(int i = x; i <= n; ++i){
    t2+=a[i];
  }
  int ans = min(t1,t2);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    int ans = 0;
    for(int i = 0; i < K; i++){
        ans += A.at(N - 1 - i);
    }
    cout << ans << endl;
    return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int mod = 1000000007;
            var N = ReadInt();
            var S1 = Read();
            var S2 = Read();
            var pat = new List<int>();
            var chk = 0;
            while (chk < N)
            {
                if (chk == N - 1)
                {
                    pat.Add(1);
                    chk++;
                }
                else
                {
                    if (S1[chk] == S1[chk + 1])
                    {
                        pat.Add(2);
                        chk += 2;
                    }
                    else
                    {
                        pat.Add(1);
                        chk++;
                    }
                }
            }
            long ans = pat[0] == 1 ? 3 : 6;
            for (int i = 1; i < pat.Count; i++)
            {
                if (pat[i - 1] == 1 && pat[i] == 1)
                {
                    ans = ans * 2 % mod;
                }
                else if (pat[i - 1] == 1 && pat[i] == 2)
                {
                    ans = ans * 2 % mod;
                }
                else if (pat[i - 1] == 2 & pat[i] == 2)
                {
                    ans = ans * 3 % mod;
                }
            }

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

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
ll lcm(ll a, ll b){
    ll ret = (a * b)/gcd(a,b);
    return ret;
}

ll a, b;

ll f(ll c){
    ll l = (a + c - 1) / c;
    ll u = b / c;
    return (u - l + 1);
}


int main(){
    ll c, d;
    cin >> a >> b >> c >> d;
    ll ans = b - a + 1 - (f(c) + f(d) - f(lcm(c, d)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
N, K = map(int, input().split())
W = tuple(map(int, sys.stdin.read().splitlines()))
ma = max(W)
def check(x):
    if x < ma:
        return False
    use = 1
    rest = x
    for w in W:
        if rest >= w:
            rest -= w
        else:
            rest = x - w
            use += 1
    return use <= K
l = 0
r = sum(W)
while r - l > 1:
    m = (r + l) // 2
    if check(m):
        r = m
    else:
        l = m
print(r)



Measured memory_bytes: 16496
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
  int n;
    cin>>n;
      int root=(int)sqrt(n);
      cout<<root*root<<endl;
			      return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e16;
typedef long long ll;
ll mod = 1e9+7;
ll fast_exp(ll a, ll b)
{
    if(b == 0)
        return 1;
    else
    {
        ll res = 1;
        res = fast_exp(a,b/2);
        res = (res*res)%mod;
        if(b%2 == 1)
            res = (res*a)%mod;
        return res;
 
    }
}
const ll N = 3001;
int a[N],b[N];
int t,n;
int dp[N][N];
int vis[N][N]={};
int knap(int i, int w)
{
  if(i == n)
    return 0;
  if(vis[i][w])
    return dp[i][w];
  else
  {
    int ctake=0, cleave=0;
    if(w>=a[i])
      ctake = b[i]+knap(i+1,w-a[i]);
    if(w>0)  
      ctake = max(ctake,b[i]);  

    cleave = knap(i+1,w);

    vis[i][w]=1;
    dp[i][w] = max(ctake,cleave);
    return dp[i][w];
  }

}
int main()
{
   // ios_base::sync_with_stdio(false);
   // cin.tie(NULL);
  cin>>n>>t;
  vector<pair<int,int>> pr;
  for(int i=0; i<n ; i++)
  {
    cin>>a[i]>>b[i];
    pr.pb(mp(a[i],b[i]));

  }
  sort(pr.begin(),pr.end());

  for(int i =0; i<(int)pr.size(); i++)
  {
    a[i]=pr[i].ff;
    b[i]=pr[i].ss;
  }

  cout<<knap(0,t)<<endl;

 return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int x, y, a, b, c;

	cin >> x >> y >> a >> b >> c;

	vector <int> p(a), q(b), r(c);

	for(int i = 0; i < a; i++){
		cin >> p[i];
	}

	for(int i = 0; i < b; i++){
		cin >> q[i];
	}

	for(int i = 0; i < c; i++){
		cin >> r[i];
	}

	multiset <int> ha, hb;

	for(int &e : p) ha.insert(e);
	for(int &e : q) hb.insert(e);

	while(ha.size() > x) ha.erase(ha.begin());
	while(hb.size() > y) hb.erase(hb.begin());

	sort(r.rbegin(), r.rend());

	for(int i = 0; i < c; i++){
		if(r[i] <= *ha.begin() and r[i] <= *hb.begin()) break;

		if(*ha.begin() < *hb.begin()){
			ha.erase(ha.begin());
			ha.insert(r[i]);
		}else{
			hb.erase(hb.begin());
			hb.insert(r[i]);
		}
	}


	int ans = 0;

	for(int e : ha) ans += e;
	for(int e : hb) ans += e;

	cout << ans << endl;

	
	
	
	return 0;
}

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

int main(){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ans += min(a,k);
  k -= a+b;
  if(k > 0) {
    ans -= min(k,c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636