akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	int n=s.size(), m=t.size(), ret=INT_MAX;
	for (int i=0; i<=n-m; i++) {
		int cur=0;
		for (int j=0; j<m; j++)
			if(s[i+j]!=t[j])
				cur++;
		ret=min(ret,cur);
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3656
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	map<ll, ll> primes;
	ll D;
	cin >> D;
	ll i=2;
	double Dsq = sqrt(D);
	while(D>1){
		while(D%i==0){
			if(primes.count(i)==0){
				primes[i]=1;
			}else{
				primes[i]+=1;
			}
			D/=i;
		}
		i++;
		if(Dsq<i){
			primes[D]=1;
			break;
		}
	}
	ll ans = 0;
	ll count;
	for(auto v : primes){
		count = 1;
		ll tmp = v.S;
		while(tmp-count>=0){
			ans++;
			tmp-=count;
			count++;
		}
	}
	cout << ans << endl;
}


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

typedef vector<vector<int> > Graph;
struct Node{
  int ord, low;
};
class ArticulationFind{
public:
  ArticulationFind(Graph _g){
    g = _g;
    node.resize(g.size(), Node{-1, (int)1e9});
  }
  vector<int> find(){
    if(v_ord == 0)dfs();
    return articulation;
  }
private:
  void dfs(int v  = 0,
           int previous = -1){
    int to, cnt = 0;
    node[v].ord = node[v].low = v_ord++;
    bool isAP = false;
    for (int i = 0; i < g[v].size(); i++) {
      to = g[v][i];
      if(previous == to)continue;
      cnt += (node[to].ord == -1);
      if(node[to].ord == -1){
        dfs(to, v); 
        node[v].low = min(node[v].low, node[to].low);
        isAP |= ((node[v].ord != 0) and
                 (node[v].ord <= node[to].low));
      }
      node[v].low = min(node[v].low, node[to].ord);
    }
    if(cnt > 1 and node[v].ord == 0)isAP = true;
    if(isAP)articulation.emplace_back(v);
  }
  int v_ord = 0;
  vector<int> articulation;
  Graph g;
  vector<Node> node;
};

int main(int argc, char *argv[]){
  int n, m;
  std::cin >> n >> m;
  Graph g(n, vector<int>());
  for (int i = 0; i < m; i++) {
    int to, from;
    std::cin >> to >> from;
    g[to].push_back(from);
    g[from].push_back(to);
  }
  ArticulationFind af(g);
  vector<int> articulation = af.find();
  sort(articulation.begin(), articulation.end());
  for (int i = 0; i < articulation.size(); i++) {
    std::cout << articulation[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 5348
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >> X;
  short int A[X+153] = {0}, *p;
  int stop = sqrt(X+153);
  for(int i=2;i<=stop;i++)
    for(int j=2*i;A[i]-1 && j<=X+152;j+=i)
      A[j]=1;
  for(p=&A[X];*p;p++);
  cout << p-A << endl;
}

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

// MY TOOLS
#define let long long int
#define async ios_base::sync_with_stdio(false);cin.tie(NULL);
#define i_upto( n ) for( int i = 0 ; i < n ; i++ )
#define ij_upto( n, m ) for( int i = 0 ; i < n ; i++ ) for( int j = 0 ; j < m ; j++ )
template<class T>
T ** array2D( let R , let C ){
	T ** t = new T * [R] ;
	for( int i = 0 ; i < R ; i++ ){
		t[i] = new T[C] ;
	}
	return t ;
}
template<class T>
T ** array2D( let R , let C, T value ){
	T ** t = new T * [R] ;
	for( int i = 0 ; i < R ; i++ ){
		t[i] = new T[C] ;
	}
    ij_upto( R, C ) t[i][j] = value ;
	return t ;
}
template<class T>
T * array1D( let N, T value ){
    T * t = new T[N] ;
    i_upto(N) t[i] = value ;
    return t ;
}
template<class T>
T * array1D( let N ){
    T * t = new T[N] ;
    return t ;
}
template<class T>
vector<vector<T>> vector2D( let N, let M ){
	return vector<vector<T>>(N,vector<T>(M)) ;
}
template<class T>
vector<vector<T>> vector2D( let N, let M, T Value ){
	return vector<vector<T>>(N,vector<T>(M,Value)) ;
}
#define then ;
#define vector2D( t ) vector<vector<t>>
template<class T>
class matrix{
	public :
    T ** v ;
	let rows, cols ;
		matrix( let n, let m ){
			v = array2D<T>( n, m ) ;
			rows = n ;
			cols = m ;
		}
		void input(){
			ij_upto( rows, cols ) cin >> v[i][j] ;
		}
		T& at( let i, let j ){
			return v[i][j] ;
		}
		void set( let i, let j, T value ){
			v[i][j] = value ;
		}
		void output(){
			for( let i = 0 ; i < rows ; i++ ){
				for( let j = 0 ; j < cols ; j++ ){
					cout << v[i][j] << " " ;
				}
				cout << endl ;
			}
		}
		void fill( T value ){
			ij_upto( rows, cols ) v[i][j] = value ;
		}
		T ** begin(){
			return v ;
		}
		T ** end(){
			return v + rows ;
		}
};
//

bool compare( let * a, let *b ){
	return a[0] + a[1] < b[0] + b[1] ;   // w should be in increasing order and s should also in increasing order
}
let Min( let a, let b ){
	return a < b ? a : b ;
}
let Max( let a, let b ){
	return a > b ? a : b ;
}

// 0 -> w, 1 -> s, 2 -> v 
// main
// write your code here
int main(){
	async ;
    let N then cin >> N ;
    matrix<let> arr( N, 3 ) then arr.input() ;
	sort( arr.begin() , arr.end() , compare ) ;
	let dp[20001] = {0} ;
	for( let part = 0 ; part < N ; part++ ){
		for( let j = Min( 20001 - arr.at(part,0), arr.at(part,1) ) ; j >= 0 ; j-- ){
			dp[j+arr.at(part,0)] = Max(dp[j+arr.at(part,0)], dp[j]+arr.at(part,2) ) ;
		}
	}
	let ans = 0 ;
	i_upto( 20001 ) ans = Max( ans, dp[i] ) ;
	cout << ans then return 0 ;
}

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

typedef long long ll;

template<class T> inline void chmax(T &a, T b) {if(a < b) a = b;}

int beki(int a, int n){
    if(n == 0){
        return 1;
    }
    int ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1){
        ans = ans * a;
    }
    return ans;
}

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

    int x; cin >> x;
    int ans = 0;
    for(int i=1;i<35;i++){
        for(int j=2;j<12;j++){
            if(beki(i,j)<=x){
                chmax(ans,beki(i,j));
            }else break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if(x+r<=w && x-r>=0 && y+r<=h && y-r>=0){
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int h, c = 1;
    cin >> h;
    int s = 0;
    while(h>0){
        s += c;
        h /= 2;
        c <<= 1;
    }
    cout << s;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 1;
    char prev = S[0];
    for (int i=0; i<N; i++){
        if (prev != S[i]){
            ans++;
        }
        prev = S[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

ll inq(ll x, ll y, ll mod)
{
    if (y == 0) return 1 % mod;
    ll l = inq(x, y / 2, mod);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

ll gcdex(ll a, ll b, ll &x, ll &y)
{
    // Solves the equation ax + by = gcd(a, b)
    // returns gcd(a, b)
    // save x and y in given values
    //
    // Correctness tested on random tests.
    //
    if (a == 0)
    {
        x = 0, y = 1;
        return b;
    }
    ll x1, y1;
    ll g = gcdex(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return g;
}

pair<ll, ll> crt(vector<ll> r, vector<ll> m)
{
    // Finds such x, that x mod m[i] = r[i] for each i
    // if such x does not exist returns {0, 0}
    //
    // Correctness tested on random tests.
    //
    int n = r.size();
    for (int i = 0; i < n; i++) r[i] %= m[i];
    ll r0 = 0, m0 = 1;
    for (int i = 0; i < n; i++)
    {
        ll r1 = r[i], m1 = m[i];
        if (m0 < m1)
        {
            swap(m0, m1);
            swap(r0, r1);
        }
        if (m0 % m1 == 0)
        {
            if (r0 % m1 != r1) return {0, 0};
            continue;
        }
        ll x, y;
        ll g = gcdex(m0, m1, x, y);
        ll u = m1 / g;
        if ((r0 - r1) % g != 0)
            return {0, 0};
        ll z = (r1 - r0) / g % u * x % u;
        r0 += z * m0;
        m0 *= u;
        if (r0 < 0) r0 += m0;
    }
    return {r0, m0};
}

const int K = 65;

ll solve(ll a, ll m)
{
    if (m == 1) return K;
    ll phi = m;
    ll z = m;
    for (int i = 2; i * i <= z; i++)
    {
        if (z % i == 0)
        {
            phi /= i;
            phi *= (i - 1);
            while (z % i == 0)
            {
                z /= i;
            }
        }
    }
    if (z > 1)
    {
        phi = phi / z * (z - 1);
    }
    ll g = __gcd(m, phi);
    ll y = solve(a, g);
    vector<ll> R = {y, inq(a, y, m)};
    vector<ll> M = {phi, m};
    pair<ll, ll> ze = crt(R, M);
    while (ze.first < K) ze.first += ze.second;
    return ze.first;
}

int main()
{
    int q;
    cin >> q;
    while (q--)
    {
        ll a, m;
        cin >> a >> m;
        ll r = solve(a, m);
        cout << r << "\n";
    }
}


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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map<int , int> s;
    int n;
    int a;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(s.end() != s.find(a)){
			cout << "NO";
			return 0;
		}
		s.insert({a , 0});
	}
	cout << "YES";
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    deque<char> q;
    rep(i,s.size()) q.push_back(s[i]);
    int ans = 0;
    while (!q.empty()) {
        char front = q.front();
        char back = q.back();
        if (front == back) {
            if (q.size() != 1) {
                q.pop_front(); 
                q.pop_back();
            } else {
                q.pop_front();
            }
        } else {
            if (front != 'x' && back != 'x') {
                cout << -1 << endl;
                return 0;
            } else if (front == 'x') {
                q.push_back('x');
                ans++;
            } else if (back == 'x') {
                q.push_front('x');
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3820
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007LL;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a=0;cin>>n;
	while(n--){
		int b;cin>>b;
		while(b%2==0){b/=2;a++;}
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <string>
#include <iostream>

using namespace std;

int main() {
  int n;
  int b[100];
  int a[100];
  cin >> n;
  for (int i = 0; i < n-1; i++) cin >> b[i];

  a[n-1] = b[n-2];
  for (int i = n-2; i >= 0; i--) {
    a[i] = b[i];
    if (a[i] < a[i+1]) a[i+1] = a[i];
  }
  
  long long sum = 0;
  for (int i = 0; i < n; i++) sum += a[i];
  
  cout << sum << endl;
}

Measured memory_bytes: 256
//abc150_b.cpp
//Thu Feb  6 21:55:08 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 0;
	for (int i=0;i<n-2;i++){
		if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
			ans++; 
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main() {
    string s, ans;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    return 0;
}

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

using LL = long long;

LL dp[105][5][2];
LL comb (int n, int m) {
        if (n < m) return 0;
        if (n == m || m == 0) return 1;
        LL ans = 1;
        for (int i = 0; i < m; ++i) ans *= (n-i);
        for (int i = 1; i <= m; ++i) ans /= i;
        return ans;
}
int main () {
        string s; cin >> s;
        int k; cin >> k;
        int n = s.size();
        assert (s[0] != '0');
        LL ans = 0;
        for (int i = k; i < n; ++i) ans += comb (i-1, k-1); 
        for (int i = 0; i < k; ++i) ans *= 9;
        cerr << "ans = " << ans << endl;
        dp[1][1][1] = 1;
        dp[1][1][0] = s[0]-'0'-1;
        for (int i = 2; i <= n; ++i) {
                for (int j = 1; j <= min(i,k); ++j) {
                        if (s[i-1]=='0') {
                                dp[i][j][1] += dp[i-1][j][1];
                                dp[i][j][0] += 9 * dp[i-1][j-1][0];
                                dp[i][j][0] += dp[i-1][j][0];
                                dp[i][j][0] += dp[i-1][j][1];
                        } else {
                                dp[i][j][1] += dp[i-1][j-1][1];
                                dp[i][j][0] += 9 * dp[i-1][j-1][0];
                                dp[i][j][0] += dp[i-1][j][0];
                                dp[i][j][0] += (s[i-1]-'0'-1) * dp[i-1][j-1][1];
                                dp[i][j][0] += dp[i-1][j][1];
                        }
                }
                /*
                for (int j = 1; j <= k; ++j) printf ("%lld%c",dp[i][j][0]," \n"[j==k]);
                for (int j = 1; j <= k; ++j) printf ("%lld%c",dp[i][j][1]," \n"[j==k]);
                cout << endl;
                */
        }
        int cnt = 0;
        LL res = 0;
        for (int i = 1; i <= n; ++i) {
                LL add = 0;
                if (s[i-1] == '0') {
                        continue;
                } else {
                        add += (s[i-1]-'0'-1) * comb (n-i,k-cnt-1) * (LL) (pow(9,k-cnt-1));
                        if (i != 1) add += comb (n-i,k-cnt) * (LL) (pow(9,k-cnt));
                        //cout << s[i-1] << " " << n-i << " | " << k-cnt-1 << endl;
                        //cout << (s[i-1]-'0'-1) << " , " << comb (n-i,k-cnt-1) << " , " << pow(9,k-cnt-1) << endl;
                        ++cnt;
                }
                res += add;
                //cout << i << " " << res << " " << add << endl;
                if (cnt == k) break;
        }
        int one = 0, nzero = 0;
        for (auto &x : s) one += x=='1', nzero += x!='0';
        res++;
        if ((one == nzero && k > one) || k > nzero) res--;
        cout << ans + res << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;cin>>s>>t;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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


string s;
ll sum = 0;  

void calc(int ind, ll now1, ll now2) {
    if (ind == s.size()) {
        sum += now1 + now2;
        return;
    }

    calc(ind + 1, s[ind] - '0', now1 + now2);
    calc(ind + 1, now1 * 10 + (s[ind] - '0'), now2);
}

int main() {
    cin >> s;
    calc(0, 0, 0);

    cout << sum / 2ll << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

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

    static class AFiftyFifty {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            TreeSet<Character> t = new TreeSet<>();
            char c[] = s.next().toCharArray();
            int f[] = new int['Z' + 1];
            for (char cc : c) {
                t.add(cc);
                f[cc]++;
            }
            w.println(t.size() == 2 && f[t.first()] == 2 ? "Yes" : "No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
x, y=gets.split.map &:to_i
d=(x.abs-y.abs).abs
if x==0
    p d+(y<0 ? 1 : 0)
elsif y==0
    p d+(x>0 ? 1 : 0)
elsif x.positive? != y.positive?
    p d+1
else
    p d+(x<y ? 0 : 2)
end

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> acc(N + 1, 0);
    rep(i, N) acc[i + 1] += acc[i] + A[i];

    map<ll, ll> cnt;
    ll ans = 0;
    rep(i, N + 1) {
        ll a = acc[i];
        ans += cnt[a];
        cnt[a] ++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int n;
    map<string,long long int> c;
    cin >> n;
    string t;
    for(int i = 0;i < n;i++) {
        cin >> t;
        sort(t.begin(),t.end());
        if(c.find(t) == c.end()) {
            c[t] = 0;
        }
        c[t]++;
    }
    long long int res = 0;
    for(auto& e:c) {
        res += e.second *(e.second - 1) / 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 11136
from collections import Counter

n = int(input())
s = input()



c = Counter(s)
SL = 0
SR = c['#']
DL = 0
DR = c['.']
if SR == 0 or DR == 0:
    score = 0
else:

    score = len(s)

    while True:
        x = s.find('.')
        if x == -1:
            break
        SR -= x
        SL += x
        s = s[x:]

        a = DL + DR
        b = SL + SR
        c = SL + DR
        score = min([a,b,c, score])
    #     print(s, score, [DL, DR, SL, SR])


        x = s.find('#')
        if x == -1:
            break
        DR -= x
        DL += x
        s = s[x:]

        a = DL + DR
        b = SL + SR
        c = SL + DR
        score = min([a,b,c, score])
    #     print(s, score, [DL, DR, SL, SR])
print(score)

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

using namespace std;

string const c[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(){
	
	int n;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		
		string s;
		
		cin >> s;
		
		int num=0;
		int cnt=0;
		
		for(int j=0;s[j];j++){
			if(s[j]=='0'){
				if(cnt!=0){
					num = s[j-1]-'0';
					cout << c[num][(cnt-1)%c[num].size()];
					cnt=0;
				}
			}else{
				cnt++;
			}
		}
	cout << endl;
	}
				
	return 0;
}
			


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

int main()
{
	int A, B, C, TMP;

	cin >> A >> B >> C;

	TMP = A;
	A = B;
	B = TMP;

	TMP = A;
	A = C;
	C = TMP;

	cout << A << " " << B << " " << C << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S,ans;
    cin >> S;
    bool a1 = "01" <= S.substr(0,2) && S.substr(0,2) <= "12";
    bool a2 = "01" <= S.substr(2,2) && S.substr(2,2) <= "12";
    if ( a1 && a2 ) ans = "AMBIGUOUS";
    else if ( a1 ) ans = "MMYY";
    else if ( a2 ) ans = "YYMM";
    else ans = "NA";
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector<int> ve[N];
priority_queue<int> qe;
int main(){
	int n,m;
	cin>>n>>m;
	int a,b;
	for(int i=1;i<=n;++i){
		cin>>a>>b;
		if(m-a+1>0) ve[m-a+1].push_back(b);
	}
	int sum=0;
	for(int i=m;i>=1;--i){
		for(int j=0;j<ve[i].size();++j){
			qe.push(ve[i][j]);
		}
		if(qe.size()){
			sum+=qe.top();
			qe.pop();
		}
	}
	cout<<sum;
}

Measured memory_bytes: 8940
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 998244353;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head


const int N = 1e7+10;
int n, fac[N], ifac[N], po[N];
int C(int n, int m) {
	return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;
}

int main() {
	fac[0] = po[0] = 1;
	REP(i,1,N-1) fac[i]=(ll)fac[i-1]*i%P,po[i]=(ll)po[i-1]*2%P;
	ifac[N-1] = inv(fac[N-1]);
	PER(i,0,N-2) ifac[i]=(ll)ifac[i+1]*(i+1)%P;
	scanf("%d", &n);
	int ans = qpow(3,n);
	REP(i,n/2+1,n) ans = (ans-2ll*C(n,i)*po[n-i])%P;
	if (ans<0) ans += P;
	printf("%d\n", ans);
}








Measured memory_bytes: 117376
n,x,y=map(int,input().split())
want=[0]*(n)
for i in range(1,n):
    for j in range(i+1,n+1):
        want[min(j-i,1+abs(j-y)+abs(i-x))]+=1
for i in range(1,n):
    print(want[i])

Measured memory_bytes: 3444
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	int x, y;
	scanf("%d%d", &x, &y);
	rep(i, x + 1){
	  for(int j = 0; i + j <= x; ++j){
	    if((y - 10000 * i - 5000 * j) / 1000 == x - i - j){
	      printf("%d\n%d\n%d\n", i, j, x - i - j);
	      return 0;
			}
		}
	}
	printf("-1\n-1\n-1\n");
	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int ko = 0;
    for(int i=1;i<=5;i++){
        int x;
        cin >> x;
        if(!x)ko = i;
    }
    cout << ko << endl;
    return 0;
}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
 
#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define MOD 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
#define dd double
#define fori(x,n) for(ll i=x;i<n;i++)
#define modd 998244353
#define umap unordered_map<ll,ll>

vi adj[100001];
ll dp[100001][2];           // 0 for no restriction and 1 for restriction

ll fun(ll i,ll state,ll p){
  if(adj[i].size()==1 and adj[i][0]==p){    //leaf nodes 
    if(state==0)return 2;
    return 1;
  }

  if(dp[i][state]!=-1)return dp[i][state];

  ll ans = 1;
  for(auto x:adj[i])if(x!=p)ans=(ans*fun(x,0,i))%mod; 

   if(state==1)return dp[i][state]=ans;


  ll ans1=1;
  for(auto x:adj[i])if(x!=p)ans1=(ans1*fun(x,1,i))%mod;
    
 

  return dp[i][state]=((ans%mod)+(ans1%mod))%mod;      // considering both possibilites 

}


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
   
   ll n;
   cin>>n;

   fori(0,n-1){
    ll x,y;
    cin>>x>>y;
    adj[x].pb(y);
    adj[y].pb(x);
   }

   memset(dp,-1,sizeof dp);

   cout<<fun(1,0,0);

 


 
return 0;
}    

Measured memory_bytes: 17604
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,ll>;
using Graph= vector<vector<P>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 ll dpa[100005]  ;
 ll dpb[100005] ;
 ll dpc[100005]  ;
int main(){
 ll n ;cin>>n ;
 vector<ll> A(n),B(n),C(n) ;
 rep(i,n) cin>>A[i]>>B[i]>>C[i] ;
  dpa[0]=0 ;dpb[0]=0 ;dpc[0] =0 ;
  rep(i,n){
    dpa[i+1]=max(dpb[i],dpc[i])+A[i] ;
    dpb[i+1]=max(dpa[i],dpc[i])+B[i] ;
    dpc[i+1]=max(dpa[i],dpb[i])+C[i] ;
  }
  cout<<max(dpa[n],max(dpb[n],dpc[n])) ;
  return 0;
  }

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define ifr(a, value) insert(a.begin(), value)
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define szz(v) ((int)(v).size())  
#define vi vector<int>
#define vll vector<ll>
#define str string
#define fr(i, j, k) for(i = j; i < k; i++)
#define bk(i, j, k) for(i = j; i >= k; i--)
#define frit(a, it) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)        // use fill() for value other than 0 //
#define rtn return 
#define clk fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock()/CLOCKS_PER_SEC)
#define nl "\n"
#define inf 1LL<<61
#define dbg(x) (cerr << #x << ": " << x << "\n")
const long long mod = 1e9+7;

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }   // no need to swap a, b, it auto. happens after first call //
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, i;
    cin >> n;
    int p[n];
    fr(i, 0, n)
    {
        int x;
        cin >> x;
        x--;
        p[x] = i;
    }
    int c = 1, ans = 1;
    fr(i, 1, n)
    {
        if(p[i] > p[i-1])
            c++;
        else c = 1;
        ans = max(ans, c);
    }
    cout << n-ans;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

ll n;
vi a;

struct SegTree{
  typedef int T;
  T e = 0;
  T m(const T&a, const T&b){return a + b;}
//###################################################
  typedef int i;i n;vector<T> d;
  void clear(){memset(&d[0], e, sizeof(d[0]) * sz(d));}
  void resize(i m){n=1<<(32-__builtin_clz(m-1));d.resize(2*n-1);clear();}
  void init(vector<T>&v){resize(sz(v));FOR(j,0,sz(v))d[j+n-1]=v[j];FORR(k,n-2,0)d[k]=m(d[k*2+1],d[k*2+2]);}
  void update(i k,T a){k+=n-1;d[k]=a;while(k>0){k=(k-1)/2;d[k]=m(d[k*2+1],d[k*2+2]);}}
  T q(i a,i b,i k,i l,i r){return (r<=a||b<=l)?e:(a<=l&&r<=b)?d[k]:m(q(a,b,k*2+1,l,(l+r)/2),q(a,b,k*2+2,(l+r)/2,r));}
  T query(i a,i b){return q(a,b,0,0,n);}
  T get(i a){return d[n+a-1];}
};
SegTree seg;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int t;
    cin >> t;
    a.pb(t);
  }
  ll l = 0, r = mod, mid, g = (n*(n+1)/2+1)/2;
  seg.resize(n*2+1);
  while(r-l > 1){
    seg.clear();
    seg.update(n, 1);
    mid = (l + r) / 2;
    int s = 0;
    ll c = 0;
    for(int aa: a){
      s += (aa >= mid) ? 1 : -1;
      c += seg.query(0, s+n+1);
      seg.update(s+n, seg.get(s+n) + 1);
    }
    if (c >= g){
      l = mid;
    }else{
      r = mid;
    }
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 2808
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

 vector<bool> arr;

void Eratosthenes(int N){
    arr.resize(N+1);
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

}

int main(){
 int Q; cin >> Q;
 Eratosthenes(1000010);
  int sum[1000010]; sum[0] = 0; sum[1] = 0;
  for(int i = 2; i < 1000010; i++){
    if(arr[i] && arr[(i+1)/2] && i % 2 != 0){sum[i] = sum[i-1] + 1;}
    else{ sum[i] = sum[i-1];}}
  //sum[x] はx以下の条件を満たす整数の総数
  for(int i = 0; i < Q; i++){
    int l,r; cin >> l >> r;
       cout << sum[r] - sum[l-1] << endl;}
  return 0;}

Measured memory_bytes: 4608
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int p=scan.nextInt();
            int rem=p%1000;
            if(rem!=0){
                out.println(1000-rem);
            }else{
                out.println(0);
            }
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 32484
n,m=map(int, input().split()) 
a=list(map(int, input().split()))

total = sum(a)
c = 0

for i in range(n):
    if a[i] * 4 * m >= total:
        c = c + 1

if c >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
(defun main ()
  (let ((S (read-line))
        (arr (make-array 26 :element-type 'fixnum))
        (a-int (char-int #\a)))
    (loop for c across S do
      (incf (aref arr (- (char-int c) a-int))))
    (if (zerop (count-if #'zerop arr))
        (format t "None~%")
        (format t "~A~%" (code-char (+ (position-if #'zerop arr) a-int))))))

(main)

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
   string s;
   cin >> s;
   int n = s.size();
   ll sum = 0;
   rep(i, 0, n){
       sum += s[i]-'0';
       sum %= 9;
   }
   if(sum%9==0){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 3684
n,m=map(int,input().split())
A=[list(map(int,input().split()))for i in range(n)]
A=sorted(A,key=lambda x:x[0])
ans=0
for i in range(n):
    buy=min(m,A[i][1])
    ans+=buy*A[i][0]
    m-=buy
print(ans)


Measured memory_bytes: 29796
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
struct edge{ll to,cap,rev;};
vector<edge> G[40010];
bool used[40010];
void add_edge(ll from,ll to,ll cap){
    G[from].push_back((edge){to,cap,(ll)G[to].size()});
    G[to].push_back((edge){from,0,(ll)G[from].size()-1});
}
ll dfs(ll v,ll t,ll f){
    if(v==t)return f;
    used[v]=true;
    rep(i,0,G[v].size()){
        edge &e=G[v][i];
        if(used[e.to]==false&&e.cap>0){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
ll max_flow(ll s,ll t){
    ll f=0;
    for(;;){
        memset(used,0,sizeof used);
        ll g=dfs(s,t,1000000000);
        if(g==0)return f;
        f+=g;
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,w;cin>>h>>w;
    string s[h];
    rep(i,0,h)cin>>s[i];
    int sh,sw,th,tw;
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='S'){
                add_edge(200,i,inf);
                add_edge(200,100+j,inf);
                sh=i,sw=j;
            }
            else if(s[i][j]=='T'){
                add_edge(i,201,inf);
                add_edge(100+j,201,inf);
                th=i,tw=j;
            }
            else if(s[i][j]=='o'){
                add_edge(i,100+j,1);
                add_edge(100+j,i,1);
            }
        }
    }
    if(sh==th||sw==tw){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=max_flow(200,201);
    cout<<ans<<endl;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, K; // 人, 身長
    cin >> N >> K;
    int ans = 0;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    for(int i = 0; i < N; i++) {
        if(v[i] >= K) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
const main = (input) =>  {
  const data = input.split(/\n|\s/).map((a) => parseInt(a, 10));
  const a = data[0];
  const b = data[1];
  if (a <= 0 && 0 <= b) {
    return "Zero"
  }

  if ((b - a) % 2  || a > 0) {
    return "Positive";
  } else {
    return "Negative";
  }
}

console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")))





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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N, D;
  scanf("%lld %lld", &N, &D);

  ll ans = 0;

  for (ll i = 0; i < N; i++) {
    ll x, y;
    scanf("%lld %lld", &x, &y);

    if (x * x + y * y <= D * D) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3760