akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#define ALL(a) (a).begin(),(a).end()

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};




long long fac[510000], finv[510000], inv[510000];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  ll r,D,x;
  cin >> r>>D>>x;
  ll ans=x;
  FOR(i,1,10){
  ans=r*ans-D;
  cout<<ans<<endl;
  }




}


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

using namespace std;

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

ll a[100010];

int main() {
    int N, x;
    cin >> N >> x;
    rep(i, N)cin >> a[i];

    ll ans = 0;
    for (int i = 1; i < N; i++) {
        ll sum = a[i - 1] + a[i];
        if (sum > x) {
            ans += sum - x;
            a[i] -= min(sum - x, a[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
void main() {
	auto ip = readAs!(int[]), n = ip[0], m = ip[1];
	auto matrix = new int[][](n, m);
	foreach(i; 0..n) {
		matrix[i] = readAs!(int[]);
	}
	auto vector = new int[](m);
	foreach(i; 0..m) {
		vector[i] = ri;
	}
	foreach(i; 0..n) {
		int s;
		foreach(j; 0..m) {
			s += matrix[i][j] * vector[j];
		}
		writeln(s);
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}



Measured memory_bytes: 2944
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i, _ := range p {
		fmt.Scan(&p[i])
	}

	ans := 0
	min := 9999999999999
	for i := 0; i < n; i++ {
		min = Min(min, p[i])
		if p[i] <= min {
			ans++
		}
	}
	fmt.Println(ans)
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

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

//31
typedef long long ll;

//ll power(ll a , ll b) {
    //ll ans = 1;
	//while (b) {
		//if (b & 1) {
			//ans = ans  * a;
		//}
		//a = a * a;
		//b  /= 2;
	//}
	//return ans;
//}

int main() {
	int n;
	int k;
	scanf("%d%d",&n,&k);
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		double p = 1.0 / n;
		int x = i;
		while (x < k) {
			x *= 2;
			p /= 2;
		}
		ans += p;
	}
	printf("%.12f\n",ans);
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll V,E;
  cin >> V >> E;
  vector<vector<ll>> vec(V,vector<ll>(V,INFLONG));
  rep(i,V){
    vec[i][i] = 0;
  }
  rep(i,E){
    cin >> t1 >> t2 >> t3;
    vec[t1][t2] = t3;
  }
  rep(k,V){
    rep(i,V){
      rep(j,V){
        chmin(vec[i][j],vec[i][k] + vec[k][j]);
      }
    }
  }
  bool can = true;
  rep(i,V){
    if(vec[i][i] < 0){
      can = false;
    }
  }
  if(can){
    rep(i,V){
      rep(j,V){
        if(vec[i][j] >= INFLONG/100){
          cout << "INF";
        }else{
          cout << vec[i][j];
        }
        if(j != V-1){
          cout << " ";
        }
      }
      cout << endl;
    }
  }else{
    cout << "NEGATIVE CYCLE" << endl;
  }
}


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

int main() {
	long long n, k, ans = 0; cin >> n >> k;
	for (long long b = k + 1, m; b <= n; b++) {
		m = n / b;
		ans += (b - k) * m + max(n - (b * m + k - 1), 0LL) - (k == 0 ? 1 : 0);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def handstand(s, k)
  ones = []
  zeros = []

  prev = s[0]
  count = 0
  s.each_char do |c|
    if prev == c
      count += 1
    else
      if prev == '1'
        ones << count
      else
        zeros << count
      end
      count = 1
    end
    prev = c
  end

  s[-1] == '1' ? ones << count : zeros << count

  if zeros.count <= k
    return s.size
  end

  ones.unshift(0) if s[0] == '0'

  max = 0
  sum = 0
  used_one = []
  used_zero = []

  sum += ones.first
  used_one << ones.shift


  k.times do
    sum += zeros.first
    sum += ones.first
    used_zero << zeros.shift
    used_one << ones.shift
  end
  max = sum

  until zeros.empty? || ones.empty?
    sum -= used_one.first
    sum -= used_zero.first
    sum += zeros.first
    sum += ones.first
    used_zero << zeros.shift
    used_one << ones.shift
    used_zero.shift
    used_one.shift
    max = [max, sum].max
  end

  unless zeros.empty?
    sum -= used_zero.first if !used_zero.empty?
    sum -= used_one.first if !used_one.empty? && s[0] == '1'
    sum += zeros.first
    max = [max, sum].max
  end

  max
end

n, k = gets.split.map(&:to_i)
s = gets.chomp
puts handstand(s, k)

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

int main(){
    int N,T,c[1000],t[1000],ans=1001;
    cin>>N>>T;
    
    for(int i=0; i<N; i++){
        cin>>c[i]>>t[i];
        if(t[i]<=T && ans>c[i]){
            ans=c[i];
        }
    }
    if(ans==1001)cout<<"TLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    int h[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }

    long int inf = 9223372036854775807;
    long int dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; i++){
        if (i < k){
            dp[i] = inf;
            for (int j = 1; j <= i; j++){
                if (dp[i - j] + abs(h[i - j] - h[i]) < dp[i]) dp[i] = dp[i - j] + abs(h[i - j] - h[i]);
            }
        }
        else if (i >= k){
            dp[i] = inf;
            for (int j = 1; j <= k; j++){
                if (dp[i - j] + abs(h[i - j] - h[i]) < dp[i]) dp[i] = dp[i - j] + abs(h[i - j] - h[i]);
            }
        }
    }
    printf("%ld\n", dp[n - 1]);

    return 0;    
}


Measured memory_bytes: 1280
#include <math.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main()
{
int n,m;
cin >> n >> m;
vector<vector<int>> a(n, vector<int>(m));
vector<int> b(m);
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++)
{
cin >> a.at(i).at(j);
}
}
for (int i=0;i<m;i++)
{
cin >> b.at(i);
}
for(int i=0;i<n;i++)
{
int ans=0;
for (int j=0;j<m;j++)
{
ans+=a.at(i).at(j)*b.at(j);
}
cout << ans << endl;
}
}



Measured memory_bytes: 3176
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <queue>
#define SIZE 2005

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

char mp[SIZE][SIZE];
int r1[SIZE][SIZE];
int r2[SIZE][SIZE];
int r3[SIZE][SIZE];

int gt1(int a,int b,int c,int d)
{
	if(b<a||d<c) return 0;
	int ret=r1[b][d];
	if(a>0) ret-=r1[a-1][d];
	if(c>0) ret-=r1[b][c-1];
	if(a>0&&c>0) ret+=r1[a-1][c-1];
	return ret;
}
int gt2(int a,int b,int c,int d)
{
	if(b<a||d<c) return 0;
	int ret=r2[b][d];
	if(a>0) ret-=r2[a-1][d];
	if(c>0) ret-=r2[b][c-1];
	if(a>0&&c>0) ret+=r2[a-1][c-1];
	return ret;
}
int gt3(int a,int b,int c,int d)
{
	if(b<a||d<c) return 0;
	int ret=r3[b][d];
	if(a>0) ret-=r3[a-1][d];
	if(c>0) ret-=r3[b][c-1];
	if(a>0&&c>0) ret+=r3[a-1][c-1];
	return ret;
}
int main()
{
	int n,m,Q;
	scanf("%d %d %d",&n,&m,&Q);
	for(int i=0;i<n;i++) scanf("%s",&mp[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			r1[i][j]=mp[i][j]-'0';
			if(i>0&&mp[i-1][j]=='1'&&mp[i][j]=='1') r2[i][j]=1;
			if(j>0&&mp[i][j-1]=='1'&&mp[i][j]=='1') r3[i][j]=1;
			if(i>0)
			{
				r1[i][j]+=r1[i-1][j];
				r2[i][j]+=r2[i-1][j];
				r3[i][j]+=r3[i-1][j];
			}
			if(j>0)
			{
				r1[i][j]+=r1[i][j-1];
				r2[i][j]+=r2[i][j-1];
				r3[i][j]+=r3[i][j-1];
			}
			if(i>0&&j>0)
			{
				r1[i][j]-=r1[i-1][j-1];
				r2[i][j]-=r2[i-1][j-1];
				r3[i][j]-=r3[i-1][j-1];
			}
		}
	}
	for(int i=0;i<Q;i++)
	{
		int a,b,c,d;
		scanf("%d %d %d %d",&a,&c,&b,&d);
		a--,b--,c--,d--;
		printf("%d\n",gt1(a,b,c,d)-(gt2(a+1,b,c,d)+gt3(a,b,c+1,d)));
	}
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/
int main(){
	int N;
	cin >> N;
	cout << (N-2) * 180 << endl;
}

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

#define int long long

struct Combination {
  int mod; // e.g. 1000000007
  vector<int> fact; // factorial
  vector<int> invf; // inverse factorial
  vector<vector<int> > part; // partition number

  /*
    constructor : O(sz+log(mod))   
    make factorial table (fact) and inverse factorial table (invf)
  */
  Combination(int sz, int mod) : fact(sz+1), invf(sz+1), mod(mod) {
    fact[0] = 1;
    for ( int i = 1; i < (int)fact.size(); i++ ) {
      fact[i] = fact[i-1]*i%mod;
    }
    invf[sz] = inv(fact[sz]);
    for ( int i = sz-1; i >= 0; i-- ) {
      invf[i] = invf[i+1]*(i+1)%mod;
    }
  }

  int pow(int x, int n) const {
    int ret = 1;
    while ( n > 0 ) {
      if ( n & 1 ) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return ret;
  }

  int inv(int x) const {
    return pow(x, mod - 2);
  }

  /*
    permutation
  */
  int P(int n, int r) const {
    if ( r < 0 || n < r ) return (0);
    return fact[n]*invf[n-r]%mod;    
  }

  /*
    combination
  */
  int C(int n, int r) const {
    if ( r < 0 || n < r ) return (0);    
    return fact[n]*invf[r]%mod*invf[n-r]%mod;    
  }  

  /*
    combination with repetition
  */
  int H(int n, int r) const {
    if ( n < 0 || r < 0 ) return 0;
    if ( n == 0 && r == 0 ) return 1;
    return C(n+r-1, n);    
  }

  /*
    stirling number
  */
  int S(int n, int r) const {
    int ret = 0;
    for ( int i = 1; i <= r; i++ ) {
      int add = C(r, i)*pow(i, n)%mod;      
      if ( (r-i)&1 ) ret += mod-add;
      else ret += add;
      ret %= mod;      
    }
    (ret *= invf[r]) %= mod;
    return ret;
  }

  /*
    bell number
  */
  int B(int n, int r) const {
    int ret = 0;
    for ( int i = 1; i <= r; i++ ) {
      (ret += S(n, i)) %= mod;      
    }
    return ret;
  }

  /*
    calc partition number
    return and make partition number table (part)
  */
  vector<vector<int> > built_part(int n, int r) {
    part = vector<vector<int> >(n+1, vector<int>(r+1, 0));
    part[0][0] = 1;
    for ( int i = 0; i <= n; i++ ) {
      for ( int j = 1; j <= r; j++ ) {
	if ( i-j >= 0 ) {
	  (part[i][j] = part[i][j-1]+part[i-j][j]) %= mod;	  
	} else {
	  part[i][j] = part[i][j-1];
	}
      }
    }
    return part;    
  }

  /*
    TODO 
    make built_part() that make only part[i][i]
    https://twitter.com/kirika_comp/status/953482654787149824
    http://d.hatena.ne.jp/DEGwer/20170829
    http://mathworld.wolfram.com/BellNumber.html
  }    
  */
};

signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];    
  }

  vector<int> cum(N+1, 0);
  int mod = 1e9+7;  
  Combination comb(N+1, mod);
  cum[1] = 1;  
  for ( int i = 2; i <= N; i++ ) {
    cum[i] = cum[i-1]+comb.inv(i);    
    cum[i] %= mod;    
  }

  int sum = 0;
  for ( int i = 0; i < N; i++ ) {
    int tmp = cum[i+1]+cum[N-i]-1;
    sum += tmp*A[i];
    sum %= mod;
  }
  sum *= comb.fact[N];  

  cout << sum%mod << endl;
  
  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
int n;
cin >>n;
int sum=0;
int a[n],b[n];
for(int i=0;i<n;i++){
cin >>a[i]>>b[i];
int k;
k=b[i]-a[i];
k++;
sum=sum+k;
}
cout <<sum;
return 0;
}

Measured memory_bytes: 256
var a:array['A'..'Z'] of byte;
    i,re:byte;
    s:string;
begin
	readln(s); re:=0;
	for i:=1 to length(s) do
	  if a[s[i]] = 0 then 
	    begin
	      inc(a[s[i]]);
	      inc(re);
	    end;
	if re = 2 then write('Yes') else write('No');
end.

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

int main(){
    ll n; cin >> n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {

	ll n, m; cin >> n >> m;
	
	vector<pair<ll, ll>> pa_ab;
	for (int i = 0; i < n; i++) {
			ll f, s; cin >> f >> s;
			pa_ab.push_back({ f,s });
	}

	vector<pair<ll, ll>> pa_cd;
	for (int i = 0; i < m; i++) {
			ll f, s; cin >> f >> s;
			pa_cd.push_back({ f,s });
	}

	for (int i = 0; i < n; i++) {
		int ansIndex;
		ll dist = 9223372036854775807LL;
		for (int j = 0; j < m; j++) {
			ll tmpDist = 0;
			tmpDist += abs(pa_ab[i].first - pa_cd[j].first);
			tmpDist += abs(pa_ab[i].second - pa_cd[j].second);
			if (chmin(dist, tmpDist)) ansIndex = j;
		}
		
		cout << ansIndex + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


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

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main(){
  int N;
  cin >> N;
  vector<double> V(N,0);
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  sort(V.begin(),V.end());
  for(int i=0;i<N-1;i++){
    V.at(i+1)= (V.at(i+1)+V.at(i))/2;
  }
  cout << V.at(N-1) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 string s,t,u;
 int a,b;
 cin >> s >> t;
 cin >> a>> b;
 cin >> u;
 if(u==s){
     cout << a-1<< " " << b << endl;
 }else{
     cout << a <<" "<< b-1 << endl;
 }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N,K,R,S,P;string t;
	in(N,K,R,S,P,t);
	int ans = 0;
	auto dp = mv(K,4);
	map<char,int>mp;
	mp['r']=0;mp['s']=1;mp['p']=2;
	REP(i,N){
		auto ndp = mv(3);
		REP(j,4){
			REP(k,3){
				if(j == k)continue;
				int cost = 0;
				if((k+1)%3==mp[t[i]]){
					if(k==0)cost+=R;
					else if(k==1)cost+=S;
					else cost+=P;
				}
				CHMAX(ndp[k],dp[i%K][j]+cost);
			}
		}
		dp[i%K]=ndp;
	}
	REP(i,K)ans+=*max_element(ALL(dp[i]));
	out(ans);
}

Measured memory_bytes: 6528
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    for (int i = 0; i < q; i++) {
        ll a, b;
        scanf("%lld %lld", &a, &b);
        if (a > b) { swap(a, b); }

        ll sq = (ll)ceil(sqrt(a*b)) - 1;
        ll ans = 2 * (sq - 1);

        if (sq * sq < a * b) {
            ans += 1;   
            if (sq * (sq + 1) < a * b) {
                ans += 1;
            }
        }
        if (sq >= a) {
            ans -= 1;
        }

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

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

// 利得がx以上の握手の組の個数がM個以上であるならtrue
bool isOK(long long x, long long M, vector<long long>& A) {
  long long count = 0;
  for (int i = 0; i < A.size(); ++i) {
    auto t = lower_bound(A.begin(), A.end(), x-A[i]);
    count += static_cast<long long>(A.end() - t);
  }
  if (M <= count) return true;
  else return false;
}

// 利得がx以上の握手の組の個数がM個以上である最大のxを求める
long long binary_search(long long M, vector<long long>& A) {
    long long ok = 0;
    long long ng = numeric_limits<long long>::max() / 2LL;

    while (abs(ng - ok) > 1) {
        long long mid = (ok + ng) / 2;;

        if (isOK(mid, M, A)) ok = mid;
        else ng = mid;
    }

    return ok;
}

void solve(long long N, long long M, std::vector<long long> A){
  sort(A.begin(), A.end());
  long long x = binary_search(M, A);
  vector<long long> C(N+1, 0);  // C[i]は大きい方からi個の和
  for (int i = 0; i < N; ++i) {
    C[1+i] = C[i] + A[N-1-i];
  }
  long long ret = 0;
  long long count = 0;
  for (int i = 0; i < A.size(); ++i) {
    auto t = lower_bound(A.begin(), A.end(), x-A[i]);
    count += static_cast<long long>(A.end()-t);
    int c = static_cast<int>(A.end()-t);
    ret += C[c] + c*A[i];
  }
  ret -= (count - M)*x;
  std::cout << ret << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, M, std::move(A));
  return 0;
}


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

const int MAX = 200005;
const long long MOD = 1000000007;

vector<int> G_bi[MAX];
vector<int> G[MAX];
int pr[200005]={};

int c[MAX]={};
void dfs(int x){
    for(int y : G[x]) dfs(y);
    int ret = 1;
    for(int y : G[x]) ret += c[y];
    c[x] = ret;
    return;
}

long long inv2[MAX]={};

void init_pow2(){
    inv2[0] = 1;
    inv2[1] = (MOD+1)/2;
    for(int i=2; i<MAX; i++){
        inv2[i] = inv2[1]*inv2[i-1]%MOD;
    }
}

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

    for(int i=1; i<n; i++){
        int x,y;
        cin >> x >> y;
        G_bi[x].push_back(y);
        G_bi[y].push_back(x);
    }

    pr[1] = 1;
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int x = que.front();
        que.pop();
        for(int y : G_bi[x]){
            if(pr[y]==0){
                pr[y] = x;
                G[x].push_back(y);
                que.push(y);
            }
        }
    }
    
    dfs(1);

    long long ans=(1+(MOD-inv2[n])+(MOD-(n*inv2[1])%MOD))%MOD;
    for(int x=1; x<=n; x++){
        //cout << c[x] << endl;
        long long z = (inv2[c[x]]-1)*(inv2[n-c[x]]-1)%MOD;
        ans += z;
        ans %= MOD;
    }
    
    cout << ans << endl;

}

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

int main(){
  int n,k,q;
  cin>>n>>k>>q;
  int a[q];
  int b[n];
  for(int i=0;i<n;i++){
    b[i]=k-q;
  }
  
  for(int i=0;i<q;i++){
    cin>>a[i];
    b[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    if(b[i]>0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	rep(i, 0, n){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i, 0, n - 1){
		if(a[i] <= x){
			ans++;
			x -= a[i];
		}
	}
	if(x == a[n - 1]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

ans = [0] * (N + 1)
for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            v = x * x + y * y + z * z + x * y + y * z + z * x
            if v <= N:
                ans[v] += 1

for i in range(1, N + 1):
    print(ans[i])

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    char a, b;
    cin >> a >> b;
    cout << (a == b ? "H" : "D") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int N;
    scanf("%d", &N);
    char s[N];
    scanf("%s", s);
    int i,x=0;
    for(i=0;i<N;i++){
        if(s[i]!=s[i+1]){
            x=x+1;
        }
    }
    printf("%d", x);

    return 0;
}


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

struct box {
    double xmax = -1e9, xmin = 1e9, ymax = -1e9, ymin = 1e9;

    void update(double x, double y) {
        xmax = max(xmax, x);
        ymax = max(ymax, y);
        xmin = min(xmin, x);
        ymin = min(ymin, y);
    }
};

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

    int n;
    cin >> n;
    box l, r, u, d;
    rep(i, 0, n) {
        double x, y;
        cin >> x >> y;
        char c;
        cin >> c;
        if (c == 'R')
            r.update(x, y);
        else if (c == 'L')
            l.update(x, y);
        else if (c == 'U')
            u.update(x, y);
        else
            d.update(x, y);
    }
    vector<double> t(1);
    double lr;
    // u
    lr = max(l.ymax, r.ymax);
    t.push_back(max(0.0, d.ymax - lr));
    t.push_back(max(0.0, lr - u.ymax));
    t.push_back(max(0.0, d.ymax - u.ymax) / 2.0);
    // d
    lr = min(l.ymin, r.ymin);
    t.push_back(max(0.0, -u.ymin + lr));
    t.push_back(max(0.0, -lr + d.ymin));
    t.push_back(max(0.0, -u.ymin + d.ymin) / 2.0);
    // r
    lr = max(u.xmax, d.xmax);
    t.push_back(max(0.0, l.xmax - lr));
    t.push_back(max(0.0, lr - r.xmax));
    t.push_back(max(0.0, l.xmax - r.xmax) / 2.0);
    // l
    lr = min(u.xmin, d.xmin);
    t.push_back(max(0.0, -r.xmin + lr));
    t.push_back(max(0.0, -lr + l.xmin));
    t.push_back(max(0.0, -r.xmin + l.xmin) / 2.0);

    double ans = 1e18;
    for (auto s : t) {
        double h = max({u.ymax + s, d.ymax - s, l.ymax, r.ymax}) -
                   min({u.ymin + s, d.ymin - s, l.ymin, r.ymin});
        double w = max({r.xmax + s, l.xmax - s, u.xmax, d.xmax}) -
                   min({r.xmin + s, l.xmin - s, u.xmin, d.xmin});
        ans = min(ans, h * w);
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
abc = N.times.map {gets.split.map &:to_i}

dp = Array.new(N + 1) {Array.new(3) {0}}
N.times do |i|
  3.times do |j|
    3.times do |k|
      if j != k
        dp[i + 1][k] = dp[i][j] + abc[i][k] if dp[i + 1][k] < dp[i][j] + abc[i][k]
      end
    end
  end
end
puts dp[N].max

Measured memory_bytes: 12028
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define maxn 100005
char s[maxn];
int a[3];
int main()
{
    scanf("%s", s);
    for(int i = 0; i < strlen(s); i++) {
        if(s[i] == 'a') a[0]++;
        else if(s[i] == 'b') a[1]++;
        else a[2]++;
    }
    sort(a, a+3);
    int ok=0;
    if(a[2]-a[0] == 1 || a[2]-a[0] == 0) ok = 1;
    if(ok) printf("YES\n");
    else printf("NO\n");
    return 0;
}


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

int main(){
    long long A,B,C,Ahako,Bhako,count=0;

    cin >> A >> B >> C;

    while(true){

        if((A % 2) != 0 || (B % 2) != 0 || (C % 2) != 0){
            cout << count << endl;
            break;
        }

        Ahako = A / 2;
        Bhako = B / 2;
        A = Bhako + C / 2;
        B = Ahako + C / 2;
        C = Ahako + Bhako;
        count++;

        
        if(A == B && A == C){
            cout << -1 << endl;
            break;
        }
    }
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z;
//string s, t;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m;
	if(n%2 == 0 || m%2 == 0) cout<<"Even";
	else cout<<"Odd";			
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
  
  #define N 100010
  #define ll long long
  int n, a[N], b[N];
  
  int main()
 {
     while (scanf("%d", &n) != EOF)
     {
         for (int i = 1; i <= n; ++i) scanf("%d", a + i);
         for (int i = 1; i <= n; ++i) scanf("%d", b + i);
         ll need = 0;
         priority_queue <int, vector <int>, less <int> > pq;
         int res = 0; 
         for (int i = 1; i <= n; ++i) 
         {
             if (b[i] > a[i]) need += b[i] - a[i], ++res;
             else if (b[i] < a[i]) pq.push(a[i] - b[i]);
         }
         while (!pq.empty() && need > 0)
        {
             int top = pq.top(); pq.pop();
             need -= top; ++res;    
         }
         if (need > 0) puts("-1");
         else printf("%d\n", res);
     }
    return 0; 
    }

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;
int main(){
    int n;
    string si;
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++){
        cin >> si;
        s.insert(si);
    }

    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <iomanip>

#define PI 3.14159265358979323846
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }

    set<string> count;
    for (int i = 0; i < n; i++) {
        count.insert(s.at(i));
    }

    cout << count.size() << endl;
}

Measured memory_bytes: 25004
#include <iostream>
#include <algorithm>
#include <climits>
#define INF INT_MAX >> 1

typedef long long ll;

using namespace std;

ll dp[110][100100];// dp[n][sum_v] = w

int main(void){
	ll N, W; cin >> N >> W;
	ll w[110], v[110];
	for(int i=0; i<N; i++){
		cin >> w[i] >> v[i];
	}

	fill(dp[0], dp[110], INF);
	dp[0][0] = 0;
	for(int i=0; i<N; i++){
		for(int j=0; j<100100; j++){
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			if(dp[i][j]+w[i] <= W) dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
		}
	}

	ll ans = 0;
	for(int i=0; i<100100; i++){
		if(dp[N][i] <= W) ans = i;
	}

	cout << ans << endl;

}

Measured memory_bytes: 86272
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

int N,M;

int X[100000],Y[100000],Z[100000];

int ans = 0;

//引用元
//http://drken1215.hatenablog.com/entry/2019/03/03/224600
struct UnionFind {
    vector<long> parent;
    
    UnionFind(long n) : parent(n, -1) { }
    void init(long n) { parent.assign(n, -1); }
    
    //xの属している木の根っこを返す
    long root(long x) {
        if (parent[x] < 0) return x;
        else return parent[x] = root(parent[x]);//経路圧縮
    }
    
    long size(long x) {return -parent[root(x)];}
    bool is_same_tree(long x,long y) {return root(x)==root(y);}
    
    bool merge(long x,long y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (parent[x] > parent[y]) swap(x, y);//xの親の方がyの親より小さくなるようにする
        parent[x] += parent[y];
        parent[y] = x;//yの親をxとする
        return true;
    }
};

void solve(){
	ans = N;//何も条件がなければN枚全てに対し魔法を使う必要がある
	UnionFind uf(N);
	for(int i=0;i<M;i++){
		if(uf.is_same_tree(X[i],Y[i])) continue;
		uf.merge(X[i],Y[i]);
		ans--;
	}
}
 
int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		cin >> X[i] >> Y[i] >> Z[i];
		X[i]--;Y[i]--;
		Z[i] %= 2;
		//Z[i]%2==0 ? X[i]+Y[i]が偶数
		//Z[i]%2==1 ? X[i]+Y[i]が奇数
	}
 
	solve();

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

Measured memory_bytes: 2176
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define MAX 1000000
const long long mod = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void Com_init(){ //##O(MAX)##
    fac[0] = fac[1] = 1; // x!
    finv[0] = finv[1] = 1; // (x!)^-1
    inv[1] = 1; //x^-1
    for(int i=2;i<MAX;i++){
        fac[i] = (fac[i-1] * i) % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

long long Combination(int n, int k){ //calc nCk, ##O(1)##
    if(n<k || (n<0||k<0))return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    if((x+y)%3!=0){
        printf("0\n");
        return 0;
    }
    int n=(x+y)/3;
    x-=n;
    y-=n;
    Com_init();
    printf("%lld\n",Combination(x+y,x));
}

Measured memory_bytes: 23680
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int A, B; cin >> A >> B;
  if(A>9 || B>9){
    cout << -1 << endl;
  }
  else cout << A*B << endl;
  return 0;
}


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

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  int a[n+1] = {};
  int grid[n+1] = {};
  for(int i = 0; i < m; i++){
    cin >> a[i];
    grid[a[i]] = 1;
  }
  int sum1 = 0, sum2 = 0;
  for(int i = x; i <= n; i++) sum1 += grid[i];
  for(int i = x; i >= 0; i--) sum2 += grid[i];
  cout << min(sum1, sum2) << endl;
  return 0;
}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << min({ abs(A - B) + abs(B - C), abs(A - B) + abs(A - C), abs(B - C) + abs(A - C) }) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N=50000;
const int MAX_M=20;

int d[MAX_M];
int dp[MAX_M+1][MAX_N+1];
int n,m;

void solve(){
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
                      if(j==0){
                            dp[i][j]=0;
                              }
                                if(i!=0){           
                       if(j<d[i-1]){
				dp[i][j]=dp[i-1][j];
			}
			else{
				dp[i][j]=min(dp[i-1][j],dp[i][j-d[i-1]]+1);
			}
}
		}

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

memset(dp,10000,sizeof(dp));
	solve();

	printf("%d\n",dp[m][n]);
	return 0;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll c[9];
int main(){
ll n;
cin >>n;
ll a[n];
for(ll i=0;i<n;i++) {
  cin >>a[i];
  if(1<=a[i]&&a[i]<=399) c[0]++;
  else if(a[i]<800) c[1]++;
  else if(a[i]<1200) c[2]++;
  else if(a[i]<1600) c[3]++;
  else if(a[i]<2000) c[4]++;
  else if(a[i]<2400) c[5]++;
  else if(a[i]<2800) c[6]++;
  else if(a[i]<3200) c[7]++;
  else c[8]++;
}
ll ans=0,ma=0;
for(ll i=0;i<9;i++){
  if(i==8){
    if(c[i]>0) {
      if(ans==0){
        ans=1;
        ma=c[i];
      }
      else ma=ans+c[i];
    }
    else ma=ans;
  }
  else if(c[i]>0) ans++;
}
cout <<ans<<" "<<ma<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = (ll)1e7;
ll sieve[N];
void buildSieve(ll n) {
    for (ll x = 1; x <= n; x++)
            for (ll u = x; u <= n; u += x)
                sieve[u]++;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, ans = 0;
  cin >> n;
  buildSieve(n);
  for(int i=1; i<=n; i++)
    ans += (i*(sieve[i]));
  cout << ans;
  return 0;
}



Measured memory_bytes: 81744
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    scanf("%d",&K);
    if(K<1||K>32)  return 0;
    else
        printf("%d",a[K-1]);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int N;
	cin >> N;
	set<string> Sa;
	string s;
	for (int i = 0; i < N; i++) {
		cin >> s;
		Sa.insert(s);
	}
	cout <<  Sa.size() << endl;
}

Measured memory_bytes: 19260
N, MOD = int(input()), 10**9 + 7
memo = [{} for x in range(N + 1)]
def ok(last4):
  for i in range(4):
    t = list(last4)
    if i >= 1:
      t[i-1], t[i] = t[i], t[i-1]
    if ''.join(t).count('AGC') >= 1:
      return False
  return True

def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == N:
    return 1
  ret = 0
  for c in 'ACGT':
    if ok(last3 + c):
      ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
  memo[cur][last3] = ret
  return ret

print(dfs(0, 'TTT'))


Measured memory_bytes: 3872
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int a=in.nextInt(),b=in.nextInt(),c=in.nextInt();
		int res=0;
		for(int i=a;i<=b;i++) {
			if(c%i==0)res++;
		}
		out.println(res);
		out.flush();
	}

}



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


using ll = long long;
const int Mod = 1e9+7;
const int MaxN = 1e5+10;
int N, K;
ll f[MaxN];


ll powmod(ll a, ll b, ll m)
{
    ll c = 1;
    for (; b; b >>= 1, a = (ll)a * a % m) {
        if (b & 1)
            c = c * a % m;
    }
    return c;
}


void solve()
{
    f[1] = 1;
    for (int k = 2; k <= K; k++) {
        ll t = powmod(k, N, Mod);
        int ksqrt = (int)sqrt((long double)k + 0.5);
        for (int i = 2; i <= ksqrt; i++) {
            t -= f[k / i];
            if (t < 0)
                t += Mod;
        }
        int xmax = k / (ksqrt + 1);
        for (int x = 1; x <= xmax; x++) {
            int c = k / x - k / (x+1);
            t = ((t - c * f[x]) % Mod + Mod) % Mod;
        }
        f[k] = t;
    }

    ll s = 0;
    for (int g = 1; g <= K; g++)
        s = (s + g * f[K/g]) % Mod;
    cout << s << endl;
}


int main()
{
    cin >> N >> K;
    solve();
    return 0;
}


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

// ------ disjoint set ------ //
struct UnionFind {
    vector<int> data;
    int __size;
    UnionFind(int size) : data(size, -1), __size(size) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) != (y = root(y))) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x; __size--;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return __size; }
};

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> lang(m);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        while (k--) {
            int l; cin >> l; l--;
            lang[l].push_back(i);
        }
    }
    UnionFind uf(n);
    for (int l = 0; l < m; l++) {
        vector<int> &cur = lang[l];
        sort(cur.begin(), cur.end());
        for (int i = 0; i + 1 < cur.size(); i++) {
            uf.unionSet(cur[i], cur[i + 1]);
        }
    }
    if (uf.size() == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

int main(){
    int a,b;
    char o[1];
    for (;;) {
        scanf("%d %c %d",&a,o,&b);
        if (o[0]=='?') break;
        if (o[0]=='+') printf("%d\n",a+b);
        else if (o[0]=='-') printf("%d\n",a-b);
        else if (o[0]=='*') printf("%d\n",a*b);
        else if (o[0]=='/') printf("%d\n",a/b);
    }
    return 0;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>

using namespace std;

using ll = long long;

ll solve(vector<ll> &v, int l, int r, int k) {
  vector<ll> v2;
  if (l + r >= v.size()) {
    copy(v.begin(), v.end(), back_inserter(v2));
  } else {
    copy(v.begin(), v.begin() + l, back_inserter(v2));
    copy(v.rbegin(), v.rbegin() + r, back_inserter(v2));
  }

  sort(v2.begin(), v2.end());

  ll ans = 0;
  for (int i = 0; i < v2.size(); ++i) {
    if (i < k - (l + r) && v2[i] < 0) {
      continue;
    }

    ans += v2[i];
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  vector<ll> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }

  ll ans = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k - i; ++j) {
      ans = max(ans, solve(v, i, j, k));
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>

#define PI 3.14159265359
using namespace std;
int main(){
    int a;
    int b;
    int min = 1000001;
    int max = -1000001;
    long sum = 0;
    cin >> a;
    for(int i = 0 ; i < a ; i++ )
    {
        cin >> b;
        if(b < min) min = b;
        if(b > max) max = b;
        sum += b;
    }
    cout << min << " " << max << " " <<sum<<endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
	int N;
	cin >> N;
	if(N/100 == N%10){
	    cout << "Yes" << endl;
	}else{
	    cout << "No" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	vi v;
	v.resize(n);
	REP(i, n)
	{
		cin >> v[i];
	}
	sort(ALL(v));
	REP(i, n)
	{
		sum += v[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	} else {
		REP(i, n)
		{
			if (v[i] % 10 != 0) {
				sum -= v[i];
			}
			if (sum % 10 != 0) {
				cout << sum << endl;
				return 0;
			}
			if (i == n - 1) {
				cout << 0 << 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;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);
    ll sum = 0;
    rep(i, n) sum += a.at(i);
    ll x = 0;
    int k = 0;
    rep(i, n) {
        x += a.at(i);
        if (sum - 2 * x < 0) {
            k = i;
            break;
        }
    }
    ll ans = x - (sum - x);
    x -= a.at(k);
    ans = min(ans, abs(x - (sum - x)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840