akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, q, t, l = 0, r = 1;
    set<pii> s = {{-mod, -1}, {mod, -1}};
    auto x = s.begin();
    ll b, c = 0, z = mod + mod;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> t;
        if (t == 1) {
            cin >> a >> b;
            c += b;
            s.insert({a, i});
            z += abs(a - x->first);
            if (s.size() % 2) {
                if (make_pair(a, i) > *x) {
                    r++;
                    int y = x->first;
                    x++;
                    z += 1ll * (x->first - y) * (l - r + 1);
                    l++;
                    r--;
                } else {
                    l++;
                }
            } else {
                if (make_pair(a, i) < *x) {
                    l++;
                    int y = x->first;
                    x--;
                    z += 1ll * (y - x->first) * (r - l + 1);
                    l--;
                    r++;
                } else {
                    r++;
                }
            }
        } else {
            cout << x->first << ' ' << z + c - mod - mod << '\n';
        }
    }
}


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


int main(){
    ll N, ans = 0;
    bool flag = true;
    cin >> N;
    vector<ll> vec(N + 1,0);
    for(int i = 1; i <= N; i++){
        cin >> vec[i];
        if(vec[i] >= vec[i - 1]){
            continue;
        }else if(vec[i] + 1 == vec[i - 1]){
            vec[i]++;
        }else{
            flag = false;
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define A_MAX 1000000
 
using namespace std;
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
int N;
 
void scanN() { 
    char c = getchar_unlocked();
    while (c > 47) {
        N = (N << 3) + (N << 1) + c - 48;
        c = getchar_unlocked();
    }
} 

void scana() { 
    for (int i = 0; i < N; ++i) {
        int x = 0;
        char c = getchar_unlocked();
        while (c > 47) {
            x = (x << 3) + (x << 1) + c - 48;
            c = getchar_unlocked();
        }
        ++a[x];
    }
} 

int main() {
 
    for (int i = 2; i <= A_MAX; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
        }
        int j = 0;
        for (int p = 2; ; p = primes[++j]) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    scanN();
    scana();
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = false;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15340
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Differ by 1 Bit
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 17;
const int NBITS = 1 << MAX_N;

/* typedef */

/* global variables */

int v[NBITS], vn = 0;

/* subroutines */

int bitp(int a) {
  int p = 0;
  for (int bi = 1; bi <= a; bi <<= 1)
    if (a & bi) p ^= 1;
  return p;
}

void rec(int a, int b, int msk, int c) {
  if (msk == 0) {
    v[vn++] = c;
    return;
  }

  int bi = 1;
  for (;; bi <<= 1)
    if ((msk & bi) && (a & bi) != (b & bi)) break;
  int abi = (a & bi), bbi = (b & bi);
  int mski = msk ^ bi;
  int ac = c | abi, bc = c | bbi;

  if (mski == 0) {
    v[vn++] = ac;
    v[vn++] = bc;
  }
  else {
    int bj = 1;
    for (; ! (mski & bj); bj <<= 1);
    int d = (a & mski) ^ bj;
    rec(a, d, mski, ac);
    rec(d, b, mski, bc);
  }
}

/* main */

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

  if (bitp(a) == bitp(b)) {
    puts("NO");
    return 0;
  }
  
  rec(a, b, (1 << n) - 1, 0);

  puts("YES");
  for (int i = 0; i < vn; i++) {
    if (i) putchar(' ');
    printf("%d", v[i]);
  }
  putchar('\n');

  return 0;
}


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

int main(int argc, char const* argv[])
{
	int m, f, r;
	while (cin >> m >> f >> r && (m != -1 || f != -1 || r != -1)) {
		if (m == -1 || f == -1) {
			cout << "F" << endl;
		} 
		else if (m+f >= 80) {
			cout << "A" << endl;
		}
		else if (m+f >= 65) {
			cout << "B" << endl;
		}
		else if (m+f >= 50) {
			cout << "C" << endl;
		}
		else if (m+f >= 30) {
			if (r >= 50) {
				cout << "C" << endl;
			} else {
				cout << "D" << endl;
			}
		}
		else {
			cout << "F" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i,l,r) for(ll i = (l); i <= (ll)(r); i++)
#define rep3(i,l,r) for(ll i = (l); i >= (ll)(r); i--)
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; }
const int inf = 1001001001;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ld pi = acos(-1);
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_),siz(sz_, 1LL){
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
   }
   void init(ll sz_){
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x){ // 根の検索
      while (par[x]!=x){
           x=par[x]=par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y){
       x=root(x);
       y=root(y);
       if (x==y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x]<siz[y]) swap(x, y);
       siz[x]+=siz[y];
       par[y]=x;
       return true;
  }
 
  bool same(ll x, ll y){ // 連結判定
       return root(x)==root(y);
  }
 
  ll size(ll x){ // 素集合のサイズ
      return siz[root(x)];
  }
};
 
ll modpow(ll x, ll n){
   x=x%mod;
   if(n==0) return 1;  //再帰の終了条件
 
   else if(n%2==1){
       return (x*modpow(x, n-1))%mod;  //nが奇数ならnを1ずらす
   }
   else return modpow((x*x)%mod, n/2)%mod;  //nが偶数ならnが半分になる
}
 
ll com(ll n, ll k){
   ll x=1;
   for(int i=n-k+1; i<=n; i++){
      x=x*i%mod;
   }
 
   ll y=1;
   for(int i=1; i<=k; i++){
       y=y*i%mod;
   }
   y=modpow(y, mod-2);
 
   return x*y%mod;
}
 
bool is_prime(const unsigned n){
   switch(n){
       case 0: // fall-through
       case 1: return false;
       case 2: // fall-through
       case 3: return true;
  } // n>3 が保証された
 
   if(n%2==0 || n%3==0) return false;
   // nは2と3のいずれの倍数でもないことが保証された
   // これよりnは(6の倍数)-1か(6の倍数)+1である
 
   // 6の倍数前後の数を使って試し割りをする
   for(unsigned i = 5; i*i<=n; i+=6) {
       if(n%i==0) return false; // (6の倍数)-1
       if(n%(i+2)==0) return false; // (6の倍数)+1
   }
 
   return true;
}
 
int digsum(int n){
   int res=0;
   while(n > 0) {
       res+=n%10; //ここをres++;に変えたら桁数を求める関数になる,res+=n%10;なら格桁の和
       n/=10;
   }
   return res;
}
vector<ll> divisor(ll n){
   vector<ll> ret;
   for(ll i=1; i*i<=n; i++){
       if(n%i==0){
           ret.push_back(i);
           if(i*i!=n) ret.push_back(n/i);
       }
   }
   sort(ret.begin(),ret.end());
   return ret;
}
 
int main(){

    ll n,ans=0;
    string s;
    cin >> n >> s;
    rep(i,n){
        if(i==0) continue;
        else{
            if(s[i]==s[i-1]) continue;
            else ans++;
        }
    }

    cout << ans+1 << endl;
 
}

Measured memory_bytes: 512
if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    from collections import deque, defaultdict
    from copy import deepcopy

    MAX = 100000
    NIL = -1

    # Gはdictで管理する、valueはdeque
    G = defaultdict(lambda: deque())
    color = [NIL]*MAX

    def dfs(r, c):
        S = deque()
        S.append(r)
        color[r] = c
        while S:
            u = S.popleft()
            for v in G[u]:  # Gのvalueはdequeなので、それをvに一つずつ入れていく
                if color[v] == NIL:
                    color[v] = c
                    S.append(v)

    def assign_color():
        id = 1
        for u in range(n):
            if color[u] == NIL:
                dfs(u, id)
                id += 1

    n, m = map(int, input().split())

    for _ in range(m):
        s, t = map(int, input().split())
        G[s].append(t)
        G[t].append(s)

    assign_color()

    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        if color[s] == color[t]:
            print('yes')
        else:
            print('no')



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

int main(){
    int n;
    cin>>n;
    vector<ll> t(n);
    ll sum=0;
    rep(i,n){
        cin>>t[i];
        sum+=t[i];
    }
    int m;
    cin>>m;
    vector<ll> p(m),x(m);
    rep(i,m) cin>>p[i]>>x[i];
    vector<ll> ans(m);
    rep(i,m){
        ans[i]=sum-t[p[i]-1]+x[i];
        cout<<ans[i]<<"\n";
    }
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

#define MAX 2000000
int n;
string s[MAX];

bool check() {
  int p=0,q=0;
  rep(i,n) {
    rep(j,(int)s[i].size()) {
      if( s[i][j] == '(' ) {
	++p;
      } else {
	++q;
      }
    }
  }
  return p == q;
}

struct Data {
  ll score, require, bad;
  bool operator < ( const Data d ) const {
    if( bad != d.bad ) return bad < d.bad;
    if( score != d.score ) return score < d.score;
    if( require != d.require ) return require > d.require;
    return score < d.score;
  }
};

void solve() {
  if( !check() ) {
    puts("No");
    return;
  }
  //vector<Data> vec;
  priority_queue<Data> Q;
  ll cur = 0;
  rep(i,n) {
    ll score = 0, mini = -LLONG_MAX;
    rep(j,(int)s[i].size()) {
      if( s[i][j] == '(' ) {
	++score;
      } else {
	--score;
      }
      if( mini == -LLONG_MAX ) mini = score;
      else mini = min(mini, score);
    }
    assert( mini != -LLONG_MAX );
    if( mini >= 0 ) {
      cur += score;
    } else {
      ll bad = 0;
      if( s[i].back() == '(' ) bad = 1;
      //vec.pb((Data){score, mini, bad});
      Q.push((Data){score,mini,bad});
    }
  }
  /*
  sort(ALL(vec));
  cout << " * cur = " << cur << endl;
  rep(i,(int)vec.size()) {
    cout << "* " << i << "-th: " << vec[i].score << " : " << vec[i].require << " : " << vec[i].bad << endl;
  }
  rep(i,(int)vec.size()) {
    if( cur + vec[i].require >= 0 ) {
      cur += vec[i].score;
      assert( cur >= 0LL);
      if( cur < 0LL ) {
	puts("No");
	return;
      }
    } else {
      puts("No");
      return;
    }
  }
  */
  bool update = true;
  while( update && !Q.empty() ) {
    deque<Data> tmp;
    update = false;
    while( !Q.empty() ) {
      Data d = Q.top(); Q.pop();
      //cout << d.score << " " << d.require << " " << d.bad << " : " << cur << endl;
      if( cur + d.require >= 0 && cur + d.score >= 0LL ) {
	cur += d.score;
	update = true;
	break;
      } else {
	tmp.pb(d);
      }
    }
    if( update ) {
      while( (int)tmp.size() ) {
	Q.push(tmp.front());
	tmp.pop_front();
      }
    } else {
      puts("No");
      return;
    }
  }
  puts("Yes");
}

int main() {
  
  cin >> n;
  rep(i,n) cin >> s[i];
  solve();
  return 0;
}


Measured memory_bytes: 78000
# include <bits/stdc++.h>
using namespace std;
int main(){
	long long a , b , res = 1;
	cin >> a >> b;
	long long gcd = __gcd(a , b);
	for(long long i = 2; i * i <= gcd; i ++){
		bool ok = false;
		while(gcd % i == 0)
			gcd /= i,
			ok = true;
		res += ok;
	}
	res += (gcd != 1);
	cout << res << "\n";
}

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, S, ans = INF;
	vector<int> a;
	
	cin>>N>>S;
	
	a.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
	}
	
	for(int i = 0, j = 0, sum = 0; i < N; i++){
		for(; j < N; j++){
			if(sum >= S) break;
			sum += a[j];
		}
		
		if(sum >= S) ans = min(ans, j-i);
		sum -= a[i];
	}
	
	if(ans != INF)cout<<ans<<endl;
	else cout<<0<<endl;
	
	return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#pragma GCC optimize("O2")
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
int main(void)
{
  int N=IN(),i=0,u,v;long x=N;
  while(i++<N-1){u=IN(),v=IN();if(u>v)x+=1l*(i+1)*(N-i)-1l*v*(N+1-u);else x+=1l*(i+1)*(N-i)-1l*u*(N+1-v);}
  return printf("%ld",x),0;
}

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

int main() {

  int q;
  cin >> q;

  list<int> L;
  auto it = L.end();

  auto insert = [&](int x) {
    L.insert(it, x);
    it--;
  };

  auto move = [&](int d) {
    while (0 < d) {
      d--;
      it++;
    }
    while (d < 0) {
      d++;
      it--;
    }
  };

  auto erase = [&]() {
    auto tmp = it++;
    L.erase(tmp);
  };

  for (int i = 0; i < q; i++) {
    int query, x;
    cin >> query;
    if (query == 0) {
      cin >> x;
      insert(x);
    } else if (query == 1) {
      cin >> x;
      move(x);
    } else {
      erase();
    }
  }

  for (auto item:L) {
    cout << item << endl;
  }

  return 0;

}


Measured memory_bytes: 18556
#include <stdio.h>
#define N 10000

int main(){
  int n,q,i,j,S[N],T[N],count=0,status;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    status = 0;
    
    if(i!=0){
      for(j=i-1;j<0;j--){
	if(T[i] == T[j]) status = 1;
      }
    }
    
    if(status == 0){
      for(j=0;j<n;j++){
	if(T[i] == S[j]){
	  count += 1;
	  break;
	}
      }
    }
  }
  
  printf("%d\n",count);
  
  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
 lint digit(lint);

int main(){

    string s;
    cin >> s;

    if(s[0] == s[1] && s[1] == s[2])cout << "No" << endl;
    else cout << "Yes" << endl;

}
lint digit(lint num){
    lint dig = 0;
    while(num){
        num /= 10;
        ++dig;
    }
    return dig;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a==b&&a!=c)||(a==c&&a!=b)||b==c&&c!=a)
    printf("Yes");
    else
    {
        printf("No");
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

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

    if (s == "SUN") cout << 7 << endl;
    else if (s == "MON") cout << 6 << endl;
    else if (s == "TUE") cout << 5 << endl;
    else if (s == "WED") cout << 4 << endl;
    else if (s == "THU") cout << 3 << endl;
    else if (s == "FRI") cout << 2 << endl;
    else if (s == "SAT") cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
typedef long long ll;
typedef pair<int, int> pii;
template<typename T> void show(T e){ cout << e << endl; }
template<typename T> void show(const vector<T>& v){ for(const auto& e : v){ cout << e << " "; } cout << endl; }
template<typename T> void show(const vector<vector<T>>& vv){ for(const auto& v : vv){ show(v); } }
template<class Iter> void show(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }

int main(int argc, char const *argv[])
{
  ll N;
  cin >> N;
  vector<ll> arr(N+1);
  unordered_map<ll, int> pos;
  RNG(i, 1, N+1) {
    cin >> arr[i];
    pos[arr[i]] = i;
  }
  set<ll> st{0, N+1};
  ll res = 0;
  for(ll snd = N; snd >= 1; snd--) {
    ll idx = pos[snd];

    auto it = st.lower_bound(idx);
    if (*it != N+1) {
      res += snd * (*next(it) - *it) * (idx-*prev(it));
    }
    if (*prev(it) != 0) {
      res += snd * (*prev(it)-*prev(prev(it))) * (*it-idx);
    }
    st.insert(idx);
  }
  cout << res << endl;
  // show(arr);
  return 0;
}


Measured memory_bytes: 9892
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<28)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n*(n - 1) / 2) + (m*(m - 1) / 2);
    return 0;
}


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

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

    int dp[N+1][W+1];

    for(int i=0;i<W+1;i++){
        dp[0][i] = 0;
    }


    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0){
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;

}

Measured memory_bytes: 79104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define Mod 2019

int main(void){
  long i,j,x,min=Mod,mini=Mod;
  long l,r;

  scanf("%ld%ld",&l,&r);

  if(r-l>=Mod){
    printf("0\n");
  }else{
    for(i=l;i<r;i++){
      x=(i*i)%Mod;
      for(j=1;i+j<=r;j++){
        x=(x+i)%Mod;
        if(x<mini){
          mini=x;
        }
      }
      if(mini<min){
        min=mini;
      }
    }
    printf("%ld\n",min);
  }


	return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int[] a = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[0] + a[1] == a[2] ? "Yes" : "No");
	}
}

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

using int64 = long long;
using Event = tuple<int64, int64, int64>; // (時刻, イベントの種類, 補足情報)

int main() {
    int64 X, K;
    cin >> X >> K;
    vector<Event> events;
    for (int i = 0; i < K; i++) {
        int64 r;
        cin >> r;
        events.emplace_back(r, 1, 0);
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int64 t, a;
        cin >> t >> a;
        events.emplace_back(t, 2, a);
    }
    sort(events.begin(), events.end());

    int64 prev = 0,
          x1 = 0, y1 = 0,
          x2 = X, y2 = X;
    int dir = -1;

    for (auto& e : events) {
        int64 t, kind, a;
        tie(t, kind, a) = e;

        // cerr << "t: " << t << " kind: " << (kind == 1 ? "R" : "Q") << " a: " << a << endl;
        // t - prev秒経過
        int64 cost = t - prev;
        if (dir < 0) {
            // 点1の移動
            // まず下に下がる
            y1 -= cost;
            // 下がりすぎた分右に進む
            x1 = min(X, x1 + max(0LL, -y1));
            y1 = max(y1, 0LL);

            // 点2の移動
            y2 -= cost;
            x2 = min(X, x2 + max(0LL, -y2));
            y2 = max(y2, 0LL);
        } else {
            // 点2の移動
            // まず上に上がる
            y2 += cost;
            // 上がりすぎた分左に進む
            x2 = max(0LL, x2 - max(0LL, y2 - X));
            y2 = min(y2, X);

            // 上に上がる
            y1 += cost;
            x1 = max(0LL, x1 - max(0LL, y1 - X));
            y1 = min(y1, X);
        }
        // cerr << "(x1, y1): (" << x1 << ", " << y1 << ") (x2, y2): (" << x2 << ", " << y2 << ")" << endl;

        if (kind == 1) {
            dir = -dir;
        } else {
            if (a <= x1) {
                cout << y1 << endl;
            } else if (a < x2) {
                cout << min(X, y1 + (a - x1)) << endl;
            } else {
                cout << y2 << endl;
            }
        }

        prev = t;
    }

    return 0;
}

Measured memory_bytes: 8432
def main():
    n = x = int(input())

    s = n % 10
    n //= 10
    while n > 0:
        s += n % 10
        n //= 10

    if x % s == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
//#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

mint calc(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) res *= (N - n);
    return res;
}


int main()
{
  ll N, A, B; cin >> N >> A >> B;
  cout << modpow((mint)2, N) - 1 - (calc(N, A) * modpow(calc(A, A), MOD - 2)) - (calc(N, B) * modpow(calc(B, B), MOD - 2)) << endl;
}



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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	int x, y;
	cin >> x >> y;
	if (x % y == 0) {
		puts("-1");
		return 0;
	}
	cout << 1ll * x * y - x << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets().to_i

l = gets().split(" ").map{|i| i.to_i}.sort
n = l.length

t = 0
for i in 0..n-3 do
    for j in (i+1)..n-2 do
        for k in (j+1)..n-1 do
            if l[i] == l[j]
                next
            end
            next if l[j] == l[k]
            next if l[k] == l[i]
            t += 1 if (l[i] + l[j] > l[k])
        end
    end
end
print(t)

Measured memory_bytes: 14404
#include <cstdio>
#include <algorithm>
using namespace std;
int a[105];
int main()
{
    int N,x,ans;
    scanf("%d%d",&N,&x);
    for(int i=0;i<N;i++)
        scanf("%d",&a[i]);
    sort(a,a+N);
    ans=0;
    for(int i=0;i<N;i++)
        if(x>=a[i])
        {
            x-=a[i];
            ans++;
        }
        else break;
    if(ans==N&&x>0)
        ans--;
    printf("%d\n",ans);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];



  vector<vector<int>> ans(h, vector<int>(w, 0));
  rep(i, h) rep(j, w) if(s[i][j] == '#') {
    ans[i][j] = k;
    --k;
  }

  rep(j, w) {
    rep(i, h) {
      if(ans[i][j] != 0) {
        int t = 1;
        while(i-t >= 0 && ans[i-t][j] == 0) {
          ans[i-t][j] = ans[i][j];
          ++t;
        }
        t = 1;
        while(i+t < h && ans[i+t][j] == 0) {
          ans[i+t][j] = ans[i][j];
          ++t;
        }
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      if(ans[i][j] != 0) {
        int t = 1;
        while(j-t >= 0 && ans[i][j-t] == 0) {
          ans[i][j-t] = ans[i][j];
          ++t;
        }
        t = 1;
        while(j+t < w && ans[i][j+t] == 0) {
          ans[i][j+t] = ans[i][j];
          ++t;
        }
      }
    }
  }
  rep(i, h) line_out(ans[i]);
}

Measured memory_bytes: 4148
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;
using P = std::pair<ll, ll>;

ll A, B, C, D;

int main()
{
  std::cin >> A >> B >> C >> D;

  ll turn = 0;

  while( true )
  {
    if( !turn )
    {
      C -= B;

      if( C <= 0 )
      {
        puts("Yes");
        return 0;
      }
    }
    else  
    {    
      A -= D;

      if( A <= 0 )
      {
        puts("No");

        return 0;
      }
    }

    turn ^= 1;
  }

  return 0;
}

Measured memory_bytes: 3152
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(k);
	cini(n);
	vi a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	int ma = 0;
	int prev = 0;
	for (int i = 0; i < n; i++) {
		ma = max(ma, abs(prev - a[i]));
		prev = a[i];
	}

	ma = max(ma, k - a.back() + a[0]);

	ll ans = k - ma;
	cout << ans << endl;

}

int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}



Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int digit_sum(int n) {
	int sum = 0;
	while (n > 0) {
		int x = n % 10;
		n = n / 10;
		sum = sum + x;	
	}
	return sum;
}

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

	int sum = digit_sum(N);
		
	if (N % sum == 0) {
		cout << "Yes" << endl;	
	}
	else {
		cout << "No" << endl;	
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		double ans = 0;
		for (int i = 1; i <= N; i++) {
			double tmp = 1.0 / N;
			int now = i;
			while (now < K) {
				now *= 2;
				tmp /= 2;
			}
			ans += tmp;
		}
		System.out.println(String.format("%.12f", ans));
		in.close();
	}
}

Measured memory_bytes: 23636
#include <stdio.h>

int main(void){

  long a,b,k;
  scanf("%ld %ld %ld", &a, &b, &k);

  if (k <= a) {
    a -= k;
  } else {
    k -= a;
    a = 0;
    if (k <= b) {
      b -= k;
    } else {
      b = 0;
    }
  }

  printf("%ld %ld\n", a, b);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef vector<point> polygon;
 
const double eps = 1e-9;
 
#define NEXT(i) (((i) + 1) % n)
 
struct line { point p, q; };
 
double cross(point a, point b) { return imag(conj(a) * b); }
 
double dot(point a, point b) { return real(conj(a) * b); }
 
double area2(point a, point b, point c) { return cross(b - a, c - a); }
 
double area2(const polygon &P)
{
    double A = 0;
    for (int i = 0, n = P.size(); i < n; ++i)
        A += cross(P[i], P[NEXT(i)]);
    return A;
}
 
int ccw(point a, point b, point c)
{
    b -= a; c -= a;
    if (cross(b, c) > 0) return +1; // counter clockwise
    if (cross(b, c) < 0) return -1; // clockwise
    if (dot(b, c) < 0) return
    +2; // c--a--b on line
    if (dot(b, b) < dot(c, c)) return -2; // a--b--c on line
    return 0;
}
 
point crosspoint(const line &l, const line &m)
{
    double A = cross(l.q - l.p, m.q - m.p);
    double B = cross(l.q - l.p, l.q - m.p);
    if (abs(A) < eps && abs(B) < eps) return m.p; // same line
    if (abs(A) < eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
    return m.p + B / A * (m.q - m.p);
}
 
polygon convex_cut(const polygon &P, const line &l)
{
    polygon Q;
    for (int i = 0, n = P.size(); i < n; ++i)
    {
        point A = P[i], B = P[(i + 1) % n];
        if (ccw(l.p, l.q, A) != -1) Q.push_back(A);
        if (ccw(l.p, l.q, A) * ccw(l.p, l.q, B) < 0)
            Q.push_back(crosspoint((line){A, B}, l));
    }
    return Q;
}
 
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int n; cin >> n;
    polygon p(n);
     
    for (int i = 0; i < n; ++i){
        double x, y; cin >> x >> y;
        p[i] = point(x, y);
    }
 
    assert(area2(p) > -eps);
 
    int q; cin >> q;
    while (q--){
        double x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        point p1(x1, y1), p2(x2, y2);
        polygon pol = convex_cut(p, (line){p1, p2});
        
        cout.precision(20);

        if (pol.size() < 3) cout << fixed << 0 << endl;
        else cout << fixed << abs(area2(pol)) / 2 << endl;
        
    }
 
    return 0;
}

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

int main() {

  string S;
  cin >> S;
  
  int N = size(S);
  
  int check1 = 0;
  int check2 = 0;
  
  for(int i = 0; i <= (N-1)/2; i++) {
    if(i == (N-1)/2) {
      check1 = 1;
      break;
    }
    if(S.at(i) != S.at(N-1-i)) break; 
  }
  
  for(int i = 0; i <= (N-1)/2; i++) {
    if(i == (N-1)/2) {
      check2 = 1;
      break;
    }
    if(S.at(i) != S.at((N-1)/2-1-i)) break; 
  }
  
  if(check1*check2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3592
#include <cstdint>
#include <algorithm>
#include <iostream>

int main()
{
    int k, x;

    std::cin >> k >> x;

    if ( ( 500 * k ) >= x ) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
//C - Repsept
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define LL long long
#define Lowbit(X) (X&(-X))
#define Lson (X<<1)
#define Rson (X<<1|1)
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(LL i=A;i<=B;i++)
#define BOR(i,A,B) for(LL i=A;i>=B;i--)
#define FOR_SIDE(i,A) for(LL i=Head[A];i;i=Next[i])
#define INF 0x7fffffff
using namespace std;
const int MAXN=1e6+10;

int Count,Ans,New;

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

int main() {
    //File();
    scanf("%d",&Count);
    while(true) {
        Ans++; New=(New*10+7)%Count;
        if(New==0) break;
        if(Ans>1000100) break;
    }
    if(Ans>1000100) printf("-1\n");
    else printf("%d\n",Ans);
    //fclose(stdin); fclose(stdout);
   // system("pause");
    return 0;
}

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

#ifdef local
template <class T> void _E(T x) { cerr << x; } void _E(double x) { cerr << fixed << setprecision(6) << x; } void _E(string s) { cerr << "\"" << s << "\""; } template <class A, class B> void _E(pair<A, B> x) { cerr << '('; _E(x.first); cerr << ", "; _E(x.second); cerr << ")"; } template <class T> void _E(vector<T> x) { cerr << "["; for (auto it = x.begin(); it != x.end(); ++it) { if (it != x.begin()) cerr << ", "; _E(*it); } cerr << "]"; }
void ERR() {} template <class A, class... B> void ERR(A x, B... y) { _E(x); cerr << (sizeof...(y) ? ", " : " "); ERR(y...); }
#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif

using ll = long long;


int main(int argc, char *argv[]) {
  cin.sync_with_stdio(false), cin.tie(nullptr);

  int n, d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (1ll * x * x + 1ll * y * y <= 1ll * d * d) {
      ++ans;
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s,t;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> s >> t;
}

string conv(string x){
    map<char,int> cnt;
    for (int i = 0; i < x.length(); i++)
    {
        cnt[x[i]]++;
    }
    string ret;
    for (char c = 'a'; c <= 'z'; c++)
    {
        ret += string(cnt[c],c);
    }
    return ret;    
}

int solve(){
    s = conv(s);
    t = conv(t);
    reverse(t.begin(),t.end());
    cout << ((s<t)?"Yes":"No") << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int D;
  scanf("%d",&D);
  switch(D){
      case 25:printf("Christmas");
              break;
      case 24:printf("Christmas Eve");
              break;
      case 23:printf("Christmas Eve Eve");
              break;
      case 22:printf("Christmas Eve Eve Eve");
              break; 
      }
  return 0;
  }

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int X = in.nextInt();
        	int Y = in.nextInt();
        	out.println(X + Y/2);
        }
    }

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

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

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

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

    }
}



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

#define repd(i,a,b) for (long long i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;
typedef pair<ll, ll> P;

int main()
{
    int N, M;
    cin >> N >> M;
    ll ans = 0;

    priority_queue<ll, vector<ll>, greater<ll>> que;

    rep(i, N) {
        ll a;
        cin >> a;
        que.push(a);
        ans += a;
    }

    vector<P> card(M);
    rep(i, M) {
        P p;
        cin >> p.second >> p.first;
        card[i] = p;
    }

    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());
    
    bool flag = true;
    rep(i, M) {
        rep(j, card[i].second) {
            if (que.top() < card[i].first) {
                ans += card[i].first - que.top();
                que.pop();
                que.push(card[i].first);
            }
            else {
                flag = false;
                break;
            }
        }
        if (!flag) {
            break;
        }
    }

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

Measured memory_bytes: 2804
#include<stdio.h>
int main(){
  int n,i,j;
  char a[60001]={1,1};
  for(i=2;i*i<60001;i++){
    if(a[i]==0){
      for(j=2;i*j<60001;j++){
	a[i*j]=1;
      }
    }
  }
  while(scanf("%d",&n)!=EOF){
    for(i=n-1;a[i];i--);
    printf("%d ",i);
    for(i=n+1;a[i];i++);
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 660