akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<ll, ll>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, D;
    cin >> n >> D;
    vector<PR> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ll x = D * D;
        ll y = a[i].first * a[i].first;
        ll z = a[i].second * a[i].second;
        if (y + z <= x) {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;
 
int _;

//========================================================================
char s[10];
//========================================================================
int main()
{
    scanf("%s",s);
    if(s[0]<='Z'&&s[0]>='A') puts("A");
    else if(s[0]<='z'&&s[0]>='a') puts("a");
    return 0;
}


Measured memory_bytes: 3656
main = do
    [a, b, c, d] <- map read . words <$> getLine
    putStrLn $ if ans a b c d then "Yes" else "No"

ans a b c d = cond1 || (cond2 && cond3)
    where
        cond1 = abs (a - c) <= d
        cond2 = abs (a - b) <= d
        cond3 = abs (b - c) <= d


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

using namespace std;
using ll = long long;

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

    int n, a;
    cin >> n;
    bool approved = true;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        if(!(a & 1) && a % 3 != 0 && a % 5 != 0) {
            approved = false;
            break;
        }
    }

    cout << (approved ? "APPROVED" : "DENIED") << "\n";

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N;
    cin >> N;

    cout << pow(2, (int)log2(N)) << endl;
    return 0;
}

Measured memory_bytes: 384
/*
 * 2468.cc: Cache Control
 */

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

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;

/* typedef */

struct Entry {
  int id;
  struct Entry *prev, *next;
};

typedef map<int,Entry *> mie;

/* global variables */

mie idmap;
Entry heap[MAX_N];

/* subroutines */

/* main */

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

  int cn = 0, hn = 0;
  Entry cache;
  cache.id = -1;
  cache.prev = cache.next = &cache;

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

    mie::iterator mit = idmap.find(id);
    Entry *ep;
    
    if (mit == idmap.end()) {
      ep = idmap[id] = &heap[hn++];
      ep->id = id;
    }
    else {
      ep = mit->second;
      ep->prev->next = ep->next;
      ep->next->prev = ep->prev;
      cn--;
    }

    cache.prev->next = ep;
    ep->prev = cache.prev;
    cache.prev = ep;
    ep->next = &cache;
    cn++;

    if (cn > m) {
      ep = cache.next;
      ep->prev->next = ep->next;
      ep->next->prev = ep->prev;
      cn--;
      idmap.erase(ep->id);
    }
  }
  //printf("cn=%d, hn=%d\n", cn, hn);

  for (Entry *ep = cache.prev; ep != &cache; ep = ep->prev)
    printf("%d\n", ep->id);

  return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

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 main() {
    int c[3][3], a[3][3], b[3][3];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> c[i][j];
        }
    }

    bool f;
    rep(i, 101) {
        rep(j, 101) {
            rep(k, 101) {
                f = true;
                for (int l = 0; l < 3; ++l) {
                    b[0][l] = c[0][l] - i;
                    b[1][l] = c[1][l] - j;
                    b[2][l] = c[2][l] - k;
                    if (b[0][l] < 0 || b[0][l] > 100)
                        f = false;
                    if (b[1][l] != b[0][l] || b[2][l] != b[0][l])
                        f = false;
                }
                if (f) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //auto dp=make_v<int>(4,h,w);
    //fill_v(dp,0);
    string s;
    cin >> s;
    bool sflag = false;
    bool nflag = false;
    bool eflag = false;
    bool wflag = false;
    rep(i,sz(s)){
        if(s[i] == 'S') sflag = true;
        if(s[i] == 'N') nflag = true;
        if(s[i] == 'E') eflag = true;
        if(s[i] == 'W') wflag = true;
    }
    if(sflag && !nflag) print("No");
    else if(!sflag && nflag) print("No");
    else if(eflag && !wflag) print("No");
    else if(!eflag && wflag) print("No");
    else print("Yes");
}


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

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

  int cnt =0, cnt1=0;
  int x =0;
  for(int i=1; i<=n; i++){
    cnt =0;
    x = i;
    while(x!=0){
      x /= 10;
      cnt++;
    }
    if(cnt%2==1)cnt1++;
  }
  cout << cnt1;

}


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

using namespace std;

static long long west = -60000000000;
static long long east =  60000000000;

long long dist(long long a, long long b, long long x) {
  return abs(x - a) + abs(a - b);
}

vector<long long> lazy_faith(
    long long a, 
    long long b,
    long long q,
    long long s[], 
    long long t[], 
    long long x[]) {
  vector<long long> ans;
  vector<long long> ss;
  
  ss.push_back(west);
  for(int i=0;i<a;i++) {
    ss.push_back(s[i]);
  }
  ss.push_back(east);
  
  vector<long long> tt;
  tt.push_back(west);
  for(int i=0;i<b;i++) {
    tt.push_back(t[i]);
  }
  tt.push_back(east);

  // std::lower_bound 指定された要素以上の値が現れる最初の位置のイレテータを返す
  // upper_bound 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
  // 返値
  // https://qiita.com/ganariya/items/33f1326154b85db465c3
  for(int i=0;i<q;i++) {
    long long xx = x[i];

    auto it = lower_bound(ss.begin(), ss.end(), xx);
    long long sa = ss[distance(ss.begin(), it) -1];

    it = upper_bound(ss.begin(), ss.end(), xx);
    long long sb = ss[distance(ss.begin(), it)];

    it = lower_bound(tt.begin(), tt.end(), xx);
    long long ta = tt[distance(tt.begin(), it) -1];

    it = upper_bound(tt.begin(), tt.end(), xx);
    long long tb = tt[distance(tt.begin(), it)];

    // cout << "sa: " << sa << " sb: " << sb << " ta: " << ta << " tb: " << tb << endl;

    // sa ta
    // sb ta
    long long result = min(dist(sa, ta, xx), dist(sb, ta, xx));
    // ta sa
    result = min(result, dist(ta, sa, xx));
    // tb sa
    result = min(result, dist(tb, sa, xx));
    // sa tb
    result = min(result, dist(sa, tb, xx));
    // sb tb
    result = min(result, dist(sb, tb, xx));
    // ta sb
    result = min(result, dist(ta, sb, xx));
    // tb sb
    result = min(result, dist(tb, sb, xx));
    ans.push_back(result);
  }
  return ans;
}
int main() {
  long long a, b, q;
  cin >> a;
  cin >> b;
  cin >> q;
  long long s[a];
  long long t[b];
  long long x[q];
  for(int i=0;i<a;i++) {
    cin >> s[i];
  }
  for(int i=0;i<b;i++) {
    cin >> t[i];
  }
  for(int i=0;i<q;i++) {
    cin >> x[i];
  }
  vector<long long> ans = lazy_faith(a, b, q, s, t, x);
  for(int i=0;i< ans.size();i++) {
    cout << ans[i];
    if(i-1 != ans.size()) {
      cout << endl;
    }
  }
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
#define ll long long
#define str string
#define optimizator ios_base::sync_with_stdio(0);
using namespace std;
int main(){
	ll n,m;
	cin>>n>>m;
	if(n==m){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

double dp[64][8192];
int X, Y, Z, N, E, A;
int V[4];
int m[64][2];

int main(){
  while(scanf("%d%d%d", &X, &Y, &Z) && X+Y+Z){
    memset(dp, 0, sizeof(dp));
    memset(m, 0, sizeof(m));
    rep(i, X) scanf("%d", V+i);
    rep(i, Z){
      scanf("%d%d%d", &N, &E, &A);
      m[N][0] = E; m[N][1] = A;
    }
    //    rep(i, Y) printf("%d %d %d\n", i, m[i][0], m[i][1]);
    dp[0][0] = 1;
    rep(i, Y) rep(j, 8192) rep(k, X){
      //      printf("%d %d %d\n", i, j, k);
      if(i + V[k] >= Y) dp[Y][j] += dp[i][j]/X;
      else if(m[i + V[k]][0] == 1) dp[min(Y, i+V[k]+m[i+V[k]][1])][j] += dp[i][j]/X;
      else if(m[i + V[k]][0] == 2) dp[i+V[k]][j+m[i+V[k]][1]] += dp[i][j]/X;
      else if(m[i + V[k]][0] == 3) dp[i+V[k]][max(0, j-m[i+V[k]][1])] += dp[i][j]/X;
      else dp[i+V[k]][j] += dp[i][j]/X;
    }

    double res = 0;
    /*    rep(i, 10){
      rep(j, 10) printf("%lf ", dp[i][j]);
      puts("");
      }*/
    rep(i, 8192) res += dp[Y][i] * i;
    printf("%d\n", (int)res);
  }
  return 0;
}

Measured memory_bytes: 5292
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200005;
int a[maxn];
long long pre[maxn];
int seq[maxn];
bool cmp(const int &a,const int &b){
  return pre[a]<pre[b];
}
int c[maxn];
int sum(int x){
  int ans=0;
  for(;x;x-=x&(-x))ans+=c[x];
  return ans;
}
void add(int x){
  for(;x<maxn;x+=x&(-x))c[x]++;
}
int main(){
  int n,k;scanf("%d%d",&n,&k);
  for(int i=1;i<=n;++i)scanf("%d",a+i),a[i]-=k;
  for(int i=1;i<=n;++i)pre[i]=pre[i-1]+a[i];
  for(int i=1;i<=n;++i)seq[i]=i;
  sort(seq,seq+n+1,cmp);
  long long old=-100000000000;int tot=0;
  for(int i=0;i<=n;++i){
    if(pre[seq[i]]!=old){
      old=pre[seq[i]];
      ++tot;
    }
    pre[seq[i]]=tot;
  }
  long long ans=0;
  for(int i=0;i<=n;++i){
    ans+=sum(pre[i]);
    add(pre[i]);
  }
  printf("%lld\n",ans);
  return 0;
}


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

char c[101][101] = { 0 };
int x, y;

void move_tile() {
	if (c[y][x] == '^') {
		c[y][x] = 'l';
		y = y - 1;
		move_tile();
	}
	else if (c[y][x] == 'v') {
		c[y][x] = 'l';
		y = y + 1;
		move_tile();
	}
	else if (c[y][x] == '<') {
		c[y][x] = 'l';
		x = x - 1;
		move_tile();
	}
	else if (c[y][x] == '>') {
		c[y][x] = 'l';
		x = x + 1;
		move_tile();
	}
	else {
		return;
	}

}

int main(void) {
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0)return 0;
		for (int i = 0; i <h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> c[i][j];
			}
		}

		x = y = 0;
		move_tile();

		if (c[y][x] == 'l') {
			cout << "LOOP" << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}

}

Measured memory_bytes: 1168
#include <iostream>
using namespace std;
int main() {
	cout << 40 << endl;
	for (int i = 0; i < 40; ++i) {
		for (int j = 0; j < 40; ++j) {
			cout << ((i < 35) != (j < 35) || (i != j && i >= 35 && j >= 35) ? "Y" : "N");
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
N,M=map(int,input().split())
K=[]
S=[]
ans=0
for i in range(M):
    tmp=list(map(int,input().split()))
    k,s=tmp[0],tmp[1:]
    K.append(k)
    S.append(s)
p=list(map(int,input().split()))
for s in range(2**N):
    cnt=[0]*M
    f=1
    for i in range(M):
        k=S[i]
        for j in k:
            if (s>>(j-1)&1):
                cnt[i]+=1
        if cnt[i]%2!=p[i]:
            f=0
            break
    if f==1:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, N) for(int i = 0, i##_len = (N); i < i##_len; ++i)
#define REPS(i, N) for(int i = 1, i##_len = (N); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const ll INF = 1e15;

using namespace std;

struct Edge {
  int to, cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
};

int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M], c[M];
  vector<vector<Edge>> g = vector<vector<Edge>>(N + 1);
  REP(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    g[a[i]].push_back(Edge(b[i], -c[i]));
  }

  vector<ll> d = vector<ll>(N + 1, INF);
  vector<bool> neg = vector<bool>(N + 1, false);
  d[1] = 0;
  REP(i, N) {
    REPS(v, N + 1) {
      REP(k, g[v].size()) {
        Edge e = g[v][k];
        if(d[v] != INF && d[v] + e.cost < d[e.to]) {
          d[e.to] = d[v] + e.cost;
          if(i == N - 1) {
            neg[e.to] = true;
          }
        }
      }
    }
  }
  if(neg[N]) {
    cout << "inf" << endl;
  } else {
    cout << -d[N] << endl;
  }
}


Measured memory_bytes: 384
// ABC088D
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <functional>
#include <set>
#include <iterator>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
   int a, b, c, d;
   cin >> a >> b >> c >> d;
   if ((abs(a-b) <= d && abs(b-c)<=d) || (abs(a-c) <=d)) {
      puts("Yes");
   } else {
      puts("No");
   }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	long long n;
	long long x, y, z;
	scanf("%lld", &n);
	scanf("%lld %lld", &x, &y);
	z = abs(y - x);
	if (z % 2 == 0) {
		z /= 2;
		printf("%lld\n", z);
		return 0;
	}
	z = x + y;
	z = min(z - 2, 2 * n - z);
	z = (z + 1) / 2;
	printf("%lld\n", z);


	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main() {
  
  string S;
  cin >> S;

  int N = S.size();
  int b = (N-1)/2,a = (N+3)/2;
  int h = 0,t = b-1;
  while(t-h>=1) {
    if(S[h] != S[t]) {
      cout << "No" << endl;
      return 0;
    }
    h++; t--;
  }

  h = a-1;
  t = N-1;
  while(t-h>=1) {
    if(S[h] != S[t]) {
      cout << "No" << endl;
      return 0;
    }
    h++; t--;
  }

  h = 0;
  t = N-1;
  while(t-h>=1) {
    if(S[h] != S[t]) {
      cout << "No" << endl;
      return 0;
    }
    h++; t--;
  }

  cout << "Yes" << endl;


}


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

int main() {
    int n;
    cin >> n;
    int mn = 1000000007;
    int a;
    long long s = 0;
    bool z = false;
    int m = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a < 0) {
            m++;
        } else if (a == 0) {
            z = true;
        }
        a = abs(a);
        s += a;
        mn = min(a, mn);
    }

    if (z) {
        cout << s << endl;
    } else {
        if (m % 2 == 0) {
            cout << s << endl;
        } else {
            cout << (s - mn * 2) << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int n;
    cin >> n;
    UnionFind all(200000);
    UnionFind fi(100000);
    vector<pair<int, int>> z(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        all.merge(a - 1, 100000 + b - 1);
        z.at(i).first = b;
        z.at(i).second = a;
    }
 
    sort(z.begin(), z.end());
    for (int i = 0; i < n-1; i++) {
        if (z.at(i).first == z.at(i + 1).first)fi.merge(z.at(i).second - 1, z.at(i + 1).second - 1);
        
    }
    ll ans = -1 * n;
    for (int i = 0; i < 100000; i++) {
       ans += all.size(i) - fi.size(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int solve(vector<int> v,int max_del_num)
{
    sort(v.begin(),v.end());
    int sum = 0;
    for(int x:v)
        sum += x;
    for(int i=0;i<max_del_num && i<v.size();++i)
    {
        if(v[i] < 0)
        {
            sum -= v[i];
        }else
            break;
    }
    return sum;
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(int i=1;i<=n;++i)cin>>v[i];
    int ans = 0;
    for(int l=0;l<=k;++l)
    {
        for(int r=0;r+l<=k;++r)
        {
            vector<int> con;
            for(int i=1;i<=l&&i<=n;++i)con.push_back(v[i]);
            for(int i=n;i>n-r&&i>l;--i)con.push_back(v[i]);
            ans=max(ans,solve(con,k-(l+r)));
        }
    }
    cout<<ans;
}

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

int main()
{
    map<string, int> hs;
    hs["SUN"] = 7, hs["SAT"] = 6, hs["FRI"] = 5, hs["THU"] = 4, hs["WED"] = 3, hs["TUE"] = 2, hs["MON"] = 1;
    string s;
    cin >> s;
    if (s == "SUN") cout << 7 << endl;
    else cout << hs["SUN"]-hs[s] << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n, m;
    cin >> n >> m;
    vector<Int> v(n, -1);
    bool result = true;
    for (Int i = 0; i < m; ++i) {
        Int s, c;
        cin >> s >> c;
        --s;
        if (v[s] == -1) {
            v[s] = c;
        } else if (v[s] == c) {
        } else {
            result = false;
        }
    }

    if (n == 1) {
        if (v[0] == -1) {
            v[0] = 0;
        }
    } else {
        if (v[0] == 0) {
            result = false;
        } else if (v[0] == -1) {
            v[0] = 1;
        }
    }
    for (Int i = 1; i < n; ++i) {
        if (v[i] == -1) {
            v[i] = 0;
        }
    }

    Int answer = 0;
    if (!result) {
        answer = -1;
    } else {
        for (Int i = 0; i < n; ++i) {
            answer *= 10;
            answer += v[i];
        }
    }
    cout << answer << endl;
    return 0;
}



Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int L = sc.nextInt();
			
			if(L == 0){
				break;
			}
			
			int over = -1;
			for(int i = 0; i < 12; i++){
				L -= (sc.nextInt() - sc.nextInt());
				if(over == -1 && L <= 0){
					over = i+1;
				}
			}
			
			System.out.println(over > 0 ? over+"" : "NA");
			
		}
		
	}

}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const ll LIM = 1000000000000000000;

int main()
{
    int N; cin >> N;
    ll sum = 1;
    bool isOK = true;
    ll A[N];
    rep(i,N){
        cin >> A[i];
    }
    sort(A, A+N);
    rep(i,N){
        double s_log = log10(sum);
        double a_log = log10(A[i]);
        double lim_log = log10(LIM);
        if(s_log+a_log>lim_log){
            isOK = false;
            break;
        }
        sum *= A[i];
        if(sum > LIM){
            isOK = false;
            break;
        }
    }
    if(isOK) cout << sum << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 4744
from collections import defaultdict
N, M = map( int, input().split())
E = [ [] for _ in range(N)]
V = [ 0 for _ in range(N)]
for i in range(M):
    L, R, D = map( int, input().split())
    E[L-1].append((R-1,D))
    V[R-1] += 1
dist = [-1]*N
for i in range(N):
    if V[i]:
        continue
    S = [i]
    dist[i] = 0
    while S:
        v = S.pop()
        for u, d in E[v]:
            if dist[u] == -1:
                dist[u] = dist[v] + d
                S.append(u)
ans = "Yes"
for v in range(N):
    for u, d in E[v]:
        if dist[v] + d != dist[u]:
            ans = "No"
            break
    if ans == "No":
        break
print(ans)


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

bool isPrime(long long X){
  if(X==2){
    return true;
  }
  else if(X%2 == 0){
    return false;
  }

  for (int k = 3; k < sqrt(X); k=k+2) {
    if(X%k==0){
      return false;
    }
  }
  return true;
}

int main(){
  long long X;

  cin >> X;

  long long i= X;
  while(true){
    if(isPrime(i)){
      cout << i << endl;
      break;
    }
    i++;
  }

  return 0;
}

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

int main()
{
	int n,l,eat,i;
	int del = 0;
	cin >> n;
	cin >> l;
	if(l >= 0){
		for(i = 2; i <= n; i++){
			del = del + i + l - 1;
		}
	}
	else if(n + l - 1 < 0){
		for(i = 1; i <= n-1; i++){
			del = del + i + l - 1;
		}
	}
	else{
		for(i = 1; i <= n; i++){
			if(i+l-1 == 0){
				eat = i;
			}
		}
		for(i = 1; i <= n ; i++){
			if(i != eat){
				del = del + i + l -1;
			}
		}
	}

	cout << del;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int a[10];
bool flag;
 
void dfs(int n, int l, int r)
{
    if (n == 10) {
        flag = true;
        return ;
    }
 
    if (a[n] > l)
        dfs(n + 1, a[n], r);
    if (a[n] > r)
        dfs(n + 1, l, a[n]);
 
    return ;
}
 
int main()
{
    int n;
 
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++)
            cin >> a[j];
 
        flag = false;
        dfs(0, 0, 0);
        if (flag)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
using namespace std;

int matrix[100][100];
bool ok[100][100];

int main()
{
  int n;
  while (cin >> n, n) {
    memset(ok, false, sizeof(ok));
    
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        cin >> matrix[i][j];
      }
    }

    for (int i = 0; i < n; ++i) {
      int k = 0;
      for (int j = 1; j < n; ++j) {
        if (matrix[i][j] < matrix[i][k]) { k = j; }
      }
      for (int j = 0; j < n; ++j) {
        if (matrix[i][j] == matrix[i][k]) { ok[i][j] = true; }
      }
    }

    for (int i = 0; i < n; ++i) {
      int k = 0;
      for (int j = 1; j < n; ++j) {
        if (matrix[j][i] > matrix[k][i]) { k = j; }
      }
      for (int j = 0; j < n; ++j) {
        if (matrix[j][i] == matrix[k][i] && ok[j][i]) {
          cout << matrix[j][i] << endl;
          goto next;
        }
      }
    }

    cout << 0 << endl;
next:;
  }
}

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

int main(void){
    int n,m,ans=0;
    scanf("%d%d",&n,&m);
    bool s[m][n];
    for (int i=0; i<m; i++){
        for (int j=0; j<n; j++){
            s[i][j]=false;
        }
    }
    for (int i=0; i<m; i++){
        int k;
        scanf("%d",&k);
        for (int j=0; j<k; j++){
            int p;
            scanf("%d",&p);
            p--;
            s[i][p]=true;
        }
    }
    int p[m];
    for (int i=0; i<m; i++){
        scanf("%d",&p[i]);
    }
    for (int i=0; i<(1<<n); i++){
        int count2=0;
        for (int i1=0; i1<m; i1++){
            int count=0;
            for (int j=0; j<n; j++){
                if ((1&i>>j)==1){
                    if (s[i1][j]==true){
                        count++;
                    }
                }
            }
            if (count%2==p[i1]){
                count2++;
            }
        }
        if (count2==m){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;   
}

Measured memory_bytes: 128
import random
import sys
import time

input = sys.stdin.readline

def main():
    # start_time = time.time()
    # while True:
    #     elapsed_time = time.time() - start_time
    #     if elapsed_time >= 2.0:
    #         print(elapsed_time)
    #         return 0
    d = int(input())
    c = list(map(int, input().split()))
    s = []
    for _ in range(d):
        s.append(list(map(int, input().split())))
    for _ in range(d):
        print(1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            Dictionary<int, int> clients = new Dictionary<int, int>();
            bool[] lastMonth = new bool[1001];

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(',');
                int c = int.Parse(temp[0]);

                if (lastMonth[c])
                {
                    clients[c]++;
                }
                else
                {
                    clients.Add(c, 1);
                    lastMonth[c] = true;
                }
            }

            List<int> succession = new List<int>();
            bool[] thisMonth = new bool[1001];

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(',');
                int c = int.Parse(temp[0]);

                if (lastMonth[c])
                {
                    clients[c]++;

                    if (!thisMonth[c])
                    {
                        succession.Add(c);
                        thisMonth[c] = true;
                    }
                }
            }

            succession.Sort();

            foreach (var s in succession)
            {
                sb.AppendLine(s + " " + clients[s]);
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9804
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,i,j,k,a,b,c;
int main(){
	scanf("%d %d",&a,&b);
	if (a*b%2==0) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 1500;
const int K = 700 ;
int a[2][N][N];
int binpow(int x, int y){
    int res = 1;
    while(y){
        if (y % 2) res = res * x % mod;
        x = x * x % mod;
        y /= 2;
    }
    return res;
}
int check(int c, int h, int w){
    if (c == 0)
    for (int i = 0; i < h; i++){
        if (a[c][i][w - 1] == 1 && a[c][i][0] == 1) return 1;
    } else{
        for (int i = 0; i < w; i++){
            if (a[0][0][i] == a[0][h - 1][i] && a[0][0][i] == 1) return 1;
        }
    }
    return 0;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int h, w, k;
    cin >> h >> w >> k;
    int b, d, e;
    b = d = e = 0;
    for (int i = 0; i < h; i++){
        string d;
        cin >> d;
        for (int j = 0; j < w; j++){
            if (d[j] == '#') a[0][i][j] = 1; else a[0][i][j] = 0;
            a[1][j][i] = a[0][i][j];
            b += a[0][i][j];
        }
    }
    if (k < 2){
        cout << 1;
        return 0;
    }
    int c1 = check(0, h, w);
    int c2 = check(1, h, w);
    if (c1 == 1 && c2 == 1){
        cout << 1;
        return 0;
    }
    if (c1 == 0 && c2 == 0){
        cout << binpow(b, k - 1);
        return 0;
    }
    int c = 0;
    if (c1 == 0){
        for (int i = 0; i < h - 1; i++){
            for (int j = 0; j < w; j++){
                if (a[c][i + 1][j] == 1 && a[c][i][j] == 1) d++;
            }
        }
        for (int j = 0; j < w; j++) if (a[c][0][j] == a[c][h - 1][j] && a[c][0][j] == 1) e++;
    } else{
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w - 1; j++){
                if (a[c][i][j + 1] == 1 && a[c][i][j] == 1) d++;
            }
            if (a[c][i][w - 1] == 1 && a[c][i][0] == 1) e++;
        }
    }
    int ans = (binpow(b, k - 1) * (b - d - e + mod) + d * binpow(e, k - 1)) % mod * binpow(b - e, mod - 2) % mod;
    if (b == e) ans = (e - ((k - 1 + mod) % mod * d % mod) + mod) % mod * binpow(e, k - 2) % mod;
    cout << ans;
}


Measured memory_bytes: 26880
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


NUM = 32

while True:
    N = int(input())
    if N == 0:
        break

    table = list(map(int,input().split()))

    num_card = NUM
    tern = 0

    while num_card > 0:
        sente = (num_card-1)%5
        num_card -= sente
        print("%d"%(num_card))

        gote = table[tern%(len(table))]
        num_card = max(0,num_card-gote)
        print("%d"%(num_card))
        tern += 1


Measured memory_bytes: 13888
//AZ@RK2019
//I know it wll accepted in first go! 
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
const int N = 2e5+7;
int n,a,one,two,four;
int main(){
	cin >> n;
	for (int i = 1;i <= n;i++){
		cin >> a; 
		if (a%4 == 0){
			four++;
		}
		else if(a%2 == 0){
			two++;
		}
		else{
			one++;
		}
	}
	if(four == one-1){
		if(two){
			cout << "No";
		}
		else{
			cout << "Yes";
		}
	}
	else if(four >= one){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	
	return 0;
}

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

int main(void){
  int N;
  cin >> N;
  bool ans = false;
  for(int i=0;i*4<=N;i++){
    if((N-4*i)%7==0) ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

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

	if (a == 1) a = 14;
	if (b == 1) b = 14;

	if (a == b) cout << "Draw" << endl;
	else if (a > b) cout << "Alice" << endl;
	else cout << "Bob" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    //   sqrt(a) + sqrt(b) < sqrt(c)
    // = 2 * sqrt(a * b) < c-a-b
    // = 4*a*b < (c-a-b)^2 && c-a-b > 0

    ll a,b,c;
    cin >> a >> b >> c;

    ll d = c-a-b;
    if(d > 0 && 4*a*b < d * d){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  int A,B,C,X ,cou=0;
  cin >>A>>B>>C>>X;
  for(int i=0;i<(A+1);i++){
    for(int j=0;j<(B+1);j++){
      for(int k=0;k<(C+1);k++){
        if(500*i+100*j+50*k==X){
          cou++;
        }
      }
    }
  }
  cout << cou <<endl;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    scanf("%d", &n);
    int m = n;
    n /= 1000;
    n *= 1000;
    if (n < m) n += 1000;
    printf("%d\n", n - m);
    return 0;
}


Measured memory_bytes: 3828
from bisect import bisect
ref = [0.2,0.6,1.1]
l,r = [0]*4,[0]*4
while 1:
    try:
        le,re = map(float, raw_input().split())
        l[bisect(ref,le)] += 1
        r[bisect(ref,re)] += 1
    except:
        break
for i in range(1,5):
	print l[-i],r[-i]

Measured memory_bytes: 4316
N,Y = map(int,input().split())


for x in range(0,N+1):

  for y in range(0,N+1-x):
    z = N-x-y
    if 10000*x + 5000*y + 1000*z == Y:
      break
      
  if 10000*x + 5000*y + 1000*z == Y:
    break
  else:
    x=-1
    y=-1
    z=-1

      
print(x,y,z)
 

Measured memory_bytes: 9032
a,b,c,d=map(int,raw_input().split())
if a%d==0:
	p=a/d
else:
	p=a/d + 1

if c%b==0:
	q=c/b
else:
	q=c/b + 1

if q<=p:
	print "Yes"

else:
	print "No"

Measured memory_bytes: 64108
#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 <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    int n, m;
    set<int> broken;
    cin >> n >> m;
    for (int i=0;i<m;++i)
    {
        int tmp;
        cin >> tmp;
        broken.insert(tmp);
    }

    ll dp[n+1] = {};
    dp[0] = 1;
    for(int i=1;i<=n;++i)
    {
        if (broken.find(i) != broken.end())
        {
            dp[i] = 0;
        }
        else
        {
            if (i==1)
            {
                dp[i] = dp[i-1];
            }
            else
            {
                dp[i] = (dp[i-1] + dp[i-2]) % 1000000007;
            }        
        }
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
    i64 n, c;
    scanf("%lld %lld", &n, &c);

    vector<i64> dist(n);
    vector<i64> value(n);

    for (int i = 0; i < n; i++)
        scanf("%lld %lld", &dist[i], &value[i]);

    vector<i64> clock(n), counter(n);
    clock[0] = value[0];
    counter[n - 1] = value[n - 1];

    for (int i = 1; i < n; i++)
        clock[i] = value[i] + clock[i - 1];

    for (int i = n - 2; i >= 0; i--)
        counter[i] = counter[i + 1] + value[i];

    //앞뒤로 시작점에서의 거리만큼 빼준다

    for (int i = 0; i < n; i++)
        clock[i] -= dist[i];

    for (int i = 0; i < n; i++)
        counter[i] -= c - dist[i];

    //각각의 방향에서 특정지점까지 갔을 때 최대치 구하기
    for (int i = 1; i < n; i++)
        clock[i] = max(clock[i - 1], clock[i]);

    for (int i = n - 2; i >= 0; i--)
        counter[i] = max(counter[i + 1], counter[i]);

    i64 ans = max({ 0ll, clock[n - 1], counter[0] });

    //각 방향에서 중간 꺾는 거 계산

    for (int i = 0; i < n - 1; i++)
        ans = max(ans, clock[i] - dist[i] + counter[i + 1]);

    for (int i = 1; i < n; i++)
        ans = max(ans, counter[i] + clock[i - 1] - (c - dist[i]));


    printf("%lld", ans);

    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  ll r=0,g=0,b=0;
  rep(i,n){
      char c=s[i];
      if(c=='R') r++;
      else if(c=='G') g++;
      else b++;
      
  }
  ll cnt=0;
  rep(i,n)for(int j=i+1;j<=n;j++){
      int k=2*j-i;
      if(k<n)if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i]) cnt++;
  }
  cout << r*g*b-cnt << endl;
}

Measured memory_bytes: 3588
#!/usr/bin/env python3
import sys
from itertools import chain
import bisect
# import numpy as np


def solve(N: int, L: "List[int]"):
    L = sorted(L)
    answer = 0
    for i in range(len(L)-1, 1, -1):
        a = L[i]
        for j in range(i-1, 0, -1):
            b = L[j]
            if a == b:
                continue
            for k in range(j-1, -1, -1):
                c = L[k]
                if b == c:
                    continue
                if b + c <= a:
                    break
                answer += 1


    return answer

def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, L)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=2e5+10;
int n,a[N];
void main() {
    R(n);
    REP1(i,1,n) R(a[i]);
    LL z=n,ans=0;
    for ( int i=n; i>=1; i-- ) {
        LL l=i-a[i];
        if ( l<1 || l>z ) {
            W(-1);
            return;
        }
        if ( l!=z ) {
            ans+=i-l;
            dump(i,ans);
        }
        z=l;
    }
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 1024
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, x;
    scan(n, x);
    auto l = aryread();
    long sum_x;
    long[] ans;
    ans ~= 0;
    // writeln(ans);
    foreach (i; 0 .. n)
    {
        sum_x += l[i];
        ans ~= sum_x;
    }
    // writeln(ans);
    long cnt;
    foreach (i; 0 .. ans.length)
    {
        if (ans[i] <= x)
        {
            cnt += 1;
        }
    }
    writeln(cnt);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

#define forn(i, n) for(int i = 0; i < (int)n; ++i)

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

	int ans = max(a+b, max(a*b, a-b));

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,a,b,d ;
  cin >> n >> a >> b;
  vector <int> v(n);
  for (int i = 1; i < n; ++i)
  {
    for (int j = i+1; j <= n; ++j)
    {
      int val = min(abs(j-i),abs(i-a)+1+abs(j-b));
      v[val]++;
    }
  }
  for (int i = 1; i <= n-1; ++i)
  {
    cout << v[i] << endl;
  }
  return 0;
} 


Measured memory_bytes: 256