akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

void end(int n = -1)
{
	cout << n << "\n";
	exit(0);
}
int a, b, c, d;
map<int, int> dp;
int fun(int n)
{
	if (n == 0)
		return 0;
	if (dp.count(n))
		return dp[n];
	int ans = inf;
	if (n < 3e9)
		ans = n * d;
	for (int i = -1; i <= 1; i++)
	{
		int x = n + i;
		if (x < 0 or x % 2)
			continue;
		int y = x / 2;
		if (y < n)
		{
			ans = min(ans, abs(i) * d + a + fun(y));
		}
	}
	for (int i = -2; i <= 2; i++)
	{
		int x = n + i;
		if (x < 0 or x % 3)
			continue;
		int y = x / 3;
		if (y < n)
		{
			ans = min(ans, abs(i) * d + b + fun(y));
		}
	}
	for (int i = -4; i <= 4; i++)
	{
		int x = n + i;
		if (x < 0 or x % 5)
			continue;
		int y = x / 5;
		if (y < n)
		{
			ans = min(ans, abs(i) * d + c + fun(y));
		}
	}
	return dp[n] = ans;
}
int32_t main()
{
	AB_BHI_NI_DEGI
	int t = 1;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		cin >> a >> b >> c >> d;
		dp.clear();
		cout << fun(n) << "\n";
	}
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());

    ll res = 0;
    vector<bool> B(N, false);
    for (int i = 0; i < N; i++) {
        if (B[i]) continue;
        while (i < N-1 && A[i] == A[i+1]) {
            B[i] = true;
            B[i+1] = true;
            i++;
        }
        int x = A[i] * 2;
        while (x <= A[N-1]) {
            auto y = lower_bound(A.begin(), A.end(), x);
            if (*y == x) {
                int d = y - A.begin();
                B[d] = true;
                while (d < N-1 && A[d] == A[d+1]) B[++d] = true;
            }
            x += A[i];
        }
    }
    rep(i,N) {
        if (!B[i]) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
#define int long long

const int MAX_N = 100010;


void printYes() {
	cout << "Yay!" << endl;
}
void printNo() {
	cout << ":(" << endl;
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int sum = 0;
	rep(i, n)sum += a[i];
	int ans = INF;
	int now = 0;
	rep(i, n) {
		now += a[i];
		int tmp = abs(now - (sum - now));
		chmin(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int bells[3];
    rep(i,3) cin >> bells[i];
    sort(bells, bells+3);
    cout << bells[0] + bells[1] << endl;
}

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

typedef long long ll;
using namespace std;
int main()
{

  char a,b;
  cin>>a>>b;
  if(a=='H'&&b=='H'||a=='D'&&b=='D'){
    cout<<'H'<<endl;
  }else{
    cout<<'D'<<endl;
  }

  return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;int a[1000000];int lea=0;
int main(){
  int n;
  cin>>n;
  if(n==1){puts("Yes");exit(0);
  }
  else{
    for(int i=1;i<=n;i++){scanf("%d",&a[i]);
    if(lea>a[i]) {cout<<"No";exit(0);}
    if(lea<a[i]) lea=max(a[i]-1,lea);
  }puts("Yes");
  }
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

typedef struct edge{
  int to, cost;
}edge;

using pii = pair<int, int>;
using piii = pair<int, pii>;//cost, c, pos

int main(){
  int c, n, m, s, d;
  while(std::cin >> c >> n >> m >> s >> d){
    if(c == 0)break;
    s--, d--;
    vector<vector<edge> > G(n);
    for (int i = 0; i < m; i++) {
      int a, b, f;
      std::cin >> a >> b >> f;
      a--, b--;
      G[a].push_back((edge){b, f});
      G[b].push_back((edge){a, f});
    }
    priority_queue<piii, vector<piii>, greater<piii> > que;
    que.push(piii(0, pii(c, s)));
    vector<vector<int> > dist(c + 1, vector<int>(n, 1e9));
    dist[c][s] = 0;
    while(not que.empty()){
      int cc = que.top().first;
      int remain = que.top().second.first;
      int v = que.top().second.second;
      // std::cout << cc << " " << remain << " " << v << std::endl;
      que.pop();
      for (int i = 0; i < G[v].size(); i++) {
        int u = G[v][i].to;
        int add = G[v][i].cost;
        // std::cout << u << std::endl;
        if(dist[remain][u] > cc + add){
          dist[remain][u] = cc + add;
          que.push(piii(cc + add, pii(remain, u)));
        }
        if(remain > 0 and dist[remain - 1][u] > cc + add/2){
          dist[remain - 1][u] = cc + add/2;
          que.push(piii(cc + add/2, pii(remain - 1, u)));
        }
      }
    }
    int ans = 1e9;
    for (int i = 0; i <= c; i++) ans = min(ans, dist[i][d]);
    std::cout << ans << std::endl;
  }
  return 0;
}



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

int c[6], cost[110][1 << 6], m, n, k, d;
struct st {
	int a, b, c;
};
int num(string s) {
	if (s == "H")return m + n;
	if (s == "D")return m + n + 1;
	if (s[0] == 'C')return s[1] - '1';
	return stoi(s.substr(1)) - 1 + m;
}
int main() {
	while (scanf("%d%d%d%d", &m, &n, &k, &d), m) {
		rep(i, m)scanf("%d", &c[i]);
		vector<st>v;
		rep(i, d) {
			string s, t; int e; cin >> s >> t >> e; e *= k;
			v.push_back({ num(s),num(t),e });
			v.push_back({ num(t),num(s),e });
		}
		memset(cost, 0x3f, sizeof(cost));
		cost[m + n][0] = 0;
		bool update = true;
		while (update) {
			update = false;
			for (st e : v)rep(i, 1 << m) {
				if (cost[e.a][i] == INF)continue;
				if (e.b < m) {
					if (!(i >> e.b & 1) && cost[e.b][i | 1 << e.b] > cost[e.a][i] + e.c - c[e.b])
						cost[e.b][i | 1 << e.b] = cost[e.a][i] + e.c - c[e.b], update = true;
				}
				else if (cost[e.b][i] > cost[e.a][i] + e.c)
					cost[e.b][i] = cost[e.a][i] + e.c, update = true;
			}
		}
		int Min = INF;
		rep(i, 1 << m)Min = min(Min, cost[m + n + 1][i]);
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 3248
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s;
	cin >> s;
	int a = 0;
	REP(i, s.size()) {
		if (s[i] == 'R')a++;
		else a--;
	}
	if (a > 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
count_list = {}

for i in range(n):
    paper = input()
    if paper in count_list.keys():
        count_list[paper] += 1
    else:
        count_list[paper] = 1

max_count = max(count_list.values())
key = [k for k, v in count_list.items() if v == max_count]
key.sort()
for k in key:
    print(k)

Measured memory_bytes: 32096
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
#define LL long long

void _131() {
    int n;
    cin >> n;
    int tmp_a, tmp_b;
    vector<pair<int, int> > data;
    for (int i = 0; i < n; ++i) {
        cin >> tmp_a >> tmp_b;
        data.push_back(make_pair(tmp_b, tmp_a));
    }

    sort(data.begin(), data.end());

    LL sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += data[i].second;
        // cout << sum << " " << data[i].first << endl;
        if (sum > data[i].first) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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



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

int  main()
{
	int a ,b; cin >> a >> b;
	if (a <= b)
		cout << a << endl;
	else
		cout << a-1 << endl;
	return (0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

// 3 6
// 5 6

// 3 4


int main(){
  int N;
  ll K;
  int A[SIZE], F[SIZE];
  ll t[SIZE];

  scanf("%d%lld", &N, &K);

  for (int i=0; i<N; i++) scanf("%d", A+i);
  for (int i=0; i<N; i++) scanf("%d", F+i);

  sort(A, A+N);

  ll l = 0, r = 1e13;

  while(l < r) {
    ll mid = (l + r) / 2;

    ll sum = 0;
    for (int i=0; i<N; i++) {
      t[i] = mid / F[i];
    }
    sort(t, t+N);

    for (int i=0; i<N; i++)
      sum += max(0LL, A[i] - t[i]);

    if (sum <= K) {
      r = mid;
    } else {
      l = mid+1;
    }
  }

  cout << l << endl;

  return 0;
}


Measured memory_bytes: 3328
// Collecting Balls (Easy Version)

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	int x[N];
	for (int i = 0; i < N; ++i)
		cin >> x[i];

	sort(x, x+N);

	int res = 0;

	for (int i = 0; i < N; ++i){
		if (x[i] <= abs(x[i]-K))
			res += x[i] * 2;
		else
			res += abs(x[i]-K) * 2;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
srray = gets.split("").map(&:to_s)
answer = []
answer.push(srray.count("."))
i=0
m= answer[0]
while i<n
  if srray[i] == "."
    m -= 1
  else
    m += 1
  end
  answer.push(m)
  i+=1
end
puts answer.min

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

int main(void)
{
    int n,y;

    scanf("%d%d",&n, &y);

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            int k=n-i-j;
            if( k>=0 && 10000*i+5000*j+k*1000==y  )
                printf("%d %d %d\n",i,j,k),exit(0);
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


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

using namespace std;

const int md = 1000000007;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

inline int mul(int a, int b) {
  return (long long) a * b % md;
}

const int N = 7510;

int c[N][N];

int main() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (j == 0) c[i][j] = 1; else
      if (i == 0) c[i][j] = 0; else {
        c[i][j] = c[i - 1][j];
        add(c[i][j], c[i - 1][j - 1]);
      }
    }
  }
  int n, A, B, C;
  scanf("%d %d %d %d", &n, &A, &B, &C);
  if (B % 2 != 0) {
    printf("%d\n", 0);
    return 0;
  }
  int ans = 0;
  for (int y = 0; y <= A && y <= C; y++) {
    for (int z = 0; y + 3 * z <= C; z++) {
      int x = A - y;
      int rm = C - y - 3 * z;
      if (rm > 0 && B == 0) {
        continue;
      }
      int ways = mul(mul(c[x + y][y], c[x + y + z][z]), c[x + y + z + B / 2][B / 2]);
      if (rm > 0) {
        ways = mul(ways, c[rm + B / 2 - 1][rm]);
      }
      add(ans, ways);
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 220672
function f(ans,pm,pre,k,l,r)
	if k==pm
		ans+max(0,r-max(pre,l-1)),pm,max(pre,r)
	else
		ans+r-l+1,k,r
	end
end
function main()
	N,X,D=map(x->parse(Int,x),split(readline()))
	make(k)=(mod(k*X,D),fld(k*X,D)+div(k*(k-1),2),fld(k*X,D)+N*k-div(k*(k+1),2))
	if D==0
		println(X==0 ? 1 : N+1)
		exit()
	end
	if D<0
		D=-D
		X=-X
	end
	S=[make(k) for k=0:N]
	sort!(S)
	ans=0
	pm=-1
	pre=0
	for (k,l,r)=S
		ans,pm,pre=f(ans,pm,pre,k,l,r)
	end
	println(ans)
end
main()

Measured memory_bytes: 157320
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		
		int []alp = new int [26];
		
		for(int i = 0 ; i < h ;i++) {
			String s = sc.next();
			for(int j = 0 ; j < w ;j++) {
				int m = s.charAt(j) - 'a';
				alp[m]++;
			}
		}
		
		int m1 = 0;
		int m2 = 0;
		int m4 = h*w;
		
		if(h % 2 == 1 && w % 2 == 1) {
			m1 = 1;
			m2 = h + w - 2;
			m4 -= m2 + m1;
		}
		else if(h % 2 ==1) {
			m1 = 0;
			m2 = w;
			m4 -= m2 + m1;
		}
		else if(w % 2 == 1) {
			m1 = 0;
			m2 = h;
			m4 -= m1 + m2;
		}
		
		for(int i = 0 ; i < m1 ;i++) {
			for(int j = 0 ; j < 26 ;j++) {
				if(alp[j] % 2 == 1) {
					alp[j]--;
					break;
				}
			}
		}
		while(m2 > 0) {
			boolean jdg = false;
			for(int i = 0 ; i < 26 ;i++) {
				if(alp[i] % 4 == 2) {
					jdg = true;
					alp[i] -= 2;
					m2 -= 2;
					break;
				}
			}
			if(!jdg) break;
		}
		
		while(m4 > 0) {
			boolean jdg = false;
			for(int i = 0 ; i < 26 ;i++) {
				if(alp[i] % 4 == 0 && alp[i] != 0) {
					jdg = true;
					alp[i] -= 4;
					m4 -= 4;
					break;
				}
			}
			if(!jdg)break;
		}
		
		int cnt = 0;
		
		for(int i = 0 ; i < 26 ;i++) {
			if(alp[i] % 4 != 0) {
				System.out.println("No");
				return;
			}
			if(alp[i] % 4 == 0 && alp[i] != 0) {
				cnt += alp[i];
			}
		}
		System.out.println((cnt == m2)? "Yes" : "No");
	}
}

Measured memory_bytes: 24916
#include<stdio.h>

int selection(int A[],int N){
    int i,j,t,a=0,minj;
    for(i=0;i<N-1;i++){
        minj=i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]) minj=j;
        }
        t=A[i];A[i]=A[minj];A[minj]=t;
        if(i!=minj) a++;
    }
    return a;
}

int main(){
    int A[100],N,i,a;
    
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    
    a=selection(A,N);
    
    for(i=0;i<N;i++){
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",a);
    
    return 0;
}


Measured memory_bytes: 2616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

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

    static class Task {
    	public void solve(int testNumber, InputReader in, PrintWriter out) {
    		String S = in.next();
    		S = S.replaceAll("0", "");
    		System.out.println(S.length());
    	}
    }

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

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

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

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

    }
}



Measured memory_bytes: 21460
input = raw_input

N = int(input())

levels = [[0 for j in range(501)] for i in range(501)]

nums = [0 for i in range(501)]
nums[2] = 1
nums[3] = 2

graphs = [None for i in range(501)]
graph2 = [[None, None, None], [None, None, 1], [None, 1, None]]
graphs[2] = graph2
graph3 = [[None for i in range(3+1)] for j in range(3+1)]
graph3[1][2] = 2
graph3[1][3] = 1
graph3[2][1] = 2
graph3[2][3] = 1
graph3[3][1] = 1
graph3[3][2] = 1
graphs[3] = graph3

def get_graph(cur_graph, nodes):
    n_nodes = len(nodes)

    old_graph = graphs[n_nodes]
    #print(old_graph, cur_graph, n_nodes)
    new_nodes = nodes
    old_nodes = list(range(1, n_nodes+1))

    for i, new_node1 in enumerate(new_nodes):
        old_node1 = i + 1
        for j2, new_node2 in enumerate(new_nodes[i+1:]):
            j = i + j2 + 1
            #if i == j:
            #    continue
            old_node2 = j + 1
            #print(new_node1, new_node2, old_node1, old_node2)
            cur_graph[new_node1][new_node2] = old_graph[old_node1][old_node2] + 1

    return cur_graph

for n in range(4, N+1):
    n1 = n // 2 
    n2 = n1

    if n % 2 == 1:
        n1 += 1

    nodes1 = [i for i in range(1, n1+1)]
    nodes2 = [i for i in range(n1+1, n+1)]

    cur_graph = [[None for i in range(n+1)] for j in range(n+1)]
    for node1 in nodes1:
        for node2 in nodes2:
            cur_graph[node1][node2] = 1
            cur_graph[node2][node1] = 1

    nums[n] = 1 + max(nums[n1], nums[n2])

    min_level = 2
    cur_graph = get_graph(cur_graph, nodes1)
    cur_graph = get_graph(cur_graph, nodes2)

    graphs[n] = cur_graph


cur_graph = graphs[N]
for i in range(1, N+1):
    out_txt = " ".join([str(cur_graph[i][j]) for j in range(i+1, N+1)])
    print(out_txt)
#out = nums[N]


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define sz(x) (int)x.size()
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    int n,k,i,j,p;
    cin>>n>>k;
    int a[n];
    REP(i,0,n-1) cin>>a[i];
    ll dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    ll sum=0,temp;
    REP(i,1,n){
        RAP(p,k,k-a[i-1]) (sum+=dp[p])%=mod;
        p++;
        RAP(j,k,0){
            temp=dp[j];
            dp[j]=sum;
            if(p) {
                p--;
                (sum+=dp[p])%=mod;
            }
            sum-=temp;
            (sum=sum+mod)%=mod;
        } 
    }
    cout<<dp[k];
    return 0; 
}


Measured memory_bytes: 1024
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); 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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    ll n,x;cin>>n>>x;
    ll sum=0;
    ll ans=1;
    rep(i,n){
        ll d;cin>>d;
        sum+=d;
        if(sum<=x)ans++;
    }
    cout<<ans<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a>>b;
    if(a<b)
        cout <<"a < b"<<endl;
    else if(a>b)
        cout <<"a > b"<<endl;
    else
        cout <<"a == b"<<endl;

    return 0;
}



Measured memory_bytes: 3096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static bool[,] graph = new bool[8, 8];
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var mm = new long[N+1];
            for(var i=1;i<=N;i++)
            {
                for(var j=i;j<=N;j+=i)
                {
                    mm[j]++;
                }
            }
            long ans = 0;
            for(var i=1;i<=N;i++)
            {
                ans += mm[i] * i;
            }
            WriteLine(ans);
        }
    }
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
    if(a<=b&&b<=c){cout<<a<<" "<<b<<" "<<c<<endl;}
    else if(a<=c&&c<=b){cout<<a<<" "<<c<<" "<<b<<endl;}
    else if(b<=a&&a<=c){cout<<b<<" "<<a<<" "<<c<<endl;}
    else if(b<=c&&c<=a){cout<<b<<" "<<c<<" "<<a<<endl;}
    else if(c<=a&&a<=b){cout<<c<<" "<<a<<" "<<b<<endl;}
    else{cout<<c<<" "<<b<<" "<<a<<endl;}
    
    return 0;
	}


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

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

    char ch = 'a';
    string x = "";
    while (1) {
        if (ch == 'a') {
            if (a.size() == 0) {
                cout << 'A' << endl;
                return 0;
            }
            else {
                ch = a.at(0);
                x = a.substr(1, a.size() - 1);
                a = x;
            }
        }
        else if (ch == 'b') {
            if (b.size() == 0) {
                cout << 'B' << endl;
                return 0;
            }
            else {
                ch = b.at(0);
                x = b.substr(1, b.size() - 1);
                b = x;
            }
        }
        else if (ch == 'c') {
            if (c.size() == 0) {
                cout << 'C' << endl;
                return 0;
            }
            else {
                ch = c.at(0);
                x = c.substr(1, c.size() - 1);
                c = x;
            }
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>

int N, nsub[200005];

int main() {
    scanf("%d", &N);
    for (int i=1; i<N; ++i) {
        int cur;
        scanf("%d", &cur);
        ++nsub[cur];
    }
    for (int i=1; i<=N; ++i) {
        printf("%d\n", nsub[i]);
    }
}

Measured memory_bytes: 2508
t=int(input())
arr=list(map(int,input().strip().split()))[:t]
arr.sort()
ct=0
for i in range(0,t-2):
    for j in range(i+1,t-1):
        if(arr[i]==arr[j]):
            continue
        x=arr[i]+arr[j]
        for k in range(j+1,t):
            if(arr[k]==arr[j] or arr[k]==arr[i]):
                continue
            if(x>arr[k]):
                ct+=1
print(ct)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define int long long
#define fir first
#define sec second
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int a,b;
	cin>>a>>b;
	cout<<a*b/__gcd(a,b)<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n,c,k;
int data[100005];
int risan;

int main()
{
  scanf("%d %d %d",&n,&c,&k);
  REP(i,n) scanf("%d",&data[i]);
  SORTA(data,n);
  int now = 0;
  int dah = 0;
  REP(i,n)
  {
    if (dah == c || data[i] > now)
    {
      ++risan;
      dah = 1;
      now = data[i] + k;
    } else ++dah;
  }
  printf("%d\n",risan);
  return 0;
}










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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,m;
    cin >>n>>m;
    vector<int> p(m),y(m),ansy(m);
    vector<pii> city[100100];
    
    for(int i = 0; i < m; i++)
    {
        cin >> p.at(i)>>y.at(i);
        city[p.at(i)-1].push_back(pii(y.at(i),i));
    }
    
    for(int i = 0; i < n; i++)
    {
        sort(all(city[i]));
        
        for(int j = 0; j < city[i].size(); j++)
        {
            ansy.at(city[i].at(j).second) = j+1;
        }        
    }
    
    
    for(int i = 0; i < m; i++)
    {
        cout<<setfill('0')<<right<<setw(6)<<p.at(i);
        cout<<setfill('0')<<right<<setw(6)<<ansy.at(i)<<endl;
    }
    
 
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=1e6+1000;
const int SIZE2=2020;
const int SIZE3=410;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string S;
ut N,M,K,X,Y;
// ut A,B,C,D,E,F,G,H,I,J,L,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
 
////////////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////////////
 
LL solve(){
	string s;
	cin >> s;
	int able=0;
	int a=0,b=0;
	if(SI(s)%2==1) {
		a=b=SI(s)/2;
	}
	else{
		a=SI(s)/2-1;
		b=SI(s)/2;
	}
	int ans=SI(s)/2;
	char c=s[a];
	while(a>=0){
		if(s[a]!=s[b]) break;
		if(s[a]!=c) break;
		c=s[a];	
		a--;
		b++;
		ans++;
	}

	return ans;
}
signed main(){
	OUT(solve());
	return 0;
}

Measured memory_bytes: 24320
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]
C = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0

for i in range(N):
    ans += B[A[i] - 1]
    if i >= 1 and A[i - 1] + 1 == A[i]:
        ans += C[A[i - 1] - 1]

print(ans)


Measured memory_bytes: 38256
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
}point;

int kock(int n,point p1,point p2){

  point s,u,t;
  
  if (n == 0) return 0;

  s.x=(2.0*p1.x+1.0*p2.x)/3.0;
  s.y=(2.0*p1.y+1.0*p2.y)/3.0;
  t.x=(1.0*p1.x+2.0*p2.x)/3.0;
  t.y=(1.0*p1.y+2.0*p2.y)/3.0;
  u.x=(t.x-s.x)*cos(M_PI/3.0)-(t.y-s.y)*sin(M_PI/3.0)+s.x;
  u.y=(t.x-s.x)*sin(M_PI/3.0)+(t.y-s.y)*cos(M_PI/3.0)+s.y;

  kock(n-1, p1, s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1, t, p2);
}

int main(){

  int n;
  point p1={0,0},p2={100,0};

  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}



Measured memory_bytes: 2108
N = int(input()) # 青いカードの枚数
s = [input() for _ in range(N)] # 青いカードに書かれている文字列
M = int(input()) # 赤いカードの枚数
t = [input() for _ in range(M)]

count = [s.count(s[i]) - t.count(s[i]) for i in range(N)] # sにある要素で得点をリストに入れる(tのみにある文字列は答えになり得ない)
ans = max(0, max(count)) # countが全て負だったら0を返す

print(ans)


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

public class Main {

    public static void solve(InputReader in, PrintWriter out) throws Exception {


        int n = in.nextInt(),w = in.nextInt();

        int[] values = new int[n];
        long[] weights = new long[n];

        for(int i=0;i<n;i++)
        {
            weights[i]=in.nextInt();
            values[i]=in.nextInt();
        }

        long[][] dp = new long[n+1][100005];


        long ans =0;

        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<100005;j++)
            {
                if(i==0 || j==0) {

                    if(j==0)
                        dp[i][j]=0;
                    else
                    dp[i][j] = Long.MAX_VALUE;

                    continue;
                }

                if(j>=values[i-1] && dp[i-1][j-values[i-1]]!=Long.MAX_VALUE)
                dp[i][j] = Math.min(dp[i-1][j], weights[i-1]+ dp[i-1][j-values[i-1]]);

                else
                    dp[i][j]=dp[i-1][j];

                if(dp[i][j]<=w)
                    ans = Math.max(ans,j);
            }
        }

        out.println(ans);
    }

    /////////////////////////////////////////////////////////


    private final static long hash(long x, long y) {
        x += offset;
        y += offset;
        return x << 32 | y;
    }

    private final static int offset = (int) 3e5;

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

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

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

        private String nextToken() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

        public String nextLine() throws IOException {
            return reader.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(nextToken());
        }

    }
}

Measured memory_bytes: 137648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,a,b,c,l=0,m=0,n=0,count=0;
  cin >> N;
  string vec;	
  cin >> vec;
  
  for(int i=0;i<N;i++){
  	if(vec.at(i)=='R'){
    	l++;
    }else if(vec.at(i)=='G'){
    	m++;
    }else if(vec.at(i)=='B'){
    	n++;
    }
  }
  
  for(a=0;a<N;a++) {
  	  for(b=0;b<N;b++) {
        	c=b+b-a;
            if(c>=N){
            	break;
            }
            	if( (c<N &&b>a&&vec.at(a)!=vec.at(b)) && (vec.at(b)!=vec.at(c))&& (vec.at(c)!=vec.at(a)))	
              count++;
            
        
      }
  }
  count=l*m*n-count;
 cout << count << endl;
}

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

int main() {
  long long k,n;
  long long Min = 9999999999;
  long long tmp;
  
  cin >> n >> k;
  vector<long long> vec(n);
  
  for(int i = 0; i < n; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end(),greater<int>());
  
  for(int i = 0; i < n - k + 1; i++){
    tmp = vec.at(i) - vec.at(k + i - 1);
    Min = min(tmp,Min);
  }
  
  cout << Min;
  
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;


int main() {
	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8) {
		cout << "Yay!"<<endl;
	}
	else {
		cout << ":("<<  endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  vi a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << a[K-1] << endl;
  return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int X, A, B;
int main() {
    std::cin >> X >> A >> B;
    X -= A;
    X -= (X/B)*B;
    std::cout << X << std::endl;
}

Measured memory_bytes: 256
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;
const int _N = 5e5 + 100;

int n,m;
ll k;
string s;
int dp[_N][4];
int ans;

void smax(int &a, int b){
	a = max(a, b);
}

int main() {
	omajinai;
	cin >> n;
	cin >> s;
	s = s + "00";

	// 連続してる数
	int zero = 0;
	int one = 0;

	VI v;
	REP(i, (int)s.size()){
		bool isZero = 0;
		if(s[i]=='0')zero++, isZero=1;
		else one++, zero=0;
		if(isZero){
			if(one)v.PB(one);
			one=0;
		}
		if(zero>1){
			if(v.size()<2){
				v.clear();
				continue;
			}
			REP(i, (int)v.size()-1){
				REP(j, 4)dp[i][j] = 0;
				int left = v[i], right = v[i+1];
				bool leftIsGood = i-1>=0 && left>=2,
						rightIsGood = right>=2;

				// 右を使う。左は1以上

				// // 一個残す : 2
				if(rightIsGood){
					// // 前回使ったのは
					// // // なし : 0
					smax(dp[i][2], (i-1 >= 0 ? dp[i-1][0] : 0) + right - 1);
					if(leftIsGood){
						// // // 左 : 1
						smax(dp[i][2], dp[i-1][1] + right - 1);
						// // // 右残し : 2
						if(leftIsGood)
						smax(dp[i][2], dp[i-1][2] + right - 1);
					}
				}

				// // 残さない : 3
				// // 前回使ったのは
				// // // なし : 0
				smax(dp[i][3], (i-1 >= 0 ? dp[i-1][0] : 0) + right);
				if(leftIsGood){
					// // // 左 : 1
					smax(dp[i][3], dp[i-1][1] + right);
					// // // 右残し : 2
					if(leftIsGood)
					smax(dp[i][3], dp[i-1][2] + right);
				}

				// 左を使う  : 1
				// 前回使ったのは
				// // なし : 0
				smax(dp[i][1], (i-1 >= 0 ? dp[i-1][0] : 0) + left);
				if(leftIsGood){
					// // 左 : 1
					smax(dp[i][1], dp[i-1][1] + left - 1); // ※
					// // 右残し : 2
					smax(dp[i][1], dp[i-1][2] + 1); // ※
				}

				// ※ここ特殊で辛かった

				// 使わない : 0
				REP(j, 4)
					smax(dp[i][0], (i-1 >= 0 ? dp[i-1][j] : 0));
			}

			int val = 0;
			REP(i, 4)smax(val, dp[v.size() - 2][i]);
			ans += val;
			v.clear();
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 1308
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod=1e+9+7;

ll N;
string n;
vector<string>S;
void dfs(string s){
    if(s.size()<=n.size()){
        for(char c='3';c<='7';c+=2){
            S.push_back(s+c);
            dfs(s+c);
        }
    }
}
int main(){
  cin>>N;
  n=to_string(N);
  ll ans=0;
  dfs("");
  for (string v:S){
      ll num=0;
      bool c3=false,c5=false,c7=false;
      rep(i,v.size()){
          if(v[i]=='3')c3=true;
          if(v[i]=='5')c5=true;
          if(v[i]=='7')c7=true;
          num=num*10+v[i]-'0';
      }
      if(c3&&c5&&c7&&num<=N)ans++;
  }
  cout<<ans<<endl;
}





























































































Measured memory_bytes: 7448