akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b < c || a > d)
        cout << '0' << endl;
    else 
        cout << min(b, d) - max(a, c) << 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; cin >> n;
  vector<ll> a(n);
for(int i = 0; i < n; ++i)cin >> a[i];
int ans = 0;
while (true){
bool f = true;
for(int i = 0; i < n; ++i){
if(a[i]%2==0){a[i]/= 2;}
else{f = false;break;}
}
if(f)++ans;
else break;
}
cout << ans << endl;
}


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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int n,a,b,pt,pA,pB,pC;
  
  cin >> n >> a >> b;
  pA = pB = pC = 0;
  for (int i=0; i<n; i++){
    cin >> pt;
    if (pt <= a) pA++;
    else if (pt <= b) pB++;
    else pC++;
  }
  cout << MIN(MIN(pA,pB),pC) << 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;

#define AND 0
#define OR  1

bool check(vector<vector<int>> A,vector<int> s,vector<int> t,vector<int> u,vector<int> v){
	int n=A.size();
	rep(i,n){
		int z;
		if(s[i]==AND){
			z=1;
			rep(j,n) z&=A[i][j];
		}
		else{
			z=0;
			rep(j,n) z|=A[i][j];
		}
		if(z!=u[i]) return false;
	}
	rep(j,n){
		int z;
		if(t[j]==AND){
			z=1;
			rep(i,n) z&=A[i][j];
		}
		else{
			z=0;
			rep(i,n) z|=A[i][j];
		}
		if(z!=v[j]) return false;
	}
	return true;
}

pair<bool,vector<vector<int>>> solve(int n,vector<int> s,vector<int> t,vector<int> u,vector<int> v){
	vector<vector<int>> res(n,vector<int>(n,-1));

	vector<int> R,C;
	int s0=0,s1=0,t0=0,t1=0;
	rep(i,n){
		if(s[i]==AND && u[i]==1){
			rep(j,n) res[i][j]=1;
			s1++;
		}
		else if(s[i]==OR && u[i]==0){
			rep(j,n) res[i][j]=0;
			s0++;
		}
		else R.emplace_back(i);
	}
	rep(j,n){
		if(t[j]==AND && v[j]==1){
			rep(i,n) res[i][j]=1;
			t1++;
		}
		else if(t[j]==OR && v[j]==0){
			rep(i,n) res[i][j]=0;
			t0++;
		}
		else C.emplace_back(j);
	}
	if((s0>0 && t1>0) || (s1>0 && t0>0)) return {false,{}};

	if(R.size()==1){
		int x=u[R[0]];
		rep(j,C.size()){
			if((v[C[j]]==0 && s0>0) || (v[C[j]]==1 && s1>0)) res[R[0]][C[j]]=x;
			else                                             res[R[0]][C[j]]=v[C[j]];
		}
	}
	else if(C.size()==1){
		int x=v[C[0]];
		rep(i,R.size()){
			if((u[R[i]]==0 && t0>0) || (u[R[i]]==1 && t1>0)) res[R[i]][C[0]]=x;
			else                                             res[R[i]][C[0]]=u[R[i]];
		}
	}
	else if(R.size()>=2 && C.size()>=2){
		rep(i,R.size()) rep(j,C.size()) res[R[i]][C[j]]=(i+j)%2;
	}
	return {check(res,s,t,u,v),res};
}

int main(){
	int n; scanf("%d",&n);
	vector<int> s(n),t(n);
	vector<unsigned long long> u(n),v(n);
	rep(i,n) scanf("%d",&s[i]);
	rep(j,n) scanf("%d",&t[j]);
	rep(i,n) scanf("%llu",&u[i]);
	rep(j,n) scanf("%llu",&v[j]);

	unsigned long long ans[500][500]={};
	rep(b,64){
		vector<int> u2(n),v2(n);
		rep(i,n){
			u2[i]=u[i]>>b&1;
			v2[i]=v[i]>>b&1;
		}
		auto tmp=solve(n,s,t,u2,v2);
		if(!tmp.first) return puts("-1"),0;
		rep(i,n) rep(j,n) if(tmp.second[i][j]==1) ans[i][j]+=1ULL<<b;
	}
	rep(i,n) rep(j,n) printf("%llu%c",ans[i][j],j<n-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 8620
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

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

  int n;
  cin >> n;

  string s,t;
  cin >> s >> t;

  rep(i,n) {
    cout << s[i];
    cout << t[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double m = sc.nextDouble();
		List<Integer> nums = new ArrayList<>();
		int sum = 0;
		for(int i = 0; i < n; i++) {
			int temp = sc.nextInt();
			nums.add(temp);
			sum += temp;
		}
		
		double base = sum / (4 * m);
		int canChoose = 0;
		
		for(int num : nums) {
			if(base <= num) {
				canChoose++;
			}
		}

		if(m <= canChoose) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
		
	}
	
}

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

int main() {
 int N;
 cin >> N;
 vector <int> szamook;
 int seged;
 for(int i=0;i<N;i++){
   cin >> seged;
   szamook.push_back(seged);
 }
 seged=0;
 for(int i=0;i<szamook.size()-1;i++){
   for(int j=i+1;j<szamook.size();j++){
     seged+=szamook[i]*szamook[j];
   }
 }
 cout << seged;
	return 0;
}


Measured memory_bytes: 3612
#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>;

vector<int> to[100005];
vector<bool> seen;

void dfs (int root) {
  // if (seen[root]) return;
  seen[root] = true;
  for (auto x : to[root]) {
    if (seen[x]) continue;
    dfs(x);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  seen.assign(n,false);
  int cnt = 0;
  rep(i,n) {
    if (seen[i]) continue;
    dfs(i);
    cnt++;
  }
  int ans = cnt - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9592
#include<bits/stdc++.h>
#define int ll
//{ PXH612
using namespace std;
#define ll long long
#define db double
#define pp pair<int,int>
#define x first
#define y second

#define false(x) if(!(x))
template<typename A,typename B>bool Min(A &a,B b){if(a<=b) return 0;a=b;return 1;}
template<typename A,typename B>bool Max(A &a,B b){if(a>=b) return 0;a=b;return 1;}
#define in ({ll x=0;int o=0,c=char(),t=0;for(;!isdigit(c)&&t<1000;c=getchar(),t++) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})

#define FOR(i,a,b) for(int i=a,ENDFOR=b;i<=ENDFOR;i++)
#define ROF(i,a,b) for(int i=b,ENDFOR=a;ENDFOR<=i;i--)
#define RR(x,a,b) {cout<<#x<<": ";FOR(_,a,b) cout<<x[_]<<" ";cout<<"\n";}
#define rr(x) " "<<#x<<'='<<(x)<<" "

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define vn(a) (int)a.size()-1

#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define mu(x) (1ll<<x)
#define bitnum(x) __builtin_popcountll(x)

#define segg(a,b) (abs(a-b)+1)
#define midd(a,b) (a+(b-(a))/2)
#define mems(x,a) memset(x,a,sizeof x)
#define open(a) freopen(a,"r",stdin)
#define shut(b) freopen(b,"w",stdout)
//}/////////////////////////////////////////////////////}

const int N=2e5+5;
int n,k,s;
main()
{
   // open("robot.inp");
    n=in,k=in,s=in;
    if(s==1)
    {
        FOR(i,1,k) cout<<1<<" ";
        FOR(i,k+1,n) cout<<2<<" ";
        return 0;
    }
    FOR(i,1,k) cout<<s<<" ";
    FOR(i,k+1,n) cout<<s-1<<" ";
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;
    int a[n], b[n], c[n];

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

    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);

    int dp[n] = {};
    int js = 0;
    int jtemp = 0;
    for(int i=0; i<n; i++){
        for(int j=js; j<n; j++){
            if(b[i] < c[j]){
                dp[i] = n - j;
                // cout << i << " " << dp[i] << endl;
                break;
            }
            else{
                jtemp++;
            }
        }
        js = jtemp;
    }

    ll sdp[n+1] = {};
    for(int i=1; i<=n; i++){
        sdp[i] += sdp[i-1] + dp[i-1];
        // cout << sdp[i] << endl;
    }

    ll cnt = 0;
    js = 0;
    jtemp = 0;
    for(int i=0; i<n; i++){
        for(int j=js; j<n; j++){
            if(a[i] < b[j]){
                cnt += sdp[n] - sdp[j];
                break;;
            }
            else{
                jtemp++;
            }
        }
        js = jtemp;
    }

    cout << cnt;


    

    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int prime(int x);

int main (){
  int i,n,a[10001],count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    count+=prime(a[i]);
  }
  printf("%d\n",count);
  return 0;
}

int prime(int x){
  int i;
  if(x==2)return 1;
  else if(x%2==0||x==1)return 0;

  for(i=3;i*i<x+1;i++){
    if(x%i==0)return 0;
  }
  return 1;
}


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


struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}//-1で初期化
  int root(int x) {
    if (d[x] < 0) return x;//rootを負にする（構成node数x(-1))
    //root以外は親の番号
    return d[x] = root(d[x]);
    //return(root(d[x]))とするとメモできないが上の書き方だとメモができる
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    //swapすることで小さい方を大きい方につけられ計算量減らせる
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  //同じグループ化
  int size(int x) { return -d[root(x)];}
  //グループのnode数
    int group_num(int n){
        set<int> s;
        for(int i = 0; i < n; ++i){
            s.insert(root(i));
        }
        return int(s.size());}
};

int deg[100005];
vector<int> to[100005];


int main(){
  ll n,k,l;
  cin>>n>>k>>l;
  map<P,int>mp;
  vector<int>v1[n];
  vector<int>v2[n];
  vector<int>r1(n);
  vector<int>r2(n);
  UnionFind uf1(n);
  UnionFind uf2(n);
  //UnionFind uf3(n);

  rep(i,k){
    ll p1,q1;cin>>p1>>q1;
    p1--;q1--;
    v1[p1].push_back(q1);
    v1[q1].push_back(p1);
    uf1.unite(p1,q1);
    uf1.unite(q1,p1);

  }
  rep(i,l){
    ll p1,q1;
    cin>>p1>>q1;
    p1--;q1--;
    v2[p1].push_back(q1);
    v2[q1].push_back(p1);
    uf2.unite(p1,q1);
    uf2.unite(q1,p1);
  }

  rep(i,n){
    r1[i]=uf1.root(i);
    r2[i]=uf2.root(i);
    mp[make_pair(r1[i],r2[i])]++;
  }
  vector<int>ans(n);
  /*
  for(auto t=mp.begin();t!=mp.end();t++){
    P p=t->first;
    ll now=t->second;
    ans[p.first]++;
    ans[p.second]++;
cout<<p.first<<" "<<p.second<<" "<<now<<endl;
  }
  */

  rep(i,n){
    ll ans;
    ans=mp[make_pair(r1[i],r2[i])];
    cout<<ans<<' ';
  }



}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

//credits ---> ksun48


ll modinv(ll a, ll m) {
    assert(m > 0);
    if (m == 1) return 0;
    a %= m;
    if (a < 0) a += m;
    assert(a != 0);
    if (a == 1) return 1;
    return m - modinv(m, a) * m / a;
}
 
template <int MOD_> struct modnum {
private:
    int v;
public:
    static const int MOD = MOD_;
 
    modnum() : v(0) {}
    modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
    explicit operator int () const { return v; }
    friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
    friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
    modnum operator ~ () const {
        modnum res;
        res.v = modinv(v, MOD);
        return res;
    }
 
    modnum& operator += (const modnum& o) {
        v += o.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }
    modnum& operator -= (const modnum& o) {
        v -= o.v;
        if (v < 0) v += MOD;
        return *this;
    }
    modnum& operator *= (const modnum& o) {
        v = int(ll(v) * ll(o.v) % MOD);
        return *this;
    }
    modnum& operator /= (const modnum& o) {
        return *this *= (~o);
    }
 
    friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
    friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
    friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
 
using num = modnum<int(1e9) + 7>;
 
vector<num> fact;
vector<num> ifact;
 
void init(){
    fact = {1};
    for(int i = 1; i < 100000; i++) fact.push_back(i * fact[i-1]);
    for(num x : fact) ifact.push_back(1 / x);	
}
 
num ncr(int n, int k){
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
}
 
num powmod(num x, int a){
    if(a == 0) return 1;
    if(a & 1) return x * powmod(x, a-1);
    return powmod(x * x, a/2);
}
 

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

    int n;
    cin >> n;
    num ans = powmod(10, n) - (powmod(9, n) + powmod(9, n) - powmod(8, n));
    cout << int(ans) << endl;

    time_taken();
    return 0;
}

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


int main()
{
    std::string s;
    std::cin >> s;
    int i = 0, j = s.size() - 1;
    while(s[i] != 'A')i++;
    while(s[j] != 'Z')j--;
    std::cout << j - i + 1 << std::endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int A[N];
    int ans = 0;
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    sort(A,A+N,greater<int>());
    for(int i = 0;i < N;i++){
        ans += (i & 1 ? -A[i] : A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
L=$(awk '{print $1,($1-1)%10}'|sort -k2|cut -d' ' -f1)
X=$(echo $L|cut -d' ' -f1)
Y=$(echo $L|cut -d' ' -f2-|tr ' ' '\n'|awk '{sum+=int(($1+9)/10)*10} END {print sum}')
echo $(($X+$Y))

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n,sum=0;
	cin >> n;
	string str = to_string(n);
	for (int i = 0; i < str.size(); i++) {
		sum += str[i]-'0';
	}
	cout << ((n%sum) ? ("No") : ("Yes")) << endl;
}


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

int main(){
  map<char, int>m;
  string s;
  cin >> s;
  for(int i=0; i<4; i++)m[s[i]]++;
  if(m.size()==2 && m[s[0]]==2)cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<ll> cum(N+1);
    REP(i,N) cin >> A[i];
    sort(A.begin(), A.end());
    REP(i,N) cum[i+1] = cum[i] + A[i];

    auto check = [&](ll m){
        ll cnt = 0;
        REP(i,N) cnt += A.end() - lower_bound(A.begin(), A.end(), m - A[i]);
        return cnt >= M;
    };

    ll l = 0, r = LINF;
    while(r - l > 1){
        ll m = (l + r) >> 1;
        if(check(m)) l = m;
        else r = m;
    }

    ll ans = 0, cnt = 0;
    REP(i,N){
        int cur = lower_bound(A.begin(), A.end(), r - A[i]) - A.begin();
        ans += cum[N] - cum[cur] + A[i] * (N - cur);
        cnt += N - cur;
    }
    if(cnt < M) ans += (M - cnt) * l;
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll n, k; cin >> n >> k;

    if(k%2==1){
        ll tmp = n/k;
        cout << (ll)pow(tmp, 3) << endl;
    }
    else{
        ll tmp = n/k;
        ll cnt = 0;
        for(int i=1; i<=n; i++){
            if(i%k==(k/2)) cnt++;
        }

        cout << (ll)(pow(tmp, 3) + pow(cnt, 3)) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
 
namespace workspace{
  class Test{
    static void Main(){
        var ansAC = 0;
        var ansWA = 0;
        var ansTLE = 0;
        var ansRE = 0;
        int N = Int32.Parse(Console.ReadLine());
        for(int i = 0; i < N ; i++){
          var S = Console.ReadLine();
          if(S == "AC"){
            ansAC++;
          }else if(S == "WA"){
            ansWA++;
          }else if(S == "TLE"){
            ansTLE++;
          }else{
            ansRE++;
          }
        }
        Console.WriteLine($"AC x {ansAC}");
        Console.WriteLine($"WA x {ansWA}");
        Console.WriteLine($"TLE x {ansTLE}");
        Console.WriteLine($"RE x {ansRE}");
      }
    }
  }

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

using namespace std;
int a,b,c,x;

int main(void) {
    cin >> a >> b >> c;
    x = max(a,b);
    x = max(x,c);
    if((a+b+c)%2 == x%2) cout << (x*3-(a+b+c))/2 << "\n";
    else cout << ((x+1)*3-(a+b+c))/2 << "\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[7]:


N,M = map(int, input().split())
lr = []
l_max = 1
r_min = N
for _ in range(M):
    lr.append(list(map(int, input().split())))
    l_max = max(l_max, lr[-1][0])
    r_min = min(r_min, lr[-1][1])

print(max(0, r_min - l_max +1))


# In[ ]:






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

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> p(N);
  for(int i = 0; i < N; i++) cin >> p[i];
  sort(p.begin(), p.end());
  
  int sum = 0;
  for(int i = 0; i < K; i++) sum += p[i];
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#define INF (1 << 30)
using namespace std;

int main() {
    int N, A_sum, B_sum, min_sum = INF, A, B;
    cin >> N;
    for (int i = 1; i <= N - 1; i++) {
        A = i;
        B = N - A;
        A_sum = B_sum = 0;
        while (A) {
            A_sum += A % 10;
            A /= 10;
        }
        while (B) {
            B_sum += B % 10;
            B /= 10;
        }
        min_sum = min(min_sum, A_sum + B_sum);
    }
    cout << min_sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1007;
const int mod = 1e9 + 7;
inline int add(int x, int y){int res = x + y; if (res >= mod) res -= mod; return res;}
int dp[MAXN][MAXN];
char s[MAXN][MAXN];
int main()
{
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf(" %s", s[i] + 1);
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            if (s[i][j] == '#') continue;
            if (s[i - 1][j] == '.') dp[i][j] = add(dp[i][j], dp[i - 1][j]);
            if (s[i][j - 1] == '.') dp[i][j] = add(dp[i][j], dp[i][j - 1]);
        }
    printf("%d\n", dp[n][m]);
    return 0;
}

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

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            pass
        else:
            print('DENIED')
            exit()
else:
    print('APPROVED')


Measured memory_bytes: 38384
import collections
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A1 = collections.Counter(A)
B1 = collections.Counter(B)
A2 = A1.most_common()
B2 = B1.most_common()

if A2[0][0] == B2[0][0]:
  if min(A2[0][1], B2[0][1]) > int(N / 2):
    print("No")
    quit()

B.reverse()    
s = 0
t = N - 1
for i in range(N):
  if A[i] == B[i]:
    if (A[s] != B[i]) and (A[i] != B[s]):
      x = B[s]
      B[s] = B[i]
      B[i] = x
      s += 1
    elif (A[t] != B[i]) and (A[i] != B[t]) :
      x = B[t]
      B[t] = B[i]
      B[i] = x
      t -= 1
    else:
      print("No")
      quit()
  
#print(B)  
print("Yes")  
for i in range(N):
  print(B[i], end = " ")
print("")

  
    


Measured memory_bytes: 143808
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        int ans = 0;
        if(n <= 99){
            ans = (int)(Math.pow(100 , d) * n);
        }else{
            ans = (int)(Math.pow(100 , d) * 101);
        }
        System.out.println(ans);
    }
}


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

using namespace std;

int to_num(char c)
{
    if (isdigit(c)) {
        return c - '0';
    } else if (isupper(c)) {
        return c - 'A' + 10;
    } else {
        return c - 'a' + 36;
    }
}

int change(int p, string m)
{
    int res = 0;
    reverse(m.begin(), m.end());
    for (int i = 0; i < (int)m.size(); i++) {
        res += to_num(m[i]) * pow(p, i);
    }
    return res;
}

int main()
{
    int N, p, x = 0;
    string m;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> p >> m;
        x ^= change(p, m);
    }
    cout << (x != 0 ? "win" : "lose") << endl;
    return 0;
}

Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W;
    cin >> H >> W;
    vector<string> G(H+2);
    for(int i=1; i<=H; i++){
         cin >> G[i];
         G[i] = "#" + G[i];
    }
    vector<vector<bool>> ok(H+2,vector<bool> (W+2,true));
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            if(G[i][j] == 'x'){
                ok[i][j] = false;
                for(int k=0; k<8; k++){
                    ok[i+dy[k]][j+dx[k]] = false;
                }
            }else if(G[i][j] == 'o'){
                for(int k=-1; k<=1; k++){
                    ok[i][j+k] = false;
                }
            }
        }
    }
    int cnt = 0;
    for(int i=2; i<=H; i++){
        for(int j=1; j<=W; j++){
            cnt += ok[i][j];            
        }
    }
    cout << cnt << "\n";
    return 0;
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 5 and b == 5 and c == 7 ||
        a == 5 and b == 7 and c == 5 ||
        a == 7 and b == 5 and c == 5)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
def B_Theater():
    groups = []
    try:
        LOCAL_FLAG
        # N = 1
        # groups = [[24, 30]]
        N = 2
        groups = [[6, 8], [3, 3]]
    except NameError:
        N = int(input())
        for i in range(N):
            groups.append(list(map(int, input().split())))

    total = 0
    for i in range(N):
        total += groups[i][1] - groups[i][0] + 1
    print(total)

B_Theater()

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

int main(void){
    int a, b, ans = 0;
    cin >> a >> b;
    ans = b;
    
    for(int i=0; i<(a-1); i++){
        ans *= (b-1);
    }
    cout << ans << endl;

    return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;

int main() {
  ll N, K;
  cin >> N >> K;

  vector<ll> dist(N);
  for (ll i = 0; i < N; i++) {
    ll d;
    cin >> d;
    dist[i] = d - 1;
  }

  ll curr = 0;
  vector<bool> visited(N, false);
  visited[curr] = true;

  ll first, last;
  ll pre = -1;
  for (ll i = 0; i < N + 1; i++) {
    ll next = dist[curr];

    if (visited[next]) {
      first = next;
      last = curr;
      break;
    }
    curr = next;
    visited[curr] = true;
  }


  curr = 0;
  ll first_cnt, last_cnt;
  for (ll i = 0; i < N; i++) {
    if (curr == first) {
      first_cnt = i + 1;
      break;
    }
    curr = dist[curr];
  }

  curr = 0;
  for (ll i = 0; i < N; i++) {
    if (curr == last) {
      last_cnt = i + 1;
      break;
    }
    curr = dist[curr];
  }

  if (K <= last_cnt) {
    ll ans = 0;
    for (ll i = 0; i < K; i++) {
      ans = dist[ans];
    }
    cout << (ans + 1) << endl;
  } else {
    ll ans = 0;
    for (ll i = 0; i < first_cnt - 1; i++) {
      ans = dist[ans];
    }
    ll loop = (K - first_cnt + 1) % (last_cnt - first_cnt + 1);
    for (ll i = 0; i < loop; i++)
    {
      ans = dist[ans];
    }
    cout << (ans + 1)<< endl;
  }
}

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007
#define sz(a) a.size()

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n; cin>>n;
	if(n==4 || n==6 || n==9 || n==10 || n==14 || n==21 || n==22 || n==25 || n==26) cout <<"2";
	else if(n==8 || n==12 || n==18 || n==20 || n==27) cout <<"5";
	else if(n==16) cout <<"14";
	else if(n==32) cout <<"51";
	else if(n==24) cout<<"15";
	else if(n==28 || n==30 )cout<<"4";
	else cout <<"1";
	
	return 0;
}

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

using namespace std;

int main() {
int n, m;
cin >> n >> m;
vector<int> c(n+1, 0);
int a, b;
for (int i = 0; i < m; i++) {
cin >> a >> b;
c[a]++;
c[b]++;
}
for (int i = 0; i < n; i++) {
cout << c[i+1] << endl;
}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S; string T;
  cin>>S>>T;
  int K=0;
  int L=S.size();
  if(S==T)
    K++;
  for(int i=0; i<L-1; i++){
    S=S.back()+S.substr(0,S.size()-1);
   if(S==T)
     K++;
    else continue;
  }
  if(K==0)
    cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3596
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll x,y,z;
    cin >> x >> y >> z;
    cout << z << endl;
    cout << x << endl;
    cout << y << endl;
}

Measured memory_bytes: 256
#import <stdio.h>
#import <stdlib.h>

int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

// 昇順に並んだ values の中で searchValue を 左から探したときに初めて上回る(order>0) / 右から探したときに初めて下回る(order<0) ような index を探す（ない場合は -1 を返す）
int binary_search(int searchValue, int *values, int minIndex, int maxIndex, int order) {
    int midIndex = (minIndex + maxIndex)/2;
    int midValue = values[midIndex];
    int maxValue = values[maxIndex];
    if (minIndex == midIndex) { // 区間の長さが2になったとき
        if (order > 0) {
            if (searchValue < midValue) { // 左がサーチ値を上回るなら左
                return midIndex;
            }
            if (searchValue < maxValue) { // 左がサーチ値以下かつ右がサーチ値を上回るなら右
                return maxIndex;
            }
        } else {
            if (searchValue > maxValue) { // 右がサーチ値を下回るなら右
                return maxIndex;
            }
            if (searchValue > midValue) { // 右がサーチ値以上かつ左がサーチ値を下回るなら左
                return midIndex;
            }
        }
        return -1; // 区間の長さが2のとき両端とも条件を満たさないなら存在しない
    }
    if (order > 0) {
        if (midValue <= searchValue) { // 中央での値がまだ上回っていないなら右半分
            return binary_search(searchValue, values, midIndex, maxIndex, order);
        } else {
            return binary_search(searchValue, values, minIndex, midIndex, order);
        }
    } else {
        if (midValue >= searchValue) { // 中央での値がまだ下回っていないなら左半分
            return binary_search(searchValue, values, minIndex, midIndex, order);
        } else {
            return binary_search(searchValue, values, midIndex, maxIndex, order);
        }
    }
}

int main(){
    int N;
    scanf("%d", &N);
    int A[200000] = {0};
    int B[200000] = {0};
    int C[200000] = {0};
    for(int i=0;i<N;i++){
        int a;
        scanf("%d", &a);
        A[i] = a;
    }
    for(int i=0;i<N;i++){
        int b;
        scanf("%d", &b);
        B[i] = b;
    }
    for(int i=0;i<N;i++){
        int c;
        scanf("%d", &c);
        C[i] = c;
    }
    qsort(A, N, sizeof(int), compare_int);
    qsort(C, N, sizeof(int), compare_int);
    if (N==1) {
        puts((A[0]<B[0] && B[0]<C[0]) ? "1" : "0");
        return 0;
    }
    long long count = 0;
    for(int j=0;j<N;j++){
        int b = B[j];
        int i = binary_search(b,A,0,N-1,-1);
        int k = binary_search(b,C,0,N-1,1);
        if (i>=0 && k>=0) {
            count += (long long)(i+1)*(N-k);
        }
    }
    printf("%lld",count);
}


Measured memory_bytes: 4860
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    cout << (a+b)*(c/2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
//#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//typedef tuple<int, int, int> tiii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775808;

int main() {
    int a, b;
    cin >> a >> b;
    int sq = a * b;
    int li = 2 * a + 2 * b;
    cout << sq << " " << li << endl;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define inf 1<<29
using namespace std;

class State{
public:
  int n,bits;
  double time;
  State(int n,double time,int bits):n(n),time(time),bits(bits){}
  bool operator<(State s)const{
    return s.time<time;
  }
};

int main()
{
  int n,m,p,a,b,x,y,z;
  double T[10],map[35][35];
  double dp[35][(1<<9)+1];
  while(1){
    cin>>n>>m>>p>>a>>b;
    if(n==0)break;
    a--;b--;
    for(int i=0;i<n;i++)cin>>T[i];
    for(int i=0;i<31;i++){
      for(int j=0;j<31;j++)map[i][j]=-1;
      for(int j=0;j<(1<<9)+1;j++)dp[i][j]=inf;
    }
    for(int i=0;i<p;i++){
      cin>>x>>y>>z;
      x--;y--;
      map[x][y]=z;
      map[y][x]=z;
    }
    double ans=inf;
    queue<State> pq;
    pq.push(State(a,0,0));
    dp[a][0]=0;
    while(!pq.empty()){
      State u=pq.front();
      pq.pop();
      //cout<<u.time<<endl;
      if(dp[u.n][u.bits]<u.time)continue;

      if(u.n==b){
	ans=min(ans,u.time);
	continue;
      }
      for(int i=0;i<m;i++){
	if(map[u.n][i]==-1)continue;
	for(int j=0;j<n;j++){
	  if(u.bits&(1<<j))continue;
	  double time=(u.time+map[u.n][i]/T[j]);
	  int v=u.bits|(1<<j);
          if(dp[i][v]>time){
	    dp[i][v]=time;
	    pq.push(State(i,time,v));
	  }
	}
      }
    }
    if(ans>=inf)cout<<"Impossible"<<endl;
    else printf("%.10f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1600
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
int n;
string s[105];
set<string> st;
char ss[105];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s",ss);
		s[i]=ss;
		if(st.count(s[i])){
			puts("No");
			return 0;
		}
		st.insert(s[i]);
	}
	for(int i=2;i<=n;i++){
		if(s[i][0]!=s[i-1][s[i-1].size()-1]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    set<int> s[n];

    for(int i = 0; i < n; i++)
    {
        int cnt;
        cin >> cnt;
        for(int j = 0; j < cnt; j++)
        {
            int x;
            cin >> x;
            s[i].insert(x);
        }
    }

    int res = m;
    for(int i = 1; i <= m; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(s[j].find(i) == s[j].end())
            {
                res--;
                break;
            }
        }
    }

    cout << res;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

condition = set()
for i in range(M):
    s, c = map(int, input().split())
    condition.add((s, c))

ans = float("inf")
if N == 1:
    for i in range(10):
        num = str(i)
        for s, c in condition:
            if num[s-1] != str(c):
                break
        else:
            print(i)
            exit()       
else:
    for i in range(10**(N-1), 10**N):
        num = str(i)
        for s, c in condition:
            if num[s-1] != str(c):
                break
        else:
            print(i)
            exit()
print(-1)

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace ABC121_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            long kan = nm[1];
            var hoge = Enumerable.Repeat(0, nm[0]).Select(x => Console.ReadLine().Split(' ').Select(long.Parse).ToList()).OrderBy(x => x[0]).ToList();
            long sum = 0;
            foreach(var ch in hoge)
            {
                sum += Math.Min(kan, ch[1]) * ch[0];
                kan -= Math.Min(kan, ch[1]);
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 31984
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define dbg(x) cout << #x"=" << x << endl; 
const int MAX_N = 550;
LL n,K;
LL A[MAX_N];
LL B[MAX_N];

bool check(int F){
    LL sum = 0;
    for(int i = 1; i <= n; ++i) {
        B[i] = A[i]%F;
        sum += B[i];
    }
    LL mn = 1 << 30;
    LL pre = 0;
    sort(B+1, B+1+n);
    for(int i = 1; i <= n; ++i){
        pre += B[i];
        mn = min(max(pre, (n-i)*F-(sum-pre)), mn);
    }
    return mn <= K;
}

int main(){ 
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> K;
    LL sum = 0;
    for(int i = 1; i <= n; ++i){
        cin >> A[i];
        sum += A[i];
    }
    int ans = 1;
    for(int i = 1; i <= sum/i; ++i){
        if(sum%i == 0){
            if(check(sum/i)){
                ans = sum/i;
                break;
            } else if(check(i)){
                ans = max(ans, i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    string s;
    string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    cin >> s;
    for(int i = 0; i<7; i++) {
        if(arr[i] == s) {
            cout << 6 - i+1 << endl;
            break;
        }
    }


    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc115 {

    class Program {
        /**
         * in
         *  25
         * out
         *  Christmas
         */
        main(inp:string) {
            const days :any= {
                '22': 'Christmas Eve Eve Eve',
                '23': 'Christmas Eve Eve',
                '24': 'Christmas Eve',
                '25': 'Christmas',
            };
            console.log(days[inp]);
        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}


Measured memory_bytes: 7372
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto t = readStr;
  auto s = t.replace("?", "D");

  writeln(s);
}


Measured memory_bytes: 3568
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>> 
#define pii pair<int,int> 
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);



int32_t 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 n,d; cin>>n>>d;
  d*=d; int cnt=0;
  f(i,0,n){
    int x,y; cin>>x>>y;
    x*=x; y*=y; x+=y;
    if(x<=d) ++cnt;
  }
  cout<<cnt;
  return 0; 
}
// check for overflows dummy !!!


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,y; cin>>n>>y;
	for(int i=0;i<=n;++i){
		for(int j=0;j<=n-i;++j){
			int k=n-i-j;
			if(i*10000+j*5000+k*1000==y){
				cout<<i<<" "s<<j<<" "s<<k<<"\n"s;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"s<<"\n"s;
}

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

int n,a;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==0){
            if(a%3==0||a%5==0){continue;
            }else {printf("DENIED\n"); return 0;}
        }
    }
    printf("APPROVED\n");
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int x[110000],y[110000];
vint G[110000];
int dfs(int from, int to) {
    int cur = 0;
    for (int i=0;i<G[to].size();i++){
      if(G[to][i]==from)continue;
      cur^=dfs(to,G[to][i])+1;
    }
    return cur;
}

signed main() {
  cin >> N;
  for(int i=0;i<N-1;i++){
    cin>>x[i]>>y[i];
    G[x[i]].push_back(y[i]);
    G[y[i]].push_back(x[i]);
  }
  if(dfs(0,1)!=0)cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
}


Measured memory_bytes: 13824
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n = int(input())
    h = list(map(int, input().split()))
    l = [[0]*100 for _ in range(100)]
    for i in range(len(h)):
        k = h[i]
        for q in range(k):
            l[i][q] = 1
    l = [list(x) for x in zip(*l)]
    ans = 0
    for i in l:
        flg = 0
        for g in i:
            if g == 1:
                if flg == 0:
                    ans += 1
                flg = 1
            if g == 0:
                flg = 0
    print(ans)


if __name__=="__main__":
    main()


Measured memory_bytes: 68888
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,s;
int l[505],r[505];
int cost[505][505];
int dp[505][501];
vector<int> tid;

int get_time(int a,int b,int l,int r){
	int va=min(b,r)-max(a,l);
	return max(0,va);
}

int main(void){
	scanf("%d%d",&n,&s);
	s--;
	for(int i=0;i<n;i++){
		scanf("%d%d",&l[i],&r[i]);
		tid.push_back(r[i]);
	}
	tid.push_back(0);
	sort(tid.begin(),tid.end());
	tid.erase(unique(tid.begin(),tid.end()),tid.end());

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&cost[i][j]);
		}
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
			}
		}
	}

	memset(dp,-1,sizeof(dp));
	dp[0][s]=0;
	for(int i=0;i+1<tid.size();i++){
		for(int j=0;j<n;j++){
			if(dp[i][j]<0)continue;
			//printf("%d %d %d\n",i,j,dp[i][j]);
			for(int k=0;k<n;k++){
				int nc=tid[i]+cost[j][k];
				if(nc>=tid.back())continue;
				int v=upper_bound(tid.begin(),tid.end(),nc)-tid.begin();
				//printf("%d->%d %d %d %d %d\n",j,k,nc,tid[v],l[k],r[k]);
				int val=get_time(nc,tid[v],l[k],r[k]);
				dp[v][k]=max(dp[v][k],dp[i][j]+val);
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,dp[tid.size()-1][i]);
	}
	printf("%d\n",ans);
	return 0;
} 


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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n,k;
	cin>>n>>k;
	vector<long long> v(n);
	for(long long i=0;i<n;i++) cin>>v.at(i);
	
	long long l=0;long long r=inf;
	while(r-l>1){
	    long long mid=(r+l)/2;
	    long long sum=0;
	    
	    for(auto a:v){
	        sum+=ceil((long double)a/mid)-1;
	    }
	    
	    if(sum>k){
	        l=mid;
	    }else{
	        r=mid;
	    }
	}
	
	cout<<r<<endl;
	
	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}





Measured memory_bytes: 4772
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long a, b, x;
	cin >> a >> b >> x;
	if(a==0) cout << b/x+1;
	else cout << b/x - (a-1)/x;
	return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  A2
//
//  Created by 汪之涛 on 16/10/7.
//  Copyright © 2016年 汪之涛. All rights reserved.
//

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

const int maxn = 100000+10;
int arr[maxn];

int main()
{
    int n;
    while(cin>>n)
    {
        memset(arr, 0, sizeof(arr));
        for(int i = 1; i <= n; ++i)
        {
            cin>>arr[i];
        }
        int res = 0;
        for(int i = 1; i <= n; ++i)
        {
            if(arr[arr[i]] == i)
            {
                arr[i] = 0;
                arr[arr[i]] = 0;
                res += 1;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int c[8]={-1,1,0,0,-1,-1,1,1};
int d[8]={0,0,-1,1,-1,1,-1,1};
char a[1001][1001];
int b[1001][1001];
int n,m;
void dfs(int x,int y)
{
	for(int i=0;i<=7;i++)
	{
		int t1=x+c[i];
		int t2=y+d[i];
		if(a[t1][t2]=='#')
		{
			b[x][y]++;
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	cin>>a[i][j];
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		dfs(i,j);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
 	 {
		if(a[i][j]=='#')
		cout<<a[i][j];
		else
		cout<<b[i][j];
	 }
	 cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<queue>
using namespace std;
int a,b,c,d;
int tot;
int main()
{
	cin>>a>>b>>c>>d;
	for(int i=0;i<=101;i++)
	{
		if(i>=a&&i<=b&&i>=c&&i<=d)tot++;
	}
	cout<<max(tot-1,0);
	return 0;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int s=0;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i],s+=a[i];
	int m;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		int p,x;
		cin>>p>>x;
		s=s-a[p]+x;
		printf("%d\n",s);
		s=s-x+a[p];
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m;
	cin >> n >> m;
	int cnt = 0;
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		if (a[i] & 1) {
			cnt++;
		}
	}
	if (cnt > 2) {
		cout << "Impossible\n";
		exit(0);
	}
	if (m == 1) {
		if (a[0] == 1) {
			cout << "1\n1\n1\n";
		}
		else {
			cout << a[0] << '\n' << 2 << '\n' << a[0] - 1 << ' ' << 1 << '\n';
		}
		exit(0);
	}
	else {
		vector<int> lol, kek;
		for (int i = 0; i < m; i++) {
			if (a[i] & 1) {
				kek.pb(a[i]);
			}
			else {
				lol.pb(a[i]);
			}
		}
		for (int i = 0; i < SZ(kek); i++) {
			if (i & 1) {
				lol.pb(kek[i]);
			}
			else {
				lol.insert(lol.begin(), kek[i]);
			}
		}
		for (auto it : lol) {
			cout << it << ' ';
		}
		cout << '\n';
		lol[0]--;
		if (lol[0] == 0) {
			lol.erase(lol.begin());
		}
		lol.back()++;
		cout << SZ(lol) << '\n';
		for (auto it : lol) {
			cout << it << ' ';
		}
		cout << '\n';
	}
}

Measured memory_bytes: 256