akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;int n;
	int m; 
struct node{
	vector<int> p;
	vector<int> to;
	vector<int> th;
}each[100000+10];
int v[100000+10];
int v2[100000+10];
int v3[100000+10];
int main(){
	scanf("%d %d",&n,&m);
	rb(i,1,m){
		int u,v;
		scanf("%d %d",&u,&v);
		each[u].to.PB(v);
//		each[v].to.PB(u);
	}
	int s,t;
	scanf("%d %d",&s,&t);
	queue<mp> Q;
	Q.push(II(s,0));
	while(!Q.empty()){
		mp now=Q.front();
		Q.pop();
		if(v[now.FIR]) continue;
		v[now.FIR]=true;
		if(now.FIR==t){
			cout<<now.SEC;
			return 0;
		} 
		int SZ=each[now.FIR].to.size();
		if(!SZ) continue;
		rb(i,0,SZ-1){
			if(v3[each[now.FIR].to[i]]) continue;
			v3[each[now.FIR].to[i]]=1;
			int SZ2=each[each[now.FIR].to[i]].to.size();
			if(!SZ2) continue;
			rb(j,0,SZ2-1){
				if(v2[each[each[now.FIR].to[i]].to[j]]) continue;
				v2[each[each[now.FIR].to[i]].to[j]]=1;
				int SZ3=each[each[each[now.FIR].to[i]].to[j]].to.size();
				if(!SZ3) continue;
				rb(k,0,SZ3-1){
					if(v[each[each[each[now.FIR].to[i]].to[j]].to[k]]) continue;
					Q.push(II(each[each[each[now.FIR].to[i]].to[j]].to[k],now.SEC+1));
				}
			}

		} 
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n;
    int a[200009]{};
    bool b[1000009]{};

    cin >> n;

    rep(i, n) cin >> a[i];
    sort(a, a + n);

    int ans = 0;

    rep(i, n) {
        if(!b[a[i]]) {
            if(i == n - 1 || a[i] != a[i + 1]) ans++;
            for(int j = a[i]; j <= 1000000; j += a[i])
                b[j] = 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5416
x,n = map(int,input().split())
if n > 0:
    a = list(map(int,input().split()))
else:
    a = []
fl = [False] * 1000
for i in a:
    fl[i] = True

res = -1
mn = 10 ** 100
for i in range(-10000, 10000):
    if 0 <= i < 1000 and fl[i]:
        continue
    xx = abs(x - i)
    if xx < mn:
        mn = xx
        res = i
print(res)

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

using namespace std;

const int N = 5e5+7;
const int INF = 1e9;

string str;
int a[N];

int main()
{
    cin >> str;
    int n = str.length()+1;
    long long sum = 0;
    for (int i = 0, cnt = 0; i < n; ++i) {
        a[i] = max(a[i], cnt);
        if (i < (int)str.length() && str[i] == '<') {
            ++cnt;
        } else {
            cnt = 0;
        }
    }
    for (int i = str.length()-1, cnt = 0; i >= -1; --i) {
        a[i+1] = max(a[i+1], cnt);
        if (i >= 0 && str[i] == '>') {
            ++cnt;
        } else {
            cnt = 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2820
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

struct edge { int to, cost; };
int v, e;
vector<edge>G[10010];
int mincost[10010];
bool used[10010];
int main() {
	cin >> v >> e;
	REP(i, v) {
		used[i] = false;
	}
	for (int i = 0; i < e; ++i) {
		int s, t, w;
		cin >> s >> t >> w;
		s--, t--;
		G[s].push_back({ t,w });
		G[t].push_back({ s,w });
	}
	priority_queue<pii, vector<pii>, greater<pii>>que;
	que.push({ 0,0 });
	ll res = 0;
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second;
		if (used[v])continue;
		res += p.first;
		used[v] = true;
		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			que.push({ e.cost,e.to });
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 7932
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

std::string IntToString(long long a){
  char x[100];
  sprintf(x,"%lld",a);
  std::string s = x;
  return s;
}
long long StringToInt(std::string a){
  char x[100]; long long res;
  strcpy(x,a.c_str());
  sscanf(x,"%lld",&res);
  return res;
}
inline void printVal(long long a) {
  std::cout << "The Value is: "<< IntToString(a) << std::endl;
}
inline void printVal(std::string a) {
  std::cout << "The Value of is: "<< a << std::endl;
}
inline std::string GetString(){
  char x[1000005];
  scanf("%s",x);
  std::string s = x;
  return s;
}

inline int GetInt(){
  int x;
  scanf("%d",&x);
  return x;
}

long long getLongLong(){
  long long x;
  scanf("%lld",&x);
  return x;
}

inline std::string uppercase(std::string s){
  int n = (int)s.size();
  for(int i = 0; i < n; i++) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
inline std::string lowercase(std::string s){
  int n = (int)s.size();;
  for(int i = 0; i < n; i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
inline void OPEN (std::string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}
inline long long CharToInt(char c) {
    return (c - '0');
}

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

int main() {

  std::string a = GetString();
  std::string b = GetString();

  if(a == b) {
    std::cout << "EQUAL" << std::endl;
  } else if(a.length() > b.length()) {
    std::cout << "GREATER" << std::endl;
  } else if(a.length() < b.length()) {
    std::cout << "LESS" << std::endl;
  } else {
    for(int i = 0; i < a.length(); i++) {
      if(a[i] > b[i]) {
        std::cout << "GREATER" << std::endl;
        break;
      }else if(a[i] < b[i]) {
        std::cout << "LESS" << std::endl;
        break;
      }
    }
  }



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string w;
    cin >> w;
    
    map<char, int>counter;
    for (int i=0; i<w.size(); i++){
        counter[w[i]]++;
    }

    int condition = true;
    for (int i=0; i<w.size(); i++){
        if (counter[w[i]] % 2 == 1)condition = false;
    }
    if (condition)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3604
#!/usr/bin/ruby
# -*- coding: utf-8 --

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  string S;
  cin >> S;


  ll ans = 1;
  string tmp;
  tmp = S[0];

  FOR(i, 0, N-1){
    string val;
    val = S[i+1];
    if (val != tmp){
      tmp = val;
      ans++;
    }
  }


  cout << ans << endl;

  return 0;
}



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

int main(){
  vector<int> v(5);
  for(int i=0; i<5; i++) cin >>v[i];
  
  vector<int> num(5); for(int i=0; i<5; i++) num[i]=i;
  int ans=-1;
  do{
    int time=0;
    int next=0;
    for(int i=0; i<5; i++){
      time=next+v[num[i]];
      next=ceil((double)time/10)*10;
    }
    if(ans==-1) ans=time;
    else ans=min(ans, time);
  }while(next_permutation(num.begin(), num.end()));
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << (H2*60 + M2)-(H1*60 + M1) - K <<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;

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

  string A, B;
  cin >> A;
  cin >> B;
  int n = max(A.size(), B.size());
  string ans;
  if (A.size() > B.size()){
    cout << "GREATER" << endl;
    return 0;
  }else if (B.size() > A.size()){
    cout << "LESS" << endl;
    return 0;
  }else{
    for (int i = 0; i < n; i++){
      if (A[i] > B[i]){
        cout << "GREATER" << endl;
        return 0;
      }
      if (A[i] < B[i]){
        cout << "LESS" << endl;
        return 0;
      }
    }
  }
  cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
import sys

dic = {}

for i in sys.stdin:
    for j in i:
        if j.isalpha():
            c = j.lower()
            dic[c] = dic.get(c,0) + 1
            
for i in range(26):
    c = chr(ord("a")+i)
    print(c," : ",dic.get(c,0),sep ='')


Measured memory_bytes: 5572
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=10010;
int n,m,top,a[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i*i<=m;i++)
	{
		if(m%i)continue;
		a[++top]=i;
		if(i*i!=m)a[++top]=m/i;
	}
	sort(a+1,a+top+1);
	for(int i=top;i;i--)
		if(m/a[i]>=n){ printf("%d\n",a[i]);return 0;}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    ll N, K;
    cin >> N >> K;
    vector<pair<int, int>> vec(N);
    rep(i, N) {
        cin >> vec[i].first >> vec[i].second;
    }
    sort(ALL(vec));
    int idx = 0;
    int ans = 0;
    while (K > 0) {
        ans = vec[idx].first;
        K -= vec[idx].second;
        idx += 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int h, w, n;
    cin >> h >> w >> n;
    
    int a[10001];
    int i;
    for(i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    int s[100];
    int l = 0;
    int c = 0;
    i = 1;
    int j;
    while(c < w){
        s[c] = i;
        c++;
        if(c == w){
            if(l % 2 == 0){
                for(j = 0; j < w; j++){
                    cout << s[j];
                    if(j != w - 1){
                        cout << " ";
                    }
                }
            }else{
                for(j = w - 1; j >= 0; j--){
                    cout << s[j];
                    if(j != 0){
                        cout << " ";
                    }
                }
            }
            cout << endl;
            c = 0;
            l++;
            if(l == h){
                break;
            }
        }
        a[i]--;
        if(a[i] == 0){
            i++;
        }
    }
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define INF 0X3f3f3f3f
#define M 1000000007
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define mp make_pair
#define pb push_back 
#define fi first
#define se second
#define endl "\n"
#define PI acos(-1)
#define fastcin ios_base::sync_with_stdio(false);
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> ii;
typedef complex<double> base;

string s;

int main(void){
	cin >> s;

	s[0] = '2';
	s[1] = '0';
	s[2] = '1';
	s[3] = '8';

	cout << s << endl;

	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}
*/

#define	MOD 1000000007

int	main() {
	int N;
	string S;
	cin >>N >>S;
	int s=0;
	for (int i=0; i<N-2; i++)
		if(('A'==S.at(i))&&('B'==S.at(i+1))&&('C'==S.at(i+2)))
			s++;
	cout <<s <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int M[3];
vector<int>G[3][100001];
bool used[3][100001];
LL gra[3][100001];
LL ans[3][100001];

LL MOD=998244353;
LL MM(LL x){
	LL answer=1;
	LL now=10;
	while(x!=0){
		if(x%2==1){
			answer*=now;
			answer%=MOD;
		}
		now*=now;
		now%=MOD;
		x/=2;
	}
	return answer;
}

void calc(int x){
	for(int i=N-1;i>=0;i--){
		int now=0;
		vector<int>v;
		REP(j,G[x][i].size()){
			if(G[x][i][j]>i){
				v.push_back(gra[x][G[x][i][j]]);
			}
		}
		sort(v.begin(),v.end());
		REP(j,v.size()){
			if(v[j]==now)now++;
		}
		gra[x][i]=now;
		ans[x][now]+=MM(18*(i+1));
		ans[x][now]%=MOD;
	}
}



int main(){
	cin>>N;
	REP(i,3){
		cin>>M[i];
		REP(j,M[i]){
			int a,b;
			cin>>a>>b;
			a--;
			b--;
			G[i][a].push_back(b);
			G[i][b].push_back(a);
		}
	}
	REP(i,3){
		REP(j,N){
			used[i][j]=false;
		}
	}
	REP(i,3){
		calc(i);
	}
	/*REP(i,3){
		REP(j,N){
			cout<<ans[i][j]<<endl;
		}
		cout<<endl;
	}*/
	LL answer=0;
	REP(i,1001){
		REP(j,1001){
			int now=i^j;
			LL temp=ans[0][i];
			temp%=MOD;
			temp*=ans[1][j];
			temp%=MOD;
			temp*=ans[2][now];
			temp%=MOD;
			//LL temp=18*(ans[0][i]*ans[1][j]*ans[2][now]);
			/*if(temp!=0){
				cout<<i<<" "<<j<<" "<<now<<" "<<temp<<endl;
				cout<<ans[0][i]<<"ans "<<ans[1][j]<<" "<<ans[2][now]<<" "<<temp<<endl;
			}*/
			answer+=temp;
			answer%=MOD;
		}
	}
	cout<<answer<<endl;
}

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

int main()
{
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2 == 0)
        {
            cout << s[i];
        }
    }
    cout << endl;
}


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

int main(){
    int max = 1;
    int tmp,i,j,k,sum=0;
    int n;
    cin >> n;
    int p[11];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    for(i=0;i<n;i++){
        if(max < p[i]){
            max = p[i];
            tmp = i;
        }
    }
    for(j=0;j<tmp;j++){
        sum += p[j];
    }
    max /= 2;
    sum += max;
    for(k=tmp+1;k<n;k++){
        sum += p[k];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = input().split()

for i in range(N):
  H[i] = int(H[i])

Cnt = 0
MaxCnt = 0

if (N == 1):
  print(0)
else:
  i = 0
  while(i < N-1):
    Cnt = 0
    for j in range(i, N-1, 1):
      if (H[j] >= H[j+1]):
        Cnt += 1
        if (j == N-2):
          i = j+1
      else:
        i = j+1
        break
    MaxCnt = max(Cnt, MaxCnt)
  print(MaxCnt)

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

using namespace std;
using LL = long long;
const LL LINF = 1e18;
const LL MOD = 1e9+7;


int main(){
    int N;cin >> N;
    vector<vector<vector<vector<LL>>>> dp(4, vector<vector<vector<LL>>>(4, vector<vector<LL>>(4, vector<LL>(N+1))));
    int A = 0;
    int G = 1;
    int C = 2;
    int T = 3;
    dp[T][T][T][0] = 1;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                for(int l = 0;l < 4;l++){
                    for(int m = 0;m < 4;m++){
                        if(j == A && k == G && l == C)continue;
                        if(j == G && k == A && l == C)continue;
                        if(j == A && k == C && l == G)continue;
                        if(j == A && k == G && m == C)continue;
                        if(j == A && l == G && m == C)continue;
                        dp[j][k][l][i+1] += (dp[k][l][m][i])%MOD;
                    }
                }
            }
        }
    }
    LL ans = 0;
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                ans += dp[i][j][k][N];
                ans %= MOD;
            }
        }
    }
    cout<<ans%MOD<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define repi(i, a, b) for(int i=a; i>b; i--)
#define db(x) (cerr << #x << ": " << x << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define fi first
#define se second
#define umap unordered_map
#define umapi umap<int, int>
#define mapi map<int, int>
#define uset unordered_set
#define useti uset<int>
#define seti set<int, int>
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 200000
#define int ll
using namespace std;

template<typename T>
using maxpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using minpq = priority_queue<T>;

#define B 20
vi ans[20];

main()
{	
	sync;
	cerr << "I will return...\n";
	
	int n;
	cin >> n;
	
	int a[n];
	int oo = 0;
	for(int & i : a){
		cin >> i;
		
		rep(k, 0, B) {
			if ((i & (1 << k))){
				ans[k].pb(oo);
			}
		}
		oo++;
	}
	
	int anss = 0;
	
	rep(i, 0, B) {
		sort(all(ans[i]));
	}
//	db("hello");
	int mn = n;
	repi(i, n-1, -1){
		int j = n;
		
		rep(l, 0, B){
			if(!(a[i] & (1 << l))) {
				continue;
			}
			int k = (upper_bound(all(ans[l]), i)) - ans[l].begin();
			
			if(k < ans[l].size()) {
				j = min(j, ans[l][k]);
			}
		}
		mn = min(mn, j);
//		db(i), db(mn);
		anss += mn - i;
	}
	
	cout << anss << '\n';
	
	cerr << "...don't you ever hang your head.";
}








Measured memory_bytes: 18084
#include<stdio.h>
int main()
{
	int R;
	scanf("%d",&R);
	if(R<1200)
	{
		printf("ABC\n");
	}
	else if(R>=1200 && R < 2800)
	{
		printf("ARC\n");
	}
	else
	{
		printf("AGC\n");
	}
}

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

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

  int ans = 0, tmp = 1e9;

  for (int i = 0; i < N - 1; i++) {
    int b;
    cin >> b;
    ans += min(tmp, b);
    tmp = b;
  }

  cout << ans + tmp << "\n";
}

Measured memory_bytes: 256
import math
import numpy as np
A,B,H,M=map(int,input().split())

M_angle=M*6
h_=0
if M_angle>0: 
    h_=30/(360/M_angle)
H_angle=H*5*6+h_
x=abs(H_angle-M_angle)
y=abs(360-x)
Angle=min(x,y)
Cos=np.cos(np.deg2rad(Angle))

ans_=(A**2)+(B**2)-(2*A*B*Cos)
ans=ans_**0.5
print(ans)

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

import math


def Isprime(num):
    for j in range(2, int(math.sqrt(num)) + 1):
        if num % j == 0:
            return 0
    return 1


count = 0
n = int(input())
for i in range(n):
    num = int(input())
    count += Isprime(num)

print(count)



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

char c;
int main() {
    cin >> c;
    if (c == 'A')
        cout << 'T' << endl;
    else if (c == 'T')
        cout << 'A' << endl;
    else if (c == 'C')
        cout << 'G' << endl;
    else
        cout << 'C' << endl;
    return 0;
}


Measured memory_bytes: 3544
# ABC079C
S = input()
# +を挿入するか-を挿入するかで全部で2 ** 3通り
for i in range(2**3):
    now_sum = int(S[0])
    for j in range(3):
        if (i >> j) & 1:
            now_sum += int(S[j+1])
        else:
            now_sum -= int(S[j+1])
    if now_sum == 7:
        ans = i
        break
fugo = ""
for j in range(3):
    if (ans >> j) & 1:
        fugo += "+"
    else:
        fugo += "-"

print("{}{}{}{}{}{}{}=7".format(S[0], fugo[0], S[1], fugo[1], S[2], fugo[2], S[3]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int xdst = x2 - x1;
    int ydst = y2 - y1;
    cout << x2 - ydst << " " << y2 + xdst << " " << x1 - ydst << " " << y1 + xdst << endl;
    return 0;
}



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

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

#define MAX_N 100005

int parent[MAX_N];
int ran[MAX_N];

void init(int n) {
	int i;
	for(int i = 0; i < n; i++) {
		parent[i] = i;
		ran[i] = 0;
	}
}

int find(int x) {
	if (parent[x] == x)return x;
	else return parent[x] = find(parent[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (ran[x]<ran[y])
		parent[x] = y;
	else {
		parent[y] = x;
		if (ran[x] == ran[y])ran[x]++;
	}
}

struct edge { int u, v, cost; };

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

edge es[2 * MAX_N];
int v, e = 0;

int kruskal() {
	sort(es, es + e, comp);
	init(v);
	int res = 0, i;
	for(int i = 0; i < e; i++) {
		edge e = es[i];
		if (find(e.u) != find(e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main(void) {
	int n;
	cin >> n;
	v = n;

	vector<pair<pii, int> > p(n);
	for(int i = 0; i < n; i++) cin >> p[i].first.first >> p[i].first.second, p[i].second = i;

	sort(p.begin(), p.end());
	for(int i = 0; i < n - 1; i++) {
		es[e].u = p[i].second;
		es[e].v = p[i + 1].second;
		es[e].cost = min(abs(p[i].first.first - p[i + 1].first.first), abs(p[i].first.second - p[i + 1].first.second));
		e++;
	}
	for(int i = 0; i < n; i++) swap(p[i].first.first, p[i].first.second);
	sort(p.begin(), p.end());
	for(int i = 0; i < n - 1; i++) {
		es[e].u = p[i].second;
		es[e].v = p[i + 1].second;
		es[e].cost = min(abs(p[i].first.first - p[i + 1].first.first), abs(p[i].first.second - p[i + 1].first.second));
		e++;
	}

	cout << kruskal() << endl;
}

Measured memory_bytes: 4480
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_set>
#include <vector>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> table(h);
    for (auto& row : table)
    {
        cin >> row;
    }

    queue<tuple<int, int, int>> que;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (table[i][j] == '#')
            {
                que.emplace(0, i, j);
            }
        }
    }

    int ans = 0;
    array<int, 4> dy = { 0, 1, 0, -1 };
    array<int, 4> dx = { 1, 0, -1, 0 };

    while (!que.empty())
    {
        int cost, y, x;
        tie(cost, y, x) = que.front();
        que.pop();
        ans = max(ans, cost);

        for (int i = 0; i < 4; i++)
        {
            const int ny = y + dy[i];
            const int nx = x + dx[i];
            if (0 <= ny && ny < h && 0 <= nx && nx < w && table[ny][nx] == '.')
            {
                table[ny][nx] = '#';
                que.emplace(cost + 1, ny, nx);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13456
#include<stdio.h>
#include<string>
#include<iostream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    
    if(B==1){
        printf("0");
        return 0;
    }
    
    int cnt = 1;
    int des = A;

    while(des < B){
        des = des + A-1;
        cnt++;
    }

    printf("%d",cnt);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
int a[100005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n-1; i++) {
		if (a[i] == 0 && a[i] == a[i + 1]) {
			cout << "0" << endl;
			return 0;
		}
		if (i != n - 1 && a[i] == a[i + 1] && a[i + 1] == a[i + 2]) {
			cout << "0" << endl;
			return 0;
		}
	}
	ll sum = 1;
	for (int i = 0; i < n-1; i++) {
		if (a[i] == a[i + 1]) {
			sum = (sum * 2)%1000000007;
		}
	}
	cout << sum%1000000007<< endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    cout << (n-2)*180 << endl;

    return 0;
}


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

int main() {
  string N;
  cin >> N;
  int s = 0;
  for(int i=0; i<(int)N.size(); i++){
      s += N.at(i) - '0';
  }
  if(stoi(N) % s == 0){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
from heapq import heappop as pop
from heapq import heappush as push

def main():
  n, k = map(int, input().split())
  
  clst = []
  rlst = []
  
  for i in range(n):
    c, r = map(int, input().split())
    clst.append(c)
    rlst.append(r)
  
  edges = [[] * n for i in range(n)]
  
  for i in range(k):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)
  
  costs = [None] * n
  used = [False] * n
  
  def make_to_lst(s_num):
    loop = rlst[s_num]
    temp = set(edges[s_num])
    ret = set()
    while loop and temp:
      new = set()
      for p in temp:
        pto = set(edges[p])
        new = new | pto
      ret = ret | temp
      temp = new - ret
      loop -= 1
    return ret
  
  used[0] = True
  costs[0] = 0
  que = [(clst[0], 0)]
  
  while que:
    next_cost, s_num = pop(que)
    to_lst = make_to_lst(s_num)

    for num in to_lst:
      if num == n - 1:
        print(next_cost)
        return

      costs[num] = next_cost

      if not used[num]:
        push(que, (next_cost + clst[num], num))
        used[num] = True
  

main()


Measured memory_bytes: 7788
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int K = scanner.nextInt();

        List<String> strings = new ArrayList<>();

        for (int i = 0; i < s.length(); i++) {
            for (int j = 1; j < 6; j++) {
                if (i + j > s.length()) {
                    break;
                }

                String sub = s.substring(i, i + j);
                if (!strings.contains(sub)){
                    strings.add(sub);
                }
            }
        }

        // sort
        Collections.sort(strings);
        System.out.print(strings.get(K - 1));
    }
}


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

int main(void) {
  int a, b; cin >> a >> b;
  if (a != 1 && b != 1) cout << 1 << endl;
  else if (a != 2 && b != 2) cout << 2 << endl;
  else if (a != 3 && b != 3) cout << 3 << endl;
  
  return 0;
}

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

int main() {
  int n,m,yn=1;
  cin >> n >> m;
  vector<int> ans(n);
  vector<int> s(m);
  vector<int> c(m);

  for(int i=0;i<m;i++) {
    cin >> s.at(i) >> c.at(i);
    if((s.at(i)==1&&c.at(i)==0)&&n>1) yn=0;
    if(yn==1){
      if(ans.at(s.at(i)-1)==0||ans.at(s.at(i)-1)==c.at(i)) ans.at(s.at(i)-1)=c.at(i);
      else yn=0;
    };
  };

  if(yn==0) {
    cout << -1;
  } else {
    if(ans.at(0)==0&&!(n==1)) ans.at(0)=1;
    for(int i=0;i<n;i++){
      cout << ans.at(i);
    };
  };
  cout << endl;
}

Measured memory_bytes: 256
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
 
INF = 10**18
 
from heapq import heappush, heappop
 
l0, r0 = P[0]
 
L = [-l0+1]
R = [l0-1]
s = t = 0
 
res = 0
for i in range(N-1):
    l0, r0 = P[i]
    l1, r1 = P[i+1]
    s += (r1 - l1); t += (r0 - l0)
    if -s-L[0] <= l1-1 <= t+R[0]:
        heappush(L, -l1+1-s)
        heappush(R, l1-1-t)
    elif l1-1 < -s-L[0]:
        heappush(L, -l1+1-s)
        heappush(L, -l1+1-s)
        p = -heappop(L)-s
        heappush(R, p-t)
        res += (p - (l1-1))
    elif t+R[0] < l1-1:
        heappush(R, l1-1-t)
        heappush(R, l1-1-t)
        p = heappop(R) + t
        heappush(L, -p-s)
        res += (l1-1 - p)
print(res)

Measured memory_bytes: 36336
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<long long> count(n+1, 0);
    count[0] = 3;
    long long ans = 1;
    for (int i = 0; i < n; i++) {
        ans = ans * count[a[i]] % mod;
        count[a[i]]--; count[a[i]+1]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int k;
    cin >> k;
    for(int i = 0; i < k ;i++){
        if(!(b > g)){
            b = b * 2;
        }
        else if(!(g > r)){
            g = g * 2;
        }
    }
    if(b > g && g > r)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
template<typename T>
string ts(T v)
{
	string res="{";
	bool r=true;
	for(const auto &x:v)
	{
		if(!r)res+=",";
		r=false;
		res+=to_string(x);
	}
	res+="}";
	return res;
}
void solve()
{
	char ch;
	cin>>ch;
	if(isupper(ch))cout<<"A";
	else cout<<"a";
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
	solve();
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

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

    int x = 0;
    int ans = 0;
    for(auto itr = s.begin(); itr != s.end(); ++itr){
        if(*itr == 'I'){
            x++;
        }else{
            x--;
        }
        ans = max(x, ans);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
    	ll x;
    	cin>> x;
    	for(int i=-1000;i<=1000;i++)
		{
			for(int j=-1000;j<=1000;j++)
			{
				if(pow(i,5)-pow(j,5)==x)
				{
					cout<< i << " "<< j;
					return 0;
				}
			}
		}


    }
    return 0;
}


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

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

    vector<tuple<int,int,int>> V;
    rep(i,n) {
        int l, r, x;
        cin >> l >> r >> x;
        V.push_back(forward_as_tuple(x, l-x, r-x));
    }
    sort(V.begin(), V.end());

    set<pair<int,int>> S;
    rep(i,q) {
        int d;
        cin >> d;
        S.insert(make_pair(d,i));
    }

    int ans[q];
    rep(i,q) ans[i] = -1;

    for (auto v : V) {
        int x, l, r;
        tie(x, l, r) = v;
        auto it = S.lower_bound(make_pair(l,0));
        while ( it != S.end()) {
            int d = it->first;
            int idx = it->second;
            if (d >= r) break;
            ans[idx] = x;
            S.erase(it++);
        }
    }

    rep(i,q) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 14576
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 1000100
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,cnt[3],id[3]={0,1,2},pos[3],g[3];
char s[N];
void Del_C(){
	int tmp=0;
	char t[N];
	for(int i=1,j=1;i<=n;i=j+1){
		int d[2]={0,0};
		j=i;
		while(j<n&&s[j+1]!='A')++j;
		if(s[i]=='A')t[++tmp]=s[i++];
		for(int k=i;k<=j;++k){
			++d[s[k]-'B'];
		}
		if(i<j&&d[1]==d[0]+1&&cnt[2]>cnt[1]+1){
			for(int k=i+1;k<j;++k){
				t[++tmp]=s[k];
			}
			cnt[2]-=2;
		}
		else if(i<j&&d[1]>=d[0]&&cnt[2]>cnt[1]){
			if(s[i]=='C'){
				for(int k=i+1;k<=j;++k){
					t[++tmp]=s[k];
				}
			}
			else{
				for(int k=i;k<j;++k){
					t[++tmp]=s[k];
				}
			}
			--cnt[2];
		}
		else{
			for(int k=i;k<=j;++k){
				t[++tmp]=s[k];
			}
		}
	}
	if(cnt[2]>cnt[1]&&t[tmp]=='C'){
		--tmp,--cnt[2];
	}
	if(cnt[2]>cnt[1]&&t[1]=='C'){
		--cnt[2];
		for(int i=1;i<tmp;++i)t[i]=t[i+1];
		--tmp;
	}
	n=tmp;
	swap(s,t);
	if(cnt[2]==cnt[1])return;
	memset(t,0,sizeof(t));
	tmp=0;
	for(int i=1;i<=n;++i){
		if(i==1&&cnt[2]>cnt[1]&&s[1]=='C'){
			--cnt[2];
		}
		else if(i<n&&cnt[2]>cnt[1]&&s[i]=='A'&&s[i+1]=='C'){
			++i;
			--cnt[2],--cnt[0];
		}
		else{
			t[++tmp]=s[i];
		}
	} 
	if(cnt[2]>cnt[1]&&s[n]=='C'){
		--tmp;
	}
	n=tmp;
	swap(s,t);
}
void Del_BC(){
	int tmp=0;
	char t[N];
	for(int i=1;i<=n;++i){
		if(cnt[1]>cnt[0]&&i<n&&s[i-1]!='A'&&s[i]!='A'&&s[i+1]!='A'){
			++i;
			--cnt[1],--cnt[2];
		}
		else{
			t[++tmp]=s[i];
		}
	}
	n=tmp;
	swap(s,t);
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int tmp=0;
	for(int i=1;i<=n;++i){
		if(s[i]^s[i-1])s[++tmp]=s[i];
	}
	n=tmp;
	for(int i=1;i<=n;++i){
		++g[s[i]-'A'];
	}
	sort(id,id+3,[&](int i,int j){return g[i]<g[j];});
	for(int i=0;i<3;++i)pos[id[i]]=i,cnt[i]=g[i];
	sort(cnt,cnt+3);
	for(int i=1;i<=n;++i){
		s[i]=pos[s[i]-'A']+'A';
	}
	Del_C();
	Del_BC();
	for(int i=1;i<=n;++i){
		putchar(id[s[i]-'A']+'A');
	}
	putchar('\n');
	return 0;
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main() {
  int n, a[101];
  cin >> n;
  rep(i, 0, n) cin >> a[i];
  sort(a, a + n);

  int b = 0, c = 0, f = 0;
  dep(i, n - 1, 0) {
    if(!f) b += a[i];
    else c += a[i];
    f = !f;
  }
  cout << b - c << endl;
}


Measured memory_bytes: 256
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	int n;
	cin>>n;
	ll ans = 0;
	ll largest = 0;
	for (int i = 0;i < n;++i) {
		ll x;
		cin>>x;
		if (largest < x) {
			largest = x;
		}
		else {
			ans += largest - x;
		}
	}

	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3588
x_1,x_2,x_3,x_4,x_5=input().split()
x_1=int(x_1)  
x_2=int(x_2)   
x_3=int(x_3)   
x_4=int(x_4)   
x_5=int(x_5)
i=1
if x_1==0:
    print(1)
if x_2==0:
    print(2)
if x_3==0:
    print(3)
if x_4==0:
    print(4)
if x_5==0:
    print(5)

Measured memory_bytes: 9076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n;cin>>n;
    int am=0,a,b,ans;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a>am){
            am=a;
            ans=b;
        }
    }
    cout<<ans+am<<endl;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main () {
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  if (S[K-1]=='A') S[K-1] = 'a';
  if (S[K-1]=='B') S[K-1] = 'b';
  if (S[K-1]=='C') S[K-1] = 'c';
  cout<<S<<endl;
  return 0;
}


Measured memory_bytes: 256
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

use std::cmp::*;

fn main() {
    let s: String = read();
    let svec: Vec<char> = s.chars().collect();

    let mut zero_count = 0_u64;
    let mut one_count = 0_u64;

    for i in 0..svec.len()
    {
        if svec[i] == '0' { zero_count += 1; } else { one_count += 1; }
    }

    let result = min(zero_count, one_count) * 2;
    println!("{}", result);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define N 1000000
using namespace std;

bool prime[N + 5] = {0};

void sprime() {
  prime[0] = 1;
  prime[1] = 1;
  for(int i = 2; i * i <= N; ++i)
    if(!prime[i])
      for(int j = 2; i * j <= N; ++j) prime[i * j] = 1;
}

int q;
vector<int> v;

void solve();

int main() {
  sprime();
  solve();
  cin >> q;
  for(int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    cout << v[r] - v[l - 1] << endl;
  }
  return 0;
}

void solve() {
  v.assign(N, 0);
  for(int i = 1; i < N; ++i) {
    v[i] += v[i - 1];
    if(i % 2 && !prime[i] && !prime[(i + 1) / 2]) ++v[i];
  }
}

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

int main(){
  int n, k; cin >> n >> k;
  double ans = 0;
  for (int x = 1; x <= n; x++){
    double prob = (double) 1/n;
    int s = x;
    while (s < k){
      prob *= 0.5;
      s *= 2;
    }
    ans += prob;
  }
  printf("%.12lf\n", ans);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int N = sc.nextInt();

        System.out.println(solve(N));

        sc.close();
    }

    static String solve(int N) {
        int[] result = new int[N];
        int x = 6;
        for (int i = 0; i < result.length; ++i) {
            while (!isPrime(x)) {
                x += 5;
            }

            result[i] = x;
            x += 5;
        }

        return Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining(" "));
    }

    static boolean isPrime(int x) {
        for (int i = 2; i * i <= x; ++i) {
            if (x % i == 0) {
                return false;
            }
        }

        return true;
    }
}

Measured memory_bytes: 30164
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
    ll n,i,j,p,r,l,sum=0,k;
    vector<vector<int> >v(10,vector<int>(10));
    cin>>n;
    for(i=1;i<=n;i++){
    p=i;
    r=p%10;
    while(p!=0)
    {
        l=p%10;
        p=p/10;
    }
    k=l;
    v[k][r]++;
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)
            sum+=v[i][j]*v[j][i];
    }
    cout<<sum;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
  int T;
  cin>>T;
  ll A,B,C,D;
  rep(i,T){
    cin>>A>>B>>C>>D;
    ll ans=1;
    if(A<B||B>D) ans=0;
    else if(B>C){
      ll E=B,r=D%B;
      while(r){
        D=E;
        E=r;
        r=D%E;
      }
      if(max((B-1)/E*E,(B-(A%B)-1)/E*E+A%B)>C) ans=0;
    }
    cout<<(ans?"Yes":"No")<<endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)

n = input()
k = int(input())
m = {}


def doit(n, k):
    if len(n) == 0:
        return k == 0
    d = int(n[0])
    if (n, k) not in m:
        ret = 0
        for i in range(d + 1):
            if i == d:
                ret += doit(n[1:], k - 1 if i > 0 else k)
            else:
                ret += doit('9' * (len(n) - 1), k - 1 if i > 0 else k)
        m[(n, k)] = ret
    return m[(n, k)]


print(doit(n, k))


Measured memory_bytes: 10092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	ans += min(a, k);
	k = max(k-a, 0LL);
	k = max(k-b, 0LL);
	ans -= min(c, k);
	cout << ans << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++) {
        string w;
        cin >> w;
        s.insert(w);
    }
    cout << s.size();
}


Measured memory_bytes: 19128
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int map[100],n;
int abs(int x,int y){
	if(x>y)
		return x-y;
	return y-x;
}
int main(){
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&map[i]);
	int ans=99999999,j;
	sort(map,map+n);
	for(i=0;i<n;i++){
		int sum=0;
		sum+=abs(map[i],map[0]);
		sum+=abs(map[i],map[n-1]); 
		ans=sum>ans?ans:sum; 
	}
	printf("%d\n",ans);
	return 0;
}


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

string S;

int main(void){
    cin >> S;
    ll ans=0;
    rep(i,S.size()/2)if(S[i] != S[S.size()-1-i])ans++;
    cout << ans << endl;
}


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

int main(){
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	int p = 0;
	while(true){
		if(s[p].empty()){
			cout << (p == 0 ? 'A' : p == 1 ? 'B' : 'C') << endl;
			return 0;
		}
		char c = s[p][0];
		s[p].erase(s[p].begin());
		p = (c != 'a') + (c != 'a' && c != 'b');
	}
}

Measured memory_bytes: 256