akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());
#define usort(a) sort(a.rbegin(),a.rend());

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  int N; cin>>N;
  vector<int> A(N);
  pair<int,int> said[16][16];
  
  rep(i,0,N){
    cin>>A[i];
    rep(j,0,A[i]){
      cin>>said[i][j].first>>said[i][j].second;
    }
  }
  int bit=0;
  int ans=0;
  
  int check=0;
  
  while(bit<jo(2,N)){
    rep(i,0,N){
     // if(bit==3) cout<<"a";
      if(bit&jo(2,i)){


        rep(k,0,A[i]){ 
  //        if(bit==3) cout<<endl<<A[i]<<" "<<said[i][k].first-1<<" "<<(!!(bit&jo(2,(said[i][k].first))))<<" "<<said[i][k].second<<endl;
          if((!!(bit&jo(2,(said[i][k].first-1))))!=said[i][k].second) check++;
          if(check) break;
        }
      }
      if(check) break;
    }
    if(!check){
     // cout<<bit<<" ";
      int sum=0;
      rep(i,0,N){
        if(jo(2,i)&bit) sum++; 
      }
      ans=max(sum,ans);
    }
    check=0;
    bit++;
  }
  cout<<ans;
  
          
    
  
  /*
  rep(i,0,N){
    rep(j,0,A[i]){
      cout<<"["<<said[i][j].first<<","<<said[i][j].second<<"] ";
    }
    cout<<endl;
  }*/
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート
//  sort(変数名.rbegin(),変数名.rend());//降順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
int tickets[4];
vector<char> symbols;
bool dfs(int index, int current_total) {
  if(index == 4) {
    if(current_total == 7) return true;
    else return false;
  }
  if(dfs(index+1, current_total+tickets[index])) {
    symbols.PB('+');
    return true;
  }
  if(dfs(index+1, current_total-tickets[index])) {
    symbols.PB('-');
    return true;
  }
  return false;
}
/***** MAIN *****/
signed main() {
  string s = stin();
  REP(i,4) {
    tickets[i] = s[i] - '0';
  }
  dfs(1,tickets[0]);
  cout << tickets[0];
  REPS(i,1,4) {
    cout << symbols[3-i] << tickets[i];
  }
  cout << "=7" << endl;
  return 0;
}
/***** MAIN *****/


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

#define swap(type,a,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(int i=0;i<n;i++)
#define forS(i,start,n) for(int i=start;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}
#define DOUBLE fixed << setprecision(15)

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

bool cmp(vi,vi);
int main(){
    int n,m,cnt=0;
    string s;

    int c;
    cin >>n>>m>>c;
    vi b(m);
    vector<vi> a(n,vi(m));
    forN(i,m) cin >> b[i] ;
    forN(i,n){
        forN(j,m) cin>>a[i][j];
    }
    forN(i,n){
        int tmp=0;
        forN(j,m) tmp+=a[i][j]*b[j];
        tmp += c;
        if(tmp > 0){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main(){
    long long x,K,D,ans,cnt;
    cin >> x >> K >> D;
    if(x<0) x = -x;
    if(x/D>=K){
        ans = x-K*D;
    }else{

        K -= x/D;
        cnt = x%D;
        if(K%2==0){
            ans = cnt;
        }else{
            ans = D - cnt;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
number = list(input())

n = len(number) // 2
ans = 0
underNum = ''

if n == 0:
  ans = int(number[0])
else:
  ans = 9
  for i in range(3, len(number)+1):
    if i == len(number) and i % 2 != 0:
      if int(number[0]) == 1:
        for j in range(1, i):
          underNum += number[j]
        ans += int(underNum) + 1
      else:
        ans += (int(number[0]) - 1) * 100 ** (i // 2)
        for j in range(1, i):
          underNum += number[j]
        ans += int(underNum) + 1
    elif i % 2 != 0:
      ans += 9 * 100 ** (i // 2)
      
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	char a,b;
	cin>>a>>b;
	if(a>b)cout<<">"<<endl;
	else if(a<b)cout<<"<"<<endl;
	else cout<<"="<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int c[5][5];

int main(){
  rep(i,3){
    rep(j,3){
      cin >> c[i][j];
    }
  }

  bool flg = false;
  rep(a0,101){
    rep(a1,101){
      rep(a2,101){
        int b00 = c[0][0]-a0;
        int b01 = c[0][1]-a0;
        int b02 = c[0][2]-a0;
        int b10 = c[1][0]-a1;
        int b11 = c[1][1]-a1;
        int b12 = c[1][2]-a1;
        int b20 = c[2][0]-a2;
        int b21 = c[2][1]-a2;
        int b22 = c[2][2]-a2;
        if(b00 >= 0 && b00 == b10 && b10 == b20 &&
           b01 >= 0 && b01 == b11 && b11 == b21 &&
           b02 >= 0 && b02 == b12 && b12 == b22){
          flg = true;
        }
      }
    }
  }

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



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

using namespace std;

int main() {
	int n, p;
	string s;
	pair<pair<string, int>, int> t[110];
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s >> p;
		t[i] = make_pair(make_pair(s, -p), i);
	}
	sort(t + 1, t + n + 1);
	for (int i = 1; i <= n; i++)
		cout << t[i].second << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ps push_back
using namespace std;
const long long inf=9999999999999;
long long dp[52][2502];
struct nex{
    int x,cost,tim;
};
struct node{
    int x, s, t;
    bool operator<(const node& a)const{
        return t>a.t;
    }
};
priority_queue<node>que;
vector<nex>edg[52];
int c[52],d[52];
int book[52][2502];
int main()
{
    int u, v, a, b, s, n, m, i, j, k;
    cin>>n>>m>>s;
    s=min(2500, s);
    nex tmp;
    while(m--)
    {
        scanf("%d%d%d%d", &u,&v,&a,&b);
        tmp.x=v,tmp.cost=a,tmp.tim=b;
        edg[u].ps(tmp);
        tmp.x=u;
        edg[v].ps(tmp);
    }
    for(int i=1; i<=n; i++)scanf("%d%d", &c[i], &d[i]);
    for(i=0; i<=n; i++)
    {
        for(j=0; j<=2500; j++)
        {
            dp[i][j]=inf;
        }
    }
    dp[1][s]=0;
    node top;
    top.x=1;top.t=0;top.s=s;
    que.push(top);
//    top.x=2;top.t=1;top.s=s;
//    que.push(top);
//    printf("%d\n",que.top().x);
    while(!que.empty())
    {
        top=que.top();
        que.pop();
        int now=top.x, coin=top.s;
//        if(coin<10)printf("now%d coin%d %d\n", now, coin, dp[now][coin]);
        int nc=min(2500, coin+c[now]);
//        if(book[now][coin])continue;
//        book[now][coin]=1;
        if(dp[now][nc]>dp[now][coin]+d[now])
        {
            dp[now][nc]=dp[now][coin]+d[now];
//            if(book[now][nc])printf("%d %d %d\n", now, nc);
//            if(book[now][nc]==0){
            top.x=now,top.s=nc;
            top.t=dp[top.x][top.s];
            que.push(top);
//            }
        }
//        if(i<10)printf("nc%d %d\n", nc, dp[now][nc]);
        nex tmp;
        for(k=0; k<edg[now].size(); k++)
        {
            tmp=edg[now][k];
            j=coin;
//            if(i<10)printf("%d %d\n%d %d\n", now, tmp.x,j-tmp.cost, dp[tmp.x][j-tmp.cost]);


            if(j-tmp.cost>=0 && dp[now][j]+tmp.tim<dp[tmp.x][j-tmp.cost])
            {

                dp[tmp.x][j-tmp.cost]=dp[now][j]+tmp.tim;
//                if(book[tmp.x][j-tmp.cost]==0){
                    top.x=tmp.x;
                    top.s=j-tmp.cost;
                    top.t=dp[top.x][top.s];
                    que.push(top);
//                }
            }
        }

    }
    for(i=2; i<=n; i++)
    {
        long long mi=inf;
        for(j=0; j<=2500; j++)
        {
            mi=min(mi,dp[i][j]);
        }
        printf("%lld\n", mi);
    }
    return 0;
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
const int mxn=1e9+5;
int main()
{
    fast;
    ll n;
    cin>>n;
    map<int,char>mp;
    char c='a';
    for(int i=1;i<=26;i++)
    {
        mp[i]=c;
        c++;
    }
    vector<char>ans;
   // if(n%2==0)n--;
    while(n)
    {

        //cout<<n<<" ";
        int tmp=n%26;
       if(!tmp)tmp=26, n--;


        ans.pb(mp[tmp]);
        n/=26;
       // cout<<tmp<<" "<<n<<endl;

    }

   // ans.pb(mp[n]);
    reverse(ans.begin(),ans.end());
    for(auto i:ans)
    {
        cout<<i;
    }
    cout<<endl;
}




Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    int n,m;
    cin>>n>>m;
    Vi keycost(m);
    VVi keys(m);
    REP(i,0,m){
        int b;
        cin>>keycost[i]>>b;
        keys[i].resize(b);
        REP(j,0,b){
            cin>>keys[i][j];
            keys[i][j]--;
        }
    }
    Vi keynum(m);
    REP(i,0,m){
        REP(j,0,n){
            if(binary_search(ALL(keys[i]),j)) keynum[i] += (1<<j);
        }
    }

    const int MAXB=1<<n; 
    VVi dp(m,Vi(MAXB,INF));
    REP(i,0,m) dp[i][0]=0;
    REP(i,0,m-1){
        REP(j,0,MAXB){
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][j|keynum[i]],dp[i][j]+keycost[i]);
        }
    }
    if(dp[m-1][MAXB-1]==INF) cout<<-1<<endl;
    else cout<<dp[m-1][MAXB-1]<<endl;
    return 0;
}


Measured memory_bytes: 32512
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"
#define PI 3.141592653589793

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


class Dice{
    public:
        int top;
        int btm;
        int lft;
        int rgt;
        int fwd;
        int bck;
        
        Dice(){
            top = 1;
            fwd = 2;
            rgt = 3;
            lft = 4;
            bck = 5;
            fwd = 6;
        }
        
        Dice(int _top,int _fwd, int _rgt, int _lft, int _bck, int _btm){
            top = _top;
            fwd = _fwd;
            rgt = _rgt;
            lft = _lft;
            bck = _bck;
            btm = _btm;
        }
        
        void turn(char c){
            int _top = top;
            if(c=='N'){
                top = fwd;
                fwd = btm;
                btm = bck;
                bck = _top;
            }else if(c=='S'){
                top = bck;
                bck = btm;
                btm = fwd;
                fwd = _top;
            }else if(c=='E'){
                top = lft;
                lft = btm;
                btm = rgt;
                rgt = _top;
            }else if(c=='W'){
                top = rgt;
                rgt = btm;
                btm = lft;
                lft = _top;
            }else{
                cout << "err\n";
                exit(1);
            }
        }
};

int main(){
    int a,b,c,e,d,f; cin>>a>>b>>c>>d>>e>>f;
    Dice dice = Dice(a,b,c,d,e,f);
    string s; cin>>s;
    int N = s.size();
    REP(i,N){
        dice.turn(s[i]);
    }
    cout << dice.top << "\n";
    
}


Measured memory_bytes: 3160
def main():
    import sys
    A,B,C=list(map(int,sys.stdin.readline().split()))
    K=int(sys.stdin.readline())
    for i in range(K+1):
        if B<=A:
            B*=2
        elif C<=B:
            C*=2
        else:
            print('Yes')
            return

    print('No')

main()

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define Rep(i,n) for(int i=0; i<(n); i+=2)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

bool compare_by_b(pair<int, ll> a, pair<int, ll> b)
{
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int n,k;
    cin >> n>>k;
    int h[n];
    int count = 0;
    rep(i,n){
        cin >> h[i];
    }
    rep(i,n){
        if(h[i]>=k)
            count++;
    }
    cout << count << endl;
}

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

#define NDEBUG

#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))


#define N_MIN 1
#define N_MAX 100

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}

int main(int argc, char **argv) {
	int a,b,x;
	fscanf(stdin,"%d%d%d",&a,&b,&x);
	ASSERT_RANGE(N_MIN,a,N_MAX);
	ASSERT_RANGE(N_MIN,b,N_MAX);
	ASSERT_RANGE(N_MIN,b,a*a*b);

	double h = (double)x / (double)a / (double)a;
	if (h < (double)b/2) {
		double l = (double)x / (double)a / (double)b * 2.0;
		double rad = atan((double)b/(double)l);
		fprintf(stdout,"%.10lf\n",rad / M_PI * 180.0);
	} else {
		double l = (double)b - h;
		double rad = atan((double)l/(double)a*2.0);
		fprintf(stdout,"%.10lf\n",rad / M_PI * 180.0);
	}
	return 0;
}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

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

            //問題162

            //Console.WriteLine("aaa");


            string[] line = Console.ReadLine().Split(' ');

            long n = long.Parse(line[0]);
            long d = long.Parse(line[1]);

            //Console.WriteLine(n);
            //Console.WriteLine(d);

            long[] x = new long[n];
            long[] y = new long[n];

            for (long i = 0; i < n; i++)
            {
                string[] line2 = Console.ReadLine().Split(' ');
                x[i] = long.Parse(line2[0]);
                y[i] = long.Parse(line2[1]);
                //Console.WriteLine(x[i]);
                //Console.WriteLine(y[i]);
            }


            long ans = 0;

            for (long i = 0; i < n; i++)
            {
                if (x[i] * x[i] + y[i] * y[i] <= d * d) 
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }

    }





    
}


Measured memory_bytes: 43748
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7) cout << "YES"<<endl;
    else cout << "NO" << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int h,w,n;cin>>h>>w>>n&&h|w|n;){
		vvi bs(h);
		rep(k,n){
			int i,j; cin>>i>>j; i--,j--;
			bs[i].push_back(j);
		}
		rep(i,h)
			sort(all(bs[i]));
		//{
		//	vvi g(h,vi(w));
		//	rep(i,h) for(int j:bs[i]) g[i][j]=1;
		//	rep(i,h) cout<<g[i]<<endl;
		//}

		int res=h;
		int x=0;
		repi(i,1,h){
			if(bs[i].empty())
				continue;
			int j=bs[i][0];
			if(j<i-x){
				res=i;
				break;
			}
			if(j==i-x){
				x++;
			}
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 11136
from heapq import heappush, heappop

N, Q = map(int, input().split())
l = []
ans = [0]*Q
used = set()
q = []

for i in range(N):
    S, T, X = map(int, input().split())
    l.append((S-X, 1, X))
    l.append((T-X, 0, X))

for i in range(Q):
    v = int(input())
    l.append((v, 2, i))

l.sort()

for pos, m, x in l:
    if m==0:
        used.remove(x)
    elif m==1:
        heappush(q, x)
        used.add(x)
    else:
        while q:
            if q[0] not in used:
                heappop(q)
            else:
                break
        ans[x] = q[0] if q else -1

for i in range(Q):
    print(ans[i])


Measured memory_bytes: 98656
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    root = 0  # 根
    d = [-1]*n  # 根からの距離
    d[root] = 0
    q = [root]
    cnt = 0
    while q:  # BFS
        cnt += 1
        qq = []
        while q:
            i = q.pop()
            for j in g[i]:
                if d[j] == -1:
                    d[j] = cnt
                    qq.append(j)
        q = qq
    d = [i % 2+1 for i in d]
    d2 = [0]*n
    x = d.count(1)
    y = d.count(2)
    if x > n//3 and y > n//3:
        j1 = 1
        for i in range(n):
            if d[i] == 1:
                d2[i] = j1
                j1 += 3
                cnt += 1
        j2 = 2
        for i in range(n):
            if d[i] == 2:
                d2[i] = j2
                j2 += 3
        j3 = 3
        for i in range(n):
            if d2[i] > n:
                d2[i] = j3
                j3 += 3
    elif x <= n//3:
        j3 = 3
        for i in range(n):
            if d[i] == 1:
                d2[i] = j3
                j3 += 3
        j2 = 1
        for i in range(n):
            if d[i] == 2:
                d2[i] = j2
                if j2 % 3 == 2:
                    j2 += 2
                else:
                    j2 += 1
        for i in range(n):
            if d2[i] > n:
                d2[i] = j3
                j3 += 3
    else:
        j3 = 3
        for i in range(n):
            if d[i] == 2:
                d2[i] = j3
                j3 += 3
        j2 = 1
        for i in range(n):
            if d[i] == 1:
                d2[i] = j2
                if j2 % 3 == 2:
                    j2 += 2
                else:
                    j2 += 1
        for i in range(n):
            if d2[i] > n:
                d2[i] = j3
                j3 += 3
    print(*d2)


main()

Measured memory_bytes: 96300
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    X = list(map(int, input().split()))

    for i in range(n):
        if X[i] >= 0:
            ori = i
            X.insert(ori, 0)
            break
    else:
        ori = n
        X.insert(ori, 0)

    res = f_inf
    start = max(0, ori - k)
    end = min(n - k + 1, ori + 1)
    for j in range(start, end):
        left = abs(X[j]) * 2 + abs(X[j + k])
        right = abs(X[j]) + abs(X[j + k]) * 2
        res = min(res, min(left, right))
    print(res)


if __name__ == '__main__':
    resolve()


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

char str[1010];

void MAIN() {
    int n;
    scanf("%d", &n);
    std::vector<std::pair<int, int> > arr(n);
    for(int i = 0; i < n; ++ i) {
        auto &now = arr[i];
        scanf("%d", &now.first);
        now.second = i;
    }
    std::sort(arr.begin(), arr.end());
    int ans = 0;
    for(int i = 0; i < n; ++ i) {
        if(std::abs(arr[i].second - i) & 1) {
            ++ ans;
        }
    }
    printf("%d\n", ans >> 1);
}

int main() {
    MAIN();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

long long GCD(long long a, long long b){
  if (b == 0) return a;
  return GCD(b, a % b);
}

long long lcm(long long a, long long b){
  return a * b / GCD(a, b);
}

int main(){
  ll a, b, c, d; cin >> a >> b >> c >> d;
  ll l = lcm(c, d);

  auto f = [&](ll x) -> ll{
    return x - x / c - x / d + x / l;
  };
  ll under_b = f(b);
  ll under_a = f(a - 1);
  cout << under_b - under_a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  vector<int> shu(10,0);
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>m;
      shu[m]++;
    }
    for(int i=0;i<=9;i++){
      if(shu[i]==0)cout<<"-"<<endl;
      else{
	for(int j=0;j<shu[i];j++)cout<<"*";
	cout<<endl;
      }
    }
    for(int i=0;i<=9;i++)shu[i]=0;
  }
  return 0;
}

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

int main(){
	int x, n;
	bool flag = true;
	cin >> x;
	n = x;
	while(true){
		flag = true;
		for(int i=2; i<sqrt(n); i++){
			if(n%i==0){
				flag = false;
				break;
			}
		}		
		if(flag){
			cout << n << endl;
			return 0;
		}
		n++;
	}
}

Measured memory_bytes: 256
#!usr/bin/env python3

import sys
import operator
from math import floor


def string_to_list_spliter():
    lst = [int(i) if isinstance(i, int) == True else i for i in sys.stdin.readline().split()]
    return lst


def main():
    ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}

    while True:
        lst = string_to_list_spliter()
        if lst[1] == '?':
            break
        elif lst[1] == '+':
            print(ops[lst[1]](int(lst[0]), int(lst[2])))
        elif lst[1] == '-':
            print(ops[lst[1]](int(lst[0]), int(lst[2])))
        elif lst[1] == '*':
            print(ops[lst[1]](int(lst[0]), int(lst[2])))
        elif lst[1] == '/':
            print(floor(ops[lst[1]](int(lst[0]), int(lst[2]))))


if __name__ == '__main__':
    main()

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

int main()
{
    long long int k,n,sum=0;
    cin>>n>>k;
    long long int h[n];
    for (long long int i=0; i<n; i++)
    {
        cin>>h[i];
    }
    if ((n-k)<0)
    cout<<0<<endl;
    else
    {
    sort(h,h+n);
    for (long long int j=0; j<(n-k); j++)
    {
        sum=(sum+h[j]);//%(1000000000+7);
    }
    cout<<sum<<endl;
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const long long infinity=0x3f3f3f3f;
const int maxn=3000+10;
int n;
int f[maxn][maxn];
int x,y,z;
int a,b;
int c,d;
int main()
{
    memset(f,infinity,sizeof(f));
    scanf("%d%d%d",&n,&a,&b);
    f[0][0]=0;
    
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&x,&y,&z);
		c=1000-x,d=1000-y;
		for(int j=c;j>=0;j--){
			for(int k=d;k>=0;k--){
				f[j+x][k+y]=min(f[j][k]+z,f[j+x][k+y]);
			}
		} 
	}
//	cout<<f[3*a][3*b]<<endl;
	int ans=infinity;
	int g=min(1000/x,1000/y);
	for(int i=1;i<=g;i++){
		ans=min(ans,f[i*a][i*b]);
	}
	
	if(ans!=infinity)
	printf("%d",ans);
	else printf("-1");

	return 0;
}

Measured memory_bytes: 35712
# ABC 057: C – Digits in Multiplication
N = int(input())

Fs = [len(str(N))]

for n in range(2, int(N ** (1 / 2)) + 1):
    if N % n == 0:
        num_digit = len(str(n)) if len(str(n)) >= len(str(N // n)) else len(str(N // n))
        Fs.append(num_digit)

print(min(Fs))

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll GCD(ll a, ll b)
{
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b)
{
    return a = a / GCD(a, b) * b;
}

int main()
{
    int n; cin >> n;
    ll sum = 0;
    rep(i, n)
    {
        ll a; cin >> a;
        sum += a;
    }
    cout << sum - n << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

typedef vector<long long> Vec;

long long mods[] = {1000000007, 100000007, 1000000009};
long long bs[] = {1000003, 1000033, 1000033};
long long is[3];

Vec ad(Vec v1, Vec v2, int coe){
	for(int i = 0; i < 3; ++i) v1[i] += (coe * v2[i]);
	for(int i = 0; i < 3; ++i){
		v1[i] %= mods[i];
		if(v1[i] < 0) v1[i] += mods[i];
	}
	return v1;
}

long long ex(long long a, long long e, long long m){
	if(e == 0) return 1;
	long long tmp = ex(a, e / 2, m);
	tmp = (tmp * tmp) % m;
	if(e % 2 == 1) tmp *= a;
	tmp %= m;
	return tmp;
}

void init(){
	for(int i = 0; i < 3; ++i){
		is[i] = ex(bs[i], mods[i] - 2, mods[i]);
	}
}

Vec cur;

int N;
char ch[250200];

void input(){
	scanf("%d", &N);
	scanf("%s", ch);
}

int ps[250200];

Vec vs[250200];

map<vector<long long>, vector<int> > mp;

Vec mv(Vec v, int e){
	if(e == 0) return v;
	for(int i = 0; i < 3; ++i){
		long long a = (e > 0) ? (bs[i]) : (is[i]);
		v[i] *= ex(a, e > 0 ? e : (-e), mods[i]);
		v[i] %= mods[i];
		if(v[i] < 0) v[i] += mods[i];
	}
	return v;
}

long long solve(){
	init();
	Vec v(3);
	ps[0] = 0;
	mp[v].push_back(0);
	for(int i = 0; i < 3; ++i){
		cur.push_back(1);
	}
	vs[0] = v;
	for(int i = 0; i < N; ++i){
		if(ch[i] == '>'){
			ps[i + 1] = ps[i] + 1;
			cur = mv(cur, 1);
		}else if(ch[i] == '<'){
			ps[i + 1] = ps[i] - 1;
			cur = mv(cur, -1);
		}else if(ch[i] == '+'){
			ps[i + 1] = ps[i];
			v = ad(v, cur, 1);
		}else{
			ps[i + 1] = ps[i];
			v = ad(v, cur, -1);
		}
		for(int j = 0; j < 3; ++j){
			v[j] %= mods[j];
			if(v[j] < 0) v[j] += mods[j];
		}
		mp[v].push_back(i + 1);
		vs[i + 1] = v;
	}
/*	printf("----\n");
	for(int i = 0; i < 3; ++i){
		printf("%lld ", v[i]);
	}
	printf("\n");*/
	long long ans = 0;
	for(int i = 0; i < N; ++i){
		Vec tmp = mv(vs[N], ps[i]);
		Vec v = ad(vs[i], tmp, 1);
		if(mp.count(v) == 0) continue;
		vector<int> &vec = mp[v];
		int id = distance(vec.begin(), lower_bound(vec.begin(), vec.end(), i + 1));
		ans += (vec.size() - id);
	/*	for(int j = id; j < vec.size(); ++j){
			printf("%d %d\n", i, vec[j]);
		}*/
	}
	return ans;
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


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

typedef pair<int, int> P;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    

    int H, W, sx, sy;
    cin >> H >> W;
    char s[H][W];
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
          cin >> s[i][j];
        }
    }
        
    int ans = 0;
    for(int m=0;m<H;m++){
      for(int n=0;n<W;n++){
        if(s[m][n] == '#') continue;
        sx = m;
        sy = n;
        int dist[25][25];
        fill((int*)dist, (int*)(dist + H), INF);
        queue<P> que;
        dist[sx][sy] = 0;
        que.push(P(sx, sy));
        while(!que.empty()){
            P p = que.front();
            que.pop();
            int x = p.first;
            int y = p.second;
            
            for(int i = 0; i < 4; ++i){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx < 0 || nx >= H || ny < 0 || ny >= W)  continue;
                if(s[nx][ny] == '#')    continue;
                
                if(dist[nx][ny] > dist[x][y] + 1){
                    dist[nx][ny] = dist[x][y] + 1;
                    que.push(P(nx, ny));
                }
            }
            for(int a = 0; a < H; ++a){
                for(int b = 0; b < W; ++b){
                    if(dist[a][b] == INF)   continue;
                    ans = max(ans, dist[a][b]);
                }
            }
        }
      }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e2 + 5, M = 2 * N + 5;

char s[N];
bool vis[N];

int main(){
    int m;
    scanf("%s %d", s, &m);
    while(m--){
        int x;
        scanf("%d", &x);
        vis[x] = true;
    }
    int n = strlen(s), j, cnt = 0;
    for(j = 0 ; j < n ; ++j){
        bool done = false, ok = false;
        for(int i = s[j] - '0' ; i <= 9 ; ++i){
            if(!vis[i]){
                ++cnt;
                ok = true;
                done |= (i > s[j] - '0');
                printf("%d", i);
                break;
            }
        }
        if(!ok){
            ++n;
            break;
        }
        if(done){++j;break;}
    }
    int dig = -1;
    for(int i = (cnt == 0) ; i <= 10 && dig == -1; ++i)
        if(!vis[i])dig = i;
    while(j++ < n)printf("%d", dig);
    puts("");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	// str s;
	// int ans=0;
	scanf("%d %d", &a,&b);

	// printf("%d\n",ans);
	if(a>=10) printf("%d\n",b);
	else printf("%d\n",b+100*(10-a));
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
#define Length 80000
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

bool used[110];

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	return a.first * a.first + a.second * a.second > b.first*b.first + b.second * b.second;
}

void solve(int n) {
	vector<pair<int, int>>p(n), q(n);
	for (int i = 0;i < n;i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i].first >> q[i].second;
	}
	int dist = Length, flag = 0;
	int ans = 0;
	sort(p.begin(), p.end());
	for (int i = 0;i < n;i++) {
		dist = Length;
		flag = 0;
		for (int j = 0;j < n;j++) {
			if (!used[j]) {
				int x = q[j].first - p[i].first;
				int y = q[j].second - p[i].second;
				if ((x > 0) && (y > 0) && y < dist) {
					dist = y;
					flag = j;
				}
			}
		}
		if (dist < Length) {
			ans++;
			used[flag] = true;
		}
	}
	cout << ans << endl;
}

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

ll rightvalue[100010];
ll leftvalue[100010];
ll rightmaxvalue1[100010];
ll leftmaxvalue1[100010];
ll rightmaxvalue2[100010];
ll leftmaxvalue2[100010];

int main(void){
	ll n, c, ans = 0, tmp = 0;
	cin >> n >> c;
	vector<ll>x(n + 1), v(n + 1);
	x[0] = 0;
	for (ll i = 1;i <= n;i++) {
		cin >> x[i] >> v[i];
		rightvalue[i] = rightvalue[i - 1] + v[i] - (x[i] - x[i - 1]);
		rightmaxvalue1[i] = max(rightvalue[i], rightmaxvalue1[i - 1]);
		rightmaxvalue2[i] = max(rightvalue[i] - x[i], rightmaxvalue2[i - 1]);
	}
	leftvalue[1] = leftvalue[0] + v[n] - (c - x[n]);
	leftmaxvalue1[1] = leftvalue[1];
	leftmaxvalue2[1] = leftvalue[1] - c + x[n];
	for (ll i = 2;i <= n;i++) {
		leftvalue[i] = leftvalue[i - 1] + v[n - i + 1] - (x[n - i + 2] - x[n - i + 1]);
		leftmaxvalue1[i] = max(leftvalue[i], leftmaxvalue1[i - 1]);
		leftmaxvalue2[i] = max(leftvalue[i] - c + x[n - i + 1], leftmaxvalue2[i - 1]);
	}
	
	tmp = 0;
	for (ll i = 1;i <= n;i++) {
		ans = max(ans, rightvalue[i]);
		ans = max(ans, rightvalue[i] - x[i] + leftmaxvalue1[n - i]);
	}
	tmp = 0;
	for (ll i = 1;i <= n;i++) {
		ans = max(ans, leftvalue[i]);
		ans = max(ans, leftvalue[i] - (c - x[n - i + 1]) + rightmaxvalue1[n - i]);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){
    int n,d[100010];
    cin >> n;
    for(int i = 0;i < n;i++)cin >> d[i];
    sort(d,d + n);
    int a = d[(n-1)/2],b = d[n/2];
    cout << b - a;
    return 0;
}

Measured memory_bytes: 768
import sys
import numpy as np
import itertools

from collections import deque 
from functools import reduce

# input = sys.stdin.readline

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

a = [list(map(int, input().split()))]

a_np = np.array(a)
a_np = a_np.flatten()
a_np = np.hstack((a_np, k+a_np[0]))
a_sa = abs(a_np[:-1] - a_np[1:])
print(a_sa.sum() - a_sa.max())

Measured memory_bytes: 43032
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        Integer[] a = new Integer[n];
        
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();
        
        int alice = 0;
        int bob = 0;
        
        Arrays.sort(a, Collections.reverseOrder());
        
        for(int i = 0; i < n; i++){
            if(i % 2 == 0){
                alice+=a[i];
            }else{
                bob+=a[i];
            }
        }
        
        System.out.println(Math.abs(alice-bob));
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>

int a[200],b[200];
int main(){
    int n;
    scanf("%d",&n);
    memset(b,0,sizeof(b));
    int j = 0;
    b[0] = 1;
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        if(i && a[i] == a[i-1])
            b[j]++;
        if(i && a[i] != a[i-1])
        {
            j++;    b[j]++;
        }
    }
    int sum = 0;
    for(int i = 0 ; i <= j; i++){
        sum += b[i]/2;
        //printf("%d",b[i]);
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 128
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let m = xs[0];
   let n = xs[1];
   let r = 0;
   let d = 0;
   let x = m;
   let y = n;
   if(m >= n) {
        	while (n > 0) {
        		let r = m % n; 
        		m = n;     
        		n = r;     
        	}
        	d = m;
        }else{ 
        	while (m > 0) {
        		r = n % m; 
        		n = m;     
        		m = r;     
        	}
        	d = n;
        }
        let ans = x*y/d;
        console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(ALL(A), greater<ll> ());

    ll ans = 0;
    ans += A[0];
    for (int i = 1; i < N-1; i++) {
        ans += A[(i+1) / 2];
    }
    printf("%lld\n", ans);

}   

Measured memory_bytes: 4792
<?php

while(true){
    
    $inputs = explode(" ", trim(fgets(STDIN)));
    $h = $inputs[0];
    $w = $inputs[1];
    
    if($h == 0 && $w == 0){ break; }
    
    for ($i = 0; $i < $h; $i++) {
        
         for ($j = 0; $j < $w; $j++) {
             
            if(($i != 0) && ($i != ($h - 1)) && (($j != 0) && ($j != ($w - 1)))){
                echo ".";
            } else {
                echo "#";
            }
         }
        echo PHP_EOL;
    }
    echo PHP_EOL;
}

Measured memory_bytes: 15356
def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    import collections
    counter = collections.Counter(A)
    maxA = max(A)
    dp = [True for _ in range(max(A)+1)]
    for a in A:
        if counter[a] > 1:
            dp[a] = False
        for j in range(a+a, maxA+1, a):
            dp[j] = False
    #print(dp)
    print(sum(1 for a in A if dp[a]))

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 187760
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cstdlib> 
#include <string.h>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <ctime>
#include <algorithm>
#include <cmath>
#define PI 3.1415926535897932384626433832795l
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define deci(n) cout<<fixed<<setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i,a,b) for(int i = a; i < b; i++)
#define ForA1(i,a,b) for(int i = b - 1; i >= a; i--)
#define ForB1(i,a,b) for(int i = b; i > a; i--)
#define ForB(i,a,b) for(int i = a; i <= b; i++)
#define INT_SIZE 18 
#define maxn 3010
#define Maxn 100010

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;
 
ld dp[maxn][maxn][2], p[maxn]; 

int main()
{
    IOS;     
    int n; cin >> n;
    ForB(i,1,n) cin >> p[i];
    dp[1][1][0] = p[1];
    dp[1][0][1] = 1 - p[1];
    ForB(i,2,n){
        ForB(j,0,i){
            if(j > 0){
                dp[i][j][0] += (dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1]) * p[i];
            }
            dp[i][j][1] += (dp[i - 1][j][0] + dp[i - 1][j][1]) * (1 - p[i]); 
        }
    }
    ld ans = 0;
    int srt = n / 2 + 1;
    ForB(i,srt,n) ans += dp[n][i][0] + dp[n][i][1];
    deci(15);
    cout << ans << '\n'; 
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0 ;
}


Measured memory_bytes: 280960