akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define M 100000007
void addSelf(ll &a,ll b)
{
    a+=b;
    while(a>=M)a-=M;
}
 
void subSelf(ll &a,ll b)
{
    a-=b;
    while(a<0)a+=M;
}

void solve()
{
    string s;
    cin >> s;

    ll ans=0;
    for(int i=0;i<s.size();i++){
        ans+=(s[i]-'0');
    }
    if(ans%9){
        cout <<"No\n";
    }else
    {
        cout <<"Yes\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif */

    clock_t start, end; 
    start = clock(); 
  
    solve(); 
  
    end = clock(); 
  /* 
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    cout << "Time taken by program is : " << fixed  
         << time_taken << setprecision(5); 
    cout << " sec " << endl;  */
}



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

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

int main() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  vector<ll> cnt(2019, 0);
  ll ans = 0, ten = 1, tot = 0;
  rep(i, s.size()) {
    cnt[tot]++;
    int x = (s[i] - '0') * ten % 2019;
    (tot += x) %= 2019;
    ans += cnt[tot];
    ten = ten * 10 % 2019;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
n = int(input())

def dfs(x):
  check(x) # x が満たされているか確認する関数
  if x <= 100000000:
    dfs(10*x+3)
    dfs(10*x+5)
    dfs(10*x+7)
target = []
def check(x):
  if '3' in str(x) and '5' in str(x) and '7' in str(x):
    target.append(x)

dfs(0)

result = 0
for i in target:
  if i <= n:
    result+= 1

print(result)


Measured memory_bytes: 10064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	final static String EVENT_HIT = "HIT";
	final static String EVENT_HOMERUN = "HOMERUN";
	// final static String EVENT_OUT = "OUT";

	static Main main = new Main();

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String event = "";

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			Inning inning = main.new Inning();
			while ((event = br.readLine()) != null) {
				if (event.equals(EVENT_HIT)) {
					inning.singleHit();
				} else if (event.equals(EVENT_HOMERUN)) {
					inning.homeRun();
				} else {
					inning.out();
					if (inning.outs == 3) {
						System.out.println(inning.run);
						break;
					}
				}
			}
		}
	}

	class Inning {

		int diamond = 0;
		int outs = 0;
		int run = 0;

		void singleHit() {
			diamond <<= 1;
			diamond |= 1;
			if ((diamond & 8) > 0) {
				run++;
				diamond &= 7;
			}
		}

		void homeRun() {
			for (int i = 0; i < 3; i++) {
				diamond <<= 1;
				if ((diamond & 8) > 0)
					run++;
			}
			run++;
			diamond = 0;
		}

		void out() {
			outs++;
		}
	}
}

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



int main(){
	string s,t;
	cin >> s;
	cin >> t;
	int l_min = 1000;
	for(int i=0;i<=s.size() - t.size();i++){
		int cnt = 0;
		for(int j=0;j<t.size();j++){
			if(s[j+i] != t[j]) cnt++;
		}
		if(cnt < l_min) l_min = cnt;
	}
	cout << l_min << endl;
	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

struct edge { int to, cost; };
using P = pair<int, int>;

const int INF = 1e8;
int n;
vec<vec<edge>> G;
int d[111];

void dijkstra(int s) {
   priority_queue<P, vec<P>, greater<P>> Q;
   fill(d, d + n, INF);
   d[s] = 0;
   Q.push({0, s});

   while (Q.size()) {
      P p = Q.top(); Q.pop();
      int v = p.second;
      if (d[v] < p.first) continue;
      for (int i = 0; i < G[v].size(); i++) {
         edge e = G[v][i];
         if (d[e.to] > d[v] + e.cost) {
            d[e.to] = d[v] + e.cost;
            Q.push({d[e.to], e.to});
         }
      }
   }
}

int main() {
   cin >> n;
   G = vec<vec<edge>>(n);
   rep (i, n) {
      int u, k;
      cin >> u >> k;
      rep (j, k) {
         int v, c;
         cin >> v >> c;
         G[u].push_back({v, c});
      }
   }

   dijkstra(0);

   rep (i, n) {
      printf("%d %d\n", i, d[i]);
   }

   return 0;
}


Measured memory_bytes: 3292
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
char S[102];
int main(){
  int i;
  int res = 0;
  N = rd(S);
  for(i=(0);i<(N/2);i++){
    if(S[i] != S[N-1-i]){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191208-1 [beta]

// --- original code ---
// int N; char S[102];
// {
//   int i, res = 0;
//   rd(S@N);
//   rep(i,N/2) if(S[i] != S[N-1-i]) res++;
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cassert>

using namespace std;

int N, M;

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

vector<Edge> Graph[200];

const int MAX = 10000000;
int min_cost[200][2];

void init() {
  for (int i = 0; i < 200; i++) {
    Graph[i].clear();
  }
  for (int i = 0; i < 200; i++) {
    for (int j = 0; j < 2; j++) {
      min_cost[i][j] = MAX;
    }
  }
}

struct State {
  int current;
  int used;
  int cost;
  State(int current, int used, int cost) : current(current), used(used), cost(cost) {}
  bool operator<(const State & rhs) const {
    return cost > rhs.cost;
  }
};


void solve() {
  priority_queue<State> Q;
  Q.push(State(0, 0, 0));

  while (!Q.empty()) {
    State c = Q.top();

    Q.pop();

    int cur = c.current;
    int used = c.used;
    int cost = c.cost;
    if (cur == N - 1) {
      cout << cost << endl;
      return;
    }
    if (min_cost[cur][used] < c.cost) {
      continue;
    }
    min_cost[cur][used] = c.cost;

    for (int i = 0; i < Graph[cur].size(); i++) {
      int dst = Graph[cur][i].dst;
      int dcost = Graph[cur][i].cost;
      if (min_cost[dst][used] > cost + dcost) {
        min_cost[dst][used] = cost + dcost;
        Q.push(State(dst, used, cost + dcost));
      }
      if (!used) {
        for (int j = 0; j < Graph[dst].size(); j++) {
          int next_dst = Graph[dst][j].dst;
          if (min_cost[next_dst][1] > cost) {
            min_cost[next_dst][1] = cost;
            Q.push(State(next_dst, 1, cost));
          }
        }
      }
    }
  }
  assert(false);
}

int main() {
  while (true) {
    cin >> N >> M;
    if (N == 0 && M == 0) {
      return 0;
    }
    init();
    for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      Graph[a].push_back(Edge(b, c));
      Graph[b].push_back(Edge(a, c));
    }
    solve();
  }
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int K = Integer.parseInt(br.readLine());
        StringBuilder sb = new StringBuilder();

        for(int i=0;i<K;i++){
            sb.append("ACL");
        }
        System.out.println(sb.toString());
    }
    
}

Measured memory_bytes: 32628
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop, core.thread;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


immutable INF = 10L^^18;

int N;
long[] A;

void main() {
  try {
    for (; ; ) {
      N = readInt;
      A = new long[N];
      foreach (i; 0 .. N) {
        A[i] = readLong();
      }
      auto dp = new long[][](N + 1, N + 1);
      foreach (i; 0 .. N + 1) {
        dp[i][i] = 0;
      }
      foreach (k; 1 .. N + 1) {
        for (int i = 0, j = k; j <= N; ++i, ++j) {
          dp[i][j] = max(A[i] - dp[i + 1][j], A[j - 1] - dp[i][j - 1]);
        }
      }
      writeln(dp[0][N]);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 74620
//#pragma GCC diagnostic error "-std=c++11"
//#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n, mod, C[3030][3030], f[3030][3030];

ll K(ll x,ll y,ll mo=mod){
  ll t=1;
  for (;y;y>>=1, x=x*x%mo)
    if (y&1) t=t*x%mo;
  return t;
}

int main(){
  cin>>n>>mod;
  for (int i=0;i<=n;++i){
    C[i][0]=1;
    for (int j=1;j<=i;++j)
      C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
  }
  f[0][0]=1;
  for (int i=1;i<=n;++i){
    f[i][0]=1;
    for (int j=1;j<=i;++j)
      f[i][j]=(f[i-1][j-1]+(ll)f[i-1][j]*(j+1))%mod;
  }
  ll ans=0;
  for (int i=0;i<=n;++i){
    ll res=0, b1=1, eb1=K(2,n-i), b2=K(2,K(2,n-i,mod-1));
    for (int j=0;j<=i;++j){
      res+= f[i][j]* b1%mod *b2%mod;
      b1=b1*eb1%mod;
    }
    res=res%mod *C[n][i]%mod;
    ans+= i&1? -res: res;
  }
  ans=(ans%mod+mod)%mod;
  cout<<ans<<endl;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 105;

string N;
int K;

int dp[MAX_N][5][2];

signed main()
{
  cin >> N;
  cin >> K;

  dp[0][0][0] = 1;

  REP(n,N.size()) {
    REP(k,K+1) {
      REP(flag,2) {
        // 0
        dp[n+1][k][flag | (N[n] != '0' ? 1 : 0)] += dp[n][k][flag];
        // 1以上9以下の数字を入れる
        if(flag) { // 自由
          dp[n+1][k+1][1] += dp[n][k][flag]*9;
        } else { // 制約あり
          if(N[n] > '0') {
            dp[n+1][k+1][1] += dp[n][k][flag] * (N[n]-'0'-1);
            dp[n+1][k+1][0] += dp[n][k][flag];
          }
        }
      }
    }
  }

  cout << dp[N.size()][K][0] + dp[N.size()][K][1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, k, v = 1;
	scanf ("%d%d", &n, &k);

	for (int i = 1; i <= n; i++) {
		if (v < k) {
			v *= 2;
		}
		else if (v > k) {
			v += k;
		}
		else if (v = k) {
				v *= 2;
		}
		
	}
	printf ("%d\n", v);
	return 0;		
}

Measured memory_bytes: 1732
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  string s;
  long long k;
  char ans;
  cin>>s;
  cin>>k;
      for(int i=0;i<k;i++){
            if(s[i]!='1'){
                ans=s[i];
                cout<<ans<<endl;
                return 0;
            }
        }
  cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-


A, B, K = list(map(int, input().split()))

# print(A, K)

set_A = set()
set_B = set()

for i in range(1, A + 1):
    if A % i == 0:
        set_A.add(i)


for i in range(1, B + 1):
    if B % i == 0:
        set_B.add(i)

# print(set_A ,set_B)

seki = set_A & set_B

seki = list(seki)

seki.sort(reverse=True)

print(seki[K - 1])



Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;
using ll = long long int;
using ha = pair<ll, ll>;
struct RollingHash {
	static const ll mul0 = 10009, mul1 = 10007;
	static const ll add0 = 1000010007, add1 = 1003333331;
	size_t len;
	//vector<ll> hash_, hash2_;
	vector<ha>hash_;
	//static vector<ll> pmo_, pmo2_;
	static vector<ha>pmo_;
	void init(const vector<ll>& s) {
		len = s.size();
		hash_.resize(len + 1);
		hash_[0] = make_pair(0, 0);

		if (pmo_.empty()) {
			pmo_.push_back(make_pair(1, 1));
		}
		while (pmo_.size() <= len) {
			pmo_.push_back(make_pair(pmo_.back().first*mul0, pmo_.back().second*mul1));
		}
		for (unsigned int i = 0; i < len; ++i) {
			hash_[i + 1] = make_pair((hash_[i].first * mul0 + s[i]), (hash_[i].second*mul1 + s[i]));
		}
		return;
	}
	void init(const string& s) {
		vector<ll>v;
		for (char c : s) {
			v.push_back(c);
		}
		init(v);
	}
	ha hash(const int l, const int r)const { // s[l..r]
		return make_pair(hash_[r + 1].first - hash_[l].first * pmo_[r + 1 - l].first,
			hash_[r + 1].second - hash_[l].second * pmo_[r + 1 - l].second);
	}
	ha  hash()const { // s[all]
		return hash(0, len - 1);
	}

	//hashの結合　
	static ha concat(const ha L, const ha R, const int RLength) { // hash(L+R) 
		return make_pair((R.first + L.first*pmo_[RLength].first), (R.second + L.second*pmo_[RLength].second));
	}

	//indexの位置をfromからtoに変えたもののハッシュを返す。
	ha get_changed_hash(const int index, const ll from, const ll to)const {
		const ha p(hash());
		return make_pair(
			p.first + (to - from) * pmo_[len - index - 1].first,
			p.second + (to - from) * pmo_[len - index - 1].second);
	}
};
vector<ha> RollingHash::pmo_;

int getnum(const RollingHash&rh,const int num) {
	unordered_set<long long int>aset;
	for (int i = 0; i <= rh.len - num; ++i) {
		aset.emplace(rh.hash(i, i + num - 1).first*142357+rh.hash(i,i+num-1).second);
	}
	return aset.size();
}

int main() {
	string st; cin >> st;
	RollingHash rh;
	rh.init(st);
	int amin = 1;
	int amax = st.size() + 1;
	while (amin + 2 < amax) {
		int amid1 = (amin * 2 + amax) / 3;
		int amid2 = (amin * 1 + amax * 2) / 3;
		int ans1 = getnum(rh, amid1);
		int ans2 = getnum(rh, amid2);
		if (ans1 < ans2) {
			amin = amid1;

		}
		else {
			amax = amid2;
		}
	}
	int ans = 0;
	for (int i = amin; i < amax; ++i) {
		ans = max(ans, getnum(rh,i));
	}
	cout << ans << endl;
	
	return 0;
}

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

int main()
{
    int a, b, c, x, ans = 0;
    cin >> a >> b >> c >> x;
    REP(i, a + 1) REP(j, b + 1) REP(k, c + 1)
    {
        if (500 * i + 100 * j + 50 * k == x) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int N, K, j = 0, R = 1;
  cin >> N >> K;
  for (int i = 1; i < K; i *= 2)
    j++;
  if (j < N) {
    N -= j;
    for (; j > 0; j--)
      R *= 2;
    for (; N > 0; N--)
      R += K;
  }
  else {
    for (; N > 0; N--)
      R *= 2;
  }
  cout << R << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
S=[list(map(int,input().split()))[1:] for i in range(m)]
P=list(map(int,input().split()))

cnt=0
for i in range(2**n):
    Q=0
    light=set([i+1 for i,j in enumerate(format(i,"b").zfill(n)[::-1]) if j=="1"])
    for k,j in enumerate(S):
        if len(light&set(j))%2==P[k]:Q +=1
    if Q==m:cnt +=1

print(cnt)

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

#include <iostream>
#include <vector>
#include <math.h>

std::unordered_map<long, int> mp;
std::vector<int> v;

int main(void) {
  char a;

  scanf("%c", &a);

  if(a >= 0x41 && a <= 0x5a){
    printf("A");
    return 0;
  }

  if (a >= 0x61 && a <= 0x7a) {
    printf("a");
    return 0;
  }

  return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    int fa[maxn], sz[maxn];
    int ffa(int x) {
        if (fa[x] == x)
            return x;
        return fa[x] = ffa(fa[x]);
    }
    void me(int x, int y) {
        x = ffa(x), y = ffa(y);
        if (x == y)
            return;
        fa[x] = y;
        sz[y] += sz[x];
    }
    int cnt[maxn];
    void solve() {
        int n, m, k;
        cin >> n >> m >> k;
        for (int i = 1; i <= n; ++i)
            fa[i] = i, sz[i] = 1;
        for (int i = 0; i < m; ++i) {
            int a, b;
            cin >> a >> b;
            me(a, b);
            cnt[a]++;
            cnt[b]++;
        }
        vector<vector<int>> bad(n + 2);
        for (int i = 0; i < k; ++i) {
            int a, b;
            cin >> a >> b;
            bad[a].push_back(b);
            bad[b].push_back(a);
        }
        for (int i = 1; i <= n; ++i) {
            int fai = ffa(i);
            int ans = sz[fai] - 1 - cnt[i];
            for (int j : bad[i]) {
                if (ffa(j) == fai)
                    ans--;
            }
            cout << ans << ' ';
        }
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

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

int w, h;
string inp[21];

const int MAX=23;
int room[MAX][MAX];
int cnt;

void init(){
    int i, j;
    for(i=0; i<MAX; i++){
        for(j=0; j<MAX; j++){
            room[i][j]=0;
        }
    }
    cnt = 0;
}

void dfs(int x, int y){
    cnt++;
    room[x][y]=0;
    if(room[x+1][y]){
        dfs(x+1,y);
    }
    if(room[x-1][y]){
        dfs(x-1,y);
    }
    if(room[x][y+1]){
        dfs(x,y+1);
    }
    if(room[x][y-1]){
        dfs(x,y-1);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    
    
    while(1){
        cin >> w >> h;
        
        if(w==0 && h==0)
            break;
        
        int i, j;
        int x=0, y=0;
        for(i=1; i<=h; i++){
            cin >> inp[i];
            for(j=0; j<w; j++){
                switch(inp[i][j]){
                    case '.':
                        room[j+1][i]=1;
                        break;
                    case '#':
                        room[j+1][i]=0;
                        break;
                    case '@':
                        room[j+1][i]=1;
                        x=j+1;
                        y=i;
                        break;
                }
            }
        }
        
        dfs(x, y);
        cout << cnt << endl;
        
        init();
    }
    return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))




struct subtree_size{//木で、ある頂点を除いた時にできる森の各木のサイズを求める
	vector<int> u,v; //辺集合
	vector<int> us,vs;
	vector<vector<int>> forest;
	int N;
	subtree_size(vector<int> u_,vector<int> v_){
		u = u_; v = v_;
		N = u.size() + 1;
		us.resize(N-1,0);
		vs.resize(N-1,0);
		set<int> connect[N];
		vector<int> num(N,0);
		vector<int> did(N-1,0);//1->uでやった 2->vでやった
		for(int i=0;i<N-1;i++){
			connect[u[i]].insert(i);
			connect[v[i]].insert(i);
		}
		queue<int> Q;//辺の番号が入る
		for(int i=0;i<N;++i){
			if(connect[i].size() == 1){
				Q.push( *connect[i].begin() );
			}
		}
		while( Q.size() ){
			int ie = Q.front();
			Q.pop();
			if(connect[u[ie]].size() == 1){
				us[ie] = num[u[ie]] + 1;
				num[v[ie]] += us[ie];
				connect[u[ie]].clear();
				connect[v[ie]].erase(ie);
				if(connect[v[ie]].size()==1){
					Q.push( *connect[v[ie]].begin() );
				}
				if(not did[ie]) did[ie] = 1;
			}else{
				vs[ie] = num[v[ie]] + 1;
				num[u[ie]] += vs[ie];
				connect[v[ie]].clear();
				connect[u[ie]].erase(ie);
				if(connect[u[ie]].size()==1){
					Q.push( *connect[u[ie]].begin() );
				}
				if(not did[ie]) did[ie] = 2;
			}
		}
		forest.resize(N);
		for(int i=0;i<N-1;i++){
			if(did[i]==1){
				vs[i] = N - us[i];
			}else{
				us[i] = N - vs[i];
			}
			forest[u[i]].push_back(vs[i]);
			forest[v[i]].push_back(us[i]);
		}
	}
};



ll calc(ll a,ll b,ll p){//a^(b) mod p   
	if(b==0)return 1;
	ll y = calc(a,b/2,p);y=(y*y)%p;
	if(b & 1) y = (y * a) % p;
	return y;
}

int main(){
	ll N;
	cin >> N;
	vector<int> u(N-1),v(N-1);
	FOR(i,0,N-1){
		cin >> u[i] >> v[i];
		u[i]--;
		v[i]--;
	}
	subtree_size ss(u,v);
	ll ans = 0;
	FOR(i,0,N){
		ll sum = 0;
		for(auto s:ss.forest[i]){
			sum += s;
			(ans += MOD - calc(2,s,MOD) + 1 ) %= MOD;
		}
		(ans += calc(2,sum,MOD)) %= MOD;
		(ans += MOD - 1) %= MOD;
	}
	(ans *= calc(calc(2,N,MOD),MOD-2,MOD)) %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 36608
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  int t=1,cnt=0;
  ll re=1;
  for(int x:a){
    if(t<=x){
      t+=2;
      ++cnt;
    }else{
      (re*=cnt+1)%=MOD;
    }
  }
  rep(i,cnt) (re*=i+1)%=MOD;
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#define SZ 131072
#define pli pair<long long,int>
using namespace std;
int n, m, Route[101000], PP[101000], ord[101000];
vector<int>E[101000], L[101000], Num[101000], T[101000];
priority_queue<pli>PQ;
struct Edge {
	int a, b, c;
}Ed[101000];
int Path[101000], chk[101000];
long long D[101000], D2[101000];
void Ins(int a, long long d, int pp) {
	if (D[a] <= d)return;
	D[a] = d;
	Path[a] = pp;
	PQ.push(pli{ -d,a });
}
void Dijk(int st) {
	int i, a;
	for (i = 1; i <= n; i++)D[i] = 1e18, Path[i] = -1;
	Ins(st, 0, 0);
	while (!PQ.empty()) {
		pli tp = PQ.top();
		PQ.pop();
		if (D[tp.second] != -tp.first)continue;
		a = tp.second;
		for (i = 0; i < E[a].size(); i++) {
			Ins(E[a][i], D[a] + L[a][i], Num[a][i]);
		}
	}
}
void DFS(int a, int pp) {
	int i;
	if (Route[a])pp = Route[a];
	PP[a] = pp;
	for (i = 0; i < T[a].size(); i++) {
		DFS(T[a][i], pp);
	}
}
int cnt;
long long IT[SZ + SZ];
void Put(int b, int e, long long x) {
	b += SZ, e += SZ;
	while (b <= e) {
		IT[b] = min(IT[b], x);
		IT[e] = min(IT[e], x);
		b = (b + 1) >> 1, e = (e - 1) >> 1;
	}
}
void Add(int a, int b, int c) {
	if (D[a] > 5e17 || D2[b] > 5e17)return;
	if (!PP[a] || !PP[b])return;
	if (PP[a] > PP[b])Put(PP[b], PP[a] - 1, D[a] + D2[b] + c);
}
int main() {
	int i, a, b, c;
	scanf("%d%d", &n, &m);
	for (i = 1; i < SZ + SZ; i++)IT[i] = 1e18;
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &a, &b, &c);
		E[b].push_back(a);
		L[b].push_back(c);
		Num[b].push_back(i);
		Ed[i] = { a,b,c };
	}
	Dijk(2);
	for (i = 1; i <= n; i++)D2[i] = D[i], E[i].clear(),L[i].clear(), Num[i].clear();
	for (i = 0; i < m; i++) {
		a = Ed[i].a, b = Ed[i].b, c = Ed[i].c;
		E[a].push_back(b);
		L[a].push_back(c);
		Num[a].push_back(i);
	}
	Dijk(1);
	a = 2;
	while (a != 1) {
		Route[a] = ++cnt;
		chk[Path[a]] = 1;
		a = Ed[Path[a]].a;
	}
	Route[a] = ++cnt;
	for (i = 2; i <= n; i++) {
		if (Path[i] != -1)T[Ed[Path[i]].a].push_back(i);
	}
	DFS(1, 0);
	for (i = 0; i < m; i++) {
		if (chk[i])continue;
		Add(Ed[i].a, Ed[i].b, Ed[i].c);
	}
	for (i = 0; i < m; i++) {
		if (chk[i]) {
			int t = SZ + min(Route[Ed[i].a], Route[Ed[i].b]);
			long long rr = 1e18;
			while (t) {
				rr = min(rr, IT[t]);
				t >>= 1;
			}
			if (rr == D[2])printf("SOSO\n");
			else printf("SAD\n");
		}
		else {
			if (D[Ed[i].b] + D2[Ed[i].a] + Ed[i].c < D[2])printf("HAPPY\n");
			else printf("SOSO\n");
		}
	}
}

Measured memory_bytes: 34048
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
	int n,p[20]={},num=0;
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>p[i];
	}

	for (int i = 1; i < n-1; i++) {
		if((p[i]>p[i-1]&&p[i]<p[i+1])||(p[i]>p[i+1]&&p[i]<p[i-1])){
			num++;
		}
	}
	cout<<num<<"\n";



	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
    void solve(Scanner sc) {
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N - 1];
        for (int i = 0; i < A.length; i++) {
            A[i] = sc.nextInt() - 1;
        }
        for (int i = 0; i < B.length; i++) {
            B[i] = sc.nextInt();
        }
        for (int i = 0; i < C.length; i++) {
            C[i] = sc.nextInt();
        }
        int sum = B[A[0]];
        for (int i = 1; i < N; i++) {
            int prev = A[i - 1];
            int next = A[i];
            if (prev + 1 == next) sum += C[prev];
            sum += B[next];
        }
        System.out.println(sum);
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

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

int main()
  {
   string a,b;
  int x,y,z;
  cin>>a>>b;
  if(a[0]==b[0])
    x=1;
  else
    x=0;
  if(a[1]==b[1])
    y=1;
  else
    y=0;
  if(a[2]==b[2])
    z=1;
  else
    z=0;
  cout<<x+y+z<<endl;
  }
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll DIVIDE = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vll a(N), b(N), c(N);
  ll a_sum=0;
  ll b_sum=0;
  ll c_sum=1;
  REP(i, N){
    cin >> a[i] >> b[i] >> c[i];
    a_sum+=a[i];
    b_sum+=b[i];
    c_sum+=c[i];
  }

  vector<vvll> dp(N+1, vvll(a_sum+1, vll(b_sum+1, c_sum)));
  dp[0][0][0]=0;

  FOR(i, 0, N){
    FOR(j, 0, a_sum+1){
      FOR(k, 0, b_sum+1){
        dp[i+1][j][k] = min(dp[i][j][k], dp[i+1][j][k]);
        if(j+a[i]<a_sum+1 && k+b[i]<b_sum+1){
          dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
        }
      }
    }
  }

  ll k = min(a_sum/Ma, b_sum/Mb);

  ll ans=c_sum;
  FOR(i, 1, k+1){
    ans = min(ans, dp[N][i*Ma][i*Mb]);
  }

  if(ans==c_sum) ans=-1;

  cout << ans << "\n";

  return 0;
}


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

int main(){
	int s=0,t=0, i, a;
	for(i=0;i<4;i++){
		cin>>a;
		s+=a;
	}
	for(i=0;i<4;i++){
		cin>>a;
		t+=a;
	}
	if(s<t)cout<<t<<endl;
	else cout<<s<<endl;
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int a = 100 * inp[0]; int b = 100 * inp[1]; int c = inp[2];
            int d = inp[3]; int e = inp[4]; int f = inp[5];
            var waterList = new List<int>();
            var sugarList = new List<int>();
            for (int i = 0; i * a <= f; i++)
            {
                for (int j = 0; i * a + j * b <= f; j++)
                {
                    waterList.Add(i * a + j * b);
                }
            }
            for (int i = 0; i * c <= f; i++)
            {
                for (int j = 0; i * c + j * d <= f; j++)
                {
                    sugarList.Add(i * c + j * d);
                }
            }
            waterList = waterList.Distinct().OrderBy(x => x).ToList();
            sugarList = sugarList.Distinct().OrderBy(x => x).ToList();
            var ans = new Dictionary<double, int[]>();
            for (int i = 0; i < waterList.Count; i++)
            {
                for (int j = 0; j < sugarList.Count; j++)
                {
                    if (!ans.ContainsKey((double)sugarList[j] / (sugarList[j] + waterList[i])))
                        ans[(double)sugarList[j] / (sugarList[j] + waterList[i])] = new int[2] { sugarList[j] + waterList[i], sugarList[j] };
                }
            }
            ans = ans.Where(x => x.Key <= e / (100.0 + e)).Where(x => x.Value[0] <= f).OrderByDescending(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
            Console.WriteLine(string.Join(" ", ans.First().Value));
        }
    }
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

map<int, int> primeFactor(int n) {
    map<int, int> factor;
    for (int i = 2; i <= ceil(sqrt(n)) + 1; i++) {
        while (n % i == 0) {
            n /= i;
            factor[i]++;
        }
    }
    if (n > 1) factor[n]++;
    return factor;
}

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

signed main() {
    ll A, B;
    cin >> A >> B;

    ll g = gcd(A, B);
    map<int, int> a = primeFactor(g);

    int ans = a.size() + 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
const ll mod=10e9+7;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll L,R;
    cin>>L>>R;
    ll l=L%2019;
    ll r=R%2019;
    if(R-L>2019){
      cout<<0<<endl;
      return 0;
    }
    if(l<r){
        ll mini=2018;
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                mini=min((i*j)%2019,mini);
            }
        }
        cout<<mini<<endl;
    }
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n,m,p;
		cin>>n>>m;
		string s;
		ll a[n+1],b[n+1];
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		for(int i=0;i<m;i++){
			cin>>p>>s;
			if(s=="AC"){
				a[p]=1;
			}
			else if(a[p]==0)
			b[p]++;
		}
		ll c1=0,c2=0;
		for(int i=1;i<=n;i++){
			c1+=a[i];
			if(a[i]!=0)
			c2+=b[i];
		}
		cout<<c1<<" "<<c2;
	}
	return 0;
	}

Measured memory_bytes: 1792
import sys
W, H, N = map(int, sys.stdin.readline().split(" "))
Map = [list(map(int,sys.stdin.readline().split(" "))) for i in range(N)]
L = 0
R = W
B = 0
T = H
 
for i in Map:
  if i[2] == 1:
    l = i[0]
    L = max(L, l)
  if i[2] == 2:
    r = i[0]
    R = min(R, r)
  if i[2] == 3:
    b = i[1]
    B = max(B, b)
  if i[2] == 4:
    t = i[1]
    T = min(T, t)
    
if R - L > 0 and T - B > 0:
  print((R - L) * (T - B))
else:
  print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

vector<int> l;
bool isok(int index, int key){
    if(l[index]>key) return true;
    else return false;
}

int binery_search (int key,int num){
    int ng=-1;
    int ok=num;
    while(abs(ok-ng)>1){
        int mid=(ok+ng)/2;
        if(isok(mid,key)) ok=mid;
        else ng=mid;
    }
    return ok;
}

int main(){
    int n; cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        l.push_back(a);
    }

    sort(l.begin(),l.end());
    int ans=0;
    for(int i=n-1; i>=2; i--){
        for(int j=i-1; j>=1; j--){
            int naga=l[i]-l[j];
            int v=binery_search(naga,j);
            int k=j-v;
           //cout<<l[i]<<" "<<l[j]<<" "<<naga<<" "<<k<<endl;
            ans+=k;
        }
    }

    cout<<ans<<endl;

}

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

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> c(h,vector<char>(w));
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) cin >> c[i][j];
    }
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) cout  << c[i][j];
        cout << endl;
        for (int j=0;j<w;j++) cout  << c[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<iostream>
#include<set>

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

using namespace std;
int n;
string str;
string mess;
set<string> ma;
int main(){
	cin>>n;
	rep(i,n){
		cin>>str>>mess;
		if(str[0]=='i'){
			ma.insert(mess);
		}else{
			if(ma.find(mess)!=ma.end()){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 30604
using System;
using System.Collections;


namespace Dcs
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse( Console.ReadLine() );
            var primes = new ArrayList();

            var x = 11;
            while ( primes.Count < n)
            {
                var max_ = (int)Math.Sqrt(x);
                bool is_prime = true;
                for(int i = 3; i <= max_; i += 2)
                {
                    if (x % i == 0)
                    {
                        is_prime = false;
                        break;
                    }
                }

                if (is_prime)
                    primes.Add(x);

                x += 10;
            }
            for (int i = 0; i < n - 1; ++i)
                Console.Write( primes[i] + " ");

            Console.WriteLine( primes[n-1] );
        }
    }
}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){
    #ifndef ONLINE_JUDGE
    freopen("../../input.txt", "r", stdin);
    freopen("../../output.txt", "w", stdout);
	#endif
    fast

    string s; cin>>s;
    pt( (s[1]=='B'?"ARC":"ABC") );
}


/*



*/





Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define FASTIO std::ios::sync_with_stdio(false);
#define MAXN 200005
int main(){
  FASTIO
  int n, ans=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n-1;i++){
    cin>>a[i];
  }
  ans+=a[0];
  for(int i=0;i<n-2;i++){
    // cout<<ans<<" ";
    if(a[i+1]>=a[i])ans+=a[i];
    else {
      ans+=a[i+1];
    }
  }
  ans+=a[n-2];
  cout<<ans<<endl;

}


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

using namespace std;

const int N = 2e5 + 10;

char s[N];

int main(){
	int n;
	scanf("%d", &n);
	scanf("%s", s);
    
    int cnt = 0;
    for (int i = 0, j = n - 1; j > i; i ++){
    	if (s[i] == 'W'){
    		while(s[j] == 'W' && j > i)   j --;
    		s[j] = 'W';
    		if (i < j)   cnt ++;
		}  
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

int main(){
    long long k;
    cin >> k;
    long long sum = 0;
    for(long long a=1; a<=k; a++){
        for(long long b=1; b<=k; b++){
            for(long long c=1; c<=k; c++){
                long long d = gcd(a,b);
                sum += gcd(c,d);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
dd power(dd x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll x,p=100,i;
       cin>>x;
       for(i=1;i<4000;i++)
       {
           if(1.01*p>=x)
           {
               cout<<i;
               return 0;
           }
           p=1.01*p;
       }
       //cout<<ans<<"\n";
       //cout<<(ll)power(1.01,2000)*100<<"\n";
   }
}

Measured memory_bytes: 3640