akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<p> lr;
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    lr.emplace_back(l, r);
  }
  vector<int> ruiseki(n + 1, 0);
  for (int i = 1; i < n; i++) {
    ruiseki[i] = ruiseki[i - 1];
    if (s[i - 1] == 'A' && s[i] == 'C') {
      ruiseki[i]++;
    }
    // cout << ruiseki[i] << endl;
  }
  rep(i, q) {
    int ans = ruiseki[lr[i].second - 1] - ruiseki[lr[i].first - 1];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4732
// ConsoleApplication2.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int d;
	cin >> d;

	if (d == 25) {
		cout << "Christmas" << endl;
	}
	else if (d == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (d == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else {
		cout << "Christmas Eve Eve Eve" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from collections import Counter
from itertools import combinations

N, X, Y = map(int, input().split())

C = Counter(min(j - i, abs(X - 1 - i) + 1 + abs(Y - 1 - j)) for i, j in combinations(range(N), 2))

for i in range(1, N):
  print(C[i])

Measured memory_bytes: 3956
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << (2 * B == A + C ? "YES" : "NO") << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int r;
  cin >> r;
  cout << (r * r) << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
N = len(S)
def calc(s):
    ret = [0] * 26
    for ss in s:
        ret[ord(ss)-97] += 1
    return ret

X = calc(S)
Y = calc(T)
ma = 0
for i in range(26):
    ma = max(ma, -(-Y[i]//X[i])-1 if X[i] else (1<<100 if Y[i] else 0))
A = [i for i in range(26) if Y[i]]
if ma == 1<<100:
    print(-1)
else:
    NE = [[-1] * N for _ in range(26)]
    for a in A:
        b = -1
        for i in list(range(N)[::-1])*2:
            if NE[a][i] >= 0:
                break
            if b >= 0:
                NE[a][i] = b
            if ord(S[i]) - 97 == a:
                b = i
    ans = 0
    i = -1
    for t in T:
        ni = NE[ord(t)-97][i]
        ans += ni - i + (N if ni <= i else 0)
        i = ni
    print(ans)

Measured memory_bytes: 90532
from collections import deque

N = int(input())
A = list(map(int, input().split()))
minAbs = 10**10
countMinus = 0
S = 0
for a in A:
  countMinus += (1 if a < 0 else 0)
  S += abs(a)
  minAbs = min(minAbs, abs(a))
print(S-2*(0 if countMinus % 2 == 0 else minAbs))



Measured memory_bytes: 14660
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int n,k,d=0;
  cin >> n >> k;
  vector<int> a(n+1,0),b(n,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(b[a[i]-1]==0)d++;
    b[a[i]-1]++;
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  int ans=0;
  for(int i=d-1;d>k;i--){
    ans+=b[i];
    d--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
#define m int64_t
#define r(s,i,n) for(m i=s;i<n;i++)
m w[555][555],p[1234];
main(){m n;cin>>n;m t=0,k=555;r(2,i,1e4){bool a=true;r(2,j,i){if(i%j==0)a=false;}if(a)p[t]=i,t++;}r(0,i,k)r(0,j,k)if(i%2==j%2)w[i][j]=p[(i+j)/2]*p[(i+k*3-j)/2];r(0,i,k)r(0,j,k)if(w[i][j]==0&&i>0&&i<554)w[i][j]=w[i-1][j]*w[i+1][j]+1;r(0,i,n)r(0,j,n)cout<<w[i+1][j+1]<<" ";}

Measured memory_bytes: 6024
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n + 1), y(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  sort(x.rbegin(), x.rend());
  sort(y.begin(), y.end());
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    if (x[i] > y[i]) {
      ans += 2 * (x[i] - y[i]);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <cstring>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
//#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 8e3 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

string s, t;

inline void read() {
    cin >> s >> t;
}

inline void solve() {
    t.pop_back();
    if (s == t) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n;
    int x, y;
    
    scanf("%d", &n);
    
    x=800*n;
    y=n/15*200;
    
    printf("%d", x-y);
    
    return 0;
}



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


 
int main(){
  /*int n, i;
  cin >> n;
  
  vector<int> A(n);

  for (i = 0; i < n; i++) {
    cin >> A[i];
  }*/
  int n, ans;
  
  cin >> n;
  
  if(n%2 == 0){
    ans = n/2;
  }
  else ans = n/2 + 1;
  
  cout << ans << endl;
  
}

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

using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
int inf_int=1e9;
ll inf_ll=1e16;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
const double pi=3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define siz(a) a.size()
#define EPS 1e-7
#define next asdfafgasgasg
bool debug=0;
typedef long double dbl;
const int MAXN = 2e6;
const int MOD = 1e9 +7;


void solve()
{
    int n;
    cin >> n;
    int n1=n;
    n=3*n;
    vector<int> a;
    for(int i=1;i<=n;++i){
        int x;
        cin >> x;
        a.pb(x);
    }
    sort(a.begin(),a.end());
    ll sum=0;
    int cnt=0;
    for(int i=a.size()-2;i>=0 && cnt<n1;i=i-2){
        sum+=a[i];
        cnt++;
    }
    cout << sum<<"\n";
}


#define FILE "palindrome"
int main()
{
        #ifdef zxc
            freopen("input.txt","r",stdin);
 //          freopen("output.txt","w",stdout);
        #else
         //     freopen(FILE".in","r",stdin);
         //     freopen(FILE".out","w",stdout);
        #endif // zxc

     //  freopen(FILE".in","r",stdin);
     //   freopen(FILE".out","w",stdout);

     //   freopen("input.txt","r",stdin);
       // freopen("output.txt","w",stdout);

       if(!debug)
       {
            ios_base::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
       }

        int t=1;
        while(t--)
           solve();
        return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int n = 0;
  for(int i=0; i<3; i++) {
    if(S[i] == T[i]) {
      n++;
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    unordered_map<i64, int> cnt;
    i64 n, v;
    cin >> n >> v;
    vvi as(4, vi(n));
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < n; j++) {
            cin >> as[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cnt[as[2][i] + as[3][j]]++;
        }
    }

    i64 ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            i64 tmp = as[0][i] + as[1][j];
            i64 res = v - tmp;
            ans += cnt[res];
        }
    }

    cout << ans << endl;
}


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

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

    ll n; cin >> n;
    ll ans = 0LL;
    for(ll i = 0LL; i < n; ++i){
        if((i+1)%3 != 0 && (i+1)%5 != 0) ans += (i+1);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3612
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T inv[N+1];
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i = 0; i < N; i++)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i = N-1; i >= 0; i--)
            ifact[i] = (ifact[i+1]*(i+1))%M;
        inv[0] = 0;
        for (int i = 0; i < N; i++)
            inv[i+1] = (fact[i]*ifact[i+1])%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    constexpr T comb(T n, T r) {
        return (((fact[n]*ifact[r])%M)*ifact[n-r])%M;
    }
};

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ModFact<100000, ll, MOD> fact;

ll N;

int main() {
    fastio();
    ll N, ans = 0, prev, now;
    N = getint();
    prev = getint();
    // cin >> N;
    // cin >> prev;
    ll a = 0;
    REP(i, N-1) {
        now = getint();
        // cin >> now;
        a = (a + fact.inv[i+1]) % MOD;
        ans = (ans + a * (now - prev)) % MOD;
        prev = now;
    }
    printf("%lld\n", (ans * fact.fact[N-1])%MOD);
	return 0;
}


Measured memory_bytes: 2688
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N = d_in()
A_list = []
B_list = []
C_list = []
for _ in range(N):
    a, b = ds_in()
    A_list.append(a)
    B_list.append(b)
    C_list.append(a+b)

c_np = np.array(C_list)
c_idx = np.argsort(c_np)[::-1]

a_h, b_h = 0, 0
for i in range(N):
    if i % 2 == 0:
        a_h += A_list[c_idx[i]]
    else:
        b_h += B_list[c_idx[i]]
print(a_h - b_h)


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

typedef long long ll;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)

const int N=16;
const ll INF=1e18;
ll n,c[1<<N],dp[1<<N],a[N][N];

ll solve(ll mask) {
  if(dp[mask]!=-1)return dp[mask];
  ll res=c[mask];
  for(int s=(mask-1)&mask;s;s=(s-1)&mask)
    res=max(res,solve(s)+solve(mask^s));
  return dp[mask]=res;
}

int main() {
  ios::sync_with_stdio(false);
  memset(dp,-1,sizeof(dp));dp[0]=0;
  cin>>n;
  fore(i,0,n)fore(j,0,n)cin>>a[i][j];
  fore(i,0,1<<n)fore(j,0,n)fore(k,j+1,n)
        if((i&(1<<j))&&(i&(1<<k)))c[i]+=a[j][k];
  //fore(i,0,1<<n)cout<<bitset<16>(i)<<" : "<<c[i]<<endl;
  cout<<solve((1<<n)-1)<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int INF=-2000000000;
P f(int x){
  int a=x%10;
  int b=0;
  while(x){
    b=x;
    x=x/10;
  }
  return P(a,b);
}
int main() {
  int n;
  cin >> n;
  map<P,int> mp;
  for(int i=1; i<=n; i++){
    P p=f(i);
    mp[p]++;
  }
  ll ans = 0;
  for(int i=1; i<=n; i++){
    P p=f(i);
    P q(p.second,p.first);
    ans+=mp[q];
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		PriorityQueue<Double> pq = new PriorityQueue<>(Collections.reverseOrder());
		long sum = 0;
		for(int i=0; i<n; i++) {
		    pq.add(Double.parseDouble(sc.next()));
		}
		

		while(m > 0) {
		    double w = ((double)(pq.poll()) / 2.0);
		    pq.add(w);
		    m--;
		}
		
		for(int i=0; i<n; i++) {
		    sum += pq.poll();
		}
		System.out.println(sum);
	}
	
}


Measured memory_bytes: 50352
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926


int main(){
    int n;
    cin >> n;
    double s = 0, br=0, br1=0;
    for (int i = 1; i <= n; i++)
    {
        if(i % 2 != 0){
            s = s + i;
            br++;
        }
         else 
            br1++;
    }
    cout << setprecision(10) << br / (br + br1);
    
    
}

    

	


Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,w,h,x,y
    real(8)::a,b
   
    read(*,*) w,h,x,y

  
    write(*,'(f29.10)',advance='no') w/2.0_8*h
    if (mod(w,2)==1 .or. mod(h,2)==1)then
        write(*,*)0
    else
        if (x==w/2 .and. y==h/2) then
            write(*,*)1
        else
            write(*,*)0
        end if
    end if
  
    stop
end program sample
  



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

#define ll long long
#define inf 1e9
const int mxN = 1e6;
ll a[mxN + 10], b[mxN + 1];
int main()
{

	int n;
	cin >> n;
	vector<ll>h;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		h.push_back(x);
	}
	int max = INT_MIN;
	for (int i = 0; i < n; i++) {
		if (h[i] >=max) {
			max = h[i];
		} else {
			if (max - h[i] != 1) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1400
N=int(input())
S=input()
ans=[]
def Cha(x, N):
    a=(ord(x)+N)%26
    if a in range(0,13):
        return(chr(a+78))
    if a in range(13, 26):
        return(chr(a+52))
for i in range(len(S)):
    ans.append(Cha(S[i], N))
print(''.join(ans))

Measured memory_bytes: 3064
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

llong sum1toN(llong N) {
   return N*(N+1)/2;
}

const int INF = 1000000000;
VI bfs(const VVI& G, int src) {
   queue<int> q;
   q.push(src);
   VI D(G.size(), INF);
   D[src] = 0;
   while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int v : G[u]) {
         if (D[v] > D[u] + 1) {
            D[v] = D[u] + 1;
            q.push(v);
         }
      }
   }
   return D;
}

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

   int N, X, Y;
   cin >> N >> X >> Y;
   --X, --Y;

   VVI adj(N);
   REP(j, N-1) {
      adj[j].push_back(j+1);
      adj[j+1].push_back(j);
   }
   adj[X].push_back(Y);
   adj[Y].push_back(X);

   VI freq(N);
   REP(u, N) {
      VI D = bfs(adj, u);
      FOR(v, u+1, N-1) {
         ++freq[ D[v] ];
      }
   }

   FOR(k, 1, N-1)
      cout << freq[k] << '\n';

   return 0;
}


Measured memory_bytes: 384
x=int(input())

if x>=1800 : print(1)
elif x>=1600 : print(2)
elif x>=1400 : print(3)
elif x>=1200 : print(4)
elif x>=1000 : print(5)
elif x>=800 : print(6)
elif x>=600 : print(7)
else : print(8)


Measured memory_bytes: 9160
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<tuple>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
int main(){
    int n;
    cin>>n;
    int a, b=0;
    rep(i, n){
        cin>>a;
        b+=a-1;
    }
    cout<<b<<endl;
    return 0;
}

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

int N;
int low;
int high;
bool b;
char buf[114514];

bool Query(int x) {
  printf("%d\n", x);
  scanf("%s", buf);
  string s = buf;
  if (s == "Vacant") exit(0);
  return s == "Male";
}

bool Check(int x) {
  return b == Query(x);
}

int main() {
  setbuf(stdout, NULL);

  scanf("%d", &N);
  b = Query(0);

  low = -1;
  high = (N+1)/2;
  while (high - low > 1) {
    int mid = (low+high)/2;
    if (Check(mid*2)) low = mid;
    else high = mid;
  }

  for (int i=low*2+1; i<N; i++) {
    Check(i);
  }
}


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

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >>x >> y;
    
    long long ans = LONG_MAX;
    for (int ab = 0; ab <= max(x, y); ab++){
        int numA = max(x - ab, 0);
        int numB = max(y - ab , 0);
        ans = min(ans, (long long)2 * ab * c + numA * a + numB * b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce

def main():
    n = int(input())
    ans = 0
    for i in range(1,10+1):
        num = 1000*i
        if num >= n:
            ans = i
            break

    print(abs(1000*ans - n))


if __name__ == "__main__":
    main()

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll EXA = 1000000000000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int a, b, c; cin >> a >> b >> c;
  if(a == b && b == c) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
s = input()
t = input()

if s == t:
    print("No")
    exit()

s = sorted(s)
t = sorted(t,reverse=True)

s = "".join(s)
t = "".join(t)


list =[s,t]
list = sorted(list)

if list[0] == s:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;
 
typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;




#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); 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 MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);


ll N, M;
ld ph;
long double p[3000][3000];

int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		cin >> N;


		for (int i = 1; i <= N; i++) {
				ld ph;
				cin >> ph;
				if (i == 1) {
						p[1][1] = ph;
						p[1][0] = 1 - ph;
						continue;
				}

				for (int j = 0; j <= i; j++) {
						if (j - 1 >= 0) p[i][j] += p[i - 1][j - 1] * ph;
						p[i][j] += p[i - 1][j] * (1 - ph);
				}
		}

		ld ans = 0;

		for (int i = N/2 + 1; i <= N; i++) {
				ans += p[N][i];
		}

		cout << fixed << setprecision(10) << ans << endl;

}


Measured memory_bytes: 139008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int r,g;
  cin >> r >> g;
  cout << 2*g-r << endl;
}

Measured memory_bytes: 256
#python3
from bisect import bisect_left
def main():
    n = int(input())
    L = [int(i) for i in input().split()]
    L.sort()
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            ab = L[i]+L[j]
            r = bisect_left(L, ab)
            l = j+1
            ans += r-l
    print(ans)
main()

Measured memory_bytes: 3188
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;

int n, l;
int a[100002];
long long int t[100002];
long long int ans;
typedef pair<int, int> P;
priority_queue<P, vector<P> > q;

int main(){
	scanf("%d %d", &n, &l);
	for(int i=1; i<n+1; i++){
		scanf("%d", &a[i]);
		q.push(P(a[i], i));
	}
	while(!q.empty()){
		P p = q.top(); q.pop();
/*		if(p.first > a[p.second-1] && p.first > a[p.second+1]) t[p.second] = l - a[p.second];
		else if((a[p.second-1] > a[p.second+1] && a[p.second+1] > p.first) || (a[p.second+1] > p.first && p.first > a[p.second-1])) t[p.second] = t[p.second+1] + l - p.first;
		else t[p.second] = t[p.second-1] + l - p.first;
		ans = max(ans, t[p.second]);
*/
		t[p.second] = l - p.first + max(t[p.second-1], t[p.second+1]);
		ans = max(ans, t[p.second]);
		//printf("%d %lld\n", p.first, t[p.second]);
	}
	printf("%lld\n", ans);
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int m, k;
    cin >> m >> k;
    if(m == 0) {
        if(k == 0) cout << "0 0" << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(m == 1) {
        if(k == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
        return 0;
    }
    if((1<<m)-1 < k) {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < (1<<m); i++) {
        if(i != k) cout << i << " ";
    }
    cout << k << " ";
    for(int i = (1<<m)-1; i >= 0; i--) {
        if(i != k) cout << i << " ";
    }
    cout << k <<  endl;
}


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

int main(){
	int A,B,j;
	cin >>A>>B;
	for(int i=A;i<=B;i++ ){
		if(i/10000==i%10)
			if((i/1000-(i/10000)*10)==(i%100)/10)
				j++;
	}
	cout << j << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>

using namespace std;

int main(){

    int n, l, sum, res;

    cin >> n >> l;

    int apple[n];

    res = l;

    for(int i = 0;i < n;i++, l++){

        apple[i] = l;

        if(abs(res) > abs(l)){

            res = l;
        }
    }

    for(int i = 0;i < n;i++){

        if(apple[i] == res){

            apple[i] = 0;
            break;
        }
    }

    sum = accumulate(apple, apple + n, 0);
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            var ans = 0;

            var leng = s.Length-1;
            for (int i = 0; i < s.Length/2; i++)
            {
                if (s[i] != s[leng - i])
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;

int main(void)
{
    int v[3];
    int K;
    cin >> v[0] >> v[1] >> v[2] >> K;

    sort(v, v + 3);
    for (int i = 0; i < K; ++i)
    {
        v[2] *= 2;
    }
    cout << v[0] + v[1] + v[2] << endl;

    return 0;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	int N;
	cin >> N;
	vector <int> vec( N );
	rep( i, 0, N )
	cin >> vec[ i ];
	sort_asc( vec );
	ll sum = 0;
	rep( i, 3, N + 2 ){
		sum += vec[ N - i / 2 ];
	}
	cout << sum << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
//#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <unordered_set>
using namespace std;
#define dbg(x) cerr << #x " = " << x <<endl;
const int MAXN = 1005;
int map[MAXN][MAXN]; 
int h, w;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
typedef struct
{
	int x, y;
	int cnt;
	void info()
	{
		dbg(x);
		dbg(y);
		dbg(cnt);
	}
}point;
vector<point> s; 
queue<point> q;
int num[MAXN][MAXN];
bool check(point a)
{
	if(a.x <= 0 || a.y <= 0 || a.x > h || a.y > w)
	{
		return false;
	}
	if(map[a.x][a.y])
	{
		return false;
	}
	return true;
}

void bfs()
{
	point now, next;
	now = q.front();
	while(!q.empty())
	{
		if(s.size() == h*w)
		{
			
			cout << (q.back()).cnt << endl;
			return ;
		}
		for(int i = 0; i < 4; i++)
		{
			next.x = now.x + dx[i];
			next.y = now.y + dy[i];
			next.cnt = now.cnt + 1;
			if(check(next))
			{
				map[next.x][next.y] = 1;
				s.push_back(next);
				q.push(next);
			}
		}
		q.pop();
		now = q.front();

	}
}

int main()
{

	cin >> h >> w;
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			char a;
			cin >> a;
			if(a == '.')
			{
				map[i][j] = 0;
			}
			if(a == '#')
			{
				map[i][j] = 1;
				point tmp;
				tmp.x = i;
				tmp.y = j;
				tmp.cnt = 0;
				q.push(tmp);
				s.push_back(tmp);
			}
		}
	}
	bfs();
	
	

} 

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

int main(){
   
   string s;
   cin >> s;
   int sum = 0;
   for(char c: s){
      sum += (c - '0');
   }
   cout << (sum % 9 == 0 ? "Yes" : "No");
   return 0;
}

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

int main() {
    char c;
    cin >> c;
    if (c == 'a') cout << "vowel";
    else if (c == 'e') cout << "vowel";
    else if (c == 'i') cout << "vowel";
    else if (c == 'o') cout << "vowel";
    else if (c == 'u') cout << "vowel";
    else cout << "consonant";
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll find(ll u,ll v,string &str){
    if(v<0 || u>=str.size())
    return 0;
  //  if(v<u)
//    return 0;
    if(str[u]==str[v])
    return find(u+1,v-1,str)+1;
    else {
        return max(find(u+1,v,str),find(u,v-1,str));
    }
}

void solve(){
    string str;
    cin>>str;
   // cout<<str.size()-find(0,str.size(),str);
   ll i=0,n=str.size()-1;
   ll ans=0;
   while(i<n){
    if(str[i++]!=str[n--])
    ans++;
   }
   cout<<ans<<endl;

}

int main(){
    ll t=1;
//cin>>t;
    while(t--){
     solve();
//     cout<<endl;
    }
    return 0;
}


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

 
int main() {

  int n,a,b;
  cin>>n>>a>>b;

  if(n*a > b){
    cout << b << endl;
  }
  else{
    cout << n*a << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8


int main(){
    int n,c,x;
    while(1){
        c=n=x=0;
        cin >> n >> x;
        if(n==0 && x==0){
            break;
        }
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if((x-i-j)>j && (x-i-j)<=n){
                    c++;
                }
            }
        }
        cout << c << endl;
    }
}


Measured memory_bytes: 3112
from collections import deque
h,w = map(int,input().split())
mz = []
q = deque()
for i in range(h):
    mz.append(list(input()))
    ls = [[i,j,0] for j, a in enumerate(mz[-1]) if a == '#'] #i黒のところのindexをqueに追加
    q.extend(ls)


delta = [[-1,0],[0,-1],[1,0],[0,1]]
while q:
    y,x,c = q.popleft()
    for dy,dx in delta:
        if (0<= y+dy <h) and (0<=x+dx <w):
            if mz[y+dy][x+dx] == ".":
                mz[y+dy][x+dx]="#" #黒に置き換え
                q.append([y+dy,x+dx,c+1])

            else: #すでに黒なら訪問しなくてよい
                pass

print(c)#cは最後にpopされたcost


Measured memory_bytes: 158084
S = list(input())

def is_good(S):
    flag = 0
    s_tmp = 0
    for s in S:
        if s == s_tmp:
            flag += 1
        s_tmp = s
    return flag

flag = is_good(S)

if flag > 0:
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 38256
import sys

T1,T2 = map(int,input().split())

A1,A2 = map(int,input().split())

B1,B2 = map(int,input().split())


if (A1 * T1 + A2 * T2) == (B1*T1 + B2*T2):
    print ("infinity")
    sys.exit()

elif (A1 > B1 and A2 > B2) or (A1 < B1 and A2 < B2):
    print (0)
    sys.exit()

else:

    pl = abs ( A1 * T1 - B1 * T1 )
    mi = abs ( A2 * T2 - B2 * T2 )

    #print (pl,mi)

    if pl > mi:
        print (0)

    else:

        if pl < (mi - pl):
            print (1)

        #print ("amari" , pl % (mi - pl))
        elif pl % (mi - pl) != 0:
            print ( pl // (mi - pl) * 2 + 1)
        else:
            print (pl // (mi - pl) * 2)

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

struct Edge {
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};

using Graph = vector<vector<Edge>>;

vector<int> color;
void dfs(const Graph &G, int v, int cur = 0) {
  color[v] = cur;
  for (auto next_v : G[v]) {
    if (color[next_v.to] != -1) continue;

    if (next_v.weight % 2 == 0) dfs(G, next_v.to, cur);
    else dfs(G, next_v.to, 1 - cur);
  }
}

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

  Graph G(1e5);
  for (int i = 0; i < N; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
  }

  color.assign(N+1, -1);
  for (int v = 1; v <= N; ++v) {
    if (color[v] != -1) continue;
    dfs(G, v);
  }

  for (int v = 1; v <= N; ++v) {
    cout << color[v] << endl;
  }
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int a[26][2];

int main() {
	string A;
	cin >> A;
	rep(i,A.size()) {
		a[A[i]-'a'][1]++;
	}
	ll res = 0;
	rep(i,A.size()) {
		a[A[i]-'a'][0]++;
		ll t = A.size()-(i+1);
		t = t - (a[A[i]-'a'][1] - a[A[i]-'a'][0]);
		res += t;
	}
	cout << res+1 << endl;
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
int X[100010], L[100010];
int ans=0, cur=-100000010;
P itv[100010];

int main()
{
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,0,N){
        cin >> X[i] >> L[i];
        itv[i].first = X[i]+L[i];
        itv[i].second = X[i]-L[i];
    }
    sort(itv, itv+N);
    REP(i,0,N){
        if (cur<=itv[i].second){
            // CO(i);
            ++ans;
            cur=itv[i].first;
        }
    }
    CO(ans);
    return 0;
}

Measured memory_bytes: 1792
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int base = 0;
	for (int i = 0; i < n-1; i++) {
		if (s[i] == 'R' && s[i + 1] == 'R')base++;
	}

	for (int i = n - 1; i >= 1; i--) {
		if (s[i] == 'L' && s[i - 1] == 'L')base++;
	}

	int kireme = 0;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[i + 1])kireme++;
	}

	int kaisuu = min(kireme, k);

	int ret = min(n - 1, base + kaisuu * 2);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

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

  ll A, B;
  std::cin >> A >> B;

  if (A > 9 || B > 9) fail();
  print(A * B);

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x

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

    int ac = 1;
    int ans = 0;
    for (int ac = 1; n >= ac; ac *= k) {
        ++ans;
    }

    cout << ans;

    return 0;
}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;


int N, L[500000], R[500000], depth[500000];
int64 sub[500000], dp1[500000], dp2[500000];

int main()
{
  scanf("%d", &N);
  int ptr = N - 1;

  for(int i = 0; i < N - 1; i++) {
    scanf("%d %d", &L[i], &R[i]);
    --L[i];
    --R[i];
    depth[L[i]] = depth[i] + 1;
    depth[R[i]] = depth[i] + 1;
  }

  sub[N - 1] = 1;
  dp1[N - 1] = dp2[N - 1] = 0;
  for(int i = N - 2; i >= 0; i--) {
    sub[i] = sub[L[i]] + sub[R[i]];
    dp1[i] = dp1[L[i]] + dp1[R[i]] + sub[i];
    dp2[i] = dp1[L[i]] + sub[L[i]] + dp2[R[i]] + 1;
    dp2[i] = min(dp2[i], dp1[R[i]] + sub[R[i]] + dp2[L[i]] + 1);
    dp2[i] = min(dp2[i], dp2[L[i]] + dp2[R[i]] + depth[i] + 2);
  }
  cout << dp2[0] << endl;
}


Measured memory_bytes: 20692
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;cin>>n;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    if(a==b){
      cout<<2*(a-1)<<endl;
      continue;
      }
    ll ret=sqrt(a*b);
    ll ans=(a*b-1)/ret+ret-2;
    cout<<ans<<endl;
    }
  
  return 0;
  }


Measured memory_bytes: 256
x,y = map(int,input().split())
ans = 10**10
if x<=y: ans = min(ans,y-x)
if -x<=y: ans = min(ans,1+y-(-x))
if x<=-y: ans = min(ans,-y-x+1)
if -x<=-y: ans = min(ans,-y-(-x)+2)
print(ans)


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

class Main {

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

    public static void main(String[] args) {
        String s = sc.next();
        int idx = 0;
        for (int i = 2; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'C') {
                idx = i;
                break;
            }
        }
        boolean allLower = true;
        for (int i = 1; i < s.length(); i++) {
            if(i != idx && s.charAt(i) < 97) {
                allLower = false;
            }
        }
        if (s.charAt(0) == 'A' && idx != 0 && allLower) {
            System.out.println("AC");
        } else {
            System.out.println("WA");
        }
    }
}

Measured memory_bytes: 21844