akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

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

int main()
{
    ll N;
    bitset<200020> X;
    cin >> N >> X;

    // popcount(X)を計算
    ll pc = 0;
    rep(0, i, N)
    {
        if (X.test(i))
        {
            pc++;
        }
    }

    ll pc1 = pc + 1, pc2 = pc - 1;

    // 前処理で2^n (mod popcount(X) + 1), 2^n (mod popcount(X) - 1)を求める
    vector<ll> pow2_mod1(200020, 0), pow2_mod2(200020, 0);
    for (ll i = 0; i <= 200000; i++)
    {
        if (i == 0)
        {
            pow2_mod1.at(i) = 1 % pc1;
            if (pc2 != 0)
            {
                pow2_mod2.at(i) = 1 % pc2;
            }
        }
        else
        {
            pow2_mod1.at(i) = (pow2_mod1.at(i - 1) * 2) % pc1;
            if (pc2 != 0)
            {
                pow2_mod2.at(i) = (pow2_mod2.at(i - 1) * 2) % pc2;
            }
        }
    }

    // 前処理で X (mod popcount(X) + 1), X (mod popcount(X) - 1)を求める
    ll X_mod1 = 0, X_mod2 = 0;
    for (ll i = 0; i < N; i++)
    {
        if (X.test(i))
        {
            X_mod1 += pow2_mod1.at(i);
            X_mod2 += pow2_mod2.at(i);
        }
    }

    // 研鑽部分本体
    for (ll i = N - 1; i >= 0; i--)
    {
        ll ans = 0;

        // そもそも操作が必要でない(つまりXi=0)のとき
        X.flip(i);
        if (!X.any())
        {
            X.flip(i);
            cout << 0 << endl;
            continue;
        }
        else
        {
            X.flip(i);
            ans++;
        }

        ll num;
        if (X.test(i))
        {
            // 1回目の操作の答え
            num = X_mod2;
            num = num + pc2 - pow2_mod2.at(i);
            num %= pc2;
        }
        else
        {
            // 1回目の操作の答え
            num = X_mod1;
            num = num + pow2_mod1.at(i);
            num %= pc1;
        }

        // 2回目以降は数値型に収まるので純粋に計算
        while (num > 0)
        {
            bitset<30> bit(num);
            pc = bit.count();
            num %= pc;
            ans++;
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 6336
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,c=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(i%2==1&&x%2==1)
        c++;
    }
    cout<<c;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>

int n;
int cnt[10001],cnt2[10001];;

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(cnt,0,sizeof(cnt));
		memset(cnt2,0,sizeof(cnt2));
		for(int i=1;i<n;i++){
			cnt[i*i%n]++;
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j)continue;
				if(cnt[i]>0 && cnt[j]>0){
					int a=i-j;
					if(a<0)a+=n;
					if(a>(n-1)/2)a=n-a;
					cnt2[a]++;
				}
			}
		}
		for(int i=1;i<=(n-1)/2;i++){
			printf("%d\n",cnt2[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<vector<lint>> dp1(n + 1, vector<lint>(t, 0));
    vector<vector<lint>> dp2(n + 1, vector<lint>(t, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
            dp2[i + 1][j] = max(dp2[i + 1][j], dp2[i][j]);
            if (j + a[i] < t) {
                dp1[i + 1][j + a[i]] =
                    max(dp1[i + 1][j + a[i]], dp1[i][j] + b[i]);
                dp2[i + 1][j + a[i]] =
                    max(dp2[i + 1][j + a[i]], dp2[i][j] + b[i]);
            }
            dp2[i + 1][j] = max(dp2[i + 1][j], dp1[i][j] + b[i]);
        }
    }
    lint ans = 0;
    for (int i = 0; i < t; i++) {
        ans = max(dp1[n][i], ans);
        ans = max(dp2[n][i], ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;} 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 
// ========================================================
signed main(){
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  #endif
  fio;
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
  rr;
}



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

#define int long long
const int INF = 1e18;

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

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

  vector<int> cum(n, 0);
  cum[0] = a[0];
  for ( int i = 1; i < n; i++ ) cum[i] = cum[i-1]+a[i];

  int ans = INF;
  for ( int i = 2; i < n-1; i++ ) {
    int a = lower_bound(cum.begin(), cum.end(), cum[i-1]/2) - cum.begin();
    int b = lower_bound(cum.begin(), cum.end(), cum[i-1]+(cum[n-1]-cum[i-1])/2) - cum.begin();
    //cout << a <<  " " << b << endl;
    if ( a != i-1 && b != i-1 ) {      
      int c = cum[a];
      int d = cum[i-1]-cum[a];
      int e = cum[b]-cum[i-1];
      int f = cum[n-1]-cum[b];
      ans = min(ans, max(c, max(d, max(e, f)))-min(c, min(d, min(e, f))));
    }    
    if ( a ) {
      int c = cum[a-1];
      int d = cum[i-1]-cum[a-1];
      int e = cum[b]-cum[i-1];
      int f = cum[n-1]-cum[b];
      ans = min(ans, max(c, max(d, max(e, f)))-min(c, min(d, min(e, f))));
    }
    if ( b > i-1 ) {      
      int c = cum[a];
      int d = cum[i-1]-cum[a];
      int e = cum[b-1]-cum[i-1];
      int f = cum[n-1]-cum[b-1];
      ans = min(ans, max(c, max(d, max(e, f)))-min(c, min(d, min(e, f))));
    }
    if ( a && b > i-1 ) {
      int c = cum[a-1];
      int d = cum[i-1]-cum[a-1];
      int e = cum[b-1]-cum[i-1];
      int f = cum[n-1]-cum[b-1];
      ans = min(ans, max(c, max(d, max(e, f)))-min(c, min(d, min(e, f))));
    }
    
  }

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


Measured memory_bytes: 3328
#include<cstdio>
#define ll long long 
#include<algorithm>
int n,a[25][25];
ll f[70050];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)scanf("%d",&a[i][j]);
	int lim=1<<n;
	for (int i=1;i<lim;i++)
		for (int j=1;j<=n;j++)if ((i&(1<<(j-1))))
			for (int k=j+1;k<=n;k++)if ((i&(1<<(k-1))))f[i]+=a[j][k];
	for (int i=1;i<lim;i++)
		for (int j=i;j;j=i&(j-1))f[i]=std::max(f[i],f[i-j]+f[j]);
	printf("%lld\n",f[lim-1]);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k, s;
	cin >> n >> k >> s;
	for(int i = 0; i < k; i++)
		cout << s << " ";
	for(int i = k; i < n; i++){
		if(s == 1000000000)
			cout << s - 1 << '\n';
		else
			cout << s + 1 << " ";
	}
	cout << '\n';


}

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

int main(void){

    vector<vector<int>> vec(3, vector<int>(3));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin>>vec[i][j];
        }
    }

    bool ok = false;

    for (int a = 0; a <= 100; ++a) {
        int b_0 = vec[0][0] - a, b_1 = vec[0][1] - a, b_2 = vec[0][2] - a,
                a_1 = vec[1][0] - b_0, a_2 = vec[2][0]-b_0;
        if (vec[1][1] == a_1 + b_1 && vec[1][2] == a_1 + b_2 && vec[2][1] == a_2 + b_1 && vec[2][2] == a_2 + b_2) {
            ok = true;
            break;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int A[10010], B[10010], diff[10010];
signed main() {
    int N; cin >> N;
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) cin >> B[i];

    int M = 0, pos = 0, neg = 0;
    rep(i,0,N) {
        diff[i] = A[i] - B[i];
        M += (-diff[i]);
        if(diff[i] > 0) pos += diff[i];
        else neg += (-diff[i]) / 2;
    }

    int X = neg - pos;
    if(pos < 0 || pos > M || X < 0 || X > M || M < 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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


int main() {
  ll N;
  cin >> N;
  for(ll i=ceil(sqrt(N)); i>1; i--){
    if (N%i == 0) {
      cout << i+(N/i)-2 << endl; return 0;
    }  
  }
  cout << N-1 << endl;
  return 0;
}
  

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

using namespace std;

int main() 
{
    int n, m, a, b, c;
    scanf("%d", &n);
    
    vector<int> v;
    
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &m);
        v.push_back(m);
    }
    
    scanf("%d", &m);
    
    for(int i = 0; i < m; i++)
    {
        scanf("%d %d %d", &a, &b, &c);
        
        int count = 0;
        
        for(int j = b-1; j >= a; j--)
            if(v[j] == c)
                count++;
                
        printf("%d\n", count);
    }
    
    return 0;
}


Measured memory_bytes: 3280
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void main(){

    int N;
    int[] arr = new int[100];
    string[] s;
    int count = 0;
    readf("%d\n",&N);
    s = split(readln());
    for(int i=0;i<N;i++){
	arr[i] = to!int(s[i]);
    }

    for(int i=0;i<N;i++){
	for(int j=N-1;j>0;j--){
	    if(arr[j] < arr[j-1]) {
		count++;
		swap(arr[j],arr[j-1]);
	    }
	}
    }

    write(arr[0]);
    for(int i=1;i<N;i++){
	writef(" %d",arr[i]);
    } 
    writeln();
    writeln(count);
}



Measured memory_bytes: 2532
package main

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

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	h, w := nextInt(), nextInt()
	ans := h * (((w + 2) / 3) - (w / 3))
	if (((h+2)/3)-(h/3))*w < ans {
		ans = (((h + 2) / 3) - (h / 3)) * w
	}
	for hi := 0; hi <= h; hi++ {
		blocks := []int{hi * ((w + 1) / 2), hi * (w / 2), (h - hi) * w}
		sort.Sort(sort.IntSlice(blocks))
		if blocks[2]-blocks[0] < ans {
			ans = blocks[2] - blocks[0]
		}
	}
	for wi := 0; wi <= w; wi++ {
		blocks := []int{((h + 1) / 2) * wi, (h / 2) * wi, h * (w - wi)}
		sort.Sort(sort.IntSlice(blocks))
		if blocks[2]-blocks[0] < ans {
			ans = blocks[2] - blocks[0]
		}
	}
	fmt.Println(ans)
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  long a; string b; cin >> a >> b;
  int c = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
  cout << a * c / 100;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using ld = long double; 
int INF = 1e9;

int main(){
  int n;cin >> n;
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  vector<int> bc(n),ab(n);
  int ind = 0;
  rep(i,n){
    while(b[i]>=c[ind]) {
      if(ind == n) break;
      ind++;
    }
    bc[i] = n-ind;
  }
  ind = 0;
  rep(i,n){
    while(a[i] >= b[ind]){
      if(ind == n) break;
      ind++;
    }
    ab[ind]++;
  }
  rep(i,n-1) ab[i+1] += ab[i];
  ll ans = 0;
  rep(i,n) ans += ll(ab[i])*ll(bc[i]);
  cout << ans << endl;

}

Measured memory_bytes: 5076
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;
  
  int s = 0;
  if (S[0] == T[0]) s+=1;
  if (S[1] == T[1]) s+=1;
  if (S[2] == T[2]) s+=1;

  cout << s << endl;
}

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

int main() {
	// your code goes here
  int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" ";
	if(a+b>n)cout<<abs(a+b-n);
	else cout<<0;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};

int pow(int x,int p)
{
  int res=1;
  while(p)
  {
    if(p&1)
    {
      res=(res*x)%mod;
    }
    p>>=1;
    x=(x*x)%mod;
  }
  return res;
}

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

 

int n;
cin>>n;

vector<int>v(n);  map<int,int>mp;


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

  int x=v[i];
  for(int j=2;j*j<=v[i]&&x>1;j++)
   {
     if(x%j==0)
     {
       int cnt=0;
       while(x%j==0)
       {
         cnt++; x/=j;
       }
       mp[j]=max(mp[j],cnt);
     }
   }
   if(x>1)mp[x]=max(mp[x],1ll);

}

int l=1;

for(auto i : mp)
{
  l=(l*pow(i.first,i.second))%mod;
}
int ans=0;
for(int i=0;i<n;i++)
{
   ans=(ans+(l*pow(v[i],mod-2))%mod)%mod;
}

cout<<ans<<"\n";
   
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main()
{
	int N, ans = 0;
	bool B[4];
	char S;

	rep(i, 4) B[i] = 0;

	cin >> N;
	rep(i, N) {
		cin >> S;
		if (S == 'P' && !B[0]) B[0] = 1;
		else if (S == 'W' && !B[1]) B[1] = 1;
		else if (S == 'G' && !B[2]) B[2] = 1;
		else if (S == 'Y' && !B[3]) B[3] = 1;
	}

	rep(i, 4) if (B[i]) ans++;
	if (ans == 3) cout << "Three" << endl;
	else cout << "Four" << endl;

	return 0;
}

Measured memory_bytes: 256
open Printf open Scanf
open Array

let si = string_of_int
let print_list f ls = List.iter (fun v -> printf "%s " @@ f v) ls
let pow n k =
  let rec f a n = function
  | 0 -> a | 1 -> n*a | k when k mod 2 = 0 -> f a (n*n) (k/2) | k -> f (a*n) (n*n) (k/2)
  in f 1 n k
let no () = print_int @@ -1

let () = scanf " %d %d" @@ fun m k ->
  let w = pow 2 m in
  if w <= k then no ()
  else if m=0 then (
    if k=0 then (
      print_list si [0;0]
    ) else no ()
  ) else if m=1 then (
    if k=0 then (
      print_list si [0;0;1;1]
    ) else no ()
  ) else (
    let ls =
      init w (fun i -> i)
      |> Array.to_list
      |> List.filter (fun v -> v <> k)
    in
    print_list si ls;
    printf "%d " k;
    print_list si @@ List.rev ls;
    printf "%d " k;
  )


Measured memory_bytes: 13184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
 
 
 
int main()
{
    string n;
    cin >> n;
    bool ans=false; 
    for(int i=0;i<2;i++)
    {
        if(n[i]==n[i+1]&&n[i+1]==n[i+2]) 
            ans = true;
    }
    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

const int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
//const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

void out(int a)
{
	if (a) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int h, w;
	cin >> h >> w;
	vs v(h);
	REP(i, h) cin >> v[i];
	int x = 0, y = 0;
	while (1)
	{
		v[x][y] = '.';
		REP(i, 2)
		{
			int nx = x + dx[i], ny = y + dy[i];
			if (!valid(nx, ny, h, w)) continue;
			if (v[nx][ny] == '#')
			{
				out(0);
				return 0;
			}
		}
		if (x == h - 1 && y == w - 1) break;
		if (x < h - 1 && y < w - 1 && v[x + 1][y] == '#' && v[x][y + 1] == '#')
		{
			out(0);
			return 0;
		}
		else if (x < h - 1 && v[x + 1][y] == '#')
		{
			x = x + 1, y = y;
			continue;
		}
		else if (y < w - 1 && v[x][y + 1] == '#')
		{
			x = x, y = y + 1;
			continue;
		}
		else assert(false);
	}
	out(1);
	return 0;
}

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

const int N_MAX = 100001;
const int M_MAX = 200000;

vector<pair<int,int>> graph[N_MAX];
int dist[N_MAX] = { 0 };
bool check[N_MAX] = { false };

void dfs(int p) {
	if (check[p])return;

	queue<pair<int,int>> q;
	q.push(make_pair(0,p));
	check[p] = true;

	while (!q.empty()) {
		pair<int,int> f = q.front(); q.pop();

		for (int j = 0; j < graph[f.second].size(); j++) {
			int v = graph[f.second][j].first;
			int d = graph[f.second][j].second;
			if (!check[v]) {
				check[v] = true;
				dist[v] = f.first + d;
				q.push(make_pair(f.first + d, v));
			}
		}
	}
}

int main() {
	int N, M;
	int L[M_MAX], R[M_MAX], D[M_MAX];

	

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i] >> D[i];
		graph[L[i]].push_back(make_pair(R[i], D[i]));
		graph[R[i]].push_back(make_pair(L[i], -D[i]));
	}

	for (int i = 0; i <= N; i++) {
		dfs(i);
	}

	bool f = true;
	for (int i = 0; i < M; i++) {
		int d = dist[R[i]] - dist[L[i]];
		if (D[i] != d) {
			f = false;
			break;
		}
	}

	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  int N; // 支払額
  int A; // 1円玉の枚数

  cin >> N >> A;
  
  if ( N % 500 <= A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題168

            int N = int.Parse(Console.ReadLine());

            if (N%10 == 3)
            {
                Console.WriteLine("bon");
            }
            else if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }

            
        }


    }
}


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

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

  int num = stoi(N);
  int sum = 0;
  string tmp;
  for (int i = 0; i < N.size(); i++)
  {
    tmp = {N.at(i)};
    sum += stoi(tmp);
  }
  
  if (num % sum == 0){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3608
// Problem : A - Rounding
// Contest : AtCoder Beginner Contest 130
// URL : https://atcoder.jp/contests/abc130/tasks/abc130_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <cmath>
#include <cstdio>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int a;
int b;

void input() {
  cin >> a >> b;
}

void solve1() {
  if (a < b) {
    cout << 0;
    
    exit(0);
  }
  
  cout << 10;
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  if(__builtin_ctz(n) + __builtin_clz(n) == 31) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  switch(n%4) {
    case 3:
      rep(i, n*2-1) {
        cout << P(i+1, i+2) << '\n';
      }
      break;
    case 1:
      rep(i, n-3) {
        cout << P(i+1, i+2) << '\n';
        cout << P(i+1+n, i+2+n) << '\n';
      }
      cout << P(n-2, n+1) << '\n';
      cout << P(n-1, n) << '\n' << P(n, 1) << '\n' << P(1, 2*n-1) << '\n' << P(n*2, 2*n-1) << '\n';
      break;
    case 0:
      int x = 1<<(31-__builtin_clz(n));
      int y = n-x;
      cout << P(x, y) << '\n' << P(y, 1) << '\n' << P(x+n, y+n) << '\n' << P(y+n, n+1) << '\n' << P(n-1, x+n) << '\n';
      cout << P(n, x) << '\n' << P(y, 2*n) << '\n';
      rep(i, n-2) {
        if(i+1 == x or i+1 == y) continue;
        int ne = i+2;
        while(ne == x or ne == y) ne++;
        cout << P(i+1, ne) << '\n' << P(i+1+n, ne+n) << '\n';
      }
      break;
  }
  if(n%4 == 2) {
    rep(i, n-4) {
      cout << P(i+1, i+2) << '\n';
      cout << P(i+1+n, i+2+n) << '\n';
    }
    cout << P(n-3, n+1) << '\n';
    cout << P(n-2, n-1) << '\n' << P(n-1, 1) << '\n' << P(1, 2*n-2) << '\n' << P(n*2-1, 2*n-2) << '\n';
    cout << P(n, n-1) << '\n' << P(2, 2*n) << '\n';
  }
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int c[10] = {};
	int n, m;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> m;
		int ret = m / 400;
		if(ret >= 8) c[8]++;
		else c[ret]++;
	}

	int s = 0;

	for(int i = 0;i < 8;i++){
		if(c[i] != 0){
			s++;
		}
	}

	cout << max(1, s) << " " << s + c[8] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c,n;
    scanf("%d",&n);
    while(n>0){
        scanf("%d %d %d",&a,&b,&c);
        if( ((a*a+b*b)==c*c) || ((b*b+c*c)==a*a) || ((c*c+a*a)==b*b) )
            printf("YES\n");
        else printf("NO\n");
        n--;
    }
    return 0;
}

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

#define N_MAX 100000
#define Q_MAX 100000
#define A_MAX 0x7FFFFFFF

typedef unsigned int    _uint;
typedef unsigned short  _ushort;

typedef struct{
    _ushort com;
    _uint   x;
    _uint   y;
}Que;

void que_operator(Que que, _uint n);

int main(void)
{
    _uint   n, q;
    _uint   ii;
    
    Que     que[Q_MAX];
    
    scanf("%d %d", &n, &q);
    
    for(ii = 0; ii < q; ii++){
        scanf("%d %d %d", &(que[ii].com), &(que[ii].x), &(que[ii].y));
    }
    
    for(ii = 0; ii < q; ii++){
        que_operator(que[ii], n);
    }
}

void que_operator(Que que, _uint n)
{
    static _uint    a[N_MAX];
    static _uint    call_list[Q_MAX];
    static _uint    call_count = 0;
    static _uint    call_count_cache = 0;
    static Que      que_cache;
    static _uint    result_cache;
    
    _uint           ii;
    _uint           r1, r2;
    _uint           result;
    
    switch(que.com){
        case 0:
            if(call_count == 0){
                for(ii = 0; ii < n; ii++){
                    a[ii] = A_MAX;
                }
            }
            a[que.x] = que.y;
            call_list[call_count] = que.x;
            call_count++;
            break;
        case 1:
            if(call_count != 0){
                if(call_count == call_count_cache){
                    if(que_cache.com == que.com){
                        if(que_cache.x == que.x){
                            if(que_cache.y == que.y){
                                printf("%d\n", result_cache);
                                return;
                            }
                        }
                    }
                }
                result = A_MAX;
                if(que.x > que.y){
                    r1 = que.y;
                    r2 = que.x;
                }else{
                    r1 = que.x;
                    r2 = que.y;
                }
                if((r2 - r1) < (call_count * 3)){
                    for(ii = r1; ii <= r2; ii++){
                        if(result > a[ii]){
                            result = a[ii];
                        }
                    }
                }else{
                    for(ii = 0; ii < call_count; ii++){
                        if(result > a[call_list[ii]]){
                            if(r1 <= call_list[ii] && call_list[ii] <= r2){
                                result = a[call_list[ii]];
                            }
                        }
                    }
                }
                que_cache = que;
                result_cache = result;
            }else{
                result = A_MAX;
                que_cache = que;
                result_cache = result;
            }
            call_count_cache = call_count;
            printf("%d\n", result);
            break;
        default:
            break;
    } 
}


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

int main(){
  ll s;
  cin>>s;
  
  int a=sqrt(s);
  if(s!=1e18) a++;
  int b=a*a-s;
  int c;
  for(int i=1;i<=b;i++){
    if(b%i==0){
      c=i;
      break;
    }
  }
  cout<<0<<" "<<0<<" "<<a<<" "<<c<<" "<<b/c<<" "<<a<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct edge{
    int to;
    ll cap;
    int rev; //逆辺のindex
};

const int MAX_V = 1e3;
vector<edge> es[MAX_V];
vector<bool> used(MAX_V, false);

//fromからtoに容量capの辺を張る
void add_edge(int from, int to, ll cap){
    edge e1 = {to, cap, sz(es[to])}, e2 = {from, 0, sz(es[from])};
    es[from].eb(e1), es[to].eb(e2);
}

//増加パスをdfsで探す
ll dfs(int now, int goal, ll flow){
    if(now == goal) return flow;
    used[now] = true;
    for(auto &e: es[now]){
        if(!used[e.to] && e.cap > 0){
            ll f = dfs(e.to, goal, min(flow, e.cap));
            if(f > 0){
                e.cap -= f;
                es[e.to][e.rev].cap += f;
                return f;
            }
        }
    }
    return 0;
}

ll max_flow(int s, int t){
    ll flow = 0;
    while(true){
        fill(all(used), false);
        ll f = dfs(s, t, INF);
        if(f == 0) break;
        flow += f;
    }
    return flow;
}

int main(){
    int N;
    cin >> N;
    ll tmp = 0;
    int s = 0, t = N+1;
    rep(i, N){
        ll A; cin >> A;
        if(A >= 0){
            tmp += A;
            add_edge(i+1, t, A);
        }
        else add_edge(s, i+1, -A);
    }
    rep2(i, 1, N){
        rep2(j, i+1, N){
            if(j%i == 0) add_edge(i, j, INF);
        }
    }
    cout << tmp-max_flow(s, t) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int N;
    string S;
    cin >> N >> S;
    int max_n = 0;
    for(int i = 0; i < N; i++){
        string S_l = S.substr(0, i + 1);
        string S_r = S.substr(i + 1);
        int count = 0;
        for(char x = 'a'; x <= 'z'; x++){
            if(S_l.find(x) != string::npos and S_r.find(x) != string::npos) count++;
        }
        max_n = max(max_n, count);
    }
    cout << max_n << endl;
}


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

using namespace std;

int main(){
    int n;

    cin >> n;

    vector<int> a(n);

    unordered_map<int, int> data;

    long sum=0;

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

    for(int i=0; i<n; i++){
        data[a[i]]=data[a[i]]+1;
    }


    int q;

    cin >> q;

    vector<long> num;

    for(int i=0; i<q; i++){
        long b,c;
        cin >> b >> c;

        long v = c-b;

        sum = sum + v*data[b];

        if(data.count(c)){
            data[c] = data[c]+data[b];
        }else{
            data[c] = data[b];
        }
        
        data.erase(b);

        num.push_back(sum);

    }

    for(auto i:num){
        cout << i << endl;
    }

}

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



long long a, b, c, d;


long long gcd(long long A, long long B){
	if(B==0) return A;
	return gcd(B, A%B);
}

long long solve(long long n) {
	long long ans=  n/c + n/d - n/( (c*d)/gcd(c,d) );

	return ans;
}

int main( ) {
	cin>> a>> b>> c>> d;
	long long  n = b-a+1;
	cout<< n-(solve(b) - solve(a-1))<<"\n";
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<double> x(n), y(n);
	rep(i, n) cin >>x[i] >>y[i];
	VI c(n);
	rep(i, n) c[i] = i;
	double ans = 0;
	int su =0;
	do {
		double sm = 0;
		rep(i,n-1){
			int z = c[i], z2 = c[i+1];
			double w =(x[z] - x[z2])*(x[z] - x[z2]) + (y[z] - y[z2])*(y[z] - y[z2]);
			sm += sqrt(w);
		}
		ans += sm; su++;
	} while ( next_permutation(all(c)) );

	
	//dbg(ans, su);
	printf("%.15f\n",  ans/su);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=1
b=[]
for i in range(n-1):
    a0=a[i+1]-a[i]
    if a0!=0:
        b.append(a0)
if len(b)>1:
    i=0
    while i<len(b)-1:
        if b[i]*b[i+1]<0:
            ans+=1
            i+=1
        i+=1
print(ans)

Measured memory_bytes: 14224
from collections import Counter
 
 
def solve():
    N = int(input())
    D = Counter(map(int, input().split()))
    M = int(input())
    T = Counter(map(int, input().split()))
    for k, v in T.items():
        if D[k] < v:
            return 'NO'
    return 'YES'
 
 
print(solve())

Measured memory_bytes: 67680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll x;
// 0 以上 n 以下の整数のうち条件を満たすものの個数
ll f(long long n)
{
    // x の倍数となる整数の個数
    // ただし n = -1 の時も定義する
    if (n == -1) return 0;
    return n / x + 1; // ゼロも含める
}

int main()
{
    ll a, b;
    scanf("%lld %lld %lld", &a, &b, &x);
    ll ans = f(b) - f(a - 1);
    printf("%lld\n", ans);
    return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    int ans(0),m(0);
    rep(i,n){
        int p;  cin >> p;
        m = max(p,m);
        ans += p;
    }

    ans -= m/2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int n,a;
int main(){
	cin>>n;
	bool f=true;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a%2==0){
			if(a%3!=0&&a%5!=0)
				f=false;
		}
	}
	if(f) cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
		
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    char s;
    cin>>s;
    if(s=='A'){
        op('T');
    }
    if(s=='T'){
        op('A');
    }
    if(s=='G'){
        op('C');
    }
    if(s=='C'){
        op('G');
    }
    return 0;
}

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

int main(){
	int p,d;cin >>p>>d;
  	long count = 0;
  	for(int i=0;i<p;i++){
      long double x,y;cin>>x>>y;
      if(sqrt(pow(x,2) + pow(y,2)) <=d){
      	count++;
      } 
    }
  	cout <<count;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

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

    int ans = 0;
    int cnt = 0;
    int c = min(a, b);
    // 大きいものからk番目
    for(int i = c; i > 0; i--){
        if(a % i == 0 && b % i == 0){
            cnt += 1;
            if(cnt == k){
                ans = i;
                break;
            }
        }
    }
    OP(ans);
}


Measured memory_bytes: 256
r, g, b, n = map(int, input().split())

cnt = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        if (n-i*r-j*g) % b == 0 and (n-i*r-j*g) // b >= 0:
            cnt += 1

print(cnt)

Measured memory_bytes: 40556
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<bool> visited(100005, false);
vector<int> adj[100005];

void dfs(int st) {
	if (!visited[st])
	{
		visited[st] = true;
		for (auto x : adj[st]) {
			dfs(x);
		}
	}
}
int32_t main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int total = 0;
	for (int i = 1; i <= n; i++) {

		if (!visited[i]) {
			total += 1;
			dfs(i);
		}
	}
	cout << total - 1 << endl;
}

Measured memory_bytes: 10308
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int maxn = 200005;
int f[maxn];

inline void work() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> f[i];
    }
    sort(f, f + n);
    LL sum = f[n - 1];
    int k=n-2;
    n=n-2;
    while(n>=2)
    {
        sum=sum+2*f[k--];
        n=n-2;

    }
    if(n==1)
    {
        sum+=f[k];
    }
    cout<<sum<<endl;
;
}

int main() {
    // freopen(".txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 4384
import java.io.*;
import java.util.*;
@SuppressWarnings("unused")
public class Main{
    public static void main(String args[]) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        String s[] = br.readLine().trim().split(" ");
        int n = Integer.parseInt(s[0]);
        int w = Integer.parseInt(s[1]);
        int[] val = new int[n];
        long[] wt = new long[n];
        for(int i=0;i<n;i++) {
            String st[] = br.readLine().trim().split(" ");
            wt[i] = Integer.parseInt(st[0]);
            val[i] = Integer.parseInt(st[1]);
        }
        int maxval = (int) 1e5+10;
        long[] dp = new long[maxval];
        long INF = (long) 1e18;
        Arrays.fill(dp, INF);
        dp[0] = 0;
        int ans = 0;
        for(int i=0;i<n;i++){
            for(int j=maxval-1;j >= val[i];--j){
                dp[j] = Math.min(dp[j], dp[j-val[i]] + wt[i]);
                if(dp[j]<=w) ans = Math.max(ans, j);
            }
        }
        
        out.println(ans);
        out.flush();
    }
}

Measured memory_bytes: 34092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

	static String matrix[][];
	static int dist[][];
	static boolean used[][];

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

	static int w;
	static int h;

	static int min = Integer.MAX_VALUE;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		long gcd = lcm(a, b);
		System.out.println(gcd);
	}

	static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	static long gcd(long m, long n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}
}

Measured memory_bytes: 21332
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}

//cout << setprecision(123)<<ans;
//a=atoi(S.c_str());
//S=to_string(a);
int main(){
  int r;
  cin>>r;
  cout<<r*r<<endl;
}


Measured memory_bytes: 256
#%%
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

def count(a1, a2, a3, n, t, k):
    ans = ['a'] * n

    if a1 == 'r':
        win = 's'
        lose = 'p'
    elif a1 == 's':
        win = 'p'
        lose = 'r'
    elif a1 == 'p':
        win = 'r'
        lose = 's'

    for i in range(n):
        if k > i :
            if t[i] == win:
                ans[i] = a1
        elif i >= k:
            if t[i] == win and ans[i-k] != a1:
                ans[i] = a1

    if a2 == 'r':
        win = 's'
        lose = 'p'
    elif a2 == 's':
        win = 'p'
        lose = 'r'
    elif a2 == 'p':
        win = 'r'
        lose = 's'
    
    for i in range(n):
        if k > i :
            if t[i] == win:
                ans[i] = a2
        elif i >= k:
            if t[i] == win and ans[i-k] != a2:
                ans[i] = a2

    if a3 == 'r':
        win = 's'
        lose = 'p'
    elif a3 == 's':
        win = 'p'
        lose = 'r'
    elif a3 == 'p':
        win = 'r'
        lose = 's'

    for i in range(n):
        if k > i :
            if t[i] == win:
                ans[i] = a3
        elif i >= k:
            if t[i] == win and ans[i-k] != a3:
                ans[i] = a3
    return ans


b1 = count('r', 's', 'p', n, t, k)
b2 = count('r', 'p', 's', n, t, k)

b3 = count('s', 'r', 'p', n, t, k)
b4 = count('s', 'p', 'r', n, t, k)

b5 = count('p', 's', 'r', n, t, k)
b6 = count('p', 'r', 's', n, t, k)

ans = 0
for i in [b1, b2, b3, b4, b5, b6]:
    tmp = 0
    for j in range(n):
        if i[j] == 'r' and t[j] == 's':
            tmp += r
        elif i[j] == 's' and t[j] == 'p':
            tmp += s
        elif i[j] == 'p' and t[j] == 'r':
            tmp += p
    ans = max(tmp, ans)
print(ans)





    



Measured memory_bytes: 10300
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

sum_idx = -(-N // 2)-1
if N % 2 == 0:
    print(sum(A[0:sum_idx+1]) + sum(A[1:sum_idx+1]))
else:
    print(sum(A[0:sum_idx+1]) + sum(A[1:sum_idx])) 


Measured memory_bytes: 31400
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,k;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(register int i=0;i<=n;++i)
		for(register int j=0;j<=m;++j)
			if((n-i)*j+(m-j)*i==k)
			{
				printf("Yes");
				return 0;
			}
	printf("No");
	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;
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;
    ll  l[N];
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            for (int k = j+1; k < N; k++)
            {
                if((l[i]+l[j])>l[k] && (l[j]+l[k])>l[i] && (l[k]+l[i])>l[j]){
                  if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k])ans++;
                }
            }
            
        }
        
    }
    
    
    cout << ans << endl;
}

Measured memory_bytes: 3632